@namroodinc/liquid-editorial 0.10.0 → 0.10.2

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.
Files changed (171) hide show
  1. package/README.md +10 -0
  2. package/UPGRADING.md +54 -0
  3. package/dist/chunks/{Board-B8wK079I.js → Board-Cnyqrc-R.js} +2 -2
  4. package/dist/chunks/{Board-B8wK079I.js.map → Board-Cnyqrc-R.js.map} +1 -1
  5. package/dist/chunks/{Board-CMf5Azt0.cjs → Board-DFuJt2Oh.cjs} +2 -2
  6. package/dist/chunks/{Board-CMf5Azt0.cjs.map → Board-DFuJt2Oh.cjs.map} +1 -1
  7. package/dist/chunks/{ColourField-C1qjpIfB.cjs → ColourField-B03ejnGS.cjs} +2 -2
  8. package/dist/chunks/{ColourField-C1qjpIfB.cjs.map → ColourField-B03ejnGS.cjs.map} +1 -1
  9. package/dist/chunks/{ColourField-Ce2oaVcd.js → ColourField-D17gkytm.js} +6 -6
  10. package/dist/chunks/{ColourField-Ce2oaVcd.js.map → ColourField-D17gkytm.js.map} +1 -1
  11. package/dist/chunks/{DatePicker-CnVmsCwO.js → DatePicker-0uvnuiye.js} +21 -21
  12. package/dist/chunks/{DatePicker-CnVmsCwO.js.map → DatePicker-0uvnuiye.js.map} +1 -1
  13. package/dist/chunks/{DatePicker-BCnzFJFF.cjs → DatePicker-CVaefhfS.cjs} +2 -2
  14. package/dist/chunks/{DatePicker-BCnzFJFF.cjs.map → DatePicker-CVaefhfS.cjs.map} +1 -1
  15. package/dist/chunks/EntryPicker-CiS8zT64.cjs +2 -0
  16. package/dist/chunks/EntryPicker-CiS8zT64.cjs.map +1 -0
  17. package/dist/chunks/EntryPicker-LWwX_EzL.js +160 -0
  18. package/dist/chunks/EntryPicker-LWwX_EzL.js.map +1 -0
  19. package/dist/chunks/FormEditor-BZ_4nxIG.cjs +2 -0
  20. package/dist/chunks/FormEditor-BZ_4nxIG.cjs.map +1 -0
  21. package/dist/chunks/{FormEditor-BEOp5EW-.js → FormEditor-IKdPwVPx.js} +112 -108
  22. package/dist/chunks/FormEditor-IKdPwVPx.js.map +1 -0
  23. package/dist/chunks/Icon-CD3oeiNA.cjs +2 -0
  24. package/dist/chunks/Icon-CD3oeiNA.cjs.map +1 -0
  25. package/dist/chunks/Icon-CYXOo0Kt.js +88 -0
  26. package/dist/chunks/Icon-CYXOo0Kt.js.map +1 -0
  27. package/dist/chunks/{Message-CaX8Y1Xb.js → Message-CyLq9ef-.js} +2 -2
  28. package/dist/chunks/{Message-CaX8Y1Xb.js.map → Message-CyLq9ef-.js.map} +1 -1
  29. package/dist/chunks/{Message-DU31JAb3.cjs → Message-D3b8HDhm.cjs} +2 -2
  30. package/dist/chunks/{Message-DU31JAb3.cjs.map → Message-D3b8HDhm.cjs.map} +1 -1
  31. package/dist/chunks/{NumberField-Ccjpa_1d.cjs → NumberField-BrWFmPkW.cjs} +2 -2
  32. package/dist/chunks/{NumberField-Ccjpa_1d.cjs.map → NumberField-BrWFmPkW.cjs.map} +1 -1
  33. package/dist/chunks/{NumberField-CVsK4l9P.js → NumberField-C90eJGny.js} +13 -13
  34. package/dist/chunks/{NumberField-CVsK4l9P.js.map → NumberField-C90eJGny.js.map} +1 -1
  35. package/dist/chunks/RichTextEditor-CwoHE-AN.js +1034 -0
  36. package/dist/chunks/RichTextEditor-CwoHE-AN.js.map +1 -0
  37. package/dist/chunks/RichTextEditor-DMrxJhA6.cjs +2 -0
  38. package/dist/chunks/RichTextEditor-DMrxJhA6.cjs.map +1 -0
  39. package/dist/chunks/use-picker-session-BLH1tXk3.js +712 -0
  40. package/dist/chunks/use-picker-session-BLH1tXk3.js.map +1 -0
  41. package/dist/chunks/use-picker-session-tRDYUd_d.cjs +2 -0
  42. package/dist/chunks/use-picker-session-tRDYUd_d.cjs.map +1 -0
  43. package/dist/components/AssetCard/index.cjs +1 -1
  44. package/dist/components/AssetCard/index.js +1 -1
  45. package/dist/components/AssetGrid/index.cjs +1 -1
  46. package/dist/components/AssetGrid/index.js +1 -1
  47. package/dist/components/Banner/index.cjs +1 -1
  48. package/dist/components/Banner/index.js +1 -1
  49. package/dist/components/Board/index.cjs +1 -1
  50. package/dist/components/Board/index.js +1 -1
  51. package/dist/components/Button/index.cjs +1 -1
  52. package/dist/components/Button/index.js +1 -1
  53. package/dist/components/ColourField/index.cjs +1 -1
  54. package/dist/components/ColourField/index.js +1 -1
  55. package/dist/components/DatePicker/index.cjs +1 -1
  56. package/dist/components/DatePicker/index.js +1 -1
  57. package/dist/components/EditLayout/index.cjs +1 -1
  58. package/dist/components/EditLayout/index.js +1 -1
  59. package/dist/components/EntryPicker/index.cjs +1 -1
  60. package/dist/components/EntryPicker/index.d.cts.map +1 -1
  61. package/dist/components/EntryPicker/index.d.ts.map +1 -1
  62. package/dist/components/EntryPicker/index.js +1 -1
  63. package/dist/components/EntryPicker/item.d.cts +3 -1
  64. package/dist/components/EntryPicker/item.d.cts.map +1 -1
  65. package/dist/components/EntryPicker/item.d.ts +3 -1
  66. package/dist/components/EntryPicker/item.d.ts.map +1 -1
  67. package/dist/components/EntryPicker/style.css +0 -4
  68. package/dist/components/EntryPicker/use-picker-session.d.cts +110 -0
  69. package/dist/components/EntryPicker/use-picker-session.d.cts.map +1 -0
  70. package/dist/components/EntryPicker/use-picker-session.d.ts +110 -0
  71. package/dist/components/EntryPicker/use-picker-session.d.ts.map +1 -0
  72. package/dist/components/EntryPicker/use-selected-items.d.cts +9 -2
  73. package/dist/components/EntryPicker/use-selected-items.d.cts.map +1 -1
  74. package/dist/components/EntryPicker/use-selected-items.d.ts +9 -2
  75. package/dist/components/EntryPicker/use-selected-items.d.ts.map +1 -1
  76. package/dist/components/FormEditor/README.md +106 -0
  77. package/dist/components/FormEditor/control.d.cts +3 -1
  78. package/dist/components/FormEditor/control.d.cts.map +1 -1
  79. package/dist/components/FormEditor/control.d.ts +3 -1
  80. package/dist/components/FormEditor/control.d.ts.map +1 -1
  81. package/dist/components/FormEditor/index.cjs +1 -1
  82. package/dist/components/FormEditor/index.d.cts +3 -1
  83. package/dist/components/FormEditor/index.d.cts.map +1 -1
  84. package/dist/components/FormEditor/index.d.ts +3 -1
  85. package/dist/components/FormEditor/index.d.ts.map +1 -1
  86. package/dist/components/FormEditor/index.js +1 -1
  87. package/dist/components/FormEditor/model.d.cts.map +1 -1
  88. package/dist/components/FormEditor/model.d.ts.map +1 -1
  89. package/dist/components/Icon/icons.d.cts +3 -0
  90. package/dist/components/Icon/icons.d.cts.map +1 -1
  91. package/dist/components/Icon/icons.d.ts +3 -0
  92. package/dist/components/Icon/icons.d.ts.map +1 -1
  93. package/dist/components/Icon/index.cjs +1 -1
  94. package/dist/components/Icon/index.js +1 -1
  95. package/dist/components/NumberField/index.cjs +1 -1
  96. package/dist/components/NumberField/index.js +1 -1
  97. package/dist/components/RichTextEditor/document.d.cts +7 -1
  98. package/dist/components/RichTextEditor/document.d.cts.map +1 -1
  99. package/dist/components/RichTextEditor/document.d.ts +7 -1
  100. package/dist/components/RichTextEditor/document.d.ts.map +1 -1
  101. package/dist/components/RichTextEditor/embed-context.d.cts +36 -0
  102. package/dist/components/RichTextEditor/embed-context.d.cts.map +1 -0
  103. package/dist/components/RichTextEditor/embed-context.d.ts +36 -0
  104. package/dist/components/RichTextEditor/embed-context.d.ts.map +1 -0
  105. package/dist/components/RichTextEditor/embed-types.d.cts +27 -0
  106. package/dist/components/RichTextEditor/embed-types.d.cts.map +1 -0
  107. package/dist/components/RichTextEditor/embed-types.d.ts +27 -0
  108. package/dist/components/RichTextEditor/embed-types.d.ts.map +1 -0
  109. package/dist/components/RichTextEditor/expansion.d.cts +6 -1
  110. package/dist/components/RichTextEditor/expansion.d.cts.map +1 -1
  111. package/dist/components/RichTextEditor/expansion.d.ts +6 -1
  112. package/dist/components/RichTextEditor/expansion.d.ts.map +1 -1
  113. package/dist/components/RichTextEditor/index.cjs +1 -1
  114. package/dist/components/RichTextEditor/index.d.cts +4 -0
  115. package/dist/components/RichTextEditor/index.d.cts.map +1 -1
  116. package/dist/components/RichTextEditor/index.d.ts +4 -0
  117. package/dist/components/RichTextEditor/index.d.ts.map +1 -1
  118. package/dist/components/RichTextEditor/index.js +1 -1
  119. package/dist/components/RichTextEditor/storyblock-view.d.cts +3 -0
  120. package/dist/components/RichTextEditor/storyblock-view.d.cts.map +1 -0
  121. package/dist/components/RichTextEditor/storyblock-view.d.ts +3 -0
  122. package/dist/components/RichTextEditor/storyblock-view.d.ts.map +1 -0
  123. package/dist/components/RichTextEditor/storyblock.d.cts +19 -0
  124. package/dist/components/RichTextEditor/storyblock.d.cts.map +1 -0
  125. package/dist/components/RichTextEditor/storyblock.d.ts +19 -0
  126. package/dist/components/RichTextEditor/storyblock.d.ts.map +1 -0
  127. package/dist/components/RichTextEditor/style.css +92 -0
  128. package/dist/components/RichTextEditor/use-embeds.d.cts +31 -0
  129. package/dist/components/RichTextEditor/use-embeds.d.cts.map +1 -0
  130. package/dist/components/RichTextEditor/use-embeds.d.ts +31 -0
  131. package/dist/components/RichTextEditor/use-embeds.d.ts.map +1 -0
  132. package/dist/components/SearchField/index.cjs +1 -1
  133. package/dist/components/SearchField/index.js +1 -1
  134. package/dist/components/Select/index.cjs +1 -1
  135. package/dist/components/Select/index.js +1 -1
  136. package/dist/components/SideNav/index.cjs +1 -1
  137. package/dist/components/SideNav/index.js +1 -1
  138. package/dist/components/SortableList/index.cjs +1 -1
  139. package/dist/components/SortableList/index.js +1 -1
  140. package/dist/components/Stepper/index.cjs +1 -1
  141. package/dist/components/Stepper/index.js +1 -1
  142. package/dist/components/SubNav/index.cjs +1 -1
  143. package/dist/components/SubNav/index.js +1 -1
  144. package/dist/components/Table/index.cjs +1 -1
  145. package/dist/components/Table/index.js +1 -1
  146. package/dist/components/Toast/index.cjs +1 -1
  147. package/dist/components/Toast/index.js +1 -1
  148. package/dist/components/TopNav/index.cjs +1 -1
  149. package/dist/components/TopNav/index.js +1 -1
  150. package/dist/index.cjs +1 -1
  151. package/dist/index.d.cts +1 -1
  152. package/dist/index.d.cts.map +1 -1
  153. package/dist/index.d.ts +1 -1
  154. package/dist/index.d.ts.map +1 -1
  155. package/dist/index.js +18 -18
  156. package/package.json +1 -1
  157. package/dist/chunks/EntryPicker-BhApdZtE.cjs +0 -2
  158. package/dist/chunks/EntryPicker-BhApdZtE.cjs.map +0 -1
  159. package/dist/chunks/EntryPicker-LBj_56_e.js +0 -803
  160. package/dist/chunks/EntryPicker-LBj_56_e.js.map +0 -1
  161. package/dist/chunks/FormEditor-B5A38LZ4.cjs +0 -2
  162. package/dist/chunks/FormEditor-B5A38LZ4.cjs.map +0 -1
  163. package/dist/chunks/FormEditor-BEOp5EW-.js.map +0 -1
  164. package/dist/chunks/Icon-WOhlu6Rp.cjs +0 -2
  165. package/dist/chunks/Icon-WOhlu6Rp.cjs.map +0 -1
  166. package/dist/chunks/Icon-spaFBU4S.js +0 -85
  167. package/dist/chunks/Icon-spaFBU4S.js.map +0 -1
  168. package/dist/chunks/RichTextEditor-CuZnjiy2.js +0 -483
  169. package/dist/chunks/RichTextEditor-CuZnjiy2.js.map +0 -1
  170. package/dist/chunks/RichTextEditor-DcbLho2Q.cjs +0 -2
  171. package/dist/chunks/RichTextEditor-DcbLho2Q.cjs.map +0 -1
