@overmap-ai/forms 1.0.32-react-flow-david-fixes.41 → 1.0.33-condition-optimizations.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 (117) hide show
  1. package/dist/form/Observable/index.d.ts +1 -0
  2. package/dist/form/UUIDFile/UUIDFile.d.ts +5 -0
  3. package/dist/form/UUIDFile/index.d.ts +1 -0
  4. package/dist/form/{fields/UploadField → UUIDPromise}/UUIDPromise.d.ts +3 -3
  5. package/dist/form/UUIDPromise/index.d.ts +2 -0
  6. package/dist/form/UUIDPromise/utils.d.ts +4 -0
  7. package/dist/form/builder/Root.d.ts +1 -1
  8. package/dist/form/builder/components/CreateFieldDropdownMenu.d.ts +8 -0
  9. package/dist/form/builder/components/FieldBuilder.d.ts +2 -2
  10. package/dist/form/builder/components/FieldBuilderWithActions.d.ts +9 -0
  11. package/dist/form/builder/components/index.d.ts +2 -1
  12. package/dist/form/builder/hooks.d.ts +1 -1
  13. package/dist/form/builder/list/FieldSectionWithActions.d.ts +1 -1
  14. package/dist/form/builder/utils.d.ts +2 -2
  15. package/dist/form/components/DisplayFile.d.ts +9 -0
  16. package/dist/form/components/index.d.ts +1 -0
  17. package/dist/form/conditions/BaseCondition/BaseCondition.d.ts +10 -9
  18. package/dist/form/conditions/BaseCondition/typings.d.ts +4 -4
  19. package/dist/form/conditions/BooleanFieldCondition/BooleanFieldCondition.d.ts +4 -6
  20. package/dist/form/conditions/CheckboxListFieldCondition/CheckboxListFieldCondition.d.ts +4 -6
  21. package/dist/form/conditions/ConditionManager/ConditionManager.d.ts +15 -0
  22. package/dist/form/conditions/ConditionManager/hooks.d.ts +4 -0
  23. package/dist/form/conditions/ConditionManager/index.d.ts +3 -0
  24. package/dist/form/conditions/ConditionManager/typings.d.ts +2 -0
  25. package/dist/form/conditions/DateFieldCondition/DateFieldCondition.d.ts +5 -7
  26. package/dist/form/conditions/MultiSelectFieldCondition/MultiSelectFieldCondition.d.ts +4 -14
  27. package/dist/form/conditions/MultiStringFieldCondition/MultiStringFieldCondition.d.ts +4 -6
  28. package/dist/form/conditions/NumberFieldCondition/NumberFieldCondition.d.ts +4 -17
  29. package/dist/form/conditions/OTPFieldCondition/OTPFieldCondition.d.ts +4 -6
  30. package/dist/form/conditions/PassFailFieldCondition/PassFailFieldCondition.d.ts +18 -0
  31. package/dist/form/conditions/PassFailFieldCondition/PassFailFieldConditionCell.d.ts +6 -0
  32. package/dist/form/conditions/PassFailFieldCondition/index.d.ts +3 -0
  33. package/dist/form/conditions/PassFailFieldCondition/typings.d.ts +4 -0
  34. package/dist/form/conditions/RadioFieldCondition/RadioFieldCondition.d.ts +4 -6
  35. package/dist/form/conditions/RatingFieldCondition/RatingFieldCondition.d.ts +21 -0
  36. package/dist/form/conditions/RatingFieldCondition/RatingFieldConditionCell.d.ts +6 -0
  37. package/dist/form/conditions/RatingFieldCondition/index.d.ts +3 -0
  38. package/dist/form/conditions/RatingFieldCondition/typings.d.ts +4 -0
  39. package/dist/form/conditions/ScanFieldCondition/ScanFieldCondition.d.ts +4 -6
  40. package/dist/form/conditions/SelectFieldCondition/SelectFieldCondition.d.ts +4 -6
  41. package/dist/form/conditions/StringFieldCondition/StringFieldCondition.d.ts +4 -6
  42. package/dist/form/conditions/TextFieldCondition/TextFieldCondition.d.ts +4 -6
  43. package/dist/form/conditions/UploadFieldCondition/UploadFieldCondition.d.ts +8 -8
  44. package/dist/form/conditions/constants.d.ts +32 -0
  45. package/dist/form/conditions/index.d.ts +3 -0
  46. package/dist/form/conditions/typings.d.ts +6 -3
  47. package/dist/form/conditions/utils.d.ts +3 -6
  48. package/dist/form/fields/BaseField/BaseField.d.ts +6 -7
  49. package/dist/form/fields/BaseField/typings.d.ts +3 -4
  50. package/dist/form/fields/BaseFormElement/BaseFormElement.d.ts +9 -9
  51. package/dist/form/fields/BaseFormElement/typings.d.ts +3 -3
  52. package/dist/form/fields/BaseOptionsField/BaseOptionsField.d.ts +7 -7
  53. package/dist/form/fields/BaseOptionsField/typings.d.ts +2 -2
  54. package/dist/form/fields/BaseStringField/BaseStringField.d.ts +4 -4
  55. package/dist/form/fields/BaseStringField/typings.d.ts +1 -1
  56. package/dist/form/fields/BooleanField/BooleanField.d.ts +3 -4
  57. package/dist/form/fields/BooleanField/BooleanInput.d.ts +1 -1
  58. package/dist/form/fields/CheckboxListField/CheckboxListField.d.ts +2 -2
  59. package/dist/form/fields/DateField/DateField.d.ts +2 -2
  60. package/dist/form/fields/DateField/DateInput.d.ts +1 -1
  61. package/dist/form/fields/FieldSection/FieldSection.d.ts +6 -8
  62. package/dist/form/fields/FieldSection/typings.d.ts +2 -2
  63. package/dist/form/fields/MultiSelectField/MultiSelectField.d.ts +2 -2
  64. package/dist/form/fields/MultiSelectField/MultiSelectInput.d.ts +1 -1
  65. package/dist/form/fields/MultiStringField/MultiStringField.d.ts +2 -2
  66. package/dist/form/fields/MultiStringField/MultiStringInput.d.ts +1 -1
  67. package/dist/form/fields/NumberField/NumberField.d.ts +2 -2
  68. package/dist/form/fields/NumberField/NumberInput.d.ts +1 -1
  69. package/dist/form/fields/OneTimePasswordField/OTPField.d.ts +2 -2
  70. package/dist/form/fields/OneTimePasswordField/typings.d.ts +1 -1
  71. package/dist/form/fields/PassFailField/PassFailField.d.ts +30 -0
  72. package/dist/form/fields/PassFailField/PassFailInput.d.ts +7 -0
  73. package/dist/form/fields/PassFailField/constants.d.ts +7 -0
  74. package/dist/form/fields/PassFailField/index.d.ts +5 -0
  75. package/dist/form/fields/PassFailField/typings.d.ts +17 -0
  76. package/dist/form/fields/PassFailField/utils.d.ts +7 -0
  77. package/dist/form/fields/RadioField/RadioField.d.ts +2 -2
  78. package/dist/form/fields/RadioField/RadioInput.d.ts +1 -1
  79. package/dist/form/fields/RatingField/RatingField.d.ts +32 -0
  80. package/dist/form/fields/RatingField/RatingInput.d.ts +7 -0
  81. package/dist/form/fields/RatingField/index.d.ts +3 -0
  82. package/dist/form/fields/RatingField/typings.d.ts +4 -0
  83. package/dist/form/fields/ScanField/ScanField.d.ts +2 -2
  84. package/dist/form/fields/ScanField/ScanInput.d.ts +1 -1
  85. package/dist/form/fields/SelectField/SelectField.d.ts +2 -2
  86. package/dist/form/fields/SelectField/SelectInput.d.ts +1 -1
  87. package/dist/form/fields/StringField/StringField.d.ts +1 -1
  88. package/dist/form/fields/StringField/StringInput.d.ts +1 -1
  89. package/dist/form/fields/TextField/TextField.d.ts +1 -1
  90. package/dist/form/fields/TextField/TextInput.d.ts +1 -1
  91. package/dist/form/fields/UploadField/UploadField.d.ts +11 -10
  92. package/dist/form/fields/UploadField/UploadInput.d.ts +1 -1
  93. package/dist/form/fields/UploadField/index.d.ts +0 -1
  94. package/dist/form/fields/UploadField/utils.d.ts +0 -3
  95. package/dist/form/fields/components/InputWithLabel.d.ts +1 -1
  96. package/dist/form/fields/constants.d.ts +7 -3
  97. package/dist/form/fields/hooks.d.ts +1 -1
  98. package/dist/form/fields/index.d.ts +2 -0
  99. package/dist/form/fields/typings.d.ts +14 -16
  100. package/dist/form/fields/utils.d.ts +7 -2
  101. package/dist/form/index.d.ts +3 -0
  102. package/dist/form/modifiers/conditionModifier.d.ts +3 -3
  103. package/dist/form/modifiers/file.d.ts +3 -2
  104. package/dist/form/modifiers/index.d.ts +1 -0
  105. package/dist/form/modifiers/passFailStatus.d.ts +6 -0
  106. package/dist/form/modifiers/typings.d.ts +2 -0
  107. package/dist/form/modifiers/utils.d.ts +1 -1
  108. package/dist/form/schema/FieldSchema.d.ts +7 -6
  109. package/dist/form/typings.d.ts +6 -2
  110. package/dist/form/utils.d.ts +4 -11
  111. package/dist/forms.js +2256 -832
  112. package/dist/forms.js.map +1 -0
  113. package/dist/forms.umd.cjs +2254 -830
  114. package/dist/forms.umd.cjs.map +1 -0
  115. package/package.json +37 -51
  116. package/dist/form/builder/components/FieldWithActions.d.ts +0 -10
  117. /package/dist/form/{observable → Observable}/Observable.d.ts +0 -0
@@ -5,11 +5,609 @@
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
7
 
8
+ /**
9
+ * @license lucide-react v0.542.0 - ISC
10
+ *
11
+ * This source code is licensed under the ISC license.
12
+ * See the LICENSE file in the root directory of this source tree.
13
+ */
14
+ const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
15
+ const toCamelCase = (string) => string.replace(
16
+ /^([A-Z])|[\s-_]+(\w)/g,
17
+ (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
18
+ );
19
+ const toPascalCase = (string) => {
20
+ const camelCase = toCamelCase(string);
21
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
22
+ };
23
+ const mergeClasses = (...classes) => classes.filter((className, index, array) => {
24
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
25
+ }).join(" ").trim();
26
+ const hasA11yProp = (props) => {
27
+ for (const prop in props) {
28
+ if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
29
+ return true;
30
+ }
31
+ }
32
+ };
33
+ /**
34
+ * @license lucide-react v0.542.0 - ISC
35
+ *
36
+ * This source code is licensed under the ISC license.
37
+ * See the LICENSE file in the root directory of this source tree.
38
+ */
39
+ var defaultAttributes = {
40
+ xmlns: "http://www.w3.org/2000/svg",
41
+ width: 24,
42
+ height: 24,
43
+ viewBox: "0 0 24 24",
44
+ fill: "none",
45
+ stroke: "currentColor",
46
+ strokeWidth: 2,
47
+ strokeLinecap: "round",
48
+ strokeLinejoin: "round"
49
+ };
50
+ /**
51
+ * @license lucide-react v0.542.0 - ISC
52
+ *
53
+ * This source code is licensed under the ISC license.
54
+ * See the LICENSE file in the root directory of this source tree.
55
+ */
56
+ const Icon = React.forwardRef(
57
+ ({
58
+ color = "currentColor",
59
+ size = 24,
60
+ strokeWidth = 2,
61
+ absoluteStrokeWidth,
62
+ className = "",
63
+ children,
64
+ iconNode,
65
+ ...rest
66
+ }, ref) => React.createElement(
67
+ "svg",
68
+ {
69
+ ref,
70
+ ...defaultAttributes,
71
+ width: size,
72
+ height: size,
73
+ stroke: color,
74
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
75
+ className: mergeClasses("lucide", className),
76
+ ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
77
+ ...rest
78
+ },
79
+ [
80
+ ...iconNode.map(([tag, attrs]) => React.createElement(tag, attrs)),
81
+ ...Array.isArray(children) ? children : [children]
82
+ ]
83
+ )
84
+ );
85
+ /**
86
+ * @license lucide-react v0.542.0 - ISC
87
+ *
88
+ * This source code is licensed under the ISC license.
89
+ * See the LICENSE file in the root directory of this source tree.
90
+ */
91
+ const createLucideIcon = (iconName, iconNode) => {
92
+ const Component = React.forwardRef(
93
+ ({ className, ...props }, ref) => React.createElement(Icon, {
94
+ ref,
95
+ iconNode,
96
+ className: mergeClasses(
97
+ `lucide-${toKebabCase(toPascalCase(iconName))}`,
98
+ `lucide-${iconName}`,
99
+ className
100
+ ),
101
+ ...props
102
+ })
103
+ );
104
+ Component.displayName = toPascalCase(iconName);
105
+ return Component;
106
+ };
107
+ /**
108
+ * @license lucide-react v0.542.0 - ISC
109
+ *
110
+ * This source code is licensed under the ISC license.
111
+ * See the LICENSE file in the root directory of this source tree.
112
+ */
113
+ const __iconNode$D = [
114
+ ["path", { d: "M3 12h18", key: "1i2n21" }],
115
+ ["path", { d: "M3 18h18", key: "1h113x" }],
116
+ ["path", { d: "M3 6h18", key: "d0wm0j" }]
117
+ ];
118
+ const AlignJustify = createLucideIcon("align-justify", __iconNode$D);
119
+ /**
120
+ * @license lucide-react v0.542.0 - ISC
121
+ *
122
+ * This source code is licensed under the ISC license.
123
+ * See the LICENSE file in the root directory of this source tree.
124
+ */
125
+ const __iconNode$C = [
126
+ ["path", { d: "m3 16 4 4 4-4", key: "1co6wj" }],
127
+ ["path", { d: "M7 20V4", key: "1yoxec" }],
128
+ ["path", { d: "m21 8-4-4-4 4", key: "1c9v7m" }],
129
+ ["path", { d: "M17 4v16", key: "7dpous" }]
130
+ ];
131
+ const ArrowDownUp = createLucideIcon("arrow-down-up", __iconNode$C);
132
+ /**
133
+ * @license lucide-react v0.542.0 - ISC
134
+ *
135
+ * This source code is licensed under the ISC license.
136
+ * See the LICENSE file in the root directory of this source tree.
137
+ */
138
+ const __iconNode$B = [
139
+ ["path", { d: "M8 3 4 7l4 4", key: "9rb6wj" }],
140
+ ["path", { d: "M4 7h16", key: "6tx8e3" }],
141
+ ["path", { d: "m16 21 4-4-4-4", key: "siv7j2" }],
142
+ ["path", { d: "M20 17H4", key: "h6l3hr" }]
143
+ ];
144
+ const ArrowLeftRight = createLucideIcon("arrow-left-right", __iconNode$B);
145
+ /**
146
+ * @license lucide-react v0.542.0 - ISC
147
+ *
148
+ * This source code is licensed under the ISC license.
149
+ * See the LICENSE file in the root directory of this source tree.
150
+ */
151
+ const __iconNode$A = [
152
+ ["path", { d: "M8 2v4", key: "1cmpym" }],
153
+ ["path", { d: "M16 2v4", key: "4m81vk" }],
154
+ ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
155
+ ["path", { d: "M3 10h18", key: "8toen8" }]
156
+ ];
157
+ const Calendar = createLucideIcon("calendar", __iconNode$A);
158
+ /**
159
+ * @license lucide-react v0.542.0 - ISC
160
+ *
161
+ * This source code is licensed under the ISC license.
162
+ * See the LICENSE file in the root directory of this source tree.
163
+ */
164
+ const __iconNode$z = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
165
+ const Check = createLucideIcon("check", __iconNode$z);
166
+ /**
167
+ * @license lucide-react v0.542.0 - ISC
168
+ *
169
+ * This source code is licensed under the ISC license.
170
+ * See the LICENSE file in the root directory of this source tree.
171
+ */
172
+ const __iconNode$y = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
173
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$y);
174
+ /**
175
+ * @license lucide-react v0.542.0 - ISC
176
+ *
177
+ * This source code is licensed under the ISC license.
178
+ * See the LICENSE file in the root directory of this source tree.
179
+ */
180
+ const __iconNode$x = [
181
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
182
+ ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
183
+ ];
184
+ const CircleCheck = createLucideIcon("circle-check", __iconNode$x);
185
+ /**
186
+ * @license lucide-react v0.542.0 - ISC
187
+ *
188
+ * This source code is licensed under the ISC license.
189
+ * See the LICENSE file in the root directory of this source tree.
190
+ */
191
+ const __iconNode$w = [
192
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
193
+ ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }]
194
+ ];
195
+ const CircleDot = createLucideIcon("circle-dot", __iconNode$w);
196
+ /**
197
+ * @license lucide-react v0.542.0 - ISC
198
+ *
199
+ * This source code is licensed under the ISC license.
200
+ * See the LICENSE file in the root directory of this source tree.
201
+ */
202
+ const __iconNode$v = [
203
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
204
+ ["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
205
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
206
+ ];
207
+ const CircleQuestionMark = createLucideIcon("circle-question-mark", __iconNode$v);
208
+ /**
209
+ * @license lucide-react v0.542.0 - ISC
210
+ *
211
+ * This source code is licensed under the ISC license.
212
+ * See the LICENSE file in the root directory of this source tree.
213
+ */
214
+ const __iconNode$u = [
215
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
216
+ ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
217
+ ["path", { d: "m9 9 6 6", key: "z0biqf" }]
218
+ ];
219
+ const CircleX = createLucideIcon("circle-x", __iconNode$u);
220
+ /**
221
+ * @license lucide-react v0.542.0 - ISC
222
+ *
223
+ * This source code is licensed under the ISC license.
224
+ * See the LICENSE file in the root directory of this source tree.
225
+ */
226
+ const __iconNode$t = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]];
227
+ const Circle = createLucideIcon("circle", __iconNode$t);
228
+ /**
229
+ * @license lucide-react v0.542.0 - ISC
230
+ *
231
+ * This source code is licensed under the ISC license.
232
+ * See the LICENSE file in the root directory of this source tree.
233
+ */
234
+ const __iconNode$s = [
235
+ ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
236
+ [
237
+ "path",
238
+ {
239
+ d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",
240
+ key: "116196"
241
+ }
242
+ ],
243
+ ["path", { d: "M12 11h4", key: "1jrz19" }],
244
+ ["path", { d: "M12 16h4", key: "n85exb" }],
245
+ ["path", { d: "M8 11h.01", key: "1dfujw" }],
246
+ ["path", { d: "M8 16h.01", key: "18s6g9" }]
247
+ ];
248
+ const ClipboardList = createLucideIcon("clipboard-list", __iconNode$s);
249
+ /**
250
+ * @license lucide-react v0.542.0 - ISC
251
+ *
252
+ * This source code is licensed under the ISC license.
253
+ * See the LICENSE file in the root directory of this source tree.
254
+ */
255
+ const __iconNode$r = [
256
+ ["path", { d: "m12 15 2 2 4-4", key: "2c609p" }],
257
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
258
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
259
+ ];
260
+ const CopyCheck = createLucideIcon("copy-check", __iconNode$r);
261
+ /**
262
+ * @license lucide-react v0.542.0 - ISC
263
+ *
264
+ * This source code is licensed under the ISC license.
265
+ * See the LICENSE file in the root directory of this source tree.
266
+ */
267
+ const __iconNode$q = [
268
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
269
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
270
+ ];
271
+ const Copy = createLucideIcon("copy", __iconNode$q);
272
+ /**
273
+ * @license lucide-react v0.542.0 - ISC
274
+ *
275
+ * This source code is licensed under the ISC license.
276
+ * See the LICENSE file in the root directory of this source tree.
277
+ */
278
+ const __iconNode$p = [
279
+ ["path", { d: "M12 15V3", key: "m9g1x1" }],
280
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
281
+ ["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
282
+ ];
283
+ const Download = createLucideIcon("download", __iconNode$p);
284
+ /**
285
+ * @license lucide-react v0.542.0 - ISC
286
+ *
287
+ * This source code is licensed under the ISC license.
288
+ * See the LICENSE file in the root directory of this source tree.
289
+ */
290
+ const __iconNode$o = [
291
+ ["path", { d: "M12 17h.01", key: "p32p05" }],
292
+ ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z", key: "1mlx9k" }],
293
+ ["path", { d: "M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3", key: "mhlwft" }]
294
+ ];
295
+ const FileQuestionMark = createLucideIcon("file-question-mark", __iconNode$o);
296
+ /**
297
+ * @license lucide-react v0.542.0 - ISC
298
+ *
299
+ * This source code is licensed under the ISC license.
300
+ * See the LICENSE file in the root directory of this source tree.
301
+ */
302
+ const __iconNode$n = [
303
+ ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
304
+ ["path", { d: "M12 9v4", key: "juzpu7" }],
305
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
306
+ ];
307
+ const FileWarning = createLucideIcon("file-warning", __iconNode$n);
308
+ /**
309
+ * @license lucide-react v0.542.0 - ISC
310
+ *
311
+ * This source code is licensed under the ISC license.
312
+ * See the LICENSE file in the root directory of this source tree.
313
+ */
314
+ const __iconNode$m = [
315
+ ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
316
+ ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }]
317
+ ];
318
+ const File$1 = createLucideIcon("file", __iconNode$m);
319
+ /**
320
+ * @license lucide-react v0.542.0 - ISC
321
+ *
322
+ * This source code is licensed under the ISC license.
323
+ * See the LICENSE file in the root directory of this source tree.
324
+ */
325
+ const __iconNode$l = [
326
+ ["line", { x1: "6", x2: "6", y1: "3", y2: "15", key: "17qcm7" }],
327
+ ["circle", { cx: "18", cy: "6", r: "3", key: "1h7g24" }],
328
+ ["circle", { cx: "6", cy: "18", r: "3", key: "fqmcym" }],
329
+ ["path", { d: "M18 9a9 9 0 0 1-9 9", key: "n2h4wq" }]
330
+ ];
331
+ const GitBranch = createLucideIcon("git-branch", __iconNode$l);
332
+ /**
333
+ * @license lucide-react v0.542.0 - ISC
334
+ *
335
+ * This source code is licensed under the ISC license.
336
+ * See the LICENSE file in the root directory of this source tree.
337
+ */
338
+ const __iconNode$k = [
339
+ ["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
340
+ ["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
341
+ ["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
342
+ ["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
343
+ ];
344
+ const Hash = createLucideIcon("hash", __iconNode$k);
345
+ /**
346
+ * @license lucide-react v0.542.0 - ISC
347
+ *
348
+ * This source code is licensed under the ISC license.
349
+ * See the LICENSE file in the root directory of this source tree.
350
+ */
351
+ const __iconNode$j = [
352
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
353
+ ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
354
+ ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
355
+ ];
356
+ const Image = createLucideIcon("image", __iconNode$j);
357
+ /**
358
+ * @license lucide-react v0.542.0 - ISC
359
+ *
360
+ * This source code is licensed under the ISC license.
361
+ * See the LICENSE file in the root directory of this source tree.
362
+ */
363
+ const __iconNode$i = [
364
+ ["rect", { width: "18", height: "7", x: "3", y: "3", rx: "1", key: "f1a2em" }],
365
+ ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }],
366
+ ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }]
367
+ ];
368
+ const LayoutPanelTop = createLucideIcon("layout-panel-top", __iconNode$i);
369
+ /**
370
+ * @license lucide-react v0.542.0 - ISC
371
+ *
372
+ * This source code is licensed under the ISC license.
373
+ * See the LICENSE file in the root directory of this source tree.
374
+ */
375
+ const __iconNode$h = [
376
+ ["path", { d: "m3 17 2 2 4-4", key: "1jhpwq" }],
377
+ ["path", { d: "m3 7 2 2 4-4", key: "1obspn" }],
378
+ ["path", { d: "M13 6h8", key: "15sg57" }],
379
+ ["path", { d: "M13 12h8", key: "h98zly" }],
380
+ ["path", { d: "M13 18h8", key: "oe0vm4" }]
381
+ ];
382
+ const ListChecks = createLucideIcon("list-checks", __iconNode$h);
383
+ /**
384
+ * @license lucide-react v0.542.0 - ISC
385
+ *
386
+ * This source code is licensed under the ISC license.
387
+ * See the LICENSE file in the root directory of this source tree.
388
+ */
389
+ const __iconNode$g = [
390
+ ["rect", { x: "3", y: "5", width: "6", height: "6", rx: "1", key: "1defrl" }],
391
+ ["path", { d: "m3 17 2 2 4-4", key: "1jhpwq" }],
392
+ ["path", { d: "M13 6h8", key: "15sg57" }],
393
+ ["path", { d: "M13 12h8", key: "h98zly" }],
394
+ ["path", { d: "M13 18h8", key: "oe0vm4" }]
395
+ ];
396
+ const ListTodo = createLucideIcon("list-todo", __iconNode$g);
397
+ /**
398
+ * @license lucide-react v0.542.0 - ISC
399
+ *
400
+ * This source code is licensed under the ISC license.
401
+ * See the LICENSE file in the root directory of this source tree.
402
+ */
403
+ const __iconNode$f = [
404
+ ["path", { d: "M3 12h.01", key: "nlz23k" }],
405
+ ["path", { d: "M3 18h.01", key: "1tta3j" }],
406
+ ["path", { d: "M3 6h.01", key: "1rqtza" }],
407
+ ["path", { d: "M8 12h13", key: "1za7za" }],
408
+ ["path", { d: "M8 18h13", key: "1lx6n3" }],
409
+ ["path", { d: "M8 6h13", key: "ik3vkj" }]
410
+ ];
411
+ const List = createLucideIcon("list", __iconNode$f);
412
+ /**
413
+ * @license lucide-react v0.542.0 - ISC
414
+ *
415
+ * This source code is licensed under the ISC license.
416
+ * See the LICENSE file in the root directory of this source tree.
417
+ */
418
+ const __iconNode$e = [
419
+ ["path", { d: "M8 3H5a2 2 0 0 0-2 2v3", key: "1dcmit" }],
420
+ ["path", { d: "M21 8V5a2 2 0 0 0-2-2h-3", key: "1e4gt3" }],
421
+ ["path", { d: "M3 16v3a2 2 0 0 0 2 2h3", key: "wsl5sc" }],
422
+ ["path", { d: "M16 21h3a2 2 0 0 0 2-2v-3", key: "18trek" }]
423
+ ];
424
+ const Maximize = createLucideIcon("maximize", __iconNode$e);
425
+ /**
426
+ * @license lucide-react v0.542.0 - ISC
427
+ *
428
+ * This source code is licensed under the ISC license.
429
+ * See the LICENSE file in the root directory of this source tree.
430
+ */
431
+ const __iconNode$d = [["path", { d: "M5 12h14", key: "1ays0h" }]];
432
+ const Minus = createLucideIcon("minus", __iconNode$d);
433
+ /**
434
+ * @license lucide-react v0.542.0 - ISC
435
+ *
436
+ * This source code is licensed under the ISC license.
437
+ * See the LICENSE file in the root directory of this source tree.
438
+ */
439
+ const __iconNode$c = [
440
+ ["path", { d: "M8 18L12 22L16 18", key: "cskvfv" }],
441
+ ["path", { d: "M12 2V22", key: "r89rzk" }]
442
+ ];
443
+ const MoveDown = createLucideIcon("move-down", __iconNode$c);
444
+ /**
445
+ * @license lucide-react v0.542.0 - ISC
446
+ *
447
+ * This source code is licensed under the ISC license.
448
+ * See the LICENSE file in the root directory of this source tree.
449
+ */
450
+ const __iconNode$b = [
451
+ ["path", { d: "M8 6L12 2L16 6", key: "1yvkyx" }],
452
+ ["path", { d: "M12 2V22", key: "r89rzk" }]
453
+ ];
454
+ const MoveUp = createLucideIcon("move-up", __iconNode$b);
455
+ /**
456
+ * @license lucide-react v0.542.0 - ISC
457
+ *
458
+ * This source code is licensed under the ISC license.
459
+ * See the LICENSE file in the root directory of this source tree.
460
+ */
461
+ const __iconNode$a = [
462
+ ["path", { d: "M5 12h14", key: "1ays0h" }],
463
+ ["path", { d: "M12 5v14", key: "s699le" }]
464
+ ];
465
+ const Plus = createLucideIcon("plus", __iconNode$a);
466
+ /**
467
+ * @license lucide-react v0.542.0 - ISC
468
+ *
469
+ * This source code is licensed under the ISC license.
470
+ * See the LICENSE file in the root directory of this source tree.
471
+ */
472
+ const __iconNode$9 = [
473
+ ["rect", { width: "20", height: "12", x: "2", y: "6", rx: "2", key: "9lu3g6" }],
474
+ ["path", { d: "M12 12h.01", key: "1mp3jc" }],
475
+ ["path", { d: "M17 12h.01", key: "1m0b6t" }],
476
+ ["path", { d: "M7 12h.01", key: "eqddd0" }]
477
+ ];
478
+ const RectangleEllipsis = createLucideIcon("rectangle-ellipsis", __iconNode$9);
479
+ /**
480
+ * @license lucide-react v0.542.0 - ISC
481
+ *
482
+ * This source code is licensed under the ISC license.
483
+ * See the LICENSE file in the root directory of this source tree.
484
+ */
485
+ const __iconNode$8 = [
486
+ ["path", { d: "M3 7V5a2 2 0 0 1 2-2h2", key: "aa7l1z" }],
487
+ ["path", { d: "M17 3h2a2 2 0 0 1 2 2v2", key: "4qcy5o" }],
488
+ ["path", { d: "M21 17v2a2 2 0 0 1-2 2h-2", key: "6vwrx8" }],
489
+ ["path", { d: "M7 21H5a2 2 0 0 1-2-2v-2", key: "ioqczr" }]
490
+ ];
491
+ const Scan = createLucideIcon("scan", __iconNode$8);
492
+ /**
493
+ * @license lucide-react v0.542.0 - ISC
494
+ *
495
+ * This source code is licensed under the ISC license.
496
+ * See the LICENSE file in the root directory of this source tree.
497
+ */
498
+ const __iconNode$7 = [
499
+ [
500
+ "path",
501
+ {
502
+ d: "M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",
503
+ key: "1i5ecw"
504
+ }
505
+ ],
506
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
507
+ ];
508
+ const Settings = createLucideIcon("settings", __iconNode$7);
509
+ /**
510
+ * @license lucide-react v0.542.0 - ISC
511
+ *
512
+ * This source code is licensed under the ISC license.
513
+ * See the LICENSE file in the root directory of this source tree.
514
+ */
515
+ const __iconNode$6 = [
516
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
517
+ ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
518
+ ];
519
+ const SquareCheck = createLucideIcon("square-check", __iconNode$6);
520
+ /**
521
+ * @license lucide-react v0.542.0 - ISC
522
+ *
523
+ * This source code is licensed under the ISC license.
524
+ * See the LICENSE file in the root directory of this source tree.
525
+ */
526
+ const __iconNode$5 = [
527
+ ["path", { d: "M5 3a2 2 0 0 0-2 2", key: "y57alp" }],
528
+ ["path", { d: "M19 3a2 2 0 0 1 2 2", key: "18rm91" }],
529
+ ["path", { d: "M21 19a2 2 0 0 1-2 2", key: "1j7049" }],
530
+ ["path", { d: "M5 21a2 2 0 0 1-2-2", key: "sbafld" }],
531
+ ["path", { d: "M9 3h1", key: "1yesri" }],
532
+ ["path", { d: "M9 21h1", key: "15o7lz" }],
533
+ ["path", { d: "M14 3h1", key: "1ec4yj" }],
534
+ ["path", { d: "M14 21h1", key: "v9vybs" }],
535
+ ["path", { d: "M3 9v1", key: "1r0deq" }],
536
+ ["path", { d: "M21 9v1", key: "mxsmne" }],
537
+ ["path", { d: "M3 14v1", key: "vnatye" }],
538
+ ["path", { d: "M21 14v1", key: "169vum" }]
539
+ ];
540
+ const SquareDashed = createLucideIcon("square-dashed", __iconNode$5);
541
+ /**
542
+ * @license lucide-react v0.542.0 - ISC
543
+ *
544
+ * This source code is licensed under the ISC license.
545
+ * See the LICENSE file in the root directory of this source tree.
546
+ */
547
+ const __iconNode$4 = [
548
+ [
549
+ "path",
550
+ {
551
+ d: "M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",
552
+ key: "r04s7s"
553
+ }
554
+ ]
555
+ ];
556
+ const Star = createLucideIcon("star", __iconNode$4);
557
+ /**
558
+ * @license lucide-react v0.542.0 - ISC
559
+ *
560
+ * This source code is licensed under the ISC license.
561
+ * See the LICENSE file in the root directory of this source tree.
562
+ */
563
+ const __iconNode$3 = [
564
+ ["path", { d: "M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6", key: "1528k5" }],
565
+ ["path", { d: "M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7", key: "13ksps" }],
566
+ ["path", { d: "M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1", key: "1n9rhb" }],
567
+ ["path", { d: "M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1", key: "1mj8rg" }],
568
+ ["path", { d: "M9 6v12", key: "velyjx" }]
569
+ ];
570
+ const TextCursorInput = createLucideIcon("text-cursor-input", __iconNode$3);
571
+ /**
572
+ * @license lucide-react v0.542.0 - ISC
573
+ *
574
+ * This source code is licensed under the ISC license.
575
+ * See the LICENSE file in the root directory of this source tree.
576
+ */
577
+ const __iconNode$2 = [
578
+ ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
579
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
580
+ ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
581
+ ];
582
+ const Trash = createLucideIcon("trash", __iconNode$2);
583
+ /**
584
+ * @license lucide-react v0.542.0 - ISC
585
+ *
586
+ * This source code is licensed under the ISC license.
587
+ * See the LICENSE file in the root directory of this source tree.
588
+ */
589
+ const __iconNode$1 = [
590
+ ["path", { d: "M12 3v12", key: "1x0j5s" }],
591
+ ["path", { d: "m17 8-5-5-5 5", key: "7q97r8" }],
592
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
593
+ ];
594
+ const Upload = createLucideIcon("upload", __iconNode$1);
595
+ /**
596
+ * @license lucide-react v0.542.0 - ISC
597
+ *
598
+ * This source code is licensed under the ISC license.
599
+ * See the LICENSE file in the root directory of this source tree.
600
+ */
601
+ const __iconNode = [
602
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
603
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
604
+ ];
605
+ const X = createLucideIcon("x", __iconNode);
8
606
  const FileCard = React.memo(
9
607
  React.forwardRef((props, ref) => {
10
608
  const { file, className, error, rightSlot, ...rest } = props;
11
609
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Card, { className: classVarianceAuthority.cx(className, "flex w-full items-center gap-2 text-sm"), ref, ...rest, children: [
12
- error ? /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "file-question-mark" }) : /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "file", color: "var(--base-a11)" }),
610
+ error ? /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: FileQuestionMark }) : /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: File$1, color: "var(--base-a11)" }),
13
611
  !error ? file ? /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: "truncate", children: file.name }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Spinner, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { accentColor: "danger", className: "truncate", children: error }),
