@uipath/apollo-wind 2.60.1 → 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/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/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/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 +230 -186
- 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.d.ts +1 -1
- 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 +225 -0
- package/package.json +1 -1
|
@@ -1,34 +1,28 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Controller, useFormContext } from "react-hook-form";
|
|
4
|
-
import { Checkbox } from "../ui/checkbox.js";
|
|
5
|
-
import { DatePicker } from "../ui/date-picker.js";
|
|
6
|
-
import { DateTimePicker } from "../ui/datetime-picker.js";
|
|
7
|
-
import { FileUpload } from "../ui/file-upload.js";
|
|
8
4
|
import { FormField, FormFieldDescription, FormFieldError, FormFieldLabel } from "../ui/form-field.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
5
|
import { deepEqual } from "../../lib/index.js";
|
|
18
6
|
import { DataFetcher } from "./data-fetcher.js";
|
|
7
|
+
import { FieldControl, clampSliderValue, useSliderMax } from "./field-control.js";
|
|
19
8
|
import { hasOptions, isCustomField } from "./form-schema.js";
|
|
9
|
+
import { ModeAwareField } from "./mode-aware-field.js";
|
|
20
10
|
import { RulesEngine } from "./rules-engine.js";
|
|
21
11
|
import { StringListField } from "./string-list-field.js";
|
|
12
|
+
import { isFieldControlRegistration, literalValues } from "./value-modes.js";
|
|
22
13
|
function FormFieldRenderer({ field, context, customComponents, disabled: formDisabled = false }) {
|
|
23
14
|
const { control, watch, getValues } = useFormContext();
|
|
24
15
|
const contextRef = useRef(context);
|
|
25
16
|
contextRef.current = context;
|
|
17
|
+
const readValues = useCallback(()=>literalValues(getValues(), contextRef.current.schema, contextRef.current.valueModes?.codecs), [
|
|
18
|
+
getValues
|
|
19
|
+
]);
|
|
26
20
|
const getInitialVisibility = ()=>{
|
|
27
21
|
if (!field.rules || 0 === field.rules.length) return true;
|
|
28
22
|
const hasShowRule = field.rules.some((rule)=>rule.effects?.visible === true);
|
|
29
23
|
const hasHideRule = field.rules.some((rule)=>rule.effects?.visible === false);
|
|
30
24
|
if (!hasShowRule && !hasHideRule) return true;
|
|
31
|
-
const allValues =
|
|
25
|
+
const allValues = readValues();
|
|
32
26
|
const ruleResult = RulesEngine.applyRules(field.rules, allValues, context);
|
|
33
27
|
if (void 0 !== ruleResult.visible) return ruleResult.visible;
|
|
34
28
|
return !hasShowRule;
|
|
@@ -36,7 +30,7 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
36
30
|
const getInitialRequired = ()=>{
|
|
37
31
|
const staticRequired = field.validation?.required ?? false;
|
|
38
32
|
if (!field.rules || 0 === field.rules.length) return staticRequired;
|
|
39
|
-
const allValues =
|
|
33
|
+
const allValues = readValues();
|
|
40
34
|
const ruleResult = RulesEngine.applyRules(field.rules, allValues, context);
|
|
41
35
|
return ruleResult.required ?? staticRequired;
|
|
42
36
|
};
|
|
@@ -75,7 +69,7 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
75
69
|
const watchedRuleDependentValues = watch(dependentFields);
|
|
76
70
|
useEffect(()=>{
|
|
77
71
|
if (!field.rules || 0 === field.rules.length) return;
|
|
78
|
-
const allValues =
|
|
72
|
+
const allValues = readValues();
|
|
79
73
|
const ruleResult = RulesEngine.applyRules(field.rules, allValues, contextRef.current);
|
|
80
74
|
const hasShowRule = field.rules.some((rule)=>rule.effects?.visible === true);
|
|
81
75
|
const hasHideRule = field.rules.some((rule)=>rule.effects?.visible === false);
|
|
@@ -102,7 +96,7 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
102
96
|
}, [
|
|
103
97
|
field.rules,
|
|
104
98
|
field.validation?.required,
|
|
105
|
-
|
|
99
|
+
readValues,
|
|
106
100
|
watchedRuleDependentValues
|
|
107
101
|
]);
|
|
108
102
|
const isOptionsField = hasOptions(field);
|
|
@@ -127,7 +121,7 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
127
121
|
if (!field.dataSource) return;
|
|
128
122
|
const fetchOptions = async ()=>{
|
|
129
123
|
try {
|
|
130
|
-
const allValues =
|
|
124
|
+
const allValues = readValues();
|
|
131
125
|
const data = await DataFetcher.fetch(field.dataSource, allValues);
|
|
132
126
|
setFieldState((prev)=>{
|
|
133
127
|
if (deepEqual(prev.options, data)) return prev;
|
|
@@ -144,7 +138,7 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
144
138
|
}, [
|
|
145
139
|
field.dataSource,
|
|
146
140
|
field.name,
|
|
147
|
-
|
|
141
|
+
readValues,
|
|
148
142
|
watchedDataSourceValues
|
|
149
143
|
]);
|
|
150
144
|
if (!fieldState.visible) return null;
|
|
@@ -152,8 +146,20 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
152
146
|
const gridStyle = {
|
|
153
147
|
gridColumn: `span ${gridSpan}`
|
|
154
148
|
};
|
|
155
|
-
if (
|
|
156
|
-
|
|
149
|
+
if (field.valueModes || field.headerActions || field.menuActions || field.badge) return /*#__PURE__*/ jsx("div", {
|
|
150
|
+
style: gridStyle,
|
|
151
|
+
children: /*#__PURE__*/ jsx(ModeAwareField, {
|
|
152
|
+
field: field,
|
|
153
|
+
context: context,
|
|
154
|
+
customComponents: customComponents,
|
|
155
|
+
disabled: formDisabled || fieldState.disabled,
|
|
156
|
+
required: fieldState.required,
|
|
157
|
+
options: fieldState.options
|
|
158
|
+
})
|
|
159
|
+
});
|
|
160
|
+
const customEntry = isCustomField(field) ? customComponents[field.component] : void 0;
|
|
161
|
+
if (isCustomField(field) && customEntry) {
|
|
162
|
+
const CustomComponent = isFieldControlRegistration(customEntry) ? customEntry.component : customEntry;
|
|
157
163
|
return /*#__PURE__*/ jsx("div", {
|
|
158
164
|
style: gridStyle,
|
|
159
165
|
children: /*#__PURE__*/ jsx(Controller, {
|
|
@@ -177,222 +183,35 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
177
183
|
name: field.name,
|
|
178
184
|
control: control,
|
|
179
185
|
defaultValue: field.defaultValue,
|
|
180
|
-
render: ({ field: formField, fieldState: { error } })=>/*#__PURE__*/ jsx(
|
|
186
|
+
render: ({ field: formField, fieldState: { error } })=>/*#__PURE__*/ jsx(BuiltInField, {
|
|
181
187
|
field: field,
|
|
182
188
|
formField: formField,
|
|
183
189
|
error: error?.message,
|
|
184
190
|
disabled: formDisabled || fieldState.disabled,
|
|
185
191
|
required: fieldState.required,
|
|
186
|
-
options: fieldState.options
|
|
192
|
+
options: fieldState.options,
|
|
193
|
+
strings: context.strings?.boolean
|
|
187
194
|
})
|
|
188
195
|
})
|
|
189
196
|
});
|
|
190
197
|
}
|
|
191
|
-
function
|
|
198
|
+
function BuiltInField({ field, formField, error, disabled, required, options, strings }) {
|
|
199
|
+
const control = /*#__PURE__*/ jsx(FieldControl, {
|
|
200
|
+
field: field,
|
|
201
|
+
formField: formField,
|
|
202
|
+
options: options,
|
|
203
|
+
disabled: disabled,
|
|
204
|
+
invalid: !!error,
|
|
205
|
+
strings: strings
|
|
206
|
+
});
|
|
192
207
|
switch(field.type){
|
|
193
|
-
case 'text':
|
|
194
|
-
case 'email':
|
|
195
|
-
return /*#__PURE__*/ jsxs(FormField, {
|
|
196
|
-
children: [
|
|
197
|
-
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
198
|
-
htmlFor: field.name,
|
|
199
|
-
required: required,
|
|
200
|
-
tooltip: field.tooltip,
|
|
201
|
-
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
202
|
-
children: field.label
|
|
203
|
-
}),
|
|
204
|
-
/*#__PURE__*/ jsx(Input, {
|
|
205
|
-
id: field.name,
|
|
206
|
-
value: formField.value,
|
|
207
|
-
onChange: (e)=>formField.onChange(e.target.value),
|
|
208
|
-
onBlur: formField.onBlur,
|
|
209
|
-
name: formField.name,
|
|
210
|
-
ref: formField.ref,
|
|
211
|
-
type: field.type,
|
|
212
|
-
placeholder: field.placeholder,
|
|
213
|
-
disabled: disabled,
|
|
214
|
-
"aria-invalid": error ? true : void 0,
|
|
215
|
-
"aria-describedby": error ? `${field.name}-error` : void 0,
|
|
216
|
-
"aria-errormessage": error ? `${field.name}-error` : void 0,
|
|
217
|
-
"aria-label": field.ariaLabel
|
|
218
|
-
}),
|
|
219
|
-
/*#__PURE__*/ jsx(FormFieldDescription, {
|
|
220
|
-
children: field.description
|
|
221
|
-
}),
|
|
222
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
223
|
-
id: `${field.name}-error`,
|
|
224
|
-
children: error
|
|
225
|
-
})
|
|
226
|
-
]
|
|
227
|
-
});
|
|
228
|
-
case 'number':
|
|
229
|
-
return /*#__PURE__*/ jsxs(FormField, {
|
|
230
|
-
children: [
|
|
231
|
-
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
232
|
-
htmlFor: field.name,
|
|
233
|
-
required: required,
|
|
234
|
-
tooltip: field.tooltip,
|
|
235
|
-
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
236
|
-
children: field.label
|
|
237
|
-
}),
|
|
238
|
-
/*#__PURE__*/ jsx(Input, {
|
|
239
|
-
id: field.name,
|
|
240
|
-
value: formField.value,
|
|
241
|
-
onBlur: formField.onBlur,
|
|
242
|
-
name: formField.name,
|
|
243
|
-
ref: formField.ref,
|
|
244
|
-
type: "number",
|
|
245
|
-
min: field.min,
|
|
246
|
-
max: field.max,
|
|
247
|
-
step: field.step,
|
|
248
|
-
placeholder: field.placeholder,
|
|
249
|
-
disabled: disabled,
|
|
250
|
-
"aria-invalid": error ? true : void 0,
|
|
251
|
-
"aria-describedby": error ? `${field.name}-error` : void 0,
|
|
252
|
-
"aria-errormessage": error ? `${field.name}-error` : void 0,
|
|
253
|
-
onChange: (e)=>formField.onChange(parseFloat(e.target.value))
|
|
254
|
-
}),
|
|
255
|
-
/*#__PURE__*/ jsx(FormFieldDescription, {
|
|
256
|
-
children: field.description
|
|
257
|
-
}),
|
|
258
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
259
|
-
id: `${field.name}-error`,
|
|
260
|
-
children: error
|
|
261
|
-
})
|
|
262
|
-
]
|
|
263
|
-
});
|
|
264
|
-
case 'textarea':
|
|
265
|
-
return /*#__PURE__*/ jsxs(FormField, {
|
|
266
|
-
children: [
|
|
267
|
-
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
268
|
-
htmlFor: field.name,
|
|
269
|
-
required: required,
|
|
270
|
-
tooltip: field.tooltip,
|
|
271
|
-
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
272
|
-
children: field.label
|
|
273
|
-
}),
|
|
274
|
-
/*#__PURE__*/ jsx(Textarea, {
|
|
275
|
-
id: field.name,
|
|
276
|
-
value: formField.value,
|
|
277
|
-
onChange: (e)=>formField.onChange(e.target.value),
|
|
278
|
-
onBlur: formField.onBlur,
|
|
279
|
-
name: formField.name,
|
|
280
|
-
ref: formField.ref,
|
|
281
|
-
placeholder: field.placeholder,
|
|
282
|
-
disabled: disabled,
|
|
283
|
-
maxLength: field.maxLength,
|
|
284
|
-
"aria-invalid": error ? true : void 0,
|
|
285
|
-
"aria-describedby": error ? `${field.name}-error` : void 0,
|
|
286
|
-
"aria-errormessage": error ? `${field.name}-error` : void 0,
|
|
287
|
-
...null != field.minRows ? {
|
|
288
|
-
minRows: field.minRows
|
|
289
|
-
} : {
|
|
290
|
-
rows: field.rows || 4
|
|
291
|
-
}
|
|
292
|
-
}),
|
|
293
|
-
/*#__PURE__*/ jsx(FormFieldDescription, {
|
|
294
|
-
children: field.description
|
|
295
|
-
}),
|
|
296
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
297
|
-
id: `${field.name}-error`,
|
|
298
|
-
children: error
|
|
299
|
-
})
|
|
300
|
-
]
|
|
301
|
-
});
|
|
302
|
-
case 'select':
|
|
303
|
-
return /*#__PURE__*/ jsxs(FormField, {
|
|
304
|
-
children: [
|
|
305
|
-
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
306
|
-
htmlFor: field.name,
|
|
307
|
-
required: required,
|
|
308
|
-
tooltip: field.tooltip,
|
|
309
|
-
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
310
|
-
children: field.label
|
|
311
|
-
}),
|
|
312
|
-
/*#__PURE__*/ jsxs(Select, {
|
|
313
|
-
value: formField.value,
|
|
314
|
-
onValueChange: formField.onChange,
|
|
315
|
-
disabled: disabled,
|
|
316
|
-
children: [
|
|
317
|
-
/*#__PURE__*/ jsx(SelectTrigger, {
|
|
318
|
-
id: field.name,
|
|
319
|
-
"aria-label": field.label,
|
|
320
|
-
"aria-invalid": error ? true : void 0,
|
|
321
|
-
"aria-describedby": error ? `${field.name}-error` : void 0,
|
|
322
|
-
"aria-errormessage": error ? `${field.name}-error` : void 0,
|
|
323
|
-
children: /*#__PURE__*/ jsx(SelectValue, {
|
|
324
|
-
placeholder: field.placeholder || 'Select...'
|
|
325
|
-
})
|
|
326
|
-
}),
|
|
327
|
-
/*#__PURE__*/ jsx(SelectContent, {
|
|
328
|
-
children: options.map((option)=>/*#__PURE__*/ jsx(SelectItem, {
|
|
329
|
-
value: String(option.value),
|
|
330
|
-
disabled: 'disabled' in option ? Boolean(option.disabled) : false,
|
|
331
|
-
children: option.label
|
|
332
|
-
}, String(option.value)))
|
|
333
|
-
})
|
|
334
|
-
]
|
|
335
|
-
}),
|
|
336
|
-
/*#__PURE__*/ jsx(FormFieldDescription, {
|
|
337
|
-
children: field.description
|
|
338
|
-
}),
|
|
339
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
340
|
-
id: `${field.name}-error`,
|
|
341
|
-
children: error
|
|
342
|
-
})
|
|
343
|
-
]
|
|
344
|
-
});
|
|
345
|
-
case 'multiselect':
|
|
346
|
-
return /*#__PURE__*/ jsxs(FormField, {
|
|
347
|
-
children: [
|
|
348
|
-
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
349
|
-
htmlFor: field.name,
|
|
350
|
-
required: required,
|
|
351
|
-
tooltip: field.tooltip,
|
|
352
|
-
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
353
|
-
children: field.label
|
|
354
|
-
}),
|
|
355
|
-
/*#__PURE__*/ jsx(MultiSelect, {
|
|
356
|
-
id: field.name,
|
|
357
|
-
selected: formField.value || [],
|
|
358
|
-
onChange: formField.onChange,
|
|
359
|
-
options: options.map((opt)=>({
|
|
360
|
-
label: opt.label,
|
|
361
|
-
value: String(opt.value)
|
|
362
|
-
})),
|
|
363
|
-
disabled: disabled,
|
|
364
|
-
placeholder: field.placeholder || 'Select items...',
|
|
365
|
-
emptyMessage: field.emptyMessage ?? 'No items found.',
|
|
366
|
-
searchPlaceholder: field.searchPlaceholder ?? 'Search...',
|
|
367
|
-
maxSelected: field.maxSelected,
|
|
368
|
-
"aria-invalid": error ? true : void 0,
|
|
369
|
-
"aria-describedby": error ? `${field.name}-error` : void 0,
|
|
370
|
-
"aria-errormessage": error ? `${field.name}-error` : void 0
|
|
371
|
-
}),
|
|
372
|
-
/*#__PURE__*/ jsx(FormFieldDescription, {
|
|
373
|
-
children: field.description
|
|
374
|
-
}),
|
|
375
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
376
|
-
id: `${field.name}-error`,
|
|
377
|
-
children: error
|
|
378
|
-
})
|
|
379
|
-
]
|
|
380
|
-
});
|
|
381
208
|
case 'checkbox':
|
|
382
209
|
return /*#__PURE__*/ jsxs(FormField, {
|
|
383
210
|
children: [
|
|
384
211
|
/*#__PURE__*/ jsxs("div", {
|
|
385
212
|
className: "flex items-start space-x-2",
|
|
386
213
|
children: [
|
|
387
|
-
|
|
388
|
-
checked: true === formField.value,
|
|
389
|
-
onCheckedChange: (checked)=>formField.onChange(true === checked),
|
|
390
|
-
disabled: disabled,
|
|
391
|
-
"aria-invalid": error ? true : void 0,
|
|
392
|
-
"aria-describedby": error ? `${field.name}-error` : void 0,
|
|
393
|
-
"aria-errormessage": error ? `${field.name}-error` : void 0,
|
|
394
|
-
id: field.name
|
|
395
|
-
}),
|
|
214
|
+
control,
|
|
396
215
|
/*#__PURE__*/ jsxs("div", {
|
|
397
216
|
className: "space-y-1 leading-none",
|
|
398
217
|
children: [
|
|
@@ -437,15 +256,7 @@ function FieldByType({ field, formField, error, disabled, required, options }) {
|
|
|
437
256
|
})
|
|
438
257
|
]
|
|
439
258
|
}),
|
|
440
|
-
|
|
441
|
-
id: field.name,
|
|
442
|
-
checked: true === formField.value,
|
|
443
|
-
onCheckedChange: (checked)=>formField.onChange(true === checked),
|
|
444
|
-
disabled: disabled,
|
|
445
|
-
"aria-invalid": error ? true : void 0,
|
|
446
|
-
"aria-describedby": error ? `${field.name}-error` : void 0,
|
|
447
|
-
"aria-errormessage": error ? `${field.name}-error` : void 0
|
|
448
|
-
})
|
|
259
|
+
control
|
|
449
260
|
]
|
|
450
261
|
}),
|
|
451
262
|
/*#__PURE__*/ jsx(FormFieldError, {
|
|
@@ -454,40 +265,26 @@ function FieldByType({ field, formField, error, disabled, required, options }) {
|
|
|
454
265
|
})
|
|
455
266
|
]
|
|
456
267
|
});
|
|
457
|
-
case '
|
|
268
|
+
case 'slider':
|
|
458
269
|
return /*#__PURE__*/ jsxs(FormField, {
|
|
459
270
|
children: [
|
|
460
|
-
/*#__PURE__*/
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
children: options.map((option)=>/*#__PURE__*/ jsxs("div", {
|
|
476
|
-
className: "flex items-center space-x-2",
|
|
477
|
-
children: [
|
|
478
|
-
/*#__PURE__*/ jsx(RadioGroupItem, {
|
|
479
|
-
value: String(option.value),
|
|
480
|
-
id: `${field.name}-${option.value}`,
|
|
481
|
-
disabled: 'disabled' in option ? Boolean(option.disabled) : false
|
|
482
|
-
}),
|
|
483
|
-
/*#__PURE__*/ jsx(Label, {
|
|
484
|
-
variant: "muted",
|
|
485
|
-
htmlFor: `${field.name}-${option.value}`,
|
|
486
|
-
children: option.label
|
|
487
|
-
})
|
|
488
|
-
]
|
|
489
|
-
}, String(option.value)))
|
|
271
|
+
/*#__PURE__*/ jsxs("div", {
|
|
272
|
+
className: "flex justify-between",
|
|
273
|
+
children: [
|
|
274
|
+
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
275
|
+
id: `${field.name}-label`,
|
|
276
|
+
required: required,
|
|
277
|
+
tooltip: field.tooltip,
|
|
278
|
+
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
279
|
+
children: field.label
|
|
280
|
+
}),
|
|
281
|
+
/*#__PURE__*/ jsx(SliderValue, {
|
|
282
|
+
field: field,
|
|
283
|
+
value: formField.value
|
|
284
|
+
})
|
|
285
|
+
]
|
|
490
286
|
}),
|
|
287
|
+
control,
|
|
491
288
|
/*#__PURE__*/ jsx(FormFieldDescription, {
|
|
492
289
|
children: field.description
|
|
493
290
|
}),
|
|
@@ -497,98 +294,34 @@ function FieldByType({ field, formField, error, disabled, required, options }) {
|
|
|
497
294
|
})
|
|
498
295
|
]
|
|
499
296
|
});
|
|
500
|
-
case '
|
|
501
|
-
return /*#__PURE__*/ jsx(
|
|
297
|
+
case 'string-list':
|
|
298
|
+
return /*#__PURE__*/ jsx(StringListField, {
|
|
502
299
|
field: field,
|
|
503
|
-
|
|
300
|
+
inputRef: formField.ref,
|
|
301
|
+
value: formField.value,
|
|
302
|
+
onChange: formField.onChange,
|
|
303
|
+
onBlur: formField.onBlur,
|
|
504
304
|
error: error,
|
|
505
305
|
disabled: disabled,
|
|
506
306
|
required: required
|
|
507
307
|
});
|
|
508
|
-
case '
|
|
509
|
-
return
|
|
510
|
-
|
|
511
|
-
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
512
|
-
htmlFor: field.name,
|
|
513
|
-
required: required,
|
|
514
|
-
tooltip: field.tooltip,
|
|
515
|
-
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
516
|
-
children: field.label
|
|
517
|
-
}),
|
|
518
|
-
/*#__PURE__*/ jsx(DatePicker, {
|
|
519
|
-
id: field.name,
|
|
520
|
-
value: formField.value,
|
|
521
|
-
onValueChange: formField.onChange,
|
|
522
|
-
disabled: disabled,
|
|
523
|
-
placeholder: field.placeholder,
|
|
524
|
-
"aria-invalid": error ? true : void 0,
|
|
525
|
-
"aria-describedby": error ? `${field.name}-error` : void 0,
|
|
526
|
-
"aria-errormessage": error ? `${field.name}-error` : void 0
|
|
527
|
-
}),
|
|
528
|
-
/*#__PURE__*/ jsx(FormFieldDescription, {
|
|
529
|
-
children: field.description
|
|
530
|
-
}),
|
|
531
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
532
|
-
id: `${field.name}-error`,
|
|
533
|
-
children: error
|
|
534
|
-
})
|
|
535
|
-
]
|
|
536
|
-
});
|
|
537
|
-
case 'datetime':
|
|
538
|
-
return /*#__PURE__*/ jsxs(FormField, {
|
|
539
|
-
children: [
|
|
540
|
-
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
541
|
-
id: `${field.name}-label`,
|
|
542
|
-
required: required,
|
|
543
|
-
tooltip: field.tooltip,
|
|
544
|
-
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
545
|
-
children: field.label
|
|
546
|
-
}),
|
|
547
|
-
/*#__PURE__*/ jsx(DateTimePicker, {
|
|
548
|
-
"aria-labelledby": `${field.name}-label`,
|
|
549
|
-
"aria-invalid": error ? true : void 0,
|
|
550
|
-
"aria-describedby": error ? `${field.name}-error` : void 0,
|
|
551
|
-
"aria-errormessage": error ? `${field.name}-error` : void 0,
|
|
552
|
-
value: formField.value,
|
|
553
|
-
onValueChange: formField.onChange,
|
|
554
|
-
disabled: disabled,
|
|
555
|
-
placeholder: field.placeholder,
|
|
556
|
-
use12Hour: field.use12Hour
|
|
557
|
-
}),
|
|
558
|
-
/*#__PURE__*/ jsx(FormFieldDescription, {
|
|
559
|
-
children: field.description
|
|
560
|
-
}),
|
|
561
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
562
|
-
id: `${field.name}-error`,
|
|
563
|
-
children: error
|
|
564
|
-
})
|
|
565
|
-
]
|
|
566
|
-
});
|
|
567
|
-
case 'file':
|
|
308
|
+
case 'custom':
|
|
309
|
+
return null;
|
|
310
|
+
default:
|
|
568
311
|
return /*#__PURE__*/ jsxs(FormField, {
|
|
569
312
|
children: [
|
|
570
313
|
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
571
|
-
|
|
314
|
+
...'radio' === field.type || 'boolean' === field.type || 'datetime' === field.type ? {
|
|
315
|
+
id: `${field.name}-label`
|
|
316
|
+
} : {
|
|
317
|
+
htmlFor: field.name
|
|
318
|
+
},
|
|
572
319
|
required: required,
|
|
573
320
|
tooltip: field.tooltip,
|
|
574
321
|
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
575
322
|
children: field.label
|
|
576
323
|
}),
|
|
577
|
-
|
|
578
|
-
id: field.name,
|
|
579
|
-
ariaLabel: field.ariaLabel ?? field.label,
|
|
580
|
-
"aria-invalid": error ? true : void 0,
|
|
581
|
-
"aria-describedby": error ? `${field.name}-error` : void 0,
|
|
582
|
-
"aria-errormessage": error ? `${field.name}-error` : void 0,
|
|
583
|
-
accept: field.accept,
|
|
584
|
-
multiple: field.multiple,
|
|
585
|
-
disabled: disabled,
|
|
586
|
-
maxSize: field.maxSize,
|
|
587
|
-
showPreview: field.showPreview,
|
|
588
|
-
onFilesChange: (files)=>{
|
|
589
|
-
formField.onChange(field.multiple ? files : files[0]);
|
|
590
|
-
}
|
|
591
|
-
}),
|
|
324
|
+
control,
|
|
592
325
|
/*#__PURE__*/ jsx(FormFieldDescription, {
|
|
593
326
|
children: field.description
|
|
594
327
|
}),
|
|
@@ -598,89 +331,13 @@ function FieldByType({ field, formField, error, disabled, required, options }) {
|
|
|
598
331
|
})
|
|
599
332
|
]
|
|
600
333
|
});
|
|
601
|
-
case 'string-list':
|
|
602
|
-
return /*#__PURE__*/ jsx(StringListField, {
|
|
603
|
-
field: field,
|
|
604
|
-
inputRef: formField.ref,
|
|
605
|
-
value: formField.value,
|
|
606
|
-
onChange: formField.onChange,
|
|
607
|
-
onBlur: formField.onBlur,
|
|
608
|
-
error: error,
|
|
609
|
-
disabled: disabled,
|
|
610
|
-
required: required
|
|
611
|
-
});
|
|
612
|
-
default:
|
|
613
|
-
return null;
|
|
614
334
|
}
|
|
615
335
|
}
|
|
616
|
-
function
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
useEffect(()=>{
|
|
622
|
-
if (resolvedMax === prevMaxRef.current) return;
|
|
623
|
-
prevMaxRef.current = resolvedMax;
|
|
624
|
-
const v = formField.value;
|
|
625
|
-
if ('number' == typeof v && v > resolvedMax) formField.onChange(resolvedMax);
|
|
626
|
-
}, [
|
|
627
|
-
resolvedMax,
|
|
628
|
-
formField.value,
|
|
629
|
-
formField.onChange
|
|
630
|
-
]);
|
|
631
|
-
const displayValue = (()=>{
|
|
632
|
-
const v = formField.value;
|
|
633
|
-
if ('number' == typeof v) return Math.min(v, resolvedMax);
|
|
634
|
-
return v;
|
|
635
|
-
})();
|
|
636
|
-
return /*#__PURE__*/ jsxs(FormField, {
|
|
637
|
-
children: [
|
|
638
|
-
/*#__PURE__*/ jsxs("div", {
|
|
639
|
-
className: "flex justify-between",
|
|
640
|
-
children: [
|
|
641
|
-
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
642
|
-
id: `${field.name}-label`,
|
|
643
|
-
required: required,
|
|
644
|
-
tooltip: field.tooltip,
|
|
645
|
-
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
646
|
-
children: field.label
|
|
647
|
-
}),
|
|
648
|
-
/*#__PURE__*/ jsx("span", {
|
|
649
|
-
className: "text-sm text-muted-foreground",
|
|
650
|
-
children: displayValue
|
|
651
|
-
})
|
|
652
|
-
]
|
|
653
|
-
}),
|
|
654
|
-
/*#__PURE__*/ jsx(Slider, {
|
|
655
|
-
"aria-labelledby": `${field.name}-label`,
|
|
656
|
-
"aria-invalid": error ? true : void 0,
|
|
657
|
-
"aria-describedby": error ? `${field.name}-error` : void 0,
|
|
658
|
-
"aria-errormessage": error ? `${field.name}-error` : void 0,
|
|
659
|
-
value: [
|
|
660
|
-
displayValue ?? field.min ?? 0
|
|
661
|
-
],
|
|
662
|
-
onValueChange: (values)=>formField.onChange(values[0]),
|
|
663
|
-
min: field.min || 0,
|
|
664
|
-
max: resolvedMax,
|
|
665
|
-
step: field.step || 1,
|
|
666
|
-
disabled: disabled
|
|
667
|
-
}),
|
|
668
|
-
/*#__PURE__*/ jsx(FormFieldDescription, {
|
|
669
|
-
children: field.description
|
|
670
|
-
}),
|
|
671
|
-
/*#__PURE__*/ jsx(FormFieldError, {
|
|
672
|
-
id: `${field.name}-error`,
|
|
673
|
-
children: error
|
|
674
|
-
})
|
|
675
|
-
]
|
|
336
|
+
function SliderValue({ field, value }) {
|
|
337
|
+
const displayValue = clampSliderValue(value, useSliderMax(field));
|
|
338
|
+
return /*#__PURE__*/ jsx("span", {
|
|
339
|
+
className: "text-sm text-muted-foreground",
|
|
340
|
+
children: displayValue
|
|
676
341
|
});
|
|
677
342
|
}
|
|
678
|
-
function resolveSliderMax(field, watchedValue) {
|
|
679
|
-
if (field.maxRef) {
|
|
680
|
-
if ('number' == typeof watchedValue && Number.isFinite(watchedValue) && watchedValue > 0) return watchedValue;
|
|
681
|
-
if ('number' == typeof field.maxRef.fallback) return field.maxRef.fallback;
|
|
682
|
-
}
|
|
683
|
-
if ('number' == typeof field.max) return field.max;
|
|
684
|
-
return 100;
|
|
685
|
-
}
|
|
686
343
|
export { FormFieldRenderer };
|
|
@@ -116,6 +116,12 @@ const FIELD_TYPE_METADATA = [
|
|
|
116
116
|
category: 'Boolean',
|
|
117
117
|
description: 'Toggle switch'
|
|
118
118
|
},
|
|
119
|
+
{
|
|
120
|
+
value: 'boolean',
|
|
121
|
+
label: 'True / False',
|
|
122
|
+
category: 'Boolean',
|
|
123
|
+
description: 'True, false or not set'
|
|
124
|
+
},
|
|
119
125
|
{
|
|
120
126
|
value: 'slider',
|
|
121
127
|
label: 'Slider',
|
|
@@ -1794,7 +1800,7 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
|
|
|
1794
1800
|
};
|
|
1795
1801
|
const targetField = allFields.find((f)=>f.name === cond.field);
|
|
1796
1802
|
const isNumericField = targetField?.type === 'number' || targetField?.type === 'slider';
|
|
1797
|
-
const isBooleanField = targetField?.type === 'checkbox' || targetField?.type === 'switch';
|
|
1803
|
+
const isBooleanField = targetField?.type === 'checkbox' || targetField?.type === 'switch' || targetField?.type === 'boolean';
|
|
1798
1804
|
const parseValue = (val)=>{
|
|
1799
1805
|
if (isBooleanField) {
|
|
1800
1806
|
if ('true' === val.toLowerCase()) return true;
|
|
@@ -88,6 +88,12 @@ const FIELD_TYPE_METADATA = [
|
|
|
88
88
|
category: 'Boolean',
|
|
89
89
|
description: 'Toggle switch'
|
|
90
90
|
},
|
|
91
|
+
{
|
|
92
|
+
value: 'boolean',
|
|
93
|
+
label: 'True / False',
|
|
94
|
+
category: 'Boolean',
|
|
95
|
+
description: 'True, false or not set'
|
|
96
|
+
},
|
|
91
97
|
{
|
|
92
98
|
value: 'slider',
|
|
93
99
|
label: 'Slider',
|
|
@@ -1766,7 +1772,7 @@ function RulesEditor({ rules = [], onChange, allFields, requiredMessage, onRequi
|
|
|
1766
1772
|
};
|
|
1767
1773
|
const targetField = allFields.find((f)=>f.name === cond.field);
|
|
1768
1774
|
const isNumericField = targetField?.type === 'number' || targetField?.type === 'slider';
|
|
1769
|
-
const isBooleanField = targetField?.type === 'checkbox' || targetField?.type === 'switch';
|
|
1775
|
+
const isBooleanField = targetField?.type === 'checkbox' || targetField?.type === 'switch' || targetField?.type === 'boolean';
|
|
1770
1776
|
const parseValue = (val)=>{
|
|
1771
1777
|
if (isBooleanField) {
|
|
1772
1778
|
if ('true' === val.toLowerCase()) return true;
|