@trackunit/react-form-components 0.0.500 → 0.0.502
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/index.cjs.js +255 -230
- package/index.esm.js +235 -196
- package/package.json +6 -5
- package/src/components/ActionButton/ActionButton.d.ts +1 -2
- package/src/components/BaseInput/DisabledForReasonsTip.d.ts +1 -2
- package/src/components/Checkbox/CheckIcon.d.ts +1 -2
- package/src/components/Checkbox/IndeterminateIcon.d.ts +1 -2
- package/src/components/DateField/DateField.d.ts +0 -1
- package/src/components/DateInput/DateInput.d.ts +0 -1
- package/src/components/DropZone/DropZone.d.ts +0 -1
- package/src/components/DropZone/DropZoneDefaultLabel.d.ts +1 -2
- package/src/components/FormGroup/FormGroup.d.ts +1 -1
- package/src/components/NumberField/NumberField.d.ts +0 -1
- package/src/components/NumberInput/NumberInput.d.ts +0 -1
- package/src/components/PasswordField/PasswordField.d.ts +0 -1
- package/src/components/PasswordInput/PasswordInput.d.ts +0 -1
- package/src/components/PhoneField/PhoneField.d.ts +0 -1
- package/src/components/PhoneFieldWithController/PhoneFieldWithController.d.ts +0 -1
- package/src/components/PhoneInput/CountryCodeSelect.d.ts +1 -1
- package/src/components/Schedule/Schedule.d.ts +1 -2
- package/src/components/Select/CreatableSelect.d.ts +1 -2
- package/src/components/Select/FieldContainer.d.ts +1 -1
- package/src/components/Select/Select.d.ts +1 -2
- package/src/components/Select/SelectMenuItem/SelectMenuItem.d.ts +2 -2
- package/src/components/Select/TagWithWidth.d.ts +1 -2
- package/src/components/Select/TagsContainer.d.ts +1 -2
- package/src/components/SelectField/CreatableSelectField.d.ts +6 -7
- package/src/components/SelectField/FormFieldSelectAdapter.d.ts +0 -1
- package/src/components/SelectField/SelectField.d.ts +6 -7
- package/src/components/TextField/TextLenghtIndicator.d.ts +1 -2
- package/src/components/TextInput/TextInput.d.ts +0 -1
- package/src/components/TimeRange/TimeRange.d.ts +1 -1
- package/src/components/TimeRangeField/TimeRangeField.d.ts +1 -2
- package/src/components/UploadField/UploadField.d.ts +0 -1
- package/src/components/UploadInput/UploadInput.d.ts +0 -1
- package/src/components/UrlField/UrlField.d.ts +0 -1
- package/src/components/UrlInput/UrlInput.d.ts +0 -1
- package/src/translation.d.ts +1 -2
- package/translation.cjs.js +1 -1
- package/translation.cjs10.js +1 -1
- package/translation.cjs11.js +1 -1
- package/translation.cjs12.js +1 -1
- package/translation.cjs13.js +1 -1
- package/translation.cjs14.js +1 -1
- package/translation.cjs15.js +1 -1
- package/translation.cjs16.js +1 -1
- package/translation.cjs17.js +1 -1
- package/translation.cjs2.js +1 -1
- package/translation.cjs3.js +1 -1
- package/translation.cjs4.js +1 -1
- package/translation.cjs5.js +1 -1
- package/translation.cjs6.js +1 -1
- package/translation.cjs7.js +1 -1
- package/translation.cjs8.js +1 -1
- package/translation.cjs9.js +1 -1
package/index.cjs.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
4
|
var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
|
|
7
5
|
var reactComponents = require('@trackunit/react-components');
|
|
@@ -20,10 +18,7 @@ var sharedUtils = require('@trackunit/shared-utils');
|
|
|
20
18
|
var tailwindMerge = require('tailwind-merge');
|
|
21
19
|
var zod = require('zod');
|
|
22
20
|
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
function _interopNamespace(e) {
|
|
26
|
-
if (e && e.__esModule) return e;
|
|
21
|
+
function _interopNamespaceDefault(e) {
|
|
27
22
|
var n = Object.create(null);
|
|
28
23
|
if (e) {
|
|
29
24
|
Object.keys(e).forEach(function (k) {
|
|
@@ -36,17 +31,11 @@ function _interopNamespace(e) {
|
|
|
36
31
|
}
|
|
37
32
|
});
|
|
38
33
|
}
|
|
39
|
-
n
|
|
34
|
+
n.default = e;
|
|
40
35
|
return Object.freeze(n);
|
|
41
36
|
}
|
|
42
37
|
|
|
43
|
-
var React__namespace = /*#__PURE__*/
|
|
44
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
45
|
-
var parsePhoneNumberFromString__default = /*#__PURE__*/_interopDefaultLegacy(parsePhoneNumberFromString);
|
|
46
|
-
var ReactSelect__default = /*#__PURE__*/_interopDefaultLegacy(ReactSelect);
|
|
47
|
-
var ReactAsyncCreatableSelect__default = /*#__PURE__*/_interopDefaultLegacy(ReactAsyncCreatableSelect);
|
|
48
|
-
var ReactCreatableSelect__default = /*#__PURE__*/_interopDefaultLegacy(ReactCreatableSelect);
|
|
49
|
-
var ReactAsyncSelect__default = /*#__PURE__*/_interopDefaultLegacy(ReactAsyncSelect);
|
|
38
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
50
39
|
|
|
51
40
|
var defaultTranslations = {
|
|
52
41
|
"clearIndicator.icon.tooltip.clearAll": "Clear all",
|
|
@@ -103,7 +92,7 @@ const useTranslation = () => i18nLibraryTranslation.useNamespaceTranslation(name
|
|
|
103
92
|
/**
|
|
104
93
|
* Trans for this specific library.
|
|
105
94
|
*/
|
|
106
|
-
const Trans = (props) => (jsxRuntime.jsx(i18nLibraryTranslation.NamespaceTrans,
|
|
95
|
+
const Trans = (props) => (jsxRuntime.jsx(i18nLibraryTranslation.NamespaceTrans, { ...props, namespace: namespace }));
|
|
107
96
|
/**
|
|
108
97
|
* Registers the translations for this library
|
|
109
98
|
*/
|
|
@@ -169,48 +158,6 @@ const ActionButton = ({ type, value, dataTestId, iconSize, disabled, className }
|
|
|
169
158
|
return (jsxRuntime.jsx("div", { className: cvaActionContainer({ className }), children: jsxRuntime.jsx(reactComponents.IconButton, { className: cvaActionButton({ size: iconSize }), dataTestId: dataTestId || "testIconButtonId", disabled: disabled, icon: jsxRuntime.jsx(reactComponents.Icon, { name: getIconName(), size: "small" }), onClick: ButtonAction, size: "small", variant: "secondary" }) }));
|
|
170
159
|
};
|
|
171
160
|
|
|
172
|
-
/******************************************************************************
|
|
173
|
-
Copyright (c) Microsoft Corporation.
|
|
174
|
-
|
|
175
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
176
|
-
purpose with or without fee is hereby granted.
|
|
177
|
-
|
|
178
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
179
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
180
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
181
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
182
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
183
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
184
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
185
|
-
***************************************************************************** */
|
|
186
|
-
|
|
187
|
-
function __rest(s, e) {
|
|
188
|
-
var t = {};
|
|
189
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
190
|
-
t[p] = s[p];
|
|
191
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
192
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
193
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
194
|
-
t[p[i]] = s[p[i]];
|
|
195
|
-
}
|
|
196
|
-
return t;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
200
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
201
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
202
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
203
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
204
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
205
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
210
|
-
var e = new Error(message);
|
|
211
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
212
|
-
};
|
|
213
|
-
|
|
214
161
|
/**
|
|
215
162
|
* Used to compare two React nodes for deep equality.
|
|
216
163
|
*/
|
|
@@ -409,9 +356,8 @@ const DisabledForReasonsTip = ({ reasons, kind }) => {
|
|
|
409
356
|
* For specific input types make sure to use the corresponding input component.
|
|
410
357
|
* This is a base used by our other input components such as TextInput, NumberInput, PasswordInput, etc.
|
|
411
358
|
*/
|
|
412
|
-
const BaseInput = React__namespace.forwardRef((
|
|
413
|
-
var
|
|
414
|
-
var { className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, showDefaultActions = false, inputClassName, placeholder, addonBeforeClassName } = _a, rest = __rest(_a, ["className", "isInvalid", "dataTestId", "prefix", "suffix", "addonBefore", "addonAfter", "actions", "fieldSize", "nonInteractive", "showDefaultActions", "inputClassName", "placeholder", "addonBeforeClassName"]);
|
|
359
|
+
const BaseInput = React__namespace.forwardRef(({ className, isInvalid, dataTestId, prefix, suffix, addonBefore, addonAfter, actions, fieldSize = "medium", nonInteractive = false, showDefaultActions = false, inputClassName, placeholder, addonBeforeClassName, ...rest }, ref) => {
|
|
360
|
+
var _a;
|
|
415
361
|
const renderAsDisabled = Boolean(rest.disabled) || rest.readOnly;
|
|
416
362
|
const innerRef = React__namespace.useRef(null);
|
|
417
363
|
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
@@ -424,22 +370,22 @@ const BaseInput = React__namespace.forwardRef((_a, ref) => {
|
|
|
424
370
|
}), "data-testid": dataTestId ? `${dataTestId}-container` : null, children: [addonBefore ? (jsxRuntime.jsx("div", { className: cvaInputAddonBefore({ className: addonBeforeClassName }), "data-testid": dataTestId ? `${dataTestId}-addonBefore` : null, children: addonBefore })) : null, prefix && !compareReactNodes(addonBefore, prefix) ? (jsxRuntime.jsx("div", { className: cvaInputPrefix({
|
|
425
371
|
disabled: renderAsDisabled,
|
|
426
372
|
addonBefore: addonBefore !== undefined,
|
|
427
|
-
}), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, children: prefix })) : null, jsxRuntime.jsx("input",
|
|
373
|
+
}), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, children: prefix })) : null, jsxRuntime.jsx("input", { "aria-required": rest.required, className: cvaInputField({
|
|
428
374
|
autoFocus: rest.autoFocus,
|
|
429
375
|
size: fieldSize,
|
|
430
376
|
disabled: renderAsDisabled,
|
|
431
377
|
className: inputClassName,
|
|
432
378
|
addonBefore: addonBefore !== undefined,
|
|
433
379
|
prefix: !compareReactNodes(addonBefore, prefix),
|
|
434
|
-
}), "data-testid": dataTestId, placeholder: renderAsDisabled ? undefined : placeholder, ref: innerRef
|
|
380
|
+
}), "data-testid": dataTestId, placeholder: renderAsDisabled ? undefined : placeholder, ref: innerRef, ...rest, disabled: renderAsDisabled, readOnly: rest.readOnly || nonInteractive }), typeof rest.disabled === "object" ? (jsxRuntime.jsx("div", { className: cvaInputSuffix({
|
|
435
381
|
disabled: false,
|
|
436
|
-
}), "data-testid": dataTestId ? `${dataTestId}-locked` : undefined, children: jsxRuntime.jsx(DisabledForReasonsTip,
|
|
382
|
+
}), "data-testid": dataTestId ? `${dataTestId}-locked` : undefined, children: jsxRuntime.jsx(DisabledForReasonsTip, { ...rest.disabled }) })) : null, suffix && addonBefore !== suffix ? (jsxRuntime.jsx("div", { className: cvaInputSuffix({
|
|
437
383
|
disabled: renderAsDisabled,
|
|
438
384
|
addonAfter: addonAfter !== undefined && !compareReactNodes(addonBefore, addonAfter),
|
|
439
385
|
actions: (actions && !compareReactNodes(addonBefore, actions)) || false,
|
|
440
386
|
}), "data-testid": dataTestId ? `${dataTestId}-suffix` : null, children: suffix })) : null, rest.readOnly === true &&
|
|
441
387
|
showDefaultActions &&
|
|
442
|
-
((
|
|
388
|
+
((_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.value.length) &&
|
|
443
389
|
innerRef.current.value.length > 0 ? (jsxRuntime.jsx(ActionButton, { type: "COPY", value: innerRef }, "default-copy-action")) : null, actions && !compareReactNodes(addonBefore, actions) ? (jsxRuntime.jsx("div", { className: cvaInputAction({
|
|
444
390
|
addonAfter: addonAfter !== undefined && !compareReactNodes(addonBefore, addonAfter),
|
|
445
391
|
suffix: !compareReactNodes(addonBefore, suffix),
|
|
@@ -607,8 +553,7 @@ const IndeterminateIcon = ({ className }) => (jsxRuntime.jsx("svg", { className:
|
|
|
607
553
|
* @param {CheckboxProps} props - The props for the Checkbox component
|
|
608
554
|
* @returns {JSX.Element} Checkbox component
|
|
609
555
|
*/
|
|
610
|
-
const Checkbox = React__namespace.forwardRef((
|
|
611
|
-
var { className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0, onLabelRefChange, stopPropagation } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "checked", "disabled", "isInvalid", "readOnly", "indeterminate", "suffix", "label", "tabIndex", "onLabelRefChange", "stopPropagation"]);
|
|
556
|
+
const Checkbox = React__namespace.forwardRef(({ className, dataTestId = "checkbox", onChange, checked = false, disabled = false, isInvalid = false, readOnly, indeterminate = false, suffix, label, tabIndex = 0, onLabelRefChange, stopPropagation, ...rest }, ref) => {
|
|
612
557
|
const icon = indeterminate ? (jsxRuntime.jsx(IndeterminateIcon, { className: cvaCheckboxIcon() })) : (checked && jsxRuntime.jsx(CheckIcon, { className: cvaCheckboxIcon() }));
|
|
613
558
|
const internalRef = React__namespace.useRef(null);
|
|
614
559
|
const isReadonly = disabled || readOnly;
|
|
@@ -627,7 +572,7 @@ const Checkbox = React__namespace.forwardRef((_a, ref) => {
|
|
|
627
572
|
onLabelRefChange && labelRef && onLabelRefChange(labelRef);
|
|
628
573
|
}, [labelRef, onLabelRefChange]);
|
|
629
574
|
const uuid = rest.id;
|
|
630
|
-
return (jsxRuntime.jsxs("label", { className: cvaCheckboxContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-container` : null, htmlFor: uuid, onClick: e => stopPropagation && e.stopPropagation(), onKeyDown: onKeyPress, ref: internalRef, children: [jsxRuntime.jsx("input",
|
|
575
|
+
return (jsxRuntime.jsxs("label", { className: cvaCheckboxContainer({ className }), "data-testid": dataTestId ? `${dataTestId}-container` : null, htmlFor: uuid, onClick: e => stopPropagation && e.stopPropagation(), onKeyDown: onKeyPress, ref: internalRef, children: [jsxRuntime.jsx("input", { "aria-checked": !indeterminate && checked, checked: !indeterminate && checked, className: cvaCheckboxInput(), "data-testid": dataTestId, disabled: disabled, id: uuid, onChange: onChange, readOnly: readOnly, type: "checkbox", ...rest, ref: ref }), jsxRuntime.jsx("span", { className: cvaCheckbox({
|
|
631
576
|
disabled: isReadonly,
|
|
632
577
|
invalid: isReadonly ? false : isInvalid,
|
|
633
578
|
state: indeterminate ? "indeterminate" : checked ? "selected" : "deselected",
|
|
@@ -679,10 +624,9 @@ const FormGroup = ({ isInvalid, helpText, helpAddon, tip, className, dataTestId,
|
|
|
679
624
|
*
|
|
680
625
|
* _**Do use**_ the CheckboxField for boolean input.
|
|
681
626
|
*/
|
|
682
|
-
const CheckboxField = React.forwardRef((
|
|
683
|
-
var { label, id, tip, helpText, helpAddon, isInvalid, className, checked, dataTestId, checkboxLabel, onChange } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "helpAddon", "isInvalid", "className", "checked", "dataTestId", "checkboxLabel", "onChange"]);
|
|
627
|
+
const CheckboxField = React.forwardRef(({ label, id, tip, helpText, helpAddon, isInvalid, className, checked, dataTestId, checkboxLabel, onChange, ...rest }, ref) => {
|
|
684
628
|
const htmlForId = id ? id : "checkboxField-" + uuid.v4();
|
|
685
|
-
return (jsxRuntime.jsx(FormGroup, { className: "flex flex-col gap-1", dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: helpText, htmlFor: htmlForId, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(Checkbox,
|
|
629
|
+
return (jsxRuntime.jsx(FormGroup, { className: "flex flex-col gap-1", dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: helpText, htmlFor: htmlForId, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(Checkbox, { checked: checked, className: className, dataTestId: dataTestId, id: htmlForId, label: checkboxLabel, onChange: onChange, ref: ref, ...rest }) }));
|
|
686
630
|
});
|
|
687
631
|
CheckboxField.displayName = "CheckboxField";
|
|
688
632
|
|
|
@@ -701,12 +645,11 @@ const isValidHEXColor = (value) => {
|
|
|
701
645
|
* ColorField validates that user enters a valid color address.
|
|
702
646
|
*
|
|
703
647
|
*/
|
|
704
|
-
const ColorField = React.forwardRef((
|
|
705
|
-
var { label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value: propValue, onChange, isInvalid = false } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "className", "defaultValue", "dataTestId", "value", "onChange", "isInvalid"]);
|
|
648
|
+
const ColorField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value: propValue, onChange, isInvalid = false, ...rest }, ref) => {
|
|
706
649
|
const htmlForId = id ? id : "colorField-" + uuid.v4();
|
|
707
|
-
const innerRef =
|
|
650
|
+
const innerRef = React.useRef(null);
|
|
708
651
|
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
709
|
-
|
|
652
|
+
React.useImperativeHandle(ref, () => innerRef.current, []);
|
|
710
653
|
// Internal state for color value
|
|
711
654
|
const [value, setValue] = React.useState(propValue || defaultValue || "");
|
|
712
655
|
const handleChange = React.useCallback((event) => {
|
|
@@ -734,12 +677,11 @@ ColorField.displayName = "ColorField";
|
|
|
734
677
|
*
|
|
735
678
|
* NOTE: If shown with a label, please use the `DateField` component instead.
|
|
736
679
|
*/
|
|
737
|
-
const DateInput = React.forwardRef((
|
|
738
|
-
var { min, max, defaultValue, value } = _a, rest = __rest(_a, ["min", "max", "defaultValue", "value"]);
|
|
680
|
+
const DateInput = React.forwardRef(({ min, max, defaultValue, value, ...rest }, ref) => {
|
|
739
681
|
const formatDateToInputString = (date) => date instanceof Date ? dateFns.format(date, "yyyy-MM-dd") : date;
|
|
740
682
|
// Chrome and Firefox need their default icon to have datepicker functionality.
|
|
741
683
|
const showIcon = !/Chrome/.test(navigator.userAgent) && !/Firefox/.test(navigator.userAgent);
|
|
742
|
-
return (jsxRuntime.jsx(BaseInput,
|
|
684
|
+
return (jsxRuntime.jsx(BaseInput, { defaultValue: formatDateToInputString(defaultValue), max: formatDateToInputString(max), min: formatDateToInputString(min), ref: ref, suffix: showIcon ? jsxRuntime.jsx(reactComponents.Icon, { dataTestId: "calendar", name: "Calendar", size: "medium", type: "solid" }) : null, type: "date", value: formatDateToInputString(value), ...rest }));
|
|
743
685
|
});
|
|
744
686
|
DateInput.displayName = "DateInput";
|
|
745
687
|
|
|
@@ -750,11 +692,10 @@ DateInput.displayName = "DateInput";
|
|
|
750
692
|
*
|
|
751
693
|
* _**Do not use**_ this fields for non-serialized dates. Use TextField instead.
|
|
752
694
|
*/
|
|
753
|
-
const DateField = React.forwardRef((
|
|
754
|
-
var { label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "className", "defaultValue", "dataTestId"]);
|
|
695
|
+
const DateField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, className, defaultValue, dataTestId, ...rest }, ref) => {
|
|
755
696
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
756
697
|
const htmlForId = id ? id : "dateField-" + uuid.v4();
|
|
757
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(DateInput,
|
|
698
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(DateInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
758
699
|
});
|
|
759
700
|
DateField.displayName = "DateField";
|
|
760
701
|
|
|
@@ -816,8 +757,7 @@ const DropZoneDefaultLabel = () => (jsxRuntime.jsx(Trans, { components: {
|
|
|
816
757
|
* @param {DropZoneProps} props - The props for the DropZone component
|
|
817
758
|
* @returns {JSX.Element} DropZone component
|
|
818
759
|
*/
|
|
819
|
-
const DropZone = (
|
|
820
|
-
var { className, dataTestId, filesSelected, label = jsxRuntime.jsx(DropZoneDefaultLabel, {}), size = "large", isInvalid = false, disabled = false, accept } = _a, rest = __rest(_a, ["className", "dataTestId", "filesSelected", "label", "size", "isInvalid", "disabled", "accept"]);
|
|
760
|
+
const DropZone = ({ className, dataTestId, filesSelected, label = jsxRuntime.jsx(DropZoneDefaultLabel, {}), size = "large", isInvalid = false, disabled = false, accept, ...rest }) => {
|
|
821
761
|
const [dragActive, setDragActive] = React.useState(false);
|
|
822
762
|
const [fileDropped, setFileDropped] = React.useState(false);
|
|
823
763
|
const [t] = useTranslation();
|
|
@@ -861,12 +801,12 @@ const DropZone = (_a) => {
|
|
|
861
801
|
}
|
|
862
802
|
(_a = inputLabelRef.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
863
803
|
};
|
|
864
|
-
return (jsxRuntime.jsxs("div",
|
|
804
|
+
return (jsxRuntime.jsxs("div", { className: cvaDropZone({ size, dropComplete: fileDropped, dragActive, disabled, invalid: isInvalid, className }), "data-testid": dataTestId, onClick: e => {
|
|
865
805
|
if (disabled) {
|
|
866
806
|
e.preventDefault();
|
|
867
807
|
e.stopPropagation();
|
|
868
808
|
}
|
|
869
|
-
}, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop
|
|
809
|
+
}, onDragEnter: handleDrag, onDragLeave: handleDrag, onDragOver: handleDrag, onDrop: handleDrop, ...rest, children: [jsxRuntime.jsx("input", { accept: accept, className: "hidden", id: "input-file-upload", onChange: handleChange, title: t("dropzone.input.title"), type: "file" }), jsxRuntime.jsxs("label", { className: cvaDropZoneLabel(), "data-testid": dataTestId ? `${dataTestId}-label` : null, htmlFor: "input-file-upload", ref: inputLabelRef, children: [jsxRuntime.jsx("div", { className: cvaDropZoneIconBackground({ invalid: isInvalid }), children: jsxRuntime.jsx(reactComponents.Icon, { className: !isInvalid ? "text-gray-400" : "", color: isInvalid ? "danger" : "neutral", name: "ArrowUpCircle", type: "solid" }) }), jsxRuntime.jsx("button", { disabled: disabled, onClick: handleButtonClick, children: label })] })] }));
|
|
870
810
|
};
|
|
871
811
|
|
|
872
812
|
// Doing the same check as we do on the backend
|
|
@@ -895,8 +835,7 @@ const validateEmailAddress = (email) => {
|
|
|
895
835
|
* A reference to the input element is provided as the `ref` prop.
|
|
896
836
|
* For specific input types make sure to use the corresponding input component.
|
|
897
837
|
*/
|
|
898
|
-
const EmailInput = React__namespace.forwardRef((
|
|
899
|
-
var { fieldSize = "medium", disabled = false, dataTestId, isInvalid = false, onChange, disableAction = false } = _a, rest = __rest(_a, ["fieldSize", "disabled", "dataTestId", "isInvalid", "onChange", "disableAction"]);
|
|
838
|
+
const EmailInput = React__namespace.forwardRef(({ fieldSize = "medium", disabled = false, dataTestId, isInvalid = false, onChange, disableAction = false, ...rest }, ref) => {
|
|
900
839
|
const [email, setEmail] = React__namespace.useState("");
|
|
901
840
|
const sendEmail = () => {
|
|
902
841
|
return window.open(`mailto:${email}`);
|
|
@@ -907,7 +846,7 @@ const EmailInput = React__namespace.forwardRef((_a, ref) => {
|
|
|
907
846
|
setEmail(newValue);
|
|
908
847
|
}, [onChange]);
|
|
909
848
|
const renderAsInvalid = (email && !validateEmailAddress(email)) || isInvalid;
|
|
910
|
-
return (jsxRuntime.jsx(BaseInput,
|
|
849
|
+
return (jsxRuntime.jsx(BaseInput, { actions: email && email.length > 0 ? (jsxRuntime.jsx(ActionButton, { dataTestId: dataTestId ? `${dataTestId}-emailIcon` : undefined, disabled: disableAction || isInvalid, iconSize: fieldSize, onClick: sendEmail, type: "EMAIL", value: email })) : null, dataTestId: dataTestId, disabled: disabled, isInvalid: renderAsInvalid, onChange: handleChange, placeholder: rest.placeholder || "mail@example.com", ref: ref, type: "email", ...rest }));
|
|
911
850
|
});
|
|
912
851
|
EmailInput.displayName = "EmailInput";
|
|
913
852
|
|
|
@@ -916,8 +855,7 @@ EmailInput.displayName = "EmailInput";
|
|
|
916
855
|
* EmailField validates that user enters a valid email address.
|
|
917
856
|
*
|
|
918
857
|
*/
|
|
919
|
-
const EmailField = React.forwardRef((
|
|
920
|
-
var { label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value, disabled, onChange, isInvalid = false } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "className", "defaultValue", "dataTestId", "value", "disabled", "onChange", "isInvalid"]);
|
|
858
|
+
const EmailField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, value, disabled, onChange, isInvalid = false, ...rest }, ref) => {
|
|
921
859
|
const htmlForId = id ? id : "emailField-" + uuid.v4();
|
|
922
860
|
// Type guard to check if value is a string
|
|
923
861
|
function isString(inputValue) {
|
|
@@ -929,7 +867,7 @@ const EmailField = React.forwardRef((_a, ref) => {
|
|
|
929
867
|
onChange(event);
|
|
930
868
|
}
|
|
931
869
|
}, [onChange]);
|
|
932
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(EmailInput,
|
|
870
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(EmailInput, { "aria-labelledby": htmlForId + "-label", defaultValue: defaultValue, disabled: disabled, id: htmlForId, isInvalid: renderAsInvalid, onChange: handleChange, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
933
871
|
});
|
|
934
872
|
EmailField.displayName = "EmailField";
|
|
935
873
|
|
|
@@ -939,7 +877,7 @@ EmailField.displayName = "EmailField";
|
|
|
939
877
|
* NOTE: If shown with a label, please use the `NumberField` component instead.
|
|
940
878
|
*/
|
|
941
879
|
const NumberInput = React.forwardRef((props, ref) => {
|
|
942
|
-
return jsxRuntime.jsx(BaseInput,
|
|
880
|
+
return jsxRuntime.jsx(BaseInput, { ref: ref, type: "number", ...props, value: props.value });
|
|
943
881
|
});
|
|
944
882
|
NumberInput.displayName = "NumberInput";
|
|
945
883
|
|
|
@@ -950,11 +888,10 @@ NumberInput.displayName = "NumberInput";
|
|
|
950
888
|
*
|
|
951
889
|
* _**Do not use**_ this fields for non-serialized numbers. Use TextField instead.
|
|
952
890
|
*/
|
|
953
|
-
const NumberField = React.forwardRef((
|
|
954
|
-
var { label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "isInvalid", "maxLength", "className", "value", "dataTestId"]);
|
|
891
|
+
const NumberField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, isInvalid, maxLength, className, value, dataTestId, ...rest }, ref) => {
|
|
955
892
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
956
893
|
const htmlForId = id ? id : "numberField-" + uuid.v4();
|
|
957
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(NumberInput,
|
|
894
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(NumberInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
958
895
|
});
|
|
959
896
|
NumberField.displayName = "NumberField";
|
|
960
897
|
|
|
@@ -987,10 +924,9 @@ const cvaOptionCardContainer = cssClassVarianceUtilities.cvaMerge(["contents"]);
|
|
|
987
924
|
/**
|
|
988
925
|
* A card version of a radio button that includes an icon, headings and a description.
|
|
989
926
|
*/
|
|
990
|
-
const OptionCard = React.forwardRef((
|
|
991
|
-
var { icon, heading, subheading, description, disabled, id, value, className, contentClassName, dataTestId, customImage } = _a, rest = __rest(_a, ["icon", "heading", "subheading", "description", "disabled", "id", "value", "className", "contentClassName", "dataTestId", "customImage"]);
|
|
927
|
+
const OptionCard = React.forwardRef(({ icon, heading, subheading, description, disabled, id, value, className, contentClassName, dataTestId, customImage, ...rest }, ref) => {
|
|
992
928
|
const htmlForId = id !== null && id !== void 0 ? id : "option-card-" + uuid.v4();
|
|
993
|
-
return (jsxRuntime.jsxs("div", { className: cvaOptionCardContainer(), "data-testid": dataTestId, children: [jsxRuntime.jsx("input",
|
|
929
|
+
return (jsxRuntime.jsxs("div", { className: cvaOptionCardContainer(), "data-testid": dataTestId, children: [jsxRuntime.jsx("input", { className: "peer absolute h-0 w-0 opacity-0", "data-testid": `${dataTestId}-option-card`, id: htmlForId, ref: ref, type: "radio", value: value, ...rest }), jsxRuntime.jsxs("label", { className: cvaOptionCardLabel({ className, disabled }), "data-testid": `${dataTestId}-option-card-label`, htmlFor: htmlForId, children: [disabled && icon && !customImage
|
|
994
930
|
? React.cloneElement(icon, { className: `${icon.props.className} text-secondary-400` })
|
|
995
931
|
: null, disabled && customImage ? jsxRuntime.jsx("img", { alt: "logo", className: customImage.className, src: customImage.src }) : null, !disabled && !customImage && icon, !disabled && customImage ? jsxRuntime.jsx("img", { alt: "logo", className: customImage.className, src: customImage.src }) : null, heading ? (jsxRuntime.jsx(reactComponents.Heading, { subtle: disabled, variant: "secondary", children: heading })) : null, subheading || description ? (jsxRuntime.jsxs("div", { className: cvaOptionCardContent({ className: contentClassName }), children: [subheading ? (jsxRuntime.jsx(reactComponents.Text, { align: "center", subtle: disabled, type: "span", weight: "thick", children: subheading })) : null, description ? (jsxRuntime.jsx(reactComponents.Text, { align: "center", subtle: true, type: "span", children: description })) : null] })) : null] })] }));
|
|
996
932
|
});
|
|
@@ -1003,7 +939,7 @@ OptionCard.displayName = "OptionCard";
|
|
|
1003
939
|
*/
|
|
1004
940
|
const PasswordInput = React.forwardRef((props, ref) => {
|
|
1005
941
|
const [showPassword, setShowPassword] = React.useState(false);
|
|
1006
|
-
return (jsxRuntime.jsx(BaseInput,
|
|
942
|
+
return (jsxRuntime.jsx(BaseInput, { ref: ref, ...props, actions: jsxRuntime.jsx("div", { className: cvaActionContainer(), children: jsxRuntime.jsx(reactComponents.IconButton, { className: cvaActionButton({ size: props.fieldSize }), icon: jsxRuntime.jsx(reactComponents.Icon, { name: showPassword ? "EyeSlash" : "Eye", size: "small" }), onClick: () => setShowPassword(prevState => !prevState), size: "small", variant: "secondary" }) }), type: showPassword ? "text" : "password" }));
|
|
1007
943
|
});
|
|
1008
944
|
PasswordInput.displayName = "PasswordInput";
|
|
1009
945
|
|
|
@@ -1014,14 +950,13 @@ PasswordInput.displayName = "PasswordInput";
|
|
|
1014
950
|
*
|
|
1015
951
|
* _**Do not use** to confirm user actions, such as deleting. Use a checkbox for such flows._
|
|
1016
952
|
*/
|
|
1017
|
-
const PasswordField = React.forwardRef((
|
|
1018
|
-
var { id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId } = _a, rest = __rest(_a, ["id", "label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
|
|
953
|
+
const PasswordField = React.forwardRef(({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, ...rest }, ref) => {
|
|
1019
954
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
1020
955
|
const htmlFor = id ? id : "passwordField-" + uuid.v4();
|
|
1021
956
|
const handleChange = React.useCallback((event) => {
|
|
1022
957
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
1023
958
|
}, [onChange]);
|
|
1024
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(PasswordInput,
|
|
959
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(PasswordInput, { ...rest, "aria-labelledby": htmlFor + "-label", className: className, dataTestId: dataTestId, disabled: rest.readOnly, id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, onChange: handleChange, ref: ref, value: value }) }));
|
|
1025
960
|
});
|
|
1026
961
|
PasswordField.displayName = "PasswordField";
|
|
1027
962
|
|
|
@@ -1089,8 +1024,7 @@ const DEFAULT_COUNTRY_CODE = undefined;
|
|
|
1089
1024
|
* @param {boolean} [disableAction=false] - Whether the action button is disabled or not.
|
|
1090
1025
|
* @returns {JSX.Element} - The PhoneInput component.
|
|
1091
1026
|
*/
|
|
1092
|
-
const PhoneInput = React.forwardRef((
|
|
1093
|
-
var { dataTestId, isInvalid, disabled = false, value, defaultValue, fieldSize = "medium", disableAction = false, onChange, readOnly, onFocus, onBlur, name } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "value", "defaultValue", "fieldSize", "disableAction", "onChange", "readOnly", "onFocus", "onBlur", "name"]);
|
|
1027
|
+
const PhoneInput = React.forwardRef(({ dataTestId, isInvalid, disabled = false, value, defaultValue, fieldSize = "medium", disableAction = false, onChange, readOnly, onFocus, onBlur, name, ...rest }, ref) => {
|
|
1094
1028
|
const [innerValue, setInnerValue] = React.useState(() => {
|
|
1095
1029
|
var _a;
|
|
1096
1030
|
return (_a = ((value === null || value === void 0 ? void 0 : value.toString()) || (defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.toString()))) !== null && _a !== void 0 ? _a : "";
|
|
@@ -1134,7 +1068,7 @@ const PhoneInput = React.forwardRef((_a, ref) => {
|
|
|
1134
1068
|
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
1135
1069
|
fieldIsFocused.current = true;
|
|
1136
1070
|
}, [onFocus]);
|
|
1137
|
-
return (jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-2", "data-testid": dataTestId ? `${dataTestId}-container` : null, children: jsxRuntime.jsx(BaseInput,
|
|
1071
|
+
return (jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-2", "data-testid": dataTestId ? `${dataTestId}-container` : null, children: jsxRuntime.jsx(BaseInput, { actions: !disableAction && innerValue && innerValue.length > 0 ? (jsxRuntime.jsx(ActionButton, { dataTestId: dataTestId ? `${dataTestId}-phoneIcon` : undefined, disabled: isInvalid, iconSize: fieldSize, type: "PHONE_NUMBER", value: (value === null || value === void 0 ? void 0 : value.toString()) || "" })) : null, dataTestId: dataTestId ? `${dataTestId}-phoneNumberInput` : undefined, disabled: disabled, fieldSize: fieldSize, id: "phoneInput-number", isInvalid: isInvalid, name: name, onBlur: handleBlur, onChange: handleChange, onFocus: handleFocus, prefix: (countryCode && countryCodeToFlagEmoji(countryCode)) || undefined, readOnly: readOnly, ref: ref, type: "tel", value: innerValue, ...rest }) }));
|
|
1138
1072
|
});
|
|
1139
1073
|
PhoneInput.displayName = "PhoneInput";
|
|
1140
1074
|
|
|
@@ -1154,11 +1088,10 @@ PhoneInput.displayName = "PhoneInput";
|
|
|
1154
1088
|
* @param {boolean} [disableAction=false] - Whether the action button is disabled or not.
|
|
1155
1089
|
* @returns {JSX.Element} - The PhoneField component.
|
|
1156
1090
|
*/
|
|
1157
|
-
const PhoneField = React.forwardRef((
|
|
1158
|
-
var { label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, dataTestId, name, onChange, onBlur } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "isInvalid", "errorMessage", "value", "helpAddon", "className", "defaultValue", "dataTestId", "name", "onChange", "onBlur"]);
|
|
1091
|
+
const PhoneField = React.forwardRef(({ label, id, tip, helpText, isInvalid, errorMessage, value, helpAddon, className, defaultValue, dataTestId, name, onChange, onBlur, ...rest }, ref) => {
|
|
1159
1092
|
const htmlForId = id ? id : "phoneField-" + uuid.v4();
|
|
1160
1093
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
1161
|
-
return (jsxRuntime.jsx(FormGroup, { className: className, dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(PhoneInput,
|
|
1094
|
+
return (jsxRuntime.jsx(FormGroup, { className: className, dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(PhoneInput, { "aria-labelledby": htmlForId + "-label", dataTestId: dataTestId, defaultValue: defaultValue, id: htmlForId, isInvalid: renderAsInvalid, name: name, onBlur: onBlur, onChange: onChange, ref: ref, value: value, ...rest }) }));
|
|
1162
1095
|
});
|
|
1163
1096
|
PhoneField.displayName = "PhoneField";
|
|
1164
1097
|
|
|
@@ -1167,9 +1100,8 @@ PhoneField.displayName = "PhoneField";
|
|
|
1167
1100
|
*
|
|
1168
1101
|
* @returns {JSX.Element} - The PhoneFieldWithController component.
|
|
1169
1102
|
*/
|
|
1170
|
-
const PhoneFieldWithController = React.forwardRef((
|
|
1171
|
-
|
|
1172
|
-
return (jsxRuntime.jsx(reactHookForm.Controller, Object.assign({ control: control, defaultValue: value, name: name }, controllerProps, { render: ({ field }) => jsxRuntime.jsx(PhoneField, Object.assign({}, rest, field, { ref: ref })) })));
|
|
1103
|
+
const PhoneFieldWithController = React.forwardRef(({ control, controllerProps, name, value, ...rest }, ref) => {
|
|
1104
|
+
return (jsxRuntime.jsx(reactHookForm.Controller, { control: control, defaultValue: value, name: name, ...controllerProps, render: ({ field }) => jsxRuntime.jsx(PhoneField, { ...rest, ...field, ref: ref }) }));
|
|
1173
1105
|
});
|
|
1174
1106
|
PhoneFieldWithController.displayName = "PhoneFieldWithController";
|
|
1175
1107
|
|
|
@@ -1185,7 +1117,7 @@ const validatePhoneNumber = (phoneNumber) => {
|
|
|
1185
1117
|
const countryCode = asYouType.getCallingCode();
|
|
1186
1118
|
const national = asYouType.getNationalNumber();
|
|
1187
1119
|
const safePhoneNumber = getPhoneNumberWithPlus(phoneNumber.trim());
|
|
1188
|
-
const number =
|
|
1120
|
+
const number = parsePhoneNumberFromString(safePhoneNumber);
|
|
1189
1121
|
if (phoneNumber && parsePhoneNumberFromString.isValidPhoneNumber(phoneNumber)) {
|
|
1190
1122
|
return undefined;
|
|
1191
1123
|
}
|
|
@@ -1343,15 +1275,15 @@ const cvaTimeRange = cssClassVarianceUtilities.cvaMerge(["flex", "flex-1", "item
|
|
|
1343
1275
|
* @returns {JSX.Element} TimeRange component
|
|
1344
1276
|
*/
|
|
1345
1277
|
const TimeRange = ({ id, className, dataTestId, children, range, onChange, disabled, isInvalid, }) => {
|
|
1346
|
-
const [timeRange, setTimeRange] =
|
|
1278
|
+
const [timeRange, setTimeRange] = React.useState(range !== null && range !== void 0 ? range : {
|
|
1347
1279
|
timeFrom: "",
|
|
1348
1280
|
timeTo: "",
|
|
1349
1281
|
});
|
|
1350
1282
|
const onChangeFrom = (timeFrom) => {
|
|
1351
|
-
setTimeRange(prev => (
|
|
1283
|
+
setTimeRange(prev => ({ ...prev, timeFrom }));
|
|
1352
1284
|
};
|
|
1353
1285
|
const onChangeTo = (timeTo) => {
|
|
1354
|
-
setTimeRange(prev => (
|
|
1286
|
+
setTimeRange(prev => ({ ...prev, timeTo }));
|
|
1355
1287
|
};
|
|
1356
1288
|
const onRangeChange = () => onChange(timeRange);
|
|
1357
1289
|
return (jsxRuntime.jsxs("div", { className: cvaTimeRange({ className }), "data-testid": dataTestId, id: id, children: [jsxRuntime.jsx(BaseInput, { dataTestId: `${dataTestId}-from`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeFrom(time.currentTarget.value), type: "time", value: timeRange.timeFrom }), children !== null && children !== void 0 ? children : jsxRuntime.jsx("div", { "data-testid": `${dataTestId}-separator`, children: "-" }), jsxRuntime.jsx(BaseInput, { dataTestId: `${dataTestId}-to`, disabled: disabled, isInvalid: isInvalid, onBlur: onRangeChange, onChange: (time) => onChangeTo(time.currentTarget.value), type: "time", value: timeRange.timeTo })] }));
|
|
@@ -1368,16 +1300,21 @@ const cvaScheduleItemText = cssClassVarianceUtilities.cvaMerge(["flex", "font-bo
|
|
|
1368
1300
|
*/
|
|
1369
1301
|
const Schedule = ({ className, dataTestId, schedule, onChange, invalidKeys = [] }) => {
|
|
1370
1302
|
const onRangeChange = (range, index) => {
|
|
1371
|
-
const newSchedule = schedule.map((day, dayIndex) => (index === dayIndex ?
|
|
1303
|
+
const newSchedule = schedule.map((day, dayIndex) => (index === dayIndex ? { ...day, range: { ...range } } : day));
|
|
1372
1304
|
onChange(newSchedule);
|
|
1373
1305
|
};
|
|
1374
1306
|
const onActiveChange = (isActive, index) => {
|
|
1375
|
-
const newSchedule = schedule.map((day, dayIndex) => index === dayIndex ?
|
|
1307
|
+
const newSchedule = schedule.map((day, dayIndex) => index === dayIndex ? { ...day, range: { timeFrom: "", timeTo: "" }, isActive } : day);
|
|
1376
1308
|
onChange(newSchedule);
|
|
1377
1309
|
};
|
|
1378
1310
|
const onAllDayChange = (isAllDayChecked, index) => {
|
|
1379
1311
|
const newSchedule = schedule.map((day, dayIndex) => index === dayIndex
|
|
1380
|
-
?
|
|
1312
|
+
? {
|
|
1313
|
+
...day,
|
|
1314
|
+
range: { timeFrom: "", timeTo: "" },
|
|
1315
|
+
isAllDayActive: isAllDayChecked,
|
|
1316
|
+
}
|
|
1317
|
+
: day);
|
|
1381
1318
|
onChange(newSchedule);
|
|
1382
1319
|
};
|
|
1383
1320
|
return (jsxRuntime.jsx("div", { className: className, "data-testid": dataTestId, children: schedule.map(({ label, range, isActive, key, checkboxLabel, isAllDayActive }, index) => {
|
|
@@ -1507,7 +1444,7 @@ const hasConsecutiveDays = (schedule) => {
|
|
|
1507
1444
|
*
|
|
1508
1445
|
* NOTE: If shown with a label, please use the `TextField` component instead.
|
|
1509
1446
|
*/
|
|
1510
|
-
const TextInput = React.forwardRef((props, ref) => (jsxRuntime.jsx(BaseInput,
|
|
1447
|
+
const TextInput = React.forwardRef((props, ref) => (jsxRuntime.jsx(BaseInput, { ref: ref, type: "text", ...props })));
|
|
1511
1448
|
TextInput.displayName = "TextInput";
|
|
1512
1449
|
|
|
1513
1450
|
const cvaSearch = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -1534,11 +1471,10 @@ const cvaSearch = cssClassVarianceUtilities.cvaMerge([
|
|
|
1534
1471
|
* @param {SearchProps} props - The props for the Search component
|
|
1535
1472
|
* @returns {JSX.Element} Search component
|
|
1536
1473
|
*/
|
|
1537
|
-
const Search = React.forwardRef((
|
|
1538
|
-
|
|
1539
|
-
return (jsxRuntime.jsx(TextInput, Object.assign({}, rest, { autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), dataTestId: dataTestId, disabled: disabled, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "MagnifyingGlass", size: "medium" }), ref: ref, suffix: onClear ? (jsxRuntime.jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
|
|
1474
|
+
const Search = React.forwardRef(({ className, placeholder = "Search", value, widenInputOnFocus, hideBorderWhenNotInFocus = false, disabled, onKeyUp, onChange, onFocus, onBlur, name, onClear, dataTestId, autoComplete = "on", ...rest }, ref) => {
|
|
1475
|
+
return (jsxRuntime.jsx(TextInput, { ...rest, autoComplete: autoComplete, className: cvaSearch({ className, border: hideBorderWhenNotInFocus, widenOnFocus: widenInputOnFocus }), dataTestId: dataTestId, disabled: disabled, name: name, onBlur: onBlur, onChange: onChange, onFocus: onFocus, onKeyUp: onKeyUp, placeholder: placeholder, prefix: jsxRuntime.jsx(reactComponents.Icon, { name: "MagnifyingGlass", size: "medium" }), ref: ref, suffix: onClear ? (jsxRuntime.jsx("button", { className: "flex", "data-testid": dataTestId ? `${dataTestId}_suffix_component` : null, onClick: () => {
|
|
1540
1476
|
onClear();
|
|
1541
|
-
}, type: "button", children: jsxRuntime.jsx(reactComponents.Icon, { name: "XMark", size: "small" }) })) : undefined, value: value }))
|
|
1477
|
+
}, type: "button", children: jsxRuntime.jsx(reactComponents.Icon, { name: "XMark", size: "small" }) })) : undefined, value: value }));
|
|
1542
1478
|
});
|
|
1543
1479
|
Search.displayName = "Search";
|
|
1544
1480
|
|
|
@@ -1656,7 +1592,7 @@ const isSelectedOption = (option, selected) => {
|
|
|
1656
1592
|
};
|
|
1657
1593
|
const removeSelectedFromGroups = (group, selected) => {
|
|
1658
1594
|
if (isGroupBase(group)) {
|
|
1659
|
-
return
|
|
1595
|
+
return { ...group, options: group.options.filter(option => !isSelectedOption(option, selected)) };
|
|
1660
1596
|
}
|
|
1661
1597
|
return group;
|
|
1662
1598
|
};
|
|
@@ -1713,14 +1649,13 @@ const MultiSelectMenuItem = ({ label, onClick, selected, dataTestId, focused, di
|
|
|
1713
1649
|
* @param {TagProps} props - The props for the tag component
|
|
1714
1650
|
* @returns {JSX.Element} TagWithWidth component
|
|
1715
1651
|
*/
|
|
1716
|
-
const TagWithWidth = (
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
React__default["default"].useLayoutEffect(() => {
|
|
1652
|
+
const TagWithWidth = ({ onWidthKnown, children, ...rest }) => {
|
|
1653
|
+
const ref = React.useRef(null);
|
|
1654
|
+
React.useLayoutEffect(() => {
|
|
1720
1655
|
var _a;
|
|
1721
1656
|
onWidthKnown && onWidthKnown({ width: ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0 });
|
|
1722
1657
|
}, [ref, onWidthKnown]);
|
|
1723
|
-
return (jsxRuntime.jsx(reactComponents.Tag,
|
|
1658
|
+
return (jsxRuntime.jsx(reactComponents.Tag, { ref: ref, ...rest, children: children }));
|
|
1724
1659
|
};
|
|
1725
1660
|
|
|
1726
1661
|
/**
|
|
@@ -1730,13 +1665,13 @@ const TagWithWidth = (_a) => {
|
|
|
1730
1665
|
* @returns {JSX.Element} TagsContainer
|
|
1731
1666
|
*/
|
|
1732
1667
|
const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled }) => {
|
|
1733
|
-
const [isReady, setIsReady] =
|
|
1734
|
-
const [counterWidth, setCounterWidth] =
|
|
1735
|
-
const containerRef =
|
|
1736
|
-
const availableWidth =
|
|
1737
|
-
const childrenWidth =
|
|
1668
|
+
const [isReady, setIsReady] = React.useState(false);
|
|
1669
|
+
const [counterWidth, setCounterWidth] = React.useState(0);
|
|
1670
|
+
const containerRef = React.useRef(null);
|
|
1671
|
+
const availableWidth = React.useRef();
|
|
1672
|
+
const childrenWidth = React.useRef([]);
|
|
1738
1673
|
const itemsCount = items.length;
|
|
1739
|
-
|
|
1674
|
+
React.useLayoutEffect(() => {
|
|
1740
1675
|
var _a;
|
|
1741
1676
|
availableWidth.current = ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
|
|
1742
1677
|
}, [containerRef]);
|
|
@@ -1805,7 +1740,8 @@ const useCustomComponents = ({ componentsProps, disabled, readOnly, refMenuIsEna
|
|
|
1805
1740
|
const [t] = useTranslation();
|
|
1806
1741
|
// perhaps it should not be wrap in memo (causing some issues with opening and closing on mobiles)
|
|
1807
1742
|
const customComponents = React__namespace.useMemo(() => {
|
|
1808
|
-
return
|
|
1743
|
+
return {
|
|
1744
|
+
ValueContainer: props => {
|
|
1809
1745
|
var _a;
|
|
1810
1746
|
if (props.isMulti && Array.isArray(props.children) && props.children.length > 0) {
|
|
1811
1747
|
const PLACEHOLDER_KEY = "placeholder";
|
|
@@ -1816,7 +1752,7 @@ const useCustomComponents = ({ componentsProps, disabled, readOnly, refMenuIsEna
|
|
|
1816
1752
|
const tags = key === PLACEHOLDER_KEY ? [] : values;
|
|
1817
1753
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
1818
1754
|
const searchInput = props && props.children && props.children[1];
|
|
1819
|
-
return (jsxRuntime.jsx(ReactSelect.components.ValueContainer,
|
|
1755
|
+
return (jsxRuntime.jsx(ReactSelect.components.ValueContainer, { ...props, isDisabled: props.selectProps.isDisabled, children: maxSelectedDisplayCount === undefined ? (jsxRuntime.jsx(TagsContainer, { disabled: disabled, items: tags
|
|
1820
1756
|
? tags.map(({ props: tagProps }) => {
|
|
1821
1757
|
return {
|
|
1822
1758
|
text: tagProps.children,
|
|
@@ -1838,47 +1774,66 @@ const useCustomComponents = ({ componentsProps, disabled, readOnly, refMenuIsEna
|
|
|
1838
1774
|
tagProps.removeProps.onClick && tagProps.removeProps.onClick(e);
|
|
1839
1775
|
}, children: tagProps.children }, (_a = tagProps.children) === null || _a === void 0 ? void 0 : _a.toString()));
|
|
1840
1776
|
})
|
|
1841
|
-
: null, tags && tags.length > maxSelectedDisplayCount ? (jsxRuntime.jsxs(reactComponents.Tag, { color: "neutral", dataTestId: "counter-tag", children: ["+", tags.length - maxSelectedDisplayCount] })) : null, searchInput] })) }))
|
|
1777
|
+
: null, tags && tags.length > maxSelectedDisplayCount ? (jsxRuntime.jsxs(reactComponents.Tag, { color: "neutral", dataTestId: "counter-tag", children: ["+", tags.length - maxSelectedDisplayCount] })) : null, searchInput] })) }));
|
|
1842
1778
|
}
|
|
1843
|
-
return (jsxRuntime.jsx(ReactSelect.components.ValueContainer,
|
|
1844
|
-
},
|
|
1779
|
+
return (jsxRuntime.jsx(ReactSelect.components.ValueContainer, { ...props, isDisabled: props.selectProps.isDisabled, children: props.children }));
|
|
1780
|
+
},
|
|
1781
|
+
LoadingIndicator: () => {
|
|
1845
1782
|
return jsxRuntime.jsx(reactComponents.Spinner, { centering: "vertically", className: "mr-2", size: "small" });
|
|
1846
|
-
},
|
|
1783
|
+
},
|
|
1784
|
+
DropdownIndicator: props => {
|
|
1847
1785
|
const icon = props.selectProps.menuIsOpen ? (jsxRuntime.jsx(reactComponents.Icon, { name: "ChevronUp", size: "medium" })) : (jsxRuntime.jsx(reactComponents.Icon, { name: "ChevronDown", size: "medium" }));
|
|
1848
|
-
return props.selectProps.isLoading || props.selectProps.isDisabled || readOnly ? null : (jsxRuntime.jsx(ReactSelect.components.DropdownIndicator,
|
|
1849
|
-
},
|
|
1786
|
+
return props.selectProps.isLoading || props.selectProps.isDisabled || readOnly ? null : (jsxRuntime.jsx(ReactSelect.components.DropdownIndicator, { ...props, children: jsxRuntime.jsx("div", { className: cvaSelectIcon(), children: dropdownIcon !== null && dropdownIcon !== void 0 ? dropdownIcon : icon }) }));
|
|
1787
|
+
},
|
|
1788
|
+
IndicatorSeparator: () => null,
|
|
1789
|
+
ClearIndicator: props => {
|
|
1850
1790
|
if (disabled) {
|
|
1851
1791
|
return null;
|
|
1852
1792
|
}
|
|
1853
|
-
return (jsxRuntime.jsx(ReactSelect.components.ClearIndicator,
|
|
1854
|
-
},
|
|
1855
|
-
|
|
1793
|
+
return (jsxRuntime.jsx(ReactSelect.components.ClearIndicator, { ...props, children: jsxRuntime.jsx("div", { className: cvaSelectXIcon(), "data-testid": dataTestId ? `${dataTestId}-XMarkIcon` : null, onClick: props.clearValue, children: jsxRuntime.jsx(reactComponents.Icon, { ariaLabel: t("clearIndicator.icon.tooltip.clearAll"), name: "XCircle", size: "medium" }) }) }));
|
|
1794
|
+
},
|
|
1795
|
+
Control: props => {
|
|
1796
|
+
return (jsxRuntime.jsx(ReactSelect.components.Control, { ...props, className: cvaSelectControl({
|
|
1856
1797
|
isDisabled: props.isDisabled,
|
|
1857
1798
|
prefix: prefix ? true : false,
|
|
1858
1799
|
invalid: hasError,
|
|
1859
|
-
}) }))
|
|
1860
|
-
},
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
return (jsxRuntime.jsx(ReactSelect.components.
|
|
1866
|
-
},
|
|
1867
|
-
|
|
1800
|
+
}) }));
|
|
1801
|
+
},
|
|
1802
|
+
SingleValue: props => {
|
|
1803
|
+
return (jsxRuntime.jsx(ReactSelect.components.SingleValue, { ...props, className: props.isDisabled ? "text-slate-700" : "", children: jsxRuntime.jsx("div", { "data-testid": dataTestId + "-singleValue", children: props.children }) }));
|
|
1804
|
+
},
|
|
1805
|
+
Menu: props => {
|
|
1806
|
+
return (jsxRuntime.jsx(ReactSelect.components.Menu, { ...props, className: cvaSelectMenuList({ menuIsOpen: props.selectProps.menuIsOpen }) }));
|
|
1807
|
+
},
|
|
1808
|
+
Placeholder: props => {
|
|
1809
|
+
return (jsxRuntime.jsx(ReactSelect.components.Placeholder, { ...props, className: "!text-slate-400", children: props.children }));
|
|
1810
|
+
},
|
|
1811
|
+
MenuList: props => {
|
|
1812
|
+
return (jsxRuntime.jsx(ReactSelect.components.MenuList, { ...props, innerProps: {
|
|
1813
|
+
...props.innerProps,
|
|
1814
|
+
onScroll: e => {
|
|
1868
1815
|
const listEl = e.currentTarget;
|
|
1869
1816
|
if (listEl.scrollTop + listEl.clientHeight >= listEl.scrollHeight) {
|
|
1870
1817
|
props.selectProps.onMenuScrollToBottom && props.selectProps.onMenuScrollToBottom(new TouchEvent(""));
|
|
1871
1818
|
}
|
|
1872
|
-
}
|
|
1873
|
-
|
|
1819
|
+
},
|
|
1820
|
+
}, children: props.children }));
|
|
1821
|
+
},
|
|
1822
|
+
Option: props => {
|
|
1874
1823
|
const componentProps = {
|
|
1875
1824
|
label: props.label,
|
|
1876
1825
|
focused: props.isFocused,
|
|
1877
1826
|
selected: props.isSelected,
|
|
1878
1827
|
onClick: props.innerProps.onClick,
|
|
1879
1828
|
};
|
|
1880
|
-
return (jsxRuntime.jsx(ReactSelect.components.Option,
|
|
1881
|
-
|
|
1829
|
+
return (jsxRuntime.jsx(ReactSelect.components.Option, { ...props, innerProps: {
|
|
1830
|
+
...props.innerProps,
|
|
1831
|
+
role: "option",
|
|
1832
|
+
onClick: () => { },
|
|
1833
|
+
}, children: props.isMulti ? (jsxRuntime.jsx(MultiSelectMenuItem, { ...componentProps, dataTestId: typeof props.label === "string" ? props.label : undefined, disabled: disabled })) : (jsxRuntime.jsx(SingleSelectMenuItem, { ...componentProps, dataTestId: typeof props.label === "string" ? props.label : undefined, disabled: disabled || props.isDisabled })) }));
|
|
1834
|
+
},
|
|
1835
|
+
...componentsProps,
|
|
1836
|
+
};
|
|
1882
1837
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1883
1838
|
}, [componentsProps, disabled, maxSelectedDisplayCount]); // do not add dropdownIcon (it will cause issue with opening/closing list for selects with custom icon)
|
|
1884
1839
|
return customComponents;
|
|
@@ -1895,19 +1850,92 @@ const useCustomComponents = ({ componentsProps, disabled, readOnly, refMenuIsEna
|
|
|
1895
1850
|
*/
|
|
1896
1851
|
const useCustomStyles = ({ refContainer, refPrefix, maxSelectedDisplayCount, styles, disabled, }) => {
|
|
1897
1852
|
const customStyles = React__namespace.useMemo(() => {
|
|
1898
|
-
return
|
|
1899
|
-
|
|
1900
|
-
|
|
1853
|
+
return {
|
|
1854
|
+
control: base => {
|
|
1855
|
+
return {
|
|
1856
|
+
...base,
|
|
1857
|
+
borderRadius: "var(--border-radius-lg)",
|
|
1858
|
+
backgroundColor: "",
|
|
1859
|
+
};
|
|
1860
|
+
},
|
|
1861
|
+
singleValue: base => ({
|
|
1862
|
+
...base,
|
|
1863
|
+
}),
|
|
1864
|
+
multiValue: base => ({
|
|
1865
|
+
...base,
|
|
1866
|
+
}),
|
|
1867
|
+
multiValueLabel: base => ({
|
|
1868
|
+
...base,
|
|
1869
|
+
}),
|
|
1870
|
+
indicatorsContainer: base => ({
|
|
1871
|
+
...base,
|
|
1872
|
+
...(disabled && { display: "none" }),
|
|
1873
|
+
}),
|
|
1874
|
+
indicatorSeparator: () => ({
|
|
1901
1875
|
width: "0px",
|
|
1902
|
-
}),
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1876
|
+
}),
|
|
1877
|
+
menu: base => {
|
|
1878
|
+
return {
|
|
1879
|
+
...base,
|
|
1880
|
+
width: "100%",
|
|
1881
|
+
marginTop: "4px",
|
|
1882
|
+
marginBottom: "18px",
|
|
1883
|
+
transition: "all 1s ease-in-out",
|
|
1884
|
+
};
|
|
1885
|
+
},
|
|
1886
|
+
input: base => ({
|
|
1887
|
+
...base,
|
|
1888
|
+
marginLeft: "0px",
|
|
1889
|
+
}),
|
|
1890
|
+
placeholder: base => ({
|
|
1891
|
+
...base,
|
|
1892
|
+
}),
|
|
1893
|
+
option: () => ({}),
|
|
1894
|
+
menuPortal: base => ({
|
|
1895
|
+
...base,
|
|
1896
|
+
width: refContainer.current ? `${refContainer.current.clientWidth}px` : base.width,
|
|
1897
|
+
backgroundColor: "#ffffff",
|
|
1898
|
+
borderRadius: "var(--border-radius-lg)",
|
|
1899
|
+
zIndex: 20,
|
|
1900
|
+
borderColor: "rgb(var(--color-slate-300))",
|
|
1901
|
+
boxShadow: "var(--tw-ring-inset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)",
|
|
1902
|
+
}),
|
|
1903
|
+
menuList: base => {
|
|
1904
|
+
return {
|
|
1905
|
+
...base,
|
|
1906
|
+
position: "relative",
|
|
1907
|
+
padding: "var(--spacing-1)",
|
|
1908
|
+
display: "grid",
|
|
1909
|
+
gap: "var(--spacing-1)",
|
|
1910
|
+
width: "100%",
|
|
1911
|
+
borderRadius: "0px",
|
|
1912
|
+
boxShadow: "none",
|
|
1913
|
+
paddingTop: "0px",
|
|
1914
|
+
};
|
|
1915
|
+
},
|
|
1916
|
+
valueContainer: base => {
|
|
1917
|
+
return {
|
|
1918
|
+
...base,
|
|
1919
|
+
flexWrap: maxSelectedDisplayCount !== undefined ? "wrap" : "nowrap",
|
|
1920
|
+
gap: "0.25rem",
|
|
1921
|
+
};
|
|
1922
|
+
},
|
|
1923
|
+
container: base => ({
|
|
1924
|
+
...base,
|
|
1925
|
+
width: "100%",
|
|
1926
|
+
}),
|
|
1927
|
+
dropdownIndicator: base => ({
|
|
1928
|
+
...base,
|
|
1929
|
+
padding: "0px",
|
|
1930
|
+
}),
|
|
1931
|
+
clearIndicator: base => {
|
|
1932
|
+
return {
|
|
1933
|
+
...base,
|
|
1934
|
+
padding: "0px",
|
|
1935
|
+
};
|
|
1936
|
+
},
|
|
1937
|
+
...styles,
|
|
1938
|
+
};
|
|
1911
1939
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1912
1940
|
}, [refContainer, refPrefix]);
|
|
1913
1941
|
return { customStyles };
|
|
@@ -1919,11 +1947,10 @@ const useCustomStyles = ({ refContainer, refPrefix, maxSelectedDisplayCount, sty
|
|
|
1919
1947
|
* @param {SelectProps} props - The props for the Select component
|
|
1920
1948
|
* @returns {UseSelectProps} Select component
|
|
1921
1949
|
*/
|
|
1922
|
-
const useSelect = (
|
|
1923
|
-
var
|
|
1924
|
-
|
|
1925
|
-
const
|
|
1926
|
-
const refPrefix = React__default["default"].useRef(null);
|
|
1950
|
+
const useSelect = ({ id, className, dataTestId = "select", prefix, async, dropdownIcon, maxMenuHeight = 200, label, hasError, disabled, isMulti, components, value, options, onChange, isLoading, classNamePrefix = "", onMenuOpen, onMenuClose, maxSelectedDisplayCount = undefined, isClearable = false, isSearchable = true, onMenuScrollToBottom, styles, filterOption, onInputChange, ...props }) => {
|
|
1951
|
+
var _a;
|
|
1952
|
+
const refContainer = React.useRef(null);
|
|
1953
|
+
const refPrefix = React.useRef(null);
|
|
1927
1954
|
const { customStyles } = useCustomStyles({
|
|
1928
1955
|
refContainer,
|
|
1929
1956
|
refPrefix,
|
|
@@ -1931,8 +1958,8 @@ const useSelect = (_a) => {
|
|
|
1931
1958
|
styles,
|
|
1932
1959
|
disabled: Boolean(disabled),
|
|
1933
1960
|
});
|
|
1934
|
-
const [menuIsOpen, setMenuIsOpen] =
|
|
1935
|
-
const refMenuIsEnabled =
|
|
1961
|
+
const [menuIsOpen, setMenuIsOpen] = React.useState((_a = props.menuIsOpen) !== null && _a !== void 0 ? _a : false);
|
|
1962
|
+
const refMenuIsEnabled = React.useRef(true);
|
|
1936
1963
|
const customComponents = useCustomComponents({
|
|
1937
1964
|
componentsProps: components,
|
|
1938
1965
|
disabled: Boolean(disabled),
|
|
@@ -1945,7 +1972,7 @@ const useSelect = (_a) => {
|
|
|
1945
1972
|
hasError,
|
|
1946
1973
|
});
|
|
1947
1974
|
const menuPlacement = "auto";
|
|
1948
|
-
const openMenuHandler = () =>
|
|
1975
|
+
const openMenuHandler = async () => {
|
|
1949
1976
|
onMenuOpen === null || onMenuOpen === void 0 ? void 0 : onMenuOpen();
|
|
1950
1977
|
if (refMenuIsEnabled.current) {
|
|
1951
1978
|
setMenuIsOpen(true);
|
|
@@ -1953,15 +1980,18 @@ const useSelect = (_a) => {
|
|
|
1953
1980
|
else {
|
|
1954
1981
|
refMenuIsEnabled.current = true;
|
|
1955
1982
|
}
|
|
1956
|
-
}
|
|
1983
|
+
};
|
|
1957
1984
|
const closeMenuHandler = () => {
|
|
1958
1985
|
setMenuIsOpen(false);
|
|
1959
1986
|
onMenuClose && onMenuClose();
|
|
1960
1987
|
};
|
|
1961
|
-
const orderedOptions =
|
|
1988
|
+
const orderedOptions = React.useMemo(() => {
|
|
1962
1989
|
return disabled
|
|
1963
1990
|
? getOrderedOptions(options, value).map(option => {
|
|
1964
|
-
return
|
|
1991
|
+
return {
|
|
1992
|
+
...option,
|
|
1993
|
+
disabled: true,
|
|
1994
|
+
};
|
|
1965
1995
|
})
|
|
1966
1996
|
: getOrderedOptions(options, value);
|
|
1967
1997
|
}, [options, value, disabled]);
|
|
@@ -2043,7 +2073,7 @@ const CreatableSelect = (props) => {
|
|
|
2043
2073
|
value,
|
|
2044
2074
|
]);
|
|
2045
2075
|
const renderAsDisabled = Boolean(props.disabled) || props.readOnly;
|
|
2046
|
-
return (jsxRuntime.jsxs("div", { className: cvaSelect({ invalid: hasError, disabled: renderAsDisabled, className: props.className }), "data-testid": dataTestId, ref: refContainer, children: [prefix !== undefined ? (jsxRuntime.jsx("div", { className: cvaSelectPrefixSuffix({ kind: "prefix" }), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, ref: refPrefix, children: prefix })) : null, async ? (jsxRuntime.jsx(
|
|
2076
|
+
return (jsxRuntime.jsxs("div", { className: cvaSelect({ invalid: hasError, disabled: renderAsDisabled, className: props.className }), "data-testid": dataTestId, ref: refContainer, children: [prefix !== undefined ? (jsxRuntime.jsx("div", { className: cvaSelectPrefixSuffix({ kind: "prefix" }), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, ref: refPrefix, children: prefix })) : null, async ? (jsxRuntime.jsx(ReactAsyncCreatableSelect, { ...props, ...reactCreatableSelectProps, ...async, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, placeholder: renderAsDisabled ? null : props.placeholder })) : (jsxRuntime.jsx(ReactCreatableSelect, { ...props, ...reactCreatableSelectProps, hideSelectedOptions: false, isMulti: isMulti, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, options: filterOption ? orderedOptions : options, placeholder: renderAsDisabled ? null : props.placeholder })), typeof props.disabled === "object" ? (jsxRuntime.jsx("div", { className: cvaSelectPrefixSuffix({ kind: "suffix" }), "data-testid": dataTestId ? `${dataTestId}-locked` : null, children: jsxRuntime.jsx(DisabledForReasonsTip, { ...props.disabled }) })) : null] }));
|
|
2047
2077
|
};
|
|
2048
2078
|
CreatableSelect.displayName = "CreatableSelect";
|
|
2049
2079
|
|
|
@@ -2110,12 +2140,11 @@ const Select = (props) => {
|
|
|
2110
2140
|
value,
|
|
2111
2141
|
]);
|
|
2112
2142
|
const renderAsDisabled = Boolean(props.disabled) || props.readOnly;
|
|
2113
|
-
return (jsxRuntime.jsxs("div", { className: cvaSelect({ invalid: hasError, disabled: renderAsDisabled, className: props.className }), "data-testid": dataTestId, ref: refContainer, children: [prefix !== undefined ? (jsxRuntime.jsx("div", { className: cvaSelectPrefixSuffix({ kind: "prefix" }), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, ref: refPrefix, children: prefix })) : null, async ? (jsxRuntime.jsx(
|
|
2143
|
+
return (jsxRuntime.jsxs("div", { className: cvaSelect({ invalid: hasError, disabled: renderAsDisabled, className: props.className }), "data-testid": dataTestId, ref: refContainer, children: [prefix !== undefined ? (jsxRuntime.jsx("div", { className: cvaSelectPrefixSuffix({ kind: "prefix" }), "data-testid": dataTestId ? `${dataTestId}-prefix` : null, ref: refPrefix, children: prefix })) : null, async ? (jsxRuntime.jsx(ReactAsyncSelect, { ...props, ...reactSelectProps, ...async, menuPosition: menuPosition, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, placeholder: renderAsDisabled ? null : props.placeholder })) : (jsxRuntime.jsx(ReactSelect, { ...props, ...reactSelectProps, isMulti: isMulti, menuPosition: menuPosition, onMenuClose: closeMenuHandler, onMenuOpen: openMenuHandler, options: filterOption ? orderedOptions : options, placeholder: renderAsDisabled ? null : props.placeholder })), typeof props.disabled === "object" ? (jsxRuntime.jsx("div", { className: cvaSelectPrefixSuffix({ kind: "suffix" }), "data-testid": dataTestId ? `${dataTestId}-locked` : null, children: jsxRuntime.jsx(DisabledForReasonsTip, { ...props.disabled }) })) : null] }));
|
|
2114
2144
|
};
|
|
2115
2145
|
Select.displayName = "Select";
|
|
2116
2146
|
|
|
2117
|
-
const FormFieldSelectAdapter = React.forwardRef((
|
|
2118
|
-
var { className, dataTestId, helpText, helpAddon, tip, label, disabled, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, onChange, children } = _a, rest = __rest(_a, ["className", "dataTestId", "helpText", "helpAddon", "tip", "label", "disabled", "isInvalid", "errorMessage", "name", "onBlur", "options", "value", "defaultValue", "id", "onChange", "children"]);
|
|
2147
|
+
const FormFieldSelectAdapter = React.forwardRef(({ className, dataTestId, helpText, helpAddon, tip, label, disabled, isInvalid, errorMessage, name, onBlur, options, value, defaultValue, id, onChange, children, ...rest }, ref) => {
|
|
2119
2148
|
const isFirstRender = reactComponents.useIsFirstRender();
|
|
2120
2149
|
const [innerValue, setInnerValue] = React.useState(value || defaultValue);
|
|
2121
2150
|
React.useEffect(() => {
|
|
@@ -2155,14 +2184,21 @@ const FormFieldSelectAdapter = React.forwardRef((_a, ref) => {
|
|
|
2155
2184
|
tip,
|
|
2156
2185
|
label, children: [jsxRuntime.jsx("select", { onChange, ref: innerRef, name, value: innerValue, hidden: true, children: optionsWithCurrentSelectionBackupOption.map(option => {
|
|
2157
2186
|
return (jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value));
|
|
2158
|
-
}) }), children(
|
|
2187
|
+
}) }), children({
|
|
2188
|
+
...rest,
|
|
2189
|
+
id,
|
|
2159
2190
|
disabled,
|
|
2160
|
-
onBlur,
|
|
2191
|
+
onBlur,
|
|
2192
|
+
options: optionsWithCurrentSelectionBackupOption,
|
|
2193
|
+
onChange: e => {
|
|
2161
2194
|
// If theres no value, set the inner value to an empty string
|
|
2162
2195
|
// A native select can not have a null value
|
|
2163
2196
|
// So even if react-select sends a null value, we need to convert it to an empty string
|
|
2164
2197
|
setInnerValue(!e ? "" : e.value);
|
|
2165
|
-
},
|
|
2198
|
+
},
|
|
2199
|
+
value: selectedOption,
|
|
2200
|
+
defaultValue: selectedOption,
|
|
2201
|
+
})] }));
|
|
2166
2202
|
});
|
|
2167
2203
|
FormFieldSelectAdapter.displayName = "FormFieldSelectAdapter";
|
|
2168
2204
|
|
|
@@ -2176,10 +2212,9 @@ FormFieldSelectAdapter.displayName = "FormFieldSelectAdapter";
|
|
|
2176
2212
|
* @param {SelectFieldProps & CreatableSelectProps} props - The props for the CreatableSelectField component
|
|
2177
2213
|
* @returns {JSX.Element} CreatableSelectField component
|
|
2178
2214
|
*/
|
|
2179
|
-
const CreatableSelectField = React.forwardRef((
|
|
2180
|
-
var { allowCreateWhileLoading, onCreateOption } = _a, props = __rest(_a, ["allowCreateWhileLoading", "onCreateOption"]);
|
|
2215
|
+
const CreatableSelectField = React.forwardRef(({ allowCreateWhileLoading, onCreateOption, ...props }, ref) => {
|
|
2181
2216
|
const creatableSelectOnlyProps = { allowCreateWhileLoading, onCreateOption };
|
|
2182
|
-
return (jsxRuntime.jsx(FormFieldSelectAdapter,
|
|
2217
|
+
return (jsxRuntime.jsx(FormFieldSelectAdapter, { ...props, ref: ref, children: convertedProps => jsxRuntime.jsx(CreatableSelect, { ...convertedProps, ...creatableSelectOnlyProps }) }));
|
|
2183
2218
|
});
|
|
2184
2219
|
CreatableSelectField.displayName = "CreatableSelectField";
|
|
2185
2220
|
|
|
@@ -2193,9 +2228,8 @@ CreatableSelectField.displayName = "CreatableSelectField";
|
|
|
2193
2228
|
* @param {SelectFieldProps} props - The props for the SelectField component
|
|
2194
2229
|
* @returns {JSX.Element} SelectField component
|
|
2195
2230
|
*/
|
|
2196
|
-
const SelectField = React.forwardRef((
|
|
2197
|
-
|
|
2198
|
-
return (jsxRuntime.jsx(FormFieldSelectAdapter, Object.assign({}, props, { ref: ref, children: convertedProps => jsxRuntime.jsx(Select, Object.assign({}, convertedProps)) })));
|
|
2231
|
+
const SelectField = React.forwardRef(({ ...props }, ref) => {
|
|
2232
|
+
return (jsxRuntime.jsx(FormFieldSelectAdapter, { ...props, ref: ref, children: convertedProps => jsxRuntime.jsx(Select, { ...convertedProps }) }));
|
|
2199
2233
|
});
|
|
2200
2234
|
SelectField.displayName = "SelectField";
|
|
2201
2235
|
|
|
@@ -2235,9 +2269,8 @@ const cvaTextArea = cssClassVarianceUtilities.cvaMerge([
|
|
|
2235
2269
|
* The TextArea is a base component, and should not be used very often.
|
|
2236
2270
|
* For most cases the TextAreaField is the correct component.
|
|
2237
2271
|
*/
|
|
2238
|
-
const TextArea = React__namespace.forwardRef((
|
|
2239
|
-
|
|
2240
|
-
return (jsxRuntime.jsx("textarea", Object.assign({ className: cvaTextArea({ className, resize, invalid: isInvalid, disabled }), defaultValue: defaultValue, disabled: disabled, id: id, maxLength: maxLength, name: name, onBlur: onBlur, onFocus: onFocus, placeholder: placeholder, readOnly: readOnly, ref: ref, required: required, rows: rows, tabIndex: tabIndex, value: value }, rest, { "data-testid": dataTestId, onChange: onChange })));
|
|
2272
|
+
const TextArea = React__namespace.forwardRef(({ id, name, value, rows, disabled, placeholder, readOnly, tabIndex, onChange, onFocus, onBlur, maxLength, resize = "vertical", defaultValue, required, dataTestId, isInvalid, className, ...rest }, ref) => {
|
|
2273
|
+
return (jsxRuntime.jsx("textarea", { className: cvaTextArea({ className, resize, invalid: isInvalid, disabled }), defaultValue: defaultValue, disabled: disabled, id: id, maxLength: maxLength, name: name, onBlur: onBlur, onFocus: onFocus, placeholder: placeholder, readOnly: readOnly, ref: ref, required: required, rows: rows, tabIndex: tabIndex, value: value, ...rest, "data-testid": dataTestId, onChange: onChange }));
|
|
2241
2274
|
});
|
|
2242
2275
|
TextArea.displayName = "TextArea";
|
|
2243
2276
|
|
|
@@ -2252,8 +2285,7 @@ const TextLengthIndicator = ({ length, maxLength }) => {
|
|
|
2252
2285
|
return (jsxRuntime.jsxs("span", { className: "font-mono", children: [length, "/", maxLength] }));
|
|
2253
2286
|
};
|
|
2254
2287
|
|
|
2255
|
-
const TextAreaField = React__namespace.forwardRef((
|
|
2256
|
-
var { id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId } = _a, rest = __rest(_a, ["id", "label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
|
|
2288
|
+
const TextAreaField = React__namespace.forwardRef(({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, ...rest }, ref) => {
|
|
2257
2289
|
const [valueLength, setValueLength] = React__namespace.useState(value ? `${value}`.length : 0);
|
|
2258
2290
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2259
2291
|
const htmlForId = id ? id : "textAreaField-" + uuid.v4();
|
|
@@ -2264,7 +2296,7 @@ const TextAreaField = React__namespace.forwardRef((_a, ref) => {
|
|
|
2264
2296
|
}
|
|
2265
2297
|
}, [onChange]);
|
|
2266
2298
|
return (jsxRuntime.jsx(FormGroup, { className: tailwindMerge.twMerge(className, "grid", "grid-rows-[auto_1fr_auto]"), dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
|
|
2267
|
-
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(TextArea,
|
|
2299
|
+
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(TextArea, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: "h-auto", dataTestId: dataTestId, onChange: handleChange }) }));
|
|
2268
2300
|
});
|
|
2269
2301
|
TextAreaField.displayName = "TextAreaField";
|
|
2270
2302
|
|
|
@@ -2275,8 +2307,7 @@ TextAreaField.displayName = "TextAreaField";
|
|
|
2275
2307
|
*
|
|
2276
2308
|
* _**Do not use** to confirm user actions, such as deleting. Use a checkbox for such flows._
|
|
2277
2309
|
*/
|
|
2278
|
-
const TextField = React__namespace.forwardRef((
|
|
2279
|
-
var { id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId } = _a, rest = __rest(_a, ["id", "label", "tip", "helpText", "helpAddon", "errorMessage", "isInvalid", "maxLength", "onChange", "className", "value", "dataTestId"]);
|
|
2310
|
+
const TextField = React__namespace.forwardRef(({ id, label, tip, helpText, helpAddon, errorMessage, isInvalid, maxLength, onChange, className, value, dataTestId, ...rest }, ref) => {
|
|
2280
2311
|
const [valueLength, setValueLength] = React__namespace.useState(value ? `${value}`.length : 0);
|
|
2281
2312
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2282
2313
|
const htmlFor = id ? id : "textField-" + uuid.v4();
|
|
@@ -2287,7 +2318,7 @@ const TextField = React__namespace.forwardRef((_a, ref) => {
|
|
|
2287
2318
|
}
|
|
2288
2319
|
}, [onChange]);
|
|
2289
2320
|
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon ||
|
|
2290
|
-
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(TextInput,
|
|
2321
|
+
(typeof maxLength === "number" && jsxRuntime.jsx(TextLengthIndicator, { length: valueLength, maxLength: maxLength })), helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(TextInput, { "aria-labelledby": htmlFor + "-label", id: htmlFor, isInvalid: renderAsInvalid, maxLength: maxLength, ref: ref, value: value, ...rest, className: className, dataTestId: dataTestId, onChange: handleChange }) }));
|
|
2291
2322
|
});
|
|
2292
2323
|
TextField.displayName = "TextField";
|
|
2293
2324
|
|
|
@@ -2297,11 +2328,10 @@ TextField.displayName = "TextField";
|
|
|
2297
2328
|
* @param {TimeRangeFieldProps} props - The props for the TimeRangeField component
|
|
2298
2329
|
* @returns {JSX.Element} TimeRangeField component
|
|
2299
2330
|
*/
|
|
2300
|
-
const TimeRangeField = (
|
|
2301
|
-
var { className, dataTestId, onChange, isInvalid, errorMessage, label, tip, children, helpText, id } = _a, rest = __rest(_a, ["className", "dataTestId", "onChange", "isInvalid", "errorMessage", "label", "tip", "children", "helpText", "id"]);
|
|
2331
|
+
const TimeRangeField = ({ className, dataTestId, onChange, isInvalid, errorMessage, label, tip, children, helpText, id, ...rest }) => {
|
|
2302
2332
|
const renderAsInvalid = isInvalid === undefined ? Boolean(errorMessage) : isInvalid;
|
|
2303
2333
|
const htmlFor = id ? id : "timeRangeField-" + uuid.v4();
|
|
2304
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(TimeRange,
|
|
2334
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpText: (renderAsInvalid && errorMessage) || helpText, htmlFor: htmlFor, isInvalid: renderAsInvalid, label: label, tip: tip, children: jsxRuntime.jsx(TimeRange, { className: className, dataTestId: dataTestId, isInvalid: renderAsInvalid, onChange: onChange, ...rest, children: children }) }));
|
|
2305
2335
|
};
|
|
2306
2336
|
|
|
2307
2337
|
const cvaToggleWrapper = cssClassVarianceUtilities.cvaMerge(["flex", "gap-2", "items-center"]);
|
|
@@ -2391,26 +2421,22 @@ const cvaUploadInputAddonBefore = cssClassVarianceUtilities.cvaMerge(["block", "
|
|
|
2391
2421
|
*
|
|
2392
2422
|
* NOTE: If shown with a label, please use the `UploadField` component instead.
|
|
2393
2423
|
*/
|
|
2394
|
-
const UploadInput = React.forwardRef((
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
}
|
|
2402
|
-
}, ref: ref, type: "file" }, rest)) }));
|
|
2403
|
-
});
|
|
2424
|
+
const UploadInput = React.forwardRef(({ disabled, acceptedTypes, nonInteractive, uploadLabel, multipleFiles, ...rest }, ref) => (jsxRuntime.jsx("label", { className: "tu-upload-input", children: jsxRuntime.jsx(BaseInput, { accept: acceptedTypes, addonBefore: uploadLabel, addonBeforeClassName: cvaUploadInputAddonBefore(), disabled: disabled, inputClassName: cvaUploadInputField(), multiple: multipleFiles, nonInteractive: nonInteractive, onClick: event => {
|
|
2425
|
+
// onClick used to work with nonInteractive option
|
|
2426
|
+
if (nonInteractive) {
|
|
2427
|
+
event.preventDefault();
|
|
2428
|
+
event.stopPropagation();
|
|
2429
|
+
}
|
|
2430
|
+
}, ref: ref, type: "file", ...rest }) })));
|
|
2404
2431
|
UploadInput.displayName = "UploadInput";
|
|
2405
2432
|
|
|
2406
2433
|
/**
|
|
2407
2434
|
* Upload fields enable the user to upload Files.
|
|
2408
2435
|
*/
|
|
2409
|
-
const UploadField = React.forwardRef((
|
|
2410
|
-
var { label, id, tip, helpText, errorMessage, isInvalid, className, value, dataTestId } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "isInvalid", "className", "value", "dataTestId"]);
|
|
2436
|
+
const UploadField = React.forwardRef(({ label, id, tip, helpText, errorMessage, isInvalid, className, value, dataTestId, ...rest }, ref) => {
|
|
2411
2437
|
const renderAsInvalid = isInvalid || Boolean(errorMessage);
|
|
2412
2438
|
const htmlForId = id ? id : "uploadField-" + uuid.v4();
|
|
2413
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(UploadInput,
|
|
2439
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: `${dataTestId}-FormGroup`, helpText: errorMessage || helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(UploadInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, ref: ref, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
2414
2440
|
});
|
|
2415
2441
|
UploadField.displayName = "UploadField";
|
|
2416
2442
|
|
|
@@ -2434,11 +2460,10 @@ const validateUrlAddress = (url) => {
|
|
|
2434
2460
|
*
|
|
2435
2461
|
* NOTE: If shown with a label, please use the `UrlField` component instead.
|
|
2436
2462
|
*/
|
|
2437
|
-
const UrlInput = React.forwardRef((
|
|
2438
|
-
var { dataTestId, isInvalid, disabled = false, fieldSize = "medium", disableAction = false, value, defaultValue } = _a, rest = __rest(_a, ["dataTestId", "isInvalid", "disabled", "fieldSize", "disableAction", "value", "defaultValue"]);
|
|
2463
|
+
const UrlInput = React.forwardRef(({ dataTestId, isInvalid, disabled = false, fieldSize = "medium", disableAction = false, value, defaultValue, ...rest }, ref) => {
|
|
2439
2464
|
const [url, setUrl] = React.useState((value === null || value === void 0 ? void 0 : value.toString()) || (defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.toString()));
|
|
2440
2465
|
const renderAsInvalid = (url && typeof url === "string" && !validateUrlAddress(url)) || isInvalid;
|
|
2441
|
-
return (jsxRuntime.jsx(BaseInput,
|
|
2466
|
+
return (jsxRuntime.jsx(BaseInput, { dataTestId: dataTestId ? `${dataTestId}-url-input` : undefined, disabled: disabled, id: "url-input", isInvalid: renderAsInvalid, onChange: e => setUrl(e.target.value), placeholder: rest.placeholder || "https://www.example.com", ref: ref, type: "url", value: url, ...rest, actions: !disableAction && (jsxRuntime.jsx(ActionButton, { dataTestId: (dataTestId && `${dataTestId}-url-input-Icon`) || "url-input-action-icon", disabled: renderAsInvalid || disableAction, iconSize: fieldSize, type: "WEB_ADDRESS", value: url })) }));
|
|
2442
2467
|
});
|
|
2443
2468
|
UrlInput.displayName = "UrlField";
|
|
2444
2469
|
|
|
@@ -2447,15 +2472,14 @@ UrlInput.displayName = "UrlField";
|
|
|
2447
2472
|
* UrlField validates that user enters a valid web address.
|
|
2448
2473
|
*
|
|
2449
2474
|
*/
|
|
2450
|
-
const UrlField = React.forwardRef((
|
|
2451
|
-
var { label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, isInvalid = false, value } = _a, rest = __rest(_a, ["label", "id", "tip", "helpText", "errorMessage", "helpAddon", "className", "defaultValue", "dataTestId", "isInvalid", "value"]);
|
|
2475
|
+
const UrlField = React.forwardRef(({ label, id, tip, helpText, errorMessage, helpAddon, className, defaultValue, dataTestId, isInvalid = false, value, ...rest }, ref) => {
|
|
2452
2476
|
const htmlForId = id ? id : "urlField-" + uuid.v4();
|
|
2453
2477
|
// Type guard to check if value is a string
|
|
2454
2478
|
function isString(inputValue) {
|
|
2455
2479
|
return typeof inputValue === "string";
|
|
2456
2480
|
}
|
|
2457
2481
|
const renderAsInvalid = !!errorMessage || (value && isString(value) && !validateUrlAddress(value)) || isInvalid;
|
|
2458
|
-
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: renderAsInvalid ? errorMessage : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(UrlInput,
|
|
2482
|
+
return (jsxRuntime.jsx(FormGroup, { dataTestId: dataTestId ? `${dataTestId}-FormGroup` : undefined, helpAddon: helpAddon, helpText: renderAsInvalid ? errorMessage : helpText, htmlFor: htmlForId, isInvalid: renderAsInvalid, label: label, required: rest.required, tip: tip, children: jsxRuntime.jsx(UrlInput, { "aria-labelledby": htmlForId + "-label", id: htmlForId, isInvalid: renderAsInvalid, ref: ref, value: value || defaultValue, ...rest, className: className, dataTestId: dataTestId }) }));
|
|
2459
2483
|
});
|
|
2460
2484
|
UrlField.displayName = "UrlField";
|
|
2461
2485
|
|
|
@@ -2478,7 +2502,11 @@ const useGetPhoneValidationRules = () => {
|
|
|
2478
2502
|
},
|
|
2479
2503
|
};
|
|
2480
2504
|
return !skipValidation
|
|
2481
|
-
?
|
|
2505
|
+
? {
|
|
2506
|
+
...pattern,
|
|
2507
|
+
...defaultRules,
|
|
2508
|
+
}
|
|
2509
|
+
: defaultRules;
|
|
2482
2510
|
}, [t]);
|
|
2483
2511
|
return { getPhoneNumberValidationRules };
|
|
2484
2512
|
};
|
|
@@ -2563,10 +2591,7 @@ const useZodValidators = () => {
|
|
|
2563
2591
|
*/
|
|
2564
2592
|
setupLibraryTranslations();
|
|
2565
2593
|
|
|
2566
|
-
|
|
2567
|
-
enumerable: true,
|
|
2568
|
-
get: function () { return ReactSelect__default["default"]; }
|
|
2569
|
-
});
|
|
2594
|
+
exports.ValueType = ReactSelect;
|
|
2570
2595
|
exports.ActionButton = ActionButton;
|
|
2571
2596
|
exports.BaseInput = BaseInput;
|
|
2572
2597
|
exports.Checkbox = Checkbox;
|