@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.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
- ...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
- });
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
- "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");
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
- 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
- });
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
- 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", {
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
- }), /* @__PURE__ */ jsxRuntime.jsx("label", {
192
- className: styles.suffix,
193
- htmlFor: rest.id,
194
- children: suffix2
195
- })]
196
- });
210
+ }
211
+ );
197
212
  }
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
- });
213
+ );
214
214
  TextField.displayName = "TextField";
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
- });
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("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
- });
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(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
- });
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(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
- });
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(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,
363
+ return /* @__PURE__ */ jsxRuntime.jsxs(
364
+ FormGroup,
365
+ {
366
+ className: classix.cx(styles.field, className),
385
367
  name,
386
- errorMessage,
387
- ...FieldErrorProps
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
- content: tooltip$1,
408
- targetClassName: styles.iconFieldButton,
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
- className: classes,
425
- "data-test-id": testId,
426
- ...rest,
427
- children: [!renderIconLast && renderIcon, children, renderIconLast && renderIcon]
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("If you do not provide children, you must specify an aria-label for accessibility");
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
- 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
- });
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
- "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
- });
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
- 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
- });
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
- "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
- });
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
- locale
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
- ...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
- })
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
- 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
- });
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;