@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.
- package/README.md +3 -3
- package/dist/atomix.css +77 -0
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +77 -0
- package/dist/atomix.min.css.map +1 -1
- package/dist/charts.js +50 -142
- package/dist/charts.js.map +1 -1
- package/dist/core.d.ts +2 -2
- package/dist/core.js +179 -274
- package/dist/core.js.map +1 -1
- package/dist/forms.js +50 -142
- package/dist/forms.js.map +1 -1
- package/dist/heavy.js +179 -274
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +1255 -1226
- package/dist/index.esm.js +2806 -2958
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3113 -3269
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/theme.d.ts +313 -667
- package/dist/theme.js +1818 -2589
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AtomixGlass/AtomixGlass.tsx +128 -356
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +1 -1
- package/src/components/Button/Button.tsx +85 -167
- package/src/components/DataTable/DataTable.stories.tsx +238 -0
- package/src/components/DataTable/DataTable.test.tsx +450 -0
- package/src/components/DataTable/DataTable.tsx +384 -61
- package/src/components/DatePicker/DatePicker.tsx +29 -38
- package/src/components/Upload/Upload.tsx +539 -40
- package/src/lib/composables/useAtomixGlass.ts +7 -7
- package/src/lib/composables/useDataTable.ts +355 -15
- package/src/lib/composables/useDatePicker.ts +19 -0
- package/src/lib/config/loader.ts +2 -3
- package/src/lib/constants/components.ts +17 -0
- package/src/lib/hooks/usePerformanceMonitor.ts +1 -1
- package/src/lib/theme/adapters/cssVariableMapper.ts +29 -14
- package/src/lib/theme/adapters/index.ts +1 -4
- package/src/lib/theme/config/configLoader.ts +82 -223
- package/src/lib/theme/config/loader.ts +15 -21
- package/src/lib/theme/constants/constants.ts +1 -1
- package/src/lib/theme/core/ThemeRegistry.ts +75 -279
- package/src/lib/theme/core/composeTheme.ts +30 -88
- package/src/lib/theme/core/createTheme.ts +88 -51
- package/src/lib/theme/core/createThemeObject.ts +2 -2
- package/src/lib/theme/core/index.ts +15 -2
- package/src/lib/theme/errors/errors.ts +1 -1
- package/src/lib/theme/generators/generateCSSNested.ts +131 -0
- package/src/lib/theme/generators/generateCSSVariables.ts +24 -16
- package/src/lib/theme/generators/index.ts +6 -0
- package/src/lib/theme/index.ts +45 -27
- package/src/lib/theme/runtime/ThemeApplicator.ts +6 -109
- package/src/lib/theme/runtime/ThemeErrorBoundary.tsx +1 -1
- package/src/lib/theme/runtime/ThemeProvider.tsx +393 -544
- package/src/lib/theme/runtime/index.ts +1 -0
- package/src/lib/theme/runtime/useTheme.ts +1 -1
- package/src/lib/theme/runtime/useThemeTokens.ts +122 -0
- package/src/lib/theme/test/testTheme.ts +2 -1
- package/src/lib/theme/types.ts +14 -14
- package/src/lib/theme/utils/componentTheming.ts +140 -0
- package/src/lib/theme/utils/domUtils.ts +57 -15
- package/src/lib/theme/utils/injectCSS.ts +0 -1
- package/src/lib/theme/utils/naming.ts +100 -0
- package/src/lib/theme/utils/themeHelpers.ts +1 -39
- package/src/lib/theme/utils/themeUtils.ts +1 -170
- package/src/lib/types/components.ts +145 -0
- package/src/lib/utils/componentUtils.ts +1 -1
- package/src/lib/utils/dataTableExport.ts +143 -0
- package/src/lib/utils/memoryMonitor.ts +3 -3
- package/src/lib/utils/themeNaming.ts +135 -0
- package/src/styles/06-components/_components.data-table.scss +95 -0
|
@@ -1,94 +1,131 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Core Theme Functions
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Simplified theme system using DesignTokens only.
|
|
5
5
|
* Config-first approach: loads from atomix.config.ts when no input is provided.
|
|
6
|
-
* Config file is required for automatic loading.
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
import type { DesignTokens } from '../tokens/tokens';
|
|
10
|
-
import type { Theme } from '../types';
|
|
11
9
|
import type { GenerateCSSVariablesOptions } from '../generators/generateCSS';
|
|
12
10
|
import { createTokens } from '../tokens/tokens';
|
|
13
11
|
import { generateCSSVariables } from '../generators/generateCSS';
|
|
14
|
-
import {
|
|
15
|
-
import { loadThemeFromConfigSync } from '../config/configLoader';
|
|
12
|
+
import { ThemeError, ThemeErrorCode } from '../errors/errors';
|
|
16
13
|
|
|
17
14
|
/**
|
|
18
|
-
* Create theme CSS from
|
|
19
|
-
*
|
|
15
|
+
* Create theme CSS from DesignTokens
|
|
16
|
+
*
|
|
20
17
|
* **Config-First Approach**: If no input is provided, loads from `atomix.config.ts`.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @param input - DesignTokens (partial), Theme object, or undefined (loads from config)
|
|
18
|
+
*
|
|
19
|
+
* @param input - DesignTokens (partial) or undefined (loads from config)
|
|
24
20
|
* @param options - CSS generation options (prefix is automatically read from config if not provided)
|
|
25
21
|
* @returns CSS string with custom properties
|
|
26
22
|
* @throws Error if config loading fails when no input is provided
|
|
27
|
-
*
|
|
23
|
+
*
|
|
28
24
|
* @example
|
|
29
25
|
* ```typescript
|
|
30
|
-
* // Loads from atomix.config.ts
|
|
26
|
+
* // Loads from atomix.config.ts
|
|
31
27
|
* const css = createTheme();
|
|
32
|
-
*
|
|
28
|
+
*
|
|
33
29
|
* // Using DesignTokens
|
|
34
30
|
* const css = createTheme({
|
|
35
31
|
* 'primary': '#7c3aed',
|
|
36
32
|
* 'spacing-4': '1rem',
|
|
37
33
|
* });
|
|
38
|
-
*
|
|
39
|
-
* // Using Theme object
|
|
40
|
-
* const theme = createThemeObject({ palette: { primary: { main: '#7c3aed' } } });
|
|
41
|
-
* const css = createTheme(theme);
|
|
42
|
-
*
|
|
34
|
+
*
|
|
43
35
|
* // With custom options
|
|
44
36
|
* const css = createTheme(undefined, { prefix: 'myapp', selector: ':root' });
|
|
45
37
|
* ```
|
|
46
38
|
*/
|
|
47
39
|
export function createTheme(
|
|
48
|
-
input?: Partial<DesignTokens
|
|
40
|
+
input?: Partial<DesignTokens>,
|
|
49
41
|
options?: GenerateCSSVariablesOptions
|
|
50
42
|
): string {
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
// Validate options if provided
|
|
44
|
+
if (options?.prefix) {
|
|
45
|
+
const prefixPattern = /^[a-z][a-z0-9-]*$/;
|
|
46
|
+
if (!prefixPattern.test(options.prefix)) {
|
|
47
|
+
throw new ThemeError(
|
|
48
|
+
`Invalid CSS variable prefix: "${options.prefix}". Prefix must start with a lowercase letter and contain only lowercase letters, numbers, and hyphens (e.g., "atomix", "my-app").`,
|
|
49
|
+
ThemeErrorCode.THEME_VALIDATION_FAILED,
|
|
50
|
+
{ prefix: options.prefix, pattern: prefixPattern.toString() }
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Validate selector if provided
|
|
56
|
+
if (options?.selector) {
|
|
57
|
+
// Basic validation - selector should be a valid CSS selector
|
|
58
|
+
if (typeof options.selector !== 'string' || options.selector.trim().length === 0) {
|
|
59
|
+
throw new ThemeError(
|
|
60
|
+
`Invalid CSS selector: "${options.selector}". Selector must be a non-empty string (e.g., ":root", ".my-theme").`,
|
|
61
|
+
ThemeErrorCode.THEME_VALIDATION_FAILED,
|
|
62
|
+
{ selector: options.selector }
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
53
66
|
|
|
54
|
-
//
|
|
67
|
+
// Determine tokens based on input
|
|
68
|
+
let tokens: Partial<DesignTokens>;
|
|
69
|
+
|
|
55
70
|
if (!input) {
|
|
56
|
-
|
|
71
|
+
// Check if we're in a browser environment
|
|
72
|
+
if (typeof window !== 'undefined') {
|
|
73
|
+
throw new ThemeError(
|
|
74
|
+
'No input provided and config loading is not available in browser environment. Please provide tokens explicitly or use Node.js/SSR environment.',
|
|
75
|
+
ThemeErrorCode.CONFIG_LOAD_FAILED,
|
|
76
|
+
{ environment: 'browser' }
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Load from config when no input provided
|
|
81
|
+
let loadThemeFromConfigSync: any;
|
|
82
|
+
let loadAtomixConfig: any;
|
|
57
83
|
|
|
58
|
-
// Get prefix from config
|
|
59
84
|
try {
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
const configLoaderModule = require('../config/configLoader');
|
|
86
|
+
const loaderModule = require('../../config/loader');
|
|
87
|
+
|
|
88
|
+
loadThemeFromConfigSync = configLoaderModule.loadThemeFromConfigSync;
|
|
89
|
+
loadAtomixConfig = loaderModule.loadAtomixConfig;
|
|
90
|
+
|
|
91
|
+
tokens = loadThemeFromConfigSync();
|
|
92
|
+
|
|
93
|
+
// Get prefix from config if needed
|
|
94
|
+
if (!options?.prefix) {
|
|
95
|
+
try {
|
|
96
|
+
const config = loadAtomixConfig({ configPath: 'atomix.config.ts', required: false });
|
|
97
|
+
options = { ...options, prefix: config?.prefix || 'atomix' };
|
|
98
|
+
} catch (error) {
|
|
99
|
+
// If config loading fails, use default prefix
|
|
100
|
+
options = { ...options, prefix: 'atomix' };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
64
103
|
} catch (error) {
|
|
65
|
-
|
|
104
|
+
throw new ThemeError(
|
|
105
|
+
'No input provided and config loading is not available in this environment. Please provide tokens explicitly.',
|
|
106
|
+
ThemeErrorCode.CONFIG_LOAD_FAILED,
|
|
107
|
+
{ error: error instanceof Error ? error.message : String(error) }
|
|
108
|
+
);
|
|
66
109
|
}
|
|
67
|
-
|
|
68
|
-
tokens = configTokens;
|
|
69
110
|
} else {
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} else {
|
|
78
|
-
// Already DesignTokens
|
|
79
|
-
tokens = input as Partial<DesignTokens>;
|
|
111
|
+
// Validate input tokens structure
|
|
112
|
+
if (typeof input !== 'object' || input === null || Array.isArray(input)) {
|
|
113
|
+
throw new ThemeError(
|
|
114
|
+
`Invalid tokens input. Expected an object with DesignTokens, but received: ${typeof input}.`,
|
|
115
|
+
ThemeErrorCode.THEME_VALIDATION_FAILED,
|
|
116
|
+
{ inputType: typeof input }
|
|
117
|
+
);
|
|
80
118
|
}
|
|
119
|
+
|
|
120
|
+
// Use DesignTokens directly
|
|
121
|
+
tokens = input;
|
|
81
122
|
}
|
|
82
123
|
|
|
83
124
|
// Merge with defaults and generate CSS
|
|
84
125
|
const allTokens = createTokens(tokens);
|
|
85
|
-
|
|
86
|
-
// Use prefix from config if not provided in options
|
|
87
|
-
const finalOptions: GenerateCSSVariablesOptions = {
|
|
88
|
-
...options,
|
|
89
|
-
prefix: options?.prefix ?? configPrefix ?? 'atomix',
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
return generateCSSVariables(allTokens, finalOptions);
|
|
93
|
-
}
|
|
94
126
|
|
|
127
|
+
// Get prefix from options or use default
|
|
128
|
+
const prefix = options?.prefix ?? 'atomix';
|
|
129
|
+
|
|
130
|
+
return generateCSSVariables(allTokens, { ...options, prefix });
|
|
131
|
+
}
|
|
@@ -327,8 +327,8 @@ export function createThemeObject(...options: ThemeOptions[]): Theme {
|
|
|
327
327
|
|
|
328
328
|
// Create typography
|
|
329
329
|
const typography: Theme['typography'] = deepMerge(
|
|
330
|
-
{ ...DEFAULT_TYPOGRAPHY } as
|
|
331
|
-
(mergedOptions.typography || {}) as
|
|
330
|
+
{ ...DEFAULT_TYPOGRAPHY } as Partial<Theme['typography']>,
|
|
331
|
+
(mergedOptions.typography || {}) as Partial<Theme['typography']>
|
|
332
332
|
) as Theme['typography'];
|
|
333
333
|
|
|
334
334
|
// Create spacing
|
|
@@ -5,6 +5,19 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
export { createTheme } from './createTheme';
|
|
8
|
-
export { createThemeObject } from './createThemeObject';
|
|
9
8
|
export { deepMerge, mergeTheme, extendTheme } from './composeTheme';
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
// Simplified Theme Registry API
|
|
11
|
+
export {
|
|
12
|
+
createThemeRegistry,
|
|
13
|
+
registerTheme,
|
|
14
|
+
unregisterTheme,
|
|
15
|
+
hasTheme,
|
|
16
|
+
getTheme,
|
|
17
|
+
getAllThemes,
|
|
18
|
+
getThemeIds,
|
|
19
|
+
clearThemes,
|
|
20
|
+
getThemeCount,
|
|
21
|
+
type ThemeRegistry,
|
|
22
|
+
type ThemeMetadata
|
|
23
|
+
} from './ThemeRegistry';
|
|
@@ -120,7 +120,7 @@ export class ThemeLogger {
|
|
|
120
120
|
|
|
121
121
|
constructor(config: LoggerConfig = {}) {
|
|
122
122
|
this.config = {
|
|
123
|
-
level: config.level ?? (process.env
|
|
123
|
+
level: config.level ?? (typeof process !== 'undefined' && process.env?.NODE_ENV === 'production' ? LogLevel.WARN : LogLevel.INFO),
|
|
124
124
|
enableConsole: config.enableConsole ?? true,
|
|
125
125
|
onError: config.onError,
|
|
126
126
|
onWarn: config.onWarn,
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS Variable Generator for Nested Tokens
|
|
3
|
+
*
|
|
4
|
+
* Generates CSS custom properties from nested token structures.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { DesignTokens } from '../tokens/tokens';
|
|
8
|
+
import { generateCSSVariables } from './generateCSS';
|
|
9
|
+
import { ThemeNaming } from '../../utils/themeNaming';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Options for CSS variable generation with nested support
|
|
13
|
+
*/
|
|
14
|
+
export interface GenerateNestedCSSVariablesOptions {
|
|
15
|
+
/** CSS selector for the variables (default: ':root') */
|
|
16
|
+
selector?: string;
|
|
17
|
+
/** Prefix for CSS variables (default: 'atomix') */
|
|
18
|
+
prefix?: string;
|
|
19
|
+
/** Separator for nested tokens (default: '-') */
|
|
20
|
+
separator?: string;
|
|
21
|
+
/** Whether to flatten nested objects (default: true) */
|
|
22
|
+
flatten?: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Generate CSS variables from nested token structure
|
|
27
|
+
*
|
|
28
|
+
* Converts nested token object to CSS custom properties.
|
|
29
|
+
* Supports both nested objects and flat token structures.
|
|
30
|
+
*
|
|
31
|
+
* @param tokens - Design tokens object (can be nested)
|
|
32
|
+
* @param options - Generation options
|
|
33
|
+
* @returns CSS string with custom properties
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const tokens = {
|
|
38
|
+
* color: {
|
|
39
|
+
* primary: '#7c3aed',
|
|
40
|
+
* secondary: '#10b981',
|
|
41
|
+
* },
|
|
42
|
+
* spacing: {
|
|
43
|
+
* small: '0.5rem',
|
|
44
|
+
* medium: '1rem',
|
|
45
|
+
* },
|
|
46
|
+
* };
|
|
47
|
+
*
|
|
48
|
+
* const css = generateNestedCSSVariables(tokens);
|
|
49
|
+
* // Returns: ":root {
|
|
50
|
+
--atomix-color-primary: #7c3aed;
|
|
51
|
+
--atomix-color-secondary: #10b981;
|
|
52
|
+
--atomix-spacing-small: 0.5rem;
|
|
53
|
+
--atomix-spacing-medium: 1rem;
|
|
54
|
+
}"
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function generateNestedCSSVariables(
|
|
58
|
+
tokens: DesignTokens,
|
|
59
|
+
options: GenerateNestedCSSVariablesOptions = {}
|
|
60
|
+
): string {
|
|
61
|
+
const {
|
|
62
|
+
selector = ':root',
|
|
63
|
+
prefix = 'atomix',
|
|
64
|
+
separator = '-',
|
|
65
|
+
flatten = true,
|
|
66
|
+
} = options;
|
|
67
|
+
|
|
68
|
+
// Flatten nested token structure
|
|
69
|
+
const flattened = flatten ? flattenTokens(tokens, separator) : tokens;
|
|
70
|
+
|
|
71
|
+
// Generate CSS variables using the original function
|
|
72
|
+
// Cast to DesignTokens since generateCSSVariables filters out undefined values
|
|
73
|
+
return generateCSSVariables(flattened as DesignTokens, { selector, prefix });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Flatten nested token structure
|
|
78
|
+
*
|
|
79
|
+
* @param tokens - Token object (can be nested)
|
|
80
|
+
* @param separator - Separator for nested keys
|
|
81
|
+
* @returns Flattened token object
|
|
82
|
+
*/
|
|
83
|
+
function flattenTokens(tokens: DesignTokens, separator: string): Partial<DesignTokens> {
|
|
84
|
+
const result: Partial<DesignTokens> = {};
|
|
85
|
+
|
|
86
|
+
for (const [key, value] of Object.entries(tokens)) {
|
|
87
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
88
|
+
// Recursively flatten nested objects
|
|
89
|
+
const flattened = flattenTokens(value, separator);
|
|
90
|
+
|
|
91
|
+
// Combine keys with separator
|
|
92
|
+
for (const [nestedKey, nestedValue] of Object.entries(flattened)) {
|
|
93
|
+
const newKey = `${key}${separator}${nestedKey}`;
|
|
94
|
+
result[newKey] = nestedValue;
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
// Direct value
|
|
98
|
+
result[key] = value;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Generate CSS variables with custom selector for nested tokens
|
|
107
|
+
*
|
|
108
|
+
* @param tokens - Design tokens object
|
|
109
|
+
* @param selector - CSS selector (e.g., '[data-theme="dark"]')
|
|
110
|
+
* @param prefix - CSS variable prefix
|
|
111
|
+
* @param separator - Separator for nested keys
|
|
112
|
+
* @returns CSS string
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const css = generateNestedCSSVariablesForSelector(
|
|
117
|
+
* tokens,
|
|
118
|
+
* '[data-theme="dark"]',
|
|
119
|
+
* 'atomix',
|
|
120
|
+
* '-'
|
|
121
|
+
* );
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export function generateNestedCSSVariablesForSelector(
|
|
125
|
+
tokens: DesignTokens,
|
|
126
|
+
selector: string,
|
|
127
|
+
prefix: string = 'atomix',
|
|
128
|
+
separator: string = '-'
|
|
129
|
+
): string {
|
|
130
|
+
return generateNestedCSSVariables(tokens, { selector, prefix, separator });
|
|
131
|
+
}
|
|
@@ -40,28 +40,36 @@ export interface GenerateCSSVariablesOptions {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Convert a nested object to flat CSS variable declarations
|
|
43
|
+
* Uses iterative approach for better performance with large objects
|
|
43
44
|
*/
|
|
44
45
|
function flattenObject(
|
|
45
46
|
obj: Record<string, any>,
|
|
46
47
|
prefix: string = '',
|
|
47
48
|
result: Record<string, string> = {}
|
|
48
49
|
): Record<string, string> {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
// Use iterative approach with stack to avoid deep recursion
|
|
51
|
+
const stack: Array<{ obj: Record<string, any>; prefix: string }> = [{ obj, prefix }];
|
|
52
|
+
|
|
53
|
+
while (stack.length > 0) {
|
|
54
|
+
const { obj: currentObj, prefix: currentPrefix } = stack.pop()!;
|
|
55
|
+
|
|
56
|
+
for (const key in currentObj) {
|
|
57
|
+
if (!Object.prototype.hasOwnProperty.call(currentObj, key)) continue;
|
|
58
|
+
|
|
59
|
+
const value = currentObj[key];
|
|
60
|
+
const newKey = currentPrefix ? `${currentPrefix}-${key}` : key;
|
|
61
|
+
|
|
62
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
63
|
+
// Skip special objects like functions
|
|
64
|
+
if (typeof value === 'function') continue;
|
|
65
|
+
|
|
66
|
+
// Add to stack for iterative processing
|
|
67
|
+
stack.push({ obj: value, prefix: newKey });
|
|
68
|
+
} else if (typeof value === 'string' || typeof value === 'number') {
|
|
69
|
+
// Convert camelCase to kebab-case
|
|
70
|
+
const kebabKey = newKey.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
|
71
|
+
result[kebabKey] = String(value);
|
|
72
|
+
}
|
|
65
73
|
}
|
|
66
74
|
}
|
|
67
75
|
|
|
@@ -10,6 +10,12 @@ export {
|
|
|
10
10
|
type GenerateCSSVariablesOptions,
|
|
11
11
|
} from './generateCSS';
|
|
12
12
|
|
|
13
|
+
export {
|
|
14
|
+
generateNestedCSSVariables,
|
|
15
|
+
generateNestedCSSVariablesForSelector,
|
|
16
|
+
type GenerateNestedCSSVariablesOptions,
|
|
17
|
+
} from './generateCSSNested';
|
|
18
|
+
|
|
13
19
|
export { generateCSSVariables as generateCSSVariablesFromTheme } from './generateCSSVariables';
|
|
14
20
|
|
|
15
21
|
export {
|
package/src/lib/theme/index.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Theme System Exports
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Simplified theme system using DesignTokens only.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```typescript
|
|
8
8
|
* import { createTheme, injectTheme } from '@shohojdhara/atomix/theme';
|
|
9
9
|
*
|
|
10
|
-
* // Using DesignTokens
|
|
10
|
+
* // Using DesignTokens
|
|
11
11
|
* const css = createTheme({ 'primary': '#7AFFD7', 'spacing-4': '1rem' });
|
|
12
12
|
* injectTheme(css);
|
|
13
13
|
*
|
|
@@ -22,17 +22,24 @@
|
|
|
22
22
|
// Core Theme Functions
|
|
23
23
|
// ============================================================================
|
|
24
24
|
|
|
25
|
-
//
|
|
25
|
+
// Create theme CSS from DesignTokens
|
|
26
26
|
export { createTheme } from './core';
|
|
27
27
|
|
|
28
|
-
// Theme object creation
|
|
29
|
-
export { createThemeObject } from './core';
|
|
30
|
-
|
|
31
28
|
// Theme composition
|
|
32
29
|
export { deepMerge, mergeTheme, extendTheme } from './core';
|
|
33
30
|
|
|
34
|
-
// Theme
|
|
35
|
-
export {
|
|
31
|
+
// Simplified Theme Registry
|
|
32
|
+
export {
|
|
33
|
+
createThemeRegistry,
|
|
34
|
+
registerTheme,
|
|
35
|
+
unregisterTheme,
|
|
36
|
+
hasTheme,
|
|
37
|
+
getTheme,
|
|
38
|
+
getAllThemes,
|
|
39
|
+
getThemeIds,
|
|
40
|
+
clearThemes,
|
|
41
|
+
getThemeCount,
|
|
42
|
+
} from './core';
|
|
36
43
|
|
|
37
44
|
// ============================================================================
|
|
38
45
|
// Theme Injection and Management
|
|
@@ -79,16 +86,32 @@ export {
|
|
|
79
86
|
} from './generators';
|
|
80
87
|
|
|
81
88
|
// ============================================================================
|
|
82
|
-
//
|
|
89
|
+
// Naming and Component Theming Utilities
|
|
83
90
|
// ============================================================================
|
|
84
91
|
|
|
85
|
-
export {
|
|
92
|
+
export {
|
|
93
|
+
generateClassName,
|
|
94
|
+
generateCSSVariableName,
|
|
95
|
+
normalizeThemeTokens,
|
|
96
|
+
camelToKebab,
|
|
97
|
+
themePropertyToCSSVar,
|
|
98
|
+
type NamingOptions,
|
|
99
|
+
} from './utils/naming';
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
getComponentThemeValue,
|
|
103
|
+
generateComponentCSSVars,
|
|
104
|
+
applyComponentTheme,
|
|
105
|
+
useComponentTheme,
|
|
106
|
+
type ComponentThemeOptions,
|
|
107
|
+
} from './utils/componentTheming';
|
|
86
108
|
|
|
87
109
|
// ============================================================================
|
|
88
|
-
//
|
|
110
|
+
// Injection Utilities
|
|
89
111
|
// ============================================================================
|
|
90
112
|
|
|
91
|
-
export {
|
|
113
|
+
export { injectCSS, removeCSS, isCSSInjected } from './utils/injectCSS';
|
|
114
|
+
|
|
92
115
|
|
|
93
116
|
// ============================================================================
|
|
94
117
|
// Config Loader
|
|
@@ -106,6 +129,7 @@ export {
|
|
|
106
129
|
// Core React components and hooks
|
|
107
130
|
export { ThemeProvider } from './runtime/ThemeProvider';
|
|
108
131
|
export { useTheme } from './runtime/useTheme';
|
|
132
|
+
export { useThemeTokens } from './runtime/useThemeTokens';
|
|
109
133
|
export { ThemeContext } from './runtime/ThemeContext';
|
|
110
134
|
export { ThemeErrorBoundary } from './runtime/ThemeErrorBoundary';
|
|
111
135
|
|
|
@@ -115,25 +139,16 @@ export { ThemeApplicator, getThemeApplicator, applyTheme } from './runtime/Theme
|
|
|
115
139
|
// DevTools (for development and debugging)
|
|
116
140
|
export * from './devtools';
|
|
117
141
|
|
|
118
|
-
//
|
|
119
|
-
export {
|
|
120
|
-
themeToDesignTokens,
|
|
121
|
-
designTokensToCSSVars,
|
|
122
|
-
createDesignTokensFromTheme,
|
|
123
|
-
designTokensToTheme,
|
|
124
|
-
} from './adapters';
|
|
142
|
+
// CSS variable utilities
|
|
143
|
+
export { designTokensToCSSVars } from './adapters';
|
|
125
144
|
|
|
126
|
-
// Theme helpers (utilities for working with
|
|
145
|
+
// Theme helpers (utilities for working with DesignTokens)
|
|
127
146
|
export {
|
|
128
|
-
getDesignTokensFromTheme,
|
|
129
147
|
isDesignTokens,
|
|
130
|
-
isThemeObject,
|
|
131
148
|
} from './utils/themeHelpers';
|
|
132
149
|
|
|
133
150
|
// CSS variable utilities
|
|
134
151
|
export {
|
|
135
|
-
generateCSSVariableName,
|
|
136
|
-
generateComponentCSSVars,
|
|
137
152
|
mapSCSSTokensToCSSVars,
|
|
138
153
|
applyCSSVariables,
|
|
139
154
|
removeCSSVariables,
|
|
@@ -147,10 +162,9 @@ export {
|
|
|
147
162
|
// RTL Support
|
|
148
163
|
export { RTLManager } from './i18n/rtl';
|
|
149
164
|
|
|
165
|
+
|
|
150
166
|
// Types
|
|
151
167
|
export type {
|
|
152
|
-
Theme,
|
|
153
|
-
ThemeMetadata,
|
|
154
168
|
ThemeChangeEvent,
|
|
155
169
|
ThemeLoadOptions,
|
|
156
170
|
ThemeValidationResult,
|
|
@@ -161,6 +175,10 @@ export type {
|
|
|
161
175
|
ThemeComponentOverrides,
|
|
162
176
|
} from './types';
|
|
163
177
|
|
|
178
|
+
// Note: Theme type is deprecated - use DesignTokens instead
|
|
179
|
+
// Keeping for backward compatibility with devtools and internal use only
|
|
180
|
+
export type { Theme } from './types';
|
|
181
|
+
|
|
164
182
|
export type { ThemeErrorBoundaryProps } from './runtime/ThemeErrorBoundary';
|
|
165
183
|
|
|
166
184
|
export type {
|
|
@@ -168,4 +186,4 @@ export type {
|
|
|
168
186
|
CSSVariableNamingOptions,
|
|
169
187
|
} from './adapters/cssVariableMapper';
|
|
170
188
|
|
|
171
|
-
export type { RTLConfig } from './i18n/rtl';
|
|
189
|
+
export type { RTLConfig } from './i18n/rtl';
|