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