@yomologic/react-ui 0.6.0 → 0.6.3
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.d.mts +81 -1
- package/dist/index.d.ts +81 -1
- package/dist/index.js +285 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +276 -20
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +31 -0
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -20,6 +20,42 @@ type ButtonAsLink = ButtonBaseProps & Omit<React.AnchorHTMLAttributes<HTMLAnchor
|
|
|
20
20
|
type ButtonProps = ButtonAsButton | ButtonAsLink;
|
|
21
21
|
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Input formatting utilities
|
|
25
|
+
*/
|
|
26
|
+
type FormatType = "phone" | "phone-intl" | "credit-card" | "date" | "datetime";
|
|
27
|
+
/**
|
|
28
|
+
* Format US phone number: (123) 456-7890
|
|
29
|
+
*/
|
|
30
|
+
declare const formatPhoneUS: (value: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Format international phone number: +1 (123) 456-7890
|
|
33
|
+
*/
|
|
34
|
+
declare const formatPhoneIntl: (value: string) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Format credit card number: 1234 5678 9012 3456
|
|
37
|
+
*/
|
|
38
|
+
declare const formatCreditCard: (value: string) => string;
|
|
39
|
+
/**
|
|
40
|
+
* Format date: MM/DD/YYYY
|
|
41
|
+
*/
|
|
42
|
+
declare const formatDate: (value: string) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Format datetime: MM/DD/YYYY HH:MM AM/PM
|
|
45
|
+
*/
|
|
46
|
+
declare const formatDateTime: (value: string) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Get raw value from formatted string
|
|
49
|
+
* - For phone/credit-card: returns digits only
|
|
50
|
+
* - For date: returns YYYY-MM-DD format (ISO 8601)
|
|
51
|
+
* - For datetime: returns ISO 8601 with timezone offset
|
|
52
|
+
*/
|
|
53
|
+
declare const getRawValue: (value: string, format?: FormatType) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Apply format based on format type
|
|
56
|
+
*/
|
|
57
|
+
declare const applyFormat: (value: string, format: FormatType) => string;
|
|
58
|
+
|
|
23
59
|
interface FormState {
|
|
24
60
|
values: Record<string, any>;
|
|
25
61
|
errors: Record<string, string>;
|
|
@@ -62,6 +98,8 @@ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
|
|
62
98
|
onValidationError?: (error: string | undefined) => void;
|
|
63
99
|
/** Regex pattern for validation (string or RegExp) */
|
|
64
100
|
pattern?: RegExp | string;
|
|
101
|
+
/** Format type for auto-formatting input value (phone, credit-card, date, etc.) */
|
|
102
|
+
format?: FormatType | ((value: string) => string);
|
|
65
103
|
/** Custom error messages for built-in validations */
|
|
66
104
|
errorMessages?: {
|
|
67
105
|
required?: string;
|
|
@@ -72,6 +110,7 @@ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
|
|
72
110
|
pattern?: string;
|
|
73
111
|
email?: string;
|
|
74
112
|
url?: string;
|
|
113
|
+
date?: string;
|
|
75
114
|
};
|
|
76
115
|
}
|
|
77
116
|
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -1107,4 +1146,45 @@ type ThemeId = keyof typeof themes;
|
|
|
1107
1146
|
|
|
1108
1147
|
declare function cn(...inputs: ClassValue[]): string;
|
|
1109
1148
|
|
|
1110
|
-
|
|
1149
|
+
/**
|
|
1150
|
+
* Validation constants and regex patterns
|
|
1151
|
+
*/
|
|
1152
|
+
/**
|
|
1153
|
+
* RFC 5322 compliant email validation regex (simplified)
|
|
1154
|
+
* Matches standard email formats like: user@example.com
|
|
1155
|
+
*/
|
|
1156
|
+
declare const EMAIL_REGEX: RegExp;
|
|
1157
|
+
/**
|
|
1158
|
+
* URL validation regex
|
|
1159
|
+
* Matches http(s) URLs
|
|
1160
|
+
*/
|
|
1161
|
+
declare const URL_REGEX: RegExp;
|
|
1162
|
+
/**
|
|
1163
|
+
* Phone number validation regex (US format)
|
|
1164
|
+
* Matches formats like: (123) 456-7890, 123-456-7890, 1234567890
|
|
1165
|
+
*/
|
|
1166
|
+
declare const PHONE_REGEX: RegExp;
|
|
1167
|
+
/**
|
|
1168
|
+
* Validate email format
|
|
1169
|
+
*/
|
|
1170
|
+
declare const isValidEmail: (email: string) => boolean;
|
|
1171
|
+
/**
|
|
1172
|
+
* Validate URL format
|
|
1173
|
+
*/
|
|
1174
|
+
declare const isValidUrl: (url: string) => boolean;
|
|
1175
|
+
/**
|
|
1176
|
+
* Date validation regex (MM/DD/YYYY)
|
|
1177
|
+
* Matches formats like: 12/31/2024, 01/01/2024
|
|
1178
|
+
*/
|
|
1179
|
+
declare const DATE_REGEX: RegExp;
|
|
1180
|
+
/**
|
|
1181
|
+
* Validate phone number format
|
|
1182
|
+
*/
|
|
1183
|
+
declare const isValidPhone: (phone: string) => boolean;
|
|
1184
|
+
/**
|
|
1185
|
+
* Validate date format and value
|
|
1186
|
+
* Checks if date is in MM/DD/YYYY format and is a valid calendar date
|
|
1187
|
+
*/
|
|
1188
|
+
declare const isValidDate: (date: string) => boolean;
|
|
1189
|
+
|
|
1190
|
+
export { Alert, Badge, Button, Card, CardActionArea, CardActions, CardContent, CardDescription, CardFooter, CardHeader, CardMedia, CardTitle, Checkbox, CheckboxGroup, CodeSnippet, Container, DATE_REGEX, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Divider, Drawer, type NavItem$1 as DrawerNavItem, type NavSection$1 as DrawerNavSection, type DrawerProps, EMAIL_REGEX, EmptyState, Form, type FormContextValue, FormControl, type FormControlContextValue, FormControlLabel, type FormControlProps, type FormControlState, type FormFieldProps, FormHelperText, type FormState, type FormatType, Input, NativeSelect, type NativeSelectProps, Nav, type NavItem$2 as NavItem, type NavProps, type NavSection, PHONE_REGEX, RadioGroup, Rating, SectionLayout, Select, type SelectOption, type SelectProps, SidebarNav, type NavItem as SidebarNavItem, Slider, type SliderMark, type SliderProps, Spinner, Switch, type SwitchProps, Textarea, type TextareaProps, type ThemeId, ThemeProvider, URL_REGEX, type ValidationFunction, type ValidationRule, applyFormat, cn, formatCreditCard, formatDate, formatDateTime, formatPhoneIntl, formatPhoneUS, getRawValue, isValidDate, isValidEmail, isValidPhone, isValidUrl, themes, useForm, useFormContext, useFormControl, useFormControlContext, useFormField, useTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,42 @@ type ButtonAsLink = ButtonBaseProps & Omit<React.AnchorHTMLAttributes<HTMLAnchor
|
|
|
20
20
|
type ButtonProps = ButtonAsButton | ButtonAsLink;
|
|
21
21
|
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
22
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Input formatting utilities
|
|
25
|
+
*/
|
|
26
|
+
type FormatType = "phone" | "phone-intl" | "credit-card" | "date" | "datetime";
|
|
27
|
+
/**
|
|
28
|
+
* Format US phone number: (123) 456-7890
|
|
29
|
+
*/
|
|
30
|
+
declare const formatPhoneUS: (value: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Format international phone number: +1 (123) 456-7890
|
|
33
|
+
*/
|
|
34
|
+
declare const formatPhoneIntl: (value: string) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Format credit card number: 1234 5678 9012 3456
|
|
37
|
+
*/
|
|
38
|
+
declare const formatCreditCard: (value: string) => string;
|
|
39
|
+
/**
|
|
40
|
+
* Format date: MM/DD/YYYY
|
|
41
|
+
*/
|
|
42
|
+
declare const formatDate: (value: string) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Format datetime: MM/DD/YYYY HH:MM AM/PM
|
|
45
|
+
*/
|
|
46
|
+
declare const formatDateTime: (value: string) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Get raw value from formatted string
|
|
49
|
+
* - For phone/credit-card: returns digits only
|
|
50
|
+
* - For date: returns YYYY-MM-DD format (ISO 8601)
|
|
51
|
+
* - For datetime: returns ISO 8601 with timezone offset
|
|
52
|
+
*/
|
|
53
|
+
declare const getRawValue: (value: string, format?: FormatType) => string;
|
|
54
|
+
/**
|
|
55
|
+
* Apply format based on format type
|
|
56
|
+
*/
|
|
57
|
+
declare const applyFormat: (value: string, format: FormatType) => string;
|
|
58
|
+
|
|
23
59
|
interface FormState {
|
|
24
60
|
values: Record<string, any>;
|
|
25
61
|
errors: Record<string, string>;
|
|
@@ -62,6 +98,8 @@ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
|
|
62
98
|
onValidationError?: (error: string | undefined) => void;
|
|
63
99
|
/** Regex pattern for validation (string or RegExp) */
|
|
64
100
|
pattern?: RegExp | string;
|
|
101
|
+
/** Format type for auto-formatting input value (phone, credit-card, date, etc.) */
|
|
102
|
+
format?: FormatType | ((value: string) => string);
|
|
65
103
|
/** Custom error messages for built-in validations */
|
|
66
104
|
errorMessages?: {
|
|
67
105
|
required?: string;
|
|
@@ -72,6 +110,7 @@ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "
|
|
|
72
110
|
pattern?: string;
|
|
73
111
|
email?: string;
|
|
74
112
|
url?: string;
|
|
113
|
+
date?: string;
|
|
75
114
|
};
|
|
76
115
|
}
|
|
77
116
|
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -1107,4 +1146,45 @@ type ThemeId = keyof typeof themes;
|
|
|
1107
1146
|
|
|
1108
1147
|
declare function cn(...inputs: ClassValue[]): string;
|
|
1109
1148
|
|
|
1110
|
-
|
|
1149
|
+
/**
|
|
1150
|
+
* Validation constants and regex patterns
|
|
1151
|
+
*/
|
|
1152
|
+
/**
|
|
1153
|
+
* RFC 5322 compliant email validation regex (simplified)
|
|
1154
|
+
* Matches standard email formats like: user@example.com
|
|
1155
|
+
*/
|
|
1156
|
+
declare const EMAIL_REGEX: RegExp;
|
|
1157
|
+
/**
|
|
1158
|
+
* URL validation regex
|
|
1159
|
+
* Matches http(s) URLs
|
|
1160
|
+
*/
|
|
1161
|
+
declare const URL_REGEX: RegExp;
|
|
1162
|
+
/**
|
|
1163
|
+
* Phone number validation regex (US format)
|
|
1164
|
+
* Matches formats like: (123) 456-7890, 123-456-7890, 1234567890
|
|
1165
|
+
*/
|
|
1166
|
+
declare const PHONE_REGEX: RegExp;
|
|
1167
|
+
/**
|
|
1168
|
+
* Validate email format
|
|
1169
|
+
*/
|
|
1170
|
+
declare const isValidEmail: (email: string) => boolean;
|
|
1171
|
+
/**
|
|
1172
|
+
* Validate URL format
|
|
1173
|
+
*/
|
|
1174
|
+
declare const isValidUrl: (url: string) => boolean;
|
|
1175
|
+
/**
|
|
1176
|
+
* Date validation regex (MM/DD/YYYY)
|
|
1177
|
+
* Matches formats like: 12/31/2024, 01/01/2024
|
|
1178
|
+
*/
|
|
1179
|
+
declare const DATE_REGEX: RegExp;
|
|
1180
|
+
/**
|
|
1181
|
+
* Validate phone number format
|
|
1182
|
+
*/
|
|
1183
|
+
declare const isValidPhone: (phone: string) => boolean;
|
|
1184
|
+
/**
|
|
1185
|
+
* Validate date format and value
|
|
1186
|
+
* Checks if date is in MM/DD/YYYY format and is a valid calendar date
|
|
1187
|
+
*/
|
|
1188
|
+
declare const isValidDate: (date: string) => boolean;
|
|
1189
|
+
|
|
1190
|
+
export { Alert, Badge, Button, Card, CardActionArea, CardActions, CardContent, CardDescription, CardFooter, CardHeader, CardMedia, CardTitle, Checkbox, CheckboxGroup, CodeSnippet, Container, DATE_REGEX, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Divider, Drawer, type NavItem$1 as DrawerNavItem, type NavSection$1 as DrawerNavSection, type DrawerProps, EMAIL_REGEX, EmptyState, Form, type FormContextValue, FormControl, type FormControlContextValue, FormControlLabel, type FormControlProps, type FormControlState, type FormFieldProps, FormHelperText, type FormState, type FormatType, Input, NativeSelect, type NativeSelectProps, Nav, type NavItem$2 as NavItem, type NavProps, type NavSection, PHONE_REGEX, RadioGroup, Rating, SectionLayout, Select, type SelectOption, type SelectProps, SidebarNav, type NavItem as SidebarNavItem, Slider, type SliderMark, type SliderProps, Spinner, Switch, type SwitchProps, Textarea, type TextareaProps, type ThemeId, ThemeProvider, URL_REGEX, type ValidationFunction, type ValidationRule, applyFormat, cn, formatCreditCard, formatDate, formatDateTime, formatPhoneIntl, formatPhoneUS, getRawValue, isValidDate, isValidEmail, isValidPhone, isValidUrl, themes, useForm, useFormContext, useFormControl, useFormControlContext, useFormField, useTheme };
|