@true-tech-team/react-components 0.0.1
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 +586 -0
- package/index.css +1 -0
- package/index.d.ts +15 -0
- package/index.js +1 -0
- package/index.mjs +5224 -0
- package/lib/assets/icons/index.d.ts +105 -0
- package/lib/components/buttons/Button/Button.d.ts +49 -0
- package/lib/components/buttons/Button/index.d.ts +3 -0
- package/lib/components/buttons/IconButton/IconButton.d.ts +48 -0
- package/lib/components/buttons/IconButton/index.d.ts +3 -0
- package/lib/components/buttons/index.d.ts +2 -0
- package/lib/components/display/Icon/Icon.d.ts +43 -0
- package/lib/components/display/Icon/index.d.ts +3 -0
- package/lib/components/display/index.d.ts +1 -0
- package/lib/components/forms/FormBuilder/FormBuilder.d.ts +109 -0
- package/lib/components/forms/FormBuilder/hooks/index.d.ts +2 -0
- package/lib/components/forms/FormBuilder/hooks/useFormState.d.ts +5 -0
- package/lib/components/forms/FormBuilder/hooks/useFormValidation.d.ts +11 -0
- package/lib/components/forms/FormBuilder/index.d.ts +4 -0
- package/lib/components/forms/FormBuilder/types.d.ts +193 -0
- package/lib/components/forms/index.d.ts +1 -0
- package/lib/components/index.d.ts +50 -0
- package/lib/components/inputs/Autocomplete/Autocomplete.d.ts +109 -0
- package/lib/components/inputs/Autocomplete/index.d.ts +2 -0
- package/lib/components/inputs/Checkbox/Checkbox.d.ts +85 -0
- package/lib/components/inputs/Checkbox/index.d.ts +2 -0
- package/lib/components/inputs/ColorPicker/ColorPicker.d.ts +82 -0
- package/lib/components/inputs/ColorPicker/index.d.ts +2 -0
- package/lib/components/inputs/DatePicker/DatePicker.d.ts +81 -0
- package/lib/components/inputs/DatePicker/index.d.ts +2 -0
- package/lib/components/inputs/DateRangePicker/DateRangePicker.d.ts +115 -0
- package/lib/components/inputs/DateRangePicker/index.d.ts +2 -0
- package/lib/components/inputs/FilePicker/FilePicker.d.ts +101 -0
- package/lib/components/inputs/FilePicker/index.d.ts +2 -0
- package/lib/components/inputs/Input/Input.d.ts +171 -0
- package/lib/components/inputs/Input/index.d.ts +3 -0
- package/lib/components/inputs/NumberInput/NumberInput.d.ts +18 -0
- package/lib/components/inputs/NumberInput/index.d.ts +2 -0
- package/lib/components/inputs/PhoneInput/PhoneInput.d.ts +87 -0
- package/lib/components/inputs/PhoneInput/index.d.ts +2 -0
- package/lib/components/inputs/Radio/Radio.d.ts +45 -0
- package/lib/components/inputs/Radio/RadioGroup.d.ts +88 -0
- package/lib/components/inputs/Radio/index.d.ts +4 -0
- package/lib/components/inputs/Rating/Rating.d.ts +22 -0
- package/lib/components/inputs/Rating/index.d.ts +2 -0
- package/lib/components/inputs/Select/Select.d.ts +142 -0
- package/lib/components/inputs/Select/index.d.ts +2 -0
- package/lib/components/inputs/Slider/Slider.d.ts +29 -0
- package/lib/components/inputs/Slider/index.d.ts +2 -0
- package/lib/components/inputs/TagInput/TagInput.d.ts +101 -0
- package/lib/components/inputs/TagInput/index.d.ts +2 -0
- package/lib/components/inputs/Textarea/Textarea.d.ts +90 -0
- package/lib/components/inputs/Textarea/index.d.ts +2 -0
- package/lib/components/inputs/Toggle/Toggle.d.ts +69 -0
- package/lib/components/inputs/Toggle/index.d.ts +2 -0
- package/lib/components/inputs/index.d.ts +16 -0
- package/lib/components/overlays/Dropdown/Dropdown.d.ts +84 -0
- package/lib/components/overlays/Dropdown/index.d.ts +2 -0
- package/lib/components/overlays/Menu/Menu.d.ts +70 -0
- package/lib/components/overlays/Menu/MenuContext.d.ts +68 -0
- package/lib/components/overlays/Menu/MenuDivider.d.ts +10 -0
- package/lib/components/overlays/Menu/MenuGroup.d.ts +20 -0
- package/lib/components/overlays/Menu/MenuItem.d.ts +42 -0
- package/lib/components/overlays/Menu/MenuList.d.ts +16 -0
- package/lib/components/overlays/Menu/index.d.ts +12 -0
- package/lib/components/overlays/Popover/Popover.d.ts +74 -0
- package/lib/components/overlays/Popover/index.d.ts +2 -0
- package/lib/components/overlays/Portal/Portal.d.ts +24 -0
- package/lib/components/overlays/Portal/index.d.ts +2 -0
- package/lib/components/overlays/Tooltip/Tooltip.d.ts +51 -0
- package/lib/components/overlays/Tooltip/index.d.ts +2 -0
- package/lib/components/overlays/index.d.ts +5 -0
- package/lib/contexts/ThemeContext/ThemeContext.d.ts +40 -0
- package/lib/contexts/ThemeContext/index.d.ts +2 -0
- package/lib/contexts/index.d.ts +2 -0
- package/lib/decorators/ComponentDecorator/ComponentDecorator.d.ts +57 -0
- package/lib/decorators/ComponentDecorator/index.d.ts +3 -0
- package/lib/decorators/index.d.ts +2 -0
- package/lib/hooks/index.d.ts +11 -0
- package/lib/hooks/useClickOutside/index.d.ts +1 -0
- package/lib/hooks/useClickOutside/useClickOutside.d.ts +9 -0
- package/lib/hooks/useDebounce/index.d.ts +1 -0
- package/lib/hooks/useDebounce/useDebounce.d.ts +10 -0
- package/lib/hooks/useEscapeKey/index.d.ts +1 -0
- package/lib/hooks/useEscapeKey/useEscapeKey.d.ts +9 -0
- package/lib/hooks/useFocusTrap/index.d.ts +1 -0
- package/lib/hooks/useFocusTrap/useFocusTrap.d.ts +8 -0
- package/lib/hooks/useHover/index.d.ts +2 -0
- package/lib/hooks/useHover/useHover.d.ts +59 -0
- package/lib/hooks/usePopoverPosition/index.d.ts +2 -0
- package/lib/hooks/usePopoverPosition/usePopoverPosition.d.ts +58 -0
- package/lib/hooks/usePortal/index.d.ts +2 -0
- package/lib/hooks/usePortal/usePortal.d.ts +23 -0
- package/lib/hooks/useTheme/index.d.ts +1 -0
- package/lib/providers/GlobalProvider/GlobalProvider.d.ts +56 -0
- package/lib/providers/GlobalProvider/index.d.ts +3 -0
- package/lib/providers/index.d.ts +2 -0
- package/lib/types/component.types.d.ts +129 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/theme.types.d.ts +139 -0
- package/lib/utils/colorUtils.d.ts +71 -0
- package/lib/utils/dateUtils.d.ts +91 -0
- package/lib/utils/dom.d.ts +50 -0
- package/lib/utils/index.d.ts +5 -0
- package/lib/utils/positioning.d.ts +59 -0
- package/lib/utils/theme-utils.d.ts +105 -0
- package/lib/utils/validation.d.ts +120 -0
- package/package.json +55 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color family names available in the theme
|
|
3
|
+
*/
|
|
4
|
+
export type ColorFamily = 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'slate' | 'gray' | 'zinc' | 'neutral' | 'stone' | 'brown' | 'copper' | 'gold' | 'silver' | 'olive' | 'mint' | 'navy' | 'coral' | 'turquoise' | 'magenta';
|
|
5
|
+
/**
|
|
6
|
+
* Color shade levels (50-900)
|
|
7
|
+
*/
|
|
8
|
+
export type ColorShade = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
9
|
+
/**
|
|
10
|
+
* Semantic color roles in the theme
|
|
11
|
+
*/
|
|
12
|
+
export interface ThemeColorTokens {
|
|
13
|
+
primary: string;
|
|
14
|
+
primaryHover: string;
|
|
15
|
+
primaryActive: string;
|
|
16
|
+
primaryDisabled: string;
|
|
17
|
+
secondary: string;
|
|
18
|
+
secondaryHover: string;
|
|
19
|
+
secondaryActive: string;
|
|
20
|
+
secondaryDisabled: string;
|
|
21
|
+
success: string;
|
|
22
|
+
warning: string;
|
|
23
|
+
error: string;
|
|
24
|
+
info: string;
|
|
25
|
+
backgroundPrimary: string;
|
|
26
|
+
backgroundSecondary: string;
|
|
27
|
+
backgroundTertiary: string;
|
|
28
|
+
surfacePrimary: string;
|
|
29
|
+
surfaceSecondary: string;
|
|
30
|
+
surfaceElevated: string;
|
|
31
|
+
textPrimary: string;
|
|
32
|
+
textSecondary: string;
|
|
33
|
+
textTertiary: string;
|
|
34
|
+
textDisabled: string;
|
|
35
|
+
textOnPrimary: string;
|
|
36
|
+
borderPrimary: string;
|
|
37
|
+
borderSecondary: string;
|
|
38
|
+
borderFocus: string;
|
|
39
|
+
interactiveHover: string;
|
|
40
|
+
interactiveFocus: string;
|
|
41
|
+
interactiveActive: string;
|
|
42
|
+
interactiveDisabled: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Spacing values based on 4px grid
|
|
46
|
+
*/
|
|
47
|
+
export interface ThemeSpacing {
|
|
48
|
+
unit: number;
|
|
49
|
+
xs: string;
|
|
50
|
+
sm: string;
|
|
51
|
+
md: string;
|
|
52
|
+
lg: string;
|
|
53
|
+
xl: string;
|
|
54
|
+
xxl: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Typography scale
|
|
58
|
+
*/
|
|
59
|
+
export interface ThemeTypography {
|
|
60
|
+
fontFamily: {
|
|
61
|
+
primary: string;
|
|
62
|
+
secondary: string;
|
|
63
|
+
mono: string;
|
|
64
|
+
};
|
|
65
|
+
fontSize: {
|
|
66
|
+
xs: string;
|
|
67
|
+
sm: string;
|
|
68
|
+
base: string;
|
|
69
|
+
lg: string;
|
|
70
|
+
xl: string;
|
|
71
|
+
'2xl': string;
|
|
72
|
+
'3xl': string;
|
|
73
|
+
'4xl': string;
|
|
74
|
+
};
|
|
75
|
+
fontWeight: {
|
|
76
|
+
light: number;
|
|
77
|
+
normal: number;
|
|
78
|
+
medium: number;
|
|
79
|
+
semibold: number;
|
|
80
|
+
bold: number;
|
|
81
|
+
};
|
|
82
|
+
lineHeight: {
|
|
83
|
+
tight: number;
|
|
84
|
+
normal: number;
|
|
85
|
+
relaxed: number;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Border radius values
|
|
90
|
+
*/
|
|
91
|
+
export interface ThemeBorderRadius {
|
|
92
|
+
none: string;
|
|
93
|
+
sm: string;
|
|
94
|
+
md: string;
|
|
95
|
+
lg: string;
|
|
96
|
+
xl: string;
|
|
97
|
+
full: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Shadow definitions
|
|
101
|
+
*/
|
|
102
|
+
export interface ThemeShadows {
|
|
103
|
+
sm: string;
|
|
104
|
+
md: string;
|
|
105
|
+
lg: string;
|
|
106
|
+
xl: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Complete theme definition
|
|
110
|
+
*/
|
|
111
|
+
export interface Theme {
|
|
112
|
+
mode: 'light' | 'dark';
|
|
113
|
+
colors: ThemeColorTokens;
|
|
114
|
+
spacing: ThemeSpacing;
|
|
115
|
+
typography: ThemeTypography;
|
|
116
|
+
borderRadius: ThemeBorderRadius;
|
|
117
|
+
shadows: ThemeShadows;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Partial theme override for customization
|
|
121
|
+
*/
|
|
122
|
+
export type ThemeOverride = Partial<{
|
|
123
|
+
colors: Partial<ThemeColorTokens>;
|
|
124
|
+
spacing: Partial<ThemeSpacing>;
|
|
125
|
+
typography: Partial<ThemeTypography>;
|
|
126
|
+
borderRadius: Partial<ThemeBorderRadius>;
|
|
127
|
+
shadows: Partial<ThemeShadows>;
|
|
128
|
+
}>;
|
|
129
|
+
/**
|
|
130
|
+
* Theme configuration for GlobalProvider
|
|
131
|
+
*/
|
|
132
|
+
export interface ThemeConfig {
|
|
133
|
+
mode?: 'light' | 'dark';
|
|
134
|
+
theme?: ThemeOverride;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Theme mode type
|
|
138
|
+
*/
|
|
139
|
+
export type ThemeMode = 'light' | 'dark';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Color conversion utilities for ColorPicker component
|
|
3
|
+
*/
|
|
4
|
+
export interface RGB {
|
|
5
|
+
r: number;
|
|
6
|
+
g: number;
|
|
7
|
+
b: number;
|
|
8
|
+
}
|
|
9
|
+
export interface HSL {
|
|
10
|
+
h: number;
|
|
11
|
+
s: number;
|
|
12
|
+
l: number;
|
|
13
|
+
}
|
|
14
|
+
export interface RGBA extends RGB {
|
|
15
|
+
a: number;
|
|
16
|
+
}
|
|
17
|
+
export interface HSLA extends HSL {
|
|
18
|
+
a: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Convert HEX to RGB
|
|
22
|
+
*/
|
|
23
|
+
export declare const hexToRgb: (hex: string) => RGB | null;
|
|
24
|
+
/**
|
|
25
|
+
* Convert RGB to HEX
|
|
26
|
+
*/
|
|
27
|
+
export declare const rgbToHex: (rgb: RGB) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Convert RGB to HSL
|
|
30
|
+
*/
|
|
31
|
+
export declare const rgbToHsl: (rgb: RGB) => HSL;
|
|
32
|
+
/**
|
|
33
|
+
* Convert HSL to RGB
|
|
34
|
+
*/
|
|
35
|
+
export declare const hslToRgb: (hsl: HSL) => RGB;
|
|
36
|
+
/**
|
|
37
|
+
* Convert HEX to HSL
|
|
38
|
+
*/
|
|
39
|
+
export declare const hexToHsl: (hex: string) => HSL | null;
|
|
40
|
+
/**
|
|
41
|
+
* Convert HSL to HEX
|
|
42
|
+
*/
|
|
43
|
+
export declare const hslToHex: (hsl: HSL) => string;
|
|
44
|
+
/**
|
|
45
|
+
* Format RGB to CSS string
|
|
46
|
+
*/
|
|
47
|
+
export declare const rgbToString: (rgb: RGB | RGBA) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Format HSL to CSS string
|
|
50
|
+
*/
|
|
51
|
+
export declare const hslToString: (hsl: HSL | HSLA) => string;
|
|
52
|
+
/**
|
|
53
|
+
* Parse color string (hex, rgb, hsl) to RGB
|
|
54
|
+
*/
|
|
55
|
+
export declare const parseColorToRgb: (color: string) => RGB | null;
|
|
56
|
+
/**
|
|
57
|
+
* Validate hex color string
|
|
58
|
+
*/
|
|
59
|
+
export declare const isValidHex: (hex: string) => boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Clamp number between min and max
|
|
62
|
+
*/
|
|
63
|
+
export declare const clamp: (value: number, min: number, max: number) => number;
|
|
64
|
+
/**
|
|
65
|
+
* Get color brightness (0-255)
|
|
66
|
+
*/
|
|
67
|
+
export declare const getBrightness: (rgb: RGB) => number;
|
|
68
|
+
/**
|
|
69
|
+
* Determine if color is light or dark
|
|
70
|
+
*/
|
|
71
|
+
export declare const isLightColor: (rgb: RGB) => boolean;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date utilities for DatePicker and DateRangePicker components
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Get the number of days in a month
|
|
6
|
+
*/
|
|
7
|
+
export declare const getDaysInMonth: (year: number, month: number) => number;
|
|
8
|
+
/**
|
|
9
|
+
* Get the first day of the month (0 = Sunday, 6 = Saturday)
|
|
10
|
+
*/
|
|
11
|
+
export declare const getFirstDayOfMonth: (year: number, month: number) => number;
|
|
12
|
+
/**
|
|
13
|
+
* Get all days to display in calendar grid for a given month
|
|
14
|
+
* Includes previous/next month days to fill the grid
|
|
15
|
+
*/
|
|
16
|
+
export declare const getCalendarDays: (year: number, month: number) => Array<{
|
|
17
|
+
date: Date;
|
|
18
|
+
isCurrentMonth: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Check if two dates are the same day
|
|
22
|
+
*/
|
|
23
|
+
export declare const isSameDay: (date1: Date | null, date2: Date | null) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a date is today
|
|
26
|
+
*/
|
|
27
|
+
export declare const isToday: (date: Date) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a date is between two dates (inclusive)
|
|
30
|
+
*/
|
|
31
|
+
export declare const isDateInRange: (date: Date, startDate: Date | null, endDate: Date | null) => boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Check if a date is before another date
|
|
34
|
+
*/
|
|
35
|
+
export declare const isDateBefore: (date: Date, compareDate: Date) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Check if a date is after another date
|
|
38
|
+
*/
|
|
39
|
+
export declare const isDateAfter: (date: Date, compareDate: Date) => boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Format date to string
|
|
42
|
+
*/
|
|
43
|
+
export declare const formatDate: (date: Date | null, format?: string) => string;
|
|
44
|
+
/**
|
|
45
|
+
* Parse date string to Date object
|
|
46
|
+
*/
|
|
47
|
+
export declare const parseDate: (dateString: string, format?: string) => Date | null;
|
|
48
|
+
/**
|
|
49
|
+
* Get month name
|
|
50
|
+
*/
|
|
51
|
+
export declare const getMonthName: (month: number, short?: boolean) => string;
|
|
52
|
+
/**
|
|
53
|
+
* Get day name
|
|
54
|
+
*/
|
|
55
|
+
export declare const getDayName: (day: number, short?: boolean) => string;
|
|
56
|
+
/**
|
|
57
|
+
* Add months to a date
|
|
58
|
+
*/
|
|
59
|
+
export declare const addMonths: (date: Date, months: number) => Date;
|
|
60
|
+
/**
|
|
61
|
+
* Add days to a date
|
|
62
|
+
*/
|
|
63
|
+
export declare const addDays: (date: Date, days: number) => Date;
|
|
64
|
+
/**
|
|
65
|
+
* Get difference in days between two dates
|
|
66
|
+
*/
|
|
67
|
+
export declare const getDaysDifference: (date1: Date, date2: Date) => number;
|
|
68
|
+
/**
|
|
69
|
+
* Check if year is a leap year
|
|
70
|
+
*/
|
|
71
|
+
export declare const isLeapYear: (year: number) => boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Clamp date between min and max
|
|
74
|
+
*/
|
|
75
|
+
export declare const clampDate: (date: Date, minDate?: Date, maxDate?: Date) => Date;
|
|
76
|
+
/**
|
|
77
|
+
* Check if date is disabled based on constraints
|
|
78
|
+
*/
|
|
79
|
+
export declare const isDateDisabled: (date: Date, minDate?: Date, maxDate?: Date, disabledDates?: Date[]) => boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Get array of years for year selector
|
|
82
|
+
*/
|
|
83
|
+
export declare const getYearRange: (startYear?: number, endYear?: number) => number[];
|
|
84
|
+
/**
|
|
85
|
+
* Set time to start of day (00:00:00)
|
|
86
|
+
*/
|
|
87
|
+
export declare const startOfDay: (date: Date) => Date;
|
|
88
|
+
/**
|
|
89
|
+
* Set time to end of day (23:59:59)
|
|
90
|
+
*/
|
|
91
|
+
export declare const endOfDay: (date: Date) => Date;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM utility functions for element measurements and viewport calculations
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Element boundary information
|
|
6
|
+
*/
|
|
7
|
+
export interface ElementBounds {
|
|
8
|
+
top: number;
|
|
9
|
+
left: number;
|
|
10
|
+
right: number;
|
|
11
|
+
bottom: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Viewport size information
|
|
17
|
+
*/
|
|
18
|
+
export interface ViewportSize {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Scroll position information
|
|
24
|
+
*/
|
|
25
|
+
export interface ScrollPosition {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get the bounding rectangle of an element
|
|
31
|
+
* @param element - The HTML element to measure
|
|
32
|
+
* @returns Element bounds including position and dimensions
|
|
33
|
+
*/
|
|
34
|
+
export declare function getElementBounds(element: HTMLElement): ElementBounds;
|
|
35
|
+
/**
|
|
36
|
+
* Get the current viewport size
|
|
37
|
+
* @returns Viewport width and height
|
|
38
|
+
*/
|
|
39
|
+
export declare function getViewportSize(): ViewportSize;
|
|
40
|
+
/**
|
|
41
|
+
* Get the current scroll position
|
|
42
|
+
* @returns Scroll x and y coordinates
|
|
43
|
+
*/
|
|
44
|
+
export declare function getScrollPosition(): ScrollPosition;
|
|
45
|
+
/**
|
|
46
|
+
* Check if an element is within the viewport
|
|
47
|
+
* @param element - The HTML element to check
|
|
48
|
+
* @returns True if element is at least partially visible in viewport
|
|
49
|
+
*/
|
|
50
|
+
export declare function isElementInViewport(element: HTMLElement): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { getThemeValue, getColorValue, setThemeValue, applyThemeValues, pxToRem, gridSpacing, isDarkMode, getThemeMode, } from './theme-utils';
|
|
2
|
+
export { getElementBounds, getViewportSize, getScrollPosition, isElementInViewport, } from './dom';
|
|
3
|
+
export type { ElementBounds, ViewportSize, ScrollPosition } from './dom';
|
|
4
|
+
export { calculatePopoverPosition, findBestPosition, } from './positioning';
|
|
5
|
+
export type { PopoverPosition, PositionCoordinates, PositionOptions, PopoverSize, PopoverWidth, } from './positioning';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ElementBounds, ViewportSize } from './dom';
|
|
2
|
+
/**
|
|
3
|
+
* Supported popover positions relative to trigger element
|
|
4
|
+
*/
|
|
5
|
+
export type PopoverPosition = 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
|
|
6
|
+
/**
|
|
7
|
+
* Calculated position coordinates
|
|
8
|
+
*/
|
|
9
|
+
export interface PositionCoordinates {
|
|
10
|
+
top: number;
|
|
11
|
+
left: number;
|
|
12
|
+
actualPosition: PopoverPosition;
|
|
13
|
+
width?: number;
|
|
14
|
+
widthValue?: string | number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Width configuration options
|
|
18
|
+
* - 'trigger': Match trigger element width
|
|
19
|
+
* - 'auto': Use natural content width with no constraints
|
|
20
|
+
* - 'content': Use content width (fit-content)
|
|
21
|
+
* - 'max-content': Use maximum content width
|
|
22
|
+
* - number: Fixed width in pixels
|
|
23
|
+
*/
|
|
24
|
+
export type PopoverWidth = 'trigger' | 'auto' | 'content' | 'max-content' | number;
|
|
25
|
+
/**
|
|
26
|
+
* Options for position calculation
|
|
27
|
+
*/
|
|
28
|
+
export interface PositionOptions {
|
|
29
|
+
preferredPosition: PopoverPosition;
|
|
30
|
+
offset: number;
|
|
31
|
+
allowFlip: boolean;
|
|
32
|
+
width?: PopoverWidth;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Popover size information
|
|
36
|
+
*/
|
|
37
|
+
export interface PopoverSize {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Find the best position that minimizes viewport overflow
|
|
43
|
+
* @param triggerBounds - Trigger element boundaries
|
|
44
|
+
* @param popoverSize - Popover dimensions
|
|
45
|
+
* @param viewportSize - Viewport dimensions
|
|
46
|
+
* @param preferredPosition - Desired position
|
|
47
|
+
* @param offset - Gap between trigger and popover
|
|
48
|
+
* @returns Best position that fits in viewport
|
|
49
|
+
*/
|
|
50
|
+
export declare function findBestPosition(triggerBounds: ElementBounds, popoverSize: PopoverSize, viewportSize: ViewportSize, preferredPosition: PopoverPosition, offset: number): PopoverPosition;
|
|
51
|
+
/**
|
|
52
|
+
* Calculate popover position coordinates
|
|
53
|
+
* @param triggerBounds - Trigger element boundaries
|
|
54
|
+
* @param popoverSize - Popover dimensions
|
|
55
|
+
* @param viewportSize - Viewport dimensions
|
|
56
|
+
* @param options - Position calculation options
|
|
57
|
+
* @returns Position coordinates and actual position used
|
|
58
|
+
*/
|
|
59
|
+
export declare function calculatePopoverPosition(triggerBounds: ElementBounds, popoverSize: PopoverSize, viewportSize: ViewportSize, options: PositionOptions): PositionCoordinates;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ColorFamily, ColorShade } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get a CSS custom property value from the document
|
|
4
|
+
*
|
|
5
|
+
* @param propertyName - CSS variable name (with or without --)
|
|
6
|
+
* @returns The value of the CSS variable
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const primaryColor = getThemeValue('--theme-primary');
|
|
11
|
+
* const spacing = getThemeValue('spacing-md');
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare function getThemeValue(propertyName: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Get a color value from the color palette
|
|
17
|
+
*
|
|
18
|
+
* @param family - Color family name
|
|
19
|
+
* @param shade - Color shade (50-900)
|
|
20
|
+
* @returns The hex color value
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const blue500 = getColorValue('blue', 500);
|
|
25
|
+
* const red700 = getColorValue('red', 700);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function getColorValue(family: ColorFamily, shade: ColorShade): string;
|
|
29
|
+
/**
|
|
30
|
+
* Set a CSS custom property on the document root
|
|
31
|
+
*
|
|
32
|
+
* @param propertyName - CSS variable name (with or without --)
|
|
33
|
+
* @param value - Value to set
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* setThemeValue('--theme-primary', '#0066ff');
|
|
38
|
+
* setThemeValue('spacing-custom', '24px');
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function setThemeValue(propertyName: string, value: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Apply multiple theme values at once
|
|
44
|
+
*
|
|
45
|
+
* @param values - Object of CSS variable names and values
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* applyThemeValues({
|
|
50
|
+
* '--theme-primary': '#0066ff',
|
|
51
|
+
* '--theme-secondary': '#708090',
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function applyThemeValues(values: Record<string, string>): void;
|
|
56
|
+
/**
|
|
57
|
+
* Convert pixels to rem units
|
|
58
|
+
*
|
|
59
|
+
* @param pixels - Pixel value
|
|
60
|
+
* @param baseFontSize - Base font size in pixels (default: 16)
|
|
61
|
+
* @returns rem value as string
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const rem = pxToRem(24); // '1.5rem'
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function pxToRem(pixels: number, baseFontSize?: number): string;
|
|
69
|
+
/**
|
|
70
|
+
* Generate spacing value based on 4px grid
|
|
71
|
+
*
|
|
72
|
+
* @param units - Number of 4px units
|
|
73
|
+
* @returns Pixel value as string
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const spacing = gridSpacing(4); // '16px'
|
|
78
|
+
* const margin = gridSpacing(6); // '24px'
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function gridSpacing(units: number): string;
|
|
82
|
+
/**
|
|
83
|
+
* Check if current theme mode is dark
|
|
84
|
+
*
|
|
85
|
+
* @returns true if dark mode is active
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* if (isDarkMode()) {
|
|
90
|
+
* // Apply dark mode specific logic
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function isDarkMode(): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Get current theme mode
|
|
97
|
+
*
|
|
98
|
+
* @returns Current theme mode
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const mode = getThemeMode(); // 'light' | 'dark'
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function getThemeMode(): 'light' | 'dark';
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation utilities for form components
|
|
3
|
+
* Provides common validation functions and composition utilities
|
|
4
|
+
*/
|
|
5
|
+
export interface ValidationResult {
|
|
6
|
+
isValid: boolean;
|
|
7
|
+
errorMessage: string | null;
|
|
8
|
+
}
|
|
9
|
+
export type Validator = (value: any) => string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Common validators for form inputs
|
|
12
|
+
*/
|
|
13
|
+
export declare const validators: {
|
|
14
|
+
/**
|
|
15
|
+
* Validates that a value is not empty
|
|
16
|
+
* @param message Custom error message
|
|
17
|
+
*/
|
|
18
|
+
required: (message?: string) => Validator;
|
|
19
|
+
/**
|
|
20
|
+
* Validates email format
|
|
21
|
+
* @param message Custom error message
|
|
22
|
+
*/
|
|
23
|
+
email: (message?: string) => Validator;
|
|
24
|
+
/**
|
|
25
|
+
* Validates minimum string length
|
|
26
|
+
* @param min Minimum length
|
|
27
|
+
* @param message Custom error message
|
|
28
|
+
*/
|
|
29
|
+
minLength: (min: number, message?: string) => Validator;
|
|
30
|
+
/**
|
|
31
|
+
* Validates maximum string length
|
|
32
|
+
* @param max Maximum length
|
|
33
|
+
* @param message Custom error message
|
|
34
|
+
*/
|
|
35
|
+
maxLength: (max: number, message?: string) => Validator;
|
|
36
|
+
/**
|
|
37
|
+
* Validates against a regex pattern
|
|
38
|
+
* @param regex Regular expression pattern
|
|
39
|
+
* @param message Error message
|
|
40
|
+
*/
|
|
41
|
+
pattern: (regex: RegExp, message?: string) => Validator;
|
|
42
|
+
/**
|
|
43
|
+
* Validates minimum numeric value
|
|
44
|
+
* @param min Minimum value
|
|
45
|
+
* @param message Custom error message
|
|
46
|
+
*/
|
|
47
|
+
min: (min: number, message?: string) => Validator;
|
|
48
|
+
/**
|
|
49
|
+
* Validates maximum numeric value
|
|
50
|
+
* @param max Maximum value
|
|
51
|
+
* @param message Custom error message
|
|
52
|
+
*/
|
|
53
|
+
max: (max: number, message?: string) => Validator;
|
|
54
|
+
/**
|
|
55
|
+
* Validates numeric range
|
|
56
|
+
* @param min Minimum value
|
|
57
|
+
* @param max Maximum value
|
|
58
|
+
* @param message Custom error message
|
|
59
|
+
*/
|
|
60
|
+
range: (min: number, max: number, message?: string) => Validator;
|
|
61
|
+
/**
|
|
62
|
+
* Validates URL format
|
|
63
|
+
* @param message Custom error message
|
|
64
|
+
*/
|
|
65
|
+
url: (message?: string) => Validator;
|
|
66
|
+
/**
|
|
67
|
+
* Validates phone number format (basic)
|
|
68
|
+
* @param message Custom error message
|
|
69
|
+
*/
|
|
70
|
+
phone: (message?: string) => Validator;
|
|
71
|
+
/**
|
|
72
|
+
* Validates that value matches another field
|
|
73
|
+
* @param otherValue Value to match against
|
|
74
|
+
* @param message Custom error message
|
|
75
|
+
*/
|
|
76
|
+
matches: (otherValue: any, message?: string) => Validator;
|
|
77
|
+
/**
|
|
78
|
+
* Validates file size
|
|
79
|
+
* @param maxSize Maximum size in bytes
|
|
80
|
+
* @param message Custom error message
|
|
81
|
+
*/
|
|
82
|
+
fileSize: (maxSize: number, message?: string) => Validator;
|
|
83
|
+
/**
|
|
84
|
+
* Validates file type
|
|
85
|
+
* @param allowedTypes Array of allowed MIME types or extensions
|
|
86
|
+
* @param message Custom error message
|
|
87
|
+
*/
|
|
88
|
+
fileType: (allowedTypes: string[], message?: string) => Validator;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Combines multiple validators into a single validator
|
|
92
|
+
* Returns the first error encountered
|
|
93
|
+
* @param validators Array of validator functions
|
|
94
|
+
*/
|
|
95
|
+
export declare const combineValidators: (...validators: Validator[]) => Validator;
|
|
96
|
+
/**
|
|
97
|
+
* Validates a value against a single validator or array of validators
|
|
98
|
+
* @param value Value to validate
|
|
99
|
+
* @param validator Single validator or array of validators
|
|
100
|
+
* @returns ValidationResult object
|
|
101
|
+
*/
|
|
102
|
+
export declare const validate: (value: any, validator: Validator | Validator[]) => ValidationResult;
|
|
103
|
+
/**
|
|
104
|
+
* Validates multiple fields
|
|
105
|
+
* @param values Object with field values
|
|
106
|
+
* @param validators Object with field validators
|
|
107
|
+
* @returns Object with validation results
|
|
108
|
+
*/
|
|
109
|
+
export declare const validateForm: (values: Record<string, any>, validators: Record<string, Validator | Validator[]>) => Record<string, ValidationResult>;
|
|
110
|
+
/**
|
|
111
|
+
* Checks if all validation results are valid
|
|
112
|
+
* @param results Validation results object
|
|
113
|
+
*/
|
|
114
|
+
export declare const isFormValid: (results: Record<string, ValidationResult>) => boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Extracts error messages from validation results
|
|
117
|
+
* @param results Validation results object
|
|
118
|
+
* @returns Object with error messages (only for invalid fields)
|
|
119
|
+
*/
|
|
120
|
+
export declare const getErrorMessages: (results: Record<string, ValidationResult>) => Record<string, string>;
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@true-tech-team/react-components",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "React TypeScript component library",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"import": "./index.mjs",
|
|
11
|
+
"require": "./index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "nx build ui-components",
|
|
16
|
+
"test": "nx test ui-components",
|
|
17
|
+
"test:watch": "nx test ui-components --watch",
|
|
18
|
+
"test:coverage": "nx test ui-components --coverage",
|
|
19
|
+
"lint": "nx lint ui-components",
|
|
20
|
+
"lint:fix": "nx lint ui-components --fix",
|
|
21
|
+
"storybook": "nx storybook ui-components",
|
|
22
|
+
"storybook:build": "nx build-storybook ui-components",
|
|
23
|
+
"typecheck": "tsc --noEmit -p tsconfig.lib.json"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": ">=18.0.0",
|
|
27
|
+
"react-dom": ">=18.0.0"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"index.js",
|
|
31
|
+
"index.mjs",
|
|
32
|
+
"index.d.ts",
|
|
33
|
+
"**/*.js",
|
|
34
|
+
"**/*.mjs",
|
|
35
|
+
"**/*.d.ts",
|
|
36
|
+
"**/*.css",
|
|
37
|
+
"**/*.scss"
|
|
38
|
+
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"directory": "libs/ui-components"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"react",
|
|
48
|
+
"components",
|
|
49
|
+
"typescript",
|
|
50
|
+
"ui",
|
|
51
|
+
"library"
|
|
52
|
+
],
|
|
53
|
+
"license": "MIT"
|
|
54
|
+
}
|
|
55
|
+
|