@ews-admin/global-design-system 1.1.11 → 1.1.13
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/README.md +3 -3
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +36 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +37 -10
- 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/components/Button/Button.tsx +20 -18
- package/src/components/Modal/Modal.tsx +2 -2
- package/src/index.ts +9 -1
- package/src/utils/index.ts +21 -0
package/dist/utils/index.d.ts
CHANGED
|
@@ -36,4 +36,17 @@ export declare function debounce<T extends (...args: any[]) => any>(func: T, wai
|
|
|
36
36
|
* @returns Unique ID string
|
|
37
37
|
*/
|
|
38
38
|
export declare function generateId(prefix?: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Utility function to format numeric input by removing non-digit characters
|
|
41
|
+
* @param value - String value to format
|
|
42
|
+
* @returns String with only numeric characters
|
|
43
|
+
*/
|
|
44
|
+
export declare const formatNumeric: (value: string) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Utility function to validate phone numbers
|
|
47
|
+
* Validates phone numbers with 1-15 digits, starting with a non-zero digit
|
|
48
|
+
* @param value - Phone number string to validate
|
|
49
|
+
* @returns Boolean indicating if the phone number is valid
|
|
50
|
+
*/
|
|
51
|
+
export declare function isValidPhoneNumber(value: string): boolean;
|
|
39
52
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MA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AAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,MAAM,GACX,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAMlC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,SAAQ,GAAG,MAAM,CAEjD;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,KAAG,MAE7C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAIzD"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,13 @@ export interface ButtonProps
|
|
|
6
6
|
/**
|
|
7
7
|
* Button variant
|
|
8
8
|
*/
|
|
9
|
-
variant?:
|
|
9
|
+
variant?:
|
|
10
|
+
| "ews-primary"
|
|
11
|
+
| "ews-secondary"
|
|
12
|
+
| "success"
|
|
13
|
+
| "warning"
|
|
14
|
+
| "error"
|
|
15
|
+
| "outline";
|
|
10
16
|
/**
|
|
11
17
|
* Button size
|
|
12
18
|
*/
|
|
@@ -33,7 +39,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
33
39
|
(
|
|
34
40
|
{
|
|
35
41
|
className,
|
|
36
|
-
variant = "primary",
|
|
42
|
+
variant = "ews-primary",
|
|
37
43
|
size = "md",
|
|
38
44
|
loading = false,
|
|
39
45
|
fullWidth = false,
|
|
@@ -46,21 +52,17 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
46
52
|
ref
|
|
47
53
|
) => {
|
|
48
54
|
const baseStyles =
|
|
49
|
-
"inline-flex items-center justify-center font-medium rounded-md transition-colors focus:outline-none
|
|
55
|
+
"inline-flex items-center justify-center font-medium rounded-md transition-colors focus:outline-none disabled:opacity-50 disabled:pointer-events-none";
|
|
50
56
|
|
|
51
57
|
const variants = {
|
|
52
|
-
primary:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"bg-
|
|
60
|
-
error:
|
|
61
|
-
"bg-ews-error text-white hover:bg-ews-error-hover focus:ring-ews-error",
|
|
62
|
-
ghost:
|
|
63
|
-
"bg-transparent text-ews-gray-700 hover:bg-ews-gray-100 focus:ring-ews-gray-500",
|
|
58
|
+
"ews-primary": "bg-ews-primary text-white hover:bg-ews-primary-hover",
|
|
59
|
+
"ews-secondary":
|
|
60
|
+
"bg-ews-secondary text-white hover:bg-ews-secondary-hover",
|
|
61
|
+
success: "bg-ews-success text-white hover:bg-ews-success-hover",
|
|
62
|
+
warning: "bg-ews-warning text-white hover:bg-ews-warning-hover",
|
|
63
|
+
error: "bg-ews-error text-white hover:bg-ews-error-hover",
|
|
64
|
+
outline:
|
|
65
|
+
"bg-transparent text-sm font-medium text-ews-primary hover:text-ews-primary/80",
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
const sizes = {
|
|
@@ -90,7 +92,7 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
90
92
|
>
|
|
91
93
|
{loading && (
|
|
92
94
|
<svg
|
|
93
|
-
className="
|
|
95
|
+
className="mr-2 -ml-1 w-4 h-4 animate-spin"
|
|
94
96
|
xmlns="http://www.w3.org/2000/svg"
|
|
95
97
|
fill="none"
|
|
96
98
|
viewBox="0 0 24 24"
|
|
@@ -111,13 +113,13 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
111
113
|
</svg>
|
|
112
114
|
)}
|
|
113
115
|
{!loading && leftIcon && (
|
|
114
|
-
<span className={cn("
|
|
116
|
+
<span className={cn("flex items-center mr-2", iconSizes[size])}>
|
|
115
117
|
{leftIcon}
|
|
116
118
|
</span>
|
|
117
119
|
)}
|
|
118
120
|
{children}
|
|
119
121
|
{!loading && rightIcon && (
|
|
120
|
-
<span className={cn("
|
|
122
|
+
<span className={cn("flex items-center ml-2", iconSizes[size])}>
|
|
121
123
|
{rightIcon}
|
|
122
124
|
</span>
|
|
123
125
|
)}
|
|
@@ -231,7 +231,7 @@ const Modal = ({
|
|
|
231
231
|
<div className="flex justify-end items-center p-6 pt-0 space-x-3">
|
|
232
232
|
{secondaryAction && (
|
|
233
233
|
<Button
|
|
234
|
-
variant="
|
|
234
|
+
variant="outline"
|
|
235
235
|
onClick={onSecondaryAction || onClose}
|
|
236
236
|
disabled={isLoading}
|
|
237
237
|
>
|
|
@@ -240,7 +240,7 @@ const Modal = ({
|
|
|
240
240
|
)}
|
|
241
241
|
{primaryAction && (
|
|
242
242
|
<Button
|
|
243
|
-
variant={variant === "error" ? "error" : "primary"}
|
|
243
|
+
variant={variant === "error" ? "error" : "ews-primary"}
|
|
244
244
|
onClick={onPrimaryAction}
|
|
245
245
|
loading={isLoading}
|
|
246
246
|
>
|
package/src/index.ts
CHANGED
|
@@ -42,7 +42,15 @@ export {
|
|
|
42
42
|
export type { IconProps, SimpleIconProps } from "./icons";
|
|
43
43
|
|
|
44
44
|
// Utils
|
|
45
|
-
export {
|
|
45
|
+
export {
|
|
46
|
+
cn,
|
|
47
|
+
debounce,
|
|
48
|
+
formatCurrency,
|
|
49
|
+
formatDate,
|
|
50
|
+
formatNumeric,
|
|
51
|
+
generateId,
|
|
52
|
+
isValidPhoneNumber,
|
|
53
|
+
} from "./utils";
|
|
46
54
|
|
|
47
55
|
// Hooks
|
|
48
56
|
export { useDebounce, useDebouncedCallback, useSelectField } from "./hooks";
|
package/src/utils/index.ts
CHANGED
|
@@ -71,3 +71,24 @@ export function debounce<T extends (...args: any[]) => any>(
|
|
|
71
71
|
export function generateId(prefix = "ews"): string {
|
|
72
72
|
return `${prefix}-${Math.random().toString(36).substr(2, 9)}`;
|
|
73
73
|
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Utility function to format numeric input by removing non-digit characters
|
|
77
|
+
* @param value - String value to format
|
|
78
|
+
* @returns String with only numeric characters
|
|
79
|
+
*/
|
|
80
|
+
export const formatNumeric = (value: string): string => {
|
|
81
|
+
return value.replace(/\D/g, "");
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Utility function to validate phone numbers
|
|
86
|
+
* Validates phone numbers with 1-15 digits, starting with a non-zero digit
|
|
87
|
+
* @param value - Phone number string to validate
|
|
88
|
+
* @returns Boolean indicating if the phone number is valid
|
|
89
|
+
*/
|
|
90
|
+
export function isValidPhoneNumber(value: string): boolean {
|
|
91
|
+
const trimmedValue = value.trim();
|
|
92
|
+
const phoneRegex = /^[0-9]\d{1,14}$/;
|
|
93
|
+
return phoneRegex.test(trimmedValue);
|
|
94
|
+
}
|