@justin_evo/evo-ui 1.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.
Files changed (110) hide show
  1. package/dist/Alert/Alert.d.ts +11 -0
  2. package/dist/AutoComplete/AutoComplete.d.ts +95 -0
  3. package/dist/Badge/Badge.d.ts +23 -0
  4. package/dist/Breadcrumb/Breadcrumb.d.ts +16 -0
  5. package/dist/Button/Button.d.ts +54 -0
  6. package/dist/Card/Card.d.ts +60 -0
  7. package/dist/Checkbox/Checkbox.d.ts +16 -0
  8. package/dist/CommandPalette/CommandPalette.d.ts +17 -0
  9. package/dist/Container/Container.d.ts +10 -0
  10. package/dist/Divider/Divider.d.ts +7 -0
  11. package/dist/Form/Form.d.ts +61 -0
  12. package/dist/Grid/Grid.d.ts +23 -0
  13. package/dist/ImageCropper/ImageCropper.d.ts +111 -0
  14. package/dist/Input/Input.d.ts +12 -0
  15. package/dist/Modal/Modal.d.ts +26 -0
  16. package/dist/Nav/Nav.d.ts +63 -0
  17. package/dist/Notification/Notification.d.ts +186 -0
  18. package/dist/Pagination/Pagination.d.ts +10 -0
  19. package/dist/Radio/Radio.d.ts +20 -0
  20. package/dist/RichTextArea/RichTextArea.d.ts +70 -0
  21. package/dist/Select/Select.d.ts +44 -0
  22. package/dist/Skeleton/Skeleton.d.ts +23 -0
  23. package/dist/Stack/Stack.d.ts +16 -0
  24. package/dist/Table/Table.d.ts +77 -0
  25. package/dist/Tabs/Tabs.d.ts +28 -0
  26. package/dist/Theme/ThemeProvider.d.ts +96 -0
  27. package/dist/Theme/ThemeToggle.d.ts +22 -0
  28. package/dist/Toggle/Toggle.d.ts +11 -0
  29. package/dist/Tooltip/Tooltip.d.ts +10 -0
  30. package/dist/TopNav/TopNav.d.ts +76 -0
  31. package/dist/TreeSelect/TreeSelect.d.ts +50 -0
  32. package/dist/declarations.d.ts +6 -0
  33. package/dist/evo-ui.css +1 -0
  34. package/dist/index.cjs.js +1 -0
  35. package/dist/index.d.ts +31 -0
  36. package/dist/index.es.js +5688 -0
  37. package/package.json +52 -0
  38. package/src/Alert/Alert.tsx +49 -0
  39. package/src/AutoComplete/AutoComplete.tsx +810 -0
  40. package/src/Badge/Badge.tsx +53 -0
  41. package/src/Breadcrumb/Breadcrumb.tsx +53 -0
  42. package/src/Button/Button.tsx +125 -0
  43. package/src/Card/Card.tsx +257 -0
  44. package/src/Checkbox/Checkbox.tsx +59 -0
  45. package/src/CommandPalette/CommandPalette.tsx +185 -0
  46. package/src/Container/Container.tsx +31 -0
  47. package/src/Divider/Divider.tsx +31 -0
  48. package/src/Form/Form.tsx +185 -0
  49. package/src/Grid/Grid.tsx +66 -0
  50. package/src/ImageCropper/ImageCropper.tsx +911 -0
  51. package/src/Input/Input.tsx +74 -0
  52. package/src/Modal/Modal.tsx +77 -0
  53. package/src/Nav/Nav.tsx +626 -0
  54. package/src/Notification/Notification.tsx +1503 -0
  55. package/src/Pagination/Pagination.tsx +76 -0
  56. package/src/Radio/Radio.tsx +69 -0
  57. package/src/RichTextArea/RichTextArea.tsx +869 -0
  58. package/src/Select/Select.tsx +515 -0
  59. package/src/Skeleton/Skeleton.tsx +70 -0
  60. package/src/Stack/Stack.tsx +52 -0
  61. package/src/Table/Table.tsx +335 -0
  62. package/src/Tabs/Tabs.tsx +90 -0
  63. package/src/Theme/ThemeProvider.tsx +253 -0
  64. package/src/Theme/ThemeToggle.tsx +79 -0
  65. package/src/Toggle/Toggle.tsx +48 -0
  66. package/src/Tooltip/Tooltip.tsx +38 -0
  67. package/src/TopNav/TopNav.tsx +994 -0
  68. package/src/TreeSelect/TreeSelect.tsx +825 -0
  69. package/src/css/alert.module.scss +93 -0
  70. package/src/css/autocomplete.module.scss +416 -0
  71. package/src/css/badge.module.scss +82 -0
  72. package/src/css/base/_color.scss +159 -0
  73. package/src/css/base/_theme.scss +237 -0
  74. package/src/css/base/_variables.scss +161 -0
  75. package/src/css/breadcrumb.module.scss +50 -0
  76. package/src/css/button.module.scss +385 -0
  77. package/src/css/card.module.scss +217 -0
  78. package/src/css/checkbox.module.scss +120 -0
  79. package/src/css/commandpalette.module.scss +211 -0
  80. package/src/css/container.module.scss +18 -0
  81. package/src/css/divider.module.scss +41 -0
  82. package/src/css/form.module.scss +245 -0
  83. package/src/css/imagecropper.module.scss +397 -0
  84. package/src/css/input.module.scss +89 -0
  85. package/src/css/modal.module.scss +105 -0
  86. package/src/css/nav.module.scss +339 -0
  87. package/src/css/notification.module.scss +691 -0
  88. package/src/css/pagination.module.scss +63 -0
  89. package/src/css/radio.module.scss +89 -0
  90. package/src/css/richtextarea.module.scss +307 -0
  91. package/src/css/select.module.scss +525 -0
  92. package/src/css/skeleton.module.scss +30 -0
  93. package/src/css/table.module.scss +386 -0
  94. package/src/css/tabs.module.scss +63 -0
  95. package/src/css/theme-toggle.module.scss +83 -0
  96. package/src/css/toggle.module.scss +54 -0
  97. package/src/css/tooltip.module.scss +97 -0
  98. package/src/css/topnav.module.scss +396 -0
  99. package/src/css/treeselect.module.scss +558 -0
  100. package/src/css/utilities/_borders.scss +111 -0
  101. package/src/css/utilities/_colors.scss +66 -0
  102. package/src/css/utilities/_effects.scss +216 -0
  103. package/src/css/utilities/_layout.scss +181 -0
  104. package/src/css/utilities/_position.scss +75 -0
  105. package/src/css/utilities/_sizing.scss +138 -0
  106. package/src/css/utilities/_spacing.scss +99 -0
  107. package/src/css/utilities/_typography.scss +121 -0
  108. package/src/css/utilities/index.scss +24 -0
  109. package/src/declarations.d.ts +6 -0
  110. package/src/index.ts +60 -0
