@namroodinc/liquid-editorial 0.13.4 → 0.14.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 +18 -6
- package/UPGRADING.md +77 -0
- package/dist/chunks/{Avatar-UjhjcHh5.js → Avatar-BToMaTdL.js} +2 -2
- package/dist/chunks/{Avatar-UjhjcHh5.js.map → Avatar-BToMaTdL.js.map} +1 -1
- package/dist/chunks/{Avatar-BY0dAItT.cjs → Avatar-Dw7EWd_-.cjs} +2 -2
- package/dist/chunks/{Avatar-BY0dAItT.cjs.map → Avatar-Dw7EWd_-.cjs.map} +1 -1
- package/dist/chunks/{Board-CQ1GTuRB.cjs → Board-DeXtaWNO.cjs} +2 -2
- package/dist/chunks/{Board-CQ1GTuRB.cjs.map → Board-DeXtaWNO.cjs.map} +1 -1
- package/dist/chunks/{Board-DUX76d2R.js → Board-XeDG9nWP.js} +2 -2
- package/dist/chunks/{Board-DUX76d2R.js.map → Board-XeDG9nWP.js.map} +1 -1
- package/dist/chunks/{CollectionView-JRNdXHti.js → CollectionView-C0_bTO2v.js} +2 -2
- package/dist/chunks/{CollectionView-JRNdXHti.js.map → CollectionView-C0_bTO2v.js.map} +1 -1
- package/dist/chunks/{CollectionView-CIJdNwcq.cjs → CollectionView-Dbg4d_tA.cjs} +2 -2
- package/dist/chunks/{CollectionView-CIJdNwcq.cjs.map → CollectionView-Dbg4d_tA.cjs.map} +1 -1
- package/dist/chunks/{ColourField-BG5oGj9f.js → ColourField-Bb8H87fg.js} +3 -3
- package/dist/chunks/{ColourField-BG5oGj9f.js.map → ColourField-Bb8H87fg.js.map} +1 -1
- package/dist/chunks/{ColourField-DFvRASVe.cjs → ColourField-DAFzOIOq.cjs} +2 -2
- package/dist/chunks/{ColourField-DFvRASVe.cjs.map → ColourField-DAFzOIOq.cjs.map} +1 -1
- package/dist/chunks/{DatePicker-LqaePc57.js → DatePicker-COm1giw8.js} +3 -3
- package/dist/chunks/{DatePicker-LqaePc57.js.map → DatePicker-COm1giw8.js.map} +1 -1
- package/dist/chunks/{DatePicker-ClOqS6oH.cjs → DatePicker-DOg3iQYy.cjs} +2 -2
- package/dist/chunks/{DatePicker-ClOqS6oH.cjs.map → DatePicker-DOg3iQYy.cjs.map} +1 -1
- package/dist/chunks/{Drawer-DdIH9jpe.cjs → Drawer-B2dcTh5l.cjs} +2 -2
- package/dist/chunks/{Drawer-DdIH9jpe.cjs.map → Drawer-B2dcTh5l.cjs.map} +1 -1
- package/dist/chunks/{Drawer-Ck5XKT_V.js → Drawer-nUTJtwX_.js} +3 -3
- package/dist/chunks/{Drawer-Ck5XKT_V.js.map → Drawer-nUTJtwX_.js.map} +1 -1
- package/dist/chunks/EntryPicker-BwEYRtQl.cjs +2 -0
- package/dist/chunks/EntryPicker-BwEYRtQl.cjs.map +1 -0
- package/dist/chunks/{use-picker-session-BSpOwnQ-.js → EntryPicker-Ie9T47hA.js} +367 -202
- package/dist/chunks/EntryPicker-Ie9T47hA.js.map +1 -0
- package/dist/chunks/FormEditor-D1HUnjMI.cjs +2 -0
- package/dist/chunks/FormEditor-D1HUnjMI.cjs.map +1 -0
- package/dist/chunks/FormEditor-DgDV5aeR.js +30 -0
- package/dist/chunks/FormEditor-DgDV5aeR.js.map +1 -0
- package/dist/chunks/Icon-Bxvp1-td.js +102 -0
- package/dist/chunks/Icon-Bxvp1-td.js.map +1 -0
- package/dist/chunks/{Icon-3ucBRgrd.cjs → Icon-CnnTrtNb.cjs} +2 -2
- package/dist/chunks/Icon-CnnTrtNb.cjs.map +1 -0
- package/dist/chunks/Message-B0A5bz8V.cjs +2 -0
- package/dist/chunks/{Message-Ce2zjtfz.cjs.map → Message-B0A5bz8V.cjs.map} +1 -1
- package/dist/chunks/{Message-DNaudg1u.js → Message-VJTPhId7.js} +3 -3
- package/dist/chunks/{Message-DNaudg1u.js.map → Message-VJTPhId7.js.map} +1 -1
- package/dist/chunks/RichTextEditor-DPhEkDxi.js +2108 -0
- package/dist/chunks/RichTextEditor-DPhEkDxi.js.map +1 -0
- package/dist/chunks/RichTextEditor-DV7NZp_k.cjs +2 -0
- package/dist/chunks/RichTextEditor-DV7NZp_k.cjs.map +1 -0
- package/dist/chunks/{dialogLabel-DT7rCr3_.js → dialogLabel-C153NosD.js} +2 -2
- package/dist/chunks/{dialogLabel-DT7rCr3_.js.map → dialogLabel-C153NosD.js.map} +1 -1
- package/dist/chunks/{dialogLabel-_-MTckE_.cjs → dialogLabel-CNNQbtob.cjs} +2 -2
- package/dist/chunks/{dialogLabel-_-MTckE_.cjs.map → dialogLabel-CNNQbtob.cjs.map} +1 -1
- package/dist/chunks/overlayLayer-CtOTt1xB.cjs +2 -0
- package/dist/chunks/overlayLayer-CtOTt1xB.cjs.map +1 -0
- package/dist/chunks/{overlayLayer-lU4iWSjO.js → overlayLayer-Og07sIyl.js} +21 -3
- package/dist/chunks/overlayLayer-Og07sIyl.js.map +1 -0
- package/dist/chunks/{useTooltip-DnJEFBLg.js → useTooltip-Du8PutGX.js} +2 -2
- package/dist/chunks/{useTooltip-DnJEFBLg.js.map → useTooltip-Du8PutGX.js.map} +1 -1
- package/dist/chunks/{useTooltip-C7ON4nkV.cjs → useTooltip-ekdwMJFz.cjs} +2 -2
- package/dist/chunks/{useTooltip-C7ON4nkV.cjs.map → useTooltip-ekdwMJFz.cjs.map} +1 -1
- package/dist/components/AppShell/index.cjs +1 -1
- package/dist/components/AppShell/index.js +1 -1
- 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/Avatar/index.cjs +1 -1
- package/dist/components/Avatar/index.js +1 -1
- package/dist/components/Banner/index.cjs +1 -1
- package/dist/components/Banner/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.js +1 -1
- package/dist/components/Choice/index.cjs +1 -1
- package/dist/components/Choice/index.cjs.map +1 -1
- package/dist/components/Choice/index.js +5 -5
- package/dist/components/CollectionView/index.cjs +1 -1
- package/dist/components/CollectionView/index.js +1 -1
- 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.js +1 -1
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.js +4 -4
- package/dist/components/EntryPicker/dialog.d.cts +11 -1
- package/dist/components/EntryPicker/dialog.d.cts.map +1 -1
- package/dist/components/EntryPicker/dialog.d.ts +11 -1
- package/dist/components/EntryPicker/dialog.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/use-picker-data.d.cts +1 -1
- package/dist/components/EntryPicker/use-picker-data.d.cts.map +1 -1
- package/dist/components/EntryPicker/use-picker-data.d.ts +1 -1
- package/dist/components/EntryPicker/use-picker-data.d.ts.map +1 -1
- package/dist/components/EntryPicker/use-picker-session.d.cts +4 -1
- package/dist/components/EntryPicker/use-picker-session.d.cts.map +1 -1
- package/dist/components/EntryPicker/use-picker-session.d.ts +4 -1
- package/dist/components/EntryPicker/use-picker-session.d.ts.map +1 -1
- package/dist/components/EntryPicker/use-selected-items.d.cts +2 -0
- package/dist/components/EntryPicker/use-selected-items.d.cts.map +1 -1
- package/dist/components/EntryPicker/use-selected-items.d.ts +2 -0
- package/dist/components/EntryPicker/use-selected-items.d.ts.map +1 -1
- package/dist/components/FormEditor/README.md +155 -24
- package/dist/components/FormEditor/control.d.cts +11 -2
- package/dist/components/FormEditor/control.d.cts.map +1 -1
- package/dist/components/FormEditor/control.d.ts +11 -2
- package/dist/components/FormEditor/control.d.ts.map +1 -1
- package/dist/components/FormEditor/form.d.cts +33 -0
- package/dist/components/FormEditor/form.d.cts.map +1 -0
- package/dist/components/FormEditor/form.d.ts +33 -0
- package/dist/components/FormEditor/form.d.ts.map +1 -0
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.d.cts +3 -27
- package/dist/components/FormEditor/index.d.cts.map +1 -1
- package/dist/components/FormEditor/index.d.ts +3 -27
- package/dist/components/FormEditor/index.d.ts.map +1 -1
- package/dist/components/FormEditor/index.js +3 -3
- package/dist/components/FormEditor/model.d.cts +2 -0
- package/dist/components/FormEditor/model.d.cts.map +1 -1
- package/dist/components/FormEditor/model.d.ts +2 -0
- package/dist/components/FormEditor/model.d.ts.map +1 -1
- package/dist/components/FormEditor/rich-text-control.d.cts +4 -0
- package/dist/components/FormEditor/rich-text-control.d.cts.map +1 -0
- package/dist/components/FormEditor/rich-text-control.d.ts +4 -0
- package/dist/components/FormEditor/rich-text-control.d.ts.map +1 -0
- package/dist/components/Icon/icons.d.cts +11 -0
- package/dist/components/Icon/icons.d.cts.map +1 -1
- package/dist/components/Icon/icons.d.ts +11 -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/ImageCropper/index.cjs +1 -1
- package/dist/components/ImageCropper/index.cjs.map +1 -1
- package/dist/components/ImageCropper/index.js +6 -6
- package/dist/components/Menu/index.cjs +1 -1
- package/dist/components/Menu/index.cjs.map +1 -1
- package/dist/components/Menu/index.d.cts +3 -2
- package/dist/components/Menu/index.d.cts.map +1 -1
- package/dist/components/Menu/index.d.ts +3 -2
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +64 -51
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.js +1 -1
- package/dist/components/RichTextEditor/document.d.cts +6 -2
- package/dist/components/RichTextEditor/document.d.cts.map +1 -1
- package/dist/components/RichTextEditor/document.d.ts +6 -2
- package/dist/components/RichTextEditor/document.d.ts.map +1 -1
- package/dist/components/RichTextEditor/embed-context.d.cts +5 -0
- package/dist/components/RichTextEditor/embed-context.d.cts.map +1 -1
- package/dist/components/RichTextEditor/embed-context.d.ts +5 -0
- package/dist/components/RichTextEditor/embed-context.d.ts.map +1 -1
- package/dist/components/RichTextEditor/embed-types.d.cts +6 -4
- package/dist/components/RichTextEditor/embed-types.d.cts.map +1 -1
- package/dist/components/RichTextEditor/embed-types.d.ts +6 -4
- package/dist/components/RichTextEditor/embed-types.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.d.cts +8 -0
- package/dist/components/RichTextEditor/index.d.cts.map +1 -1
- package/dist/components/RichTextEditor/index.d.ts +8 -0
- package/dist/components/RichTextEditor/index.d.ts.map +1 -1
- package/dist/components/RichTextEditor/index.js +1 -2
- package/dist/components/RichTextEditor/storyblock-view.d.cts.map +1 -1
- package/dist/components/RichTextEditor/storyblock-view.d.ts.map +1 -1
- package/dist/components/RichTextEditor/style.css +44 -46
- package/dist/components/RichTextEditor/tables.d.cts +7 -0
- package/dist/components/RichTextEditor/tables.d.cts.map +1 -0
- package/dist/components/RichTextEditor/tables.d.ts +7 -0
- package/dist/components/RichTextEditor/tables.d.ts.map +1 -0
- package/dist/components/RichTextEditor/use-embeds.d.cts.map +1 -1
- package/dist/components/RichTextEditor/use-embeds.d.ts.map +1 -1
- 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 +2 -2
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.cjs.map +1 -1
- package/dist/components/SelectionCard/index.js +4 -4
- package/dist/components/SelectionCard/index.js.map +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.js +1 -1
- 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/Time/index.cjs +1 -1
- package/dist/components/Time/index.js +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.cjs.map +1 -1
- package/dist/components/Toast/index.d.cts +16 -3
- package/dist/components/Toast/index.d.cts.map +1 -1
- package/dist/components/Toast/index.d.ts +16 -3
- package/dist/components/Toast/index.d.ts.map +1 -1
- package/dist/components/Toast/index.js +65 -31
- package/dist/components/Toast/index.js.map +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.js +28 -28
- package/dist/internal/Message.d.cts.map +1 -1
- package/dist/internal/Message.d.ts.map +1 -1
- package/dist/internal/dialogFocus.d.cts +6 -1
- package/dist/internal/dialogFocus.d.cts.map +1 -1
- package/dist/internal/dialogFocus.d.ts +6 -1
- package/dist/internal/dialogFocus.d.ts.map +1 -1
- package/package.json +8 -6
- package/dist/chunks/EntryPicker-B4dAsObz.cjs +0 -2
- package/dist/chunks/EntryPicker-B4dAsObz.cjs.map +0 -1
- package/dist/chunks/EntryPicker-DDXHytMN.js +0 -160
- package/dist/chunks/EntryPicker-DDXHytMN.js.map +0 -1
- package/dist/chunks/FormEditor-BGzE-rqk.cjs +0 -2
- package/dist/chunks/FormEditor-BGzE-rqk.cjs.map +0 -1
- package/dist/chunks/FormEditor-ChH4e5sB.js +0 -693
- package/dist/chunks/FormEditor-ChH4e5sB.js.map +0 -1
- package/dist/chunks/Icon-3ucBRgrd.cjs.map +0 -1
- package/dist/chunks/Icon-dPXyBYe5.js +0 -91
- package/dist/chunks/Icon-dPXyBYe5.js.map +0 -1
- package/dist/chunks/Message-Ce2zjtfz.cjs +0 -2
- package/dist/chunks/RichTextEditor-BFblqw8m.js +0 -1144
- package/dist/chunks/RichTextEditor-BFblqw8m.js.map +0 -1
- package/dist/chunks/RichTextEditor-DU9CVeRD.cjs +0 -2
- package/dist/chunks/RichTextEditor-DU9CVeRD.cjs.map +0 -1
- package/dist/chunks/overlayLayer-iGhuAByk.cjs +0 -2
- package/dist/chunks/overlayLayer-iGhuAByk.cjs.map +0 -1
- package/dist/chunks/overlayLayer-lU4iWSjO.js.map +0 -1
- package/dist/chunks/use-picker-session-BSpOwnQ-.js.map +0 -1
- package/dist/chunks/use-picker-session-ouqHBmVA.cjs +0 -2
- package/dist/chunks/use-picker-session-ouqHBmVA.cjs.map +0 -1
|
@@ -1,693 +0,0 @@
|
|
|
1
|
-
import { Button as e } from "../components/Button/index.js";
|
|
2
|
-
import { Field as t } from "../components/Field/index.js";
|
|
3
|
-
import { TextArea as n, TextField as r } from "../components/TextField/index.js";
|
|
4
|
-
import { n as i, r as a, t as o } from "./RichTextEditor-BFblqw8m.js";
|
|
5
|
-
import { n as s, r as c } from "./use-picker-session-BSpOwnQ-.js";
|
|
6
|
-
import { Checkbox as l, ChoiceGroup as u, Radio as d } from "../components/Choice/index.js";
|
|
7
|
-
import { Container as f } from "../components/Container/index.js";
|
|
8
|
-
import { t as p } from "./EntryPicker-DDXHytMN.js";
|
|
9
|
-
import { n as m } from "./decimal-hq_W9D3s.js";
|
|
10
|
-
import { t as h } from "./NumberField-C90eJGny.js";
|
|
11
|
-
import { Select as g } from "../components/Select/index.js";
|
|
12
|
-
import { Switch as _ } from "../components/Switch/index.js";
|
|
13
|
-
import { i as v } from "./colour-CYEF4Q_n.js";
|
|
14
|
-
import { i as y, n as b, r as x, t as S } from "./Slider-Cab6NqhK.js";
|
|
15
|
-
import { t as C } from "./ColourField-BG5oGj9f.js";
|
|
16
|
-
import { a as ee, n as te } from "./DatePicker-LqaePc57.js";
|
|
17
|
-
import { TagsInput as ne } from "../components/TagsInput/index.js";
|
|
18
|
-
import { CheckboxCard as re, RadioCard as ie, SelectionCardGroup as w } from "../components/SelectionCard/index.js";
|
|
19
|
-
import { useMemo as T, useState as E } from "react";
|
|
20
|
-
import { Fragment as D, jsx as O, jsxs as k } from "react/jsx-runtime";
|
|
21
|
-
//#region src/components/RichTextEditor/expanded-width.ts
|
|
22
|
-
var ae = ["wide", "full"], oe = [
|
|
23
|
-
"sm",
|
|
24
|
-
"md",
|
|
25
|
-
"lg"
|
|
26
|
-
], se = /* @__PURE__ */ new Set([
|
|
27
|
-
"shortText",
|
|
28
|
-
"longText",
|
|
29
|
-
"richText",
|
|
30
|
-
"number",
|
|
31
|
-
"boolean",
|
|
32
|
-
"dateTime",
|
|
33
|
-
"asset",
|
|
34
|
-
"reference",
|
|
35
|
-
"select",
|
|
36
|
-
"slider",
|
|
37
|
-
"rangeSlider",
|
|
38
|
-
"colour",
|
|
39
|
-
"radioGroup",
|
|
40
|
-
"checkboxGroup",
|
|
41
|
-
"tags",
|
|
42
|
-
"date",
|
|
43
|
-
"divider"
|
|
44
|
-
]);
|
|
45
|
-
function A(e) {
|
|
46
|
-
let t = /* @__PURE__ */ new Set();
|
|
47
|
-
for (let n of e.fields) {
|
|
48
|
-
if (!n.id?.trim() || t.has(n.id)) throw Error("Form field IDs must be nonempty and unique.");
|
|
49
|
-
if (!se.has(n.type)) throw Error(`Unsupported form field type: ${n.type}`);
|
|
50
|
-
if ("labelHint" in n) throw Error(`Field ${n.id} uses the removed labelHint; move its content into hint.`);
|
|
51
|
-
n.type !== "divider" && (ce(n), P(n), ue(n)), t.add(n.id);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function ce(e) {
|
|
55
|
-
switch (e.type) {
|
|
56
|
-
case "select":
|
|
57
|
-
case "radioGroup":
|
|
58
|
-
case "checkboxGroup": return L(e);
|
|
59
|
-
case "slider":
|
|
60
|
-
case "rangeSlider": return F(e);
|
|
61
|
-
case "number": return I(e);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
var le = /* @__PURE__ */ new Set([
|
|
65
|
-
"shortText",
|
|
66
|
-
"longText",
|
|
67
|
-
"tags",
|
|
68
|
-
"asset",
|
|
69
|
-
"reference"
|
|
70
|
-
]);
|
|
71
|
-
function j(e) {
|
|
72
|
-
return le.has(e.type);
|
|
73
|
-
}
|
|
74
|
-
function ue(e) {
|
|
75
|
-
if (j(e)) {
|
|
76
|
-
if (e.limitDisplay !== void 0 && !["used", "remaining"].includes(e.limitDisplay)) throw Error(`Field ${e.id} needs a limitDisplay of used or remaining.`);
|
|
77
|
-
if (e.limitVisibility !== void 0 && !["always", "nearLimit"].includes(e.limitVisibility)) throw Error(`Field ${e.id} needs a limitVisibility of always or nearLimit.`);
|
|
78
|
-
if (e.showLimitRing !== void 0 && typeof e.showLimitRing != "boolean") throw Error(`Field ${e.id} needs a boolean showLimitRing.`);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function de(e, t, n, r) {
|
|
82
|
-
return j(e) ? {
|
|
83
|
-
limitDisplay: e.limitDisplay,
|
|
84
|
-
limitVisibility: e.limitVisibility,
|
|
85
|
-
showLimitRing: e.showLimitRing,
|
|
86
|
-
limit: fe(e, t, n ?? [], r)
|
|
87
|
-
} : {};
|
|
88
|
-
}
|
|
89
|
-
function fe(e, t, n, r) {
|
|
90
|
-
switch (e.type) {
|
|
91
|
-
case "shortText":
|
|
92
|
-
case "longText": return e.maxLength === void 0 ? void 0 : {
|
|
93
|
-
count: M(t).length,
|
|
94
|
-
max: e.maxLength
|
|
95
|
-
};
|
|
96
|
-
case "tags": return e.max === void 0 ? void 0 : {
|
|
97
|
-
count: q(t).length,
|
|
98
|
-
max: e.max
|
|
99
|
-
};
|
|
100
|
-
default: {
|
|
101
|
-
let { mode: t, max: i } = N(e, r);
|
|
102
|
-
return c(t, n.length, i);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function pe(e, t, n, r) {
|
|
107
|
-
if (n !== void 0 && (e.type === "asset" || e.type === "reference")) {
|
|
108
|
-
let { mode: t, max: i } = N(e, r);
|
|
109
|
-
return s(t, n.length, i);
|
|
110
|
-
}
|
|
111
|
-
return e.type === "checkboxGroup" ? q(t).length : void 0;
|
|
112
|
-
}
|
|
113
|
-
function M(e) {
|
|
114
|
-
return typeof e == "string" ? e : "";
|
|
115
|
-
}
|
|
116
|
-
function N(e, t) {
|
|
117
|
-
let n = t?.mode ?? (e.multiple ? "multiple" : "single");
|
|
118
|
-
if (!e.multiple) return {
|
|
119
|
-
mode: n,
|
|
120
|
-
max: n === "multiple" ? 1 : void 0
|
|
121
|
-
};
|
|
122
|
-
let r = [B(e).max, t?.max].filter((e) => e !== void 0 && Number.isFinite(e));
|
|
123
|
-
return {
|
|
124
|
-
mode: n,
|
|
125
|
-
max: r.length > 0 ? Math.min(...r) : void 0
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
function P(e) {
|
|
129
|
-
if (e.width !== void 0 && !oe.includes(e.width)) throw Error(`Field ${e.id} needs a width of sm, md or lg.`);
|
|
130
|
-
if (e.type === "richText" && e.expandedWidth !== void 0 && !ae.includes(e.expandedWidth)) throw Error(`Rich text field ${e.id} needs an expandedWidth of wide or full.`);
|
|
131
|
-
}
|
|
132
|
-
function F(e) {
|
|
133
|
-
let { min: t, max: n, step: r } = y(e);
|
|
134
|
-
if (![
|
|
135
|
-
t,
|
|
136
|
-
n,
|
|
137
|
-
r
|
|
138
|
-
].every(Number.isFinite) || t >= n || r <= 0) throw Error(`Slider field ${e.id} needs finite min < max and a positive step.`);
|
|
139
|
-
if (e.type === "rangeSlider" && r > m(n, -t)) throw Error(`Range slider ${e.id} needs room for at least one step.`);
|
|
140
|
-
}
|
|
141
|
-
function I(e) {
|
|
142
|
-
let { min: t, max: n, step: r = "any" } = e;
|
|
143
|
-
if ([t, n].some((e) => e !== void 0 && !Number.isFinite(e)) || t !== void 0 && n !== void 0 && t > n || r !== "any" && !(Number.isFinite(r) && r > 0)) throw Error(`Number field ${e.id} needs finite min <= max and a positive step or "any".`);
|
|
144
|
-
if ([e.decreaseLabel, e.increaseLabel].some((e) => e !== void 0 && (typeof e != "string" || !e.trim()))) throw Error(`Number field ${e.id} needs nonempty stepper labels.`);
|
|
145
|
-
}
|
|
146
|
-
function L(e) {
|
|
147
|
-
if (!Array.isArray(e.options)) {
|
|
148
|
-
let t = e.type === "select" ? "Select" : "Choice";
|
|
149
|
-
throw Error(`${t} field ${e.id} needs an options array.`);
|
|
150
|
-
}
|
|
151
|
-
if (e.type === "select") return;
|
|
152
|
-
let t = e.options.map((e) => e.value);
|
|
153
|
-
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.`);
|
|
154
|
-
}
|
|
155
|
-
var R = {
|
|
156
|
-
asset: {
|
|
157
|
-
key: "assetId",
|
|
158
|
-
itemLabel: "asset",
|
|
159
|
-
itemsLabel: "assets"
|
|
160
|
-
},
|
|
161
|
-
reference: {
|
|
162
|
-
key: "entryId",
|
|
163
|
-
itemLabel: "entry",
|
|
164
|
-
itemsLabel: "entries"
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
function z(e) {
|
|
168
|
-
return e.type === "asset" || e.type === "reference" ? e.picker?.label ?? e.label : e.label;
|
|
169
|
-
}
|
|
170
|
-
function B(e) {
|
|
171
|
-
let t = R[e.type], { addLabel: n = `Choose ${z(e)}`, emptyLabel: r, itemLabel: i = t.itemLabel, itemsLabel: a = t.itemsLabel, max: o, isReorderable: s } = e.picker ?? {};
|
|
172
|
-
return {
|
|
173
|
-
addLabel: n,
|
|
174
|
-
emptyLabel: r,
|
|
175
|
-
itemLabel: i,
|
|
176
|
-
itemsLabel: a,
|
|
177
|
-
max: o,
|
|
178
|
-
isReorderable: s
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
function me(e, t) {
|
|
182
|
-
let { key: n } = R[e.type];
|
|
183
|
-
return (Array.isArray(t) ? t : t === void 0 ? [] : [t]).flatMap((e) => H(e, n) ? [e[n]] : []);
|
|
184
|
-
}
|
|
185
|
-
function V(e) {
|
|
186
|
-
if (typeof e != "string") return;
|
|
187
|
-
let t = /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(?:Z|\+00:00)$/.exec(e);
|
|
188
|
-
if (!t) return;
|
|
189
|
-
let n = `${t[1]}:${t[2] ?? "00"}.${(t[3] ?? "").padEnd(3, "0")}Z`, r = new Date(n);
|
|
190
|
-
if (Number.isFinite(r.getTime()) && r.toISOString() === n) return n;
|
|
191
|
-
}
|
|
192
|
-
function H(e, t) {
|
|
193
|
-
return !!e && typeof e == "object" && t in e && typeof e[t] == "string" && e[t].trim().length > 0;
|
|
194
|
-
}
|
|
195
|
-
function U(e) {
|
|
196
|
-
return !!e.text?.trim() || e.type === "horizontalRule" || e.type === "storyblock" || !!e.content?.some(U);
|
|
197
|
-
}
|
|
198
|
-
function W(e) {
|
|
199
|
-
return `${z(e)} is required.`;
|
|
200
|
-
}
|
|
201
|
-
function G(e, t) {
|
|
202
|
-
if (typeof t != "string") return "Enter text.";
|
|
203
|
-
if (e.required && !t.trim()) return W(e);
|
|
204
|
-
if ((e.type === "shortText" || e.type === "longText") && e.maxLength !== void 0 && t.length > e.maxLength) return `Enter no more than ${e.maxLength} characters.`;
|
|
205
|
-
}
|
|
206
|
-
function he(e, t) {
|
|
207
|
-
let n = i(t);
|
|
208
|
-
if (n) return n;
|
|
209
|
-
if (e.required && !U(t)) return W(e);
|
|
210
|
-
}
|
|
211
|
-
function K(e, t) {
|
|
212
|
-
if (typeof t != "string") return "Choose an available option.";
|
|
213
|
-
if (t === "") return e.required ? W(e) : void 0;
|
|
214
|
-
if ((e.type === "select" || e.type === "radioGroup") && e.options.length > 0 && !e.options.some((e) => e.value === t)) return "Choose an available option.";
|
|
215
|
-
}
|
|
216
|
-
function q(e) {
|
|
217
|
-
return Array.isArray(e) ? e.filter((e) => typeof e == "string") : [];
|
|
218
|
-
}
|
|
219
|
-
function J(e, t) {
|
|
220
|
-
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.";
|
|
221
|
-
if (e.required && !t.length) return W(e);
|
|
222
|
-
if (e.type === "tags" && e.max !== void 0 && t.length > e.max) return `Enter no more than ${e.max} tags.`;
|
|
223
|
-
if (e.type === "checkboxGroup" && e.options.length && t.some((t) => !e.options.some((e) => e.value === t))) return "Choose available options.";
|
|
224
|
-
}
|
|
225
|
-
function Y(e, t) {
|
|
226
|
-
if (typeof t != "number" || !Number.isFinite(t)) return "Enter a finite number.";
|
|
227
|
-
let { min: n, max: r } = e.type === "slider" || e.type === "rangeSlider" ? y(e) : e.type === "number" ? e : {};
|
|
228
|
-
if (n !== void 0 && t < n) return `Enter a number of at least ${n}.`;
|
|
229
|
-
if (r !== void 0 && t > r) return `Enter a number no greater than ${r}.`;
|
|
230
|
-
}
|
|
231
|
-
function ge(e, t) {
|
|
232
|
-
if (typeof t != "string") return "Enter a valid calendar date (YYYY-MM-DD).";
|
|
233
|
-
if (!t) return e.required ? W(e) : void 0;
|
|
234
|
-
if (!ee(t)) return "Enter a valid calendar date (YYYY-MM-DD).";
|
|
235
|
-
if (e.type === "date") {
|
|
236
|
-
if (e.min && t < e.min) return `Choose a date on or after ${e.min}.`;
|
|
237
|
-
if (e.max && t > e.max) return `Choose a date on or before ${e.max}.`;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
function X(e, t) {
|
|
241
|
-
return typeof e == "number" && Number.isFinite(e) ? x(e, t) : void 0;
|
|
242
|
-
}
|
|
243
|
-
function _e(e, t) {
|
|
244
|
-
let n = e, r = X(n?.min, t), i = X(n?.max, t);
|
|
245
|
-
if (r === void 0 && i === void 0) return;
|
|
246
|
-
let [a, o] = [r ?? t.min, i ?? t.max].sort((e, t) => e - t);
|
|
247
|
-
return {
|
|
248
|
-
min: a,
|
|
249
|
-
max: o
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
function ve(e, t) {
|
|
253
|
-
if (!t || typeof t != "object" || Array.isArray(t)) return "Enter a range.";
|
|
254
|
-
let n = t, r = n.min, i = n.max, a = Y(e, r) ?? Y(e, i);
|
|
255
|
-
if (a) return a;
|
|
256
|
-
if (r > i) return "The start must not be greater than the end.";
|
|
257
|
-
if (e.type === "rangeSlider" && m(i, -r) < y(e).step) return "Keep the range endpoints at least one step apart.";
|
|
258
|
-
}
|
|
259
|
-
function ye(e, t) {
|
|
260
|
-
return typeof t == "string" ? t.trim() ? v(t) ? void 0 : "Enter a valid colour." : e.required ? W(e) : void 0 : "Enter a valid colour.";
|
|
261
|
-
}
|
|
262
|
-
function Z(e, t) {
|
|
263
|
-
if (e.type !== "asset" && e.type !== "reference") return;
|
|
264
|
-
let { key: n, itemLabel: r, itemsLabel: i } = R[e.type];
|
|
265
|
-
if (!e.multiple) return H(t, n) ? void 0 : `Choose an ${r}.`;
|
|
266
|
-
if (!Array.isArray(t) || !t.every((e) => H(e, n))) return `Choose a list of ${i}.`;
|
|
267
|
-
if (e.required && t.length === 0) return W(e);
|
|
268
|
-
let a = e.picker?.max;
|
|
269
|
-
if (a !== void 0 && t.length > a) return `Choose no more than ${a} ${B(e).itemsLabel}.`;
|
|
270
|
-
}
|
|
271
|
-
var be = {
|
|
272
|
-
shortText: G,
|
|
273
|
-
longText: G,
|
|
274
|
-
richText: he,
|
|
275
|
-
number: Y,
|
|
276
|
-
slider: Y,
|
|
277
|
-
rangeSlider: ve,
|
|
278
|
-
date: ge,
|
|
279
|
-
colour: ye,
|
|
280
|
-
radioGroup: K,
|
|
281
|
-
checkboxGroup: J,
|
|
282
|
-
tags: J,
|
|
283
|
-
boolean: (e, t) => typeof t == "boolean" ? void 0 : "Choose a boolean value.",
|
|
284
|
-
dateTime: (e, t) => V(t) ? void 0 : "Enter a valid UTC date and time.",
|
|
285
|
-
select: K,
|
|
286
|
-
asset: Z,
|
|
287
|
-
reference: Z
|
|
288
|
-
};
|
|
289
|
-
function Q(e, t) {
|
|
290
|
-
return t === void 0 ? e.required ? W(e) : void 0 : be[e.type](e, t);
|
|
291
|
-
}
|
|
292
|
-
function xe(e, t) {
|
|
293
|
-
return A(e), Object.fromEntries(e.fields.flatMap((e) => {
|
|
294
|
-
if (e.type === "divider") return [];
|
|
295
|
-
let n = Q(e, Object.hasOwn(t, e.id) ? t[e.id] : void 0);
|
|
296
|
-
return n ? [[e.id, n]] : [];
|
|
297
|
-
}));
|
|
298
|
-
}
|
|
299
|
-
//#endregion
|
|
300
|
-
//#region src/components/FormEditor/choice-control.tsx
|
|
301
|
-
function Se({ field: e, option: t, name: n, checked: r, isDisabled: i, invalid: a, onChange: o }) {
|
|
302
|
-
let s = {
|
|
303
|
-
name: n,
|
|
304
|
-
value: t.value,
|
|
305
|
-
checked: r,
|
|
306
|
-
disabled: i || t.isDisabled,
|
|
307
|
-
"aria-invalid": a,
|
|
308
|
-
onChange: () => {
|
|
309
|
-
!i && !t.isDisabled && o();
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
if (e.appearance === "card") {
|
|
313
|
-
let n = e.type === "radioGroup" ? ie : re;
|
|
314
|
-
return /* @__PURE__ */ O(n, {
|
|
315
|
-
...s,
|
|
316
|
-
title: t.label,
|
|
317
|
-
description: t.description
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
let c = e.type === "radioGroup" ? d : l;
|
|
321
|
-
return /* @__PURE__ */ O(c, {
|
|
322
|
-
...s,
|
|
323
|
-
children: /* @__PURE__ */ k("span", { children: [t.label, t.description && /* @__PURE__ */ O("span", {
|
|
324
|
-
className: "ds-form-editor__option-description",
|
|
325
|
-
children: t.description
|
|
326
|
-
})] })
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
function Ce({ field: t, stored: n, isDisabled: r, required: i, accessibility: a, onChange: o }) {
|
|
330
|
-
let s = t.type === "checkboxGroup", c = s ? q(n) : typeof n == "string" && n ? [n] : [], l = t.appearance === "card" ? w : u;
|
|
331
|
-
return /* @__PURE__ */ k(D, { children: [/* @__PURE__ */ O(l, {
|
|
332
|
-
...a,
|
|
333
|
-
label: t.label,
|
|
334
|
-
columns: t.columns ?? (t.appearance === "card" ? 2 : 1),
|
|
335
|
-
children: t.options.map((e) => /* @__PURE__ */ O(Se, {
|
|
336
|
-
field: t,
|
|
337
|
-
option: e,
|
|
338
|
-
name: a.id,
|
|
339
|
-
checked: c.includes(e.value),
|
|
340
|
-
isDisabled: r,
|
|
341
|
-
invalid: a["aria-invalid"],
|
|
342
|
-
onChange: () => {
|
|
343
|
-
o(s ? c.includes(e.value) ? c.filter((t) => t !== e.value) : [...c, e.value] : e.value);
|
|
344
|
-
}
|
|
345
|
-
}, e.value))
|
|
346
|
-
}), !s && !i && c.length > 0 && /* @__PURE__ */ k(e, {
|
|
347
|
-
variant: "simple",
|
|
348
|
-
size: "sm",
|
|
349
|
-
isDisabled: r,
|
|
350
|
-
onClick: () => o(void 0),
|
|
351
|
-
children: ["Clear ", t.label]
|
|
352
|
-
})] });
|
|
353
|
-
}
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region src/components/FormEditor/additional-control.tsx
|
|
356
|
-
function we({ field: e, stored: t, isDisabled: n, accessibility: r, onChange: i }) {
|
|
357
|
-
let a = y(e), o = X(t, a);
|
|
358
|
-
return /* @__PURE__ */ O(b, {
|
|
359
|
-
...r,
|
|
360
|
-
...a,
|
|
361
|
-
prefix: e.prefix,
|
|
362
|
-
suffix: e.suffix,
|
|
363
|
-
hasValueLabel: e.hasValueLabel,
|
|
364
|
-
valueText: o === void 0 ? e.placeholder ?? "Not set" : void 0,
|
|
365
|
-
autoFocus: e.autoFocus,
|
|
366
|
-
isDisabled: n,
|
|
367
|
-
value: o ?? a.min,
|
|
368
|
-
onValueChange: i,
|
|
369
|
-
onValueCommit: (e) => {
|
|
370
|
-
o === void 0 && i(e);
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
function Te({ field: e, stored: t, isDisabled: n, accessibility: r, onChange: i }) {
|
|
375
|
-
let a = y(e), o = _e(t, a);
|
|
376
|
-
return /* @__PURE__ */ O(S, {
|
|
377
|
-
...r,
|
|
378
|
-
...a,
|
|
379
|
-
prefix: e.prefix,
|
|
380
|
-
suffix: e.suffix,
|
|
381
|
-
hasValueLabel: e.hasValueLabel,
|
|
382
|
-
minLabel: `${e.label} minimum`,
|
|
383
|
-
maxLabel: `${e.label} maximum`,
|
|
384
|
-
isDisabled: n,
|
|
385
|
-
valueText: o === void 0 ? e.placeholder ?? "Not set" : void 0,
|
|
386
|
-
hasFill: o !== void 0,
|
|
387
|
-
value: o ?? {
|
|
388
|
-
min: a.min,
|
|
389
|
-
max: a.max
|
|
390
|
-
},
|
|
391
|
-
onValueChange: i,
|
|
392
|
-
onValueCommit: (e) => {
|
|
393
|
-
o === void 0 && i(e);
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
function Ee({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
|
|
398
|
-
let o = {
|
|
399
|
-
stored: t,
|
|
400
|
-
isDisabled: n,
|
|
401
|
-
required: r,
|
|
402
|
-
accessibility: i,
|
|
403
|
-
onChange: a
|
|
404
|
-
};
|
|
405
|
-
switch (e.type) {
|
|
406
|
-
case "radioGroup":
|
|
407
|
-
case "checkboxGroup": return /* @__PURE__ */ O(Ce, {
|
|
408
|
-
field: e,
|
|
409
|
-
...o
|
|
410
|
-
});
|
|
411
|
-
case "rangeSlider": return /* @__PURE__ */ O(Te, {
|
|
412
|
-
field: e,
|
|
413
|
-
...o
|
|
414
|
-
});
|
|
415
|
-
case "slider": return /* @__PURE__ */ O(we, {
|
|
416
|
-
field: e,
|
|
417
|
-
...o
|
|
418
|
-
});
|
|
419
|
-
case "colour": return /* @__PURE__ */ O(C, {
|
|
420
|
-
...i,
|
|
421
|
-
required: r,
|
|
422
|
-
placeholder: e.placeholder,
|
|
423
|
-
presets: e.presets,
|
|
424
|
-
showPresets: e.showPresets,
|
|
425
|
-
picker: e.picker,
|
|
426
|
-
placement: e.placement,
|
|
427
|
-
readOnly: e.readOnly,
|
|
428
|
-
autoFocus: e.autoFocus,
|
|
429
|
-
isDisabled: n,
|
|
430
|
-
value: typeof t == "string" ? t : "",
|
|
431
|
-
onInput: (e) => {
|
|
432
|
-
let t = e.currentTarget.value;
|
|
433
|
-
t.trim() && !v(t) && a(t);
|
|
434
|
-
},
|
|
435
|
-
onValueChange: (e) => a(e === "" ? void 0 : e)
|
|
436
|
-
});
|
|
437
|
-
case "tags": return /* @__PURE__ */ O(ne, {
|
|
438
|
-
...i,
|
|
439
|
-
required: r,
|
|
440
|
-
placeholder: e.placeholder,
|
|
441
|
-
max: e.max,
|
|
442
|
-
isDisabled: n,
|
|
443
|
-
value: q(t),
|
|
444
|
-
onValueChange: a
|
|
445
|
-
});
|
|
446
|
-
case "date": return /* @__PURE__ */ O(te, {
|
|
447
|
-
...i,
|
|
448
|
-
placeholder: e.placeholder,
|
|
449
|
-
min: e.min,
|
|
450
|
-
max: e.max,
|
|
451
|
-
placement: e.placement,
|
|
452
|
-
isDisabled: n,
|
|
453
|
-
isClearable: !0,
|
|
454
|
-
clearLabel: `Clear ${e.label}`,
|
|
455
|
-
value: typeof t == "string" ? t : "",
|
|
456
|
-
onValueChange: (e) => a(e === "" ? void 0 : e)
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
//#endregion
|
|
461
|
-
//#region src/components/FormEditor/control.tsx
|
|
462
|
-
function De(e, t) {
|
|
463
|
-
if (e.type === "asset") {
|
|
464
|
-
let n = t.map((e) => ({ assetId: e }));
|
|
465
|
-
return e.multiple ? n : n[0];
|
|
466
|
-
}
|
|
467
|
-
let n = t.map((e) => ({ entryId: e }));
|
|
468
|
-
return e.multiple ? n : n[0];
|
|
469
|
-
}
|
|
470
|
-
function $({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
|
|
471
|
-
return /* @__PURE__ */ O(h, {
|
|
472
|
-
...i,
|
|
473
|
-
required: r,
|
|
474
|
-
isDisabled: n,
|
|
475
|
-
placeholder: e.placeholder,
|
|
476
|
-
min: e.min,
|
|
477
|
-
max: e.max,
|
|
478
|
-
step: e.step ?? "any",
|
|
479
|
-
hasSteppers: e.hasSteppers,
|
|
480
|
-
prefix: e.prefix,
|
|
481
|
-
suffix: e.suffix,
|
|
482
|
-
autoFocus: e.autoFocus,
|
|
483
|
-
decreaseLabel: e.decreaseLabel ?? `Decrease ${e.label}`,
|
|
484
|
-
increaseLabel: e.increaseLabel ?? `Increase ${e.label}`,
|
|
485
|
-
value: typeof t == "number" && Number.isFinite(t) ? t : "",
|
|
486
|
-
onValueChange: (e) => {
|
|
487
|
-
(e === "" || Number.isFinite(e)) && a(e === "" ? void 0 : e);
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
function Oe({ field: e, stored: t, isDisabled: n, required: r, accessibility: i, onChange: a }) {
|
|
492
|
-
let o = !r && !e.options.some((e) => e.value === "");
|
|
493
|
-
return /* @__PURE__ */ O(g, {
|
|
494
|
-
...i,
|
|
495
|
-
"aria-required": r || void 0,
|
|
496
|
-
isDisabled: n,
|
|
497
|
-
isInvalid: i["aria-invalid"],
|
|
498
|
-
options: o ? [{
|
|
499
|
-
value: "",
|
|
500
|
-
label: e.placeholder ?? "None"
|
|
501
|
-
}, ...e.options] : e.options,
|
|
502
|
-
placeholder: e.placeholder,
|
|
503
|
-
autoFocus: e.autoFocus,
|
|
504
|
-
value: typeof t == "string" ? t : "",
|
|
505
|
-
onValueChange: (e) => a(e === "" ? void 0 : e)
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
function ke({ field: e, selected: t, items: n, source: r, isDisabled: i, accessibility: a, onChange: o }) {
|
|
509
|
-
return /* @__PURE__ */ O(p, {
|
|
510
|
-
...a,
|
|
511
|
-
...r,
|
|
512
|
-
items: n,
|
|
513
|
-
value: t,
|
|
514
|
-
...B(e),
|
|
515
|
-
...N(e, r),
|
|
516
|
-
isDisabled: i,
|
|
517
|
-
onValueChange: (t) => o(De(e, t))
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
function Ae({ embeds: e, field: t, stored: i, selected: s, items: c, source: l, isDisabled: u, accessibility: { required: d, ...f }, onChange: p }) {
|
|
521
|
-
let m = {
|
|
522
|
-
stored: i,
|
|
523
|
-
isDisabled: u,
|
|
524
|
-
required: d,
|
|
525
|
-
accessibility: f,
|
|
526
|
-
onChange: p
|
|
527
|
-
};
|
|
528
|
-
switch (t.type) {
|
|
529
|
-
case "shortText": return /* @__PURE__ */ O(r, {
|
|
530
|
-
...f,
|
|
531
|
-
required: d,
|
|
532
|
-
disabled: u,
|
|
533
|
-
placeholder: t.placeholder,
|
|
534
|
-
type: t.inputType,
|
|
535
|
-
maxLength: t.maxLength,
|
|
536
|
-
readOnly: t.readOnly,
|
|
537
|
-
autoFocus: t.autoFocus,
|
|
538
|
-
value: M(i),
|
|
539
|
-
onChange: (e) => p(e.target.value)
|
|
540
|
-
});
|
|
541
|
-
case "longText": return /* @__PURE__ */ O(n, {
|
|
542
|
-
...f,
|
|
543
|
-
required: d,
|
|
544
|
-
disabled: u,
|
|
545
|
-
placeholder: t.placeholder,
|
|
546
|
-
rows: t.rows,
|
|
547
|
-
maxLength: t.maxLength,
|
|
548
|
-
readOnly: t.readOnly,
|
|
549
|
-
autoFocus: t.autoFocus,
|
|
550
|
-
value: M(i),
|
|
551
|
-
onChange: (e) => p(e.target.value)
|
|
552
|
-
});
|
|
553
|
-
case "number": return /* @__PURE__ */ O($, {
|
|
554
|
-
field: t,
|
|
555
|
-
...m
|
|
556
|
-
});
|
|
557
|
-
case "boolean": return /* @__PURE__ */ O(_, {
|
|
558
|
-
...f,
|
|
559
|
-
isDisabled: u,
|
|
560
|
-
autoFocus: t.autoFocus,
|
|
561
|
-
isSelected: i === !0,
|
|
562
|
-
onSelectedChange: p
|
|
563
|
-
});
|
|
564
|
-
case "dateTime": return /* @__PURE__ */ O(r, {
|
|
565
|
-
...f,
|
|
566
|
-
required: d,
|
|
567
|
-
disabled: u,
|
|
568
|
-
type: "datetime-local",
|
|
569
|
-
step: "0.001",
|
|
570
|
-
autoFocus: t.autoFocus,
|
|
571
|
-
value: V(i)?.slice(0, -1) ?? "",
|
|
572
|
-
onChange: (e) => p(V(`${e.target.value}Z`))
|
|
573
|
-
});
|
|
574
|
-
case "richText": return /* @__PURE__ */ O(o, {
|
|
575
|
-
...f,
|
|
576
|
-
expandedWidth: t.expandedWidth,
|
|
577
|
-
embeds: e,
|
|
578
|
-
label: t.label,
|
|
579
|
-
isRequired: d,
|
|
580
|
-
isDisabled: u,
|
|
581
|
-
placeholder: t.placeholder,
|
|
582
|
-
format: "json",
|
|
583
|
-
value: i === void 0 ? a : i,
|
|
584
|
-
onChange: p
|
|
585
|
-
});
|
|
586
|
-
case "select": return /* @__PURE__ */ O(Oe, {
|
|
587
|
-
field: t,
|
|
588
|
-
...m
|
|
589
|
-
});
|
|
590
|
-
case "asset":
|
|
591
|
-
case "reference": return /* @__PURE__ */ O(ke, {
|
|
592
|
-
field: t,
|
|
593
|
-
items: c,
|
|
594
|
-
source: l,
|
|
595
|
-
selected: s ?? [],
|
|
596
|
-
...m
|
|
597
|
-
});
|
|
598
|
-
default: return /* @__PURE__ */ O(Ee, {
|
|
599
|
-
field: t,
|
|
600
|
-
...m
|
|
601
|
-
});
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
//#endregion
|
|
605
|
-
//#region src/components/FormEditor/index.tsx
|
|
606
|
-
function je({ field: e, stored: n, items: r, source: i, embeds: a, isDisabled: o, error: s, isErrorVisible: c, onChange: l }) {
|
|
607
|
-
let u = T(() => s === void 0 && c ? Q(e, n) : void 0, [
|
|
608
|
-
s,
|
|
609
|
-
c,
|
|
610
|
-
e,
|
|
611
|
-
n
|
|
612
|
-
]), d = T(() => e.type === "asset" || e.type === "reference" ? me(e, n) : void 0, [e, n]);
|
|
613
|
-
return /* @__PURE__ */ O(f, {
|
|
614
|
-
width: e.width,
|
|
615
|
-
padded: !1,
|
|
616
|
-
center: !1,
|
|
617
|
-
className: "ds-form-editor__field",
|
|
618
|
-
children: /* @__PURE__ */ O(t, {
|
|
619
|
-
...de(e, n, d, i),
|
|
620
|
-
label: e.type === "dateTime" ? `${e.label} (UTC)` : z(e),
|
|
621
|
-
hint: e.hint,
|
|
622
|
-
error: s ?? u,
|
|
623
|
-
isRequired: e.required,
|
|
624
|
-
count: pe(e, n, d, i),
|
|
625
|
-
isGroup: d !== void 0 || Me.has(e.type),
|
|
626
|
-
children: (t) => /* @__PURE__ */ O(Ae, {
|
|
627
|
-
field: e,
|
|
628
|
-
stored: n,
|
|
629
|
-
selected: d,
|
|
630
|
-
items: r,
|
|
631
|
-
source: i,
|
|
632
|
-
embeds: a,
|
|
633
|
-
isDisabled: o,
|
|
634
|
-
accessibility: t,
|
|
635
|
-
onChange: l
|
|
636
|
-
})
|
|
637
|
-
})
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
var Me = /* @__PURE__ */ new Set([
|
|
641
|
-
"radioGroup",
|
|
642
|
-
"checkboxGroup",
|
|
643
|
-
"rangeSlider"
|
|
644
|
-
]), Ne = /* @__PURE__ */ new Set([
|
|
645
|
-
"slider",
|
|
646
|
-
"rangeSlider",
|
|
647
|
-
"date",
|
|
648
|
-
"colour"
|
|
649
|
-
]);
|
|
650
|
-
function Pe({ schema: e, value: t, defaultValue: n = {}, onValueChange: r, pickerItems: i = {}, pickerSources: a = {}, embedSources: o = {}, errors: s = {}, isDisabled: c = !1, showAllErrors: l = !1, columns: u = 1, minColumnWidth: d = "16rem", className: f, style: p, ...m }) {
|
|
651
|
-
let [h, g] = E(n), [_, v] = E(() => /* @__PURE__ */ new Set()), y = t ?? h;
|
|
652
|
-
T(() => A(e), [e]);
|
|
653
|
-
let b = (e, n) => {
|
|
654
|
-
let i = { ...y };
|
|
655
|
-
n === void 0 ? delete i[e] : i[e] = n, t === void 0 && g(i), v((t) => new Set(t).add(e)), r?.(i, { fieldId: e });
|
|
656
|
-
}, x = u === "auto" ? { "--form-editor-min-column": d } : {
|
|
657
|
-
"--form-editor-columns": u,
|
|
658
|
-
"--form-editor-min-column": d
|
|
659
|
-
};
|
|
660
|
-
return /* @__PURE__ */ O("div", {
|
|
661
|
-
className: [
|
|
662
|
-
"ds-form-editor",
|
|
663
|
-
u === "auto" && "ds-form-editor--auto",
|
|
664
|
-
f
|
|
665
|
-
].filter(Boolean).join(" "),
|
|
666
|
-
style: {
|
|
667
|
-
...x,
|
|
668
|
-
...p
|
|
669
|
-
},
|
|
670
|
-
...m,
|
|
671
|
-
children: e.fields.map((e) => {
|
|
672
|
-
if (e.type === "divider") return /* @__PURE__ */ O("hr", { className: "ds-form-editor__divider" }, e.id);
|
|
673
|
-
let t = Object.hasOwn(y, e.id) ? y[e.id] : void 0, n = c || !!e.isDisabled, r = n || "readOnly" in e && !!e.readOnly, u = typeof t == "string" ? t.trim() !== "" : t !== void 0, d = l || _.has(e.id) || u && Ne.has(e.type) || e.type === "number" && typeof t == "number";
|
|
674
|
-
return /* @__PURE__ */ O(je, {
|
|
675
|
-
field: e,
|
|
676
|
-
stored: t,
|
|
677
|
-
items: i[e.id] ?? [],
|
|
678
|
-
source: a[e.id],
|
|
679
|
-
embeds: o[e.id],
|
|
680
|
-
isDisabled: n,
|
|
681
|
-
error: s[e.id],
|
|
682
|
-
isErrorVisible: d,
|
|
683
|
-
onChange: (t) => {
|
|
684
|
-
(!r || e.type === "richText" && (o[e.id]?.entry?.isCreating || o[e.id]?.asset?.isCreating)) && b(e.id, t);
|
|
685
|
-
}
|
|
686
|
-
}, e.id);
|
|
687
|
-
})
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
//#endregion
|
|
691
|
-
export { xe as n, Pe as t };
|
|
692
|
-
|
|
693
|
-
//# sourceMappingURL=FormEditor-ChH4e5sB.js.map
|