@launchpad-ui/form 0.8.13 → 0.8.15
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/FieldError.d.ts +1 -1
- package/dist/FieldError.d.ts.map +1 -1
- package/dist/FieldSet.d.ts +1 -1
- package/dist/FieldSet.d.ts.map +1 -1
- package/dist/Form.d.ts +1 -1
- package/dist/Form.d.ts.map +1 -1
- package/dist/FormField.d.ts +7 -1
- package/dist/FormField.d.ts.map +1 -1
- package/dist/FormGroup.d.ts +1 -1
- package/dist/FormGroup.d.ts.map +1 -1
- package/dist/FormHint.d.ts +1 -1
- package/dist/FormHint.d.ts.map +1 -1
- package/dist/IconField.d.ts +1 -1
- package/dist/IconField.d.ts.map +1 -1
- package/dist/Label.d.ts +1 -1
- package/dist/Label.d.ts.map +1 -1
- package/dist/Radio.d.ts +1 -1
- 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 +1 -1
- package/dist/RequiredAsterisk.d.ts.map +1 -1
- package/dist/SelectField.d.ts +1 -1
- package/dist/SelectField.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +359 -297
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +357 -295
- package/dist/index.js.map +1 -1
- package/dist/style.css +140 -74
- package/dist/useNumberField.d.ts +18 -0
- package/dist/useNumberField.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +6 -2
package/dist/index.js
CHANGED
@@ -1,39 +1,44 @@
|
|
1
1
|
require('./style.css');
|
2
2
|
"use strict";
|
3
|
-
Object.
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
4
5
|
const react = require("react");
|
5
6
|
const classix = require("classix");
|
6
|
-
const jsxRuntime = require("react/jsx-runtime");
|
7
7
|
const icons = require("@launchpad-ui/icons");
|
8
8
|
const visuallyHidden = require("@react-aria/visually-hidden");
|
9
|
-
const
|
10
|
-
const
|
11
|
-
const
|
12
|
-
const
|
13
|
-
const
|
14
|
-
const
|
15
|
-
const
|
16
|
-
const
|
17
|
-
const
|
18
|
-
const
|
19
|
-
const
|
20
|
-
const
|
21
|
-
const
|
22
|
-
const
|
23
|
-
const
|
24
|
-
const
|
25
|
-
const
|
26
|
-
const
|
27
|
-
const
|
28
|
-
const
|
29
|
-
const
|
30
|
-
const
|
31
|
-
const
|
32
|
-
const
|
33
|
-
const
|
34
|
-
const
|
35
|
-
const
|
36
|
-
const
|
9
|
+
const button = require("@react-aria/button");
|
10
|
+
const i18n = require("@react-aria/i18n");
|
11
|
+
const numberfield$1 = require("@react-aria/numberfield");
|
12
|
+
const numberfield = require("@react-stately/numberfield");
|
13
|
+
const formGroup = "_formGroup_1u9hb_10";
|
14
|
+
const formIncreasedErrorMargin = "_formIncreasedErrorMargin_1u9hb_18";
|
15
|
+
const formInline = "_formInline_1u9hb_22";
|
16
|
+
const form = "_form_1u9hb_10";
|
17
|
+
const formInput = "_formInput_1u9hb_36";
|
18
|
+
const isFocused = "_isFocused_1u9hb_56";
|
19
|
+
const iconField = "_iconField_1u9hb_73";
|
20
|
+
const suffixContainer = "_suffixContainer_1u9hb_77";
|
21
|
+
const isInvalid = "_isInvalid_1u9hb_82";
|
22
|
+
const inlineForm = "_inlineForm_1u9hb_93";
|
23
|
+
const label = "_label_1u9hb_98";
|
24
|
+
const labelDisabled = "_labelDisabled_1u9hb_104";
|
25
|
+
const labelOptional = "_labelOptional_1u9hb_108";
|
26
|
+
const compactTextField = "_compactTextField_1u9hb_114";
|
27
|
+
const fieldError = "_fieldError_1u9hb_138";
|
28
|
+
const hint = "_hint_1u9hb_184";
|
29
|
+
const field = "_field_1u9hb_138";
|
30
|
+
const fieldErrorMessage = "_fieldErrorMessage_1u9hb_204";
|
31
|
+
const isDisabled = "_isDisabled_1u9hb_217";
|
32
|
+
const checkbox = "_checkbox_1u9hb_284";
|
33
|
+
const radio = "_radio_1u9hb_291";
|
34
|
+
const number = "_number_1u9hb_295";
|
35
|
+
const suffix = "_suffix_1u9hb_77";
|
36
|
+
const iconFieldIcon = "_iconFieldIcon_1u9hb_333";
|
37
|
+
const formInputTiny = "_formInputTiny_1u9hb_341";
|
38
|
+
const requiredAsterisk = "_requiredAsterisk_1u9hb_350";
|
39
|
+
const fieldSet = "_fieldSet_1u9hb_354";
|
40
|
+
const isActive = "_isActive_1u9hb_365";
|
41
|
+
const numberField = "_numberField_1u9hb_372";
|
37
42
|
const styles = {
|
38
43
|
formGroup,
|
39
44
|
formIncreasedErrorMargin,
|
@@ -62,7 +67,11 @@ const styles = {
|
|
62
67
|
formInputTiny,
|
63
68
|
requiredAsterisk,
|
64
69
|
fieldSet,
|
65
|
-
isActive
|
70
|
+
isActive,
|
71
|
+
numberField,
|
72
|
+
"numberField-input": "_numberField-input_1u9hb_376",
|
73
|
+
"numberField-stepperContainer": "_numberField-stepperContainer_1u9hb_380",
|
74
|
+
"numberField-stepper": "_numberField-stepper_1u9hb_380"
|
66
75
|
};
|
67
76
|
const RequiredAsterisk = ({
|
68
77
|
className,
|
@@ -70,12 +79,7 @@ const RequiredAsterisk = ({
|
|
70
79
|
...rest
|
71
80
|
}) => {
|
72
81
|
const classes = classix.cx(styles.requiredAsterisk, className);
|
73
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", {
|
74
|
-
...rest,
|
75
|
-
"data-test-id": testId,
|
76
|
-
className: classes,
|
77
|
-
children: "*"
|
78
|
-
});
|
82
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { ...rest, "data-test-id": testId, className: classes, children: "*" });
|
79
83
|
};
|
80
84
|
const Label = ({
|
81
85
|
disabled,
|
@@ -87,141 +91,164 @@ const Label = ({
|
|
87
91
|
...rest
|
88
92
|
}) => {
|
89
93
|
const classes = classix.cx(styles.label, className, disabled && styles.labelDisabled);
|
90
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("label", {
|
91
|
-
|
92
|
-
"
|
93
|
-
|
94
|
-
|
95
|
-
className: styles.labelOptional,
|
96
|
-
children: "(optional)"
|
97
|
-
}), required && !optional && /* @__PURE__ */ jsxRuntime.jsx(RequiredAsterisk, {})]
|
98
|
-
});
|
94
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("label", { ...rest, "data-test-id": testId, className: classes, children: [
|
95
|
+
children,
|
96
|
+
optional && !required && /* @__PURE__ */ jsxRuntime.jsx("small", { className: styles.labelOptional, children: "(optional)" }),
|
97
|
+
required && !optional && /* @__PURE__ */ jsxRuntime.jsx(RequiredAsterisk, {})
|
98
|
+
] });
|
99
99
|
};
|
100
|
-
const Checkbox = react.forwardRef(
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
100
|
+
const Checkbox = react.forwardRef(
|
101
|
+
({
|
102
|
+
"aria-label": ariaLabel,
|
103
|
+
"aria-labelledby": ariaLabelledby,
|
104
|
+
children,
|
105
|
+
disabled,
|
106
|
+
checked,
|
107
|
+
labelClassName,
|
108
|
+
"data-test-id": testId = "checkbox",
|
109
|
+
...rest
|
110
|
+
}, ref) => {
|
111
|
+
const hasAriaLabel = ariaLabel !== void 0 || ariaLabelledby !== void 0;
|
112
|
+
if (!children && !hasAriaLabel) {
|
113
|
+
console.warn(
|
114
|
+
"If you do not provide children, you must specify an aria-label for accessibility"
|
115
|
+
);
|
116
|
+
}
|
117
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Label, { className: labelClassName, children: [
|
118
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
119
|
+
"input",
|
120
|
+
{
|
121
|
+
...rest,
|
122
|
+
ref,
|
123
|
+
checked,
|
124
|
+
"aria-checked": checked ? "true" : "false",
|
125
|
+
"aria-label": ariaLabel,
|
126
|
+
"aria-labelledby": ariaLabelledby,
|
127
|
+
className: styles.checkbox,
|
128
|
+
disabled,
|
129
|
+
type: "checkbox",
|
130
|
+
"data-test-id": testId
|
131
|
+
}
|
132
|
+
),
|
133
|
+
" ",
|
134
|
+
disabled ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.labelDisabled, children }) : children
|
135
|
+
] });
|
113
136
|
}
|
114
|
-
|
115
|
-
className: labelClassName,
|
116
|
-
children: [/* @__PURE__ */ jsxRuntime.jsx("input", {
|
117
|
-
...rest,
|
118
|
-
ref,
|
119
|
-
checked,
|
120
|
-
"aria-checked": checked ? "true" : "false",
|
121
|
-
"aria-label": ariaLabel,
|
122
|
-
"aria-labelledby": ariaLabelledby,
|
123
|
-
className: styles.checkbox,
|
124
|
-
disabled,
|
125
|
-
type: "checkbox",
|
126
|
-
"data-test-id": testId
|
127
|
-
}), " ", disabled ? /* @__PURE__ */ jsxRuntime.jsx("span", {
|
128
|
-
className: styles.labelDisabled,
|
129
|
-
children
|
130
|
-
}) : children]
|
131
|
-
});
|
132
|
-
});
|
137
|
+
);
|
133
138
|
Checkbox.displayName = "Checkbox";
|
134
139
|
const createFieldErrorId = (fieldIdentifier) => fieldIdentifier ? `${[...fieldIdentifier].join("")}-err` : void 0;
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
140
|
+
function hasObjectChanged(obj1, obj2) {
|
141
|
+
return Object.keys(obj1).length !== Object.keys(obj2).length || Object.keys(obj1).some((k) => {
|
142
|
+
const key = k;
|
143
|
+
return typeof obj1[key] === "object" && typeof obj2[key] === "object" ? hasObjectChanged(obj1[key], obj2[key]) : obj1[key] !== obj2[key];
|
144
|
+
});
|
145
|
+
}
|
146
|
+
function useObjectMemo(obj) {
|
147
|
+
const objRef = react.useRef(obj);
|
148
|
+
return react.useMemo(() => {
|
149
|
+
if (hasObjectChanged(obj, objRef.current)) {
|
150
|
+
objRef.current = obj;
|
151
|
+
}
|
152
|
+
return objRef.current;
|
153
|
+
}, [obj]);
|
154
|
+
}
|
155
|
+
const TextField = react.forwardRef(
|
156
|
+
({
|
157
|
+
className,
|
158
|
+
type = "text",
|
159
|
+
tiny = false,
|
160
|
+
readOnly,
|
161
|
+
tabIndex = 0,
|
162
|
+
suffix: suffix2,
|
163
|
+
overrideWidth,
|
164
|
+
"data-test-id": testId = "text-field",
|
165
|
+
...rest
|
166
|
+
}, ref) => {
|
167
|
+
const classes = overrideWidth ? className : classix.cx(styles.formInput, tiny && styles.formInputTiny, className);
|
168
|
+
if (suffix2) {
|
169
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles.suffixContainer, children: [
|
170
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
171
|
+
"input",
|
172
|
+
{
|
173
|
+
...rest,
|
174
|
+
type,
|
175
|
+
"data-test-id": testId,
|
176
|
+
className: classes,
|
177
|
+
readOnly,
|
178
|
+
ref,
|
179
|
+
"aria-describedby": rest["aria-describedby"] || createFieldErrorId(rest.id)
|
180
|
+
}
|
181
|
+
),
|
182
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: styles.suffix, htmlFor: rest.id, children: suffix2 })
|
183
|
+
] });
|
184
|
+
}
|
185
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
186
|
+
"input",
|
187
|
+
{
|
151
188
|
...rest,
|
152
189
|
type,
|
153
|
-
"data-test-id": testId,
|
154
190
|
className: classes,
|
155
191
|
readOnly,
|
192
|
+
tabIndex,
|
156
193
|
ref,
|
194
|
+
"data-test-id": testId,
|
195
|
+
style: overrideWidth ? {
|
196
|
+
width: overrideWidth
|
197
|
+
} : void 0,
|
157
198
|
"aria-describedby": rest["aria-describedby"] || createFieldErrorId(rest.id)
|
158
|
-
}
|
159
|
-
|
160
|
-
htmlFor: rest.id,
|
161
|
-
children: suffix2
|
162
|
-
})]
|
163
|
-
});
|
199
|
+
}
|
200
|
+
);
|
164
201
|
}
|
165
|
-
|
166
|
-
...rest,
|
167
|
-
type,
|
168
|
-
className: classes,
|
169
|
-
readOnly,
|
170
|
-
tabIndex,
|
171
|
-
ref,
|
172
|
-
"data-test-id": testId,
|
173
|
-
style: overrideWidth ? {
|
174
|
-
width: overrideWidth
|
175
|
-
} : void 0,
|
176
|
-
"aria-describedby": rest["aria-describedby"] || createFieldErrorId(rest.id)
|
177
|
-
});
|
178
|
-
});
|
202
|
+
);
|
179
203
|
TextField.displayName = "TextField";
|
180
|
-
const CompactTextField = react.forwardRef(
|
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
|
-
|
211
|
-
|
212
|
-
htmlFor: id,
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
204
|
+
const CompactTextField = react.forwardRef(
|
205
|
+
({
|
206
|
+
className,
|
207
|
+
id,
|
208
|
+
label: label2,
|
209
|
+
needsErrorFeedback,
|
210
|
+
value,
|
211
|
+
onFocus,
|
212
|
+
onBlur,
|
213
|
+
"data-test-id": testId = "compact-text-field",
|
214
|
+
...rest
|
215
|
+
}, ref) => {
|
216
|
+
const [isActive2, setIsActive] = react.useState(
|
217
|
+
(typeof value === "boolean" || value ? value.toString() : "").trim().length !== 0
|
218
|
+
);
|
219
|
+
const isActiveState = isActive2 || needsErrorFeedback;
|
220
|
+
const classes = classix.cx(styles.compactTextField, className, isActiveState && styles.isActive);
|
221
|
+
const placeholder = isActiveState ? "" : label2;
|
222
|
+
const handleFocus = (event) => {
|
223
|
+
setIsActive(true);
|
224
|
+
if (onFocus) {
|
225
|
+
onFocus(event);
|
226
|
+
}
|
227
|
+
};
|
228
|
+
const handleBlur = (event) => {
|
229
|
+
const value2 = event.target.value || "";
|
230
|
+
setIsActive(value2.trim().length !== 0);
|
231
|
+
if (onBlur) {
|
232
|
+
onBlur(event);
|
233
|
+
}
|
234
|
+
};
|
235
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes, "data-test-id": testId, children: [
|
236
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: id, children: label2 }),
|
237
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
238
|
+
TextField,
|
239
|
+
{
|
240
|
+
...rest,
|
241
|
+
id,
|
242
|
+
placeholder,
|
243
|
+
value,
|
244
|
+
ref,
|
245
|
+
onFocus: handleFocus,
|
246
|
+
onBlur: handleBlur
|
247
|
+
}
|
248
|
+
)
|
249
|
+
] });
|
250
|
+
}
|
251
|
+
);
|
225
252
|
CompactTextField.displayName = "CompactTextField";
|
226
253
|
const FieldError = ({
|
227
254
|
name,
|
@@ -233,17 +260,22 @@ const FieldError = ({
|
|
233
260
|
if (!errorMessage) {
|
234
261
|
return null;
|
235
262
|
}
|
236
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
263
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
264
|
+
"span",
|
265
|
+
{
|
266
|
+
...rest,
|
267
|
+
className: classix.cx(styles.fieldError, className),
|
268
|
+
"aria-live": "polite",
|
269
|
+
"data-test-id": testId,
|
270
|
+
"aria-label": "Error",
|
271
|
+
id: createFieldErrorId(name),
|
272
|
+
children: [
|
273
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.AlertRhombus, { size: "small" }),
|
274
|
+
" ",
|
275
|
+
errorMessage
|
276
|
+
]
|
277
|
+
}
|
278
|
+
);
|
247
279
|
};
|
248
280
|
const FieldSet = ({
|
249
281
|
children,
|
@@ -252,12 +284,7 @@ const FieldSet = ({
|
|
252
284
|
...rest
|
253
285
|
}) => {
|
254
286
|
const classes = classix.cx(styles.fieldSet, className);
|
255
|
-
return /* @__PURE__ */ jsxRuntime.jsx("fieldset", {
|
256
|
-
"data-test-id": testId,
|
257
|
-
className: classes,
|
258
|
-
...rest,
|
259
|
-
children
|
260
|
-
});
|
287
|
+
return /* @__PURE__ */ jsxRuntime.jsx("fieldset", { "data-test-id": testId, className: classes, ...rest, children });
|
261
288
|
};
|
262
289
|
const Form = (props) => {
|
263
290
|
const {
|
@@ -268,13 +295,13 @@ const Form = (props) => {
|
|
268
295
|
"data-test-id": testId = "form",
|
269
296
|
...rest
|
270
297
|
} = props;
|
271
|
-
const classes = classix.cx(
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
});
|
298
|
+
const classes = classix.cx(
|
299
|
+
styles.form,
|
300
|
+
className,
|
301
|
+
inline && styles.formInline,
|
302
|
+
!!hasIncreasedErrorMargin && styles.formIncreasedErrorMargin
|
303
|
+
);
|
304
|
+
return /* @__PURE__ */ jsxRuntime.jsx("form", { ...rest, "data-test-id": testId, className: classes, children });
|
278
305
|
};
|
279
306
|
const FormGroup = (props) => {
|
280
307
|
const {
|
@@ -286,13 +313,12 @@ const FormGroup = (props) => {
|
|
286
313
|
"data-test-id": testId = "form-group",
|
287
314
|
...rest
|
288
315
|
} = props;
|
289
|
-
const classes = classix.cx(
|
290
|
-
|
291
|
-
className
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
});
|
316
|
+
const classes = classix.cx(
|
317
|
+
styles.formGroup,
|
318
|
+
className,
|
319
|
+
!ignoreValidation && isInvalid2 && styles.isInvalid
|
320
|
+
);
|
321
|
+
return /* @__PURE__ */ jsxRuntime.jsx("fieldset", { className: classes, "data-test-id": testId, ...rest, children });
|
296
322
|
};
|
297
323
|
const FormHint = ({
|
298
324
|
className,
|
@@ -301,12 +327,7 @@ const FormHint = ({
|
|
301
327
|
...rest
|
302
328
|
}) => {
|
303
329
|
const classes = classix.cx(styles.hint, className);
|
304
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", {
|
305
|
-
...rest,
|
306
|
-
"data-test-id": testId,
|
307
|
-
className: classes,
|
308
|
-
children
|
309
|
-
});
|
330
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...rest, "data-test-id": testId, className: classes, children });
|
310
331
|
};
|
311
332
|
const FormField = ({
|
312
333
|
isRequired,
|
@@ -320,31 +341,39 @@ const FormField = ({
|
|
320
341
|
children,
|
321
342
|
className,
|
322
343
|
onBlur,
|
323
|
-
"data-test-id": testId = "form-field"
|
344
|
+
"data-test-id": testId = "form-field",
|
345
|
+
LabelProps = {},
|
346
|
+
FormHintProps = {},
|
347
|
+
FieldErrorProps = {}
|
324
348
|
}) => {
|
325
349
|
const handleBlur = () => {
|
326
350
|
onBlur && onBlur(name);
|
327
351
|
};
|
328
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
isInvalid: isInvalid2,
|
333
|
-
onBlur: handleBlur,
|
334
|
-
"data-test-id": testId,
|
335
|
-
children: [label2 && /* @__PURE__ */ jsxRuntime.jsx(Label, {
|
336
|
-
htmlFor,
|
337
|
-
required: isRequired,
|
338
|
-
children: label2
|
339
|
-
}), hint2 && /* @__PURE__ */ jsxRuntime.jsx(FormHint, {
|
340
|
-
className: styles.hint,
|
341
|
-
children: hint2
|
342
|
-
}), children, /* @__PURE__ */ jsxRuntime.jsx(FieldError, {
|
343
|
-
className: styles.fieldErrorMessage,
|
352
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
353
|
+
FormGroup,
|
354
|
+
{
|
355
|
+
className: classix.cx(styles.field, className),
|
344
356
|
name,
|
345
|
-
|
346
|
-
|
347
|
-
|
357
|
+
ignoreValidation,
|
358
|
+
isInvalid: isInvalid2,
|
359
|
+
onBlur: handleBlur,
|
360
|
+
"data-test-id": testId,
|
361
|
+
children: [
|
362
|
+
label2 && /* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor, required: isRequired, ...LabelProps, children: label2 }),
|
363
|
+
hint2 && /* @__PURE__ */ jsxRuntime.jsx(FormHint, { className: styles.hint, ...FormHintProps, children: hint2 }),
|
364
|
+
children,
|
365
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
366
|
+
FieldError,
|
367
|
+
{
|
368
|
+
className: styles.fieldErrorMessage,
|
369
|
+
name,
|
370
|
+
errorMessage,
|
371
|
+
...FieldErrorProps
|
372
|
+
}
|
373
|
+
)
|
374
|
+
]
|
375
|
+
}
|
376
|
+
);
|
348
377
|
};
|
349
378
|
const IconField = ({
|
350
379
|
icon,
|
@@ -355,15 +384,10 @@ const IconField = ({
|
|
355
384
|
}) => {
|
356
385
|
const Icon = icon;
|
357
386
|
const classes = classix.cx(styles.iconField, className);
|
358
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", {
|
359
|
-
|
360
|
-
"
|
361
|
-
|
362
|
-
children: [children, /* @__PURE__ */ jsxRuntime.jsx(Icon, {
|
363
|
-
size: "small",
|
364
|
-
className: styles.iconFieldIcon
|
365
|
-
})]
|
366
|
-
});
|
387
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classes, "data-test-id": testId, ...rest, children: [
|
388
|
+
children,
|
389
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: "small", className: styles.iconFieldIcon })
|
390
|
+
] });
|
367
391
|
};
|
368
392
|
const Radio = ({
|
369
393
|
"aria-label": ariaLabel,
|
@@ -380,29 +404,27 @@ const Radio = ({
|
|
380
404
|
}) => {
|
381
405
|
const hasAriaLabel = ariaLabel !== void 0 || ariaLabelledby !== void 0;
|
382
406
|
if (!children && !hasAriaLabel) {
|
383
|
-
console.warn(
|
407
|
+
console.warn(
|
408
|
+
"If you do not provide children, you must specify an aria-label for accessibility"
|
409
|
+
);
|
384
410
|
}
|
385
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
children
|
403
|
-
}) : children
|
404
|
-
})]
|
405
|
-
});
|
411
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
412
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
413
|
+
"input",
|
414
|
+
{
|
415
|
+
...rest,
|
416
|
+
"aria-label": ariaLabel,
|
417
|
+
"aria-labelledby": ariaLabelledby,
|
418
|
+
className: classix.cx(styles.radio, className),
|
419
|
+
checked,
|
420
|
+
disabled,
|
421
|
+
id,
|
422
|
+
"data-test-id": testId,
|
423
|
+
type: "radio"
|
424
|
+
}
|
425
|
+
),
|
426
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { className: labelClassName, htmlFor: id, style: labelStyle, children: disabled ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles.labelDisabled, children }) : children })
|
427
|
+
] });
|
406
428
|
};
|
407
429
|
const RadioGroup = (props) => {
|
408
430
|
const {
|
@@ -455,56 +477,95 @@ const RadioGroup = (props) => {
|
|
455
477
|
return null;
|
456
478
|
}
|
457
479
|
const radios = react.Children.map(children, (child) => updateRadioElems(child));
|
458
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("fieldset", {
|
459
|
-
"
|
460
|
-
|
461
|
-
|
462
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(visuallyHidden.VisuallyHidden, {
|
463
|
-
children: legend
|
464
|
-
})
|
465
|
-
}), /* @__PURE__ */ jsxRuntime.jsx("div", {
|
466
|
-
...rest,
|
467
|
-
children: radios
|
468
|
-
})]
|
469
|
-
});
|
480
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { "data-test-id": testId, ref: fieldsetRef, children: [
|
481
|
+
legend && /* @__PURE__ */ jsxRuntime.jsx("legend", { children: /* @__PURE__ */ jsxRuntime.jsx(visuallyHidden.VisuallyHidden, { children: legend }) }),
|
482
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ...rest, children: radios })
|
483
|
+
] });
|
470
484
|
};
|
471
|
-
const SelectField = (
|
472
|
-
className,
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
485
|
+
const SelectField = react.forwardRef(
|
486
|
+
({ className, children, "data-test-id": testId = "select", ...rest }, ref) => {
|
487
|
+
const classes = classix.cx(styles.formInput, className);
|
488
|
+
return /* @__PURE__ */ jsxRuntime.jsx("select", { ...rest, "data-test-id": testId, className: classes, ref, children });
|
489
|
+
}
|
490
|
+
);
|
491
|
+
SelectField.displayName = "SelectField";
|
492
|
+
const TextArea = react.forwardRef(
|
493
|
+
({ className, "data-test-id": testId = "text-area", ...props }, ref) => {
|
494
|
+
const onKeyDown = (e) => {
|
495
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "ArrowLeft") {
|
496
|
+
e.stopPropagation();
|
497
|
+
}
|
498
|
+
if (e.key === "Escape") {
|
499
|
+
e.nativeEvent.stopImmediatePropagation();
|
500
|
+
}
|
501
|
+
};
|
502
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
503
|
+
"textarea",
|
504
|
+
{
|
505
|
+
...props,
|
506
|
+
className: classix.cx(styles.formInput, className),
|
507
|
+
ref,
|
508
|
+
"data-test-id": testId,
|
509
|
+
"aria-describedby": props["aria-describedby"] || createFieldErrorId(props.id),
|
510
|
+
onKeyDown
|
511
|
+
}
|
512
|
+
);
|
513
|
+
}
|
514
|
+
);
|
515
|
+
TextArea.displayName = "TextArea";
|
516
|
+
const defaultFormatOptions = {
|
517
|
+
maximumFractionDigits: 6
|
484
518
|
};
|
485
|
-
const
|
486
|
-
className,
|
487
|
-
"data-test-id": testId = "
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
e.nativeEvent.stopImmediatePropagation();
|
496
|
-
}
|
497
|
-
};
|
498
|
-
return /* @__PURE__ */ jsxRuntime.jsx("textarea", {
|
499
|
-
...props,
|
500
|
-
className: classix.cx(styles.formInput, className),
|
501
|
-
ref,
|
502
|
-
"data-test-id": testId,
|
503
|
-
"aria-describedby": props["aria-describedby"] || createFieldErrorId(props.id),
|
504
|
-
onKeyDown
|
519
|
+
const useNumberField = ({
|
520
|
+
className: rootClassName,
|
521
|
+
"data-test-id": testId = "input",
|
522
|
+
id,
|
523
|
+
name,
|
524
|
+
...otherProps
|
525
|
+
} = {}) => {
|
526
|
+
const formatOptions = useObjectMemo({
|
527
|
+
...defaultFormatOptions,
|
528
|
+
...otherProps.formatOptions
|
505
529
|
});
|
506
|
-
});
|
507
|
-
|
530
|
+
const { locale } = i18n.useLocale();
|
531
|
+
const numberFieldState = numberfield.useNumberFieldState({ ...otherProps, locale, formatOptions });
|
532
|
+
const inputRef = react.useRef(null);
|
533
|
+
const {
|
534
|
+
descriptionProps: formHintProps,
|
535
|
+
errorMessageProps: fieldErrorProps,
|
536
|
+
labelProps,
|
537
|
+
groupProps,
|
538
|
+
inputProps,
|
539
|
+
incrementButtonProps,
|
540
|
+
decrementButtonProps
|
541
|
+
} = numberfield$1.useNumberField({ ...otherProps, formatOptions, id }, numberFieldState, inputRef);
|
542
|
+
return {
|
543
|
+
fieldErrorProps,
|
544
|
+
formHintProps,
|
545
|
+
labelProps,
|
546
|
+
renderNumberField: () => /* @__PURE__ */ jsxRuntime.jsxs("div", { ...groupProps, className: styles.numberField, children: [
|
547
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
548
|
+
"input",
|
549
|
+
{
|
550
|
+
...inputProps,
|
551
|
+
className: classix.cx(styles.formInput, styles["numberField-input"]),
|
552
|
+
"data-test-id": testId,
|
553
|
+
name,
|
554
|
+
ref: inputRef
|
555
|
+
}
|
556
|
+
),
|
557
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles["numberField-stepperContainer"], children: [
|
558
|
+
/* @__PURE__ */ jsxRuntime.jsx(Stepper, { ...incrementButtonProps, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ExpandLess, {}) }),
|
559
|
+
/* @__PURE__ */ jsxRuntime.jsx(Stepper, { ...decrementButtonProps, children: /* @__PURE__ */ jsxRuntime.jsx(icons.ExpandMore, {}) })
|
560
|
+
] })
|
561
|
+
] })
|
562
|
+
};
|
563
|
+
};
|
564
|
+
const Stepper = (props) => {
|
565
|
+
const buttonRef = react.useRef(null);
|
566
|
+
const { buttonProps } = button.useButton(props, buttonRef);
|
567
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", { ...buttonProps, className: styles["numberField-stepper"], ref: buttonRef, children: props.children });
|
568
|
+
};
|
508
569
|
exports.Checkbox = Checkbox;
|
509
570
|
exports.CompactTextField = CompactTextField;
|
510
571
|
exports.FieldError = FieldError;
|
@@ -521,4 +582,5 @@ exports.RequiredAsterisk = RequiredAsterisk;
|
|
521
582
|
exports.SelectField = SelectField;
|
522
583
|
exports.TextArea = TextArea;
|
523
584
|
exports.TextField = TextField;
|
585
|
+
exports.useNumberField = useNumberField;
|
524
586
|
//# sourceMappingURL=index.js.map
|