@shohojdhara/atomix 0.3.6 → 0.3.8

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 (74) hide show
  1. package/README.md +3 -3
  2. package/dist/atomix.css +77 -0
  3. package/dist/atomix.css.map +1 -1
  4. package/dist/atomix.min.css +77 -0
  5. package/dist/atomix.min.css.map +1 -1
  6. package/dist/charts.js +50 -142
  7. package/dist/charts.js.map +1 -1
  8. package/dist/core.d.ts +2 -2
  9. package/dist/core.js +179 -274
  10. package/dist/core.js.map +1 -1
  11. package/dist/forms.js +50 -142
  12. package/dist/forms.js.map +1 -1
  13. package/dist/heavy.js +179 -274
  14. package/dist/heavy.js.map +1 -1
  15. package/dist/index.d.ts +1255 -1226
  16. package/dist/index.esm.js +2806 -2958
  17. package/dist/index.esm.js.map +1 -1
  18. package/dist/index.js +3113 -3269
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.min.js +1 -1
  21. package/dist/index.min.js.map +1 -1
  22. package/dist/theme.d.ts +313 -667
  23. package/dist/theme.js +1818 -2589
  24. package/dist/theme.js.map +1 -1
  25. package/package.json +1 -1
  26. package/src/components/AtomixGlass/AtomixGlass.tsx +128 -356
  27. package/src/components/AtomixGlass/AtomixGlassContainer.tsx +1 -1
  28. package/src/components/Button/Button.tsx +85 -167
  29. package/src/components/DataTable/DataTable.stories.tsx +238 -0
  30. package/src/components/DataTable/DataTable.test.tsx +450 -0
  31. package/src/components/DataTable/DataTable.tsx +384 -61
  32. package/src/components/DatePicker/DatePicker.tsx +29 -38
  33. package/src/components/Upload/Upload.tsx +539 -40
  34. package/src/lib/composables/useAtomixGlass.ts +7 -7
  35. package/src/lib/composables/useDataTable.ts +355 -15
  36. package/src/lib/composables/useDatePicker.ts +19 -0
  37. package/src/lib/config/loader.ts +2 -3
  38. package/src/lib/constants/components.ts +17 -0
  39. package/src/lib/hooks/usePerformanceMonitor.ts +1 -1
  40. package/src/lib/theme/adapters/cssVariableMapper.ts +29 -14
  41. package/src/lib/theme/adapters/index.ts +1 -4
  42. package/src/lib/theme/config/configLoader.ts +82 -223
  43. package/src/lib/theme/config/loader.ts +15 -21
  44. package/src/lib/theme/constants/constants.ts +1 -1
  45. package/src/lib/theme/core/ThemeRegistry.ts +75 -279
  46. package/src/lib/theme/core/composeTheme.ts +30 -88
  47. package/src/lib/theme/core/createTheme.ts +88 -51
  48. package/src/lib/theme/core/createThemeObject.ts +2 -2
  49. package/src/lib/theme/core/index.ts +15 -2
  50. package/src/lib/theme/errors/errors.ts +1 -1
  51. package/src/lib/theme/generators/generateCSSNested.ts +131 -0
  52. package/src/lib/theme/generators/generateCSSVariables.ts +24 -16
  53. package/src/lib/theme/generators/index.ts +6 -0
  54. package/src/lib/theme/index.ts +45 -27
  55. package/src/lib/theme/runtime/ThemeApplicator.ts +6 -109
  56. package/src/lib/theme/runtime/ThemeErrorBoundary.tsx +1 -1
  57. package/src/lib/theme/runtime/ThemeProvider.tsx +393 -544
  58. package/src/lib/theme/runtime/index.ts +1 -0
  59. package/src/lib/theme/runtime/useTheme.ts +1 -1
  60. package/src/lib/theme/runtime/useThemeTokens.ts +122 -0
  61. package/src/lib/theme/test/testTheme.ts +2 -1
  62. package/src/lib/theme/types.ts +14 -14
  63. package/src/lib/theme/utils/componentTheming.ts +140 -0
  64. package/src/lib/theme/utils/domUtils.ts +57 -15
  65. package/src/lib/theme/utils/injectCSS.ts +0 -1
  66. package/src/lib/theme/utils/naming.ts +100 -0
  67. package/src/lib/theme/utils/themeHelpers.ts +1 -39
  68. package/src/lib/theme/utils/themeUtils.ts +1 -170
  69. package/src/lib/types/components.ts +145 -0
  70. package/src/lib/utils/componentUtils.ts +1 -1
  71. package/src/lib/utils/dataTableExport.ts +143 -0
  72. package/src/lib/utils/memoryMonitor.ts +3 -3
  73. package/src/lib/utils/themeNaming.ts +135 -0
  74. package/src/styles/06-components/_components.data-table.scss +95 -0
