@uibot/registry 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -9
- package/dist/shadcn/r/admin-dashboard.json +70 -0
- package/dist/shadcn/r/admin-shell.json +148 -0
- package/dist/shadcn/r/ai-chat.json +74 -0
- package/dist/shadcn/r/analytics-dashboard.json +65 -0
- package/dist/shadcn/r/app-shell-floating.json +54 -0
- package/dist/shadcn/r/app-shell-icon-rail.json +54 -0
- package/dist/shadcn/r/app-shell-inset.json +54 -0
- package/dist/shadcn/r/app-shell-settings.json +54 -0
- package/dist/shadcn/r/app-shell-sidebar.json +54 -0
- package/dist/shadcn/r/app-shell-workspace.json +54 -0
- package/dist/shadcn/r/auth.json +61 -0
- package/dist/shadcn/r/blog.json +64 -0
- package/dist/shadcn/r/charts.json +211 -0
- package/dist/shadcn/r/content.json +444 -0
- package/dist/shadcn/r/creation-html-generation.json +29 -0
- package/dist/shadcn/r/creation-reference-generation.json +29 -0
- package/dist/shadcn/r/creation-revision-export.json +27 -0
- package/dist/shadcn/r/creation-shared.json +24 -0
- package/dist/shadcn/r/creation-workspace.json +33 -0
- package/dist/shadcn/r/crm.json +67 -0
- package/dist/shadcn/r/dashboard.json +147 -0
- package/dist/shadcn/r/data-studio.json +368 -0
- package/dist/shadcn/r/data-table.json +224 -0
- package/dist/shadcn/r/data.json +320 -0
- package/dist/shadcn/r/ecommerce.json +65 -0
- package/dist/shadcn/r/feedback.json +300 -0
- package/dist/shadcn/r/field.json +164 -0
- package/dist/shadcn/r/form.json +425 -0
- package/dist/shadcn/r/grid.json +188 -0
- package/dist/shadcn/r/interactive.json +355 -0
- package/dist/shadcn/r/kanban.json +154 -0
- package/dist/shadcn/r/layout.json +529 -0
- package/dist/shadcn/r/lms.json +74 -0
- package/dist/shadcn/r/marketing.json +402 -0
- package/dist/shadcn/r/nav.json +257 -0
- package/dist/shadcn/r/portfolio.json +62 -0
- package/dist/shadcn/r/presentation.json +454 -0
- package/dist/shadcn/r/pricing.json +63 -0
- package/dist/shadcn/r/primitives.json +360 -0
- package/dist/shadcn/r/saas-landing.json +60 -0
- package/dist/shadcn/r/sections.json +734 -0
- package/dist/shadcn/r/settings.json +72 -0
- package/dist/shadcn/r/shadcn-admin-shell.json +49 -0
- package/dist/shadcn/r/shadcn-admin.json +76 -0
- package/dist/shadcn/r/store.json +75 -0
- package/dist/shadcn/r/support-inbox.json +63 -0
- package/dist/shadcn/r/team-directory.json +59 -0
- package/dist/shadcn/r/uibot-base.json +30 -0
- package/dist/shadcn/r/uibot-theme.json +86 -0
- package/dist/shadcn/r/workspace.json +174 -0
- package/dist/shadcn/registry.json +615 -0
- package/dist/shadcn.d.ts +10 -5
- package/package.json +2 -2
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "form",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "Form wrapper that prevents default submission. Place Form.Input, Form.Select, etc. as children and end with Form.Submit.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"react",
|
|
8
|
+
"radix-ui",
|
|
9
|
+
"react-day-picker"
|
|
10
|
+
],
|
|
11
|
+
"registryDependencies": [
|
|
12
|
+
"@uibot/uibot-base"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"path": "components/uibot/form.tsx",
|
|
17
|
+
"target": "components/uibot/form.tsx",
|
|
18
|
+
"content": "import { FormDateControl, FormSelectControl } from \"./form-controls\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { submissionKey } from \"./interaction\";\nimport type { RendererComponent } from \"@/lib/uibot-renderer\";\n\nconst fieldBase =\n \"flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground shadow-sm placeholder:text-muted-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50\";\n\nconst labelBase = \"text-sm font-medium text-foreground\";\n\ntype RendererContext = Parameters<RendererComponent>[1];\ntype ActionChain = Parameters<NonNullable<RendererContext[\"dispatch\"]>>[0];\n\ninterface InteractiveElement {\n props?: Record<string, unknown>;\n events?: Record<string, ActionChain>;\n}\n\nfunction asInteractiveElement(element: unknown): InteractiveElement {\n return element as InteractiveElement;\n}\n\nfunction eventChain(element: unknown, name: string): ActionChain {\n return asInteractiveElement(element).events?.[name] ?? [];\n}\n\nfunction bindStatePath(element: unknown, propName: string): string | undefined {\n const value = asInteractiveElement(element).props?.[propName];\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return undefined;\n const candidate = (value as Record<string, unknown>)[\"_bindState\"];\n return typeof candidate === \"string\" ? candidate : undefined;\n}\n\nfunction changeEvent(\n target: { name?: string; value?: string; checked?: boolean },\n value: string | boolean,\n): Record<string, unknown> {\n return {\n type: \"change\",\n ...(target.name ? { name: target.name } : {}),\n value,\n ...(typeof target.checked === \"boolean\" ? { checked: target.checked } : {}),\n };\n}\n\nfunction dispatchChange(\n ctx: RendererContext,\n propName: string,\n value: string | boolean,\n target: { name?: string; value?: string; checked?: boolean },\n): void {\n const path = bindStatePath(ctx.element, propName);\n const explicit = eventChain(ctx.element, \"onChange\");\n const chain: ActionChain = [\n ...(path ? [{ action: \"SetState\", params: { path, value } }] : []),\n ...explicit,\n ];\n if (chain.length > 0) void ctx.dispatch?.(chain, { event: changeEvent(target, value) });\n}\n\ntype FormValue = string | boolean | Array<string | boolean>;\n\nfunction collectFormValues(form: HTMLFormElement): Record<string, FormValue> {\n const entries = new Map<string, FormValue>();\n for (const rawControl of Array.from(form.elements)) {\n const control = rawControl as unknown as {\n name?: string;\n type?: string;\n value?: string;\n checked?: boolean;\n disabled?: boolean;\n multiple?: boolean;\n selectedOptions?: ArrayLike<{ value: string }>;\n };\n if (!control.name || control.disabled) continue;\n\n let value: FormValue;\n if (control.type === \"checkbox\") {\n value = control.checked === true;\n } else if (control.type === \"radio\") {\n if (!control.checked) continue;\n value = control.value ?? \"\";\n } else if (control.multiple && control.selectedOptions) {\n value = Array.from(control.selectedOptions).map((option) => option.value);\n } else {\n value = control.value ?? \"\";\n }\n\n const element = rawControl as HTMLElement;\n if (element.getAttribute?.(\"data-uibot-array-empty\") === \"true\") value = [];\n else if (element.getAttribute?.(\"data-uibot-array\") === \"true\" && !Array.isArray(value))\n value = [value];\n const previous = entries.get(control.name);\n if (previous === undefined) {\n entries.set(control.name, value);\n } else {\n const priorValues = Array.isArray(previous) ? previous : [previous];\n const nextValues = Array.isArray(value) ? value : [value];\n entries.set(control.name, [...priorValues, ...nextValues]);\n }\n }\n return Object.fromEntries(entries);\n}\n\n/** Form container */\nexport const Form: RendererComponent = (props, ctx) => {\n const onSubmit = eventChain(ctx.element, \"onSubmit\");\n const onChange = eventChain(ctx.element, \"onChange\");\n return (\n <form\n className={cn(\"uibot-form\", props[\"layout\"] === \"horizontal\" ? \"space-y-3\" : \"space-y-4\")}\n data-uibot-type=\"Form\"\n aria-busy={props.pending === true}\n aria-label={typeof props[\"label\"] === \"string\" ? props[\"label\"] : undefined}\n onChange={(event) => {\n const target = event.target as unknown as HTMLInputElement;\n if (props.pending !== true && onChange.length > 0)\n void ctx.dispatch?.(onChange, {\n event: changeEvent(target, target.type === \"checkbox\" ? target.checked : target.value),\n });\n }}\n onSubmit={(event) => {\n event.preventDefault();\n if (props.pending !== true && onSubmit.length > 0) {\n const values = collectFormValues(event.currentTarget);\n void ctx.dispatch?.(onSubmit, {\n event: {\n type: \"submit\",\n values,\n ...(props.idempotent === true\n ? { value: submissionKey(event.currentTarget, values) }\n : {}),\n },\n });\n }\n }}\n >\n {props.pending === undefined ? (\n (ctx.children as ReactNode[])\n ) : (\n <fieldset disabled={props.pending === true} className=\"space-y-4\">\n {ctx.children as ReactNode[]}\n </fieldset>\n )}\n </form>\n );\n};\n\n/** Text input field */\nexport const FormInput: RendererComponent = (props, ctx) => {\n const name = String(props[\"name\"] ?? \"\");\n const helpText = typeof props[\"helpText\"] === \"string\" ? props[\"helpText\"] : null;\n const error = typeof props[\"error\"] === \"string\" ? props[\"error\"] : null;\n const binding = bindStatePath(ctx.element, \"value\");\n\n return (\n <div className=\"uibot-form-field flex flex-col gap-1.5\" data-uibot-type=\"Form.Input\">\n {typeof props[\"label\"] === \"string\" && (\n <label className={labelBase} htmlFor={name}>\n {props[\"label\"]}\n {props[\"required\"] === true && (\n <span className=\"ml-1 text-destructive\" aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n {props[\"type\"] === \"date\" ? (\n <FormDateControl\n id={name}\n name={name}\n {...(typeof props[\"placeholder\"] === \"string\"\n ? { placeholder: props[\"placeholder\"] }\n : {})}\n {...(binding\n ? { value: String(props[\"value\"] ?? \"\") }\n : typeof props[\"defaultValue\"] === \"string\"\n ? { defaultValue: props[\"defaultValue\"] }\n : {})}\n required={props[\"required\"] === true}\n disabled={props[\"disabled\"] === true}\n readOnly={props[\"readOnly\"] === true}\n invalid={Boolean(error)}\n {...(helpText || error ? { describedBy: `${name}-desc` } : {})}\n onValueChange={\n binding || eventChain(ctx.element, \"onChange\").length > 0\n ? (value) => dispatchChange(ctx, \"value\", value, { name, value })\n : undefined\n }\n />\n ) : (\n <input\n id={name}\n name={name}\n type={typeof props[\"type\"] === \"string\" ? props[\"type\"] : \"text\"}\n placeholder={typeof props[\"placeholder\"] === \"string\" ? props[\"placeholder\"] : undefined}\n {...(binding\n ? { value: String(props[\"value\"] ?? \"\") }\n : {\n defaultValue:\n typeof props[\"defaultValue\"] === \"string\" ? props[\"defaultValue\"] : undefined,\n })}\n onChange={\n binding || eventChain(ctx.element, \"onChange\").length > 0\n ? (event) =>\n dispatchChange(ctx, \"value\", event.currentTarget.value, event.currentTarget)\n : undefined\n }\n required={props[\"required\"] === true}\n disabled={props[\"disabled\"] === true}\n readOnly={props[\"readOnly\"] === true}\n aria-invalid={error ? true : undefined}\n aria-describedby={helpText || error ? `${name}-desc` : undefined}\n className={cn(\n fieldBase,\n error ? \"border-destructive focus-visible:ring-destructive/50\" : \"\",\n )}\n />\n )}\n {(helpText || error) && (\n <p\n id={`${name}-desc`}\n className={cn(\"text-xs\", error ? \"text-destructive\" : \"text-muted-foreground\")}\n >\n {error ?? helpText}\n </p>\n )}\n </div>\n );\n};\n\n/** Dropdown select field */\nexport const FormSelect: RendererComponent = (props, ctx) => {\n const options = Array.isArray(props[\"options\"])\n ? (props[\"options\"] as Array<{ value: string; label: string }>)\n : [];\n const name = String(props[\"name\"] ?? \"\");\n const placeholder =\n typeof props[\"placeholder\"] === \"string\" ? props[\"placeholder\"] : \"Select an option\";\n const binding = bindStatePath(ctx.element, \"value\");\n\n return (\n <div className=\"uibot-form-field flex flex-col gap-1.5\" data-uibot-type=\"Form.Select\">\n {typeof props[\"label\"] === \"string\" && (\n <label className={labelBase} htmlFor={name}>\n {props[\"label\"]}\n {props[\"required\"] === true && (\n <span className=\"ml-1 text-destructive\" aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n <FormSelectControl\n id={name}\n name={name}\n options={options}\n placeholder={placeholder}\n {...(binding\n ? { value: String(props[\"value\"] ?? \"\") }\n : typeof props[\"defaultValue\"] === \"string\"\n ? { defaultValue: props[\"defaultValue\"] }\n : {})}\n required={props[\"required\"] === true}\n disabled={props[\"disabled\"] === true}\n onValueChange={\n binding || eventChain(ctx.element, \"onChange\").length > 0\n ? (value) => dispatchChange(ctx, \"value\", value, { name, value })\n : undefined\n }\n />\n </div>\n );\n};\n\n/** Multi-line textarea field */\nexport const FormTextArea: RendererComponent = (props, ctx) => {\n const name = String(props[\"name\"] ?? \"\");\n const helpText = typeof props[\"helpText\"] === \"string\" ? props[\"helpText\"] : null;\n const binding = bindStatePath(ctx.element, \"value\");\n\n return (\n <div className=\"uibot-form-field flex flex-col gap-1.5\" data-uibot-type=\"Form.TextArea\">\n {typeof props[\"label\"] === \"string\" && (\n <label className={labelBase} htmlFor={name}>\n {props[\"label\"]}\n {props[\"required\"] === true && (\n <span className=\"ml-1 text-destructive\" aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n <textarea\n id={name}\n name={name}\n required={props[\"required\"] === true}\n rows={typeof props[\"rows\"] === \"number\" ? props[\"rows\"] : 4}\n placeholder={typeof props[\"placeholder\"] === \"string\" ? props[\"placeholder\"] : undefined}\n disabled={props[\"disabled\"] === true}\n readOnly={props[\"readOnly\"] === true}\n {...(binding\n ? { value: String(props[\"value\"] ?? \"\") }\n : {\n defaultValue:\n typeof props[\"defaultValue\"] === \"string\" ? props[\"defaultValue\"] : undefined,\n })}\n onChange={\n binding || eventChain(ctx.element, \"onChange\").length > 0\n ? (event) =>\n dispatchChange(ctx, \"value\", event.currentTarget.value, event.currentTarget)\n : undefined\n }\n className={cn(fieldBase, \"resize-y\")}\n aria-describedby={helpText ? `${name}-desc` : undefined}\n />\n {helpText && (\n <p id={`${name}-desc`} className=\"text-xs text-muted-foreground\">\n {helpText}\n </p>\n )}\n </div>\n );\n};\n\n/** Checkbox toggle field */\nexport const FormCheckbox: RendererComponent = (props, ctx) => {\n const name = String(props[\"name\"] ?? \"\");\n const binding = bindStatePath(ctx.element, \"checked\");\n\n return (\n <div className=\"uibot-form-field flex items-start gap-2.5\" data-uibot-type=\"Form.Checkbox\">\n <input\n id={name}\n name={name}\n type=\"checkbox\"\n {...(binding\n ? { checked: props[\"checked\"] === true }\n : { defaultChecked: props[\"defaultChecked\"] === true })}\n onChange={\n binding || eventChain(ctx.element, \"onChange\").length > 0\n ? (event) =>\n dispatchChange(ctx, \"checked\", event.currentTarget.checked, event.currentTarget)\n : undefined\n }\n disabled={props[\"disabled\"] === true}\n className=\"mt-0.5 h-4 w-4 shrink-0 rounded border border-input bg-background shadow-sm transition-colors checked:bg-primary checked:border-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50\"\n />\n {typeof props[\"label\"] === \"string\" && (\n <div className=\"flex flex-col gap-0.5\">\n <label className={cn(labelBase, \"cursor-pointer\")} htmlFor={name}>\n {props[\"label\"]}\n </label>\n {typeof props[\"description\"] === \"string\" && (\n <p className=\"text-xs text-muted-foreground\">{props[\"description\"]}</p>\n )}\n </div>\n )}\n </div>\n );\n};\n\n/** Form submit button */\nexport const FormSubmit: RendererComponent = (props, ctx) => {\n const variant = typeof props[\"variant\"] === \"string\" ? props[\"variant\"] : \"default\";\n const onClick = eventChain(ctx.element, \"onClick\");\n const VARIANTS: Record<string, string> = {\n default: \"bg-primary text-primary-foreground hover:bg-primary/90 shadow-sm\",\n destructive: \"bg-destructive text-white hover:bg-destructive/90 shadow-sm\",\n outline:\n \"border bg-background text-foreground hover:bg-accent hover:text-accent-foreground shadow-sm\",\n ghost: \"hover:bg-accent hover:text-accent-foreground\",\n };\n\n return (\n <button\n type=\"submit\"\n disabled={props[\"disabled\"] === true}\n className={cn(\n \"uibot-submit inline-flex items-center justify-center gap-2 rounded-md px-4 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50\",\n VARIANTS[variant] ?? VARIANTS[\"default\"]!,\n props[\"full\"] === true ? \"w-full\" : \"\",\n )}\n data-uibot-type=\"Form.Submit\"\n onClick={\n onClick.length > 0\n ? (event) =>\n void ctx.dispatch?.(onClick, {\n event: {\n type: \"click\",\n ...(event.currentTarget.name ? { name: event.currentTarget.name } : {}),\n },\n })\n : undefined\n }\n >\n {typeof props[\"label\"] === \"string\" ? props[\"label\"] : \"Submit\"}\n </button>\n );\n};\n",
|
|
19
|
+
"type": "registry:ui"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "components/uibot/form-controls.tsx",
|
|
23
|
+
"target": "components/uibot/form-controls.tsx",
|
|
24
|
+
"content": "import { type ReactNode, useCallback, useRef, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { Popover as PopoverPrimitive, Select as SelectPrimitive } from \"radix-ui\";\nimport { DayPicker } from \"react-day-picker\";\n\n/** Same field surface as the other Form.* controls (shadcn Input). */\nconst triggerBase =\n \"flex h-9 w-full items-center justify-between gap-2 rounded-md border border-input bg-background px-3 py-2 text-left text-sm text-foreground shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground\";\n\nconst popoverSurface =\n \"z-50 rounded-md border bg-popover text-popover-foreground shadow-md outline-none\";\n\nfunction Chevron({ className }: { className?: string }) {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={className}\n aria-hidden=\"true\"\n >\n <path d=\"m4 6 4 4 4-4\" />\n </svg>\n );\n}\n\n/** Frame that owns the theme (dark class, tokens): portalled content mounts inside it. */\nfunction useThemeContainer() {\n const [container, setContainer] = useState<HTMLElement | undefined>(undefined);\n const ref = useCallback((node: HTMLElement | null) => {\n setContainer(\n (node?.closest(\"[data-uibot-type='PageLayout']\") as HTMLElement | null) ?? undefined,\n );\n }, []);\n return [container, ref] as const;\n}\n\nexport interface SelectOption {\n value: string;\n label: string;\n}\n\nexport interface FormSelectControlProps {\n id: string;\n name: string;\n options: SelectOption[];\n placeholder: string;\n /** Present for controlled use (`_bindState`); omit to let the control hold its own value. */\n value?: string;\n defaultValue?: string;\n required?: boolean;\n disabled?: boolean;\n onValueChange?: ((value: string, element: HTMLElement) => void) | undefined;\n}\n\n/**\n * shadcn/ui Select (Radix). Radix renders a hidden native `<select name>` inside forms, so native\n * form values, `required` validation and the bubbling `change` event the Form block listens to keep\n * working.\n */\nexport function FormSelectControl(props: FormSelectControlProps) {\n const [container, triggerRef] = useThemeContainer();\n const triggerEl = useRef<HTMLButtonElement | null>(null);\n // Radix rejects empty-string items; an empty value means \"no selection\" and is the placeholder.\n const options = props.options.filter((option) => option.value !== \"\");\n return (\n <SelectPrimitive.Root\n name={props.name}\n {...(props.value !== undefined\n ? { value: props.value === \"\" ? undefined : props.value }\n : props.defaultValue\n ? { defaultValue: props.defaultValue }\n : {})}\n {...(props.required ? { required: true } : {})}\n {...(props.disabled ? { disabled: true } : {})}\n onValueChange={(value) => props.onValueChange?.(value, triggerEl.current as HTMLElement)}\n >\n <SelectPrimitive.Trigger\n id={props.id}\n ref={(node) => {\n triggerEl.current = node;\n triggerRef(node);\n }}\n className={triggerBase}\n >\n <SelectPrimitive.Value placeholder={props.placeholder} />\n <SelectPrimitive.Icon asChild>\n <Chevron className=\"size-4 shrink-0 opacity-50\" />\n </SelectPrimitive.Icon>\n </SelectPrimitive.Trigger>\n <SelectPrimitive.Portal {...(container ? { container } : {})}>\n <SelectPrimitive.Content\n position=\"popper\"\n sideOffset={4}\n className={cn(\n popoverSurface,\n \"max-h-80 min-w-[var(--radix-select-trigger-width)] overflow-hidden\",\n )}\n >\n <SelectPrimitive.Viewport className=\"p-1\">\n {options.map((option) => (\n <SelectPrimitive.Item\n key={option.value}\n value={option.value}\n className=\"relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50\"\n >\n <SelectPrimitive.ItemText>{option.label}</SelectPrimitive.ItemText>\n <SelectPrimitive.ItemIndicator className=\"absolute right-2 flex size-3.5 items-center justify-center\">\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"m3.5 8.5 3 3 6-7\" />\n </svg>\n </SelectPrimitive.ItemIndicator>\n </SelectPrimitive.Item>\n ))}\n </SelectPrimitive.Viewport>\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n </SelectPrimitive.Root>\n );\n}\n\nconst ISO_DATE = /^(\\d{4})-(\\d{2})-(\\d{2})$/;\n\n/** Parse `yyyy-MM-dd` as a local calendar date (no time zone shift). */\nfunction parseIsoDate(value: string): Date | undefined {\n const match = ISO_DATE.exec(value);\n if (!match) return undefined;\n const date = new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));\n return Number.isNaN(date.getTime()) ? undefined : date;\n}\n\nfunction toIsoDate(date: Date): string {\n const month = String(date.getMonth() + 1).padStart(2, \"0\");\n const day = String(date.getDate()).padStart(2, \"0\");\n return `${String(date.getFullYear()).padStart(4, \"0\")}-${month}-${day}`;\n}\n\nexport interface FormDateControlProps {\n id: string;\n name: string;\n placeholder?: string;\n /** Controlled value (`yyyy-MM-dd`); omit to let the control hold its own. */\n value?: string;\n defaultValue?: string;\n required?: boolean;\n disabled?: boolean;\n readOnly?: boolean;\n invalid?: boolean;\n describedBy?: string;\n onValueChange?: ((value: string, element: HTMLElement) => void) | undefined;\n}\n\n/**\n * shadcn/ui date picker: a Popover with a Calendar (react-day-picker). The value stays an ISO\n * `yyyy-MM-dd` string. A visually hidden text input carries the name and value so the surrounding\n * Form collects it, runs native `required` validation (focus is handed to the trigger) and sees a\n * bubbling `input` event when the date changes.\n */\nexport function FormDateControl(props: FormDateControlProps) {\n const [container, popoverRef] = useThemeContainer();\n const [internal, setInternal] = useState(props.defaultValue ?? \"\");\n const [open, setOpen] = useState(false);\n const proxy = useRef<HTMLInputElement | null>(null);\n const trigger = useRef<HTMLButtonElement | null>(null);\n const value = props.value !== undefined ? props.value : internal;\n const selected = parseIsoDate(value);\n const interactive = !props.disabled && !props.readOnly;\n\n const commit = (next: string) => {\n setInternal(next);\n const input = proxy.current;\n if (input) {\n // Let the Form block see a native bubbling event, as it does for text inputs.\n const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, \"value\")?.set;\n setter?.call(input, next);\n input.dispatchEvent(new Event(\"input\", { bubbles: true }));\n }\n props.onValueChange?.(next, input ?? (trigger.current as HTMLElement));\n };\n\n let label: ReactNode = props.placeholder ?? \"Pick a date\";\n if (selected) {\n label = new Intl.DateTimeFormat(undefined, { dateStyle: \"medium\" }).format(selected);\n }\n return (\n <PopoverPrimitive.Root open={interactive && open} onOpenChange={setOpen}>\n <div className=\"relative\">\n <PopoverPrimitive.Trigger asChild>\n <button\n id={props.id}\n ref={(node) => {\n trigger.current = node;\n popoverRef(node);\n }}\n type=\"button\"\n disabled={props.disabled}\n aria-invalid={props.invalid ? true : undefined}\n aria-describedby={props.describedBy}\n data-placeholder={selected ? undefined : \"\"}\n className={cn(triggerBase, !interactive && \"cursor-default\")}\n >\n <span className=\"flex items-center gap-2\">\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className=\"size-4 shrink-0 opacity-60\"\n aria-hidden=\"true\"\n >\n <rect x=\"2\" y=\"3\" width=\"12\" height=\"11\" rx=\"2\" />\n <path d=\"M2 6.5h12M5.5 1.5v3M10.5 1.5v3\" />\n </svg>\n {label}\n </span>\n </button>\n </PopoverPrimitive.Trigger>\n <input\n ref={proxy}\n type=\"text\"\n name={props.name}\n value={value}\n onChange={() => undefined}\n required={props.required}\n disabled={props.disabled}\n tabIndex={-1}\n aria-hidden=\"true\"\n onFocus={() => trigger.current?.focus()}\n className=\"pointer-events-none absolute inset-0 h-full w-full opacity-0\"\n />\n </div>\n <PopoverPrimitive.Portal {...(container ? { container } : {})}>\n <PopoverPrimitive.Content\n align=\"start\"\n sideOffset={4}\n className={cn(popoverSurface, \"w-auto p-3\")}\n >\n <DayPicker\n mode=\"single\"\n showOutsideDays\n {...(selected ? { selected, defaultMonth: selected } : {})}\n onSelect={(date) => {\n if (!date) return;\n commit(toIsoDate(date));\n setOpen(false);\n trigger.current?.focus();\n }}\n classNames={{\n root: \"relative text-sm\",\n months: \"relative flex flex-col gap-4\",\n month: \"flex flex-col gap-3\",\n month_caption: \"flex h-8 items-center justify-center px-8 font-medium\",\n nav: \"absolute inset-x-0 top-0 flex items-center justify-between\",\n button_previous:\n \"inline-flex size-8 items-center justify-center rounded-md border border-input bg-background text-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50\",\n button_next:\n \"inline-flex size-8 items-center justify-center rounded-md border border-input bg-background text-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50\",\n month_grid: \"w-full border-collapse\",\n weekdays: \"flex\",\n weekday: \"w-9 text-[0.8rem] font-normal text-muted-foreground\",\n week: \"mt-1 flex w-full\",\n day: \"relative size-9 p-0 text-center\",\n day_button:\n \"inline-flex size-9 items-center justify-center rounded-md text-sm font-normal hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50\",\n selected:\n \"[&>button]:bg-primary [&>button]:text-primary-foreground [&>button:hover]:bg-primary [&>button:hover]:text-primary-foreground\",\n today: \"[&>button]:bg-accent [&>button]:text-accent-foreground\",\n outside: \"[&>button]:text-muted-foreground [&>button]:opacity-50\",\n disabled: \"[&>button]:opacity-40\",\n hidden: \"invisible\",\n }}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n );\n}\n",
|
|
25
|
+
"type": "registry:ui"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "components/uibot/interaction.ts",
|
|
29
|
+
"target": "components/uibot/interaction.ts",
|
|
30
|
+
"content": "import type { RendererComponent } from \"@/lib/uibot-renderer\";\nexport type BlockContext = Parameters<RendererComponent>[1];\nexport type Chain = Parameters<NonNullable<BlockContext[\"dispatch\"]>>[0];\nexport type EventValue = string | number | boolean | null;\nexport function emit(\n ctx: BlockContext,\n name: string,\n values: Record<string, EventValue | EventValue[]> = {},\n value?: EventValue,\n): void {\n const element = ctx.element as { events?: Record<string, Chain> };\n const chain = element.events?.[name];\n if (chain?.length)\n void ctx.dispatch?.(chain, {\n event: { type: name, values, ...(value !== undefined ? { value } : {}) },\n });\n}\nexport function text(value: unknown, fallback = \"\"): string {\n return value == null ? fallback : String(value);\n}\nexport function records(value: unknown): Record<string, unknown>[] {\n return Array.isArray(value)\n ? value.filter(\n (v): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v),\n )\n : [];\n}\n\nconst submissions = new WeakMap<object, { payload: string; key: string }>();\n/** A new owner represents a new user intent; an unchanged failed submission keeps its key. */\nexport function submissionKey(owner: object, values: unknown): string {\n const payload = JSON.stringify(values);\n const previous = submissions.get(owner);\n if (previous?.payload === payload) return previous.key;\n const key = crypto.randomUUID();\n submissions.set(owner, { payload, key });\n return key;\n}\n",
|
|
31
|
+
"type": "registry:ui"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"path": "components/uibot/form.uibot.json",
|
|
35
|
+
"target": "components/uibot/form.uibot.json",
|
|
36
|
+
"content": "{\n \"schema\": \"uibot.registry.item.v1\",\n \"item\": \"form\",\n \"channel\": \"public\",\n \"components\": [\n {\n \"name\": \"Form\",\n \"export\": \"Form\",\n \"module\": \"form.tsx\",\n \"catalog\": {\n \"name\": \"Form\",\n \"description\": \"Form wrapper that prevents default submission. Place Form.Input, Form.Select, etc. as children and end with Form.Submit.\",\n \"category\": \"composite\",\n \"level\": \"L2\",\n \"tags\": [\n \"form\",\n \"input\"\n ],\n \"props\": {\n \"idempotent\": {\n \"type\": \"boolean\",\n \"description\": \"Emit a stable event.value idempotency key while retrying unchanged form values\"\n },\n \"pending\": {\n \"type\": \"boolean\"\n },\n \"label\": {\n \"type\": \"string\"\n },\n \"layout\": {\n \"type\": \"string\",\n \"enum\": [\n \"vertical\",\n \"horizontal\"\n ],\n \"default\": \"vertical\"\n }\n },\n \"events\": {\n \"onChange\": {\n \"description\": \"Bubbled native field changes with { type, name, value, checked }.\"\n },\n \"onSubmit\": {\n \"description\": \"Runs after native submission is prevented.\",\n \"payload\": {\n \"type\": \"object\",\n \"description\": \"{ type: 'submit', values: Record<string, value> }\"\n }\n }\n },\n \"usageScenarios\": [\n \"Create / edit entity form\",\n \"Login form\",\n \"Search filter form\"\n ],\n \"constraints\": [\n \"Always include exactly one Form.Submit as the last child\",\n \"Do not nest forms inside forms\"\n ]\n }\n },\n {\n \"name\": \"Form.Checkbox\",\n \"export\": \"FormCheckbox\",\n \"module\": \"form.tsx\",\n \"catalog\": {\n \"name\": \"Form.Checkbox\",\n \"description\": \"Single boolean checkbox with optional description beneath the label.\",\n \"category\": \"primitive\",\n \"level\": \"L1\",\n \"tags\": [\n \"form\",\n \"checkbox\"\n ],\n \"props\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"label\": {\n \"type\": \"string\"\n },\n \"description\": {\n \"type\": \"string\"\n },\n \"checked\": {\n \"type\": \"boolean\",\n \"description\": \"Supports {_bindState: 'path'} for two-way state.\"\n }\n },\n \"events\": {\n \"onChange\": {\n \"description\": \"Runs with { type, name, value, checked }.\"\n }\n },\n \"usageScenarios\": [\n \"Terms & conditions consent\",\n \"Opt-in notification preference\"\n ],\n \"constraints\": []\n }\n },\n {\n \"name\": \"Form.Input\",\n \"export\": \"FormInput\",\n \"module\": \"form.tsx\",\n \"catalog\": {\n \"name\": \"Form.Input\",\n \"description\": \"Single-line text field. Supports text, email, password, number, tel, url, date types.\",\n \"category\": \"primitive\",\n \"level\": \"L1\",\n \"tags\": [\n \"form\",\n \"input\"\n ],\n \"props\": {\n \"name\": {\n \"type\": \"string\",\n \"description\": \"Field identifier (must be unique in the form)\"\n },\n \"label\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\",\n \"enum\": [\n \"text\",\n \"email\",\n \"password\",\n \"number\",\n \"tel\",\n \"url\",\n \"date\",\n \"search\"\n ],\n \"default\": \"text\"\n },\n \"placeholder\": {\n \"type\": \"string\"\n },\n \"helpText\": {\n \"type\": \"string\"\n },\n \"error\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\",\n \"default\": false\n },\n \"disabled\": {\n \"type\": \"boolean\",\n \"default\": false\n },\n \"value\": {\n \"type\": \"string\",\n \"description\": \"Supports {_bindState: 'path'} for two-way state.\"\n }\n },\n \"events\": {\n \"onChange\": {\n \"description\": \"Runs with { type, name, value }.\"\n }\n },\n \"usageScenarios\": [\n \"Email address field in a login form\",\n \"Search bar with type=search\",\n \"Price input with type=number\"\n ],\n \"constraints\": [\n \"name prop is required and must be unique within the parent Form\"\n ]\n }\n },\n {\n \"name\": \"Form.Select\",\n \"export\": \"FormSelect\",\n \"module\": \"form.tsx\",\n \"catalog\": {\n \"name\": \"Form.Select\",\n \"description\": \"Dropdown select field with an options array [{value, label}].\",\n \"category\": \"primitive\",\n \"level\": \"L1\",\n \"tags\": [\n \"form\",\n \"select\"\n ],\n \"props\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"label\": {\n \"type\": \"string\"\n },\n \"options\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"value\": {\n \"type\": \"string\"\n },\n \"label\": {\n \"type\": \"string\"\n }\n }\n },\n \"description\": \"[{value, label}]\"\n },\n \"placeholder\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\",\n \"default\": false\n },\n \"value\": {\n \"type\": \"string\",\n \"description\": \"Supports {_bindState: 'path'} for two-way state.\"\n }\n },\n \"events\": {\n \"onChange\": {\n \"description\": \"Runs with { type, name, value }.\"\n }\n },\n \"usageScenarios\": [\n \"Role selector (Admin/Editor/Viewer)\",\n \"Status filter dropdown\"\n ],\n \"constraints\": []\n }\n },\n {\n \"name\": \"Form.Submit\",\n \"export\": \"FormSubmit\",\n \"module\": \"form.tsx\",\n \"catalog\": {\n \"name\": \"Form.Submit\",\n \"description\": \"Form submit button. Use variant=destructive for irreversible actions.\",\n \"category\": \"primitive\",\n \"level\": \"L1\",\n \"tags\": [\n \"form\",\n \"button\"\n ],\n \"props\": {\n \"label\": {\n \"type\": \"string\",\n \"default\": \"Submit\"\n },\n \"variant\": {\n \"type\": \"string\",\n \"enum\": [\n \"default\",\n \"destructive\",\n \"outline\",\n \"ghost\"\n ],\n \"default\": \"default\"\n },\n \"full\": {\n \"type\": \"boolean\",\n \"default\": false\n }\n },\n \"events\": {\n \"onClick\": {\n \"description\": \"Runs with a plain click payload before the parent form submits.\"\n }\n },\n \"usageScenarios\": [\n \"Save button at the bottom of a form\",\n \"Delete action with variant=destructive\"\n ],\n \"constraints\": [\n \"Must be inside a Form block\"\n ]\n }\n },\n {\n \"name\": \"Form.TextArea\",\n \"export\": \"FormTextArea\",\n \"module\": \"form.tsx\",\n \"catalog\": {\n \"name\": \"Form.TextArea\",\n \"description\": \"Multi-line text input. Use for descriptions, messages, or any free-form long text.\",\n \"category\": \"primitive\",\n \"level\": \"L1\",\n \"tags\": [\n \"form\",\n \"textarea\"\n ],\n \"props\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"label\": {\n \"type\": \"string\"\n },\n \"placeholder\": {\n \"type\": \"string\"\n },\n \"rows\": {\n \"type\": \"integer\",\n \"default\": 4\n },\n \"helpText\": {\n \"type\": \"string\"\n },\n \"required\": {\n \"type\": \"boolean\",\n \"default\": false\n },\n \"value\": {\n \"type\": \"string\",\n \"description\": \"Supports {_bindState: 'path'} for two-way state.\"\n }\n },\n \"events\": {\n \"onChange\": {\n \"description\": \"Runs with { type, name, value }.\"\n }\n },\n \"usageScenarios\": [\n \"Bio / description field on a profile form\",\n \"Message body in a contact form\"\n ],\n \"constraints\": []\n }\n }\n ]\n}\n",
|
|
37
|
+
"type": "registry:ui"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"meta": {
|
|
41
|
+
"category": "composite",
|
|
42
|
+
"level": "L2",
|
|
43
|
+
"props": {
|
|
44
|
+
"idempotent": {
|
|
45
|
+
"type": "boolean",
|
|
46
|
+
"description": "Emit a stable event.value idempotency key while retrying unchanged form values"
|
|
47
|
+
},
|
|
48
|
+
"pending": {
|
|
49
|
+
"type": "boolean"
|
|
50
|
+
},
|
|
51
|
+
"label": {
|
|
52
|
+
"type": "string"
|
|
53
|
+
},
|
|
54
|
+
"layout": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"enum": [
|
|
57
|
+
"vertical",
|
|
58
|
+
"horizontal"
|
|
59
|
+
],
|
|
60
|
+
"default": "vertical"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"events": {
|
|
64
|
+
"onChange": {
|
|
65
|
+
"description": "Bubbled native field changes with { type, name, value, checked }."
|
|
66
|
+
},
|
|
67
|
+
"onSubmit": {
|
|
68
|
+
"description": "Runs after native submission is prevented.",
|
|
69
|
+
"payload": {
|
|
70
|
+
"type": "object",
|
|
71
|
+
"description": "{ type: 'submit', values: Record<string, value> }"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"scenarios": [
|
|
76
|
+
"Create / edit entity form",
|
|
77
|
+
"Login form",
|
|
78
|
+
"Search filter form"
|
|
79
|
+
],
|
|
80
|
+
"constraints": [
|
|
81
|
+
"Always include exactly one Form.Submit as the last child",
|
|
82
|
+
"Do not nest forms inside forms"
|
|
83
|
+
],
|
|
84
|
+
"provides": [
|
|
85
|
+
"Form",
|
|
86
|
+
"Form.Input",
|
|
87
|
+
"Form.Select",
|
|
88
|
+
"Form.TextArea",
|
|
89
|
+
"Form.Checkbox",
|
|
90
|
+
"Form.Submit"
|
|
91
|
+
],
|
|
92
|
+
"uibot": {
|
|
93
|
+
"schema": "uibot.registry.item.v1",
|
|
94
|
+
"item": "form",
|
|
95
|
+
"channel": "public",
|
|
96
|
+
"components": [
|
|
97
|
+
{
|
|
98
|
+
"name": "Form",
|
|
99
|
+
"export": "Form",
|
|
100
|
+
"module": "form.tsx",
|
|
101
|
+
"catalog": {
|
|
102
|
+
"name": "Form",
|
|
103
|
+
"description": "Form wrapper that prevents default submission. Place Form.Input, Form.Select, etc. as children and end with Form.Submit.",
|
|
104
|
+
"category": "composite",
|
|
105
|
+
"level": "L2",
|
|
106
|
+
"tags": [
|
|
107
|
+
"form",
|
|
108
|
+
"input"
|
|
109
|
+
],
|
|
110
|
+
"props": {
|
|
111
|
+
"idempotent": {
|
|
112
|
+
"type": "boolean",
|
|
113
|
+
"description": "Emit a stable event.value idempotency key while retrying unchanged form values"
|
|
114
|
+
},
|
|
115
|
+
"pending": {
|
|
116
|
+
"type": "boolean"
|
|
117
|
+
},
|
|
118
|
+
"label": {
|
|
119
|
+
"type": "string"
|
|
120
|
+
},
|
|
121
|
+
"layout": {
|
|
122
|
+
"type": "string",
|
|
123
|
+
"enum": [
|
|
124
|
+
"vertical",
|
|
125
|
+
"horizontal"
|
|
126
|
+
],
|
|
127
|
+
"default": "vertical"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"events": {
|
|
131
|
+
"onChange": {
|
|
132
|
+
"description": "Bubbled native field changes with { type, name, value, checked }."
|
|
133
|
+
},
|
|
134
|
+
"onSubmit": {
|
|
135
|
+
"description": "Runs after native submission is prevented.",
|
|
136
|
+
"payload": {
|
|
137
|
+
"type": "object",
|
|
138
|
+
"description": "{ type: 'submit', values: Record<string, value> }"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"usageScenarios": [
|
|
143
|
+
"Create / edit entity form",
|
|
144
|
+
"Login form",
|
|
145
|
+
"Search filter form"
|
|
146
|
+
],
|
|
147
|
+
"constraints": [
|
|
148
|
+
"Always include exactly one Form.Submit as the last child",
|
|
149
|
+
"Do not nest forms inside forms"
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"name": "Form.Checkbox",
|
|
155
|
+
"export": "FormCheckbox",
|
|
156
|
+
"module": "form.tsx",
|
|
157
|
+
"catalog": {
|
|
158
|
+
"name": "Form.Checkbox",
|
|
159
|
+
"description": "Single boolean checkbox with optional description beneath the label.",
|
|
160
|
+
"category": "primitive",
|
|
161
|
+
"level": "L1",
|
|
162
|
+
"tags": [
|
|
163
|
+
"form",
|
|
164
|
+
"checkbox"
|
|
165
|
+
],
|
|
166
|
+
"props": {
|
|
167
|
+
"name": {
|
|
168
|
+
"type": "string"
|
|
169
|
+
},
|
|
170
|
+
"label": {
|
|
171
|
+
"type": "string"
|
|
172
|
+
},
|
|
173
|
+
"description": {
|
|
174
|
+
"type": "string"
|
|
175
|
+
},
|
|
176
|
+
"checked": {
|
|
177
|
+
"type": "boolean",
|
|
178
|
+
"description": "Supports {_bindState: 'path'} for two-way state."
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"events": {
|
|
182
|
+
"onChange": {
|
|
183
|
+
"description": "Runs with { type, name, value, checked }."
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"usageScenarios": [
|
|
187
|
+
"Terms & conditions consent",
|
|
188
|
+
"Opt-in notification preference"
|
|
189
|
+
],
|
|
190
|
+
"constraints": []
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"name": "Form.Input",
|
|
195
|
+
"export": "FormInput",
|
|
196
|
+
"module": "form.tsx",
|
|
197
|
+
"catalog": {
|
|
198
|
+
"name": "Form.Input",
|
|
199
|
+
"description": "Single-line text field. Supports text, email, password, number, tel, url, date types.",
|
|
200
|
+
"category": "primitive",
|
|
201
|
+
"level": "L1",
|
|
202
|
+
"tags": [
|
|
203
|
+
"form",
|
|
204
|
+
"input"
|
|
205
|
+
],
|
|
206
|
+
"props": {
|
|
207
|
+
"name": {
|
|
208
|
+
"type": "string",
|
|
209
|
+
"description": "Field identifier (must be unique in the form)"
|
|
210
|
+
},
|
|
211
|
+
"label": {
|
|
212
|
+
"type": "string"
|
|
213
|
+
},
|
|
214
|
+
"type": {
|
|
215
|
+
"type": "string",
|
|
216
|
+
"enum": [
|
|
217
|
+
"text",
|
|
218
|
+
"email",
|
|
219
|
+
"password",
|
|
220
|
+
"number",
|
|
221
|
+
"tel",
|
|
222
|
+
"url",
|
|
223
|
+
"date",
|
|
224
|
+
"search"
|
|
225
|
+
],
|
|
226
|
+
"default": "text"
|
|
227
|
+
},
|
|
228
|
+
"placeholder": {
|
|
229
|
+
"type": "string"
|
|
230
|
+
},
|
|
231
|
+
"helpText": {
|
|
232
|
+
"type": "string"
|
|
233
|
+
},
|
|
234
|
+
"error": {
|
|
235
|
+
"type": "string"
|
|
236
|
+
},
|
|
237
|
+
"required": {
|
|
238
|
+
"type": "boolean",
|
|
239
|
+
"default": false
|
|
240
|
+
},
|
|
241
|
+
"disabled": {
|
|
242
|
+
"type": "boolean",
|
|
243
|
+
"default": false
|
|
244
|
+
},
|
|
245
|
+
"value": {
|
|
246
|
+
"type": "string",
|
|
247
|
+
"description": "Supports {_bindState: 'path'} for two-way state."
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"events": {
|
|
251
|
+
"onChange": {
|
|
252
|
+
"description": "Runs with { type, name, value }."
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"usageScenarios": [
|
|
256
|
+
"Email address field in a login form",
|
|
257
|
+
"Search bar with type=search",
|
|
258
|
+
"Price input with type=number"
|
|
259
|
+
],
|
|
260
|
+
"constraints": [
|
|
261
|
+
"name prop is required and must be unique within the parent Form"
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"name": "Form.Select",
|
|
267
|
+
"export": "FormSelect",
|
|
268
|
+
"module": "form.tsx",
|
|
269
|
+
"catalog": {
|
|
270
|
+
"name": "Form.Select",
|
|
271
|
+
"description": "Dropdown select field with an options array [{value, label}].",
|
|
272
|
+
"category": "primitive",
|
|
273
|
+
"level": "L1",
|
|
274
|
+
"tags": [
|
|
275
|
+
"form",
|
|
276
|
+
"select"
|
|
277
|
+
],
|
|
278
|
+
"props": {
|
|
279
|
+
"name": {
|
|
280
|
+
"type": "string"
|
|
281
|
+
},
|
|
282
|
+
"label": {
|
|
283
|
+
"type": "string"
|
|
284
|
+
},
|
|
285
|
+
"options": {
|
|
286
|
+
"type": "array",
|
|
287
|
+
"items": {
|
|
288
|
+
"type": "object",
|
|
289
|
+
"properties": {
|
|
290
|
+
"value": {
|
|
291
|
+
"type": "string"
|
|
292
|
+
},
|
|
293
|
+
"label": {
|
|
294
|
+
"type": "string"
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
"description": "[{value, label}]"
|
|
299
|
+
},
|
|
300
|
+
"placeholder": {
|
|
301
|
+
"type": "string"
|
|
302
|
+
},
|
|
303
|
+
"required": {
|
|
304
|
+
"type": "boolean",
|
|
305
|
+
"default": false
|
|
306
|
+
},
|
|
307
|
+
"value": {
|
|
308
|
+
"type": "string",
|
|
309
|
+
"description": "Supports {_bindState: 'path'} for two-way state."
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
"events": {
|
|
313
|
+
"onChange": {
|
|
314
|
+
"description": "Runs with { type, name, value }."
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
"usageScenarios": [
|
|
318
|
+
"Role selector (Admin/Editor/Viewer)",
|
|
319
|
+
"Status filter dropdown"
|
|
320
|
+
],
|
|
321
|
+
"constraints": []
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"name": "Form.Submit",
|
|
326
|
+
"export": "FormSubmit",
|
|
327
|
+
"module": "form.tsx",
|
|
328
|
+
"catalog": {
|
|
329
|
+
"name": "Form.Submit",
|
|
330
|
+
"description": "Form submit button. Use variant=destructive for irreversible actions.",
|
|
331
|
+
"category": "primitive",
|
|
332
|
+
"level": "L1",
|
|
333
|
+
"tags": [
|
|
334
|
+
"form",
|
|
335
|
+
"button"
|
|
336
|
+
],
|
|
337
|
+
"props": {
|
|
338
|
+
"label": {
|
|
339
|
+
"type": "string",
|
|
340
|
+
"default": "Submit"
|
|
341
|
+
},
|
|
342
|
+
"variant": {
|
|
343
|
+
"type": "string",
|
|
344
|
+
"enum": [
|
|
345
|
+
"default",
|
|
346
|
+
"destructive",
|
|
347
|
+
"outline",
|
|
348
|
+
"ghost"
|
|
349
|
+
],
|
|
350
|
+
"default": "default"
|
|
351
|
+
},
|
|
352
|
+
"full": {
|
|
353
|
+
"type": "boolean",
|
|
354
|
+
"default": false
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
"events": {
|
|
358
|
+
"onClick": {
|
|
359
|
+
"description": "Runs with a plain click payload before the parent form submits."
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
"usageScenarios": [
|
|
363
|
+
"Save button at the bottom of a form",
|
|
364
|
+
"Delete action with variant=destructive"
|
|
365
|
+
],
|
|
366
|
+
"constraints": [
|
|
367
|
+
"Must be inside a Form block"
|
|
368
|
+
]
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
"name": "Form.TextArea",
|
|
373
|
+
"export": "FormTextArea",
|
|
374
|
+
"module": "form.tsx",
|
|
375
|
+
"catalog": {
|
|
376
|
+
"name": "Form.TextArea",
|
|
377
|
+
"description": "Multi-line text input. Use for descriptions, messages, or any free-form long text.",
|
|
378
|
+
"category": "primitive",
|
|
379
|
+
"level": "L1",
|
|
380
|
+
"tags": [
|
|
381
|
+
"form",
|
|
382
|
+
"textarea"
|
|
383
|
+
],
|
|
384
|
+
"props": {
|
|
385
|
+
"name": {
|
|
386
|
+
"type": "string"
|
|
387
|
+
},
|
|
388
|
+
"label": {
|
|
389
|
+
"type": "string"
|
|
390
|
+
},
|
|
391
|
+
"placeholder": {
|
|
392
|
+
"type": "string"
|
|
393
|
+
},
|
|
394
|
+
"rows": {
|
|
395
|
+
"type": "integer",
|
|
396
|
+
"default": 4
|
|
397
|
+
},
|
|
398
|
+
"helpText": {
|
|
399
|
+
"type": "string"
|
|
400
|
+
},
|
|
401
|
+
"required": {
|
|
402
|
+
"type": "boolean",
|
|
403
|
+
"default": false
|
|
404
|
+
},
|
|
405
|
+
"value": {
|
|
406
|
+
"type": "string",
|
|
407
|
+
"description": "Supports {_bindState: 'path'} for two-way state."
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
"events": {
|
|
411
|
+
"onChange": {
|
|
412
|
+
"description": "Runs with { type, name, value }."
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
"usageScenarios": [
|
|
416
|
+
"Bio / description field on a profile form",
|
|
417
|
+
"Message body in a contact form"
|
|
418
|
+
],
|
|
419
|
+
"constraints": []
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
]
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|