@uipath/apollo-wind 2.63.0 → 2.65.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/aria-ids.cjs +38 -0
- package/dist/components/forms/aria-ids.d.ts +2 -0
- package/dist/components/forms/aria-ids.js +4 -0
- package/dist/components/forms/demo-mocks.cjs +0 -448
- package/dist/components/forms/demo-mocks.js +0 -448
- package/dist/components/forms/field-control.cjs +21 -17
- package/dist/components/forms/field-control.d.ts +3 -1
- package/dist/components/forms/field-control.js +21 -17
- package/dist/components/forms/field-renderer.cjs +65 -37
- package/dist/components/forms/field-renderer.js +66 -38
- package/dist/components/forms/form-designer.cjs +204 -3
- package/dist/components/forms/form-designer.js +204 -3
- package/dist/components/forms/form-examples.cjs +3 -190
- package/dist/components/forms/form-examples.d.ts +0 -10
- package/dist/components/forms/form-examples.js +3 -184
- package/dist/components/forms/form-schema.d.ts +6 -0
- package/dist/components/forms/metadata-form.cjs +9 -1
- package/dist/components/forms/metadata-form.d.ts +8 -1
- package/dist/components/forms/metadata-form.js +9 -1
- package/dist/components/forms/mode-aware-field.cjs +11 -6
- package/dist/components/forms/mode-aware-field.d.ts +2 -0
- package/dist/components/forms/mode-aware-field.js +11 -6
- package/dist/components/forms/string-list-field.cjs +5 -4
- package/dist/components/forms/string-list-field.d.ts +4 -2
- package/dist/components/forms/string-list-field.js +5 -4
- package/dist/components/ui/index.cjs +77 -66
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/components/ui/json-tree-view/JsonTree.types.d.ts +13 -0
- package/dist/components/ui/json-tree-view/JsonTreeRow.cjs +2 -1
- package/dist/components/ui/json-tree-view/JsonTreeRow.js +2 -1
- package/dist/components/ui/json-tree-view/JsonTypeBadge.cjs +43 -6
- package/dist/components/ui/json-tree-view/JsonTypeBadge.d.ts +6 -3
- package/dist/components/ui/json-tree-view/JsonTypeBadge.js +44 -7
- package/dist/components/ui/json-tree-view/index.d.ts +1 -1
- package/dist/components/ui/json-tree-view/strings.cjs +1 -0
- package/dist/components/ui/json-tree-view/strings.d.ts +10 -2
- package/dist/components/ui/json-tree-view/strings.js +1 -0
- package/dist/components/ui/prompt-value-control.cjs +3 -1
- package/dist/components/ui/prompt-value-control.d.ts +5 -0
- package/dist/components/ui/prompt-value-control.js +3 -1
- package/dist/components/ui/sidebar/index.cjs +113 -0
- package/dist/components/ui/sidebar/index.d.ts +10 -0
- package/dist/components/ui/sidebar/index.js +7 -0
- package/dist/components/ui/sidebar/sidebar-context.cjs +151 -0
- package/dist/components/ui/sidebar/sidebar-context.d.ts +39 -0
- package/dist/components/ui/sidebar/sidebar-context.js +108 -0
- package/dist/components/ui/sidebar/sidebar-group.cjs +87 -0
- package/dist/components/ui/sidebar/sidebar-group.d.ts +10 -0
- package/dist/components/ui/sidebar/sidebar-group.js +44 -0
- package/dist/components/ui/sidebar/sidebar-layout.cjs +92 -0
- package/dist/components/ui/sidebar/sidebar-layout.d.ts +7 -0
- package/dist/components/ui/sidebar/sidebar-layout.js +46 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub.cjs +79 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub.d.ts +11 -0
- package/dist/components/ui/sidebar/sidebar-menu-sub.js +39 -0
- package/dist/components/ui/sidebar/sidebar-menu.cjs +185 -0
- package/dist/components/ui/sidebar/sidebar-menu.d.ts +26 -0
- package/dist/components/ui/sidebar/sidebar-menu.js +133 -0
- package/dist/components/ui/sidebar/sidebar.cjs +220 -0
- package/dist/components/ui/sidebar/sidebar.d.ts +22 -0
- package/dist/components/ui/sidebar/sidebar.js +177 -0
- package/dist/components/ui/variable-value-control.cjs +3 -1
- package/dist/components/ui/variable-value-control.d.ts +5 -0
- package/dist/components/ui/variable-value-control.js +3 -1
- package/dist/index.cjs +94 -18
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/styles.css +647 -0
- package/package.json +1 -1
- package/dist/templates/Forms/form-builder-example.d.ts +0 -1
|
@@ -14,6 +14,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from ".
|
|
|
14
14
|
import { Slider } from "../ui/slider.js";
|
|
15
15
|
import { Switch } from "../ui/switch.js";
|
|
16
16
|
import { Textarea } from "../ui/textarea.js";
|
|
17
|
+
import { joinIds } from "./aria-ids.js";
|
|
17
18
|
import { LiteralValueContext } from "./literal-value-context.js";
|
|
18
19
|
import { StringListControl } from "./string-list-field.js";
|
|
19
20
|
const FIELD_CONTROL_GEOMETRY = {
|
|
@@ -80,8 +81,9 @@ const FIELD_CONTROL_GEOMETRY = {
|
|
|
80
81
|
};
|
|
81
82
|
const NO_OPTIONS = [];
|
|
82
83
|
const NO_SELECTION = [];
|
|
83
|
-
function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false, invalid = false, strings }) {
|
|
84
|
+
function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false, invalid = false, strings, describedBy }) {
|
|
84
85
|
const errorId = invalid ? `${field.name}-error` : void 0;
|
|
86
|
+
const describedById = joinIds(errorId, describedBy);
|
|
85
87
|
const { onChange } = formField;
|
|
86
88
|
const multipleFiles = 'file' === field.type && field.multiple;
|
|
87
89
|
const onTextChange = useCallback((event)=>onChange(event.target.value), [
|
|
@@ -117,7 +119,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
117
119
|
placeholder: field.placeholder,
|
|
118
120
|
disabled: disabled,
|
|
119
121
|
"aria-invalid": invalid || void 0,
|
|
120
|
-
"aria-describedby":
|
|
122
|
+
"aria-describedby": describedById,
|
|
121
123
|
"aria-errormessage": errorId,
|
|
122
124
|
"aria-label": field.ariaLabel
|
|
123
125
|
});
|
|
@@ -135,7 +137,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
135
137
|
placeholder: field.placeholder,
|
|
136
138
|
disabled: disabled,
|
|
137
139
|
"aria-invalid": invalid || void 0,
|
|
138
|
-
"aria-describedby":
|
|
140
|
+
"aria-describedby": describedById,
|
|
139
141
|
"aria-errormessage": errorId,
|
|
140
142
|
onChange: onNumberChange
|
|
141
143
|
});
|
|
@@ -151,7 +153,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
151
153
|
disabled: disabled,
|
|
152
154
|
maxLength: field.maxLength,
|
|
153
155
|
"aria-invalid": invalid || void 0,
|
|
154
|
-
"aria-describedby":
|
|
156
|
+
"aria-describedby": describedById,
|
|
155
157
|
"aria-errormessage": errorId,
|
|
156
158
|
...null != field.minRows ? {
|
|
157
159
|
minRows: field.minRows
|
|
@@ -169,7 +171,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
169
171
|
id: field.name,
|
|
170
172
|
"aria-label": field.label,
|
|
171
173
|
"aria-invalid": invalid || void 0,
|
|
172
|
-
"aria-describedby":
|
|
174
|
+
"aria-describedby": describedById,
|
|
173
175
|
"aria-errormessage": errorId,
|
|
174
176
|
children: /*#__PURE__*/ jsx(SelectValue, {
|
|
175
177
|
placeholder: field.placeholder || 'Select...'
|
|
@@ -196,7 +198,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
196
198
|
searchPlaceholder: field.searchPlaceholder ?? 'Search...',
|
|
197
199
|
maxSelected: field.maxSelected,
|
|
198
200
|
"aria-invalid": invalid || void 0,
|
|
199
|
-
"aria-describedby":
|
|
201
|
+
"aria-describedby": describedById,
|
|
200
202
|
"aria-errormessage": errorId
|
|
201
203
|
});
|
|
202
204
|
case 'checkbox':
|
|
@@ -205,7 +207,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
205
207
|
onCheckedChange: onCheckedChange,
|
|
206
208
|
disabled: disabled,
|
|
207
209
|
"aria-invalid": invalid || void 0,
|
|
208
|
-
"aria-describedby":
|
|
210
|
+
"aria-describedby": describedById,
|
|
209
211
|
"aria-errormessage": errorId,
|
|
210
212
|
id: field.name
|
|
211
213
|
});
|
|
@@ -217,7 +219,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
217
219
|
onBlur: formField.onBlur,
|
|
218
220
|
disabled: disabled,
|
|
219
221
|
"aria-invalid": invalid || void 0,
|
|
220
|
-
"aria-describedby":
|
|
222
|
+
"aria-describedby": describedById,
|
|
221
223
|
"aria-errormessage": errorId,
|
|
222
224
|
strings: strings
|
|
223
225
|
});
|
|
@@ -228,7 +230,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
228
230
|
onCheckedChange: onCheckedChange,
|
|
229
231
|
disabled: disabled,
|
|
230
232
|
"aria-invalid": invalid || void 0,
|
|
231
|
-
"aria-describedby":
|
|
233
|
+
"aria-describedby": describedById,
|
|
232
234
|
"aria-errormessage": errorId
|
|
233
235
|
});
|
|
234
236
|
case 'radio':
|
|
@@ -238,7 +240,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
238
240
|
onValueChange: formField.onChange,
|
|
239
241
|
disabled: disabled,
|
|
240
242
|
"aria-invalid": invalid || void 0,
|
|
241
|
-
"aria-describedby":
|
|
243
|
+
"aria-describedby": describedById,
|
|
242
244
|
"aria-errormessage": errorId,
|
|
243
245
|
children: options.map((option)=>/*#__PURE__*/ jsxs("div", {
|
|
244
246
|
className: "flex items-center space-x-2",
|
|
@@ -262,7 +264,8 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
262
264
|
formField: formField,
|
|
263
265
|
disabled: disabled,
|
|
264
266
|
invalid: invalid,
|
|
265
|
-
errorId: errorId
|
|
267
|
+
errorId: errorId,
|
|
268
|
+
describedById: describedById
|
|
266
269
|
});
|
|
267
270
|
case 'date':
|
|
268
271
|
return /*#__PURE__*/ jsx(DatePicker, {
|
|
@@ -272,14 +275,14 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
272
275
|
disabled: disabled,
|
|
273
276
|
placeholder: field.placeholder,
|
|
274
277
|
"aria-invalid": invalid || void 0,
|
|
275
|
-
"aria-describedby":
|
|
278
|
+
"aria-describedby": describedById,
|
|
276
279
|
"aria-errormessage": errorId
|
|
277
280
|
});
|
|
278
281
|
case 'datetime':
|
|
279
282
|
return /*#__PURE__*/ jsx(DateTimePicker, {
|
|
280
283
|
"aria-labelledby": `${field.name}-label`,
|
|
281
284
|
"aria-invalid": invalid || void 0,
|
|
282
|
-
"aria-describedby":
|
|
285
|
+
"aria-describedby": describedById,
|
|
283
286
|
"aria-errormessage": errorId,
|
|
284
287
|
value: formField.value,
|
|
285
288
|
onValueChange: formField.onChange,
|
|
@@ -292,7 +295,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
292
295
|
id: field.name,
|
|
293
296
|
ariaLabel: field.ariaLabel ?? field.label,
|
|
294
297
|
"aria-invalid": invalid || void 0,
|
|
295
|
-
"aria-describedby":
|
|
298
|
+
"aria-describedby": describedById,
|
|
296
299
|
"aria-errormessage": errorId,
|
|
297
300
|
accept: field.accept,
|
|
298
301
|
multiple: field.multiple,
|
|
@@ -309,13 +312,14 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
309
312
|
onChange: formField.onChange,
|
|
310
313
|
onBlur: formField.onBlur,
|
|
311
314
|
invalid: invalid,
|
|
312
|
-
disabled: disabled
|
|
315
|
+
disabled: disabled,
|
|
316
|
+
ariaDescribedBy: describedById
|
|
313
317
|
});
|
|
314
318
|
default:
|
|
315
319
|
return null;
|
|
316
320
|
}
|
|
317
321
|
}
|
|
318
|
-
function SliderControl({ field, formField, disabled, invalid, errorId }) {
|
|
322
|
+
function SliderControl({ field, formField, disabled, invalid, errorId, describedById }) {
|
|
319
323
|
const resolvedMax = useSliderMax(field);
|
|
320
324
|
const prevMaxRef = useRef(resolvedMax);
|
|
321
325
|
useEffect(()=>{
|
|
@@ -342,7 +346,7 @@ function SliderControl({ field, formField, disabled, invalid, errorId }) {
|
|
|
342
346
|
return /*#__PURE__*/ jsx(Slider, {
|
|
343
347
|
"aria-labelledby": `${field.name}-label`,
|
|
344
348
|
"aria-invalid": invalid || void 0,
|
|
345
|
-
"aria-describedby":
|
|
349
|
+
"aria-describedby": describedById,
|
|
346
350
|
"aria-errormessage": errorId,
|
|
347
351
|
value: sliderValue,
|
|
348
352
|
onValueChange: onValueChange,
|
|
@@ -31,6 +31,7 @@ const external_react_namespaceObject = require("react");
|
|
|
31
31
|
const external_react_hook_form_namespaceObject = require("react-hook-form");
|
|
32
32
|
const form_field_cjs_namespaceObject = require("../ui/form-field.cjs");
|
|
33
33
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
34
|
+
const external_aria_ids_cjs_namespaceObject = require("./aria-ids.cjs");
|
|
34
35
|
const external_data_fetcher_cjs_namespaceObject = require("./data-fetcher.cjs");
|
|
35
36
|
const external_field_control_cjs_namespaceObject = require("./field-control.cjs");
|
|
36
37
|
const external_form_schema_cjs_namespaceObject = require("./form-schema.cjs");
|
|
@@ -40,6 +41,7 @@ const external_string_list_field_cjs_namespaceObject = require("./string-list-fi
|
|
|
40
41
|
const external_value_modes_cjs_namespaceObject = require("./value-modes.cjs");
|
|
41
42
|
function FormFieldRenderer({ field, context, customComponents, disabled: formDisabled = false }) {
|
|
42
43
|
const { control, watch, getValues } = (0, external_react_hook_form_namespaceObject.useFormContext)();
|
|
44
|
+
const changedNoteId = `${(0, external_react_namespaceObject.useId)()}-changed`;
|
|
43
45
|
const contextRef = (0, external_react_namespaceObject.useRef)(context);
|
|
44
46
|
contextRef.current = context;
|
|
45
47
|
const readValues = (0, external_react_namespaceObject.useCallback)(()=>(0, external_value_modes_cjs_namespaceObject.literalValues)(getValues(), contextRef.current.schema, contextRef.current.valueModes?.codecs), [
|
|
@@ -174,63 +176,88 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
174
176
|
const gridStyle = {
|
|
175
177
|
gridColumn: `span ${gridSpan}`
|
|
176
178
|
};
|
|
177
|
-
|
|
179
|
+
const isChanged = context.changedFields?.has(field.name) ?? false;
|
|
180
|
+
const wrapperProps = {
|
|
178
181
|
style: gridStyle,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
className: isChanged ? '-ml-2 rounded-md border-l-2 border-warning bg-warning-background/30 pl-1.5' : void 0,
|
|
183
|
+
'data-field-name': field.name,
|
|
184
|
+
'data-changed': isChanged || void 0
|
|
185
|
+
};
|
|
186
|
+
const changedNote = isChanged ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
|
|
187
|
+
id: changedNoteId,
|
|
188
|
+
className: "sr-only",
|
|
189
|
+
children: context.changedFieldLabel ?? 'Changed'
|
|
190
|
+
}) : null;
|
|
191
|
+
if (field.valueModes || field.headerActions || field.menuActions || field.badge) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
192
|
+
...wrapperProps,
|
|
193
|
+
children: [
|
|
194
|
+
changedNote,
|
|
195
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_mode_aware_field_cjs_namespaceObject.ModeAwareField, {
|
|
196
|
+
field: field,
|
|
197
|
+
context: context,
|
|
198
|
+
customComponents: customComponents,
|
|
199
|
+
disabled: formDisabled || fieldState.disabled,
|
|
200
|
+
required: fieldState.required,
|
|
201
|
+
options: fieldState.options,
|
|
202
|
+
describedBy: isChanged ? changedNoteId : void 0
|
|
203
|
+
})
|
|
204
|
+
]
|
|
187
205
|
});
|
|
188
206
|
const customEntry = (0, external_form_schema_cjs_namespaceObject.isCustomField)(field) ? customComponents[field.component] : void 0;
|
|
189
207
|
if ((0, external_form_schema_cjs_namespaceObject.isCustomField)(field) && customEntry) {
|
|
190
208
|
const CustomComponent = (0, external_value_modes_cjs_namespaceObject.isFieldControlRegistration)(customEntry) ? customEntry.component : customEntry;
|
|
191
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.
|
|
192
|
-
|
|
193
|
-
children:
|
|
209
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
210
|
+
...wrapperProps,
|
|
211
|
+
children: [
|
|
212
|
+
changedNote,
|
|
213
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_hook_form_namespaceObject.Controller, {
|
|
214
|
+
name: field.name,
|
|
215
|
+
control: control,
|
|
216
|
+
defaultValue: field.defaultValue,
|
|
217
|
+
render: ({ field: { ref: _ref, ...formField }, fieldState: { error } })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CustomComponent, {
|
|
218
|
+
...formField,
|
|
219
|
+
...field.componentProps,
|
|
220
|
+
field: field,
|
|
221
|
+
disabled: formDisabled || fieldState.disabled,
|
|
222
|
+
required: fieldState.required,
|
|
223
|
+
error: error?.message,
|
|
224
|
+
"aria-describedby": (0, external_aria_ids_cjs_namespaceObject.joinIds)(field.componentProps?.['aria-describedby'], isChanged && changedNoteId)
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
]
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
231
|
+
...wrapperProps,
|
|
232
|
+
children: [
|
|
233
|
+
changedNote,
|
|
234
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_hook_form_namespaceObject.Controller, {
|
|
194
235
|
name: field.name,
|
|
195
236
|
control: control,
|
|
196
237
|
defaultValue: field.defaultValue,
|
|
197
|
-
render: ({ field:
|
|
198
|
-
...formField,
|
|
199
|
-
...field.componentProps,
|
|
238
|
+
render: ({ field: formField, fieldState: { error } })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(BuiltInField, {
|
|
200
239
|
field: field,
|
|
240
|
+
formField: formField,
|
|
241
|
+
error: error?.message,
|
|
201
242
|
disabled: formDisabled || fieldState.disabled,
|
|
202
243
|
required: fieldState.required,
|
|
203
|
-
|
|
244
|
+
options: fieldState.options,
|
|
245
|
+
strings: context.strings?.boolean,
|
|
246
|
+
changedNoteId: isChanged ? changedNoteId : void 0
|
|
204
247
|
})
|
|
205
248
|
})
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
209
|
-
style: gridStyle,
|
|
210
|
-
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_react_hook_form_namespaceObject.Controller, {
|
|
211
|
-
name: field.name,
|
|
212
|
-
control: control,
|
|
213
|
-
defaultValue: field.defaultValue,
|
|
214
|
-
render: ({ field: formField, fieldState: { error } })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(BuiltInField, {
|
|
215
|
-
field: field,
|
|
216
|
-
formField: formField,
|
|
217
|
-
error: error?.message,
|
|
218
|
-
disabled: formDisabled || fieldState.disabled,
|
|
219
|
-
required: fieldState.required,
|
|
220
|
-
options: fieldState.options,
|
|
221
|
-
strings: context.strings?.boolean
|
|
222
|
-
})
|
|
223
|
-
})
|
|
249
|
+
]
|
|
224
250
|
});
|
|
225
251
|
}
|
|
226
|
-
function BuiltInField({ field, formField, error, disabled, required, options, strings }) {
|
|
252
|
+
function BuiltInField({ field, formField, error, disabled, required, options, strings, changedNoteId }) {
|
|
227
253
|
const control = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_field_control_cjs_namespaceObject.FieldControl, {
|
|
228
254
|
field: field,
|
|
229
255
|
formField: formField,
|
|
230
256
|
options: options,
|
|
231
257
|
disabled: disabled,
|
|
232
258
|
invalid: !!error,
|
|
233
|
-
strings: strings
|
|
259
|
+
strings: strings,
|
|
260
|
+
describedBy: changedNoteId
|
|
234
261
|
});
|
|
235
262
|
switch(field.type){
|
|
236
263
|
case 'checkbox':
|
|
@@ -331,7 +358,8 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
331
358
|
onBlur: formField.onBlur,
|
|
332
359
|
error: error,
|
|
333
360
|
disabled: disabled,
|
|
334
|
-
required: required
|
|
361
|
+
required: required,
|
|
362
|
+
ariaDescribedBy: (0, external_aria_ids_cjs_namespaceObject.joinIds)(error && `${field.name}-error`, changedNoteId)
|
|
335
363
|
});
|
|
336
364
|
case 'custom':
|
|
337
365
|
return null;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { Controller, useFormContext } from "react-hook-form";
|
|
4
4
|
import { FormField, FormFieldDescription, FormFieldError, FormFieldLabel } from "../ui/form-field.js";
|
|
5
5
|
import { deepEqual } from "../../lib/index.js";
|
|
6
|
+
import { joinIds } from "./aria-ids.js";
|
|
6
7
|
import { DataFetcher } from "./data-fetcher.js";
|
|
7
8
|
import { FieldControl, clampSliderValue, useSliderMax } from "./field-control.js";
|
|
8
9
|
import { hasOptions, isCustomField } from "./form-schema.js";
|
|
@@ -12,6 +13,7 @@ import { StringListField } from "./string-list-field.js";
|
|
|
12
13
|
import { isFieldControlRegistration, literalValues } from "./value-modes.js";
|
|
13
14
|
function FormFieldRenderer({ field, context, customComponents, disabled: formDisabled = false }) {
|
|
14
15
|
const { control, watch, getValues } = useFormContext();
|
|
16
|
+
const changedNoteId = `${useId()}-changed`;
|
|
15
17
|
const contextRef = useRef(context);
|
|
16
18
|
contextRef.current = context;
|
|
17
19
|
const readValues = useCallback(()=>literalValues(getValues(), contextRef.current.schema, contextRef.current.valueModes?.codecs), [
|
|
@@ -146,63 +148,88 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
146
148
|
const gridStyle = {
|
|
147
149
|
gridColumn: `span ${gridSpan}`
|
|
148
150
|
};
|
|
149
|
-
|
|
151
|
+
const isChanged = context.changedFields?.has(field.name) ?? false;
|
|
152
|
+
const wrapperProps = {
|
|
150
153
|
style: gridStyle,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
className: isChanged ? '-ml-2 rounded-md border-l-2 border-warning bg-warning-background/30 pl-1.5' : void 0,
|
|
155
|
+
'data-field-name': field.name,
|
|
156
|
+
'data-changed': isChanged || void 0
|
|
157
|
+
};
|
|
158
|
+
const changedNote = isChanged ? /*#__PURE__*/ jsx("span", {
|
|
159
|
+
id: changedNoteId,
|
|
160
|
+
className: "sr-only",
|
|
161
|
+
children: context.changedFieldLabel ?? 'Changed'
|
|
162
|
+
}) : null;
|
|
163
|
+
if (field.valueModes || field.headerActions || field.menuActions || field.badge) return /*#__PURE__*/ jsxs("div", {
|
|
164
|
+
...wrapperProps,
|
|
165
|
+
children: [
|
|
166
|
+
changedNote,
|
|
167
|
+
/*#__PURE__*/ jsx(ModeAwareField, {
|
|
168
|
+
field: field,
|
|
169
|
+
context: context,
|
|
170
|
+
customComponents: customComponents,
|
|
171
|
+
disabled: formDisabled || fieldState.disabled,
|
|
172
|
+
required: fieldState.required,
|
|
173
|
+
options: fieldState.options,
|
|
174
|
+
describedBy: isChanged ? changedNoteId : void 0
|
|
175
|
+
})
|
|
176
|
+
]
|
|
159
177
|
});
|
|
160
178
|
const customEntry = isCustomField(field) ? customComponents[field.component] : void 0;
|
|
161
179
|
if (isCustomField(field) && customEntry) {
|
|
162
180
|
const CustomComponent = isFieldControlRegistration(customEntry) ? customEntry.component : customEntry;
|
|
163
|
-
return /*#__PURE__*/
|
|
164
|
-
|
|
165
|
-
children:
|
|
181
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
182
|
+
...wrapperProps,
|
|
183
|
+
children: [
|
|
184
|
+
changedNote,
|
|
185
|
+
/*#__PURE__*/ jsx(Controller, {
|
|
186
|
+
name: field.name,
|
|
187
|
+
control: control,
|
|
188
|
+
defaultValue: field.defaultValue,
|
|
189
|
+
render: ({ field: { ref: _ref, ...formField }, fieldState: { error } })=>/*#__PURE__*/ jsx(CustomComponent, {
|
|
190
|
+
...formField,
|
|
191
|
+
...field.componentProps,
|
|
192
|
+
field: field,
|
|
193
|
+
disabled: formDisabled || fieldState.disabled,
|
|
194
|
+
required: fieldState.required,
|
|
195
|
+
error: error?.message,
|
|
196
|
+
"aria-describedby": joinIds(field.componentProps?.['aria-describedby'], isChanged && changedNoteId)
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
]
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
203
|
+
...wrapperProps,
|
|
204
|
+
children: [
|
|
205
|
+
changedNote,
|
|
206
|
+
/*#__PURE__*/ jsx(Controller, {
|
|
166
207
|
name: field.name,
|
|
167
208
|
control: control,
|
|
168
209
|
defaultValue: field.defaultValue,
|
|
169
|
-
render: ({ field:
|
|
170
|
-
...formField,
|
|
171
|
-
...field.componentProps,
|
|
210
|
+
render: ({ field: formField, fieldState: { error } })=>/*#__PURE__*/ jsx(BuiltInField, {
|
|
172
211
|
field: field,
|
|
212
|
+
formField: formField,
|
|
213
|
+
error: error?.message,
|
|
173
214
|
disabled: formDisabled || fieldState.disabled,
|
|
174
215
|
required: fieldState.required,
|
|
175
|
-
|
|
216
|
+
options: fieldState.options,
|
|
217
|
+
strings: context.strings?.boolean,
|
|
218
|
+
changedNoteId: isChanged ? changedNoteId : void 0
|
|
176
219
|
})
|
|
177
220
|
})
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
return /*#__PURE__*/ jsx("div", {
|
|
181
|
-
style: gridStyle,
|
|
182
|
-
children: /*#__PURE__*/ jsx(Controller, {
|
|
183
|
-
name: field.name,
|
|
184
|
-
control: control,
|
|
185
|
-
defaultValue: field.defaultValue,
|
|
186
|
-
render: ({ field: formField, fieldState: { error } })=>/*#__PURE__*/ jsx(BuiltInField, {
|
|
187
|
-
field: field,
|
|
188
|
-
formField: formField,
|
|
189
|
-
error: error?.message,
|
|
190
|
-
disabled: formDisabled || fieldState.disabled,
|
|
191
|
-
required: fieldState.required,
|
|
192
|
-
options: fieldState.options,
|
|
193
|
-
strings: context.strings?.boolean
|
|
194
|
-
})
|
|
195
|
-
})
|
|
221
|
+
]
|
|
196
222
|
});
|
|
197
223
|
}
|
|
198
|
-
function BuiltInField({ field, formField, error, disabled, required, options, strings }) {
|
|
224
|
+
function BuiltInField({ field, formField, error, disabled, required, options, strings, changedNoteId }) {
|
|
199
225
|
const control = /*#__PURE__*/ jsx(FieldControl, {
|
|
200
226
|
field: field,
|
|
201
227
|
formField: formField,
|
|
202
228
|
options: options,
|
|
203
229
|
disabled: disabled,
|
|
204
230
|
invalid: !!error,
|
|
205
|
-
strings: strings
|
|
231
|
+
strings: strings,
|
|
232
|
+
describedBy: changedNoteId
|
|
206
233
|
});
|
|
207
234
|
switch(field.type){
|
|
208
235
|
case 'checkbox':
|
|
@@ -303,7 +330,8 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
303
330
|
onBlur: formField.onBlur,
|
|
304
331
|
error: error,
|
|
305
332
|
disabled: disabled,
|
|
306
|
-
required: required
|
|
333
|
+
required: required,
|
|
334
|
+
ariaDescribedBy: joinIds(error && `${field.name}-error`, changedNoteId)
|
|
307
335
|
});
|
|
308
336
|
case 'custom':
|
|
309
337
|
return null;
|