@optilogic/core 1.0.0-beta.0

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 (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +107 -0
  3. package/dist/index.cjs +6003 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +2310 -0
  6. package/dist/index.d.ts +2310 -0
  7. package/dist/index.js +5828 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/styles.css +96 -0
  10. package/dist/tailwind-preset.cjs +106 -0
  11. package/dist/tailwind-preset.cjs.map +1 -0
  12. package/dist/tailwind-preset.d.cts +23 -0
  13. package/dist/tailwind-preset.d.ts +23 -0
  14. package/dist/tailwind-preset.js +101 -0
  15. package/dist/tailwind-preset.js.map +1 -0
  16. package/package.json +154 -0
  17. package/src/components/accordion.tsx +187 -0
  18. package/src/components/alert-dialog.tsx +143 -0
  19. package/src/components/autocomplete.tsx +271 -0
  20. package/src/components/badge.tsx +62 -0
  21. package/src/components/button.tsx +85 -0
  22. package/src/components/calendar.tsx +235 -0
  23. package/src/components/card.tsx +94 -0
  24. package/src/components/checkbox.tsx +77 -0
  25. package/src/components/chip.tsx +77 -0
  26. package/src/components/confirmation-modal.tsx +195 -0
  27. package/src/components/context-menu.tsx +406 -0
  28. package/src/components/copy-button.tsx +84 -0
  29. package/src/components/data-grid/DataGrid.tsx +1027 -0
  30. package/src/components/data-grid/components/CellEditor.tsx +346 -0
  31. package/src/components/data-grid/components/FilterPopover.tsx +459 -0
  32. package/src/components/data-grid/components/HeaderCell.tsx +207 -0
  33. package/src/components/data-grid/components/index.ts +14 -0
  34. package/src/components/data-grid/hooks/index.ts +28 -0
  35. package/src/components/data-grid/hooks/useColumnResize.ts +378 -0
  36. package/src/components/data-grid/hooks/useDataGridState.ts +346 -0
  37. package/src/components/data-grid/hooks/useKeyboardNavigation.ts +361 -0
  38. package/src/components/data-grid/index.ts +71 -0
  39. package/src/components/data-grid/types.ts +478 -0
  40. package/src/components/data-grid/utils/dataProcessing.ts +277 -0
  41. package/src/components/data-grid/utils/index.ts +12 -0
  42. package/src/components/date-picker.tsx +366 -0
  43. package/src/components/dropdown-menu.tsx +230 -0
  44. package/src/components/icon-button.tsx +157 -0
  45. package/src/components/input.tsx +40 -0
  46. package/src/components/label.tsx +37 -0
  47. package/src/components/loading-spinner.tsx +113 -0
  48. package/src/components/modal.tsx +207 -0
  49. package/src/components/popover.tsx +62 -0
  50. package/src/components/progress.tsx +41 -0
  51. package/src/components/resizable-panel.tsx +434 -0
  52. package/src/components/resize-handle.tsx +187 -0
  53. package/src/components/select.tsx +160 -0
  54. package/src/components/separator.tsx +50 -0
  55. package/src/components/skeleton.tsx +37 -0
  56. package/src/components/switch.tsx +59 -0
  57. package/src/components/table.tsx +136 -0
  58. package/src/components/tabs.tsx +102 -0
  59. package/src/components/textarea.tsx +36 -0
  60. package/src/components/theme-picker.tsx +245 -0
  61. package/src/components/toaster.tsx +84 -0
  62. package/src/components/tooltip.tsx +199 -0
  63. package/src/index.ts +318 -0
  64. package/src/styles.css +96 -0
  65. package/src/tailwind-preset.ts +129 -0
  66. package/src/theme/index.ts +41 -0
  67. package/src/theme/presets.ts +502 -0
  68. package/src/theme/types.ts +164 -0
  69. package/src/theme/utils.ts +309 -0
  70. package/src/utils/cn.ts +14 -0
package/src/index.ts ADDED
@@ -0,0 +1,318 @@
1
+ // Utility exports
2
+ export { cn } from "./utils/cn";
3
+
4
+ // Primitive components
5
+ export { Button, buttonVariants, type ButtonProps } from "./components/button";
6
+ export { Input, type InputProps } from "./components/input";
7
+ export { Label, labelVariants, type LabelProps } from "./components/label";
8
+ export { Textarea, type TextareaProps } from "./components/textarea";
9
+ export { Badge, badgeVariants, type BadgeProps } from "./components/badge";
10
+ export { Checkbox, type CheckboxProps } from "./components/checkbox";
11
+ export { Switch, type SwitchProps } from "./components/switch";
12
+ export { Progress, type ProgressProps } from "./components/progress";
13
+ export { Separator, type SeparatorProps } from "./components/separator";
14
+ export { Skeleton, type SkeletonProps } from "./components/skeleton";
15
+
16
+ // Radix-based components
17
+ export {
18
+ Select,
19
+ SelectGroup,
20
+ SelectValue,
21
+ SelectTrigger,
22
+ SelectContent,
23
+ SelectLabel,
24
+ SelectItem,
25
+ SelectSeparator,
26
+ SelectScrollUpButton,
27
+ SelectScrollDownButton,
28
+ type SelectTriggerProps,
29
+ } from "./components/select";
30
+
31
+ export {
32
+ Tabs,
33
+ TabsList,
34
+ TabsTrigger,
35
+ TabsContent,
36
+ } from "./components/tabs";
37
+
38
+ export {
39
+ Accordion,
40
+ AccordionItem,
41
+ AccordionTrigger,
42
+ AccordionContent,
43
+ accordionItemVariants,
44
+ accordionTriggerVariants,
45
+ accordionContentVariants,
46
+ type AccordionVariant,
47
+ type AccordionItemProps,
48
+ type AccordionTriggerProps,
49
+ type AccordionContentProps,
50
+ } from "./components/accordion";
51
+
52
+ export {
53
+ Tooltip,
54
+ TooltipProvider,
55
+ TooltipRoot,
56
+ TooltipTrigger,
57
+ TooltipPortal,
58
+ TooltipContent,
59
+ TooltipArrow,
60
+ type TooltipProps,
61
+ } from "./components/tooltip";
62
+
63
+ export {
64
+ Popover,
65
+ PopoverTrigger,
66
+ PopoverContent,
67
+ PopoverAnchor,
68
+ type PopoverContentProps,
69
+ } from "./components/popover";
70
+
71
+ export {
72
+ DropdownMenu,
73
+ DropdownMenuTrigger,
74
+ DropdownMenuContent,
75
+ DropdownMenuItem,
76
+ DropdownMenuCheckboxItem,
77
+ DropdownMenuRadioItem,
78
+ DropdownMenuLabel,
79
+ DropdownMenuSeparator,
80
+ DropdownMenuShortcut,
81
+ DropdownMenuGroup,
82
+ DropdownMenuPortal,
83
+ DropdownMenuSub,
84
+ DropdownMenuSubContent,
85
+ DropdownMenuSubTrigger,
86
+ DropdownMenuRadioGroup,
87
+ type DropdownMenuItemProps,
88
+ type DropdownMenuLabelProps,
89
+ type DropdownMenuSubTriggerProps,
90
+ type DropdownMenuShortcutProps,
91
+ } from "./components/dropdown-menu";
92
+
93
+ export {
94
+ AlertDialog,
95
+ AlertDialogPortal,
96
+ AlertDialogOverlay,
97
+ AlertDialogTrigger,
98
+ AlertDialogContent,
99
+ AlertDialogHeader,
100
+ AlertDialogFooter,
101
+ AlertDialogTitle,
102
+ AlertDialogDescription,
103
+ AlertDialogAction,
104
+ AlertDialogCancel,
105
+ type AlertDialogHeaderProps,
106
+ type AlertDialogFooterProps,
107
+ } from "./components/alert-dialog";
108
+
109
+ // Layout components
110
+ export {
111
+ Card,
112
+ CardHeader,
113
+ CardFooter,
114
+ CardTitle,
115
+ CardDescription,
116
+ CardContent,
117
+ type CardProps,
118
+ type CardHeaderProps,
119
+ type CardTitleProps,
120
+ type CardDescriptionProps,
121
+ type CardContentProps,
122
+ type CardFooterProps,
123
+ } from "./components/card";
124
+
125
+ export {
126
+ Table,
127
+ TableHeader,
128
+ TableBody,
129
+ TableFooter,
130
+ TableHead,
131
+ TableRow,
132
+ TableCell,
133
+ TableCaption,
134
+ type TableProps,
135
+ type TableHeaderProps,
136
+ type TableBodyProps,
137
+ type TableFooterProps,
138
+ type TableHeadProps,
139
+ type TableRowProps,
140
+ type TableCellProps,
141
+ type TableCaptionProps,
142
+ } from "./components/table";
143
+
144
+ export {
145
+ Modal,
146
+ ModalButton,
147
+ type ModalProps,
148
+ type ModalButtonProps,
149
+ } from "./components/modal";
150
+
151
+ export {
152
+ ConfirmationModal,
153
+ useConfirmation,
154
+ type ConfirmationModalProps,
155
+ } from "./components/confirmation-modal";
156
+
157
+ export {
158
+ ResizeHandle,
159
+ type ResizeHandleProps,
160
+ } from "./components/resize-handle";
161
+
162
+ export {
163
+ ResizablePanel,
164
+ type ResizablePanelProps,
165
+ } from "./components/resizable-panel";
166
+
167
+ // Feedback components
168
+ export { Chip, type ChipProps } from "./components/chip";
169
+
170
+ export {
171
+ LoadingSpinner,
172
+ loadingSpinnerVariants,
173
+ type LoadingSpinnerProps,
174
+ } from "./components/loading-spinner";
175
+
176
+ export { Toaster, type ToasterProps } from "./components/toaster";
177
+
178
+ // Data components - import directly from folder to avoid circular dependency
179
+ export {
180
+ // Main component
181
+ DataGrid,
182
+
183
+ // Types - Column and data
184
+ type ColumnDef,
185
+ type SelectOption,
186
+ type FilterType,
187
+ type EditorType,
188
+
189
+ // Types - Filter
190
+ type FilterConfig,
191
+ type FilterOperator,
192
+ type TextFilterOperator,
193
+ type NumberFilterOperator,
194
+ type DateFilterOperator,
195
+
196
+ // Types - Sort
197
+ type SortConfig,
198
+
199
+ // Types - Cell
200
+ type CellPosition,
201
+ type EditingCell,
202
+ type CellEditEvent,
203
+
204
+ // Types - Configuration
205
+ type PaginationConfig,
206
+ type SearchConfig,
207
+ type DataGridState,
208
+ type DataGridProps,
209
+ type DataGridInternalState,
210
+ type DataGridContextValue,
211
+
212
+ // Types - Sub-component props
213
+ type HeaderCellProps,
214
+ type FilterPopoverProps,
215
+ type CellEditorProps,
216
+ type GridCellProps,
217
+
218
+ // Sub-components (for advanced customization)
219
+ HeaderCell,
220
+ FilterPopover,
221
+ CellEditor,
222
+
223
+ // Hooks (for building custom grid implementations)
224
+ useDataGridState,
225
+ useKeyboardNavigation,
226
+ useColumnResize,
227
+ useColumnResizeManager,
228
+
229
+ // Utilities (for custom data processing in controlled mode)
230
+ applyFilterOperator,
231
+ applyFilters,
232
+ applySorting,
233
+ getCellValue,
234
+ } from "./components/data-grid/index";
235
+
236
+ // Legacy type alias for backward compatibility
237
+ /** @deprecated Use SortConfig instead */
238
+ export type SortingConfig = {
239
+ field: string;
240
+ direction: "asc" | "desc";
241
+ onSort: (field: string) => void;
242
+ };
243
+
244
+ export {
245
+ Autocomplete,
246
+ type AutocompleteProps,
247
+ type AutocompleteOption,
248
+ } from "./components/autocomplete";
249
+
250
+ // Utility components
251
+ export {
252
+ IconButton,
253
+ iconButtonVariants,
254
+ type IconButtonProps,
255
+ } from "./components/icon-button";
256
+
257
+ export {
258
+ CopyButton,
259
+ type CopyButtonProps,
260
+ } from "./components/copy-button";
261
+
262
+ export {
263
+ ThemePicker,
264
+ type ThemePickerProps,
265
+ } from "./components/theme-picker";
266
+
267
+ export { Calendar, type CalendarProps } from "./components/calendar";
268
+
269
+ export {
270
+ DatePicker,
271
+ DatePickerInput,
272
+ type DatePickerProps,
273
+ type DatePickerInputProps,
274
+ } from "./components/date-picker";
275
+
276
+ export {
277
+ ContextMenu,
278
+ useContextMenu,
279
+ type ContextMenuProps,
280
+ type ContextMenuItem,
281
+ type UseContextMenuResult,
282
+ } from "./components/context-menu";
283
+
284
+ // Theme system
285
+ export {
286
+ // Types
287
+ type Theme,
288
+ type ThemeHex,
289
+ type ThemeHSL,
290
+ type ColorFieldConfig,
291
+ // Presets
292
+ GREEN_THEME,
293
+ OPTILOGIC_LEGACY_THEME,
294
+ FUTURISTIC_THEME,
295
+ NATURE_THEME,
296
+ SCIFI_THEME,
297
+ OCEAN_THEME,
298
+ SUNSET_THEME,
299
+ FOREST_THEME,
300
+ CYBERPUNK_THEME,
301
+ MINIMALIST_LIGHT_THEME,
302
+ DARK_ELEGANT_THEME,
303
+ PRESET_THEMES,
304
+ ALL_THEMES,
305
+ getPresetTheme,
306
+ getDefaultTheme,
307
+ isPresetTheme,
308
+ // Utilities
309
+ hexToHsl,
310
+ themeToHsl,
311
+ applyTheme,
312
+ getCurrentTheme,
313
+ validateTheme,
314
+ cloneTheme,
315
+ areThemesEqual,
316
+ exportTheme,
317
+ importTheme,
318
+ } from "./theme";
package/src/styles.css ADDED
@@ -0,0 +1,96 @@
1
+ /**
2
+ * opti-ui Base Styles
3
+ *
4
+ * This file contains the CSS variables required for opti-ui components.
5
+ * Import this file or define these variables in your own CSS.
6
+ *
7
+ * Usage:
8
+ * import '@optilogic/core/styles.css';
9
+ *
10
+ * Or define in your own CSS:
11
+ * :root { --background: 0 0% 100%; ... }
12
+ */
13
+
14
+ @tailwind base;
15
+ @tailwind components;
16
+ @tailwind utilities;
17
+
18
+ @layer base {
19
+ :root {
20
+ --background: 0 0% 100%;
21
+ --foreground: 222.2 84% 4.9%;
22
+ --card: 0 0% 100%;
23
+ --card-foreground: 222.2 84% 4.9%;
24
+ --popover: 0 0% 100%;
25
+ --popover-foreground: 222.2 84% 4.9%;
26
+ --primary: 222.2 47.4% 11.2%;
27
+ --primary-foreground: 210 40% 98%;
28
+ --secondary: 210 40% 96.1%;
29
+ --secondary-foreground: 222.2 47.4% 11.2%;
30
+ --muted: 210 40% 96.1%;
31
+ --muted-foreground: 215.4 16.3% 46.9%;
32
+ --accent: 210 40% 96.1%;
33
+ --accent-foreground: 222.2 47.4% 11.2%;
34
+ --destructive: 0 84.2% 60.2%;
35
+ --destructive-foreground: 210 40% 98%;
36
+ --success: 142 76% 36%;
37
+ --success-foreground: 210 40% 98%;
38
+ --warning: 38 92% 50%;
39
+ --warning-foreground: 222.2 47.4% 11.2%;
40
+ --border: 214.3 31.8% 91.4%;
41
+ --input: 214.3 31.8% 91.4%;
42
+ --ring: 222.2 84% 4.9%;
43
+ --divider: 214.3 31.8% 91.4%;
44
+ --chip: 210 40% 96.1%;
45
+ --chip-foreground: 222.2 47.4% 11.2%;
46
+ --radius: 0.5rem;
47
+ --chart-1: 12 76% 61%;
48
+ --chart-2: 173 58% 39%;
49
+ --chart-3: 197 37% 24%;
50
+ --chart-4: 43 74% 66%;
51
+ --chart-5: 27 87% 67%;
52
+ }
53
+
54
+ .dark {
55
+ --background: 222.2 84% 4.9%;
56
+ --foreground: 210 40% 98%;
57
+ --card: 222.2 84% 4.9%;
58
+ --card-foreground: 210 40% 98%;
59
+ --popover: 222.2 84% 4.9%;
60
+ --popover-foreground: 210 40% 98%;
61
+ --primary: 210 40% 98%;
62
+ --primary-foreground: 222.2 47.4% 11.2%;
63
+ --secondary: 217.2 32.6% 17.5%;
64
+ --secondary-foreground: 210 40% 98%;
65
+ --muted: 217.2 32.6% 17.5%;
66
+ --muted-foreground: 215 20.2% 65.1%;
67
+ --accent: 217.2 32.6% 17.5%;
68
+ --accent-foreground: 210 40% 98%;
69
+ --destructive: 0 62.8% 30.6%;
70
+ --destructive-foreground: 210 40% 98%;
71
+ --success: 142 76% 36%;
72
+ --success-foreground: 210 40% 98%;
73
+ --warning: 38 92% 50%;
74
+ --warning-foreground: 222.2 47.4% 11.2%;
75
+ --border: 217.2 32.6% 17.5%;
76
+ --input: 217.2 32.6% 17.5%;
77
+ --ring: 212.7 26.8% 83.9%;
78
+ --divider: 217.2 32.6% 17.5%;
79
+ --chip: 217.2 32.6% 17.5%;
80
+ --chip-foreground: 210 40% 98%;
81
+ --chart-1: 220 70% 50%;
82
+ --chart-2: 160 60% 45%;
83
+ --chart-3: 30 80% 55%;
84
+ --chart-4: 280 65% 60%;
85
+ --chart-5: 340 75% 55%;
86
+ }
87
+ }
88
+
89
+ @layer base {
90
+ * {
91
+ @apply border-border;
92
+ }
93
+ body {
94
+ @apply bg-background text-foreground;
95
+ }
96
+ }
@@ -0,0 +1,129 @@
1
+ import type { Config } from "tailwindcss";
2
+
3
+ /**
4
+ * opti-ui Tailwind CSS preset
5
+ *
6
+ * This preset provides the theme configuration required for opti-ui components.
7
+ * Consumers should extend their Tailwind config with this preset.
8
+ *
9
+ * @example
10
+ * // tailwind.config.js
11
+ * import { optiUiPreset } from '@optilogic/core/tailwind-preset';
12
+ *
13
+ * export default {
14
+ * presets: [optiUiPreset],
15
+ * content: [
16
+ * './src/**\/*.{js,ts,jsx,tsx}',
17
+ * './node_modules/@optilogic/core/dist/**\/*.{js,mjs}'
18
+ * ]
19
+ * }
20
+ */
21
+ export const optiUiPreset: Partial<Config> = {
22
+ darkMode: ["class"],
23
+ theme: {
24
+ extend: {
25
+ colors: {
26
+ // Background colors
27
+ background: "hsl(var(--background))",
28
+ foreground: "hsl(var(--foreground))",
29
+
30
+ // Card
31
+ card: {
32
+ DEFAULT: "hsl(var(--card))",
33
+ foreground: "hsl(var(--card-foreground))",
34
+ },
35
+
36
+ // Popover
37
+ popover: {
38
+ DEFAULT: "hsl(var(--popover))",
39
+ foreground: "hsl(var(--popover-foreground))",
40
+ },
41
+
42
+ // Primary
43
+ primary: {
44
+ DEFAULT: "hsl(var(--primary))",
45
+ foreground: "hsl(var(--primary-foreground))",
46
+ },
47
+
48
+ // Secondary
49
+ secondary: {
50
+ DEFAULT: "hsl(var(--secondary))",
51
+ foreground: "hsl(var(--secondary-foreground))",
52
+ },
53
+
54
+ // Muted
55
+ muted: {
56
+ DEFAULT: "hsl(var(--muted))",
57
+ foreground: "hsl(var(--muted-foreground))",
58
+ },
59
+
60
+ // Accent
61
+ accent: {
62
+ DEFAULT: "hsl(var(--accent))",
63
+ foreground: "hsl(var(--accent-foreground))",
64
+ },
65
+
66
+ // Destructive
67
+ destructive: {
68
+ DEFAULT: "hsl(var(--destructive))",
69
+ foreground: "hsl(var(--destructive-foreground))",
70
+ },
71
+
72
+ // Success
73
+ success: {
74
+ DEFAULT: "hsl(var(--success))",
75
+ foreground: "hsl(var(--success-foreground))",
76
+ },
77
+
78
+ // Warning
79
+ warning: {
80
+ DEFAULT: "hsl(var(--warning))",
81
+ foreground: "hsl(var(--warning-foreground))",
82
+ },
83
+
84
+ // Border, input, ring
85
+ border: "hsl(var(--border))",
86
+ input: "hsl(var(--input))",
87
+ ring: "hsl(var(--ring))",
88
+ divider: "hsl(var(--divider))",
89
+
90
+ // Chip
91
+ chip: {
92
+ DEFAULT: "hsl(var(--chip))",
93
+ foreground: "hsl(var(--chip-foreground))",
94
+ },
95
+
96
+ // Chart colors
97
+ chart: {
98
+ 1: "hsl(var(--chart-1))",
99
+ 2: "hsl(var(--chart-2))",
100
+ 3: "hsl(var(--chart-3))",
101
+ 4: "hsl(var(--chart-4))",
102
+ 5: "hsl(var(--chart-5))",
103
+ },
104
+ },
105
+ borderRadius: {
106
+ lg: "var(--radius)",
107
+ md: "calc(var(--radius) - 2px)",
108
+ sm: "calc(var(--radius) - 4px)",
109
+ },
110
+ keyframes: {
111
+ "accordion-down": {
112
+ from: { height: "0" },
113
+ to: { height: "var(--radix-accordion-content-height)" },
114
+ },
115
+ "accordion-up": {
116
+ from: { height: "var(--radix-accordion-content-height)" },
117
+ to: { height: "0" },
118
+ },
119
+ },
120
+ animation: {
121
+ "accordion-down": "accordion-down 0.2s ease-out",
122
+ "accordion-up": "accordion-up 0.2s ease-out",
123
+ },
124
+ },
125
+ },
126
+ plugins: [],
127
+ };
128
+
129
+ export default optiUiPreset;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Theme Module
3
+ *
4
+ * Exports all theme types, presets, and utilities.
5
+ */
6
+
7
+ // Types
8
+ export type { Theme, ThemeHex, ThemeHSL, ColorFieldConfig } from "./types";
9
+
10
+ // Presets
11
+ export {
12
+ GREEN_THEME,
13
+ OPTILOGIC_LEGACY_THEME,
14
+ FUTURISTIC_THEME,
15
+ NATURE_THEME,
16
+ SCIFI_THEME,
17
+ OCEAN_THEME,
18
+ SUNSET_THEME,
19
+ FOREST_THEME,
20
+ CYBERPUNK_THEME,
21
+ MINIMALIST_LIGHT_THEME,
22
+ DARK_ELEGANT_THEME,
23
+ PRESET_THEMES,
24
+ ALL_THEMES,
25
+ getPresetTheme,
26
+ getDefaultTheme,
27
+ isPresetTheme,
28
+ } from "./presets";
29
+
30
+ // Utilities
31
+ export {
32
+ hexToHsl,
33
+ themeToHsl,
34
+ applyTheme,
35
+ getCurrentTheme,
36
+ validateTheme,
37
+ cloneTheme,
38
+ areThemesEqual,
39
+ exportTheme,
40
+ importTheme,
41
+ } from "./utils";