dynamic-mui 2.5.3 → 2.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.
Files changed (252) hide show
  1. package/dist/accordion-DB151BNT.mjs +22 -0
  2. package/dist/accordion-YWjUldL8.js +1 -0
  3. package/dist/addressfield-CpvOajVo.mjs +242 -0
  4. package/dist/addressfield-CwKjfnTq.js +1 -0
  5. package/dist/ai/index.cjs +1 -1
  6. package/dist/ai/index.mjs +1 -14
  7. package/dist/ai/react/AIForm.d.ts +2 -1
  8. package/dist/ai/react/AIFormGenerator.d.ts +1 -1
  9. package/dist/ai/react/AISchemaReview.d.ts +1 -1
  10. package/dist/ai/react/AITextAssist.d.ts +1 -1
  11. package/dist/ai/react/AIVisionImport.d.ts +2 -1
  12. package/dist/ai-BFpA3uHx.js +29 -0
  13. package/dist/ai-UvDYQ30b.mjs +4533 -0
  14. package/dist/asyncautocomplete-DQLDdmVl.js +1 -0
  15. package/dist/asyncautocomplete-mwra2KKJ.mjs +72 -0
  16. package/dist/bar-CgYZxXHl.js +1 -0
  17. package/dist/bar-LVtZP6Ui.mjs +4 -0
  18. package/dist/cascadeselect-BJzHZA9-.js +1 -0
  19. package/dist/cascadeselect-Cl4OHq-L.mjs +66 -0
  20. package/dist/chartControl-IQafKpDk.mjs +29 -0
  21. package/dist/chartControl-ifHiG3nr.js +1 -0
  22. package/dist/collection-DPJTrAiB.mjs +1692 -0
  23. package/dist/collection-Dd_Ojgwl.js +1 -0
  24. package/dist/colorpicker-9AUe21p1.mjs +110 -0
  25. package/dist/colorpicker-DgKTLBmU.js +1 -0
  26. package/dist/components/DynamicComponent.d.ts +2 -1
  27. package/dist/components/FormGenerator.d.ts +1 -1
  28. package/dist/components/charts/Bar/bar.d.ts +6 -2
  29. package/dist/components/charts/Line/line.d.ts +6 -2
  30. package/dist/components/charts/Mixchart/mixChart.d.ts +2 -1
  31. package/dist/components/charts/Pie/pie.d.ts +6 -2
  32. package/dist/components/charts/chartControl.d.ts +15 -0
  33. package/dist/components/controls/Accordion/accordion.d.ts +2 -1
  34. package/dist/components/controls/AddressField/addressfield.d.ts +2 -1
  35. package/dist/components/controls/Alert/alert.d.ts +1 -1
  36. package/dist/components/controls/AsyncAutocomplete/asyncautocomplete.d.ts +1 -1
  37. package/dist/components/controls/Autocomplete/autocomplete.d.ts +1 -1
  38. package/dist/components/controls/Button/button.d.ts +1 -1
  39. package/dist/components/controls/CascadeSelect/cascadeselect.d.ts +2 -1
  40. package/dist/components/controls/CheckBox/checkbox.d.ts +2 -2
  41. package/dist/components/controls/CheckBox/toggleInput.d.ts +25 -0
  42. package/dist/components/controls/Chip/chip.d.ts +1 -1
  43. package/dist/components/controls/ChipSelect/chipselect.d.ts +2 -1
  44. package/dist/components/controls/Collection/CollectionList.d.ts +1 -1
  45. package/dist/components/controls/Collection/ItemDialog.d.ts +1 -1
  46. package/dist/components/controls/Collection/collection.d.ts +1 -1
  47. package/dist/components/controls/Collection/parts.d.ts +6 -6
  48. package/dist/components/controls/ColorPicker/colorpicker.d.ts +2 -1
  49. package/dist/components/controls/Computed/computed.d.ts +1 -1
  50. package/dist/components/controls/ConsentField/consentfield.d.ts +2 -1
  51. package/dist/components/controls/CurrencyField/currencyfield.d.ts +1 -1
  52. package/dist/components/controls/DataTable/datatable.d.ts +2 -1
  53. package/dist/components/controls/DateRangePicker/daterangepicker.d.ts +1 -1
  54. package/dist/components/controls/DateTime/datetime.d.ts +15 -1
  55. package/dist/components/controls/DateTimePicker/datetimepicker.d.ts +6 -2
  56. package/dist/components/controls/Divider/divider.d.ts +1 -1
  57. package/dist/components/controls/EditableTable/editabletable.d.ts +1 -1
  58. package/dist/components/controls/FileUpload/fileupload.d.ts +1 -1
  59. package/dist/components/controls/FormRepeater/formrepeater.d.ts +1 -1
  60. package/dist/components/controls/FormWizard/formwizard.d.ts +1 -1
  61. package/dist/components/controls/GeoField/geofield.d.ts +1 -1
  62. package/dist/components/controls/Group/group.d.ts +2 -1
  63. package/dist/components/controls/Hyperlink/hyperlink.d.ts +1 -1
  64. package/dist/components/controls/ImageList/imagelist.d.ts +1 -1
  65. package/dist/components/controls/IntlPhone/intlphone.d.ts +2 -1
  66. package/dist/components/controls/KeyValueField/keyvaluefield.d.ts +2 -1
  67. package/dist/components/controls/LineItemList/lineitemlist.d.ts +1 -1
  68. package/dist/components/controls/List/list.d.ts +1 -1
  69. package/dist/components/controls/LocationField/locationfield.d.ts +1 -1
  70. package/dist/components/controls/MarkdownEditor/markdowneditor.d.ts +2 -1
  71. package/dist/components/controls/MatrixField/matrixfield.d.ts +2 -1
  72. package/dist/components/controls/MultiTextbox/multitextbox.d.ts +1 -1
  73. package/dist/components/controls/NpsScale/npsscale.d.ts +2 -1
  74. package/dist/components/controls/NumberField/numberfield.d.ts +2 -1
  75. package/dist/components/controls/NumberStepper/numberstepper.d.ts +1 -1
  76. package/dist/components/controls/OtpField/otpfield.d.ts +2 -1
  77. package/dist/components/controls/PasswordField/passwordfield.d.ts +2 -1
  78. package/dist/components/controls/PhoneField/phonefield.d.ts +1 -1
  79. package/dist/components/controls/Radio/radio.d.ts +2 -1
  80. package/dist/components/controls/Rating/rating.d.ts +2 -1
  81. package/dist/components/controls/RichTextEditor/richtexteditor.d.ts +2 -1
  82. package/dist/components/controls/Select/select.d.ts +2 -1
  83. package/dist/components/controls/Signature/signature.d.ts +1 -1
  84. package/dist/components/controls/Slider/slider.d.ts +1 -1
  85. package/dist/components/controls/Stepper/stepper.d.ts +1 -1
  86. package/dist/components/controls/SummaryField/summaryfield.d.ts +2 -1
  87. package/dist/components/controls/Switch/switch.d.ts +1 -1
  88. package/dist/components/controls/Tabs/tabs.d.ts +2 -1
  89. package/dist/components/controls/TagsInput/tagsinput.d.ts +1 -1
  90. package/dist/components/controls/TextField/textfield.d.ts +1 -1
  91. package/dist/components/controls/TextField/useTextInput.d.ts +18 -0
  92. package/dist/components/controls/TimePicker/timepicker.d.ts +6 -2
  93. package/dist/components/controls/ToggleButtons/togglebuttons.d.ts +1 -1
  94. package/dist/components/controls/Typography/typography.d.ts +1 -1
  95. package/dist/components/controls/index.d.ts +24 -9
  96. package/dist/consentfield-CFm1IDa5.mjs +68 -0
  97. package/dist/consentfield-z8W0Yfx8.js +1 -0
  98. package/dist/datatable-CMjaTDPM.js +1 -0
  99. package/dist/datatable-lZIwHx6a.mjs +29 -0
  100. package/dist/dynamic-mui.cjs +1 -1
  101. package/dist/dynamic-mui.d.ts +1 -1
  102. package/dist/dynamic-mui.mjs +264 -204
  103. package/dist/editabletable-B3Df4Jys.mjs +117 -0
  104. package/dist/editabletable-r0RwM1rO.js +1 -0
  105. package/dist/fileupload-Cr-Mz7oH.js +1 -0
  106. package/dist/fileupload-D2fXyMIu.mjs +191 -0
  107. package/dist/formrepeater-BP-RBrQv.js +1 -0
  108. package/dist/formrepeater-BrYTYCzc.mjs +82 -0
  109. package/dist/formwizard-CQ2z6fUX.mjs +82 -0
  110. package/dist/formwizard-DR7fa59M.js +1 -0
  111. package/dist/geofield-CxVFA0og.mjs +116 -0
  112. package/dist/geofield-DtN-d2Bq.js +1 -0
  113. package/dist/group-CiohorzN.mjs +30 -0
  114. package/dist/group-HQL7UqHt.js +1 -0
  115. package/dist/imagelist-CNe1Dp_M.mjs +23 -0
  116. package/dist/imagelist-Wm5Qa6wA.js +1 -0
  117. package/dist/index.d.ts +1 -0
  118. package/dist/intlphone-DwsiSfSt.js +1 -0
  119. package/dist/intlphone-LGE-cB6X.mjs +341 -0
  120. package/dist/keyvaluefield-B7NlE0AT.js +1 -0
  121. package/dist/keyvaluefield-Cd4NQf6d.mjs +128 -0
  122. package/dist/line-BGSi1tvf.js +1 -0
  123. package/dist/line-cK6taoCA.mjs +4 -0
  124. package/dist/lineitemlist-bmk7fEf9.mjs +169 -0
  125. package/dist/lineitemlist-mulPt3cO.js +1 -0
  126. package/dist/list-D5qW-7Xg.js +1 -0
  127. package/dist/list-xPNiijgm.mjs +20 -0
  128. package/dist/locationfield-DtWkxnX-.js +1 -0
  129. package/dist/locationfield-SPonkbMU.mjs +90 -0
  130. package/dist/markdowneditor-6lJQ5cEn.mjs +82 -0
  131. package/dist/markdowneditor-nPP0t2eK.js +2 -0
  132. package/dist/matrixfield-CUYoJCwi.js +1 -0
  133. package/dist/matrixfield-Jm9Yx0EP.mjs +119 -0
  134. package/dist/mixChart-CSq7pQqJ.mjs +49 -0
  135. package/dist/mixChart-DoehYa8V.js +1 -0
  136. package/dist/muiX-BHOKpogF.mjs +12 -0
  137. package/dist/muiX-CG_D1XQ2.js +1 -0
  138. package/dist/multitextbox-D-JUSnT7.js +1 -0
  139. package/dist/multitextbox-gUt8BmfQ.mjs +96 -0
  140. package/dist/npsscale-D_VtbpJi.js +1 -0
  141. package/dist/npsscale-LWe7yCxB.mjs +111 -0
  142. package/dist/numberstepper-BXXlSKT_.js +1 -0
  143. package/dist/numberstepper-K_JfJJtg.mjs +111 -0
  144. package/dist/pie-CueMspFX.js +1 -0
  145. package/dist/pie-DFO89j-z.mjs +4 -0
  146. package/dist/richtexteditor-BHM-8xe3.js +1 -0
  147. package/dist/richtexteditor-gmObNHZ7.mjs +178 -0
  148. package/dist/rolldown-runtime-5iZMYShA.js +1 -0
  149. package/dist/s3Upload-C3-wcrua.js +1 -0
  150. package/dist/s3Upload-HtE088XA.mjs +39 -0
  151. package/dist/signature-DjYfiNzq.js +3 -0
  152. package/dist/signature-HiL8FJ6C.mjs +1116 -0
  153. package/dist/stepper-cpOj2wWz.mjs +166 -0
  154. package/dist/stepper-zEfhqmbA.js +1 -0
  155. package/dist/summaryfield-BzrdvTVy.js +1 -0
  156. package/dist/summaryfield-DIQfJjjo.mjs +65 -0
  157. package/dist/tabs-DvPu-zDC.mjs +50 -0
  158. package/dist/tabs-xdkLXUCp.js +1 -0
  159. package/dist/tagsinput-B33m6GJ_.js +1 -0
  160. package/dist/tagsinput-CTBGuv0M.mjs +49 -0
  161. package/dist/useSyncedState-CzAO4D1o.mjs +17 -0
  162. package/dist/useSyncedState-DYNKkpDv.js +1 -0
  163. package/dist/useTextInput-Cm0_Ps2V.js +1 -0
  164. package/dist/useTextInput-Dr-ncTE8.mjs +1683 -0
  165. package/dist/useUpdateEffect-CNBo9hj8.js +1 -0
  166. package/dist/useUpdateEffect-CXAhttj7.mjs +14 -0
  167. package/dist/util/helper.d.ts +18 -1
  168. package/dist/util/muiVersion.d.ts +13 -0
  169. package/dist/util/stepperComponents.d.ts +1 -1
  170. package/dist/util/useSyncedState.d.ts +22 -0
  171. package/dist/util/validation.d.ts +40 -0
  172. package/dist/v4-Dyp-SQ1c.js +1 -0
  173. package/dist/v4-YCkfo8OR.mjs +27 -0
  174. package/dist/validation-B7DPZ218.js +7 -0
  175. package/dist/validation-BRcYhhsT.mjs +4991 -0
  176. package/package.json +35 -35
  177. package/dist/AIForm-D204ogdw.js +0 -44
  178. package/dist/AIForm-IafSvW2_.mjs +0 -12281
  179. package/dist/accordion-DA8VpkJ_.mjs +0 -23
  180. package/dist/accordion-yIxiSIl4.js +0 -1
  181. package/dist/addressfield-DCzPapIx.mjs +0 -164
  182. package/dist/addressfield-EFiWgeWB.js +0 -1
  183. package/dist/asyncautocomplete-5-8SXotM.mjs +0 -92
  184. package/dist/asyncautocomplete-BmHm-S4u.js +0 -1
  185. package/dist/bar-BvwjqB4v.mjs +0 -21
  186. package/dist/bar-DRjoPCtv.js +0 -1
  187. package/dist/cascadeselect-BEaoupK6.js +0 -1
  188. package/dist/cascadeselect-CzSf78Pg.mjs +0 -66
  189. package/dist/collection-CthMZ0Go.js +0 -1
  190. package/dist/collection-n9eBOioi.mjs +0 -1157
  191. package/dist/colorpicker-Bm9M38_c.mjs +0 -111
  192. package/dist/colorpicker-DHkdM8Q2.js +0 -1
  193. package/dist/consentfield-B2-UFm5n.mjs +0 -80
  194. package/dist/consentfield-DV8Gz0k9.js +0 -1
  195. package/dist/datatable-BVZFBd-8.mjs +0 -21
  196. package/dist/datatable-DnnyVWJm.js +0 -1
  197. package/dist/editabletable-B_JS4UZ9.js +0 -1
  198. package/dist/editabletable-BwvIvAt7.mjs +0 -128
  199. package/dist/fileupload-BHT7K0YT.mjs +0 -185
  200. package/dist/fileupload-CugVG3o3.js +0 -1
  201. package/dist/formrepeater-CaJMPo3Q.mjs +0 -75
  202. package/dist/formrepeater-DiKPaOfi.js +0 -1
  203. package/dist/formwizard-BzvdbvBY.js +0 -1
  204. package/dist/formwizard-C9fOIHQv.mjs +0 -83
  205. package/dist/geofield-BM4b5Zwx.js +0 -1
  206. package/dist/geofield-DYXx9K9o.mjs +0 -108
  207. package/dist/group-D5fMqJTx.mjs +0 -23
  208. package/dist/group-mwS8FSGJ.js +0 -1
  209. package/dist/imagelist-Bn9QhIv7.js +0 -1
  210. package/dist/imagelist-rqmJajHt.mjs +0 -18
  211. package/dist/intlphone-BQYytFWy.js +0 -1
  212. package/dist/intlphone-DHDwdBbm.mjs +0 -144
  213. package/dist/keyvaluefield-DM0eSfPF.mjs +0 -127
  214. package/dist/keyvaluefield-DXyuqDba.js +0 -1
  215. package/dist/line-Dst2QjuI.mjs +0 -21
  216. package/dist/line-hM3OgPH7.js +0 -1
  217. package/dist/lineitemlist-89hrdS0p.mjs +0 -170
  218. package/dist/lineitemlist-DfEjbNCH.js +0 -1
  219. package/dist/list-B8S2MrOx.js +0 -1
  220. package/dist/list-C97cCc78.mjs +0 -20
  221. package/dist/locationfield-BEMe22_x.mjs +0 -118
  222. package/dist/locationfield-DlgLvvdU.js +0 -1
  223. package/dist/markdowneditor-JoiWE-qO.js +0 -2
  224. package/dist/markdowneditor-K4TAKJ3s.mjs +0 -94
  225. package/dist/matrixfield-D4sHu6rU.mjs +0 -121
  226. package/dist/matrixfield-szah6uOP.js +0 -1
  227. package/dist/mixChart-Doq4lt7Z.mjs +0 -75
  228. package/dist/mixChart-rgyMCdnp.js +0 -1
  229. package/dist/multitextbox-CBChuyw9.js +0 -1
  230. package/dist/multitextbox-Cnrwie5U.mjs +0 -78
  231. package/dist/npsscale-Cc2eD9Nk.js +0 -1
  232. package/dist/npsscale-DgQPa1eH.mjs +0 -91
  233. package/dist/numberstepper-BcuSZHwZ.js +0 -1
  234. package/dist/numberstepper-BqINnIm7.mjs +0 -132
  235. package/dist/pie-B6dXjc4o.mjs +0 -21
  236. package/dist/pie-a_dhmBUq.js +0 -1
  237. package/dist/richtexteditor-Bs5-VQj3.js +0 -1
  238. package/dist/richtexteditor-CveBdsmJ.mjs +0 -143
  239. package/dist/s3Upload-B0JeoLkS.js +0 -1
  240. package/dist/s3Upload-dpioZ2c8.mjs +0 -51
  241. package/dist/signature-BRWAWqeA.mjs +0 -1227
  242. package/dist/signature-Bj9GDrvy.js +0 -2
  243. package/dist/stepper-B9sSsbQD.js +0 -1
  244. package/dist/stepper-DTMAP67o.mjs +0 -140
  245. package/dist/summaryfield-JKL3ZLl2.js +0 -1
  246. package/dist/summaryfield-xhr0Q4RL.mjs +0 -96
  247. package/dist/tabs-ClkmKlV8.mjs +0 -39
  248. package/dist/tabs-DmEP_QW0.js +0 -1
  249. package/dist/tagsinput-B0yVrYgB.mjs +0 -58
  250. package/dist/tagsinput-COKkxIxg.js +0 -1
  251. package/dist/v4-BysszJq8.mjs +0 -30
  252. package/dist/v4-CqdK_b8Y.js +0 -1
