@namroodinc/liquid-editorial 0.6.7 → 0.6.9
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 +108 -2
- package/UPGRADING.md +88 -0
- package/dist/chunks/CollectionView-BIuOL917.cjs +2 -0
- package/dist/chunks/CollectionView-BIuOL917.cjs.map +1 -0
- package/dist/chunks/CollectionView-Cr12UFWa.js +179 -0
- package/dist/chunks/CollectionView-Cr12UFWa.js.map +1 -0
- package/dist/chunks/{EntryPicker-CR8Phuzl.js → EntryPicker-B88N69zH.js} +2 -2
- package/dist/chunks/{EntryPicker-CR8Phuzl.js.map → EntryPicker-B88N69zH.js.map} +1 -1
- package/dist/chunks/{EntryPicker-D7JIgx23.cjs → EntryPicker-daSkD4aR.cjs} +2 -2
- package/dist/chunks/{EntryPicker-D7JIgx23.cjs.map → EntryPicker-daSkD4aR.cjs.map} +1 -1
- package/dist/chunks/{FormEditor-DNcSAnRF.cjs → FormEditor-B4mtAxaU.cjs} +2 -2
- package/dist/chunks/FormEditor-B4mtAxaU.cjs.map +1 -0
- package/dist/chunks/{FormEditor-BSfxVqLn.js → FormEditor-BkBhcYI5.js} +3 -2
- package/dist/chunks/FormEditor-BkBhcYI5.js.map +1 -0
- package/dist/chunks/LoadState-B7GTDlWv.js +71 -0
- package/dist/chunks/LoadState-B7GTDlWv.js.map +1 -0
- package/dist/chunks/LoadState-C7tQ6fIP.cjs +2 -0
- package/dist/chunks/LoadState-C7tQ6fIP.cjs.map +1 -0
- package/dist/chunks/Wizard-B_CPW1V6.cjs +2 -0
- package/dist/chunks/Wizard-B_CPW1V6.cjs.map +1 -0
- package/dist/chunks/Wizard-C1iR5z44.js +99 -0
- package/dist/chunks/Wizard-C1iR5z44.js.map +1 -0
- package/dist/chunks/frame-C8TwdWBC.cjs +2 -0
- package/dist/chunks/frame-C8TwdWBC.cjs.map +1 -0
- package/dist/chunks/frame-DaC03_n-.js +203 -0
- package/dist/chunks/frame-DaC03_n-.js.map +1 -0
- package/dist/chunks/{group-Ckz4Xya-.js → group-C6EOgTgM.js} +2 -2
- package/dist/chunks/{group-Ckz4Xya-.js.map → group-C6EOgTgM.js.map} +1 -1
- package/dist/chunks/{group-Bj9ZKc0R.cjs → group-QSnlx4jX.cjs} +2 -2
- package/dist/chunks/{group-Bj9ZKc0R.cjs.map → group-QSnlx4jX.cjs.map} +1 -1
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.js +1 -1
- package/dist/components/CollectionView/empty.d.cts +15 -0
- package/dist/components/CollectionView/empty.d.cts.map +1 -0
- package/dist/components/CollectionView/empty.d.ts +15 -0
- package/dist/components/CollectionView/empty.d.ts.map +1 -0
- package/dist/components/CollectionView/filters.d.cts +6 -0
- package/dist/components/CollectionView/filters.d.cts.map +1 -0
- package/dist/components/CollectionView/filters.d.ts +6 -0
- package/dist/components/CollectionView/filters.d.ts.map +1 -0
- package/dist/components/CollectionView/index.cjs +1 -0
- package/dist/components/CollectionView/index.d.cts +6 -0
- package/dist/components/CollectionView/index.d.cts.map +1 -0
- package/dist/components/CollectionView/index.d.ts +6 -0
- package/dist/components/CollectionView/index.d.ts.map +1 -0
- package/dist/components/CollectionView/index.js +2 -0
- package/dist/components/CollectionView/style.css +70 -0
- package/dist/components/CollectionView/toolbar.d.cts +5 -0
- package/dist/components/CollectionView/toolbar.d.cts.map +1 -0
- package/dist/components/CollectionView/toolbar.d.ts +5 -0
- package/dist/components/CollectionView/toolbar.d.ts.map +1 -0
- package/dist/components/CollectionView/types.d.cts +40 -0
- package/dist/components/CollectionView/types.d.cts.map +1 -0
- package/dist/components/CollectionView/types.d.ts +40 -0
- package/dist/components/CollectionView/types.d.ts.map +1 -0
- package/dist/components/EditLayout/style.css +1 -1
- package/dist/components/EditSection/index.cjs +2 -0
- package/dist/components/EditSection/index.cjs.map +1 -0
- package/dist/components/EditSection/index.d.cts +9 -0
- package/dist/components/EditSection/index.d.cts.map +1 -0
- package/dist/components/EditSection/index.d.ts +9 -0
- package/dist/components/EditSection/index.d.ts.map +1 -0
- package/dist/components/EditSection/index.js +22 -0
- package/dist/components/EditSection/index.js.map +1 -0
- package/dist/components/EditSection/style.css +31 -0
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/Field/frame.d.cts +1 -1
- package/dist/components/Field/frame.d.cts.map +1 -1
- package/dist/components/Field/frame.d.ts +1 -1
- package/dist/components/Field/frame.d.ts.map +1 -1
- package/dist/components/Field/header.d.cts +5 -3
- package/dist/components/Field/header.d.cts.map +1 -1
- package/dist/components/Field/header.d.ts +5 -3
- package/dist/components/Field/header.d.ts.map +1 -1
- package/dist/components/Field/index.cjs +1 -1
- package/dist/components/Field/index.js +1 -1
- package/dist/components/Field/style.css +18 -0
- package/dist/components/Field/types.d.cts +2 -0
- package/dist/components/Field/types.d.cts.map +1 -1
- package/dist/components/Field/types.d.ts +2 -0
- package/dist/components/Field/types.d.ts.map +1 -1
- package/dist/components/FormEditor/README.md +25 -0
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/FormEditor/model.d.cts +1 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +1 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/LoadState/error.d.cts +13 -0
- package/dist/components/LoadState/error.d.cts.map +1 -0
- package/dist/components/LoadState/error.d.ts +13 -0
- package/dist/components/LoadState/error.d.ts.map +1 -0
- package/dist/components/LoadState/index.cjs +1 -0
- package/dist/components/LoadState/index.d.cts +15 -0
- package/dist/components/LoadState/index.d.cts.map +1 -0
- package/dist/components/LoadState/index.d.ts +15 -0
- package/dist/components/LoadState/index.d.ts.map +1 -0
- package/dist/components/LoadState/index.js +1 -0
- package/dist/components/LoadState/types.d.cts +3 -0
- package/dist/components/LoadState/types.d.cts.map +1 -0
- package/dist/components/LoadState/types.d.ts +3 -0
- package/dist/components/LoadState/types.d.ts.map +1 -0
- package/dist/components/LoadState/useRetryAttempt.d.cts +15 -0
- package/dist/components/LoadState/useRetryAttempt.d.cts.map +1 -0
- package/dist/components/LoadState/useRetryAttempt.d.ts +15 -0
- package/dist/components/LoadState/useRetryAttempt.d.ts.map +1 -0
- package/dist/components/MetaList/index.cjs +2 -0
- package/dist/components/MetaList/index.cjs.map +1 -0
- package/dist/components/MetaList/index.d.cts +7 -0
- package/dist/components/MetaList/index.d.cts.map +1 -0
- package/dist/components/MetaList/index.d.ts +7 -0
- package/dist/components/MetaList/index.d.ts.map +1 -0
- package/dist/components/MetaList/index.js +13 -0
- package/dist/components/MetaList/index.js.map +1 -0
- package/dist/components/MetaList/style.css +19 -0
- package/dist/components/PageHeader/index.cjs +2 -0
- package/dist/components/PageHeader/index.cjs.map +1 -0
- package/dist/components/PageHeader/index.d.cts +9 -0
- package/dist/components/PageHeader/index.d.cts.map +1 -0
- package/dist/components/PageHeader/index.d.ts +9 -0
- package/dist/components/PageHeader/index.d.ts.map +1 -0
- package/dist/components/PageHeader/index.js +27 -0
- package/dist/components/PageHeader/index.js.map +1 -0
- package/dist/components/PageHeader/style.css +39 -0
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.js +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.cjs.map +1 -1
- package/dist/components/Stepper/index.d.cts +8 -0
- package/dist/components/Stepper/index.d.cts.map +1 -1
- package/dist/components/Stepper/index.d.ts +8 -0
- package/dist/components/Stepper/index.d.ts.map +1 -1
- package/dist/components/Stepper/index.js +15 -14
- package/dist/components/Stepper/index.js.map +1 -1
- package/dist/components/Stepper/style.css +53 -0
- package/dist/components/Wizard/actions.d.cts +13 -0
- package/dist/components/Wizard/actions.d.cts.map +1 -0
- package/dist/components/Wizard/actions.d.ts +13 -0
- package/dist/components/Wizard/actions.d.ts.map +1 -0
- package/dist/components/Wizard/index.cjs +1 -0
- package/dist/components/Wizard/index.d.cts +7 -0
- package/dist/components/Wizard/index.d.cts.map +1 -0
- package/dist/components/Wizard/index.d.ts +7 -0
- package/dist/components/Wizard/index.d.ts.map +1 -0
- package/dist/components/Wizard/index.js +2 -0
- package/dist/components/Wizard/review-table.d.cts +13 -0
- package/dist/components/Wizard/review-table.d.cts.map +1 -0
- package/dist/components/Wizard/review-table.d.ts +13 -0
- package/dist/components/Wizard/review-table.d.ts.map +1 -0
- package/dist/components/Wizard/style.css +13 -0
- package/dist/components/Wizard/types.d.cts +35 -0
- package/dist/components/Wizard/types.d.cts.map +1 -0
- package/dist/components/Wizard/types.d.ts +35 -0
- package/dist/components/Wizard/types.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -30
- package/dist/styles.css +5 -0
- package/package.json +1 -1
- package/dist/chunks/FormEditor-BSfxVqLn.js.map +0 -1
- package/dist/chunks/FormEditor-DNcSAnRF.cjs.map +0 -1
- package/dist/chunks/frame-BBVQTBcX.cjs +0 -2
- package/dist/chunks/frame-BBVQTBcX.cjs.map +0 -1
- package/dist/chunks/frame-De6IuTQz.js +0 -189
- package/dist/chunks/frame-De6IuTQz.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntryPicker-D7JIgx23.cjs","names":["Icon","useState","useMemo","_Fragment","FieldGroup","SortableList","SortableListItem","Button","Modal","SearchField","require_Icon","require_components_Button_index","require_components_Modal_index","require_group","require_components_SearchField_index","require_components_SortableList_index","react","react_jsx_runtime","selectionLimit","mode","max","cx","parts","matches","query","item","Thumb","EntryPicker","fieldProps","internal","setInternal","defaultValue","selected","value","isOpen","setOpen","setQuery","byId","items","results","atMax","commit","isDisabled","next","onValueChange","toggle","id","chosen","canReorder","isReorderable","row","className","emptyLabel","addLabel","itemLabel","itemsLabel","event","isSelected","isBlocked"],"sources":["../../src/components/EntryPicker/limit.ts","../../src/components/EntryPicker/index.tsx"],"sourcesContent":["import type { FieldLimit } from \"../Field/types\";\nimport type { EntryPickerMode } from \".\";\n\n/**\n * Only an explicitly capped multiple selection has a usage limit. Pure, so\n * FormEditor's model derives the same server-rendered limit the picker reports.\n */\nexport function selectionLimit(\n mode: EntryPickerMode,\n count: number,\n max: number | undefined,\n): FieldLimit | undefined {\n return mode === \"multiple\" && max !== undefined ? { count, max } : undefined;\n}\n","import { useMemo, useState, type ReactNode } from \"react\";\nimport { FieldGroup, type FieldGroupProps } from \"../Field/group\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { Modal } from \"../Modal\";\nimport { SearchField } from \"../SearchField\";\nimport { SortableList, SortableListItem } from \"../SortableList\";\nimport { selectionLimit } from \"./limit\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface EntryItem {\n id: string;\n title: string;\n /** Second line — a content type, a path, a file size. */\n subtitle?: string;\n /** Main image: an asset thumbnail, or the entry's hero. */\n imageUrl?: string;\n /** Words the search matches on top of the title and subtitle. */\n keywords?: string[];\n isDisabled?: boolean;\n}\n\nexport type EntryPickerMode = \"single\" | \"multiple\";\n\nexport interface EntryPickerProps extends Omit<FieldGroupProps, \"children\" | \"label\" | \"count\"> {\n items: EntryItem[];\n /** Selected ids, in the order they will be stored. */\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[]) => void;\n mode?: EntryPickerMode;\n /** Cap a multiple selection. Reaching it disables the unpicked rows. */\n max?: number;\n label?: string;\n /** Copy shown when nothing is picked yet. */\n emptyLabel?: string;\n addLabel?: string;\n itemLabel?: string;\n itemsLabel?: string;\n /** Multiple selections are reorderable by default — the stored order is the shown order. */\n isReorderable?: boolean;\n isDisabled?: boolean;\n className?: string;\n}\n\nfunction matches(item: EntryItem, query: string) {\n if (!query) {\n return true;\n }\n const haystack = [item.title, item.subtitle, ...(item.keywords ?? [])]\n .filter(Boolean)\n .join(\" \")\n .toLowerCase();\n return haystack.includes(query.toLowerCase());\n}\n\nfunction Thumb({ item }: { item: EntryItem }) {\n return (\n <span className=\"ds-entry__thumb\">\n {item.imageUrl ? (\n <img\n src={item.imageUrl}\n alt=\"\"\n loading=\"lazy\"\n />\n ) : (\n <Icon\n name=\"file-text\"\n size={20}\n />\n )}\n </span>\n );\n}\n\n/**\n * Pick entries or assets out of a list. Search narrows it, a row toggles,\n * and a multiple selection keeps — and reorders — the order you chose.\n */\nexport function EntryPicker({\n items,\n value,\n defaultValue = [],\n onValueChange,\n mode = \"multiple\",\n max,\n label = \"Entries\",\n emptyLabel = \"Nothing selected yet.\",\n addLabel = \"Choose entries\",\n itemLabel = \"entry\",\n itemsLabel = \"entries\",\n isReorderable = true,\n isDisabled = false,\n className,\n ...fieldProps\n}: EntryPickerProps) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const selected = value ?? internal;\n const [isOpen, setOpen] = useState(false);\n const [query, setQuery] = useState(\"\");\n\n const byId = useMemo(() => new Map(items.map((item) => [item.id, item])), [items]);\n const results = useMemo(() => items.filter((item) => matches(item, query)), [items, query]);\n const atMax = mode === \"multiple\" && max !== undefined && selected.length >= max;\n\n const commit = (next: string[]) => {\n if (isDisabled) {\n return;\n }\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n\n const toggle = (id: string) => {\n if (mode === \"single\") {\n commit(selected[0] === id ? [] : [id]);\n setOpen(false);\n return;\n }\n if (selected.includes(id)) {\n commit(selected.filter((item) => item !== id));\n } else if (!atMax) {\n commit([...selected, id]);\n }\n };\n\n const chosen = selected.map((id) => byId.get(id) ?? { id, title: id });\n const canReorder = isReorderable && mode === \"multiple\" && chosen.length > 1;\n\n const row = (item: EntryItem): ReactNode => (\n <>\n <Thumb item={item} />\n <span className=\"ds-entry__body\">\n <span className=\"ds-entry__title\">{item.title}</span>\n {item.subtitle && <span className=\"ds-entry__subtitle\">{item.subtitle}</span>}\n </span>\n </>\n );\n\n return (\n <FieldGroup\n {...fieldProps}\n className={cx(\"ds-entry-picker\", className)}\n label={label}\n count={selected.length}\n limit={fieldProps.limit ?? selectionLimit(mode, selected.length, max)}\n >\n {chosen.length === 0 ? (\n <p className=\"ds-entry-picker__empty\">{emptyLabel}</p>\n ) : canReorder ? (\n <SortableList\n items={selected}\n onReorder={commit}\n isDisabled={isDisabled}\n >\n {chosen.map((item) => (\n <SortableListItem\n key={item.id}\n id={item.id}\n label={item.title}\n action={\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${item.title}`}\n isDisabled={isDisabled}\n onClick={() => commit(selected.filter((id) => id !== item.id))}\n />\n }\n >\n <div className=\"ds-entry\">{row(item)}</div>\n </SortableListItem>\n ))}\n </SortableList>\n ) : (\n <ul className=\"ds-entry-picker__list\">\n {chosen.map((item) => (\n <li\n key={item.id}\n className=\"ds-entry-picker__row\"\n >\n <div className=\"ds-entry\">{row(item)}</div>\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${item.title}`}\n isDisabled={isDisabled}\n onClick={() => commit(selected.filter((id) => id !== item.id))}\n />\n </li>\n ))}\n </ul>\n )}\n\n <div className=\"ds-entry-picker__actions\">\n <Button\n variant=\"neutral\"\n size=\"sm\"\n iconStart=\"plus\"\n isDisabled={isDisabled}\n onClick={() => setOpen(true)}\n >\n {addLabel}\n </Button>\n {selected.length > 0 && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isDisabled={isDisabled}\n onClick={() => commit([])}\n >\n Clear\n </Button>\n )}\n </div>\n\n <Modal\n isOpen={isOpen}\n onClose={() => setOpen(false)}\n title={addLabel}\n description={\n mode === \"single\"\n ? `Choose one ${itemLabel}.`\n : max !== undefined\n ? `Choose up to ${max} ${itemsLabel}.`\n : `Choose as many ${itemsLabel} as you need.`\n }\n footer={\n <Button\n variant=\"primary\"\n onClick={() => setOpen(false)}\n >\n Done\n </Button>\n }\n >\n <div className=\"ds-entry-picker__search\">\n <SearchField\n value={query}\n placeholder={`Search ${itemsLabel}`}\n onChange={(event) => setQuery(event.target.value)}\n onClear={() => setQuery(\"\")}\n />\n </div>\n <ul className=\"ds-entry-picker__results\">\n {results.map((item) => {\n const isSelected = selected.includes(item.id);\n const isBlocked = isDisabled || item.isDisabled || (!isSelected && atMax);\n return (\n <li key={item.id}>\n <Button\n variant={isSelected ? \"active\" : \"simple\"}\n size=\"lg\"\n className=\"ds-entry-picker__result\"\n aria-pressed={isSelected}\n isDisabled={Boolean(isBlocked)}\n onClick={() => toggle(item.id)}\n >\n <span className=\"ds-entry\">{row(item)}</span>\n {isSelected && (\n <Icon\n name=\"check\"\n size={20}\n />\n )}\n </Button>\n </li>\n );\n })}\n {results.length === 0 && (\n <li className=\"ds-entry-picker__no-results\">\n No {itemsLabel} match “{query}”.\n </li>\n )}\n </ul>\n </Modal>\n </FieldGroup>\n );\n}\n"],"mappings":"A,yTAOA,SAAgBkB,EACd,EACA,EACA,EACwB,CACxB,OAAOC,IAAS,YAAcC,IAAQ,IAAA,GAAY,CAAE,QAAO,KAAI,EAAI,IAAA,EACrE,CCHA,SAASC,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAqCA,SAASC,EAAQ,EAAiB,EAAe,CAQ/C,MAPA,CAAKC,GAGY,CAACC,EAAK,MAAOA,EAAK,SAAU,GAAIA,EAAK,UAAY,CAAC,CAAE,CAAC,CACnE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG,CAAC,CACT,YACI,CAAA,CAAS,SAASD,EAAM,YAAY,CAAC,CAC9C,CAEA,SAASE,EAAM,CAAE,QAA6B,CAC5C,OACE,EAAAT,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,kBACb,SAAA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on","useState","useMemo","_Fragment","FieldGroup","SortableList","SortableListItem","Button","Modal","SearchField","require_Icon","require_components_Button_index","require_components_Modal_index","require_group","require_components_SearchField_index","require_components_SortableList_index","react","react_jsx_runtime","selectionLimit","mode","max","cx","parts","matches","query","item","Thumb","EntryPicker","fieldProps","internal","setInternal","defaultValue","selected","value","isOpen","setOpen","setQuery","byId","items","results","atMax","commit","isDisabled","next","onValueChange","toggle","id","chosen","canReorder","isReorderable","row","className","emptyLabel","addLabel","itemLabel","itemsLabel","event","isSelected","isBlocked"],"sources":["../../src/components/EntryPicker/limit.ts","../../src/components/EntryPicker/index.tsx"],"sourcesContent":["import type { FieldLimit } from \"../Field/types\";\nimport type { EntryPickerMode } from \".\";\n\n/**\n * Only an explicitly capped multiple selection has a usage limit. Pure, so\n * FormEditor's model derives the same server-rendered limit the picker reports.\n */\nexport function selectionLimit(\n mode: EntryPickerMode,\n count: number,\n max: number | undefined,\n): FieldLimit | undefined {\n return mode === \"multiple\" && max !== undefined ? { count, max } : undefined;\n}\n","import { useMemo, useState, type ReactNode } from \"react\";\nimport { FieldGroup, type FieldGroupProps } from \"../Field/group\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { Modal } from \"../Modal\";\nimport { SearchField } from \"../SearchField\";\nimport { SortableList, SortableListItem } from \"../SortableList\";\nimport { selectionLimit } from \"./limit\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface EntryItem {\n id: string;\n title: string;\n /** Second line — a content type, a path, a file size. */\n subtitle?: string;\n /** Main image: an asset thumbnail, or the entry's hero. */\n imageUrl?: string;\n /** Words the search matches on top of the title and subtitle. */\n keywords?: string[];\n isDisabled?: boolean;\n}\n\nexport type EntryPickerMode = \"single\" | \"multiple\";\n\nexport interface EntryPickerProps extends Omit<FieldGroupProps, \"children\" | \"label\" | \"count\"> {\n items: EntryItem[];\n /** Selected ids, in the order they will be stored. */\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[]) => void;\n mode?: EntryPickerMode;\n /** Cap a multiple selection. Reaching it disables the unpicked rows. */\n max?: number;\n label?: string;\n /** Copy shown when nothing is picked yet. */\n emptyLabel?: string;\n addLabel?: string;\n itemLabel?: string;\n itemsLabel?: string;\n /** Multiple selections are reorderable by default — the stored order is the shown order. */\n isReorderable?: boolean;\n isDisabled?: boolean;\n className?: string;\n}\n\nfunction matches(item: EntryItem, query: string) {\n if (!query) {\n return true;\n }\n const haystack = [item.title, item.subtitle, ...(item.keywords ?? [])]\n .filter(Boolean)\n .join(\" \")\n .toLowerCase();\n return haystack.includes(query.toLowerCase());\n}\n\nfunction Thumb({ item }: { item: EntryItem }) {\n return (\n <span className=\"ds-entry__thumb\">\n {item.imageUrl ? (\n <img\n src={item.imageUrl}\n alt=\"\"\n loading=\"lazy\"\n />\n ) : (\n <Icon\n name=\"file-text\"\n size={20}\n />\n )}\n </span>\n );\n}\n\n/**\n * Pick entries or assets out of a list. Search narrows it, a row toggles,\n * and a multiple selection keeps — and reorders — the order you chose.\n */\nexport function EntryPicker({\n items,\n value,\n defaultValue = [],\n onValueChange,\n mode = \"multiple\",\n max,\n label = \"Entries\",\n emptyLabel = \"Nothing selected yet.\",\n addLabel = \"Choose entries\",\n itemLabel = \"entry\",\n itemsLabel = \"entries\",\n isReorderable = true,\n isDisabled = false,\n className,\n ...fieldProps\n}: EntryPickerProps) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const selected = value ?? internal;\n const [isOpen, setOpen] = useState(false);\n const [query, setQuery] = useState(\"\");\n\n const byId = useMemo(() => new Map(items.map((item) => [item.id, item])), [items]);\n const results = useMemo(() => items.filter((item) => matches(item, query)), [items, query]);\n const atMax = mode === \"multiple\" && max !== undefined && selected.length >= max;\n\n const commit = (next: string[]) => {\n if (isDisabled) {\n return;\n }\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n\n const toggle = (id: string) => {\n if (mode === \"single\") {\n commit(selected[0] === id ? [] : [id]);\n setOpen(false);\n return;\n }\n if (selected.includes(id)) {\n commit(selected.filter((item) => item !== id));\n } else if (!atMax) {\n commit([...selected, id]);\n }\n };\n\n const chosen = selected.map((id) => byId.get(id) ?? { id, title: id });\n const canReorder = isReorderable && mode === \"multiple\" && chosen.length > 1;\n\n const row = (item: EntryItem): ReactNode => (\n <>\n <Thumb item={item} />\n <span className=\"ds-entry__body\">\n <span className=\"ds-entry__title\">{item.title}</span>\n {item.subtitle && <span className=\"ds-entry__subtitle\">{item.subtitle}</span>}\n </span>\n </>\n );\n\n return (\n <FieldGroup\n {...fieldProps}\n className={cx(\"ds-entry-picker\", className)}\n label={label}\n count={selected.length}\n limit={fieldProps.limit ?? selectionLimit(mode, selected.length, max)}\n >\n {chosen.length === 0 ? (\n <p className=\"ds-entry-picker__empty\">{emptyLabel}</p>\n ) : canReorder ? (\n <SortableList\n items={selected}\n onReorder={commit}\n isDisabled={isDisabled}\n >\n {chosen.map((item) => (\n <SortableListItem\n key={item.id}\n id={item.id}\n label={item.title}\n action={\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${item.title}`}\n isDisabled={isDisabled}\n onClick={() => commit(selected.filter((id) => id !== item.id))}\n />\n }\n >\n <div className=\"ds-entry\">{row(item)}</div>\n </SortableListItem>\n ))}\n </SortableList>\n ) : (\n <ul className=\"ds-entry-picker__list\">\n {chosen.map((item) => (\n <li\n key={item.id}\n className=\"ds-entry-picker__row\"\n >\n <div className=\"ds-entry\">{row(item)}</div>\n <Button\n variant=\"simple\"\n size=\"sm\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${item.title}`}\n isDisabled={isDisabled}\n onClick={() => commit(selected.filter((id) => id !== item.id))}\n />\n </li>\n ))}\n </ul>\n )}\n\n <div className=\"ds-entry-picker__actions\">\n <Button\n variant=\"neutral\"\n size=\"sm\"\n iconStart=\"plus\"\n isDisabled={isDisabled}\n onClick={() => setOpen(true)}\n >\n {addLabel}\n </Button>\n {selected.length > 0 && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isDisabled={isDisabled}\n onClick={() => commit([])}\n >\n Clear\n </Button>\n )}\n </div>\n\n <Modal\n isOpen={isOpen}\n onClose={() => setOpen(false)}\n title={addLabel}\n description={\n mode === \"single\"\n ? `Choose one ${itemLabel}.`\n : max !== undefined\n ? `Choose up to ${max} ${itemsLabel}.`\n : `Choose as many ${itemsLabel} as you need.`\n }\n footer={\n <Button\n variant=\"primary\"\n onClick={() => setOpen(false)}\n >\n Done\n </Button>\n }\n >\n <div className=\"ds-entry-picker__search\">\n <SearchField\n value={query}\n placeholder={`Search ${itemsLabel}`}\n onChange={(event) => setQuery(event.target.value)}\n onClear={() => setQuery(\"\")}\n />\n </div>\n <ul className=\"ds-entry-picker__results\">\n {results.map((item) => {\n const isSelected = selected.includes(item.id);\n const isBlocked = isDisabled || item.isDisabled || (!isSelected && atMax);\n return (\n <li key={item.id}>\n <Button\n variant={isSelected ? \"active\" : \"simple\"}\n size=\"lg\"\n className=\"ds-entry-picker__result\"\n aria-pressed={isSelected}\n isDisabled={Boolean(isBlocked)}\n onClick={() => toggle(item.id)}\n >\n <span className=\"ds-entry\">{row(item)}</span>\n {isSelected && (\n <Icon\n name=\"check\"\n size={20}\n />\n )}\n </Button>\n </li>\n );\n })}\n {results.length === 0 && (\n <li className=\"ds-entry-picker__no-results\">\n No {itemsLabel} match “{query}”.\n </li>\n )}\n </ul>\n </Modal>\n </FieldGroup>\n );\n}\n"],"mappings":"A,yTAOA,SAAgBkB,EACd,EACA,EACA,EACwB,CACxB,OAAOC,IAAS,YAAcC,IAAQ,IAAA,GAAY,CAAE,QAAO,KAAI,EAAI,IAAA,EACrE,CCHA,SAASC,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAqCA,SAASC,EAAQ,EAAiB,EAAe,CAQ/C,MAPA,CAAKC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A,EAjBKyB,EAAK,EAiBV,CAER,CAAC,EACAc,EAAQ,SAAW,IAClB,EAAAtB,EAAA,KAAA,CAAC,KAAD,CAAI,UAAU,8BAAd,SAAA,CAA4C,MACtCsC,EAAW,WAAS/B,EAAM,IAC5B,CAEJ,CAAA,CAAA,CACC,CAAA,CAAA,C,EACG,C,EAEhB,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./colour-BmtxDlWF.cjs"),t=require("../components/Button/index.cjs"),n=require("../components/Field/index.cjs"),r=require("../components/TextField/index.cjs"),i=require("./RichTextEditor-DAnjElUO.cjs"),a=require("../components/Container/index.cjs"),o=require("./EntryPicker-D7JIgx23.cjs"),s=require("../components/NumberField/index.cjs"),c=require("../components/Select/index.cjs"),l=require("../components/Switch/index.cjs"),u=require("./ColourField-NnFxLEsh.cjs"),d=require("./Slider-k8weRl34.cjs"),f=require("./DatePicker-01sor8iD.cjs"),p=require("../components/TagsInput/index.cjs"),m=require("../components/Choice/index.cjs"),h=require("../components/SelectionCard/index.cjs");let g=require("react"),_=require("react/jsx-runtime");var v=[`wide`,`full`],y=[`sm`,`md`,`lg`],b=new Set([`shortText`,`longText`,`richText`,`number`,`boolean`,`dateTime`,`asset`,`reference`,`select`,`slider`,`rangeSlider`,`colour`,`radioGroup`,`checkboxGroup`,`tags`,`date`,`divider`]);function x(e){let t=new Set;for(let n of e.fields){if(!n.id?.trim()||t.has(n.id))throw Error(`Form field IDs must be nonempty and unique.`);if(!b.has(n.type))throw Error(`Unsupported form field type: ${n.type}`);(n.type===`select`||n.type===`radioGroup`||n.type===`checkboxGroup`)&&ee(n),(n.type===`slider`||n.type===`rangeSlider`)&&A(n),n.type!==`divider`&&(k(n),w(n)),t.add(n.id)}}var S=new Set([`shortText`,`longText`,`tags`,`asset`,`reference`]);function C(e){return S.has(e.type)}function w(e){if(C(e)){if(e.limitDisplay!==void 0&&![`used`,`remaining`].includes(e.limitDisplay))throw Error(`Field ${e.id} needs a limitDisplay of used or remaining.`);if(e.limitVisibility!==void 0&&![`always`,`nearLimit`].includes(e.limitVisibility))throw Error(`Field ${e.id} needs a limitVisibility of always or nearLimit.`);if(e.showLimitRing!==void 0&&typeof e.showLimitRing!=`boolean`)throw Error(`Field ${e.id} needs a boolean showLimitRing.`)}}function T(e,t,n){return C(e)?{limitDisplay:e.limitDisplay,limitVisibility:e.limitVisibility,showLimitRing:e.showLimitRing,limit:E(e,t,n??[])}:{}}function E(e,t,n){switch(e.type){case`shortText`:case`longText`:return e.maxLength===void 0?void 0:{count:D(t).length,max:e.maxLength};case`tags`:return e.max===void 0?void 0:{count:H(t).length,max:e.max};default:return o.n(O(e),n.length,N(e).max)}}function D(e){return typeof e==`string`?e:``}function O(e){return e.multiple?`multiple`:`single`}function k(e){if(e.width!==void 0&&!y.includes(e.width))throw Error(`Field ${e.id} needs a width of sm, md or lg.`);if(e.type===`richText`&&e.expandedWidth!==void 0&&!v.includes(e.expandedWidth))throw Error(`Rich text field ${e.id} needs an expandedWidth of wide or full.`)}function A(e){let{min:t,max:n,step:r}=d.a(e);if(![t,n,r].every(Number.isFinite)||t>=n||r<=0)throw Error(`Slider field ${e.id} needs finite min < max and a positive step.`);if(e.type===`rangeSlider`&&r>d.i(n,-t))throw Error(`Range slider ${e.id} needs room for at least one step.`)}function ee(e){if(!Array.isArray(e.options)){let t=e.type===`select`?`Select`:`Choice`;throw Error(`${t} field ${e.id} needs an options array.`)}if(e.type===`select`)return;let t=e.options.map(e=>e.value);if(t.some(e=>typeof e!=`string`||!e.trim())||new Set(t).size!==t.length)throw Error(`Choice field ${e.id} needs nonempty, unique option values.`)}var j={asset:{key:`assetId`,itemLabel:`asset`,itemsLabel:`assets`},reference:{key:`entryId`,itemLabel:`entry`,itemsLabel:`entries`}};function M(e){return e.type===`asset`||e.type===`reference`?e.picker?.label??e.label:e.label}function N(e){let t=j[e.type],{addLabel:n=`Choose ${M(e)}`,emptyLabel:r,itemLabel:i=t.itemLabel,itemsLabel:a=t.itemsLabel,max:o,isReorderable:s}=e.picker??{};return{addLabel:n,emptyLabel:r,itemLabel:i,itemsLabel:a,max:o,isReorderable:s}}function P(e,t){let{key:n}=j[e.type];return(Array.isArray(t)?t:t===void 0?[]:[t]).flatMap(e=>I(e,n)?[e[n]]:[])}function F(e){if(typeof e!=`string`)return;let t=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(?:Z|\+00:00)$/.exec(e);if(!t)return;let n=`${t[1]}:${t[2]??`00`}.${(t[3]??``).padEnd(3,`0`)}Z`,r=new Date(n);if(Number.isFinite(r.getTime())&&r.toISOString()===n)return n}function I(e,t){return!!e&&typeof e==`object`&&t in e&&typeof e[t]==`string`&&e[t].trim().length>0}function L(e){return!!e.text?.trim()||e.type===`horizontalRule`||!!e.content?.some(L)}function R(e){return`${M(e)} is required.`}function z(e,t){if(typeof t!=`string`)return`Enter text.`;if(e.required&&!t.trim())return R(e);if((e.type===`shortText`||e.type===`longText`)&&e.maxLength!==void 0&&t.length>e.maxLength)return`Enter no more than ${e.maxLength} characters.`}function B(e,t){let n=i.n(t);if(n)return n;if(e.required&&!L(t))return R(e)}function V(e,t){if(typeof t!=`string`)return`Choose an available option.`;if(t===``)return e.required?R(e):void 0;if((e.type===`select`||e.type===`radioGroup`)&&e.options.length>0&&!e.options.some(e=>e.value===t))return`Choose an available option.`}function H(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function U(e,t){if(!Array.isArray(t)||!t.every(e=>typeof e==`string`&&e.trim())||new Set(t).size!==t.length)return`Enter a list of unique, nonempty text values.`;if(e.required&&!t.length)return R(e);if(e.type===`tags`&&e.max!==void 0&&t.length>e.max)return`Enter no more than ${e.max} tags.`;if(e.type===`checkboxGroup`&&e.options.length&&t.some(t=>!e.options.some(e=>e.value===t)))return`Choose available options.`}function W(e,t){if(typeof t!=`number`||!Number.isFinite(t))return`Enter a finite number.`;let{min:n,max:r}=e.type===`slider`||e.type===`rangeSlider`?d.a(e):e.type===`number`?e:{};if(n!==void 0&&t<n)return`Enter a number of at least ${n}.`;if(r!==void 0&&t>r)return`Enter a number no greater than ${r}.`}function G(e,t){if(typeof t!=`string`)return`Enter a valid calendar date (YYYY-MM-DD).`;if(!t)return e.required?R(e):void 0;if(!f.a(t))return`Enter a valid calendar date (YYYY-MM-DD).`;if(e.type===`date`){if(e.min&&t<e.min)return`Choose a date on or after ${e.min}.`;if(e.max&&t>e.max)return`Choose a date on or before ${e.max}.`}}function K(e,t){return typeof e==`number`&&Number.isFinite(e)?d.r(e,t):void 0}function q(e,t){let n=e,r=K(n?.min,t),i=K(n?.max,t);if(r===void 0&&i===void 0)return;let[a,o]=[r??t.min,i??t.max].sort((e,t)=>e-t);return{min:a,max:o}}function J(e,t){if(!t||typeof t!=`object`||Array.isArray(t))return`Enter a range.`;let n=t,r=n.min,i=n.max,a=W(e,r)??W(e,i);if(a)return a;if(r>i)return`The start must not be greater than the end.`;if(e.type===`rangeSlider`&&d.i(i,-r)<d.a(e).step)return`Keep the range endpoints at least one step apart.`}function Y(t,n){return typeof n==`string`?n.trim()?e.i(n)?void 0:`Enter a valid colour.`:t.required?R(t):void 0:`Enter a valid colour.`}function X(e,t){if(e.type!==`asset`&&e.type!==`reference`)return;let{key:n,itemLabel:r,itemsLabel:i}=j[e.type];if(!e.multiple)return I(t,n)?void 0:`Choose an ${r}.`;if(!Array.isArray(t)||!t.every(e=>I(e,n)))return`Choose a list of ${i}.`;if(e.required&&t.length===0)return R(e);let a=e.picker?.max;if(a!==void 0&&t.length>a)return`Choose no more than ${a} ${N(e).itemsLabel}.`}var Z={shortText:z,longText:z,richText:B,number:W,slider:W,rangeSlider:J,date:G,colour:Y,radioGroup:V,checkboxGroup:U,tags:U,boolean:(e,t)=>typeof t==`boolean`?void 0:`Choose a boolean value.`,dateTime:(e,t)=>F(t)?void 0:`Enter a valid UTC date and time.`,select:V,asset:X,reference:X};function Q(e,t){return t===void 0?e.required?R(e):void 0:Z[e.type](e,t)}function te(e,t){return x(e),Object.fromEntries(e.fields.flatMap(e=>{if(e.type===`divider`)return[];let n=Q(e,Object.hasOwn(t,e.id)?t[e.id]:void 0);return n?[[e.id,n]]:[]}))}function ne({field:e,option:t,name:n,checked:r,isDisabled:i,invalid:a,onChange:o}){let s={name:n,value:t.value,checked:r,disabled:i||t.isDisabled,"aria-invalid":a,onChange:()=>{!i&&!t.isDisabled&&o()}};if(e.appearance===`card`){let n=e.type===`radioGroup`?h.RadioCard:h.CheckboxCard;return(0,_.jsx)(n,{...s,title:t.label,description:t.description})}let c=e.type===`radioGroup`?m.Radio:m.Checkbox;return(0,_.jsx)(c,{...s,children:(0,_.jsxs)(`span`,{children:[t.label,t.description&&(0,_.jsx)(`span`,{className:`ds-form-editor__option-description`,children:t.description})]})})}function re({field:e,stored:n,isDisabled:r,required:i,accessibility:a,onChange:o}){let s=e.type===`checkboxGroup`,c=s?H(n):typeof n==`string`&&n?[n]:[],l=e.appearance===`card`?h.SelectionCardGroup:m.ChoiceGroup;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(l,{...a,label:e.label,columns:e.columns??(e.appearance===`card`?2:1),children:e.options.map(t=>(0,_.jsx)(ne,{field:e,option:t,name:a.id,checked:c.includes(t.value),isDisabled:r,invalid:a[`aria-invalid`],onChange:()=>{o(s?c.includes(t.value)?c.filter(e=>e!==t.value):[...c,t.value]:t.value)}},t.value))}),!s&&!i&&c.length>0&&(0,_.jsxs)(t.Button,{variant:`simple`,size:`sm`,isDisabled:r,onClick:()=>o(void 0),children:[`Clear `,e.label]})]})}function ie({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=d.a(e),o=K(t,a);return(0,_.jsx)(d.n,{...r,...a,prefix:e.prefix,suffix:e.suffix,hasValueLabel:e.hasValueLabel,valueText:o===void 0?e.placeholder??`Not set`:void 0,autoFocus:e.autoFocus,isDisabled:n,value:o??a.min,onValueChange:i,onValueCommit:e=>{o===void 0&&i(e)}})}function ae({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=d.a(e),o=q(t,a);return(0,_.jsx)(d.t,{...r,...a,prefix:e.prefix,suffix:e.suffix,hasValueLabel:e.hasValueLabel,minLabel:`${e.label} minimum`,maxLabel:`${e.label} maximum`,isDisabled:n,valueText:o===void 0?e.placeholder??`Not set`:void 0,hasFill:o!==void 0,value:o??{min:a.min,max:a.max},onValueChange:i,onValueCommit:e=>{o===void 0&&i(e)}})}function oe({field:t,stored:n,isDisabled:r,required:i,accessibility:a,onChange:o}){let s={stored:n,isDisabled:r,required:i,accessibility:a,onChange:o};switch(t.type){case`radioGroup`:case`checkboxGroup`:return(0,_.jsx)(re,{field:t,...s});case`rangeSlider`:return(0,_.jsx)(ae,{field:t,...s});case`slider`:return(0,_.jsx)(ie,{field:t,...s});case`colour`:return(0,_.jsx)(u.t,{...a,required:i,placeholder:t.placeholder,presets:t.presets,showPresets:t.showPresets,picker:t.picker,placement:t.placement,readOnly:t.readOnly,autoFocus:t.autoFocus,isDisabled:r,value:typeof n==`string`?n:``,onInput:t=>{let n=t.currentTarget.value;n.trim()&&!e.i(n)&&o(n)},onValueChange:e=>o(e===``?void 0:e)});case`tags`:return(0,_.jsx)(p.TagsInput,{...a,required:i,placeholder:t.placeholder,max:t.max,isDisabled:r,value:H(n),onValueChange:o});case`date`:return(0,_.jsx)(f.n,{...a,placeholder:t.placeholder,min:t.min,max:t.max,placement:t.placement,isDisabled:r,isClearable:!0,clearLabel:`Clear ${t.label}`,value:typeof n==`string`?n:``,onValueChange:e=>o(e===``?void 0:e)})}}function se(e,t){if(e.type===`asset`){let n=t.map(e=>({assetId:e}));return e.multiple?n:n[0]}let n=t.map(e=>({entryId:e}));return e.multiple?n:n[0]}function ce({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){return(0,_.jsx)(s.NumberField,{...i,required:r,isDisabled:n,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step??`any`,hasSteppers:e.hasSteppers??!1,prefix:e.prefix,suffix:e.suffix,autoFocus:e.autoFocus,decreaseLabel:`Decrease ${e.label}`,increaseLabel:`Increase ${e.label}`,value:typeof t==`number`&&Number.isFinite(t)?t:``,onValueChange:e=>{(e===``||Number.isFinite(e))&&a(e===``?void 0:e)}})}function le({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){let o=!r&&!e.options.some(e=>e.value===``);return(0,_.jsx)(c.Select,{...i,"aria-required":r||void 0,isDisabled:n,isInvalid:i[`aria-invalid`],options:o?[{value:``,label:e.placeholder??`None`},...e.options]:e.options,placeholder:e.placeholder,autoFocus:e.autoFocus,value:typeof t==`string`?t:``,onValueChange:e=>a(e===``?void 0:e)})}function ue({field:e,selected:t,items:n,isDisabled:r,accessibility:i,onChange:a}){return(0,_.jsx)(o.t,{...i,items:n,value:t,...N(e),mode:O(e),isDisabled:r,onValueChange:t=>a(se(e,t))})}function $({field:e,stored:t,selected:n,items:a,isDisabled:o,accessibility:{required:s,...c},onChange:u}){let d={stored:t,isDisabled:o,required:s,accessibility:c,onChange:u};switch(e.type){case`shortText`:return(0,_.jsx)(r.TextField,{...c,required:s,disabled:o,placeholder:e.placeholder,type:e.inputType,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:D(t),onChange:e=>u(e.target.value)});case`longText`:return(0,_.jsx)(r.TextArea,{...c,required:s,disabled:o,placeholder:e.placeholder,rows:e.rows,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:D(t),onChange:e=>u(e.target.value)});case`number`:return(0,_.jsx)(ce,{field:e,...d});case`boolean`:return(0,_.jsx)(l.Switch,{...c,isDisabled:o,autoFocus:e.autoFocus,isSelected:t===!0,onSelectedChange:u});case`dateTime`:return(0,_.jsx)(r.TextField,{...c,required:s,disabled:o,type:`datetime-local`,step:`0.001`,autoFocus:e.autoFocus,value:F(t)?.slice(0,-1)??``,onChange:e=>u(F(`${e.target.value}Z`))});case`richText`:return(0,_.jsx)(i.t,{...c,expandedWidth:e.expandedWidth,label:e.label,isRequired:s,isDisabled:o,placeholder:e.placeholder,format:`json`,value:t===void 0?i.r:t,onChange:u});case`select`:return(0,_.jsx)(le,{field:e,...d});case`asset`:case`reference`:return(0,_.jsx)(ue,{field:e,items:a,selected:n??[],...d});default:return(0,_.jsx)(oe,{field:e,...d})}}function de({field:e,stored:t,items:r,isDisabled:i,error:o,isErrorVisible:s,onChange:c}){let l=(0,g.useMemo)(()=>o===void 0&&s?Q(e,t):void 0,[o,s,e,t]),u=(0,g.useMemo)(()=>e.type===`asset`||e.type===`reference`?P(e,t):void 0,[e,t]);return(0,_.jsx)(a.Container,{width:e.width,padded:!1,center:!1,className:`ds-form-editor__field`,children:(0,_.jsx)(n.Field,{...T(e,t,u),label:e.type===`dateTime`?`${e.label} (UTC)`:M(e),hint:e.hint,error:o??l,isRequired:e.required,count:u?.length??(e.type===`checkboxGroup`?H(t).length:void 0),isGroup:u!==void 0||fe.has(e.type),children:n=>(0,_.jsx)($,{field:e,stored:t,selected:u,items:r,isDisabled:i,accessibility:n,onChange:c})})})}var fe=new Set([`radioGroup`,`checkboxGroup`,`rangeSlider`]),pe=new Set([`slider`,`rangeSlider`,`date`,`colour`]);function me({schema:e,value:t,defaultValue:n={},onValueChange:r,pickerItems:i={},errors:a={},isDisabled:o=!1,showAllErrors:s=!1,columns:c=1,minColumnWidth:l=`16rem`,className:u,style:d,...f}){let[p,m]=(0,g.useState)(n),[h,v]=(0,g.useState)(()=>new Set),y=t??p;(0,g.useMemo)(()=>x(e),[e]);let b=(e,n)=>{let i={...y};n===void 0?delete i[e]:i[e]=n,t===void 0&&m(i),v(t=>new Set(t).add(e)),r?.(i,{fieldId:e})},S=c===`auto`?{"--form-editor-min-column":l}:{"--form-editor-columns":c,"--form-editor-min-column":l};return(0,_.jsx)(`div`,{className:[`ds-form-editor`,c===`auto`&&`ds-form-editor--auto`,u].filter(Boolean).join(` `),style:{...S,...d},...f,children:e.fields.map(e=>{if(e.type===`divider`)return(0,_.jsx)(`hr`,{className:`ds-form-editor__divider`},e.id);let t=Object.hasOwn(y,e.id)?y[e.id]:void 0,n=o||!!e.isDisabled,r=n||`readOnly`in e&&!!e.readOnly,c=typeof t==`string`?t.trim()!==``:t!==void 0,l=s||h.has(e.id)||c&&pe.has(e.type)||e.type===`number`&&typeof t==`number`;return(0,_.jsx)(de,{field:e,stored:t,items:i[e.id]??[],isDisabled:n,error:a[e.id],isErrorVisible:l,onChange:t=>{r||b(e.id,t)}},e.id)})})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return me}});
|
|
2
|
-
//# sourceMappingURL=FormEditor-
|
|
1
|
+
const e=require("./colour-BmtxDlWF.cjs"),t=require("../components/Button/index.cjs"),n=require("../components/Field/index.cjs"),r=require("../components/TextField/index.cjs"),i=require("./RichTextEditor-DAnjElUO.cjs"),a=require("../components/Container/index.cjs"),o=require("./EntryPicker-daSkD4aR.cjs"),s=require("../components/NumberField/index.cjs"),c=require("../components/Select/index.cjs"),l=require("../components/Switch/index.cjs"),u=require("./ColourField-NnFxLEsh.cjs"),d=require("./Slider-k8weRl34.cjs"),f=require("./DatePicker-01sor8iD.cjs"),p=require("../components/TagsInput/index.cjs"),m=require("../components/Choice/index.cjs"),h=require("../components/SelectionCard/index.cjs");let g=require("react"),_=require("react/jsx-runtime");var v=[`wide`,`full`],y=[`sm`,`md`,`lg`],b=new Set([`shortText`,`longText`,`richText`,`number`,`boolean`,`dateTime`,`asset`,`reference`,`select`,`slider`,`rangeSlider`,`colour`,`radioGroup`,`checkboxGroup`,`tags`,`date`,`divider`]);function x(e){let t=new Set;for(let n of e.fields){if(!n.id?.trim()||t.has(n.id))throw Error(`Form field IDs must be nonempty and unique.`);if(!b.has(n.type))throw Error(`Unsupported form field type: ${n.type}`);(n.type===`select`||n.type===`radioGroup`||n.type===`checkboxGroup`)&&ee(n),(n.type===`slider`||n.type===`rangeSlider`)&&A(n),n.type!==`divider`&&(k(n),w(n)),t.add(n.id)}}var S=new Set([`shortText`,`longText`,`tags`,`asset`,`reference`]);function C(e){return S.has(e.type)}function w(e){if(C(e)){if(e.limitDisplay!==void 0&&![`used`,`remaining`].includes(e.limitDisplay))throw Error(`Field ${e.id} needs a limitDisplay of used or remaining.`);if(e.limitVisibility!==void 0&&![`always`,`nearLimit`].includes(e.limitVisibility))throw Error(`Field ${e.id} needs a limitVisibility of always or nearLimit.`);if(e.showLimitRing!==void 0&&typeof e.showLimitRing!=`boolean`)throw Error(`Field ${e.id} needs a boolean showLimitRing.`)}}function T(e,t,n){return C(e)?{limitDisplay:e.limitDisplay,limitVisibility:e.limitVisibility,showLimitRing:e.showLimitRing,limit:E(e,t,n??[])}:{}}function E(e,t,n){switch(e.type){case`shortText`:case`longText`:return e.maxLength===void 0?void 0:{count:D(t).length,max:e.maxLength};case`tags`:return e.max===void 0?void 0:{count:H(t).length,max:e.max};default:return o.n(O(e),n.length,N(e).max)}}function D(e){return typeof e==`string`?e:``}function O(e){return e.multiple?`multiple`:`single`}function k(e){if(e.width!==void 0&&!y.includes(e.width))throw Error(`Field ${e.id} needs a width of sm, md or lg.`);if(e.type===`richText`&&e.expandedWidth!==void 0&&!v.includes(e.expandedWidth))throw Error(`Rich text field ${e.id} needs an expandedWidth of wide or full.`)}function A(e){let{min:t,max:n,step:r}=d.a(e);if(![t,n,r].every(Number.isFinite)||t>=n||r<=0)throw Error(`Slider field ${e.id} needs finite min < max and a positive step.`);if(e.type===`rangeSlider`&&r>d.i(n,-t))throw Error(`Range slider ${e.id} needs room for at least one step.`)}function ee(e){if(!Array.isArray(e.options)){let t=e.type===`select`?`Select`:`Choice`;throw Error(`${t} field ${e.id} needs an options array.`)}if(e.type===`select`)return;let t=e.options.map(e=>e.value);if(t.some(e=>typeof e!=`string`||!e.trim())||new Set(t).size!==t.length)throw Error(`Choice field ${e.id} needs nonempty, unique option values.`)}var j={asset:{key:`assetId`,itemLabel:`asset`,itemsLabel:`assets`},reference:{key:`entryId`,itemLabel:`entry`,itemsLabel:`entries`}};function M(e){return e.type===`asset`||e.type===`reference`?e.picker?.label??e.label:e.label}function N(e){let t=j[e.type],{addLabel:n=`Choose ${M(e)}`,emptyLabel:r,itemLabel:i=t.itemLabel,itemsLabel:a=t.itemsLabel,max:o,isReorderable:s}=e.picker??{};return{addLabel:n,emptyLabel:r,itemLabel:i,itemsLabel:a,max:o,isReorderable:s}}function P(e,t){let{key:n}=j[e.type];return(Array.isArray(t)?t:t===void 0?[]:[t]).flatMap(e=>I(e,n)?[e[n]]:[])}function F(e){if(typeof e!=`string`)return;let t=/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(?:Z|\+00:00)$/.exec(e);if(!t)return;let n=`${t[1]}:${t[2]??`00`}.${(t[3]??``).padEnd(3,`0`)}Z`,r=new Date(n);if(Number.isFinite(r.getTime())&&r.toISOString()===n)return n}function I(e,t){return!!e&&typeof e==`object`&&t in e&&typeof e[t]==`string`&&e[t].trim().length>0}function L(e){return!!e.text?.trim()||e.type===`horizontalRule`||!!e.content?.some(L)}function R(e){return`${M(e)} is required.`}function z(e,t){if(typeof t!=`string`)return`Enter text.`;if(e.required&&!t.trim())return R(e);if((e.type===`shortText`||e.type===`longText`)&&e.maxLength!==void 0&&t.length>e.maxLength)return`Enter no more than ${e.maxLength} characters.`}function B(e,t){let n=i.n(t);if(n)return n;if(e.required&&!L(t))return R(e)}function V(e,t){if(typeof t!=`string`)return`Choose an available option.`;if(t===``)return e.required?R(e):void 0;if((e.type===`select`||e.type===`radioGroup`)&&e.options.length>0&&!e.options.some(e=>e.value===t))return`Choose an available option.`}function H(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function U(e,t){if(!Array.isArray(t)||!t.every(e=>typeof e==`string`&&e.trim())||new Set(t).size!==t.length)return`Enter a list of unique, nonempty text values.`;if(e.required&&!t.length)return R(e);if(e.type===`tags`&&e.max!==void 0&&t.length>e.max)return`Enter no more than ${e.max} tags.`;if(e.type===`checkboxGroup`&&e.options.length&&t.some(t=>!e.options.some(e=>e.value===t)))return`Choose available options.`}function W(e,t){if(typeof t!=`number`||!Number.isFinite(t))return`Enter a finite number.`;let{min:n,max:r}=e.type===`slider`||e.type===`rangeSlider`?d.a(e):e.type===`number`?e:{};if(n!==void 0&&t<n)return`Enter a number of at least ${n}.`;if(r!==void 0&&t>r)return`Enter a number no greater than ${r}.`}function G(e,t){if(typeof t!=`string`)return`Enter a valid calendar date (YYYY-MM-DD).`;if(!t)return e.required?R(e):void 0;if(!f.a(t))return`Enter a valid calendar date (YYYY-MM-DD).`;if(e.type===`date`){if(e.min&&t<e.min)return`Choose a date on or after ${e.min}.`;if(e.max&&t>e.max)return`Choose a date on or before ${e.max}.`}}function K(e,t){return typeof e==`number`&&Number.isFinite(e)?d.r(e,t):void 0}function q(e,t){let n=e,r=K(n?.min,t),i=K(n?.max,t);if(r===void 0&&i===void 0)return;let[a,o]=[r??t.min,i??t.max].sort((e,t)=>e-t);return{min:a,max:o}}function J(e,t){if(!t||typeof t!=`object`||Array.isArray(t))return`Enter a range.`;let n=t,r=n.min,i=n.max,a=W(e,r)??W(e,i);if(a)return a;if(r>i)return`The start must not be greater than the end.`;if(e.type===`rangeSlider`&&d.i(i,-r)<d.a(e).step)return`Keep the range endpoints at least one step apart.`}function Y(t,n){return typeof n==`string`?n.trim()?e.i(n)?void 0:`Enter a valid colour.`:t.required?R(t):void 0:`Enter a valid colour.`}function X(e,t){if(e.type!==`asset`&&e.type!==`reference`)return;let{key:n,itemLabel:r,itemsLabel:i}=j[e.type];if(!e.multiple)return I(t,n)?void 0:`Choose an ${r}.`;if(!Array.isArray(t)||!t.every(e=>I(e,n)))return`Choose a list of ${i}.`;if(e.required&&t.length===0)return R(e);let a=e.picker?.max;if(a!==void 0&&t.length>a)return`Choose no more than ${a} ${N(e).itemsLabel}.`}var Z={shortText:z,longText:z,richText:B,number:W,slider:W,rangeSlider:J,date:G,colour:Y,radioGroup:V,checkboxGroup:U,tags:U,boolean:(e,t)=>typeof t==`boolean`?void 0:`Choose a boolean value.`,dateTime:(e,t)=>F(t)?void 0:`Enter a valid UTC date and time.`,select:V,asset:X,reference:X};function Q(e,t){return t===void 0?e.required?R(e):void 0:Z[e.type](e,t)}function te(e,t){return x(e),Object.fromEntries(e.fields.flatMap(e=>{if(e.type===`divider`)return[];let n=Q(e,Object.hasOwn(t,e.id)?t[e.id]:void 0);return n?[[e.id,n]]:[]}))}function ne({field:e,option:t,name:n,checked:r,isDisabled:i,invalid:a,onChange:o}){let s={name:n,value:t.value,checked:r,disabled:i||t.isDisabled,"aria-invalid":a,onChange:()=>{!i&&!t.isDisabled&&o()}};if(e.appearance===`card`){let n=e.type===`radioGroup`?h.RadioCard:h.CheckboxCard;return(0,_.jsx)(n,{...s,title:t.label,description:t.description})}let c=e.type===`radioGroup`?m.Radio:m.Checkbox;return(0,_.jsx)(c,{...s,children:(0,_.jsxs)(`span`,{children:[t.label,t.description&&(0,_.jsx)(`span`,{className:`ds-form-editor__option-description`,children:t.description})]})})}function re({field:e,stored:n,isDisabled:r,required:i,accessibility:a,onChange:o}){let s=e.type===`checkboxGroup`,c=s?H(n):typeof n==`string`&&n?[n]:[],l=e.appearance===`card`?h.SelectionCardGroup:m.ChoiceGroup;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(l,{...a,label:e.label,columns:e.columns??(e.appearance===`card`?2:1),children:e.options.map(t=>(0,_.jsx)(ne,{field:e,option:t,name:a.id,checked:c.includes(t.value),isDisabled:r,invalid:a[`aria-invalid`],onChange:()=>{o(s?c.includes(t.value)?c.filter(e=>e!==t.value):[...c,t.value]:t.value)}},t.value))}),!s&&!i&&c.length>0&&(0,_.jsxs)(t.Button,{variant:`simple`,size:`sm`,isDisabled:r,onClick:()=>o(void 0),children:[`Clear `,e.label]})]})}function ie({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=d.a(e),o=K(t,a);return(0,_.jsx)(d.n,{...r,...a,prefix:e.prefix,suffix:e.suffix,hasValueLabel:e.hasValueLabel,valueText:o===void 0?e.placeholder??`Not set`:void 0,autoFocus:e.autoFocus,isDisabled:n,value:o??a.min,onValueChange:i,onValueCommit:e=>{o===void 0&&i(e)}})}function ae({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=d.a(e),o=q(t,a);return(0,_.jsx)(d.t,{...r,...a,prefix:e.prefix,suffix:e.suffix,hasValueLabel:e.hasValueLabel,minLabel:`${e.label} minimum`,maxLabel:`${e.label} maximum`,isDisabled:n,valueText:o===void 0?e.placeholder??`Not set`:void 0,hasFill:o!==void 0,value:o??{min:a.min,max:a.max},onValueChange:i,onValueCommit:e=>{o===void 0&&i(e)}})}function oe({field:t,stored:n,isDisabled:r,required:i,accessibility:a,onChange:o}){let s={stored:n,isDisabled:r,required:i,accessibility:a,onChange:o};switch(t.type){case`radioGroup`:case`checkboxGroup`:return(0,_.jsx)(re,{field:t,...s});case`rangeSlider`:return(0,_.jsx)(ae,{field:t,...s});case`slider`:return(0,_.jsx)(ie,{field:t,...s});case`colour`:return(0,_.jsx)(u.t,{...a,required:i,placeholder:t.placeholder,presets:t.presets,showPresets:t.showPresets,picker:t.picker,placement:t.placement,readOnly:t.readOnly,autoFocus:t.autoFocus,isDisabled:r,value:typeof n==`string`?n:``,onInput:t=>{let n=t.currentTarget.value;n.trim()&&!e.i(n)&&o(n)},onValueChange:e=>o(e===``?void 0:e)});case`tags`:return(0,_.jsx)(p.TagsInput,{...a,required:i,placeholder:t.placeholder,max:t.max,isDisabled:r,value:H(n),onValueChange:o});case`date`:return(0,_.jsx)(f.n,{...a,placeholder:t.placeholder,min:t.min,max:t.max,placement:t.placement,isDisabled:r,isClearable:!0,clearLabel:`Clear ${t.label}`,value:typeof n==`string`?n:``,onValueChange:e=>o(e===``?void 0:e)})}}function se(e,t){if(e.type===`asset`){let n=t.map(e=>({assetId:e}));return e.multiple?n:n[0]}let n=t.map(e=>({entryId:e}));return e.multiple?n:n[0]}function ce({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){return(0,_.jsx)(s.NumberField,{...i,required:r,isDisabled:n,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step??`any`,hasSteppers:e.hasSteppers??!1,prefix:e.prefix,suffix:e.suffix,autoFocus:e.autoFocus,decreaseLabel:`Decrease ${e.label}`,increaseLabel:`Increase ${e.label}`,value:typeof t==`number`&&Number.isFinite(t)?t:``,onValueChange:e=>{(e===``||Number.isFinite(e))&&a(e===``?void 0:e)}})}function le({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){let o=!r&&!e.options.some(e=>e.value===``);return(0,_.jsx)(c.Select,{...i,"aria-required":r||void 0,isDisabled:n,isInvalid:i[`aria-invalid`],options:o?[{value:``,label:e.placeholder??`None`},...e.options]:e.options,placeholder:e.placeholder,autoFocus:e.autoFocus,value:typeof t==`string`?t:``,onValueChange:e=>a(e===``?void 0:e)})}function ue({field:e,selected:t,items:n,isDisabled:r,accessibility:i,onChange:a}){return(0,_.jsx)(o.t,{...i,items:n,value:t,...N(e),mode:O(e),isDisabled:r,onValueChange:t=>a(se(e,t))})}function $({field:e,stored:t,selected:n,items:a,isDisabled:o,accessibility:{required:s,...c},onChange:u}){let d={stored:t,isDisabled:o,required:s,accessibility:c,onChange:u};switch(e.type){case`shortText`:return(0,_.jsx)(r.TextField,{...c,required:s,disabled:o,placeholder:e.placeholder,type:e.inputType,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:D(t),onChange:e=>u(e.target.value)});case`longText`:return(0,_.jsx)(r.TextArea,{...c,required:s,disabled:o,placeholder:e.placeholder,rows:e.rows,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:D(t),onChange:e=>u(e.target.value)});case`number`:return(0,_.jsx)(ce,{field:e,...d});case`boolean`:return(0,_.jsx)(l.Switch,{...c,isDisabled:o,autoFocus:e.autoFocus,isSelected:t===!0,onSelectedChange:u});case`dateTime`:return(0,_.jsx)(r.TextField,{...c,required:s,disabled:o,type:`datetime-local`,step:`0.001`,autoFocus:e.autoFocus,value:F(t)?.slice(0,-1)??``,onChange:e=>u(F(`${e.target.value}Z`))});case`richText`:return(0,_.jsx)(i.t,{...c,expandedWidth:e.expandedWidth,label:e.label,isRequired:s,isDisabled:o,placeholder:e.placeholder,format:`json`,value:t===void 0?i.r:t,onChange:u});case`select`:return(0,_.jsx)(le,{field:e,...d});case`asset`:case`reference`:return(0,_.jsx)(ue,{field:e,items:a,selected:n??[],...d});default:return(0,_.jsx)(oe,{field:e,...d})}}function de({field:e,stored:t,items:r,isDisabled:i,error:o,isErrorVisible:s,onChange:c}){let l=(0,g.useMemo)(()=>o===void 0&&s?Q(e,t):void 0,[o,s,e,t]),u=(0,g.useMemo)(()=>e.type===`asset`||e.type===`reference`?P(e,t):void 0,[e,t]);return(0,_.jsx)(a.Container,{width:e.width,padded:!1,center:!1,className:`ds-form-editor__field`,children:(0,_.jsx)(n.Field,{...T(e,t,u),label:e.type===`dateTime`?`${e.label} (UTC)`:M(e),hint:e.hint,labelHint:e.labelHint,error:o??l,isRequired:e.required,count:u?.length??(e.type===`checkboxGroup`?H(t).length:void 0),isGroup:u!==void 0||fe.has(e.type),children:n=>(0,_.jsx)($,{field:e,stored:t,selected:u,items:r,isDisabled:i,accessibility:n,onChange:c})})})}var fe=new Set([`radioGroup`,`checkboxGroup`,`rangeSlider`]),pe=new Set([`slider`,`rangeSlider`,`date`,`colour`]);function me({schema:e,value:t,defaultValue:n={},onValueChange:r,pickerItems:i={},errors:a={},isDisabled:o=!1,showAllErrors:s=!1,columns:c=1,minColumnWidth:l=`16rem`,className:u,style:d,...f}){let[p,m]=(0,g.useState)(n),[h,v]=(0,g.useState)(()=>new Set),y=t??p;(0,g.useMemo)(()=>x(e),[e]);let b=(e,n)=>{let i={...y};n===void 0?delete i[e]:i[e]=n,t===void 0&&m(i),v(t=>new Set(t).add(e)),r?.(i,{fieldId:e})},S=c===`auto`?{"--form-editor-min-column":l}:{"--form-editor-columns":c,"--form-editor-min-column":l};return(0,_.jsx)(`div`,{className:[`ds-form-editor`,c===`auto`&&`ds-form-editor--auto`,u].filter(Boolean).join(` `),style:{...S,...d},...f,children:e.fields.map(e=>{if(e.type===`divider`)return(0,_.jsx)(`hr`,{className:`ds-form-editor__divider`},e.id);let t=Object.hasOwn(y,e.id)?y[e.id]:void 0,n=o||!!e.isDisabled,r=n||`readOnly`in e&&!!e.readOnly,c=typeof t==`string`?t.trim()!==``:t!==void 0,l=s||h.has(e.id)||c&&pe.has(e.type)||e.type===`number`&&typeof t==`number`;return(0,_.jsx)(de,{field:e,stored:t,items:i[e.id]??[],isDisabled:n,error:a[e.id],isErrorVisible:l,onChange:t=>{r||b(e.id,t)}},e.id)})})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return me}});
|
|
2
|
+
//# sourceMappingURL=FormEditor-B4mtAxaU.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormEditor-B4mtAxaU.cjs","names":["selectionLimit","sliderScale","preciseSum","documentError","isIsoDate","clampToScale","parseColour","RadioCard","CheckboxCard","Radio","Checkbox","SelectionCardGroup","ChoiceGroup","_Fragment","Button","sliderScale","Slider","RangeSlider","ColourField","parseColour","TagsInput","DateField","NumberField","Select","EntryPicker","TextField","TextArea","Switch","RichTextEditor","emptyDocument","useMemo","Container","Field","useState","require_colour","require_components_Button_index","require_components_Field_index","require_components_TextField_index","require_RichTextEditor","require_components_Container_index","require_EntryPicker","require_components_NumberField_index","require_components_Select_index","require_components_Switch_index","require_ColourField","require_Slider","require_DatePicker","require_components_TagsInput_index","require_components_Choice_index","require_components_SelectionCard_index","react","react_jsx_runtime","expandedWidths","fieldWidths","fieldTypes","assertModel","ids","field","model","assertChoices","assertSlider","assertMeasures","assertLimitOptions","limitedTypes","supportsLimit","fieldLimitProps","schemaLimit","stored","selected","textValue","stringList","pickerMode","pickerCopy","min","max","step","kind","values","option","value","linkCopy","fieldLabel","defaults","selectedIds","isLink","link","key","parseUtcDateTime","match","canonical","date","hasRichText","node","requiredError","textError","richTextError","error","choiceError","item","listError","numberError","dateError","sliderValue","scale","rangeSliderValue","range","start","end","low","high","a","b","rangeError","colourError","linkError","itemLabel","itemsLabel","validators","fieldError","validateFormValues","Option","props","isDisabled","invalid","onChange","Card","Choice","ChoiceControl","multiple","Group","accessibility","required","SliderControl","shown","next","RangeSliderControl","AdditionalControl","raw","event","pickerValue","links","NumberControl","SelectControl","isClearable","PickerControl","FormControl","shared","FormEditorField","validation","isErrorVisible","groupTypes","loadedValidationTypes","FormEditor","rest","internal","setInternal","defaultValue","changed","setChanged","current","schema","commit","fieldId","previous","onValueChange","layout","columns","minColumnWidth","className","style","fieldDisabled","isLocked","isLoaded","showAllErrors","pickerItems","errors"],"sources":["../../src/components/RichTextEditor/expanded-width.ts","../../src/components/FormEditor/model.ts","../../src/components/FormEditor/choice-control.tsx","../../src/components/FormEditor/additional-control.tsx","../../src/components/FormEditor/control.tsx","../../src/components/FormEditor/index.tsx"],"sourcesContent":["/** Expanded writing measures: `wide` caps at the shared wide Modal width; `full` fills the viewport inside the scrim's gutters. */\nexport const expandedWidths = [\"wide\", \"full\"] as const;\n\nexport type RichTextEditorExpandedWidth = (typeof expandedWidths)[number];\n","import type { ReactNode } from \"react\";\nimport type { SelectOption } from \"../Select\";\nimport type { EntryPickerMode, EntryPickerProps } from \"../EntryPicker\";\nimport { selectionLimit } from \"../EntryPicker/limit\";\nimport type { JSONContent } from \"@tiptap/react\";\nimport { documentError } from \"../RichTextEditor/document\";\nimport type { RichTextDocument } from \"../RichTextEditor\";\nimport { expandedWidths, type RichTextEditorExpandedWidth } from \"../RichTextEditor/expanded-width\";\nimport { isIsoDate } from \"../DatePicker/date\";\nimport type { RangeSliderValue } from \"../Slider\";\nimport { clampToScale, preciseSum, sliderScale, type SliderScale } from \"../Slider/scale\";\nimport { parseColour } from \"../ColourField/colour\";\nimport type { PopoverPlacement } from \"../Popover\";\nimport type { ContainerWidth } from \"../Container\";\nimport type { FieldLimit, FieldLimitOptions } from \"../Field/types\";\n\n/** The shared measures a field may cap at; checked against Container's scale. */\nconst fieldWidths = [\"sm\", \"md\", \"lg\"] as const satisfies readonly ContainerWidth[];\n\ninterface FormFieldBase {\n id: string;\n label: string;\n labelHint?: ReactNode;\n hint?: ReactNode;\n /** Maximum width of the whole field, using Container's measures and its `lg` default. */\n width?: (typeof fieldWidths)[number];\n placeholder?: string;\n required?: boolean;\n isDisabled?: boolean;\n}\n\ninterface SliderOptions {\n multiple?: never;\n min?: number;\n max?: number;\n step?: number;\n prefix?: string;\n suffix?: string;\n hasValueLabel?: boolean;\n}\n\ninterface ChoiceOptions {\n multiple?: never;\n autoFocus?: never;\n options: SelectOption[];\n appearance?: \"default\" | \"card\";\n /** Maximum options per row inside this group; independent of FormEditor columns. */\n columns?: 1 | 2 | 3;\n}\n\nexport type FormField = FormFieldBase &\n (\n | ({\n type: \"shortText\";\n inputType?: \"text\" | \"email\";\n maxLength?: number;\n readOnly?: boolean;\n autoFocus?: boolean;\n multiple?: never;\n } & FieldLimitOptions)\n | ({\n type: \"longText\";\n rows?: number;\n maxLength?: number;\n readOnly?: boolean;\n autoFocus?: boolean;\n multiple?: never;\n } & FieldLimitOptions)\n | { type: \"boolean\" | \"dateTime\"; autoFocus?: boolean; multiple?: never }\n | {\n type: \"richText\";\n expandedWidth?: RichTextEditorExpandedWidth;\n autoFocus?: never;\n multiple?: never;\n }\n | {\n type: \"number\";\n min?: number;\n max?: number;\n step?: number | \"any\";\n hasSteppers?: boolean;\n prefix?: string;\n suffix?: string;\n autoFocus?: boolean;\n multiple?: never;\n }\n | { type: \"select\"; options: SelectOption[]; autoFocus?: boolean; multiple?: never }\n | ({ type: \"slider\"; autoFocus?: boolean } & SliderOptions)\n | ({ type: \"rangeSlider\"; autoFocus?: never } & SliderOptions)\n | ({ type: \"radioGroup\" } & ChoiceOptions)\n | ({ type: \"checkboxGroup\" } & ChoiceOptions)\n | {\n type: \"colour\";\n multiple?: never;\n presets?: string[];\n showPresets?: boolean;\n picker?: \"custom\" | \"native\";\n placement?: PopoverPlacement;\n readOnly?: boolean;\n autoFocus?: boolean;\n }\n | ({ type: \"tags\"; max?: number; multiple?: never; autoFocus?: never } & FieldLimitOptions)\n | {\n type: \"date\";\n min?: string;\n max?: string;\n placement?: PopoverPlacement;\n multiple?: never;\n autoFocus?: never;\n }\n | ({\n type: \"asset\" | \"reference\";\n multiple?: boolean;\n autoFocus?: never;\n picker?: Pick<\n EntryPickerProps,\n \"label\" | \"addLabel\" | \"emptyLabel\" | \"itemLabel\" | \"itemsLabel\" | \"max\" | \"isReorderable\"\n >;\n } & FieldLimitOptions)\n );\n\nexport type FieldOf<T extends FormField[\"type\"]> = Extract<FormField, { type: T }>;\n\n/** Layout only: no label, value, disabled state, or validation. */\nexport interface FormDivider {\n id: string;\n type: \"divider\";\n}\n\nexport type FormItem = FormField | FormDivider;\n\nexport interface FormSchema {\n fields: readonly FormItem[];\n}\n\nexport interface AssetValue {\n assetId: string;\n}\nexport interface ReferenceValue {\n entryId: string;\n}\nexport type FormFieldValue =\n | string\n | number\n | boolean\n | RichTextDocument\n | AssetValue\n | ReferenceValue\n | string[]\n | RangeSliderValue\n | AssetValue[]\n | ReferenceValue[];\nexport type FormValues = Record<string, FormFieldValue | undefined>;\nexport type FormErrors = Partial<Record<string, string>>;\n\nconst fieldTypes = new Set([\n \"shortText\",\n \"longText\",\n \"richText\",\n \"number\",\n \"boolean\",\n \"dateTime\",\n \"asset\",\n \"reference\",\n \"select\",\n \"slider\",\n \"rangeSlider\",\n \"colour\",\n \"radioGroup\",\n \"checkboxGroup\",\n \"tags\",\n \"date\",\n \"divider\",\n]);\n\nexport function assertModel(model: FormSchema) {\n const ids = new Set<string>();\n for (const field of model.fields) {\n if (!field.id?.trim() || ids.has(field.id)) {\n throw new Error(\"Form field IDs must be nonempty and unique.\");\n }\n if (!fieldTypes.has(field.type)) {\n throw new Error(`Unsupported form field type: ${field.type}`);\n }\n if (field.type === \"select\" || field.type === \"radioGroup\" || field.type === \"checkboxGroup\") {\n assertChoices(field);\n }\n if (field.type === \"slider\" || field.type === \"rangeSlider\") {\n assertSlider(field);\n }\n if (field.type !== \"divider\") {\n assertMeasures(field);\n assertLimitOptions(field);\n }\n ids.add(field.id);\n }\n}\n\nconst limitedTypes = new Set([\"shortText\", \"longText\", \"tags\", \"asset\", \"reference\"]);\n\nfunction supportsLimit(\n field: FormField,\n): field is FieldOf<\"shortText\" | \"longText\" | \"tags\" | \"asset\" | \"reference\"> {\n return limitedTypes.has(field.type);\n}\n\nfunction assertLimitOptions(field: FormField) {\n if (!supportsLimit(field)) {\n return;\n }\n if (field.limitDisplay !== undefined && ![\"used\", \"remaining\"].includes(field.limitDisplay)) {\n throw new Error(`Field ${field.id} needs a limitDisplay of used or remaining.`);\n }\n if (\n field.limitVisibility !== undefined &&\n ![\"always\", \"nearLimit\"].includes(field.limitVisibility)\n ) {\n throw new Error(`Field ${field.id} needs a limitVisibility of always or nearLimit.`);\n }\n if (field.showLimitRing !== undefined && typeof field.showLimitRing !== \"boolean\") {\n throw new Error(`Field ${field.id} needs a boolean showLimitRing.`);\n }\n}\n\n/**\n * Explicit limits for complete server markup. Counts come from the helpers the\n * adapters display with (`textValue`, `stringList`, the owning field's selected\n * IDs and EntryPicker's `selectionLimit`), so the counter cannot drift from them.\n */\nexport function fieldLimitProps(\n field: FormField,\n stored: FormFieldValue | undefined,\n selected: string[] | undefined,\n): FieldLimitOptions & { limit?: FieldLimit } {\n if (!supportsLimit(field)) {\n return {};\n }\n return {\n limitDisplay: field.limitDisplay,\n limitVisibility: field.limitVisibility,\n showLimitRing: field.showLimitRing,\n limit: schemaLimit(field, stored, selected ?? []),\n };\n}\n\nfunction schemaLimit(\n field: FieldOf<\"shortText\" | \"longText\" | \"tags\" | \"asset\" | \"reference\">,\n stored: FormFieldValue | undefined,\n selected: string[],\n): FieldLimit | undefined {\n switch (field.type) {\n case \"shortText\":\n case \"longText\":\n return field.maxLength === undefined\n ? undefined\n : { count: textValue(stored).length, max: field.maxLength };\n case \"tags\":\n return field.max === undefined\n ? undefined\n : { count: stringList(stored).length, max: field.max };\n default:\n return selectionLimit(pickerMode(field), selected.length, pickerCopy(field).max);\n }\n}\n\n/** The text a shortText or longText adapter displays. */\nexport function textValue(stored: unknown): string {\n return typeof stored === \"string\" ? stored : \"\";\n}\n\n/** The EntryPicker mode a picker field renders with. */\nexport function pickerMode(field: FieldOf<\"asset\" | \"reference\">): EntryPickerMode {\n return field.multiple ? \"multiple\" : \"single\";\n}\n\n/** Runtime schemas can carry any string; the types only cover typed schemas. */\nfunction assertMeasures(field: FormField) {\n if (field.width !== undefined && !fieldWidths.includes(field.width)) {\n throw new Error(`Field ${field.id} needs a width of sm, md or lg.`);\n }\n if (\n field.type === \"richText\" &&\n field.expandedWidth !== undefined &&\n !expandedWidths.includes(field.expandedWidth)\n ) {\n throw new Error(`Rich text field ${field.id} needs an expandedWidth of wide or full.`);\n }\n}\n\nfunction assertSlider(field: FieldOf<\"slider\" | \"rangeSlider\">) {\n const { min, max, step } = sliderScale(field);\n if (![min, max, step].every(Number.isFinite) || min >= max || step <= 0) {\n throw new Error(`Slider field ${field.id} needs finite min < max and a positive step.`);\n }\n if (field.type === \"rangeSlider\" && step > preciseSum(max, -min)) {\n throw new Error(`Range slider ${field.id} needs room for at least one step.`);\n }\n}\n\nfunction assertChoices(field: FieldOf<\"select\" | \"radioGroup\" | \"checkboxGroup\">) {\n if (!Array.isArray(field.options)) {\n const kind = field.type === \"select\" ? \"Select\" : \"Choice\";\n throw new Error(`${kind} field ${field.id} needs an options array.`);\n }\n if (field.type === \"select\") {\n return;\n }\n const values = field.options.map((option) => option.value);\n if (\n values.some((value) => typeof value !== \"string\" || !value.trim()) ||\n new Set(values).size !== values.length\n ) {\n throw new Error(`Choice field ${field.id} needs nonempty, unique option values.`);\n }\n}\n\nconst linkCopy = {\n asset: { key: \"assetId\", itemLabel: \"asset\", itemsLabel: \"assets\" },\n reference: { key: \"entryId\", itemLabel: \"entry\", itemsLabel: \"entries\" },\n} as const;\n\n/** The field's visible and accessible name. A picker's `label` overrides it. */\nexport function fieldLabel(field: FormField): string {\n return field.type === \"asset\" || field.type === \"reference\"\n ? (field.picker?.label ?? field.label)\n : field.label;\n}\n\n/** Picker action and item copy, with asset or entry wording for any option left out or undefined. */\nexport function pickerCopy(field: FieldOf<\"asset\" | \"reference\">) {\n const defaults = linkCopy[field.type];\n const {\n addLabel = `Choose ${fieldLabel(field)}`,\n emptyLabel,\n itemLabel = defaults.itemLabel,\n itemsLabel = defaults.itemsLabel,\n max,\n isReorderable,\n } = field.picker ?? {};\n return { addLabel, emptyLabel, itemLabel, itemsLabel, max, isReorderable };\n}\n\n/** The picked IDs, in stored order, skipping anything that isn't a link. */\nexport function selectedIds(field: FieldOf<\"asset\" | \"reference\">, value: unknown): string[] {\n const { key } = linkCopy[field.type];\n const links = Array.isArray(value) ? value : value === undefined ? [] : [value];\n return links.flatMap((link) =>\n isLink(link, key) ? [(link as Record<string, string>)[key]] : [],\n );\n}\n\n/** Accept UTC ISO strings without rolling invalid dates into the next month. */\nexport function parseUtcDateTime(value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return;\n }\n const match = /^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3}))?)?(?:Z|\\+00:00)$/.exec(\n value,\n );\n if (!match) {\n return;\n }\n const canonical = `${match[1]}:${match[2] ?? \"00\"}.${(match[3] ?? \"\").padEnd(3, \"0\")}Z`;\n const date = new Date(canonical);\n if (Number.isFinite(date.getTime()) && date.toISOString() === canonical) {\n return canonical;\n }\n}\n\nfunction isLink(value: unknown, key: \"assetId\" | \"entryId\"): boolean {\n return (\n !!value &&\n typeof value === \"object\" &&\n key in value &&\n typeof (value as Record<string, unknown>)[key] === \"string\" &&\n (value as Record<string, string>)[key].trim().length > 0\n );\n}\n\nfunction hasRichText(node: JSONContent): boolean {\n return !!node.text?.trim() || node.type === \"horizontalRule\" || !!node.content?.some(hasRichText);\n}\n\nfunction requiredError(field: FormField): string {\n return `${fieldLabel(field)} is required.`;\n}\n\nfunction textError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Enter text.\";\n }\n if (field.required && !value.trim()) {\n return requiredError(field);\n }\n if (\n (field.type === \"shortText\" || field.type === \"longText\") &&\n field.maxLength !== undefined &&\n value.length > field.maxLength\n ) {\n return `Enter no more than ${field.maxLength} characters.`;\n }\n}\n\nfunction richTextError(field: FormField, value: unknown): string | undefined {\n const error = documentError(value);\n if (error) {\n return error;\n }\n if (field.required && !hasRichText(value as RichTextDocument)) {\n return requiredError(field);\n }\n}\n\nfunction choiceError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Choose an available option.\";\n }\n if (value === \"\") {\n return field.required ? requiredError(field) : undefined;\n }\n // An empty list means the choices are still loading, so a stored value stays valid until they arrive.\n if (\n (field.type === \"select\" || field.type === \"radioGroup\") &&\n field.options.length > 0 &&\n !field.options.some((option) => option.value === value)\n ) {\n return \"Choose an available option.\";\n }\n}\n\nexport function stringList(value: unknown): string[] {\n return Array.isArray(value)\n ? value.filter((item): item is string => typeof item === \"string\")\n : [];\n}\n\nfunction listError(field: FormField, value: unknown): string | undefined {\n if (\n !Array.isArray(value) ||\n !value.every((item) => typeof item === \"string\" && item.trim()) ||\n new Set(value).size !== value.length\n ) {\n return \"Enter a list of unique, nonempty text values.\";\n }\n if (field.required && !value.length) {\n return requiredError(field);\n }\n if (field.type === \"tags\" && field.max !== undefined && value.length > field.max) {\n return `Enter no more than ${field.max} tags.`;\n }\n if (\n field.type === \"checkboxGroup\" &&\n field.options.length &&\n value.some((item) => !field.options.some((option) => option.value === item))\n ) {\n return \"Choose available options.\";\n }\n}\n\nfunction numberError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n return \"Enter a finite number.\";\n }\n const { min, max }: { min?: number; max?: number } =\n field.type === \"slider\" || field.type === \"rangeSlider\"\n ? sliderScale(field)\n : field.type === \"number\"\n ? field\n : {};\n if (min !== undefined && value < min) {\n return `Enter a number of at least ${min}.`;\n }\n if (max !== undefined && value > max) {\n return `Enter a number no greater than ${max}.`;\n }\n}\n\nfunction dateError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Enter a valid calendar date (YYYY-MM-DD).\";\n }\n if (!value) {\n return field.required ? requiredError(field) : undefined;\n }\n if (!isIsoDate(value)) {\n return \"Enter a valid calendar date (YYYY-MM-DD).\";\n }\n if (field.type !== \"date\") {\n return;\n }\n if (field.min && value < field.min) {\n return `Choose a date on or after ${field.min}.`;\n }\n if (field.max && value > field.max) {\n return `Choose a date on or before ${field.max}.`;\n }\n}\n\n/**\n * Display positions for loaded values: out-of-scale numbers clamp and reversed\n * endpoints swap, without overwriting the stored data that validation reports.\n * A value that is not a finite number has no position, so the control is unset.\n */\nexport function sliderValue(value: unknown, scale: SliderScale): number | undefined {\n return typeof value === \"number\" && Number.isFinite(value)\n ? clampToScale(value, scale)\n : undefined;\n}\n\n/** A range with neither endpoint usable is unset; one usable endpoint pairs with the scale's end. */\nexport function rangeSliderValue(value: unknown, scale: SliderScale): RangeSliderValue | undefined {\n const range = value as Partial<Record<\"min\" | \"max\", unknown>> | null;\n const start = sliderValue(range?.min, scale);\n const end = sliderValue(range?.max, scale);\n if (start === undefined && end === undefined) {\n return undefined;\n }\n const [low, high] = [start ?? scale.min, end ?? scale.max].sort((a, b) => a - b);\n return { min: low, max: high };\n}\n\nfunction rangeError(field: FormField, value: unknown): string | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return \"Enter a range.\";\n }\n const range = value as Record<string, unknown>;\n const start = range.min;\n const end = range.max;\n const error = numberError(field, start) ?? numberError(field, end);\n if (error) {\n return error;\n }\n if ((start as number) > (end as number)) {\n return \"The start must not be greater than the end.\";\n }\n if (\n field.type === \"rangeSlider\" &&\n preciseSum(end as number, -(start as number)) < sliderScale(field).step\n ) {\n return \"Keep the range endpoints at least one step apart.\";\n }\n}\n\nfunction colourError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Enter a valid colour.\";\n }\n if (!value.trim()) {\n return field.required ? requiredError(field) : undefined;\n }\n return parseColour(value) ? undefined : \"Enter a valid colour.\";\n}\n\nfunction linkError(field: FormField, value: unknown): string | undefined {\n if (field.type !== \"asset\" && field.type !== \"reference\") {\n return;\n }\n const { key, itemLabel, itemsLabel } = linkCopy[field.type];\n if (!field.multiple) {\n return isLink(value, key) ? undefined : `Choose an ${itemLabel}.`;\n }\n if (!Array.isArray(value) || !value.every((item) => isLink(item, key))) {\n return `Choose a list of ${itemsLabel}.`;\n }\n if (field.required && value.length === 0) {\n return requiredError(field);\n }\n const max = field.picker?.max;\n if (max !== undefined && value.length > max) {\n return `Choose no more than ${max} ${pickerCopy(field).itemsLabel}.`;\n }\n}\n\nconst validators: Record<\n FormField[\"type\"],\n (field: FormField, value: unknown) => string | undefined\n> = {\n shortText: textError,\n longText: textError,\n richText: richTextError,\n number: numberError,\n slider: numberError,\n rangeSlider: rangeError,\n date: dateError,\n colour: colourError,\n radioGroup: choiceError,\n checkboxGroup: listError,\n tags: listError,\n boolean: (_field, value) => (typeof value === \"boolean\" ? undefined : \"Choose a boolean value.\"),\n dateTime: (_field, value) =>\n parseUtcDateTime(value) ? undefined : \"Enter a valid UTC date and time.\",\n select: choiceError,\n asset: linkError,\n reference: linkError,\n};\n\nexport function fieldError(field: FormField, value: unknown): string | undefined {\n if (value === undefined) {\n return field.required ? requiredError(field) : undefined;\n }\n return validators[field.type](field, value);\n}\n\n/** Validate data loaded from JSON as well as values emitted by FormEditor. */\nexport function validateFormValues(model: FormSchema, values: Record<string, unknown>): FormErrors {\n assertModel(model);\n return Object.fromEntries(\n model.fields.flatMap((field): [string, string][] => {\n if (field.type === \"divider\") {\n return [];\n }\n const error = fieldError(\n field,\n Object.hasOwn(values, field.id) ? values[field.id] : undefined,\n );\n return error ? [[field.id, error]] : [];\n }),\n );\n}\n","import { Button } from \"../Button\";\nimport { Checkbox, ChoiceGroup, Radio } from \"../Choice\";\nimport { CheckboxCard, RadioCard, SelectionCardGroup } from \"../SelectionCard\";\nimport type { SelectOption } from \"../Select\";\nimport type { ControlProps } from \"./control\";\nimport { stringList, type FieldOf } from \"./model\";\n\ntype ChoiceField = FieldOf<\"radioGroup\" | \"checkboxGroup\">;\n\nfunction Option({\n field,\n option,\n name,\n checked,\n isDisabled,\n invalid,\n onChange,\n}: {\n field: ChoiceField;\n option: SelectOption;\n name: string;\n checked: boolean;\n isDisabled: boolean;\n invalid: true | undefined;\n onChange: () => void;\n}) {\n const props = {\n name,\n value: option.value,\n checked,\n disabled: isDisabled || option.isDisabled,\n \"aria-invalid\": invalid,\n onChange: () => {\n if (!isDisabled && !option.isDisabled) {\n onChange();\n }\n },\n };\n if (field.appearance === \"card\") {\n const Card = field.type === \"radioGroup\" ? RadioCard : CheckboxCard;\n return (\n <Card\n {...props}\n title={option.label}\n description={option.description}\n />\n );\n }\n const Choice = field.type === \"radioGroup\" ? Radio : Checkbox;\n return (\n <Choice {...props}>\n <span>\n {option.label}\n {option.description && (\n <span className=\"ds-form-editor__option-description\">{option.description}</span>\n )}\n </span>\n </Choice>\n );\n}\n\nexport function ChoiceControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<ChoiceField>) {\n const multiple = field.type === \"checkboxGroup\";\n // Option values are nonempty, so a stored \"\" selects nothing.\n const selected = multiple\n ? stringList(stored)\n : typeof stored === \"string\" && stored\n ? [stored]\n : [];\n const Group = field.appearance === \"card\" ? SelectionCardGroup : ChoiceGroup;\n return (\n <>\n <Group\n {...accessibility}\n label={field.label}\n columns={field.columns ?? (field.appearance === \"card\" ? 2 : 1)}\n >\n {field.options.map((option) => (\n <Option\n key={option.value}\n field={field}\n option={option}\n name={accessibility.id}\n checked={selected.includes(option.value)}\n isDisabled={isDisabled}\n invalid={accessibility[\"aria-invalid\"]}\n onChange={() => {\n if (multiple) {\n onChange(\n selected.includes(option.value)\n ? selected.filter((value) => value !== option.value)\n : [...selected, option.value],\n );\n } else {\n onChange(option.value);\n }\n }}\n />\n ))}\n </Group>\n {!multiple && !required && selected.length > 0 && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isDisabled={isDisabled}\n onClick={() => onChange(undefined)}\n >\n Clear {field.label}\n </Button>\n )}\n </>\n );\n}\n","import { ColourField } from \"../ColourField\";\nimport { parseColour } from \"../ColourField/colour\";\nimport { DateField } from \"../DatePicker\";\nimport { RangeSlider, Slider } from \"../Slider\";\nimport { sliderScale } from \"../Slider/scale\";\nimport { TagsInput } from \"../TagsInput\";\nimport { ChoiceControl } from \"./choice-control\";\nimport type { ControlProps } from \"./control\";\nimport { rangeSliderValue, sliderValue, stringList, type FieldOf } from \"./model\";\n\ntype AdditionalField = FieldOf<\n \"slider\" | \"rangeSlider\" | \"date\" | \"colour\" | \"tags\" | \"radioGroup\" | \"checkboxGroup\"\n>;\n\nfunction SliderControl({\n field,\n stored,\n isDisabled,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"slider\">>) {\n const scale = sliderScale(field);\n const shown = sliderValue(stored, scale);\n return (\n <Slider\n {...accessibility}\n {...scale}\n prefix={field.prefix}\n suffix={field.suffix}\n hasValueLabel={field.hasValueLabel}\n valueText={shown === undefined ? (field.placeholder ?? \"Not set\") : undefined}\n autoFocus={field.autoFocus}\n isDisabled={isDisabled}\n value={shown ?? scale.min}\n onValueChange={onChange}\n // An unset thumb rests at the minimum, where a click or a key toward it fires\n // no change event. Committing stores the position the slider shows.\n onValueCommit={(next) => {\n if (shown === undefined) {\n onChange(next);\n }\n }}\n />\n );\n}\n\nfunction RangeSliderControl({\n field,\n stored,\n isDisabled,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"rangeSlider\">>) {\n const scale = sliderScale(field);\n const shown = rangeSliderValue(stored, scale);\n return (\n <RangeSlider\n {...accessibility}\n {...scale}\n prefix={field.prefix}\n suffix={field.suffix}\n hasValueLabel={field.hasValueLabel}\n minLabel={`${field.label} minimum`}\n maxLabel={`${field.label} maximum`}\n isDisabled={isDisabled}\n // Unset thumbs rest at both ends without a fill, so nothing looks chosen; a click\n // or key that leaves them there stores the full range they show.\n valueText={shown === undefined ? (field.placeholder ?? \"Not set\") : undefined}\n hasFill={shown !== undefined}\n value={shown ?? { min: scale.min, max: scale.max }}\n onValueChange={onChange}\n onValueCommit={(next) => {\n if (shown === undefined) {\n onChange(next);\n }\n }}\n />\n );\n}\n\nexport function AdditionalControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<AdditionalField>) {\n const props = { stored, isDisabled, required, accessibility, onChange };\n switch (field.type) {\n case \"radioGroup\":\n case \"checkboxGroup\":\n return (\n <ChoiceControl\n field={field}\n {...props}\n />\n );\n case \"rangeSlider\":\n return (\n <RangeSliderControl\n field={field}\n {...props}\n />\n );\n case \"slider\":\n return (\n <SliderControl\n field={field}\n {...props}\n />\n );\n case \"colour\":\n return (\n <ColourField\n {...accessibility}\n required={required}\n placeholder={field.placeholder}\n presets={field.presets}\n showPresets={field.showPresets}\n picker={field.picker}\n placement={field.placement}\n readOnly={field.readOnly}\n autoFocus={field.autoFocus}\n isDisabled={isDisabled}\n value={typeof stored === \"string\" ? stored : \"\"}\n onInput={(event) => {\n const raw = event.currentTarget.value;\n if (raw.trim() && !parseColour(raw)) {\n onChange(raw);\n }\n }}\n onValueChange={(next) => onChange(next === \"\" ? undefined : next)}\n />\n );\n case \"tags\":\n return (\n <TagsInput\n {...accessibility}\n required={required}\n placeholder={field.placeholder}\n max={field.max}\n isDisabled={isDisabled}\n value={stringList(stored)}\n onValueChange={onChange}\n />\n );\n case \"date\":\n return (\n <DateField\n {...accessibility}\n placeholder={field.placeholder}\n min={field.min}\n max={field.max}\n placement={field.placement}\n isDisabled={isDisabled}\n isClearable\n clearLabel={`Clear ${field.label}`}\n value={typeof stored === \"string\" ? stored : \"\"}\n onValueChange={(next) => onChange(next === \"\" ? undefined : next)}\n />\n );\n }\n}\n","import { EntryPicker, type EntryItem } from \"../EntryPicker\";\nimport type { FieldRenderProps } from \"../Field\";\nimport { NumberField } from \"../NumberField\";\nimport { RichTextEditor, type RichTextDocument } from \"../RichTextEditor\";\nimport { emptyDocument } from \"../RichTextEditor/document\";\nimport { Select } from \"../Select\";\nimport { Switch } from \"../Switch\";\nimport { TextArea, TextField } from \"../TextField\";\nimport { AdditionalControl } from \"./additional-control\";\nimport {\n parseUtcDateTime,\n pickerCopy,\n pickerMode,\n textValue,\n type FieldOf,\n type FormField,\n type FormFieldValue,\n} from \"./model\";\n\nfunction pickerValue(\n field: FieldOf<\"asset\" | \"reference\">,\n ids: string[],\n): FormFieldValue | undefined {\n if (field.type === \"asset\") {\n const links = ids.map((assetId) => ({ assetId }));\n return field.multiple ? links : links[0];\n }\n const links = ids.map((entryId) => ({ entryId }));\n return field.multiple ? links : links[0];\n}\n\ntype Accessibility = FieldRenderProps;\n\nexport interface ControlProps<F extends FormField> {\n field: F;\n stored: FormFieldValue | undefined;\n isDisabled: boolean;\n required: boolean | undefined;\n accessibility: Omit<Accessibility, \"required\">;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\nfunction NumberControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"number\">>) {\n return (\n <NumberField\n {...accessibility}\n required={required}\n isDisabled={isDisabled}\n placeholder={field.placeholder}\n min={field.min}\n max={field.max}\n step={field.step ?? \"any\"}\n hasSteppers={field.hasSteppers ?? false}\n prefix={field.prefix}\n suffix={field.suffix}\n autoFocus={field.autoFocus}\n decreaseLabel={`Decrease ${field.label}`}\n increaseLabel={`Increase ${field.label}`}\n value={typeof stored === \"number\" && Number.isFinite(stored) ? stored : \"\"}\n onValueChange={(next) => {\n if (next === \"\" || Number.isFinite(next)) {\n onChange(next === \"\" ? undefined : next);\n }\n }}\n />\n );\n}\n\nfunction SelectControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"select\">>) {\n // Optional selects lead with an empty choice; picking it removes the key.\n const isClearable = !required && !field.options.some((option) => option.value === \"\");\n return (\n <Select\n {...accessibility}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n isInvalid={accessibility[\"aria-invalid\"]}\n options={\n isClearable\n ? [{ value: \"\", label: field.placeholder ?? \"None\" }, ...field.options]\n : field.options\n }\n placeholder={field.placeholder}\n autoFocus={field.autoFocus}\n value={typeof stored === \"string\" ? stored : \"\"}\n onValueChange={(next) => onChange(next === \"\" ? undefined : next)}\n />\n );\n}\n\nfunction PickerControl({\n field,\n selected,\n items,\n isDisabled,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"asset\" | \"reference\">> & { items: EntryItem[]; selected: string[] }) {\n return (\n <EntryPicker\n {...accessibility}\n items={items}\n value={selected}\n {...pickerCopy(field)}\n mode={pickerMode(field)}\n isDisabled={isDisabled}\n onValueChange={(ids) => onChange(pickerValue(field, ids))}\n />\n );\n}\n\ninterface FormControlProps {\n field: FormField;\n stored: FormFieldValue | undefined;\n /** Picker fields' stored IDs, derived once by the owning field. */\n selected: string[] | undefined;\n items: EntryItem[];\n isDisabled: boolean;\n accessibility: Accessibility;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\nexport function FormControl({\n field,\n stored,\n selected,\n items,\n isDisabled,\n accessibility: { required, ...accessibility },\n onChange,\n}: FormControlProps) {\n const shared = { stored, isDisabled, required, accessibility, onChange };\n switch (field.type) {\n case \"shortText\":\n return (\n <TextField\n {...accessibility}\n required={required}\n disabled={isDisabled}\n placeholder={field.placeholder}\n type={field.inputType}\n maxLength={field.maxLength}\n readOnly={field.readOnly}\n autoFocus={field.autoFocus}\n value={textValue(stored)}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n case \"longText\":\n return (\n <TextArea\n {...accessibility}\n required={required}\n disabled={isDisabled}\n placeholder={field.placeholder}\n rows={field.rows}\n maxLength={field.maxLength}\n readOnly={field.readOnly}\n autoFocus={field.autoFocus}\n value={textValue(stored)}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n case \"number\":\n return (\n <NumberControl\n field={field}\n {...shared}\n />\n );\n case \"boolean\":\n return (\n <Switch\n {...accessibility}\n isDisabled={isDisabled}\n autoFocus={field.autoFocus}\n isSelected={stored === true}\n onSelectedChange={onChange}\n />\n );\n case \"dateTime\":\n return (\n <TextField\n {...accessibility}\n required={required}\n disabled={isDisabled}\n type=\"datetime-local\"\n step=\"0.001\"\n autoFocus={field.autoFocus}\n value={parseUtcDateTime(stored)?.slice(0, -1) ?? \"\"}\n onChange={(event) => onChange(parseUtcDateTime(`${event.target.value}Z`))}\n />\n );\n case \"richText\":\n return (\n <RichTextEditor\n {...accessibility}\n expandedWidth={field.expandedWidth}\n label={field.label}\n isRequired={required}\n isDisabled={isDisabled}\n placeholder={field.placeholder}\n format=\"json\"\n value={stored === undefined ? emptyDocument : (stored as RichTextDocument)}\n onChange={onChange}\n />\n );\n case \"select\":\n return (\n <SelectControl\n field={field}\n {...shared}\n />\n );\n case \"asset\":\n case \"reference\":\n return (\n <PickerControl\n field={field}\n items={items}\n selected={selected ?? []}\n {...shared}\n />\n );\n default:\n return (\n <AdditionalControl\n field={field}\n {...shared}\n />\n );\n }\n}\n","import { useMemo, useState, type CSSProperties, type HTMLAttributes } from \"react\";\nimport { Container } from \"../Container\";\nimport type { EntryItem } from \"../EntryPicker\";\nimport { Field } from \"../Field\";\nimport type { GridColumns } from \"../Grid\";\nimport { FormControl } from \"./control\";\nimport {\n assertModel,\n fieldError,\n fieldLabel,\n fieldLimitProps,\n selectedIds,\n stringList,\n type FormField,\n type FormSchema,\n type FormErrors,\n type FormFieldValue,\n type FormValues,\n} from \"./model\";\nimport \"./style.css\";\n\nexport { validateFormValues } from \"./model\";\nexport type {\n AssetValue,\n FormField,\n FormDivider,\n FormItem,\n FormSchema,\n FormErrors,\n FormFieldValue,\n FormValues,\n ReferenceValue,\n} from \"./model\";\n\nexport interface FormChange {\n fieldId: string;\n}\n\nexport interface FormEditorProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n \"defaultValue\" | \"onChange\"\n> {\n schema: FormSchema;\n value?: FormValues;\n defaultValue?: FormValues;\n onValueChange?: (values: FormValues, change: FormChange) => void;\n /** Available assets or entries, keyed by field ID. Loading belongs to the app. */\n pickerItems?: Record<string, EntryItem[]>;\n /** App-provided messages take precedence over built-in validation. */\n errors?: FormErrors;\n isDisabled?: boolean;\n showAllErrors?: boolean;\n /** Columns at the widest. The form drops one whenever a field would be narrower than `minColumnWidth`. */\n columns?: GridColumns;\n /** Narrowest a field may get before the form drops a column. */\n minColumnWidth?: string;\n}\n\ninterface FormEditorFieldProps {\n field: FormField;\n stored: FormFieldValue | undefined;\n items: EntryItem[];\n isDisabled: boolean;\n error: string | undefined;\n isErrorVisible: boolean;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\n/** Validates only when its message can show, and only when its own field or value changes. */\nfunction FormEditorField({\n field,\n stored,\n items,\n isDisabled,\n error,\n isErrorVisible,\n onChange,\n}: FormEditorFieldProps) {\n const validation = useMemo(\n () => (error === undefined && isErrorVisible ? fieldError(field, stored) : undefined),\n [error, isErrorVisible, field, stored],\n );\n const selected = useMemo(\n () =>\n field.type === \"asset\" || field.type === \"reference\" ? selectedIds(field, stored) : undefined,\n [field, stored],\n );\n return (\n <Container\n width={field.width}\n padded={false}\n center={false}\n className=\"ds-form-editor__field\"\n >\n <Field\n {...fieldLimitProps(field, stored, selected)}\n label={field.type === \"dateTime\" ? `${field.label} (UTC)` : fieldLabel(field)}\n hint={field.hint}\n labelHint={field.labelHint}\n error={error ?? validation}\n isRequired={field.required}\n count={\n selected?.length ??\n (field.type === \"checkboxGroup\" ? stringList(stored).length : undefined)\n }\n isGroup={selected !== undefined || groupTypes.has(field.type)}\n >\n {(accessibility) => (\n <FormControl\n field={field}\n stored={stored}\n selected={selected}\n items={items}\n isDisabled={isDisabled}\n accessibility={accessibility}\n onChange={onChange}\n />\n )}\n </Field>\n </Container>\n );\n}\n\nconst groupTypes = new Set([\"radioGroup\", \"checkboxGroup\", \"rangeSlider\"]);\nconst loadedValidationTypes = new Set([\"slider\", \"rangeSlider\", \"date\", \"colour\"]);\n\n/** Ordered form controls. Loading, submission, and persistence belong to the app. */\nexport function FormEditor({\n schema,\n value,\n defaultValue = {},\n onValueChange,\n pickerItems = {},\n errors = {},\n isDisabled = false,\n showAllErrors = false,\n columns = 1,\n minColumnWidth = \"16rem\",\n className,\n style,\n ...rest\n}: FormEditorProps) {\n const [internal, setInternal] = useState<FormValues>(defaultValue);\n const [changed, setChanged] = useState<Set<string>>(() => new Set());\n const current = value ?? internal;\n useMemo(() => assertModel(schema), [schema]);\n\n const commit = (fieldId: string, next: FormFieldValue | undefined) => {\n const values = { ...current };\n if (next === undefined) {\n delete values[fieldId];\n } else {\n values[fieldId] = next;\n }\n if (value === undefined) {\n setInternal(values);\n }\n setChanged((previous) => new Set(previous).add(fieldId));\n onValueChange?.(values, { fieldId });\n };\n\n const layout =\n columns === \"auto\"\n ? { \"--form-editor-min-column\": minColumnWidth }\n : { \"--form-editor-columns\": columns, \"--form-editor-min-column\": minColumnWidth };\n\n return (\n <div\n className={[\"ds-form-editor\", columns === \"auto\" && \"ds-form-editor--auto\", className]\n .filter(Boolean)\n .join(\" \")}\n style={{ ...layout, ...style } as CSSProperties}\n {...rest}\n >\n {schema.fields.map((field) => {\n if (field.type === \"divider\") {\n return (\n <hr\n key={field.id}\n className=\"ds-form-editor__divider\"\n />\n );\n }\n const stored = Object.hasOwn(current, field.id) ? current[field.id] : undefined;\n const fieldDisabled = isDisabled || Boolean(field.isDisabled);\n const isLocked = fieldDisabled || (\"readOnly\" in field && Boolean(field.readOnly));\n // Explain loaded invalid values alongside the controls' invalid styling. Blank\n // strings are empty, so their required message waits like any other field's.\n const isLoaded = typeof stored === \"string\" ? stored.trim() !== \"\" : stored !== undefined;\n const isErrorVisible =\n showAllErrors ||\n changed.has(field.id) ||\n (isLoaded && loadedValidationTypes.has(field.type)) ||\n (field.type === \"number\" && typeof stored === \"number\");\n return (\n <FormEditorField\n key={field.id}\n field={field}\n stored={stored}\n items={pickerItems[field.id] ?? []}\n isDisabled={fieldDisabled}\n error={errors[field.id]}\n isErrorVisible={isErrorVisible}\n onChange={(next) => {\n if (!isLocked) {\n commit(field.id, next);\n }\n }}\n />\n );\n })}\n </div>\n );\n}\n"],"mappings":"A,gvBACA,IAAaoD,EAAiB,CAAC,OAAQ,MAAM,ECgBvCC,EAAc,CAAC,KAAM,KAAM,IAAI,EA0I/BC,EAAa,IAAI,IAAI,CACzB,YACA,WACA,WACA,SACA,UACA,WACA,QACA,YACA,SACA,SACA,cACA,SACA,aACA,gBACA,OACA,OACA,SACF,CAAC,EAED,SAAgBC,EAAY,EAAmB,CAC7C,IAAMC,EAAM,IAAI,IAChB,IAAK,IAAMC,KAASC,EAAM,OAAQ,CAChC,GAAI,CAACD,EAAM,IAAI,KAAK,GAAKD,EAAI,IAAIC,EAAM,EAAE,EACvC,MAAU,MAAM,6CAA6C,EAE/D,GAAI,CAACH,EAAW,IAAIG,EAAM,IAAI,EAC5B,MAAU,MAAM,gCAAgCA,EAAM,MAAM,GAE1DA,EAAM,OAAS,UAAYA,EAAM,OAAS,cAAgBA,EAAM,OAAS,kBAC3EE,GAAcF,CAAK,GAEjBA,EAAM,OAAS,UAAYA,EAAM,OAAS,gBAC5CG,EAAaH,CAAK,EAEhBA,EAAM,OAAS,YACjBI,EAAeJ,CAAK,EACpBK,EAAmBL,CAAK,GAE1BD,EAAI,IAAIC,EAAM,EAAE,CAClB,CACF,CAEA,IAAMM,EAAe,IAAI,IAAI,CAAC,YAAa,WAAY,OAAQ,QAAS,WAAW,CAAC,EAEpF,SAASC,EACP,EAC6E,CAC7E,OAAOD,EAAa,IAAIN,EAAM,IAAI,CACpC,CAEA,SAASK,E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M,EAAM,EAEZ,EAGL,IAAMU,EAAS,OAAO,OAAO4F,EAAStG,EAAM,EAAE,EAAIsG,EAAQtG,EAAM,IAAM,IAAA,GAChEiH,EAAgBhD,GAAc,EAAQjE,EAAM,WAC5CkH,EAAWD,GAAkB,aAAcjH,GAAS,EAAQA,EAAM,SAGlEmH,EAAW,OAAOzG,GAAW,SAAWA,EAAO,KAAK,IAAM,GAAKA,IAAW,IAAA,GAC1EkF,EACJwB,GACAhB,EAAQ,IAAIpG,EAAM,EAAE,GACnBmH,GAAYrB,GAAsB,IAAI9F,EAAM,IAAI,GAChDA,EAAM,OAAS,UAAY,OAAOU,GAAW,SAChD,OACE,EAAAhB,EAAA,IAAA,CAACgG,GAAD,CAES,QACC,SACR,MAAO2B,EAAYrH,EAAM,KAAO,CAAC,EACjC,WAAYiH,EACZ,MAAOK,EAAOtH,EAAM,IACJ,iBAChB,SAAW,GAAS,CACbkH,GACHV,EAAOxG,EAAM,GAAI6E,CAAI,CAEzB,CACD,EAZM7E,EAAM,EAYZ,CAEL,CAAC,CACE,CAAA,CAET,C"}
|
|
@@ -3,7 +3,7 @@ import { Field as t } from "../components/Field/index.js";
|
|
|
3
3
|
import { TextArea as n, TextField as r } from "../components/TextField/index.js";
|
|
4
4
|
import { n as i, r as a, t as o } from "./RichTextEditor-CNkwWist.js";
|
|
5
5
|
import { Container as s } from "../components/Container/index.js";
|
|
6
|
-
import { n as c, t as l } from "./EntryPicker-
|
|
6
|
+
import { n as c, t as l } from "./EntryPicker-B88N69zH.js";
|
|
7
7
|
import { NumberField as u } from "../components/NumberField/index.js";
|
|
8
8
|
import { Select as d } from "../components/Select/index.js";
|
|
9
9
|
import { Switch as f } from "../components/Switch/index.js";
|
|
@@ -579,6 +579,7 @@ function De({ field: e, stored: n, items: r, isDisabled: i, error: a, isErrorVis
|
|
|
579
579
|
...le(e, n, u),
|
|
580
580
|
label: e.type === "dateTime" ? `${e.label} (UTC)` : R(e),
|
|
581
581
|
hint: e.hint,
|
|
582
|
+
labelHint: e.labelHint,
|
|
582
583
|
error: a ?? l,
|
|
583
584
|
isRequired: e.required,
|
|
584
585
|
count: u?.length ?? (e.type === "checkboxGroup" ? q(n).length : void 0),
|
|
@@ -646,4 +647,4 @@ function Ae({ schema: e, value: t, defaultValue: n = {}, onValueChange: r, picke
|
|
|
646
647
|
//#endregion
|
|
647
648
|
export { _e as n, Ae as t };
|
|
648
649
|
|
|
649
|
-
//# sourceMappingURL=FormEditor-
|
|
650
|
+
//# sourceMappingURL=FormEditor-BkBhcYI5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormEditor-BkBhcYI5.js","names":["_Fragment","documentError","emptyDocument","RichTextEditor","selectionLimit","EntryPicker","parseColour","ColourField","sliderScale","preciseSum","Slider","clampToScale","RangeSlider","isIsoDate","DateField","Fragment$1","expandedWidths","fieldWidths","fieldTypes","assertModel","ids","field","model","assertChoices","assertSlider","assertMeasures","assertLimitOptions","limitedTypes","supportsLimit","fieldLimitProps","schemaLimit","stored","selected","textValue","stringList","pickerMode","pickerCopy","min","max","step","kind","values","option","value","linkCopy","fieldLabel","defaults","selectedIds","isLink","link","key","parseUtcDateTime","match","canonical","date","hasRichText","node","requiredError","textError","richTextError","error","choiceError","item","listError","numberError","dateError","sliderValue","scale","rangeSliderValue","range","start","end","low","high","a","b","rangeError","colourError","linkError","itemLabel","itemsLabel","validators","fieldError","validateFormValues","Option","props","isDisabled","invalid","onChange","Card","RadioCard","CheckboxCard","Choice","Radio","Checkbox","ChoiceControl","multiple","Group","SelectionCardGroup","ChoiceGroup","accessibility","required","Button","SliderControl","shown","next","RangeSliderControl","AdditionalControl","raw","event","TagsInput","pickerValue","links","NumberControl","NumberField","SelectControl","isClearable","Select","PickerControl","FormControl","shared","TextField","TextArea","Switch","FormEditorField","validation","useMemo","isErrorVisible","Container","Field","groupTypes","loadedValidationTypes","FormEditor","rest","internal","setInternal","useState","defaultValue","changed","setChanged","current","schema","commit","fieldId","previous","onValueChange","layout","columns","minColumnWidth","className","style","fieldDisabled","isLocked","isLoaded","showAllErrors","pickerItems","errors"],"sources":["../../src/components/RichTextEditor/expanded-width.ts","../../src/components/FormEditor/model.ts","../../src/components/FormEditor/choice-control.tsx","../../src/components/FormEditor/additional-control.tsx","../../src/components/FormEditor/control.tsx","../../src/components/FormEditor/index.tsx"],"sourcesContent":["/** Expanded writing measures: `wide` caps at the shared wide Modal width; `full` fills the viewport inside the scrim's gutters. */\nexport const expandedWidths = [\"wide\", \"full\"] as const;\n\nexport type RichTextEditorExpandedWidth = (typeof expandedWidths)[number];\n","import type { ReactNode } from \"react\";\nimport type { SelectOption } from \"../Select\";\nimport type { EntryPickerMode, EntryPickerProps } from \"../EntryPicker\";\nimport { selectionLimit } from \"../EntryPicker/limit\";\nimport type { JSONContent } from \"@tiptap/react\";\nimport { documentError } from \"../RichTextEditor/document\";\nimport type { RichTextDocument } from \"../RichTextEditor\";\nimport { expandedWidths, type RichTextEditorExpandedWidth } from \"../RichTextEditor/expanded-width\";\nimport { isIsoDate } from \"../DatePicker/date\";\nimport type { RangeSliderValue } from \"../Slider\";\nimport { clampToScale, preciseSum, sliderScale, type SliderScale } from \"../Slider/scale\";\nimport { parseColour } from \"../ColourField/colour\";\nimport type { PopoverPlacement } from \"../Popover\";\nimport type { ContainerWidth } from \"../Container\";\nimport type { FieldLimit, FieldLimitOptions } from \"../Field/types\";\n\n/** The shared measures a field may cap at; checked against Container's scale. */\nconst fieldWidths = [\"sm\", \"md\", \"lg\"] as const satisfies readonly ContainerWidth[];\n\ninterface FormFieldBase {\n id: string;\n label: string;\n labelHint?: ReactNode;\n hint?: ReactNode;\n /** Maximum width of the whole field, using Container's measures and its `lg` default. */\n width?: (typeof fieldWidths)[number];\n placeholder?: string;\n required?: boolean;\n isDisabled?: boolean;\n}\n\ninterface SliderOptions {\n multiple?: never;\n min?: number;\n max?: number;\n step?: number;\n prefix?: string;\n suffix?: string;\n hasValueLabel?: boolean;\n}\n\ninterface ChoiceOptions {\n multiple?: never;\n autoFocus?: never;\n options: SelectOption[];\n appearance?: \"default\" | \"card\";\n /** Maximum options per row inside this group; independent of FormEditor columns. */\n columns?: 1 | 2 | 3;\n}\n\nexport type FormField = FormFieldBase &\n (\n | ({\n type: \"shortText\";\n inputType?: \"text\" | \"email\";\n maxLength?: number;\n readOnly?: boolean;\n autoFocus?: boolean;\n multiple?: never;\n } & FieldLimitOptions)\n | ({\n type: \"longText\";\n rows?: number;\n maxLength?: number;\n readOnly?: boolean;\n autoFocus?: boolean;\n multiple?: never;\n } & FieldLimitOptions)\n | { type: \"boolean\" | \"dateTime\"; autoFocus?: boolean; multiple?: never }\n | {\n type: \"richText\";\n expandedWidth?: RichTextEditorExpandedWidth;\n autoFocus?: never;\n multiple?: never;\n }\n | {\n type: \"number\";\n min?: number;\n max?: number;\n step?: number | \"any\";\n hasSteppers?: boolean;\n prefix?: string;\n suffix?: string;\n autoFocus?: boolean;\n multiple?: never;\n }\n | { type: \"select\"; options: SelectOption[]; autoFocus?: boolean; multiple?: never }\n | ({ type: \"slider\"; autoFocus?: boolean } & SliderOptions)\n | ({ type: \"rangeSlider\"; autoFocus?: never } & SliderOptions)\n | ({ type: \"radioGroup\" } & ChoiceOptions)\n | ({ type: \"checkboxGroup\" } & ChoiceOptions)\n | {\n type: \"colour\";\n multiple?: never;\n presets?: string[];\n showPresets?: boolean;\n picker?: \"custom\" | \"native\";\n placement?: PopoverPlacement;\n readOnly?: boolean;\n autoFocus?: boolean;\n }\n | ({ type: \"tags\"; max?: number; multiple?: never; autoFocus?: never } & FieldLimitOptions)\n | {\n type: \"date\";\n min?: string;\n max?: string;\n placement?: PopoverPlacement;\n multiple?: never;\n autoFocus?: never;\n }\n | ({\n type: \"asset\" | \"reference\";\n multiple?: boolean;\n autoFocus?: never;\n picker?: Pick<\n EntryPickerProps,\n \"label\" | \"addLabel\" | \"emptyLabel\" | \"itemLabel\" | \"itemsLabel\" | \"max\" | \"isReorderable\"\n >;\n } & FieldLimitOptions)\n );\n\nexport type FieldOf<T extends FormField[\"type\"]> = Extract<FormField, { type: T }>;\n\n/** Layout only: no label, value, disabled state, or validation. */\nexport interface FormDivider {\n id: string;\n type: \"divider\";\n}\n\nexport type FormItem = FormField | FormDivider;\n\nexport interface FormSchema {\n fields: readonly FormItem[];\n}\n\nexport interface AssetValue {\n assetId: string;\n}\nexport interface ReferenceValue {\n entryId: string;\n}\nexport type FormFieldValue =\n | string\n | number\n | boolean\n | RichTextDocument\n | AssetValue\n | ReferenceValue\n | string[]\n | RangeSliderValue\n | AssetValue[]\n | ReferenceValue[];\nexport type FormValues = Record<string, FormFieldValue | undefined>;\nexport type FormErrors = Partial<Record<string, string>>;\n\nconst fieldTypes = new Set([\n \"shortText\",\n \"longText\",\n \"richText\",\n \"number\",\n \"boolean\",\n \"dateTime\",\n \"asset\",\n \"reference\",\n \"select\",\n \"slider\",\n \"rangeSlider\",\n \"colour\",\n \"radioGroup\",\n \"checkboxGroup\",\n \"tags\",\n \"date\",\n \"divider\",\n]);\n\nexport function assertModel(model: FormSchema) {\n const ids = new Set<string>();\n for (const field of model.fields) {\n if (!field.id?.trim() || ids.has(field.id)) {\n throw new Error(\"Form field IDs must be nonempty and unique.\");\n }\n if (!fieldTypes.has(field.type)) {\n throw new Error(`Unsupported form field type: ${field.type}`);\n }\n if (field.type === \"select\" || field.type === \"radioGroup\" || field.type === \"checkboxGroup\") {\n assertChoices(field);\n }\n if (field.type === \"slider\" || field.type === \"rangeSlider\") {\n assertSlider(field);\n }\n if (field.type !== \"divider\") {\n assertMeasures(field);\n assertLimitOptions(field);\n }\n ids.add(field.id);\n }\n}\n\nconst limitedTypes = new Set([\"shortText\", \"longText\", \"tags\", \"asset\", \"reference\"]);\n\nfunction supportsLimit(\n field: FormField,\n): field is FieldOf<\"shortText\" | \"longText\" | \"tags\" | \"asset\" | \"reference\"> {\n return limitedTypes.has(field.type);\n}\n\nfunction assertLimitOptions(field: FormField) {\n if (!supportsLimit(field)) {\n return;\n }\n if (field.limitDisplay !== undefined && ![\"used\", \"remaining\"].includes(field.limitDisplay)) {\n throw new Error(`Field ${field.id} needs a limitDisplay of used or remaining.`);\n }\n if (\n field.limitVisibility !== undefined &&\n ![\"always\", \"nearLimit\"].includes(field.limitVisibility)\n ) {\n throw new Error(`Field ${field.id} needs a limitVisibility of always or nearLimit.`);\n }\n if (field.showLimitRing !== undefined && typeof field.showLimitRing !== \"boolean\") {\n throw new Error(`Field ${field.id} needs a boolean showLimitRing.`);\n }\n}\n\n/**\n * Explicit limits for complete server markup. Counts come from the helpers the\n * adapters display with (`textValue`, `stringList`, the owning field's selected\n * IDs and EntryPicker's `selectionLimit`), so the counter cannot drift from them.\n */\nexport function fieldLimitProps(\n field: FormField,\n stored: FormFieldValue | undefined,\n selected: string[] | undefined,\n): FieldLimitOptions & { limit?: FieldLimit } {\n if (!supportsLimit(field)) {\n return {};\n }\n return {\n limitDisplay: field.limitDisplay,\n limitVisibility: field.limitVisibility,\n showLimitRing: field.showLimitRing,\n limit: schemaLimit(field, stored, selected ?? []),\n };\n}\n\nfunction schemaLimit(\n field: FieldOf<\"shortText\" | \"longText\" | \"tags\" | \"asset\" | \"reference\">,\n stored: FormFieldValue | undefined,\n selected: string[],\n): FieldLimit | undefined {\n switch (field.type) {\n case \"shortText\":\n case \"longText\":\n return field.maxLength === undefined\n ? undefined\n : { count: textValue(stored).length, max: field.maxLength };\n case \"tags\":\n return field.max === undefined\n ? undefined\n : { count: stringList(stored).length, max: field.max };\n default:\n return selectionLimit(pickerMode(field), selected.length, pickerCopy(field).max);\n }\n}\n\n/** The text a shortText or longText adapter displays. */\nexport function textValue(stored: unknown): string {\n return typeof stored === \"string\" ? stored : \"\";\n}\n\n/** The EntryPicker mode a picker field renders with. */\nexport function pickerMode(field: FieldOf<\"asset\" | \"reference\">): EntryPickerMode {\n return field.multiple ? \"multiple\" : \"single\";\n}\n\n/** Runtime schemas can carry any string; the types only cover typed schemas. */\nfunction assertMeasures(field: FormField) {\n if (field.width !== undefined && !fieldWidths.includes(field.width)) {\n throw new Error(`Field ${field.id} needs a width of sm, md or lg.`);\n }\n if (\n field.type === \"richText\" &&\n field.expandedWidth !== undefined &&\n !expandedWidths.includes(field.expandedWidth)\n ) {\n throw new Error(`Rich text field ${field.id} needs an expandedWidth of wide or full.`);\n }\n}\n\nfunction assertSlider(field: FieldOf<\"slider\" | \"rangeSlider\">) {\n const { min, max, step } = sliderScale(field);\n if (![min, max, step].every(Number.isFinite) || min >= max || step <= 0) {\n throw new Error(`Slider field ${field.id} needs finite min < max and a positive step.`);\n }\n if (field.type === \"rangeSlider\" && step > preciseSum(max, -min)) {\n throw new Error(`Range slider ${field.id} needs room for at least one step.`);\n }\n}\n\nfunction assertChoices(field: FieldOf<\"select\" | \"radioGroup\" | \"checkboxGroup\">) {\n if (!Array.isArray(field.options)) {\n const kind = field.type === \"select\" ? \"Select\" : \"Choice\";\n throw new Error(`${kind} field ${field.id} needs an options array.`);\n }\n if (field.type === \"select\") {\n return;\n }\n const values = field.options.map((option) => option.value);\n if (\n values.some((value) => typeof value !== \"string\" || !value.trim()) ||\n new Set(values).size !== values.length\n ) {\n throw new Error(`Choice field ${field.id} needs nonempty, unique option values.`);\n }\n}\n\nconst linkCopy = {\n asset: { key: \"assetId\", itemLabel: \"asset\", itemsLabel: \"assets\" },\n reference: { key: \"entryId\", itemLabel: \"entry\", itemsLabel: \"entries\" },\n} as const;\n\n/** The field's visible and accessible name. A picker's `label` overrides it. */\nexport function fieldLabel(field: FormField): string {\n return field.type === \"asset\" || field.type === \"reference\"\n ? (field.picker?.label ?? field.label)\n : field.label;\n}\n\n/** Picker action and item copy, with asset or entry wording for any option left out or undefined. */\nexport function pickerCopy(field: FieldOf<\"asset\" | \"reference\">) {\n const defaults = linkCopy[field.type];\n const {\n addLabel = `Choose ${fieldLabel(field)}`,\n emptyLabel,\n itemLabel = defaults.itemLabel,\n itemsLabel = defaults.itemsLabel,\n max,\n isReorderable,\n } = field.picker ?? {};\n return { addLabel, emptyLabel, itemLabel, itemsLabel, max, isReorderable };\n}\n\n/** The picked IDs, in stored order, skipping anything that isn't a link. */\nexport function selectedIds(field: FieldOf<\"asset\" | \"reference\">, value: unknown): string[] {\n const { key } = linkCopy[field.type];\n const links = Array.isArray(value) ? value : value === undefined ? [] : [value];\n return links.flatMap((link) =>\n isLink(link, key) ? [(link as Record<string, string>)[key]] : [],\n );\n}\n\n/** Accept UTC ISO strings without rolling invalid dates into the next month. */\nexport function parseUtcDateTime(value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return;\n }\n const match = /^(\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3}))?)?(?:Z|\\+00:00)$/.exec(\n value,\n );\n if (!match) {\n return;\n }\n const canonical = `${match[1]}:${match[2] ?? \"00\"}.${(match[3] ?? \"\").padEnd(3, \"0\")}Z`;\n const date = new Date(canonical);\n if (Number.isFinite(date.getTime()) && date.toISOString() === canonical) {\n return canonical;\n }\n}\n\nfunction isLink(value: unknown, key: \"assetId\" | \"entryId\"): boolean {\n return (\n !!value &&\n typeof value === \"object\" &&\n key in value &&\n typeof (value as Record<string, unknown>)[key] === \"string\" &&\n (value as Record<string, string>)[key].trim().length > 0\n );\n}\n\nfunction hasRichText(node: JSONContent): boolean {\n return !!node.text?.trim() || node.type === \"horizontalRule\" || !!node.content?.some(hasRichText);\n}\n\nfunction requiredError(field: FormField): string {\n return `${fieldLabel(field)} is required.`;\n}\n\nfunction textError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Enter text.\";\n }\n if (field.required && !value.trim()) {\n return requiredError(field);\n }\n if (\n (field.type === \"shortText\" || field.type === \"longText\") &&\n field.maxLength !== undefined &&\n value.length > field.maxLength\n ) {\n return `Enter no more than ${field.maxLength} characters.`;\n }\n}\n\nfunction richTextError(field: FormField, value: unknown): string | undefined {\n const error = documentError(value);\n if (error) {\n return error;\n }\n if (field.required && !hasRichText(value as RichTextDocument)) {\n return requiredError(field);\n }\n}\n\nfunction choiceError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Choose an available option.\";\n }\n if (value === \"\") {\n return field.required ? requiredError(field) : undefined;\n }\n // An empty list means the choices are still loading, so a stored value stays valid until they arrive.\n if (\n (field.type === \"select\" || field.type === \"radioGroup\") &&\n field.options.length > 0 &&\n !field.options.some((option) => option.value === value)\n ) {\n return \"Choose an available option.\";\n }\n}\n\nexport function stringList(value: unknown): string[] {\n return Array.isArray(value)\n ? value.filter((item): item is string => typeof item === \"string\")\n : [];\n}\n\nfunction listError(field: FormField, value: unknown): string | undefined {\n if (\n !Array.isArray(value) ||\n !value.every((item) => typeof item === \"string\" && item.trim()) ||\n new Set(value).size !== value.length\n ) {\n return \"Enter a list of unique, nonempty text values.\";\n }\n if (field.required && !value.length) {\n return requiredError(field);\n }\n if (field.type === \"tags\" && field.max !== undefined && value.length > field.max) {\n return `Enter no more than ${field.max} tags.`;\n }\n if (\n field.type === \"checkboxGroup\" &&\n field.options.length &&\n value.some((item) => !field.options.some((option) => option.value === item))\n ) {\n return \"Choose available options.\";\n }\n}\n\nfunction numberError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) {\n return \"Enter a finite number.\";\n }\n const { min, max }: { min?: number; max?: number } =\n field.type === \"slider\" || field.type === \"rangeSlider\"\n ? sliderScale(field)\n : field.type === \"number\"\n ? field\n : {};\n if (min !== undefined && value < min) {\n return `Enter a number of at least ${min}.`;\n }\n if (max !== undefined && value > max) {\n return `Enter a number no greater than ${max}.`;\n }\n}\n\nfunction dateError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Enter a valid calendar date (YYYY-MM-DD).\";\n }\n if (!value) {\n return field.required ? requiredError(field) : undefined;\n }\n if (!isIsoDate(value)) {\n return \"Enter a valid calendar date (YYYY-MM-DD).\";\n }\n if (field.type !== \"date\") {\n return;\n }\n if (field.min && value < field.min) {\n return `Choose a date on or after ${field.min}.`;\n }\n if (field.max && value > field.max) {\n return `Choose a date on or before ${field.max}.`;\n }\n}\n\n/**\n * Display positions for loaded values: out-of-scale numbers clamp and reversed\n * endpoints swap, without overwriting the stored data that validation reports.\n * A value that is not a finite number has no position, so the control is unset.\n */\nexport function sliderValue(value: unknown, scale: SliderScale): number | undefined {\n return typeof value === \"number\" && Number.isFinite(value)\n ? clampToScale(value, scale)\n : undefined;\n}\n\n/** A range with neither endpoint usable is unset; one usable endpoint pairs with the scale's end. */\nexport function rangeSliderValue(value: unknown, scale: SliderScale): RangeSliderValue | undefined {\n const range = value as Partial<Record<\"min\" | \"max\", unknown>> | null;\n const start = sliderValue(range?.min, scale);\n const end = sliderValue(range?.max, scale);\n if (start === undefined && end === undefined) {\n return undefined;\n }\n const [low, high] = [start ?? scale.min, end ?? scale.max].sort((a, b) => a - b);\n return { min: low, max: high };\n}\n\nfunction rangeError(field: FormField, value: unknown): string | undefined {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n return \"Enter a range.\";\n }\n const range = value as Record<string, unknown>;\n const start = range.min;\n const end = range.max;\n const error = numberError(field, start) ?? numberError(field, end);\n if (error) {\n return error;\n }\n if ((start as number) > (end as number)) {\n return \"The start must not be greater than the end.\";\n }\n if (\n field.type === \"rangeSlider\" &&\n preciseSum(end as number, -(start as number)) < sliderScale(field).step\n ) {\n return \"Keep the range endpoints at least one step apart.\";\n }\n}\n\nfunction colourError(field: FormField, value: unknown): string | undefined {\n if (typeof value !== \"string\") {\n return \"Enter a valid colour.\";\n }\n if (!value.trim()) {\n return field.required ? requiredError(field) : undefined;\n }\n return parseColour(value) ? undefined : \"Enter a valid colour.\";\n}\n\nfunction linkError(field: FormField, value: unknown): string | undefined {\n if (field.type !== \"asset\" && field.type !== \"reference\") {\n return;\n }\n const { key, itemLabel, itemsLabel } = linkCopy[field.type];\n if (!field.multiple) {\n return isLink(value, key) ? undefined : `Choose an ${itemLabel}.`;\n }\n if (!Array.isArray(value) || !value.every((item) => isLink(item, key))) {\n return `Choose a list of ${itemsLabel}.`;\n }\n if (field.required && value.length === 0) {\n return requiredError(field);\n }\n const max = field.picker?.max;\n if (max !== undefined && value.length > max) {\n return `Choose no more than ${max} ${pickerCopy(field).itemsLabel}.`;\n }\n}\n\nconst validators: Record<\n FormField[\"type\"],\n (field: FormField, value: unknown) => string | undefined\n> = {\n shortText: textError,\n longText: textError,\n richText: richTextError,\n number: numberError,\n slider: numberError,\n rangeSlider: rangeError,\n date: dateError,\n colour: colourError,\n radioGroup: choiceError,\n checkboxGroup: listError,\n tags: listError,\n boolean: (_field, value) => (typeof value === \"boolean\" ? undefined : \"Choose a boolean value.\"),\n dateTime: (_field, value) =>\n parseUtcDateTime(value) ? undefined : \"Enter a valid UTC date and time.\",\n select: choiceError,\n asset: linkError,\n reference: linkError,\n};\n\nexport function fieldError(field: FormField, value: unknown): string | undefined {\n if (value === undefined) {\n return field.required ? requiredError(field) : undefined;\n }\n return validators[field.type](field, value);\n}\n\n/** Validate data loaded from JSON as well as values emitted by FormEditor. */\nexport function validateFormValues(model: FormSchema, values: Record<string, unknown>): FormErrors {\n assertModel(model);\n return Object.fromEntries(\n model.fields.flatMap((field): [string, string][] => {\n if (field.type === \"divider\") {\n return [];\n }\n const error = fieldError(\n field,\n Object.hasOwn(values, field.id) ? values[field.id] : undefined,\n );\n return error ? [[field.id, error]] : [];\n }),\n );\n}\n","import { Button } from \"../Button\";\nimport { Checkbox, ChoiceGroup, Radio } from \"../Choice\";\nimport { CheckboxCard, RadioCard, SelectionCardGroup } from \"../SelectionCard\";\nimport type { SelectOption } from \"../Select\";\nimport type { ControlProps } from \"./control\";\nimport { stringList, type FieldOf } from \"./model\";\n\ntype ChoiceField = FieldOf<\"radioGroup\" | \"checkboxGroup\">;\n\nfunction Option({\n field,\n option,\n name,\n checked,\n isDisabled,\n invalid,\n onChange,\n}: {\n field: ChoiceField;\n option: SelectOption;\n name: string;\n checked: boolean;\n isDisabled: boolean;\n invalid: true | undefined;\n onChange: () => void;\n}) {\n const props = {\n name,\n value: option.value,\n checked,\n disabled: isDisabled || option.isDisabled,\n \"aria-invalid\": invalid,\n onChange: () => {\n if (!isDisabled && !option.isDisabled) {\n onChange();\n }\n },\n };\n if (field.appearance === \"card\") {\n const Card = field.type === \"radioGroup\" ? RadioCard : CheckboxCard;\n return (\n <Card\n {...props}\n title={option.label}\n description={option.description}\n />\n );\n }\n const Choice = field.type === \"radioGroup\" ? Radio : Checkbox;\n return (\n <Choice {...props}>\n <span>\n {option.label}\n {option.description && (\n <span className=\"ds-form-editor__option-description\">{option.description}</span>\n )}\n </span>\n </Choice>\n );\n}\n\nexport function ChoiceControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<ChoiceField>) {\n const multiple = field.type === \"checkboxGroup\";\n // Option values are nonempty, so a stored \"\" selects nothing.\n const selected = multiple\n ? stringList(stored)\n : typeof stored === \"string\" && stored\n ? [stored]\n : [];\n const Group = field.appearance === \"card\" ? SelectionCardGroup : ChoiceGroup;\n return (\n <>\n <Group\n {...accessibility}\n label={field.label}\n columns={field.columns ?? (field.appearance === \"card\" ? 2 : 1)}\n >\n {field.options.map((option) => (\n <Option\n key={option.value}\n field={field}\n option={option}\n name={accessibility.id}\n checked={selected.includes(option.value)}\n isDisabled={isDisabled}\n invalid={accessibility[\"aria-invalid\"]}\n onChange={() => {\n if (multiple) {\n onChange(\n selected.includes(option.value)\n ? selected.filter((value) => value !== option.value)\n : [...selected, option.value],\n );\n } else {\n onChange(option.value);\n }\n }}\n />\n ))}\n </Group>\n {!multiple && !required && selected.length > 0 && (\n <Button\n variant=\"simple\"\n size=\"sm\"\n isDisabled={isDisabled}\n onClick={() => onChange(undefined)}\n >\n Clear {field.label}\n </Button>\n )}\n </>\n );\n}\n","import { ColourField } from \"../ColourField\";\nimport { parseColour } from \"../ColourField/colour\";\nimport { DateField } from \"../DatePicker\";\nimport { RangeSlider, Slider } from \"../Slider\";\nimport { sliderScale } from \"../Slider/scale\";\nimport { TagsInput } from \"../TagsInput\";\nimport { ChoiceControl } from \"./choice-control\";\nimport type { ControlProps } from \"./control\";\nimport { rangeSliderValue, sliderValue, stringList, type FieldOf } from \"./model\";\n\ntype AdditionalField = FieldOf<\n \"slider\" | \"rangeSlider\" | \"date\" | \"colour\" | \"tags\" | \"radioGroup\" | \"checkboxGroup\"\n>;\n\nfunction SliderControl({\n field,\n stored,\n isDisabled,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"slider\">>) {\n const scale = sliderScale(field);\n const shown = sliderValue(stored, scale);\n return (\n <Slider\n {...accessibility}\n {...scale}\n prefix={field.prefix}\n suffix={field.suffix}\n hasValueLabel={field.hasValueLabel}\n valueText={shown === undefined ? (field.placeholder ?? \"Not set\") : undefined}\n autoFocus={field.autoFocus}\n isDisabled={isDisabled}\n value={shown ?? scale.min}\n onValueChange={onChange}\n // An unset thumb rests at the minimum, where a click or a key toward it fires\n // no change event. Committing stores the position the slider shows.\n onValueCommit={(next) => {\n if (shown === undefined) {\n onChange(next);\n }\n }}\n />\n );\n}\n\nfunction RangeSliderControl({\n field,\n stored,\n isDisabled,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"rangeSlider\">>) {\n const scale = sliderScale(field);\n const shown = rangeSliderValue(stored, scale);\n return (\n <RangeSlider\n {...accessibility}\n {...scale}\n prefix={field.prefix}\n suffix={field.suffix}\n hasValueLabel={field.hasValueLabel}\n minLabel={`${field.label} minimum`}\n maxLabel={`${field.label} maximum`}\n isDisabled={isDisabled}\n // Unset thumbs rest at both ends without a fill, so nothing looks chosen; a click\n // or key that leaves them there stores the full range they show.\n valueText={shown === undefined ? (field.placeholder ?? \"Not set\") : undefined}\n hasFill={shown !== undefined}\n value={shown ?? { min: scale.min, max: scale.max }}\n onValueChange={onChange}\n onValueCommit={(next) => {\n if (shown === undefined) {\n onChange(next);\n }\n }}\n />\n );\n}\n\nexport function AdditionalControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<AdditionalField>) {\n const props = { stored, isDisabled, required, accessibility, onChange };\n switch (field.type) {\n case \"radioGroup\":\n case \"checkboxGroup\":\n return (\n <ChoiceControl\n field={field}\n {...props}\n />\n );\n case \"rangeSlider\":\n return (\n <RangeSliderControl\n field={field}\n {...props}\n />\n );\n case \"slider\":\n return (\n <SliderControl\n field={field}\n {...props}\n />\n );\n case \"colour\":\n return (\n <ColourField\n {...accessibility}\n required={required}\n placeholder={field.placeholder}\n presets={field.presets}\n showPresets={field.showPresets}\n picker={field.picker}\n placement={field.placement}\n readOnly={field.readOnly}\n autoFocus={field.autoFocus}\n isDisabled={isDisabled}\n value={typeof stored === \"string\" ? stored : \"\"}\n onInput={(event) => {\n const raw = event.currentTarget.value;\n if (raw.trim() && !parseColour(raw)) {\n onChange(raw);\n }\n }}\n onValueChange={(next) => onChange(next === \"\" ? undefined : next)}\n />\n );\n case \"tags\":\n return (\n <TagsInput\n {...accessibility}\n required={required}\n placeholder={field.placeholder}\n max={field.max}\n isDisabled={isDisabled}\n value={stringList(stored)}\n onValueChange={onChange}\n />\n );\n case \"date\":\n return (\n <DateField\n {...accessibility}\n placeholder={field.placeholder}\n min={field.min}\n max={field.max}\n placement={field.placement}\n isDisabled={isDisabled}\n isClearable\n clearLabel={`Clear ${field.label}`}\n value={typeof stored === \"string\" ? stored : \"\"}\n onValueChange={(next) => onChange(next === \"\" ? undefined : next)}\n />\n );\n }\n}\n","import { EntryPicker, type EntryItem } from \"../EntryPicker\";\nimport type { FieldRenderProps } from \"../Field\";\nimport { NumberField } from \"../NumberField\";\nimport { RichTextEditor, type RichTextDocument } from \"../RichTextEditor\";\nimport { emptyDocument } from \"../RichTextEditor/document\";\nimport { Select } from \"../Select\";\nimport { Switch } from \"../Switch\";\nimport { TextArea, TextField } from \"../TextField\";\nimport { AdditionalControl } from \"./additional-control\";\nimport {\n parseUtcDateTime,\n pickerCopy,\n pickerMode,\n textValue,\n type FieldOf,\n type FormField,\n type FormFieldValue,\n} from \"./model\";\n\nfunction pickerValue(\n field: FieldOf<\"asset\" | \"reference\">,\n ids: string[],\n): FormFieldValue | undefined {\n if (field.type === \"asset\") {\n const links = ids.map((assetId) => ({ assetId }));\n return field.multiple ? links : links[0];\n }\n const links = ids.map((entryId) => ({ entryId }));\n return field.multiple ? links : links[0];\n}\n\ntype Accessibility = FieldRenderProps;\n\nexport interface ControlProps<F extends FormField> {\n field: F;\n stored: FormFieldValue | undefined;\n isDisabled: boolean;\n required: boolean | undefined;\n accessibility: Omit<Accessibility, \"required\">;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\nfunction NumberControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"number\">>) {\n return (\n <NumberField\n {...accessibility}\n required={required}\n isDisabled={isDisabled}\n placeholder={field.placeholder}\n min={field.min}\n max={field.max}\n step={field.step ?? \"any\"}\n hasSteppers={field.hasSteppers ?? false}\n prefix={field.prefix}\n suffix={field.suffix}\n autoFocus={field.autoFocus}\n decreaseLabel={`Decrease ${field.label}`}\n increaseLabel={`Increase ${field.label}`}\n value={typeof stored === \"number\" && Number.isFinite(stored) ? stored : \"\"}\n onValueChange={(next) => {\n if (next === \"\" || Number.isFinite(next)) {\n onChange(next === \"\" ? undefined : next);\n }\n }}\n />\n );\n}\n\nfunction SelectControl({\n field,\n stored,\n isDisabled,\n required,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"select\">>) {\n // Optional selects lead with an empty choice; picking it removes the key.\n const isClearable = !required && !field.options.some((option) => option.value === \"\");\n return (\n <Select\n {...accessibility}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n isInvalid={accessibility[\"aria-invalid\"]}\n options={\n isClearable\n ? [{ value: \"\", label: field.placeholder ?? \"None\" }, ...field.options]\n : field.options\n }\n placeholder={field.placeholder}\n autoFocus={field.autoFocus}\n value={typeof stored === \"string\" ? stored : \"\"}\n onValueChange={(next) => onChange(next === \"\" ? undefined : next)}\n />\n );\n}\n\nfunction PickerControl({\n field,\n selected,\n items,\n isDisabled,\n accessibility,\n onChange,\n}: ControlProps<FieldOf<\"asset\" | \"reference\">> & { items: EntryItem[]; selected: string[] }) {\n return (\n <EntryPicker\n {...accessibility}\n items={items}\n value={selected}\n {...pickerCopy(field)}\n mode={pickerMode(field)}\n isDisabled={isDisabled}\n onValueChange={(ids) => onChange(pickerValue(field, ids))}\n />\n );\n}\n\ninterface FormControlProps {\n field: FormField;\n stored: FormFieldValue | undefined;\n /** Picker fields' stored IDs, derived once by the owning field. */\n selected: string[] | undefined;\n items: EntryItem[];\n isDisabled: boolean;\n accessibility: Accessibility;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\nexport function FormControl({\n field,\n stored,\n selected,\n items,\n isDisabled,\n accessibility: { required, ...accessibility },\n onChange,\n}: FormControlProps) {\n const shared = { stored, isDisabled, required, accessibility, onChange };\n switch (field.type) {\n case \"shortText\":\n return (\n <TextField\n {...accessibility}\n required={required}\n disabled={isDisabled}\n placeholder={field.placeholder}\n type={field.inputType}\n maxLength={field.maxLength}\n readOnly={field.readOnly}\n autoFocus={field.autoFocus}\n value={textValue(stored)}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n case \"longText\":\n return (\n <TextArea\n {...accessibility}\n required={required}\n disabled={isDisabled}\n placeholder={field.placeholder}\n rows={field.rows}\n maxLength={field.maxLength}\n readOnly={field.readOnly}\n autoFocus={field.autoFocus}\n value={textValue(stored)}\n onChange={(event) => onChange(event.target.value)}\n />\n );\n case \"number\":\n return (\n <NumberControl\n field={field}\n {...shared}\n />\n );\n case \"boolean\":\n return (\n <Switch\n {...accessibility}\n isDisabled={isDisabled}\n autoFocus={field.autoFocus}\n isSelected={stored === true}\n onSelectedChange={onChange}\n />\n );\n case \"dateTime\":\n return (\n <TextField\n {...accessibility}\n required={required}\n disabled={isDisabled}\n type=\"datetime-local\"\n step=\"0.001\"\n autoFocus={field.autoFocus}\n value={parseUtcDateTime(stored)?.slice(0, -1) ?? \"\"}\n onChange={(event) => onChange(parseUtcDateTime(`${event.target.value}Z`))}\n />\n );\n case \"richText\":\n return (\n <RichTextEditor\n {...accessibility}\n expandedWidth={field.expandedWidth}\n label={field.label}\n isRequired={required}\n isDisabled={isDisabled}\n placeholder={field.placeholder}\n format=\"json\"\n value={stored === undefined ? emptyDocument : (stored as RichTextDocument)}\n onChange={onChange}\n />\n );\n case \"select\":\n return (\n <SelectControl\n field={field}\n {...shared}\n />\n );\n case \"asset\":\n case \"reference\":\n return (\n <PickerControl\n field={field}\n items={items}\n selected={selected ?? []}\n {...shared}\n />\n );\n default:\n return (\n <AdditionalControl\n field={field}\n {...shared}\n />\n );\n }\n}\n","import { useMemo, useState, type CSSProperties, type HTMLAttributes } from \"react\";\nimport { Container } from \"../Container\";\nimport type { EntryItem } from \"../EntryPicker\";\nimport { Field } from \"../Field\";\nimport type { GridColumns } from \"../Grid\";\nimport { FormControl } from \"./control\";\nimport {\n assertModel,\n fieldError,\n fieldLabel,\n fieldLimitProps,\n selectedIds,\n stringList,\n type FormField,\n type FormSchema,\n type FormErrors,\n type FormFieldValue,\n type FormValues,\n} from \"./model\";\nimport \"./style.css\";\n\nexport { validateFormValues } from \"./model\";\nexport type {\n AssetValue,\n FormField,\n FormDivider,\n FormItem,\n FormSchema,\n FormErrors,\n FormFieldValue,\n FormValues,\n ReferenceValue,\n} from \"./model\";\n\nexport interface FormChange {\n fieldId: string;\n}\n\nexport interface FormEditorProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n \"defaultValue\" | \"onChange\"\n> {\n schema: FormSchema;\n value?: FormValues;\n defaultValue?: FormValues;\n onValueChange?: (values: FormValues, change: FormChange) => void;\n /** Available assets or entries, keyed by field ID. Loading belongs to the app. */\n pickerItems?: Record<string, EntryItem[]>;\n /** App-provided messages take precedence over built-in validation. */\n errors?: FormErrors;\n isDisabled?: boolean;\n showAllErrors?: boolean;\n /** Columns at the widest. The form drops one whenever a field would be narrower than `minColumnWidth`. */\n columns?: GridColumns;\n /** Narrowest a field may get before the form drops a column. */\n minColumnWidth?: string;\n}\n\ninterface FormEditorFieldProps {\n field: FormField;\n stored: FormFieldValue | undefined;\n items: EntryItem[];\n isDisabled: boolean;\n error: string | undefined;\n isErrorVisible: boolean;\n onChange: (value: FormFieldValue | undefined) => void;\n}\n\n/** Validates only when its message can show, and only when its own field or value changes. */\nfunction FormEditorField({\n field,\n stored,\n items,\n isDisabled,\n error,\n isErrorVisible,\n onChange,\n}: FormEditorFieldProps) {\n const validation = useMemo(\n () => (error === undefined && isErrorVisible ? fieldError(field, stored) : undefined),\n [error, isErrorVisible, field, stored],\n );\n const selected = useMemo(\n () =>\n field.type === \"asset\" || field.type === \"reference\" ? selectedIds(field, stored) : undefined,\n [field, stored],\n );\n return (\n <Container\n width={field.width}\n padded={false}\n center={false}\n className=\"ds-form-editor__field\"\n >\n <Field\n {...fieldLimitProps(field, stored, selected)}\n label={field.type === \"dateTime\" ? `${field.label} (UTC)` : fieldLabel(field)}\n hint={field.hint}\n labelHint={field.labelHint}\n error={error ?? validation}\n isRequired={field.required}\n count={\n selected?.length ??\n (field.type === \"checkboxGroup\" ? stringList(stored).length : undefined)\n }\n isGroup={selected !== undefined || groupTypes.has(field.type)}\n >\n {(accessibility) => (\n <FormControl\n field={field}\n stored={stored}\n selected={selected}\n items={items}\n isDisabled={isDisabled}\n accessibility={accessibility}\n onChange={onChange}\n />\n )}\n </Field>\n </Container>\n );\n}\n\nconst groupTypes = new Set([\"radioGroup\", \"checkboxGroup\", \"rangeSlider\"]);\nconst loadedValidationTypes = new Set([\"slider\", \"rangeSlider\", \"date\", \"colour\"]);\n\n/** Ordered form controls. Loading, submission, and persistence belong to the app. */\nexport function FormEditor({\n schema,\n value,\n defaultValue = {},\n onValueChange,\n pickerItems = {},\n errors = {},\n isDisabled = false,\n showAllErrors = false,\n columns = 1,\n minColumnWidth = \"16rem\",\n className,\n style,\n ...rest\n}: FormEditorProps) {\n const [internal, setInternal] = useState<FormValues>(defaultValue);\n const [changed, setChanged] = useState<Set<string>>(() => new Set());\n const current = value ?? internal;\n useMemo(() => assertModel(schema), [schema]);\n\n const commit = (fieldId: string, next: FormFieldValue | undefined) => {\n const values = { ...current };\n if (next === undefined) {\n delete values[fieldId];\n } else {\n values[fieldId] = next;\n }\n if (value === undefined) {\n setInternal(values);\n }\n setChanged((previous) => new Set(previous).add(fieldId));\n onValueChange?.(values, { fieldId });\n };\n\n const layout =\n columns === \"auto\"\n ? { \"--form-editor-min-column\": minColumnWidth }\n : { \"--form-editor-columns\": columns, \"--form-editor-min-column\": minColumnWidth };\n\n return (\n <div\n className={[\"ds-form-editor\", columns === \"auto\" && \"ds-form-editor--auto\", className]\n .filter(Boolean)\n .join(\" \")}\n style={{ ...layout, ...style } as CSSProperties}\n {...rest}\n >\n {schema.fields.map((field) => {\n if (field.type === \"divider\") {\n return (\n <hr\n key={field.id}\n className=\"ds-form-editor__divider\"\n />\n );\n }\n const stored = Object.hasOwn(current, field.id) ? current[field.id] : undefined;\n const fieldDisabled = isDisabled || Boolean(field.isDisabled);\n const isLocked = fieldDisabled || (\"readOnly\" in field && Boolean(field.readOnly));\n // Explain loaded invalid values alongside the controls' invalid styling. Blank\n // strings are empty, so their required message waits like any other field's.\n const isLoaded = typeof stored === \"string\" ? stored.trim() !== \"\" : stored !== undefined;\n const isErrorVisible =\n showAllErrors ||\n changed.has(field.id) ||\n (isLoaded && loadedValidationTypes.has(field.type)) ||\n (field.type === \"number\" && typeof stored === \"number\");\n return (\n <FormEditorField\n key={field.id}\n field={field}\n stored={stored}\n items={pickerItems[field.id] ?? []}\n isDisabled={fieldDisabled}\n error={errors[field.id]}\n isErrorVisible={isErrorVisible}\n onChange={(next) => {\n if (!isLocked) {\n commit(field.id, next);\n }\n }}\n />\n );\n })}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AACA,IAAagB,KAAiB,CAAC,QAAQ,MAAM,GCgBvCC,KAAc;CAAC;CAAM;CAAM;AAAI,GA0I/BC,qB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AC5CmI,IAAWD,KAAkB,cAAclI,KAAS,EAAQA,EAAM,UAGlEoI,IAAW,OAAO1H,KAAW,WAAWA,EAAO,KAAK,MAAM,KAAKA,MAAW,KAAA,GAC1EgG,IACJ2B,KACAhB,EAAQ,IAAIrH,EAAM,EAAE,KACnBoI,KAAYtB,GAAsB,IAAI9G,EAAM,IAAI,KAChDA,EAAM,SAAS,YAAY,OAAOU,KAAW;GAChD,OACE,kBAAC6F,IAAD;IAES;IACC;IACR,OAAO+B,EAAYtI,EAAM,OAAO,CAAC;IACjC,YAAYkI;IACZ,OAAOK,EAAOvI,EAAM;IACJ;IAChB,WAAW,MAAS;KAClB,AAAKmI,KACHV,EAAOzH,EAAM,IAAIoF,CAAI;IAEzB;GACD,GAZMpF,EAAM,EAYZ;EAEL,CAAC;CACE,CAAA;AAET"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Button as e } from "../components/Button/index.js";
|
|
2
|
+
import { Banner as t } from "../components/Banner/index.js";
|
|
3
|
+
import { SkeletonText as n } from "../components/Skeleton/index.js";
|
|
4
|
+
import { useEffect as r, useState as i } from "react";
|
|
5
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/LoadState/error.tsx
|
|
7
|
+
var c = {
|
|
8
|
+
pending: "Trying again…",
|
|
9
|
+
failed: "Still couldn't load this."
|
|
10
|
+
};
|
|
11
|
+
function l({ error: n, onRetry: r, retryState: i }) {
|
|
12
|
+
return /* @__PURE__ */ s(t, {
|
|
13
|
+
tone: "danger",
|
|
14
|
+
role: "note",
|
|
15
|
+
icon: "auto",
|
|
16
|
+
title: "Couldn't load this",
|
|
17
|
+
actions: r && /* @__PURE__ */ o(e, {
|
|
18
|
+
size: "sm",
|
|
19
|
+
isPending: i === "pending",
|
|
20
|
+
isFocusableWhenDisabled: !0,
|
|
21
|
+
onClick: r,
|
|
22
|
+
children: "Try again"
|
|
23
|
+
}),
|
|
24
|
+
children: [
|
|
25
|
+
n?.message,
|
|
26
|
+
" ",
|
|
27
|
+
/* @__PURE__ */ o("span", {
|
|
28
|
+
role: "status",
|
|
29
|
+
children: i && c[i]
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/components/LoadState/useRetryAttempt.ts
|
|
36
|
+
var u = 1e3;
|
|
37
|
+
function d(e, t, n) {
|
|
38
|
+
let [a, o] = i(null), [s, c] = i(e);
|
|
39
|
+
e !== s && (c(e), a?.phase === "pending" && e === "error" ? o({ phase: "failed" }) : (a?.phase !== "pending" || e !== "loading") && o(null));
|
|
40
|
+
let l = a?.phase === "pending" && e !== "loading";
|
|
41
|
+
r(() => {
|
|
42
|
+
if (!l) return;
|
|
43
|
+
let e = setTimeout(() => o((e) => e === a ? null : e), u);
|
|
44
|
+
return () => clearTimeout(e);
|
|
45
|
+
}, [a, l]);
|
|
46
|
+
let d = a?.phase === "pending" && e === "loading" ? "pending" : a?.phase === "failed" && e === "error" ? "failed" : void 0;
|
|
47
|
+
return {
|
|
48
|
+
state: d,
|
|
49
|
+
error: d === "pending" ? a?.error : t,
|
|
50
|
+
retry: n && (() => {
|
|
51
|
+
o({
|
|
52
|
+
phase: "pending",
|
|
53
|
+
error: t
|
|
54
|
+
}), n();
|
|
55
|
+
})
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/components/LoadState/index.tsx
|
|
60
|
+
function f({ status: e, error: t, onRetry: r, children: i }) {
|
|
61
|
+
let s = d(e, t, r);
|
|
62
|
+
return e === "error" || s.state === "pending" ? /* @__PURE__ */ o(l, {
|
|
63
|
+
error: s.error,
|
|
64
|
+
onRetry: s.retry,
|
|
65
|
+
retryState: s.state
|
|
66
|
+
}) : e === "loading" ? /* @__PURE__ */ o(n, { lines: 4 }) : /* @__PURE__ */ o(a, { children: i });
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { l as n, f as t };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=LoadState-B7GTDlWv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadState-B7GTDlWv.js","names":["_Fragment","Fragment$1","retryNotes","LoadError","Banner","onRetry","Button","retryState","error","RETRY_START_WINDOW_MS","useRetryAttempt","attempt","setAttempt","useState","seenStatus","setSeenStatus","status","awaitsLoad","timer","current","state","LoadState","retry","SkeletonText"],"sources":["../../src/components/LoadState/error.tsx","../../src/components/LoadState/useRetryAttempt.ts","../../src/components/LoadState/index.tsx"],"sourcesContent":["import { Banner } from \"../Banner\";\nimport { Button } from \"../Button\";\n\nimport type { RetryState } from \"./types\";\n\nconst retryNotes: Record<RetryState, string> = {\n pending: \"Trying again…\",\n failed: \"Still couldn't load this.\",\n};\n\n/**\n * Persistent load feedback; the owning view controls when it is shown. A first\n * failure stays quiet, while a retry's progress and repeated failure are announced.\n */\nexport interface LoadErrorProps {\n error?: Error | null;\n onRetry?: () => void;\n /** Set while the owner keeps this banner mounted through a retry, so Retry keeps focus. */\n retryState?: RetryState;\n}\n\nexport function LoadError({ error, onRetry, retryState }: LoadErrorProps) {\n return (\n <Banner\n tone=\"danger\"\n role=\"note\"\n icon=\"auto\"\n title=\"Couldn't load this\"\n actions={\n onRetry && (\n <Button\n size=\"sm\"\n isPending={retryState === \"pending\"}\n isFocusableWhenDisabled\n onClick={onRetry}\n >\n Try again\n </Button>\n )\n }\n >\n {error?.message} <span role=\"status\">{retryState && retryNotes[retryState]}</span>\n </Banner>\n );\n}\n","import { useEffect, useState } from \"react\";\nimport type { RetryState } from \"./types\";\nimport type { LoadStatus } from \"./types\";\n\n/**\n * How long a retry waits for its load to be reported. Loads usually start in\n * the retry handler or within a few ticks of it, such as a query library's\n * batched notification. A later load is unrelated.\n */\nconst RETRY_START_WINDOW_MS = 1000;\n\ninterface Attempt {\n phase: RetryState;\n /** The failure being retried, kept on screen while the retry loads. */\n error?: Error | null;\n}\n\n/**\n * A retry started from failure feedback. The owner keeps that feedback mounted\n * while the retry loads, so Retry keeps focus, and reports a repeated failure.\n * Success, or any load the retry didn't start, clears it. A retry that reports\n * no load within RETRY_START_WINDOW_MS, for example because the owner keeps\n * `error` while refetching, lapses, so a later unrelated load shows a skeleton.\n */\nexport function useRetryAttempt(\n status: LoadStatus,\n error: Error | null | undefined,\n onRetry?: () => void,\n) {\n const [attempt, setAttempt] = useState<Attempt | null>(null);\n const [seenStatus, setSeenStatus] = useState(status);\n if (status !== seenStatus) {\n setSeenStatus(status);\n if (attempt?.phase === \"pending\" && status === \"error\") {\n setAttempt({ phase: \"failed\" });\n } else if (attempt?.phase !== \"pending\" || status !== \"loading\") {\n setAttempt(null);\n }\n }\n const awaitsLoad = attempt?.phase === \"pending\" && status !== \"loading\";\n useEffect(() => {\n if (!awaitsLoad) {\n return;\n }\n const timer = setTimeout(\n () => setAttempt((current) => (current === attempt ? null : current)),\n RETRY_START_WINDOW_MS,\n );\n return () => clearTimeout(timer);\n }, [attempt, awaitsLoad]);\n const state: RetryState | undefined =\n attempt?.phase === \"pending\" && status === \"loading\"\n ? \"pending\"\n : attempt?.phase === \"failed\" && status === \"error\"\n ? \"failed\"\n : undefined;\n return {\n state,\n error: state === \"pending\" ? attempt?.error : error,\n retry:\n onRetry &&\n (() => {\n setAttempt({\n phase: \"pending\",\n error,\n });\n onRetry();\n }),\n };\n}\n","import { SkeletonText } from \"../Skeleton\";\nimport { LoadError } from \"./error\";\nimport { useRetryAttempt } from \"./useRetryAttempt\";\nimport type { LoadStatus } from \"./types\";\nimport type { ReactNode } from \"react\";\n\nexport interface LoadStateProps {\n status: LoadStatus;\n error?: Error | null;\n onRetry?: () => void;\n /** Rendered once loaded. */\n children?: ReactNode;\n}\n\n/** The loading and failed states every API-backed view shares; children render once ready. */\nexport function LoadState({ status, error, onRetry, children }: LoadStateProps) {\n const retry = useRetryAttempt(status, error, onRetry);\n // One LoadError instance spans a retry, so focus stays on its Retry button.\n if (status === \"error\" || retry.state === \"pending\") {\n return (\n <LoadError\n error={retry.error}\n onRetry={retry.retry}\n retryState={retry.state}\n />\n );\n }\n if (status === \"loading\") {\n return <SkeletonText lines={4} />;\n }\n return <>{children}</>;\n}\n\nexport { LoadError } from \"./error\";\nexport type { LoadErrorProps } from \"./error\";\nexport type { LoadStatus, RetryState } from \"./types\";\n"],"mappings":";;;;;;AAKA,IAAME,IAAyC;CAC7C,SAAS;CACT,QAAQ;AACV;AAaA,SAAgBC,EAAU,EAAE,UAAO,YAAS,iBAA8B;CACxE,OACE,kBAACC,GAAD;EACE,MAAK;EACL,MAAK;EACL,MAAK;EACL,OAAM;EACN,SACEC,KACE,kBAACC,GAAD;GACE,MAAK;GACL,WAAWC,MAAe;GAC1B,yBAAA;GACA,SAASF;GACV,UAAA;EAEO,CAAA;EAdd,UAAA;GAkBGG,GAAO;GAAQ;GAAC,kBAAC,QAAD;IAAM,MAAK;IAAU,UAAAD,KAAcL,EAAWK;GAAkB,CAAA;EAC3E;;AAEZ;;;ACnCA,IAAME,IAAwB;AAe9B,SAAgBC,EACd,GACA,GACA,GACA;CACA,IAAM,CAACC,GAASC,KAAcC,EAAyB,IAAI,GACrD,CAACC,GAAYC,KAAiBF,EAASG,CAAM;CACnD,AAAIA,MAAWF,MACbC,EAAcC,CAAM,GAChBL,GAAS,UAAU,aAAaK,MAAW,UAC7CJ,EAAW,EAAE,OAAO,SAAS,CAAC,KACrBD,GAAS,UAAU,aAAaK,MAAW,cACpDJ,EAAW,IAAI;CAGnB,IAAMK,IAAaN,GAAS,UAAU,aAAaK,MAAW;CAC9D,QAAgB;EACd,IAAI,CAACC,GACH;EAEF,IAAMC,IAAQ,iBACNN,GAAY,MAAaO,MAAYR,IAAU,OAAOQ,CAAQ,GACpEV,CACF;EACA,aAAa,aAAaS,CAAK;CACjC,GAAG,CAACP,GAASM,CAAU,CAAC;CACxB,IAAMG,IACJT,GAAS,UAAU,aAAaK,MAAW,YACvC,YACAL,GAAS,UAAU,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