@uipath/apollo-wind 2.95.2 → 2.96.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 +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/byo-model-dialog/byo-model-dialog.cjs +340 -212
- package/dist/components/ui/byo-model-dialog/byo-model-dialog.js +342 -214
- package/dist/components/ui/byo-model-dialog/index.d.ts +1 -1
- package/dist/components/ui/byo-model-dialog/labels.cjs +22 -10
- package/dist/components/ui/byo-model-dialog/labels.d.ts +19 -5
- package/dist/components/ui/byo-model-dialog/labels.js +22 -10
- package/dist/components/ui/byo-model-dialog/model-alias-picker.cjs +293 -0
- package/dist/components/ui/byo-model-dialog/model-alias-picker.d.ts +24 -0
- package/dist/components/ui/byo-model-dialog/model-alias-picker.js +259 -0
- package/dist/components/ui/byo-model-dialog/types.d.ts +19 -0
- package/dist/components/ui/index.cjs +22 -22
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -47,6 +47,7 @@ const button_cjs_namespaceObject = require("../ui/button.cjs");
|
|
|
47
47
|
const panel_tabs_cjs_namespaceObject = require("../ui/panel-tabs.cjs");
|
|
48
48
|
const tooltip_cjs_namespaceObject = require("../ui/tooltip.cjs");
|
|
49
49
|
const index_cjs_namespaceObject = require("../../lib/index.cjs");
|
|
50
|
+
const external_aria_ids_cjs_namespaceObject = require("./aria-ids.cjs");
|
|
50
51
|
const external_data_fetcher_cjs_namespaceObject = require("./data-fetcher.cjs");
|
|
51
52
|
const external_field_actions_cjs_namespaceObject = require("./field-actions.cjs");
|
|
52
53
|
const external_field_renderer_cjs_namespaceObject = require("./field-renderer.cjs");
|
|
@@ -57,6 +58,7 @@ const external_validation_converter_cjs_namespaceObject = require("./validation-
|
|
|
57
58
|
const external_value_modes_cjs_namespaceObject = require("./value-modes.cjs");
|
|
58
59
|
const DEFAULT_PLUGINS = [];
|
|
59
60
|
function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className, disabled = false, autoComplete, stepVariant = 'wizard', sectionVariant = 'card', activeStepId, onActiveStepChange, container = 'form', changedFields, changedFieldLabel }) {
|
|
61
|
+
const fieldIdScope = `${(0, external_react_namespaceObject.useId)()}-`;
|
|
60
62
|
const [currentStep, setCurrentStep] = (0, external_react_namespaceObject.useState)(0);
|
|
61
63
|
const [customComponents, setCustomComponents] = (0, external_react_namespaceObject.useState)({});
|
|
62
64
|
const [isInitialized, setIsInitialized] = (0, external_react_namespaceObject.useState)(false);
|
|
@@ -302,9 +304,12 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
302
304
|
...form,
|
|
303
305
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_literal_value_context_cjs_namespaceObject.LiteralValueContext.Provider, {
|
|
304
306
|
value: readLiteralValue,
|
|
305
|
-
children:
|
|
306
|
-
|
|
307
|
-
|
|
307
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_aria_ids_cjs_namespaceObject.FieldIdScopeContext.Provider, {
|
|
308
|
+
value: fieldIdScope,
|
|
309
|
+
children: hasFieldTooltip ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(tooltip_cjs_namespaceObject.TooltipProvider, {
|
|
310
|
+
children: body
|
|
311
|
+
}) : body
|
|
312
|
+
})
|
|
308
313
|
})
|
|
309
314
|
});
|
|
310
315
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { standardSchemaResolver } from "@hookform/resolvers/standard-schema";
|
|
3
|
-
import react, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import react, { useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { FormProvider, useForm, useFormState, useWatch } from "react-hook-form";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "../ui/accordion.js";
|
|
@@ -8,6 +8,7 @@ import { Button } from "../ui/button.js";
|
|
|
8
8
|
import { PanelTabs, PanelTabsContent, PanelTabsList, PanelTabsTrigger } from "../ui/panel-tabs.js";
|
|
9
9
|
import { TooltipProvider } from "../ui/tooltip.js";
|
|
10
10
|
import { deepEqual, get } from "../../lib/index.js";
|
|
11
|
+
import { FieldIdScopeContext } from "./aria-ids.js";
|
|
11
12
|
import { DataFetcher } from "./data-fetcher.js";
|
|
12
13
|
import { buildFieldActionRegistry } from "./field-actions.js";
|
|
13
14
|
import { FormFieldRenderer } from "./field-renderer.js";
|
|
@@ -18,6 +19,7 @@ import { modeAwareSchema, validationConfigToZod } from "./validation-converter.j
|
|
|
18
19
|
import { buildValueModeRegistry, codecContext, isEmptyModeValue, literalValueOf, literalValues, resolveCodec } from "./value-modes.js";
|
|
19
20
|
const DEFAULT_PLUGINS = [];
|
|
20
21
|
function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className, disabled = false, autoComplete, stepVariant = 'wizard', sectionVariant = 'card', activeStepId, onActiveStepChange, container = 'form', changedFields, changedFieldLabel }) {
|
|
22
|
+
const fieldIdScope = `${useId()}-`;
|
|
21
23
|
const [currentStep, setCurrentStep] = useState(0);
|
|
22
24
|
const [customComponents, setCustomComponents] = useState({});
|
|
23
25
|
const [isInitialized, setIsInitialized] = useState(false);
|
|
@@ -263,9 +265,12 @@ function MetadataForm({ schema, plugins = DEFAULT_PLUGINS, onSubmit, className,
|
|
|
263
265
|
...form,
|
|
264
266
|
children: /*#__PURE__*/ jsx(LiteralValueContext.Provider, {
|
|
265
267
|
value: readLiteralValue,
|
|
266
|
-
children:
|
|
267
|
-
|
|
268
|
-
|
|
268
|
+
children: /*#__PURE__*/ jsx(FieldIdScopeContext.Provider, {
|
|
269
|
+
value: fieldIdScope,
|
|
270
|
+
children: hasFieldTooltip ? /*#__PURE__*/ jsx(TooltipProvider, {
|
|
271
|
+
children: body
|
|
272
|
+
}) : body
|
|
273
|
+
})
|
|
269
274
|
})
|
|
270
275
|
});
|
|
271
276
|
}
|
|
@@ -103,8 +103,7 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
103
103
|
const strings = context.strings ?? external_form_strings_cjs_namespaceObject.DEFAULT_METADATA_FORM_STRINGS;
|
|
104
104
|
const config = field.valueModes;
|
|
105
105
|
const { name } = field;
|
|
106
|
-
const errorId =
|
|
107
|
-
const labelId = `${name}-label`;
|
|
106
|
+
const { controlId, labelId, errorId } = (0, external_aria_ids_cjs_namespaceObject.useFieldIds)(name);
|
|
108
107
|
const controlDescribedBy = (0, external_aria_ids_cjs_namespaceObject.joinIds)(error && errorId, describedBy);
|
|
109
108
|
const formVariables = context.variables;
|
|
110
109
|
const variables = (0, external_react_namespaceObject.useCallback)(()=>(0, external_field_actions_cjs_namespaceObject.resolveVariables)(formVariables, field), [
|
|
@@ -199,9 +198,9 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
199
198
|
const writeInnerRef = (0, external_react_namespaceObject.useRef)(writeInner);
|
|
200
199
|
writeInnerRef.current = writeInner;
|
|
201
200
|
const domHandle = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
202
|
-
focus: ()=>controlElement(groupRef.current,
|
|
201
|
+
focus: ()=>controlElement(groupRef.current, controlId)?.focus(),
|
|
203
202
|
insertText: (text)=>{
|
|
204
|
-
const element = controlElement(groupRef.current,
|
|
203
|
+
const element = controlElement(groupRef.current, controlId);
|
|
205
204
|
if (!(element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement)) {
|
|
206
205
|
const current = latest.current.inner;
|
|
207
206
|
writeInnerRef.current(`${'string' == typeof current ? current : ''}${text}`, 'set');
|
|
@@ -218,7 +217,7 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
218
217
|
});
|
|
219
218
|
}
|
|
220
219
|
}), [
|
|
221
|
-
|
|
220
|
+
controlId
|
|
222
221
|
]);
|
|
223
222
|
const ctx = useActionContext({
|
|
224
223
|
field,
|
|
@@ -259,6 +258,7 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
259
258
|
customComponents,
|
|
260
259
|
binding,
|
|
261
260
|
controlRef,
|
|
261
|
+
controlId,
|
|
262
262
|
labelId,
|
|
263
263
|
options,
|
|
264
264
|
disabled,
|
|
@@ -280,7 +280,8 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
280
280
|
requestModeSwitch: handleSelect,
|
|
281
281
|
controlRef,
|
|
282
282
|
inputRef: formField.ref,
|
|
283
|
-
id:
|
|
283
|
+
id: controlId,
|
|
284
|
+
controlId,
|
|
284
285
|
labelId,
|
|
285
286
|
invalid: !!error,
|
|
286
287
|
placeholder: field.placeholder,
|
|
@@ -319,7 +320,7 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
319
320
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldHeader, {
|
|
320
321
|
label: field.label,
|
|
321
322
|
labelId: labelId,
|
|
322
|
-
htmlFor: 'control' === resolved.geometry.labelTarget ?
|
|
323
|
+
htmlFor: 'control' === resolved.geometry.labelTarget ? controlId : void 0,
|
|
323
324
|
required: required,
|
|
324
325
|
tooltip: field.tooltip,
|
|
325
326
|
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
@@ -523,10 +524,10 @@ function resolveControl(input) {
|
|
|
523
524
|
source: 'fallback'
|
|
524
525
|
};
|
|
525
526
|
}
|
|
526
|
-
function FallbackControl({ field, binding, disabled, error, errorId, describedBy }) {
|
|
527
|
+
function FallbackControl({ field, binding, disabled, error, errorId, describedBy, controlId }) {
|
|
527
528
|
const { value } = binding;
|
|
528
529
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_cjs_namespaceObject.Input, {
|
|
529
|
-
id:
|
|
530
|
+
id: controlId,
|
|
530
531
|
name: binding.name,
|
|
531
532
|
ref: binding.ref,
|
|
532
533
|
value: 'string' == typeof value ? value : null == value ? '' : String(value),
|
|
@@ -564,6 +565,7 @@ function builtInLiteral(input) {
|
|
|
564
565
|
required: required,
|
|
565
566
|
error: error,
|
|
566
567
|
controlRef: input.controlRef,
|
|
568
|
+
controlId: input.controlId,
|
|
567
569
|
labelId: input.labelId,
|
|
568
570
|
"aria-describedby": (0, external_aria_ids_cjs_namespaceObject.joinIds)(field.componentProps?.['aria-describedby'], input.describedBy)
|
|
569
571
|
}),
|
|
@@ -10,7 +10,7 @@ import { Input } from "../ui/input.js";
|
|
|
10
10
|
import { InputGroup, InputGroupAddon } from "../ui/input-group.js";
|
|
11
11
|
import { PromptValueControl } from "../ui/prompt-value-control.js";
|
|
12
12
|
import { VariableValueControl } from "../ui/variable-value-control.js";
|
|
13
|
-
import { joinIds } from "./aria-ids.js";
|
|
13
|
+
import { joinIds, useFieldIds } from "./aria-ids.js";
|
|
14
14
|
import { DEFAULT_FIELD_ACTION_REGISTRY, resolveFieldActions, resolveVariables } from "./field-actions.js";
|
|
15
15
|
import { FIELD_CONTROL_GEOMETRY, FieldControl } from "./field-control.js";
|
|
16
16
|
import { DEFAULT_METADATA_FORM_STRINGS } from "./form-strings.js";
|
|
@@ -75,8 +75,7 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
75
75
|
const strings = context.strings ?? DEFAULT_METADATA_FORM_STRINGS;
|
|
76
76
|
const config = field.valueModes;
|
|
77
77
|
const { name } = field;
|
|
78
|
-
const errorId =
|
|
79
|
-
const labelId = `${name}-label`;
|
|
78
|
+
const { controlId, labelId, errorId } = useFieldIds(name);
|
|
80
79
|
const controlDescribedBy = joinIds(error && errorId, describedBy);
|
|
81
80
|
const formVariables = context.variables;
|
|
82
81
|
const variables = useCallback(()=>resolveVariables(formVariables, field), [
|
|
@@ -171,9 +170,9 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
171
170
|
const writeInnerRef = useRef(writeInner);
|
|
172
171
|
writeInnerRef.current = writeInner;
|
|
173
172
|
const domHandle = useMemo(()=>({
|
|
174
|
-
focus: ()=>controlElement(groupRef.current,
|
|
173
|
+
focus: ()=>controlElement(groupRef.current, controlId)?.focus(),
|
|
175
174
|
insertText: (text)=>{
|
|
176
|
-
const element = controlElement(groupRef.current,
|
|
175
|
+
const element = controlElement(groupRef.current, controlId);
|
|
177
176
|
if (!(element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement)) {
|
|
178
177
|
const current = latest.current.inner;
|
|
179
178
|
writeInnerRef.current(`${'string' == typeof current ? current : ''}${text}`, 'set');
|
|
@@ -190,7 +189,7 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
190
189
|
});
|
|
191
190
|
}
|
|
192
191
|
}), [
|
|
193
|
-
|
|
192
|
+
controlId
|
|
194
193
|
]);
|
|
195
194
|
const ctx = useActionContext({
|
|
196
195
|
field,
|
|
@@ -231,6 +230,7 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
231
230
|
customComponents,
|
|
232
231
|
binding,
|
|
233
232
|
controlRef,
|
|
233
|
+
controlId,
|
|
234
234
|
labelId,
|
|
235
235
|
options,
|
|
236
236
|
disabled,
|
|
@@ -252,7 +252,8 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
252
252
|
requestModeSwitch: handleSelect,
|
|
253
253
|
controlRef,
|
|
254
254
|
inputRef: formField.ref,
|
|
255
|
-
id:
|
|
255
|
+
id: controlId,
|
|
256
|
+
controlId,
|
|
256
257
|
labelId,
|
|
257
258
|
invalid: !!error,
|
|
258
259
|
placeholder: field.placeholder,
|
|
@@ -291,7 +292,7 @@ function FieldAnatomy({ field, context, customComponents, disabled, required, op
|
|
|
291
292
|
/*#__PURE__*/ jsx(FormFieldHeader, {
|
|
292
293
|
label: field.label,
|
|
293
294
|
labelId: labelId,
|
|
294
|
-
htmlFor: 'control' === resolved.geometry.labelTarget ?
|
|
295
|
+
htmlFor: 'control' === resolved.geometry.labelTarget ? controlId : void 0,
|
|
295
296
|
required: required,
|
|
296
297
|
tooltip: field.tooltip,
|
|
297
298
|
tooltipAriaLabel: field.tooltipAriaLabel,
|
|
@@ -495,10 +496,10 @@ function resolveControl(input) {
|
|
|
495
496
|
source: 'fallback'
|
|
496
497
|
};
|
|
497
498
|
}
|
|
498
|
-
function FallbackControl({ field, binding, disabled, error, errorId, describedBy }) {
|
|
499
|
+
function FallbackControl({ field, binding, disabled, error, errorId, describedBy, controlId }) {
|
|
499
500
|
const { value } = binding;
|
|
500
501
|
return /*#__PURE__*/ jsx(Input, {
|
|
501
|
-
id:
|
|
502
|
+
id: controlId,
|
|
502
503
|
name: binding.name,
|
|
503
504
|
ref: binding.ref,
|
|
504
505
|
value: 'string' == typeof value ? value : null == value ? '' : String(value),
|
|
@@ -536,6 +537,7 @@ function builtInLiteral(input) {
|
|
|
536
537
|
required: required,
|
|
537
538
|
error: error,
|
|
538
539
|
controlRef: input.controlRef,
|
|
540
|
+
controlId: input.controlId,
|
|
539
541
|
labelId: input.labelId,
|
|
540
542
|
"aria-describedby": joinIds(field.componentProps?.['aria-describedby'], input.describedBy)
|
|
541
543
|
}),
|
|
@@ -34,10 +34,12 @@ const external_react_namespaceObject = require("react");
|
|
|
34
34
|
const button_cjs_namespaceObject = require("../ui/button.cjs");
|
|
35
35
|
const form_field_cjs_namespaceObject = require("../ui/form-field.cjs");
|
|
36
36
|
const textarea_cjs_namespaceObject = require("../ui/textarea.cjs");
|
|
37
|
+
const external_aria_ids_cjs_namespaceObject = require("./aria-ids.cjs");
|
|
37
38
|
function formatTemplate(template, values) {
|
|
38
39
|
return template.replace(/\{\{(\w+)\}\}/g, (match, token)=>token in values ? String(values[token]) : match);
|
|
39
40
|
}
|
|
40
|
-
function StringListField({ field, value, onChange, onBlur, error, disabled = false, required = false, inputRef, ariaDescribedBy
|
|
41
|
+
function StringListField({ field, value, onChange, onBlur, error, disabled = false, required = false, inputRef, ariaDescribedBy }) {
|
|
42
|
+
const { errorId } = (0, external_aria_ids_cjs_namespaceObject.useFieldIds)(field.name);
|
|
41
43
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(form_field_cjs_namespaceObject.FormField, {
|
|
42
44
|
"data-slot": "string-list-field",
|
|
43
45
|
children: [
|
|
@@ -55,19 +57,21 @@ function StringListField({ field, value, onChange, onBlur, error, disabled = fal
|
|
|
55
57
|
invalid: !!error,
|
|
56
58
|
disabled: disabled,
|
|
57
59
|
inputRef: inputRef,
|
|
58
|
-
ariaDescribedBy: ariaDescribedBy
|
|
60
|
+
ariaDescribedBy: ariaDescribedBy ?? (error ? errorId : void 0)
|
|
59
61
|
}),
|
|
60
62
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldDescription, {
|
|
61
63
|
children: field.description
|
|
62
64
|
}),
|
|
63
65
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(form_field_cjs_namespaceObject.FormFieldError, {
|
|
64
|
-
id:
|
|
66
|
+
id: errorId,
|
|
65
67
|
children: error
|
|
66
68
|
})
|
|
67
69
|
]
|
|
68
70
|
});
|
|
69
71
|
}
|
|
70
|
-
function StringListControl({ field, value, onChange, onBlur, invalid = false, disabled = false, inputRef, ariaDescribedBy
|
|
72
|
+
function StringListControl({ field, value, onChange, onBlur, invalid = false, disabled = false, inputRef, ariaDescribedBy }) {
|
|
73
|
+
const { errorId } = (0, external_aria_ids_cjs_namespaceObject.useFieldIds)(field.name);
|
|
74
|
+
const describedBy = ariaDescribedBy ?? (invalid ? errorId : void 0);
|
|
71
75
|
const items = value ?? [];
|
|
72
76
|
const maxItems = field.maxItems ?? 1 / 0;
|
|
73
77
|
const canAdd = !disabled && items.length < maxItems;
|
|
@@ -127,8 +131,8 @@ function StringListControl({ field, value, onChange, onBlur, invalid = false, di
|
|
|
127
131
|
disabled: disabled,
|
|
128
132
|
"aria-label": `${field.label} ${index + 1}`,
|
|
129
133
|
"aria-invalid": invalid || void 0,
|
|
130
|
-
"aria-describedby":
|
|
131
|
-
"aria-errormessage": invalid ?
|
|
134
|
+
"aria-describedby": describedBy,
|
|
135
|
+
"aria-errormessage": invalid ? errorId : void 0,
|
|
132
136
|
className: "flex-1"
|
|
133
137
|
}),
|
|
134
138
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(button_cjs_namespaceObject.Button, {
|
|
@@ -30,7 +30,7 @@ export interface StringListFieldProps {
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function StringListField({ field, value, onChange, onBlur, error, disabled, required, inputRef, ariaDescribedBy, }: StringListFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
32
32
|
export interface StringListControlProps extends Omit<StringListFieldProps, 'error' | 'required'> {
|
|
33
|
-
/** Marks every row invalid and points it at the
|
|
33
|
+
/** Marks every row invalid and points it at the field's error message. */
|
|
34
34
|
invalid?: boolean;
|
|
35
35
|
}
|
|
36
36
|
/** The rows and Add button of a string list, without its label, description or error. */
|
|
@@ -4,10 +4,12 @@ import { useCallback, useState } from "react";
|
|
|
4
4
|
import { Button } from "../ui/button.js";
|
|
5
5
|
import { FormField, FormFieldDescription, FormFieldError, FormFieldLabel } from "../ui/form-field.js";
|
|
6
6
|
import { Textarea } from "../ui/textarea.js";
|
|
7
|
+
import { useFieldIds } from "./aria-ids.js";
|
|
7
8
|
function formatTemplate(template, values) {
|
|
8
9
|
return template.replace(/\{\{(\w+)\}\}/g, (match, token)=>token in values ? String(values[token]) : match);
|
|
9
10
|
}
|
|
10
|
-
function StringListField({ field, value, onChange, onBlur, error, disabled = false, required = false, inputRef, ariaDescribedBy
|
|
11
|
+
function StringListField({ field, value, onChange, onBlur, error, disabled = false, required = false, inputRef, ariaDescribedBy }) {
|
|
12
|
+
const { errorId } = useFieldIds(field.name);
|
|
11
13
|
return /*#__PURE__*/ jsxs(FormField, {
|
|
12
14
|
"data-slot": "string-list-field",
|
|
13
15
|
children: [
|
|
@@ -25,19 +27,21 @@ function StringListField({ field, value, onChange, onBlur, error, disabled = fal
|
|
|
25
27
|
invalid: !!error,
|
|
26
28
|
disabled: disabled,
|
|
27
29
|
inputRef: inputRef,
|
|
28
|
-
ariaDescribedBy: ariaDescribedBy
|
|
30
|
+
ariaDescribedBy: ariaDescribedBy ?? (error ? errorId : void 0)
|
|
29
31
|
}),
|
|
30
32
|
/*#__PURE__*/ jsx(FormFieldDescription, {
|
|
31
33
|
children: field.description
|
|
32
34
|
}),
|
|
33
35
|
/*#__PURE__*/ jsx(FormFieldError, {
|
|
34
|
-
id:
|
|
36
|
+
id: errorId,
|
|
35
37
|
children: error
|
|
36
38
|
})
|
|
37
39
|
]
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
|
-
function StringListControl({ field, value, onChange, onBlur, invalid = false, disabled = false, inputRef, ariaDescribedBy
|
|
42
|
+
function StringListControl({ field, value, onChange, onBlur, invalid = false, disabled = false, inputRef, ariaDescribedBy }) {
|
|
43
|
+
const { errorId } = useFieldIds(field.name);
|
|
44
|
+
const describedBy = ariaDescribedBy ?? (invalid ? errorId : void 0);
|
|
41
45
|
const items = value ?? [];
|
|
42
46
|
const maxItems = field.maxItems ?? 1 / 0;
|
|
43
47
|
const canAdd = !disabled && items.length < maxItems;
|
|
@@ -97,8 +101,8 @@ function StringListControl({ field, value, onChange, onBlur, invalid = false, di
|
|
|
97
101
|
disabled: disabled,
|
|
98
102
|
"aria-label": `${field.label} ${index + 1}`,
|
|
99
103
|
"aria-invalid": invalid || void 0,
|
|
100
|
-
"aria-describedby":
|
|
101
|
-
"aria-errormessage": invalid ?
|
|
104
|
+
"aria-describedby": describedBy,
|
|
105
|
+
"aria-errormessage": invalid ? errorId : void 0,
|
|
102
106
|
className: "flex-1"
|
|
103
107
|
}),
|
|
104
108
|
/*#__PURE__*/ jsx(Button, {
|