14
612
  rightSlot
15
613
  ] });
@@ -67,12 +665,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
67
665
  }
68
666
  class BaseField extends BaseFormElement {
69
667
  constructor(options) {
70
- const { label, description = null, required, image, fieldValidators = [], ...base } = options;
668
+ const { label, description = null, required, image, ...base } = options;
71
669
  super(base);
72
670
  __publicField(this, "label");
73
671
  __publicField(this, "description");
74
672
  __publicField(this, "required");
75
- __publicField(this, "fieldValidators");
76
673
  __publicField(this, "image");
77
674
  /**
78
675
  * By default, validation doesn't execute on `onChange` events when editing fields
@@ -85,7 +682,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
85
682
  this.description = description;
86
683
  this.required = required;
87
684
  this.image = image;
88
- this.fieldValidators = fieldValidators;
89
685
  }
90
686
  getError(value) {
91
687
  if (this.required && this.isValueBlank(value)) {
@@ -111,24 +707,22 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
111
707
  label: this.label,
112
708
  description: this.description,
113
709
  required: this.required,
114
- image: this.image,
115
- fieldValidators: this.fieldValidators
710
+ image: this.image
116
711
  };
117
712
  }
118
713
  setOptions(options) {
119
- const { label, description = null, required, image, fieldValidators, ...base } = options;
714
+ const { label, description = null, required, image, ...base } = options;
120
715
  this.label = label ?? this.label;
121
716
  this.description = description ?? this.description;
122
717
  this.required = required ?? this.required;
123
718
  this.image = image ?? this.image;
124
- this.fieldValidators = fieldValidators ?? this.fieldValidators;
125
719
  super.setOptions(base);
126
720
  }
127
721
  isValueBlank(value) {
128
722
  return this.areValuesEqual(value, this.blankValue());
129
723
  }
130
724
  getFieldValidators() {
131
- return [...this.fieldValidators];
725
+ return [];
132
726
  }
133
727
  }
134
728
  __publicField(BaseField, "fieldTypeName");
@@ -172,15 +766,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
172
766
  variant: "ghost",
173
767
  children: [
174
768
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Tooltip.Root, { children: [
175
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Tooltip.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: handleCopy, "aria-label": "copy to clipboard", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "copy" }) }) }),
769
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Tooltip.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: handleCopy, "aria-label": "copy to clipboard", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Copy }) }) }),
176
770
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Tooltip.Content, { size: "sm", children: "Copy" })
177
771
  ] }),
178
772
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Tooltip.Root, { children: [
179
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Tooltip.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: handleDownload, "aria-label": "download", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "download" }) }) }),
773
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Tooltip.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: handleDownload, "aria-label": "download", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Download }) }) }),
180
774
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Tooltip.Content, { size: "sm", children: "Download" })
181
775
  ] }),
182
776
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Separator, { orientation: "vertical", size: "sm" }),
183
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Overlay.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: onClose, "aria-label": "close", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "x" }) }) })
777
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Overlay.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: onClose, "aria-label": "close", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: X }) }) })
184
778
  ]
185
779
  }
186
780
  ),
@@ -219,7 +813,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
219
813
  ] });
220
814
  });
221
815
  ImageViewerProvider.displayName = "FileViewerProvider";
222
- const InputWithLabel = (props) => {
816
+ const InputWithLabel = React.memo((props) => {
223
817
  const { className, label, children, severity, inputId, labelId, image } = props;
224
818
  const [resolvedImage, setResolvedImage] = React.useState(void 0);
225
819
  const openImageViewer = useImageViewer();
@@ -251,7 +845,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
251
845
  !!label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: classVarianceAuthority.cx(className, "w-max max-w-full"), htmlFor: inputId, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { accentColor: color, size: "sm", id: labelId, className: "text-wrap", children: label }) }),
252
846
  children
253
847
  ] });
254
- };
848
+ });
255
849
  const InputWithLabelAndHelpText = (props) => {
256
850
  const { children, ...restProps } = props;
257
851
  return /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { ...restProps, children });
@@ -278,14 +872,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
278
872
  const label = field.required ? `${field.label} *` : field.label;
279
873
  const fieldPropsWithValidation = React.useMemo(() => {
280
874
  const handleChange = (value) => {
281
- helpers.setValue(value, false).then();
875
+ void helpers.setValue(value, false);
282
876
  onValuesChange == null ? void 0 : onValuesChange(field.identifier, value);
283
877
  if (touched || !field.onlyValidateAfterTouched) {
284
878
  helpers.setError(field.getError(value));
285
879
  }
286
880
  };
287
881
  const handleBlur = (value) => {
288
- void helpers.setTouched(true, false).then();
882
+ void helpers.setTouched(true, false);
289
883
  helpers.setError(field.getError(value));
290
884
  };
291
885
  return {
@@ -418,7 +1012,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
418
1012
  "aria-label": "Add option",
419
1013
  disabled: !!internalError || disabled,
420
1014
  onClick: addOption,
421
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" })
1015
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Plus })
422
1016
  }
423
1017
  )
424
1018
  ] })
@@ -465,7 +1059,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
465
1059
  onClick: () => {
466
1060
  handleDeleteOption(index);
467
1061
  },
468
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "x" })
1062
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: X })
469
1063
  }
470
1064
  )
471
1065
  ]
@@ -559,7 +1153,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
559
1153
  return [];
560
1154
  }
561
1155
  areValuesEqual(value1, value2) {
562
- return value1.every((v) => value2.includes(v)) && value2.every((v) => value1.includes(v));
1156
+ const value1Set = new Set(value1);
1157
+ const value2Set = new Set(value2);
1158
+ return value1Set.size === value2Set.size && value1Set.isSubsetOf(value2Set);
563
1159
  }
564
1160
  };
565
1161
  __publicField(_MultiStringField, "fieldTypeName", "Multi-string");
@@ -653,7 +1249,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
653
1249
  accentColor: "primary",
654
1250
  variant: "surface",
655
1251
  disabled,
656
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Checkbox.Indicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) })
1252
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Checkbox.Indicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) })
657
1253
  }
658
1254
  )
659
1255
  }
@@ -682,7 +1278,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
682
1278
  });
683
1279
  }
684
1280
  static deserialize(data) {
685
- if (data.type !== "boolean") throw new Error("Type mismatch.");
686
1281
  return new _BooleanField(data);
687
1282
  }
688
1283
  serializeValue(value) {
@@ -795,8 +1390,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
795
1390
  description: "Minimum value",
796
1391
  integers: true,
797
1392
  required: false,
798
- identifier: `${path}minimum`,
799
- fieldValidators: []
1393
+ identifier: `${path}minimum`
800
1394
  }),
801
1395
  showDirectly: false
802
1396
  },
@@ -806,8 +1400,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
806
1400
  description: "Maximum value",
807
1401
  integers: true,
808
1402
  required: false,
809
- identifier: `${path}maximum`,
810
- fieldValidators: []
1403
+ identifier: `${path}maximum`
811
1404
  }),
812
1405
  showDirectly: false
813
1406
  },
@@ -932,7 +1525,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
932
1525
  identifier: `${path}minimum_length`,
933
1526
  minimum: 0,
934
1527
  maximum: 100,
935
- fieldValidators: [],
936
1528
  integers: true
937
1529
  }),
938
1530
  showDirectly: false
@@ -946,7 +1538,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
946
1538
  minimum: 1,
947
1539
  maximum: LONG_TEXT_FIELD_MAX_LENGTH,
948
1540
  // TODO: depends on short vs long text
949
- fieldValidators: [],
950
1541
  // TODO: default: 500 (see: "Short text fields can hold up to 500 characters on a single line.")
951
1542
  integers: true
952
1543
  }),
@@ -1049,7 +1640,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1049
1640
  onValuesChange: handleChange,
1050
1641
  disabled,
1051
1642
  children: field.options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex gap-2 items-center min-w-0", children: [
1052
- /* @__PURE__ */ jsxRuntime.jsx(blocks.CheckboxGroup.Item, { value: option.value, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.CheckboxGroup.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) }) }),
1643
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.CheckboxGroup.Item, { value: option.value, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.CheckboxGroup.ItemIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) }) }),
1053
1644
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "sm", accentColor: "base", className: "truncate", children: option.label })
1054
1645
  ] }, `${inputId}-${option.value}-${index}`))
1055
1646
  }
@@ -1098,7 +1689,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1098
1689
  return [];
1099
1690
  }
1100
1691
  areValuesEqual(value1, value2) {
1101
- return value1.every((v) => value2.includes(v)) && value2.every((v) => value1.includes(v));
1692
+ const value1Set = new Set(value1);
1693
+ const value2Set = new Set(value2);
1694
+ return value1Set.size === value2Set.size && value1Set.isSubsetOf(value2Set);
1102
1695
  }
1103
1696
  };
1104
1697
  __publicField(_CheckboxListField, "fieldTypeName", "Checkbox list");
@@ -1151,7 +1744,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1151
1744
  month: "2-digit",
1152
1745
  day: "2-digit"
1153
1746
  }) : "yyyy-mm-dd",
1154
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "chevron-down" })
1747
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: ChevronDown })
1155
1748
  ]
1156
1749
  }
1157
1750
  ) }),
@@ -1262,13 +1855,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1262
1855
  disabled,
1263
1856
  children: [
1264
1857
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: value && value.length > 0 ? value.join(", ") : field.placeholder ?? "Select one or more..." }),
1265
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "chevron-down" })
1858
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: ChevronDown })
1266
1859
  ]
1267
1860
  }
1268
1861
  ) }),
1269
1862
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Scroll, { children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.MultiSelectGroup, { values: value, onValuesChange: handleChange, children: [
1270
1863
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.SelectAllItem, { children: [
1271
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.CheckboxItemIndicator, { children: (indeterminate) => indeterminate ? /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "minus" }) : /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) }),
1864
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.CheckboxItemIndicator, { children: (indeterminate) => indeterminate ? /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Minus }) : /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) }),
1272
1865
  "Select all"
1273
1866
  ] }),
1274
1867
  field.options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1276,7 +1869,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1276
1869
  {
1277
1870
  value: option.value,
1278
1871
  children: [
1279
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) }),
1872
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) }),
1280
1873
  option.label
1281
1874
  ]
1282
1875
  },
@@ -1338,7 +1931,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1338
1931
  return [];
1339
1932
  }
1340
1933
  areValuesEqual(value1, value2) {
1341
- return value1.every((v) => value2.includes(v)) && value2.every((v) => value1.includes(v));
1934
+ const value1Set = new Set(value1);
1935
+ const value2Set = new Set(value2);
1936
+ return value1Set.size === value2Set.size && value1Set.isSubsetOf(value2Set);
1342
1937
  }
1343
1938
  };
1344
1939
  __publicField(_MultiSelectField, "fieldTypeName", "Multi-select");
@@ -1382,12 +1977,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1382
1977
  disabled,
1383
1978
  children: [
1384
1979
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: currentOption ? currentOption.label : field.placeholder ?? "Select one..." }),
1385
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "chevron-down" })
1980
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: ChevronDown })
1386
1981
  ]
1387
1982
  }
1388
1983
  ) }),
1389
1984
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Scroll, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectGroup, { required: false, value: value ?? void 0, onValueChange: handleChange, children: field.options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.SelectItem, { value: option.value, children: [
1390
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) }),
1985
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) }),
1391
1986
  option.label
1392
1987
  ] }, `${inputId}-${option.value}-${index}`)) }) }) })
1393
1988
  ] })
@@ -1473,17 +2068,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1473
2068
  },
1474
2069
  [field, helpers, touched]
1475
2070
  );
1476
- const handleBlur = React.useCallback(
1477
- (e) => {
1478
- const { relatedTarget } = e;
1479
- if (relatedTarget instanceof Element && inputUuids.includes(relatedTarget.id)) {
1480
- return;
1481
- }
1482
- onChange(internalValue);
1483
- onBlur(internalValue);
1484
- },
1485
- [inputUuids, internalValue, onBlur, onChange]
1486
- );
2071
+ const handleBlur = React.useCallback(() => {
2072
+ onChange(internalValue);
2073
+ onBlur(internalValue);
2074
+ }, [internalValue, onBlur, onChange]);
1487
2075
  return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText: computedHelpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(
1488
2076
  InputWithLabel,
1489
2077
  {
@@ -1513,8 +2101,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1513
2101
  accentColor: "base",
1514
2102
  variant: "surface",
1515
2103
  size: "sm",
2104
+ onBlur: handleBlur,
1516
2105
  children: [
1517
- inputUuids.map((inputUuid) => /* @__PURE__ */ jsxRuntime.jsx(blocks.OneTimePasswordField.Input, { id: inputUuid, onBlur: handleBlur }, inputUuid)),
2106
+ inputUuids.map((inputUuid) => /* @__PURE__ */ jsxRuntime.jsx(blocks.OneTimePasswordField.Input, { id: inputUuid }, inputUuid)),
1518
2107
  /* @__PURE__ */ jsxRuntime.jsx(blocks.OneTimePasswordField.HiddenInput, {})
1519
2108
  ]
1520
2109
  }
@@ -1544,8 +2133,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1544
2133
  required: false,
1545
2134
  minimum: 1,
1546
2135
  maximum: 16,
1547
- identifier: `${path}length`,
1548
- fieldValidators: []
2136
+ identifier: `${path}length`
1549
2137
  }),
1550
2138
  showDirectly: false
1551
2139
  },
@@ -1581,7 +2169,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1581
2169
  const validators = super.getFieldValidators();
1582
2170
  const length = this.length;
