@launchpad-ui/form 0.10.10 → 0.10.12
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/index.es.js +277 -328
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +277 -328
- package/dist/index.js.map +1 -1
- package/dist/style.css +2 -2
- package/package.json +11 -11
package/dist/index.js
CHANGED
@@ -85,12 +85,7 @@ const RequiredAsterisk = ({
|
|
85
85
|
...rest
|
86
86
|
}) => {
|
87
87
|
const classes = classix.cx(styles.requiredAsterisk, className);
|
88
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", {
|
89
|
-
...rest,
|
90
|
-
"data-test-id": testId,
|
91
|
-
className: classes,
|
92
|
-
children: "*"
|
93
|
-
});
|
88
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { ...rest, "data-test-id": testId, className: classes, children: "*" });
|
94
89
|
};
|
95
90
|
const Label = ({
|
96
91
|
disabled,
|
@@ -102,49 +97,50 @@ const Label = ({
|
|
102
97
|
...rest
|
103
98
|
}) => {
|
104
99
|
const classes = classix.cx(styles.label, className, disabled && styles.labelDisabled);
|
105
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("label", {
|
106
|
-
|
107
|
-
"
|
108
|
-
|
109
|
-
|
110
|
-
className: styles.labelOptional,
|
111
|
-
children: "(optional)"
|
112
|
-
}), required && !optional && /* @__PURE__ */ jsxRuntime.jsx(RequiredAsterisk, {})]
|
113
|
-
});
|
100
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("label", { ...rest, "data-test-id": testId, className: classes, children: [
|
101
|
+
children,
|
102
|
+
optional && !required && /* @__PURE__ */ jsxRuntime.jsx("small", { className: styles.labelOptional, children: "(optional)" }),
|
103
|
+
required && !optional && /* @__PURE__ */ jsxRuntime.jsx(RequiredAsterisk, {})
|
104
|
+
] });
|
114
105
|
};
|
115
|
-
const Checkbox = /* @__PURE__ */ react.forwardRef(
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
106
|
+
const Checkbox = /* @__PURE__ */ react.forwardRef(
|
107
|
+
({
|
108
|
+
"aria-label": ariaLabel,
|
109
|
+
"aria-labelledby": ariaLabelledby,
|
110
|
+
children,
|
111
|
+
disabled,
|
112
|
+
checked,
|
113
|
+
labelClassName,
|
114
|
+
"data-test-id": testId = "checkbox",
|
115
|
+
...rest
|
116
|
+
}, ref) => {
|
117
|
+
const hasAriaLabel = ariaLabel !== void 0 || ariaLabelledby !== void 0;
|
118
|
+
if (!children && !hasAriaLabel) {
|
119
|
+
console.warn(
|
120
|
+
"If you do not provide children, you must specify an aria-label for accessibility"
|
121
|
+
);
|
122
|
+
}
|
123
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Label, { className: labelClassName, children: [
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
125
|
+
"input",
|
126
|
+
{
|
127
|
+
...rest,
|
128
|
+
ref,
|
129
|
+
checked,
|
130
|
+
"aria-checked": checked ? "true" : "false",
|
131
|
+
"aria-label": ariaLabel,
|
132
|
+
"aria-labelledby": ariaLabelledby,
|
133
|
+
className: styles.checkbox,
|
134
|
+
disabled,
|
135
|
+
type: "checkbox",
|
136
|
+
"data-test-id": testId
|
137
|
+
}
|
138
|
+
),
|
139
|
+
" ",
|
140
|
+
disabled ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.labelDisabled, children }) : children
|
141
|
+
] });
|
128
142
|
}
|
129
|
-
|
130
|
-
className: labelClassName,
|
131
|
-
children: [/* @__PURE__ */ jsxRuntime.jsx("input", {
|
132
|
-
...rest,
|
133
|
-
ref,
|
134
|
-
checked,
|
135
|
-
"aria-checked": checked ? "true" : "false",
|
136
|
-
"aria-label": ariaLabel,
|
137
|
-
"aria-labelledby": ariaLabelledby,
|
138
|
-
className: styles.checkbox,
|
139
|
-
disabled,
|
140
|
-
type: "checkbox",
|
141
|
-
"data-test-id": testId
|
142
|
-
}), " ", disabled ? /* @__PURE__ */ jsxRuntime.jsx("span", {
|
143
|
-
className: styles.labelDisabled,
|
144
|
-
children
|
145
|
-
}) : children]
|
146
|
-
});
|
147
|
-
});
|
143
|
+
);
|
148
144
|
Checkbox.displayName = "Checkbox";
|
149
145
|
const createFieldErrorId = (fieldIdentifier) => fieldIdentifier ? `${[...fieldIdentifier].join("")}-err` : void 0;
|
150
146
|
function hasObjectChanged(obj1, obj2) {
|
@@ -162,101 +158,108 @@ function useObjectMemo(obj) {
|
|
162
158
|
return objRef.current;
|
163
159
|
}, [obj]);
|
164
160
|
}
|
165
|
-
const TextField = /* @__PURE__ */ react.forwardRef(
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
className: styles.suffixContainer,
|
182
|
-
|
161
|
+
const TextField = /* @__PURE__ */ react.forwardRef(
|
162
|
+
({
|
163
|
+
className,
|
164
|
+
type = "text",
|
165
|
+
tiny = false,
|
166
|
+
readOnly,
|
167
|
+
tabIndex = 0,
|
168
|
+
suffix: suffix2,
|
169
|
+
overrideWidth,
|
170
|
+
"data-test-id": testId = "text-field",
|
171
|
+
autoComplete,
|
172
|
+
...rest
|
173
|
+
}, ref) => {
|
174
|
+
const classes = overrideWidth ? className : classix.cx(styles.formInput, tiny && styles.formInputTiny, className);
|
175
|
+
const disablePasswordManagers = autoComplete === "off";
|
176
|
+
if (suffix2) {
|
177
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.suffixContainer, children: [
|
178
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
179
|
+
"input",
|
180
|
+
{
|
181
|
+
...rest,
|
182
|
+
type,
|
183
|
+
"data-test-id": testId,
|
184
|
+
autoComplete,
|
185
|
+
className: classes,
|
186
|
+
readOnly,
|
187
|
+
ref,
|
188
|
+
"aria-describedby": rest["aria-describedby"] || createFieldErrorId(rest.id)
|
189
|
+
}
|
190
|
+
),
|
191
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: styles.suffix, htmlFor: rest.id, children: suffix2 })
|
192
|
+
] });
|
193
|
+
}
|
194
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
195
|
+
"input",
|
196
|
+
{
|
183
197
|
...rest,
|
198
|
+
"data-1p-ignore": disablePasswordManagers,
|
184
199
|
type,
|
185
|
-
"data-test-id": testId,
|
186
|
-
autoComplete,
|
187
200
|
className: classes,
|
188
201
|
readOnly,
|
202
|
+
tabIndex,
|
203
|
+
autoComplete,
|
189
204
|
ref,
|
205
|
+
"data-test-id": testId,
|
206
|
+
style: overrideWidth ? {
|
207
|
+
width: overrideWidth
|
208
|
+
} : void 0,
|
190
209
|
"aria-describedby": rest["aria-describedby"] || createFieldErrorId(rest.id)
|
191
|
-
}
|
192
|
-
|
193
|
-
htmlFor: rest.id,
|
194
|
-
children: suffix2
|
195
|
-
})]
|
196
|
-
});
|
210
|
+
}
|
211
|
+
);
|
197
212
|
}
|
198
|
-
|
199
|
-
...rest,
|
200
|
-
"data-1p-ignore": disablePasswordManagers,
|
201
|
-
type,
|
202
|
-
className: classes,
|
203
|
-
readOnly,
|
204
|
-
tabIndex,
|
205
|
-
autoComplete,
|
206
|
-
ref,
|
207
|
-
"data-test-id": testId,
|
208
|
-
style: overrideWidth ? {
|
209
|
-
width: overrideWidth
|
210
|
-
} : void 0,
|
211
|
-
"aria-describedby": rest["aria-describedby"] || createFieldErrorId(rest.id)
|
212
|
-
});
|
213
|
-
});
|
213
|
+
);
|
214
214
|
TextField.displayName = "TextField";
|
215
|
-
const CompactTextField = /* @__PURE__ */ react.forwardRef(
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
htmlFor: id,
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
215
|
+
const CompactTextField = /* @__PURE__ */ react.forwardRef(
|
216
|
+
({
|
217
|
+
className,
|
218
|
+
id,
|
219
|
+
label: label2,
|
220
|
+
needsErrorFeedback,
|
221
|
+
value,
|
222
|
+
onFocus,
|
223
|
+
onBlur,
|
224
|
+
"data-test-id": testId = "compact-text-field",
|
225
|
+
...rest
|
226
|
+
}, ref) => {
|
227
|
+
const [isActive2, setIsActive] = react.useState(
|
228
|
+
(typeof value === "boolean" || value ? value.toString() : "").trim().length !== 0
|
229
|
+
);
|
230
|
+
const isActiveState = isActive2 || needsErrorFeedback;
|
231
|
+
const classes = classix.cx(styles.compactTextField, className, isActiveState && styles.isActive);
|
232
|
+
const placeholder = isActiveState ? "" : label2;
|
233
|
+
const handleFocus = (event) => {
|
234
|
+
setIsActive(true);
|
235
|
+
if (onFocus) {
|
236
|
+
onFocus(event);
|
237
|
+
}
|
238
|
+
};
|
239
|
+
const handleBlur = (event) => {
|
240
|
+
const value2 = event.target.value || "";
|
241
|
+
setIsActive(value2.trim().length !== 0);
|
242
|
+
if (onBlur) {
|
243
|
+
onBlur(event);
|
244
|
+
}
|
245
|
+
};
|
246
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes, "data-test-id": testId, children: [
|
247
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: id, children: label2 }),
|
248
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
249
|
+
TextField,
|
250
|
+
{
|
251
|
+
...rest,
|
252
|
+
id,
|
253
|
+
placeholder,
|
254
|
+
value,
|
255
|
+
ref,
|
256
|
+
onFocus: handleFocus,
|
257
|
+
onBlur: handleBlur
|
258
|
+
}
|
259
|
+
)
|
260
|
+
] });
|
261
|
+
}
|
262
|
+
);
|
260
263
|
CompactTextField.displayName = "CompactTextField";
|
261
264
|
const FieldError = ({
|
262
265
|
name,
|
@@ -268,18 +271,22 @@ const FieldError = ({
|
|
268
271
|
if (!errorMessage) {
|
269
272
|
return null;
|
270
273
|
}
|
271
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
274
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
275
|
+
"span",
|
276
|
+
{
|
277
|
+
...rest,
|
278
|
+
className: classix.cx(styles.fieldError, className),
|
279
|
+
"aria-live": "polite",
|
280
|
+
"data-test-id": testId,
|
281
|
+
"aria-label": "Error",
|
282
|
+
id: createFieldErrorId(name),
|
283
|
+
children: [
|
284
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.Icon, { name: "alert-rhombus", size: "small" }),
|
285
|
+
" ",
|
286
|
+
errorMessage
|
287
|
+
]
|
288
|
+
}
|
289
|
+
);
|
283
290
|
};
|
284
291
|
const FieldSet = ({
|
285
292
|
children,
|
@@ -288,12 +295,7 @@ const FieldSet = ({
|
|
288
295
|
...rest
|
289
296
|
}) => {
|
290
297
|
const classes = classix.cx(styles.fieldSet, className);
|
291
|
-
return /* @__PURE__ */ jsxRuntime.jsx("fieldset", {
|
292
|
-
"data-test-id": testId,
|
293
|
-
className: classes,
|
294
|
-
...rest,
|
295
|
-
children
|
296
|
-
});
|
298
|
+
return /* @__PURE__ */ jsxRuntime.jsx("fieldset", { "data-test-id": testId, className: classes, ...rest, children });
|
297
299
|
};
|
298
300
|
const Form = (props) => {
|
299
301
|
const {
|
@@ -304,13 +306,13 @@ const Form = (props) => {
|
|
304
306
|
"data-test-id": testId = "form",
|
305
307
|
...rest
|
306
308
|
} = props;
|
307
|
-
const classes = classix.cx(
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
});
|
309
|
+
const classes = classix.cx(
|
310
|
+
styles.form,
|
311
|
+
className,
|
312
|
+
inline && styles.formInline,
|
313
|
+
!!hasIncreasedErrorMargin && styles.formIncreasedErrorMargin
|
314
|
+
);
|
315
|
+
return /* @__PURE__ */ jsxRuntime.jsx("form", { ...rest, "data-test-id": testId, className: classes, children });
|
314
316
|
};
|
315
317
|
const FormGroup = (props) => {
|
316
318
|
const {
|
@@ -322,13 +324,12 @@ const FormGroup = (props) => {
|
|
322
324
|
"data-test-id": testId = "form-group",
|
323
325
|
...rest
|
324
326
|
} = props;
|
325
|
-
const classes = classix.cx(
|
326
|
-
|
327
|
-
className
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
});
|
327
|
+
const classes = classix.cx(
|
328
|
+
styles.formGroup,
|
329
|
+
className,
|
330
|
+
!ignoreValidation && isInvalid2 && styles.isInvalid
|
331
|
+
);
|
332
|
+
return /* @__PURE__ */ jsxRuntime.jsx("fieldset", { className: classes, "data-test-id": testId, ...rest, children });
|
332
333
|
};
|
333
334
|
const FormHint = ({
|
334
335
|
className,
|
@@ -337,12 +338,7 @@ const FormHint = ({
|
|
337
338
|
...rest
|
338
339
|
}) => {
|
339
340
|
const classes = classix.cx(styles.hint, className);
|
340
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", {
|
341
|
-
...rest,
|
342
|
-
"data-test-id": testId,
|
343
|
-
className: classes,
|
344
|
-
children
|
345
|
-
});
|
341
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...rest, "data-test-id": testId, className: classes, children });
|
346
342
|
};
|
347
343
|
const FormField = ({
|
348
344
|
isRequired,
|
@@ -364,29 +360,31 @@ const FormField = ({
|
|
364
360
|
const handleBlur = () => {
|
365
361
|
onBlur && onBlur(name);
|
366
362
|
};
|
367
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
isInvalid: isInvalid2,
|
372
|
-
onBlur: handleBlur,
|
373
|
-
"data-test-id": testId,
|
374
|
-
children: [label2 && /* @__PURE__ */ jsxRuntime.jsx(Label, {
|
375
|
-
htmlFor,
|
376
|
-
required: isRequired,
|
377
|
-
...LabelProps,
|
378
|
-
children: label2
|
379
|
-
}), hint2 && /* @__PURE__ */ jsxRuntime.jsx(FormHint, {
|
380
|
-
className: styles.hint,
|
381
|
-
...FormHintProps,
|
382
|
-
children: hint2
|
383
|
-
}), children, /* @__PURE__ */ jsxRuntime.jsx(FieldError, {
|
384
|
-
className: styles.fieldErrorMessage,
|
363
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
364
|
+
FormGroup,
|
365
|
+
{
|
366
|
+
className: classix.cx(styles.field, className),
|
385
367
|
name,
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
368
|
+
ignoreValidation,
|
369
|
+
isInvalid: isInvalid2,
|
370
|
+
onBlur: handleBlur,
|
371
|
+
"data-test-id": testId,
|
372
|
+
children: [
|
373
|
+
label2 && /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor, required: isRequired, ...LabelProps, children: label2 }),
|
374
|
+
hint2 && /* @__PURE__ */ jsxRuntime.jsx(FormHint, { className: styles.hint, ...FormHintProps, children: hint2 }),
|
375
|
+
children,
|
376
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
377
|
+
FieldError,
|
378
|
+
{
|
379
|
+
className: styles.fieldErrorMessage,
|
380
|
+
name,
|
381
|
+
errorMessage,
|
382
|
+
...FieldErrorProps
|
383
|
+
}
|
384
|
+
)
|
385
|
+
]
|
386
|
+
}
|
387
|
+
);
|
390
388
|
};
|
391
389
|
const IconField = ({
|
392
390
|
icon,
|
@@ -403,29 +401,23 @@ const IconField = ({
|
|
403
401
|
className: classix.cx(styles.iconFieldIcon, styles.iconFieldIconFill)
|
404
402
|
});
|
405
403
|
const classes = classix.cx(styles.iconField, renderIconLast ? "IconAfter" : "IconBefore", className);
|
406
|
-
const renderIcon = tooltip$1 ? /* @__PURE__ */ jsxRuntime.jsx(tooltip.Tooltip, {
|
407
|
-
|
408
|
-
|
409
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(button.IconButton, {
|
404
|
+
const renderIcon = tooltip$1 ? /* @__PURE__ */ jsxRuntime.jsx(tooltip.Tooltip, { content: tooltip$1, targetClassName: styles.iconFieldButton, children: /* @__PURE__ */ jsxRuntime.jsx(
|
405
|
+
button.IconButton,
|
406
|
+
{
|
410
407
|
icon: /* @__PURE__ */ react.cloneElement(icon, {
|
411
408
|
className: styles.iconFieldIconFill
|
412
409
|
}),
|
413
410
|
size: "small",
|
414
411
|
className: styles.iconFieldIcon,
|
415
|
-
style: renderIconLast ? {
|
416
|
-
right: "0.313rem"
|
417
|
-
} : {
|
418
|
-
left: "0.313rem"
|
419
|
-
},
|
412
|
+
style: renderIconLast ? { right: "0.313rem" } : { left: "0.313rem" },
|
420
413
|
"aria-label": ariaLabel
|
421
|
-
}
|
422
|
-
}) : iconElement;
|
423
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
});
|
414
|
+
}
|
415
|
+
) }) : iconElement;
|
416
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes, "data-test-id": testId, ...rest, children: [
|
417
|
+
!renderIconLast && renderIcon,
|
418
|
+
children,
|
419
|
+
renderIconLast && renderIcon
|
420
|
+
] });
|
429
421
|
};
|
430
422
|
const Radio = ({
|
431
423
|
"aria-label": ariaLabel,
|
@@ -442,29 +434,27 @@ const Radio = ({
|
|
442
434
|
}) => {
|
443
435
|
const hasAriaLabel = ariaLabel !== void 0 || ariaLabelledby !== void 0;
|
444
436
|
if (!children && !hasAriaLabel) {
|
445
|
-
console.warn(
|
437
|
+
console.warn(
|
438
|
+
"If you do not provide children, you must specify an aria-label for accessibility"
|
439
|
+
);
|
446
440
|
}
|
447
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
children
|
465
|
-
}) : children
|
466
|
-
})]
|
467
|
-
});
|
441
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
442
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
443
|
+
"input",
|
444
|
+
{
|
445
|
+
...rest,
|
446
|
+
"aria-label": ariaLabel,
|
447
|
+
"aria-labelledby": ariaLabelledby,
|
448
|
+
className: classix.cx(styles.radio, className),
|
449
|
+
checked,
|
450
|
+
disabled,
|
451
|
+
id,
|
452
|
+
"data-test-id": testId,
|
453
|
+
type: "radio"
|
454
|
+
}
|
455
|
+
),
|
456
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClassName, htmlFor: id, style: labelStyle, children: disabled ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.labelDisabled, children }) : children })
|
457
|
+
] });
|
468
458
|
};
|
469
459
|
const RadioGroup = (props) => {
|
470
460
|
const {
|
@@ -517,57 +507,41 @@ const RadioGroup = (props) => {
|
|
517
507
|
return null;
|
518
508
|
}
|
519
509
|
const radios = react.Children.map(children, (child) => updateRadioElems(child));
|
520
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("fieldset", {
|
521
|
-
"
|
522
|
-
|
523
|
-
|
524
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(visuallyHidden.VisuallyHidden, {
|
525
|
-
children: legend
|
526
|
-
})
|
527
|
-
}), /* @__PURE__ */ jsxRuntime.jsx("div", {
|
528
|
-
...rest,
|
529
|
-
children: radios
|
530
|
-
})]
|
531
|
-
});
|
510
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { "data-test-id": testId, ref: fieldsetRef, children: [
|
511
|
+
legend && /* @__PURE__ */ jsxRuntime.jsx("legend", { children: /* @__PURE__ */ jsxRuntime.jsx(visuallyHidden.VisuallyHidden, { children: legend }) }),
|
512
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ...rest, children: radios })
|
513
|
+
] });
|
532
514
|
};
|
533
|
-
const SelectField = /* @__PURE__ */ react.forwardRef(
|
534
|
-
className,
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
const classes = classix.cx(styles.formInput, className);
|
540
|
-
return /* @__PURE__ */ jsxRuntime.jsx("select", {
|
541
|
-
...rest,
|
542
|
-
"data-test-id": testId,
|
543
|
-
className: classes,
|
544
|
-
ref,
|
545
|
-
children
|
546
|
-
});
|
547
|
-
});
|
515
|
+
const SelectField = /* @__PURE__ */ react.forwardRef(
|
516
|
+
({ className, children, "data-test-id": testId = "select", ...rest }, ref) => {
|
517
|
+
const classes = classix.cx(styles.formInput, className);
|
518
|
+
return /* @__PURE__ */ jsxRuntime.jsx("select", { ...rest, "data-test-id": testId, className: classes, ref, children });
|
519
|
+
}
|
520
|
+
);
|
548
521
|
SelectField.displayName = "SelectField";
|
549
|
-
const TextArea = /* @__PURE__ */ react.forwardRef(
|
550
|
-
className,
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
}
|
522
|
+
const TextArea = /* @__PURE__ */ react.forwardRef(
|
523
|
+
({ className, "data-test-id": testId = "text-area", ...props }, ref) => {
|
524
|
+
const onKeyDown = (e) => {
|
525
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "ArrowLeft") {
|
526
|
+
e.stopPropagation();
|
527
|
+
}
|
528
|
+
if (e.key === "Escape") {
|
529
|
+
e.nativeEvent.stopImmediatePropagation();
|
530
|
+
}
|
531
|
+
};
|
532
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
533
|
+
"textarea",
|
534
|
+
{
|
535
|
+
...props,
|
536
|
+
className: classix.cx(styles.formInput, className),
|
537
|
+
ref,
|
538
|
+
"data-test-id": testId,
|
539
|
+
"aria-describedby": props["aria-describedby"] || createFieldErrorId(props.id),
|
540
|
+
onKeyDown
|
541
|
+
}
|
542
|
+
);
|
543
|
+
}
|
544
|
+
);
|
571
545
|
TextArea.displayName = "TextArea";
|
572
546
|
const defaultFormatOptions = {
|
573
547
|
maximumFractionDigits: 6
|
@@ -583,14 +557,8 @@ const useNumberField = ({
|
|
583
557
|
...defaultFormatOptions,
|
584
558
|
...otherProps.formatOptions
|
585
559
|
});
|
586
|
-
const {
|
587
|
-
|
588
|
-
} = i18n.useLocale();
|
589
|
-
const numberFieldState = numberfield.useNumberFieldState({
|
590
|
-
...otherProps,
|
591
|
-
locale,
|
592
|
-
formatOptions
|
593
|
-
});
|
560
|
+
const { locale } = i18n.useLocale();
|
561
|
+
const numberFieldState = numberfield.useNumberFieldState({ ...otherProps, locale, formatOptions });
|
594
562
|
const inputRef = react.useRef(null);
|
595
563
|
const {
|
596
564
|
descriptionProps: formHintProps,
|
@@ -600,52 +568,33 @@ const useNumberField = ({
|
|
600
568
|
inputProps,
|
601
569
|
incrementButtonProps,
|
602
570
|
decrementButtonProps
|
603
|
-
} = numberfield$1.useNumberField({
|
604
|
-
...otherProps,
|
605
|
-
formatOptions,
|
606
|
-
id
|
607
|
-
}, numberFieldState, inputRef);
|
571
|
+
} = numberfield$1.useNumberField({ ...otherProps, formatOptions, id }, numberFieldState, inputRef);
|
608
572
|
return {
|
609
573
|
fieldErrorProps,
|
610
574
|
formHintProps,
|
611
575
|
labelProps,
|
612
|
-
renderNumberField: () => /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
}), /* @__PURE__ */ jsxRuntime.jsx(Stepper, {
|
629
|
-
...decrementButtonProps,
|
630
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(icons.Icon, {
|
631
|
-
name: "chevron-down"
|
632
|
-
})
|
633
|
-
})]
|
634
|
-
})]
|
635
|
-
})
|
576
|
+
renderNumberField: () => /* @__PURE__ */ jsxRuntime.jsxs("div", { ...groupProps, className: styles.numberField, children: [
|
577
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
578
|
+
"input",
|
579
|
+
{
|
580
|
+
...inputProps,
|
581
|
+
className: classix.cx(styles.formInput, styles["numberField-input"]),
|
582
|
+
"data-test-id": testId,
|
583
|
+
name,
|
584
|
+
ref: inputRef
|
585
|
+
}
|
586
|
+
),
|
587
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles["numberField-stepperContainer"], children: [
|
588
|
+
/* @__PURE__ */ jsxRuntime.jsx(Stepper, { ...incrementButtonProps, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Icon, { name: "chevron-up" }) }),
|
589
|
+
/* @__PURE__ */ jsxRuntime.jsx(Stepper, { ...decrementButtonProps, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Icon, { name: "chevron-down" }) })
|
590
|
+
] })
|
591
|
+
] })
|
636
592
|
};
|
637
593
|
};
|
638
594
|
const Stepper = (props) => {
|
639
595
|
const buttonRef = react.useRef(null);
|
640
|
-
const {
|
641
|
-
|
642
|
-
} = button$1.useButton(props, buttonRef);
|
643
|
-
return /* @__PURE__ */ jsxRuntime.jsx("button", {
|
644
|
-
...buttonProps,
|
645
|
-
className: styles["numberField-stepper"],
|
646
|
-
ref: buttonRef,
|
647
|
-
children: props.children
|
648
|
-
});
|
596
|
+
const { buttonProps } = button$1.useButton(props, buttonRef);
|
597
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", { ...buttonProps, className: styles["numberField-stepper"], ref: buttonRef, children: props.children });
|
649
598
|
};
|
650
599
|
exports.Checkbox = Checkbox;
|
651
600
|
exports.CompactTextField = CompactTextField;
|