@ews-admin/global-design-system 1.1.11 → 1.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +26 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +9 -1
- package/src/utils/index.ts +21 -0
package/dist/index.js
CHANGED
|
@@ -65,6 +65,25 @@ function debounce(func, wait) {
|
|
|
65
65
|
function generateId(prefix = "ews") {
|
|
66
66
|
return `${prefix}-${Math.random().toString(36).substr(2, 9)}`;
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Utility function to format numeric input by removing non-digit characters
|
|
70
|
+
* @param value - String value to format
|
|
71
|
+
* @returns String with only numeric characters
|
|
72
|
+
*/
|
|
73
|
+
const formatNumeric = (value) => {
|
|
74
|
+
return value.replace(/\D/g, "");
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Utility function to validate phone numbers
|
|
78
|
+
* Validates phone numbers with 1-15 digits, starting with a non-zero digit
|
|
79
|
+
* @param value - Phone number string to validate
|
|
80
|
+
* @returns Boolean indicating if the phone number is valid
|
|
81
|
+
*/
|
|
82
|
+
function isValidPhoneNumber(value) {
|
|
83
|
+
const trimmedValue = value.trim();
|
|
84
|
+
const phoneRegex = /^[0-9]\d{1,14}$/;
|
|
85
|
+
return phoneRegex.test(trimmedValue);
|
|
86
|
+
}
|
|
68
87
|
|
|
69
88
|
const Button = React.forwardRef(({ className, variant = "primary", size = "md", loading = false, fullWidth = false, leftIcon, rightIcon, children, disabled, ...props }, ref) => {
|
|
70
89
|
const baseStyles = "inline-flex items-center justify-center font-medium rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none";
|
|
@@ -1125,6 +1144,7 @@ function useController(props) {
|
|
|
1125
1144
|
exact: true,
|
|
1126
1145
|
});
|
|
1127
1146
|
const _props = React.useRef(props);
|
|
1147
|
+
const _previousNameRef = React.useRef(undefined);
|
|
1128
1148
|
const _registerProps = React.useRef(control.register(name, {
|
|
1129
1149
|
...props.rules,
|
|
1130
1150
|
value,
|
|
@@ -1190,6 +1210,10 @@ function useController(props) {
|
|
|
1190
1210
|
}), [name, disabled, formState.disabled, onChange, onBlur, ref, value]);
|
|
1191
1211
|
React.useEffect(() => {
|
|
1192
1212
|
const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
|
|
1213
|
+
const previousName = _previousNameRef.current;
|
|
1214
|
+
if (previousName && previousName !== name && !isArrayField) {
|
|
1215
|
+
control.unregister(previousName);
|
|
1216
|
+
}
|
|
1193
1217
|
control.register(name, {
|
|
1194
1218
|
..._props.current.rules,
|
|
1195
1219
|
...(isBoolean(_props.current.disabled)
|
|
@@ -1211,6 +1235,7 @@ function useController(props) {
|
|
|
1211
1235
|
}
|
|
1212
1236
|
}
|
|
1213
1237
|
!isArrayField && control.register(name);
|
|
1238
|
+
_previousNameRef.current = name;
|
|
1214
1239
|
return () => {
|
|
1215
1240
|
(isArrayField
|
|
1216
1241
|
? _shouldUnregisterField && !control._state.action
|
|
@@ -1785,7 +1810,9 @@ exports.cn = cn;
|
|
|
1785
1810
|
exports.debounce = debounce;
|
|
1786
1811
|
exports.formatCurrency = formatCurrency;
|
|
1787
1812
|
exports.formatDate = formatDate;
|
|
1813
|
+
exports.formatNumeric = formatNumeric;
|
|
1788
1814
|
exports.generateId = generateId;
|
|
1815
|
+
exports.isValidPhoneNumber = isValidPhoneNumber;
|
|
1789
1816
|
exports.useDebounce = useDebounce;
|
|
1790
1817
|
exports.useDebouncedCallback = useDebouncedCallback;
|
|
1791
1818
|
exports.useSelectField = useSelectField;
|