1583
2171
  validators.push((value) => {
1584
- if (!this.isValueBlank(value) && (value.length < length || value.length > length)) {
2172
+ if (!this.isValueBlank(value) && value.length != length) {
1585
2173
  return `Must be ${length} characters.`;
1586
2174
  }
1587
2175
  });
@@ -1641,6 +2229,565 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1641
2229
  __publicField(_OTPField, "fieldTypeName", "OTP");
1642
2230
  __publicField(_OTPField, "fieldTypeDescription", "Allows specifying a number within a given range.");
1643
2231
  let OTPField = _OTPField;
2232
+ const passFailFieldStatusMapping = {
2233
+ pass: {
2234
+ label: "Pass",
2235
+ icon: CircleCheck
2236
+ },
2237
+ fail: {
2238
+ label: "Fail",
2239
+ icon: CircleX
2240
+ },
2241
+ na: {
2242
+ label: "N/A",
2243
+ icon: CircleQuestionMark
2244
+ }
2245
+ };
2246
+ const passFailFieldStatuses = Object.keys(passFailFieldStatusMapping);
2247
+ class UUIDFile extends File {
2248
+ constructor(uuid2, ...args) {
2249
+ super(...args);
2250
+ __publicField(this, "uuid");
2251
+ this.uuid = uuid2;
2252
+ }
2253
+ static from(uuid2, file) {
2254
+ return new UUIDFile(uuid2, [file], file.name, {
2255
+ lastModified: file.lastModified,
2256
+ type: file.type
2257
+ });
2258
+ }
2259
+ }
2260
+ class UUIDPromise extends Promise {
2261
+ constructor(executor, uuid2) {
2262
+ super(executor);
2263
+ __publicField(this, "_uuid");
2264
+ this._uuid = uuid2;
2265
+ }
2266
+ get uuid() {
2267
+ return this._uuid;
2268
+ }
2269
+ set uuid(uuid2) {
2270
+ this._uuid = uuid2;
2271
+ }
2272
+ static from(promise, uuid2) {
2273
+ return new UUIDPromise((resolve, reject) => {
2274
+ Promise.resolve(promise).then(resolve).catch(reject);
2275
+ }, uuid2);
2276
+ }
2277
+ // oxlint-disable-next-line no-thenable
2278
+ then(onFulfilled, onRejected) {
2279
+ const promise = super.then(onFulfilled, onRejected);
2280
+ promise.uuid = this.uuid;
2281
+ return promise;
2282
+ }
2283
+ catch(onRejected) {
2284
+ const promise = super.catch(onRejected);
2285
+ promise.uuid = this.uuid;
2286
+ return promise;
2287
+ }
2288
+ finally(onFinally) {
2289
+ const promise = super.finally(onFinally);
2290
+ promise.uuid = this.uuid;
2291
+ return promise;
2292
+ }
2293
+ }
2294
+ function isFileAndPromiseArray(value) {
2295
+ if (!Array.isArray(value)) return false;
2296
+ return value.every((item) => item instanceof UUIDPromise || item instanceof UUIDFile);
2297
+ }
2298
+ function areFileAndPromiseArraysEqual(value1, value2) {
2299
+ const value1Set = new Set(value1.map(({ uuid: uuid2 }) => uuid2));
2300
+ const value2Set = new Set(value2.map(({ uuid: uuid2 }) => uuid2));
2301
+ return value1Set.size === value2Set.size && value1Set.isSubsetOf(value2Set);
2302
+ }
2303
+ const ImageCard = React.memo(
2304
+ React.forwardRef((props, forwardedRef) => {
2305
+ const { file, alt, error, rightSlot, className, ...rest } = props;
2306
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2307
+ blocks.Card,
2308
+ {
2309
+ className: classVarianceAuthority.cx(className, "relative flex h-[200px] w-full flex-col gap-2 overflow-hidden items-center"),
2310
+ ref: forwardedRef,
2311
+ ...rest,
2312
+ children: [
2313
+ !file && !error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 grow flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Spinner, {}) }),
2314
+ !!file && !error && /* @__PURE__ */ jsxRuntime.jsx(blocks.Card, { className: "flex max-w-full grow items-center !p-0 justify-center overflow-hidden bg-clip-padding", children: /* @__PURE__ */ jsxRuntime.jsx(
2315
+ "img",
2316
+ {
2317
+ className: "max-w-full object-cover",
2318
+ src: URL.createObjectURL(file),
2319
+ alt: alt ?? file.name
2320
+ }
2321
+ ) }),
2322
+ (!!file || !!error) && /* @__PURE__ */ jsxRuntime.jsxs(
2323
+ "div",
2324
+ {
2325
+ className: classVarianceAuthority.cx("flex w-full items-center gap-2 self-end", {
2326
+ "bg-transparent": !file
2327
+ }),
2328
+ children: [
2329
+ error ? /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: FileWarning }) : file && /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: File$1 }),
2330
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: "truncate", size: "sm", children: error ?? (file == null ? void 0 : file.name) }),
2331
+ rightSlot
2332
+ ]
2333
+ }
2334
+ )
2335
+ ]
2336
+ }
2337
+ );
2338
+ })
2339
+ );
2340
+ const convertBytesToLargestUnit = (bytes) => {
2341
+ const units = ["byte", "kilobyte", "megabyte"];
2342
+ let sizeInUnit = bytes;
2343
+ let unitIndex = 0;
2344
+ while (sizeInUnit > 1e3 && unitIndex < units.length - 1) {
2345
+ sizeInUnit /= 1e3;
2346
+ unitIndex++;
2347
+ }
2348
+ const formatter = new Intl.NumberFormat([], {
2349
+ // 0 for bytes and kilobytes, 1 for megabytes
2350
+ maximumFractionDigits: Math.max(0, unitIndex - 1),
2351
+ style: "unit",
2352
+ unit: units[unitIndex]
2353
+ });
2354
+ return formatter.format(sizeInUnit);
2355
+ };
2356
+ const DisplayFile = React.memo((props) => {
2357
+ const { file, onRemove, disabled } = props;
2358
+ const [resolvedFile, setResolvedFile] = React.useState(null);
2359
+ const [error, setError] = React.useState(null);
2360
+ const openImageViewer = useImageViewer();
2361
+ const { url, name } = React.useMemo(() => {
2362
+ let url2 = null;
2363
+ let name2;
2364
+ let size;
2365
+ if (resolvedFile == null ? void 0 : resolvedFile.type.startsWith("image/")) {
2366
+ url2 = URL.createObjectURL(resolvedFile);
2367
+ }
2368
+ if (resolvedFile) {
2369
+ name2 = resolvedFile.name;
2370
+ size = convertBytesToLargestUnit(resolvedFile.size);
2371
+ } else {
2372
+ name2 = "Downloading...";
2373
+ size = "...";
2374
+ }
2375
+ return { url: url2, name: name2, size };
2376
+ }, [resolvedFile]);
2377
+ React.useEffect(() => {
2378
+ if (file instanceof UUIDPromise) {
2379
+ file.then((file2) => {
2380
+ setResolvedFile(file2);
2381
+ }).catch((err) => {
2382
+ setError(err instanceof Error ? err.message : "Unknown error");
2383
+ });
2384
+ } else {
2385
+ setResolvedFile(file);
2386
+ }
2387
+ }, [file]);
2388
+ const handleDownload = React.useCallback(
2389
+ (event) => {
2390
+ event.stopPropagation();
2391
+ if (!resolvedFile) {
2392
+ throw new Error("Cannot download a file that is not resolved.");
2393
+ }
2394
+ const blob = new Blob([resolvedFile]);
2395
+ fileSaver.saveAs(blob, name);
2396
+ },
2397
+ [name, resolvedFile]
2398
+ );
2399
+ const handleDelete = React.useCallback(
2400
+ (e) => {
2401
+ e.stopPropagation();
2402
+ onRemove();
2403
+ },
2404
+ [onRemove]
2405
+ );
2406
+ const handleImageCardClick = React.useCallback(() => {
2407
+ if (!resolvedFile) return;
2408
+ openImageViewer((closeFileViewer) => ({
2409
+ file: resolvedFile,
2410
+ onDelete: !disabled ? () => {
2411
+ onRemove();
2412
+ closeFileViewer();
2413
+ } : void 0
2414
+ }));
2415
+ }, [disabled, onRemove, openImageViewer, resolvedFile]);
2416
+ const rightSlotContent = React.useMemo(
2417
+ () => /* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex grow justify-end", variant: "ghost", accentColor: "base", size: "sm", children: [
2418
+ /* @__PURE__ */ jsxRuntime.jsx(
2419
+ blocks.IconButton,
2420
+ {
2421
+ "aria-label": `Download ${name}`,
2422
+ type: "button",
2423
+ onClick: handleDownload,
2424
+ disabled: !resolvedFile,
2425
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Download })
2426
+ }
2427
+ ),
2428
+ !disabled && /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", "aria-label": `Remove ${name}`, disabled, onClick: handleDelete, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Trash }) })
2429
+ ] }),
2430
+ [disabled, handleDelete, handleDownload, name, resolvedFile]
2431
+ );
2432
+ return url ? /* @__PURE__ */ jsxRuntime.jsx(
2433
+ ImageCard,
2434
+ {
2435
+ className: "cursor-pointer",
2436
+ onClick: handleImageCardClick,
2437
+ file: resolvedFile,
2438
+ error: error ?? void 0,
2439
+ rightSlot: rightSlotContent
2440
+ }
2441
+ ) : /* @__PURE__ */ jsxRuntime.jsx(FileCard, { file: resolvedFile, error: error ?? void 0, rightSlot: rightSlotContent });
2442
+ });
2443
+ DisplayFile.displayName = "DisplayFile";
2444
+ const PassFailInput = React.memo((props) => {
2445
+ const [
2446
+ { inputId, labelId, size, severity, showInputOnly, field, helpText, label, fieldProps, touched, helpers },
2447
+ { disabled }
2448
+ ] = useFormikInput(props);
2449
+ const { value, onChange, onBlur, name } = fieldProps;
2450
+ const [internalNotes, setInternalNotes] = React.useState("");
2451
+ const input = React.useRef(null);
2452
+ const computedHelpText = showInputOnly ? null : helpText;
2453
+ const computedLabel = showInputOnly ? "" : label;
2454
+ const showNotesAndFiles = value.status && field.showNotesAndFilesOn.includes(value.status);
2455
+ const handleStatusChange = React.useCallback(
2456
+ (status) => {
2457
+ const newValue = field.cleanValue({
2458
+ ...value,
2459
+ status
2460
+ });
2461
+ onChange(newValue);
2462
+ onBlur(newValue);
2463
+ },
2464
+ [field, onBlur, onChange, value]
2465
+ );
2466
+ React.useEffect(() => {
2467
+ setInternalNotes(value.notes);
2468
+ }, [value]);
2469
+ const handleNotesChange = React.useCallback(
2470
+ (e) => {
2471
+ const notes = e.target.value;
2472
+ setInternalNotes(notes);
2473
+ if (touched || !field.onlyValidateAfterTouched) {
2474
+ helpers.setError(
2475
+ field.getError({
2476
+ ...value,
2477
+ notes: internalNotes
2478
+ })
2479
+ );
2480
+ }
2481
+ },
2482
+ [field, helpers, internalNotes, touched, value]
2483
+ );
2484
+ const handleNotesBlur = React.useCallback(() => {
2485
+ const newValue = {
2486
+ ...value,
2487
+ notes: internalNotes
2488
+ };
2489
+ onChange(newValue);
2490
+ onBlur(newValue);
2491
+ }, [internalNotes, onBlur, onChange, value]);
2492
+ const handleRemoveFile = React.useCallback(
2493
+ (index) => {
2494
+ const files = [...value.files];
2495
+ void files.splice(index, 1);
2496
+ onChange({
2497
+ ...value,
2498
+ files
2499
+ });
2500
+ },
2501
+ [onChange, value]
2502
+ );
2503
+ const handleFileButtonClick = React.useCallback(() => {
2504
+ var _a2;
2505
+ (_a2 = input.current) == null ? void 0 : _a2.click();
2506
+ }, []);
2507
+ const handleFilesChange = React.useCallback(
2508
+ (e) => {
2509
+ const files = Array.from(e.target.files ?? []).map((file) => UUIDFile.from(uuid.v4(), file));
2510
+ const newValue = {
2511
+ ...value,
2512
+ files: [...value.files, ...files]
2513
+ };
2514
+ onChange(newValue);
2515
+ onBlur(newValue);
2516
+ },
2517
+ [onBlur, onChange, value]
2518
+ );
2519
+ React.useEffect(() => {
2520
+ if (!input.current) return;
2521
+ const abortController = new AbortController();
2522
+ input.current.addEventListener(
2523
+ "cancel",
2524
+ () => {
2525
+ onBlur(value);
2526
+ },
2527
+ {
2528
+ signal: abortController.signal
2529
+ }
2530
+ );
2531
+ return () => {
2532
+ abortController.abort();
2533
+ };
2534
+ }, [onBlur, value]);
2535
+ const statusInputId = `${inputId}-status`;
2536
+ const notesInputId = `${inputId}-notes`;
2537
+ const filesInputId = `${inputId}-files`;
2538
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText: computedHelpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(
2539
+ InputWithLabel,
2540
+ {
2541
+ size,
2542
+ severity,
2543
+ inputId,
2544
+ labelId,
2545
+ label: computedLabel,
2546
+ image: showInputOnly ? void 0 : field.image,
2547
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
2548
+ /* @__PURE__ */ jsxRuntime.jsx(
2549
+ blocks.RadioGroup.Root,
2550
+ {
2551
+ id: statusInputId,
2552
+ className: "flex gap-2",
2553
+ name,
2554
+ value: value.status,
2555
+ disabled,
2556
+ accentColor: "base",
2557
+ variant: "surface",
2558
+ size: "sm",
2559
+ onValueChange: handleStatusChange,
2560
+ children: passFailFieldStatuses.map((status) => {
2561
+ const { label: label2 } = passFailFieldStatusMapping[status];
2562
+ return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex gap-2 items-center min-w-0", children: [
2563
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.RadioGroup.Item, { value: status, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RadioGroup.Indicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Circle, className: "fill-current" }) }) }),
2564
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "sm", accentColor: "base", className: "truncate", children: label2 })
2565
+ ] }, `${inputId}-${status}`);
2566
+ })
2567
+ }
2568
+ ),
2569
+ showNotesAndFiles && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2570
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
2571
+ blocks.TextArea,
2572
+ {
2573
+ id: notesInputId,
2574
+ value: internalNotes,
2575
+ name,
2576
+ onChange: handleNotesChange,
2577
+ onBlur: handleNotesBlur,
2578
+ className: "field-sizing-content w-full min-h-12",
2579
+ placeholder: "Notes",
2580
+ resize: "vertical",
2581
+ accentColor: "base",
2582
+ variant: "surface",
2583
+ size: "sm",
2584
+ disabled
2585
+ }
2586
+ ) }),
2587
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
2588
+ /* @__PURE__ */ jsxRuntime.jsxs(
2589
+ blocks.Button,
2590
+ {
2591
+ className: "w-max",
2592
+ size: "sm",
2593
+ variant: "soft",
2594
+ accentColor: "base",
2595
+ onClick: handleFileButtonClick,
2596
+ type: "button",
2597
+ disabled,
2598
+ children: [
2599
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Upload }),
2600
+ "Select files"
2601
+ ]
2602
+ }
2603
+ ),
2604
+ /* @__PURE__ */ jsxRuntime.jsx(
2605
+ "input",
2606
+ {
2607
+ id: filesInputId,
2608
+ name,
2609
+ type: "file",
2610
+ ref: input,
2611
+ multiple: true,
2612
+ className: "hidden",
2613
+ onChange: handleFilesChange,
2614
+ value: ""
2615
+ }
2616
+ ),
2617
+ value.files.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-max flex-col gap-2", children: value.files.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(
2618
+ DisplayFile,
2619
+ {
2620
+ file,
2621
+ onRemove: () => {
2622
+ handleRemoveFile(index);
2623
+ },
2624
+ disabled
2625
+ },
2626
+ index
2627
+ )) })
2628
+ ] })
2629
+ ] })
2630
+ ] })
2631
+ }
2632
+ ) });
2633
+ });
2634
+ PassFailInput.displayName = "PassFailInput";
2635
+ const isPassFailFieldStatus = (value) => {
2636
+ return typeof value === "string" && passFailFieldStatuses.includes(value);
2637
+ };
2638
+ const isSerializedPassFailFieldValue = (value) => {
2639
+ if (value === null || typeof value !== "object") return false;
2640
+ if (!("status" in value) || !isPassFailFieldStatus(value.status)) return false;
2641
+ if (!("notes" in value) || !(typeof value.notes === "string")) return false;
2642
+ if (!("files" in value) || !(Array.isArray(value.files) && value.files.length === 0)) return false;
2643
+ return true;
2644
+ };
2645
+ const isPassFailFieldValue = (value) => {
2646
+ if (value === null || typeof value !== "object") return false;
2647
+ if (!("status" in value) || !isPassFailFieldStatus(value.status)) return false;
2648
+ if (!("notes" in value) || !(typeof value.notes === "string")) return false;
2649
+ if (!("files" in value) || !isFileAndPromiseArray(value.files)) return false;
2650
+ return true;
2651
+ };
2652
+ const serializePassFailFieldValue = (value) => {
2653
+ return {
2654
+ status: value.status,
2655
+ notes: value.notes,
2656
+ files: []
2657
+ };
2658
+ };
2659
+ const deserializePassFailFieldValue = (value) => {
2660
+ return {
2661
+ status: value.status,
2662
+ notes: value.notes,
2663
+ files: []
2664
+ };
2665
+ };
2666
+ const arePassFieldValuesEqual = (value1, value2) => {
2667
+ if (value1.status !== value2.status) return false;
2668
+ if (value1.notes !== value2.notes) return false;
2669
+ if (!areFileAndPromiseArraysEqual(value1.files, value2.files)) return false;
2670
+ return true;
2671
+ };
2672
+ const _PassFailField = class _PassFailField extends BaseField {
2673
+ constructor(options) {
2674
+ const { showNotesAndFilesOn, ...rest } = options;
2675
+ super(rest);
2676
+ __publicField(this, "type", "pass-fail");
2677
+ __publicField(this, "onlyValidateAfterTouched", false);
2678
+ __publicField(this, "showNotesAndFilesOn");
2679
+ this.showNotesAndFilesOn = showNotesAndFilesOn;
2680
+ }
2681
+ static getFieldCreationSchema(parentPath = "") {
2682
+ const path = parentPath && `${parentPath}.`;
2683
+ return [
2684
+ {
2685
+ field: new MultiSelectField({
2686
+ identifier: `${path}showNotesAndFilesOn`,
2687
+ label: "Show notes and files on",
2688
+ description: "Show the notes and files on desired statuses.",
2689
+ options: passFailFieldStatuses.map((status) => {
2690
+ const { label } = passFailFieldStatusMapping[status];
2691
+ return {
2692
+ value: status,
2693
+ label
2694
+ };
2695
+ }),
2696
+ required: false
2697
+ }),
2698
+ showDirectly: false
2699
+ }
2700
+ ];
2701
+ }
2702
+ serialize() {
2703
+ return {
2704
+ ...super.serialize(),
2705
+ showNotesAndFilesOn: this.showNotesAndFilesOn
2706
+ };
2707
+ }
2708
+ getOptions() {
2709
+ return {
2710
+ ...super.getOptions(),
2711
+ showNotesAndFilesOn: this.showNotesAndFilesOn
2712
+ };
2713
+ }
2714
+ duplicate(identifier) {
2715
+ return new _PassFailField({
2716
+ ...this.getOptions(),
2717
+ identifier
2718
+ });
2719
+ }
2720
+ setOptions(options) {
2721
+ const { showNotesAndFilesOn, ...rest } = options;
2722
+ this.showNotesAndFilesOn = showNotesAndFilesOn ?? this.showNotesAndFilesOn;
2723
+ super.setOptions(rest);
2724
+ }
2725
+ getFieldValidators() {
2726
+ const validators = super.getFieldValidators();
2727
+ const showNotesAndFileOn = this.showNotesAndFilesOn;
2728
+ const blankValue = this.blankValue();
2729
+ if (showNotesAndFileOn.length > 0) {
2730
+ validators.push((value) => {
2731
+ if (!value.status || !showNotesAndFileOn.includes(value.status)) return;
2732
+ if (blankValue.notes === value.notes) {
2733
+ return "Notes is required.";
2734
+ }
2735
+ });
2736
+ validators.push((value) => {
2737
+ if (!value.status || !showNotesAndFileOn.includes(value.status)) return;
2738
+ if (areFileAndPromiseArraysEqual(blankValue.files, value.files)) {
2739
+ return "Files is required.";
2740
+ }
2741
+ });
2742
+ }
2743
+ return validators;
2744
+ }
2745
+ static deserialize(data) {
2746
+ return new _PassFailField({
2747
+ ...data,
2748
+ showNotesAndFilesOn: data.showNotesAndFilesOn ?? false
2749
+ });
2750
+ }
2751
+ serializeValue(value) {
2752
+ return serializePassFailFieldValue(value);
2753
+ }
2754
+ deserializeValue(value) {
2755
+ return deserializePassFailFieldValue(value);
2756
+ }
2757
+ render(props) {
2758
+ return /* @__PURE__ */ jsxRuntime.jsx(PassFailInput, { field: this, ...props });
2759
+ }
2760
+ isSerializedValueValid(value) {
2761
+ return isSerializedPassFailFieldValue(value);
2762
+ }
2763
+ isValueValid(value) {
2764
+ return isPassFailFieldValue(value);
2765
+ }
2766
+ areValuesEqual(value1, value2) {
2767
+ return arePassFieldValuesEqual(value1, value2);
2768
+ }
2769
+ blankValue() {
2770
+ return {
2771
+ status: null,
2772
+ notes: "",
2773
+ files: []
2774
+ };
2775
+ }
2776
+ cleanValue(value) {
2777
+ if (value.status && this.showNotesAndFilesOn.includes(value.status)) {
2778
+ return value;
2779
+ } else {
2780
+ return {
2781
+ status: value.status,
2782
+ notes: "",
2783
+ files: []
2784
+ };
2785
+ }
2786
+ }
2787
+ };
2788
+ __publicField(_PassFailField, "fieldTypeName", "Pass - Fail");
2789
+ __publicField(_PassFailField, "fieldTypeDescription", "Track pass, fail, or N/A outcome.");
2790
+ let PassFailField = _PassFailField;
1644
2791
  const RadioInput = React.memo((props) => {
1645
2792
  const [{ inputId, labelId, size, severity, showInputOnly, field, helpText, label, fieldProps }, { disabled }] = useFormikInput(props);
1646
2793
  const { name, onChange, onBlur, value } = fieldProps;
@@ -1666,68 +2813,207 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1666
2813
  labelId,
1667
2814
  label: computedLabel,
1668
2815
  image: showInputOnly ? void 0 : field.image,
1669
- children: /* @__PURE__ */ jsxRuntime.jsxs(
1670
- blocks.RadioGroup.Root,
1671
- {
1672
- id: inputId,
1673
- name,
1674
- className: "flex flex-col gap-1",
1675
- accentColor: "base",
1676
- variant: "surface",
1677
- size: "sm",
1678
- value: value ?? "",
1679
- onValueChange: handleChange,
1680
- disabled,
1681
- children: [
1682
- field.options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex gap-2 items-center min-w-0", children: [
1683
- /* @__PURE__ */ jsxRuntime.jsx(blocks.RadioGroup.Item, { value: option.value, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RadioGroup.Indicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "circle", className: "fill-current" }) }) }),
1684
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "sm", accentColor: "base", className: "truncate", children: option.label })
1685
- ] }, `${inputId}-${option.value}-${index}`)),
1686
- !!value && /* @__PURE__ */ jsxRuntime.jsxs(
1687
- blocks.Button,
2816
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
2817
+ blocks.RadioGroup.Root,
2818
+ {
2819
+ id: inputId,
2820
+ name,
2821
+ className: "flex flex-col gap-1",
2822
+ accentColor: "base",
2823
+ variant: "surface",
2824
+ size: "sm",
2825
+ value: value ?? "",
2826
+ onValueChange: handleChange,
2827
+ disabled,
2828
+ children: [
2829
+ field.options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex gap-2 items-center min-w-0", children: [
2830
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.RadioGroup.Item, { value: option.value, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RadioGroup.Indicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Circle, className: "fill-current" }) }) }),
2831
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "sm", accentColor: "base", className: "truncate", children: option.label })
2832
+ ] }, `${inputId}-${option.value}-${index}`)),
2833
+ !!value && /* @__PURE__ */ jsxRuntime.jsxs(
2834
+ blocks.Button,
2835
+ {
2836
+ onClick: handleClear,
2837
+ className: "w-max -mx-2",
2838
+ type: "button",
2839
+ variant: "ghost",
2840
+ accentColor: "base",
2841
+ size: "sm",
2842
+ children: [
2843
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: X }),
2844
+ "Clear"
2845
+ ]
2846
+ }
2847
+ )
2848
+ ]
2849
+ }
2850
+ )
2851
+ }
2852
+ ) });
2853
+ });
2854
+ RadioInput.displayName = "SelectInput";
2855
+ const _RadioField = class _RadioField extends BaseOptionsField {
2856
+ constructor(options) {
2857
+ super(options);
2858
+ __publicField(this, "type", "radio");
2859
+ __publicField(this, "onlyValidateAfterTouched", false);
2860
+ }
2861
+ serialize() {
2862
+ return super.serialize();
2863
+ }
2864
+ getOptions() {
2865
+ return super.getOptions();
2866
+ }
2867
+ duplicate(identifier) {
2868
+ return new _RadioField({
2869
+ ...this.getOptions(),
2870
+ identifier
2871
+ });
2872
+ }
2873
+ setOptions(options) {
2874
+ super.setOptions(options);
2875
+ }
2876
+ static deserialize(data) {
2877
+ return new _RadioField(data);
2878
+ }
2879
+ serializeValue(value) {
2880
+ return value;
2881
+ }
2882
+ deserializeValue(value) {
2883
+ return value;
2884
+ }
2885
+ render(props) {
2886
+ return /* @__PURE__ */ jsxRuntime.jsx(RadioInput, { field: this, ...props });
2887
+ }
2888
+ isSerializedValueValid(value) {
2889
+ return typeof value === "string" || value === "null";
2890
+ }
2891
+ isValueValid(value) {
2892
+ return typeof value === "string" || value === "null";
2893
+ }
2894
+ blankValue() {
2895
+ return null;
2896
+ }
2897
+ areValuesEqual(value1, value2) {
2898
+ return value1 === value2;
2899
+ }
2900
+ };
2901
+ __publicField(_RadioField, "fieldTypeName", "Option list");
2902
+ __publicField(_RadioField, "fieldTypeDescription", "Allows the user to select a single option from a list of options.");
2903
+ let RadioField = _RadioField;
2904
+ const RatingInput = React.memo((props) => {
2905
+ const [{ inputId, labelId, size, severity, showInputOnly, field, helpText, label, fieldProps }, { disabled }] = useFormikInput(props);
2906
+ const { name, onChange, onBlur, value } = fieldProps;
2907
+ const computedHelpText = showInputOnly ? null : helpText;
2908
+ const computedLabel = showInputOnly ? "" : label;
2909
+ const handleChange = React.useCallback(
2910
+ (value2) => {
2911
+ onChange(value2);
2912
+ onBlur(value2);
2913
+ },
2914
+ [onBlur, onChange]
2915
+ );
2916
+ const handleClear = React.useCallback(() => {
2917
+ onChange(null);
2918
+ onBlur(null);
2919
+ }, [onBlur, onChange]);
2920
+ const ratingOptions = Array.from({ length: field.maxRating }, (_, i) => i + 1);
2921
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText: computedHelpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(
2922
+ InputWithLabel,
2923
+ {
2924
+ size,
2925
+ severity,
2926
+ inputId,
2927
+ labelId,
2928
+ label: computedLabel,
2929
+ image: showInputOnly ? void 0 : field.image,
2930
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row gap-1 items-center", children: [
2931
+ /* @__PURE__ */ jsxRuntime.jsx(
2932
+ blocks.Rating.Root,
2933
+ {
2934
+ id: inputId,
2935
+ name,
2936
+ className: "flex items-center gap-0.5",
2937
+ value,
2938
+ onValueChange: handleChange,
2939
+ disabled,
2940
+ children: ratingOptions.map((rating) => /* @__PURE__ */ jsxRuntime.jsx(
2941
+ blocks.Rating.Item,
1688
2942
  {
1689
- onClick: handleClear,
1690
- className: "w-max -mx-2",
1691
- type: "button",
1692
- variant: "ghost",
1693
- accentColor: "base",
1694
- size: "sm",
1695
- children: [
1696
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "x" }),
1697
- "Clear"
1698
- ]
1699
- }
1700
- )
1701
- ]
1702
- }
1703
- )
2943
+ value: rating,
2944
+ className: "group size-7 flex cursor-pointer disabled:opacity-50 disabled:pointer-events-none items-center justify-center text-yellow-500 transition-colors",
2945
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Star, className: "group-data-[active=true]:fill-current size-full" })
2946
+ },
2947
+ `${inputId}-${rating}`
2948
+ ))
2949
+ }
2950
+ ),
2951
+ !disabled && value !== null && /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: handleClear, type: "button", variant: "ghost", accentColor: "base", size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: X }) })
2952
+ ] })
1704
2953
  }
1705
2954
  ) });
1706
2955
  });
