@qualtrics/ui-react 2.28.0 → 2.29.0
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/CHANGELOG.md +11 -0
- package/dist/__shared/cjs/{index-2ad33b44.js → index-c2d2f188.js} +601 -391
- package/dist/__shared/cjs/{index-0c005184.js → index-c9e48360.js} +3 -3
- package/dist/components/Accordion/Accordion2.js +3 -3
- package/dist/components/Button/Button.js +3 -3
- package/dist/components/ButtonGroup/ButtonGroup2.js +3 -3
- package/dist/components/Checkbox/Checkbox.js +54 -10
- package/dist/components/Checkbox/Checkbox2.js +3 -3
- package/dist/components/Checkbox/VisualCheckbox2.js +3 -3
- package/dist/components/ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/Combobox/Combobox2.js +3 -3
- package/dist/components/ConfigPane/ConfigPane2.js +3 -3
- package/dist/components/Divider/Divider2.js +3 -3
- package/dist/components/Dropdown/Dropdown.js +59 -7
- package/dist/components/Dropdown/Dropdown2.js +3 -3
- package/dist/components/FilePicker/FilePicker2.js +3 -3
- package/dist/components/FormField/Caption.js +3 -3
- package/dist/components/FormField/FormField2.js +3 -3
- package/dist/components/FullScreenTakeover/FullScreenTakeover2.js +3 -3
- package/dist/components/IconButton/IconButton2.js +3 -3
- package/dist/components/InlineInput/InlineInput2.js +3 -3
- package/dist/components/Input/Input2.js +3 -3
- package/dist/components/InputGroup/InputGroup2.js +3 -3
- package/dist/components/Label/Label2.js +3 -3
- package/dist/components/Link/Link2.js +3 -3
- package/dist/components/LoadingSpinner/LoadingSpinner2.js +3 -3
- package/dist/components/LogicEditor/LogicEditor2.js +3 -3
- package/dist/components/Modal/Modal2.js +3 -3
- package/dist/components/NewMenu/NewMenu.js +3 -3
- package/dist/components/NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/PageLayout/PageLayout.js +3 -3
- package/dist/components/Pagination/Pagination2.js +3 -3
- package/dist/components/Popover/Popover2.js +3 -3
- package/dist/components/QuickSearch/QuickSearch2.js +3 -3
- package/dist/components/Radio/Radio.js +25 -5
- package/dist/components/Radio/Radio2.js +3 -3
- package/dist/components/Radio/RadioGroup.js +16 -3
- package/dist/components/SearchInput/SearchInput2.js +3 -3
- package/dist/components/SidebarNav/SidebarNav2.js +3 -3
- package/dist/components/Slider/Slider2.js +3 -3
- package/dist/components/Switch/Switch2.js +3 -3
- package/dist/components/Table/Table2.js +3 -3
- package/dist/components/Tabs/Tabs2.js +3 -3
- package/dist/components/Tooltip/Tooltip2.js +3 -3
- package/dist/components/deprecated_ColorPicker/ColorPicker2.js +3 -3
- package/dist/components/deprecated_NumberStepper/NumberStepper2.js +3 -3
- package/dist/components/deprecated_Tabs/Tabs2.js +3 -3
- package/dist/components/deprecated_Toolbar/Toolbar2.js +3 -3
- package/dist/hooks/useOverlay/useOverlay2.js +3 -3
- package/dist/hooks/useScreenReaderAnnouncement/useScreenReaderAnnouncement2.js +3 -3
- package/dist/icons/Icon.js +3 -3
- package/dist/icons/index.js +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.es.js +1 -1
- package/dist/index.js +3 -3
- package/dist/next/AdvancedTable/AdvancedTable.js +54 -78
- package/dist/next/AdvancedTable/AdvancedTable2.js +3 -3
- package/dist/next/CollapsibleSearchInput/CollapsibleSearchInput2.js +3 -3
- package/dist/next/Combobox/Combobox2.js +3 -3
- package/dist/next/Drawer/Drawer2.js +3 -3
- package/dist/next/FilterAnchor/FilterAnchor2.js +3 -3
- package/dist/next/Form/FormFields/FormFieldWrapper.js +36 -0
- package/dist/next/Form/FormFields/InputField.js +8 -0
- package/dist/next/Form/index.js +2 -0
- package/dist/next/Form/useForm.js +298 -0
- package/dist/next/Form/useFormField.js +25 -0
- package/dist/next/Form/utils/createFormInstance.js +32 -0
- package/dist/next/Form/utils/useFormContext.js +9 -0
- package/dist/next/Input/Input.js +47 -7
- package/dist/next/Input/Input2.js +3 -3
- package/dist/next/Menu/Menu2.js +3 -3
- package/dist/next/Menu/MenuPane.js +2 -2
- package/dist/next/Pagination/Pagination.css.js +9 -0
- package/dist/next/Pagination/Pagination.css.ts.vanilla.js +8 -0
- package/dist/next/Pagination/Pagination.js +166 -0
- package/dist/next/Pagination/RowDisplayCount.js +46 -0
- package/dist/next/Pagination/index.js +2 -0
- package/dist/next/PhoneNumberInput/PhoneNumberInput2.js +3 -3
- package/dist/next/Select/Select2.js +3 -3
- package/dist/next/SplitButton/SplitButton2.js +3 -3
- package/dist/next/TimePicker/TimePicker2.js +3 -3
- package/dist/next/ToggleButton/ToggleButton.js +2 -2
- package/dist/next/ToggleButton/styles.js +3 -3
- package/dist/next/index.d.ts +168 -2
- package/dist/next/index.es.js +29 -23
- package/dist/next/index.js +1962 -1474
- package/dist/utils/Flyout/Flyout2.js +3 -3
- package/icons/package.json +1 -1
- package/next/package.json +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { useState, useRef, useCallback, useMemo } from 'react';
|
|
2
|
+
import '../../hooks/index.js';
|
|
3
|
+
import createFormInstance from './utils/createFormInstance.js';
|
|
4
|
+
import useLatest from '../../hooks/useLatest/useLatest.js';
|
|
5
|
+
|
|
6
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
7
|
+
function useForm(_ref) {
|
|
8
|
+
let {
|
|
9
|
+
initialValues,
|
|
10
|
+
validateField
|
|
11
|
+
} = _ref;
|
|
12
|
+
const [formState, setFormState] = useState({
|
|
13
|
+
values: initialValues !== null && initialValues !== void 0 ? initialValues : {},
|
|
14
|
+
touched: {},
|
|
15
|
+
errors: {},
|
|
16
|
+
formError: '',
|
|
17
|
+
isSubmitting: false
|
|
18
|
+
});
|
|
19
|
+
const formStateRef = useRef(formState);
|
|
20
|
+
formStateRef.current = formState;
|
|
21
|
+
const getFormState = useCallback(() => formStateRef.current, []);
|
|
22
|
+
const formRef = useRef(null);
|
|
23
|
+
const allFieldRefs = useRef({});
|
|
24
|
+
const validateFieldRef = useLatest(validateField);
|
|
25
|
+
const refCallback = useCallback(node => {
|
|
26
|
+
if (!node) return;
|
|
27
|
+
const fieldName = node.name;
|
|
28
|
+
if (node.type === 'radio') {
|
|
29
|
+
const radioNodes = allFieldRefs.current[fieldName];
|
|
30
|
+
if (radioNodes && Array.isArray(radioNodes)) {
|
|
31
|
+
allFieldRefs.current[fieldName] = [...radioNodes, node];
|
|
32
|
+
} else {
|
|
33
|
+
allFieldRefs.current[fieldName] = [node];
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
allFieldRefs.current[fieldName] = node;
|
|
37
|
+
}
|
|
38
|
+
}, []);
|
|
39
|
+
const refCallbackCustom = useCallback(fieldName => node => {
|
|
40
|
+
if (!node) return;
|
|
41
|
+
allFieldRefs.current[fieldName] = node;
|
|
42
|
+
}, []);
|
|
43
|
+
const setValue = useCallback((name, value) => {
|
|
44
|
+
setFormState(prevFormState => ({
|
|
45
|
+
...prevFormState,
|
|
46
|
+
values: {
|
|
47
|
+
...prevFormState.values,
|
|
48
|
+
[name]: value
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
}, [setFormState]);
|
|
52
|
+
const setTouched = useCallback((name, touched) => {
|
|
53
|
+
setFormState(prevFormState => ({
|
|
54
|
+
...prevFormState,
|
|
55
|
+
touched: {
|
|
56
|
+
...prevFormState.touched,
|
|
57
|
+
[name]: touched
|
|
58
|
+
}
|
|
59
|
+
}));
|
|
60
|
+
}, [setFormState]);
|
|
61
|
+
const setError = useCallback((name, error) => {
|
|
62
|
+
setFormState(prevFormState => ({
|
|
63
|
+
...prevFormState,
|
|
64
|
+
errors: {
|
|
65
|
+
...prevFormState.errors,
|
|
66
|
+
[name]: error
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
}, [setFormState]);
|
|
70
|
+
const validate = useCallback((name, value) => {
|
|
71
|
+
var _validateFieldRef$cur;
|
|
72
|
+
const formValues = getFormState().values;
|
|
73
|
+
const newFormValues = {
|
|
74
|
+
...formValues,
|
|
75
|
+
[name]: value
|
|
76
|
+
};
|
|
77
|
+
const validationResult = (_validateFieldRef$cur = validateFieldRef.current) === null || _validateFieldRef$cur === void 0 ? void 0 : _validateFieldRef$cur.call(validateFieldRef, name, value, newFormValues);
|
|
78
|
+
return validationResult;
|
|
79
|
+
}, [getFormState, validateFieldRef]);
|
|
80
|
+
const onChange = useCallback(event => {
|
|
81
|
+
const target = event.currentTarget;
|
|
82
|
+
const fieldName = target.name;
|
|
83
|
+
const fieldType = target.type;
|
|
84
|
+
let fieldValue;
|
|
85
|
+
switch (fieldType) {
|
|
86
|
+
case 'text':
|
|
87
|
+
case 'email':
|
|
88
|
+
case 'password':
|
|
89
|
+
case 'radio':
|
|
90
|
+
fieldValue = target.value;
|
|
91
|
+
break;
|
|
92
|
+
case 'checkbox':
|
|
93
|
+
fieldValue = target.checked;
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
fieldValue = '';
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (getFormState().touched[fieldName]) {
|
|
100
|
+
const error = validate(fieldName, fieldValue);
|
|
101
|
+
setError(fieldName, error);
|
|
102
|
+
}
|
|
103
|
+
setValue(fieldName, fieldValue);
|
|
104
|
+
}, [setValue, setError, validate, getFormState]);
|
|
105
|
+
|
|
106
|
+
// Used for registering components without normal event passing
|
|
107
|
+
const onChangeCustom = useCallback(fieldName => fieldValue => {
|
|
108
|
+
if (getFormState().touched[fieldName]) {
|
|
109
|
+
const error = validate(fieldName, fieldValue);
|
|
110
|
+
setError(fieldName, error);
|
|
111
|
+
}
|
|
112
|
+
setValue(fieldName, fieldValue);
|
|
113
|
+
}, [getFormState, setValue, setError, validate]);
|
|
114
|
+
const onBlur = useCallback(event => {
|
|
115
|
+
const fieldName = event.target.name;
|
|
116
|
+
const fieldType = event.target.type;
|
|
117
|
+
let fieldValue;
|
|
118
|
+
switch (fieldType) {
|
|
119
|
+
case 'text':
|
|
120
|
+
case 'email':
|
|
121
|
+
case 'password':
|
|
122
|
+
case 'radio':
|
|
123
|
+
fieldValue = event.target.value;
|
|
124
|
+
break;
|
|
125
|
+
case 'checkbox':
|
|
126
|
+
fieldValue = event.target.checked;
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
fieldValue = '';
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
const error = validate(fieldName, fieldValue);
|
|
133
|
+
setError(fieldName, error);
|
|
134
|
+
setTouched(fieldName, true);
|
|
135
|
+
}, [setTouched, setError, validate]);
|
|
136
|
+
const onBlurCustom = useCallback(fieldName => () => {
|
|
137
|
+
const fieldValue = getFormState().values[fieldName];
|
|
138
|
+
const error = validate(fieldName, fieldValue);
|
|
139
|
+
setError(fieldName, error);
|
|
140
|
+
setTouched(fieldName, true);
|
|
141
|
+
}, [getFormState, setError, setTouched, validate]);
|
|
142
|
+
|
|
143
|
+
// register function types are determined by overloading here
|
|
144
|
+
|
|
145
|
+
function internalRegister(name) {
|
|
146
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
147
|
+
type: 'text'
|
|
148
|
+
};
|
|
149
|
+
const {
|
|
150
|
+
type
|
|
151
|
+
} = options;
|
|
152
|
+
let registerProps;
|
|
153
|
+
switch (type) {
|
|
154
|
+
case 'text':
|
|
155
|
+
case 'email':
|
|
156
|
+
case 'password':
|
|
157
|
+
{
|
|
158
|
+
const defaultValue = getFormState().values[name];
|
|
159
|
+
registerProps = {
|
|
160
|
+
name,
|
|
161
|
+
type,
|
|
162
|
+
value: defaultValue,
|
|
163
|
+
onBlur,
|
|
164
|
+
onChange,
|
|
165
|
+
ref: refCallback
|
|
166
|
+
};
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case 'checkbox':
|
|
170
|
+
{
|
|
171
|
+
const defaultChecked = !!getFormState().values[name];
|
|
172
|
+
registerProps = {
|
|
173
|
+
name,
|
|
174
|
+
type,
|
|
175
|
+
checked: defaultChecked,
|
|
176
|
+
onBlur,
|
|
177
|
+
onChange,
|
|
178
|
+
ref: refCallback
|
|
179
|
+
};
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case 'radio':
|
|
183
|
+
{
|
|
184
|
+
const {
|
|
185
|
+
radioValue
|
|
186
|
+
} = options;
|
|
187
|
+
const defaultChecked = getFormState().values[name] === radioValue;
|
|
188
|
+
registerProps = {
|
|
189
|
+
name,
|
|
190
|
+
type,
|
|
191
|
+
value: radioValue,
|
|
192
|
+
checked: defaultChecked,
|
|
193
|
+
onBlur,
|
|
194
|
+
onChange,
|
|
195
|
+
ref: refCallback
|
|
196
|
+
};
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
default:
|
|
200
|
+
{
|
|
201
|
+
const defaultValue = getFormState().values[name];
|
|
202
|
+
registerProps = {
|
|
203
|
+
name,
|
|
204
|
+
value: defaultValue,
|
|
205
|
+
onBlur: onBlurCustom(name),
|
|
206
|
+
onChange: onChangeCustom(name),
|
|
207
|
+
ref: refCallbackCustom(name)
|
|
208
|
+
};
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return registerProps;
|
|
213
|
+
}
|
|
214
|
+
const register = useCallback(internalRegister, [onChange, onChangeCustom, onBlur, onBlurCustom, refCallback, refCallbackCustom, getFormState]);
|
|
215
|
+
const handleSubmit = useCallback(onSubmit => async e => {
|
|
216
|
+
e.preventDefault(); // prevents page refresh on submit
|
|
217
|
+
|
|
218
|
+
const {
|
|
219
|
+
values
|
|
220
|
+
} = getFormState();
|
|
221
|
+
const invalidFieldNames = [];
|
|
222
|
+
Object.keys(allFieldRefs.current).forEach(fieldName => {
|
|
223
|
+
const fieldValue = values[fieldName];
|
|
224
|
+
const error = validate(fieldName, fieldValue);
|
|
225
|
+
setError(fieldName, error);
|
|
226
|
+
setTouched(fieldName, true);
|
|
227
|
+
if (typeof error === 'string') {
|
|
228
|
+
invalidFieldNames.push(fieldName);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
if (invalidFieldNames.length > 0) {
|
|
232
|
+
var _allFieldRefs$current;
|
|
233
|
+
const sorted = [...invalidFieldNames].sort((a, b) => {
|
|
234
|
+
const fieldA = allFieldRefs.current[a];
|
|
235
|
+
const fieldB = allFieldRefs.current[b];
|
|
236
|
+
|
|
237
|
+
// Radio nodes are as an array within the same key
|
|
238
|
+
// If node is an array, instead compare based on the first node in the array
|
|
239
|
+
const nodeA = Array.isArray(fieldA) ? fieldA[0] : fieldA;
|
|
240
|
+
const nodeB = Array.isArray(fieldB) ? fieldB[0] : fieldB;
|
|
241
|
+
|
|
242
|
+
/* eslint-disable no-bitwise */
|
|
243
|
+
// @ts-ignore
|
|
244
|
+
return nodeA.compareDocumentPosition(nodeB) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
// TODO: replace with imperitve focusField function
|
|
248
|
+
// If first invalid field is a radio, focus the checked input
|
|
249
|
+
// or the first input if none are checked
|
|
250
|
+
const firstInvalidField = (_allFieldRefs$current = allFieldRefs.current) === null || _allFieldRefs$current === void 0 ? void 0 : _allFieldRefs$current[sorted[0]];
|
|
251
|
+
if (Array.isArray(firstInvalidField)) {
|
|
252
|
+
const checkedRadio = firstInvalidField.find(node => node.checked);
|
|
253
|
+
if (checkedRadio) checkedRadio.focus();else firstInvalidField[0].focus();
|
|
254
|
+
} else {
|
|
255
|
+
firstInvalidField === null || firstInvalidField === void 0 || firstInvalidField.focus();
|
|
256
|
+
}
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
setFormState(prevFormState => ({
|
|
260
|
+
...prevFormState,
|
|
261
|
+
isSubmitting: true
|
|
262
|
+
}));
|
|
263
|
+
try {
|
|
264
|
+
await onSubmit(values, e);
|
|
265
|
+
setFormState(prevFormState => ({
|
|
266
|
+
...prevFormState,
|
|
267
|
+
isSubmitting: false
|
|
268
|
+
}));
|
|
269
|
+
} catch (err) {
|
|
270
|
+
setFormState(prevFormState => ({
|
|
271
|
+
...prevFormState,
|
|
272
|
+
isSubmitting: false,
|
|
273
|
+
formError: err === null || err === void 0 ? void 0 : err.message
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
}, [setError, setTouched, getFormState, setFormState, validate]);
|
|
277
|
+
const {
|
|
278
|
+
Form
|
|
279
|
+
} = useMemo(() => createFormInstance({
|
|
280
|
+
handleSubmit,
|
|
281
|
+
register,
|
|
282
|
+
getFormState,
|
|
283
|
+
setFormState,
|
|
284
|
+
formRef
|
|
285
|
+
}), [getFormState, handleSubmit, register, formRef]);
|
|
286
|
+
return {
|
|
287
|
+
Form,
|
|
288
|
+
register,
|
|
289
|
+
formValues: formState.values,
|
|
290
|
+
fieldErrors: formState.errors,
|
|
291
|
+
formError: formState.formError,
|
|
292
|
+
formTouched: formState.touched,
|
|
293
|
+
isSubmitting: formState.isSubmitting,
|
|
294
|
+
handleSubmit
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export { useForm as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useFormContext } from './utils/useFormContext.js';
|
|
2
|
+
|
|
3
|
+
// TODO
|
|
4
|
+
// Since strong typing is not possible with generics across context, this register
|
|
5
|
+
// function will have weaker TypeScript/autocomplete than the useForm register.
|
|
6
|
+
// We may want to consider logging a warning or throwing a runtime error if something
|
|
7
|
+
// goes wrong to compensate for this gap.
|
|
8
|
+
|
|
9
|
+
function useFormField() {
|
|
10
|
+
const {
|
|
11
|
+
register,
|
|
12
|
+
formState
|
|
13
|
+
} = useFormContext();
|
|
14
|
+
|
|
15
|
+
// const { values, touched, errors, formError, isSubmitting } = formState;
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
register,
|
|
19
|
+
formValues: formState === null || formState === void 0 ? void 0 : formState.values,
|
|
20
|
+
formTouched: formState === null || formState === void 0 ? void 0 : formState.touched,
|
|
21
|
+
fieldErrors: formState === null || formState === void 0 ? void 0 : formState.errors
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { useFormField as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
2
|
+
import React__default, { useMemo } from 'react';
|
|
3
|
+
import { FormProvider } from './useFormContext.js';
|
|
4
|
+
|
|
5
|
+
function createFormInstance(_ref) {
|
|
6
|
+
let {
|
|
7
|
+
register,
|
|
8
|
+
getFormState,
|
|
9
|
+
formRef
|
|
10
|
+
} = _ref;
|
|
11
|
+
const Form = _ref2 => {
|
|
12
|
+
let {
|
|
13
|
+
children,
|
|
14
|
+
...rest
|
|
15
|
+
} = _ref2;
|
|
16
|
+
const formState = getFormState();
|
|
17
|
+
const context = useMemo(() => ({
|
|
18
|
+
register,
|
|
19
|
+
formState
|
|
20
|
+
}), [formState]);
|
|
21
|
+
return /*#__PURE__*/React__default.createElement(FormProvider, {
|
|
22
|
+
value: context
|
|
23
|
+
}, /*#__PURE__*/React__default.createElement("form", _extends({
|
|
24
|
+
ref: formRef
|
|
25
|
+
}, rest), children));
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
Form
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { createFormInstance as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import '../../../utils/index.js';
|
|
2
|
+
import createContextUtilities from '../../../utils/createContextUtilities/createContextUtilities.js';
|
|
3
|
+
|
|
4
|
+
const {
|
|
5
|
+
Provider: FormProvider,
|
|
6
|
+
useContext: useFormContext
|
|
7
|
+
} = createContextUtilities({});
|
|
8
|
+
|
|
9
|
+
export { FormProvider, useFormContext };
|
package/dist/next/Input/Input.js
CHANGED
|
@@ -2,8 +2,14 @@ import _extends from '@babel/runtime-corejs3/helpers/extends';
|
|
|
2
2
|
import React__default, { forwardRef, useRef, useState } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import inputClasses from './Input2.js';
|
|
5
|
+
import FormFieldWrapper from '../Form/FormFields/FormFieldWrapper.js';
|
|
6
|
+
import useFormField from '../Form/useFormField.js';
|
|
5
7
|
import '../../hooks/index.js';
|
|
8
|
+
import '../../hooks/useId/index.js';
|
|
9
|
+
import '../../utils/mergeRefs/index.js';
|
|
10
|
+
import useId from '../../hooks/useId/useId.js';
|
|
6
11
|
import useSSRLayoutEffect from '../../hooks/useSSRLayoutEffect/useSSRLayoutEffect.js';
|
|
12
|
+
import mergeRefs from '../../utils/mergeRefs/mergeRefs.js';
|
|
7
13
|
|
|
8
14
|
const getAddOnComponent = (addOn, containerClassName, containerRef) => {
|
|
9
15
|
if (!addOn) {
|
|
@@ -20,16 +26,39 @@ const getAddOnComponent = (addOn, containerClassName, containerRef) => {
|
|
|
20
26
|
};
|
|
21
27
|
const Input = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
22
28
|
let {
|
|
29
|
+
name,
|
|
30
|
+
id,
|
|
23
31
|
type = 'text',
|
|
24
32
|
initialValue,
|
|
25
|
-
value,
|
|
26
|
-
onChange,
|
|
33
|
+
value: externalValue,
|
|
34
|
+
onChange: externalOnChange,
|
|
35
|
+
onBlur: externalOnBlur,
|
|
36
|
+
label,
|
|
27
37
|
leftAddOn,
|
|
28
38
|
rightAddOn,
|
|
39
|
+
errorText,
|
|
40
|
+
helperText,
|
|
29
41
|
className: externalClassName,
|
|
42
|
+
'data-testid': dataTestId,
|
|
30
43
|
style,
|
|
31
44
|
...rest
|
|
32
45
|
} = _ref;
|
|
46
|
+
const {
|
|
47
|
+
register,
|
|
48
|
+
fieldErrors
|
|
49
|
+
} = useFormField();
|
|
50
|
+
const inputId = useId(id);
|
|
51
|
+
const registerProps = name && register ? register(name, {
|
|
52
|
+
type: 'text'
|
|
53
|
+
}) : undefined;
|
|
54
|
+
const onChange = e => {
|
|
55
|
+
externalOnChange === null || externalOnChange === void 0 || externalOnChange(e);
|
|
56
|
+
registerProps === null || registerProps === void 0 || registerProps.onChange(e);
|
|
57
|
+
};
|
|
58
|
+
const onBlur = e => {
|
|
59
|
+
externalOnBlur === null || externalOnBlur === void 0 || externalOnBlur(e);
|
|
60
|
+
registerProps === null || registerProps === void 0 || registerProps.onBlur(e);
|
|
61
|
+
};
|
|
33
62
|
const leftAddOnRef = useRef(null);
|
|
34
63
|
const rightAddOnRef = useRef(null);
|
|
35
64
|
const [addOnWidths, setAddOnWidths] = useState({
|
|
@@ -55,21 +84,32 @@ const Input = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
|
55
84
|
rightAddOn // Re-runs effect when the right add-on changes
|
|
56
85
|
]);
|
|
57
86
|
|
|
58
|
-
return /*#__PURE__*/React__default.createElement(
|
|
59
|
-
|
|
87
|
+
return /*#__PURE__*/React__default.createElement(FormFieldWrapper, {
|
|
88
|
+
inputId: inputId,
|
|
89
|
+
"data-testid": dataTestId,
|
|
90
|
+
label: label,
|
|
91
|
+
errorText: errorText !== null && errorText !== void 0 ? errorText : name && (fieldErrors === null || fieldErrors === void 0 ? void 0 : fieldErrors[name]),
|
|
92
|
+
helperText: helperText,
|
|
93
|
+
className: externalClassName,
|
|
60
94
|
style: style
|
|
95
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
96
|
+
className: inputClasses.container
|
|
61
97
|
}, getAddOnComponent(leftAddOn, inputClasses.leftAddOn, leftAddOnRef), /*#__PURE__*/React__default.createElement("input", _extends({}, rest, {
|
|
98
|
+
id: inputId,
|
|
99
|
+
name: registerProps === null || registerProps === void 0 ? void 0 : registerProps.name,
|
|
62
100
|
type: type,
|
|
63
101
|
defaultValue: initialValue,
|
|
64
|
-
value: value,
|
|
102
|
+
value: externalValue !== null && externalValue !== void 0 ? externalValue : registerProps === null || registerProps === void 0 ? void 0 : registerProps.value,
|
|
65
103
|
onChange: onChange,
|
|
104
|
+
onBlur: onBlur,
|
|
66
105
|
className: inputClasses.input,
|
|
67
106
|
style: {
|
|
68
107
|
paddingLeft: "".concat(addOnWidths.leftAddOnWidth + ADD_ON_HORIZONTAL_PADDING, "px"),
|
|
69
108
|
paddingRight: "".concat(addOnWidths.rightAddOnWidth + ADD_ON_HORIZONTAL_PADDING, "px")
|
|
70
109
|
},
|
|
71
|
-
|
|
72
|
-
|
|
110
|
+
"data-testid": dataTestId,
|
|
111
|
+
ref: mergeRefs(ref, registerProps === null || registerProps === void 0 ? void 0 : registerProps.ref)
|
|
112
|
+
})), getAddOnComponent(rightAddOn, inputClasses.rightAddOn, rightAddOnRef)));
|
|
73
113
|
});
|
|
74
114
|
|
|
75
115
|
export { Input as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".
|
|
4
|
-
var inputClasses = {"container":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._qUQkQ{position:relative;display:inline-block;height:36px}._8u-HP{width:100%;height:100%;padding:8px 12px;color:#32363a;caret-color:#32363a;font-size:14px;background-color:#fafafa;border:1px solid #898989;border-radius:4px;outline:none}._8u-HP:hover{cursor:pointer;background-color:#f5f5f5}._8u-HP:focus{background-color:#fafafa;cursor:text;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;outline:none;border-color:transparent}._8u-HP:disabled,._8u-HP[aria-disabled=true]{background-color:#fafafa;border-color:#e5e5e5;color:#9d9fa1;-webkit-text-fill-color:#9d9fa1;cursor:not-allowed}._8u-HP:disabled::-moz-placeholder,._8u-HP[aria-disabled=true]::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._8u-HP:disabled::placeholder,._8u-HP[aria-disabled=true]::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._8u-HP:invalid,._8u-HP[aria-invalid=true]{border-color:#b00}._8u-HP:invalid:focus,._8u-HP[aria-invalid=true]:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000;border-color:transparent}._8u-HP[type=number]{-moz-appearance:textfield}._8u-HP[type=number]::-webkit-inner-spin-button,._8u-HP[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}._8u-HP::-moz-placeholder{color:#515559;opacity:1}._8u-HP::placeholder{color:#515559;opacity:1}._3dyBI{pointer-events:none;color:#515559;fill:#515559}._lkORl{display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._qmQyj{color:#515559;font-size:16px}._v3K-R{left:0;margin-left:6px}._SU6o5,._v3K-R{pointer-events:none;color:#515559;fill:#515559;display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._SU6o5{right:0;margin-right:6px}";
|
|
4
|
+
var inputClasses = {"container":"_qUQkQ","input":"_8u-HP","addOn":"_3dyBI","addOnVerticalCenter":"_lkORl","addOnTextNode":"_qmQyj","leftAddOn":"_v3K-R","rightAddOn":"_SU6o5"};
|
|
5
|
+
var stylesheet="._qUQkQ{position:relative;display:inline-block;height:36px}._8u-HP{width:100%;height:100%;padding:8px 12px;color:#32363a;caret-color:#32363a;font-size:14px;background-color:#fafafa;border:1px solid #898989;border-radius:4px;outline:none}._8u-HP:hover{cursor:pointer;background-color:#f5f5f5}._8u-HP:focus{background-color:#fafafa;cursor:text;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88;outline:none;border-color:transparent}._8u-HP:disabled,._8u-HP[aria-disabled=true]{background-color:#fafafa;border-color:#e5e5e5;color:#9d9fa1;-webkit-text-fill-color:#9d9fa1;cursor:not-allowed}._8u-HP:disabled::-moz-placeholder,._8u-HP[aria-disabled=true]::-moz-placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._8u-HP:disabled::placeholder,._8u-HP[aria-disabled=true]::placeholder{color:#aaabad;-webkit-text-fill-color:#aaabad}._8u-HP:invalid,._8u-HP[aria-invalid=true]{border-color:#b00}._8u-HP:invalid:focus,._8u-HP[aria-invalid=true]:focus{box-shadow:0 0 0 2px #fff,0 0 0 4px #900000;border-color:transparent}._8u-HP[type=number]{-moz-appearance:textfield}._8u-HP[type=number]::-webkit-inner-spin-button,._8u-HP[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}._8u-HP::-moz-placeholder{color:#515559;opacity:1}._8u-HP::placeholder{color:#515559;opacity:1}._3dyBI{pointer-events:none;color:#515559;fill:#515559}._lkORl{display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._qmQyj{color:#515559;font-size:16px}._v3K-R{left:0;margin-left:6px}._SU6o5,._v3K-R{pointer-events:none;color:#515559;fill:#515559;display:flex;flex-direction:column;align-items:center;position:absolute;top:50%;transform:translateY(-50%)}._SU6o5{right:0;margin-right:6px}";
|
|
6
6
|
if(typeof process !== 'object' || !process.hasOwnProperty('env') || process.env.NODE_ENV !== 'test'){styleInject(css_248z);}
|
|
7
7
|
|
|
8
8
|
export { inputClasses as default, stylesheet };
|
package/dist/next/Menu/Menu2.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".
|
|
4
|
-
var styles = {"buttonContainer":"
|
|
5
|
-
var stylesheet=".
|
|
3
|
+
var css_248z = "._JzPKZ{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._JzPKZ>._q6pza{cursor:unset;width:100%;height:100%;padding:0 28px 0 12px;border-radius:4px;white-space:nowrap;line-height:20px;font-size:14px;text-align:left;outline:none;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559;background-color:#fafafa;overflow:hidden;text-overflow:ellipsis}._JzPKZ>._q6pza:hover:not([aria-disabled=true]){background-color:#f5f5f5}._JzPKZ>._q6pza.focus-visible,._JzPKZ>._q6pza:focus-visible{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._JzPKZ>._q6pza+._4U8FO{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._JzPKZ>._q6pza[data-state=open]+._4U8FO{transform:rotate(-180deg) translateY(50%)}._JzPKZ>._q6pza[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._JzPKZ>._q6pza[aria-disabled=true]+._4U8FO{fill:#515559;opacity:.4}._R24FG>[data-radix-popper-content-wrapper]{overflow:hidden;background-color:#fff;max-width:350px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);border-radius:4px;z-index:var(--mask-z-index)!important;width:var(--mask-width);height:var(--mask-height);transition:height .35s,width .35s}._R24FG>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._jjLLy{margin:0;padding-bottom:var(--flyout-bottom-padding);background:#fff;transition:margin-left .35s,opacity .35s,height .35s,width .35s;opacity:1;max-width:350px;width:-webkit-max-content;width:-moz-max-content;width:max-content;min-width:200px;max-height:var(--flyout-max-height)}._jjLLy ._V4D9n{height:100%;overflow-y:scroll}._jjLLy._SZQCR{margin-left:30px;opacity:0}._jjLLy._wMgQL{margin-left:-30px}._Qq6ps{position:relative;padding:10px 12px;display:flex;flex-direction:row;min-height:40px;align-items:center;cursor:pointer;outline:none;word-break:break-word;font-size:14px;color:#32363a;width:100%}._Qq6ps._Uy4Cq{cursor:unset}._Qq6ps ._oEnlH{fill:#32363a;margin-right:4px}._Qq6ps:focus,._Qq6ps:hover:not(._Qq6ps._Uy4Cq){background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._Qq6ps[aria-disabled=true]{cursor:not-allowed;opacity:.65}._Qq6ps._2pXrP{padding-right:32px}._Qq6ps._2pXrP ._4U8FO{position:absolute;height:100%;right:3px;fill:#515559}._Qq6ps._T7j0r{pointer-events:none}._F-fgA{position:-webkit-sticky;position:sticky;top:0;background-color:#fff;border-bottom:1px solid #e8e8e8}._F-fgA._tR4v6{padding-top:52px}._Ys3hV{pointer-events:none;position:fixed;left:0;top:0;transition:width .35s;min-width:200px;width:var(--mask-width);max-width:350px}._-uV5H{position:absolute;padding:8px;border-radius:4px 4px 0 0;pointer-events:auto;opacity:1;width:100%;transition:opacity .35s,margin-left .35s}._-uV5H._wMgQL{opacity:0}._-uV5H._wMgQL>._7IFWj{margin-left:-30px}._-uV5H._SZQCR{opacity:0}._-uV5H._SZQCR>._7IFWj{margin-left:30px}._-uV5H>._7IFWj{transition:margin-left .35s;width:100%}._-uV5H._T7j0r{pointer-events:none}body.keyboard-user ._Qq6ps:hover:not(:focus){background-color:#fff;box-shadow:none}";
|
|
4
|
+
var styles = {"buttonContainer":"_JzPKZ","button":"_q6pza","rightIcon":"_4U8FO","maskContainer":"_R24FG","flyout":"_jjLLy","scrollContainer":"_V4D9n","animatedRight":"_SZQCR","animatedLeft":"_wMgQL","menuItem":"_Qq6ps","noItems":"_Uy4Cq","backIcon":"_oEnlH","subMenu":"_2pXrP","unresponsive":"_T7j0r","stickyBox":"_F-fgA","isSearchable":"_tR4v6","searchBoxesContainer":"_Ys3hV","searchBox":"_-uV5H","searchInput":"_7IFWj"};
|
|
5
|
+
var stylesheet="._JzPKZ{position:relative;display:inline-flex;height:36px;min-width:60px;cursor:pointer}._JzPKZ>._q6pza{cursor:unset;width:100%;height:100%;padding:0 28px 0 12px;border-radius:4px;white-space:nowrap;line-height:20px;font-size:14px;text-align:left;outline:none;border:none;box-shadow:inset 0 0 0 1px #898989;color:#515559;background-color:#fafafa;overflow:hidden;text-overflow:ellipsis}._JzPKZ>._q6pza:hover:not([aria-disabled=true]){background-color:#f5f5f5}._JzPKZ>._q6pza.focus-visible,._JzPKZ>._q6pza:focus-visible{background-color:#fafafa;box-shadow:0 0 0 2px #fff,0 0 0 4px #0a3f88}._JzPKZ>._q6pza+._4U8FO{fill:#515559;position:absolute;pointer-events:none;right:4px;top:50%;transform:translateY(-50%)}._JzPKZ>._q6pza[data-state=open]+._4U8FO{transform:rotate(-180deg) translateY(50%)}._JzPKZ>._q6pza[aria-disabled=true]{box-shadow:inset 0 0 0 1px #e5e5e5;color:#74777a;cursor:not-allowed}._JzPKZ>._q6pza[aria-disabled=true]+._4U8FO{fill:#515559;opacity:.4}._R24FG>[data-radix-popper-content-wrapper]{overflow:hidden;background-color:#fff;max-width:350px;box-shadow:0 8px 20px rgba(0,0,0,.1),0 4px 6px rgba(0,0,0,.05);border-radius:4px;z-index:var(--mask-z-index)!important;width:var(--mask-width);height:var(--mask-height);transition:height .35s,width .35s}._R24FG>[data-radix-popper-content-wrapper] [data-radix-popper-content-wrapper]{transform:translateZ(0)!important}._jjLLy{margin:0;padding-bottom:var(--flyout-bottom-padding);background:#fff;transition:margin-left .35s,opacity .35s,height .35s,width .35s;opacity:1;max-width:350px;width:-webkit-max-content;width:-moz-max-content;width:max-content;min-width:200px;max-height:var(--flyout-max-height)}._jjLLy ._V4D9n{height:100%;overflow-y:scroll}._jjLLy._SZQCR{margin-left:30px;opacity:0}._jjLLy._wMgQL{margin-left:-30px}._Qq6ps{position:relative;padding:10px 12px;display:flex;flex-direction:row;min-height:40px;align-items:center;cursor:pointer;outline:none;word-break:break-word;font-size:14px;color:#32363a;width:100%}._Qq6ps._Uy4Cq{cursor:unset}._Qq6ps ._oEnlH{fill:#32363a;margin-right:4px}._Qq6ps:focus,._Qq6ps:hover:not(._Qq6ps._Uy4Cq){background-color:#efefef;box-shadow:inset 0 0 0 2px #0a3f88,inset 0 0 0 4px #fff;border-radius:6px}._Qq6ps[aria-disabled=true]{cursor:not-allowed;opacity:.65}._Qq6ps._2pXrP{padding-right:32px}._Qq6ps._2pXrP ._4U8FO{position:absolute;height:100%;right:3px;fill:#515559}._Qq6ps._T7j0r{pointer-events:none}._F-fgA{position:-webkit-sticky;position:sticky;top:0;background-color:#fff;border-bottom:1px solid #e8e8e8}._F-fgA._tR4v6{padding-top:52px}._Ys3hV{pointer-events:none;position:fixed;left:0;top:0;transition:width .35s;min-width:200px;width:var(--mask-width);max-width:350px}._-uV5H{position:absolute;padding:8px;border-radius:4px 4px 0 0;pointer-events:auto;opacity:1;width:100%;transition:opacity .35s,margin-left .35s}._-uV5H._wMgQL{opacity:0}._-uV5H._wMgQL>._7IFWj{margin-left:-30px}._-uV5H._SZQCR{opacity:0}._-uV5H._SZQCR>._7IFWj{margin-left:30px}._-uV5H>._7IFWj{transition:margin-left .35s;width:100%}._-uV5H._T7j0r{pointer-events:none}body.keyboard-user ._Qq6ps:hover:not(:focus){background-color:#fff;box-shadow:none}";
|
|
6
6
|
if(typeof process !== 'object' || !process.hasOwnProperty('env') || process.env.NODE_ENV !== 'test'){styleInject(css_248z);}
|
|
7
7
|
|
|
8
8
|
export { styles as default, stylesheet };
|
|
@@ -130,8 +130,8 @@ const MenuPane = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
130
130
|
// We use the top-level Radix container as a mask. Radix does not expose this container to consumers, except through CSS.
|
|
131
131
|
// These hooks dynamically update the style of that container using CSS variables.
|
|
132
132
|
useCSSVariable('--mask-z-index', String(zIndex), [open]);
|
|
133
|
-
useCSSVariable('--mask-width', "".concat(maskWidth, "px"));
|
|
134
|
-
useCSSVariable('--mask-height', "".concat(maskHeight, "px"));
|
|
133
|
+
useCSSVariable('--mask-width', Number.isNaN(Number(maskWidth)) ? "".concat(maskWidth) : "".concat(maskWidth, "px"));
|
|
134
|
+
useCSSVariable('--mask-height', Number.isNaN(Number(maskHeight)) ? "".concat(maskHeight) : "".concat(maskHeight, "px"));
|
|
135
135
|
useCSSVariable('--flyout-max-height', "".concat(paneMaxHeight, "px"));
|
|
136
136
|
useCSSVariable('--flyout-bottom-padding', "".concat(paneBottomPadding, "px"));
|
|
137
137
|
useOverlay({
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import './Pagination.css.ts.vanilla.js';
|
|
2
|
+
|
|
3
|
+
var growingInput = 'Pagination_growingInput__1iropsc2';
|
|
4
|
+
var hidden = 'Pagination_hidden__1iropsc3';
|
|
5
|
+
var pageNumber = 'Pagination_pageNumber__1iropsc1';
|
|
6
|
+
var pagination = 'Pagination_pagination__1iropsc0';
|
|
7
|
+
var rowCount = 'Pagination_rowCount__1iropsc4';
|
|
8
|
+
|
|
9
|
+
export { growingInput, hidden, pageNumber, pagination, rowCount };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import styleInject from './../../__node_modules/style-inject/dist/style-inject.es.js';
|
|
2
|
+
|
|
3
|
+
var css_248z = ".Pagination_pagination__1iropsc0{display:flex;align-items:center}.Pagination_pageNumber__1iropsc1{display:inline-flex;align-items:center;font-size:14px;grid-gap:6px;gap:6px;padding:0 6px;color:#32363a;text-align:center}.Pagination_growingInput__1iropsc2{position:relative;display:inline-flex}.Pagination_hidden__1iropsc3{position:absolute;visibility:hidden;padding:8px 12px;border:1px solid transparent}.Pagination_rowCount__1iropsc4{display:inline-flex;align-items:center;grid-gap:6px;gap:6px;font-size:14px;padding:0 6px;color:#32363a}";
|
|
4
|
+
var Pagination_css_ts_vanilla = {"Pagination_pagination__1iropsc0":"Pagination_pagination__1iropsc0","Pagination_pageNumber__1iropsc1":"Pagination_pageNumber__1iropsc1","Pagination_growingInput__1iropsc2":"Pagination_growingInput__1iropsc2","Pagination_hidden__1iropsc3":"Pagination_hidden__1iropsc3","Pagination_rowCount__1iropsc4":"Pagination_rowCount__1iropsc4"};
|
|
5
|
+
var stylesheet=".Pagination_pagination__1iropsc0{display:flex;align-items:center}.Pagination_pageNumber__1iropsc1{display:inline-flex;align-items:center;font-size:14px;grid-gap:6px;gap:6px;padding:0 6px;color:#32363a;text-align:center}.Pagination_growingInput__1iropsc2{position:relative;display:inline-flex}.Pagination_hidden__1iropsc3{position:absolute;visibility:hidden;padding:8px 12px;border:1px solid transparent}.Pagination_rowCount__1iropsc4{display:inline-flex;align-items:center;grid-gap:6px;gap:6px;font-size:14px;padding:0 6px;color:#32363a}";
|
|
6
|
+
if(typeof process !== 'object' || !process.hasOwnProperty('env') || process.env.NODE_ENV !== 'test'){styleInject(css_248z);}
|
|
7
|
+
|
|
8
|
+
export { Pagination_css_ts_vanilla as default, stylesheet };
|