@launchpad-ui/form 0.8.12 → 0.8.14
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/Checkbox.d.ts +3 -9
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/CompactTextField.d.ts +1 -9
- package/dist/CompactTextField.d.ts.map +1 -1
- package/dist/FieldError.d.ts +3 -3
- package/dist/FieldError.d.ts.map +1 -1
- package/dist/FieldSet.d.ts +3 -3
- package/dist/FieldSet.d.ts.map +1 -1
- package/dist/Form.d.ts +3 -3
- package/dist/Form.d.ts.map +1 -1
- package/dist/FormField.d.ts +1 -1
- package/dist/FormField.d.ts.map +1 -1
- package/dist/FormGroup.d.ts +3 -3
- package/dist/FormGroup.d.ts.map +1 -1
- package/dist/FormHint.d.ts +3 -3
- package/dist/FormHint.d.ts.map +1 -1
- package/dist/IconField.d.ts +3 -3
- package/dist/IconField.d.ts.map +1 -1
- package/dist/Label.d.ts +3 -3
- package/dist/Label.d.ts.map +1 -1
- package/dist/Radio.d.ts +3 -3
- package/dist/Radio.d.ts.map +1 -1
- package/dist/RadioGroup.d.ts +1 -1
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RequiredAsterisk.d.ts +3 -3
- package/dist/RequiredAsterisk.d.ts.map +1 -1
- package/dist/SelectField.d.ts +3 -3
- package/dist/SelectField.d.ts.map +1 -1
- package/dist/TextArea.d.ts +3 -5
- package/dist/TextArea.d.ts.map +1 -1
- package/dist/TextField.d.ts +3 -8
- package/dist/TextField.d.ts.map +1 -1
- package/dist/index.es.js +238 -265
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +239 -266
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import './style.css';
|
|
2
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
3
|
import { forwardRef, useState, useRef, Children, isValidElement, cloneElement } from "react";
|
|
3
4
|
import { cx } from "classix";
|
|
4
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import { AlertRhombus } from "@launchpad-ui/icons";
|
|
6
6
|
import { VisuallyHidden } from "@react-aria/visually-hidden";
|
|
7
7
|
const formGroup = "_formGroup_p76jo_10";
|
|
@@ -68,12 +68,7 @@ const RequiredAsterisk = ({
|
|
|
68
68
|
...rest
|
|
69
69
|
}) => {
|
|
70
70
|
const classes = cx(styles.requiredAsterisk, className);
|
|
71
|
-
return /* @__PURE__ */ jsx("span", {
|
|
72
|
-
...rest,
|
|
73
|
-
"data-test-id": testId,
|
|
74
|
-
className: classes,
|
|
75
|
-
children: "*"
|
|
76
|
-
});
|
|
71
|
+
return /* @__PURE__ */ jsx("span", { ...rest, "data-test-id": testId, className: classes, children: "*" });
|
|
77
72
|
};
|
|
78
73
|
const Label = ({
|
|
79
74
|
disabled,
|
|
@@ -85,141 +80,149 @@ const Label = ({
|
|
|
85
80
|
...rest
|
|
86
81
|
}) => {
|
|
87
82
|
const classes = cx(styles.label, className, disabled && styles.labelDisabled);
|
|
88
|
-
return /* @__PURE__ */ jsxs("label", {
|
|
89
|
-
|
|
90
|
-
"
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
className: styles.labelOptional,
|
|
94
|
-
children: "(optional)"
|
|
95
|
-
}), required && !optional && /* @__PURE__ */ jsx(RequiredAsterisk, {})]
|
|
96
|
-
});
|
|
83
|
+
return /* @__PURE__ */ jsxs("label", { ...rest, "data-test-id": testId, className: classes, children: [
|
|
84
|
+
children,
|
|
85
|
+
optional && !required && /* @__PURE__ */ jsx("small", { className: styles.labelOptional, children: "(optional)" }),
|
|
86
|
+
required && !optional && /* @__PURE__ */ jsx(RequiredAsterisk, {})
|
|
87
|
+
] });
|
|
97
88
|
};
|
|
98
|
-
const Checkbox = forwardRef(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
89
|
+
const Checkbox = forwardRef(
|
|
90
|
+
({
|
|
91
|
+
"aria-label": ariaLabel,
|
|
92
|
+
"aria-labelledby": ariaLabelledby,
|
|
93
|
+
children,
|
|
94
|
+
disabled,
|
|
95
|
+
checked,
|
|
96
|
+
labelClassName,
|
|
97
|
+
"data-test-id": testId = "checkbox",
|
|
98
|
+
...rest
|
|
99
|
+
}, ref) => {
|
|
100
|
+
const hasAriaLabel = ariaLabel !== void 0 || ariaLabelledby !== void 0;
|
|
101
|
+
if (!children && !hasAriaLabel) {
|
|
102
|
+
console.warn(
|
|
103
|
+
"If you do not provide children, you must specify an aria-label for accessibility"
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
return /* @__PURE__ */ jsxs(Label, { className: labelClassName, children: [
|
|
107
|
+
/* @__PURE__ */ jsx(
|
|
108
|
+
"input",
|
|
109
|
+
{
|
|
110
|
+
...rest,
|
|
111
|
+
ref,
|
|
112
|
+
checked,
|
|
113
|
+
"aria-checked": checked ? "true" : "false",
|
|
114
|
+
"aria-label": ariaLabel,
|
|
115
|
+
"aria-labelledby": ariaLabelledby,
|
|
116
|
+
className: styles.checkbox,
|
|
117
|
+
disabled,
|
|
118
|
+
type: "checkbox",
|
|
119
|
+
"data-test-id": testId
|
|
120
|
+
}
|
|
121
|
+
),
|
|
122
|
+
" ",
|
|
123
|
+
disabled ? /* @__PURE__ */ jsx("span", { className: styles.labelDisabled, children }) : children
|
|
124
|
+
] });
|
|
111
125
|
}
|
|
112
|
-
|
|
113
|
-
className: labelClassName,
|
|
114
|
-
children: [/* @__PURE__ */ jsx("input", {
|
|
115
|
-
...rest,
|
|
116
|
-
ref,
|
|
117
|
-
checked,
|
|
118
|
-
"aria-checked": checked ? "true" : "false",
|
|
119
|
-
"aria-label": ariaLabel,
|
|
120
|
-
"aria-labelledby": ariaLabelledby,
|
|
121
|
-
className: styles.checkbox,
|
|
122
|
-
disabled,
|
|
123
|
-
type: "checkbox",
|
|
124
|
-
"data-test-id": testId
|
|
125
|
-
}), " ", disabled ? /* @__PURE__ */ jsx("span", {
|
|
126
|
-
className: styles.labelDisabled,
|
|
127
|
-
children
|
|
128
|
-
}) : children]
|
|
129
|
-
});
|
|
130
|
-
});
|
|
126
|
+
);
|
|
131
127
|
Checkbox.displayName = "Checkbox";
|
|
132
128
|
const createFieldErrorId = (fieldIdentifier) => fieldIdentifier ? `${[...fieldIdentifier].join("")}-err` : void 0;
|
|
133
|
-
const TextField = forwardRef(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
className: styles.suffixContainer,
|
|
148
|
-
|
|
129
|
+
const TextField = forwardRef(
|
|
130
|
+
({
|
|
131
|
+
className,
|
|
132
|
+
type = "text",
|
|
133
|
+
tiny = false,
|
|
134
|
+
readOnly,
|
|
135
|
+
tabIndex = 0,
|
|
136
|
+
suffix: suffix2,
|
|
137
|
+
overrideWidth,
|
|
138
|
+
"data-test-id": testId = "text-field",
|
|
139
|
+
...rest
|
|
140
|
+
}, ref) => {
|
|
141
|
+
const classes = overrideWidth ? className : cx(styles.formInput, tiny && styles.formInputTiny, className);
|
|
142
|
+
if (suffix2) {
|
|
143
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.suffixContainer, children: [
|
|
144
|
+
/* @__PURE__ */ jsx(
|
|
145
|
+
"input",
|
|
146
|
+
{
|
|
147
|
+
...rest,
|
|
148
|
+
type,
|
|
149
|
+
"data-test-id": testId,
|
|
150
|
+
className: classes,
|
|
151
|
+
readOnly,
|
|
152
|
+
ref,
|
|
153
|
+
"aria-describedby": rest["aria-describedby"] || createFieldErrorId(rest.id)
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ jsx("label", { className: styles.suffix, htmlFor: rest.id, children: suffix2 })
|
|
157
|
+
] });
|
|
158
|
+
}
|
|
159
|
+
return /* @__PURE__ */ jsx(
|
|
160
|
+
"input",
|
|
161
|
+
{
|
|
149
162
|
...rest,
|
|
150
163
|
type,
|
|
151
|
-
"data-test-id": testId,
|
|
152
164
|
className: classes,
|
|
153
165
|
readOnly,
|
|
166
|
+
tabIndex,
|
|
154
167
|
ref,
|
|
168
|
+
"data-test-id": testId,
|
|
169
|
+
style: overrideWidth ? {
|
|
170
|
+
width: overrideWidth
|
|
171
|
+
} : void 0,
|
|
155
172
|
"aria-describedby": rest["aria-describedby"] || createFieldErrorId(rest.id)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
htmlFor: rest.id,
|
|
159
|
-
children: suffix2
|
|
160
|
-
})]
|
|
161
|
-
});
|
|
173
|
+
}
|
|
174
|
+
);
|
|
162
175
|
}
|
|
163
|
-
|
|
164
|
-
...rest,
|
|
165
|
-
type,
|
|
166
|
-
className: classes,
|
|
167
|
-
readOnly,
|
|
168
|
-
tabIndex,
|
|
169
|
-
ref,
|
|
170
|
-
"data-test-id": testId,
|
|
171
|
-
style: overrideWidth ? {
|
|
172
|
-
width: overrideWidth
|
|
173
|
-
} : void 0,
|
|
174
|
-
"aria-describedby": rest["aria-describedby"] || createFieldErrorId(rest.id)
|
|
175
|
-
});
|
|
176
|
-
});
|
|
176
|
+
);
|
|
177
177
|
TextField.displayName = "TextField";
|
|
178
|
-
const CompactTextField = forwardRef(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
htmlFor: id,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
178
|
+
const CompactTextField = forwardRef(
|
|
179
|
+
({
|
|
180
|
+
className,
|
|
181
|
+
id,
|
|
182
|
+
label: label2,
|
|
183
|
+
needsErrorFeedback,
|
|
184
|
+
value,
|
|
185
|
+
onFocus,
|
|
186
|
+
onBlur,
|
|
187
|
+
"data-test-id": testId = "compact-text-field",
|
|
188
|
+
...rest
|
|
189
|
+
}, ref) => {
|
|
190
|
+
const [isActive2, setIsActive] = useState(
|
|
191
|
+
(typeof value === "boolean" || value ? value.toString() : "").trim().length !== 0
|
|
192
|
+
);
|
|
193
|
+
const isActiveState = isActive2 || needsErrorFeedback;
|
|
194
|
+
const classes = cx(styles.compactTextField, className, isActiveState && styles.isActive);
|
|
195
|
+
const placeholder = isActiveState ? "" : label2;
|
|
196
|
+
const handleFocus = (event) => {
|
|
197
|
+
setIsActive(true);
|
|
198
|
+
if (onFocus) {
|
|
199
|
+
onFocus(event);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const handleBlur = (event) => {
|
|
203
|
+
const value2 = event.target.value || "";
|
|
204
|
+
setIsActive(value2.trim().length !== 0);
|
|
205
|
+
if (onBlur) {
|
|
206
|
+
onBlur(event);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, "data-test-id": testId, children: [
|
|
210
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: id, children: label2 }),
|
|
211
|
+
/* @__PURE__ */ jsx(
|
|
212
|
+
TextField,
|
|
213
|
+
{
|
|
214
|
+
...rest,
|
|
215
|
+
id,
|
|
216
|
+
placeholder,
|
|
217
|
+
value,
|
|
218
|
+
ref,
|
|
219
|
+
onFocus: handleFocus,
|
|
220
|
+
onBlur: handleBlur
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
] });
|
|
224
|
+
}
|
|
225
|
+
);
|
|
223
226
|
CompactTextField.displayName = "CompactTextField";
|
|
224
227
|
const FieldError = ({
|
|
225
228
|
name,
|
|
@@ -231,17 +234,22 @@ const FieldError = ({
|
|
|
231
234
|
if (!errorMessage) {
|
|
232
235
|
return null;
|
|
233
236
|
}
|
|
234
|
-
return /* @__PURE__ */ jsxs(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
return /* @__PURE__ */ jsxs(
|
|
238
|
+
"span",
|
|
239
|
+
{
|
|
240
|
+
...rest,
|
|
241
|
+
className: cx(styles.fieldError, className),
|
|
242
|
+
"aria-live": "polite",
|
|
243
|
+
"data-test-id": testId,
|
|
244
|
+
"aria-label": "Error",
|
|
245
|
+
id: createFieldErrorId(name),
|
|
246
|
+
children: [
|
|
247
|
+
/* @__PURE__ */ jsx(AlertRhombus, { size: "small" }),
|
|
248
|
+
" ",
|
|
249
|
+
errorMessage
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
);
|
|
245
253
|
};
|
|
246
254
|
const FieldSet = ({
|
|
247
255
|
children,
|
|
@@ -250,12 +258,7 @@ const FieldSet = ({
|
|
|
250
258
|
...rest
|
|
251
259
|
}) => {
|
|
252
260
|
const classes = cx(styles.fieldSet, className);
|
|
253
|
-
return /* @__PURE__ */ jsx("fieldset", {
|
|
254
|
-
"data-test-id": testId,
|
|
255
|
-
className: classes,
|
|
256
|
-
...rest,
|
|
257
|
-
children
|
|
258
|
-
});
|
|
261
|
+
return /* @__PURE__ */ jsx("fieldset", { "data-test-id": testId, className: classes, ...rest, children });
|
|
259
262
|
};
|
|
260
263
|
const Form = (props) => {
|
|
261
264
|
const {
|
|
@@ -266,13 +269,13 @@ const Form = (props) => {
|
|
|
266
269
|
"data-test-id": testId = "form",
|
|
267
270
|
...rest
|
|
268
271
|
} = props;
|
|
269
|
-
const classes = cx(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
});
|
|
272
|
+
const classes = cx(
|
|
273
|
+
styles.form,
|
|
274
|
+
className,
|
|
275
|
+
inline && styles.formInline,
|
|
276
|
+
!!hasIncreasedErrorMargin && styles.formIncreasedErrorMargin
|
|
277
|
+
);
|
|
278
|
+
return /* @__PURE__ */ jsx("form", { ...rest, "data-test-id": testId, className: classes, children });
|
|
276
279
|
};
|
|
277
280
|
const FormGroup = (props) => {
|
|
278
281
|
const {
|
|
@@ -284,13 +287,12 @@ const FormGroup = (props) => {
|
|
|
284
287
|
"data-test-id": testId = "form-group",
|
|
285
288
|
...rest
|
|
286
289
|
} = props;
|
|
287
|
-
const classes = cx(
|
|
288
|
-
|
|
289
|
-
className
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
});
|
|
290
|
+
const classes = cx(
|
|
291
|
+
styles.formGroup,
|
|
292
|
+
className,
|
|
293
|
+
!ignoreValidation && isInvalid2 && styles.isInvalid
|
|
294
|
+
);
|
|
295
|
+
return /* @__PURE__ */ jsx("fieldset", { className: classes, "data-test-id": testId, ...rest, children });
|
|
294
296
|
};
|
|
295
297
|
const FormHint = ({
|
|
296
298
|
className,
|
|
@@ -299,12 +301,7 @@ const FormHint = ({
|
|
|
299
301
|
...rest
|
|
300
302
|
}) => {
|
|
301
303
|
const classes = cx(styles.hint, className);
|
|
302
|
-
return /* @__PURE__ */ jsx("div", {
|
|
303
|
-
...rest,
|
|
304
|
-
"data-test-id": testId,
|
|
305
|
-
className: classes,
|
|
306
|
-
children
|
|
307
|
-
});
|
|
304
|
+
return /* @__PURE__ */ jsx("div", { ...rest, "data-test-id": testId, className: classes, children });
|
|
308
305
|
};
|
|
309
306
|
const FormField = ({
|
|
310
307
|
isRequired,
|
|
@@ -323,26 +320,23 @@ const FormField = ({
|
|
|
323
320
|
const handleBlur = () => {
|
|
324
321
|
onBlur && onBlur(name);
|
|
325
322
|
};
|
|
326
|
-
return /* @__PURE__ */ jsxs(
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
isInvalid: isInvalid2,
|
|
331
|
-
onBlur: handleBlur,
|
|
332
|
-
"data-test-id": testId,
|
|
333
|
-
children: [label2 && /* @__PURE__ */ jsx(Label, {
|
|
334
|
-
htmlFor,
|
|
335
|
-
required: isRequired,
|
|
336
|
-
children: label2
|
|
337
|
-
}), hint2 && /* @__PURE__ */ jsx(FormHint, {
|
|
338
|
-
className: styles.hint,
|
|
339
|
-
children: hint2
|
|
340
|
-
}), children, /* @__PURE__ */ jsx(FieldError, {
|
|
341
|
-
className: styles.fieldErrorMessage,
|
|
323
|
+
return /* @__PURE__ */ jsxs(
|
|
324
|
+
FormGroup,
|
|
325
|
+
{
|
|
326
|
+
className: cx(styles.field, className),
|
|
342
327
|
name,
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
328
|
+
ignoreValidation,
|
|
329
|
+
isInvalid: isInvalid2,
|
|
330
|
+
onBlur: handleBlur,
|
|
331
|
+
"data-test-id": testId,
|
|
332
|
+
children: [
|
|
333
|
+
label2 && /* @__PURE__ */ jsx(Label, { htmlFor, required: isRequired, children: label2 }),
|
|
334
|
+
hint2 && /* @__PURE__ */ jsx(FormHint, { className: styles.hint, children: hint2 }),
|
|
335
|
+
children,
|
|
336
|
+
/* @__PURE__ */ jsx(FieldError, { className: styles.fieldErrorMessage, name, errorMessage })
|
|
337
|
+
]
|
|
338
|
+
}
|
|
339
|
+
);
|
|
346
340
|
};
|
|
347
341
|
const IconField = ({
|
|
348
342
|
icon,
|
|
@@ -353,15 +347,10 @@ const IconField = ({
|
|
|
353
347
|
}) => {
|
|
354
348
|
const Icon = icon;
|
|
355
349
|
const classes = cx(styles.iconField, className);
|
|
356
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
357
|
-
|
|
358
|
-
"
|
|
359
|
-
|
|
360
|
-
children: [children, /* @__PURE__ */ jsx(Icon, {
|
|
361
|
-
size: "small",
|
|
362
|
-
className: styles.iconFieldIcon
|
|
363
|
-
})]
|
|
364
|
-
});
|
|
350
|
+
return /* @__PURE__ */ jsxs("div", { className: classes, "data-test-id": testId, ...rest, children: [
|
|
351
|
+
children,
|
|
352
|
+
/* @__PURE__ */ jsx(Icon, { size: "small", className: styles.iconFieldIcon })
|
|
353
|
+
] });
|
|
365
354
|
};
|
|
366
355
|
const Radio = ({
|
|
367
356
|
"aria-label": ariaLabel,
|
|
@@ -378,29 +367,27 @@ const Radio = ({
|
|
|
378
367
|
}) => {
|
|
379
368
|
const hasAriaLabel = ariaLabel !== void 0 || ariaLabelledby !== void 0;
|
|
380
369
|
if (!children && !hasAriaLabel) {
|
|
381
|
-
console.warn(
|
|
370
|
+
console.warn(
|
|
371
|
+
"If you do not provide children, you must specify an aria-label for accessibility"
|
|
372
|
+
);
|
|
382
373
|
}
|
|
383
|
-
return /* @__PURE__ */ jsxs(Fragment, {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
children
|
|
401
|
-
}) : children
|
|
402
|
-
})]
|
|
403
|
-
});
|
|
374
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
375
|
+
/* @__PURE__ */ jsx(
|
|
376
|
+
"input",
|
|
377
|
+
{
|
|
378
|
+
...rest,
|
|
379
|
+
"aria-label": ariaLabel,
|
|
380
|
+
"aria-labelledby": ariaLabelledby,
|
|
381
|
+
className: cx(styles.radio, className),
|
|
382
|
+
checked,
|
|
383
|
+
disabled,
|
|
384
|
+
id,
|
|
385
|
+
"data-test-id": testId,
|
|
386
|
+
type: "radio"
|
|
387
|
+
}
|
|
388
|
+
),
|
|
389
|
+
/* @__PURE__ */ jsx(Label, { className: labelClassName, htmlFor: id, style: labelStyle, children: disabled ? /* @__PURE__ */ jsx("span", { className: styles.labelDisabled, children }) : children })
|
|
390
|
+
] });
|
|
404
391
|
};
|
|
405
392
|
const RadioGroup = (props) => {
|
|
406
393
|
const {
|
|
@@ -453,55 +440,41 @@ const RadioGroup = (props) => {
|
|
|
453
440
|
return null;
|
|
454
441
|
}
|
|
455
442
|
const radios = Children.map(children, (child) => updateRadioElems(child));
|
|
456
|
-
return /* @__PURE__ */ jsxs("fieldset", {
|
|
457
|
-
"
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
children: /* @__PURE__ */ jsx(VisuallyHidden, {
|
|
461
|
-
children: legend
|
|
462
|
-
})
|
|
463
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
464
|
-
...rest,
|
|
465
|
-
children: radios
|
|
466
|
-
})]
|
|
467
|
-
});
|
|
443
|
+
return /* @__PURE__ */ jsxs("fieldset", { "data-test-id": testId, ref: fieldsetRef, children: [
|
|
444
|
+
legend && /* @__PURE__ */ jsx("legend", { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: legend }) }),
|
|
445
|
+
/* @__PURE__ */ jsx("div", { ...rest, children: radios })
|
|
446
|
+
] });
|
|
468
447
|
};
|
|
469
|
-
const SelectField = (
|
|
470
|
-
className,
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
ref,
|
|
500
|
-
"data-test-id": testId,
|
|
501
|
-
"aria-describedby": props["aria-describedby"] || createFieldErrorId(props.id),
|
|
502
|
-
onKeyDown
|
|
503
|
-
});
|
|
504
|
-
});
|
|
448
|
+
const SelectField = forwardRef(
|
|
449
|
+
({ className, children, "data-test-id": testId = "select", ...rest }, ref) => {
|
|
450
|
+
const classes = cx(styles.formInput, className);
|
|
451
|
+
return /* @__PURE__ */ jsx("select", { ...rest, "data-test-id": testId, className: classes, ref, children });
|
|
452
|
+
}
|
|
453
|
+
);
|
|
454
|
+
SelectField.displayName = "SelectField";
|
|
455
|
+
const TextArea = forwardRef(
|
|
456
|
+
({ className, "data-test-id": testId = "text-area", ...props }, ref) => {
|
|
457
|
+
const onKeyDown = (e) => {
|
|
458
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "ArrowLeft") {
|
|
459
|
+
e.stopPropagation();
|
|
460
|
+
}
|
|
461
|
+
if (e.key === "Escape") {
|
|
462
|
+
e.nativeEvent.stopImmediatePropagation();
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
return /* @__PURE__ */ jsx(
|
|
466
|
+
"textarea",
|
|
467
|
+
{
|
|
468
|
+
...props,
|
|
469
|
+
className: cx(styles.formInput, className),
|
|
470
|
+
ref,
|
|
471
|
+
"data-test-id": testId,
|
|
472
|
+
"aria-describedby": props["aria-describedby"] || createFieldErrorId(props.id),
|
|
473
|
+
onKeyDown
|
|
474
|
+
}
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
);
|
|
505
478
|
TextArea.displayName = "TextArea";
|
|
506
479
|
export {
|
|
507
480
|
Checkbox,
|