1707
- RadioInput.displayName = "SelectInput";
1708
- const _RadioField = class _RadioField extends BaseOptionsField {
2956
+ RatingInput.displayName = "RatingInput";
2957
+ const _RatingField = class _RatingField extends BaseField {
1709
2958
  constructor(options) {
1710
- super(options);
1711
- __publicField(this, "type", "radio");
1712
- __publicField(this, "onlyValidateAfterTouched", false);
2959
+ const { maxRating, ...rest } = options;
2960
+ super(rest);
2961
+ __publicField(this, "type", "rating");
2962
+ __publicField(this, "maxRating");
2963
+ this.maxRating = maxRating;
2964
+ }
2965
+ static getFieldCreationSchema(parentPath = "") {
2966
+ const path = parentPath && `${parentPath}.`;
2967
+ return [
2968
+ {
2969
+ field: new NumberField({
2970
+ label: "Max Rating",
2971
+ description: "Maximum rating value",
2972
+ integers: true,
2973
+ required: false,
2974
+ minimum: 1,
2975
+ maximum: 10,
2976
+ identifier: `${path}maxRating`
2977
+ }),
2978
+ showDirectly: false
2979
+ }
2980
+ ];
2981
+ }
2982
+ getFieldValidators() {
2983
+ const validators = super.getFieldValidators();
2984
+ const max = this.maxRating;
2985
+ validators.push((value) => {
2986
+ if (typeof value === "number" && (value < 1 || value > max)) {
2987
+ return `Rating must be between 1 and ${max}.`;
2988
+ }
2989
+ });
2990
+ return validators;
1713
2991
  }
1714
2992
  serialize() {
1715
- return super.serialize();
2993
+ return {
2994
+ ...super.serialize(),
2995
+ maxRating: this.maxRating
2996
+ };
1716
2997
  }
1717
2998
  getOptions() {
1718
- return super.getOptions();
2999
+ return {
3000
+ ...super.getOptions(),
3001
+ maxRating: this.maxRating
3002
+ };
1719
3003
  }
1720
3004
  duplicate(identifier) {
1721
- return new _RadioField({
3005
+ return new _RatingField({
1722
3006
  ...this.getOptions(),
1723
3007
  identifier
1724
3008
  });
1725
3009
  }
1726
3010
  setOptions(options) {
1727
- super.setOptions(options);
3011
+ const { maxRating, ...rest } = options;
3012
+ this.maxRating = maxRating ?? this.maxRating;
3013
+ super.setOptions(rest);
1728
3014
  }
1729
3015
  static deserialize(data) {
1730
- return new _RadioField(data);
3016
+ return new _RatingField(data);
1731
3017
  }
1732
3018
  serializeValue(value) {
1733
3019
  return value;
@@ -1736,24 +3022,24 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1736
3022
  return value;
1737
3023
  }
1738
3024
  render(props) {
1739
- return /* @__PURE__ */ jsxRuntime.jsx(RadioInput, { field: this, ...props });
3025
+ return /* @__PURE__ */ jsxRuntime.jsx(RatingInput, { field: this, ...props });
1740
3026
  }
1741
3027
  isSerializedValueValid(value) {
1742
- return typeof value === "string" || value === "null";
3028
+ return typeof value === "number" || value === null;
1743
3029
  }
1744
3030
  isValueValid(value) {
1745
- return typeof value === "string" || value === "null";
1746
- }
1747
- blankValue() {
1748
- return null;
3031
+ return typeof value === "number" || value === null;
1749
3032
  }
1750
3033
  areValuesEqual(value1, value2) {
1751
3034
  return value1 === value2;
1752
3035
  }
3036
+ blankValue() {
3037
+ return null;
3038
+ }
1753
3039
  };
1754
- __publicField(_RadioField, "fieldTypeName", "Option list");
1755
- __publicField(_RadioField, "fieldTypeDescription", "Allows the user to select a single option from a list of options.");
1756
- let RadioField = _RadioField;
3040
+ __publicField(_RatingField, "fieldTypeName", "Rating");
3041
+ __publicField(_RatingField, "fieldTypeDescription", "Allows users to select a rating value.");
3042
+ let RatingField = _RatingField;
1757
3043
  const ScannerContext = React.createContext(() => {
1758
3044
  throw new Error("No ScannerProvider found");
1759
3045
  });
@@ -24080,7 +25366,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
24080
25366
  return PDF417CodewordDecoder2;
24081
25367
  }()
24082
25368
  );
24083
- const global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
24084
25369
  var PDF417ResultMetadata = (
24085
25370
  /** @class */
24086
25371
  function() {
@@ -24375,8 +25660,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
24375
25660
  if (typeof window !== "undefined") {
24376
25661
  return window["BigInt"] || null;
24377
25662
  }
24378
- if (typeof global$1 !== "undefined") {
24379
- return global$1["BigInt"] || null;
25663
+ if (typeof global !== "undefined") {
25664
+ return global["BigInt"] || null;
24380
25665
  }
24381
25666
  if (typeof self !== "undefined") {
24382
25667
  return self["BigInt"] || null;
@@ -29870,7 +31155,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
29870
31155
  ]
29871
31156
  ]);
29872
31157
  const Scanner = React.memo((props) => {
29873
- const { children, open, onOpenChange, defaultOpen, modal, ...rest } = props;
31158
+ const {
31159
+ children,
31160
+ open,
31161
+ onOpenChange,
31162
+ // oxlint-disable-line unbound-method
31163
+ defaultOpen,
31164
+ modal,
31165
+ ...rest
31166
+ } = props;
29874
31167
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Overlay.Root, { open, onOpenChange, defaultOpen, modal, children: [
29875
31168
  !!children && /* @__PURE__ */ jsxRuntime.jsx(blocks.Overlay.Trigger, { asChild: true, children }),
29876
31169
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Overlay.Content, { children: [
@@ -29892,7 +31185,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
29892
31185
  hints: SCANNER_HINTS
29893
31186
  });
29894
31187
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex size-full flex-col justify-center overflow-hidden bg-(--color-background)", children: [
29895
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full justify-end p-4", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Overlay.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { "aria-label": "close", variant: "soft", accentColor: "base", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "x" }) }) }) }),
31188
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full justify-end p-4", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Overlay.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { "aria-label": "close", variant: "soft", accentColor: "base", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: X }) }) }) }),
29896
31189
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grow w-full max-h-full overflow-hidden p-4", children: /* @__PURE__ */ jsxRuntime.jsx("video", { className: "size-full", ref }) })
29897
31190
  ] });
29898
31191
  });
@@ -29999,7 +31292,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
29999
31292
  accentColor: "base",
30000
31293
  disabled,
30001
31294
  children: [
30002
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "maximize" }),
31295
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Maximize }),
30003
31296
  "Scan"
30004
31297
  ]
30005
31298
  }
@@ -30137,7 +31430,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30137
31430
  super.setOptions(options);
30138
31431
  }
30139
31432
  static deserialize(data) {
30140
- if (data.type !== "string") throw new Error("Type mismatch.");
30141
31433
  const { maximum_length, minimum_length, ...rest } = data;
30142
31434
  return new _StringField({
30143
31435
  ...rest,
@@ -30247,107 +31539,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30247
31539
  __publicField(_TextField, "fieldTypeName", "Paragraph");
30248
31540
  __publicField(_TextField, "fieldTypeDescription", `Paragraph fields can hold up to ${LONG_TEXT_FIELD_MAX_LENGTH} characters and can have multiple lines.`);
30249
31541
  let TextField = _TextField;
30250
- const ImageCard = React.memo(
30251
- React.forwardRef((props, forwardedRef) => {
30252
- const { file, alt, error, rightSlot, className, ...rest } = props;
30253
- return /* @__PURE__ */ jsxRuntime.jsxs(
30254
- blocks.Card,
30255
- {
30256
- className: classVarianceAuthority.cx(className, "relative flex h-[200px] w-full flex-col gap-2 overflow-hidden items-center"),
30257
- ref: forwardedRef,
30258
- ...rest,
30259
- children: [
30260
- !file && !error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 grow flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Spinner, {}) }),
30261
- !!file && !error && /* @__PURE__ */ jsxRuntime.jsx(blocks.Card, { className: "flex max-w-full grow items-center !p-0 justify-center overflow-hidden bg-clip-padding", children: /* @__PURE__ */ jsxRuntime.jsx(
30262
- "img",
30263
- {
30264
- className: "max-w-full object-cover",
30265
- src: URL.createObjectURL(file),
30266
- alt: alt ?? file.name
30267
- }
30268
- ) }),
30269
- (!!file || !!error) && /* @__PURE__ */ jsxRuntime.jsxs(
30270
- "div",
30271
- {
30272
- className: classVarianceAuthority.cx("flex w-full items-center gap-2 self-end", {
30273
- "bg-transparent": !file
30274
- }),
30275
- children: [
30276
- error ? /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "file-warning" }) : file && /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "file" }),
30277
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: "truncate", size: "sm", children: error ?? (file == null ? void 0 : file.name) }),
30278
- rightSlot
30279
- ]
30280
- }
30281
- )
30282
- ]
30283
- }
30284
- );
30285
- })
30286
- );
30287
- class UUIDPromise extends Promise {
30288
- constructor(executor, uuid2) {
30289
- super(executor);
30290
- __publicField(this, "_uuid");
30291
- this._uuid = uuid2;
30292
- }
30293
- get uuid() {
30294
- return this._uuid;
30295
- }
30296
- set uuid(uuid2) {
30297
- this._uuid = uuid2;
30298
- }
30299
- static from(promise, uuid2) {
30300
- return new UUIDPromise((resolve, reject) => {
30301
- Promise.resolve(promise).then(resolve).catch(reject);
30302
- }, uuid2);
30303
- }
30304
- then(onFulfilled, onRejected) {
30305
- const promise = super.then(onFulfilled, onRejected);
30306
- promise.uuid = this.uuid;
30307
- return promise;
30308
- }
30309
- catch(onRejected) {
30310
- const promise = super.catch(onRejected);
30311
- promise.uuid = this.uuid;
30312
- return promise;
30313
- }
30314
- finally(onFinally) {
30315
- const promise = super.finally(onFinally);
30316
- promise.uuid = this.uuid;
30317
- return promise;
30318
- }
30319
- }
30320
- const convertBytesToLargestUnit = (bytes) => {
30321
- const units = ["byte", "kilobyte", "megabyte"];
30322
- let sizeInUnit = bytes;
30323
- let unitIndex = 0;
30324
- while (sizeInUnit > 1e3 && unitIndex < units.length - 1) {
30325
- sizeInUnit /= 1e3;
30326
- unitIndex++;
30327
- }
30328
- const formatter = new Intl.NumberFormat([], {
30329
- // 0 for bytes and kilobytes, 1 for megabytes
30330
- maximumFractionDigits: Math.max(0, unitIndex - 1),
30331
- style: "unit",
30332
- unit: units[unitIndex]
30333
- });
30334
- return formatter.format(sizeInUnit);
30335
- };
30336
- function areFilesEqual(file1, file2) {
30337
- return file1.name === file2.name && file1.size === file2.size && file1.type === file2.type;
30338
- }
30339
- function separateFilesFromPromises(filesOrPromises) {
30340
- const files = [];
30341
- const promises = [];
30342
- for (const fileOrPromise of filesOrPromises) {
30343
- if (fileOrPromise instanceof UUIDPromise) {
30344
- promises.push(fileOrPromise);
30345
- } else {
30346
- files.push(fileOrPromise);
30347
- }
30348
- }
30349
- return [files, promises];
30350
- }
30351
31542
  const UploadInput = React.memo((props) => {
30352
31543
  var _a2;
30353
31544
  const [{ inputId, labelId, label, size, severity, helpText, showInputOnly, field, fieldProps }, { disabled }] = useFormikInput(props);
@@ -30372,7 +31563,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30372
31563
  onBlur([]);
30373
31564
  return;
30374
31565
  }
30375
- const fileArray = Array.from(files);
31566
+ const fileArray = Array.from(files).map((file) => UUIDFile.from(uuid.v4(), file));
30376
31567
  const newValue = [...value, ...fileArray];
30377
31568
  onChange(newValue);
30378
31569
  onBlur(newValue);
@@ -30380,7 +31571,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30380
31571
  const handleRemove = React.useCallback(
30381
31572
  (index) => {
30382
31573
  const files = [...value];
30383
- files.splice(index, 1);
31574
+ void files.splice(index, 1);
30384
31575
  onChange(files);
30385
31576
  },
30386
31577
  [value, onChange]
@@ -30427,7 +31618,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30427
31618
  type: "button",
30428
31619
  disabled,
30429
31620
  children: [
30430
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "upload" }),
31621
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Upload }),
30431
31622
  buttonText
30432
31623
  ]
30433
31624
  }
@@ -30452,7 +31643,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30452
31643
  Array.isArray(value) && value.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-max flex-col gap-2", children: value.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(
30453
31644
  DisplayFile,
30454
31645
  {
30455
- field,
30456
31646
  file,
30457
31647
  onRemove: () => {
30458
31648
  handleRemove(index);
@@ -30464,92 +31654,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30464
31654
  ] });
30465
31655
  });
30466
31656
  UploadInput.displayName = "UploadInput";
30467
- const DisplayFile = React.memo((props) => {
30468
- const { file, field, onRemove, disabled } = props;
30469
- const [resolvedFile, setResolvedFile] = React.useState(null);
30470
- const openImageViewer = useImageViewer();
30471
- const error = React.useMemo(() => resolvedFile && field.getError([resolvedFile]), [field, resolvedFile]);
30472
- const { url, name } = React.useMemo(() => {
30473
- let url2 = null;
30474
- let name2;
30475
- let size;
30476
- if (resolvedFile == null ? void 0 : resolvedFile.type.startsWith("image/")) {
30477
- url2 = URL.createObjectURL(resolvedFile);
30478
- }
30479
- if (resolvedFile) {
30480
- name2 = resolvedFile.name;
30481
- size = convertBytesToLargestUnit(resolvedFile.size);
30482
- } else {
30483
- name2 = "Downloading...";
30484
- size = "...";
30485
- }
30486
- return { url: url2, name: name2, size };
30487
- }, [resolvedFile]);
30488
- React.useEffect(() => {
30489
- if (file instanceof UUIDPromise) {
30490
- file.then((file2) => {
30491
- setResolvedFile(file2);
30492
- }).catch(console.error);
30493
- } else {
30494
- setResolvedFile(file);
30495
- }
30496
- }, [file]);
30497
- const handleDownload = React.useCallback(
30498
- (event) => {
30499
- event.stopPropagation();
30500
- if (!resolvedFile) {
30501
- throw new Error("Cannot download a file that is not resolved.");
30502
- }
30503
- const blob = new Blob([resolvedFile]);
30504
- fileSaver.saveAs(blob, name);
30505
- },
30506
- [name, resolvedFile]
30507
- );
30508
- const handleDelete = React.useCallback(
30509
- (e) => {
30510
- e.stopPropagation();
30511
- onRemove();
30512
- },
30513
- [onRemove]
30514
- );
30515
- const handleImageCardClick = React.useCallback(() => {
30516
- if (!resolvedFile) return;
30517
- openImageViewer((closeFileViewer) => ({
30518
- file: resolvedFile,
30519
- onDelete: !disabled ? () => {
30520
- onRemove();
30521
- closeFileViewer();
30522
- } : void 0
30523
- }));
30524
- }, [disabled, onRemove, openImageViewer, resolvedFile]);
30525
- const rightSlotContent = React.useMemo(
30526
- () => /* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex grow justify-end", variant: "ghost", accentColor: "base", size: "sm", children: [
30527
- /* @__PURE__ */ jsxRuntime.jsx(
30528
- blocks.IconButton,
30529
- {
30530
- "aria-label": `Download ${name}`,
30531
- type: "button",
30532
- onClick: handleDownload,
30533
- disabled: !resolvedFile,
30534
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "download" })
30535
- }
30536
- ),
30537
- !disabled && /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", "aria-label": `Remove ${name}`, disabled, onClick: handleDelete, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "trash" }) })
30538
- ] }),
30539
- [disabled, handleDelete, handleDownload, name, resolvedFile]
30540
- );
30541
- return url ? /* @__PURE__ */ jsxRuntime.jsx(
30542
- ImageCard,
30543
- {
30544
- className: "cursor-pointer",
30545
- onClick: handleImageCardClick,
30546
- file: resolvedFile,
30547
- error: error ?? void 0,
30548
- rightSlot: rightSlotContent
30549
- }
30550
- ) : /* @__PURE__ */ jsxRuntime.jsx(FileCard, { file: resolvedFile, error: error ?? void 0, rightSlot: rightSlotContent });
30551
- });
30552
- DisplayFile.displayName = "DisplayFile";
30553
31657
  const _UploadField = class _UploadField extends BaseField {
30554
31658
  constructor(options) {
30555
31659
  const { extensions, maximum_files, maximum_size, ...base } = options;
@@ -30629,7 +31733,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30629
31733
  const maxFileSizeInB = maxFileSizeInMB * 1e3 * 1e3;
30630
31734
  const maxFiles = this.maxFiles || 1;
30631
31735
  validators.push((value) => {
30632
- if (value && value.some((file) => file instanceof File && file.size > maxFileSizeInB)) {
31736
+ if (value && value.some((file) => file instanceof UUIDFile && file.size > maxFileSizeInB)) {
30633
31737
  return `Files must be at most ${maxFileSizeInMB}MB.`;
30634
31738
  }
30635
31739
  });
@@ -30686,16 +31790,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30686
31790
  }
30687
31791
  isValueValid(value) {
30688
31792
  if (!Array.isArray(value)) return false;
30689
- return value.every((item) => item instanceof UUIDPromise || item instanceof File);
31793
+ return value.every((item) => item instanceof UUIDPromise || item instanceof UUIDFile);
30690
31794
  }
30691
31795
  areValuesEqual(value1, value2) {
30692
- const [files1, promises1] = separateFilesFromPromises(value1);
30693
- const [files2, promises2] = separateFilesFromPromises(value2);
30694
- if (!files1.every((file1) => files2.some((file2) => areFilesEqual(file1, file2)))) return false;
30695
- if (!files2.every((file2) => files1.some((file1) => areFilesEqual(file1, file2)))) return false;
30696
- if (!promises1.every((promise1) => promises2.some((promise2) => promise1.uuid === promise2.uuid))) return false;
30697
- if (!promises2.every((promise2) => promises1.some((promise1) => promise1.uuid === promise2.uuid))) return false;
30698
- return true;
31796
+ return areFileAndPromiseArraysEqual(value1, value2);
30699
31797
  }
30700
31798
  blankValue() {
30701
31799
  return [];
@@ -30717,23 +31815,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30717
31815
  "multi-select": MultiSelectField,
30718
31816
  radio: RadioField,
30719
31817
  "checkbox-list": CheckboxListField,
30720
- otp: OTPField
31818
+ "pass-fail": PassFailField,
31819
+ otp: OTPField,
31820
+ rating: RatingField
30721
31821
  };
30722
31822
  const fieldIcons = {
30723
- boolean: "square-check",
30724
- date: "calendar",
30725
- "multi-string": "list",
30726
- number: "hash",
30727
- qr: "scan",
30728
- "multi-select": "list-checks",
30729
- select: "list-todo",
30730
- string: "text-cursor-input",
30731
- text: "align-justify",
30732
- upload: "upload",
30733
- section: "layout-panel-top",
30734
- radio: "circle-dot",
30735
- "checkbox-list": "copy-check",
30736
- otp: "rectangle-ellipsis"
31823
+ boolean: SquareCheck,
31824
+ date: Calendar,
31825
+ "multi-string": List,
31826
+ number: Hash,
31827
+ qr: Scan,
31828
+ "multi-select": ListChecks,
31829
+ select: ListTodo,
31830
+ string: TextCursorInput,
31831
+ text: AlignJustify,
31832
+ upload: Upload,
31833
+ section: LayoutPanelTop,
31834
+ radio: CircleDot,
31835
+ "checkbox-list": CopyCheck,
31836
+ "pass-fail": ClipboardList,
31837
+ otp: RectangleEllipsis,
31838
+ rating: Star
30737
31839
  };
30738
31840
  const maxFileSizeMB = 50;
30739
31841
  const maxFileSizeKB = maxFileSizeMB * 1e3;
@@ -30742,12 +31844,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30742
31844
  constructor(config) {
30743
31845
  __publicField(this, "id");
30744
31846
  __publicField(this, "label");
30745
- __publicField(this, "modifierFn");
31847
+ __publicField(this, "getApplyFn");
30746
31848
  __publicField(this, "serialize");
30747
31849
  __publicField(this, "deserialize");
30748
- const { id, modifierFn, label, serialize, deserialize: deserialize2 } = config;
31850
+ const { id, getApplyFn, label, serialize, deserialize: deserialize2 } = config;
30749
31851
  this.id = id;
30750
- this.modifierFn = modifierFn;
31852
+ this.getApplyFn = getApplyFn;
30751
31853
  this.label = label;
30752
31854
  this.serialize = serialize;
30753
31855
  this.deserialize = deserialize2;
@@ -30759,40 +31861,34 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30759
31861
  const BooleanEqualsConditionModifier = ConditionModifier.create({
30760
31862
  id: "nullable-boolean-equals",
30761
31863
  label: "is",
30762
- modifierFn: (value, filterValue) => value === filterValue,
31864
+ getApplyFn: (filterValue) => (value) => value === filterValue,
30763
31865
  serialize: (filterValue) => filterValue,
30764
31866
  deserialize: (filterValue) => filterValue
30765
31867
  });
30766
31868
  const BooleanNotEqualsConditionModifier = ConditionModifier.create({
30767
31869
  id: "nullable-boolean-not-equals",
30768
31870
  label: "is not",
30769
- modifierFn: (value, filterValue) => value !== filterValue,
31871
+ getApplyFn: (filterValue) => (value) => value !== filterValue,
30770
31872
  serialize: (filterValue) => filterValue,
30771
31873
  deserialize: (filterValue) => filterValue
30772
31874
  });
30773
31875
  const DateEqualsConditionModifier = ConditionModifier.create({
30774
31876
  id: "date-equals",
30775
- modifierFn: (value, filterValue) => {
30776
- return value.getTime() === filterValue.getTime();
30777
- },
31877
+ getApplyFn: (filterValue) => (value) => value.getTime() === filterValue.getTime(),
30778
31878
  label: "is",
30779
31879
  serialize: (filterValue) => filterValue.toISOString(),
30780
31880
  deserialize: (filterValue) => new Date(filterValue)
30781
31881
  });
30782
31882
  const DateNotEqualsConditionModifier = ConditionModifier.create({
30783
31883
  id: "date-not-equals",
30784
- modifierFn: (value, filterValue) => {
30785
- return value.getTime() !== filterValue.getTime();
30786
- },
31884
+ getApplyFn: (filterValue) => (value) => value.getTime() !== filterValue.getTime(),
30787
31885
  label: "is not",
30788
31886
  serialize: (filterValue) => filterValue.toISOString(),
30789
31887
  deserialize: (filterValue) => new Date(filterValue)
30790
31888
  });
30791
31889
  const DateBeforeConditionModifier = ConditionModifier.create({
30792
31890
  id: "date-before",
30793
- modifierFn: (value, filterValue) => {
30794
- return value.getTime() < filterValue.getTime();
30795
- },
31891
+ getApplyFn: (filterValue) => (value) => value.getTime() < filterValue.getTime(),
30796
31892
  label: "before",
30797
31893
  serialize: (filterValue) => filterValue.toISOString(),
30798
31894
  deserialize: (filterValue) => new Date(filterValue)
@@ -30800,16 +31896,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30800
31896
  const DateAfterConditionModifier = ConditionModifier.create({
30801
31897
  id: "date-after",
30802
31898
  label: "after",
30803
- modifierFn: (value, filterValue) => {
30804
- return value.getTime() > filterValue.getTime();
30805
- },
31899
+ getApplyFn: (filterValue) => (value) => value.getTime() > filterValue.getTime(),
30806
31900
  serialize: (filterValue) => filterValue.toISOString(),
30807
31901
  deserialize: (filterValue) => new Date(filterValue)
30808
31902
  });
30809
31903
  const DateRangeInConditionModifier = ConditionModifier.create({
30810
31904
  id: "date-range-in",
30811
31905
  label: "in between",
30812
- modifierFn: (value, filterValue) => {
31906
+ getApplyFn: (filterValue) => (value) => {
30813
31907
  if ((filterValue == null ? void 0 : filterValue.from) && filterValue.from.getTime() > value.getTime()) return false;
30814
31908
  if ((filterValue == null ? void 0 : filterValue.to) && filterValue.to.getTime() < value.getTime()) return false;
30815
31909
  return true;
@@ -30831,7 +31925,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30831
31925
  const DateRangeNotInConditionModifier = ConditionModifier.create({
30832
31926
  id: "date-range-not-in",
30833
31927
  label: "not in between",
30834
- modifierFn: (value, filterValue) => {
31928
+ getApplyFn: (filterValue) => (value) => {
30835
31929
  if ((filterValue == null ? void 0 : filterValue.from) && filterValue.from.getTime() > value.getTime()) return true;
30836
31930
  if ((filterValue == null ? void 0 : filterValue.to) && filterValue.to.getTime() < value.getTime()) return true;
30837
31931
  return false;
@@ -30853,74 +31947,62 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30853
31947
  const HasFilesConditionModifier = ConditionModifier.create({
30854
31948
  id: "has-files",
30855
31949
  label: "is",
30856
- modifierFn: (value, _filterValue) => value.length > 0,
31950
+ getApplyFn: (_filterValue) => (value) => value.length > 0,
30857
31951
  serialize: (filterValue) => filterValue,
30858
31952
  deserialize: (filterValue) => filterValue
30859
31953
  });
30860
31954
  const DoesNotHaveFilesConditionModifier = ConditionModifier.create({
30861
31955
  id: "does-not-have-files",
30862
31956
  label: "is not",
30863
- modifierFn: (value, _filterValue) => value.length === 0,
31957
+ getApplyFn: (_filterValue) => (value) => value.length === 0,
30864
31958
  serialize: (filterValue) => filterValue,
30865
31959
  deserialize: (filterValue) => filterValue
30866
31960
  });
30867
31961
  const NumberEqualsConditionModifier = ConditionModifier.create({
30868
31962
  id: "number-equals",
30869
- modifierFn: (value, filterValue) => {
30870
- return value === filterValue;
30871
- },
31963
+ getApplyFn: (filterValue) => (value) => value === filterValue,
30872
31964
  label: "is",
30873
31965
  serialize: (filterValue) => filterValue,
30874
31966
  deserialize: (filterValue) => filterValue
30875
31967
  });
30876
31968
  const NumberNotEqualsConditionModifier = ConditionModifier.create({
30877
31969
  id: "number-not-equals",
30878
- modifierFn: (value, filterValue) => {
30879
- return value !== filterValue;
30880
- },
31970
+ getApplyFn: (filterValue) => (value) => value !== filterValue,
30881
31971
  label: "is not",
30882
31972
  serialize: (filterValue) => filterValue,
30883
31973
  deserialize: (filterValue) => filterValue
30884
31974
  });
30885
31975
  const NumberLessThanConditionModifier = ConditionModifier.create({
30886
31976
  id: "number-less-than",
30887
- modifierFn: (value, filterValue) => {
30888
- return value < filterValue;
30889
- },
31977
+ getApplyFn: (filterValue) => (value) => value < filterValue,
30890
31978
  label: "is less than",
30891
31979
  serialize: (filterValue) => filterValue,
30892
31980
  deserialize: (filterValue) => filterValue
30893
31981
  });
30894
31982
  const NumberLessThanOrEqualsConditionModifier = ConditionModifier.create({
30895
31983
  id: "number-less-than-or-equals",
30896
- modifierFn: (value, filterValue) => {
30897
- return value <= filterValue;
30898
- },
31984
+ getApplyFn: (filterValue) => (value) => value <= filterValue,
30899
31985
  label: "is less than or equal to",
30900
31986
  serialize: (filterValue) => filterValue,
30901
31987
  deserialize: (filterValue) => filterValue
30902
31988
  });
30903
31989
  const NumberGreaterThanConditionModifier = ConditionModifier.create({
30904
31990
  id: "number-greater-than",
30905
- modifierFn: (value, filterValue) => {
30906
- return value > filterValue;
30907
- },
31991
+ getApplyFn: (filterValue) => (value) => value > filterValue,
30908
31992
  label: "is greater than",
30909
31993
  serialize: (filterValue) => filterValue,
30910
31994
  deserialize: (filterValue) => filterValue
30911
31995
  });
30912
31996
  const NumberGreaterThanOrEqualsConditionModifier = ConditionModifier.create({
30913
31997
  id: "number-greater-than-or-equals",
30914
- modifierFn: (value, filterValue) => {
30915
- return value >= filterValue;
30916
- },
31998
+ getApplyFn: (filterValue) => (value) => value >= filterValue,
30917
31999
  label: "is greater than or equal to",
30918
32000
  serialize: (filterValue) => filterValue,
30919
32001
  deserialize: (filterValue) => filterValue
30920
32002
  });
30921
32003
  const NumberRangeInConditionModifier = ConditionModifier.create({
30922
32004
  id: "number-range-in",
30923
- modifierFn: (value, filterValue) => {
32005
+ getApplyFn: (filterValue) => (value) => {
30924
32006
  if (filterValue.to && value > filterValue.to) return false;
30925
32007
  if (filterValue.from && value < filterValue.from) return false;
30926
32008
  return true;
@@ -30931,7 +32013,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30931
32013
  });
30932
32014
  const NumberRangeNotInConditionModifier = ConditionModifier.create({
30933
32015
  id: "number-range-not-in",
30934
- modifierFn: (value, filterValue) => {
32016
+ getApplyFn: (filterValue) => (value) => {
30935
32017
  if (filterValue.to && value > filterValue.to) return true;
30936
32018
  if (filterValue.from && value < filterValue.from) return true;
30937
32019
  return false;
@@ -30940,46 +32022,73 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30940
32022
  serialize: (filterValue) => filterValue,
30941
32023
  deserialize: (filterValue) => filterValue
30942
32024
  });
32025
+ const PassFailEqualsConditionModifier = ConditionModifier.create({
32026
+ id: "pass-fail-equals",
32027
+ getApplyFn: (filterValue) => (value) => value === filterValue,
32028
+ label: "is",
32029
+ serialize: (filterValue) => filterValue,
32030
+ deserialize: (filterValue) => filterValue
32031
+ });
32032
+ const PassFailNotEqualsConditionModifier = ConditionModifier.create({
32033
+ id: "pass-fail-not-equals",
32034
+ getApplyFn: (filterValue) => (value) => value !== filterValue,
32035
+ label: "is not",
32036
+ serialize: (filterValue) => filterValue,
32037
+ deserialize: (filterValue) => filterValue
32038
+ });
32039
+ const PassFailArrayIncludesConditionModifier = ConditionModifier.create({
32040
+ id: "pass-fail-array-includes",
32041
+ getApplyFn: (filterValue) => {
32042
+ const filterValueSet = new Set(filterValue);
32043
+ return (value) => filterValueSet.has(value);
32044
+ },
32045
+ label: "is any of",
32046
+ serialize: (filterValue) => filterValue,
32047
+ deserialize: (filterValue) => filterValue
32048
+ });
32049
+ const PassFailArrayExcludesConditionModifier = ConditionModifier.create({
32050
+ id: "pass-fail-array-excludes",
32051
+ getApplyFn: (filterValue) => {
32052
+ const filterValueSet = new Set(filterValue);
32053
+ return (value) => !filterValueSet.has(value);
32054
+ },
32055
+ label: "is none of",
32056
+ serialize: (filterValue) => filterValue,
32057
+ deserialize: (filterValue) => filterValue
32058
+ });
30943
32059
  const StringEqualsConditionModifier = ConditionModifier.create({
30944
32060
  id: "nullable-string-equals",
30945
- modifierFn: (value, filterValue) => {
30946
- return value === filterValue;
30947
- },
32061
+ getApplyFn: (filterValue) => (value) => value === filterValue,
30948
32062
  label: "is",
30949
32063
  serialize: (filterValue) => filterValue,
30950
32064
  deserialize: (filterValue) => filterValue
30951
32065
  });
30952
32066
  const StringNotEqualsConditionModifier = ConditionModifier.create({
30953
32067
  id: "nullable-string-not-equals",
30954
- modifierFn: (value, filterValue) => {
30955
- return value !== filterValue;
30956
- },
32068
+ getApplyFn: (filterValue) => (value) => value !== filterValue,
30957
32069
  label: "is not",
30958
32070
  serialize: (filterValue) => filterValue,
30959
32071
  deserialize: (filterValue) => filterValue
30960
32072
  });
30961
32073
  const StringIncludesConditionModifier = ConditionModifier.create({
30962
32074
  id: "string-includes",
30963
- modifierFn: (value, filterValue) => {
30964
- return value.includes(filterValue);
30965
- },
32075
+ getApplyFn: (filterValue) => (value) => value.includes(filterValue),
30966
32076
  label: "includes",
30967
32077
  serialize: (filterValue) => filterValue,
30968
32078
  deserialize: (filterValue) => filterValue
30969
32079
  });
30970
32080
  const StringExcludesConditionModifier = ConditionModifier.create({
30971
32081
  id: "string-excludes",
30972
- modifierFn: (value, filterValue) => {
30973
- return !value.includes(filterValue);
30974
- },
32082
+ getApplyFn: (filterValue) => (value) => !value.includes(filterValue),
30975
32083
  label: "does not include",
30976
32084
  serialize: (filterValue) => filterValue,
30977
32085
  deserialize: (filterValue) => filterValue
30978
32086
  });
30979
32087
  const StringArrayIncludesConditionModifier = ConditionModifier.create({
30980
32088
  id: "string-array-includes",
30981
- modifierFn: (value, filterValue) => {
30982
- return filterValue.includes(value);
32089
+ getApplyFn: (filterValue) => {
32090
+ const filterValueSet = new Set(filterValue);
32091
+ return (value) => filterValueSet.has(value);
30983
32092
  },
30984
32093
  label: "is any of",
30985
32094
  serialize: (filterValue) => filterValue,
@@ -30987,8 +32096,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30987
32096
  });
30988
32097
  const StringArrayExcludesConditionModifier = ConditionModifier.create({
30989
32098
  id: "string-array-excludes",
30990
- modifierFn: (value, filterValue) => {
30991
- return !filterValue.includes(value);
32099
+ getApplyFn: (filterValue) => {
32100
+ const filterValueSet = new Set(filterValue);
32101
+ return (value) => !filterValueSet.has(value);
30992
32102
  },
30993
32103
  label: "is none of",
30994
32104
  serialize: (filterValue) => filterValue,
@@ -30996,8 +32106,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
30996
32106
  });
30997
32107
  const StringArrayEveryConditionModifier = ConditionModifier.create({
30998
32108
  id: "string-array-every",
30999
- modifierFn: (value, filterValue) => {
31000
- return filterValue.every((filterValue2) => value.includes(filterValue2));
32109
+ getApplyFn: (filterValue) => {
32110
+ const filterValueSet = new Set(filterValue);
32111
+ return (value) => {
32112
+ const valueSet = new Set(value);
32113
+ return filterValueSet.isSubsetOf(valueSet);
32114
+ };
31001
32115
  },
31002
32116
  label: "has all of",
31003
32117
  serialize: (filterValue) => filterValue,
@@ -31005,8 +32119,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31005
32119
  });
31006
32120
  const StringArraySomeConditionModifier = ConditionModifier.create({
31007
32121
  id: "string-array-some",
31008
- modifierFn: (value, filterValue) => {
31009
- return filterValue.some((filterValue2) => value.includes(filterValue2));
32122
+ getApplyFn: (filterValue) => {
32123
+ const filterValueSet = new Set(filterValue);
32124
+ return (value) => {
32125
+ const valueSet = new Set(value);
32126
+ return !filterValueSet.isDisjointFrom(valueSet);
32127
+ };
31010
32128
  },
31011
32129
  label: "has any of",
31012
32130
  serialize: (filterValue) => filterValue,
@@ -31014,8 +32132,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31014
32132
  });
31015
32133
  const StringArrayNoneConditionModifier = ConditionModifier.create({
31016
32134
  id: "string-array-none",
31017
- modifierFn: (value, filterValue) => {
31018
- return filterValue.every((filterValue2) => !value.includes(filterValue2));
32135
+ getApplyFn: (filterValue) => {
32136
+ const filterValueSet = new Set(filterValue);
32137
+ return (value) => {
32138
+ const valueSet = new Set(value);
32139
+ return filterValueSet.isDisjointFrom(valueSet);
32140
+ };
31019
32141
  },
31020
32142
  label: "has none of",
31021
32143
  serialize: (filterValue) => filterValue,
@@ -31023,10 +32145,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31023
32145
  });
31024
32146
  const StringArrayEqualsConditionModifier = ConditionModifier.create({
31025
32147
  id: "string-array-equals",
31026
- modifierFn: (value, filterValue) => {
31027
- if (filterValue === null && value === null) return true;
31028
- if (filterValue === null || value === null) return false;
31029
- return value.every((value2) => filterValue.includes(value2)) && filterValue.every((filterValue2) => value.includes(filterValue2));
32148
+ getApplyFn: (filterValue) => {
32149
+ const filterValueSet = new Set(filterValue);
32150
+ return (value) => {
32151
+ const valueSet = new Set(value);
32152
+ return filterValueSet.size === valueSet.size && valueSet.isSubsetOf(filterValueSet);
32153
+ };
31030
32154
  },
31031
32155
  label: "is",
31032
32156
  serialize: (filterValue) => filterValue,
@@ -31034,10 +32158,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31034
32158
  });
31035
32159
  const StringArrayNotEqualsConditionModifier = ConditionModifier.create({
31036
32160
  id: "string-array-not-equals",
31037
- modifierFn: (value, filterValue) => {
31038
- if (filterValue === null && value === null) return false;
31039
- if (filterValue === null || value === null) return true;
31040
- return !(value.every((value2) => filterValue.includes(value2)) && filterValue.every((filterValue2) => value.includes(filterValue2)));
32161
+ getApplyFn: (filterValue) => {
32162
+ const filterValueSet = new Set(filterValue);
32163
+ return (value) => {
32164
+ const valueSet = new Set(value);
32165
+ return filterValueSet.size !== valueSet.size || !valueSet.isSubsetOf(filterValueSet);
32166
+ };
31041
32167
  },
31042
32168
  label: "is not",
31043
32169
  serialize: (filterValue) => filterValue,
@@ -31076,12 +32202,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31076
32202
  __publicField(this, "getConditionModifiers", () => {
31077
32203
  return Object.entries(this.modifiers);
31078
32204
  });
31079
- __publicField(this, "apply", (value) => {
32205
+ __publicField(this, "accessorFn", (values) => {
32206
+ return values[this.field.identifier];
32207
+ });
32208
+ __publicField(this, "getApplyFn", () => {
31080
32209
  const modifier = this.modifiers[this.conditionModifier];
31081
32210
  const conditionValue = this.getConditionValue();
31082
- if (conditionValue === void 0 || !modifier.isConditionValueValid(conditionValue)) return true;
31083
- if (!modifier.isValueValid(value)) return false;
31084
- return modifier.modifier.modifierFn(value, conditionValue);
32211
+ const conditionValueInvalid = conditionValue === void 0 || !modifier.isConditionValueValid(conditionValue);
32212
+ const applyFn = modifier.modifier.getApplyFn(conditionValue);
32213
+ return (value) => {
32214
+ if (conditionValueInvalid) return true;
32215
+ const transformedValue = this.transformValue(value);
32216
+ if (!modifier.isValueValid(transformedValue)) return false;
32217
+ return applyFn(transformedValue);
32218
+ };
31085
32219
  });
31086
32220
  this.id = id;
31087
32221
  this.field = field;
@@ -31097,6 +32231,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31097
32231
  conditionModifier: this.conditionModifier
31098
32232
  };
31099
32233
  }
32234
+ transformValue(value) {
32235
+ return value;
32236
+ }
31100
32237
  }
31101
32238
  const formId = "form-builder";
31102
32239
  const UNLABELLED_FIELD_LABEL = "Unlabelled";
@@ -31109,12 +32246,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31109
32246
  if (typeof children === "function") {
31110
32247
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
31111
32248
  children(meta),
31112
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { className: "ml-[auto]", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) })
32249
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { className: "ml-[auto]", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) })
31113
32250
  ] });
31114
32251
  } else {
31115
32252
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
31116
32253
  children,
31117
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { className: "ml-[auto]", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) })
32254
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { className: "ml-[auto]", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) })
31118
32255
  ] });
31119
32256
  }
31120
32257
  },
@@ -31129,12 +32266,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31129
32266
  if (typeof children === "function") {
31130
32267
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
31131
32268
  children(meta),
31132
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { className: "ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) })
32269
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { className: "ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) })
31133
32270
  ] });
31134
32271
  } else {
31135
32272
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
31136
32273
  children,
31137
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { className: "ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) })
32274
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.SelectedIndicator, { className: "ml-auto", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) })
31138
32275
  ] });
31139
32276
  }
31140
32277
  },
@@ -31149,12 +32286,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31149
32286
  if (typeof children === "function") {
31150
32287
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
31151
32288
  children(meta),
31152
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.CheckboxItemIndicator, { className: "ml-[auto]", children: (indeterminate) => indeterminate ? /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "minus" }) : /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) })
32289
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.CheckboxItemIndicator, { className: "ml-[auto]", children: (indeterminate) => indeterminate ? /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Minus }) : /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) })
31153
32290
  ] });
