@uipath/apollo-wind 2.60.0 → 2.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/components/forms/field-actions.cjs +181 -0
- package/dist/components/forms/field-actions.d.ts +131 -0
- package/dist/components/forms/field-actions.js +129 -0
- package/dist/components/forms/field-control.cjs +415 -0
- package/dist/components/forms/field-control.d.ts +52 -0
- package/dist/components/forms/field-control.js +372 -0
- package/dist/components/forms/field-renderer.cjs +77 -420
- package/dist/components/forms/field-renderer.d.ts +2 -3
- package/dist/components/forms/field-renderer.js +78 -421
- package/dist/components/forms/form-designer.cjs +7 -1
- package/dist/components/forms/form-designer.js +7 -1
- package/dist/components/forms/form-schema.d.ts +121 -2
- package/dist/components/forms/form-strings.cjs +67 -0
- package/dist/components/forms/form-strings.d.ts +30 -0
- package/dist/components/forms/form-strings.js +30 -0
- package/dist/components/forms/index.cjs +53 -9
- package/dist/components/forms/index.d.ts +6 -1
- package/dist/components/forms/index.js +6 -1
- package/dist/components/forms/literal-value-context.cjs +37 -0
- package/dist/components/forms/literal-value-context.d.ts +5 -0
- package/dist/components/forms/literal-value-context.js +3 -0
- package/dist/components/forms/metadata-form.cjs +100 -21
- package/dist/components/forms/metadata-form.d.ts +5 -0
- package/dist/components/forms/metadata-form.js +101 -22
- package/dist/components/forms/mode-aware-field.cjs +589 -0
- package/dist/components/forms/mode-aware-field.d.ts +15 -0
- package/dist/components/forms/mode-aware-field.js +555 -0
- package/dist/components/forms/opaque-value.cjs +44 -0
- package/dist/components/forms/opaque-value.d.ts +7 -0
- package/dist/components/forms/opaque-value.js +7 -0
- package/dist/components/forms/rules-engine.cjs +13 -0
- package/dist/components/forms/rules-engine.js +13 -0
- package/dist/components/forms/schema-serializer.cjs +8 -0
- package/dist/components/forms/schema-serializer.js +8 -0
- package/dist/components/forms/string-list-field.cjs +36 -18
- package/dist/components/forms/string-list-field.d.ts +6 -0
- package/dist/components/forms/string-list-field.js +35 -20
- package/dist/components/forms/validation-converter.cjs +32 -2
- package/dist/components/forms/validation-converter.d.ts +17 -1
- package/dist/components/forms/validation-converter.js +30 -3
- package/dist/components/forms/value-modes.cjs +253 -0
- package/dist/components/forms/value-modes.d.ts +236 -0
- package/dist/components/forms/value-modes.js +180 -0
- package/dist/components/ui/accordion.cjs +1 -0
- package/dist/components/ui/accordion.js +1 -0
- package/dist/components/ui/avatar.d.ts +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/boolean-radio-group.cjs +114 -0
- package/dist/components/ui/boolean-radio-group.d.ts +24 -0
- package/dist/components/ui/boolean-radio-group.js +77 -0
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/command.d.ts +7 -7
- package/dist/components/ui/dialog.cjs +1 -0
- package/dist/components/ui/dialog.js +1 -0
- package/dist/components/ui/drawer.cjs +1 -1
- package/dist/components/ui/drawer.js +1 -1
- package/dist/components/ui/field-addons/field-menu.cjs +1 -0
- package/dist/components/ui/field-addons/field-menu.d.ts +2 -0
- package/dist/components/ui/field-addons/field-menu.js +1 -0
- package/dist/components/ui/field-addons/index.cjs +4 -0
- package/dist/components/ui/field-addons/index.d.ts +1 -0
- package/dist/components/ui/field-addons/index.js +2 -1
- package/dist/components/ui/field-addons/value-mode-strings.cjs +7 -1
- package/dist/components/ui/field-addons/value-mode-strings.d.ts +9 -0
- package/dist/components/ui/field-addons/value-mode-strings.js +7 -1
- package/dist/components/ui/field-addons/value-mode-switch-dialog.cjs +73 -0
- package/dist/components/ui/field-addons/value-mode-switch-dialog.d.ts +16 -0
- package/dist/components/ui/field-addons/value-mode-switch-dialog.js +39 -0
- package/dist/components/ui/form-field.cjs +2 -1
- package/dist/components/ui/form-field.d.ts +2 -0
- package/dist/components/ui/form-field.js +2 -1
- package/dist/components/ui/index.cjs +235 -191
- package/dist/components/ui/index.d.ts +4 -0
- package/dist/components/ui/index.js +4 -0
- package/dist/components/ui/input-group.cjs +6 -3
- package/dist/components/ui/input-group.d.ts +6 -5
- package/dist/components/ui/input-group.js +6 -3
- package/dist/components/ui/json-tree-view/DecorationChip.cjs +81 -0
- package/dist/components/ui/json-tree-view/DecorationChip.d.ts +4 -0
- package/dist/components/ui/json-tree-view/DecorationChip.js +47 -0
- package/dist/components/ui/json-tree-view/EditorChrome.cjs +88 -0
- package/dist/components/ui/json-tree-view/EditorChrome.d.ts +21 -0
- package/dist/components/ui/json-tree-view/EditorChrome.js +51 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.cjs +95 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.d.ts +18 -0
- package/dist/components/ui/json-tree-view/JsonContainerEditor.js +61 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.cjs +86 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.d.ts +12 -0
- package/dist/components/ui/json-tree-view/JsonLeafValueEditor.js +52 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.cjs +74 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.d.ts +13 -0
- package/dist/components/ui/json-tree-view/JsonMultilineLeafEditor.js +40 -0
- package/dist/components/ui/json-tree-view/JsonTree.cjs +253 -0
- package/dist/components/ui/json-tree-view/JsonTree.d.ts +81 -0
- package/dist/components/ui/json-tree-view/JsonTree.js +219 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.cjs +18 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.d.ts +253 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.js +0 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.cjs +284 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.d.ts +50 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.js +244 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.cjs +209 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.d.ts +35 -0
- package/dist/components/ui/json-tree-view/JsonTreeToolbar.js +175 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.cjs +84 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.d.ts +21 -0
- package/dist/components/ui/json-tree-view/JsonTreeTooltip.js +47 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.cjs +70 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.d.ts +17 -0
- package/dist/components/ui/json-tree-view/JsonTypeBadge.js +36 -0
- package/dist/components/ui/json-tree-view/NodeKey.cjs +77 -0
- package/dist/components/ui/json-tree-view/NodeKey.d.ts +16 -0
- package/dist/components/ui/json-tree-view/NodeKey.js +43 -0
- package/dist/components/ui/json-tree-view/RowActions.cjs +120 -0
- package/dist/components/ui/json-tree-view/RowActions.d.ts +15 -0
- package/dist/components/ui/json-tree-view/RowActions.js +86 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.cjs +112 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.d.ts +18 -0
- package/dist/components/ui/json-tree-view/ScalarValueCell.js +75 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.cjs +324 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.d.ts +75 -0
- package/dist/components/ui/json-tree-view/buildJsonTree.js +257 -0
- package/dist/components/ui/json-tree-view/clipboard.cjs +63 -0
- package/dist/components/ui/json-tree-view/clipboard.d.ts +6 -0
- package/dist/components/ui/json-tree-view/clipboard.js +29 -0
- package/dist/components/ui/json-tree-view/index.cjs +175 -0
- package/dist/components/ui/json-tree-view/index.d.ts +10 -0
- package/dist/components/ui/json-tree-view/index.js +11 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.cjs +74 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.d.ts +12 -0
- package/dist/components/ui/json-tree-view/leafEditTypes.js +34 -0
- package/dist/components/ui/json-tree-view/strings.cjs +122 -0
- package/dist/components/ui/json-tree-view/strings.d.ts +65 -0
- package/dist/components/ui/json-tree-view/strings.js +79 -0
- package/dist/components/ui/prompt-value-control.cjs +70 -0
- package/dist/components/ui/prompt-value-control.d.ts +28 -0
- package/dist/components/ui/prompt-value-control.js +36 -0
- package/dist/components/ui/sheet.cjs +2 -2
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/components/ui/sheet.js +2 -2
- package/dist/components/ui/spinner.d.ts +1 -1
- package/dist/components/ui/switch.d.ts +2 -2
- package/dist/components/ui/textarea.cjs +1 -1
- package/dist/components/ui/textarea.js +1 -1
- package/dist/components/ui/toggle-group.d.ts +2 -2
- package/dist/components/ui/toggle.d.ts +2 -2
- package/dist/components/ui/variable-value-control.cjs +98 -0
- package/dist/components/ui/variable-value-control.d.ts +35 -0
- package/dist/components/ui/variable-value-control.js +64 -0
- package/dist/index.cjs +145 -16
- package/dist/index.d.ts +21 -3
- package/dist/index.js +11 -2
- package/dist/lib/index.cjs +4 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +2 -2
- package/dist/lib/utils.cjs +21 -1
- package/dist/lib/utils.d.ts +8 -0
- package/dist/lib/utils.js +18 -1
- package/dist/styles.css +278 -0
- package/dist/tailwind.css +72 -0
- package/package.json +1 -1
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useContext, useEffect, useMemo, useRef } from "react";
|
|
3
|
+
import { useFormContext } from "react-hook-form";
|
|
4
|
+
import { BooleanRadioGroup } from "../ui/boolean-radio-group.js";
|
|
5
|
+
import { Checkbox } from "../ui/checkbox.js";
|
|
6
|
+
import { DatePicker } from "../ui/date-picker.js";
|
|
7
|
+
import { DateTimePicker } from "../ui/datetime-picker.js";
|
|
8
|
+
import { FileUpload } from "../ui/file-upload.js";
|
|
9
|
+
import { Input } from "../ui/input.js";
|
|
10
|
+
import { Label } from "../ui/label.js";
|
|
11
|
+
import { MultiSelect } from "../ui/multi-select.js";
|
|
12
|
+
import { RadioGroup, RadioGroupItem } from "../ui/radio-group.js";
|
|
13
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select.js";
|
|
14
|
+
import { Slider } from "../ui/slider.js";
|
|
15
|
+
import { Switch } from "../ui/switch.js";
|
|
16
|
+
import { Textarea } from "../ui/textarea.js";
|
|
17
|
+
import { LiteralValueContext } from "./literal-value-context.js";
|
|
18
|
+
import { StringListControl } from "./string-list-field.js";
|
|
19
|
+
const FIELD_CONTROL_GEOMETRY = {
|
|
20
|
+
text: {
|
|
21
|
+
layout: 'row',
|
|
22
|
+
variant: 'default',
|
|
23
|
+
labelTarget: 'control',
|
|
24
|
+
insertable: true
|
|
25
|
+
},
|
|
26
|
+
email: {
|
|
27
|
+
layout: 'row',
|
|
28
|
+
variant: 'default',
|
|
29
|
+
labelTarget: 'control',
|
|
30
|
+
insertable: true
|
|
31
|
+
},
|
|
32
|
+
number: {
|
|
33
|
+
layout: 'row',
|
|
34
|
+
variant: 'default',
|
|
35
|
+
labelTarget: 'control',
|
|
36
|
+
insertable: false
|
|
37
|
+
},
|
|
38
|
+
select: {
|
|
39
|
+
layout: 'row',
|
|
40
|
+
variant: 'default',
|
|
41
|
+
labelTarget: 'control',
|
|
42
|
+
insertable: false
|
|
43
|
+
},
|
|
44
|
+
textarea: {
|
|
45
|
+
layout: 'grow',
|
|
46
|
+
variant: 'default',
|
|
47
|
+
labelTarget: 'control',
|
|
48
|
+
insertable: true
|
|
49
|
+
},
|
|
50
|
+
file: {
|
|
51
|
+
layout: 'grow',
|
|
52
|
+
variant: 'default',
|
|
53
|
+
labelTarget: 'control',
|
|
54
|
+
insertable: false
|
|
55
|
+
},
|
|
56
|
+
multiselect: {
|
|
57
|
+
layout: 'grow',
|
|
58
|
+
variant: 'default',
|
|
59
|
+
labelTarget: 'control',
|
|
60
|
+
insertable: false
|
|
61
|
+
},
|
|
62
|
+
switch: {
|
|
63
|
+
layout: 'row',
|
|
64
|
+
variant: 'none',
|
|
65
|
+
labelTarget: 'control',
|
|
66
|
+
insertable: false
|
|
67
|
+
},
|
|
68
|
+
checkbox: {
|
|
69
|
+
layout: 'row',
|
|
70
|
+
variant: 'none',
|
|
71
|
+
labelTarget: 'control',
|
|
72
|
+
insertable: false
|
|
73
|
+
},
|
|
74
|
+
boolean: {
|
|
75
|
+
layout: 'row',
|
|
76
|
+
variant: 'none',
|
|
77
|
+
labelTarget: 'labelledby',
|
|
78
|
+
insertable: false
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const NO_OPTIONS = [];
|
|
82
|
+
const NO_SELECTION = [];
|
|
83
|
+
function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false, invalid = false, strings }) {
|
|
84
|
+
const errorId = invalid ? `${field.name}-error` : void 0;
|
|
85
|
+
const { onChange } = formField;
|
|
86
|
+
const multipleFiles = 'file' === field.type && field.multiple;
|
|
87
|
+
const onTextChange = useCallback((event)=>onChange(event.target.value), [
|
|
88
|
+
onChange
|
|
89
|
+
]);
|
|
90
|
+
const onNumberChange = useCallback((event)=>onChange(parseFloat(event.target.value)), [
|
|
91
|
+
onChange
|
|
92
|
+
]);
|
|
93
|
+
const onCheckedChange = useCallback((checked)=>onChange(true === checked), [
|
|
94
|
+
onChange
|
|
95
|
+
]);
|
|
96
|
+
const onFilesChange = useCallback((files)=>onChange(multipleFiles ? files : files[0]), [
|
|
97
|
+
onChange,
|
|
98
|
+
multipleFiles
|
|
99
|
+
]);
|
|
100
|
+
const multiSelectOptions = useMemo(()=>options.map((option)=>({
|
|
101
|
+
label: option.label,
|
|
102
|
+
value: String(option.value)
|
|
103
|
+
})), [
|
|
104
|
+
options
|
|
105
|
+
]);
|
|
106
|
+
switch(field.type){
|
|
107
|
+
case 'text':
|
|
108
|
+
case 'email':
|
|
109
|
+
return /*#__PURE__*/ jsx(Input, {
|
|
110
|
+
id: field.name,
|
|
111
|
+
value: formField.value,
|
|
112
|
+
onChange: onTextChange,
|
|
113
|
+
onBlur: formField.onBlur,
|
|
114
|
+
name: formField.name,
|
|
115
|
+
ref: formField.ref,
|
|
116
|
+
type: field.type,
|
|
117
|
+
placeholder: field.placeholder,
|
|
118
|
+
disabled: disabled,
|
|
119
|
+
"aria-invalid": invalid || void 0,
|
|
120
|
+
"aria-describedby": errorId,
|
|
121
|
+
"aria-errormessage": errorId,
|
|
122
|
+
"aria-label": field.ariaLabel
|
|
123
|
+
});
|
|
124
|
+
case 'number':
|
|
125
|
+
return /*#__PURE__*/ jsx(Input, {
|
|
126
|
+
id: field.name,
|
|
127
|
+
value: formField.value,
|
|
128
|
+
onBlur: formField.onBlur,
|
|
129
|
+
name: formField.name,
|
|
130
|
+
ref: formField.ref,
|
|
131
|
+
type: "number",
|
|
132
|
+
min: field.min,
|
|
133
|
+
max: field.max,
|
|
134
|
+
step: field.step,
|
|
135
|
+
placeholder: field.placeholder,
|
|
136
|
+
disabled: disabled,
|
|
137
|
+
"aria-invalid": invalid || void 0,
|
|
138
|
+
"aria-describedby": errorId,
|
|
139
|
+
"aria-errormessage": errorId,
|
|
140
|
+
onChange: onNumberChange
|
|
141
|
+
});
|
|
142
|
+
case 'textarea':
|
|
143
|
+
return /*#__PURE__*/ jsx(Textarea, {
|
|
144
|
+
id: field.name,
|
|
145
|
+
value: formField.value,
|
|
146
|
+
onChange: onTextChange,
|
|
147
|
+
onBlur: formField.onBlur,
|
|
148
|
+
name: formField.name,
|
|
149
|
+
ref: formField.ref,
|
|
150
|
+
placeholder: field.placeholder,
|
|
151
|
+
disabled: disabled,
|
|
152
|
+
maxLength: field.maxLength,
|
|
153
|
+
"aria-invalid": invalid || void 0,
|
|
154
|
+
"aria-describedby": errorId,
|
|
155
|
+
"aria-errormessage": errorId,
|
|
156
|
+
...null != field.minRows ? {
|
|
157
|
+
minRows: field.minRows
|
|
158
|
+
} : {
|
|
159
|
+
rows: field.rows || 4
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
case 'select':
|
|
163
|
+
return /*#__PURE__*/ jsxs(Select, {
|
|
164
|
+
value: formField.value,
|
|
165
|
+
onValueChange: formField.onChange,
|
|
166
|
+
disabled: disabled,
|
|
167
|
+
children: [
|
|
168
|
+
/*#__PURE__*/ jsx(SelectTrigger, {
|
|
169
|
+
id: field.name,
|
|
170
|
+
"aria-label": field.label,
|
|
171
|
+
"aria-invalid": invalid || void 0,
|
|
172
|
+
"aria-describedby": errorId,
|
|
173
|
+
"aria-errormessage": errorId,
|
|
174
|
+
children: /*#__PURE__*/ jsx(SelectValue, {
|
|
175
|
+
placeholder: field.placeholder || 'Select...'
|
|
176
|
+
})
|
|
177
|
+
}),
|
|
178
|
+
/*#__PURE__*/ jsx(SelectContent, {
|
|
179
|
+
children: options.map((option)=>/*#__PURE__*/ jsx(SelectItem, {
|
|
180
|
+
value: String(option.value),
|
|
181
|
+
disabled: 'disabled' in option ? Boolean(option.disabled) : false,
|
|
182
|
+
children: option.label
|
|
183
|
+
}, String(option.value)))
|
|
184
|
+
})
|
|
185
|
+
]
|
|
186
|
+
});
|
|
187
|
+
case 'multiselect':
|
|
188
|
+
return /*#__PURE__*/ jsx(MultiSelect, {
|
|
189
|
+
id: field.name,
|
|
190
|
+
selected: formField.value || NO_SELECTION,
|
|
191
|
+
onChange: formField.onChange,
|
|
192
|
+
options: multiSelectOptions,
|
|
193
|
+
disabled: disabled,
|
|
194
|
+
placeholder: field.placeholder || 'Select items...',
|
|
195
|
+
emptyMessage: field.emptyMessage ?? 'No items found.',
|
|
196
|
+
searchPlaceholder: field.searchPlaceholder ?? 'Search...',
|
|
197
|
+
maxSelected: field.maxSelected,
|
|
198
|
+
"aria-invalid": invalid || void 0,
|
|
199
|
+
"aria-describedby": errorId,
|
|
200
|
+
"aria-errormessage": errorId
|
|
201
|
+
});
|
|
202
|
+
case 'checkbox':
|
|
203
|
+
return /*#__PURE__*/ jsx(Checkbox, {
|
|
204
|
+
checked: true === formField.value,
|
|
205
|
+
onCheckedChange: onCheckedChange,
|
|
206
|
+
disabled: disabled,
|
|
207
|
+
"aria-invalid": invalid || void 0,
|
|
208
|
+
"aria-describedby": errorId,
|
|
209
|
+
"aria-errormessage": errorId,
|
|
210
|
+
id: field.name
|
|
211
|
+
});
|
|
212
|
+
case 'boolean':
|
|
213
|
+
return /*#__PURE__*/ jsx(BooleanRadioGroup, {
|
|
214
|
+
"aria-labelledby": `${field.name}-label`,
|
|
215
|
+
value: 'boolean' == typeof formField.value ? formField.value : null,
|
|
216
|
+
onValueChange: formField.onChange,
|
|
217
|
+
onBlur: formField.onBlur,
|
|
218
|
+
disabled: disabled,
|
|
219
|
+
"aria-invalid": invalid || void 0,
|
|
220
|
+
"aria-describedby": errorId,
|
|
221
|
+
"aria-errormessage": errorId,
|
|
222
|
+
strings: strings
|
|
223
|
+
});
|
|
224
|
+
case 'switch':
|
|
225
|
+
return /*#__PURE__*/ jsx(Switch, {
|
|
226
|
+
id: field.name,
|
|
227
|
+
checked: true === formField.value,
|
|
228
|
+
onCheckedChange: onCheckedChange,
|
|
229
|
+
disabled: disabled,
|
|
230
|
+
"aria-invalid": invalid || void 0,
|
|
231
|
+
"aria-describedby": errorId,
|
|
232
|
+
"aria-errormessage": errorId
|
|
233
|
+
});
|
|
234
|
+
case 'radio':
|
|
235
|
+
return /*#__PURE__*/ jsx(RadioGroup, {
|
|
236
|
+
"aria-labelledby": `${field.name}-label`,
|
|
237
|
+
value: formField.value,
|
|
238
|
+
onValueChange: formField.onChange,
|
|
239
|
+
disabled: disabled,
|
|
240
|
+
"aria-invalid": invalid || void 0,
|
|
241
|
+
"aria-describedby": errorId,
|
|
242
|
+
"aria-errormessage": errorId,
|
|
243
|
+
children: options.map((option)=>/*#__PURE__*/ jsxs("div", {
|
|
244
|
+
className: "flex items-center space-x-2",
|
|
245
|
+
children: [
|
|
246
|
+
/*#__PURE__*/ jsx(RadioGroupItem, {
|
|
247
|
+
value: String(option.value),
|
|
248
|
+
id: `${field.name}-${option.value}`,
|
|
249
|
+
disabled: 'disabled' in option ? Boolean(option.disabled) : false
|
|
250
|
+
}),
|
|
251
|
+
/*#__PURE__*/ jsx(Label, {
|
|
252
|
+
variant: "muted",
|
|
253
|
+
htmlFor: `${field.name}-${option.value}`,
|
|
254
|
+
children: option.label
|
|
255
|
+
})
|
|
256
|
+
]
|
|
257
|
+
}, String(option.value)))
|
|
258
|
+
});
|
|
259
|
+
case 'slider':
|
|
260
|
+
return /*#__PURE__*/ jsx(SliderControl, {
|
|
261
|
+
field: field,
|
|
262
|
+
formField: formField,
|
|
263
|
+
disabled: disabled,
|
|
264
|
+
invalid: invalid,
|
|
265
|
+
errorId: errorId
|
|
266
|
+
});
|
|
267
|
+
case 'date':
|
|
268
|
+
return /*#__PURE__*/ jsx(DatePicker, {
|
|
269
|
+
id: field.name,
|
|
270
|
+
value: formField.value,
|
|
271
|
+
onValueChange: formField.onChange,
|
|
272
|
+
disabled: disabled,
|
|
273
|
+
placeholder: field.placeholder,
|
|
274
|
+
"aria-invalid": invalid || void 0,
|
|
275
|
+
"aria-describedby": errorId,
|
|
276
|
+
"aria-errormessage": errorId
|
|
277
|
+
});
|
|
278
|
+
case 'datetime':
|
|
279
|
+
return /*#__PURE__*/ jsx(DateTimePicker, {
|
|
280
|
+
"aria-labelledby": `${field.name}-label`,
|
|
281
|
+
"aria-invalid": invalid || void 0,
|
|
282
|
+
"aria-describedby": errorId,
|
|
283
|
+
"aria-errormessage": errorId,
|
|
284
|
+
value: formField.value,
|
|
285
|
+
onValueChange: formField.onChange,
|
|
286
|
+
disabled: disabled,
|
|
287
|
+
placeholder: field.placeholder,
|
|
288
|
+
use12Hour: field.use12Hour
|
|
289
|
+
});
|
|
290
|
+
case 'file':
|
|
291
|
+
return /*#__PURE__*/ jsx(FileUpload, {
|
|
292
|
+
id: field.name,
|
|
293
|
+
ariaLabel: field.ariaLabel ?? field.label,
|
|
294
|
+
"aria-invalid": invalid || void 0,
|
|
295
|
+
"aria-describedby": errorId,
|
|
296
|
+
"aria-errormessage": errorId,
|
|
297
|
+
accept: field.accept,
|
|
298
|
+
multiple: field.multiple,
|
|
299
|
+
disabled: disabled,
|
|
300
|
+
maxSize: field.maxSize,
|
|
301
|
+
showPreview: field.showPreview,
|
|
302
|
+
onFilesChange: onFilesChange
|
|
303
|
+
});
|
|
304
|
+
case 'string-list':
|
|
305
|
+
return /*#__PURE__*/ jsx(StringListControl, {
|
|
306
|
+
field: field,
|
|
307
|
+
inputRef: formField.ref,
|
|
308
|
+
value: formField.value,
|
|
309
|
+
onChange: formField.onChange,
|
|
310
|
+
onBlur: formField.onBlur,
|
|
311
|
+
invalid: invalid,
|
|
312
|
+
disabled: disabled
|
|
313
|
+
});
|
|
314
|
+
default:
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function SliderControl({ field, formField, disabled, invalid, errorId }) {
|
|
319
|
+
const resolvedMax = useSliderMax(field);
|
|
320
|
+
const prevMaxRef = useRef(resolvedMax);
|
|
321
|
+
useEffect(()=>{
|
|
322
|
+
if (resolvedMax === prevMaxRef.current) return;
|
|
323
|
+
prevMaxRef.current = resolvedMax;
|
|
324
|
+
const v = formField.value;
|
|
325
|
+
if ('number' == typeof v && v > resolvedMax) formField.onChange(resolvedMax);
|
|
326
|
+
}, [
|
|
327
|
+
resolvedMax,
|
|
328
|
+
formField.value,
|
|
329
|
+
formField.onChange
|
|
330
|
+
]);
|
|
331
|
+
const displayValue = clampSliderValue(formField.value, resolvedMax);
|
|
332
|
+
const sliderValue = useMemo(()=>[
|
|
333
|
+
displayValue ?? field.min ?? 0
|
|
334
|
+
], [
|
|
335
|
+
displayValue,
|
|
336
|
+
field.min
|
|
337
|
+
]);
|
|
338
|
+
const { onChange } = formField;
|
|
339
|
+
const onValueChange = useCallback((values)=>onChange(values[0]), [
|
|
340
|
+
onChange
|
|
341
|
+
]);
|
|
342
|
+
return /*#__PURE__*/ jsx(Slider, {
|
|
343
|
+
"aria-labelledby": `${field.name}-label`,
|
|
344
|
+
"aria-invalid": invalid || void 0,
|
|
345
|
+
"aria-describedby": errorId,
|
|
346
|
+
"aria-errormessage": errorId,
|
|
347
|
+
value: sliderValue,
|
|
348
|
+
onValueChange: onValueChange,
|
|
349
|
+
min: field.min || 0,
|
|
350
|
+
max: resolvedMax,
|
|
351
|
+
step: field.step || 1,
|
|
352
|
+
disabled: disabled
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function useSliderMax(field) {
|
|
356
|
+
const { watch } = useFormContext();
|
|
357
|
+
const readValue = useContext(LiteralValueContext);
|
|
358
|
+
const watchedMax = field.maxRef ? readValue(field.maxRef.fromField, watch(field.maxRef.fromField)) : void 0;
|
|
359
|
+
return resolveSliderMax(field, watchedMax);
|
|
360
|
+
}
|
|
361
|
+
function clampSliderValue(value, max) {
|
|
362
|
+
return 'number' == typeof value ? Math.min(value, max) : value;
|
|
363
|
+
}
|
|
364
|
+
function resolveSliderMax(field, watchedValue) {
|
|
365
|
+
if (field.maxRef) {
|
|
366
|
+
if ('number' == typeof watchedValue && Number.isFinite(watchedValue) && watchedValue > 0) return watchedValue;
|
|
367
|
+
if ('number' == typeof field.maxRef.fallback) return field.maxRef.fallback;
|
|
368
|
+
}
|
|
369
|
+
if ('number' == typeof field.max) return field.max;
|
|
370
|
+
return 100;
|
|
371
|
+
}
|
|
372
|
+
export { FIELD_CONTROL_GEOMETRY, FieldControl, clampSliderValue, useSliderMax };
|