@uibot/registry 0.10.0 → 0.11.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/shadcn/r/collection-cell-editor.json +41 -0
- package/dist/shadcn/r/collection-panel-drawer.json +27 -0
- package/dist/shadcn/r/collection-record-menu.json +26 -0
- package/dist/shadcn/r/collection-shared.json +23 -0
- package/dist/shadcn/r/creation-html-generation.json +2 -2
- package/dist/shadcn/r/creation-reference-generation.json +2 -2
- package/dist/shadcn/r/creation-revision-export.json +2 -2
- package/dist/shadcn/r/creation-shared.json +2 -2
- package/dist/shadcn/r/creation-workspace.json +2 -2
- package/dist/shadcn/registry.json +69 -10
- package/package.json +2 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "collection-cell-editor",
|
|
4
|
+
"type": "registry:block",
|
|
5
|
+
"description": "Design-system cell editors for PagedCollectionGrid's renderCellEditor: text, number, long text, checkbox, single/multiple select, calendar dates (timestamps keep their time) and a searchable relation picker.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"react",
|
|
8
|
+
"@uibot/renderer-react@^0.11.0",
|
|
9
|
+
"cmdk@^1",
|
|
10
|
+
"date-fns@^4",
|
|
11
|
+
"lucide-react",
|
|
12
|
+
"react-day-picker@^9"
|
|
13
|
+
],
|
|
14
|
+
"registryDependencies": [
|
|
15
|
+
"button",
|
|
16
|
+
"calendar",
|
|
17
|
+
"checkbox",
|
|
18
|
+
"input",
|
|
19
|
+
"popover",
|
|
20
|
+
"select",
|
|
21
|
+
"@uibot/collection-shared"
|
|
22
|
+
],
|
|
23
|
+
"files": [
|
|
24
|
+
{
|
|
25
|
+
"path": "components/uibot/collection/collection-cell-editor.tsx",
|
|
26
|
+
"target": "components/uibot/collection/collection-cell-editor.tsx",
|
|
27
|
+
"content": "import { Button } from \"@/components/ui/button\";\nimport { Calendar } from \"@/components/ui/calendar\";\nimport { Checkbox } from \"@/components/ui/checkbox\";\nimport { Input } from \"@/components/ui/input\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\";\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@/components/ui/select\";\nimport { format, isValid } from \"date-fns\";\nimport { enUS, zhCN } from \"react-day-picker/locale\";\nimport { CalendarDays, ChevronDown } from \"lucide-react\";\nimport { type KeyboardEvent, useEffect, useRef, useState } from \"react\";\nimport { CollectionRelationEditor } from \"./collection-relation-editor\";\nimport {\n CELL_CONTROL_CLASS,\n type CollectionCellEditorProps,\n collectionChromeMessages,\n commitEditorTab,\n} from \"./collection-shared\";\n\nconst TIMESTAMP = /^\\d{4}-\\d{2}-\\d{2}T.*(?:Z|[+-]\\d{2}:\\d{2})$/i;\nconst EMPTY = \"__uibot_empty_option__\";\n\n/**\n * Design-system cell editor for `PagedCollectionGrid`'s `renderCellEditor`. Linked-record fields\n * keep the grid's built-in picker: return `undefined` for them, e.g.\n * `renderCellEditor={(input) => input.field.type === \"linkedRecord\" ? undefined : <CollectionCellEditor {...input} />}`.\n */\nexport function CollectionCellEditor(props: CollectionCellEditorProps) {\n const t = collectionChromeMessages(props.locale);\n const { field } = props;\n if (field.type === \"singleSelect\" || field.type === \"multipleSelect\")\n return <CollectionChoiceEditor {...props} />;\n if (field.type === \"relation\") return <CollectionRelationEditor {...props} />;\n if (field.type === \"date\") return <CollectionDateEditor {...props} />;\n if (field.type === \"checkbox\" && props.mode === \"inline\")\n return (\n <div className=\"flex h-full w-full items-center\">\n <Checkbox\n id={props.id}\n aria-label={props.label ?? t.edit(field.name)}\n disabled={props.disabled}\n checked={props.text === \"true\"}\n onCheckedChange={(checked) => props.onChange(checked === true ? \"true\" : \"false\")}\n />\n </div>\n );\n if (field.type === \"checkbox\")\n return (\n <Select\n disabled={props.disabled}\n value={props.text || (field.required ? undefined : EMPTY)}\n onValueChange={(value) => props.onChange(value === EMPTY ? \"\" : value)}\n >\n <SelectTrigger\n id={props.id}\n onKeyDown={(event) => commitEditorTab(event, props)}\n aria-label={props.label ?? t.edit(field.name)}\n className={\n props.autoOpen === false\n ? \"h-9 w-full\"\n : \"h-full w-full rounded-none border-0 px-[7px] shadow-none focus-visible:ring-0\"\n }\n >\n <SelectValue placeholder={t.empty} />\n </SelectTrigger>\n <SelectContent\n onEscapeKeyDown={props.onCancel}\n onKeyDown={(event) => commitEditorTab(event, props)}\n >\n {!field.required && <SelectItem value={EMPTY}>{t.empty}</SelectItem>}\n <SelectItem value=\"true\">{t.yes}</SelectItem>\n <SelectItem value=\"false\">{t.no}</SelectItem>\n </SelectContent>\n </Select>\n );\n return <CollectionTextEditor {...props} />;\n}\n\n/** Text, number and long-text cells. Enter saves (Ctrl/Cmd+Enter for multiline), Escape cancels. */\nexport function CollectionTextEditor(props: CollectionCellEditorProps) {\n const { field, text, disabled, onChange, onSave, onCancel, autoOpen = true, id, label } = props;\n const t = collectionChromeMessages(props.locale);\n const ref = useRef<HTMLInputElement & HTMLTextAreaElement>(null);\n useEffect(() => {\n if (autoOpen) ref.current?.focus();\n }, [autoOpen]);\n const multiline = field.type === \"longText\" || field.type === \"json\";\n const keyDown = (event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => {\n event.stopPropagation();\n if (event.key === \"Tab\" && autoOpen && !disabled) {\n event.preventDefault();\n onSave(event.shiftKey ? \"previous\" : \"next\");\n }\n if (event.key === \"Escape\") {\n event.preventDefault();\n onCancel();\n }\n if (\n event.key === \"Enter\" &&\n !event.shiftKey &&\n (!multiline || event.ctrlKey || event.metaKey)\n ) {\n event.preventDefault();\n onSave();\n }\n };\n const common = {\n ref,\n id,\n \"aria-label\": label ?? t.edit(field.name),\n disabled,\n value: text,\n onKeyDown: keyDown,\n onChange: (event: { target: { value: string } }) => onChange(event.target.value),\n };\n if (multiline)\n return (\n <textarea\n {...common}\n data-slot=\"textarea\"\n rows={autoOpen ? 1 : 3}\n className={\n autoOpen\n ? `${CELL_CONTROL_CLASS} resize-none`\n : \"w-full rounded-lg border border-input bg-transparent px-3 py-2 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring/50\"\n }\n />\n );\n return (\n <Input\n {...common}\n {...(autoOpen ? { className: CELL_CONTROL_CLASS } : {})}\n inputMode={field.type === \"number\" ? \"decimal\" : undefined}\n readOnly={field.type === \"blob\"}\n />\n );\n}\n\n/** Calendar picker. A timestamp keeps its time of day (editable below the calendar); a date stays a date. */\nexport function CollectionDateEditor(props: CollectionCellEditorProps) {\n const { field, text, disabled, onChange, onCancel, autoOpen = true, id, label } = props;\n const t = collectionChromeMessages(props.locale);\n const [open, setOpen] = useState(autoOpen);\n const timestamp = TIMESTAMP.test(text);\n const parsed = text ? new Date(timestamp ? text : `${text}T00:00:00`) : undefined;\n const selected = parsed && isValid(parsed) ? parsed : undefined;\n const selectDate = (date: Date | undefined) => {\n if (!date || disabled) return;\n if (timestamp && selected) {\n const next = new Date(selected);\n next.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());\n onChange(next.getTime() === selected.getTime() ? text : next.toISOString());\n } else onChange(format(date, \"yyyy-MM-dd\"));\n setOpen(false);\n };\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n id={id}\n aria-label={label ?? t.edit(field.name)}\n disabled={disabled}\n variant=\"ghost\"\n className={\n autoOpen\n ? `${CELL_CONTROL_CLASS} justify-start font-normal`\n : \"h-9 w-full justify-start border border-input font-normal\"\n }\n onKeyDown={(event) => {\n event.stopPropagation();\n commitEditorTab(event, props);\n if (event.key === \"Escape\") onCancel();\n }}\n >\n <span className=\"truncate\">\n {selected\n ? format(selected, timestamp ? \"yyyy-MM-dd HH:mm:ss\" : \"yyyy-MM-dd\")\n : text || t.chooseDate}\n </span>\n <CalendarDays className=\"ml-auto size-3.5 opacity-60\" />\n </Button>\n </PopoverTrigger>\n <PopoverContent align=\"start\" className=\"w-auto p-0\" onEscapeKeyDown={onCancel}>\n <Calendar\n mode=\"single\"\n locale={props.locale === \"zh\" ? zhCN : enUS}\n selected={selected}\n defaultMonth={selected}\n onSelect={selectDate}\n disabled={disabled}\n autoFocus\n />\n {timestamp && selected && (\n <div className=\"flex items-center gap-2 border-t px-3 py-2 text-xs\">\n <span className=\"shrink-0\">{t.time}</span>\n <Input\n type=\"time\"\n aria-label={t.timeOf(field.name)}\n step=\"0.001\"\n disabled={disabled}\n value={format(selected, \"HH:mm:ss.SSS\")}\n onChange={(event) => {\n const parts = event.target.value.match(\n /^(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3}))?)?$/,\n );\n if (!parts) return;\n const next = new Date(selected);\n next.setHours(\n Number(parts[1]),\n Number(parts[2]),\n Number(parts[3] ?? 0),\n Number((parts[4] ?? \"\").padEnd(3, \"0\")),\n );\n onChange(next.toISOString());\n }}\n />\n </div>\n )}\n {!field.required && (\n <div className=\"border-t p-2\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n disabled={disabled}\n onClick={() => {\n onChange(\"\");\n setOpen(false);\n }}\n >\n {t.clearDate}\n </Button>\n </div>\n )}\n </PopoverContent>\n </Popover>\n );\n}\n\n/** Single select is a dropdown; multiple select is a searchable checklist saved explicitly. Values are option ids. */\nexport function CollectionChoiceEditor(props: CollectionCellEditorProps) {\n const { field, text, disabled, onChange, onSave, onCancel, autoOpen = true, id, label } = props;\n const t = collectionChromeMessages(props.locale);\n const [search, setSearch] = useState(\"\");\n const [open, setOpen] = useState(autoOpen);\n const options = field.options ?? [];\n if (field.type === \"singleSelect\")\n return (\n <Select\n defaultOpen={autoOpen}\n disabled={disabled}\n value={text ? `option:${text}` : \"empty\"}\n onValueChange={(value) => onChange(value === \"empty\" ? \"\" : value.slice(7))}\n >\n <SelectTrigger\n id={id}\n onKeyDown={(event) => commitEditorTab(event, props)}\n aria-label={label ?? t.edit(field.name)}\n className={\n autoOpen\n ? \"h-full w-full rounded-none border-0 bg-transparent px-[7px] shadow-none focus-visible:ring-0\"\n : \"h-9 w-full\"\n }\n >\n <SelectValue placeholder={t.chooseOption}>\n {text ? (options.find((option) => option.id === text)?.name ?? text) : t.chooseOption}\n </SelectValue>\n </SelectTrigger>\n <SelectContent\n onEscapeKeyDown={onCancel}\n onKeyDown={(event) => commitEditorTab(event, props)}\n >\n {!field.required && <SelectItem value=\"empty\">{t.clearChoice}</SelectItem>}\n {options.map((option) => (\n <SelectItem key={option.id} value={`option:${option.id}`}>\n {option.name}\n </SelectItem>\n ))}\n {text && !options.some((option) => option.id === text) && (\n <SelectItem value={`option:${text}`} disabled>\n {t.removedOption(text)}\n </SelectItem>\n )}\n {!options.length && (\n <p className=\"px-2 py-3 text-sm text-muted-foreground\">{t.noOptions}</p>\n )}\n </SelectContent>\n </Select>\n );\n const selected = text.split(\",\").filter(Boolean);\n const visible = options.filter((option) =>\n option.name.toLocaleLowerCase().includes(search.toLocaleLowerCase()),\n );\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n disabled={disabled}\n variant=\"ghost\"\n className={\n autoOpen\n ? \"h-full w-full justify-between rounded-none border-0 bg-transparent px-[7px] font-normal shadow-none focus-visible:ring-0\"\n : \"h-9 w-full justify-between border border-input px-3\"\n }\n id={id}\n onKeyDown={(event) => commitEditorTab(event, props)}\n aria-label={label ?? t.edit(field.name)}\n >\n <span className=\"truncate\">\n {selected\n .map((value) => options.find((option) => option.id === value)?.name ?? value)\n .join(props.locale === \"zh\" ? \"、\" : \", \") || t.chooseOption}\n </span>\n <ChevronDown size={12} />\n </Button>\n </PopoverTrigger>\n <PopoverContent\n align=\"start\"\n className=\"w-64\"\n onEscapeKeyDown={onCancel}\n onKeyDown={(event) => commitEditorTab(event, props)}\n >\n <p className=\"px-1 text-xs text-muted-foreground\">\n {t.selectedCount(field.name, selected.length)}\n </p>\n <Input\n aria-label={t.searchOptionsOf(field.name)}\n placeholder={t.searchOptions}\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n className=\"h-8\"\n />\n <fieldset\n className=\"m-0 max-h-56 min-w-0 overflow-y-auto border-0 p-0\"\n aria-label={t.optionsOf(field.name)}\n >\n {visible.map((option) => (\n <Button\n key={option.id}\n role=\"checkbox\"\n aria-checked={selected.includes(option.id)}\n disabled={disabled}\n variant=\"ghost\"\n className=\"h-8 w-full justify-start px-2\"\n onClick={() =>\n onChange(\n (selected.includes(option.id)\n ? selected.filter((value) => value !== option.id)\n : [...selected, option.id]\n ).join(\",\"),\n )\n }\n >\n <span aria-hidden=\"true\" className=\"w-4\">\n {selected.includes(option.id) ? \"✓\" : \"\"}\n </span>\n {option.name}\n </Button>\n ))}\n {!visible.length && (\n <p className=\"px-2 py-3 text-sm text-muted-foreground\">\n {options.length ? t.noMatchingOptions : t.noOptions}\n </p>\n )}\n </fieldset>\n <div className=\"flex justify-end gap-2 border-t pt-2\">\n <Button\n variant=\"ghost\"\n size=\"sm\"\n disabled={disabled}\n onClick={() => {\n setOpen(false);\n onCancel();\n }}\n >\n {t.cancel}\n </Button>\n <Button\n size=\"sm\"\n disabled={disabled}\n onClick={() => {\n setOpen(false);\n onSave();\n }}\n >\n {t.save}\n </Button>\n </div>\n </PopoverContent>\n </Popover>\n );\n}\n",
|
|
28
|
+
"type": "registry:component"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"path": "components/uibot/collection/collection-relation-editor.tsx",
|
|
32
|
+
"target": "components/uibot/collection/collection-relation-editor.tsx",
|
|
33
|
+
"content": "import { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\";\nimport { Command } from \"cmdk\";\nimport { Check, ChevronsUpDown } from \"lucide-react\";\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport {\n type CollectionCellEditorProps,\n collectionChromeMessages,\n commitEditorTab,\n} from \"./collection-shared\";\n\nconst ITEM_CLASS =\n \"flex cursor-default items-center gap-2 rounded-md px-2 py-2 text-sm data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground\";\n\n/**\n * Searchable picker for `relation` fields over the grid's `getRelationOptions` lookup (paged,\n * debounced). The stored value stays the record id; labels are only displayed.\n */\nexport function CollectionRelationEditor(props: CollectionCellEditorProps) {\n const {\n field,\n text,\n disabled,\n getRelationOptions,\n onChange,\n onCancel,\n autoOpen = true,\n id,\n label,\n } = props;\n const t = collectionChromeMessages(props.locale);\n const [open, setOpen] = useState(autoOpen && !disabled);\n const [search, setSearch] = useState(\"\");\n const [cursor, setCursor] = useState<string>();\n const [next, setNext] = useState<string | null>(null);\n const [options, setOptions] = useState<{ id: string; label: string }[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState(\"\");\n const [retry, setRetry] = useState(0);\n const labels = useRef(new Map<string, string>());\n const listId = useId();\n const provider = useRef(getRelationOptions);\n provider.current = getRelationOptions;\n const lookupFailed = useRef(t.lookupFailed);\n lookupFailed.current = t.lookupFailed;\n const collectionId = field.relation?.collectionId;\n const labelFieldId = field.relation?.labelFieldId;\n const available = Boolean(collectionId && getRelationOptions);\n // biome-ignore lint/correctness/useExhaustiveDependencies: retry explicitly restarts a failed lookup.\n useEffect(() => {\n if (!open || disabled || !collectionId || !available) return;\n let cancelled = false;\n setLoading(true);\n setError(\"\");\n const timer = setTimeout(\n () => {\n void provider\n .current?.({ collectionId, labelFieldId, search, cursor, limit: 50 })\n .then((result) => {\n if (cancelled) return;\n if (!result.ok) {\n setError(result.error.message);\n setNext(null);\n return;\n }\n for (const item of result.data.items) labels.current.set(item.id, item.label);\n setOptions((old) => [\n ...new Map(\n (cursor ? [...old, ...result.data.items] : result.data.items).map((item) => [\n item.id,\n item,\n ]),\n ).values(),\n ]);\n setNext(result.data.nextCursor);\n })\n .catch(() => {\n if (!cancelled) setError(lookupFailed.current);\n })\n .finally(() => {\n if (!cancelled) setLoading(false);\n });\n },\n search ? 180 : 0,\n );\n return () => {\n cancelled = true;\n clearTimeout(timer);\n };\n }, [open, disabled, collectionId, labelFieldId, search, cursor, available, retry]);\n const select = (value: string) => {\n if (disabled) return;\n onChange(value);\n setOpen(false);\n };\n return (\n <Popover open={open && !disabled} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <Button\n id={id}\n onKeyDown={(event) => commitEditorTab(event, props)}\n variant=\"outline\"\n role=\"combobox\"\n aria-label={label ?? t.edit(field.name)}\n aria-expanded={open && !disabled}\n aria-controls={listId}\n disabled={disabled || !available}\n className={\n autoOpen\n ? \"h-full min-h-0 w-full min-w-0 justify-between rounded-none border-0 bg-transparent px-[7px] py-0 text-[inherit] shadow-none focus-visible:ring-0\"\n : \"h-9 w-full min-w-0 justify-between\"\n }\n >\n <span\n className=\"min-w-0 truncate\"\n title={text ? (labels.current.get(text) ?? text) : undefined}\n >\n {text ? (labels.current.get(text) ?? t.currentLink) : t.unlinked}\n </span>\n <ChevronsUpDown size={14} className=\"shrink-0 text-muted-foreground\" />\n </Button>\n </PopoverTrigger>\n <PopoverContent\n align=\"start\"\n className=\"w-80 max-w-[calc(100vw-2rem)] gap-0 p-1\"\n onEscapeKeyDown={(event) => {\n event.stopPropagation();\n onCancel();\n }}\n onKeyDown={(event) => {\n event.stopPropagation();\n commitEditorTab(event, props);\n }}\n >\n <Command shouldFilter={false} label={t.chooseRecord(field.name)}>\n <Command.Input\n asChild\n value={search}\n onValueChange={(value) => {\n setSearch(value);\n setCursor(undefined);\n setNext(null);\n setOptions([]);\n }}\n >\n <Input\n aria-label={t.searchRecords(field.name)}\n placeholder={t.searchRecordsPlaceholder}\n className=\"mb-1 h-8\"\n />\n </Command.Input>\n <Command.List\n id={listId}\n className=\"max-h-64 overflow-y-auto\"\n aria-busy={loading}\n aria-label={t.recordCandidates}\n >\n {!field.required && !search && (\n <Command.Item value=\"__empty__\" onSelect={() => select(\"\")} className={ITEM_CLASS}>\n <Check size={14} className={text ? \"invisible\" : \"\"} />\n {t.unlinked}\n </Command.Item>\n )}\n {!loading && !error && options.length === 0 && (\n <Command.Empty className=\"px-2 py-4 text-sm text-muted-foreground\">\n {t.noMatchingRecords}\n </Command.Empty>\n )}\n {options.map((option) => (\n <Command.Item\n key={option.id}\n value={option.id}\n onSelect={() => select(option.id)}\n className={ITEM_CLASS}\n >\n <Check\n size={14}\n className={text === option.id ? \"shrink-0\" : \"invisible shrink-0\"}\n />\n <span className=\"min-w-0 truncate\" title={option.label}>\n {option.label}\n </span>\n </Command.Item>\n ))}\n </Command.List>\n </Command>\n {loading && (\n <p role=\"status\" className=\"px-2 py-2 text-xs text-muted-foreground\">\n {t.loading}\n </p>\n )}\n {error && (\n <div role=\"alert\" className=\"p-2 text-sm\">\n <p>{error}</p>\n <Button variant=\"ghost\" size=\"sm\" onClick={() => setRetry((value) => value + 1)}>\n {t.retry}\n </Button>\n </div>\n )}\n {next && (\n <Button variant=\"ghost\" size=\"sm\" disabled={loading} onClick={() => setCursor(next)}>\n {t.loadMore}\n </Button>\n )}\n </PopoverContent>\n </Popover>\n );\n}\n",
|
|
34
|
+
"type": "registry:component"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"meta": {
|
|
38
|
+
"composite": true,
|
|
39
|
+
"channel": "public"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "collection-panel-drawer",
|
|
4
|
+
"type": "registry:block",
|
|
5
|
+
"description": "Right-hand drawer for PagedCollectionWorkspace's renderPanel; a busy panel stays open and unsaved edits ask before closing.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"react",
|
|
8
|
+
"@uibot/renderer-react@^0.11.0"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"button",
|
|
12
|
+
"dialog",
|
|
13
|
+
"@uibot/collection-shared"
|
|
14
|
+
],
|
|
15
|
+
"files": [
|
|
16
|
+
{
|
|
17
|
+
"path": "components/uibot/collection/collection-panel-drawer.tsx",
|
|
18
|
+
"target": "components/uibot/collection/collection-panel-drawer.tsx",
|
|
19
|
+
"content": "import { Button } from \"@/components/ui/button\";\nimport { Dialog, DialogContent, DialogDescription, DialogTitle } from \"@/components/ui/dialog\";\nimport type { PagedCollectionWorkspaceProps } from \"@uibot/renderer-react/collection-workspace\";\nimport { type ReactNode, useState } from \"react\";\nimport { type CollectionLocale, collectionChromeMessages } from \"./collection-shared\";\n\nexport type CollectionPanelDrawerProps = Pick<\n Parameters<NonNullable<PagedCollectionWorkspaceProps[\"renderPanel\"]>>[0],\n \"title\" | \"dirty\" | \"busy\" | \"onClose\"\n> & { children: ReactNode; locale?: CollectionLocale };\n\n/**\n * Right-hand drawer for `PagedCollectionWorkspace`'s `renderPanel` (record, field and view panels).\n * A busy panel stays open; unsaved edits ask before closing.\n */\nexport function CollectionPanelDrawer({\n title,\n dirty,\n busy,\n children,\n onClose,\n locale,\n}: CollectionPanelDrawerProps) {\n const t = collectionChromeMessages(locale);\n const [confirming, setConfirming] = useState(false);\n const requestClose = () => {\n if (busy) return;\n if (dirty) setConfirming(true);\n else onClose();\n };\n return (\n <>\n <Dialog open onOpenChange={(open) => !open && requestClose()}>\n <DialogContent\n data-slot=\"collection-panel-drawer\"\n // The panels handle Escape themselves (and confirm discarding), so the drawer must not ask twice.\n onEscapeKeyDown={(event) => event.preventDefault()}\n className=\"top-0 right-0 left-auto flex h-dvh max-h-none w-full max-w-xl translate-x-0 translate-y-0 flex-col gap-4 rounded-none rounded-l-xl border-y-0 border-r-0 sm:max-w-xl\"\n >\n <DialogTitle className=\"pr-8 text-lg font-semibold\">{title}</DialogTitle>\n <DialogDescription className=\"sr-only\">{title}</DialogDescription>\n <div className=\"min-h-0 flex-1 overflow-y-auto\">{children}</div>\n </DialogContent>\n </Dialog>\n <Dialog open={confirming} onOpenChange={setConfirming}>\n <DialogContent>\n <DialogTitle className=\"pr-6 text-lg font-semibold\">{t.discardTitle}</DialogTitle>\n <DialogDescription className=\"text-sm text-muted-foreground\">\n {t.discardDescription}\n </DialogDescription>\n <div className=\"flex justify-end gap-2\">\n <Button variant=\"outline\" size=\"sm\" onClick={() => setConfirming(false)}>\n {t.keepEditing}\n </Button>\n <Button\n variant=\"destructive\"\n size=\"sm\"\n onClick={() => {\n setConfirming(false);\n onClose();\n }}\n >\n {t.discard}\n </Button>\n </div>\n </DialogContent>\n </Dialog>\n </>\n );\n}\n",
|
|
20
|
+
"type": "registry:component"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"meta": {
|
|
24
|
+
"composite": true,
|
|
25
|
+
"channel": "public"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "collection-record-menu",
|
|
4
|
+
"type": "registry:block",
|
|
5
|
+
"description": "Right-click record actions (expand, duplicate, copy cells, delete) for renderRecordContextMenu.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"react",
|
|
8
|
+
"@uibot/renderer-react@^0.11.0"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"context-menu",
|
|
12
|
+
"@uibot/collection-shared"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
{
|
|
16
|
+
"path": "components/uibot/collection/collection-record-menu.tsx",
|
|
17
|
+
"target": "components/uibot/collection/collection-record-menu.tsx",
|
|
18
|
+
"content": "import {\n ContextMenu,\n ContextMenuContent,\n ContextMenuItem,\n ContextMenuTrigger,\n} from \"@/components/ui/context-menu\";\nimport { type CollectionRecordMenuProps, collectionChromeMessages } from \"./collection-shared\";\n\n/**\n * Right-click record actions for `PagedCollectionGrid`'s `renderRecordContextMenu`. The grid keeps\n * selection and mutations; this only offers the actions it passes.\n */\nexport function CollectionRecordMenu({\n children,\n recordIds,\n disabled,\n onDelete,\n onExpand,\n onCopy,\n onDuplicate,\n locale,\n}: CollectionRecordMenuProps) {\n const t = collectionChromeMessages(locale);\n return (\n <ContextMenu>\n <ContextMenuTrigger asChild>{children}</ContextMenuTrigger>\n <ContextMenuContent>\n {onExpand ? <ContextMenuItem onSelect={onExpand}>{t.expandRecord}</ContextMenuItem> : null}\n {onDuplicate ? (\n <ContextMenuItem disabled={disabled} onSelect={onDuplicate}>\n {t.duplicate(recordIds.length)}\n </ContextMenuItem>\n ) : null}\n <ContextMenuItem disabled={recordIds.length === 0} onSelect={onCopy}>\n {t.copyCells}\n </ContextMenuItem>\n <ContextMenuItem\n className=\"text-destructive focus:text-destructive\"\n disabled={disabled}\n onSelect={onDelete}\n >\n {t.deleteRecords(recordIds.length)}\n </ContextMenuItem>\n </ContextMenuContent>\n </ContextMenu>\n );\n}\n",
|
|
19
|
+
"type": "registry:component"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"meta": {
|
|
23
|
+
"composite": true,
|
|
24
|
+
"channel": "public"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "collection-shared",
|
|
4
|
+
"type": "registry:lib",
|
|
5
|
+
"description": "Copy (zh/en), editor prop types and Tab-commit helper shared by the UIBot collection blocks.",
|
|
6
|
+
"dependencies": [
|
|
7
|
+
"react",
|
|
8
|
+
"@uibot/renderer-react@^0.11.0"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"path": "components/uibot/collection/collection-shared.ts",
|
|
14
|
+
"target": "components/uibot/collection/collection-shared.ts",
|
|
15
|
+
"content": "import type { PagedCollectionGridProps } from \"@uibot/renderer-react/collection-grid\";\nimport type { KeyboardEvent } from \"react\";\n\nexport type CollectionLocale = \"zh\" | \"en\";\n\n/** What the grid passes to `renderCellEditor`, plus the copy locale. */\nexport type CollectionCellEditorProps = Parameters<\n NonNullable<PagedCollectionGridProps[\"renderCellEditor\"]>\n>[0] & { locale?: CollectionLocale };\n\n/** What the grid passes to `renderRecordContextMenu`, plus the copy locale. */\nexport type CollectionRecordMenuProps = Parameters<\n NonNullable<PagedCollectionGridProps[\"renderRecordContextMenu\"]>\n>[0] & { locale?: CollectionLocale };\n\nconst MESSAGES = {\n zh: {\n edit: (field: string) => `编辑 ${field}`,\n chooseOption: \"选择选项\",\n clearChoice: \"清空选择\",\n removedOption: (value: string) => `${value}(选项已移除)`,\n noOptions: \"尚未配置选项\",\n noMatchingOptions: \"没有匹配的选项\",\n searchOptions: \"搜索选项\",\n searchOptionsOf: (field: string) => `搜索${field}选项`,\n optionsOf: (field: string) => `${field}选项`,\n selectedCount: (field: string, count: number) => `${field} · 已选 ${count} 项`,\n cancel: \"取消\",\n save: \"保存\",\n empty: \"未填写\",\n yes: \"是\",\n no: \"否\",\n chooseDate: \"选择日期\",\n clearDate: \"清空日期\",\n time: \"时间\",\n timeOf: (field: string) => `${field}时间`,\n unlinked: \"未关联\",\n currentLink: \"当前关联记录\",\n chooseRecord: (field: string) => `选择${field}`,\n searchRecords: (field: string) => `搜索${field}`,\n searchRecordsPlaceholder: \"搜索关联记录…\",\n recordCandidates: \"关联记录候选项\",\n noMatchingRecords: \"没有匹配的记录\",\n loading: \"加载中…\",\n lookupFailed: \"关联记录加载失败,请重试\",\n retry: \"重试\",\n loadMore: \"加载更多记录\",\n expandRecord: \"展开记录\",\n duplicate: (count: number) => `创建 ${count} 条副本`,\n copyCells: \"复制单元格\",\n deleteRecords: (count: number) => `删除 ${count} 条记录`,\n discardTitle: \"放弃未保存的修改?\",\n discardDescription: \"关闭后当前面板中的修改将丢失。\",\n keepEditing: \"继续编辑\",\n discard: \"放弃修改\",\n },\n en: {\n edit: (field: string) => `Edit ${field}`,\n chooseOption: \"Choose an option\",\n clearChoice: \"Clear selection\",\n removedOption: (value: string) => `${value} (option removed)`,\n noOptions: \"No options yet\",\n noMatchingOptions: \"No matching options\",\n searchOptions: \"Search options\",\n searchOptionsOf: (field: string) => `Search ${field} options`,\n optionsOf: (field: string) => `${field} options`,\n selectedCount: (field: string, count: number) => `${field} · ${count} selected`,\n cancel: \"Cancel\",\n save: \"Save\",\n empty: \"Empty\",\n yes: \"Yes\",\n no: \"No\",\n chooseDate: \"Choose a date\",\n clearDate: \"Clear date\",\n time: \"Time\",\n timeOf: (field: string) => `${field} time`,\n unlinked: \"Not linked\",\n currentLink: \"Linked record\",\n chooseRecord: (field: string) => `Choose ${field}`,\n searchRecords: (field: string) => `Search ${field}`,\n searchRecordsPlaceholder: \"Search linked records…\",\n recordCandidates: \"Linked record candidates\",\n noMatchingRecords: \"No matching records\",\n loading: \"Loading…\",\n lookupFailed: \"Could not load linked records. Try again.\",\n retry: \"Retry\",\n loadMore: \"Load more records\",\n expandRecord: \"Expand record\",\n duplicate: (count: number) => `Duplicate ${count} ${count === 1 ? \"record\" : \"records\"}`,\n copyCells: \"Copy cells\",\n deleteRecords: (count: number) => `Delete ${count} ${count === 1 ? \"record\" : \"records\"}`,\n discardTitle: \"Discard unsaved changes?\",\n discardDescription: \"Closing loses the changes in this panel.\",\n keepEditing: \"Keep editing\",\n discard: \"Discard\",\n },\n};\n\nexport type CollectionChromeMessages = (typeof MESSAGES)[\"en\"];\n\nexport function collectionChromeMessages(\n locale: CollectionLocale = \"en\",\n): CollectionChromeMessages {\n return MESSAGES[locale];\n}\n\n/** Grid editors commit before Tab leaves the cell; form editors (`autoOpen: false`) keep native Tab. */\nexport function commitEditorTab(event: KeyboardEvent, props: CollectionCellEditorProps): void {\n if (event.key !== \"Tab\" || props.autoOpen === false || props.disabled) return;\n event.preventDefault();\n event.stopPropagation();\n props.onSave(event.shiftKey ? \"previous\" : \"next\");\n}\n\n/** Borderless full-cell control for grid editing. */\nexport const CELL_CONTROL_CLASS =\n \"h-full min-h-0 w-full min-w-0 rounded-none border-0 bg-transparent px-[7px] py-0 text-[inherit] shadow-none outline-none focus-visible:border-transparent focus-visible:ring-0\";\n",
|
|
16
|
+
"type": "registry:lib"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"meta": {
|
|
20
|
+
"composite": true,
|
|
21
|
+
"channel": "public"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"description": "Generate a new HTML artifact or rewrite the current revision, with at-most-once dispatch and reconcile from @uibot/creation-kit.",
|
|
6
6
|
"dependencies": [
|
|
7
7
|
"react",
|
|
8
|
-
"@uibot/contracts@^0.
|
|
9
|
-
"@uibot/creation-kit@^0.
|
|
8
|
+
"@uibot/contracts@^0.11.0",
|
|
9
|
+
"@uibot/creation-kit@^0.11.0"
|
|
10
10
|
],
|
|
11
11
|
"registryDependencies": [
|
|
12
12
|
"button",
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"description": "Generate a presentation from an explicitly chosen saved HTML revision.",
|
|
6
6
|
"dependencies": [
|
|
7
7
|
"react",
|
|
8
|
-
"@uibot/contracts@^0.
|
|
9
|
-
"@uibot/creation-kit@^0.
|
|
8
|
+
"@uibot/contracts@^0.11.0",
|
|
9
|
+
"@uibot/creation-kit@^0.11.0"
|
|
10
10
|
],
|
|
11
11
|
"registryDependencies": [
|
|
12
12
|
"button",
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"description": "Download a saved HTML revision (PPTX for presentations) once no model request is open; the host supplies the export transport.",
|
|
6
6
|
"dependencies": [
|
|
7
7
|
"react",
|
|
8
|
-
"@uibot/contracts@^0.
|
|
9
|
-
"@uibot/creation-kit@^0.
|
|
8
|
+
"@uibot/contracts@^0.11.0",
|
|
9
|
+
"@uibot/creation-kit@^0.11.0"
|
|
10
10
|
],
|
|
11
11
|
"registryDependencies": [
|
|
12
12
|
"button",
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"description": "Copy (zh/en), domain filters and run checks shared by the UIBot creation blocks.",
|
|
6
6
|
"dependencies": [
|
|
7
7
|
"react",
|
|
8
|
-
"@uibot/contracts@^0.
|
|
9
|
-
"@uibot/creation-kit@^0.
|
|
8
|
+
"@uibot/contracts@^0.11.0",
|
|
9
|
+
"@uibot/creation-kit@^0.11.0"
|
|
10
10
|
],
|
|
11
11
|
"registryDependencies": [],
|
|
12
12
|
"files": [
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"description": "Manual HTML creation workspace (projects, artifacts, CAS saves with a conflict step, generation, export) over useCreationWorkspace; the host renders the editor.",
|
|
6
6
|
"dependencies": [
|
|
7
7
|
"react",
|
|
8
|
-
"@uibot/contracts@^0.
|
|
9
|
-
"@uibot/creation-kit@^0.
|
|
8
|
+
"@uibot/contracts@^0.11.0",
|
|
9
|
+
"@uibot/creation-kit@^0.11.0"
|
|
10
10
|
],
|
|
11
11
|
"registryDependencies": [
|
|
12
12
|
"button",
|
|
@@ -541,8 +541,8 @@
|
|
|
541
541
|
"registryDependencies": [],
|
|
542
542
|
"dependencies": [
|
|
543
543
|
"react",
|
|
544
|
-
"@uibot/contracts@^0.
|
|
545
|
-
"@uibot/creation-kit@^0.
|
|
544
|
+
"@uibot/contracts@^0.11.0",
|
|
545
|
+
"@uibot/creation-kit@^0.11.0"
|
|
546
546
|
]
|
|
547
547
|
},
|
|
548
548
|
{
|
|
@@ -557,8 +557,8 @@
|
|
|
557
557
|
],
|
|
558
558
|
"dependencies": [
|
|
559
559
|
"react",
|
|
560
|
-
"@uibot/contracts@^0.
|
|
561
|
-
"@uibot/creation-kit@^0.
|
|
560
|
+
"@uibot/contracts@^0.11.0",
|
|
561
|
+
"@uibot/creation-kit@^0.11.0"
|
|
562
562
|
]
|
|
563
563
|
},
|
|
564
564
|
{
|
|
@@ -573,8 +573,8 @@
|
|
|
573
573
|
],
|
|
574
574
|
"dependencies": [
|
|
575
575
|
"react",
|
|
576
|
-
"@uibot/contracts@^0.
|
|
577
|
-
"@uibot/creation-kit@^0.
|
|
576
|
+
"@uibot/contracts@^0.11.0",
|
|
577
|
+
"@uibot/creation-kit@^0.11.0"
|
|
578
578
|
]
|
|
579
579
|
},
|
|
580
580
|
{
|
|
@@ -587,8 +587,8 @@
|
|
|
587
587
|
],
|
|
588
588
|
"dependencies": [
|
|
589
589
|
"react",
|
|
590
|
-
"@uibot/contracts@^0.
|
|
591
|
-
"@uibot/creation-kit@^0.
|
|
590
|
+
"@uibot/contracts@^0.11.0",
|
|
591
|
+
"@uibot/creation-kit@^0.11.0"
|
|
592
592
|
]
|
|
593
593
|
},
|
|
594
594
|
{
|
|
@@ -607,8 +607,67 @@
|
|
|
607
607
|
],
|
|
608
608
|
"dependencies": [
|
|
609
609
|
"react",
|
|
610
|
-
"@uibot/contracts@^0.
|
|
611
|
-
"@uibot/creation-kit@^0.
|
|
610
|
+
"@uibot/contracts@^0.11.0",
|
|
611
|
+
"@uibot/creation-kit@^0.11.0"
|
|
612
|
+
]
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
"name": "collection-shared",
|
|
616
|
+
"type": "registry:lib",
|
|
617
|
+
"description": "Copy (zh/en), editor prop types and Tab-commit helper shared by the UIBot collection blocks.",
|
|
618
|
+
"registryDependencies": [],
|
|
619
|
+
"dependencies": [
|
|
620
|
+
"react",
|
|
621
|
+
"@uibot/renderer-react@^0.11.0"
|
|
622
|
+
]
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
"name": "collection-cell-editor",
|
|
626
|
+
"type": "registry:block",
|
|
627
|
+
"description": "Design-system cell editors for PagedCollectionGrid's renderCellEditor: text, number, long text, checkbox, single/multiple select, calendar dates (timestamps keep their time) and a searchable relation picker.",
|
|
628
|
+
"registryDependencies": [
|
|
629
|
+
"button",
|
|
630
|
+
"calendar",
|
|
631
|
+
"checkbox",
|
|
632
|
+
"input",
|
|
633
|
+
"popover",
|
|
634
|
+
"select",
|
|
635
|
+
"@uibot/collection-shared"
|
|
636
|
+
],
|
|
637
|
+
"dependencies": [
|
|
638
|
+
"react",
|
|
639
|
+
"@uibot/renderer-react@^0.11.0",
|
|
640
|
+
"cmdk@^1",
|
|
641
|
+
"date-fns@^4",
|
|
642
|
+
"lucide-react",
|
|
643
|
+
"react-day-picker@^9"
|
|
644
|
+
]
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
"name": "collection-record-menu",
|
|
648
|
+
"type": "registry:block",
|
|
649
|
+
"description": "Right-click record actions (expand, duplicate, copy cells, delete) for renderRecordContextMenu.",
|
|
650
|
+
"registryDependencies": [
|
|
651
|
+
"context-menu",
|
|
652
|
+
"@uibot/collection-shared"
|
|
653
|
+
],
|
|
654
|
+
"dependencies": [
|
|
655
|
+
"react",
|
|
656
|
+
"@uibot/renderer-react@^0.11.0"
|
|
657
|
+
]
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
"name": "collection-panel-drawer",
|
|
661
|
+
"type": "registry:block",
|
|
662
|
+
"description": "Right-hand drawer for PagedCollectionWorkspace's renderPanel; a busy panel stays open and unsaved edits ask before closing.",
|
|
663
|
+
"registryDependencies": [
|
|
664
|
+
"button",
|
|
665
|
+
"dialog",
|
|
666
|
+
"@uibot/collection-shared"
|
|
667
|
+
],
|
|
668
|
+
"dependencies": [
|
|
669
|
+
"react",
|
|
670
|
+
"@uibot/renderer-react@^0.11.0"
|
|
612
671
|
]
|
|
613
672
|
}
|
|
614
673
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uibot/registry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"access": "public"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@uibot/contracts": "^0.
|
|
30
|
+
"@uibot/contracts": "^0.11.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "rm -rf dist tsconfig.tsbuildinfo && bun build --minify ./src/index.ts --outdir ./dist --format esm --target bun && bun x tsc -b",
|