31154
32291
  } else {
31155
32292
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
31156
32293
  children,
31157
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.CheckboxItemIndicator, { className: "ml-[auto]", children: (indeterminate) => indeterminate ? /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "minus" }) : /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) })
32294
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.CheckboxItemIndicator, { className: "ml-[auto]", children: (indeterminate) => indeterminate ? /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Minus }) : /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) })
31158
32295
  ] });
31159
32296
  }
31160
32297
  },
@@ -31248,7 +32385,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31248
32385
  variant: "soft",
31249
32386
  type: "button",
31250
32387
  onClick: handleAddValueClick,
31251
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" })
32388
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Plus })
31252
32389
  }
31253
32390
  )
31254
32391
  ] }),
@@ -31271,7 +32408,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31271
32408
  onClick: () => {
31272
32409
  handleRemoveValueClick(index);
31273
32410
  },
31274
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "x" })
32411
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: X })
31275
32412
  }
31276
32413
  )
31277
32414
  ]
@@ -31331,7 +32468,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31331
32468
  const handleRemoveFilter = React.useCallback(() => {
31332
32469
  onClick(condition);
31333
32470
  }, [condition, onClick]);
31334
- return /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: handleRemoveFilter, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "x" }) });
32471
+ return /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: handleRemoveFilter, ...rest, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: X }) });
31335
32472
  };
31336
32473
  RemoveConditionButton.displayName = "RemoveConditionButton";
31337
32474
  const SelectFieldOptionMultiSelectGroup = React.memo((props) => {
@@ -31446,7 +32583,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31446
32583
  /* @__PURE__ */ jsxRuntime.jsx(RemoveConditionButton, { condition, onClick: onRemove })
31447
32584
  ] });
31448
32585
  };
31449
- const modifiers$c = {
32586
+ const modifiers$e = {
31450
32587
  equals: createConditionModifierConfig({
31451
32588
  modifier: BooleanEqualsConditionModifier,
31452
32589
  isValueValid: (_value) => true,
@@ -31463,13 +32600,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31463
32600
  class BooleanFieldCondition extends BaseCondition {
31464
32601
  constructor(options) {
31465
32602
  super(options);
31466
- __publicField(this, "defaultConditionModifier", "equals");
31467
- __publicField(this, "defaultConditionValue");
31468
- __publicField(this, "modifiers", modifiers$c);
32603
+ __publicField(this, "modifiers", modifiers$e);
31469
32604
  }
31470
32605
  static deserialize(serializedCondition, field) {
31471
32606
  const { conditionValue, conditionModifier, ...rest } = serializedCondition;
31472
- const modifierConfig = modifiers$c[conditionModifier];
32607
+ const modifierConfig = modifiers$e[conditionModifier];
31473
32608
  let deserializedValue = void 0;
31474
32609
  if (conditionValue !== void 0) {
31475
32610
  deserializedValue = modifierConfig.modifier.deserialize(conditionValue);
@@ -31525,7 +32660,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31525
32660
  /* @__PURE__ */ jsxRuntime.jsx(RemoveConditionButton, { condition, onClick: onRemove })
31526
32661
  ] });
31527
32662
  };
31528
- const modifiers$b = {
32663
+ const modifiers$d = {
31529
32664
  equals: createConditionModifierConfig({
31530
32665
  modifier: StringArrayEqualsConditionModifier,
31531
32666
  isValueValid: (_value) => true,
@@ -31560,13 +32695,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31560
32695
  class CheckboxListFieldCondition extends BaseCondition {
31561
32696
  constructor(options) {
31562
32697
  super(options);
31563
- __publicField(this, "defaultConditionModifier", "equals");
31564
- __publicField(this, "defaultConditionValue");
31565
- __publicField(this, "modifiers", modifiers$b);
32698
+ __publicField(this, "modifiers", modifiers$d);
31566
32699
  }
31567
32700
  static deserialize(serializedCondition, field) {
31568
32701
  const { conditionValue, conditionModifier, ...rest } = serializedCondition;
31569
- const modifierConfig = modifiers$b[conditionModifier];
32702
+ const modifierConfig = modifiers$d[conditionModifier];
31570
32703
  const deserializedValue = conditionValue !== void 0 && modifierConfig.isSerializedValueValid(conditionValue) ? modifierConfig.modifier.deserialize(conditionValue) : void 0;
31571
32704
  return new CheckboxListFieldCondition({ field, conditionModifier, conditionValue: deserializedValue, ...rest });
31572
32705
  }
@@ -31574,6 +32707,55 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31574
32707
  return /* @__PURE__ */ jsxRuntime.jsx(CheckboxListFieldConditionCell, { condition: this, ...props }, this.id);
31575
32708
  }
31576
32709
  }
32710
+ class ConditionManager extends Observable {
32711
+ constructor(conditions) {
32712
+ super();
32713
+ __publicField(this, "conditions");
32714
+ __publicField(this, "conditionObserver", () => {
32715
+ this.conditions = [...this.conditions];
32716
+ this.notify(this);
32717
+ });
32718
+ __publicField(this, "initConditions", (conditions) => {
32719
+ for (const c of conditions) c.observe(this.conditionObserver);
32720
+ return conditions;
32721
+ });
32722
+ this.conditions = this.initConditions(conditions);
32723
+ }
32724
+ getConditions() {
32725
+ return this.conditions;
32726
+ }
32727
+ addCondition(condition) {
32728
+ this.conditions = this.initConditions([...this.conditions, condition]);
32729
+ this.notify(this);
32730
+ }
32731
+ addConditions(conditions) {
32732
+ this.conditions = this.initConditions([...this.conditions, ...conditions]);
32733
+ this.notify(this);
32734
+ }
32735
+ removeCondition(condition) {
32736
+ this.conditions = this.initConditions(this.conditions.filter((c) => c.id !== condition.id));
32737
+ this.notify(this);
32738
+ }
32739
+ removeConditions(conditions) {
32740
+ const conditionIds = new Set(conditions.map((c) => c.id));
32741
+ this.conditions = this.initConditions(this.conditions.filter((c) => !conditionIds.has(c.id)));
32742
+ this.notify(this);
32743
+ }
32744
+ applyConditions(values) {
32745
+ if (this.conditions.length === 0) return true;
32746
+ const applyAndAccessorFns = this.conditions.map((condition) => [condition.getApplyFn(), condition.accessorFn]);
32747
+ return applyAndAccessorFns.every(([applyFn, accessorFn]) => {
32748
+ return applyFn(accessorFn(values));
32749
+ });
32750
+ }
32751
+ }
32752
+ const useConditionManager = (conditions, onConditionsChange) => {
32753
+ return React.useMemo(() => {
32754
+ const ret = new ConditionManager(conditions);
32755
+ ret.observe((conditionManager) => onConditionsChange(conditionManager.getConditions()));
32756
+ return ret;
32757
+ }, [conditions, onConditionsChange]);
32758
+ };
31577
32759
  const DateFieldConditionCell = (props) => {
31578
32760
  const { condition, onRemove } = props;
31579
32761
  const conditionValue = condition.getConditionValue();
@@ -31641,7 +32823,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31641
32823
  /* @__PURE__ */ jsxRuntime.jsx(RemoveConditionButton, { condition, onClick: onRemove })
31642
32824
  ] });
31643
32825
  };
31644
- const modifiers$a = {
32826
+ const modifiers$c = {
31645
32827
  equals: createConditionModifierConfig({
31646
32828
  modifier: DateEqualsConditionModifier,
31647
32829
  isValueValid: (value) => value instanceof Date,
@@ -31682,13 +32864,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31682
32864
  class DateFieldCondition extends BaseCondition {
31683
32865
  constructor(options) {
31684
32866
  super(options);
31685
- __publicField(this, "defaultConditionModifier", "equals");
31686
- __publicField(this, "defaultConditionValue");
31687
- __publicField(this, "modifiers", modifiers$a);
32867
+ __publicField(this, "modifiers", modifiers$c);
31688
32868
  }
31689
32869
  static deserialize(serializedCondition, field) {
31690
32870
  const { conditionValue, conditionModifier, ...rest } = serializedCondition;
31691
- const modifierConfig = modifiers$a[conditionModifier];
32871
+ const modifierConfig = modifiers$c[conditionModifier];
31692
32872
  const deserializedValue = conditionValue !== void 0 && modifierConfig.isSerializedValueValid(conditionValue) ? (
31693
32873
  // @ts-expect-error calling isSerializedValueValid means conditionValue is of appropriate type
31694
32874
  modifierConfig.modifier.deserialize(conditionValue)
@@ -31744,7 +32924,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31744
32924
  /* @__PURE__ */ jsxRuntime.jsx(RemoveConditionButton, { condition, onClick: onRemove })
31745
32925
  ] });
31746
32926
  };
31747
- const modifiers$9 = {
32927
+ const modifiers$b = {
31748
32928
  equals: createConditionModifierConfig({
31749
32929
  modifier: StringArrayEqualsConditionModifier,
31750
32930
  isValueValid: (_value) => true,
@@ -31779,13 +32959,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31779
32959
  class MultiSelectFieldCondition extends BaseCondition {
31780
32960
  constructor(options) {
31781
32961
  super(options);
31782
- __publicField(this, "defaultConditionValue");
31783
- __publicField(this, "defaultConditionModifier", "equals");
31784
- __publicField(this, "modifiers", modifiers$9);
32962
+ __publicField(this, "modifiers", modifiers$b);
31785
32963
  }
31786
32964
  static deserialize(serializedCondition, field) {
31787
32965
  const { conditionValue, conditionModifier, ...rest } = serializedCondition;
31788
- const modifierConfig = modifiers$9[conditionModifier];
32966
+ const modifierConfig = modifiers$b[conditionModifier];
31789
32967
  const deserializedValue = conditionValue !== void 0 && modifierConfig.isSerializedValueValid(conditionValue) ? modifierConfig.modifier.deserialize(conditionValue) : void 0;
31790
32968
  return new MultiSelectFieldCondition({ field, conditionModifier, conditionValue: deserializedValue, ...rest });
31791
32969
  }
@@ -31829,7 +33007,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31829
33007
  /* @__PURE__ */ jsxRuntime.jsx(RemoveConditionButton, { condition, onClick: onRemove })
31830
33008
  ] });
31831
33009
  };
31832
- const modifiers$8 = {
33010
+ const modifiers$a = {
31833
33011
  equals: createConditionModifierConfig({
31834
33012
  modifier: StringArrayEqualsConditionModifier,
31835
33013
  isValueValid: (_value) => true,
@@ -31864,13 +33042,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31864
33042
  class MultiStringFieldCondition extends BaseCondition {
31865
33043
  constructor(options) {
31866
33044
  super(options);
31867
- __publicField(this, "defaultConditionValue");
31868
- __publicField(this, "defaultConditionModifier", "equals");
31869
- __publicField(this, "modifiers", modifiers$8);
33045
+ __publicField(this, "modifiers", modifiers$a);
31870
33046
  }
31871
33047
  static deserialize(serializedCondition, field) {
31872
33048
  const { conditionValue, conditionModifier, ...rest } = serializedCondition;
31873
- const modifierConfig = modifiers$8[conditionModifier];
33049
+ const modifierConfig = modifiers$a[conditionModifier];
31874
33050
  const deserializedValue = conditionValue !== void 0 && modifierConfig.isSerializedValueValid(conditionValue) ? modifierConfig.modifier.deserialize(conditionValue) : void 0;
31875
33051
  return new MultiStringFieldCondition({ field, conditionModifier, conditionValue: deserializedValue, ...rest });
31876
33052
  }
@@ -31949,7 +33125,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
31949
33125
  /* @__PURE__ */ jsxRuntime.jsx(RemoveConditionButton, { condition, onClick: onRemove })
31950
33126
  ] });
31951
33127
  };
31952
- const modifiers$7 = {
33128
+ const modifiers$9 = {
31953
33129
  equals: createConditionModifierConfig({
31954
33130
  modifier: NumberEqualsConditionModifier,
31955
33131
  isValueValid: (value) => typeof value === "number",
@@ -32002,13 +33178,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32002
33178
  class NumberFieldCondition extends BaseCondition {
32003
33179
  constructor(options) {
32004
33180
  super(options);
32005
- __publicField(this, "defaultConditionValue");
32006
- __publicField(this, "defaultConditionModifier", "equals");
32007
- __publicField(this, "modifiers", modifiers$7);
33181
+ __publicField(this, "modifiers", modifiers$9);
32008
33182
  }
32009
33183
  static deserialize(serializedCondition, field) {
32010
33184
  const { conditionValue, conditionModifier, ...rest } = serializedCondition;
32011
- const modifierConfig = modifiers$7[conditionModifier];
33185
+ const modifierConfig = modifiers$9[conditionModifier];
32012
33186
  const deserializedValue = conditionValue !== void 0 && modifierConfig.isSerializedValueValid(conditionValue) ? (
32013
33187
  // @ts-expect-error calling isSerializedValueValid means conditionValue is of appropriate type
32014
33188
  modifierConfig.modifier.deserialize(conditionValue)
@@ -32052,7 +33226,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32052
33226
  /* @__PURE__ */ jsxRuntime.jsx(RemoveConditionButton, { condition, onClick: onRemove })
32053
33227
  ] });
32054
33228
  };
32055
- const modifiers$6 = {
33229
+ const modifiers$8 = {
32056
33230
  equals: createConditionModifierConfig({
32057
33231
  modifier: StringEqualsConditionModifier,
32058
33232
  isValueValid: (_value) => true,
@@ -32081,13 +33255,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32081
33255
  class OTPFieldCondition extends BaseCondition {
32082
33256
  constructor(options) {
32083
33257
  super(options);
32084
- __publicField(this, "defaultConditionValue");
32085
- __publicField(this, "defaultConditionModifier", "equals");
32086
- __publicField(this, "modifiers", modifiers$6);
33258
+ __publicField(this, "modifiers", modifiers$8);
32087
33259
  }
32088
33260
  static deserialize(serializedCondition, field) {
32089
33261
  const { conditionValue, conditionModifier, ...rest } = serializedCondition;
32090
- const modifierConfig = modifiers$6[conditionModifier];
33262
+ const modifierConfig = modifiers$8[conditionModifier];
32091
33263
  const deserializedValue = conditionValue !== void 0 && modifierConfig.isSerializedValueValid(conditionValue) ? modifierConfig.modifier.deserialize(conditionValue) : void 0;
32092
33264
  return new OTPFieldCondition({ field, conditionModifier, conditionValue: deserializedValue, ...rest });
32093
33265
  }
@@ -32095,6 +33267,117 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32095
33267
  return /* @__PURE__ */ jsxRuntime.jsx(OTPFieldConditionCell, { condition: this, ...props }, this.id);
32096
33268
  }
32097
33269
  }
33270
+ const PassFailFieldConditionCell = (props) => {
33271
+ const { condition, onRemove } = props;
33272
+ const field = condition.field;
33273
+ const conditionValue = condition.getConditionValue();
33274
+ const conditionModifier = condition.getConditionModifier();
33275
+ const getFilterValueUi = () => {
33276
+ switch (conditionModifier) {
33277
+ case "equals":
33278
+ case "notEquals": {
33279
+ const equalsModifier = condition.modifiers.equals;
33280
+ const equalsFilterValue = conditionValue !== void 0 && equalsModifier.isConditionValueValid(conditionValue) ? conditionValue : void 0;
33281
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { children: [
33282
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.ClickTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", className: "min-w-0 shrink-1 grow", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: equalsFilterValue !== void 0 ? equalsFilterValue ? passFailFieldStatusMapping[equalsFilterValue].label : "empty" : "..." }) }) }),
33283
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(
33284
+ blocks.Menu.SelectGroup,
33285
+ {
33286
+ required: false,
33287
+ value: equalsFilterValue,
33288
+ onValueChange: condition.setConditionValue,
33289
+ children: passFailFieldStatuses.map((status) => {
33290
+ const { label } = passFailFieldStatusMapping[status];
33291
+ return /* @__PURE__ */ jsxRuntime.jsx(SelectItemTemplate, { value: status, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: label }) }, status);
33292
+ })
33293
+ }
33294
+ ) })
33295
+ ] });
33296
+ }
33297
+ case "includes":
33298
+ case "excludes": {
33299
+ const includesModifier = condition.modifiers.includes;
33300
+ const includesModifierFilterValue = conditionValue !== void 0 && includesModifier.isConditionValueValid(conditionValue) ? conditionValue : void 0;
33301
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { children: [
33302
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.ClickTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", children: includesModifierFilterValue ? `${includesModifierFilterValue.length} statuses` : "..." }) }),
33303
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { size: "sm", children: /* @__PURE__ */ jsxRuntime.jsxs(
33304
+ blocks.Menu.MultiSelectGroup,
33305
+ {
33306
+ values: includesModifierFilterValue ?? EMPTY_ARRAY,
33307
+ onValuesChange: condition.setConditionValue,
33308
+ children: [
33309
+ /* @__PURE__ */ jsxRuntime.jsx(SelectAllItemTemplate, { children: "Select all" }),
33310
+ passFailFieldStatuses.map((status) => {
33311
+ const { label, icon } = passFailFieldStatusMapping[status];
33312
+ return /* @__PURE__ */ jsxRuntime.jsxs(MultiSelectItemTemplate, { value: status, children: [
33313
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon }),
33314
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: label })
33315
+ ] }, status);
33316
+ })
33317
+ ]
33318
+ }
33319
+ ) })
33320
+ ] });
33321
+ }
33322
+ }
33323
+ };
33324
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex w-max max-w-full min-w-0 gap-0.5", size: "sm", variant: "fill", accentColor: "base", children: [
33325
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Badge, { className: "min-w-0 shrink-1", size: "sm", variant: "fill", accentColor: "base", children: [
33326
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[field.type] }),
33327
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: field.label || UNLABELLED_FIELD_LABEL })
33328
+ ] }),
33329
+ /* @__PURE__ */ jsxRuntime.jsx(ConditionModifierDropdown, { condition, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", children: condition.modifiers[conditionModifier].modifier.label }) }),
33330
+ getFilterValueUi(),
33331
+ /* @__PURE__ */ jsxRuntime.jsx(RemoveConditionButton, { condition, onClick: onRemove })
33332
+ ] });
33333
+ };
33334
+ const modifiers$7 = {
33335
+ equals: createConditionModifierConfig({
33336
+ modifier: PassFailEqualsConditionModifier,
33337
+ isValueValid: (value) => value !== null,
33338
+ isConditionValueValid: (conditionValue) => typeof conditionValue === "string",
33339
+ isSerializedValueValid: (serializedConditionValue) => typeof serializedConditionValue === "string"
33340
+ }),
33341
+ notEquals: createConditionModifierConfig({
33342
+ modifier: PassFailNotEqualsConditionModifier,
33343
+ isValueValid: (value) => value !== null,
33344
+ isConditionValueValid: (conditionValue) => typeof conditionValue === "string",
33345
+ isSerializedValueValid: (serializedConditionValue) => typeof serializedConditionValue === "string"
33346
+ }),
33347
+ includes: createConditionModifierConfig({
33348
+ modifier: PassFailArrayIncludesConditionModifier,
33349
+ isValueValid: (value) => value !== null,
33350
+ isConditionValueValid: (conditionValue) => Array.isArray(conditionValue),
33351
+ isSerializedValueValid: (serializedConditionValue) => Array.isArray(serializedConditionValue)
33352
+ }),
33353
+ excludes: createConditionModifierConfig({
33354
+ modifier: PassFailArrayExcludesConditionModifier,
33355
+ isValueValid: (value) => value !== null,
33356
+ isConditionValueValid: (conditionValue) => Array.isArray(conditionValue),
33357
+ isSerializedValueValid: (serializedConditionValue) => Array.isArray(serializedConditionValue)
33358
+ })
33359
+ };
33360
+ class PassFailFieldCondition extends BaseCondition {
33361
+ constructor(options) {
33362
+ super(options);
33363
+ __publicField(this, "modifiers", modifiers$7);
33364
+ }
33365
+ static deserialize(serializedCondition, field) {
33366
+ const { conditionValue, conditionModifier, ...rest } = serializedCondition;
33367
+ const modifierConfig = modifiers$7[conditionModifier];
33368
+ const deserializedValue = conditionValue !== void 0 && modifierConfig.isSerializedValueValid(conditionValue) ? (
33369
+ // @ts-expect-error calling isSerializedValueValid means conditionValue is of appropriate type
33370
+ modifierConfig.modifier.deserialize(conditionValue)
33371
+ ) : void 0;
33372
+ return new PassFailFieldCondition({ field, conditionModifier, conditionValue: deserializedValue, ...rest });
33373
+ }
33374
+ transformValue(value) {
33375
+ return value.status;
33376
+ }
33377
+ render(props) {
33378
+ return /* @__PURE__ */ jsxRuntime.jsx(PassFailFieldConditionCell, { condition: this, ...props }, this.id);
33379
+ }
33380
+ }
32098
33381
  const RadioFieldConditionCell = (props) => {
32099
33382
  const { condition, onRemove } = props;
32100
33383
  const field = condition.field;
@@ -32115,16 +33398,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32115
33398
  }
