@uibot/registry 0.18.1 → 0.20.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/README.md +59 -0
- package/dist/component-replacement.d.ts +10 -0
- package/dist/distribution-snapshot.d.ts +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -11
- package/dist/resource-query.d.ts +4 -0
- package/dist/resources.d.ts +4 -0
- package/dist/resources.js +3 -3
- package/dist/shadcn/r/admin-apps.json +61 -0
- package/dist/shadcn/r/admin-chats.json +54 -0
- package/dist/shadcn/r/admin-error-401.json +54 -0
- package/dist/shadcn/r/admin-error-403.json +54 -0
- package/dist/shadcn/r/admin-error-404.json +54 -0
- package/dist/shadcn/r/admin-error-500.json +54 -0
- package/dist/shadcn/r/admin-error-503.json +54 -0
- package/dist/shadcn/r/admin-forgot-password.json +59 -0
- package/dist/shadcn/r/admin-help.json +53 -0
- package/dist/shadcn/r/admin-otp.json +59 -0
- package/dist/shadcn/r/admin-overview.json +62 -0
- package/dist/shadcn/r/admin-settings-account.json +61 -0
- package/dist/shadcn/r/admin-settings-appearance.json +61 -0
- package/dist/shadcn/r/admin-settings-display.json +61 -0
- package/dist/shadcn/r/admin-settings-notifications.json +61 -0
- package/dist/shadcn/r/admin-settings-profile.json +61 -0
- package/dist/shadcn/r/admin-settings.json +65 -0
- package/dist/shadcn/r/admin-shell.json +25 -6
- package/dist/shadcn/r/admin-sign-in-2.json +67 -0
- package/dist/shadcn/r/admin-sign-in.json +59 -0
- package/dist/shadcn/r/admin-sign-up.json +59 -0
- package/dist/shadcn/r/admin-tasks.json +66 -0
- package/dist/shadcn/r/admin-users.json +66 -0
- package/dist/shadcn/r/auth-01.json +24 -0
- package/dist/shadcn/r/auth-02.json +24 -0
- package/dist/shadcn/r/auth-03.json +24 -0
- package/dist/shadcn/r/auth-04.json +24 -0
- package/dist/shadcn/r/auth-05.json +24 -0
- package/dist/shadcn/r/auth-centered.json +61 -0
- package/dist/shadcn/r/auth-enterprise.json +61 -0
- package/dist/shadcn/r/auth-primitives.json +58 -0
- package/dist/shadcn/r/auth-recovery.json +64 -0
- package/dist/shadcn/r/auth-registration.json +63 -0
- package/dist/shadcn/r/auth-split.json +67 -0
- package/dist/shadcn/r/auth.json +13 -13
- package/dist/shadcn/r/charts.json +45 -18
- package/dist/shadcn/r/chat-artifact.json +49 -0
- package/dist/shadcn/r/chat-focused.json +49 -0
- package/dist/shadcn/r/chat-history.json +49 -0
- package/dist/shadcn/r/chat-knowledge.json +49 -0
- package/dist/shadcn/r/chat-support.json +49 -0
- package/dist/shadcn/r/chat-workspace.json +136 -0
- package/dist/shadcn/r/collection-cell-editor.json +6 -6
- package/dist/shadcn/r/collection-panel-drawer.json +2 -2
- package/dist/shadcn/r/collection-record-menu.json +2 -2
- package/dist/shadcn/r/collection-shared.json +2 -2
- package/dist/shadcn/r/commerce-workspace.json +69 -0
- package/dist/shadcn/r/console-billing.json +68 -0
- package/dist/shadcn/r/console-page.json +289 -0
- package/dist/shadcn/r/console-shell.json +29 -0
- package/dist/shadcn/r/content.json +1 -1
- package/dist/shadcn/r/creation-html-generation.json +3 -3
- package/dist/shadcn/r/creation-reference-generation.json +3 -3
- package/dist/shadcn/r/creation-revision-export.json +3 -3
- package/dist/shadcn/r/creation-shared.json +3 -3
- package/dist/shadcn/r/creation-variant-compare.json +4 -4
- package/dist/shadcn/r/creation-workspace.json +4 -4
- package/dist/shadcn/r/crm-workspace.json +73 -0
- package/dist/shadcn/r/dashboard-01.json +78 -0
- package/dist/shadcn/r/dashboard.json +114 -4
- package/dist/shadcn/r/data-studio.json +1 -1
- package/dist/shadcn/r/data-table.json +138 -10
- package/dist/shadcn/r/data.json +88 -11
- package/dist/shadcn/r/document-assistant.json +54 -0
- package/dist/shadcn/r/document-library.json +49 -0
- package/dist/shadcn/r/document-reading.json +49 -0
- package/dist/shadcn/r/document-workspace.json +164 -0
- package/dist/shadcn/r/document-writing.json +49 -0
- package/dist/shadcn/r/drilldown-menu.json +233 -0
- package/dist/shadcn/r/education-workspace.json +82 -0
- package/dist/shadcn/r/feedback.json +19 -6
- package/dist/shadcn/r/field.json +1 -1
- package/dist/shadcn/r/form.json +12 -12
- package/dist/shadcn/r/grid.json +1 -1
- package/dist/shadcn/r/interactive.json +1 -1
- package/dist/shadcn/r/item-grid.json +219 -0
- package/dist/shadcn/r/kanban.json +1 -1
- package/dist/shadcn/r/layout.json +217 -18
- package/dist/shadcn/r/marketing.json +1 -1
- package/dist/shadcn/r/nav.json +39 -11
- package/dist/shadcn/r/presentation.json +1 -1
- package/dist/shadcn/r/preview-device-frame.json +2 -2
- package/dist/shadcn/r/primitives.json +2 -2
- package/dist/shadcn/r/sections.json +1 -1
- package/dist/shadcn/r/shadcn-admin-shell.json +1 -1
- package/dist/shadcn/r/shadcn-admin.json +23 -22
- package/dist/shadcn/r/sidebar-01.json +42 -0
- package/dist/shadcn/r/sidebar-02.json +42 -0
- package/dist/shadcn/r/sidebar-03.json +30 -0
- package/dist/shadcn/r/sidebar-04.json +30 -0
- package/dist/shadcn/r/sidebar-05.json +36 -0
- package/dist/shadcn/r/sidebar-06.json +42 -0
- package/dist/shadcn/r/sidebar-07.json +54 -0
- package/dist/shadcn/r/sidebar-08.json +54 -0
- package/dist/shadcn/r/sidebar-09.json +36 -0
- package/dist/shadcn/r/sidebar-10.json +66 -0
- package/dist/shadcn/r/sidebar-11.json +30 -0
- package/dist/shadcn/r/sidebar-12.json +48 -0
- package/dist/shadcn/r/sidebar-13.json +30 -0
- package/dist/shadcn/r/sidebar-14.json +30 -0
- package/dist/shadcn/r/sidebar-15.json +84 -0
- package/dist/shadcn/r/sidebar-16.json +66 -0
- package/dist/shadcn/r/sidebar-drilldown.json +29 -0
- package/dist/shadcn/r/sidebar-primitives.json +155 -0
- package/dist/shadcn/r/uibot-base.json +3 -3
- package/dist/shadcn/r/workspace.json +11 -4
- package/dist/shadcn/registry.json +1016 -176
- package/dist/shadcn.d.ts +0 -39
- package/dist/solution-composition.d.ts +45 -0
- package/dist/solution-regions.d.ts +3 -0
- package/dist/solution-spec.d.ts +7 -0
- package/dist/template-source.d.ts +2 -0
- package/package.json +2 -2
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
"type": "registry:ui",
|
|
5
5
|
"description": "Standalone action button. Six visual variants and five sizes. Does not submit forms — use Form.Submit for that.",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"react"
|
|
7
|
+
"react@19.3.0",
|
|
8
|
+
"radix-ui@1.4.3"
|
|
8
9
|
],
|
|
9
10
|
"registryDependencies": [
|
|
10
11
|
"@uibot/uibot-base"
|
|
@@ -25,13 +26,25 @@
|
|
|
25
26
|
{
|
|
26
27
|
"path": "components/uibot/overlay.tsx",
|
|
27
28
|
"target": "components/uibot/overlay.tsx",
|
|
28
|
-
"content": "import { useEffect, useId, useRef, type ReactNode } from \"react\";\nimport type { RendererComponent } from \"@/lib/uibot-renderer\";\nimport { emit, text, type BlockContext } from \"./interaction\";\n\nfunction useNativeDialogLifecycle(\n ref: { current: HTMLDialogElement | null },\n open: boolean,\n triggerRef?: { current: HTMLElement | null },\n) {\n useEffect(() => {\n const dialog = ref.current;\n if (!dialog || !open) return;\n const trigger = triggerRef\n ? triggerRef.current\n : document.activeElement instanceof HTMLElement\n ? document.activeElement\n : null;\n dialog.showModal();\n return () => {\n if (dialog.open) dialog.close();\n if (trigger?.isConnected) trigger.focus();\n };\n }, [open, ref, triggerRef]);\n}\n\nfunction Overlay({\n props,\n ctx,\n drawer,\n blockType,\n}: {\n props: Record<string, unknown>;\n ctx: BlockContext;\n drawer: boolean;\n blockType?: \"Dialog\";\n}) {\n const ref = useRef<HTMLDialogElement>(null);\n const titleId = useId(),\n descriptionId = useId();\n const open = props.open === true;\n const close = () => emit(ctx, \"onClose\", { open: false }, false);\n useNativeDialogLifecycle(ref, open);\n if (!open) return null;\n return (\n <dialog\n ref={ref}\n aria-labelledby={titleId}\n aria-describedby={props.description ? descriptionId : undefined}\n aria-busy={props.pending === true || undefined}\n data-uibot-type={blockType ?? (drawer ? \"Drawer\" : \"Modal\")}\n className={`uibot-overlay bg-background text-foreground p-0 shadow-xl backdrop:bg-black/50 ${drawer ? \"fixed inset-y-0 start-auto end-0 m-0 h-dvh max-h-dvh w-full max-w-md border-s\" : \"m-auto w-[calc(100%-2rem)] max-w-lg rounded-xl border\"}`}\n onCancel={(e) => {\n e.preventDefault();\n if (props.pending !== true) close();\n }}\n onClick={(e) => {\n if (e.target === e.currentTarget && props.pending !== true) {\n const r = e.currentTarget.getBoundingClientRect();\n if (\n e.clientX < r.left ||\n e.clientX > r.right ||\n e.clientY < r.top ||\n e.clientY > r.bottom\n )\n close();\n }\n }}\n >\n <div className=\"flex h-full max-h-dvh flex-col\">\n <header className=\"flex items-start justify-between gap-4 border-b p-6\">\n <div>\n <h2 id={titleId} className=\"text-lg font-semibold\">\n {text(props.title, drawer ? \"Edit record\" : \"Confirm\")}\n </h2>\n {Boolean(props.description) && (\n <p id={descriptionId} className=\"mt-1 text-sm text-muted-foreground\">\n {text(props.description)}\n </p>\n )}\n </div>\n <button\n type=\"button\"\n disabled={props.pending === true}\n className=\"rounded px-2 py-1 text-sm hover:bg-muted focus-visible:ring-2\"\n aria-label=\"Close dialog\"\n onClick={close}\n >\n Close\n </button>\n </header>\n <
|
|
29
|
+
"content": "import { useEffect, useId, useRef, type ReactNode } from \"react\";\nimport type { RendererComponent } from \"@/lib/uibot-renderer\";\nimport { emit, text, type BlockContext } from \"./interaction\";\nimport { containPreviewNavigationDialog } from \"./preview-scope\";\nimport { ScrollArea } from \"./scroll-area\";\n\nfunction useNativeDialogLifecycle(\n ref: { current: HTMLDialogElement | null },\n open: boolean,\n triggerRef?: { current: HTMLElement | null },\n containNavigation = false,\n) {\n useEffect(() => {\n const dialog = ref.current;\n if (!dialog || !open) return;\n const trigger = triggerRef\n ? triggerRef.current\n : document.activeElement instanceof HTMLElement\n ? document.activeElement\n : null;\n const releaseBounds = containNavigation ? containPreviewNavigationDialog(dialog) : () => {};\n dialog.showModal();\n return () => {\n if (dialog.open) dialog.close();\n releaseBounds();\n if (trigger?.isConnected) trigger.focus();\n };\n }, [open, ref, triggerRef, containNavigation]);\n}\n\nfunction Overlay({\n props,\n ctx,\n drawer,\n blockType,\n}: {\n props: Record<string, unknown>;\n ctx: BlockContext;\n drawer: boolean;\n blockType?: \"Dialog\";\n}) {\n const ref = useRef<HTMLDialogElement>(null);\n const titleId = useId(),\n descriptionId = useId();\n const open = props.open === true;\n const close = () => emit(ctx, \"onClose\", { open: false }, false);\n useNativeDialogLifecycle(ref, open);\n if (!open) return null;\n return (\n <dialog\n ref={ref}\n aria-labelledby={titleId}\n aria-describedby={props.description ? descriptionId : undefined}\n aria-busy={props.pending === true || undefined}\n data-uibot-type={blockType ?? (drawer ? \"Drawer\" : \"Modal\")}\n className={`uibot-overlay overflow-hidden bg-background text-foreground p-0 shadow-xl backdrop:bg-black/50 ${drawer ? (props.placement === \"responsive\" ? \"fixed inset-x-0 top-auto bottom-0 m-0 h-[90dvh] max-h-[90dvh] w-full max-w-none rounded-t-xl border sm:inset-y-0 sm:start-auto sm:end-0 sm:h-dvh sm:max-h-dvh sm:max-w-md sm:rounded-none sm:border-s\" : \"fixed inset-y-0 start-auto end-0 m-0 h-dvh max-h-dvh w-full max-w-md border-s\") : \"m-auto w-[calc(100%-2rem)] max-w-lg rounded-xl border\"}`}\n onCancel={(e) => {\n e.preventDefault();\n if (props.pending !== true) close();\n }}\n onClick={(e) => {\n if (e.target === e.currentTarget && props.pending !== true) {\n const r = e.currentTarget.getBoundingClientRect();\n if (\n e.clientX < r.left ||\n e.clientX > r.right ||\n e.clientY < r.top ||\n e.clientY > r.bottom\n )\n close();\n }\n }}\n >\n <div className=\"flex h-full max-h-dvh flex-col\">\n <header className=\"flex items-start justify-between gap-4 border-b p-6\">\n <div>\n <h2 id={titleId} className=\"text-lg font-semibold\">\n {text(props.title, drawer ? \"Edit record\" : \"Confirm\")}\n </h2>\n {Boolean(props.description) && (\n <p id={descriptionId} className=\"mt-1 text-sm text-muted-foreground\">\n {text(props.description)}\n </p>\n )}\n </div>\n <button\n type=\"button\"\n disabled={props.pending === true}\n className=\"rounded px-2 py-1 text-sm hover:bg-muted focus-visible:ring-2\"\n aria-label=\"Close dialog\"\n onClick={close}\n >\n Close\n </button>\n </header>\n <ScrollArea\n className=\"min-h-0 flex-1\"\n viewportProps={{ className: \"p-6\", \"aria-label\": text(props.title, \"Dialog content\") }}\n >\n {ctx.children as ReactNode[]}\n </ScrollArea>\n {ctx.slots.footer && (\n <footer className=\"flex justify-end gap-2 border-t p-6\">\n {ctx.slots.footer as ReactNode[]}\n </footer>\n )}\n </div>\n </dialog>\n );\n}\nexport const LiveDrawer: RendererComponent = (props, ctx) => (\n <Overlay props={props} ctx={ctx} drawer />\n);\nexport const LiveModal: RendererComponent = (props, ctx) => (\n <Overlay props={props} ctx={ctx} drawer={false} />\n);\nexport const LiveConfirmationDialog: RendererComponent = (props, ctx) => (\n <Overlay props={props} ctx={ctx} drawer={false} blockType=\"Dialog\" />\n);\n\n/** Internal mobile navigation drawer shared by renderer blocks, not a Spec component. */\nexport function SidebarDrawer({\n id,\n open,\n onClose,\n triggerRef,\n children,\n}: {\n id: string;\n open: boolean;\n onClose: () => void;\n triggerRef: { current: HTMLButtonElement | null };\n children: ReactNode;\n}) {\n const ref = useRef<HTMLDialogElement>(null);\n useNativeDialogLifecycle(ref, open, triggerRef, true);\n\n if (!open) return null;\n return (\n <dialog\n id={id}\n ref={ref}\n aria-label=\"Navigation\"\n className=\"fixed inset-y-0 start-0 z-50 m-0 h-dvh max-h-dvh w-72 max-w-[85vw] border-r bg-background p-0 text-foreground shadow-xl backdrop:bg-black/50\"\n onCancel={(event) => {\n event.preventDefault();\n onClose();\n }}\n onClick={(event) => {\n if (event.target === event.currentTarget) {\n const bounds = event.currentTarget.getBoundingClientRect();\n if (\n event.clientX < bounds.left ||\n event.clientX > bounds.right ||\n event.clientY < bounds.top ||\n event.clientY > bounds.bottom\n )\n onClose();\n }\n if (\n event.target instanceof Element &&\n event.target.closest('a, button[data-uibot-type=\"MenuLink\"]') &&\n !event.metaKey &&\n !event.ctrlKey &&\n !event.shiftKey &&\n !event.altKey &&\n event.button === 0\n )\n onClose();\n }}\n >\n <button\n type=\"button\"\n className=\"m-3 rounded border px-3 py-2 text-sm focus-visible:ring-2\"\n aria-label=\"Close navigation\"\n onClick={onClose}\n >\n Close\n </button>\n <ScrollArea\n style={{ height: \"calc(100% - 4rem)\" }}\n viewportProps={{ \"aria-label\": \"Navigation links\" }}\n >\n {children}\n </ScrollArea>\n </dialog>\n );\n}\n",
|
|
30
|
+
"type": "registry:ui"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"path": "components/uibot/preview-scope.ts",
|
|
34
|
+
"target": "components/uibot/preview-scope.ts",
|
|
35
|
+
"content": "/**\n * Page frames (`PageLayout`) fill the viewport so only their main area scrolls. Hosts that embed a\n * rendered page in a smaller pane mark the pane with `data-uibot-preview-scope`; inside it the frame\n * fills the pane instead of the viewport: wrappers between the pane and the frame become a flex column\n * chain, so a pane that is a flex column with a definite height hands the frame exactly the space\n * left under any sibling (such as a notice strip). Without such a pane the frame falls back to\n * `height:100%`, and to content height when that is not definite either. The pane also becomes the\n * containing block for fixed-position content such as floating toasts. Native modal navigation\n * escapes that containment and uses containPreviewNavigationDialog for its visible bounds.\n */\nexport const PREVIEW_SCOPE_CSS =\n \"[data-uibot-preview-dialog]::backdrop{clip-path:inset(var(--uibot-preview-backdrop-inset))}[data-uibot-preview-scope]{contain:layout}[data-uibot-preview-scope] .uibot-admin,[data-uibot-preview-scope] .uibot-page-layout{height:100%;min-height:0;flex:1 1 0}[data-uibot-preview-scope] div:has(.uibot-admin),[data-uibot-preview-scope] div:has(.uibot-page-layout){display:flex;flex-direction:column;min-height:0;flex:1 1 0}\";\n\n/**\n * shadcn/ui Scroll Area look for every scroll container inside a page frame (content area, sidebar,\n * table wrappers, dialogs): a slim 10px track with a rounded, theme-aware thumb. This styles the\n * native scrollbar so it matches shadcn's `ScrollArea`; it does not load Radix.\n */\nexport const SCROLLBAR_CSS =\n \".uibot-admin,.uibot-admin *,.uibot-page-layout,.uibot-page-layout *{scrollbar-width:thin;scrollbar-color:color-mix(in srgb,currentColor 28%,transparent) transparent}.uibot-admin ::-webkit-scrollbar,.uibot-page-layout ::-webkit-scrollbar{width:10px;height:10px}.uibot-admin ::-webkit-scrollbar-track,.uibot-page-layout ::-webkit-scrollbar-track{background:transparent}.uibot-admin ::-webkit-scrollbar-thumb,.uibot-page-layout ::-webkit-scrollbar-thumb{border:2px solid transparent;border-radius:9999px;background:color-mix(in srgb,currentColor 28%,transparent);background-clip:padding-box}.uibot-admin ::-webkit-scrollbar-thumb:hover,.uibot-page-layout ::-webkit-scrollbar-thumb:hover{background:color-mix(in srgb,currentColor 45%,transparent);background-clip:padding-box}.uibot-admin ::-webkit-scrollbar-corner,.uibot-page-layout ::-webkit-scrollbar-corner{background:transparent}\";\n\n/** Native modal dialogs escape layout containment; navigation stays in its host preview. */\nexport function containPreviewNavigationDialog(dialog: HTMLDialogElement, inset = 0): () => void {\n const scope = dialog.closest<HTMLElement>(\"[data-uibot-preview-scope]\");\n if (!scope) return () => {};\n const originalStyle = dialog.getAttribute(\"style\");\n const originalVisibility = dialog.style.visibility;\n const originalMarker = dialog.getAttribute(\"data-uibot-preview-dialog\");\n dialog.setAttribute(\"data-uibot-preview-dialog\", \"\");\n let active = true;\n const sync = () => {\n if (!active) return;\n const rect = scope.getBoundingClientRect();\n const left = Math.max(0, rect.left),\n top = Math.max(0, rect.top);\n const right = Math.min(window.innerWidth, rect.right);\n const bottom = Math.min(window.innerHeight, rect.bottom);\n const width = right - left,\n height = bottom - top;\n if (width <= 0 || height <= 0) {\n dialog.style.visibility = \"hidden\";\n dialog.style.setProperty(\"--uibot-preview-backdrop-inset\", \"100% 100% 0px 0px\");\n return;\n }\n dialog.style.visibility = originalVisibility;\n const gap = Math.min(inset, width / 4, height / 4);\n const maxWidth = Math.max(0, Math.min(width * 0.85, width - gap * 2));\n const rtl = getComputedStyle(dialog).direction === \"rtl\";\n Object.assign(dialog.style, {\n position: \"fixed\",\n top: `${top + gap}px`,\n bottom: \"auto\",\n left: rtl ? \"auto\" : `${left + gap}px`,\n right: rtl ? `${window.innerWidth - right + gap}px` : \"auto\",\n height: `${height - gap * 2}px`,\n maxHeight: `${height - gap * 2}px`,\n maxWidth: `${maxWidth}px`,\n margin: \"0px\",\n });\n dialog.style.setProperty(\n \"--uibot-preview-backdrop-inset\",\n `${top}px ${window.innerWidth - right}px ${window.innerHeight - bottom}px ${left}px`,\n );\n };\n sync();\n const observer = typeof ResizeObserver === \"undefined\" ? undefined : new ResizeObserver(sync);\n observer?.observe(scope);\n window.addEventListener(\"resize\", sync);\n window.addEventListener(\"scroll\", sync, true);\n return () => {\n active = false;\n observer?.disconnect();\n window.removeEventListener(\"resize\", sync);\n window.removeEventListener(\"scroll\", sync, true);\n if (originalStyle === null) dialog.removeAttribute(\"style\");\n else dialog.setAttribute(\"style\", originalStyle);\n if (originalMarker === null) dialog.removeAttribute(\"data-uibot-preview-dialog\");\n else dialog.setAttribute(\"data-uibot-preview-dialog\", originalMarker);\n };\n}\n",
|
|
36
|
+
"type": "registry:ui"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"path": "components/uibot/scroll-area.tsx",
|
|
40
|
+
"target": "components/uibot/scroll-area.tsx",
|
|
41
|
+
"content": "// Adapted from shadcn/ui Scroll Area (MIT).\nimport type { ComponentProps } from \"react\";\nimport { ScrollArea as Primitive } from \"radix-ui\";\n\nconst styles = `\n.uibot-scroll-area{position:relative;min-width:0;min-height:0;overflow:hidden}\n.uibot-scroll-viewport{width:100%;height:100%;max-height:inherit;border-radius:inherit;outline:none}\n.uibot-scroll-viewport:focus-visible{outline:2px solid var(--ring,#94a3b8);outline-offset:-2px}\n.uibot-scroll-viewport>div{display:block!important;min-width:100%}\n.uibot-scroll-area[data-fill-content=true]>.uibot-scroll-viewport>div{display:flex!important;flex-direction:column;min-height:100%}\n.uibot-scroll-area[data-scrollbars=horizontal]>.uibot-scroll-viewport{height:auto}\n.uibot-scrollbar{display:flex;touch-action:none;user-select:none;padding:1px;z-index:20}\n.uibot-scrollbar[data-orientation=vertical]{width:10px;border-inline-start:1px solid transparent}\n.uibot-scrollbar[data-orientation=horizontal]{height:10px;flex-direction:column;border-top:1px solid transparent}\n.uibot-scroll-thumb{position:relative;flex:1;border-radius:9999px;background:var(--nui-border,var(--border,#d4d4d8))}\n.uibot-scroll-thumb:hover,.uibot-scrollbar[data-state=visible]:active .uibot-scroll-thumb{background:var(--muted-foreground,#71717a)}\n`;\n\n/** Shared presentation primitive; refs and scroll events belong to the actual viewport. */\nexport function ScrollArea({\n children,\n className,\n scrollbars = \"vertical\",\n viewportProps,\n fillContent = false,\n ...props\n}: ComponentProps<typeof Primitive.Root> & {\n scrollbars?: \"vertical\" | \"horizontal\" | \"both\";\n viewportProps?: ComponentProps<typeof Primitive.Viewport>;\n fillContent?: boolean;\n}) {\n const { className: viewportClassName, ...viewportRest } = viewportProps ?? {};\n return (\n <Primitive.Root\n data-slot=\"scroll-area\"\n data-scrollbars={scrollbars}\n data-fill-content={fillContent}\n className={`uibot-scroll-area ${className ?? \"\"}`}\n type=\"auto\"\n {...props}\n >\n <style>{styles}</style>\n <Primitive.Viewport\n data-slot=\"scroll-area-viewport\"\n className={`uibot-scroll-viewport ${viewportClassName ?? \"\"}`}\n tabIndex={0}\n {...viewportRest}\n >\n {children}\n </Primitive.Viewport>\n {scrollbars !== \"horizontal\" && <ScrollBar />}\n {scrollbars !== \"vertical\" && <ScrollBar orientation=\"horizontal\" />}\n <Primitive.Corner />\n </Primitive.Root>\n );\n}\n\nexport function ScrollBar({\n className,\n orientation = \"vertical\",\n ...props\n}: ComponentProps<typeof Primitive.Scrollbar>) {\n return (\n <Primitive.Scrollbar\n data-slot=\"scroll-area-scrollbar\"\n orientation={orientation}\n className={`uibot-scrollbar ${className ?? \"\"}`}\n {...props}\n >\n <Primitive.Thumb data-slot=\"scroll-area-thumb\" className=\"uibot-scroll-thumb\" />\n </Primitive.Scrollbar>\n );\n}\n",
|
|
29
42
|
"type": "registry:ui"
|
|
30
43
|
},
|
|
31
44
|
{
|
|
32
45
|
"path": "components/uibot/feedback.uibot.json",
|
|
33
46
|
"target": "components/uibot/feedback.uibot.json",
|
|
34
|
-
"content": "{\n \"schema\": \"uibot.registry.item.v1\",\n \"item\": \"feedback\",\n \"channel\": \"public\",\n \"components\": [\n {\n \"name\": \"Button\",\n \"export\": \"Button\",\n \"module\": \"feedback.tsx\",\n \"catalog\": {\n \"name\": \"Button\",\n \"description\": \"Standalone action button. Six visual variants and five sizes. Does not submit forms — use Form.Submit for that.\",\n \"category\": \"primitive\",\n \"level\": \"L1\",\n \"tags\": [\n \"button\",\n \"action\"\n ],\n \"props\": {\n \"label\": {\n \"type\": \"string\"\n },\n \"variant\": {\n \"type\": \"string\",\n \"enum\": [\n \"default\",\n \"destructive\",\n \"outline\",\n \"secondary\",\n \"ghost\",\n \"link\"\n ],\n \"default\": \"default\"\n },\n \"size\": {\n \"type\": \"string\",\n \"enum\": [\n \"xs\",\n \"sm\",\n \"default\",\n \"lg\",\n \"icon\"\n ],\n \"default\": \"default\"\n },\n \"full\": {\n \"type\": \"boolean\",\n \"default\": false\n },\n \"disabled\": {\n \"type\": \"boolean\",\n \"default\": false\n }\n },\n \"events\": {\n \"onClick\": {\n \"description\": \"Runs with a plain click payload.\"\n }\n },\n \"usageScenarios\": [\n \"Primary CTA on a hero section\",\n \"Row of outline action buttons in a Card actions slot\",\n \"Ghost icon button in a toolbar\"\n ],\n \"constraints\": [\n \"Use Form.Submit, not Button[type=submit], inside a Form\",\n \"Do not place more than 3 primary (default) buttons on the same view\"\n ]\n }\n },\n {\n \"name\": \"Dialog\",\n \"export\": \"Dialog\",\n \"module\": \"feedback.tsx\",\n \"catalog\": {\n \"name\": \"Dialog\",\n \"description\": \"Confirmation with explicit action intents. Boolean open uses a native modal; omitted open keeps an inline composition.\",\n \"category\": \"composite\",\n \"level\": \"L2\",\n \"tags\": [\n \"dialog\",\n \"modal\",\n \"confirm\"\n ],\n \"props\": {\n \"open\": {\n \"type\": \"boolean\",\n \"description\": \"Omit for inline.\"\n },\n \"pending\": {\n \"type\": \"boolean\",\n \"description\": \"Lock actions/dismissal.\"\n },\n \"title\": {\n \"type\": \"string\"\n },\n \"description\": {\n \"type\": \"string\"\n },\n \"cancelLabel\": {\n \"type\": \"string\"\n },\n \"confirmLabel\": {\n \"type\": \"string\"\n },\n \"confirmVariant\": {\n \"type\": \"string\",\n \"enum\": [\n \"default\",\n \"destructive\",\n \"outline\"\n ],\n \"default\": \"default\"\n }\n },\n \"events\": {\n \"onConfirm\": {\n \"description\": \"value=values.action=confirm.\"\n },\n \"onCancel\": {\n \"description\": \"value=values.action=cancel.\"\n },\n \"onClose\": {\n \"description\": \"Dismiss: value=values.open=false.\"\n }\n },\n \"usageScenarios\": [\n \"Delete confirmation prompt\",\n \"Unsaved changes warning before navigation\"\n ],\n \"constraints\": [\n \"Host owns open/pending and persistence; no automatic close/write/retry.\"\n ]\n }\n },\n {\n \"name\": \"Skeleton\",\n \"export\": \"Skeleton\",\n \"module\": \"feedback.tsx\",\n \"catalog\": {\n \"name\": \"Skeleton\",\n \"description\": \"Animated loading placeholder. Three presets: lines (text), card (avatar + lines), table (header + rows).\",\n \"category\": \"primitive\",\n \"level\": \"L1\",\n \"tags\": [\n \"skeleton\",\n \"loading\",\n \"placeholder\"\n ],\n \"props\": {\n \"lines\": {\n \"type\": \"integer\",\n \"default\": 3,\n \"description\": \"Number of skeleton rows (for lines and table types)\"\n },\n \"type\": {\n \"type\": \"string\",\n \"enum\": [\n \"lines\",\n \"card\",\n \"table\"\n ],\n \"default\": \"lines\"\n }\n },\n \"usageScenarios\": [\n \"Loading state while fetching table data\",\n \"Card placeholder during profile load\"\n ],\n \"constraints\": [\n \"Replace with real content once data loads; do not keep Skeleton visible indefinitely\"\n ]\n }\n },\n {\n \"name\": \"Toast\",\n \"export\": \"Toast\",\n \"module\": \"feedback.tsx\",\n \"catalog\": {\n \"name\": \"Toast\",\n \"description\": \"Alert banner (info, success, warning, error); placement top-right floats it as a dismissible corner notice.\",\n \"category\": \"primitive\",\n \"level\": \"L1\",\n \"tags\": [\n \"toast\",\n \"alert\",\n \"notification\"\n ],\n \"props\": {\n \"message\": {\n \"type\": \"string\"\n },\n \"title\": {\n \"type\": \"string\"\n },\n \"level\": {\n \"type\": \"string\",\n \"enum\": [\n \"info\",\n \"success\",\n \"warning\",\n \"error\"\n ],\n \"default\": \"info\"\n },\n \"closeable\": {\n \"type\": \"boolean\",\n \"default\": true\n },\n \"placement\": {\n \"type\": \"string\",\n \"enum\": [\n \"inline\",\n \"top-right\"\n ],\n \"default\": \"inline\"\n },\n \"duration\": {\n \"type\": \"number\",\n \"description\": \"Auto-dismiss after ms\"\n }\n },\n \"usageScenarios\": [\n \"
|
|
47
|
+
"content": "{\n \"schema\": \"uibot.registry.item.v1\",\n \"item\": \"feedback\",\n \"channel\": \"public\",\n \"components\": [\n {\n \"name\": \"Button\",\n \"export\": \"Button\",\n \"module\": \"feedback.tsx\",\n \"catalog\": {\n \"name\": \"Button\",\n \"description\": \"Standalone action button. Six visual variants and five sizes. Does not submit forms — use Form.Submit for that.\",\n \"category\": \"primitive\",\n \"level\": \"L1\",\n \"tags\": [\n \"button\",\n \"action\"\n ],\n \"props\": {\n \"label\": {\n \"type\": \"string\"\n },\n \"variant\": {\n \"type\": \"string\",\n \"enum\": [\n \"default\",\n \"destructive\",\n \"outline\",\n \"secondary\",\n \"ghost\",\n \"link\"\n ],\n \"default\": \"default\"\n },\n \"size\": {\n \"type\": \"string\",\n \"enum\": [\n \"xs\",\n \"sm\",\n \"default\",\n \"lg\",\n \"icon\"\n ],\n \"default\": \"default\"\n },\n \"full\": {\n \"type\": \"boolean\",\n \"default\": false\n },\n \"disabled\": {\n \"type\": \"boolean\",\n \"default\": false\n }\n },\n \"events\": {\n \"onClick\": {\n \"description\": \"Runs with a plain click payload.\"\n }\n },\n \"usageScenarios\": [\n \"Primary CTA on a hero section\",\n \"Row of outline action buttons in a Card actions slot\",\n \"Ghost icon button in a toolbar\"\n ],\n \"constraints\": [\n \"Use Form.Submit, not Button[type=submit], inside a Form\",\n \"Do not place more than 3 primary (default) buttons on the same view\"\n ]\n }\n },\n {\n \"name\": \"Dialog\",\n \"export\": \"Dialog\",\n \"module\": \"feedback.tsx\",\n \"catalog\": {\n \"name\": \"Dialog\",\n \"description\": \"Confirmation with explicit action intents. Boolean open uses a native modal; omitted open keeps an inline composition.\",\n \"category\": \"composite\",\n \"level\": \"L2\",\n \"tags\": [\n \"dialog\",\n \"modal\",\n \"confirm\"\n ],\n \"props\": {\n \"open\": {\n \"type\": \"boolean\",\n \"description\": \"Omit for inline.\"\n },\n \"pending\": {\n \"type\": \"boolean\",\n \"description\": \"Lock actions/dismissal.\"\n },\n \"title\": {\n \"type\": \"string\"\n },\n \"description\": {\n \"type\": \"string\"\n },\n \"cancelLabel\": {\n \"type\": \"string\"\n },\n \"confirmLabel\": {\n \"type\": \"string\"\n },\n \"confirmVariant\": {\n \"type\": \"string\",\n \"enum\": [\n \"default\",\n \"destructive\",\n \"outline\"\n ],\n \"default\": \"default\"\n }\n },\n \"events\": {\n \"onConfirm\": {\n \"description\": \"value=values.action=confirm.\"\n },\n \"onCancel\": {\n \"description\": \"value=values.action=cancel.\"\n },\n \"onClose\": {\n \"description\": \"Dismiss: value=values.open=false.\"\n }\n },\n \"usageScenarios\": [\n \"Delete confirmation prompt\",\n \"Unsaved changes warning before navigation\"\n ],\n \"constraints\": [\n \"Host owns open/pending and persistence; no automatic close/write/retry.\"\n ]\n }\n },\n {\n \"name\": \"Skeleton\",\n \"export\": \"Skeleton\",\n \"module\": \"feedback.tsx\",\n \"catalog\": {\n \"name\": \"Skeleton\",\n \"description\": \"Animated loading placeholder. Three presets: lines (text), card (avatar + lines), table (header + rows).\",\n \"category\": \"primitive\",\n \"level\": \"L1\",\n \"tags\": [\n \"skeleton\",\n \"loading\",\n \"placeholder\"\n ],\n \"props\": {\n \"lines\": {\n \"type\": \"integer\",\n \"default\": 3,\n \"description\": \"Number of skeleton rows (for lines and table types)\"\n },\n \"type\": {\n \"type\": \"string\",\n \"enum\": [\n \"lines\",\n \"card\",\n \"table\"\n ],\n \"default\": \"lines\"\n }\n },\n \"usageScenarios\": [\n \"Loading state while fetching table data\",\n \"Card placeholder during profile load\"\n ],\n \"constraints\": [\n \"Replace with real content once data loads; do not keep Skeleton visible indefinitely\"\n ]\n }\n },\n {\n \"name\": \"Toast\",\n \"export\": \"Toast\",\n \"module\": \"feedback.tsx\",\n \"catalog\": {\n \"name\": \"Toast\",\n \"description\": \"Alert banner (info, success, warning, error); placement top-right floats it as a dismissible corner notice.\",\n \"category\": \"primitive\",\n \"level\": \"L1\",\n \"tags\": [\n \"toast\",\n \"alert\",\n \"notification\"\n ],\n \"props\": {\n \"message\": {\n \"type\": \"string\"\n },\n \"title\": {\n \"type\": \"string\"\n },\n \"level\": {\n \"type\": \"string\",\n \"enum\": [\n \"info\",\n \"success\",\n \"warning\",\n \"error\"\n ],\n \"default\": \"info\"\n },\n \"closeable\": {\n \"type\": \"boolean\",\n \"default\": true\n },\n \"placement\": {\n \"type\": \"string\",\n \"enum\": [\n \"inline\",\n \"top-right\"\n ],\n \"default\": \"inline\"\n },\n \"duration\": {\n \"type\": \"number\",\n \"description\": \"Auto-dismiss after ms\"\n }\n },\n \"usageScenarios\": [\n \"Transient success message after form submit\",\n \"Contextual inline data notice\"\n ],\n \"constraints\": [\n \"Floating notices must auto-dismiss; keep persistent disclosure inline, clear of navigation and controls\"\n ]\n }\n }\n ]\n}\n",
|
|
35
48
|
"type": "registry:ui"
|
|
36
49
|
}
|
|
37
50
|
],
|
|
@@ -317,11 +330,11 @@
|
|
|
317
330
|
}
|
|
318
331
|
},
|
|
319
332
|
"usageScenarios": [
|
|
320
|
-
"
|
|
321
|
-
"
|
|
333
|
+
"Transient success message after form submit",
|
|
334
|
+
"Contextual inline data notice"
|
|
322
335
|
],
|
|
323
336
|
"constraints": [
|
|
324
|
-
"
|
|
337
|
+
"Floating notices must auto-dismiss; keep persistent disclosure inline, clear of navigation and controls"
|
|
325
338
|
]
|
|
326
339
|
}
|
|
327
340
|
}
|
package/dist/shadcn/r/field.json
CHANGED
package/dist/shadcn/r/form.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"type": "registry:ui",
|
|
5
5
|
"description": "Form wrapper that prevents default submission. Place Form.Input, Form.Select, etc. as children and end with Form.Submit.",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"react",
|
|
8
|
-
"radix-ui",
|
|
9
|
-
"react-day-picker"
|
|
7
|
+
"react@19.3.0",
|
|
8
|
+
"radix-ui@1.4.3",
|
|
9
|
+
"react-day-picker@9.14.0"
|
|
10
10
|
],
|
|
11
11
|
"registryDependencies": [
|
|
12
12
|
"@uibot/uibot-base"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
{
|
|
22
22
|
"path": "components/uibot/form-controls.tsx",
|
|
23
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",
|
|
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/** Preserve the native modal's top layer, or the owning frame's theme. */\nfunction useThemeContainer() {\n const [container, setContainer] = useState<HTMLElement | undefined>(undefined);\n const ref = useCallback((node: HTMLElement | null) => {\n setContainer(\n (node?.closest(\"dialog, [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 [internalValue, setInternalValue] = useState(props.defaultValue ?? \"\");\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 dir={container?.closest(\"[dir]\")?.getAttribute(\"dir\") === \"rtl\" ? \"rtl\" : \"ltr\"}\n {...(props.value !== undefined\n ? { value: props.value }\n : props.defaultValue\n ? { defaultValue: props.defaultValue }\n : {})}\n {...(props.required ? { required: true } : {})}\n {...(props.disabled ? { disabled: true } : {})}\n onValueChange={(value) => {\n setInternalValue(value);\n props.onValueChange?.(value, triggerEl.current as HTMLElement);\n }}\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 {options.find((option) => option.value === (props.value ?? internalValue))?.label}\n </SelectPrimitive.Value>\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
25
|
"type": "registry:ui"
|
|
26
26
|
},
|
|
27
27
|
{
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
{
|
|
34
34
|
"path": "components/uibot/form.uibot.json",
|
|
35
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\": \"
|
|
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\": \"Stable event.value idempotency key for unchanged-value retries\"\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\": \"Two-way {_bindState:'path'}.\"\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\": \"Unique form field name\"\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\": \"Two-way {_bindState:'path'}.\"\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\": \"Two-way {_bindState:'path'}.\"\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 \"disabled\": {\n \"type\": \"boolean\",\n \"default\": false\n },\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\": \"Two-way {_bindState:'path'}.\"\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
37
|
"type": "registry:ui"
|
|
38
38
|
}
|
|
39
39
|
],
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"props": {
|
|
44
44
|
"idempotent": {
|
|
45
45
|
"type": "boolean",
|
|
46
|
-
"description": "
|
|
46
|
+
"description": "Stable event.value idempotency key for unchanged-value retries"
|
|
47
47
|
},
|
|
48
48
|
"pending": {
|
|
49
49
|
"type": "boolean"
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"props": {
|
|
111
111
|
"idempotent": {
|
|
112
112
|
"type": "boolean",
|
|
113
|
-
"description": "
|
|
113
|
+
"description": "Stable event.value idempotency key for unchanged-value retries"
|
|
114
114
|
},
|
|
115
115
|
"pending": {
|
|
116
116
|
"type": "boolean"
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
},
|
|
176
176
|
"checked": {
|
|
177
177
|
"type": "boolean",
|
|
178
|
-
"description": "
|
|
178
|
+
"description": "Two-way {_bindState:'path'}."
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
181
|
"events": {
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
"props": {
|
|
207
207
|
"name": {
|
|
208
208
|
"type": "string",
|
|
209
|
-
"description": "
|
|
209
|
+
"description": "Unique form field name"
|
|
210
210
|
},
|
|
211
211
|
"label": {
|
|
212
212
|
"type": "string"
|
|
@@ -244,7 +244,7 @@
|
|
|
244
244
|
},
|
|
245
245
|
"value": {
|
|
246
246
|
"type": "string",
|
|
247
|
-
"description": "
|
|
247
|
+
"description": "Two-way {_bindState:'path'}."
|
|
248
248
|
}
|
|
249
249
|
},
|
|
250
250
|
"events": {
|
|
@@ -306,7 +306,7 @@
|
|
|
306
306
|
},
|
|
307
307
|
"value": {
|
|
308
308
|
"type": "string",
|
|
309
|
-
"description": "
|
|
309
|
+
"description": "Two-way {_bindState:'path'}."
|
|
310
310
|
}
|
|
311
311
|
},
|
|
312
312
|
"events": {
|
|
@@ -408,7 +408,7 @@
|
|
|
408
408
|
},
|
|
409
409
|
"value": {
|
|
410
410
|
"type": "string",
|
|
411
|
-
"description": "
|
|
411
|
+
"description": "Two-way {_bindState:'path'}."
|
|
412
412
|
}
|
|
413
413
|
},
|
|
414
414
|
"events": {
|
package/dist/shadcn/r/grid.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "registry:ui",
|
|
5
5
|
"description": "Table with a built-in search box. Typing dispatches SetState onto searchKey and filters the resolved rows (case-insensitive substring across all columns).",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"react"
|
|
7
|
+
"react@19.3.0"
|
|
8
8
|
],
|
|
9
9
|
"registryDependencies": [
|
|
10
10
|
"@uibot/uibot-base"
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "item-grid",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "Public-facing collection of whole-card buttons with optional images, local search and category filters. Use for browsable pets, products or projects instead of duplicating cards and a management table. No data writes.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"react@19.3.0"
|
|
8
|
+
],
|
|
9
|
+
"registryDependencies": [
|
|
10
|
+
"@uibot/uibot-base"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
{
|
|
14
|
+
"path": "components/uibot/item-grid.tsx",
|
|
15
|
+
"target": "components/uibot/item-grid.tsx",
|
|
16
|
+
"content": "import { useId, useState } from \"react\";\nimport type { RendererComponent } from \"@/lib/uibot-renderer\";\nimport { emit, records, text } from \"./interaction\";\n\nexport interface GridItem {\n id: string;\n title: string;\n description: string;\n category: string;\n meta: string;\n image: string;\n imageAlt: string;\n}\n\nexport function readGridItems(value: unknown): GridItem[] {\n const seen = new Set<string>();\n return records(value).flatMap((row) => {\n if (typeof row.id !== \"string\" || !row.id || seen.has(row.id)) return [];\n seen.add(row.id);\n return [\n {\n id: row.id,\n title: text(row.title),\n description: text(row.description),\n category: text(row.category),\n meta: text(row.meta),\n image:\n typeof row.image === \"string\" && /^(https?:\\/\\/|data:image\\/|\\/)/i.test(row.image)\n ? row.image\n : \"\",\n imageAlt: text(row.imageAlt),\n },\n ];\n });\n}\n\nexport function filterGridItems(items: GridItem[], query: string, category: string): GridItem[] {\n const needle = query.trim().toLocaleLowerCase();\n return items.filter(\n (item) =>\n (!category || item.category === category) &&\n (!needle ||\n [item.title, item.description, item.meta].some((value) =>\n value.toLocaleLowerCase().includes(needle),\n )),\n );\n}\n\nconst CSS = `\n.uibot-item-grid{container-type:inline-size;min-width:0}\n.uibot-item-grid-controls{display:flex;flex-wrap:wrap;align-items:center;gap:12px;margin-bottom:24px}\n.uibot-item-grid input{flex:1 1 220px;min-width:0;min-height:44px;border:1px solid var(--border);border-radius:999px;padding:10px 18px;background:var(--card);font:inherit}\n.uibot-item-grid-filters{display:flex;flex-wrap:wrap;gap:8px}\n.uibot-item-grid-filters button{min-height:44px;padding:8px 20px;border:1px solid var(--border);border-radius:999px;background:transparent;font:inherit}\n.uibot-item-grid-filters button[aria-pressed=true]{background:var(--primary);color:var(--primary-foreground);border-color:var(--primary)}\n.uibot-item-grid-list{display:grid;grid-template-columns:minmax(0,1fr);gap:24px;list-style:none;margin:0;padding:0}\n@container (min-width:560px){.uibot-item-grid-list{grid-template-columns:repeat(2,minmax(0,1fr))}}\n@container (min-width:960px){.uibot-item-grid-list[data-columns=\"3\"]{grid-template-columns:repeat(3,minmax(0,1fr))}}\n.uibot-item-grid li{min-width:0}\n.uibot-item-grid-card{display:flex;flex-direction:column;width:100%;height:100%;overflow:hidden;border:1px solid var(--border);border-radius:18px;background:var(--card);color:var(--card-foreground);text-align:start;font:inherit;padding:0}\nbutton.uibot-item-grid-card{cursor:pointer}\n.uibot-item-grid button:focus-visible,.uibot-item-grid input:focus-visible{outline:3px solid var(--ring,var(--primary));outline-offset:4px}\nbutton.uibot-item-grid-card:hover{border-color:var(--primary)}\n.uibot-item-grid-card img{width:100%;aspect-ratio:4/3;object-fit:cover;display:block;background:var(--muted)}\n.uibot-item-grid-copy{display:flex;flex:1;flex-direction:column;gap:10px;padding:24px}\n.uibot-item-grid-meta{display:flex;justify-content:space-between;flex-wrap:wrap;gap:8px;font-size:13px;color:var(--muted-foreground)}\n.uibot-item-grid-title{font-size:24px;font-weight:600;line-height:1.25}\n.uibot-item-grid-description{font-size:15px;line-height:1.7;color:var(--muted-foreground)}\n.uibot-item-grid-action{padding-top:12px;margin-top:auto;font-size:14px;font-weight:600;color:var(--primary)}\n.uibot-item-grid-empty{padding:32px 0;color:var(--muted-foreground)}\n`;\n\n/** A single searchable collection; all card content activates the declared item event. */\nexport const ItemGrid: RendererComponent = (props, ctx) => {\n const searchId = useId();\n const [query, setQuery] = useState(\"\");\n const [category, setCategory] = useState(\"\");\n const items = readGridItems(props.items);\n const categories = [...new Set(items.map((item) => item.category).filter(Boolean))];\n const activeCategory = categories.includes(category) ? category : \"\";\n const visible = filterGridItems(\n items,\n props.searchable === true ? query : \"\",\n props.filterable === true ? activeCategory : \"\",\n );\n const selectable = Boolean(\n (ctx.element as { events?: Record<string, unknown> }).events?.onSelect,\n );\n return (\n <section\n className=\"uibot-item-grid\"\n data-uibot-type=\"ItemGrid\"\n aria-label={text(props.label, \"Items\")}\n >\n <style>{CSS}</style>\n {(props.searchable === true || props.filterable === true) && (\n <div className=\"uibot-item-grid-controls\">\n {props.searchable === true && (\n <input\n id={searchId}\n type=\"search\"\n aria-label={text(props.searchPlaceholder, \"Search items\")}\n placeholder={text(props.searchPlaceholder, \"Search items\")}\n value={query}\n onChange={(event) => setQuery(event.currentTarget.value)}\n />\n )}\n {props.filterable === true && categories.length > 0 && (\n <div\n className=\"uibot-item-grid-filters\"\n role=\"group\"\n aria-label={text(props.filterLabel, \"Category\")}\n >\n {[\"\", ...categories].map((value) => (\n <button\n key={value}\n type=\"button\"\n aria-pressed={activeCategory === value}\n onClick={() => setCategory(value)}\n >\n {value || text(props.allLabel, \"All\")}\n </button>\n ))}\n </div>\n )}\n </div>\n )}\n <ul className=\"uibot-item-grid-list\" data-columns={props.columns === \"2\" ? \"2\" : \"3\"}>\n {visible.map((item) => {\n const content = (\n <>\n {item.image && <img src={item.image} alt={item.imageAlt} loading=\"lazy\" />}\n <span className=\"uibot-item-grid-copy\">\n {(item.category || item.meta) && (\n <span className=\"uibot-item-grid-meta\">\n <span>{item.category}</span>\n <span>{item.meta}</span>\n </span>\n )}\n <span className=\"uibot-item-grid-title\">{item.title}</span>\n {item.description && (\n <span className=\"uibot-item-grid-description\">{item.description}</span>\n )}\n {selectable && (\n <span className=\"uibot-item-grid-action\">\n {text(props.actionLabel, \"View details\")}\n </span>\n )}\n </span>\n </>\n );\n return (\n <li key={item.id}>\n {selectable ? (\n <button\n type=\"button\"\n className=\"uibot-item-grid-card\"\n aria-label={`${text(props.actionLabel, \"View details\")}: ${item.title}`}\n onClick={() => emit(ctx, \"onSelect\", { id: item.id })}\n >\n {content}\n </button>\n ) : (\n <article className=\"uibot-item-grid-card\">{content}</article>\n )}\n </li>\n );\n })}\n </ul>\n {visible.length === 0 && (\n <p role=\"status\" className=\"uibot-item-grid-empty\">\n {text(props.emptyText, \"No matching items\")}\n </p>\n )}\n </section>\n );\n};\n",
|
|
17
|
+
"type": "registry:ui"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"path": "components/uibot/interaction.ts",
|
|
21
|
+
"target": "components/uibot/interaction.ts",
|
|
22
|
+
"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",
|
|
23
|
+
"type": "registry:ui"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"path": "components/uibot/item-grid.uibot.json",
|
|
27
|
+
"target": "components/uibot/item-grid.uibot.json",
|
|
28
|
+
"content": "{\n \"schema\": \"uibot.registry.item.v1\",\n \"item\": \"item-grid\",\n \"channel\": \"public\",\n \"components\": [\n {\n \"name\": \"ItemGrid\",\n \"export\": \"ItemGrid\",\n \"module\": \"item-grid.tsx\",\n \"catalog\": {\n \"name\": \"ItemGrid\",\n \"description\": \"Public-facing collection of whole-card buttons with optional images, local search and category filters. Use for browsable pets, products or projects instead of duplicating cards and a management table. No data writes.\",\n \"category\": \"composite\",\n \"level\": \"L2\",\n \"tags\": [\n \"cards\",\n \"search\",\n \"collection\",\n \"gallery\"\n ],\n \"props\": {\n \"label\": {\n \"type\": \"string\"\n },\n \"items\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"required\": [\n \"id\",\n \"title\"\n ],\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"title\": {\n \"type\": \"string\"\n },\n \"description\": {\n \"type\": \"string\"\n },\n \"category\": {\n \"type\": \"string\"\n },\n \"meta\": {\n \"type\": \"string\"\n },\n \"image\": {\n \"type\": \"string\",\n \"description\": \"Supplied image URL or inline data:image illustration; never invent an asset URL\"\n },\n \"imageAlt\": {\n \"type\": \"string\"\n }\n }\n }\n },\n \"columns\": {\n \"type\": \"string\",\n \"enum\": [\n \"2\",\n \"3\"\n ],\n \"default\": \"3\"\n },\n \"searchable\": {\n \"type\": \"boolean\",\n \"default\": false\n },\n \"filterable\": {\n \"type\": \"boolean\",\n \"default\": false\n },\n \"searchPlaceholder\": {\n \"type\": \"string\"\n },\n \"filterLabel\": {\n \"type\": \"string\"\n },\n \"allLabel\": {\n \"type\": \"string\"\n },\n \"emptyText\": {\n \"type\": \"string\"\n },\n \"actionLabel\": {\n \"type\": \"string\"\n }\n },\n \"events\": {\n \"onSelect\": {\n \"description\": \"Whole-card click or keyboard activation emits the selected string id in {\\\"_event\\\":\\\"values.id\\\"}.\"\n }\n },\n \"constraints\": [\n \"Use unique non-empty string item IDs. Category filters derive from items; search and category combine on these same cards. Set all control labels in the product language. Image is optional; omit it when unavailable.\"\n ]\n }\n }\n ]\n}\n",
|
|
29
|
+
"type": "registry:ui"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"meta": {
|
|
33
|
+
"category": "composite",
|
|
34
|
+
"level": "L2",
|
|
35
|
+
"props": {
|
|
36
|
+
"label": {
|
|
37
|
+
"type": "string"
|
|
38
|
+
},
|
|
39
|
+
"items": {
|
|
40
|
+
"type": "array",
|
|
41
|
+
"items": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"required": [
|
|
44
|
+
"id",
|
|
45
|
+
"title"
|
|
46
|
+
],
|
|
47
|
+
"properties": {
|
|
48
|
+
"id": {
|
|
49
|
+
"type": "string"
|
|
50
|
+
},
|
|
51
|
+
"title": {
|
|
52
|
+
"type": "string"
|
|
53
|
+
},
|
|
54
|
+
"description": {
|
|
55
|
+
"type": "string"
|
|
56
|
+
},
|
|
57
|
+
"category": {
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"meta": {
|
|
61
|
+
"type": "string"
|
|
62
|
+
},
|
|
63
|
+
"image": {
|
|
64
|
+
"type": "string",
|
|
65
|
+
"description": "Supplied image URL or inline data:image illustration; never invent an asset URL"
|
|
66
|
+
},
|
|
67
|
+
"imageAlt": {
|
|
68
|
+
"type": "string"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"columns": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"enum": [
|
|
76
|
+
"2",
|
|
77
|
+
"3"
|
|
78
|
+
],
|
|
79
|
+
"default": "3"
|
|
80
|
+
},
|
|
81
|
+
"searchable": {
|
|
82
|
+
"type": "boolean",
|
|
83
|
+
"default": false
|
|
84
|
+
},
|
|
85
|
+
"filterable": {
|
|
86
|
+
"type": "boolean",
|
|
87
|
+
"default": false
|
|
88
|
+
},
|
|
89
|
+
"searchPlaceholder": {
|
|
90
|
+
"type": "string"
|
|
91
|
+
},
|
|
92
|
+
"filterLabel": {
|
|
93
|
+
"type": "string"
|
|
94
|
+
},
|
|
95
|
+
"allLabel": {
|
|
96
|
+
"type": "string"
|
|
97
|
+
},
|
|
98
|
+
"emptyText": {
|
|
99
|
+
"type": "string"
|
|
100
|
+
},
|
|
101
|
+
"actionLabel": {
|
|
102
|
+
"type": "string"
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"events": {
|
|
106
|
+
"onSelect": {
|
|
107
|
+
"description": "Whole-card click or keyboard activation emits the selected string id in {\"_event\":\"values.id\"}."
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"constraints": [
|
|
111
|
+
"Use unique non-empty string item IDs. Category filters derive from items; search and category combine on these same cards. Set all control labels in the product language. Image is optional; omit it when unavailable."
|
|
112
|
+
],
|
|
113
|
+
"provides": [
|
|
114
|
+
"ItemGrid"
|
|
115
|
+
],
|
|
116
|
+
"uibot": {
|
|
117
|
+
"schema": "uibot.registry.item.v1",
|
|
118
|
+
"item": "item-grid",
|
|
119
|
+
"channel": "public",
|
|
120
|
+
"components": [
|
|
121
|
+
{
|
|
122
|
+
"name": "ItemGrid",
|
|
123
|
+
"export": "ItemGrid",
|
|
124
|
+
"module": "item-grid.tsx",
|
|
125
|
+
"catalog": {
|
|
126
|
+
"name": "ItemGrid",
|
|
127
|
+
"description": "Public-facing collection of whole-card buttons with optional images, local search and category filters. Use for browsable pets, products or projects instead of duplicating cards and a management table. No data writes.",
|
|
128
|
+
"category": "composite",
|
|
129
|
+
"level": "L2",
|
|
130
|
+
"tags": [
|
|
131
|
+
"cards",
|
|
132
|
+
"search",
|
|
133
|
+
"collection",
|
|
134
|
+
"gallery"
|
|
135
|
+
],
|
|
136
|
+
"props": {
|
|
137
|
+
"label": {
|
|
138
|
+
"type": "string"
|
|
139
|
+
},
|
|
140
|
+
"items": {
|
|
141
|
+
"type": "array",
|
|
142
|
+
"items": {
|
|
143
|
+
"type": "object",
|
|
144
|
+
"required": [
|
|
145
|
+
"id",
|
|
146
|
+
"title"
|
|
147
|
+
],
|
|
148
|
+
"properties": {
|
|
149
|
+
"id": {
|
|
150
|
+
"type": "string"
|
|
151
|
+
},
|
|
152
|
+
"title": {
|
|
153
|
+
"type": "string"
|
|
154
|
+
},
|
|
155
|
+
"description": {
|
|
156
|
+
"type": "string"
|
|
157
|
+
},
|
|
158
|
+
"category": {
|
|
159
|
+
"type": "string"
|
|
160
|
+
},
|
|
161
|
+
"meta": {
|
|
162
|
+
"type": "string"
|
|
163
|
+
},
|
|
164
|
+
"image": {
|
|
165
|
+
"type": "string",
|
|
166
|
+
"description": "Supplied image URL or inline data:image illustration; never invent an asset URL"
|
|
167
|
+
},
|
|
168
|
+
"imageAlt": {
|
|
169
|
+
"type": "string"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"columns": {
|
|
175
|
+
"type": "string",
|
|
176
|
+
"enum": [
|
|
177
|
+
"2",
|
|
178
|
+
"3"
|
|
179
|
+
],
|
|
180
|
+
"default": "3"
|
|
181
|
+
},
|
|
182
|
+
"searchable": {
|
|
183
|
+
"type": "boolean",
|
|
184
|
+
"default": false
|
|
185
|
+
},
|
|
186
|
+
"filterable": {
|
|
187
|
+
"type": "boolean",
|
|
188
|
+
"default": false
|
|
189
|
+
},
|
|
190
|
+
"searchPlaceholder": {
|
|
191
|
+
"type": "string"
|
|
192
|
+
},
|
|
193
|
+
"filterLabel": {
|
|
194
|
+
"type": "string"
|
|
195
|
+
},
|
|
196
|
+
"allLabel": {
|
|
197
|
+
"type": "string"
|
|
198
|
+
},
|
|
199
|
+
"emptyText": {
|
|
200
|
+
"type": "string"
|
|
201
|
+
},
|
|
202
|
+
"actionLabel": {
|
|
203
|
+
"type": "string"
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"events": {
|
|
207
|
+
"onSelect": {
|
|
208
|
+
"description": "Whole-card click or keyboard activation emits the selected string id in {\"_event\":\"values.id\"}."
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
"constraints": [
|
|
212
|
+
"Use unique non-empty string item IDs. Category filters derive from items; search and category combine on these same cards. Set all control labels in the product language. Image is optional; omit it when unavailable."
|
|
213
|
+
]
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|