@justin_evo/evo-ui 1.2.0 → 1.2.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.
Files changed (77) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +70 -70
  3. package/dist/declarations.d.ts +6 -6
  4. package/package.json +52 -52
  5. package/src/Alert/Alert.tsx +49 -49
  6. package/src/AutoComplete/AutoComplete.tsx +810 -810
  7. package/src/Badge/Badge.tsx +53 -53
  8. package/src/Breadcrumb/Breadcrumb.tsx +53 -53
  9. package/src/Button/Button.tsx +125 -125
  10. package/src/Card/Card.tsx +257 -257
  11. package/src/Checkbox/Checkbox.tsx +59 -59
  12. package/src/CommandPalette/CommandPalette.tsx +185 -185
  13. package/src/Container/Container.tsx +31 -31
  14. package/src/Divider/Divider.tsx +31 -31
  15. package/src/Form/Form.tsx +185 -185
  16. package/src/Grid/Grid.tsx +66 -66
  17. package/src/ImageCropper/ImageCropper.tsx +911 -911
  18. package/src/Input/Input.tsx +74 -74
  19. package/src/Modal/Modal.tsx +77 -77
  20. package/src/Nav/Nav.tsx +708 -708
  21. package/src/Notification/Notification.tsx +1503 -1503
  22. package/src/Pagination/Pagination.tsx +76 -76
  23. package/src/Radio/Radio.tsx +69 -69
  24. package/src/RichTextArea/RichTextArea.tsx +886 -886
  25. package/src/Select/Select.tsx +515 -515
  26. package/src/Skeleton/Skeleton.tsx +70 -70
  27. package/src/Stack/Stack.tsx +52 -52
  28. package/src/Table/Table.tsx +335 -335
  29. package/src/Tabs/Tabs.tsx +90 -90
  30. package/src/Theme/ThemeProvider.tsx +253 -253
  31. package/src/Theme/ThemeToggle.tsx +79 -79
  32. package/src/Toggle/Toggle.tsx +48 -48
  33. package/src/Tooltip/Tooltip.tsx +38 -38
  34. package/src/TopNav/TopNav.tsx +1163 -1163
  35. package/src/TreeSelect/TreeSelect.tsx +825 -825
  36. package/src/css/alert.module.scss +93 -93
  37. package/src/css/autocomplete.module.scss +416 -416
  38. package/src/css/badge.module.scss +82 -82
  39. package/src/css/base/_color.scss +159 -159
  40. package/src/css/base/_theme.scss +237 -237
  41. package/src/css/base/_variables.scss +161 -161
  42. package/src/css/breadcrumb.module.scss +50 -50
  43. package/src/css/button.module.scss +385 -385
  44. package/src/css/card.module.scss +217 -217
  45. package/src/css/checkbox.module.scss +123 -123
  46. package/src/css/commandpalette.module.scss +211 -211
  47. package/src/css/container.module.scss +18 -18
  48. package/src/css/divider.module.scss +41 -41
  49. package/src/css/form.module.scss +245 -245
  50. package/src/css/imagecropper.module.scss +397 -397
  51. package/src/css/input.module.scss +89 -89
  52. package/src/css/modal.module.scss +105 -105
  53. package/src/css/nav.module.scss +494 -494
  54. package/src/css/notification.module.scss +691 -691
  55. package/src/css/pagination.module.scss +63 -63
  56. package/src/css/radio.module.scss +89 -89
  57. package/src/css/richtextarea.module.scss +307 -307
  58. package/src/css/select.module.scss +525 -525
  59. package/src/css/skeleton.module.scss +30 -30
  60. package/src/css/table.module.scss +386 -386
  61. package/src/css/tabs.module.scss +63 -63
  62. package/src/css/theme-toggle.module.scss +83 -83
  63. package/src/css/toggle.module.scss +54 -54
  64. package/src/css/tooltip.module.scss +97 -97
  65. package/src/css/topnav.module.scss +568 -568
  66. package/src/css/treeselect.module.scss +558 -558
  67. package/src/css/utilities/_borders.scss +111 -111
  68. package/src/css/utilities/_colors.scss +66 -66
  69. package/src/css/utilities/_effects.scss +216 -216
  70. package/src/css/utilities/_layout.scss +181 -181
  71. package/src/css/utilities/_position.scss +75 -75
  72. package/src/css/utilities/_sizing.scss +138 -138
  73. package/src/css/utilities/_spacing.scss +99 -99
  74. package/src/css/utilities/_typography.scss +121 -121
  75. package/src/css/utilities/index.scss +24 -24
  76. package/src/declarations.d.ts +6 -6
  77. package/src/index.ts +60 -60