32116
33399
  return mapping;
32117
33400
  }, [normalizedOptions]);
32118
- const handleValuesChange = React.useCallback(
32119
- (values) => {
32120
- if (values.length > 0) {
32121
- condition.setConditionValue(values);
32122
- } else {
32123
- condition.setConditionValue([]);
32124
- }
32125
- },
32126
- [condition]
32127
- );
32128
33401
  const getFilterValueUi = () => {
32129
33402
  switch (conditionModifier) {
32130
33403
  case "equals":
@@ -32154,8 +33427,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32154
33427
  SelectFieldOptionMultiSelectGroup,
32155
33428
  {
32156
33429
  selectFieldOptions: field.options,
32157
- values: includesModifierFilterValue ?? [],
32158
- onValuesChange: handleValuesChange
33430
+ values: includesModifierFilterValue ?? EMPTY_ARRAY,
33431
+ onValuesChange: condition.setConditionValue
32159
33432
  }
32160
33433
  ) })
32161
33434
  ] });
@@ -32172,7 +33445,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32172
33445
  /* @__PURE__ */ jsxRuntime.jsx(RemoveConditionButton, { condition, onClick: onRemove })
32173
33446
  ] });
32174
33447
  };
32175
- const modifiers$5 = {
33448
+ const modifiers$6 = {
32176
33449
  equals: createConditionModifierConfig({
32177
33450
  modifier: StringEqualsConditionModifier,
32178
33451
  isValueValid: (value) => typeof value === "string",
@@ -32201,13 +33474,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32201
33474
  class RadioFieldCondition extends BaseCondition {
32202
33475
  constructor(options) {
32203
33476
  super(options);
32204
- __publicField(this, "defaultConditionValue");
32205
- __publicField(this, "defaultConditionModifier", "equals");
32206
- __publicField(this, "modifiers", modifiers$5);
33477
+ __publicField(this, "modifiers", modifiers$6);
32207
33478
  }
32208
33479
  static deserialize(serializedCondition, field) {
32209
33480
  const { conditionValue, conditionModifier, ...rest } = serializedCondition;
32210
- const modifierConfig = modifiers$5[conditionModifier];
33481
+ const modifierConfig = modifiers$6[conditionModifier];
32211
33482
  const deserializedValue = conditionValue !== void 0 && modifierConfig.isSerializedValueValid(conditionValue) ? (
32212
33483
  // @ts-expect-error calling isSerializedValueValid means conditionValue is of appropriate type
32213
33484
  modifierConfig.modifier.deserialize(conditionValue)
@@ -32218,6 +33489,146 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32218
33489
  return /* @__PURE__ */ jsxRuntime.jsx(RadioFieldConditionCell, { condition: this, ...props }, this.id);
32219
33490
  }
32220
33491
  }
33492
+ const RatingFieldConditionCell = (props) => {
33493
+ const { condition, onRemove } = props;
33494
+ const field = condition.field;
33495
+ const conditionValue = condition.getConditionValue();
33496
+ const conditionModifier = condition.getConditionModifier();
33497
+ const getFilterValueUi = () => {
33498
+ switch (conditionModifier) {
33499
+ case "equals":
33500
+ case "notEquals":
33501
+ case "greaterThanOrEquals":
33502
+ case "lessThanOrEquals":
33503
+ case "greaterThan":
33504
+ case "lessThan": {
33505
+ const modifier = condition.modifiers[conditionModifier];
33506
+ const filterValue = conditionValue !== void 0 && modifier.isConditionValueValid(conditionValue) ? conditionValue : void 0;
33507
+ return /* @__PURE__ */ jsxRuntime.jsx(
33508
+ NumberInputPopover,
33509
+ {
33510
+ value: filterValue ?? null,
33511
+ onValueChange: (value) => condition.setConditionValue(value ?? void 0),
33512
+ size: "sm",
33513
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", className: "truncate", children: filterValue !== void 0 ? filterValue : "..." })
33514
+ }
33515
+ );
33516
+ }
33517
+ case "inRange":
33518
+ case "notInRange": {
33519
+ const inRangeModifier = condition.modifiers.inRange;
33520
+ const rangeFilterValue = conditionValue !== void 0 && inRangeModifier.isConditionValueValid(conditionValue) ? conditionValue : void 0;
33521
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
33522
+ /* @__PURE__ */ jsxRuntime.jsx(
33523
+ NumberInputPopover,
33524
+ {
33525
+ value: (rangeFilterValue == null ? void 0 : rangeFilterValue.from) ?? null,
33526
+ onValueChange: (value) => {
33527
+ condition.setConditionValue({
33528
+ from: value,
33529
+ to: (rangeFilterValue == null ? void 0 : rangeFilterValue.to) ?? null
33530
+ });
33531
+ },
33532
+ size: "sm",
33533
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { className: "truncate", children: (rangeFilterValue == null ? void 0 : rangeFilterValue.from) ?? "..." })
33534
+ }
33535
+ ),
33536
+ /* @__PURE__ */ jsxRuntime.jsx(
33537
+ NumberInputPopover,
33538
+ {
33539
+ value: (rangeFilterValue == null ? void 0 : rangeFilterValue.to) ?? null,
33540
+ onValueChange: (value) => {
33541
+ condition.setConditionValue({
33542
+ from: (rangeFilterValue == null ? void 0 : rangeFilterValue.from) ?? null,
33543
+ to: value
33544
+ });
33545
+ },
33546
+ size: "sm",
33547
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { className: "truncate", children: (rangeFilterValue == null ? void 0 : rangeFilterValue.to) ?? "..." })
33548
+ }
33549
+ )
33550
+ ] });
33551
+ }
33552
+ }
33553
+ };
33554
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex w-max max-w-full min-w-0 gap-0.5", size: "sm", variant: "fill", accentColor: "base", children: [
33555
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Badge, { className: "min-w-0 shrink-1", size: "sm", variant: "fill", accentColor: "base", children: [
33556
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[field.type] }),
33557
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: field.label || UNLABELLED_FIELD_LABEL })
33558
+ ] }),
33559
+ /* @__PURE__ */ jsxRuntime.jsx(ConditionModifierDropdown, { condition, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", children: condition.modifiers[conditionModifier].modifier.label }) }),
33560
+ getFilterValueUi(),
33561
+ /* @__PURE__ */ jsxRuntime.jsx(RemoveConditionButton, { condition, onClick: onRemove })
33562
+ ] });
33563
+ };
33564
+ const modifiers$5 = {
33565
+ equals: createConditionModifierConfig({
33566
+ modifier: NumberEqualsConditionModifier,
33567
+ isValueValid: (value) => typeof value === "number",
33568
+ isConditionValueValid: (conditionValue) => typeof conditionValue === "number",
33569
+ isSerializedValueValid: (conditionValue) => typeof conditionValue === "number"
33570
+ }),
33571
+ notEquals: createConditionModifierConfig({
33572
+ modifier: NumberNotEqualsConditionModifier,
33573
+ isValueValid: (value) => typeof value === "number",
33574
+ isConditionValueValid: (conditionValue) => typeof conditionValue === "number",
33575
+ isSerializedValueValid: (conditionValue) => typeof conditionValue === "number"
33576
+ }),
33577
+ lessThan: createConditionModifierConfig({
33578
+ modifier: NumberLessThanConditionModifier,
33579
+ isValueValid: (value) => typeof value === "number",
33580
+ isConditionValueValid: (conditionValue) => typeof conditionValue === "number",
33581
+ isSerializedValueValid: (conditionValue) => typeof conditionValue === "number"
33582
+ }),
33583
+ lessThanOrEquals: createConditionModifierConfig({
33584
+ modifier: NumberLessThanOrEqualsConditionModifier,
33585
+ isValueValid: (value) => typeof value === "number",
33586
+ isConditionValueValid: (conditionValue) => typeof conditionValue === "number",
33587
+ isSerializedValueValid: (conditionValue) => typeof conditionValue === "number"
33588
+ }),
33589
+ greaterThan: createConditionModifierConfig({
33590
+ modifier: NumberGreaterThanConditionModifier,
33591
+ isValueValid: (value) => typeof value === "number",
33592
+ isConditionValueValid: (conditionValue) => typeof conditionValue === "number",
33593
+ isSerializedValueValid: (conditionValue) => typeof conditionValue === "number"
33594
+ }),
33595
+ greaterThanOrEquals: createConditionModifierConfig({
33596
+ modifier: NumberGreaterThanOrEqualsConditionModifier,
33597
+ isValueValid: (value) => typeof value === "number",
33598
+ isConditionValueValid: (conditionValue) => typeof conditionValue === "number",
33599
+ isSerializedValueValid: (conditionValue) => typeof conditionValue === "number"
33600
+ }),
33601
+ inRange: createConditionModifierConfig({
33602
+ modifier: NumberRangeInConditionModifier,
33603
+ isValueValid: (value) => typeof value === "number",
33604
+ isConditionValueValid: (conditionValue) => typeof conditionValue === "object",
33605
+ isSerializedValueValid: (conditionValue) => typeof conditionValue === "object"
33606
+ }),
33607
+ notInRange: createConditionModifierConfig({
33608
+ modifier: NumberRangeNotInConditionModifier,
33609
+ isValueValid: (value) => typeof value === "number",
33610
+ isConditionValueValid: (conditionValue) => typeof conditionValue === "object",
33611
+ isSerializedValueValid: (conditionValue) => typeof conditionValue === "object"
33612
+ })
33613
+ };
33614
+ class RatingFieldCondition extends BaseCondition {
33615
+ constructor(options) {
33616
+ super(options);
33617
+ __publicField(this, "modifiers", modifiers$5);
33618
+ }
33619
+ static deserialize(serializedCondition, field) {
33620
+ const { conditionValue, conditionModifier, ...rest } = serializedCondition;
33621
+ const modifierConfig = modifiers$5[conditionModifier];
33622
+ const deserializedValue = conditionValue !== void 0 && modifierConfig.isSerializedValueValid(conditionValue) ? (
33623
+ // @ts-expect-error calling isSerializedValueValid means conditionValue is of appropriate type
33624
+ modifierConfig.modifier.deserialize(conditionValue)
33625
+ ) : void 0;
33626
+ return new RatingFieldCondition({ field, conditionModifier, conditionValue: deserializedValue, ...rest });
33627
+ }
33628
+ render(props) {
33629
+ return /* @__PURE__ */ jsxRuntime.jsx(RatingFieldConditionCell, { condition: this, ...props }, this.id);
33630
+ }
33631
+ }
32221
33632
  const ScanFieldConditionCell = (props) => {
32222
33633
  const { condition, onRemove } = props;
32223
33634
  const field = condition.field;
@@ -32280,8 +33691,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32280
33691
  class ScanFieldCondition extends BaseCondition {
32281
33692
  constructor(options) {
32282
33693
  super(options);
32283
- __publicField(this, "defaultConditionValue");
32284
- __publicField(this, "defaultConditionModifier", "equals");
32285
33694
  __publicField(this, "modifiers", modifiers$4);
32286
33695
  }
32287
33696
  static deserialize(serializedCondition, field) {
@@ -32400,8 +33809,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32400
33809
  class SelectFieldCondition extends BaseCondition {
32401
33810
  constructor(options) {
32402
33811
  super(options);
32403
- __publicField(this, "defaultConditionValue");
32404
- __publicField(this, "defaultConditionModifier", "equals");
32405
33812
  __publicField(this, "modifiers", modifiers$3);
32406
33813
  }
32407
33814
  static deserialize(serializedCondition, field) {
@@ -32479,8 +33886,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32479
33886
  class StringFieldCondition extends BaseCondition {
32480
33887
  constructor(options) {
32481
33888
  super(options);
32482
- __publicField(this, "defaultConditionValue");
32483
- __publicField(this, "defaultConditionModifier", "equals");
32484
33889
  __publicField(this, "modifiers", modifiers$2);
32485
33890
  }
32486
33891
  static deserialize(serializedCondition, field) {
@@ -32555,8 +33960,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32555
33960
  class TextFieldCondition extends BaseCondition {
32556
33961
  constructor(options) {
32557
33962
  super(options);
32558
- __publicField(this, "defaultConditionValue");
32559
- __publicField(this, "defaultConditionModifier", "equals");
32560
33963
  __publicField(this, "modifiers", modifiers$1);
32561
33964
  }
32562
33965
  static deserialize(serializedCondition, field) {
@@ -32627,8 +34030,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32627
34030
  class UploadFieldCondition extends BaseCondition {
32628
34031
  constructor(options) {
32629
34032
  super(options);
32630
- __publicField(this, "defaultConditionValue");
32631
- __publicField(this, "defaultConditionModifier", "equals");
32632
34033
  __publicField(this, "modifiers", modifiers);
32633
34034
  }
32634
34035
  static deserialize(serializedCondition, field) {
@@ -32641,79 +34042,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32641
34042
  return /* @__PURE__ */ jsxRuntime.jsx(UploadFieldConditionCell, { condition: this, ...props }, this.id);
32642
34043
  }
32643
34044
  }
32644
- const deserializeCondition = (serializedCondition, field) => {
32645
- switch (serializedCondition.type) {
32646
- case "text":
32647
- return TextFieldCondition.deserialize(serializedCondition, field);
32648
- case "boolean":
32649
- return BooleanFieldCondition.deserialize(serializedCondition, field);
32650
- case "number":
32651
- return NumberFieldCondition.deserialize(serializedCondition, field);
32652
- case "date":
32653
- return DateFieldCondition.deserialize(serializedCondition, field);
32654
- case "string":
32655
- return StringFieldCondition.deserialize(serializedCondition, field);
32656
- case "select":
32657
- return SelectFieldCondition.deserialize(serializedCondition, field);
32658
- case "multi-string":
32659
- return MultiStringFieldCondition.deserialize(serializedCondition, field);
32660
- case "multi-select":
32661
- return MultiSelectFieldCondition.deserialize(serializedCondition, field);
32662
- case "upload":
32663
- return UploadFieldCondition.deserialize(serializedCondition, field);
32664
- case "qr":
32665
- return ScanFieldCondition.deserialize(serializedCondition, field);
32666
- case "radio":
32667
- return RadioFieldCondition.deserialize(serializedCondition, field);
32668
- case "checkbox-list":
32669
- return CheckboxListFieldCondition.deserialize(serializedCondition, field);
32670
- case "otp":
32671
- return OTPFieldCondition.deserialize(serializedCondition, field);
32672
- }
34045
+ const ConditionTypeToClsMapping = {
34046
+ date: DateFieldCondition,
34047
+ number: NumberFieldCondition,
34048
+ boolean: BooleanFieldCondition,
34049
+ select: SelectFieldCondition,
34050
+ string: StringFieldCondition,
34051
+ text: TextFieldCondition,
34052
+ upload: UploadFieldCondition,
34053
+ qr: ScanFieldCondition,
34054
+ "multi-string": MultiStringFieldCondition,
34055
+ "multi-select": MultiSelectFieldCondition,
34056
+ radio: RadioFieldCondition,
34057
+ "checkbox-list": CheckboxListFieldCondition,
34058
+ "pass-fail": PassFailFieldCondition,
34059
+ otp: OTPFieldCondition,
34060
+ rating: RatingFieldCondition
34061
+ };
34062
+ const deserializeCondition = (field, serializedCondition) => {
34063
+ if (field.type !== serializedCondition.type)
34064
+ throw new Error(`field and condition type mismatch ${field.type} !== ${serializedCondition.type}`);
34065
+ return ConditionTypeToClsMapping[serializedCondition.type].deserialize(serializedCondition, field);
32673
34066
  };
32674
- const deserializeConditions = (serializedConditions, fields) => {
34067
+ const deserializeConditions = (fields, serializedConditions) => {
32675
34068
  const fieldsMapping = {};
32676
34069
  for (const field of fields) {
32677
34070
  fieldsMapping[field.identifier] = field;
32678
34071
  }
32679
34072
  return serializedConditions.map(
32680
- (serializedCondition) => deserializeCondition(serializedCondition, fieldsMapping[serializedCondition.fieldId])
34073
+ (serializedCondition) => deserializeCondition(fieldsMapping[serializedCondition.fieldId], serializedCondition)
32681
34074
  );
32682
34075
  };
32683
- const applyConditions = (conditions, values) => {
32684
- return conditions.length > 0 ? conditions.every((condition) => {
32685
- return condition.apply(values[condition.field.identifier]);
32686
- }) : true;
32687
- };
32688
34076
  const deserializeField = (serializedField) => {
32689
- switch (serializedField.type) {
32690
- case "boolean":
32691
- return BooleanField.deserialize(serializedField);
32692
- case "text":
32693
- return TextField.deserialize(serializedField);
32694
- case "number":
32695
- return NumberField.deserialize(serializedField);
32696
- case "date":
32697
- return DateField.deserialize(serializedField);
32698
- case "select":
32699
- return SelectField.deserialize(serializedField);
32700
- case "multi-string":
32701
- return MultiStringField.deserialize(serializedField);
32702
- case "multi-select":
32703
- return MultiSelectField.deserialize(serializedField);
32704
- case "upload":
32705
- return UploadField.deserialize(serializedField);
32706
- case "qr":
32707
- return ScanField.deserialize(serializedField);
32708
- case "radio":
32709
- return RadioField.deserialize(serializedField);
32710
- case "checkbox-list":
32711
- return CheckboxListField.deserialize(serializedField);
32712
- case "string":
32713
- return StringField.deserialize(serializedField);
32714
- case "otp":
32715
- return OTPField.deserialize(serializedField);
32716
- }
34077
+ return FieldTypeToClsMapping[serializedField.type].deserialize(serializedField);
32717
34078
  };
32718
34079
  function deserializeFields(fields) {
32719
34080
  return fields.map(deserialize);
@@ -32788,6 +34149,85 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32788
34149
  }
32789
34150
  return ret;
32790
34151
  }
34152
+ function extractFilesAndPromisesFromFieldValues(fields, values) {
34153
+ const cleanValues = cleanFieldValues(fields, values);
34154
+ const valuesRet = {};
34155
+ const filesRet = {};
34156
+ for (const field of fields) {
34157
+ if (!(field.identifier in cleanValues)) continue;
34158
+ const value = cleanValues[field.identifier];
34159
+ switch (field.type) {
34160
+ case "upload":
34161
+ if (!field.isValueValid(value)) break;
34162
+ filesRet[field.identifier] = value;
34163
+ valuesRet[field.identifier] = [];
34164
+ break;
34165
+ case "pass-fail":
34166
+ if (!field.isValueValid(value)) break;
34167
+ filesRet[field.identifier] = value.files;
34168
+ valuesRet[field.identifier] = {
34169
+ ...value,
34170
+ files: []
34171
+ };
34172
+ break;
34173
+ default:
34174
+ valuesRet[field.identifier] = values[field.identifier];
34175
+ }
34176
+ }
34177
+ return [valuesRet, filesRet];
34178
+ }
34179
+ function insertFilesAndPromisesToFieldValues(fields, values, filesAndPromises) {
34180
+ const ret = {};
34181
+ for (const field of fields) {
34182
+ if (!(field.identifier in values)) continue;
34183
+ const value = values[field.identifier];
34184
+ switch (field.type) {
34185
+ case "upload":
34186
+ if (!field.isValueValid(value)) break;
34187
+ ret[field.identifier] = filesAndPromises[field.identifier] ?? [];
34188
+ break;
34189
+ case "pass-fail":
34190
+ if (!field.isValueValid(value)) break;
34191
+ ret[field.identifier] = {
34192
+ ...value,
34193
+ files: filesAndPromises[field.identifier] ?? []
34194
+ };
34195
+ break;
34196
+ default:
34197
+ if (!field.isValueValid(value)) break;
34198
+ ret[field.identifier] = value;
34199
+ }
34200
+ }
34201
+ return ret;
34202
+ }
34203
+ const initializeFieldValues = (fields, values) => {
34204
+ const ret = {};
34205
+ for (const field of fields) {
34206
+ const value = values[field.identifier];
34207
+ ret[field.identifier] = value !== void 0 ? value : field.blankValue();
34208
+ }
34209
+ return ret;
34210
+ };
34211
+ const changedFieldValues = (fields, values1, values2) => {
34212
+ const ret = {};
34213
+ for (const field of fields) {
34214
+ const value1 = values1[field.identifier];
34215
+ const value2 = values2[field.identifier];
34216
+ if (field.areValuesEqual(value1, value2)) continue;
34217
+ ret[field.identifier] = value2;
34218
+ }
34219
+ return ret;
34220
+ };
34221
+ const unchangedFieldValues = (fields, values1, values2) => {
34222
+ const ret = {};
34223
+ for (const field of fields) {
34224
+ const value1 = values1[field.identifier];
34225
+ const value2 = values2[field.identifier];
34226
+ if (!field.areValuesEqual(value1, value2)) continue;
34227
+ ret[field.identifier] = value2;
34228
+ }
34229
+ return ret;
34230
+ };
32791
34231
  const RendererContext = React.createContext({});
32792
34232
  const FieldSectionLayout = React.memo((props) => {
32793
34233
  const { fieldSection: section, ...rest } = props;
@@ -32802,9 +34242,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32802
34242
  }, [fieldSections, section.identifier]);
32803
34243
  const conditionMet = React.useMemo(() => {
32804
34244
  if (conditionalSections.length === 0) return true;
32805
- return conditionalSections.some(
32806
- (conditionalSection) => applyConditions(conditionalSection.getConditions(section.identifier), values)
32807
- );
34245
+ return conditionalSections.some((conditionalSection) => {
34246
+ const conditions = conditionalSection.getConditions(section.identifier);
34247
+ const conditionManager = new ConditionManager(conditions);
34248
+ return conditionManager.applyConditions(values);
34249
+ });
32808
34250
  }, [conditionalSections, section, values]);
32809
34251
  const inputs = useFieldInputs(section.fields, rest);
32810
34252
  if (!conditionMet) return null;
@@ -32864,14 +34306,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32864
34306
  fields: this.fields.map((field) => field.serialize())
32865
34307
  };
32866
34308
  }
32867
- static deserialize(data) {
32868
- const fields = data.fields.map(deserializeField);
32869
- const conditions = {};
32870
- for (const [sectionId, serializedConditions] of Object.entries(data.conditions)) {
32871
- conditions[sectionId] = deserializeConditions(serializedConditions, fields);
32872
- }
32873
- return new _FieldSection({ ...data, fields, conditions });
32874
- }
32875
34309
  getOptions() {
32876
34310
  return {
32877
34311
  ...super.getOptions(),
@@ -32909,12 +34343,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32909
34343
  getFields() {
32910
34344
  return this.fields;
32911
34345
  }
32912
- addField(field) {
32913
- this.fields = this.initFields([...this.fields, field]);
32914
- this.notify(this);
32915
- }
32916
- addFields(fields) {
32917
- this.fields = this.initFields([...this.fields, ...fields]);
34346
+ addField(field, index) {
34347
+ const copy = [...this.fields];
34348
+ copy.splice(index ?? this.fields.length, 0, field);
34349
+ this.fields = this.initFields(copy);
32918
34350
  this.notify(this);
32919
34351
  }
32920
34352
  moveField(sourceIndex, targetIndex) {
@@ -32933,16 +34365,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32933
34365
  this.conditions = newConditions;
32934
34366
  this.notify(this);
32935
34367
  }
32936
- removeFields(fields) {
32937
- const fieldIdentifiers = new Set(fields.map(({ identifier }) => identifier));
32938
- this.fields = this.initFields(this.fields.filter(({ identifier }) => !fieldIdentifiers.has(identifier)));
32939
- const newConditions = {};
32940
- for (const [sectionId, conditions] of Object.entries(this.conditions)) {
32941
- newConditions[sectionId] = conditions.filter(({ field }) => !fieldIdentifiers.has(field.identifier));
32942
- }
32943
- this.conditions = newConditions;
32944
- this.notify(this);
32945
- }
32946
34368
  getConditions(identifier) {
32947
34369
  return this.conditions[identifier];
32948
34370
  }
@@ -32979,7 +34401,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32979
34401
  return new Set(Object.keys(this.conditions));
32980
34402
  }
32981
34403
  addConditional(identifier) {
32982
- this.conditions = this.initConditions({ ...this.conditions, [identifier]: [] });
34404
+ this.conditions = this.initConditions({
34405
+ ...this.conditions,
34406
+ [identifier]: []
34407
+ });
32983
34408
  this.notify(this);
32984
34409
  }
32985
34410
  removeConditional(identifier) {
@@ -32995,6 +34420,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
32995
34420
  };
32996
34421
  __publicField(_FieldSection, "fieldTypeName", "Section");
32997
34422
  __publicField(_FieldSection, "fieldTypeDescription", "Sections can be useful for grouping fields together. They can also be conditionally shown or hidden.");
34423
+ __publicField(_FieldSection, "deserialize", (data) => {
34424
+ const fields = data.fields.map(deserializeField);
34425
+ const conditions = {};
34426
+ for (const [sectionId, serializedConditions] of Object.entries(data.conditions)) {
34427
+ conditions[sectionId] = deserializeConditions(fields, serializedConditions);
34428
+ }
34429
+ return new _FieldSection({ ...data, fields, conditions });
34430
+ });
32998
34431
  let FieldSection = _FieldSection;
32999
34432
  class FieldSchema extends Observable {
33000
34433
  constructor(fields) {
@@ -33022,27 +34455,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33022
34455
  getFieldSections() {
33023
34456
  return this.fieldSections;
33024
34457
  }
33025
- addFieldSection(field) {
33026
- this.fieldSections = this.initFields([...this.fieldSections, field]);
33027
- this.notify(this);
33028
- }
33029
- addFieldSections(fields) {
33030
- this.fieldSections = this.initFields([...this.fieldSections, ...fields]);
34458
+ addFieldSection(fieldSection, index) {
34459
+ const copy = [...this.fieldSections];
34460
+ copy.splice(index ?? this.fieldSections.length, 0, fieldSection);
34461
+ this.fieldSections = this.initFields(copy);
33031
34462
  this.notify(this);
33032
34463
  }
33033
- removeFieldSection(field) {
33034
- const newFields = this.fieldSections.filter((f) => f.identifier !== field.identifier);
33035
- for (const field2 of newFields) {
33036
- field2.removeConditional(field2.identifier);
34464
+ removeFieldSection(fieldSection) {
34465
+ const newFields = this.fieldSections.filter((f) => f.identifier !== fieldSection.identifier);
34466
+ for (const field of newFields) {
34467
+ field.removeConditional(field.identifier);
33037
34468
  }
33038
34469
  this.fieldSections = this.initFields(newFields);
33039
34470
  this.notify(this);
33040
34471
  }
33041
- removeFieldSections(fields) {
33042
- const fieldsIds = new Set(fields.map((f) => f.identifier));
33043
- this.fieldSections = this.initFields(this.fieldSections.filter((f) => !fieldsIds.has(f.identifier)));
33044
- this.notify(this);
33045
- }
33046
34472
  moveFieldSection(sourceIndex, targetIndex) {
33047
34473
  const newFields = [...this.fieldSections];
33048
34474
  const [removedElement] = newFields.splice(sourceIndex, 1);
@@ -33056,44 +34482,70 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33056
34482
  serializeValues(values) {
33057
34483
  return serializeFieldValues(this.getFields(), values);
33058
34484
  }
34485
+ deserializeConditions(conditions) {
34486
+ return deserializeConditions(this.getFields(), conditions);
34487
+ }
34488
+ initializeValues(values) {
34489
+ return initializeFieldValues(this.getFields(), values);
34490
+ }
33059
34491
  }
33060
34492
  const FieldSchemaContext = React.createContext(new FieldSchema([]));
33061
34493
  const FormBuilderContext = React.createContext({});
34494
+ const useFieldTypeItems = (onSelect = () => null) => {
34495
+ return React.useMemo(() => {
34496
+ const entries = Object.entries(FieldTypeToClsMapping);
34497
+ return entries.map(([type, fieldClass]) => ({
34498
+ children: fieldClass.fieldTypeName,
34499
+ icon: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[type] }),
34500
+ value: type,
34501
+ onSelect: () => {
34502
+ onSelect(type);
34503
+ }
34504
+ }));
34505
+ }, [onSelect]);
34506
+ };
34507
+ const CreateFieldDropdownMenu = React.memo((props) => {
34508
+ const { children, variant, size, accentColor, onSelectFieldType, ...rest } = props;
34509
+ const fieldTypeItems = useFieldTypeItems(onSelectFieldType);
34510
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { ...rest, children: [
34511
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.ClickTrigger, { children }),
34512
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { variant, size, accentColor, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Scroll, { children: fieldTypeItems.flat().map((item) => /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Item, { onSelect: item.onSelect, children: [
34513
+ item.icon,
34514
+ item.children
34515
+ ] }, item.value)) }) })
34516
+ ] });
34517
+ });
34518
+ CreateFieldDropdownMenu.displayName = "CreateFieldDropdownMenu";
33062
34519
  const createField = (type) => {
33063
34520
  switch (type) {
33064
34521
  case "text":
33065
- return new TextField({ fieldValidators: [], label: "", required: false, identifier: uuid.v4() });
34522
+ return new TextField({ label: "", required: false, identifier: uuid.v4() });
33066
34523
  case "boolean":
33067
34524
  return new BooleanField({
33068
- fieldValidators: [],
33069
34525
  label: "",
33070
34526
  required: false,
33071
34527
  identifier: uuid.v4()
33072
34528
  });
33073
34529
  case "number":
33074
34530
  return new NumberField({
33075
- fieldValidators: [],
33076
34531
  label: "",
33077
34532
  required: false,
33078
34533
  identifier: uuid.v4()
33079
34534
  });
33080
34535
  case "date":
33081
34536
  return new DateField({
33082
- fieldValidators: [],
33083
34537
  label: "",
33084
34538
  required: false,
33085
34539
  identifier: uuid.v4()
33086
34540
  });
33087
34541
  case "string":
33088
34542
  return new StringField({
33089
- fieldValidators: [],
33090
34543
  label: "",
33091
34544
  required: false,
33092
34545
  identifier: uuid.v4()
33093
34546
  });
33094
34547
  case "select":
33095
34548
  return new SelectField({
33096
- fieldValidators: [],
33097
34549
  label: "",
33098
34550
  options: [],
33099
34551
  required: false,
@@ -33101,14 +34553,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33101
34553
  });
33102
34554
  case "multi-string":
33103
34555
  return new MultiStringField({
33104
- fieldValidators: [],
33105
34556
  label: "",
33106
34557
  required: false,
33107
34558
  identifier: uuid.v4()
33108
34559
  });
33109
34560
  case "multi-select":
33110
34561
  return new MultiSelectField({
33111
- fieldValidators: [],
33112
34562
  label: "",
33113
34563
  options: [],
33114
34564
  required: false,
@@ -33116,21 +34566,20 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33116
34566
  });
33117
34567
  case "upload":
33118
34568
  return new UploadField({
33119
- fieldValidators: [],
33120
34569
  label: "",
33121
34570
  required: false,
33122
- identifier: uuid.v4()
34571
+ identifier: uuid.v4(),
34572
+ maximum_files: 6,
34573
+ maximum_size: maxFileSizeMB
33123
34574
  });
33124
34575
  case "qr":
33125
34576
  return new ScanField({
33126
- fieldValidators: [],
33127
34577
  label: "",
33128
34578
  required: false,
33129
34579
  identifier: uuid.v4()
33130
34580
  });
33131
34581
  case "radio":
33132
34582
  return new RadioField({
33133
- fieldValidators: [],
33134
34583
  label: "",
33135
34584
  options: [],
33136
34585
  required: false,
@@ -33138,21 +34587,34 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33138
34587
  });
33139
34588
  case "checkbox-list":
33140
34589
  return new CheckboxListField({
33141
- fieldValidators: [],
33142
34590
  label: "",
33143
34591
  options: [],
33144
34592
  required: false,
33145
34593
  identifier: uuid.v4()
33146
34594
  });
34595
+ case "pass-fail":
34596
+ return new PassFailField({
34597
+ label: "",
34598
+ required: false,
34599
+ identifier: uuid.v4(),
34600
+ showNotesAndFilesOn: ["fail"]
34601
+ // TODO: what defaults
34602
+ });
33147
34603
  case "otp":
33148
34604
  return new OTPField({
33149
- fieldValidators: [],
33150
34605
  label: "",
33151
34606
  validationType: "none",
33152
34607
  required: false,
33153
34608
  identifier: uuid.v4(),
33154
34609
  length: 6
33155
34610
  });
34611
+ case "rating":
34612
+ return new RatingField({
34613
+ label: "",
34614
+ required: false,
34615
+ identifier: uuid.v4(),
34616
+ maxRating: 5
34617
+ });
33156
34618
  }
33157
34619
  };
33158
34620
  const createCondition = (field) => {
@@ -33236,6 +34698,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33236
34698
  conditionModifier: "equals",
33237
34699
  field
33238
34700
  });
34701
+ case "pass-fail":
34702
+ return new PassFailFieldCondition({
34703
+ id: uuid.v4(),
34704
+ conditionValue: void 0,
34705
+ conditionModifier: "equals",
34706
+ field
34707
+ });
33239
34708
  case "otp":
33240
34709
  return new OTPFieldCondition({
33241
34710
  id: uuid.v4(),
@@ -33243,6 +34712,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33243
34712
  conditionModifier: "equals",
33244
34713
  field
33245
34714
  });
34715
+ case "rating":
34716
+ return new RatingFieldCondition({
34717
+ id: uuid.v4(),
34718
+ conditionValue: void 0,
34719
+ conditionModifier: "equals",
34720
+ field
34721
+ });
33246
34722
  }
33247
34723
  };
33248
34724
  const getFieldCreationSchema = (type, path) => {
@@ -33263,8 +34739,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33263
34739
  return TextField.getFieldCreationSchema(path);
33264
34740
  case "upload":
33265
34741
  return UploadField.getFieldCreationSchema(path);
34742
+ case "pass-fail":
34743
+ return PassFailField.getFieldCreationSchema(path);
33266
34744
  case "otp":
33267
34745
  return OTPField.getFieldCreationSchema(path);
34746
+ case "rating":
34747
+ return RatingField.getFieldCreationSchema(path);
33268
34748
  default:
33269
34749
  return;
33270
34750
  }
@@ -33282,7 +34762,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33282
34762
  accentColor: "base",
33283
34763
  ...hasError && { color: SEVERITY_COLOR_MAPPING.danger },
33284
34764
  children: [
33285
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "settings" }),
34765
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Settings }),
33286
34766
  "Settings"
33287
34767
  ]
33288
34768
  },