@@ -1,209 +1,269 @@
1
- import { y as I, z as k, B as Q, V as U, D as Z } from "./AIForm-IafSvW2_.mjs";
2
- import { A as pe, a as fe, b as me, c as ge, d as ve, e as ye, E as be, C as Ae, G as Ee, q as we, F as Me, w as Se, H as Fe, f as Ie, g as Oe, i as Ve, I as $e, J as Ce, K as We, L as qe, M as Re, N as De, s as ke, h as Te, O as Le, u as _e, Q as ze } from "./AIForm-IafSvW2_.mjs";
3
- import { useMemo as V, useState as T, useRef as x, useCallback as A } from "react";
4
- function te(e) {
5
- return (n) => {
6
- const r = e.safeParse(n);
7
- return !r || r.success ? [] : (r.error?.issues || r.error?.errors || []).map((u) => ({ id: String(u?.path?.[0] ?? ""), message: u?.message || "Invalid value", rule: u?.code || "zod" })).filter((u) => u.id);
8
- };
1
+ import { c as e, n as t, t as n } from "./validation-BRcYhhsT.mjs";
2
+ import { l as r, u as i } from "./useTextInput-Dr-ncTE8.mjs";
3
+ import { A as a, D as o, F as s, G as c, I as l, K as u, L as d, M as f, N as p, O as m, P as h, a as g, c as _, d as v, f as y, h as b, i as x, j as S, k as C, l as w, m as T, n as E, o as D, p as O, r as k, s as A, t as j, u as M } from "./ai-UvDYQ30b.mjs";
4
+ import { n as N, r as P, t as F } from "./muiX-BHOKpogF.mjs";
5
+ import { useCallback as I, useMemo as L, useRef as R, useState as z } from "react";
6
+ // src/util/resolvers.ts
7
+ function B(e) {
8
+ return (t) => {
9
+ let n = e.safeParse(t);
10
+ return !n || n.success ? [] : (n.error?.issues || n.error?.errors || []).map((e) => ({
11
+ id: String(e?.path?.[0] ?? ""),
12
+ message: e?.message || "Invalid value",
13
+ rule: e?.code || "zod"
14
+ })).filter((e) => e.id);
15
+ };
9
16
  }
10
- function ae(e) {
11
- return (n) => {
12
- try {
13
- return e.validateSync(n, { abortEarly: !1 }), [];
14
- } catch (r) {
15
- return (r?.inner?.length ? r.inner : r ? [r] : []).map((u) => ({ id: String(u?.path ?? ""), message: u?.message || "Invalid value", rule: u?.type || "yup" })).filter((u) => u.id);
16
- }
17
- };
17
+ function V(e) {
18
+ return (t) => {
19
+ try {
20
+ return e.validateSync(t, { abortEarly: !1 }), [];
21
+ } catch (e) {
22
+ return (e?.inner?.length ? e.inner : e ? [e] : []).map((e) => ({
23
+ id: String(e?.path ?? ""),
24
+ message: e?.message || "Invalid value",
25
+ rule: e?.type || "yup"
26
+ })).filter((e) => e.id);
27
+ }
28
+ };
18
29
  }
19
- const $ = ["mandatory", "mandatoryselect"], S = (e, n) => {
20
- const r = [];
21
- return (e || []).forEach((h) => {
22
- if (r.push(h), Array.isArray(h.subforms) && h.subforms.length) {
23
- const u = h?.id || h?.props?.id, l = u ? n[u] : void 0;
24
- h.subforms.forEach((t) => {
25
- (Array.isArray(l) ? l.includes(t.conditionValue) : t.conditionValue === l) && r.push(...S(t.data || [], n));
26
- });
27
- }
28
- }), r;
29
- }, E = (e) => e?.id || e?.props?.id || "", L = (e, n) => !e?.visibleWhen || I(e.visibleWhen, n), ee = (e, n) => e?.optionsMap && e?.dependsOn ? e.optionsMap[n[e.dependsOn]] || [] : e?.props?.options;
30
- function de(e, n = {}) {
31
- const { resolver: r } = n, h = n.messages?.required || "This field is required", u = V(() => {
32
- const i = { ...n.initialValues || {} };
33
- return S(e, i).forEach((s) => {
34
- const f = E(s), d = s?.props?.value;
35
- f && i[f] === void 0 && d !== void 0 && (i[f] = d);
36
- }), i;
37
- }, []), [l, t] = T(u), [a, w] = T([]), m = x(u), v = A((i) => {
38
- const s = { ...i };
39
- return S(e, s).forEach((d) => {
40
- const o = E(d);
41
- if (o && d.visibleWhen && !I(d.visibleWhen, s) && delete s[o], o && d.optionsMap && d.dependsOn) {
42
- const y = (d.optionsMap[s[d.dependsOn]] || []).map((g) => typeof g == "string" ? g : g?.value), b = s[o];
43
- b != null && b !== "" && !y.includes(b) && delete s[o];
44
- }
45
- }), (e || []).forEach((d) => {
46
- if (!Array.isArray(d.subforms) || !d.subforms.length) return;
47
- const o = E(d), c = o ? s[o] : void 0, y = /* @__PURE__ */ new Set(), b = /* @__PURE__ */ new Set();
48
- d.subforms.forEach((g) => {
49
- const M = Array.isArray(c) ? c.includes(g.conditionValue) : g.conditionValue === c;
50
- (g.data || []).forEach((C) => {
51
- const p = E(C);
52
- p && (M ? y : b).add(p);
53
- });
54
- }), b.forEach((g) => {
55
- y.has(g) || delete s[g];
56
- });
57
- }), S(e, s).forEach((d) => {
58
- const o = E(d);
59
- o && d.formula && (s[o] = k(d.formula, s));
60
- }), s;
61
- }, [e]), N = A((i, s) => {
62
- t((f) => v({ ...f, [i]: s }));
63
- }, [v]), X = A((i) => {
64
- t((s) => v({ ...s, ...i || {} }));
65
- }, [v]), O = A((i) => {
66
- const s = S(e, i), f = [], d = /* @__PURE__ */ new Set();
67
- if (s.forEach((o) => {
68
- const c = E(o);
69
- c && !L(o, i) && d.add(c);
70
- }), s.forEach((o) => {
71
- const c = E(o);
72
- if (!c || d.has(c)) return;
73
- const y = [...o?.rules?.validation || []], b = y.some((p) => $.includes(p.rule));
74
- if (o.requiredWhen && !b && I(o.requiredWhen, i) && y.push({ rule: "mandatory", message: o.requiredMessage || h }), !y.length) return;
75
- const g = i[c], M = g == null ? "" : String(g), C = y.some((p) => $.includes(p.rule));
76
- y.forEach((p) => {
77
- const R = Q[p.rule];
78
- if (R) {
79
- if (!M && !C) return;
80
- const D = i[p.field ?? p.value], K = D == null ? "" : String(D);
81
- R(M, K) || f.push({ id: c, rule: p.rule, message: p.message });
82
- return;
83
- }
84
- const W = U[p.rule];
85
- if (typeof W != "function") return;
86
- const q = $.includes(p.rule);
87
- if (!M && !q) return;
88
- W(q ? g : M, p.value) || f.push({ id: c, rule: p.rule, message: p.message || (q ? h : "") });
89
- });
90
- }), r) {
91
- let o = [];
92
- try {
93
- o = r(i) || [];
94
- } catch {
95
- o = [];
96
- }
97
- o.forEach((c) => {
98
- c && c.id && !d.has(c.id) && f.push({ id: c.id, rule: c.rule || "schema", message: c.message });
99
- });
100
- }
101
- return f;
102
- }, [e, r, h]), Y = A(() => {
103
- const i = O(l);
104
- return w(i), i;
105
- }, [O, l]), B = A((i) => {
106
- const s = O(l);
107
- return w(s), s.length === 0 && i && i({ ...l }), s;
108
- }, [O, l]), P = A(() => {
109
- t({ ...m.current }), w([]);
110
- }, []), F = V(() => {
111
- const i = /* @__PURE__ */ new Map();
112
- return a.forEach((s) => {
113
- s.id && !i.has(s.id) && i.set(s.id, s.message);
114
- }), S(e, l).map((s) => {
115
- const f = E(s), o = (s?.rules?.validation || []).some((y) => $.includes(y.rule)) || !!(s.requiredWhen && I(s.requiredWhen, l)), c = s.formula ? k(s.formula, l) : l[f];
116
- return {
117
- id: f,
118
- field: s,
119
- value: c,
120
- visible: L(s, l),
121
- disabled: !!(s.disabledWhen && I(s.disabledWhen, l)),
122
- required: o,
123
- options: ee(s, l),
124
- error: i.get(f)
125
- };
126
- });
127
- }, [e, l, a]), j = V(() => F.filter((i) => i.visible), [F]), H = A((i) => F.find((s) => s.id === i), [F]), J = V(() => !Z(l, m.current), [l]);
128
- return {
129
- values: l,
130
- errors: a,
131
- fields: F,
132
- visibleFields: j,
133
- getFieldState: H,
134
- setValue: N,
135
- setValues: X,
136
- validate: Y,
137
- isValid: a.length === 0,
138
- isDirty: J,
139
- reset: P,
140
- submit: B
141
- };
30
+ // src/util/useFormEngine.ts
31
+ var H = /* @__PURE__ */ e(u()), U = (e, t) => {
32
+ let n = [];
33
+ return (e || []).forEach((e) => {
34
+ if (n.push(e), Array.isArray(e.subforms) && e.subforms.length) {
35
+ let r = e?.id || e?.props?.id, i = r ? t[r] : void 0;
36
+ e.subforms.forEach((e) => {
37
+ (Array.isArray(i) ? i.includes(e.conditionValue) : e.conditionValue === i) && n.push(...U(e.data || [], t));
38
+ });
39
+ }
40
+ }), n;
41
+ }, W = (e) => e?.id || e?.props?.id || "", G = (e, t) => !e?.visibleWhen || C(e.visibleWhen, t), K = (e, t) => e?.optionsMap && e?.dependsOn ? e.optionsMap[t[e.dependsOn]] || [] : e?.props?.options;
42
+ function q(e, r = {}) {
43
+ let { resolver: i } = r, a = r.messages?.required || "This field is required", s = L(() => {
44
+ let t = { ...r.initialValues || {} };
45
+ return U(e, t).forEach((e) => {
46
+ let n = W(e), r = e?.props?.value;
47
+ n && t[n] === void 0 && r !== void 0 && (t[n] = r);
48
+ }), t;
49
+ }, []), [c, l] = z(s), [u, d] = z([]), f = R(s), p = I((t) => {
50
+ let n = { ...t };
51
+ return U(e, n).forEach((e) => {
52
+ let t = W(e);
53
+ if (t && e.visibleWhen && !C(e.visibleWhen, n) && delete n[t], t && e.optionsMap && e.dependsOn) {
54
+ let r = (e.optionsMap[n[e.dependsOn]] || []).map((e) => typeof e == "string" ? e : e?.value), i = n[t];
55
+ i != null && i !== "" && !r.includes(i) && delete n[t];
56
+ }
57
+ }), (e || []).forEach((e) => {
58
+ if (!Array.isArray(e.subforms) || !e.subforms.length) return;
59
+ let t = W(e), r = t ? n[t] : void 0, i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
60
+ e.subforms.forEach((e) => {
61
+ let t = Array.isArray(r) ? r.includes(e.conditionValue) : e.conditionValue === r;
62
+ (e.data || []).forEach((e) => {
63
+ let n = W(e);
64
+ n && (t ? i : a).add(n);
65
+ });
66
+ }), a.forEach((e) => {
67
+ i.has(e) || delete n[e];
68
+ });
69
+ }), U(e, n).forEach((e) => {
70
+ let t = W(e);
71
+ t && e.formula && (n[t] = m(e.formula, n));
72
+ }), n;
73
+ }, [e]), h = I((e, t) => {
74
+ l((n) => p({
75
+ ...n,
76
+ [e]: t
77
+ }));
78
+ }, [p]), g = I((e) => {
79
+ l((t) => p({
80
+ ...t,
81
+ ...e || {}
82
+ }));
83
+ }, [p]), _ = I((r) => {
84
+ let s = U(e, r), c = [], l = /* @__PURE__ */ new Set();
85
+ if (s.forEach((e) => {
86
+ let t = W(e);
87
+ t && !G(e, r) && l.add(t);
88
+ }), s.forEach((e) => {
89
+ let i = W(e);
90
+ if (!i || l.has(i)) return;
91
+ let s = [...e?.rules?.validation || []], u = s.some((e) => n.includes(e.rule));
92
+ if (e.requiredWhen && !u && C(e.requiredWhen, r) && s.push({
93
+ rule: "mandatory",
94
+ message: e.requiredMessage || a
95
+ }), !s.length) return;
96
+ let d = r[i], f = d == null ? "" : String(d), p = s.some((e) => n.includes(e.rule));
97
+ s.forEach((e) => {
98
+ let s = o[e.rule];
99
+ if (s) {
100
+ if (!f && !p) return;
101
+ let t = r[e.field ?? e.value];
102
+ s(f, t == null ? "" : String(t)) || c.push({
103
+ id: i,
104
+ rule: e.rule,
105
+ message: e.message
106
+ });
107
+ return;
108
+ }
109
+ let l = t[e.rule];
110
+ if (typeof l != "function") return;
111
+ let u = n.includes(e.rule);
112
+ (f || u) && (l(u ? d : f, e.value) || c.push({
113
+ id: i,
114
+ rule: e.rule,
115
+ message: e.message || (u ? a : "")
116
+ }));
117
+ });
118
+ }), i) {
119
+ let e = [];
120
+ try {
121
+ e = i(r) || [];
122
+ } catch {
123
+ e = [];
124
+ }
125
+ e.forEach((e) => {
126
+ e && e.id && !l.has(e.id) && c.push({
127
+ id: e.id,
128
+ rule: e.rule || "schema",
129
+ message: e.message
130
+ });
131
+ });
132
+ }
133
+ return c;
134
+ }, [
135
+ e,
136
+ i,
137
+ a
138
+ ]), v = I(() => {
139
+ let e = _(c);
140
+ return d(e), e;
141
+ }, [_, c]), y = I((e) => {
142
+ let t = _(c);
143
+ return d(t), t.length === 0 && e && e({ ...c }), t;
144
+ }, [_, c]), b = I(() => {
145
+ l({ ...f.current }), d([]);
146
+ }, []), x = L(() => {
147
+ let t = /* @__PURE__ */ new Map();
148
+ return u.forEach((e) => {
149
+ e.id && !t.has(e.id) && t.set(e.id, e.message);
150
+ }), U(e, c).map((e) => {
151
+ let r = W(e), i = (e?.rules?.validation || []).some((e) => n.includes(e.rule)) || !!(e.requiredWhen && C(e.requiredWhen, c));
152
+ return {
153
+ id: r,
154
+ field: e,
155
+ value: e.formula ? m(e.formula, c) : c[r],
156
+ visible: G(e, c),
157
+ disabled: !!(e.disabledWhen && C(e.disabledWhen, c)),
158
+ required: i,
159
+ options: K(e, c),
160
+ error: t.get(r)
161
+ };
162
+ });
163
+ }, [
164
+ e,
165
+ c,
166
+ u
167
+ ]), S = L(() => x.filter((e) => e.visible), [x]), w = I((e) => x.find((t) => t.id === e), [x]), T = L(() => !(0, H.default)(c, f.current), [c]);
168
+ return {
169
+ values: c,
170
+ errors: u,
171
+ fields: x,
172
+ visibleFields: S,
173
+ getFieldState: w,
174
+ setValue: h,
175
+ setValues: g,
176
+ validate: v,
177
+ isValid: u.length === 0,
178
+ isDirty: T,
179
+ reset: b,
180
+ submit: y
181
+ };
142
182
  }
143
- const se = /* @__PURE__ */ new Set(["typography", "divider", "alert", "image", "imagelist", "hyperlink", "button"]), _ = (e) => e?.id || e?.props?.id, z = (e, n = /* @__PURE__ */ new Set()) => ((e || []).forEach((r) => {
144
- const h = _(r);
145
- h && n.add(h), Array.isArray(r?.subforms) && r.subforms.forEach((u) => z(u?.data || [], n));
146
- }), n), G = (e) => {
147
- if (!e || typeof e != "object") return [];
148
- if (typeof e.field == "string") return [e.field];
149
- const n = e.all || e.any || e.none;
150
- return Array.isArray(n) ? n.flatMap(G) : [];
151
- }, ne = (e) => (Array.isArray(e) ? e : []).map((n) => typeof n == "string" ? n : n?.value);
152
- function le(e) {
153
- const n = [], r = z(e), h = (u) => {
154
- const l = /* @__PURE__ */ new Set();
155
- (u || []).forEach((t) => {
156
- const a = _(t), w = t?.type;
157
- if (!a && !se.has(w) && n.push({ level: "warning", code: "missing-id", message: `A "${w || "field"}" has no id; its value can't be captured.` }), a && (l.has(a) && n.push({ level: "error", code: "duplicate-id", field: a, message: `Duplicate field id "${a}" among siblings — their values will collide.` }), l.add(a)), t?.dependsOn && !t?.optionsMap && n.push({ level: "warning", code: "depends-without-options", field: a, message: `"${a}" has \`dependsOn\` but no \`optionsMap\`, so its options never change.` }), t?.optionsMap && !t?.dependsOn && n.push({ level: "warning", code: "options-without-depends", field: a, message: `"${a}" has \`optionsMap\` but no \`dependsOn\`, so it can't pick a branch.` }), t?.dependsOn && !r.has(t.dependsOn) && n.push({ level: "error", code: "unknown-depends-target", field: a, message: `"${a}" dependsOn "${t.dependsOn}", which is not a field in this schema.` }), ["visibleWhen", "disabledWhen", "requiredWhen"].forEach((m) => {
158
- G(t?.[m]).forEach((v) => {
159
- r.has(v) || n.push({ level: "error", code: "unknown-rule-field", field: a, message: `"${a}" ${m} references field "${v}", which does not exist.` });
160
- });
161
- }), (t?.rules?.validation || []).forEach((m) => {
162
- m?.field && /Field$/.test(m?.rule || "") && !r.has(m.field) && n.push({ level: "error", code: "unknown-cross-field", field: a, message: `"${a}" rule "${m.rule}" compares against "${m.field}", which does not exist.` });
163
- }), Array.isArray(t?.subforms) && t.subforms.length) {
164
- const m = ne(t?.props?.options);
165
- m.length && t.subforms.forEach((v) => {
166
- v?.conditionValue !== void 0 && !m.includes(v.conditionValue) && n.push({ level: "warning", code: "subform-condition-not-an-option", field: a, message: `"${a}" has a subform for value "${v.conditionValue}", which isn't one of its options.` });
167
- }), t.subforms.forEach((v) => h(v?.data || []));
168
- }
169
- });
170
- };
171
- return h(e), n;
183
+ // src/util/validateSchema.ts
184
+ var J = /* @__PURE__ */ new Set([
185
+ "typography",
186
+ "divider",
187
+ "alert",
188
+ "image",
189
+ "imagelist",
190
+ "hyperlink",
191
+ "button"
192
+ ]), Y = (e) => e?.id || e?.props?.id, X = (e, t = /* @__PURE__ */ new Set()) => ((e || []).forEach((e) => {
193
+ let n = Y(e);
194
+ n && t.add(n), Array.isArray(e?.subforms) && e.subforms.forEach((e) => X(e?.data || [], t));
195
+ }), t), Z = (e) => {
196
+ if (!e || typeof e != "object") return [];
197
+ if (typeof e.field == "string") return [e.field];
198
+ let t = e.all || e.any || e.none;
199
+ return Array.isArray(t) ? t.flatMap(Z) : [];
200
+ }, Q = (e) => (Array.isArray(e) ? e : []).map((e) => typeof e == "string" ? e : e?.value);
201
+ function $(e) {
202
+ let t = [], n = X(e), r = (e) => {
203
+ let i = /* @__PURE__ */ new Set();
204
+ (e || []).forEach((e) => {
205
+ let a = Y(e), o = e?.type;
206
+ if (!a && !J.has(o) && t.push({
207
+ level: "warning",
208
+ code: "missing-id",
209
+ message: `A "${o || "field"}" has no id; its value can't be captured.`
210
+ }), a && (i.has(a) && t.push({
211
+ level: "error",
212
+ code: "duplicate-id",
213
+ field: a,
214
+ message: `Duplicate field id "${a}" among siblings — their values will collide.`
215
+ }), i.add(a)), e?.dependsOn && !e?.optionsMap && t.push({
216
+ level: "warning",
217
+ code: "depends-without-options",
218
+ field: a,
219
+ message: `"${a}" has \`dependsOn\` but no \`optionsMap\`, so its options never change.`
220
+ }), e?.optionsMap && !e?.dependsOn && t.push({
221
+ level: "warning",
222
+ code: "options-without-depends",
223
+ field: a,
224
+ message: `"${a}" has \`optionsMap\` but no \`dependsOn\`, so it can't pick a branch.`
225
+ }), e?.dependsOn && !n.has(e.dependsOn) && t.push({
226
+ level: "error",
227
+ code: "unknown-depends-target",
228
+ field: a,
229
+ message: `"${a}" dependsOn "${e.dependsOn}", which is not a field in this schema.`
230
+ }), [
231
+ "visibleWhen",
232
+ "disabledWhen",
233
+ "requiredWhen"
234
+ ].forEach((r) => {
235
+ Z(e?.[r]).forEach((e) => {
236
+ n.has(e) || t.push({
237
+ level: "error",
238
+ code: "unknown-rule-field",
239
+ field: a,
240
+ message: `"${a}" ${r} references field "${e}", which does not exist.`
241
+ });
242
+ });
243
+ }), (e?.rules?.validation || []).forEach((e) => {
244
+ e?.field && /Field$/.test(e?.rule || "") && !n.has(e.field) && t.push({
245
+ level: "error",
246
+ code: "unknown-cross-field",
247
+ field: a,
248
+ message: `"${a}" rule "${e.rule}" compares against "${e.field}", which does not exist.`
249
+ });
250
+ }), Array.isArray(e?.subforms) && e.subforms.length) {
251
+ let n = Q(e?.props?.options);
252
+ n.length && e.subforms.forEach((e) => {
253
+ e?.conditionValue !== void 0 && !n.includes(e.conditionValue) && t.push({
254
+ level: "warning",
255
+ code: "subform-condition-not-an-option",
256
+ field: a,
257
+ message: `"${a}" has a subform for value "${e.conditionValue}", which isn't one of its options.`
258
+ });
259
+ }), e.subforms.forEach((e) => r(e?.data || []));
260
+ }
261
+ });
262
+ };
263
+ return r(e), t;
172
264
  }
173
- function ce(e) {
174
- return e;
265
+ // src/schema.ts
266
+ function ee(e) {
267
+ return e;
175
268
  }
176
- export {
177
- pe as AIFill,
178
- fe as AIForm,
179
- me as AIFormGenerator,
180
- ge as AISchemaReview,
181
- ve as AITextAssist,
182
- ye as AIVisionImport,
183
- be as ClearFormData,
184
- Ae as Controls,
185
- Ee as DynamicComponent,
186
- we as FormData,
187
- Me as FormGenerator,
188
- Se as MuiConfig,
189
- Fe as configureMuiX,
190
- Ie as createAIClient,
191
- ce as defineForm,
192
- Oe as formFieldsToSimple,
193
- Ve as getMuiX,
194
- $e as getRegisteredControl,
195
- Ce as hasRegisteredControl,
196
- We as registerControl,
197
- qe as registerControls,
198
- Re as registeredControlTypes,
199
- De as resetMuiX,
200
- ke as simpleFieldsToFormFields,
201
- Te as slug,
202
- Le as unregisterControl,
203
- _e as useAIAssist,
204
- ze as useForm,
205
- de as useFormEngine,
206
- le as validateSchema,
207
- ae as yupResolver,
208
- te as zodResolver
209
- };
269
+ export { D as AIFill, j as AIForm, A as AIFormGenerator, k as AISchemaReview, x as AITextAssist, E as AIVisionImport, y as ClearFormData, d as Controls, a as DynamicComponent, O as FormData, T as FormGenerator, c as MuiConfig, F as configureMuiX, _ as createAIClient, ee as defineForm, w as formFieldsToSimple, N as getMuiX, S as getRegisteredControl, f as hasRegisteredControl, r as migrateFormData, i as migrateFormField, p as registerControl, h as registerControls, s as registeredControlTypes, P as resetMuiX, M as simpleFieldsToFormFields, v as slug, l as unregisterControl, g as useAIAssist, b as useForm, q as useFormEngine, $ as validateSchema, V as yupResolver, B as zodResolver };
@@ -0,0 +1,117 @@
1
+ import { B as e, U as t } from "./ai-UvDYQ30b.mjs";
2
+ import { n } from "./useSyncedState-CzAO4D1o.mjs";
3
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
4
+ import a from "@mui/material/TextField";
5
+ import o from "@mui/material/FormControl";
6
+ import s from "@mui/material/FormLabel";
7
+ import c from "@mui/material/Button";
8
+ import l from "@mui/material/IconButton";
9
+ import u from "@mui/material/Table";
10
+ import d from "@mui/material/TableBody";
11
+ import f from "@mui/material/TableCell";
12
+ import p from "@mui/material/TableContainer";
13
+ import m from "@mui/material/TableHead";
14
+ import h from "@mui/material/TableRow";
15
+ import g from "@mui/material/Paper";
16
+ import _ from "@mui/icons-material/Add";
17
+ import v from "@mui/icons-material/Close";
18
+ // src/components/controls/EditableTable/editabletable.tsx
19
+ function y(e) {
20
+ return Array.isArray(e) ? e.map((e) => ({ ...e || {} })) : [];
21
+ }
22
+ function b({ attributes: b = {}, onChange: x }) {
23
+ let { MuiAttributes: S = {}, id: C = "", columns: w = [], addLabel: T = "Add row", label: E } = b, { sx: D, ...O } = S, k = Array.isArray(w) ? w : [], [A, j] = n(() => y(b.value), [b.value]), M = (e) => {
24
+ x?.({
25
+ id: C,
26
+ value: e
27
+ });
28
+ }, N = (e, t, n) => {
29
+ let r = A.map((r, i) => i === e ? {
30
+ ...r,
31
+ [t]: n
32
+ } : r);
33
+ j(r), M(r);
34
+ }, P = () => {
35
+ let e = [...A, {}];
36
+ j(e), M(e);
37
+ }, F = (e) => {
38
+ let t = A.filter((t, n) => n !== e);
39
+ j(t), M(t);
40
+ };
41
+ return /* @__PURE__ */ i(o, {
42
+ component: "fieldset",
43
+ fullWidth: !0,
44
+ children: [
45
+ E && /* @__PURE__ */ r(s, {
46
+ component: "legend",
47
+ sx: { mb: 1 },
48
+ children: E
49
+ }),
50
+ /* @__PURE__ */ r(p, {
51
+ component: g,
52
+ variant: "outlined",
53
+ sx: {
54
+ borderRadius: 2,
55
+ overflow: "hidden"
56
+ },
57
+ children: /* @__PURE__ */ i(u, {
58
+ size: "small",
59
+ children: [/* @__PURE__ */ r(m, { children: /* @__PURE__ */ i(h, {
60
+ sx: { backgroundColor: "action.hover" },
61
+ children: [k.map((e) => /* @__PURE__ */ r(f, {
62
+ sx: { fontWeight: 600 },
63
+ children: e.label
64
+ }, e.key)), /* @__PURE__ */ r(f, {
65
+ align: "right",
66
+ sx: { width: 48 }
67
+ })]
68
+ }) }), /* @__PURE__ */ r(d, { children: A.map((n, o) => /* @__PURE__ */ i(h, {
69
+ sx: {
70
+ transition: "background-color 150ms cubic-bezier(0.4, 0, 0.2, 1)",
71
+ "&:hover": { backgroundColor: "action.hover" }
72
+ },
73
+ children: [k.map((i) => /* @__PURE__ */ r(f, { children: /* @__PURE__ */ r(a, {
74
+ ...O,
75
+ type: i.type === "number" ? "number" : "text",
76
+ value: n[i.key] ?? "",
77
+ onChange: (e) => N(o, i.key, e.target.value),
78
+ size: "small",
79
+ variant: "standard",
80
+ fullWidth: !0,
81
+ sx: e(t, D),
82
+ slotProps: { htmlInput: { "aria-label": `${i.label} row ${o + 1}` } }
83
+ }) }, i.key)), /* @__PURE__ */ r(f, {
84
+ align: "right",
85
+ children: /* @__PURE__ */ r(l, {
86
+ "aria-label": `Remove row ${o + 1}`,
87
+ onClick: () => F(o),
88
+ size: "small",
89
+ sx: {
90
+ borderRadius: 2,
91
+ color: "text.secondary",
92
+ "&:hover": { color: "error.main" }
93
+ },
94
+ children: /* @__PURE__ */ r(v, { fontSize: "small" })
95
+ })
96
+ })]
97
+ }, o)) })]
98
+ })
99
+ }),
100
+ /* @__PURE__ */ r(c, {
101
+ onClick: P,
102
+ startIcon: /* @__PURE__ */ r(_, {}),
103
+ size: "small",
104
+ variant: "text",
105
+ sx: {
106
+ alignSelf: "flex-start",
107
+ mt: 1,
108
+ borderRadius: 2,
109
+ textTransform: "none",
110
+ fontWeight: 600
111
+ },
112
+ children: T
113
+ })
114
+ ]
115
+ });
116
+ }
117
+ export { b as default };
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-5iZMYShA.js"),t=require("./ai-BFpA3uHx.js"),n=require("./useSyncedState-DYNKkpDv.js");let r=require("react/jsx-runtime"),i=require("@mui/material/TextField");i=e.n(i);let a=require("@mui/material/FormControl");a=e.n(a);let o=require("@mui/material/FormLabel");o=e.n(o);let s=require("@mui/material/Button");s=e.n(s);let c=require("@mui/material/IconButton");c=e.n(c);let l=require("@mui/material/Table");l=e.n(l);let u=require("@mui/material/TableBody");u=e.n(u);let d=require("@mui/material/TableCell");d=e.n(d);let f=require("@mui/material/TableContainer");f=e.n(f);let p=require("@mui/material/TableHead");p=e.n(p);let m=require("@mui/material/TableRow");m=e.n(m);let h=require("@mui/material/Paper");h=e.n(h);let g=require("@mui/icons-material/Add");g=e.n(g);let _=require("@mui/icons-material/Close");_=e.n(_);function v(e){return Array.isArray(e)?e.map(e=>({...e||{}})):[]}function y({attributes:e={},onChange:y}){let{MuiAttributes:b={},id:x=``,columns:S=[],addLabel:C=`Add row`,label:w}=e,{sx:T,...E}=b,D=Array.isArray(S)?S:[],[O,k]=n.n(()=>v(e.value),[e.value]),A=e=>{y?.({id:x,value:e})},j=(e,t,n)=>{let r=O.map((r,i)=>i===e?{...r,[t]:n}:r);k(r),A(r)},M=()=>{let e=[...O,{}];k(e),A(e)},N=e=>{let t=O.filter((t,n)=>n!==e);k(t),A(t)};return(0,r.jsxs)(a.default,{component:`fieldset`,fullWidth:!0,children:[w&&(0,r.jsx)(o.default,{component:`legend`,sx:{mb:1},children:w}),(0,r.jsx)(f.default,{component:h.default,variant:`outlined`,sx:{borderRadius:2,overflow:`hidden`},children:(0,r.jsxs)(l.default,{size:`small`,children:[(0,r.jsx)(p.default,{children:(0,r.jsxs)(m.default,{sx:{backgroundColor:`action.hover`},children:[D.map(e=>(0,r.jsx)(d.default,{sx:{fontWeight:600},children:e.label},e.key)),(0,r.jsx)(d.default,{align:`right`,sx:{width:48}})]})}),(0,r.jsx)(u.default,{children:O.map((e,n)=>(0,r.jsxs)(m.default,{sx:{transition:`background-color 150ms cubic-bezier(0.4, 0, 0.2, 1)`,"&:hover":{backgroundColor:`action.hover`}},children:[D.map(a=>(0,r.jsx)(d.default,{children:(0,r.jsx)(i.default,{...E,type:a.type===`number`?`number`:`text`,value:e[a.key]??``,onChange:e=>j(n,a.key,e.target.value),size:`small`,variant:`standard`,fullWidth:!0,sx:t.B(t.U,T),slotProps:{htmlInput:{"aria-label":`${a.label} row ${n+1}`}}})},a.key)),(0,r.jsx)(d.default,{align:`right`,children:(0,r.jsx)(c.default,{"aria-label":`Remove row ${n+1}`,onClick:()=>N(n),size:`small`,sx:{borderRadius:2,color:`text.secondary`,"&:hover":{color:`error.main`}},children:(0,r.jsx)(_.default,{fontSize:`small`})})})]},n))})]})}),(0,r.jsx)(s.default,{onClick:M,startIcon:(0,r.jsx)(g.default,{}),size:`small`,variant:`text`,sx:{alignSelf:`flex-start`,mt:1,borderRadius:2,textTransform:`none`,fontWeight:600},children:C})]})}exports.default=y;
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-5iZMYShA.js"),t=require("./ai-BFpA3uHx.js"),n=require("./validation-B7DPZ218.js"),r=require("./useSyncedState-DYNKkpDv.js"),i=require("./s3Upload-C3-wcrua.js");let a=require("react"),o=require("@mui/material/Typography");o=e.n(o);let s=require("react/jsx-runtime"),c=require("@mui/material/Box");c=e.n(c);let l=require("@mui/material/IconButton");l=e.n(l);let u=require("@mui/material/CircularProgress");u=e.n(u);let d=require("@mui/icons-material/CloudUpload");d=e.n(d);let f=require("@mui/icons-material/Close");f=e.n(f);let p=require("@mui/icons-material/InsertDriveFile");p=e.n(p);var m=e=>e?Array.isArray(e)?e.filter(Boolean):[e]:[],h=e=>/^data:image\//i.test(e)||/\.(png|jpe?g|gif|webp|bmp|svg)(\?.*)?$/i.test(e),g=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result||``),r.onerror=()=>n(r.error),r.readAsDataURL(e)});function _({attributes:e={},rules:_={},onChange:v}){let{id:y=``,multiple:b=!1,accept:x=``,bucket:S=``,region:C=``,identityPoolId:w=``,path:T=``,maxSizeMB:E=0,label:D=`Upload file`,MuiAttributes:O={}}=e,k=(0,a.useRef)(null),[A,j]=r.n(()=>m(e.value),[e.value]),[M,N]=(0,a.useState)(!1),[P,F]=(0,a.useState)(!1),[I,L]=(0,a.useState)(``),R=n.r(_),z=(e,t)=>{v?.({id:y,value:b?e:e[0]??``,option:t})},B=async e=>{let t=Array.from(e);if(!t.length)return;L(``),F(!0);let n=[],r=[];try{for(let e of t){if(E&&e.size>E*1024*1024){L(`"${e.name}" exceeds the ${E}MB limit.`);continue}let t=await g(e),a=await i.t(t,e.name,S,C,w,T);n.push(a),r.push(e)}}catch(e){console.error(`FileUpload failed`,e),L(`Upload failed. Please try again.`)}finally{F(!1)}if(!n.length)return;let a=b?[...A,...n]:n.slice(0,1);j(a),z(a,r)},V=e=>{e.target.files&&B(e.target.files),e.target.value=``},H=e=>{e.preventDefault(),N(!1),e.dataTransfer?.files?.length&&B(e.dataTransfer.files)},U=e=>{let t=A.filter((t,n)=>n!==e);j(t),z(t)};return(0,s.jsxs)(c.default,{sx:{width:`100%`,...O.sx},children:[(0,s.jsxs)(o.default,{variant:`subtitle2`,gutterBottom:!0,sx:{display:`flex`},children:[D,R&&(0,s.jsx)(c.default,{component:`span`,sx:{color:`error.main`,ml:.5},children:`*`})]}),(0,s.jsx)(`input`,{ref:k,type:`file`,hidden:!0,multiple:b,accept:x||void 0,onChange:V}),(0,s.jsxs)(c.default,{role:`button`,"aria-label":D,onClick:()=>k.current?.click(),onDragOver:e=>{e.preventDefault(),N(!0)},onDragLeave:()=>N(!1),onDrop:H,sx:{border:`2px dashed`,borderColor:M?`primary.main`:`divider`,borderRadius:`12px`,p:3,textAlign:`center`,cursor:`pointer`,transition:`all .2s`,bgcolor:M?`action.hover`:`background.paper`,"&:hover":{borderColor:`primary.main`,bgcolor:`action.hover`}},children:[P?(0,s.jsx)(u.default,{size:28}):(0,s.jsx)(d.default,{sx:{fontSize:40,color:`primary.main`}}),(0,s.jsxs)(o.default,{variant:`body2`,sx:{mt:1},children:[`Drag & drop `,b?`files`:`a file`,` here, or click to browse`]}),x&&(0,s.jsxs)(o.default,{variant:`caption`,sx:{color:`text.secondary`},children:[`Accepted: `,x]})]}),I&&(0,s.jsx)(o.default,{variant:`caption`,sx:{color:`error.main`,display:`block`,mt:1},children:I}),A.length>0&&(0,s.jsx)(c.default,{sx:t.B(t.W,{mt:1.5,p:1}),children:A.map((e,t)=>(0,s.jsxs)(c.default,{sx:{display:`flex`,alignItems:`center`,gap:1.5,p:1,borderRadius:`8px`,transition:`background-color .18s`,"&:hover":{bgcolor:`action.hover`}},children:[h(e)?(0,s.jsx)(c.default,{component:`img`,src:e,alt:`upload-${t}`,sx:{width:40,height:40,objectFit:`cover`,borderRadius:`8px`,flexShrink:0}}):(0,s.jsx)(p.default,{color:`action`,sx:{flexShrink:0}}),(0,s.jsx)(o.default,{variant:`body2`,sx:{flexGrow:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.split(`/`).pop()?.split(`?`)[0]||e}),(0,s.jsx)(l.default,{size:`small`,"aria-label":`remove`,onClick:e=>{e.stopPropagation(),U(t)},children:(0,s.jsx)(f.default,{fontSize:`small`})})]},`${e}-${t}`))})]})}exports.default=_;