@@ -1,803 +0,0 @@
1
- import { t as e } from "./Icon-spaFBU4S.js";
2
- import { Button as t } from "../components/Button/index.js";
3
- import { d as n, h as r, u as i } from "./overlayLayer-IuoPVwTO.js";
4
- import { Badge as a } from "../components/Badge/index.js";
5
- import { r as o } from "./limit-s9zfxIMC.js";
6
- import { LimitReading as s } from "../components/LimitReading/index.js";
7
- import { Modal as c } from "../components/Modal/index.js";
8
- import { t as l } from "./group-7Z_xRlQx.js";
9
- import { n as u, r as d, t as f } from "./LoadState-B056EPu7.js";
10
- import { SearchField as p } from "../components/SearchField/index.js";
11
- import { Checkbox as m } from "../components/Choice/index.js";
12
- import { SortableList as h, SortableListItem as g } from "../components/SortableList/index.js";
13
- import { useEffect as _, useId as v, useMemo as y, useRef as b, useState as x } from "react";
14
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
15
- //#region src/components/EntryPicker/blocked.ts
16
- function T(e, t, { isDisabled: n, searching: r, atMax: i }) {
17
- if (n || r) return "inactive";
18
- if (e.isDisabled) return "restricted";
19
- if (!t && i) return "full";
20
- }
21
- //#endregion
22
- //#region src/components/EntryPicker/feedback.tsx
23
- function E(e, t, n, r) {
24
- let i = u(t, n, r);
25
- return t !== "error" && i.state !== "pending" ? null : /* @__PURE__ */ C(d, {
26
- title: e,
27
- error: i.error,
28
- onRetry: i.retry,
29
- retryState: i.state
30
- });
31
- }
32
- function D({ query: e, itemLabel: t, itemsLabel: n, canCreate: r }) {
33
- let i = e.trim();
34
- return /* @__PURE__ */ w("div", {
35
- className: "ds-entry-picker__no-results",
36
- children: [/* @__PURE__ */ C("p", { children: i ? `No ${n} match “${i}”` : `No ${n} yet` }), i && /* @__PURE__ */ w("p", { children: ["Try a different search.", r ? ` Or create the ${t} you need.` : ""] })]
37
- });
38
- }
39
- function O(e, t) {
40
- let n = e.closest(".ds-entry-picker__scroll") ?? e.parentElement, i = Array.from(n?.querySelectorAll(".ds-entry-picker__result") ?? []);
41
- for (let e of [...i.slice(t), ...i.slice(0, t).reverse()]) {
42
- let t = r(e)[0];
43
- if (t) return t;
44
- }
45
- }
46
- function k(e) {
47
- let t = b(null), i = b(null), { more: a, offset: o } = e;
48
- return _(() => {
49
- let e = i.current, o = t.current;
50
- e !== null && a.status !== "loading" && (i.current = null, o && n(document.activeElement) && (a.status === "error" ? r(o)[0] : O(o, e))?.focus());
51
- }, [a.status, o]), {
52
- pagingRef: t,
53
- load: () => {
54
- i.current = t.current?.contains(document.activeElement) ? o : null, a.load();
55
- }
56
- };
57
- }
58
- function A(e, t) {
59
- let i = b(t);
60
- _(() => {
61
- if (i.current === t) return;
62
- i.current = t;
63
- let a = e.current;
64
- a && n(document.activeElement) && (r(a)[0] ?? O(a, Infinity))?.focus();
65
- }, [e, t]);
66
- }
67
- function j({ count: e, total: n, isRemote: r, pageSize: i, remote: a, itemsLabel: o }) {
68
- let { more: s } = a, { pagingRef: c, load: l } = k(a), u = E(`Couldn't load more ${o}`, s.status, s.error, l);
69
- return A(c, u ? "failure" : r && a.hasMore ? "more" : "none"), n === 0 ? null : /* @__PURE__ */ w("div", {
70
- ref: c,
71
- className: "ds-entry-picker__paging",
72
- children: [u ?? (r && a.hasMore && /* @__PURE__ */ w(t, {
73
- isPending: s.status === "loading",
74
- isFocusableWhenDisabled: !0,
75
- isDisabled: !s.isAvailable,
76
- onClick: l,
77
- children: [
78
- "Load ",
79
- Math.min(i, n - a.offset),
80
- " more"
81
- ]
82
- })), /* @__PURE__ */ C("span", { children: e < n ? `Showing ${e} of ${n}` : `All ${e} shown` })]
83
- });
84
- }
85
- //#endregion
86
- //#region src/components/EntryPicker/item.tsx
87
- function M(e) {
88
- return e.isDisabled ? e.disabledReason : void 0;
89
- }
90
- function N(e) {
91
- return e.tone === "removed";
92
- }
93
- function P(e) {
94
- return N(e) ? void 0 : M(e);
95
- }
96
- function F({ item: t, reasonId: n }) {
97
- let r = M(t);
98
- return /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("span", {
99
- className: "ds-entry__thumb",
100
- children: t.imageUrl ? /* @__PURE__ */ C("img", {
101
- src: t.imageUrl,
102
- alt: "",
103
- loading: "lazy"
104
- }) : /* @__PURE__ */ C(e, {
105
- name: "file-text",
106
- size: 20
107
- })
108
- }), /* @__PURE__ */ w("span", {
109
- className: "ds-entry__body",
110
- children: [
111
- /* @__PURE__ */ C("span", {
112
- className: "ds-entry__title",
113
- "data-unavailable": t.isUnavailable || void 0,
114
- children: t.title
115
- }),
116
- t.metadata != null && /* @__PURE__ */ C("span", {
117
- className: "ds-entry__meta",
118
- children: t.metadata
119
- }),
120
- r && /* @__PURE__ */ w("span", {
121
- id: n,
122
- className: "ds-entry__reason",
123
- children: [
124
- /* @__PURE__ */ C(a, {
125
- shape: "tag",
126
- size: "sm",
127
- children: r.label
128
- }),
129
- " ",
130
- /* @__PURE__ */ C("span", { children: r.description })
131
- ]
132
- })
133
- ]
134
- })] });
135
- }
136
- function I({ item: e, reasonId: t }) {
137
- return N(e) ? /* @__PURE__ */ w("span", {
138
- className: "ds-entry__removed",
139
- children: [
140
- /* @__PURE__ */ C("strong", { children: e.title }),
141
- " ",
142
- e.metadata ?? /* @__PURE__ */ C("code", { children: e.id })
143
- ]
144
- }) : /* @__PURE__ */ C(F, {
145
- item: e,
146
- reasonId: t
147
- });
148
- }
149
- function L({ item: e }) {
150
- return N(e) ? /* @__PURE__ */ C(a, {
151
- shape: "tag",
152
- children: e.removedLabel ?? "Removed on save"
153
- }) : null;
154
- }
155
- function R({ item: e, onEdit: n, isDisabled: r }) {
156
- return !n || e.isUnavailable || e.isDisabled ? null : /* @__PURE__ */ C(t, {
157
- variant: "simple",
158
- size: "sm",
159
- isIconOnly: !0,
160
- iconStart: "pencil",
161
- "aria-label": `Edit ${e.title}`,
162
- isDisabled: r,
163
- onClick: () => n(e)
164
- });
165
- }
166
- //#endregion
167
- //#region src/components/EntryPicker/results.tsx
168
- function ee({ items: e, selected: t, block: n, onToggle: r, onEdit: i }) {
169
- let a = v(), o = `${a}-full`;
170
- return /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("span", {
171
- id: o,
172
- hidden: !0,
173
- children: "The selection is full. Remove one to choose another."
174
- }), /* @__PURE__ */ C("ul", {
175
- className: "ds-entry-picker__results",
176
- "data-searching": n.searching || void 0,
177
- children: e.map((e, s) => {
178
- let c = t.includes(e.id), l = T(e, c, n), u = M(e) ? `${a}-reason-${s}` : void 0;
179
- return /* @__PURE__ */ w("li", {
180
- className: "ds-entry-picker__result",
181
- "data-selected": c || void 0,
182
- "data-blocked": l ? !0 : void 0,
183
- onClick: (t) => {
184
- let n = t.target instanceof Element ? t.target.closest("button, input, label, a, select, textarea, summary, [tabindex]") : null;
185
- (!n || !t.currentTarget.contains(n)) && r(e.id);
186
- },
187
- children: [
188
- /* @__PURE__ */ C(m, {
189
- checked: c,
190
- "aria-checked": c,
191
- "aria-label": `Select ${e.title}`,
192
- "aria-describedby": l === "full" ? o : u,
193
- disabled: !!l,
194
- isFocusableWhenDisabled: l !== "inactive",
195
- onChange: () => r(e.id)
196
- }),
197
- /* @__PURE__ */ C("span", {
198
- className: "ds-entry",
199
- children: /* @__PURE__ */ C(F, {
200
- item: e,
201
- reasonId: u
202
- })
203
- }),
204
- /* @__PURE__ */ C(R, {
205
- item: e,
206
- onEdit: i,
207
- isDisabled: l === "inactive"
208
- })
209
- ]
210
- }, e.id);
211
- })
212
- })] });
213
- }
214
- //#endregion
215
- //#region src/components/EntryPicker/use-picker-scroll.ts
216
- function z() {
217
- let e = b(null), [t, n] = x(!1);
218
- return {
219
- ref: e,
220
- scrolled: t,
221
- toTop: () => {
222
- n(!1), e.current && (e.current.scrollTop = 0);
223
- },
224
- onScroll: (e) => {
225
- n(e.currentTarget.scrollTop > 0);
226
- }
227
- };
228
- }
229
- //#endregion
230
- //#region src/components/EntryPicker/dialog.tsx
231
- function te({ isOpen: e, onClose: n, query: r, onQuery: i, selected: a, results: o, cap: l, block: u, isRemote: d, pageSize: p, remote: m, onToggle: h, onEdit: g, itemLabel: _, itemsLabel: v, addLabel: y, onCreate: b, isCreating: x, dialogTitle: T, dialogDescription: O, isDialogHidden: k }) {
232
- let A = E(`Couldn't refresh ${v}`, m.refresh.status, m.refresh.error, m.refresh.retry);
233
- return /* @__PURE__ */ C(c, {
234
- isOpen: e,
235
- isHidden: k,
236
- onClose: n,
237
- title: T ?? y,
238
- description: O ?? l.description,
239
- className: "ds-entry-picker__dialog",
240
- footer: /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("span", {
241
- className: "ds-entry-picker__selection",
242
- role: "status",
243
- children: l.reading ? /* @__PURE__ */ C(s, {
244
- ...l.reading,
245
- size: "lg"
246
- }) : `${a.length} selected`
247
- }), /* @__PURE__ */ C(t, {
248
- variant: "primary",
249
- onClick: n,
250
- children: "Done"
251
- })] }),
252
- children: /* @__PURE__ */ C(B, {
253
- query: r,
254
- onQuery: i,
255
- itemsLabel: v,
256
- isSearching: m.loading,
257
- action: b && /* @__PURE__ */ C(t, {
258
- variant: "primary",
259
- isPending: x,
260
- isFocusableWhenDisabled: !0,
261
- iconStart: "plus",
262
- isDisabled: u.isDisabled || l.atMax,
263
- onClick: b,
264
- children: `New ${_}`
265
- }),
266
- banner: A,
267
- isBusy: m.loading || m.more.status === "loading" || m.refresh.status === "loading",
268
- children: /* @__PURE__ */ w(f, {
269
- status: m.status,
270
- errorTitle: `Couldn't load ${v}`,
271
- error: m.error,
272
- onRetry: m.retry,
273
- children: [
274
- /* @__PURE__ */ C(ee, {
275
- items: o,
276
- selected: a,
277
- block: u,
278
- onToggle: h,
279
- onEdit: g
280
- }),
281
- !m.searching && o.length === 0 && /* @__PURE__ */ C(D, {
282
- query: r,
283
- itemLabel: _,
284
- itemsLabel: v,
285
- canCreate: !!b
286
- }),
287
- /* @__PURE__ */ C(j, {
288
- count: o.length,
289
- total: d ? m.total : o.length,
290
- isRemote: d,
291
- pageSize: p,
292
- remote: m,
293
- itemsLabel: v
294
- })
295
- ]
296
- })
297
- })
298
- });
299
- }
300
- function B({ query: e, onQuery: t, itemsLabel: n, isSearching: r, action: i, banner: a, isBusy: o, children: s }) {
301
- let { ref: c, scrolled: l, onScroll: u, toTop: d } = z(), f = (e) => {
302
- d(), t(e);
303
- };
304
- return /* @__PURE__ */ w(S, { children: [
305
- /* @__PURE__ */ w("div", {
306
- className: "ds-entry-picker__search",
307
- "data-scrolled": l || void 0,
308
- children: [/* @__PURE__ */ C(p, {
309
- "aria-label": `Search ${n}`,
310
- value: e,
311
- isBusy: r,
312
- placeholder: `Search ${n}`,
313
- onChange: (e) => f(e.target.value),
314
- onClear: () => f("")
315
- }), i]
316
- }),
317
- a && /* @__PURE__ */ C("div", {
318
- className: "ds-entry-picker__refresh",
319
- children: a
320
- }),
321
- /* @__PURE__ */ C("div", {
322
- className: "ds-entry-picker__scroll",
323
- ref: c,
324
- onScroll: u,
325
- "aria-busy": o,
326
- children: s
327
- })
328
- ] });
329
- }
330
- //#endregion
331
- //#region src/components/EntryPicker/selected-items.tsx
332
- function ne({ items: e, selected: n, onChange: r, onEdit: i, isDisabled: a, canReorder: o, emptyLabel: s }) {
333
- let c = v(), l = (e, t) => P(e) ? `${c}-reason-${t}` : void 0, u = (e, o) => /* @__PURE__ */ w("span", {
334
- className: "ds-entry-picker__item-actions",
335
- children: [
336
- /* @__PURE__ */ C(L, { item: e }),
337
- /* @__PURE__ */ C(R, {
338
- item: e,
339
- onEdit: e.tone === "removed" ? void 0 : i,
340
- isDisabled: a
341
- }),
342
- /* @__PURE__ */ C(t, {
343
- variant: "simple",
344
- size: "sm",
345
- isIconOnly: !0,
346
- iconStart: "x",
347
- "aria-label": `Remove ${e.title}`,
348
- "aria-describedby": o,
349
- isDisabled: a,
350
- onClick: () => r(n.filter((t) => t !== e.id))
351
- })
352
- ]
353
- });
354
- return e.length === 0 ? /* @__PURE__ */ C("p", {
355
- className: "ds-entry-picker__empty",
356
- children: s
357
- }) : o ? /* @__PURE__ */ C(h, {
358
- items: n,
359
- onReorder: r,
360
- isDisabled: a,
361
- children: e.map((e, t) => /* @__PURE__ */ C(g, {
362
- id: e.id,
363
- label: e.title,
364
- "data-tone": e.tone,
365
- handleDescribedBy: l(e, t),
366
- action: u(e, l(e, t)),
367
- children: /* @__PURE__ */ C("div", {
368
- className: "ds-entry",
369
- children: /* @__PURE__ */ C(I, {
370
- item: e,
371
- reasonId: l(e, t)
372
- })
373
- })
374
- }, e.id))
375
- }) : /* @__PURE__ */ C("ul", {
376
- className: "ds-entry-picker__list",
377
- children: e.map((e, t) => /* @__PURE__ */ w("li", {
378
- className: "ds-entry-picker__row",
379
- "data-tone": e.tone,
380
- children: [/* @__PURE__ */ C("div", {
381
- className: "ds-entry",
382
- children: /* @__PURE__ */ C(I, {
383
- item: e,
384
- reasonId: l(e, t)
385
- })
386
- }), u(e, l(e, t))]
387
- }, e.id))
388
- });
389
- }
390
- //#endregion
391
- //#region src/components/EntryPicker/chosen.ts
392
- function V(e, t, n) {
393
- return {
394
- id: e,
395
- title: t,
396
- metadata: n,
397
- isUnavailable: !0
398
- };
399
- }
400
- function re({ selected: e, items: t, pageItems: n, known: r, failures: i, hasResolver: a, itemLabel: o }) {
401
- let s = new Map(t.map((e) => [e.id, e])), c = new Map(n.map((e) => [e.id, e]));
402
- return e.map((e) => (s.get(e) ?? (r.has(e) ? r.get(e) : c.get(e))) || (r.has(e) ? V(e, `${`${o.charAt(0).toUpperCase()}${o.slice(1)}`} no longer available`, "Replace or clear this selection.") : a ? V(e, i.has(e) ? `Couldn't load ${o}` : "Loading…") : {
403
- id: e,
404
- title: e
405
- }));
406
- }
407
- //#endregion
408
- //#region src/components/EntryPicker/limit.ts
409
- function H(e, t) {
410
- return e === "single" || t === 1;
411
- }
412
- function U(e, t, n) {
413
- return H(e, n) ? {
414
- count: t,
415
- max: 1,
416
- tone: "neutral"
417
- } : e === "multiple" && n !== void 0 ? {
418
- count: t,
419
- max: n
420
- } : void 0;
421
- }
422
- function ie(e, t, n) {
423
- return H(e, n) ? void 0 : t;
424
- }
425
- function ae(e, t, n, { itemLabel: r, itemsLabel: i }) {
426
- let a = U(e, t, n), s = e === "multiple" && a && Number.isFinite(a.max) ? a.max : void 0, c = `Choose as many ${i} as you need.`;
427
- return e === "single" || s === 1 ? c = `Choose one ${r}.` : s !== void 0 && (c = `Choose up to ${s} ${i}.`), {
428
- limit: a,
429
- atMax: s !== void 0 && t >= s,
430
- description: c,
431
- reading: e === "multiple" && o(a) ? a : void 0
432
- };
433
- }
434
- //#endregion
435
- //#region src/components/EntryPicker/use-selected-items.ts
436
- function W(e) {
437
- return e instanceof Error ? e : null;
438
- }
439
- function G(e, t) {
440
- if (!t.some((t) => e.has(t))) return e;
441
- let n = new Map(e);
442
- for (let e of t) n.delete(e);
443
- return n;
444
- }
445
- function K(e, t) {
446
- return e !== t && (e.length !== t.length || t.some((t) => !e.includes(t)));
447
- }
448
- function q(e, t, n) {
449
- let r = e;
450
- if (Object.is(r.refreshKey, n) || (r = {
451
- ...r,
452
- refreshKey: n,
453
- known: /* @__PURE__ */ new Map(),
454
- stale: new Map([...r.stale, ...r.known]),
455
- failures: /* @__PURE__ */ new Map()
456
- }), K(r.selected, t)) {
457
- let e = r.selected.filter((e) => !t.includes(e));
458
- r = {
459
- ...r,
460
- selected: t,
461
- known: G(r.known, e),
462
- stale: G(r.stale, e),
463
- failures: G(r.failures, e)
464
- };
465
- }
466
- return r;
467
- }
468
- function oe(e, t, n, r) {
469
- let a = i(n), o = i(e), [s, c] = x(() => ({
470
- refreshKey: r,
471
- selected: e,
472
- known: /* @__PURE__ */ new Map(),
473
- stale: /* @__PURE__ */ new Map(),
474
- failures: /* @__PURE__ */ new Map()
475
- })), l = q(s, e, r);
476
- l !== s && c(l);
477
- let { known: u, stale: d, failures: f } = l, p = y(() => d.size === 0 ? u : new Map([...d, ...u]), [d, u]), m = (e, t, n = o.current) => {
478
- let r = e.filter((e) => e !== void 0 && n.includes(e.id)).map((e) => [e.id, e]);
479
- r.length !== 0 && c((e) => {
480
- if (Object.is(e.refreshKey, t)) return {
481
- ...e,
482
- known: new Map([...e.known, ...r])
483
- };
484
- let n = r.filter(([t]) => !e.known.has(t) && !e.stale.has(t));
485
- return n.length === 0 ? e : {
486
- ...e,
487
- stale: new Map([...e.stale, ...n])
488
- };
489
- });
490
- }, h = new Set(t.map((e) => e.id)), g = n ? e.filter((e) => !h.has(e) && !u.has(e) && !f.has(e)) : [], v = JSON.stringify(g), S = b({
491
- refreshKey: r,
492
- tokens: /* @__PURE__ */ new Map()
493
- });
494
- _(() => {
495
- let e = a.current;
496
- if (!e) return;
497
- let t = JSON.parse(v);
498
- Object.is(S.current.refreshKey, r) || (S.current = {
499
- refreshKey: r,
500
- tokens: /* @__PURE__ */ new Map()
501
- });
502
- let { tokens: n } = S.current;
503
- for (let e of n.keys()) t.includes(e) || n.delete(e);
504
- for (let i of t.filter((e) => !n.has(e))) {
505
- let t = Symbol(i);
506
- n.set(i, t);
507
- let a = (e) => {
508
- S.current.tokens.get(i) === t && (S.current.tokens.delete(i), c((t) => Object.is(t.refreshKey, r) && t.selected.includes(i) ? e(t) : t));
509
- };
510
- Promise.resolve().then(() => e(i)).then((e) => a((t) => t.known.has(i) ? t : {
511
- ...t,
512
- known: new Map(t.known).set(i, e ?? null)
513
- }), (e) => a((t) => ({
514
- ...t,
515
- failures: new Map(t.failures).set(i, W(e))
516
- })));
517
- }
518
- }, [
519
- v,
520
- r,
521
- a
522
- ]);
523
- let C = e.filter((e) => f.has(e) && !u.has(e));
524
- return {
525
- known: p,
526
- failures: f,
527
- remember: m,
528
- status: g.length > 0 ? "loading" : C.length > 0 ? "error" : "ready",
529
- error: C.length > 0 ? f.get(C[0]) ?? null : null,
530
- retry: () => c((e) => ({
531
- ...e,
532
- failures: G(e.failures, C)
533
- }))
534
- };
535
- }
536
- //#endregion
537
- //#region src/components/EntryPicker/use-picker-data.ts
538
- var J = 250;
539
- function se(e) {
540
- return Array.from(new Map(e.map((e) => [e.id, e])).values());
541
- }
542
- var Y = {
543
- items: [],
544
- offset: 0,
545
- total: 0
546
- }, X = {
547
- ...Y,
548
- key: null,
549
- revision: void 0,
550
- status: "ready",
551
- error: null
552
- };
553
- function Z(e, t) {
554
- let n = e?.status === "error" && t;
555
- return {
556
- status: e?.status === "loading" ? "loading" : n ? "error" : "ready",
557
- error: n ? e.error ?? null : null,
558
- isAvailable: t
559
- };
560
- }
561
- function Q(e, t) {
562
- return {
563
- items: se([...e.items, ...t.items]),
564
- offset: e.offset + t.items.length,
565
- total: t.items.length === 0 ? Math.min(t.total, e.offset) : t.total
566
- };
567
- }
568
- function $(e, t, n, r) {
569
- return e.key !== t || e.offset !== n ? e : {
570
- ...e,
571
- ...Q(e, r)
572
- };
573
- }
574
- async function ce(e, t, n, r, i) {
575
- let a = Math.max(1, Math.ceil(r / n)), o = await Promise.all(Array.from({ length: a }, (r, i) => e({
576
- offset: i * n,
577
- limit: n
578
- }, { query: t }))), s = Y;
579
- for (let [e, t] of o.entries()) {
580
- if (s.offset !== e * n) break;
581
- s = Q(s, t);
582
- }
583
- for (; s.offset < r && s.offset < s.total && i();) s = Q(s, await e({
584
- offset: s.offset,
585
- limit: n
586
- }, { query: t }));
587
- return s;
588
- }
589
- function le(e, t, n, r) {
590
- let i = e !== null && t.key === e, a = i && Object.is(t.revision, n), o = e !== null && !a && (!i || t.status === "error"), s = o && t.key !== null && t.status === "ready", c = o && !s ? "loading" : t.status === "error" ? "error" : "ready", l = t.status === "ready" && t.offset < t.total, u = i && !a && t.status === "ready", d = u && r?.key === e && Object.is(r.revision, n);
591
- return {
592
- loading: o,
593
- searching: s,
594
- status: c,
595
- hasMore: l,
596
- refresh: u ? d ? "error" : "loading" : "ready",
597
- refreshFailed: d
598
- };
599
- }
600
- function ue(e, t, n, r, a, o) {
601
- let s = i(e), c = i(a), l = i(o), [u, d] = x(0), [f, p] = x(X), [m, h] = x(null), [g, v] = x(null), [y, S] = x(r);
602
- y !== r && (S(r), r || (p(X), h(null), v(null), d((e) => e + 1)));
603
- let C = n.trim(), w = e && r ? JSON.stringify([
604
- C,
605
- t,
606
- u
607
- ]) : null, T = i(f), E = b(null), D = b(C), { loading: O, searching: k, status: A, hasMore: j, refresh: M, refreshFailed: N } = le(w, f, o, g), P = !O && M === "ready", F = O ? "load" : M === "loading" ? "refresh" : null;
608
- _(() => {
609
- if (w === null) return;
610
- let e = F === "load" && C !== D.current ? J : 0;
611
- if (D.current = C, F === null) return;
612
- let n = F === "refresh" ? T.current.offset + (E.current ? t : 0) : 0, r = !0, i = window.setTimeout(() => {
613
- let e = s.current;
614
- e && ce(e, C, t, n, () => r).then((e) => {
615
- r && (E.current = null, p({
616
- ...e,
617
- key: w,
618
- revision: o,
619
- status: "ready",
620
- error: null
621
- }), h(null), v(null), c.current(e.items, o));
622
- }, (e) => {
623
- r && (F === "refresh" ? v({
624
- key: w,
625
- revision: o,
626
- error: W(e)
627
- }) : (E.current = null, p({
628
- ...X,
629
- key: w,
630
- revision: o,
631
- status: "error",
632
- error: W(e)
633
- }), h(null)));
634
- });
635
- }, e);
636
- return () => {
637
- r = !1, window.clearTimeout(i);
638
- };
639
- }, [
640
- w,
641
- F,
642
- o,
643
- C,
644
- t,
645
- s,
646
- c,
647
- T
648
- ]);
649
- let I = () => {
650
- let e = s.current, n = f.key, { offset: r } = f;
651
- if (!e || n === null || !P || !j || E.current) return;
652
- let i = Symbol("load more"), a = o;
653
- E.current = i, h({
654
- token: i,
655
- status: "loading",
656
- error: null
657
- });
658
- let u = () => E.current === i && T.current.key === n && T.current.offset === r && Object.is(l.current, a), d = (e) => {
659
- E.current === i && (E.current = null), h((t) => t?.token === i ? e : t);
660
- };
661
- Promise.resolve().then(() => e({
662
- offset: r,
663
- limit: t
664
- }, { query: C })).then((e) => {
665
- u() && (p((t) => $(t, n, r, e)), c.current(e.items, a)), d(null);
666
- }, (e) => d(u() ? {
667
- token: i,
668
- status: "error",
669
- error: W(e)
670
- } : null));
671
- };
672
- return {
673
- items: f.items,
674
- total: f.total,
675
- offset: f.offset,
676
- hasMore: j,
677
- pageRevision: f.revision,
678
- loading: O,
679
- searching: k,
680
- status: A,
681
- error: f.error,
682
- retry: () => d((e) => e + 1),
683
- more: {
684
- ...Z(m, P),
685
- load: I
686
- },
687
- refresh: {
688
- status: M,
689
- error: N ? g?.error ?? null : null,
690
- retry: () => v(null)
691
- }
692
- };
693
- }
694
- //#endregion
695
- //#region src/components/EntryPicker/index.tsx
696
- var de = [];
697
- function fe(e, t) {
698
- let n = t.trim().toLowerCase();
699
- return n ? e.filter((e) => [e.title, ...e.keywords ?? []].join(" ").toLowerCase().includes(n)) : e;
700
- }
701
- function pe({ items: e = de, value: n, defaultValue: r = [], onValueChange: i, mode: a = "multiple", max: o, label: s = "Entries", emptyLabel: c = "Nothing selected yet.", addLabel: u = "Choose entries", itemLabel: d = "entry", itemsLabel: f = "entries", isReorderable: p = !0, isDisabled: m = !1, loadPage: h, pageSize: g = 10, resolveItem: _, onEditItem: v, onCreate: b, isCreating: S = !1, refreshKey: D, dialogTitle: O, dialogDescription: k, isDialogHidden: A = !1, className: j, ...M }) {
702
- let [N, P] = x(r), F = n ?? N, [I, L] = x(!1), [R, ee] = x(""), z = oe(F, e, _, D), B = ue(h, g, R, I, z.remember, D), V = E(`Couldn't load selected ${f}`, z.status, z.error, z.retry), H = !!h, U = y(() => H ? de : fe(e, R), [
703
- H,
704
- e,
705
- R
706
- ]), W = H ? B.items : U, G = ae(a, F.length, o, {
707
- itemLabel: d,
708
- itemsLabel: f
709
- }), K = {
710
- isDisabled: m,
711
- searching: B.searching,
712
- atMax: G.atMax
713
- }, q = (e) => {
714
- m || (n === void 0 && P(e), i?.(e));
715
- }, J = (e, t) => {
716
- let n = H ? B.pageRevision : D;
717
- z.remember([t], n, e), q(e);
718
- }, se = (e) => {
719
- let t = W.find((t) => t.id === e);
720
- t && !T(t, F.includes(e), K) && (a === "single" ? (J(F[0] === e ? [] : [e], t), L(!1)) : F.includes(e) ? q(F.filter((t) => t !== e)) : J([...F, e], t));
721
- }, { known: Y, failures: X } = z, Z = !!_, Q = y(() => re({
722
- selected: F,
723
- items: e,
724
- pageItems: B.items,
725
- known: Y,
726
- failures: X,
727
- hasResolver: Z,
728
- itemLabel: d
729
- }), [
730
- F,
731
- e,
732
- B.items,
733
- Y,
734
- X,
735
- Z,
736
- d
737
- ]), $ = v ? (e) => {
738
- v(e) === !1 && L(!1);
739
- } : void 0;
740
- return /* @__PURE__ */ w(l, {
741
- ...M,
742
- className: ["ds-entry-picker", j].filter(Boolean).join(" "),
743
- label: s,
744
- count: ie(a, F.length, o),
745
- limit: M.limit === void 0 ? G.limit : M.limit,
746
- children: [
747
- /* @__PURE__ */ C(ne, {
748
- items: Q,
749
- selected: F,
750
- onChange: q,
751
- onEdit: $,
752
- isDisabled: m,
753
- canReorder: p && a === "multiple" && Q.length > 1,
754
- emptyLabel: c
755
- }),
756
- V,
757
- /* @__PURE__ */ w("div", {
758
- className: "ds-entry-picker__actions",
759
- children: [/* @__PURE__ */ C(t, {
760
- variant: "neutral",
761
- size: "sm",
762
- iconStart: "plus",
763
- isDisabled: m,
764
- onClick: () => L(!0),
765
- children: u
766
- }), F.length > 0 && /* @__PURE__ */ C(t, {
767
- variant: "simple",
768
- size: "sm",
769
- isDisabled: m,
770
- onClick: () => q([]),
771
- children: "Clear"
772
- })]
773
- }),
774
- /* @__PURE__ */ C(te, {
775
- isOpen: I,
776
- onClose: () => L(!1),
777
- query: R,
778
- onQuery: ee,
779
- selected: F,
780
- results: W,
781
- cap: G,
782
- block: K,
783
- isRemote: H,
784
- pageSize: g,
785
- remote: B,
786
- onToggle: se,
787
- onEdit: $,
788
- itemLabel: d,
789
- itemsLabel: f,
790
- addLabel: u,
791
- onCreate: b,
792
- isCreating: S,
793
- dialogTitle: O,
794
- dialogDescription: k,
795
- isDialogHidden: A
796
- })
797
- ]
798
- });
799
- }
800
- //#endregion
801
- export { ie as n, U as r, pe as t };
802
-
803
- //# sourceMappingURL=EntryPicker-LBj_56_e.js.map