@trackunit/react-form-components 0.0.272 → 0.0.275
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
CHANGED
|
@@ -662,6 +662,9 @@ const DropZone = (_a) => {
|
|
|
662
662
|
} }, rest, { children: [jsxRuntime.jsx("input", { title: "Hidden File Input", type: "file", id: "input-file-upload", onChange: handleChange, className: "hidden" }), jsxRuntime.jsxs("label", { className: cvaDropZoneLabel(), htmlFor: "input-file-upload", "data-testid": dataTestId && `${dataTestId}-label`, children: [jsxRuntime.jsx(reactComponents.Icon, { type: "solid", name: "ArrowUpCircle", color: isInvalid ? "danger" : "neutral", style: !isInvalid ? { color: "rgb(156 163 175)" } : {} }), jsxRuntime.jsx("span", { children: label })] })] })));
|
|
663
663
|
};
|
|
664
664
|
|
|
665
|
+
// Doing the same check as we do on the backend
|
|
666
|
+
// Using OWASP pattern from: https://owasp.org/www-community/OWASP_Validation_Regex_Repository
|
|
667
|
+
const EMAIL_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
665
668
|
/**
|
|
666
669
|
* @description Validate given email id.
|
|
667
670
|
* @param email The address to validate.
|
|
@@ -672,10 +675,7 @@ const validateEmailAddress = (email) => {
|
|
|
672
675
|
if (!email) {
|
|
673
676
|
return false;
|
|
674
677
|
}
|
|
675
|
-
|
|
676
|
-
// Using OWASP pattern from: https://owasp.org/www-community/OWASP_Validation_Regex_Repository
|
|
677
|
-
const emailValidationPattern = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
678
|
-
return emailValidationPattern.test(email);
|
|
678
|
+
return EMAIL_REGEX.test(email);
|
|
679
679
|
};
|
|
680
680
|
|
|
681
681
|
/**
|
|
@@ -1072,7 +1072,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
|
|
|
1072
1072
|
return (jsxRuntime.jsx(TagWithWidth, { onWidthKnown: onWidthKnownHandler, className: "inline-flex shrink-0", onClose: e => {
|
|
1073
1073
|
e.stopPropagation();
|
|
1074
1074
|
item.onClick();
|
|
1075
|
-
}, color: item.disabled ? "unknown" : "primary", dataTestId: item.text
|
|
1075
|
+
}, color: item.disabled ? "unknown" : "primary", dataTestId: `${item.text}-tag`, disabled: disabled, children: item.text }, item.text + index));
|
|
1076
1076
|
}
|
|
1077
1077
|
const fromTheItems = item.text !== "";
|
|
1078
1078
|
if (fromTheItems) {
|
|
@@ -1133,8 +1133,8 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
1133
1133
|
e.stopPropagation();
|
|
1134
1134
|
refMenuIsEnabled.current = false;
|
|
1135
1135
|
((_a = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _a === void 0 ? void 0 : _a.onClick) && ((_b = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _b === void 0 ? void 0 : _b.onClick(e));
|
|
1136
|
-
}, color: disabled ? "unknown" : "primary", dataTestId: (_a = tagProps.children) === null || _a === void 0 ? void 0 : _a.toString(), children: tagProps.children }, (_b = tagProps.children) === null || _b === void 0 ? void 0 : _b.toString()));
|
|
1137
|
-
}), tags && tags.length > maxSelectedDisplayCount && (jsxRuntime.jsxs(reactComponents.Tag, { color: "neutral", dataTestId: "counter", children: ["+", tags.length - maxSelectedDisplayCount] })), searchInput] })) })));
|
|
1136
|
+
}, color: disabled ? "unknown" : "primary", dataTestId: tagProps.children ? `${(_a = tagProps.children) === null || _a === void 0 ? void 0 : _a.toString()}-tag` : undefined, children: tagProps.children }, (_b = tagProps.children) === null || _b === void 0 ? void 0 : _b.toString()));
|
|
1137
|
+
}), tags && tags.length > maxSelectedDisplayCount && (jsxRuntime.jsxs(reactComponents.Tag, { color: "neutral", dataTestId: "counter-tag", children: ["+", tags.length - maxSelectedDisplayCount] })), searchInput] })) })));
|
|
1138
1138
|
}
|
|
1139
1139
|
return (jsxRuntime.jsx(ReactSelect.components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: props.children })));
|
|
1140
1140
|
}, LoadingIndicator: props => {
|
|
@@ -1526,7 +1526,7 @@ const PhoneInput = React.forwardRef((_a, ref) => {
|
|
|
1526
1526
|
// the event's type is inferred as Event, which doesn't have a target property, whereas ChangeEvent does.
|
|
1527
1527
|
onChange && onChange(event);
|
|
1528
1528
|
}, [phoneNumber, onChange]);
|
|
1529
|
-
return (jsxRuntime.jsxs("div", { className: "grid-cols-min-fr grid gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsxRuntime.jsx("input", { hidden: true, id: "phone-input", "data-testid": dataTestId, value: phoneNumber, ref: hiddenInputRef, onChange: onChange, "aria-invalid": isInvalid }), jsxRuntime.jsx(CountryCodeSelect, { dataTestId: dataTestId && `${dataTestId}-countryCodeSelect`, countryCode: code, onBlur: e => {
|
|
1529
|
+
return (jsxRuntime.jsxs("div", { className: "grid-cols-min-fr grid gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsxRuntime.jsx("input", { hidden: true, id: "phone-input", "data-testid": dataTestId, value: phoneNumber, ref: hiddenInputRef, onChange: onChange, "aria-invalid": isInvalid, readOnly: readOnly }), jsxRuntime.jsx(CountryCodeSelect, { dataTestId: dataTestId && `${dataTestId}-countryCodeSelect`, countryCode: code, onBlur: e => {
|
|
1530
1530
|
onBlurHandler();
|
|
1531
1531
|
}, onChange: e => {
|
|
1532
1532
|
var _a;
|
|
@@ -2247,6 +2247,7 @@ exports.CreatableSelect = CreatableSelect;
|
|
|
2247
2247
|
exports.DateField = DateField;
|
|
2248
2248
|
exports.DateInput = DateInput;
|
|
2249
2249
|
exports.DropZone = DropZone;
|
|
2250
|
+
exports.EMAIL_REGEX = EMAIL_REGEX;
|
|
2250
2251
|
exports.EmailField = EmailField;
|
|
2251
2252
|
exports.EmailInput = EmailInput;
|
|
2252
2253
|
exports.FormGroup = FormGroup;
|
package/index.esm.js
CHANGED
|
@@ -632,6 +632,9 @@ const DropZone = (_a) => {
|
|
|
632
632
|
} }, rest, { children: [jsx("input", { title: "Hidden File Input", type: "file", id: "input-file-upload", onChange: handleChange, className: "hidden" }), jsxs("label", { className: cvaDropZoneLabel(), htmlFor: "input-file-upload", "data-testid": dataTestId && `${dataTestId}-label`, children: [jsx(Icon, { type: "solid", name: "ArrowUpCircle", color: isInvalid ? "danger" : "neutral", style: !isInvalid ? { color: "rgb(156 163 175)" } : {} }), jsx("span", { children: label })] })] })));
|
|
633
633
|
};
|
|
634
634
|
|
|
635
|
+
// Doing the same check as we do on the backend
|
|
636
|
+
// Using OWASP pattern from: https://owasp.org/www-community/OWASP_Validation_Regex_Repository
|
|
637
|
+
const EMAIL_REGEX = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
635
638
|
/**
|
|
636
639
|
* @description Validate given email id.
|
|
637
640
|
* @param email The address to validate.
|
|
@@ -642,10 +645,7 @@ const validateEmailAddress = (email) => {
|
|
|
642
645
|
if (!email) {
|
|
643
646
|
return false;
|
|
644
647
|
}
|
|
645
|
-
|
|
646
|
-
// Using OWASP pattern from: https://owasp.org/www-community/OWASP_Validation_Regex_Repository
|
|
647
|
-
const emailValidationPattern = /^[a-zA-Z0-9_+&*-]+(?:\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$/;
|
|
648
|
-
return emailValidationPattern.test(email);
|
|
648
|
+
return EMAIL_REGEX.test(email);
|
|
649
649
|
};
|
|
650
650
|
|
|
651
651
|
/**
|
|
@@ -1042,7 +1042,7 @@ const TagsContainer = ({ items, width = "100%", itemsGap = 5, postFix, disabled
|
|
|
1042
1042
|
return (jsx(TagWithWidth, { onWidthKnown: onWidthKnownHandler, className: "inline-flex shrink-0", onClose: e => {
|
|
1043
1043
|
e.stopPropagation();
|
|
1044
1044
|
item.onClick();
|
|
1045
|
-
}, color: item.disabled ? "unknown" : "primary", dataTestId: item.text
|
|
1045
|
+
}, color: item.disabled ? "unknown" : "primary", dataTestId: `${item.text}-tag`, disabled: disabled, children: item.text }, item.text + index));
|
|
1046
1046
|
}
|
|
1047
1047
|
const fromTheItems = item.text !== "";
|
|
1048
1048
|
if (fromTheItems) {
|
|
@@ -1103,8 +1103,8 @@ const useCustomComponents = (componentsProps, disabled, menuIsOpen, refMenuIsEna
|
|
|
1103
1103
|
e.stopPropagation();
|
|
1104
1104
|
refMenuIsEnabled.current = false;
|
|
1105
1105
|
((_a = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _a === void 0 ? void 0 : _a.onClick) && ((_b = tagProps === null || tagProps === void 0 ? void 0 : tagProps.removeProps) === null || _b === void 0 ? void 0 : _b.onClick(e));
|
|
1106
|
-
}, color: disabled ? "unknown" : "primary", dataTestId: (_a = tagProps.children) === null || _a === void 0 ? void 0 : _a.toString(), children: tagProps.children }, (_b = tagProps.children) === null || _b === void 0 ? void 0 : _b.toString()));
|
|
1107
|
-
}), tags && tags.length > maxSelectedDisplayCount && (jsxs(Tag, { color: "neutral", dataTestId: "counter", children: ["+", tags.length - maxSelectedDisplayCount] })), searchInput] })) })));
|
|
1106
|
+
}, color: disabled ? "unknown" : "primary", dataTestId: tagProps.children ? `${(_a = tagProps.children) === null || _a === void 0 ? void 0 : _a.toString()}-tag` : undefined, children: tagProps.children }, (_b = tagProps.children) === null || _b === void 0 ? void 0 : _b.toString()));
|
|
1107
|
+
}), tags && tags.length > maxSelectedDisplayCount && (jsxs(Tag, { color: "neutral", dataTestId: "counter-tag", children: ["+", tags.length - maxSelectedDisplayCount] })), searchInput] })) })));
|
|
1108
1108
|
}
|
|
1109
1109
|
return (jsx(components.ValueContainer, Object.assign({}, props, { isDisabled: props.selectProps.isDisabled, children: props.children })));
|
|
1110
1110
|
}, LoadingIndicator: props => {
|
|
@@ -1496,7 +1496,7 @@ const PhoneInput = forwardRef((_a, ref) => {
|
|
|
1496
1496
|
// the event's type is inferred as Event, which doesn't have a target property, whereas ChangeEvent does.
|
|
1497
1497
|
onChange && onChange(event);
|
|
1498
1498
|
}, [phoneNumber, onChange]);
|
|
1499
|
-
return (jsxs("div", { className: "grid-cols-min-fr grid gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsx("input", { hidden: true, id: "phone-input", "data-testid": dataTestId, value: phoneNumber, ref: hiddenInputRef, onChange: onChange, "aria-invalid": isInvalid }), jsx(CountryCodeSelect, { dataTestId: dataTestId && `${dataTestId}-countryCodeSelect`, countryCode: code, onBlur: e => {
|
|
1499
|
+
return (jsxs("div", { className: "grid-cols-min-fr grid gap-2", "data-testid": dataTestId && `${dataTestId}-container`, children: [jsx("input", { hidden: true, id: "phone-input", "data-testid": dataTestId, value: phoneNumber, ref: hiddenInputRef, onChange: onChange, "aria-invalid": isInvalid, readOnly: readOnly }), jsx(CountryCodeSelect, { dataTestId: dataTestId && `${dataTestId}-countryCodeSelect`, countryCode: code, onBlur: e => {
|
|
1500
1500
|
onBlurHandler();
|
|
1501
1501
|
}, onChange: e => {
|
|
1502
1502
|
var _a;
|
|
@@ -2206,4 +2206,4 @@ const UrlField = forwardRef((_a, ref) => {
|
|
|
2206
2206
|
*/
|
|
2207
2207
|
setupLibraryTranslations();
|
|
2208
2208
|
|
|
2209
|
-
export { ActionButton, BaseInput, Checkbox, CreatableSelect, DateField, DateInput, DropZone, EmailField, EmailInput, FormGroup, Label, MultiSelectMenuItem, NumberField, NumberInput, OptionCard, PasswordField, PasswordInput, PhoneField, PhoneInput, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, Select, SingleSelectMenuItem, TextArea, TextAreaField, TextField, TextInput, TimeRange, TimeRangeField, Toggle, UploadField, UploadInput, UrlField, UrlInput, checkIfPhoneNumberHasPlus, countryCodeToFlagEmoji, cvaInput, cvaInputAddon, cvaInputAddonAfter, cvaInputAddonBefore, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid, cvaInputField, cvaInputPrefix, cvaInputSuffix, cvaSelect, cvaSelectCounter, cvaSelectDynamicTagContainer, cvaSelectIcon, cvaSelectMenu, cvaSelectMenuList, cvaSelectPrefix, cvaSelectXIcon, getCountryAbbreviation, getOrderedOptions, getPhoneNumberWithPlus, isInvalidCountryCode, isInvalidPhoneNumber, isMultiValue, parseSchedule, serializeSchedule, useCustomComponents, usePhoneInput, validateEmailAddress, validatePhoneNumber, weekDay };
|
|
2209
|
+
export { ActionButton, BaseInput, Checkbox, CreatableSelect, DateField, DateInput, DropZone, EMAIL_REGEX, EmailField, EmailInput, FormGroup, Label, MultiSelectMenuItem, NumberField, NumberInput, OptionCard, PasswordField, PasswordInput, PhoneField, PhoneInput, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, Select, SingleSelectMenuItem, TextArea, TextAreaField, TextField, TextInput, TimeRange, TimeRangeField, Toggle, UploadField, UploadInput, UrlField, UrlInput, checkIfPhoneNumberHasPlus, countryCodeToFlagEmoji, cvaInput, cvaInputAddon, cvaInputAddonAfter, cvaInputAddonBefore, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid, cvaInputField, cvaInputPrefix, cvaInputSuffix, cvaSelect, cvaSelectCounter, cvaSelectDynamicTagContainer, cvaSelectIcon, cvaSelectMenu, cvaSelectMenuList, cvaSelectPrefix, cvaSelectXIcon, getCountryAbbreviation, getOrderedOptions, getPhoneNumberWithPlus, isInvalidCountryCode, isInvalidPhoneNumber, isMultiValue, parseSchedule, serializeSchedule, useCustomComponents, usePhoneInput, validateEmailAddress, validatePhoneNumber, weekDay };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { GroupBase } from "react-select";
|
|
3
3
|
import { SelectProps } from "./useSelect";
|
|
4
|
-
export interface SelectOption<T extends string> {
|
|
4
|
+
export interface SelectOption<T extends string | number> {
|
|
5
5
|
label: string;
|
|
6
6
|
value: T;
|
|
7
7
|
disabled?: boolean;
|