From 64d0bf4ec2d837fd97410d566a25cdbfaaf55078 Mon Sep 17 00:00:00 2001 From: Haydn Ewers <27211+haydn@users.noreply.github.com> Date: Thu, 28 Aug 2025 17:10:25 +1000 Subject: [PATCH] add description to form fields closes #10 --- src/app/ListForm.tsx | 207 +++++++++++++++++++++++++++---------------- 1 file changed, 131 insertions(+), 76 deletions(-) diff --git a/src/app/ListForm.tsx b/src/app/ListForm.tsx index 44236aa..dd009ca 100644 --- a/src/app/ListForm.tsx +++ b/src/app/ListForm.tsx @@ -1,4 +1,7 @@ +"use client"; + import { Action } from "@colonydb/anthill/Action"; +import { Block } from "@colonydb/anthill/Block"; import { Button } from "@colonydb/anthill/Button"; import { Card } from "@colonydb/anthill/Card"; import { CardContent } from "@colonydb/anthill/CardContent"; @@ -13,7 +16,9 @@ import { RegularField } from "@colonydb/anthill/RegularField"; import { Section } from "@colonydb/anthill/Section"; import { Specimen } from "@colonydb/anthill/Specimen"; import { StringInput } from "@colonydb/anthill/StringInput"; +import { TabSet } from "@colonydb/anthill/TabSet"; import { useForm } from "@colonydb/anthill/useForm"; +import { useState } from "react"; import * as v from "valibot"; import type { ListConfig } from "."; import List from "./List"; @@ -38,83 +43,133 @@ const schema = v.object({ url: v.pipe(v.string(), v.nonEmpty(), v.url()), }); -const ListForm = ({ id, list: initialList, onCancel, onSubmit, onSuccess, title }: Props) => ( -
{ - onSubmit(data); - return { - data, - ok: true, - }; - }} - onSuccess={onSuccess} - id={id} - initialData={initialList} - schema={schema} - > - } - title="close" - onClick={() => { - onCancel(); - }} - /> - } - > - {title} - - } - footer={ - { - onCancel(); - }} - > - Cancel - - } - /> - } +const ListForm = ({ id, list: initialList, onCancel, onSubmit, onSuccess, title }: Props) => { + const [tab, setTab] = useState<"basics" | "filters">("basics"); + return ( + { + onSubmit(data); + return { + data, + ok: true, + }; + }} + onSuccess={onSuccess} + id={id} + initialData={initialList} + schema={schema} > - - -
Configuration}> - - - - - - - - - - - - - - - - - - - - - -
- -
-
-
-
-); + } + title="close" + onClick={() => { + onCancel(); + }} + /> + } + > + {title} + + } + footer={ + { + onCancel(); + }} + > + Cancel + + } + /> + } + > + + +
Configuration}> + { + setTab("basics"); + }, + selected: tab === "basics", + }, + { + key: "filters", + label: "Filters", + onClick: () => { + setTab("filters"); + }, + selected: tab === "filters", + }, + ]} + /> + {tab === "basics" ? ( + <> + + + + + + + + + CSS selector identifying the items on the page to be listed. + + + + + + CSS selector applied to each item to identify its title. If not provided, the + text of the entire item will be used. + + + + + + CSS selector applied to each item to identify its link. If not provided, the + items itself will be used. + + + + + ) : null} + {tab === "filters" ? ( + <> + + + A comma-separated list of phrases to filter the items by. If an item does not + contain any of the phrases, it will be excluded from the list. + + + + + + A comma-separated list of phrases to filter the items by. If an item contains + any of the phrases, it will be excluded from the list. + + + + + ) : null} +
+ +
+
+
+ + ); +}; const Preview = () => { const { data } = useForm(schema); -- 2.51.2