@@ -33293,7 +34773,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33293
34773
  });
33294
34774
  FieldSettingsPopover.displayName = "FieldSettingsPopover";
33295
34775
  const FieldBuilder = React.memo((props) => {
33296
- const { parentPath, index, field } = props;
34776
+ const { parentPath, fieldIndex, field } = props;
33297
34777
  const { errors } = formik.useFormikContext();
33298
34778
  const openImageViewer = useImageViewer();
33299
34779
  const { disableRequiredFields } = React.use(FormBuilderContext);
@@ -33309,17 +34789,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33309
34789
  const handleImageDelete = React.useCallback(() => {
33310
34790
  field.setOptions({ image: void 0 });
33311
34791
  }, [field]);
33312
- const type = field.type;
33313
34792
  const [directlyShownFields, popoverFields] = React.useMemo(() => {
33314
34793
  const directlyShownFields2 = [];
33315
34794
  const popoverFields2 = [];
33316
- const fieldObject = getFieldCreationSchema(field.type, `${parentPath}.${index}`) ?? [];
34795
+ const fieldObject = getFieldCreationSchema(field.type, `${parentPath}.${fieldIndex}`) ?? [];
33317
34796
  for (const item of fieldObject) {
33318
34797
  if (item.showDirectly) directlyShownFields2.push(item.field);
33319
34798
  else popoverFields2.push(item.field);
33320
34799
  }
33321
34800
  return [directlyShownFields2, popoverFields2];
33322
- }, [field, parentPath, index]);
34801
+ }, [field, parentPath, fieldIndex]);
33323
34802
  const directlyShownInputs = useFieldInputs(directlyShownFields, {
33324
34803
  formId,
33325
34804
  disabled: false
@@ -33344,7 +34823,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33344
34823
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 w-full justify-between", children: [
33345
34824
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 items-center", children: [
33346
34825
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Badge, { accentColor: "base", variant: "soft", size: "sm", children: [
33347
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[type] }),
34826
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[field.type] }),
33348
34827
  fieldTypeName
33349
34828
  ] }),
33350
34829
  !disableRequiredFields && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
@@ -33354,7 +34833,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33354
34833
  checked: field.required,
33355
34834
  onCheckedChange: (required) => field.setOptions({ required: !!required }),
33356
34835
  size: "sm",
33357
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Checkbox.Indicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }) })
34836
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Checkbox.Indicator, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }) })
33358
34837
  }
33359
34838
  ),
33360
34839
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "sm", accentColor: "base", children: "Required" })
@@ -33382,7 +34861,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33382
34861
  "aria-label": "delete",
33383
34862
  onClick: handleImageDelete,
33384
34863
  size: "sm",
33385
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "trash" })
34864
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Trash })
33386
34865
  }
33387
34866
  )
33388
34867
  ] }),
@@ -33413,46 +34892,25 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33413
34892
  ] });
33414
34893
  });
33415
34894
  FieldBuilder.displayName = "FieldBuilder";
33416
- const FieldDropdownMenu = React.memo((props) => {
33417
- const { children, variant, size, accentColor, fields, onSelectField, ...rest } = props;
33418
- return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { ...rest, children: [
33419
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.ClickTrigger, { children }),
33420
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { variant, size, accentColor, children: fields.map((field) => {
33421
- return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Item, { onSelect: () => onSelectField(field), children: [
33422
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[field.type] }),
33423
- field.label || UNLABELLED_FIELD_LABEL
33424
- ] }, field.identifier);
33425
- }) })
33426
- ] });
33427
- });
33428
- FieldDropdownMenu.displayName = "IssueDataFilterMenu";
33429
- const FieldSectionDropdownMenu = React.memo((props) => {
33430
- const { children, variant, size, accentColor, fieldSections, onSelectFieldCondition, ...rest } = props;
33431
- return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { ...rest, children: [
33432
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.ClickTrigger, { children }),
33433
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { variant, size, accentColor, children: fieldSections.map((fieldSection) => {
33434
- return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Item, { onSelect: () => onSelectFieldCondition(fieldSection), children: [
33435
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[fieldSection.type] }),
33436
- fieldSection.label || UNLABELLED_SECTION_LABEL
33437
- ] }, fieldSection.identifier);
33438
- }) })
33439
- ] });
33440
- });
33441
- FieldSectionDropdownMenu.displayName = "IssueDataFilterMenu";
33442
- const FieldWithActions = React.memo((props) => {
33443
- const { field, fieldSection, index, sectionIndex, remove } = props;
33444
- const { showError } = blocks.useToast();
34895
+ const FieldBuilderWithActions = React.memo((props) => {
34896
+ const { field, fieldSection, fieldIndex, sectionIndex } = props;
33445
34897
  const fileInputRef = React.useRef(null);
33446
34898
  const parentPath = `fields.${sectionIndex}.fields`;
34899
+ const handleAddField = React.useCallback(
34900
+ (type) => {
34901
+ fieldSection.addField(createField(type), fieldIndex + 1);
34902
+ },
34903
+ [fieldIndex, fieldSection]
34904
+ );
33447
34905
  const duplicateField = React.useCallback(() => {
33448
34906
  fieldSection.addField(field.duplicate(uuid.v4()));
33449
34907
  }, [field, fieldSection]);
33450
34908
  const moveField = React.useCallback(
33451
34909
  (direction) => {
33452
34910
  const targetIndex = direction === "up" ? sectionIndex - 1 : sectionIndex + 1;
33453
- fieldSection.moveField(index, targetIndex);
34911
+ fieldSection.moveField(fieldIndex, targetIndex);
33454
34912
  },
33455
- [fieldSection, index, sectionIndex]
34913
+ [fieldSection, fieldIndex, sectionIndex]
33456
34914
  );
33457
34915
  const uploadImage = React.useCallback(
33458
34916
  (event) => {
@@ -33461,7 +34919,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33461
34919
  const file = files.item(0);
33462
34920
  if (!file) return;
33463
34921
  if (file.size > maxFileSizeB) {
33464
- showError({
34922
+ blocks.toast.error({
33465
34923
  title: "File upload error",
33466
34924
  description: `The file ${file.name} exceeded the maximum file size`
33467
34925
  });
@@ -33471,7 +34929,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33471
34929
  image: file
33472
34930
  });
33473
34931
  },
33474
- [field, showError]
34932
+ [field]
33475
34933
  );
33476
34934
  const handleMoveUp = React.useCallback(() => {
33477
34935
  moveField("up");
@@ -33484,21 +34942,48 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33484
34942
  (_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
33485
34943
  }, []);
33486
34944
  const handleRemove = React.useCallback(() => {
33487
- remove(field);
33488
- }, [field, remove]);
34945
+ fieldSection.removeField(field);
34946
+ }, [field, fieldSection]);
33489
34947
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Card, { className: "flex items-center justify-between gap-4 w-full", children: [
33490
- /* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { index, field, parentPath }),
34948
+ /* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { fieldIndex, field, parentPath }),
33491
34949
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex-col gap-0.5 flex", variant: "ghost", accentColor: "base", size: "sm", children: [
33492
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveUp, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "move-up" }) }),
33493
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveDown, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "move-down" }) }),
33494
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: duplicateField, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "copy" }) }),
33495
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleUploadImage, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "image" }) }),
33496
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleRemove, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "trash" }) })
34950
+ /* @__PURE__ */ jsxRuntime.jsx(CreateFieldDropdownMenu, { onSelectFieldType: handleAddField, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Plus }) }) }),
34951
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveUp, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: MoveUp }) }),
34952
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveDown, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: MoveDown }) }),
34953
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: duplicateField, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Copy }) }),
34954
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleUploadImage, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Image }) }),
34955
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleRemove, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Trash }) })
33497
34956
  ] }),
33498
34957
  /* @__PURE__ */ jsxRuntime.jsx("input", { className: "hidden", ref: fileInputRef, type: "file", accept: "image/*", onChange: uploadImage })
33499
34958
  ] });
33500
34959
  });
33501
- FieldWithActions.displayName = "FieldWithActions";
34960
+ FieldBuilderWithActions.displayName = "FieldBuilderWithActions";
34961
+ const FieldDropdownMenu = React.memo((props) => {
34962
+ const { children, variant, size, accentColor, fields, onSelectField, ...rest } = props;
34963
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { ...rest, children: [
34964
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.ClickTrigger, { children }),
34965
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { variant, size, accentColor, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Scroll, { children: fields.map((field) => {
34966
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Item, { onSelect: () => onSelectField(field), children: [
34967
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[field.type] }),
34968
+ field.label || UNLABELLED_FIELD_LABEL
34969
+ ] }, field.identifier);
34970
+ }) }) })
34971
+ ] });
34972
+ });
34973
+ FieldDropdownMenu.displayName = "IssueDataFilterMenu";
34974
+ const FieldSectionDropdownMenu = React.memo((props) => {
34975
+ const { children, variant, size, accentColor, fieldSections, onSelectFieldCondition, ...rest } = props;
34976
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { ...rest, children: [
34977
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.ClickTrigger, { children }),
34978
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { variant, size, accentColor, children: fieldSections.map((fieldSection) => {
34979
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Item, { onSelect: () => onSelectFieldCondition(fieldSection), children: [
34980
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[fieldSection.type] }),
34981
+ fieldSection.label || UNLABELLED_SECTION_LABEL
34982
+ ] }, fieldSection.identifier);
34983
+ }) })
34984
+ ] });
34985
+ });
34986
+ FieldSectionDropdownMenu.displayName = "IssueDataFilterMenu";
33502
34987
  const FieldSectionConditionEdgeComponent = React.memo((props) => {
33503
34988
  const { id, sourceX, sourceY, targetX, targetY, style, markerEnd, data } = props;
33504
34989
  const { targetSection, sourceSection, layoutDirection } = data;
@@ -33552,7 +35037,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33552
35037
  variant: "surface",
33553
35038
  size: "xs",
33554
35039
  accentColor: "base",
33555
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" })
35040
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Plus })
33556
35041
  }
33557
35042
  ) }),
33558
35043
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Tooltip.Root, { children: [
@@ -33566,7 +35051,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33566
35051
  accentColor: "base",
33567
35052
  color: "danger",
33568
35053
  onClick: handleDelete,
33569
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "trash" })
35054
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Trash })
33570
35055
  }
33571
35056
  ) }),
33572
35057
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Tooltip.Content, { size: "sm", children: "Remove conditional logic" })
@@ -33582,27 +35067,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33582
35067
  ] });
33583
35068
  });
33584
35069
  FieldSectionConditionEdgeComponent.displayName = "FieldSectionConditionEdgeComponent";
33585
- const useFieldTypeItems = (onSelect = () => null) => {
33586
- return React.useMemo(() => {
33587
- const entries = Object.entries(FieldTypeToClsMapping);
33588
- return entries.map(([type, fieldClass]) => ({
33589
- children: fieldClass.fieldTypeName,
33590
- icon: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons[type] }),
33591
- value: type,
33592
- onSelect: () => {
33593
- onSelect(type);
33594
- }
33595
- }));
33596
- }, [onSelect]);
33597
- };
33598
35070
  const FieldSectionNodeComponent = React.memo((props) => {
33599
35071
  const { data, selected } = props;
33600
35072
  const { fieldSection, index: sectionIndex, layoutDirection } = data;
33601
35073
  const fieldSchema = React.use(FieldSchemaContext);
33602
- const removeSection = React.useCallback(() => {
35074
+ const handleRemoveSection = React.useCallback(() => {
33603
35075
  fieldSchema.removeFieldSection(fieldSection);
33604
35076
  }, [fieldSchema, fieldSection]);
33605
- const addField = React.useCallback(
35077
+ const handleAddField = React.useCallback(
33606
35078
  (type) => {
33607
35079
  fieldSection.addField(createField(type));
33608
35080
  },
@@ -33616,13 +35088,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33616
35088
  const handleDuplicate = React.useCallback(() => {
33617
35089
  fieldSchema.addFieldSection(fieldSection.duplicate(uuid.v4()));
33618
35090
  }, [fieldSchema, fieldSection]);
33619
- const fieldTypeItems = useFieldTypeItems(addField);
33620
- const removeField = React.useCallback(
33621
- (field) => {
33622
- fieldSection.removeField(field);
33623
- },
33624
- [fieldSection]
33625
- );
33626
35091
  return /* @__PURE__ */ jsxRuntime.jsxs(
33627
35092
  blocks.Card,
33628
35093
  {
@@ -33656,25 +35121,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33656
35121
  ] }),
33657
35122
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
33658
35123
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { weight: "bold", children: "Fields" }),
33659
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { children: [
33660
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.ClickTrigger, { children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "soft", size: "sm", accentColor: "base", children: [
33661
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
33662
- " Add field"
33663
- ] }) }),
33664
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Scroll, { children: fieldTypeItems.flat().map((item) => /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Item, { onSelect: item.onSelect, children: [
33665
- item.icon,
33666
- item.children
33667
- ] }, item.value)) }) })
33668
- ] })
35124
+ /* @__PURE__ */ jsxRuntime.jsx(CreateFieldDropdownMenu, { onSelectFieldType: handleAddField, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "soft", size: "sm", accentColor: "base", children: [
35125
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Plus }),
35126
+ " Add field"
35127
+ ] }) })
33669
35128
  ] }),
