@uipath/apollo-wind 2.60.1 → 2.62.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 (154) hide show
  1. package/dist/components/forms/field-actions.cjs +181 -0
  2. package/dist/components/forms/field-actions.d.ts +131 -0
  3. package/dist/components/forms/field-actions.js +129 -0
  4. package/dist/components/forms/field-control.cjs +415 -0
  5. package/dist/components/forms/field-control.d.ts +52 -0
  6. package/dist/components/forms/field-control.js +372 -0
  7. package/dist/components/forms/field-renderer.cjs +77 -420
  8. package/dist/components/forms/field-renderer.d.ts +2 -3
  9. package/dist/components/forms/field-renderer.js +78 -421
  10. package/dist/components/forms/form-designer.cjs +7 -1
  11. package/dist/components/forms/form-designer.js +7 -1
  12. package/dist/components/forms/form-schema.d.ts +121 -2
  13. package/dist/components/forms/form-strings.cjs +67 -0
  14. package/dist/components/forms/form-strings.d.ts +30 -0
  15. package/dist/components/forms/form-strings.js +30 -0
  16. package/dist/components/forms/index.cjs +53 -9
  17. package/dist/components/forms/index.d.ts +6 -1
  18. package/dist/components/forms/index.js +6 -1
  19. package/dist/components/forms/literal-value-context.cjs +37 -0
  20. package/dist/components/forms/literal-value-context.d.ts +5 -0
  21. package/dist/components/forms/literal-value-context.js +3 -0
  22. package/dist/components/forms/metadata-form.cjs +100 -21
  23. package/dist/components/forms/metadata-form.d.ts +5 -0
  24. package/dist/components/forms/metadata-form.js +101 -22
  25. package/dist/components/forms/mode-aware-field.cjs +589 -0
  26. package/dist/components/forms/mode-aware-field.d.ts +15 -0
  27. package/dist/components/forms/mode-aware-field.js +555 -0
  28. package/dist/components/forms/opaque-value.cjs +44 -0
  29. package/dist/components/forms/opaque-value.d.ts +7 -0
  30. package/dist/components/forms/opaque-value.js +7 -0
  31. package/dist/components/forms/rules-engine.cjs +13 -0
  32. package/dist/components/forms/rules-engine.js +13 -0
  33. package/dist/components/forms/schema-serializer.cjs +8 -0
  34. package/dist/components/forms/schema-serializer.js +8 -0
  35. package/dist/components/forms/string-list-field.cjs +36 -18
  36. package/dist/components/forms/string-list-field.d.ts +6 -0
  37. package/dist/components/forms/string-list-field.js +35 -20
  38. package/dist/components/forms/validation-converter.cjs +32 -2
  39. package/dist/components/forms/validation-converter.d.ts +17 -1
  40. package/dist/components/forms/validation-converter.js +30 -3
  41. package/dist/components/forms/value-modes.cjs +253 -0
  42. package/dist/components/forms/value-modes.d.ts +236 -0
  43. package/dist/components/forms/value-modes.js +180 -0
  44. package/dist/components/ui/avatar.d.ts +1 -1
  45. package/dist/components/ui/badge.d.ts +1 -1
  46. package/dist/components/ui/boolean-radio-group.cjs +114 -0
  47. package/dist/components/ui/boolean-radio-group.d.ts +24 -0
  48. package/dist/components/ui/boolean-radio-group.js +77 -0
  49. package/dist/components/ui/button.d.ts +2 -2
  50. package/dist/components/ui/checkbox.cjs +10 -5
  51. package/dist/components/ui/checkbox.js +12 -7
  52. package/dist/components/ui/command.d.ts +7 -7
  53. package/dist/components/ui/field-addons/field-menu.cjs +1 -0
  54. package/dist/components/ui/field-addons/field-menu.d.ts +2 -0
  55. package/dist/components/ui/field-addons/field-menu.js +1 -0
  56. package/dist/components/ui/field-addons/index.cjs +4 -0
  57. package/dist/components/ui/field-addons/index.d.ts +1 -0
  58. package/dist/components/ui/field-addons/index.js +2 -1
  59. package/dist/components/ui/field-addons/value-mode-strings.cjs +7 -1
  60. package/dist/components/ui/field-addons/value-mode-strings.d.ts +9 -0
  61. package/dist/components/ui/field-addons/value-mode-strings.js +7 -1
  62. package/dist/components/ui/field-addons/value-mode-switch-dialog.cjs +73 -0
  63. package/dist/components/ui/field-addons/value-mode-switch-dialog.d.ts +16 -0
  64. package/dist/components/ui/field-addons/value-mode-switch-dialog.js +39 -0
  65. package/dist/components/ui/form-field.cjs +2 -1
  66. package/dist/components/ui/form-field.d.ts +2 -0
  67. package/dist/components/ui/form-field.js +2 -1
  68. package/dist/components/ui/index.cjs +237 -193
  69. package/dist/components/ui/index.d.ts +4 -0
  70. package/dist/components/ui/index.js +4 -0
  71. package/dist/components/ui/input-group.cjs +6 -3
  72. package/dist/components/ui/input-group.d.ts +6 -5
  73. package/dist/components/ui/input-group.js +6 -3
  74. package/dist/components/ui/json-tree-view/DecorationChip.cjs +81 -0
  75. package/dist/components/ui/json-tree-view/DecorationChip.d.ts +4 -0
  76. package/dist/components/ui/json-tree-view/DecorationChip.js +47 -0
  77. package/dist/components/ui/json-tree-view/EditorChrome.cjs +88 -0
  78. package/dist/components/ui/json-tree-view/EditorChrome.d.ts +21 -0
  79. package/dist/components/ui/json-tree-view/EditorChrome.js +51 -0
  80. package/dist/components/ui/json-tree-view/JsonContainerEditor.cjs +95 -0
  81. package/dist/components/ui/json-tree-view/JsonContainerEditor.d.ts +18 -0
  82. package/dist/components/ui/json-tree-view/JsonContainerEditor.js +61 -0
  83. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.cjs +86 -0
  84. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.d.ts +12 -0
  85. package/dist/components/ui/json-tree-view/JsonLeafValueEditor.js +52 -0
  86. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.cjs +74 -0
  87. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.d.ts +13 -0
  88. package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.js +40 -0
  89. package/dist/components/ui/json-tree-view/JsonTree.cjs +253 -0
  90. package/dist/components/ui/json-tree-view/JsonTree.d.ts +81 -0
  91. package/dist/components/ui/json-tree-view/JsonTree.js +219 -0
  92. package/dist/components/ui/json-tree-view/JsonTree.types.cjs +18 -0
  93. package/dist/components/ui/json-tree-view/JsonTree.types.d.ts +253 -0
  94. package/dist/components/ui/json-tree-view/JsonTree.types.js +0 -0
  95. package/dist/components/ui/json-tree-view/JsonTreeRow.cjs +284 -0
  96. package/dist/components/ui/json-tree-view/JsonTreeRow.d.ts +50 -0
  97. package/dist/components/ui/json-tree-view/JsonTreeRow.js +244 -0
  98. package/dist/components/ui/json-tree-view/JsonTreeToolbar.cjs +209 -0
  99. package/dist/components/ui/json-tree-view/JsonTreeToolbar.d.ts +35 -0
  100. package/dist/components/ui/json-tree-view/JsonTreeToolbar.js +175 -0
  101. package/dist/components/ui/json-tree-view/JsonTreeTooltip.cjs +84 -0
  102. package/dist/components/ui/json-tree-view/JsonTreeTooltip.d.ts +21 -0
  103. package/dist/components/ui/json-tree-view/JsonTreeTooltip.js +47 -0
  104. package/dist/components/ui/json-tree-view/JsonTypeBadge.cjs +70 -0
  105. package/dist/components/ui/json-tree-view/JsonTypeBadge.d.ts +17 -0
  106. package/dist/components/ui/json-tree-view/JsonTypeBadge.js +36 -0
  107. package/dist/components/ui/json-tree-view/NodeKey.cjs +77 -0
  108. package/dist/components/ui/json-tree-view/NodeKey.d.ts +16 -0
  109. package/dist/components/ui/json-tree-view/NodeKey.js +43 -0
  110. package/dist/components/ui/json-tree-view/RowActions.cjs +120 -0
  111. package/dist/components/ui/json-tree-view/RowActions.d.ts +15 -0
  112. package/dist/components/ui/json-tree-view/RowActions.js +86 -0
  113. package/dist/components/ui/json-tree-view/ScalarValueCell.cjs +112 -0
  114. package/dist/components/ui/json-tree-view/ScalarValueCell.d.ts +18 -0
  115. package/dist/components/ui/json-tree-view/ScalarValueCell.js +75 -0
  116. package/dist/components/ui/json-tree-view/buildJsonTree.cjs +324 -0
  117. package/dist/components/ui/json-tree-view/buildJsonTree.d.ts +75 -0
  118. package/dist/components/ui/json-tree-view/buildJsonTree.js +257 -0
  119. package/dist/components/ui/json-tree-view/clipboard.cjs +63 -0
  120. package/dist/components/ui/json-tree-view/clipboard.d.ts +6 -0
  121. package/dist/components/ui/json-tree-view/clipboard.js +29 -0
  122. package/dist/components/ui/json-tree-view/index.cjs +175 -0
  123. package/dist/components/ui/json-tree-view/index.d.ts +10 -0
  124. package/dist/components/ui/json-tree-view/index.js +11 -0
  125. package/dist/components/ui/json-tree-view/leafEditTypes.cjs +74 -0
  126. package/dist/components/ui/json-tree-view/leafEditTypes.d.ts +12 -0
  127. package/dist/components/ui/json-tree-view/leafEditTypes.js +34 -0
  128. package/dist/components/ui/json-tree-view/strings.cjs +122 -0
  129. package/dist/components/ui/json-tree-view/strings.d.ts +65 -0
  130. package/dist/components/ui/json-tree-view/strings.js +79 -0
  131. package/dist/components/ui/prompt-value-control.cjs +70 -0
  132. package/dist/components/ui/prompt-value-control.d.ts +28 -0
  133. package/dist/components/ui/prompt-value-control.js +36 -0
  134. package/dist/components/ui/sheet.d.ts +1 -1
  135. package/dist/components/ui/spinner.d.ts +1 -1
  136. package/dist/components/ui/switch.d.ts +2 -2
  137. package/dist/components/ui/textarea.cjs +1 -1
  138. package/dist/components/ui/textarea.js +1 -1
  139. package/dist/components/ui/toggle-group.d.ts +2 -2
  140. package/dist/components/ui/toggle.d.ts +2 -2
  141. package/dist/components/ui/variable-value-control.cjs +98 -0
  142. package/dist/components/ui/variable-value-control.d.ts +35 -0
  143. package/dist/components/ui/variable-value-control.js +64 -0
  144. package/dist/index.cjs +145 -16
  145. package/dist/index.d.ts +21 -3
  146. package/dist/index.js +11 -2
  147. package/dist/lib/index.cjs +4 -1
  148. package/dist/lib/index.d.ts +1 -1
  149. package/dist/lib/index.js +2 -2
  150. package/dist/lib/utils.cjs +21 -1
  151. package/dist/lib/utils.d.ts +8 -0
  152. package/dist/lib/utils.js +18 -1
  153. package/dist/styles.css +279 -0
  154. package/package.json +1 -1
