@uipath/apollo-wind 2.95.2 → 2.95.3
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 +24 -2
- package/dist/components/forms/aria-ids.d.ts +15 -0
- package/dist/components/forms/aria-ids.js +14 -1
- package/dist/components/forms/field-control.cjs +18 -16
- package/dist/components/forms/field-control.d.ts +6 -5
- package/dist/components/forms/field-control.js +19 -17
- package/dist/components/forms/field-renderer.cjs +14 -10
- package/dist/components/forms/field-renderer.js +15 -11
- package/dist/components/forms/form-schema.d.ts +6 -1
- package/dist/components/forms/metadata-form.cjs +8 -3
- package/dist/components/forms/metadata-form.js +9 -4
- package/dist/components/forms/mode-aware-field.cjs +11 -9
- package/dist/components/forms/mode-aware-field.js +12 -10
- package/dist/components/forms/string-list-field.cjs +10 -6
- package/dist/components/forms/string-list-field.d.ts +1 -1
- package/dist/components/forms/string-list-field.js +10 -6
- package/dist/components/ui/index.cjs +36 -36
- package/package.json +1 -1
|
@@ -24,14 +24,36 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
joinIds: ()=>joinIds
|
|
27
|
+
joinIds: ()=>joinIds,
|
|
28
|
+
fieldIds: ()=>fieldIds,
|
|
29
|
+
useFieldIds: ()=>useFieldIds,
|
|
30
|
+
FieldIdScopeContext: ()=>FieldIdScopeContext
|
|
28
31
|
});
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
29
33
|
function joinIds(...ids) {
|
|
30
34
|
return ids.filter(Boolean).join(' ') || void 0;
|
|
31
35
|
}
|
|
36
|
+
const FieldIdScopeContext = (0, external_react_namespaceObject.createContext)('');
|
|
37
|
+
function fieldIds(scope, name) {
|
|
38
|
+
const controlId = `${scope}${name}`;
|
|
39
|
+
return {
|
|
40
|
+
controlId,
|
|
41
|
+
labelId: `${controlId}-label`,
|
|
42
|
+
errorId: `${controlId}-error`
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function useFieldIds(name) {
|
|
46
|
+
return fieldIds((0, external_react_namespaceObject.useContext)(FieldIdScopeContext), name);
|
|
47
|
+
}
|
|
48
|
+
exports.FieldIdScopeContext = __webpack_exports__.FieldIdScopeContext;
|
|
49
|
+
exports.fieldIds = __webpack_exports__.fieldIds;
|
|
32
50
|
exports.joinIds = __webpack_exports__.joinIds;
|
|
51
|
+
exports.useFieldIds = __webpack_exports__.useFieldIds;
|
|
33
52
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
34
|
-
"
|
|
53
|
+
"FieldIdScopeContext",
|
|
54
|
+
"fieldIds",
|
|
55
|
+
"joinIds",
|
|
56
|
+
"useFieldIds"
|
|
35
57
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
36
58
|
Object.defineProperty(exports, '__esModule', {
|
|
37
59
|
value: true
|
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
/** Space-joins the ids that are set, or `undefined` when none is. */
|
|
2
2
|
export declare function joinIds(...ids: (string | false | undefined)[]): string | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Prefix put on every DOM id a form derives from a field name. `MetadataForm` gives each instance
|
|
5
|
+
* its own, so two forms over the same schema (a panel and its expanded dialog) do not share ids.
|
|
6
|
+
* Empty outside a form, which keeps a standalone `FieldControl`'s id at `field.name`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FieldIdScopeContext: import("react").Context<string>;
|
|
9
|
+
export interface FieldIds {
|
|
10
|
+
/** The focusable control's id, which the label's `htmlFor` points at. */
|
|
11
|
+
controlId: string;
|
|
12
|
+
labelId: string;
|
|
13
|
+
errorId: string;
|
|
14
|
+
}
|
|
15
|
+
/** Field-name ids scoped to the enclosing form. */
|
|
16
|
+
export declare function fieldIds(scope: string, name: string): FieldIds;
|
|
17
|
+
export declare function useFieldIds(name: string): FieldIds;
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
1
2
|
function joinIds(...ids) {
|
|
2
3
|
return ids.filter(Boolean).join(' ') || void 0;
|
|
3
4
|
}
|
|
4
|
-
|
|
5
|
+
const FieldIdScopeContext = createContext('');
|
|
6
|
+
function fieldIds(scope, name) {
|
|
7
|
+
const controlId = `${scope}${name}`;
|
|
8
|
+
return {
|
|
9
|
+
controlId,
|
|
10
|
+
labelId: `${controlId}-label`,
|
|
11
|
+
errorId: `${controlId}-error`
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function useFieldIds(name) {
|
|
15
|
+
return fieldIds(useContext(FieldIdScopeContext), name);
|
|
16
|
+
}
|
|
17
|
+
export { FieldIdScopeContext, fieldIds, joinIds, useFieldIds };
|
|
@@ -114,7 +114,8 @@ const FIELD_CONTROL_GEOMETRY = {
|
|
|
114
114
|
const NO_OPTIONS = [];
|
|
115
115
|
const NO_SELECTION = [];
|
|
116
116
|
function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false, invalid = false, strings, describedBy }) {
|
|
117
|
-
const
|
|
117
|
+
const ids = (0, external_aria_ids_cjs_namespaceObject.useFieldIds)(field.name);
|
|
118
|
+
const errorId = invalid ? ids.errorId : void 0;
|
|
118
119
|
const describedById = (0, external_aria_ids_cjs_namespaceObject.joinIds)(errorId, describedBy);
|
|
119
120
|
const { onChange } = formField;
|
|
120
121
|
const multipleFiles = 'file' === field.type && field.multiple;
|
|
@@ -141,7 +142,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
141
142
|
case 'text':
|
|
142
143
|
case 'email':
|
|
143
144
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
|
|
144
|
-
id:
|
|
145
|
+
id: ids.controlId,
|
|
145
146
|
value: formField.value,
|
|
146
147
|
onChange: onTextChange,
|
|
147
148
|
onBlur: formField.onBlur,
|
|
@@ -157,7 +158,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
157
158
|
});
|
|
158
159
|
case 'number':
|
|
159
160
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
|
|
160
|
-
id:
|
|
161
|
+
id: ids.controlId,
|
|
161
162
|
value: formField.value,
|
|
162
163
|
onBlur: formField.onBlur,
|
|
163
164
|
name: formField.name,
|
|
@@ -175,7 +176,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
175
176
|
});
|
|
176
177
|
case 'textarea':
|
|
177
178
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(textarea_cjs_namespaceObject.Textarea, {
|
|
178
|
-
id:
|
|
179
|
+
id: ids.controlId,
|
|
179
180
|
value: formField.value,
|
|
180
181
|
onChange: onTextChange,
|
|
181
182
|
onBlur: formField.onBlur,
|
|
@@ -200,7 +201,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
200
201
|
disabled: disabled,
|
|
201
202
|
children: [
|
|
202
203
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(select_cjs_namespaceObject.SelectTrigger, {
|
|
203
|
-
id:
|
|
204
|
+
id: ids.controlId,
|
|
204
205
|
"aria-label": field.label,
|
|
205
206
|
"aria-invalid": invalid || void 0,
|
|
206
207
|
"aria-describedby": describedById,
|
|
@@ -220,7 +221,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
220
221
|
});
|
|
221
222
|
case 'multiselect':
|
|
222
223
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(multi_select_cjs_namespaceObject.MultiSelect, {
|
|
223
|
-
id:
|
|
224
|
+
id: ids.controlId,
|
|
224
225
|
selected: formField.value || NO_SELECTION,
|
|
225
226
|
onChange: formField.onChange,
|
|
226
227
|
options: multiSelectOptions,
|
|
@@ -241,11 +242,11 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
241
242
|
"aria-invalid": invalid || void 0,
|
|
242
243
|
"aria-describedby": describedById,
|
|
243
244
|
"aria-errormessage": errorId,
|
|
244
|
-
id:
|
|
245
|
+
id: ids.controlId
|
|
245
246
|
});
|
|
246
247
|
case 'boolean':
|
|
247
248
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(boolean_radio_group_cjs_namespaceObject.BooleanRadioGroup, {
|
|
248
|
-
"aria-labelledby":
|
|
249
|
+
"aria-labelledby": ids.labelId,
|
|
249
250
|
value: 'boolean' == typeof formField.value ? formField.value : null,
|
|
250
251
|
onValueChange: formField.onChange,
|
|
251
252
|
onBlur: formField.onBlur,
|
|
@@ -257,7 +258,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
257
258
|
});
|
|
258
259
|
case 'switch':
|
|
259
260
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(switch_cjs_namespaceObject.Switch, {
|
|
260
|
-
id:
|
|
261
|
+
id: ids.controlId,
|
|
261
262
|
checked: true === formField.value,
|
|
262
263
|
onCheckedChange: onCheckedChange,
|
|
263
264
|
disabled: disabled,
|
|
@@ -267,7 +268,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
267
268
|
});
|
|
268
269
|
case 'radio':
|
|
269
270
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(radio_group_cjs_namespaceObject.RadioGroup, {
|
|
270
|
-
"aria-labelledby":
|
|
271
|
+
"aria-labelledby": ids.labelId,
|
|
271
272
|
value: formField.value,
|
|
272
273
|
onValueChange: formField.onChange,
|
|
273
274
|
disabled: disabled,
|
|
@@ -279,12 +280,12 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
279
280
|
children: [
|
|
280
281
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(radio_group_cjs_namespaceObject.RadioGroupItem, {
|
|
281
282
|
value: String(option.value),
|
|
282
|
-
id: `${
|
|
283
|
+
id: `${ids.controlId}-${option.value}`,
|
|
283
284
|
disabled: 'disabled' in option ? Boolean(option.disabled) : false
|
|
284
285
|
}),
|
|
285
286
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(label_cjs_namespaceObject.Label, {
|
|
286
287
|
variant: "muted",
|
|
287
|
-
htmlFor: `${
|
|
288
|
+
htmlFor: `${ids.controlId}-${option.value}`,
|
|
288
289
|
children: option.label
|
|
289
290
|
})
|
|
290
291
|
]
|
|
@@ -301,7 +302,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
301
302
|
});
|
|
302
303
|
case 'date':
|
|
303
304
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(date_picker_cjs_namespaceObject.DatePicker, {
|
|
304
|
-
id:
|
|
305
|
+
id: ids.controlId,
|
|
305
306
|
value: (0, date_value_cjs_namespaceObject.toDateValue)(formField.value),
|
|
306
307
|
onValueChange: formField.onChange,
|
|
307
308
|
disabled: disabled,
|
|
@@ -312,7 +313,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
312
313
|
});
|
|
313
314
|
case 'datetime':
|
|
314
315
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(datetime_picker_cjs_namespaceObject.DateTimePicker, {
|
|
315
|
-
"aria-labelledby":
|
|
316
|
+
"aria-labelledby": ids.labelId,
|
|
316
317
|
"aria-invalid": invalid || void 0,
|
|
317
318
|
"aria-describedby": describedById,
|
|
318
319
|
"aria-errormessage": errorId,
|
|
@@ -324,7 +325,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
324
325
|
});
|
|
325
326
|
case 'file':
|
|
326
327
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(file_upload_cjs_namespaceObject.FileUpload, {
|
|
327
|
-
id:
|
|
328
|
+
id: ids.controlId,
|
|
328
329
|
ariaLabel: field.ariaLabel ?? field.label,
|
|
329
330
|
"aria-invalid": invalid || void 0,
|
|
330
331
|
"aria-describedby": describedById,
|
|
@@ -352,6 +353,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
352
353
|
}
|
|
353
354
|
}
|
|
354
355
|
function SliderControl({ field, formField, disabled, invalid, errorId, describedById }) {
|
|
356
|
+
const ids = (0, external_aria_ids_cjs_namespaceObject.useFieldIds)(field.name);
|
|
355
357
|
const resolvedMax = useSliderMax(field);
|
|
356
358
|
const prevMaxRef = (0, external_react_namespaceObject.useRef)(resolvedMax);
|
|
357
359
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
@@ -376,7 +378,7 @@ function SliderControl({ field, formField, disabled, invalid, errorId, described
|
|
|
376
378
|
onChange
|
|
377
379
|
]);
|
|
378
380
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(slider_cjs_namespaceObject.Slider, {
|
|
379
|
-
"aria-labelledby":
|
|
381
|
+
"aria-labelledby": ids.labelId,
|
|
380
382
|
"aria-invalid": invalid || void 0,
|
|
381
383
|
"aria-describedby": describedById,
|
|
382
384
|
"aria-errormessage": errorId,
|
|
@@ -16,7 +16,7 @@ export interface FieldControlProps {
|
|
|
16
16
|
/** The resolved options of a select, multiselect or radio field. */
|
|
17
17
|
options?: FieldOption[];
|
|
18
18
|
disabled?: boolean;
|
|
19
|
-
/** Marks the control invalid and points it at the
|
|
19
|
+
/** Marks the control invalid and points it at the field's error message. */
|
|
20
20
|
invalid?: boolean;
|
|
21
21
|
/** Labels of a `boolean` field's radios. */
|
|
22
22
|
strings?: Partial<BooleanRadioGroupStrings>;
|
|
@@ -24,9 +24,9 @@ export interface FieldControlProps {
|
|
|
24
24
|
describedBy?: string;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* How a field's label reaches its control: `control` labels it with `htmlFor` the control's id
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* How a field's label reaches its control: `control` labels it with `htmlFor` the control's id,
|
|
28
|
+
* and `labelledby` has the control name itself with `aria-labelledby` the label's id. A custom
|
|
29
|
+
* component gets the two as `controlId` and `labelId`.
|
|
30
30
|
*/
|
|
31
31
|
export type FieldControlLabelTarget = 'control' | 'labelledby';
|
|
32
32
|
/** How a field type's control sits in an `InputGroup`. */
|
|
@@ -45,7 +45,8 @@ export declare const FIELD_CONTROL_GEOMETRY: Readonly<Partial<Record<FieldType,
|
|
|
45
45
|
/**
|
|
46
46
|
* The bare control for a field's type, without its label, description or error. Its id is
|
|
47
47
|
* `field.name`, and it names the label and error by `${field.name}-label` and
|
|
48
|
-
* `${field.name}-error`, so those are the ids to give them.
|
|
48
|
+
* `${field.name}-error`, so those are the ids to give them. Inside `MetadataForm` all three
|
|
49
|
+
* carry the form's id prefix. Custom fields render nothing.
|
|
49
50
|
*/
|
|
50
51
|
export declare function FieldControl({ field, formField, options, disabled, invalid, strings, describedBy, }: FieldControlProps): import("react/jsx-runtime").JSX.Element | null;
|
|
51
52
|
/** The slider's effective max, following `field.maxRef` when it has one. */
|
|
@@ -15,7 +15,7 @@ import { Slider } from "../ui/slider.js";
|
|
|
15
15
|
import { Switch } from "../ui/switch.js";
|
|
16
16
|
import { Textarea } from "../ui/textarea.js";
|
|
17
17
|
import { toDateValue } from "../../lib/date-value.js";
|
|
18
|
-
import { joinIds } from "./aria-ids.js";
|
|
18
|
+
import { joinIds, useFieldIds } from "./aria-ids.js";
|
|
19
19
|
import { LiteralValueContext } from "./literal-value-context.js";
|
|
20
20
|
import { StringListControl } from "./string-list-field.js";
|
|
21
21
|
const FIELD_CONTROL_GEOMETRY = {
|
|
@@ -83,7 +83,8 @@ const FIELD_CONTROL_GEOMETRY = {
|
|
|
83
83
|
const NO_OPTIONS = [];
|
|
84
84
|
const NO_SELECTION = [];
|
|
85
85
|
function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false, invalid = false, strings, describedBy }) {
|
|
86
|
-
const
|
|
86
|
+
const ids = useFieldIds(field.name);
|
|
87
|
+
const errorId = invalid ? ids.errorId : void 0;
|
|
87
88
|
const describedById = joinIds(errorId, describedBy);
|
|
88
89
|
const { onChange } = formField;
|
|
89
90
|
const multipleFiles = 'file' === field.type && field.multiple;
|
|
@@ -110,7 +111,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
110
111
|
case 'text':
|
|
111
112
|
case 'email':
|
|
112
113
|
return /*#__PURE__*/ jsx(Input, {
|
|
113
|
-
id:
|
|
114
|
+
id: ids.controlId,
|
|
114
115
|
value: formField.value,
|
|
115
116
|
onChange: onTextChange,
|
|
116
117
|
onBlur: formField.onBlur,
|
|
@@ -126,7 +127,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
126
127
|
});
|
|
127
128
|
case 'number':
|
|
128
129
|
return /*#__PURE__*/ jsx(Input, {
|
|
129
|
-
id:
|
|
130
|
+
id: ids.controlId,
|
|
130
131
|
value: formField.value,
|
|
131
132
|
onBlur: formField.onBlur,
|
|
132
133
|
name: formField.name,
|
|
@@ -144,7 +145,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
144
145
|
});
|
|
145
146
|
case 'textarea':
|
|
146
147
|
return /*#__PURE__*/ jsx(Textarea, {
|
|
147
|
-
id:
|
|
148
|
+
id: ids.controlId,
|
|
148
149
|
value: formField.value,
|
|
149
150
|
onChange: onTextChange,
|
|
150
151
|
onBlur: formField.onBlur,
|
|
@@ -169,7 +170,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
169
170
|
disabled: disabled,
|
|
170
171
|
children: [
|
|
171
172
|
/*#__PURE__*/ jsx(SelectTrigger, {
|
|
172
|
-
id:
|
|
173
|
+
id: ids.controlId,
|
|
173
174
|
"aria-label": field.label,
|
|
174
175
|
"aria-invalid": invalid || void 0,
|
|
175
176
|
"aria-describedby": describedById,
|
|
@@ -189,7 +190,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
189
190
|
});
|
|
190
191
|
case 'multiselect':
|
|
191
192
|
return /*#__PURE__*/ jsx(MultiSelect, {
|
|
192
|
-
id:
|
|
193
|
+
id: ids.controlId,
|
|
193
194
|
selected: formField.value || NO_SELECTION,
|
|
194
195
|
onChange: formField.onChange,
|
|
195
196
|
options: multiSelectOptions,
|
|
@@ -210,11 +211,11 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
210
211
|
"aria-invalid": invalid || void 0,
|
|
211
212
|
"aria-describedby": describedById,
|
|
212
213
|
"aria-errormessage": errorId,
|
|
213
|
-
id:
|
|
214
|
+
id: ids.controlId
|
|
214
215
|
});
|
|
215
216
|
case 'boolean':
|
|
216
217
|
return /*#__PURE__*/ jsx(BooleanRadioGroup, {
|
|
217
|
-
"aria-labelledby":
|
|
218
|
+
"aria-labelledby": ids.labelId,
|
|
218
219
|
value: 'boolean' == typeof formField.value ? formField.value : null,
|
|
219
220
|
onValueChange: formField.onChange,
|
|
220
221
|
onBlur: formField.onBlur,
|
|
@@ -226,7 +227,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
226
227
|
});
|
|
227
228
|
case 'switch':
|
|
228
229
|
return /*#__PURE__*/ jsx(Switch, {
|
|
229
|
-
id:
|
|
230
|
+
id: ids.controlId,
|
|
230
231
|
checked: true === formField.value,
|
|
231
232
|
onCheckedChange: onCheckedChange,
|
|
232
233
|
disabled: disabled,
|
|
@@ -236,7 +237,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
236
237
|
});
|
|
237
238
|
case 'radio':
|
|
238
239
|
return /*#__PURE__*/ jsx(RadioGroup, {
|
|
239
|
-
"aria-labelledby":
|
|
240
|
+
"aria-labelledby": ids.labelId,
|
|
240
241
|
value: formField.value,
|
|
241
242
|
onValueChange: formField.onChange,
|
|
242
243
|
disabled: disabled,
|
|
@@ -248,12 +249,12 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
248
249
|
children: [
|
|
249
250
|
/*#__PURE__*/ jsx(RadioGroupItem, {
|
|
250
251
|
value: String(option.value),
|
|
251
|
-
id: `${
|
|
252
|
+
id: `${ids.controlId}-${option.value}`,
|
|
252
253
|
disabled: 'disabled' in option ? Boolean(option.disabled) : false
|
|
253
254
|
}),
|
|
254
255
|
/*#__PURE__*/ jsx(Label, {
|
|
255
256
|
variant: "muted",
|
|
256
|
-
htmlFor: `${
|
|
257
|
+
htmlFor: `${ids.controlId}-${option.value}`,
|
|
257
258
|
children: option.label
|
|
258
259
|
})
|
|
259
260
|
]
|
|
@@ -270,7 +271,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
270
271
|
});
|
|
271
272
|
case 'date':
|
|
272
273
|
return /*#__PURE__*/ jsx(DatePicker, {
|
|
273
|
-
id:
|
|
274
|
+
id: ids.controlId,
|
|
274
275
|
value: toDateValue(formField.value),
|
|
275
276
|
onValueChange: formField.onChange,
|
|
276
277
|
disabled: disabled,
|
|
@@ -281,7 +282,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
281
282
|
});
|
|
282
283
|
case 'datetime':
|
|
283
284
|
return /*#__PURE__*/ jsx(DateTimePicker, {
|
|
284
|
-
"aria-labelledby":
|
|
285
|
+
"aria-labelledby": ids.labelId,
|
|
285
286
|
"aria-invalid": invalid || void 0,
|
|
286
287
|
"aria-describedby": describedById,
|
|
287
288
|
"aria-errormessage": errorId,
|
|
@@ -293,7 +294,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
293
294
|
});
|
|
294
295
|
case 'file':
|
|
295
296
|
return /*#__PURE__*/ jsx(FileUpload, {
|
|
296
|
-
id:
|
|
297
|
+
id: ids.controlId,
|
|
297
298
|
ariaLabel: field.ariaLabel ?? field.label,
|
|
298
299
|
"aria-invalid": invalid || void 0,
|
|
299
300
|
"aria-describedby": describedById,
|
|
@@ -321,6 +322,7 @@ function FieldControl({ field, formField, options = NO_OPTIONS, disabled = false
|
|
|
321
322
|
}
|
|
322
323
|
}
|
|
323
324
|
function SliderControl({ field, formField, disabled, invalid, errorId, describedById }) {
|
|
325
|
+
const ids = useFieldIds(field.name);
|
|
324
326
|
const resolvedMax = useSliderMax(field);
|
|
325
327
|
const prevMaxRef = useRef(resolvedMax);
|
|
326
328
|
useEffect(()=>{
|
|
@@ -345,7 +347,7 @@ function SliderControl({ field, formField, disabled, invalid, errorId, described
|
|
|
345
347
|
onChange
|
|
346
348
|
]);
|
|
347
349
|
return /*#__PURE__*/ jsx(Slider, {
|
|
348
|
-
"aria-labelledby":
|
|
350
|
+
"aria-labelledby": ids.labelId,
|
|
349
351
|
"aria-invalid": invalid || void 0,
|
|
350
352
|
"aria-describedby": describedById,
|
|
351
353
|
"aria-errormessage": errorId,
|
|
@@ -42,6 +42,7 @@ const external_value_modes_cjs_namespaceObject = require("./value-modes.cjs");
|
|
|
42
42
|
function FormFieldRenderer({ field, context, customComponents, disabled: formDisabled = false }) {
|
|
43
43
|
const { control, watch, getValues } = (0, external_react_hook_form_namespaceObject.useFormContext)();
|
|
44
44
|
const changedNoteId = `${(0, external_react_namespaceObject.useId)()}-changed`;
|
|
45
|
+
const ids = (0, external_aria_ids_cjs_namespaceObject.useFieldIds)(field.name);
|
|
45
46
|
const contextRef = (0, external_react_namespaceObject.useRef)(context);
|
|
46
47
|
contextRef.current = context;
|
|
47
48
|
const readValues = (0, external_react_namespaceObject.useCallback)(()=>(0, external_value_modes_cjs_namespaceObject.literalValues)(getValues(), contextRef.current.schema, contextRef.current.valueModes?.codecs), [
|
|
@@ -221,6 +222,8 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
221
222
|
disabled: formDisabled || fieldState.disabled,
|
|
222
223
|
required: fieldState.required,
|
|
223
224
|
error: error?.message,
|
|
225
|
+
controlId: ids.controlId,
|
|
226
|
+
labelId: ids.labelId,
|
|
224
227
|
"aria-describedby": (0, external_aria_ids_cjs_namespaceObject.joinIds)(field.componentProps?.['aria-describedby'], isChanged && changedNoteId)
|
|
225
228
|
})
|
|
226
229
|
})
|
|
@@ -250,6 +253,7 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
250
253
|
});
|
|
251
254
|
}
|
|
252
255
|
function BuiltInField({ field, formField, error, disabled, required, options, strings, changedNoteId }) {
|
|
256
|
+
const ids = (0, external_aria_ids_cjs_namespaceObject.useFieldIds)(field.name);
|
|
253
257
|
const control = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_field_control_cjs_namespaceObject.FieldControl, {
|
|
254
258
|
field: field,
|
|
255
259
|
formField: formField,
|
|
@@ -271,7 +275,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
271
275
|
className: "space-y-1 leading-none",
|
|
272
276
|
children: [
|
|
273
277
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldLabel, {
|
|
274
|
-
htmlFor:
|
|
278
|
+
htmlFor: ids.controlId,
|
|
275
279
|
tooltip: field.tooltip,
|
|
276
280
|
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
277
281
|
className: "font-normal",
|
|
@@ -285,7 +289,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
285
289
|
]
|
|
286
290
|
}),
|
|
287
291
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldError, {
|
|
288
|
-
id:
|
|
292
|
+
id: ids.errorId,
|
|
289
293
|
children: error
|
|
290
294
|
})
|
|
291
295
|
]
|
|
@@ -300,7 +304,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
300
304
|
className: "space-y-0.5",
|
|
301
305
|
children: [
|
|
302
306
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldLabel, {
|
|
303
|
-
htmlFor:
|
|
307
|
+
htmlFor: ids.controlId,
|
|
304
308
|
required: required,
|
|
305
309
|
tooltip: field.tooltip,
|
|
306
310
|
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
@@ -315,7 +319,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
315
319
|
]
|
|
316
320
|
}),
|
|
317
321
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldError, {
|
|
318
|
-
id:
|
|
322
|
+
id: ids.errorId,
|
|
319
323
|
children: error
|
|
320
324
|
})
|
|
321
325
|
]
|
|
@@ -327,7 +331,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
327
331
|
className: "flex justify-between",
|
|
328
332
|
children: [
|
|
329
333
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldLabel, {
|
|
330
|
-
id:
|
|
334
|
+
id: ids.labelId,
|
|
331
335
|
required: required,
|
|
332
336
|
tooltip: field.tooltip,
|
|
333
337
|
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
@@ -344,7 +348,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
344
348
|
children: field.description
|
|
345
349
|
}),
|
|
346
350
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldError, {
|
|
347
|
-
id:
|
|
351
|
+
id: ids.errorId,
|
|
348
352
|
children: error
|
|
349
353
|
})
|
|
350
354
|
]
|
|
@@ -359,7 +363,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
359
363
|
error: error,
|
|
360
364
|
disabled: disabled,
|
|
361
365
|
required: required,
|
|
362
|
-
ariaDescribedBy: (0, external_aria_ids_cjs_namespaceObject.joinIds)(error &&
|
|
366
|
+
ariaDescribedBy: (0, external_aria_ids_cjs_namespaceObject.joinIds)(error && ids.errorId, changedNoteId)
|
|
363
367
|
});
|
|
364
368
|
case 'custom':
|
|
365
369
|
return null;
|
|
@@ -368,9 +372,9 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
368
372
|
children: [
|
|
369
373
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldLabel, {
|
|
370
374
|
...'radio' === field.type || 'boolean' === field.type || 'datetime' === field.type ? {
|
|
371
|
-
id:
|
|
375
|
+
id: ids.labelId
|
|
372
376
|
} : {
|
|
373
|
-
htmlFor:
|
|
377
|
+
htmlFor: ids.controlId
|
|
374
378
|
},
|
|
375
379
|
required: required,
|
|
376
380
|
tooltip: field.tooltip,
|
|
@@ -382,7 +386,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
382
386
|
children: field.description
|
|
383
387
|
}),
|
|
384
388
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldError, {
|
|
385
|
-
id:
|
|
389
|
+
id: ids.errorId,
|
|
386
390
|
children: error
|
|
387
391
|
})
|
|
388
392
|
]
|
|
@@ -3,7 +3,7 @@ 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
|
+
import { joinIds, useFieldIds } from "./aria-ids.js";
|
|
7
7
|
import { DataFetcher } from "./data-fetcher.js";
|
|
8
8
|
import { FieldControl, clampSliderValue, useSliderMax } from "./field-control.js";
|
|
9
9
|
import { hasOptions, isCustomField } from "./form-schema.js";
|
|
@@ -14,6 +14,7 @@ import { isFieldControlRegistration, literalValues } from "./value-modes.js";
|
|
|
14
14
|
function FormFieldRenderer({ field, context, customComponents, disabled: formDisabled = false }) {
|
|
15
15
|
const { control, watch, getValues } = useFormContext();
|
|
16
16
|
const changedNoteId = `${useId()}-changed`;
|
|
17
|
+
const ids = useFieldIds(field.name);
|
|
17
18
|
const contextRef = useRef(context);
|
|
18
19
|
contextRef.current = context;
|
|
19
20
|
const readValues = useCallback(()=>literalValues(getValues(), contextRef.current.schema, contextRef.current.valueModes?.codecs), [
|
|
@@ -193,6 +194,8 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
193
194
|
disabled: formDisabled || fieldState.disabled,
|
|
194
195
|
required: fieldState.required,
|
|
195
196
|
error: error?.message,
|
|
197
|
+
controlId: ids.controlId,
|
|
198
|
+
labelId: ids.labelId,
|
|
196
199
|
"aria-describedby": joinIds(field.componentProps?.['aria-describedby'], isChanged && changedNoteId)
|
|
197
200
|
})
|
|
198
201
|
})
|
|
@@ -222,6 +225,7 @@ function FormFieldRenderer({ field, context, customComponents, disabled: formDis
|
|
|
222
225
|
});
|
|
223
226
|
}
|
|
224
227
|
function BuiltInField({ field, formField, error, disabled, required, options, strings, changedNoteId }) {
|
|
228
|
+
const ids = useFieldIds(field.name);
|
|
225
229
|
const control = /*#__PURE__*/ jsx(FieldControl, {
|
|
226
230
|
field: field,
|
|
227
231
|
formField: formField,
|
|
@@ -243,7 +247,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
243
247
|
className: "space-y-1 leading-none",
|
|
244
248
|
children: [
|
|
245
249
|
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
246
|
-
htmlFor:
|
|
250
|
+
htmlFor: ids.controlId,
|
|
247
251
|
tooltip: field.tooltip,
|
|
248
252
|
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
249
253
|
className: "font-normal",
|
|
@@ -257,7 +261,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
257
261
|
]
|
|
258
262
|
}),
|
|
259
263
|
/*#__PURE__*/ jsx(FormFieldError, {
|
|
260
|
-
id:
|
|
264
|
+
id: ids.errorId,
|
|
261
265
|
children: error
|
|
262
266
|
})
|
|
263
267
|
]
|
|
@@ -272,7 +276,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
272
276
|
className: "space-y-0.5",
|
|
273
277
|
children: [
|
|
274
278
|
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
275
|
-
htmlFor:
|
|
279
|
+
htmlFor: ids.controlId,
|
|
276
280
|
required: required,
|
|
277
281
|
tooltip: field.tooltip,
|
|
278
282
|
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
@@ -287,7 +291,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
287
291
|
]
|
|
288
292
|
}),
|
|
289
293
|
/*#__PURE__*/ jsx(FormFieldError, {
|
|
290
|
-
id:
|
|
294
|
+
id: ids.errorId,
|
|
291
295
|
children: error
|
|
292
296
|
})
|
|
293
297
|
]
|
|
@@ -299,7 +303,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
299
303
|
className: "flex justify-between",
|
|
300
304
|
children: [
|
|
301
305
|
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
302
|
-
id:
|
|
306
|
+
id: ids.labelId,
|
|
303
307
|
required: required,
|
|
304
308
|
tooltip: field.tooltip,
|
|
305
309
|
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
@@ -316,7 +320,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
316
320
|
children: field.description
|
|
317
321
|
}),
|
|
318
322
|
/*#__PURE__*/ jsx(FormFieldError, {
|
|
319
|
-
id:
|
|
323
|
+
id: ids.errorId,
|
|
320
324
|
children: error
|
|
321
325
|
})
|
|
322
326
|
]
|
|
@@ -331,7 +335,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
331
335
|
error: error,
|
|
332
336
|
disabled: disabled,
|
|
333
337
|
required: required,
|
|
334
|
-
ariaDescribedBy: joinIds(error &&
|
|
338
|
+
ariaDescribedBy: joinIds(error && ids.errorId, changedNoteId)
|
|
335
339
|
});
|
|
336
340
|
case 'custom':
|
|
337
341
|
return null;
|
|
@@ -340,9 +344,9 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
340
344
|
children: [
|
|
341
345
|
/*#__PURE__*/ jsx(FormFieldLabel, {
|
|
342
346
|
...'radio' === field.type || 'boolean' === field.type || 'datetime' === field.type ? {
|
|
343
|
-
id:
|
|
347
|
+
id: ids.labelId
|
|
344
348
|
} : {
|
|
345
|
-
htmlFor:
|
|
349
|
+
htmlFor: ids.controlId
|
|
346
350
|
},
|
|
347
351
|
required: required,
|
|
348
352
|
tooltip: field.tooltip,
|
|
@@ -354,7 +358,7 @@ function BuiltInField({ field, formField, error, disabled, required, options, st
|
|
|
354
358
|
children: field.description
|
|
355
359
|
}),
|
|
356
360
|
/*#__PURE__*/ jsx(FormFieldError, {
|
|
357
|
-
id:
|
|
361
|
+
id: ids.errorId,
|
|
358
362
|
children: error
|
|
359
363
|
})
|
|
360
364
|
]
|
|
@@ -445,9 +445,14 @@ export interface CustomFieldComponentProps {
|
|
|
445
445
|
error?: string;
|
|
446
446
|
/**
|
|
447
447
|
* In the field anatomy: the handle Insert variable writes through. A component registered as
|
|
448
|
-
* `insertable` without a text input carrying
|
|
448
|
+
* `insertable` without a text input carrying `controlId` as its id attaches one.
|
|
449
449
|
*/
|
|
450
450
|
controlRef?: React.Ref<ValueModeControlHandle>;
|
|
451
|
+
/**
|
|
452
|
+
* The id to put on the focusable control, which the label's `htmlFor` points at. It carries the
|
|
453
|
+
* form's id prefix, so it differs from `name` and stays unique when the same schema is mounted twice.
|
|
454
|
+
*/
|
|
455
|
+
controlId?: string;
|
|
451
456
|
/** In the field anatomy: the label's id, for a component registered with `labelTarget: 'labelledby'`. */
|
|
452
457
|
labelId?: string;
|
|
453
458
|
/** Id of the changed-field note while the field is flagged; put it on the focusable control. */
|