@@ -1,297 +1,93 @@
1
1
  /**
2
- * Theme Registry
3
- *
4
- * Central registry for all themes with discovery and dependency management
2
+ * Theme Metadata interface
5
3
  */
4
+ export interface ThemeMetadata {
5
+ name: string;
6
+ class: string;
7
+ description?: string;
8
+ version?: string;
9
+ [key: string]: any;
10
+ }
6
11
 
7
- import type { Theme, ThemeMetadata } from '../types';
8
- import type { ThemeDefinition, LoadedThemeConfig } from '../config/types';
9
- import { loadThemeConfig } from '../config/loader';
12
+ /**
13
+ * Theme Registry type - a record of theme IDs to metadata
14
+ */
15
+ export type ThemeRegistry = Record<string, ThemeMetadata>;
10
16
 
11
17
  /**
12
- * Registry entry
18
+ * Create a new theme registry
13
19
  */
14
- interface RegistryEntry {
15
- /** Theme ID */
16
- id: string;
17
- /** Theme definition from config */
18
- definition: ThemeDefinition;
19
- /** Resolved theme object (for JS themes) */
20
- theme?: Theme;
21
- /** Whether theme is loaded */
22
- loaded: boolean;
23
- /** Loading promise (if currently loading) */
24
- loading?: Promise<Theme | void>;
25
- /** Dependencies */
26
- dependencies: string[];
27
- /** Dependent themes (themes that depend on this one) */
28
- dependents: string[];
20
+ export function createThemeRegistry(): ThemeRegistry {
21
+ return {};
29
22
  }
30
23
 
31
24
  /**
32
- * Theme Registry
33
- *
34
- * Manages theme registration, discovery, and dependency resolution
25
+ * Register a theme
26
+ * @param registry - Theme registry object
27
+ * @param id - Theme identifier
28
+ * @param metadata - Theme metadata
35
29
  */
36
- export class ThemeRegistry {
37
- private entries: Map<string, RegistryEntry> = new Map();
38
- private config: LoadedThemeConfig | null = null;
39
- private initialized: boolean = false;
40
-
41
- /**
42
- * Initialize registry from config
43
- */
44
- async initialize(config?: LoadedThemeConfig): Promise<void> {
45
- if (this.initialized) {
46
- return;
47
- }
48
-
49
- // Load config if not provided
50
- if (!config) {
51
- try {
52
- this.config = loadThemeConfig();
53
- } catch (error) {
54
- // In browser environments, config loading will fail
55
- // Use empty config as fallback
56
- this.config = {
57
- themes: {},
58
- build: {
59
- output: { directory: 'themes', formats: { expanded: '.css', compressed: '.min.css' } },
60
- sass: { style: 'expanded', sourceMap: true, loadPaths: ['src'] },
61
- },
62
- runtime: {
63
- basePath: '',
64
- defaultTheme: undefined, // No default - use built-in styles
65
- },
66
- integration: {
67
- cssVariables: { colorMode: '--color-mode' },
68
- classNames: { theme: 'data-theme', colorMode: 'data-color-mode' },
69
- },
70
- dependencies: {},
71
- validated: false,
72
- errors: [],
73
- warnings: [],
74
- __tokens: {},
75
- __extend: {},
76
- };
77
- }
78
- } else {
79
- this.config = config;
80
- }
81
-
82
- // Register all themes from config
83
- for (const [themeId, definition] of Object.entries(this.config.themes)) {
84
- this.register(themeId, definition);
85
- }
86
-
87
- // Resolve dependencies
88
- this.resolveDependencies();
89
-
90
- this.initialized = true;
91
- }
92
-
93
- /**
94
- * Register a theme
95
- */
96
- register(themeId: string, definition: ThemeDefinition): void {
97
- // Get dependencies from config or definition
98
- const dependencies =
99
- this.config?.dependencies?.[themeId] ||
100
- definition.dependencies ||
101
- [];
102
-
103
- const entry: RegistryEntry = {
104
- id: themeId,
105
- definition,
106
- loaded: false,
107
- dependencies: [...dependencies],
108
- dependents: [],
109
- };
110
-
111
- this.entries.set(themeId, entry);
112
- }
113
-
114
- /**
115
- * Get theme entry
116
- */
117
- get(themeId: string): RegistryEntry | undefined {
118
- return this.entries.get(themeId);
119
- }
120
-
121
- /**
122
- * Check if theme exists
123
- */
124
- has(themeId: string): boolean {
125
- return this.entries.has(themeId);
126
- }
127
-
128
- /**
129
- * Get all theme IDs
130
- */
131
- getAllIds(): string[] {
132
- return Array.from(this.entries.keys());
133
- }
134
-
135
- /**
136
- * Get all theme metadata
137
- */
138
- getAllMetadata(): ThemeMetadata[] {
139
- return Array.from(this.entries.values()).map(entry => ({
140
- id: entry.id,
141
- name: entry.definition.name,
142
- type: entry.definition.type,
143
- class: entry.definition.class,
144
- description: entry.definition.description,
145
- author: entry.definition.author,
146
- version: entry.definition.version,
147
- tags: entry.definition.tags,
148
- supportsDarkMode: entry.definition.supportsDarkMode,
149
- status: entry.definition.status,
150
- a11y: entry.definition.a11y,
151
- color: entry.definition.color,
152
- features: entry.definition.features,
153
- dependencies: entry.dependencies,
154
- }));
155
- }
156
-
157
- /**
158
- * Get theme definition
159
- */
160
- getDefinition(themeId: string): ThemeDefinition | undefined {
161
- return this.entries.get(themeId)?.definition;
162
- }
163
-
164
- /**
165
- * Check if a theme is loaded
166
- */
167
- isThemeLoaded(themeId: string): boolean {
168
- const entry = this.entries.get(themeId);
169
- return entry ? entry.loaded : false;
170
- }
171
-
172
- /**
173
- * Mark a theme as loaded
174
- */
175
- markLoaded(themeId: string, theme?: Theme): void {
176
- const entry = this.entries.get(themeId);
177
- if (entry) {
178
- entry.loaded = true;
179
- if (theme) {
180
- entry.theme = theme;
181
- }
182
- }
183
- }
184
-
185
- /**
186
- * Get theme object (for JS themes)
187
- */
188
- getTheme(themeId: string): Theme | undefined {
189
- const entry = this.entries.get(themeId);
190
- return entry?.loaded ? entry.theme : undefined;
191
- }
192
-
193
- /**
194
- * Get dependencies for a theme
195
- */
196
- getDependencies(themeId: string): string[] {
197
- return this.entries.get(themeId)?.dependencies || [];
198
- }
199
-
200
- /**
201
- * Get dependents for a theme (themes that depend on this one)
202
- */
203
- getDependents(themeId: string): string[] {
204
- return this.entries.get(themeId)?.dependents || [];
205
- }
206
-
207
- /**
208
- * Resolve all dependencies in correct order
209
- */
210
- resolveDependencyOrder(themeId: string): string[] {
211
- const resolved: string[] = [];
212
- const visited = new Set<string>();
213
- const visiting = new Set<string>();
214
-
215
- const visit = (id: string): void => {
216
- if (visiting.has(id)) {
217
- throw new Error(`Circular dependency detected involving theme: ${id}`);
218
- }
219
- if (visited.has(id)) {
220
- return;
221
- }
222
-
223
- visiting.add(id);
224
- const entry = this.entries.get(id);
225
- if (entry) {
226
- for (const dep of entry.dependencies) {
227
- if (!this.has(dep)) {
228
- throw new Error(`Theme "${id}" depends on non-existent theme: ${dep}`);
229
- }
230
- visit(dep);
231
- }
232
- }
233
- visiting.delete(id);
234
- visited.add(id);
235
- resolved.push(id);
236
- };
30
+ export function registerTheme(registry: ThemeRegistry, id: string, metadata: ThemeMetadata): void {
31
+ registry[id] = metadata;
32
+ }
237
33
 
238
- visit(themeId);
239
- return resolved;
240
- }
34
+ /**
35
+ * Unregister a theme
36
+ * @param registry - Theme registry object
37
+ * @param id - Theme identifier
38
+ */
39
+ export function unregisterTheme(registry: ThemeRegistry, id: string): boolean {
40
+ const exists = id in registry;
41
+ delete registry[id];
42
+ return exists;
43
+ }
241
44
 
242
- /**
243
- * Resolve dependencies and build dependency graph
244
- */
245
- private resolveDependencies(): void {
246
- // Build dependents map
247
- for (const entry of this.entries.values()) {
248
- for (const dep of entry.dependencies) {
249
- const depEntry = this.entries.get(dep);
250
- if (depEntry) {
251
- if (!depEntry.dependents.includes(entry.id)) {
252
- depEntry.dependents.push(entry.id);
253
- }
254
- }
255
- }
256
- }
257
- }
45
+ /**
46
+ * Check if a theme is registered
47
+ * @param registry - Theme registry object
48
+ * @param id - Theme identifier
49
+ */
50
+ export function hasTheme(registry: ThemeRegistry, id: string): boolean {
51
+ return id in registry;
52
+ }
258
53
 
259
- /**
260
- * Validate all themes
261
- */
262
- validate(): { valid: boolean; errors: string[] } {
263
- const errors: string[] = [];
54
+ /**
55
+ * Get theme metadata
56
+ * @param registry - Theme registry object
57
+ * @param id - Theme identifier
58
+ */
59
+ export function getTheme(registry: ThemeRegistry, id: string): ThemeMetadata | undefined {
60
+ return registry[id];
61
+ }
264
62
 
265
- // Check for circular dependencies
266
- for (const themeId of this.entries.keys()) {
267
- try {
268
- this.resolveDependencyOrder(themeId);
269
- } catch (error) {
270
- errors.push(error instanceof Error ? error.message : String(error));
271
- }
272
- }
63
+ /**
64
+ * Get all registered theme metadata
65
+ * @param registry - Theme registry object
66
+ */
67
+ export function getAllThemes(registry: ThemeRegistry): ThemeMetadata[] {
68
+ return Object.values(registry);
69
+ }
273
70
 
274
- // Check for missing dependencies
275
- for (const [themeId, entry] of this.entries.entries()) {
276
- for (const dep of entry.dependencies) {
277
- if (!this.has(dep)) {
278
- errors.push(`Theme "${themeId}" depends on non-existent theme: ${dep}`);
279
- }
280
- }
281
- }
71
+ /**
72
+ * Get all registered theme IDs
73
+ * @param registry - Theme registry object
74
+ */
75
+ export function getThemeIds(registry: ThemeRegistry): string[] {
76
+ return Object.keys(registry);
77
+ }
282
78
 
283
- return {
284
- valid: errors.length === 0,
285
- errors,
286
- };
287
- }
79
+ /**
80
+ * Clear all registered themes
81
+ * @param registry - Theme registry object
82
+ */
83
+ export function clearThemes(registry: ThemeRegistry): void {
84
+ Object.keys(registry).forEach(key => delete registry[key]);
85
+ }
288
86
 
289
- /**
290
- * Clear registry
291
- */
292
- clear(): void {
293
- this.entries.clear();
294
- this.config = null;
295
- this.initialized = false;
296
- }
87
+ /**
88
+ * Get the number of registered themes
89
+ * @param registry - Theme registry object
90
+ */
91
+ export function getThemeCount(registry: ThemeRegistry): number {
92
+ return Object.keys(registry).length;
297
93
  }
@@ -1,12 +1,9 @@
1
1
  /**
2
2
  * Theme Composition Utilities
3
- *
4
- * Utilities for composing, merging, and extending themes.
3
+ *
4
+ * Simplified utilities for composing and merging DesignTokens.
5
5
  */
6
6
 
7
- import type { Theme, ThemeOptions } from '../types';
8
- import { createThemeObject } from './createThemeObject';
9
-
10
7
  // ============================================================================
11
8
  // Deep Merge Utility
12
9
  // ============================================================================
@@ -22,7 +19,7 @@ function isObject(item: any): item is Record<string, any> {
22
19
  * Deep merge multiple objects
23
20
  * Later objects override earlier ones
24
21
  */
25
- export function deepMerge<T extends Record<string, any>>(...objects: Partial<T>[]): T {
22
+ export function deepMerge<T extends Record<string, unknown>>(...objects: Partial<T>[]): T {
26
23
  if (objects.length === 0) return {} as T;
27
24
  if (objects.length === 1) return objects[0] as T;
28
25
 
@@ -40,10 +37,10 @@ export function deepMerge<T extends Record<string, any>>(...objects: Partial<T>[
40
37
 
41
38
  if (isObject(targetValue) && isObject(sourceValue)) {
42
39
  // Recursively merge objects
43
- result[key] = deepMerge(targetValue as any, sourceValue as any) as any;
40
+ result[key] = deepMerge(targetValue as Record<string, unknown>, sourceValue as Record<string, unknown>) as T[Extract<keyof T, string>];
44
41
  } else {
45
42
  // Override with source value
46
- result[key] = sourceValue as any;
43
+ result[key] = sourceValue as T[Extract<keyof T, string>];
47
44
  }
48
45
  }
49
46
  }
@@ -52,100 +49,45 @@ export function deepMerge<T extends Record<string, any>>(...objects: Partial<T>[
52
49
  }
53
50
 
54
51
  // ============================================================================
55
- // Theme Merging
52
+ // DesignTokens Merging
56
53
  // ============================================================================
57
54
 
55
+ import type { DesignTokens } from '../tokens/tokens';
56
+
58
57
  /**
59
- * Merge multiple theme options into a single theme options object
60
- *
61
- * @param themes - Theme options to merge
62
- * @returns Merged theme options
63
- *
58
+ * Merge multiple DesignTokens objects into a single DesignTokens object
59
+ *
60
+ * @param tokens - DesignTokens objects to merge
61
+ * @returns Merged DesignTokens object
62
+ *
64
63
  * @example
65
64
  * ```typescript
66
- * const baseTheme = { palette: { primary: { main: '#000' } } };
67
- * const customTheme = { palette: { secondary: { main: '#fff' } } };
68
- * const merged = mergeTheme(baseTheme, customTheme);
65
+ * const baseTokens = { 'primary': '#000', 'spacing-4': '1rem' };
66
+ * const customTokens = { 'secondary': '#fff', 'spacing-4': '1.5rem' };
67
+ * const merged = mergeTheme(baseTokens, customTokens);
68
+ * // Returns: { 'primary': '#000', 'secondary': '#fff', 'spacing-4': '1.5rem' }
69
69
  * ```
70
70
  */
71
- export function mergeTheme(...themes: ThemeOptions[]): ThemeOptions {
72
- return deepMerge({}, ...themes);
71
+ export function mergeTheme(...tokens: Partial<DesignTokens>[]): Partial<DesignTokens> {
72
+ return deepMerge({}, ...tokens);
73
73
  }
74
74
 
75
75
  /**
76
- * Extend an existing theme with new options
77
- *
78
- * @param baseTheme - Base theme to extend (can be Theme or ThemeOptions)
79
- * @param extension - Theme options to extend with
80
- * @returns New theme with extended options
81
- *
76
+ * Extend DesignTokens with additional tokens
77
+ *
78
+ * @param baseTokens - Base DesignTokens to extend
79
+ * @param extension - Additional DesignTokens to merge
80
+ * @returns Extended DesignTokens object
81
+ *
82
82
  * @example
83
83
  * ```typescript
84
- * const base = createTheme({ palette: { primary: { main: '#000' } } });
85
- * const extended = extendTheme(base, {
86
- * palette: { secondary: { main: '#fff' } }
87
- * });
84
+ * const base = { 'primary': '#000' };
85
+ * const extended = extendTheme(base, { 'secondary': '#fff' });
86
+ * // Returns: { 'primary': '#000', 'secondary': '#fff' }
88
87
  * ```
89
88
  */
90
- export function extendTheme(baseTheme: Theme | ThemeOptions, extension: ThemeOptions): Theme {
91
- // If baseTheme is a complete Theme, extract the options
92
- const baseOptions: ThemeOptions = (baseTheme as any).__isJSTheme
93
- ? extractThemeOptions(baseTheme as Theme)
94
- : (baseTheme as ThemeOptions);
95
-
96
- const merged = mergeTheme(baseOptions, extension);
97
- return createThemeObject(merged);
98
- }
99
-
100
- /**
101
- * Extract theme options from a complete Theme object
102
- */
103
- function extractThemeOptions(theme: Theme): ThemeOptions {
104
- return {
105
- name: theme.name,
106
- class: theme.class,
107
- description: theme.description,
108
- author: theme.author,
109
- version: theme.version,
110
- tags: theme.tags,
111
- supportsDarkMode: theme.supportsDarkMode,
112
- status: theme.status,
113
- a11y: theme.a11y,
114
- color: theme.color,
115
- features: theme.features,
116
- dependencies: theme.dependencies,
117
- palette: {
118
- primary: theme.palette.primary,
119
- secondary: theme.palette.secondary,
120
- error: theme.palette.error,
121
- warning: theme.palette.warning,
122
- info: theme.palette.info,
123
- success: theme.palette.success,
124
- background: theme.palette.background,
125
- text: theme.palette.text,
126
- },
127
- typography: {
128
- fontFamily: theme.typography.fontFamily,
129
- fontSize: theme.typography.fontSize,
130
- fontWeightLight: theme.typography.fontWeightLight,
131
- fontWeightRegular: theme.typography.fontWeightRegular,
132
- fontWeightMedium: theme.typography.fontWeightMedium,
133
- fontWeightSemiBold: theme.typography.fontWeightSemiBold,
134
- fontWeightBold: theme.typography.fontWeightBold,
135
- h1: theme.typography.h1,
136
- h2: theme.typography.h2,
137
- h3: theme.typography.h3,
138
- h4: theme.typography.h4,
139
- h5: theme.typography.h5,
140
- h6: theme.typography.h6,
141
- body1: theme.typography.body1,
142
- body2: theme.typography.body2,
143
- },
144
- shadows: theme.shadows,
145
- transitions: theme.transitions,
146
- zIndex: theme.zIndex,
147
- custom: theme.custom,
148
- };
89
+ export function extendTheme(baseTokens: Partial<DesignTokens>, extension: Partial<DesignTokens>): Partial<DesignTokens> {
90
+ return mergeTheme(baseTokens, extension);
149
91
  }
150
92
 
151
93
  export default {