@launchpad-ui/form 0.15.11 → 0.15.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.
Files changed (44) hide show
  1. package/package.json +5 -5
  2. package/dist/Checkbox.d.ts +0 -17
  3. package/dist/Checkbox.d.ts.map +0 -1
  4. package/dist/CompactTextField.d.ts +0 -14
  5. package/dist/CompactTextField.d.ts.map +0 -1
  6. package/dist/FieldError.d.ts +0 -16
  7. package/dist/FieldError.d.ts.map +0 -1
  8. package/dist/FieldSet.d.ts +0 -13
  9. package/dist/FieldSet.d.ts.map +0 -1
  10. package/dist/Form.d.ts +0 -15
  11. package/dist/Form.d.ts.map +0 -1
  12. package/dist/FormField.d.ts +0 -30
  13. package/dist/FormField.d.ts.map +0 -1
  14. package/dist/FormGroup.d.ts +0 -16
  15. package/dist/FormGroup.d.ts.map +0 -1
  16. package/dist/FormHint.d.ts +0 -13
  17. package/dist/FormHint.d.ts.map +0 -1
  18. package/dist/IconField.d.ts +0 -19
  19. package/dist/IconField.d.ts.map +0 -1
  20. package/dist/Label.d.ts +0 -16
  21. package/dist/Label.d.ts.map +0 -1
  22. package/dist/Radio.d.ts +0 -15
  23. package/dist/Radio.d.ts.map +0 -1
  24. package/dist/RadioGroup.d.ts +0 -46
  25. package/dist/RadioGroup.d.ts.map +0 -1
  26. package/dist/RequiredAsterisk.d.ts +0 -13
  27. package/dist/RequiredAsterisk.d.ts.map +0 -1
  28. package/dist/SelectField.d.ts +0 -13
  29. package/dist/SelectField.d.ts.map +0 -1
  30. package/dist/TextArea.d.ts +0 -13
  31. package/dist/TextArea.d.ts.map +0 -1
  32. package/dist/TextField.d.ts +0 -16
  33. package/dist/TextField.d.ts.map +0 -1
  34. package/dist/index.d.ts +0 -35
  35. package/dist/index.d.ts.map +0 -1
  36. package/dist/index.es.js +0 -558
  37. package/dist/index.es.js.map +0 -1
  38. package/dist/index.js +0 -594
  39. package/dist/index.js.map +0 -1
  40. package/dist/style.css +0 -2
  41. package/dist/useNumberField.d.ts +0 -23
  42. package/dist/useNumberField.d.ts.map +0 -1
  43. package/dist/utils/index.d.ts +0 -6
  44. package/dist/utils/index.d.ts.map +0 -1