package/src/Form/Form.tsx CHANGED
@@ -1,185 +1,185 @@
1
- import React, { createContext, useContext, useId } from 'react';
2
- import styles from '../css/form.module.scss';
3
-
4
- type FormSize = 'sm' | 'md' | 'lg';
5
- type FormLayout = 'vertical' | 'horizontal';
6
-
7
- interface FormContextType {
8
- disabled?: boolean;
9
- size?: FormSize;
10
- layout?: FormLayout;
11
- }
12
-
13
- const FormContext = createContext<FormContextType>({});
14
-
15
- export const useFormContext = () => useContext(FormContext);
16
-
17
- const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(' ');
18
-
19
- // ---------- Root ----------
20
- interface EvoFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
21
- children: React.ReactNode;
22
- disabled?: boolean;
23
- size?: FormSize;
24
- layout?: FormLayout;
25
- maxWidth?: number | string;
26
- className?: string;
27
- }
28
-
29
- export const EvoForm = ({
30
- children,
31
- disabled = false,
32
- size = 'md',
33
- layout = 'vertical',
34
- maxWidth,
35
- className = '',
36
- style,
37
- ...rest
38
- }: EvoFormProps) => (
39
- <FormContext.Provider value={{ disabled, size, layout }}>
40
- <form
41
- className={cx(styles.form, styles[`form_${size}`], styles[`form_${layout}`], className)}
42
- style={maxWidth !== undefined ? { maxWidth, ...style } : style}
43
- {...rest}
44
- >
45
- {children}
46
- </form>
47
- </FormContext.Provider>
48
- );
49
-
50
- // ---------- Header ----------
51
- interface EvoFormHeaderProps {
52
- title?: React.ReactNode;
53
- description?: React.ReactNode;
54
- badge?: React.ReactNode;
55
- children?: React.ReactNode;
56
- className?: string;
57
- }
58
-
59
- const EvoFormHeader = ({ title, description, badge, children, className = '' }: EvoFormHeaderProps) => (
60
- <header className={cx(styles.header, className)}>
61
- {badge && <div className={styles.headerBadge}>{badge}</div>}
62
- {title && <h2 className={styles.headerTitle}>{title}</h2>}
63
- {description && <p className={styles.headerDesc}>{description}</p>}
64
- {children}
65
- </header>
66
- );
67
-
68
- // ---------- Section ----------
69
- interface EvoFormSectionProps {
70
- title?: React.ReactNode;
71
- description?: React.ReactNode;
72
- variant?: 'stacked' | 'split';
73
- children: React.ReactNode;
74
- className?: string;
75
- }
76
-
77
- const EvoFormSection = ({
78
- title,
79
- description,
80
- variant = 'stacked',
81
- children,
82
- className = '',
83
- }: EvoFormSectionProps) => (
84
- <section className={cx(styles.section, styles[`section_${variant}`], className)}>
85
- {(title || description) && (
86
- <div className={styles.sectionHead}>
87
- {title && <h3 className={styles.sectionTitle}>{title}</h3>}
88
- {description && <p className={styles.sectionDesc}>{description}</p>}
89
- </div>
90
- )}
91
- <div className={styles.sectionBody}>{children}</div>
92
- </section>
93
- );
94
-
95
- // ---------- Row (side-by-side fields) ----------
96
- interface EvoFormRowProps {
97
- children: React.ReactNode;
98
- gap?: 'sm' | 'md' | 'lg';
99
- align?: 'start' | 'center' | 'end';
100
- className?: string;
101
- }
102
-
103
- const EvoFormRow = ({ children, gap = 'md', align = 'start', className = '' }: EvoFormRowProps) => (
104
- <div className={cx(styles.row, styles[`row_${gap}`], styles[`row_align_${align}`], className)}>
105
- {children}
106
- </div>
107
- );
108
-
109
- // ---------- Field ----------
110
- interface EvoFormFieldProps {
111
- children: React.ReactNode;
112
- label?: React.ReactNode;
113
- description?: React.ReactNode;
114
- error?: React.ReactNode;
115
- required?: boolean;
116
- htmlFor?: string;
117
- className?: string;
118
- }
119
-
120
- const EvoFormField = ({
121
- children,
122
- label,
123
- description,
124
- error,
125
- required,
126
- htmlFor,
127
- className = '',
128
- }: EvoFormFieldProps) => {
129
- const reactId = useId();
130
- const fieldId = htmlFor ?? `evo-field-${reactId}`;
131
- const hasMeta = label || description || error;
132
-
133
- if (!hasMeta) {
134
- return <div className={cx(styles.field, className)}>{children}</div>;
135
- }
136
-
137
- return (
138
- <div className={cx(styles.field, error ? styles.field_error : '', className)}>
139
- {label && (
140
- <label htmlFor={fieldId} className={styles.fieldLabel}>
141
- {label}
142
- {required && <span className={styles.fieldRequired} aria-hidden="true">*</span>}
143
- </label>
144
- )}
145
- <div className={styles.fieldControl}>{children}</div>
146
- {error ? (
147
- <p className={styles.fieldError} role="alert">{error}</p>
148
- ) : description ? (
149
- <p className={styles.fieldDesc}>{description}</p>
150
- ) : null}
151
- </div>
152
- );
153
- };
154
-
155
- // ---------- Actions (footer) ----------
156
- interface EvoFormActionsProps {
157
- children: React.ReactNode;
158
- align?: 'left' | 'right' | 'between' | 'center';
159
- divider?: boolean;
160
- className?: string;
161
- }
162
-
163
- const EvoFormActions = ({
164
- children,
165
- align = 'right',
166
- divider = true,
167
- className = '',
168
- }: EvoFormActionsProps) => (
169
- <div
170
- className={cx(
171
- styles.actions,
172
- styles[`actions_${align}`],
173
- divider ? styles.actions_divider : '',
174
- className,
175
- )}
176
- >
177
- {children}
178
- </div>
179
- );
180
-
181
- EvoForm.Header = EvoFormHeader;
182
- EvoForm.Section = EvoFormSection;
183
- EvoForm.Row = EvoFormRow;
184
- EvoForm.Field = EvoFormField;
185
- EvoForm.Actions = EvoFormActions;
1
+ import React, { createContext, useContext, useId } from 'react';
2
+ import styles from '../css/form.module.scss';
3
+
4
+ type FormSize = 'sm' | 'md' | 'lg';
5
+ type FormLayout = 'vertical' | 'horizontal';
6
+
7
+ interface FormContextType {
8
+ disabled?: boolean;
9
+ size?: FormSize;
10
+ layout?: FormLayout;
11
+ }
12
+
13
+ const FormContext = createContext<FormContextType>({});
14
+
15
+ export const useFormContext = () => useContext(FormContext);
16
+
17
+ const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(' ');
18
+
19
+ // ---------- Root ----------
20
+ interface EvoFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
21
+ children: React.ReactNode;
22
+ disabled?: boolean;
23
+ size?: FormSize;
24
+ layout?: FormLayout;
25
+ maxWidth?: number | string;
26
+ className?: string;
27
+ }
28
+
29
+ export const EvoForm = ({
30
+ children,
31
+ disabled = false,
32
+ size = 'md',
33
+ layout = 'vertical',
34
+ maxWidth,
35
+ className = '',
36
+ style,
37
+ ...rest
38
+ }: EvoFormProps) => (
39
+ <FormContext.Provider value={{ disabled, size, layout }}>
40
+ <form
41
+ className={cx(styles.form, styles[`form_${size}`], styles[`form_${layout}`], className)}
42
+ style={maxWidth !== undefined ? { maxWidth, ...style } : style}
43
+ {...rest}
44
+ >
45
+ {children}
46
+ </form>
47
+ </FormContext.Provider>
48
+ );
49
+
50
+ // ---------- Header ----------
51
+ interface EvoFormHeaderProps {
52
+ title?: React.ReactNode;
53
+ description?: React.ReactNode;
54
+ badge?: React.ReactNode;
55
+ children?: React.ReactNode;
56
+ className?: string;
57
+ }
58
+
59
+ const EvoFormHeader = ({ title, description, badge, children, className = '' }: EvoFormHeaderProps) => (
60
+ <header className={cx(styles.header, className)}>
61
+ {badge && <div className={styles.headerBadge}>{badge}</div>}
62
+ {title && <h2 className={styles.headerTitle}>{title}</h2>}
63
+ {description && <p className={styles.headerDesc}>{description}</p>}
64
+ {children}
65
+ </header>
66
+ );
67
+
68
+ // ---------- Section ----------
69
+ interface EvoFormSectionProps {
70
+ title?: React.ReactNode;
71
+ description?: React.ReactNode;
72
+ variant?: 'stacked' | 'split';
73
+ children: React.ReactNode;
74
+ className?: string;
75
+ }
76
+
77
+ const EvoFormSection = ({
78
+ title,
79
+ description,
80
+ variant = 'stacked',
81
+ children,
82
+ className = '',
83
+ }: EvoFormSectionProps) => (
84
+ <section className={cx(styles.section, styles[`section_${variant}`], className)}>
85
+ {(title || description) && (
86
+ <div className={styles.sectionHead}>
87
+ {title && <h3 className={styles.sectionTitle}>{title}</h3>}
88
+ {description && <p className={styles.sectionDesc}>{description}</p>}
89
+ </div>
90
+ )}
91
+ <div className={styles.sectionBody}>{children}</div>
92
+ </section>
93
+ );
94
+
95
+ // ---------- Row (side-by-side fields) ----------
96
+ interface EvoFormRowProps {
97
+ children: React.ReactNode;
98
+ gap?: 'sm' | 'md' | 'lg';
99
+ align?: 'start' | 'center' | 'end';
100
+ className?: string;
101
+ }
102
+
103
+ const EvoFormRow = ({ children, gap = 'md', align = 'start', className = '' }: EvoFormRowProps) => (
104
+ <div className={cx(styles.row, styles[`row_${gap}`], styles[`row_align_${align}`], className)}>
105
+ {children}
106
+ </div>
107
+ );
108
+
109
+ // ---------- Field ----------
110
+ interface EvoFormFieldProps {
111
+ children: React.ReactNode;
112
+ label?: React.ReactNode;
113
+ description?: React.ReactNode;
114
+ error?: React.ReactNode;
115
+ required?: boolean;
116
+ htmlFor?: string;
117
+ className?: string;
118
+ }
119
+
120
+ const EvoFormField = ({
121
+ children,
122
+ label,
123
+ description,
124
+ error,
125
+ required,
126
+ htmlFor,
127
+ className = '',
128
+ }: EvoFormFieldProps) => {
129
+ const reactId = useId();
130
+ const fieldId = htmlFor ?? `evo-field-${reactId}`;
131
+ const hasMeta = label || description || error;
132
+
133
+ if (!hasMeta) {
134
+ return <div className={cx(styles.field, className)}>{children}</div>;
135
+ }
136
+
137
+ return (
138
+ <div className={cx(styles.field, error ? styles.field_error : '', className)}>
139
+ {label && (
140
+ <label htmlFor={fieldId} className={styles.fieldLabel}>
141
+ {label}
142
+ {required && <span className={styles.fieldRequired} aria-hidden="true">*</span>}
143
+ </label>
144
+ )}
145
+ <div className={styles.fieldControl}>{children}</div>
146
+ {error ? (
147
+ <p className={styles.fieldError} role="alert">{error}</p>
148
+ ) : description ? (
149
+ <p className={styles.fieldDesc}>{description}</p>
150
+ ) : null}
151
+ </div>
152
+ );
153
+ };
154
+
155
+ // ---------- Actions (footer) ----------
156
+ interface EvoFormActionsProps {
157
+ children: React.ReactNode;
158
+ align?: 'left' | 'right' | 'between' | 'center';
159
+ divider?: boolean;
160
+ className?: string;
161
+ }
162
+
163
+ const EvoFormActions = ({
164
+ children,
165
+ align = 'right',
166
+ divider = true,
167
+ className = '',
168
+ }: EvoFormActionsProps) => (
169
+ <div
170
+ className={cx(
171
+ styles.actions,
172
+ styles[`actions_${align}`],
173
+ divider ? styles.actions_divider : '',
174
+ className,
175
+ )}
176
+ >
177
+ {children}
178
+ </div>
179
+ );
180
+
181
+ EvoForm.Header = EvoFormHeader;
182
+ EvoForm.Section = EvoFormSection;
183
+ EvoForm.Row = EvoFormRow;
184
+ EvoForm.Field = EvoFormField;
185
+ EvoForm.Actions = EvoFormActions;
package/src/Grid/Grid.tsx CHANGED
@@ -1,66 +1,66 @@
1
- import React, { CSSProperties } from 'react';
2
-
3
- interface EvoGridProps {
4
- children: React.ReactNode;
5
- cols?: number | string;
6
- rows?: number | string;
7
- gap?: number | string;
8
- colGap?: number | string;
9
- rowGap?: number | string;
10
- className?: string;
11
- style?: CSSProperties;
12
- }
13
-
14
- interface EvoGridItemProps {
15
- children: React.ReactNode;
16
- colSpan?: number;
17
- rowSpan?: number;
18
- className?: string;
19
- style?: CSSProperties;
20
- }
21
-
22
- const toSize = (v: number | string | undefined) =>
23
- v === undefined ? undefined : typeof v === 'number' ? `${v}px` : v;
24
-
25
- const EvoGridItem = ({ children, colSpan, rowSpan, className = '', style }: EvoGridItemProps) => (
26
- <div
27
- className={className}
28
- style={{
29
- gridColumn: colSpan ? `span ${colSpan}` : undefined,
30
- gridRow: rowSpan ? `span ${rowSpan}` : undefined,
31
- ...style,
32
- }}
33
- >
34
- {children}
35
- </div>
36
- );
37
-
38
- export const EvoGrid = ({
39
- children,
40
- cols = 3,
41
- rows,
42
- gap = '1rem',
43
- colGap,
44
- rowGap,
45
- className = '',
46
- style,
47
- }: EvoGridProps) => (
48
- <div
49
- className={className}
50
- style={{
51
- display: 'grid',
52
- gridTemplateColumns: typeof cols === 'number' ? `repeat(${cols}, 1fr)` : cols,
53
- gridTemplateRows: rows
54
- ? typeof rows === 'number' ? `repeat(${rows}, auto)` : rows
55
- : undefined,
56
- gap: toSize(gap),
57
- columnGap: toSize(colGap),
58
- rowGap: toSize(rowGap),
59
- ...style,
60
- }}
61
- >
62
- {children}
63
- </div>
64
- );
65
-
66
- EvoGrid.Item = EvoGridItem;
1
+ import React, { CSSProperties } from 'react';
2
+
3
+ interface EvoGridProps {
4
+ children: React.ReactNode;
5
+ cols?: number | string;
6
+ rows?: number | string;
7
+ gap?: number | string;
8
+ colGap?: number | string;
9
+ rowGap?: number | string;
10
+ className?: string;
11
+ style?: CSSProperties;
12
+ }
13
+
14
+ interface EvoGridItemProps {
15
+ children: React.ReactNode;
16
+ colSpan?: number;
17
+ rowSpan?: number;
18
+ className?: string;
19
+ style?: CSSProperties;
20
+ }
21
+
22
+ const toSize = (v: number | string | undefined) =>
23
+ v === undefined ? undefined : typeof v === 'number' ? `${v}px` : v;
24
+
25
+ const EvoGridItem = ({ children, colSpan, rowSpan, className = '', style }: EvoGridItemProps) => (
26
+ <div
27
+ className={className}
28
+ style={{
29
+ gridColumn: colSpan ? `span ${colSpan}` : undefined,
30
+ gridRow: rowSpan ? `span ${rowSpan}` : undefined,
31
+ ...style,
32
+ }}
33
+ >
34
+ {children}
35
+ </div>
36
+ );
37
+
38
+ export const EvoGrid = ({
39
+ children,
40
+ cols = 3,
41
+ rows,
42
+ gap = '1rem',
43
+ colGap,
44
+ rowGap,
45
+ className = '',
46
+ style,
47
+ }: EvoGridProps) => (
48
+ <div
49
+ className={className}
50
+ style={{
51
+ display: 'grid',
52
+ gridTemplateColumns: typeof cols === 'number' ? `repeat(${cols}, 1fr)` : cols,
53
+ gridTemplateRows: rows
54
+ ? typeof rows === 'number' ? `repeat(${rows}, auto)` : rows
55
+ : undefined,
56
+ gap: toSize(gap),
57
+ columnGap: toSize(colGap),
58
+ rowGap: toSize(rowGap),
59
+ ...style,
60
+ }}
61
+ >
62
+ {children}
63
+ </div>
64
+ );
65
+
66
+ EvoGrid.Item = EvoGridItem;