@@ -0,0 +1,515 @@
1
+ import React, { useCallback, useEffect, useId, useRef, useState } from 'react';
2
+ import styles from '../css/select.module.scss';
3
+
4
+ export interface SelectOption {
5
+ value: string;
6
+ label: string;
7
+ description?: string;
8
+ icon?: React.ReactNode;
9
+ disabled?: boolean;
10
+ }
11
+
12
+ interface EvoSelectBaseProps {
13
+ label?: string;
14
+ options: SelectOption[];
15
+ placeholder?: string;
16
+ helperText?: string;
17
+ error?: string;
18
+ size?: 'sm' | 'md' | 'lg';
19
+ fullWidth?: boolean;
20
+ disabled?: boolean;
21
+ searchable?: boolean;
22
+ clearable?: boolean;
23
+ id?: string;
24
+ name?: string;
25
+ className?: string;
26
+ }
27
+
28
+ export interface EvoSelectSingleProps extends EvoSelectBaseProps {
29
+ multiple?: false;
30
+ value?: string;
31
+ defaultValue?: string;
32
+ onChange?: (value: string) => void;
33
+ }
34
+
35
+ export interface EvoSelectMultipleProps extends EvoSelectBaseProps {
36
+ multiple: true;
37
+ value?: string[];
38
+ defaultValue?: string[];
39
+ onChange?: (value: string[]) => void;
40
+ /** How the trigger displays selected items. Defaults to 'chips'. */
41
+ multipleDisplay?: 'chips' | 'count';
42
+ /** Maximum number of options that can be selected at once. */
43
+ maxSelections?: number;
44
+ /** Show Select-all / Clear-all buttons at the top of the menu. */
45
+ showSelectAll?: boolean;
46
+ }
47
+
48
+ export type EvoSelectProps = EvoSelectSingleProps | EvoSelectMultipleProps;
49
+
50
+ const ChevronIcon = () => (
51
+ <svg viewBox="0 0 16 16" width="14" height="14" fill="none" aria-hidden="true">
52
+ <path d="M4 6l4 4 4-4" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" />
53
+ </svg>
54
+ );
55
+
56
+ const CheckIcon = () => (
57
+ <svg viewBox="0 0 16 16" width="14" height="14" fill="none" aria-hidden="true">
58
+ <path d="M3.5 8.5l3 3 6-7" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" strokeLinejoin="round" />
59
+ </svg>
60
+ );
61
+
62
+ const ClearIcon = () => (
63
+ <svg viewBox="0 0 16 16" width="12" height="12" fill="none" aria-hidden="true">
64
+ <path d="M4 4l8 8M12 4l-8 8" stroke="currentColor" strokeWidth="1.75" strokeLinecap="round" />
65
+ </svg>
66
+ );
67
+
68
+ const SearchIcon = () => (
69
+ <svg viewBox="0 0 16 16" width="14" height="14" fill="none" aria-hidden="true">
70
+ <circle cx="7" cy="7" r="4.5" stroke="currentColor" strokeWidth="1.5" />
71
+ <path d="M10.5 10.5L13 13" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
72
+ </svg>
73
+ );
74
+
75
+ export const EvoSelect = (props: EvoSelectProps) => {
76
+ const {
77
+ label,
78
+ options,
79
+ placeholder = 'Select an option',
80
+ helperText,
81
+ error,
82
+ size = 'md',
83
+ fullWidth = false,
84
+ disabled = false,
85
+ searchable = false,
86
+ clearable = false,
87
+ id,
88
+ name,
89
+ className = '',
90
+ } = props;
91
+
92
+ const isMultiple = props.multiple === true;
93
+ const multipleDisplay = isMultiple ? (props.multipleDisplay ?? 'chips') : 'chips';
94
+ const maxSelections = isMultiple ? props.maxSelections : undefined;
95
+ const showSelectAll = isMultiple ? (props.showSelectAll ?? false) : false;
96
+
97
+ const reactId = useId();
98
+ const selectId = id ?? `evo-select-${reactId}`;
99
+ const listId = `${selectId}-listbox`;
100
+
101
+ const controlledValue = props.value as string | string[] | undefined;
102
+ const defaultValue = props.defaultValue as string | string[] | undefined;
103
+
104
+ const isControlled = controlledValue !== undefined;
105
+ const initial: string | string[] = isMultiple
106
+ ? (Array.isArray(defaultValue) ? defaultValue : [])
107
+ : (typeof defaultValue === 'string' ? defaultValue : '');
108
+ const [internalValue, setInternalValue] = useState<string | string[]>(initial);
109
+ const value = isControlled ? controlledValue! : internalValue;
110
+
111
+ const selectedValues: string[] = isMultiple
112
+ ? (Array.isArray(value) ? value : [])
113
+ : (typeof value === 'string' && value ? [value] : []);
114
+
115
+ const [open, setOpen] = useState(false);
116
+ const [activeIdx, setActiveIdx] = useState(-1);
117
+ const [query, setQuery] = useState('');
118
+
119
+ const wrapperRef = useRef<HTMLDivElement>(null);
120
+ const triggerRef = useRef<HTMLButtonElement>(null);
121
+ const searchRef = useRef<HTMLInputElement>(null);
122
+ const listRef = useRef<HTMLDivElement>(null);
123
+
124
+ const filtered = searchable && query
125
+ ? options.filter(o => o.label.toLowerCase().includes(query.toLowerCase()))
126
+ : options;
127
+
128
+ const selectedOption = !isMultiple
129
+ ? options.find(o => o.value === value)
130
+ : undefined;
131
+
132
+ const selectedOptions = isMultiple
133
+ ? options.filter(o => selectedValues.includes(o.value))
134
+ : [];
135
+
136
+ const atMax = isMultiple && maxSelections !== undefined && selectedValues.length >= maxSelections;
137
+
138
+ const emit = useCallback((next: string | string[]) => {
139
+ if (!isControlled) setInternalValue(next);
140
+ if (isMultiple) {
141
+ (props.onChange as ((v: string[]) => void) | undefined)?.(next as string[]);
142
+ } else {
143
+ (props.onChange as ((v: string) => void) | undefined)?.(next as string);
144
+ }
145
+ }, [isControlled, isMultiple, props.onChange]);
146
+
147
+ const toggleValue = useCallback((v: string) => {
148
+ if (isMultiple) {
149
+ const current = Array.isArray(value) ? value : [];
150
+ if (current.includes(v)) {
151
+ emit(current.filter(x => x !== v));
152
+ } else {
153
+ if (maxSelections !== undefined && current.length >= maxSelections) return;
154
+ emit([...current, v]);
155
+ }
156
+ } else {
157
+ emit(v);
158
+ }
159
+ }, [emit, isMultiple, maxSelections, value]);
160
+
161
+ useEffect(() => {
162
+ if (!open) return;
163
+ const handler = (e: MouseEvent) => {
164
+ if (!wrapperRef.current?.contains(e.target as Node)) {
165
+ setOpen(false);
166
+ setQuery('');
167
+ }
168
+ };
169
+ document.addEventListener('mousedown', handler);
170
+ return () => document.removeEventListener('mousedown', handler);
171
+ }, [open]);
172
+
173
+ useEffect(() => {
174
+ if (open) {
175
+ const firstSelectedIdx = filtered.findIndex(o => selectedValues.includes(o.value));
176
+ setActiveIdx(firstSelectedIdx >= 0 ? firstSelectedIdx : filtered.findIndex(o => !o.disabled));
177
+ if (searchable) {
178
+ const t = setTimeout(() => searchRef.current?.focus(), 30);
179
+ return () => clearTimeout(t);
180
+ }
181
+ } else {
182
+ setQuery('');
183
+ setActiveIdx(-1);
184
+ }
185
+ }, [open]); // eslint-disable-line react-hooks/exhaustive-deps
186
+
187
+ useEffect(() => {
188
+ if (!open || activeIdx < 0) return;
189
+ const el = listRef.current?.querySelector(`[data-idx="${activeIdx}"]`) as HTMLElement | null;
190
+ el?.scrollIntoView({ block: 'nearest' });
191
+ }, [activeIdx, open]);
192
+
193
+ const moveActive = (dir: 1 | -1) => {
194
+ if (filtered.length === 0) return;
195
+ let next = activeIdx;
196
+ for (let i = 0; i < filtered.length; i++) {
197
+ next = (next + dir + filtered.length) % filtered.length;
198
+ if (!filtered[next].disabled) {
199
+ setActiveIdx(next);
200
+ return;
201
+ }
202
+ }
203
+ };
204
+
205
+ const handleKeyDown = (e: React.KeyboardEvent) => {
206
+ if (disabled) return;
207
+
208
+ if (!open) {
209
+ if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown' || e.key === 'ArrowUp') {
210
+ e.preventDefault();
211
+ setOpen(true);
212
+ }
213
+ return;
214
+ }
215
+
216
+ if (e.key === 'Escape') {
217
+ e.preventDefault();
218
+ setOpen(false);
219
+ triggerRef.current?.focus();
220
+ } else if (e.key === 'ArrowDown') {
221
+ e.preventDefault();
222
+ moveActive(1);
223
+ } else if (e.key === 'ArrowUp') {
224
+ e.preventDefault();
225
+ moveActive(-1);
226
+ } else if (e.key === 'Enter') {
227
+ e.preventDefault();
228
+ const opt = filtered[activeIdx];
229
+ if (opt && !opt.disabled) {
230
+ const isSelected = selectedValues.includes(opt.value);
231
+ if (!isSelected && atMax) return;
232
+ toggleValue(opt.value);
233
+ if (!isMultiple) {
234
+ setOpen(false);
235
+ triggerRef.current?.focus();
236
+ }
237
+ }
238
+ } else if (e.key === 'Home') {
239
+ e.preventDefault();
240
+ const idx = filtered.findIndex(o => !o.disabled);
241
+ if (idx >= 0) setActiveIdx(idx);
242
+ } else if (e.key === 'End') {
243
+ e.preventDefault();
244
+ for (let i = filtered.length - 1; i >= 0; i--) {
245
+ if (!filtered[i].disabled) { setActiveIdx(i); break; }
246
+ }
247
+ } else if (e.key === 'Tab') {
248
+ setOpen(false);
249
+ }
250
+ };
251
+
252
+ const handleSelect = (opt: SelectOption) => {
253
+ if (opt.disabled) return;
254
+ const isSelected = selectedValues.includes(opt.value);
255
+ if (!isSelected && atMax) return;
256
+ toggleValue(opt.value);
257
+ if (!isMultiple) {
258
+ setOpen(false);
259
+ triggerRef.current?.focus();
260
+ }
261
+ };
262
+
263
+ const handleClearAll = (e: React.MouseEvent) => {
264
+ e.stopPropagation();
265
+ if (isMultiple) emit([]);
266
+ else emit('');
267
+ };
268
+
269
+ const handleRemoveChip = (e: React.MouseEvent, v: string) => {
270
+ e.stopPropagation();
271
+ if (!isMultiple) return;
272
+ const current = Array.isArray(value) ? value : [];
273
+ emit(current.filter(x => x !== v));
274
+ };
275
+
276
+ const handleSelectAll = () => {
277
+ if (!isMultiple) return;
278
+ const selectable = filtered.filter(o => !o.disabled).map(o => o.value);
279
+ const merged = Array.from(new Set([...(Array.isArray(value) ? value : []), ...selectable]));
280
+ const limited = maxSelections !== undefined ? merged.slice(0, maxSelections) : merged;
281
+ emit(limited);
282
+ };
283
+
284
+ const hasSelection = isMultiple ? selectedValues.length > 0 : !!value;
285
+
286
+ const renderTriggerContent = () => {
287
+ if (!hasSelection) {
288
+ return (
289
+ <span className={styles.triggerPlaceholder}>
290
+ <span className={styles.triggerText}>{placeholder}</span>
291
+ </span>
292
+ );
293
+ }
294
+
295
+ if (!isMultiple) {
296
+ return (
297
+ <span className={styles.triggerValue}>
298
+ {selectedOption?.icon && (
299
+ <span className={styles.triggerIcon}>{selectedOption.icon}</span>
300
+ )}
301
+ <span className={styles.triggerText}>{selectedOption?.label}</span>
302
+ </span>
303
+ );
304
+ }
305
+
306
+ if (multipleDisplay === 'count') {
307
+ const first = selectedOptions[0]?.label ?? '';
308
+ const more = selectedOptions.length - 1;
309
+ return (
310
+ <span className={styles.triggerValue}>
311
+ <span className={styles.triggerText}>
312
+ {first}{more > 0 && <span className={styles.countMore}>, +{more} more</span>}
313
+ </span>
314
+ </span>
315
+ );
316
+ }
317
+
318
+ return (
319
+ <span className={styles.chipRow}>
320
+ {selectedOptions.map(opt => (
321
+ <span key={opt.value} className={styles.chip}>
322
+ {opt.icon && <span className={styles.chipIcon}>{opt.icon}</span>}
323
+ <span className={styles.chipLabel}>{opt.label}</span>
324
+ {!disabled && (
325
+ <span
326
+ role="button"
327
+ tabIndex={-1}
328
+ aria-label={`Remove ${opt.label}`}
329
+ className={styles.chipRemove}
330
+ onClick={(e) => handleRemoveChip(e, opt.value)}
331
+ onMouseDown={(e) => e.preventDefault()}
332
+ >
333
+ <ClearIcon />
334
+ </span>
335
+ )}
336
+ </span>
337
+ ))}
338
+ </span>
339
+ );
340
+ };
341
+
342
+ return (
343
+ <div
344
+ ref={wrapperRef}
345
+ className={[
346
+ styles.field,
347
+ fullWidth ? styles.fullWidth : '',
348
+ disabled ? styles.disabled : '',
349
+ className,
350
+ ].filter(Boolean).join(' ')}
351
+ >
352
+ {label && (
353
+ <label htmlFor={selectId} className={styles.label}>
354
+ {label}
355
+ </label>
356
+ )}
357
+
358
+ <div className={styles.selectWrapper}>
359
+ <button
360
+ ref={triggerRef}
361
+ id={selectId}
362
+ type="button"
363
+ role="combobox"
364
+ aria-haspopup="listbox"
365
+ aria-expanded={open}
366
+ aria-controls={listId}
367
+ aria-invalid={!!error}
368
+ aria-multiselectable={isMultiple || undefined}
369
+ disabled={disabled}
370
+ className={[
371
+ styles.trigger,
372
+ styles[size],
373
+ open ? styles.open : '',
374
+ error ? styles.hasError : '',
375
+ isMultiple && multipleDisplay === 'chips' && selectedValues.length > 0 ? styles.triggerChips : '',
376
+ ].filter(Boolean).join(' ')}
377
+ onClick={() => !disabled && setOpen(o => !o)}
378
+ onKeyDown={handleKeyDown}
379
+ >
380
+ {renderTriggerContent()}
381
+
382
+ <span className={styles.triggerActions}>
383
+ {clearable && hasSelection && !disabled && (
384
+ <span
385
+ role="button"
386
+ tabIndex={-1}
387
+ aria-label="Clear selection"
388
+ className={styles.clearBtn}
389
+ onClick={handleClearAll}
390
+ onMouseDown={(e) => e.preventDefault()}
391
+ >
392
+ <ClearIcon />
393
+ </span>
394
+ )}
395
+ <span className={[styles.chevron, open ? styles.chevronOpen : ''].filter(Boolean).join(' ')}>
396
+ <ChevronIcon />
397
+ </span>
398
+ </span>
399
+ </button>
400
+
401
+ {open && (
402
+ <div
403
+ className={styles.menu}
404
+ role="listbox"
405
+ id={listId}
406
+ aria-labelledby={selectId}
407
+ aria-multiselectable={isMultiple || undefined}
408
+ aria-activedescendant={activeIdx >= 0 ? `${selectId}-opt-${activeIdx}` : undefined}
409
+ >
410
+ {searchable && (
411
+ <div className={styles.searchRow}>
412
+ <span className={styles.searchIconWrap}><SearchIcon /></span>
413
+ <input
414
+ ref={searchRef}
415
+ type="text"
416
+ className={styles.searchInput}
417
+ placeholder="Search..."
418
+ value={query}
419
+ onChange={(e) => { setQuery(e.target.value); setActiveIdx(0); }}
420
+ onKeyDown={handleKeyDown}
421
+ />
422
+ </div>
423
+ )}
424
+
425
+ {isMultiple && showSelectAll && filtered.length > 0 && (
426
+ <div className={styles.bulkRow}>
427
+ <button
428
+ type="button"
429
+ className={styles.bulkBtn}
430
+ onClick={handleSelectAll}
431
+ disabled={maxSelections !== undefined && selectedValues.length >= maxSelections}
432
+ >
433
+ Select all
434
+ </button>
435
+ <button
436
+ type="button"
437
+ className={styles.bulkBtn}
438
+ onClick={() => emit([])}
439
+ disabled={selectedValues.length === 0}
440
+ >
441
+ Clear all
442
+ </button>
443
+ {maxSelections !== undefined && (
444
+ <span className={styles.bulkCount}>
445
+ {selectedValues.length} / {maxSelections}
446
+ </span>
447
+ )}
448
+ </div>
449
+ )}
450
+
451
+ <div className={styles.list} ref={listRef} role="presentation">
452
+ {filtered.length === 0 ? (
453
+ <div className={styles.empty}>No results</div>
454
+ ) : (
455
+ filtered.map((opt, idx) => {
456
+ const isSelected = selectedValues.includes(opt.value);
457
+ const isActive = idx === activeIdx;
458
+ const reachedMax = !isSelected && atMax;
459
+ const rowDisabled = opt.disabled || reachedMax;
460
+ return (
461
+ <div
462
+ key={opt.value}
463
+ id={`${selectId}-opt-${idx}`}
464
+ role="option"
465
+ aria-selected={isSelected}
466
+ aria-disabled={rowDisabled}
467
+ data-idx={idx}
468
+ className={[
469
+ styles.option,
470
+ isSelected ? styles.optionSelected : '',
471
+ isActive ? styles.optionActive : '',
472
+ rowDisabled ? styles.optionDisabled : '',
473
+ ].filter(Boolean).join(' ')}
474
+ onClick={() => !rowDisabled && handleSelect(opt)}
475
+ onMouseEnter={() => !rowDisabled && setActiveIdx(idx)}
476
+ >
477
+ {isMultiple && (
478
+ <span
479
+ className={[styles.checkbox, isSelected ? styles.checkboxChecked : ''].filter(Boolean).join(' ')}
480
+ aria-hidden="true"
481
+ >
482
+ {isSelected && <CheckIcon />}
483
+ </span>
484
+ )}
485
+ {opt.icon && <span className={styles.optionIcon}>{opt.icon}</span>}
486
+ <span className={styles.optionLabel}>
487
+ <span className={styles.optionTitle}>{opt.label}</span>
488
+ {opt.description && (
489
+ <span className={styles.optionDesc}>{opt.description}</span>
490
+ )}
491
+ </span>
492
+ {!isMultiple && (
493
+ <span className={styles.check} aria-hidden>
494
+ {isSelected && <CheckIcon />}
495
+ </span>
496
+ )}
497
+ </div>
498
+ );
499
+ })
500
+ )}
501
+ </div>
502
+ </div>
503
+ )}
504
+
505
+ {name && !isMultiple && <input type="hidden" name={name} value={value as string} />}
506
+ {name && isMultiple && selectedValues.map(v => (
507
+ <input key={v} type="hidden" name={name} value={v} />
508
+ ))}
509
+ </div>
510
+
511
+ {error && <p className={styles.errorText}>{error}</p>}
512
+ {!error && helperText && <p className={styles.helperText}>{helperText}</p>}
513
+ </div>
514
+ );
515
+ };
@@ -0,0 +1,70 @@
1
+ import styles from '../css/skeleton.module.scss';
2
+
3
+ interface EvoSkeletonProps {
4
+ width?: number | string;
5
+ height?: number | string;
6
+ borderRadius?: number | string;
7
+ className?: string;
8
+ animated?: boolean;
9
+ }
10
+
11
+ interface EvoSkeletonTextProps {
12
+ lines?: number;
13
+ className?: string;
14
+ animated?: boolean;
15
+ }
16
+
17
+ interface EvoSkeletonCircleProps {
18
+ size?: number | string;
19
+ className?: string;
20
+ animated?: boolean;
21
+ }
22
+
23
+ const toSize = (v: number | string) => (typeof v === 'number' ? `${v}px` : v);
24
+
25
+ const EvoSkeletonText = ({ lines = 3, className = '', animated = true }: EvoSkeletonTextProps) => (
26
+ <div className={`${styles.textGroup} ${className}`}>
27
+ {Array.from({ length: lines }).map((_, i) => (
28
+ <div
29
+ key={i}
30
+ className={[styles.skeleton, animated ? styles.animated : ''].filter(Boolean).join(' ')}
31
+ style={{
32
+ width: i === lines - 1 ? '65%' : '100%',
33
+ height: '0.875rem',
34
+ borderRadius: '4px',
35
+ }}
36
+ />
37
+ ))}
38
+ </div>
39
+ );
40
+
41
+ const EvoSkeletonCircle = ({ size = 40, className = '', animated = true }: EvoSkeletonCircleProps) => (
42
+ <div
43
+ className={[styles.skeleton, animated ? styles.animated : '', className].filter(Boolean).join(' ')}
44
+ style={{
45
+ width: toSize(size),
46
+ height: toSize(size),
47
+ borderRadius: '50%',
48
+ }}
49
+ />
50
+ );
51
+
52
+ export const EvoSkeleton = ({
53
+ width = '100%',
54
+ height = '1rem',
55
+ borderRadius = '6px',
56
+ className = '',
57
+ animated = true,
58
+ }: EvoSkeletonProps) => (
59
+ <div
60
+ className={[styles.skeleton, animated ? styles.animated : '', className].filter(Boolean).join(' ')}
61
+ style={{
62
+ width: toSize(width),
63
+ height: toSize(height),
64
+ borderRadius: toSize(borderRadius),
65
+ }}
66
+ />
67
+ );
68
+
69
+ EvoSkeleton.Text = EvoSkeletonText;
70
+ EvoSkeleton.Circle = EvoSkeletonCircle;
@@ -0,0 +1,52 @@
1
+ import React, { CSSProperties } from 'react';
2
+
3
+ type Direction = 'row' | 'column';
4
+ type Align = 'start' | 'center' | 'end' | 'stretch' | 'baseline';
5
+ type Justify = 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';
6
+
7
+ interface EvoStackProps {
8
+ children: React.ReactNode;
9
+ direction?: Direction;
10
+ gap?: number | string;
11
+ align?: Align;
12
+ justify?: Justify;
13
+ wrap?: boolean;
14
+ className?: string;
15
+ style?: CSSProperties;
16
+ }
17
+
18
+ const alignMap: Record<Align, string> = {
19
+ start: 'flex-start', center: 'center', end: 'flex-end',
20
+ stretch: 'stretch', baseline: 'baseline',
21
+ };
22
+
23
+ const justifyMap: Record<Justify, string> = {
24
+ start: 'flex-start', center: 'center', end: 'flex-end',
25
+ between: 'space-between', around: 'space-around', evenly: 'space-evenly',
26
+ };
27
+
28
+ export const EvoStack = ({
29
+ children,
30
+ direction = 'column',
31
+ gap = '1rem',
32
+ align = 'stretch',
33
+ justify = 'start',
34
+ wrap = false,
35
+ className = '',
36
+ style,
37
+ }: EvoStackProps) => (
38
+ <div
39
+ className={className}
40
+ style={{
41
+ display: 'flex',
42
+ flexDirection: direction,
43
+ gap: typeof gap === 'number' ? `${gap}px` : gap,
44
+ alignItems: alignMap[align],
45
+ justifyContent: justifyMap[justify],
46
+ flexWrap: wrap ? 'wrap' : 'nowrap',
47
+ ...style,
48
+ }}
49
+ >
50
+ {children}
51
+ </div>
52
+ );