33670
35129
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3", children: fieldSection.fields.map((child, index) => /* @__PURE__ */ jsxRuntime.jsx(
33671
- FieldWithActions,
35130
+ FieldBuilderWithActions,
33672
35131
  {
33673
35132
  field: child,
33674
35133
  fieldSection,
33675
- index,
33676
- sectionIndex,
33677
- remove: removeField
35134
+ fieldIndex: index,
35135
+ sectionIndex
33678
35136
  },
33679
35137
  child.identifier
33680
35138
  )) })
@@ -33695,9 +35153,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33695
35153
  size: "xs",
33696
35154
  onClick: (e) => e.stopPropagation(),
33697
35155
  children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex flex-col gap-2", variant: "surface", size: "xs", accentColor: "base", children: [
33698
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleAddBranch, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "git-branch" }) }),
33699
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleDuplicate, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "copy" }) }),
33700
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: removeSection, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "trash" }) })
35156
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleAddBranch, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: GitBranch }) }),
35157
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleDuplicate, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Copy }) }),
35158
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleRemoveSection, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Trash }) })
33701
35159
  ] })
33702
35160
  }
33703
35161
  )
@@ -33914,7 +35372,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33914
35372
  }
33915
35373
  ),
33916
35374
  /* @__PURE__ */ jsxRuntime.jsx(react.Panel, { position: "top-left", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.ButtonGroup, { className: "flex items-center justify-end gap-2", size: "sm", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "surface", onClick: handleAddSection, children: [
33917
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
35375
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Plus }),
33918
35376
  " Add section"
33919
35377
  ] }) }) }),
33920
35378
  /* @__PURE__ */ jsxRuntime.jsxs(react.Panel, { position: "top-right", className: "flex flex-col items-center gap-2", children: [
@@ -33928,16 +35386,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33928
35386
  value: layoutDirection,
33929
35387
  onValueChange: setLayoutDirection,
33930
35388
  children: [
33931
- /* @__PURE__ */ jsxRuntime.jsx(blocks.ToggleGroup.IconItem, { className: "rounded-b-none", value: "LR", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "arrow-right-left" }) }),
33932
- /* @__PURE__ */ jsxRuntime.jsx(blocks.ToggleGroup.IconItem, { className: "rounded-t-none", value: "TB", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "arrow-down-up" }) })
35389
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.ToggleGroup.IconItem, { className: "rounded-b-none", value: "LR", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: ArrowLeftRight }) }),
35390
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.ToggleGroup.IconItem, { className: "rounded-t-none", value: "TB", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: ArrowDownUp }) })
33933
35391
  ]
33934
35392
  }
33935
35393
  ),
33936
35394
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Separator, { size: "sm" }),
33937
35395
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex flex-col ", size: "sm", accentColor: "base", variant: "soft", children: [
33938
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { className: "rounded-b-none", onClick: () => reactFlow == null ? void 0 : reactFlow.zoomIn(), type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }) }),
33939
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: () => reactFlow == null ? void 0 : reactFlow.zoomOut(), radius: "none", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "minus" }) }),
33940
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { className: "rounded-t-none", onClick: () => reactFlow == null ? void 0 : reactFlow.fitView(), type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "square-dashed" }) })
35396
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { className: "rounded-b-none", onClick: () => reactFlow == null ? void 0 : reactFlow.zoomIn(), type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Plus }) }),
35397
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { onClick: () => reactFlow == null ? void 0 : reactFlow.zoomOut(), radius: "none", type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Minus }) }),
35398
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { className: "rounded-t-none", onClick: () => reactFlow == null ? void 0 : reactFlow.fitView(), type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: SquareDashed }) })
33941
35399
  ] })
33942
35400
  ] }),
33943
35401
  /* @__PURE__ */ jsxRuntime.jsx(react.Panel, { position: "bottom-right", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex items-center justify-end gap-2", size: "sm", children: [
@@ -33975,7 +35433,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33975
35433
  /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: fieldIcons.section }),
33976
35434
  sourceFieldSection.label ?? UNLABELLED_SECTION_LABEL
33977
35435
  ] }),
33978
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleDelete, variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "trash" }) })
35436
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleDelete, variant: "ghost", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Trash }) })
33979
35437
  ] }),
33980
35438
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-max w-full flex-wrap gap-2", children: [
33981
35439
  conditions.map((condition) => {
@@ -33983,7 +35441,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
33983
35441
  onRemove: handleDeleteCondition
33984
35442
  });
33985
35443
  }),
33986
- /* @__PURE__ */ jsxRuntime.jsx(FieldDropdownMenu, { fields: sourceFieldSection.fields, onSelectField: handleSelectField, align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", size: "sm", variant: "soft", accentColor: "base", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }) }) })
35444
+ /* @__PURE__ */ jsxRuntime.jsx(FieldDropdownMenu, { fields: sourceFieldSection.fields, onSelectField: handleSelectField, align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", size: "sm", variant: "soft", accentColor: "base", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Plus }) }) })
33987
35445
  ] })
33988
35446
  ] });
33989
35447
  });
@@ -34045,7 +35503,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34045
35503
  fieldSections: validFieldSections,
34046
35504
  onSelectFieldCondition: handleAddConditional,
34047
35505
  children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "soft", size: "sm", className: "w-max", children: [
34048
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
35506
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Plus }),
34049
35507
  "Add condition"
34050
35508
  ] })
34051
35509
  }
@@ -34065,15 +35523,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34065
35523
  });
34066
35524
  FieldSectionBuilder.displayName = "FieldSectionBuilder";
34067
35525
  const FieldSectionWithActions = React.memo((props) => {
34068
- const { fieldSection, index: sectionIndex } = props;
35526
+ const { fieldSection, sectionIndex } = props;
34069
35527
  const fieldSchema = React.use(FieldSchemaContext);
34070
- const removeField = React.useCallback(
34071
- (field) => {
34072
- fieldSection.removeField(field);
34073
- },
34074
- [fieldSection]
34075
- );
34076
- const removeSection = React.useCallback(() => {
35528
+ const handleRemoveSection = React.useCallback(() => {
34077
35529
  fieldSchema.removeFieldSection(fieldSection);
34078
35530
  }, [fieldSchema, fieldSection]);
34079
35531
  const moveSection = React.useCallback(
@@ -34086,7 +35538,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34086
35538
  const duplicateSection = React.useCallback(() => {
34087
35539
  fieldSchema.addFieldSection(fieldSection.duplicate(uuid.v4()));
34088
35540
  }, [fieldSchema, fieldSection]);
34089
- const handleCreateField = React.useCallback(
35541
+ const handleAddField = React.useCallback(
34090
35542
  (type) => {
34091
35543
  fieldSection.addField(createField(type));
34092
35544
  },
@@ -34098,42 +35550,34 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34098
35550
  const handleMoveDown = React.useCallback(() => {
34099
35551
  moveSection("down");
34100
35552
  }, [moveSection]);
34101
- const fieldTypeItems = useFieldTypeItems(handleCreateField);
34102
35553
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Card, { variant: "outline", className: "flex items-center justify-between gap-4 w-full", children: [
34103
35554
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex grow flex-col gap-4 w-full", children: [
34104
35555
  /* @__PURE__ */ jsxRuntime.jsx(FieldSectionBuilder, { fieldSection }),
34105
35556
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 w-full", children: [
34106
35557
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 justify-between", children: [
34107
35558
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { accentColor: "base", size: "md", children: "Fields" }),
34108
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Root, { children: [
34109
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.ClickTrigger, { children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "soft", size: "sm", children: [
34110
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
34111
- " Add field"
34112
- ] }) }),
34113
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Menu.Scroll, { children: fieldTypeItems.flat().map((item) => /* @__PURE__ */ jsxRuntime.jsxs(blocks.Menu.Item, { onSelect: item.onSelect, children: [
34114
- item.icon,
34115
- item.children
34116
- ] }, item.value)) }) })
34117
- ] })
35559
+ /* @__PURE__ */ jsxRuntime.jsx(CreateFieldDropdownMenu, { onSelectFieldType: handleAddField, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { type: "button", variant: "soft", size: "sm", children: [
35560
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Plus }),
35561
+ " Add field"
35562
+ ] }) })
34118
35563
  ] }),
34119
35564
  fieldSection.fields.map((child, index) => /* @__PURE__ */ jsxRuntime.jsx(
34120
- FieldWithActions,
35565
+ FieldBuilderWithActions,
34121
35566
  {
34122
35567
  field: child,
34123
35568
  fieldSection,
34124
- index,
34125
- sectionIndex,
34126
- remove: removeField
35569
+ fieldIndex: index,
35570
+ sectionIndex
34127
35571
  },
34128
35572
  child.identifier
34129
35573
  ))
34130
35574
  ] })
34131
35575
  ] }),
34132
35576
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.ButtonGroup, { className: "flex-col gap-0.5 flex", variant: "ghost", accentColor: "base", size: "sm", children: [
34133
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveUp, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "move-up" }) }),
34134
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveDown, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "move-down" }) }),
34135
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: duplicateSection, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "copy" }) }),
34136
- /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: removeSection, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "trash" }) })
35577
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveUp, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: MoveUp }) }),
35578
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleMoveDown, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: MoveDown }) }),
35579
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: duplicateSection, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Copy }) }),
35580
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { type: "button", onClick: handleRemoveSection, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Trash }) })
34137
35581
  ] })
34138
35582
  ] });
34139
35583
  });
@@ -34182,7 +35626,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34182
35626
  }
34183
35627
  ),
34184
35628
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4", children: [
34185
- fieldSchema.fieldSections.map((fieldSection, index) => /* @__PURE__ */ jsxRuntime.jsx(FieldSectionWithActions, { fieldSection, index }, fieldSection.identifier)),
35629
+ fieldSchema.fieldSections.map((fieldSection, index) => /* @__PURE__ */ jsxRuntime.jsx(
35630
+ FieldSectionWithActions,
35631
+ {
35632
+ fieldSection,
35633
+ sectionIndex: index
35634
+ },
35635
+ fieldSection.identifier
35636
+ )),
34186
35637
  /* @__PURE__ */ jsxRuntime.jsxs(
34187
35638
  blocks.Button,
34188
35639
  {
@@ -34193,7 +35644,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34193
35644
  size: "sm",
34194
35645
  onClick: handleCreateEmptySection,
34195
35646
  children: [
34196
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "plus" }),
35647
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Plus }),
34197
35648
  " Add section"
34198
35649
  ]
34199
35650
  }
@@ -34213,9 +35664,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34213
35664
  for (const field of fields) {
34214
35665
  if (field instanceof FieldSection) {
34215
35666
  const conditionalSections = sectionElements.filter((section) => field.identifier in section.conditions);
34216
- const conditionMet = conditionalSections.length > 0 ? conditionalSections.some(
34217
- (conditionalSection) => applyConditions(conditionalSection.getConditions(field.identifier), values)
34218
- ) : true;
35667
+ if (conditionalSections.length === 0) continue;
35668
+ const conditionMet = conditionalSections.some((conditionalSection) => {
35669
+ const conditions = conditionalSection.getConditions(field.identifier);
35670
+ const conditionManager = new ConditionManager(conditions);
35671
+ return conditionManager.applyConditions(values);
35672
+ });
34219
35673
  if (!conditionMet) continue;
34220
35674
  Object.assign(errors, field.getErrors(values));
34221
35675
  } else {
@@ -34229,59 +35683,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34229
35683
  }
34230
35684
  if (Object.keys(errors).length > 0) return errors;
34231
35685
  };
34232
- const initializeFieldValues = (fields, values) => {
34233
- const ret = {};
34234
- for (const field of fields) {
34235
- const value = values[field.identifier];
34236
- ret[field.identifier] = value !== void 0 ? value : field.blankValue();
34237
- }
34238
- return ret;
34239
- };
34240
- const changedFieldValues = (fields, values1, values2) => {
34241
- const ret = {};
34242
- for (const field of fields) {
34243
- const value1 = values1[field.identifier];
34244
- const value2 = values2[field.identifier];
34245
- if (field.areValuesEqual(value1, value2)) continue;
34246
- ret[field.identifier] = value2;
34247
- }
34248
- return ret;
34249
- };
34250
- const unchangedFieldValues = (fields, values1, values2) => {
34251
- const ret = {};
34252
- for (const field of fields) {
34253
- const value1 = values1[field.identifier];
34254
- const value2 = values2[field.identifier];
34255
- if (!field.areValuesEqual(value1, value2)) continue;
34256
- ret[field.identifier] = value2;
34257
- }
34258
- return ret;
34259
- };
34260
- const isArrayOfFiles = (value) => {
34261
- return Array.isArray(value) && value[0] instanceof File;
34262
- };
34263
- const separateFilesFromFieldValues = (values) => {
34264
- const files = {};
34265
- const newValues = {};
34266
- for (const key in values) {
34267
- const value = values[key];
34268
- if (value instanceof File) {
34269
- files[key] = [value];
34270
- } else if (isArrayOfFiles(value)) {
34271
- files[key] = value;
34272
- } else if (value !== void 0) {
34273
- newValues[key] = value;
34274
- }
34275
- }
34276
- return { values: newValues, files };
34277
- };
34278
- const separateFilesFromFields = async (fields) => {
35686
+ const separateImagesFromFields = async (fields) => {
34279
35687
  const images = {};
34280
35688
  const newFields = [];
34281
35689
  for (const section of fields) {
34282
- if (section.type !== "section") {
34283
- throw new Error(`Expected ISerializedField type to be a section. Got ${section.type} instead.`);
34284
- }
34285
35690
  const { fields: sectionFields } = section;
34286
35691
  const newSectionFields = [];
34287
35692
  for (const field of sectionFields) {
@@ -34303,16 +35708,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34303
35708
  }
34304
35709
  return { fields: newFields, images };
34305
35710
  };
34306
- async function awaitPromisesFromFieldValues(values) {
34307
- const valuesWithoutFiles = {};
35711
+ async function awaitFilesAndPromises(values) {
35712
+ const ret = {};
34308
35713
  for (const [key, value] of Object.entries(values)) {
34309
- if (Array.isArray(value) && value.some((item) => item instanceof UUIDPromise)) {
34310
- valuesWithoutFiles[key] = await Promise.all(value);
34311
- } else {
34312
- valuesWithoutFiles[key] = value;
34313
- }
35714
+ ret[key] = await Promise.all(value);
34314
35715
  }
34315
- return valuesWithoutFiles;
35716
+ return ret;
34316
35717
  }
34317
35718
  const FormRenderer = React.memo(
34318
35719
  React.forwardRef((props, ref) => {
@@ -34341,9 +35742,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34341
35742
  }, [schema.fields, values]);
34342
35743
  const handleSubmit = React.useCallback(
34343
35744
  (values2) => {
34344
- onSubmit == null ? void 0 : onSubmit(
35745
+ void (onSubmit == null ? void 0 : onSubmit(
34345
35746
  excludeUnchangedFields ? changedFieldValues(flattenFields(schema.fields), initialValues, values2) : values2
34346
- );
35747
+ ));
34347
35748
  },
34348
35749
  [excludeUnchangedFields, initialValues, onSubmit, schema.fields]
34349
35750
  );
@@ -34408,13 +35809,13 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34408
35809
  variant: "soft",
34409
35810
  onClick: onCancel,
34410
35811
  children: [
34411
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "x" }),
35812
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: X }),
34412
35813
  cancelText
34413
35814
  ]
34414
35815
  }
34415
35816
  ),
34416
35817
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { ...buttonProps, type: "submit", accentColor: "primary", variant: "surface", children: [
34417
- /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: "check" }),
35818
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.LuIcon, { icon: Check }),
34418
35819
  submitText
34419
35820
  ] })
34420
35821
  ] })
@@ -34453,43 +35854,39 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34453
35854
  enableReinitialize = false,
34454
35855
  disableRequiredFields = false
34455
35856
  } = props;
34456
- const { showError } = blocks.useToast();
34457
- const validate = React.useCallback(
34458
- (form) => {
34459
- var _a2;
34460
- const errors = {};
34461
- if (!form.title) {
34462
- errors.title = "Title is required.";
34463
- }
34464
- if (!form.fields || form.fields.length === 0) {
34465
- errors.fields = "At least one field is required.";
34466
- }
34467
- const fieldsToValidate = [];
34468
- for (const [sectionIndex, section] of form.fields.entries())
34469
- for (const [fieldIndex, field] of section.fields.entries()) {
34470
- const fieldSettings = ((_a2 = getFieldCreationSchema(field.type, `fields.${sectionIndex}.fields.${fieldIndex}`)) == null ? void 0 : _a2.map(
34471
- ({ field: field2 }) => field2
34472
- )) ?? [];
34473
- fieldsToValidate.push(...fieldSettings);
34474
- }
34475
- const values = {};
34476
- for (const field of fieldsToValidate) {
34477
- values[field.identifier] = get(form, field.identifier);
34478
- }
34479
- const fieldErrors = validateFields(fieldsToValidate, values);
34480
- if (fieldErrors) {
34481
- errors.fields = fieldErrors.fields;
34482
- }
34483
- if (Object.keys(errors).length > 0) {
34484
- showError({
34485
- title: "Some form settings are invalid",
34486
- description: "Please check settings highlighted in red."
34487
- });
34488
- return errors;
34489
- }
34490
- },
34491
- [showError]
34492
- );
35857
+ const validate = React.useCallback((form) => {
35858
+ var _a2;
35859
+ const errors = {};
35860
+ if (!form.title) {
35861
+ errors.title = "Title is required.";
35862
+ }
35863
+ if (!form.fields || form.fields.length === 0) {
35864
+ errors.fields = "At least one field is required.";
35865
+ }
35866
+ const fieldsToValidate = [];
35867
+ for (const [sectionIndex, section] of form.fields.entries())
35868
+ for (const [fieldIndex, field] of section.fields.entries()) {
35869
+ const fieldSettings = ((_a2 = getFieldCreationSchema(field.type, `fields.${sectionIndex}.fields.${fieldIndex}`)) == null ? void 0 : _a2.map(
35870
+ ({ field: field2 }) => field2
35871
+ )) ?? [];
35872
+ fieldsToValidate.push(...fieldSettings);
35873
+ }
35874
+ const values = {};
35875
+ for (const field of fieldsToValidate) {
35876
+ values[field.identifier] = get(form, field.identifier);
35877
+ }
35878
+ const fieldErrors = validateFields(fieldsToValidate, values);
35879
+ if (fieldErrors) {
35880
+ errors.fields = fieldErrors.fields;
35881
+ }
35882
+ if (Object.keys(errors).length > 0) {
35883
+ blocks.toast.error({
35884
+ title: "Some form settings are invalid",
35885
+ description: "Please check settings highlighted in red."
35886
+ });
35887
+ return errors;
35888
+ }
35889
+ }, []);
34493
35890
  const initialValues = React.useMemo(
34494
35891
  () => ({
34495
35892
  title: initialTitle ?? "",
@@ -34508,7 +35905,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34508
35905
  });
34509
35906
  const observer = React.useCallback(
34510
35907
  (fieldSchema) => {
34511
- formik$1.setFieldValue("fields", fieldSchema.serialize());
35908
+ void formik$1.setFieldValue("fields", fieldSchema.serialize());
34512
35909
  },
34513
35910
  [formik$1]
34514
35911
  );
@@ -34549,6 +35946,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34549
35946
  exports2.CheckboxListFieldCondition = CheckboxListFieldCondition;
34550
35947
  exports2.CheckboxListFieldConditionCell = CheckboxListFieldConditionCell;
34551
35948
  exports2.CheckboxListInput = CheckboxListInput;
35949
+ exports2.ConditionManager = ConditionManager;
34552
35950
  exports2.DateAfterConditionModifier = DateAfterConditionModifier;
34553
35951
  exports2.DateBeforeConditionModifier = DateBeforeConditionModifier;
34554
35952
  exports2.DateEqualsConditionModifier = DateEqualsConditionModifier;
@@ -34599,10 +35997,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34599
35997
  exports2.OTPFieldCondition = OTPFieldCondition;
34600
35998
  exports2.OTPFieldConditionCell = OTPFieldConditionCell;
34601
35999
  exports2.OTPInput = OTPInput;
36000
+ exports2.Observable = Observable;
36001
+ exports2.PassFailArrayExcludesConditionModifier = PassFailArrayExcludesConditionModifier;
36002
+ exports2.PassFailArrayIncludesConditionModifier = PassFailArrayIncludesConditionModifier;
36003
+ exports2.PassFailEqualsConditionModifier = PassFailEqualsConditionModifier;
36004
+ exports2.PassFailField = PassFailField;
36005
+ exports2.PassFailFieldCondition = PassFailFieldCondition;
36006
+ exports2.PassFailFieldConditionCell = PassFailFieldConditionCell;
36007
+ exports2.PassFailInput = PassFailInput;
36008
+ exports2.PassFailNotEqualsConditionModifier = PassFailNotEqualsConditionModifier;
34602
36009
  exports2.RadioField = RadioField;
34603
36010
  exports2.RadioFieldCondition = RadioFieldCondition;
34604
36011
  exports2.RadioFieldConditionCell = RadioFieldConditionCell;
34605
36012
  exports2.RadioInput = RadioInput;
36013
+ exports2.RatingField = RatingField;
36014
+ exports2.RatingFieldCondition = RatingFieldCondition;
36015
+ exports2.RatingFieldConditionCell = RatingFieldConditionCell;
36016
+ exports2.RatingInput = RatingInput;
34606
36017
  exports2.SEVERITY_COLOR_MAPPING = SEVERITY_COLOR_MAPPING;
34607
36018
  exports2.SHORT_TEXT_FIELD_MAX_LENGTH = SHORT_TEXT_FIELD_MAX_LENGTH;
34608
36019
  exports2.ScanField = ScanField;
@@ -34634,13 +36045,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34634
36045
  exports2.TextFieldCondition = TextFieldCondition;
34635
36046
  exports2.TextFieldConditionCell = TextFieldConditionCell;
34636
36047
  exports2.TextInput = TextInput;
36048
+ exports2.UUIDFile = UUIDFile;
34637
36049
  exports2.UUIDPromise = UUIDPromise;
34638
36050
  exports2.UploadField = UploadField;
34639
36051
  exports2.UploadFieldCondition = UploadFieldCondition;
34640
36052
  exports2.UploadFieldConditionCell = UploadFieldConditionCell;
34641
36053
  exports2.UploadInput = UploadInput;
34642
- exports2.applyConditions = applyConditions;
34643
- exports2.awaitPromisesFromFieldValues = awaitPromisesFromFieldValues;
36054
+ exports2.areFileAndPromiseArraysEqual = areFileAndPromiseArraysEqual;
36055
+ exports2.arePassFieldValuesEqual = arePassFieldValuesEqual;
36056
+ exports2.awaitFilesAndPromises = awaitFilesAndPromises;
34644
36057
  exports2.changedFieldValues = changedFieldValues;
34645
36058
  exports2.cleanFieldValues = cleanFieldValues;
34646
36059
  exports2.cleanSerializedFieldValues = cleanSerializedFieldValues;
@@ -34654,18 +36067,28 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34654
36067
  exports2.deserializeFieldValues = deserializeFieldValues;
34655
36068
  exports2.deserializeFields = deserializeFields;
34656
36069
  exports2.deserializeOnlyFields = deserializeOnlyFields;
36070
+ exports2.deserializePassFailFieldValue = deserializePassFailFieldValue;
36071
+ exports2.extractFilesAndPromisesFromFieldValues = extractFilesAndPromisesFromFieldValues;
34657
36072
  exports2.fieldIcons = fieldIcons;
34658
36073
  exports2.flattenFields = flattenFields;
34659
36074
  exports2.getFieldsMapping = getFieldsMapping;
34660
36075
  exports2.initializeFieldValues = initializeFieldValues;
36076
+ exports2.insertFilesAndPromisesToFieldValues = insertFilesAndPromisesToFieldValues;
36077
+ exports2.isFileAndPromiseArray = isFileAndPromiseArray;
36078
+ exports2.isPassFailFieldStatus = isPassFailFieldStatus;
36079
+ exports2.isPassFailFieldValue = isPassFailFieldValue;
36080
+ exports2.isSerializedPassFailFieldValue = isSerializedPassFailFieldValue;
34661
36081
  exports2.isStringArray = isStringArray;
34662
36082
  exports2.maxFileSizeB = maxFileSizeB;
34663
36083
  exports2.maxFileSizeKB = maxFileSizeKB;
34664
36084
  exports2.maxFileSizeMB = maxFileSizeMB;
34665
- exports2.separateFilesFromFieldValues = separateFilesFromFieldValues;
34666
- exports2.separateFilesFromFields = separateFilesFromFields;
36085
+ exports2.passFailFieldStatusMapping = passFailFieldStatusMapping;
36086
+ exports2.passFailFieldStatuses = passFailFieldStatuses;
36087
+ exports2.separateImagesFromFields = separateImagesFromFields;
34667
36088
  exports2.serializeFieldValues = serializeFieldValues;
36089
+ exports2.serializePassFailFieldValue = serializePassFailFieldValue;
34668
36090
  exports2.unchangedFieldValues = unchangedFieldValues;
36091
+ exports2.useConditionManager = useConditionManager;
34669
36092
  exports2.useFieldInput = useFieldInput;
34670
36093
  exports2.useFieldInputs = useFieldInputs;
34671
36094
  exports2.useFormikInput = useFormikInput;
@@ -34674,3 +36097,4 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34674
36097
  exports2.validateFields = validateFields;
34675
36098
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
34676
36099
  });
36100
+ //# sourceMappingURL=forms.umd.cjs.map