package/dist/index.js DELETED
@@ -1,594 +0,0 @@
1
- require('./style.css');
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- const react = __toESM(require("react"));
23
- const classix = __toESM(require("classix"));
24
- const react_jsx_runtime = __toESM(require("react/jsx-runtime"));
25
- const __launchpad_ui_icons = __toESM(require("@launchpad-ui/icons"));
26
- const __launchpad_ui_button = __toESM(require("@launchpad-ui/button"));
27
- const __launchpad_ui_tooltip = __toESM(require("@launchpad-ui/tooltip"));
28
- const __react_aria_visually_hidden = __toESM(require("@react-aria/visually-hidden"));
29
- const __react_aria_button = __toESM(require("@react-aria/button"));
30
- const __react_aria_i18n = __toESM(require("@react-aria/i18n"));
31
- const __react_aria_numberfield = __toESM(require("@react-aria/numberfield"));
32
- const __react_stately_numberfield = __toESM(require("@react-stately/numberfield"));
33
- const checkbox = "QJPOUG_checkbox";
34
- const compactTextField = "QJPOUG_compactTextField";
35
- const field = "QJPOUG_field";
36
- const fieldError = "QJPOUG_fieldError";
37
- const fieldErrorMessage = "QJPOUG_fieldErrorMessage";
38
- const fieldSet = "QJPOUG_fieldSet";
39
- const form = "QJPOUG_form";
40
- const formGroup = "QJPOUG_formGroup";
41
- const formIncreasedErrorMargin = "QJPOUG_formIncreasedErrorMargin";
42
- const formInline = "QJPOUG_formInline";
43
- const formInput = "QJPOUG_formInput";
44
- const formInputTiny = "QJPOUG_formInputTiny";
45
- const hint = "QJPOUG_hint";
46
- const iconField = "QJPOUG_iconField";
47
- const iconFieldButton = "QJPOUG_iconFieldButton";
48
- const iconFieldIcon = "QJPOUG_iconFieldIcon";
49
- const iconFieldIconFill = "QJPOUG_iconFieldIconFill";
50
- const inlineForm = "QJPOUG_inlineForm";
51
- const isActive = "QJPOUG_isActive";
52
- const isDisabled = "QJPOUG_isDisabled";
53
- const isFocused = "QJPOUG_isFocused";
54
- const isInvalid = "QJPOUG_isInvalid";
55
- const label = "QJPOUG_label";
56
- const labelDisabled = "QJPOUG_labelDisabled";
57
- const labelOptional = "QJPOUG_labelOptional";
58
- const number = "QJPOUG_number";
59
- const numberField = "QJPOUG_numberField";
60
- const radio = "QJPOUG_radio";
61
- const requiredAsterisk = "QJPOUG_requiredAsterisk";
62
- const suffix = "QJPOUG_suffix";
63
- const suffixContainer = "QJPOUG_suffixContainer";
64
- var Form_module_default = {
65
- checkbox,
66
- compactTextField,
67
- field,
68
- fieldError,
69
- fieldErrorMessage,
70
- fieldSet,
71
- form,
72
- formGroup,
73
- formIncreasedErrorMargin,
74
- formInline,
75
- formInput,
76
- formInputTiny,
77
- hint,
78
- iconField,
79
- iconFieldButton,
80
- iconFieldIcon,
81
- iconFieldIconFill,
82
- inlineForm,
83
- isActive,
84
- isDisabled,
85
- isFocused,
86
- isInvalid,
87
- label,
88
- labelDisabled,
89
- labelOptional,
90
- number,
91
- numberField,
92
- "numberField-input": "QJPOUG_numberField-input",
93
- "numberField-stepper": "QJPOUG_numberField-stepper",
94
- "numberField-stepperContainer": "QJPOUG_numberField-stepperContainer",
95
- radio,
96
- requiredAsterisk,
97
- suffix,
98
- suffixContainer
99
- };
100
- /**
101
- * @deprecated use `Label` from `@launchpad-ui/components` instead
102
- *
103
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-textfield--docs
104
- */
105
- const RequiredAsterisk = ({ className, "data-test-id": testId = "required-asterisk",...rest }) => {
106
- const classes = (0, classix.cx)(Form_module_default.requiredAsterisk, className);
107
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
108
- ...rest,
109
- "data-test-id": testId,
110
- className: classes,
111
- children: "*"
112
- });
113
- };
114
- /**
115
- * @deprecated use `Label` from `@launchpad-ui/components` instead
116
- *
117
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-textfield--docs
118
- */
119
- const Label = ({ disabled, className, children, required = false, optional = false, "data-test-id": testId = "label",...rest }) => {
120
- const classes = (0, classix.cx)(Form_module_default.label, className, disabled && Form_module_default.labelDisabled);
121
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
122
- ...rest,
123
- "data-test-id": testId,
124
- className: classes,
125
- children: [
126
- children,
127
- optional && !required && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", {
128
- className: Form_module_default.labelOptional,
129
- children: "(optional)"
130
- }),
131
- required && !optional && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RequiredAsterisk, {})
132
- ]
133
- });
134
- };
135
- /**
136
- * @deprecated use `Checkbox` or `CheckboxGroup` from `@launchpad-ui/components` instead
137
- *
138
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-checkbox--docs
139
- */
140
- const Checkbox = /* @__PURE__ */ (0, react.forwardRef)(({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, children, disabled, checked, labelClassName, "data-test-id": testId = "checkbox",...rest }, ref) => {
141
- const hasAriaLabel = ariaLabel !== void 0 || ariaLabelledby !== void 0;
142
- if (!children && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
143
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Label, {
144
- className: labelClassName,
145
- children: [
146
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
147
- ...rest,
148
- ref,
149
- checked,
150
- "aria-checked": checked ? "true" : "false",
151
- "aria-label": ariaLabel,
152
- "aria-labelledby": ariaLabelledby,
153
- className: Form_module_default.checkbox,
154
- disabled,
155
- type: "checkbox",
156
- "data-test-id": testId
157
- }),
158
- " ",
159
- disabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
160
- className: Form_module_default.labelDisabled,
161
- children
162
- }) : children
163
- ]
164
- });
165
- });
166
- Checkbox.displayName = "Checkbox";
167
- const createFieldErrorId = (fieldIdentifier) => fieldIdentifier ? `${[...fieldIdentifier].join("")}-err` : void 0;
168
- function hasObjectChanged(obj1, obj2) {
169
- return Object.keys(obj1).length !== Object.keys(obj2).length || Object.keys(obj1).some((k) => {
170
- const key = k;
171
- return typeof obj1[key] === "object" && typeof obj2[key] === "object" ? hasObjectChanged(obj1[key], obj2[key]) : obj1[key] !== obj2[key];
172
- });
173
- }
174
- function useObjectMemo(obj) {
175
- const objRef = (0, react.useRef)(obj);
176
- return (0, react.useMemo)(() => {
177
- if (hasObjectChanged(obj, objRef.current)) objRef.current = obj;
178
- return objRef.current;
179
- }, [obj]);
180
- }
181
- /**
182
- * @deprecated use `TextField` from `@launchpad-ui/components` instead
183
- *
184
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-textfield--docs
185
- */
186
- const TextField = /* @__PURE__ */ (0, react.forwardRef)(({ className, type = "text", tiny = false, readOnly, tabIndex = 0, suffix: suffix$1, overrideWidth, "data-test-id": testId = "text-field", autoComplete,...rest }, ref) => {
187
- const classes = overrideWidth ? className : (0, classix.cx)(Form_module_default.formInput, tiny && Form_module_default.formInputTiny, className);
188
- const disablePasswordManagers = autoComplete === "off";
189
- if (suffix$1) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
190
- className: Form_module_default.suffixContainer,
191
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
192
- ...rest,
193
- type,
194
- "data-test-id": testId,
195
- autoComplete,
196
- className: classes,
197
- readOnly,
198
- ref,
199
- "aria-describedby": rest["aria-describedby"] || createFieldErrorId(rest.id)
200
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
201
- className: Form_module_default.suffix,
202
- htmlFor: rest.id,
203
- children: suffix$1
204
- })]
205
- });
206
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
207
- ...rest,
208
- "data-1p-ignore": disablePasswordManagers,
209
- type,
210
- className: classes,
211
- readOnly,
212
- tabIndex,
213
- autoComplete,
214
- ref,
215
- "data-test-id": testId,
216
- style: overrideWidth ? { width: overrideWidth } : void 0,
217
- "aria-describedby": rest["aria-describedby"] || createFieldErrorId(rest.id)
218
- });
219
- });
220
- TextField.displayName = "TextField";
221
- /**
222
- * @deprecated use `TextField` from `@launchpad-ui/components` instead
223
- *
224
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-textfield--docs
225
- */
226
- const CompactTextField = /* @__PURE__ */ (0, react.forwardRef)(({ className, id, label: label$1, needsErrorFeedback, value, onFocus, onBlur, "data-test-id": testId = "compact-text-field",...rest }, ref) => {
227
- const [isActive$1, setIsActive] = (0, react.useState)((typeof value === "boolean" || value ? value.toString() : "").trim().length !== 0);
228
- const isActiveState = isActive$1 || needsErrorFeedback;
229
- const classes = (0, classix.cx)(Form_module_default.compactTextField, className, isActiveState && Form_module_default.isActive);
230
- const placeholder = isActiveState ? "" : label$1;
231
- const handleFocus = (event) => {
232
- setIsActive(true);
233
- if (onFocus) onFocus(event);
234
- };
235
- const handleBlur = (event) => {
236
- const value$1 = event.target.value || "";
237
- setIsActive(value$1.trim().length !== 0);
238
- if (onBlur) onBlur(event);
239
- };
240
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
241
- className: classes,
242
- "data-test-id": testId,
243
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
244
- htmlFor: id,
245
- children: label$1
246
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextField, {
247
- ...rest,
248
- id,
249
- placeholder,
250
- value,
251
- ref,
252
- onFocus: handleFocus,
253
- onBlur: handleBlur
254
- })]
255
- });
256
- });
257
- CompactTextField.displayName = "CompactTextField";
258
- /**
259
- * @deprecated use `FieldError` from `@launchpad-ui/components` instead
260
- *
261
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-textfield--docs
262
- */
263
- const FieldError = ({ name, errorMessage, className, "data-test-id": testId = "field-error",...rest }) => {
264
- if (!errorMessage) return null;
265
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
266
- ...rest,
267
- className: (0, classix.cx)(Form_module_default.fieldError, className),
268
- "aria-live": "polite",
269
- "data-test-id": testId,
270
- "aria-label": "Error",
271
- id: createFieldErrorId(name),
272
- children: [
273
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__launchpad_ui_icons.Icon, {
274
- name: "alert-rhombus",
275
- size: "small"
276
- }),
277
- " ",
278
- errorMessage
279
- ]
280
- });
281
- };
282
- /**
283
- * @deprecated use `FieldGroup` from `@launchpad-ui/components` instead
284
- *
285
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-fieldgroup--docs
286
- */
287
- const FieldSet = ({ children, className, "data-test-id": testId = "field-set",...rest }) => {
288
- const classes = (0, classix.cx)(Form_module_default.fieldSet, className);
289
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("fieldset", {
290
- "data-test-id": testId,
291
- className: classes,
292
- ...rest,
293
- children
294
- });
295
- };
296
- /**
297
- * @deprecated use `Form` from `@launchpad-ui/components` instead
298
- *
299
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-form--docs
300
- */
301
- const Form = (props) => {
302
- const { className, inline, children, hasIncreasedErrorMargin, "data-test-id": testId = "form",...rest } = props;
303
- const classes = (0, classix.cx)(Form_module_default.form, className, inline && Form_module_default.formInline, !!hasIncreasedErrorMargin && Form_module_default.formIncreasedErrorMargin);
304
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
305
- ...rest,
306
- "data-test-id": testId,
307
- className: classes,
308
- children
309
- });
310
- };
311
- /**
312
- * @deprecated use `FieldGroup` from `@launchpad-ui/components` instead
313
- *
314
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-fieldgroup--docs
315
- */
316
- const FormGroup = (props) => {
317
- const { className, name, ignoreValidation, isInvalid: isInvalid$1, children, "data-test-id": testId = "form-group",...rest } = props;
318
- const classes = (0, classix.cx)(Form_module_default.formGroup, className, !ignoreValidation && isInvalid$1 && Form_module_default.isInvalid);
319
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("fieldset", {
320
- className: classes,
321
- "data-test-id": testId,
322
- ...rest,
323
- children
324
- });
325
- };
326
- /**
327
- * @deprecated use `Text` with `[slot='description']` from `@launchpad-ui/components` instead
328
- *
329
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-textfield--docs
330
- */
331
- const FormHint = ({ className, children, "data-test-id": testId = "form-hint",...rest }) => {
332
- const classes = (0, classix.cx)(Form_module_default.hint, className);
333
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
334
- ...rest,
335
- "data-test-id": testId,
336
- className: classes,
337
- children
338
- });
339
- };
340
- /**
341
- * @deprecated use form elements from `@launchpad-ui/components` instead
342
- *
343
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-textfield--docs
344
- */
345
- const FormField = ({ isRequired, label: label$1, name, htmlFor, hint: hint$1, errorMessage, ignoreValidation, isInvalid: isInvalid$1, children, className, onBlur, "data-test-id": testId = "form-field", LabelProps = {}, FormHintProps = {}, FieldErrorProps = {} }) => {
346
- const handleBlur = () => {
347
- onBlur?.(name);
348
- };
349
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(FormGroup, {
350
- className: (0, classix.cx)(Form_module_default.field, className),
351
- name,
352
- ignoreValidation,
353
- isInvalid: isInvalid$1,
354
- onBlur: handleBlur,
355
- "data-test-id": testId,
356
- children: [
357
- label$1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
358
- htmlFor,
359
- required: isRequired,
360
- ...LabelProps,
361
- children: label$1
362
- }),
363
- hint$1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormHint, {
364
- className: Form_module_default.hint,
365
- ...FormHintProps,
366
- children: hint$1
367
- }),
368
- children,
369
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FieldError, {
370
- className: Form_module_default.fieldErrorMessage,
371
- name,
372
- errorMessage,
373
- ...FieldErrorProps
374
- })
375
- ]
376
- });
377
- };
378
- /**
379
- * @deprecated use `Group` from `@launchpad-ui/components` instead
380
- *
381
- * https://launchpad.launchdarkly.com/?path=/docs/components-content-group--docs
382
- */
383
- const IconField = ({ icon, children, className, "data-test-id": testId = "icon-field", tooltip, renderIconLast = false, ariaLabel = "More info",...rest }) => {
384
- const iconElement = /* @__PURE__ */ (0, react.cloneElement)(icon, {
385
- size: "small",
386
- className: (0, classix.cx)(Form_module_default.iconFieldIcon, Form_module_default.iconFieldIconFill)
387
- });
388
- const classes = (0, classix.cx)(Form_module_default.iconField, renderIconLast ? "IconAfter" : "IconBefore", className);
389
- const renderIcon = tooltip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__launchpad_ui_tooltip.Tooltip, {
390
- content: tooltip,
391
- targetClassName: Form_module_default.iconFieldButton,
392
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__launchpad_ui_button.IconButton, {
393
- icon: /* @__PURE__ */ (0, react.cloneElement)(icon, { className: Form_module_default.iconFieldIconFill }),
394
- size: "small",
395
- className: Form_module_default.iconFieldIcon,
396
- style: renderIconLast ? { right: "0.313rem" } : { left: "0.313rem" },
397
- "aria-label": ariaLabel
398
- })
399
- }) : iconElement;
400
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
401
- className: classes,
402
- "data-test-id": testId,
403
- ...rest,
404
- children: [
405
- !renderIconLast && renderIcon,
406
- children,
407
- renderIconLast && renderIcon
408
- ]
409
- });
410
- };
411
- /**
412
- * @deprecated use `RadioGroup` from `@launchpad-ui/components` instead
413
- *
414
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-radiogroup--docs
415
- */
416
- const Radio = ({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, checked = false, children, className, disabled = false, id, labelClassName, labelStyle, "data-test-id": testId = "radio",...rest }) => {
417
- const hasAriaLabel = ariaLabel !== void 0 || ariaLabelledby !== void 0;
418
- if (!children && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
419
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
420
- ...rest,
421
- "aria-label": ariaLabel,
422
- "aria-labelledby": ariaLabelledby,
423
- className: (0, classix.cx)(Form_module_default.radio, className),
424
- checked,
425
- disabled,
426
- id,
427
- "data-test-id": testId,
428
- type: "radio"
429
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Label, {
430
- className: labelClassName,
431
- htmlFor: id,
432
- style: labelStyle,
433
- children: disabled ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
434
- className: Form_module_default.labelDisabled,
435
- children
436
- }) : children
437
- })] });
438
- };
439
- /**
440
- * @deprecated use `RadioGroup` from `@launchpad-ui/components` instead
441
- *
442
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-radiogroup--docs
443
- */
444
- const RadioGroup = (props) => {
445
- const { name, value, onChange, children, disabled, legend, "data-test-id": testId = "radio-group",...rest } = props;
446
- const fieldsetRef = (0, react.useRef)(null);
447
- function updateRadioElems(elem) {
448
- if (!/* @__PURE__ */ (0, react.isValidElement)(elem)) return elem;
449
- const item = elem;
450
- if (item?.type && item.type === Radio) return /* @__PURE__ */ (0, react.cloneElement)(item, {
451
- ...item.props,
452
- name,
453
- checked: item.props.value === value,
454
- onChange,
455
- disabled: typeof item.props?.disabled !== "undefined" ? item.props.disabled : disabled
456
- });
457
- if (item?.type && item.type === Label) return /* @__PURE__ */ (0, react.cloneElement)(item, {
458
- ...item.props,
459
- onChange,
460
- disabled
461
- });
462
- const elemChildren = item?.props?.children;
463
- if (elemChildren) {
464
- if (Array.isArray(elemChildren)) return /* @__PURE__ */ (0, react.cloneElement)(item, { children: react.Children.map(elemChildren, (elemChild) => updateRadioElems(elemChild)) });
465
- return /* @__PURE__ */ (0, react.cloneElement)(item, { children: updateRadioElems(elemChildren) });
466
- }
467
- if (item?.type && item.type !== Radio && item.type !== Label) return item;
468
- return null;
469
- }
470
- const radios = react.Children.map(children, (child) => updateRadioElems(child));
471
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("fieldset", {
472
- "data-test-id": testId,
473
- ref: fieldsetRef,
474
- children: [legend && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("legend", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__react_aria_visually_hidden.VisuallyHidden, { children: legend }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
475
- ...rest,
476
- children: radios
477
- })]
478
- });
479
- };
480
- /**
481
- * @deprecated use `Select` from `@launchpad-ui/components` instead
482
- *
483
- * https://launchpad.launchdarkly.com/?path=/docs/components-pickers-select--docs
484
- */
485
- const SelectField = /* @__PURE__ */ (0, react.forwardRef)(({ className, children, "data-test-id": testId = "select",...rest }, ref) => {
486
- const classes = (0, classix.cx)(Form_module_default.formInput, className);
487
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
488
- ...rest,
489
- "data-test-id": testId,
490
- className: classes,
491
- ref,
492
- children
493
- });
494
- });
495
- SelectField.displayName = "SelectField";
496
- /**
497
- * @deprecated use `TextArea` from `@launchpad-ui/components` instead
498
- *
499
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-textfield--docs#multi%20line
500
- */
501
- const TextArea = /* @__PURE__ */ (0, react.forwardRef)(({ className, "data-test-id": testId = "text-area",...props }, ref) => {
502
- const onKeyDown = (e) => {
503
- if (e.key === "ArrowRight" || e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "ArrowLeft") e.stopPropagation();
504
- if (e.key === "Escape") e.nativeEvent.stopImmediatePropagation();
505
- };
506
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
507
- ...props,
508
- className: (0, classix.cx)(Form_module_default.formInput, className),
509
- ref,
510
- "data-test-id": testId,
511
- "aria-describedby": props["aria-describedby"] || createFieldErrorId(props.id),
512
- onKeyDown
513
- });
514
- });
515
- TextArea.displayName = "TextArea";
516
- const defaultFormatOptions = { maximumFractionDigits: 6 };
517
- /**
518
- * @deprecated use `NumberField` from `@launchpad-ui/components` instead
519
- *
520
- * https://launchpad.launchdarkly.com/?path=/docs/components-forms-numberfield--docs
521
- */
522
- const useNumberField = ({ className, "data-test-id": testId = "input", id, name,...otherProps } = {}) => {
523
- const formatOptions = useObjectMemo({
524
- ...defaultFormatOptions,
525
- ...otherProps.formatOptions
526
- });
527
- const { locale } = (0, __react_aria_i18n.useLocale)();
528
- const numberFieldState = (0, __react_stately_numberfield.useNumberFieldState)({
529
- ...otherProps,
530
- locale,
531
- formatOptions
532
- });
533
- const inputRef = (0, react.useRef)(null);
534
- const { descriptionProps: formHintProps, errorMessageProps: fieldErrorProps, labelProps, groupProps, inputProps, incrementButtonProps, decrementButtonProps } = (0, __react_aria_numberfield.useNumberField)({
535
- ...otherProps,
536
- formatOptions,
537
- id
538
- }, numberFieldState, inputRef);
539
- return {
540
- fieldErrorProps,
541
- formHintProps,
542
- labelProps,
543
- renderNumberField: () => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
544
- ...groupProps,
545
- className: Form_module_default.numberField,
546
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
547
- ...inputProps,
548
- className: (0, classix.cx)(Form_module_default.formInput, Form_module_default["numberField-input"]),
549
- "data-test-id": testId,
550
- name,
551
- ref: inputRef
552
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
553
- className: Form_module_default["numberField-stepperContainer"],
554
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Stepper, {
555
- ...incrementButtonProps,
556
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__launchpad_ui_icons.Icon, { name: "chevron-up" })
557
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Stepper, {
558
- ...decrementButtonProps,
559
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__launchpad_ui_icons.Icon, { name: "chevron-down" })
560
- })]
561
- })]
562
- })
563
- };
564
- };
565
- const Stepper = (props) => {
566
- const buttonRef = (0, react.useRef)(null);
567
- const { buttonProps } = (0, __react_aria_button.useButton)(props, buttonRef);
568
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
569
- type: "button",
570
- ...buttonProps,
571
- className: Form_module_default["numberField-stepper"],
572
- ref: buttonRef,
573
- children: props.children
574
- });
575
- };
576
- exports.Checkbox = Checkbox;
577
- exports.CompactTextField = CompactTextField;
578
- exports.FieldError = FieldError;
579
- exports.FieldSet = FieldSet;
580
- exports.Form = Form;
581
- exports.FormField = FormField;
582
- exports.FormGroup = FormGroup;
583
- exports.FormHint = FormHint;
584
- exports.IconField = IconField;
585
- exports.Label = Label;
586
- exports.Radio = Radio;
587
- exports.RadioGroup = RadioGroup;
588
- exports.RequiredAsterisk = RequiredAsterisk;
589
- exports.SelectField = SelectField;
590
- exports.TextArea = TextArea;
591
- exports.TextField = TextField;
592
- exports.useNumberField = useNumberField;
593
-
594
- //# sourceMappingURL=index.js.map