@namroodinc/liquid-editorial 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -7
- package/UPGRADING.md +217 -0
- package/dist/chunks/{Board-BaQ04nWg.cjs → Board-BPA6mVhf.cjs} +2 -2
- package/dist/chunks/{Board-BaQ04nWg.cjs.map → Board-BPA6mVhf.cjs.map} +1 -1
- package/dist/chunks/{Board-CUhF8pTX.js → Board-CcIF7jS0.js} +2 -2
- package/dist/chunks/{Board-CUhF8pTX.js.map → Board-CcIF7jS0.js.map} +1 -1
- package/dist/chunks/{ColourField-CJicr3OT.cjs → ColourField-BQ4a5tAV.cjs} +2 -2
- package/dist/chunks/{ColourField-CJicr3OT.cjs.map → ColourField-BQ4a5tAV.cjs.map} +1 -1
- package/dist/chunks/{ColourField-DjHRiFDU.js → ColourField-Doew1hLw.js} +3 -3
- package/dist/chunks/{ColourField-DjHRiFDU.js.map → ColourField-Doew1hLw.js.map} +1 -1
- package/dist/chunks/{DatePicker-aSlYLjtW.cjs → DatePicker-C0-609Zx.cjs} +2 -2
- package/dist/chunks/{DatePicker-aSlYLjtW.cjs.map → DatePicker-C0-609Zx.cjs.map} +1 -1
- package/dist/chunks/{DatePicker-D_6CQpUd.js → DatePicker-DmeWUsOS.js} +2 -2
- package/dist/chunks/{DatePicker-D_6CQpUd.js.map → DatePicker-DmeWUsOS.js.map} +1 -1
- package/dist/chunks/{FormEditor-CaskinQ1.js → FormEditor-DTnFO4oS.js} +170 -154
- package/dist/chunks/FormEditor-DTnFO4oS.js.map +1 -0
- package/dist/chunks/FormEditor-DfQLJnsO.cjs +2 -0
- package/dist/chunks/FormEditor-DfQLJnsO.cjs.map +1 -0
- package/dist/chunks/Icon-D1kx7-1c.js +81 -0
- package/dist/chunks/Icon-D1kx7-1c.js.map +1 -0
- package/dist/chunks/Icon-D38lQXNe.cjs +2 -0
- package/dist/chunks/Icon-D38lQXNe.cjs.map +1 -0
- package/dist/chunks/RichTextEditor-DEJ-u-ZR.js +483 -0
- package/dist/chunks/RichTextEditor-DEJ-u-ZR.js.map +1 -0
- package/dist/chunks/RichTextEditor-Ddk7qaqg.cjs +2 -0
- package/dist/chunks/RichTextEditor-Ddk7qaqg.cjs.map +1 -0
- package/dist/chunks/movableHost-CajG9_5Z.cjs +2 -0
- package/dist/chunks/movableHost-CajG9_5Z.cjs.map +1 -0
- package/dist/chunks/movableHost-NJj_FsAu.js +23 -0
- package/dist/chunks/movableHost-NJj_FsAu.js.map +1 -0
- package/dist/chunks/portalScope-AzzPM54i.js +105 -0
- package/dist/chunks/portalScope-AzzPM54i.js.map +1 -0
- package/dist/chunks/portalScope-BVA1-Ypu.cjs +2 -0
- package/dist/chunks/portalScope-BVA1-Ypu.cjs.map +1 -0
- package/dist/chunks/useModalDialog-BVaG--b3.js +87 -0
- package/dist/chunks/useModalDialog-BVaG--b3.js.map +1 -0
- package/dist/chunks/useModalDialog-Ctu270Dp.cjs +2 -0
- package/dist/chunks/useModalDialog-Ctu270Dp.cjs.map +1 -0
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.js +1 -1
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.js +1 -1
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.cjs.map +1 -1
- package/dist/components/Button/index.d.cts +5 -0
- package/dist/components/Button/index.d.cts.map +1 -1
- package/dist/components/Button/index.d.ts +5 -0
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +14 -12
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/style.css +43 -11
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +59 -75
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Drawer/style.css +3 -0
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.d.cts.map +1 -1
- package/dist/components/EditLayout/index.d.ts.map +1 -1
- package/dist/components/EditLayout/index.js +107 -121
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.cjs.map +1 -1
- package/dist/components/EntryPicker/index.d.cts.map +1 -1
- package/dist/components/EntryPicker/index.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.js +3 -9
- package/dist/components/EntryPicker/index.js.map +1 -1
- package/dist/components/FormEditor/README.md +79 -3
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- 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 +2 -1
- package/dist/components/FormEditor/model.d.cts +6 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +6 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/FormEditor/style.css +7 -0
- package/dist/components/Icon/icons.d.cts +2 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +2 -0
- package/dist/components/Icon/icons.d.ts.map +1 -1
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts +9 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts +9 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +37 -45
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/style.css +8 -1
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.d.cts.map +1 -1
- package/dist/components/Popover/index.d.ts.map +1 -1
- package/dist/components/Popover/index.js +44 -37
- package/dist/components/Popover/index.js.map +1 -1
- package/dist/components/Popover/style.css +3 -0
- package/dist/components/RichTextEditor/expanded-width.d.cts +4 -0
- package/dist/components/RichTextEditor/expanded-width.d.cts.map +1 -0
- package/dist/components/RichTextEditor/expanded-width.d.ts +4 -0
- package/dist/components/RichTextEditor/expanded-width.d.ts.map +1 -0
- package/dist/components/RichTextEditor/expansion.d.cts +28 -0
- package/dist/components/RichTextEditor/expansion.d.cts.map +1 -0
- package/dist/components/RichTextEditor/expansion.d.ts +28 -0
- package/dist/components/RichTextEditor/expansion.d.ts.map +1 -0
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.d.cts +4 -4
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts +4 -4
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/RichTextEditor/style.css +85 -4
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.js +1 -1
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.cjs.map +1 -1
- package/dist/components/SortableList/index.d.cts +12 -2
- package/dist/components/SortableList/index.d.cts.map +1 -1
- package/dist/components/SortableList/index.d.ts +12 -2
- package/dist/components/SortableList/index.d.ts.map +1 -1
- package/dist/components/SortableList/index.js +126 -66
- package/dist/components/SortableList/index.js.map +1 -1
- package/dist/components/SortableList/style.css +19 -5
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.js +1 -1
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -30
- package/dist/internal/dialogFocus.d.cts +8 -0
- package/dist/internal/dialogFocus.d.cts.map +1 -1
- package/dist/internal/dialogFocus.d.ts +8 -0
- package/dist/internal/dialogFocus.d.ts.map +1 -1
- package/dist/internal/movableHost.d.cts +20 -0
- package/dist/internal/movableHost.d.cts.map +1 -0
- package/dist/internal/movableHost.d.ts +20 -0
- package/dist/internal/movableHost.d.ts.map +1 -0
- package/dist/internal/portalScope.d.cts +23 -0
- package/dist/internal/portalScope.d.cts.map +1 -0
- package/dist/internal/portalScope.d.ts +23 -0
- package/dist/internal/portalScope.d.ts.map +1 -0
- package/dist/internal/useModalDialog.d.cts +22 -0
- package/dist/internal/useModalDialog.d.cts.map +1 -0
- package/dist/internal/useModalDialog.d.ts +22 -0
- package/dist/internal/useModalDialog.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/chunks/FormEditor-CaskinQ1.js.map +0 -1
- package/dist/chunks/FormEditor-DDylpJ9O.cjs +0 -2
- package/dist/chunks/FormEditor-DDylpJ9O.cjs.map +0 -1
- package/dist/chunks/Icon-BBoWP_Y6.cjs +0 -2
- package/dist/chunks/Icon-BBoWP_Y6.cjs.map +0 -1
- package/dist/chunks/Icon-XNismJDm.js +0 -79
- package/dist/chunks/Icon-XNismJDm.js.map +0 -1
- package/dist/chunks/RichTextEditor-C7nMfDmE.cjs +0 -2
- package/dist/chunks/RichTextEditor-C7nMfDmE.cjs.map +0 -1
- package/dist/chunks/RichTextEditor-DjR10XJ-.js +0 -370
- package/dist/chunks/RichTextEditor-DjR10XJ-.js.map +0 -1
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs +0 -2
- package/dist/chunks/dialogFocus-B9iqKl3I.cjs.map +0 -1
- package/dist/chunks/dialogFocus-BFoyeTpA.js +0 -48
- package/dist/chunks/dialogFocus-BFoyeTpA.js.map +0 -1
- package/dist/chunks/dialogStack-6yv3NXFD.js +0 -43
- package/dist/chunks/dialogStack-6yv3NXFD.js.map +0 -1
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs +0 -2
- package/dist/chunks/dialogStack-C9SLVu6Q.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e, r as t, t as ee } from "./chunks/Icon-
|
|
1
|
+
import { n as e, r as t, t as ee } from "./chunks/Icon-D1kx7-1c.js";
|
|
2
2
|
import { Button as te } from "./components/Button/index.js";
|
|
3
3
|
import { Drawer as n } from "./components/Drawer/index.js";
|
|
4
4
|
import { SideNav as r, SideNavFooter as i, SideNavHeader as a, SideNavItem as o, SideNavSection as s, useSideNavCollapsed as c } from "./components/SideNav/index.js";
|
|
@@ -9,36 +9,36 @@ import { Badge as p } from "./components/Badge/index.js";
|
|
|
9
9
|
import { Field as m } from "./components/Field/index.js";
|
|
10
10
|
import { Modal as h } from "./components/Modal/index.js";
|
|
11
11
|
import { TextArea as g, TextField as _ } from "./components/TextField/index.js";
|
|
12
|
-
import { t as v } from "./chunks/RichTextEditor-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { n as
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import { n as
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
12
|
+
import { t as v } from "./chunks/RichTextEditor-DEJ-u-ZR.js";
|
|
13
|
+
import { Container as y } from "./components/Container/index.js";
|
|
14
|
+
import { FieldAffix as b } from "./components/FieldAffix/index.js";
|
|
15
|
+
import { SearchField as x } from "./components/SearchField/index.js";
|
|
16
|
+
import { SortableList as S, SortableListItem as C } from "./components/SortableList/index.js";
|
|
17
|
+
import { EntryPicker as w } from "./components/EntryPicker/index.js";
|
|
18
|
+
import { NumberField as T, NumberRangeField as E } from "./components/NumberField/index.js";
|
|
19
|
+
import { Popover as D } from "./components/Popover/index.js";
|
|
20
|
+
import { Select as O } from "./components/Select/index.js";
|
|
21
|
+
import { Switch as k } from "./components/Switch/index.js";
|
|
22
|
+
import { n as A, t as j } from "./chunks/ColourField-Doew1hLw.js";
|
|
23
|
+
import { n as M, t as N } from "./chunks/Slider-vdMFLX-H.js";
|
|
24
|
+
import { i as P, n as F, r as I, t as L } from "./chunks/DatePicker-DmeWUsOS.js";
|
|
25
|
+
import { TagsInput as R } from "./components/TagsInput/index.js";
|
|
26
|
+
import { Grid as z, GridItem as B, Stack as V } from "./components/Grid/index.js";
|
|
27
|
+
import { Checkbox as H, ChoiceGroup as U, Radio as W } from "./components/Choice/index.js";
|
|
28
|
+
import { CheckboxCard as G, RadioCard as K, SelectionCardGroup as q } from "./components/SelectionCard/index.js";
|
|
29
|
+
import { n as J, t as ne } from "./chunks/FormEditor-DTnFO4oS.js";
|
|
30
|
+
import { n as Y, r as X, t as Z } from "./chunks/Board-CcIF7jS0.js";
|
|
31
|
+
import { Avatar as re, AvatarGroup as ie } from "./components/Avatar/index.js";
|
|
32
|
+
import { Table as ae, TableBody as oe, TableCell as se, TableEmpty as ce, TableFrame as le, TableHead as ue, TableHeaderCell as de, TableRow as fe, TableToolbar as pe } from "./components/Table/index.js";
|
|
33
|
+
import { Menu as me, MenuItem as he, MenuLabel as ge, MenuSeparator as _e } from "./components/Menu/index.js";
|
|
34
|
+
import { Toast as ve, ToastProvider as ye, useToast as be } from "./components/Toast/index.js";
|
|
35
|
+
import { Skeleton as xe, SkeletonText as Se } from "./components/Skeleton/index.js";
|
|
36
|
+
import { SubNav as Ce, SubNavButton as we, SubNavItem as Te } from "./components/SubNav/index.js";
|
|
37
|
+
import { Stepper as Ee } from "./components/Stepper/index.js";
|
|
37
38
|
import { AssetCard as Q, AssetCardSkeleton as $ } from "./components/AssetCard/index.js";
|
|
38
|
-
import { AssetGrid as
|
|
39
|
-
import { ImageCropper as
|
|
40
|
-
import { Container as Ae } from "./components/Container/index.js";
|
|
39
|
+
import { AssetGrid as De, AssetGridEmpty as Oe } from "./components/AssetGrid/index.js";
|
|
40
|
+
import { ImageCropper as ke, cropToBlob as Ae } from "./components/ImageCropper/index.js";
|
|
41
41
|
import { Time as je, formatAbsoluteDate as Me, formatAbsoluteTime as Ne, formatRelativeTime as Pe } from "./components/Time/index.js";
|
|
42
42
|
import { Pagination as Fe } from "./components/Pagination/index.js";
|
|
43
43
|
import { EditLayout as Ie } from "./components/EditLayout/index.js";
|
|
44
|
-
export { d as AppShell, Q as AssetCard, Q as AssetTile, $ as AssetCardSkeleton, $ as AssetTileSkeleton,
|
|
44
|
+
export { d as AppShell, Q as AssetCard, Q as AssetTile, $ as AssetCardSkeleton, $ as AssetTileSkeleton, De as AssetGrid, Oe as AssetGridEmpty, re as Avatar, ie as AvatarGroup, p as Badge, Z as Board, Y as BoardCard, X as BoardColumn, te as Button, f as ButtonGroup, L as Calendar, H as Checkbox, G as CheckboxCard, U as ChoiceGroup, j as ColourField, A as ColourPanel, y as Container, F as DateField, I as DateRangeField, n as Drawer, Ie as EditLayout, w as EntryPicker, m as Field, b as FieldAffix, ne as FormEditor, z as Grid, B as GridItem, ee as Icon, ke as ImageCropper, me as Menu, he as MenuItem, ge as MenuLabel, _e as MenuSeparator, h as Modal, T as NumberField, E as NumberRangeField, Fe as Pagination, D as Popover, W as Radio, K as RadioCard, N as RangeSlider, v as RichTextEditor, x as SearchField, O as Select, q as SelectionCardGroup, r as SideNav, i as SideNavFooter, a as SideNavHeader, o as SideNavItem, s as SideNavSection, xe as Skeleton, Se as SkeletonText, M as Slider, S as SortableList, C as SortableListItem, V as Stack, Ee as Stepper, Ce as SubNav, we as SubNavButton, Te as SubNavItem, k as Switch, ae as Table, oe as TableBody, se as TableCell, ce as TableEmpty, le as TableFrame, ue as TableHead, de as TableHeaderCell, fe as TableRow, pe as TableToolbar, R as TagsInput, g as TextArea, _ as TextField, je as Time, ve as Toast, ye as ToastProvider, l as TopNav, u as TopNavItem, Ae as cropToBlob, Me as formatAbsoluteDate, Ne as formatAbsoluteTime, P as formatIsoDate, Pe as formatRelativeTime, e as iconNames, t as icons, c as useSideNavCollapsed, be as useToast, J as validateFormValues };
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/** Removed, hidden and inert elements can't keep focus, and neither can the page. */
|
|
2
|
+
export declare function cannotHoldFocus(element: Element | null): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Focuses `element`, or, when it can no longer take focus (disabled, or no
|
|
5
|
+
* longer editable), its nearest ancestor with a tabindex, such as an enclosing
|
|
6
|
+
* dialog panel. Returns whether anything took focus.
|
|
7
|
+
*/
|
|
8
|
+
export declare function focusNearest(element: Element | null, options?: FocusOptions): boolean;
|
|
1
9
|
/**
|
|
2
10
|
* The controls Tab visits inside `container`, in document order. A radio group
|
|
3
11
|
* contributes only its checked radio, or every radio while none is checked.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialogFocus.d.cts","sourceRoot":"","sources":["../../src/internal/dialogFocus.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,WAAW,iBAUtD;AAID;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,cAK5D;AA8BD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,QA4B3E"}
|
|
1
|
+
{"version":3,"file":"dialogFocus.d.cts","sourceRoot":"","sources":["../../src/internal/dialogFocus.ts"],"names":[],"mappings":"AAuBA,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,WAOtD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,YAAY,WAY3E;AAaD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,WAAW,iBAUtD;AAID;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,cAK5D;AA8BD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,QA4B3E"}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/** Removed, hidden and inert elements can't keep focus, and neither can the page. */
|
|
2
|
+
export declare function cannotHoldFocus(element: Element | null): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Focuses `element`, or, when it can no longer take focus (disabled, or no
|
|
5
|
+
* longer editable), its nearest ancestor with a tabindex, such as an enclosing
|
|
6
|
+
* dialog panel. Returns whether anything took focus.
|
|
7
|
+
*/
|
|
8
|
+
export declare function focusNearest(element: Element | null, options?: FocusOptions): boolean;
|
|
1
9
|
/**
|
|
2
10
|
* The controls Tab visits inside `container`, in document order. A radio group
|
|
3
11
|
* contributes only its checked radio, or every radio while none is checked.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialogFocus.d.ts","sourceRoot":"","sources":["../../src/internal/dialogFocus.ts"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,WAAW,iBAUtD;AAID;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,cAK5D;AA8BD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,QA4B3E"}
|
|
1
|
+
{"version":3,"file":"dialogFocus.d.ts","sourceRoot":"","sources":["../../src/internal/dialogFocus.ts"],"names":[],"mappings":"AAuBA,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,WAOtD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,YAAY,WAY3E;AAaD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,WAAW,iBAUtD;AAID;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,cAK5D;AA8BD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,QA4B3E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A detached element for portal content that moves between slots, so the tree
|
|
3
|
+
* rendered into it never remounts. Null on the server.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createMovableHost(className: string): HTMLDivElement | null;
|
|
6
|
+
/**
|
|
7
|
+
* A movable host for content that is also server rendered. It is null on the
|
|
8
|
+
* server and while hydrating, so the first client render can match inline
|
|
9
|
+
* server markup; client-only renders get the host on their first render.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useMovableHost(className: string): HTMLDivElement | null;
|
|
12
|
+
/**
|
|
13
|
+
* Moves `host` into `slot`, or detaches it when there is no slot. A host already
|
|
14
|
+
* in place is left alone: re-inserting it would reset scroll positions and drop
|
|
15
|
+
* focus and the text selection. Moving drops focus, so the element inside the
|
|
16
|
+
* host that had it (or `lastFocused`, when an earlier removal already dropped
|
|
17
|
+
* it) gets it back. Returns whether the host moved.
|
|
18
|
+
*/
|
|
19
|
+
export declare function moveHost(host: HTMLElement, slot: Element | null, lastFocused?: Element | null): boolean;
|
|
20
|
+
//# sourceMappingURL=movableHost.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"movableHost.d.cts","sourceRoot":"","sources":["../../src/internal/movableHost.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,yBAOlD;AAID;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,yBAS/C;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,OAAO,GAAG,IAAI,EACpB,WAAW,GAAE,OAAO,GAAG,IAAW,WAoBnC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A detached element for portal content that moves between slots, so the tree
|
|
3
|
+
* rendered into it never remounts. Null on the server.
|
|
4
|
+
*/
|
|
5
|
+
export declare function createMovableHost(className: string): HTMLDivElement | null;
|
|
6
|
+
/**
|
|
7
|
+
* A movable host for content that is also server rendered. It is null on the
|
|
8
|
+
* server and while hydrating, so the first client render can match inline
|
|
9
|
+
* server markup; client-only renders get the host on their first render.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useMovableHost(className: string): HTMLDivElement | null;
|
|
12
|
+
/**
|
|
13
|
+
* Moves `host` into `slot`, or detaches it when there is no slot. A host already
|
|
14
|
+
* in place is left alone: re-inserting it would reset scroll positions and drop
|
|
15
|
+
* focus and the text selection. Moving drops focus, so the element inside the
|
|
16
|
+
* host that had it (or `lastFocused`, when an earlier removal already dropped
|
|
17
|
+
* it) gets it back. Returns whether the host moved.
|
|
18
|
+
*/
|
|
19
|
+
export declare function moveHost(host: HTMLElement, slot: Element | null, lastFocused?: Element | null): boolean;
|
|
20
|
+
//# sourceMappingURL=movableHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"movableHost.d.ts","sourceRoot":"","sources":["../../src/internal/movableHost.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,yBAOlD;AAID;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,yBAS/C;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,OAAO,GAAG,IAAI,EACpB,WAAW,GAAE,OAAO,GAAG,IAAW,WAoBnC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The inline element whose theme, direction and language body-mounted overlays
|
|
4
|
+
* opened from inside it carry: RichTextEditor's frame, or a Popover's anchor.
|
|
5
|
+
* Nested overlays inherit the same inline anchor rather than their parent's
|
|
6
|
+
* panel, so they never depend on the order in which overlays mount.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PortalScopeContext: import("react").Context<RefObject<Element | null> | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Copies the anchor's `data-theme`, `lang` and `dir` onto an overlay root while
|
|
11
|
+
* it is open, and follows later changes to those attributes on the anchor's
|
|
12
|
+
* ancestors. Attributes rather than resolved values, so the theme's whole
|
|
13
|
+
* stylesheet keeps applying, including `color-scheme` and media queries.
|
|
14
|
+
* Without an anchor the overlay inherits from the document root, as before.
|
|
15
|
+
*/
|
|
16
|
+
export declare function usePortalScope(rootRef: RefObject<HTMLElement | null>, isOpen: boolean, getAnchor: (() => Element | null | undefined) | null, { keepDir }?: {
|
|
17
|
+
keepDir?: boolean;
|
|
18
|
+
}): void;
|
|
19
|
+
/** Applies the scope of the inline anchor an enclosing editor or popover provides, if any. */
|
|
20
|
+
export declare function useInheritedPortalScope(rootRef: RefObject<HTMLElement | null>, isOpen: boolean, options?: {
|
|
21
|
+
keepDir?: boolean;
|
|
22
|
+
}): void;
|
|
23
|
+
//# sourceMappingURL=portalScope.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portalScope.d.cts","sourceRoot":"","sources":["../../src/internal/portalScope.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,2DAAwD,CAAC;AAexF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACtC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,CAAC,MAAM,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,EACpD,EAAE,OAAe,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,QAiChD;AAED,8FAA8F;AAC9F,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACtC,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,QAIhC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The inline element whose theme, direction and language body-mounted overlays
|
|
4
|
+
* opened from inside it carry: RichTextEditor's frame, or a Popover's anchor.
|
|
5
|
+
* Nested overlays inherit the same inline anchor rather than their parent's
|
|
6
|
+
* panel, so they never depend on the order in which overlays mount.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PortalScopeContext: import("react").Context<RefObject<Element | null> | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Copies the anchor's `data-theme`, `lang` and `dir` onto an overlay root while
|
|
11
|
+
* it is open, and follows later changes to those attributes on the anchor's
|
|
12
|
+
* ancestors. Attributes rather than resolved values, so the theme's whole
|
|
13
|
+
* stylesheet keeps applying, including `color-scheme` and media queries.
|
|
14
|
+
* Without an anchor the overlay inherits from the document root, as before.
|
|
15
|
+
*/
|
|
16
|
+
export declare function usePortalScope(rootRef: RefObject<HTMLElement | null>, isOpen: boolean, getAnchor: (() => Element | null | undefined) | null, { keepDir }?: {
|
|
17
|
+
keepDir?: boolean;
|
|
18
|
+
}): void;
|
|
19
|
+
/** Applies the scope of the inline anchor an enclosing editor or popover provides, if any. */
|
|
20
|
+
export declare function useInheritedPortalScope(rootRef: RefObject<HTMLElement | null>, isOpen: boolean, options?: {
|
|
21
|
+
keepDir?: boolean;
|
|
22
|
+
}): void;
|
|
23
|
+
//# sourceMappingURL=portalScope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portalScope.d.ts","sourceRoot":"","sources":["../../src/internal/portalScope.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,2DAAwD,CAAC;AAexF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACtC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,CAAC,MAAM,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,EACpD,EAAE,OAAe,EAAE,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,QAiChD;AAED,8FAA8F;AAC9F,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACtC,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,QAIhC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type MouseEvent, type RefObject } from "react";
|
|
2
|
+
export interface ModalDialogOptions {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
panelRef: RefObject<HTMLElement | null>;
|
|
5
|
+
/** Escape and a direct scrim press call this. Read when called, so it may change every render. */
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
/** First focus when focus isn't already inside the panel. Defaults to the first tabbable control, then the panel. */
|
|
8
|
+
initialFocus?: () => HTMLElement | null | undefined;
|
|
9
|
+
/** Panels that slide in from off-screen must not scroll the page when focused. */
|
|
10
|
+
preventScroll?: boolean;
|
|
11
|
+
/** Registration restarts when this changes while open, such as a new portal container. */
|
|
12
|
+
container?: unknown;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Behaviour every modal overlay shares: one dialog-stack entry, a body scroll
|
|
16
|
+
* lock, Escape and a Tab trap while topmost, initial focus, and focus returned
|
|
17
|
+
* to the opener (or its nearest focusable container) when closing dropped it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useModalDialog({ isOpen, panelRef, onClose, initialFocus, preventScroll, container, }: ModalDialogOptions): {
|
|
20
|
+
onScrimMouseDown: (event: MouseEvent) => void;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useModalDialog.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useModalDialog.d.cts","sourceRoot":"","sources":["../../src/internal/useModalDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKrF,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACxC,kGAAkG;IAClG,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qHAAqH;IACrH,YAAY,CAAC,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACpD,kFAAkF;IAClF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0FAA0F;IAC1F,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAOD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,aAAqB,EACrB,SAAS,GACV,EAAE,kBAAkB;8BA0Dc,UAAU;EAO5C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type MouseEvent, type RefObject } from "react";
|
|
2
|
+
export interface ModalDialogOptions {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
panelRef: RefObject<HTMLElement | null>;
|
|
5
|
+
/** Escape and a direct scrim press call this. Read when called, so it may change every render. */
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
/** First focus when focus isn't already inside the panel. Defaults to the first tabbable control, then the panel. */
|
|
8
|
+
initialFocus?: () => HTMLElement | null | undefined;
|
|
9
|
+
/** Panels that slide in from off-screen must not scroll the page when focused. */
|
|
10
|
+
preventScroll?: boolean;
|
|
11
|
+
/** Registration restarts when this changes while open, such as a new portal container. */
|
|
12
|
+
container?: unknown;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Behaviour every modal overlay shares: one dialog-stack entry, a body scroll
|
|
16
|
+
* lock, Escape and a Tab trap while topmost, initial focus, and focus returned
|
|
17
|
+
* to the opener (or its nearest focusable container) when closing dropped it.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useModalDialog({ isOpen, panelRef, onClose, initialFocus, preventScroll, container, }: ModalDialogOptions): {
|
|
20
|
+
onScrimMouseDown: (event: MouseEvent) => void;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useModalDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useModalDialog.d.ts","sourceRoot":"","sources":["../../src/internal/useModalDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKrF,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACxC,kGAAkG;IAClG,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qHAAqH;IACrH,YAAY,CAAC,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACpD,kFAAkF;IAClF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0FAA0F;IAC1F,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAOD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,aAAqB,EACrB,SAAS,GACV,EAAE,kBAAkB;8BA0Dc,UAAU;EAO5C"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormEditor-CaskinQ1.js","names":["_Fragment","documentError","emptyDocument","RichTextEditor","parseColour","ColourField","sliderScale","preciseSum","Slider","clampToScale","RangeSlider","isIsoDate","DateField","Fragment$1","fieldTypes","assertModel","ids","field","model","assertChoices","assertSlider","min","max","step","kind","values","option","value","linkCopy","fieldLabel","pickerCopy","defaults","selectedIds","isLink","link","key","parseUtcDateTime","match","canonical","date","hasRichText","node","requiredError","textError","richTextError","error","choiceError","stringList","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","selected","stored","Group","SelectionCardGroup","ChoiceGroup","accessibility","required","Button","SliderControl","shown","next","RangeSliderControl","AdditionalControl","raw","event","TagsInput","pickerValue","links","NumberControl","NumberField","SelectControl","isClearable","Select","PickerControl","EntryPicker","FormControl","shared","TextField","TextArea","Switch","FormEditorField","validation","useMemo","isErrorVisible","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/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":["import type { ReactNode } from \"react\";\nimport type { SelectOption } from \"../Select\";\nimport type { EntryPickerProps } from \"../EntryPicker\";\nimport type { JSONContent } from \"@tiptap/react\";\nimport { documentError } from \"../RichTextEditor/document\";\nimport type { RichTextDocument } from \"../RichTextEditor\";\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\";\n\ninterface FormFieldBase {\n id: string;\n label: string;\n hint?: ReactNode;\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 }\n | {\n type: \"longText\";\n rows?: number;\n maxLength?: number;\n readOnly?: boolean;\n autoFocus?: boolean;\n multiple?: never;\n }\n | { type: \"boolean\" | \"dateTime\"; autoFocus?: boolean; multiple?: never }\n | { type: \"richText\"; autoFocus?: never; multiple?: never }\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 }\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 }\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 ids.add(field.id);\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 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={field.multiple ? \"multiple\" : \"single\"}\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={typeof stored === \"string\" ? 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={typeof stored === \"string\" ? 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 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 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 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 <Field\n label={field.type === \"dateTime\" ? `${field.label} (UTC)` : fieldLabel(field)}\n hint={field.hint}\n error={error ?? validation}\n isRequired={field.required}\n count={\n selected?.length ?? (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 );\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":";;;;;;;;;;;;;;;;;AA4IA,IAAMc,oBAAa,IAAI,IAAI;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAgBC,EAAY,GAAmB;CAC7C,IAAMC,oBAAM,IAAI,IAAY;CAC5B,KAAK,IAAMC,KAASC,EAAM,QAAQ;EAChC,IAAI,CAACD,EAAM,IAAI,KAAK,KAAKD,EAAI,IAAIC,EAAM,EAAE,GACvC,MAAU,MAAM,6CAA6C;EAE/D,IAAI,CAACH,EAAW,IAAIG,EAAM,IAAI,GAC5B,MAAU,MAAM,gCAAgCA,EAAM,MAAM;EAQ9D,CANIA,EAAM,SAAS,YAAYA,EAAM,SAAS,gBAAgBA,EAAM,SAAS,oBAC3EE,EAAcF,CAAK,IAEjBA,EAAM,SAAS,YAAYA,EAAM,SAAS,kBAC5CG,EAAaH,CAAK,GAEpBD,EAAI,IAAIC,EAAM,EAAE;CAClB;AACF;AAEA,SAASG,EAAa,GAA0C;CAC9D,IAAM,EAAE,QAAK,QAAK,YAASd,EAAYW,CAAK;CAC5C,IAAI,CAAC;EAACI;EAAKC;EAAKC;CAAI,CAAC,CAAC,MAAM,OAAO,QAAQ,KAAKF,KAAOC,KAAOC,KAAQ,GACpE,MAAU,MAAM,gBAAgBN,EAAM,GAAG,6CAA6C;CAExF,IAAIA,EAAM,SAAS,iBAAiBM,IAAOhB,EAAWe,GAAK,CAACD,CAAG,GAC7D,MAAU,MAAM,gBAAgBJ,EAAM,GAAG,mCAAmC;AAEhF;AAEA,SAASE,EAAc,GAA2D;CAChF,IAAI,CAAC,MAAM,QAAQF,EAAM,OAAO,GAAG;EACjC,IAAMO,IAAOP,EAAM,S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L,CAAC;CACE,CAAA;AAET"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const e=require("./ColourField-CJicr3OT.cjs"),t=require("../components/Button/index.cjs"),n=require("../components/Field/index.cjs"),r=require("../components/TextField/index.cjs"),i=require("./RichTextEditor-C7nMfDmE.cjs"),a=require("../components/EntryPicker/index.cjs"),o=require("../components/NumberField/index.cjs"),s=require("../components/Select/index.cjs"),c=require("../components/Switch/index.cjs"),l=require("./Slider-k8weRl34.cjs"),u=require("./DatePicker-aSlYLjtW.cjs"),d=require("../components/TagsInput/index.cjs"),f=require("../components/Choice/index.cjs"),p=require("../components/SelectionCard/index.cjs");let m=require("react"),h=require("react/jsx-runtime");var g=new Set([`shortText`,`longText`,`richText`,`number`,`boolean`,`dateTime`,`asset`,`reference`,`select`,`slider`,`rangeSlider`,`colour`,`radioGroup`,`checkboxGroup`,`tags`,`date`,`divider`]);function _(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(!g.has(n.type))throw Error(`Unsupported form field type: ${n.type}`);(n.type===`select`||n.type===`radioGroup`||n.type===`checkboxGroup`)&&y(n),(n.type===`slider`||n.type===`rangeSlider`)&&v(n),t.add(n.id)}}function v(e){let{min:t,max:n,step:r}=l.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>l.i(n,-t))throw Error(`Range slider ${e.id} needs room for at least one step.`)}function y(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 b={asset:{key:`assetId`,itemLabel:`asset`,itemsLabel:`assets`},reference:{key:`entryId`,itemLabel:`entry`,itemsLabel:`entries`}};function x(e){return e.type===`asset`||e.type===`reference`?e.picker?.label??e.label:e.label}function S(e){let t=b[e.type],{addLabel:n=`Choose ${x(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 C(e,t){let{key:n}=b[e.type];return(Array.isArray(t)?t:t===void 0?[]:[t]).flatMap(e=>T(e,n)?[e[n]]:[])}function w(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 T(e,t){return!!e&&typeof e==`object`&&t in e&&typeof e[t]==`string`&&e[t].trim().length>0}function E(e){return!!e.text?.trim()||e.type===`horizontalRule`||!!e.content?.some(E)}function D(e){return`${x(e)} is required.`}function O(e,t){if(typeof t!=`string`)return`Enter text.`;if(e.required&&!t.trim())return D(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 k(e,t){let n=i.n(t);if(n)return n;if(e.required&&!E(t))return D(e)}function A(e,t){if(typeof t!=`string`)return`Choose an available option.`;if(t===``)return e.required?D(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 j(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function M(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 D(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 N(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`?l.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 P(e,t){if(typeof t!=`string`)return`Enter a valid calendar date (YYYY-MM-DD).`;if(!t)return e.required?D(e):void 0;if(!u.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 F(e,t){return typeof e==`number`&&Number.isFinite(e)?l.r(e,t):void 0}function I(e,t){let n=e,r=F(n?.min,t),i=F(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 L(e,t){if(!t||typeof t!=`object`||Array.isArray(t))return`Enter a range.`;let n=t,r=n.min,i=n.max,a=N(e,r)??N(e,i);if(a)return a;if(r>i)return`The start must not be greater than the end.`;if(e.type===`rangeSlider`&&l.i(i,-r)<l.a(e).step)return`Keep the range endpoints at least one step apart.`}function R(t,n){return typeof n==`string`?n.trim()?e.r(n)?void 0:`Enter a valid colour.`:t.required?D(t):void 0:`Enter a valid colour.`}function z(e,t){if(e.type!==`asset`&&e.type!==`reference`)return;let{key:n,itemLabel:r,itemsLabel:i}=b[e.type];if(!e.multiple)return T(t,n)?void 0:`Choose an ${r}.`;if(!Array.isArray(t)||!t.every(e=>T(e,n)))return`Choose a list of ${i}.`;if(e.required&&t.length===0)return D(e);let a=e.picker?.max;if(a!==void 0&&t.length>a)return`Choose no more than ${a} ${S(e).itemsLabel}.`}var B={shortText:O,longText:O,richText:k,number:N,slider:N,rangeSlider:L,date:P,colour:R,radioGroup:A,checkboxGroup:M,tags:M,boolean:(e,t)=>typeof t==`boolean`?void 0:`Choose a boolean value.`,dateTime:(e,t)=>w(t)?void 0:`Enter a valid UTC date and time.`,select:A,asset:z,reference:z};function V(e,t){return t===void 0?e.required?D(e):void 0:B[e.type](e,t)}function H(e,t){return _(e),Object.fromEntries(e.fields.flatMap(e=>{if(e.type===`divider`)return[];let n=V(e,Object.hasOwn(t,e.id)?t[e.id]:void 0);return n?[[e.id,n]]:[]}))}function U({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`?p.RadioCard:p.CheckboxCard;return(0,h.jsx)(n,{...s,title:t.label,description:t.description})}let c=e.type===`radioGroup`?f.Radio:f.Checkbox;return(0,h.jsx)(c,{...s,children:(0,h.jsxs)(`span`,{children:[t.label,t.description&&(0,h.jsx)(`span`,{className:`ds-form-editor__option-description`,children:t.description})]})})}function W({field:e,stored:n,isDisabled:r,required:i,accessibility:a,onChange:o}){let s=e.type===`checkboxGroup`,c=s?j(n):typeof n==`string`&&n?[n]:[],l=e.appearance===`card`?p.SelectionCardGroup:f.ChoiceGroup;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(l,{...a,label:e.label,columns:e.columns??(e.appearance===`card`?2:1),children:e.options.map(t=>(0,h.jsx)(U,{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,h.jsxs)(t.Button,{variant:`simple`,size:`sm`,isDisabled:r,onClick:()=>o(void 0),children:[`Clear `,e.label]})]})}function G({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=l.a(e),o=F(t,a);return(0,h.jsx)(l.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 K({field:e,stored:t,isDisabled:n,accessibility:r,onChange:i}){let a=l.a(e),o=I(t,a);return(0,h.jsx)(l.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 q({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,h.jsx)(W,{field:t,...s});case`rangeSlider`:return(0,h.jsx)(K,{field:t,...s});case`slider`:return(0,h.jsx)(G,{field:t,...s});case`colour`:return(0,h.jsx)(e.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.r(n)&&o(n)},onValueChange:e=>o(e===``?void 0:e)});case`tags`:return(0,h.jsx)(d.TagsInput,{...a,required:i,placeholder:t.placeholder,max:t.max,isDisabled:r,value:j(n),onValueChange:o});case`date`:return(0,h.jsx)(u.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 J(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 Y({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){return(0,h.jsx)(o.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 X({field:e,stored:t,isDisabled:n,required:r,accessibility:i,onChange:a}){let o=!r&&!e.options.some(e=>e.value===``);return(0,h.jsx)(s.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 Z({field:e,selected:t,items:n,isDisabled:r,accessibility:i,onChange:o}){return(0,h.jsx)(a.EntryPicker,{...i,items:n,value:t,...S(e),mode:e.multiple?`multiple`:`single`,isDisabled:r,onValueChange:t=>o(J(e,t))})}function Q({field:e,stored:t,selected:n,items:a,isDisabled:o,accessibility:{required:s,...l},onChange:u}){let d={stored:t,isDisabled:o,required:s,accessibility:l,onChange:u};switch(e.type){case`shortText`:return(0,h.jsx)(r.TextField,{...l,required:s,disabled:o,placeholder:e.placeholder,type:e.inputType,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:typeof t==`string`?t:``,onChange:e=>u(e.target.value)});case`longText`:return(0,h.jsx)(r.TextArea,{...l,required:s,disabled:o,placeholder:e.placeholder,rows:e.rows,maxLength:e.maxLength,readOnly:e.readOnly,autoFocus:e.autoFocus,value:typeof t==`string`?t:``,onChange:e=>u(e.target.value)});case`number`:return(0,h.jsx)(Y,{field:e,...d});case`boolean`:return(0,h.jsx)(c.Switch,{...l,isDisabled:o,autoFocus:e.autoFocus,isSelected:t===!0,onSelectedChange:u});case`dateTime`:return(0,h.jsx)(r.TextField,{...l,required:s,disabled:o,type:`datetime-local`,step:`0.001`,autoFocus:e.autoFocus,value:w(t)?.slice(0,-1)??``,onChange:e=>u(w(`${e.target.value}Z`))});case`richText`:return(0,h.jsx)(i.t,{...l,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,h.jsx)(X,{field:e,...d});case`asset`:case`reference`:return(0,h.jsx)(Z,{field:e,items:a,selected:n??[],...d});default:return(0,h.jsx)(q,{field:e,...d})}}function $({field:e,stored:t,items:r,isDisabled:i,error:a,isErrorVisible:o,onChange:s}){let c=(0,m.useMemo)(()=>a===void 0&&o?V(e,t):void 0,[a,o,e,t]),l=(0,m.useMemo)(()=>e.type===`asset`||e.type===`reference`?C(e,t):void 0,[e,t]);return(0,h.jsx)(n.Field,{label:e.type===`dateTime`?`${e.label} (UTC)`:x(e),hint:e.hint,error:a??c,isRequired:e.required,count:l?.length??(e.type===`checkboxGroup`?j(t).length:void 0),isGroup:l!==void 0||ee.has(e.type),children:n=>(0,h.jsx)(Q,{field:e,stored:t,selected:l,items:r,isDisabled:i,accessibility:n,onChange:s})})}var ee=new Set([`radioGroup`,`checkboxGroup`,`rangeSlider`]),te=new Set([`slider`,`rangeSlider`,`date`,`colour`]);function ne({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,g]=(0,m.useState)(n),[v,y]=(0,m.useState)(()=>new Set),b=t??p;(0,m.useMemo)(()=>_(e),[e]);let x=(e,n)=>{let i={...b};n===void 0?delete i[e]:i[e]=n,t===void 0&&g(i),y(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,h.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,h.jsx)(`hr`,{className:`ds-form-editor__divider`},e.id);let t=Object.hasOwn(b,e.id)?b[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||v.has(e.id)||c&&te.has(e.type)||e.type===`number`&&typeof t==`number`;return(0,h.jsx)($,{field:e,stored:t,items:i[e.id]??[],isDisabled:n,error:a[e.id],isErrorVisible:l,onChange:t=>{r||x(e.id,t)}},e.id)})})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return ne}});
|
|
2
|
-
//# sourceMappingURL=FormEditor-DDylpJ9O.cjs.map
|