@@ -0,0 +1,415 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ FIELD_CONTROL_GEOMETRY: ()=>FIELD_CONTROL_GEOMETRY,
28
+ FieldControl: ()=>FieldControl,
29
+ useSliderMax: ()=>useSliderMax,
30
+ clampSliderValue: ()=>clampSliderValue
31
+ });
32
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
33
+ const external_react_namespaceObject = require("react");
34
+ const external_react_hook_form_namespaceObject = require("react-hook-form");
35
+ const boolean_radio_group_cjs_namespaceObject = require("../ui/boolean-radio-group.cjs");
36
+ const checkbox_cjs_namespaceObject = require("../ui/checkbox.cjs");
37
+ const date_picker_cjs_namespaceObject = require("../ui/date-picker.cjs");
38
+ const datetime_picker_cjs_namespaceObject = require("../ui/datetime-picker.cjs");
39
+ const file_upload_cjs_namespaceObject = require("../ui/file-upload.cjs");
40
+ const input_cjs_namespaceObject = require("../ui/input.cjs");
41
+ const label_cjs_namespaceObject = require("../ui/label.cjs");
42
+ const multi_select_cjs_namespaceObject = require("../ui/multi-select.cjs");
43
+ const radio_group_cjs_namespaceObject = require("../ui/radio-group.cjs");
44
+ const select_cjs_namespaceObject = require("../ui/select.cjs");
45
+ const slider_cjs_namespaceObject = require("../ui/slider.cjs");
46
+ const switch_cjs_namespaceObject = require("../ui/switch.cjs");
47
+ const textarea_cjs_namespaceObject = require("../ui/textarea.cjs");
48
+ const external_literal_value_context_cjs_namespaceObject = require("./literal-value-context.cjs");
49
+ const external_string_list_field_cjs_namespaceObject = require("./string-list-field.cjs");
50
+ const FIELD_CONTROL_GEOMETRY = {
51
+ text: {
52
+ layout: 'row',
53
+ variant: 'default',
54
+ labelTarget: 'control',
55
+ insertable: true
56
+ },
57
+ email: {
58
+ layout: 'row',
59
+ variant: 'default',
60
+ labelTarget: 'control',
61
+ insertable: true
62
+ },
63
+ number: {
64
+ layout: 'row',
65
+ variant: 'default',
66
+ labelTarget: 'control',
67
+ insertable: false
68
+ },
69
+ select: {
70
+ layout: 'row',
71
+ variant: 'default',
72
+ labelTarget: 'control',
73
+ insertable: false
74
+ },
75
+ textarea: {
76
+ layout: 'grow',
77
+ variant: 'default',
78
+ labelTarget: 'control',
79
+ insertable: true
80
+ },
81
+ file: {
82
+ layout: 'grow',
83
+ variant: 'default',
84
+ labelTarget: 'control',
85
+ insertable: false
86
+ },
87
+ multiselect: {
88
+ layout: 'grow',
89
+ variant: 'default',
90
+ labelTarget: 'control',
91
+ insertable: false
92
+ },
93
+ switch: {
94
+ layout: 'row',
95
+ variant: 'none',
96
+ labelTarget: 'control',
97
+ insertable: false
98
+ },
99
+ checkbox: {
100
+ layout: 'row',
101
+ variant: 'none',
102
+ labelTarget: 'control',
103
+ insertable: false
104
+ },
105
+ boolean: {
106
+ layout: 'row',
107
+ variant: 'none',
108
+ labelTarget: 'labelledby',
109
+ insertable: false
110
+ }
111
+ };
112
+ const NO_OPTIONS = [];
113
+ const NO_SELECTION = [];
114
+ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false, invalid = false, strings }) {
115
+ const errorId = invalid ? `${field.name}-error` : void 0;
116
+ const { onChange } = formField;
117
+ const multipleFiles = 'file' === field.type && field.multiple;
118
+ const onTextChange = (0, external_react_namespaceObject.useCallback)((event)=>onChange(event.target.value), [
119
+ onChange
120
+ ]);
121
+ const onNumberChange = (0, external_react_namespaceObject.useCallback)((event)=>onChange(parseFloat(event.target.value)), [
122
+ onChange
123
+ ]);
124
+ const onCheckedChange = (0, external_react_namespaceObject.useCallback)((checked)=>onChange(true === checked), [
125
+ onChange
126
+ ]);
127
+ const onFilesChange = (0, external_react_namespaceObject.useCallback)((files)=>onChange(multipleFiles ? files : files[0]), [
128
+ onChange,
129
+ multipleFiles
130
+ ]);
131
+ const multiSelectOptions = (0, external_react_namespaceObject.useMemo)(()=>options.map((option)=>({
132
+ label: option.label,
133
+ value: String(option.value)
134
+ })), [
135
+ options
136
+ ]);
137
+ switch(field.type){
138
+ case 'text':
139
+ case 'email':
140
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
141
+ id: field.name,
142
+ value: formField.value,
143
+ onChange: onTextChange,
144
+ onBlur: formField.onBlur,
145
+ name: formField.name,
146
+ ref: formField.ref,
147
+ type: field.type,
148
+ placeholder: field.placeholder,
149
+ disabled: disabled,
150
+ "aria-invalid": invalid || void 0,
151
+ "aria-describedby": errorId,
152
+ "aria-errormessage": errorId,
153
+ "aria-label": field.ariaLabel
154
+ });
155
+ case 'number':
156
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
157
+ id: field.name,
158
+ value: formField.value,
159
+ onBlur: formField.onBlur,
160
+ name: formField.name,
161
+ ref: formField.ref,
162
+ type: "number",
163
+ min: field.min,
164
+ max: field.max,
165
+ step: field.step,
166
+ placeholder: field.placeholder,
167
+ disabled: disabled,
168
+ "aria-invalid": invalid || void 0,
169
+ "aria-describedby": errorId,
170
+ "aria-errormessage": errorId,
171
+ onChange: onNumberChange
172
+ });
173
+ case 'textarea':
174
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(textarea_cjs_namespaceObject.Textarea, {
175
+ id: field.name,
176
+ value: formField.value,
177
+ onChange: onTextChange,
178
+ onBlur: formField.onBlur,
179
+ name: formField.name,
180
+ ref: formField.ref,
181
+ placeholder: field.placeholder,
182
+ disabled: disabled,
183
+ maxLength: field.maxLength,
184
+ "aria-invalid": invalid || void 0,
185
+ "aria-describedby": errorId,
186
+ "aria-errormessage": errorId,
187
+ ...null != field.minRows ? {
188
+ minRows: field.minRows
189
+ } : {
190
+ rows: field.rows || 4
191
+ }
192
+ });
193
+ case 'select':
194
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(select_cjs_namespaceObject.Select, {
195
+ value: formField.value,
196
+ onValueChange: formField.onChange,
197
+ disabled: disabled,
198
+ children: [
199
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectTrigger, {
200
+ id: field.name,
201
+ "aria-label": field.label,
202
+ "aria-invalid": invalid || void 0,
203
+ "aria-describedby": errorId,
204
+ "aria-errormessage": errorId,
205
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectValue, {
206
+ placeholder: field.placeholder || 'Select...'
207
+ })
208
+ }),
209
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectContent, {
210
+ children: options.map((option)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectItem, {
211
+ value: String(option.value),
212
+ disabled: 'disabled' in option ? Boolean(option.disabled) : false,
213
+ children: option.label
214
+ }, String(option.value)))
215
+ })
216
+ ]
217
+ });
218
+ case 'multiselect':
219
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(multi_select_cjs_namespaceObject.MultiSelect, {
220
+ id: field.name,
221
+ selected: formField.value || NO_SELECTION,
222
+ onChange: formField.onChange,
223
+ options: multiSelectOptions,
224
+ disabled: disabled,
225
+ placeholder: field.placeholder || 'Select items...',
226
+ emptyMessage: field.emptyMessage ?? 'No items found.',
227
+ searchPlaceholder: field.searchPlaceholder ?? 'Search...',
228
+ maxSelected: field.maxSelected,
229
+ "aria-invalid": invalid || void 0,
230
+ "aria-describedby": errorId,
231
+ "aria-errormessage": errorId
232
+ });
233
+ case 'checkbox':
234
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(checkbox_cjs_namespaceObject.Checkbox, {
235
+ checked: true === formField.value,
236
+ onCheckedChange: onCheckedChange,
237
+ disabled: disabled,
238
+ "aria-invalid": invalid || void 0,
239
+ "aria-describedby": errorId,
240
+ "aria-errormessage": errorId,
241
+ id: field.name
242
+ });
243
+ case 'boolean':
244
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(boolean_radio_group_cjs_namespaceObject.BooleanRadioGroup, {
245
+ "aria-labelledby": `${field.name}-label`,
246
+ value: 'boolean' == typeof formField.value ? formField.value : null,
247
+ onValueChange: formField.onChange,
248
+ onBlur: formField.onBlur,
249
+ disabled: disabled,
250
+ "aria-invalid": invalid || void 0,
251
+ "aria-describedby": errorId,
252
+ "aria-errormessage": errorId,
253
+ strings: strings
254
+ });
255
+ case 'switch':
256
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(switch_cjs_namespaceObject.Switch, {
257
+ id: field.name,
258
+ checked: true === formField.value,
259
+ onCheckedChange: onCheckedChange,
260
+ disabled: disabled,
261
+ "aria-invalid": invalid || void 0,
262
+ "aria-describedby": errorId,
263
+ "aria-errormessage": errorId
264
+ });
265
+ case 'radio':
266
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(radio_group_cjs_namespaceObject.RadioGroup, {
267
+ "aria-labelledby": `${field.name}-label`,
268
+ value: formField.value,
269
+ onValueChange: formField.onChange,
270
+ disabled: disabled,
271
+ "aria-invalid": invalid || void 0,
272
+ "aria-describedby": errorId,
273
+ "aria-errormessage": errorId,
274
+ children: options.map((option)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
275
+ className: "flex items-center space-x-2",
276
+ children: [
277
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(radio_group_cjs_namespaceObject.RadioGroupItem, {
278
+ value: String(option.value),
279
+ id: `${field.name}-${option.value}`,
280
+ disabled: 'disabled' in option ? Boolean(option.disabled) : false
281
+ }),
282
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
283
+ variant: "muted",
284
+ htmlFor: `${field.name}-${option.value}`,
285
+ children: option.label
286
+ })
287
+ ]
288
+ }, String(option.value)))
289
+ });
290
+ case 'slider':
291
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SliderControl, {
292
+ field: field,
293
+ formField: formField,
294
+ disabled: disabled,
295
+ invalid: invalid,
296
+ errorId: errorId
297
+ });
298
+ case 'date':
299
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(date_picker_cjs_namespaceObject.DatePicker, {
300
+ id: field.name,
301
+ value: formField.value,
302
+ onValueChange: formField.onChange,
303
+ disabled: disabled,
304
+ placeholder: field.placeholder,
305
+ "aria-invalid": invalid || void 0,
306
+ "aria-describedby": errorId,
307
+ "aria-errormessage": errorId
308
+ });
309
+ case 'datetime':
310
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(datetime_picker_cjs_namespaceObject.DateTimePicker, {
311
+ "aria-labelledby": `${field.name}-label`,
312
+ "aria-invalid": invalid || void 0,
313
+ "aria-describedby": errorId,
314
+ "aria-errormessage": errorId,
315
+ value: formField.value,
316
+ onValueChange: formField.onChange,
317
+ disabled: disabled,
318
+ placeholder: field.placeholder,
319
+ use12Hour: field.use12Hour
320
+ });
321
+ case 'file':
322
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(file_upload_cjs_namespaceObject.FileUpload, {
323
+ id: field.name,
324
+ ariaLabel: field.ariaLabel ?? field.label,
325
+ "aria-invalid": invalid || void 0,
326
+ "aria-describedby": errorId,
327
+ "aria-errormessage": errorId,
328
+ accept: field.accept,
329
+ multiple: field.multiple,
330
+ disabled: disabled,
331
+ maxSize: field.maxSize,
332
+ showPreview: field.showPreview,
333
+ onFilesChange: onFilesChange
334
+ });
335
+ case 'string-list':
336
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_string_list_field_cjs_namespaceObject.StringListControl, {
337
+ field: field,
338
+ inputRef: formField.ref,
339
+ value: formField.value,
340
+ onChange: formField.onChange,
341
+ onBlur: formField.onBlur,
342
+ invalid: invalid,
343
+ disabled: disabled
344
+ });
345
+ default:
346
+ return null;
347
+ }
348
+ }
349
+ function SliderControl({ field, formField, disabled, invalid, errorId }) {
350
+ const resolvedMax = useSliderMax(field);
351
+ const prevMaxRef = (0, external_react_namespaceObject.useRef)(resolvedMax);
352
+ (0, external_react_namespaceObject.useEffect)(()=>{
353
+ if (resolvedMax === prevMaxRef.current) return;
354
+ prevMaxRef.current = resolvedMax;
355
+ const v = formField.value;
356
+ if ('number' == typeof v && v > resolvedMax) formField.onChange(resolvedMax);
357
+ }, [
358
+ resolvedMax,
359
+ formField.value,
360
+ formField.onChange
361
+ ]);
362
+ const displayValue = clampSliderValue(formField.value, resolvedMax);
363
+ const sliderValue = (0, external_react_namespaceObject.useMemo)(()=>[
364
+ displayValue ?? field.min ?? 0
365
+ ], [
366
+ displayValue,
367
+ field.min
368
+ ]);
369
+ const { onChange } = formField;
370
+ const onValueChange = (0, external_react_namespaceObject.useCallback)((values)=>onChange(values[0]), [
371
+ onChange
372
+ ]);
373
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(slider_cjs_namespaceObject.Slider, {
374
+ "aria-labelledby": `${field.name}-label`,
375
+ "aria-invalid": invalid || void 0,
376
+ "aria-describedby": errorId,
377
+ "aria-errormessage": errorId,
378
+ value: sliderValue,
379
+ onValueChange: onValueChange,
380
+ min: field.min || 0,
381
+ max: resolvedMax,
382
+ step: field.step || 1,
383
+ disabled: disabled
384
+ });
385
+ }
386
+ function useSliderMax(field) {
387
+ const { watch } = (0, external_react_hook_form_namespaceObject.useFormContext)();
388
+ const readValue = (0, external_react_namespaceObject.useContext)(external_literal_value_context_cjs_namespaceObject.LiteralValueContext);
389
+ const watchedMax = field.maxRef ? readValue(field.maxRef.fromField, watch(field.maxRef.fromField)) : void 0;
390
+ return resolveSliderMax(field, watchedMax);
391
+ }
392
+ function clampSliderValue(value, max) {
393
+ return 'number' == typeof value ? Math.min(value, max) : value;
394
+ }
395
+ function resolveSliderMax(field, watchedValue) {
396
+ if (field.maxRef) {
397
+ if ('number' == typeof watchedValue && Number.isFinite(watchedValue) && watchedValue > 0) return watchedValue;
398
+ if ('number' == typeof field.maxRef.fallback) return field.maxRef.fallback;
399
+ }
400
+ if ('number' == typeof field.max) return field.max;
401
+ return 100;
402
+ }
403
+ exports.FIELD_CONTROL_GEOMETRY = __webpack_exports__.FIELD_CONTROL_GEOMETRY;
404
+ exports.FieldControl = __webpack_exports__.FieldControl;
405
+ exports.clampSliderValue = __webpack_exports__.clampSliderValue;
406
+ exports.useSliderMax = __webpack_exports__.useSliderMax;
407
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
408
+ "FIELD_CONTROL_GEOMETRY",
409
+ "FieldControl",
410
+ "clampSliderValue",
411
+ "useSliderMax"
412
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
413
+ Object.defineProperty(exports, '__esModule', {
414
+ value: true
415
+ });
@@ -0,0 +1,52 @@
1
+ import type * as React from 'react';
2
+ import { type BooleanRadioGroupStrings } from '../ui/boolean-radio-group';
3
+ import type { InputGroupLayout, InputGroupProps } from '../ui/input-group';
4
+ import type { FieldMetadata, FieldOption, FieldType, SliderFieldMetadata } from './form-schema';
5
+ /** The react-hook-form `Controller` binding a control reads and writes. */
6
+ export interface FieldControlFormField {
7
+ value: unknown;
8
+ onChange: (value: unknown) => void;
9
+ onBlur: () => void;
10
+ name: string;
11
+ ref: React.Ref<unknown>;
12
+ }
13
+ export interface FieldControlProps {
14
+ field: FieldMetadata;
15
+ formField: FieldControlFormField;
16
+ /** The resolved options of a select, multiselect or radio field. */
17
+ options?: FieldOption[];
18
+ disabled?: boolean;
19
+ /** Marks the control invalid and points it at the `${field.name}-error` message. */
20
+ invalid?: boolean;
21
+ /** Labels of a `boolean` field's radios. */
22
+ strings?: Partial<BooleanRadioGroupStrings>;
23
+ }
24
+ /**
25
+ * How a field's label reaches its control: `control` labels it with `htmlFor` the control's id
26
+ * (`field.name`), and `labelledby` has the control name itself with `aria-labelledby` the label's
27
+ * id (`${field.name}-label`).
28
+ */
29
+ export type FieldControlLabelTarget = 'control' | 'labelledby';
30
+ /** How a field type's control sits in an `InputGroup`. */
31
+ export interface FieldControlGeometry {
32
+ layout: InputGroupLayout;
33
+ variant: NonNullable<InputGroupProps['variant']>;
34
+ labelTarget: FieldControlLabelTarget;
35
+ /** Whether text can be inserted at the caret, as Insert variable does. */
36
+ insertable: boolean;
37
+ }
38
+ /**
39
+ * Each field type's geometry inside an `InputGroup`. Types not listed have not been fitted to one
40
+ * yet.
41
+ */
42
+ export declare const FIELD_CONTROL_GEOMETRY: Readonly<Partial<Record<FieldType, FieldControlGeometry>>>;
43
+ /**
44
+ * The bare control for a field's type, without its label, description or error. Its id is
45
+ * `field.name`, and it names the label and error by `${field.name}-label` and
46
+ * `${field.name}-error`, so those are the ids to give them. Custom fields render nothing.
47
+ */
48
+ export declare function FieldControl({ field, formField, options, disabled, invalid, strings, }: FieldControlProps): import("react/jsx-runtime").JSX.Element | null;
49
+ /** The slider's effective max, following `field.maxRef` when it has one. */
50
+ export declare function useSliderMax(field: SliderFieldMetadata): number;
51
+ /** A numeric slider value capped at `max`; anything else as it is. */
52
+ export declare function clampSliderValue(value: unknown, max: number): unknown;