@shohojdhara/atomix 0.3.5 → 0.3.6
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 +101 -199
- package/atomix.config.ts +241 -0
- package/dist/atomix.css +260 -179
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +250 -179
- package/dist/atomix.min.css.map +1 -1
- package/dist/charts.js +61 -66
- package/dist/charts.js.map +1 -1
- package/dist/core.js +47 -31
- package/dist/core.js.map +1 -1
- package/dist/forms.js +47 -31
- package/dist/forms.js.map +1 -1
- package/dist/heavy.js +47 -31
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +1841 -1633
- package/dist/index.esm.js +4975 -4113
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +5151 -4290
- 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 +1572 -1442
- package/dist/theme.js +4816 -4080
- package/dist/theme.js.map +1 -1
- package/package.json +6 -20
- package/src/components/Accordion/Accordion.stories.tsx +50 -17
- package/src/components/AtomixGlass/AtomixGlass.tsx +65 -31
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +11 -4
- package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +1 -32
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +2 -2
- package/src/components/AtomixGlass/stories/shared-components.tsx +0 -31
- package/src/components/Avatar/Avatar.stories.tsx +7 -0
- package/src/components/Badge/Badge.stories.tsx +91 -13
- package/src/components/Block/Block.stories.tsx +7 -23
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +7 -0
- package/src/components/Button/Button.stories.tsx +141 -22
- package/src/components/Button/ButtonGroup.stories.tsx +315 -0
- package/src/components/Button/ButtonGroup.tsx +67 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Callout/Callout.stories.tsx +8 -6
- package/src/components/Card/Card.stories.tsx +82 -28
- package/src/components/Chart/AnimatedChart.tsx +0 -1
- package/src/components/Chart/AreaChart.tsx +0 -1
- package/src/components/Chart/BarChart.tsx +0 -1
- package/src/components/Chart/BubbleChart.tsx +0 -1
- package/src/components/Chart/CandlestickChart.tsx +0 -1
- package/src/components/Chart/Chart.stories.tsx +5 -7
- package/src/components/Chart/Chart.tsx +0 -16
- package/src/components/Chart/ChartRenderer.tsx +1 -1
- package/src/components/Chart/DonutChart.tsx +0 -1
- package/src/components/Chart/FunnelChart.tsx +0 -1
- package/src/components/Chart/GaugeChart.tsx +0 -1
- package/src/components/Chart/HeatmapChart.tsx +0 -1
- package/src/components/Chart/LineChart.tsx +0 -1
- package/src/components/Chart/MultiAxisChart.tsx +0 -1
- package/src/components/Chart/PieChart.tsx +0 -1
- package/src/components/Chart/RadarChart.tsx +0 -1
- package/src/components/Chart/ScatterChart.tsx +0 -1
- package/src/components/Chart/WaterfallChart.tsx +0 -1
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +7 -0
- package/src/components/DataTable/DataTable.stories.tsx +23 -16
- package/src/components/DatePicker/DatePicker.stories.tsx +27 -19
- package/src/components/Dropdown/Dropdown.stories.tsx +11 -19
- package/src/components/EdgePanel/EdgePanel.stories.tsx +1 -0
- package/src/components/Footer/Footer.stories.tsx +8 -6
- package/src/components/Footer/FooterLink.tsx +9 -2
- package/src/components/Form/Checkbox.stories.tsx +7 -0
- package/src/components/Form/Form.stories.tsx +7 -0
- package/src/components/Form/FormGroup.stories.tsx +9 -1
- package/src/components/Form/Input.stories.tsx +69 -16
- package/src/components/Form/Radio.stories.tsx +9 -1
- package/src/components/Form/Select.stories.tsx +9 -1
- package/src/components/Form/Textarea.stories.tsx +10 -2
- package/src/components/Hero/Hero.stories.tsx +7 -0
- package/src/components/List/List.stories.tsx +7 -0
- package/src/components/Messages/Messages.stories.tsx +8 -7
- package/src/components/Modal/Modal.stories.tsx +17 -6
- package/src/components/Navigation/Menu/Menu.stories.tsx +7 -0
- package/src/components/Navigation/Nav/Nav.stories.tsx +7 -0
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +1 -0
- package/src/components/Navigation/SideMenu/SideMenu.stories.tsx +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +188 -111
- package/src/components/Pagination/Pagination.tsx +83 -3
- package/src/components/PhotoViewer/PhotoViewer.stories.tsx +10 -5
- package/src/components/Popover/Popover.stories.tsx +191 -115
- package/src/components/ProductReview/ProductReview.stories.tsx +80 -58
- package/src/components/Progress/Progress.stories.tsx +79 -49
- package/src/components/Rating/Rating.stories.tsx +109 -84
- package/src/components/River/River.stories.tsx +194 -114
- package/src/components/SectionIntro/SectionIntro.stories.tsx +19 -9
- package/src/components/Slider/Slider.stories.tsx +7 -0
- package/src/components/Spinner/Spinner.stories.tsx +15 -11
- package/src/components/Steps/Steps.stories.tsx +132 -98
- package/src/components/Tabs/Tabs.stories.tsx +163 -112
- package/src/components/Testimonial/Testimonial.stories.tsx +114 -68
- package/src/components/Todo/Todo.stories.tsx +38 -12
- package/src/components/Toggle/Toggle.stories.tsx +61 -28
- package/src/components/Tooltip/Tooltip.stories.tsx +318 -200
- package/src/components/Upload/Upload.stories.tsx +122 -84
- package/src/components/VideoPlayer/VideoPlayer.stories.tsx +7 -24
- package/src/components/index.ts +1 -0
- package/src/lib/composables/useAtomixGlass.ts +2 -3
- package/src/lib/composables/useNavbar.ts +0 -10
- package/src/lib/config/loader.ts +2 -1
- package/src/lib/constants/components.ts +10 -0
- package/src/lib/hooks/useComponentCustomization.ts +1 -1
- package/src/lib/theme/README.md +174 -0
- package/src/lib/theme/adapters/index.ts +31 -0
- package/src/lib/theme/adapters/themeAdapter.ts +287 -0
- package/src/lib/theme/config/__tests__/configLoader.test.ts +207 -0
- package/src/lib/theme/config/configLoader.ts +254 -0
- package/src/lib/theme/config/loader.ts +37 -48
- package/src/lib/theme/config/types.ts +2 -2
- package/src/lib/theme/config/validator.ts +15 -91
- package/src/lib/theme/{constants.ts → constants/constants.ts} +0 -18
- package/src/lib/theme/constants/index.ts +8 -0
- package/src/lib/theme/core/ThemeRegistry.ts +19 -6
- package/src/lib/theme/core/__tests__/createTheme.test.ts +132 -0
- package/src/lib/theme/core/composeTheme.ts +155 -0
- package/src/lib/theme/core/createTheme.ts +94 -0
- package/src/lib/theme/{createTheme.ts → core/createThemeObject.ts} +10 -6
- package/src/lib/theme/core/index.ts +5 -19
- package/src/lib/theme/devtools/Comparator.tsx +346 -22
- package/src/lib/theme/devtools/IMPROVEMENTS.md +139 -38
- package/src/lib/theme/devtools/Inspector.tsx +335 -51
- package/src/lib/theme/devtools/LiveEditor.tsx +478 -107
- package/src/lib/theme/devtools/Preview.tsx +471 -221
- package/src/lib/theme/{core → devtools}/ThemeValidator.ts +1 -1
- package/src/lib/theme/devtools/index.ts +14 -4
- package/src/lib/theme/devtools/useHistory.ts +130 -0
- package/src/lib/theme/errors/index.ts +12 -0
- package/src/lib/theme/generators/cssFile.ts +79 -0
- package/src/lib/theme/generators/generateCSS.ts +89 -0
- package/src/lib/theme/{generateCSSVariables.ts → generators/generateCSSVariables.ts} +3 -13
- package/src/lib/theme/generators/index.ts +19 -0
- package/src/lib/theme/i18n/rtl.ts +5 -6
- package/src/lib/theme/index.ts +120 -15
- package/src/lib/theme/runtime/ThemeApplicator.ts +52 -111
- package/src/lib/theme/{ThemeContext.tsx → runtime/ThemeContext.tsx} +1 -1
- package/src/lib/theme/runtime/ThemeErrorBoundary.tsx +1 -1
- package/src/lib/theme/runtime/ThemeProvider.tsx +456 -179
- package/src/lib/theme/runtime/index.ts +1 -2
- package/src/lib/theme/runtime/useTheme.ts +1 -2
- package/src/lib/theme/test/testTheme.ts +385 -0
- package/src/lib/theme/tokens/index.ts +12 -0
- package/src/lib/theme/tokens/tokens.ts +721 -0
- package/src/lib/theme/types.ts +6 -42
- package/src/lib/theme/{utils.ts → utils/domUtils.ts} +2 -2
- package/src/lib/theme/utils/index.ts +11 -0
- package/src/lib/theme/utils/injectCSS.ts +90 -0
- package/src/lib/theme/utils/themeHelpers.ts +78 -0
- package/src/lib/theme/{themeUtils.ts → utils/themeUtils.ts} +1 -1
- package/src/lib/theme-tools.ts +7 -8
- package/src/lib/types/components.ts +40 -130
- package/src/lib/utils/componentUtils.ts +1 -1
- package/src/styles/01-settings/_settings.design-tokens.scss +4 -1
- package/src/styles/02-tools/_tools.button.scss +66 -79
- package/src/styles/06-components/_components.atomix-glass.scss +13 -3
- package/src/styles/06-components/_components.pagination.scss +88 -0
- package/scripts/sync-theme-config.js +0 -309
- package/src/lib/theme/composeTheme.ts +0 -370
- package/src/lib/theme/core/ThemeCache.ts +0 -283
- package/src/lib/theme/core/ThemeEngine.test.ts +0 -146
- package/src/lib/theme/core/ThemeEngine.ts +0 -665
- package/src/lib/theme/createThemeFromConfig.ts +0 -132
- package/src/lib/theme/devtools/CLI.ts +0 -364
- package/src/lib/theme/runtime/ThemeManager.test.ts +0 -192
- package/src/lib/theme/runtime/ThemeManager.ts +0 -446
- package/src/styles/03-generic/_generated-root.css +0 -26
- package/src/themes/README.md +0 -442
- package/src/themes/themes.config.js +0 -68
- /package/src/lib/theme/{cssVariableMapper.ts → adapters/cssVariableMapper.ts} +0 -0
- /package/src/lib/theme/{errors.ts → errors/errors.ts} +0 -0
package/src/lib/theme/types.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* TypeScript types and interfaces for the Atomix Design System theme management system.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { ThemeManager as ThemeManagerType } from './runtime/ThemeManager';
|
|
8
7
|
import type { PartStyleProps } from '../types/partProps';
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -42,39 +41,6 @@ export interface ThemeMetadata {
|
|
|
42
41
|
dependencies?: string[];
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
/**
|
|
46
|
-
* Theme manager configuration options
|
|
47
|
-
*/
|
|
48
|
-
export interface ThemeManagerConfig {
|
|
49
|
-
/** Available themes metadata */
|
|
50
|
-
themes: Record<string, ThemeMetadata>;
|
|
51
|
-
/** Default theme to use */
|
|
52
|
-
defaultTheme?: string | Theme;
|
|
53
|
-
/** Base path for theme CSS files */
|
|
54
|
-
basePath?: string;
|
|
55
|
-
/** CDN path for theme CSS files (optional) */
|
|
56
|
-
cdnPath?: string | null;
|
|
57
|
-
/** Themes to preload on initialization */
|
|
58
|
-
preload?: string[];
|
|
59
|
-
/** Enable lazy loading of themes */
|
|
60
|
-
lazy?: boolean;
|
|
61
|
-
/** localStorage key for persistence */
|
|
62
|
-
storageKey?: string;
|
|
63
|
-
/** Data attribute name for theme */
|
|
64
|
-
dataAttribute?: string;
|
|
65
|
-
/** Enable persistence */
|
|
66
|
-
enablePersistence?: boolean;
|
|
67
|
-
/** Custom CSS file extension */
|
|
68
|
-
cssExtension?: string;
|
|
69
|
-
/** Use minified CSS files */
|
|
70
|
-
useMinified?: boolean;
|
|
71
|
-
/** Callback when theme changes */
|
|
72
|
-
onThemeChange?: (theme: string | Theme) => void;
|
|
73
|
-
/** Callback when theme load fails */
|
|
74
|
-
onError?: (error: Error, themeName: string) => void;
|
|
75
|
-
/** RTL configuration */
|
|
76
|
-
rtl?: import('./i18n/rtl').RTLConfig;
|
|
77
|
-
}
|
|
78
44
|
|
|
79
45
|
/**
|
|
80
46
|
* Theme change event payload
|
|
@@ -160,7 +126,7 @@ export interface UseThemeOptions {
|
|
|
160
126
|
/** Custom storage key */
|
|
161
127
|
storageKey?: string;
|
|
162
128
|
/** Callback when theme changes */
|
|
163
|
-
onChange?: (theme: string | Theme) => void;
|
|
129
|
+
onChange?: (theme: string | Theme | import('./tokens').DesignTokens) => void;
|
|
164
130
|
}
|
|
165
131
|
|
|
166
132
|
/**
|
|
@@ -171,8 +137,8 @@ export interface UseThemeReturn {
|
|
|
171
137
|
theme: string;
|
|
172
138
|
/** Current active theme object (for JS themes) */
|
|
173
139
|
activeTheme: Theme | null;
|
|
174
|
-
/** Function to change theme */
|
|
175
|
-
setTheme: (theme: string | Theme
|
|
140
|
+
/** Function to change theme (supports string, Theme, or DesignTokens) */
|
|
141
|
+
setTheme: (theme: string | Theme | import('./tokens').DesignTokens | Partial<import('./tokens').DesignTokens>, options?: ThemeLoadOptions) => Promise<void>;
|
|
176
142
|
/** Available themes */
|
|
177
143
|
availableThemes: ThemeMetadata[];
|
|
178
144
|
/** Whether a theme is currently loading */
|
|
@@ -268,7 +234,7 @@ export interface ThemeProviderProps {
|
|
|
268
234
|
/** Use minified CSS */
|
|
269
235
|
useMinified?: boolean;
|
|
270
236
|
/** Callback when theme changes */
|
|
271
|
-
onThemeChange?: (theme: string | Theme) => void;
|
|
237
|
+
onThemeChange?: (theme: string | Theme | import('./tokens').DesignTokens) => void;
|
|
272
238
|
/** Callback on error */
|
|
273
239
|
onError?: (error: Error, themeName: string) => void;
|
|
274
240
|
}
|
|
@@ -281,8 +247,8 @@ export interface ThemeContextValue {
|
|
|
281
247
|
theme: string;
|
|
282
248
|
/** Current active theme object (for JS themes) */
|
|
283
249
|
activeTheme: Theme | null;
|
|
284
|
-
/** Set theme function */
|
|
285
|
-
setTheme: (theme: string | Theme
|
|
250
|
+
/** Set theme function (supports string, Theme, or DesignTokens) */
|
|
251
|
+
setTheme: (theme: string | Theme | import('./tokens').DesignTokens | Partial<import('./tokens').DesignTokens>, options?: ThemeLoadOptions) => Promise<void>;
|
|
286
252
|
/** Available themes */
|
|
287
253
|
availableThemes: ThemeMetadata[];
|
|
288
254
|
/** Loading state */
|
|
@@ -293,8 +259,6 @@ export interface ThemeContextValue {
|
|
|
293
259
|
isThemeLoaded: (themeName: string) => boolean;
|
|
294
260
|
/** Preload theme */
|
|
295
261
|
preloadTheme: (themeName: string) => Promise<void>;
|
|
296
|
-
/** Theme manager instance */
|
|
297
|
-
themeManager: ThemeManagerType;
|
|
298
262
|
}
|
|
299
263
|
|
|
300
264
|
// ============================================================================
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* and theme validation.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { ThemeMetadata, ThemeValidationResult } from '
|
|
9
|
-
import { THEME_LINK_ID_PREFIX } from '
|
|
8
|
+
import type { ThemeMetadata, ThemeValidationResult } from '../types';
|
|
9
|
+
import { THEME_LINK_ID_PREFIX } from '../constants/constants';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Check if code is running in a browser environment
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS Injection Utilities
|
|
3
|
+
*
|
|
4
|
+
* Inject CSS into HTML head via <style> element.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Check if running in browser environment
|
|
9
|
+
*/
|
|
10
|
+
function isBrowser(): boolean {
|
|
11
|
+
return typeof document !== 'undefined';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Inject CSS into HTML head via <style> element
|
|
16
|
+
*
|
|
17
|
+
* Creates or updates a style element in the document head.
|
|
18
|
+
* If an element with the same ID exists, it will be updated.
|
|
19
|
+
*
|
|
20
|
+
* @param css - CSS string to inject
|
|
21
|
+
* @param id - Style element ID (default: 'atomix-theme')
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const css = ':root { --atomix-color-primary: #7AFFD7; }';
|
|
26
|
+
* injectCSS(css);
|
|
27
|
+
*
|
|
28
|
+
* // With custom ID
|
|
29
|
+
* injectCSS(css, 'my-custom-theme');
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function injectCSS(
|
|
33
|
+
css: string,
|
|
34
|
+
id: string = 'atomix-theme'
|
|
35
|
+
): void {
|
|
36
|
+
if (!isBrowser()) {
|
|
37
|
+
console.warn('injectCSS: Not in browser environment, CSS not injected');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let styleElement = document.getElementById(id) as HTMLStyleElement | null;
|
|
42
|
+
|
|
43
|
+
if (!styleElement) {
|
|
44
|
+
styleElement = document.createElement('style');
|
|
45
|
+
styleElement.id = id;
|
|
46
|
+
styleElement.setAttribute('data-atomix-theme', 'true');
|
|
47
|
+
document.head.appendChild(styleElement);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
styleElement.textContent = css;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Remove injected CSS from DOM
|
|
55
|
+
*
|
|
56
|
+
* Removes the style element with the given ID from the document head.
|
|
57
|
+
*
|
|
58
|
+
* @param id - Style element ID to remove (default: 'atomix-theme')
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* removeCSS(); // Removes default 'atomix-theme'
|
|
63
|
+
* removeCSS('my-custom-theme'); // Removes custom ID
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export function removeCSS(id: string = 'atomix-theme'): void {
|
|
67
|
+
if (!isBrowser()) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const styleElement = document.getElementById(id);
|
|
72
|
+
if (styleElement) {
|
|
73
|
+
styleElement.remove();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Check if CSS is already injected
|
|
79
|
+
*
|
|
80
|
+
* @param id - Style element ID to check (default: 'atomix-theme')
|
|
81
|
+
* @returns True if style element exists
|
|
82
|
+
*/
|
|
83
|
+
export function isCSSInjected(id: string = 'atomix-theme'): boolean {
|
|
84
|
+
if (!isBrowser()) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return document.getElementById(id) !== null;
|
|
89
|
+
}
|
|
90
|
+
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Helper Functions
|
|
3
|
+
*
|
|
4
|
+
* Utility functions for working with themes and DesignTokens
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Theme } from '../types';
|
|
8
|
+
import type { DesignTokens } from '../tokens/tokens';
|
|
9
|
+
import { createDesignTokensFromTheme } from '../adapters/themeAdapter';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get DesignTokens from current theme
|
|
13
|
+
*
|
|
14
|
+
* Converts a Theme object to DesignTokens. Useful when you need to
|
|
15
|
+
* work with DesignTokens but have a Theme object.
|
|
16
|
+
*
|
|
17
|
+
* @param theme - Theme object to convert
|
|
18
|
+
* @returns DesignTokens object
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // If you have a Theme object, convert it to DesignTokens
|
|
23
|
+
* const tokens = getDesignTokensFromTheme(theme);
|
|
24
|
+
* // Now you can use tokens with unified theme system
|
|
25
|
+
* const css = createTheme(tokens);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function getDesignTokensFromTheme(theme: Theme | null): DesignTokens | null {
|
|
29
|
+
if (!theme) return null;
|
|
30
|
+
return createDesignTokensFromTheme(theme);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Check if a value is DesignTokens
|
|
35
|
+
*
|
|
36
|
+
* Type guard to check if an object is DesignTokens format.
|
|
37
|
+
*
|
|
38
|
+
* @param value - Value to check
|
|
39
|
+
* @returns True if value is DesignTokens
|
|
40
|
+
*/
|
|
41
|
+
export function isDesignTokens(value: unknown): value is DesignTokens {
|
|
42
|
+
if (!value || typeof value !== 'object') return false;
|
|
43
|
+
|
|
44
|
+
// DesignTokens is a flat object with string keys, no nested structures
|
|
45
|
+
const obj = value as Record<string, unknown>;
|
|
46
|
+
|
|
47
|
+
// Check for absence of Theme-specific properties
|
|
48
|
+
if ('palette' in obj || 'typography' in obj || '__isJSTheme' in obj) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Check if it has DesignTokens-like structure (flat string keys)
|
|
53
|
+
const keys = Object.keys(obj);
|
|
54
|
+
if (keys.length === 0) return false;
|
|
55
|
+
|
|
56
|
+
// Check if keys look like DesignTokens (kebab-case, no nesting)
|
|
57
|
+
const hasDesignTokenKeys = keys.some(key =>
|
|
58
|
+
/^[a-z]+(-[a-z0-9]+)*$/.test(key) &&
|
|
59
|
+
typeof obj[key] === 'string'
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return hasDesignTokenKeys;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Check if a value is a Theme object
|
|
67
|
+
*
|
|
68
|
+
* Type guard to check if an object is a Theme.
|
|
69
|
+
*
|
|
70
|
+
* @param value - Value to check
|
|
71
|
+
* @returns True if value is Theme
|
|
72
|
+
*/
|
|
73
|
+
export function isThemeObject(value: unknown): value is Theme {
|
|
74
|
+
if (!value || typeof value !== 'object') return false;
|
|
75
|
+
const obj = value as Record<string, unknown>;
|
|
76
|
+
return '__isJSTheme' in obj || ('palette' in obj && 'typography' in obj);
|
|
77
|
+
}
|
|
78
|
+
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* spacing helpers, and theme value accessors.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { Theme, SpacingFunction, SpacingOptions } from '
|
|
8
|
+
import type { Theme, SpacingFunction, SpacingOptions } from '../types';
|
|
9
9
|
|
|
10
10
|
// ============================================================================
|
|
11
11
|
// Color Manipulation Utilities
|
package/src/lib/theme-tools.ts
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Theme, ThemeMetadata } from './theme/types';
|
|
8
|
-
import {
|
|
9
|
-
import { extendTheme, mergeTheme } from './theme/composeTheme';
|
|
10
|
-
import { generateCSSVariables } from './theme/generateCSSVariables';
|
|
8
|
+
import { createThemeObject } from './theme/core/createThemeObject';
|
|
9
|
+
import { extendTheme, mergeTheme } from './theme/core/composeTheme';
|
|
10
|
+
import { generateCSSVariables } from './theme/generators/generateCSSVariables';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Quick theme creator with sensible defaults
|
|
14
14
|
*/
|
|
15
15
|
export function quickTheme(name: string, primaryColor: string, secondaryColor?: string): Theme {
|
|
16
|
-
return
|
|
16
|
+
return createThemeObject({
|
|
17
17
|
name,
|
|
18
18
|
palette: {
|
|
19
19
|
primary: { main: primaryColor },
|
|
@@ -119,7 +119,6 @@ export function importTheme(json: string): Theme {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
//
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
export { RTLManager } from './theme/i18n/rtl';
|
|
122
|
+
// Note: createTheme, extendTheme, mergeTheme, and generateCSSVariables
|
|
123
|
+
// are already exported from './theme' module. Import them directly from there.
|
|
124
|
+
// This file only exports theme-tools specific utilities.
|
|
@@ -560,6 +560,36 @@ export interface ButtonProps extends BaseComponentProps {
|
|
|
560
560
|
style?: React.CSSProperties;
|
|
561
561
|
}
|
|
562
562
|
|
|
563
|
+
/**
|
|
564
|
+
* ButtonGroup component properties
|
|
565
|
+
*/
|
|
566
|
+
export interface ButtonGroupProps extends BaseComponentProps {
|
|
567
|
+
/**
|
|
568
|
+
* ButtonGroup children (should be Button components)
|
|
569
|
+
*/
|
|
570
|
+
children?: ReactNode;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Additional CSS class names
|
|
574
|
+
*/
|
|
575
|
+
className?: string;
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Inline style for the component root element
|
|
579
|
+
*/
|
|
580
|
+
style?: React.CSSProperties;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* ARIA label for accessibility
|
|
584
|
+
*/
|
|
585
|
+
'aria-label'?: string;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* ARIA role for the button group
|
|
589
|
+
*/
|
|
590
|
+
role?: string;
|
|
591
|
+
}
|
|
592
|
+
|
|
563
593
|
/**
|
|
564
594
|
* Badge component properties
|
|
565
595
|
*/
|
|
@@ -631,69 +661,6 @@ export interface BadgeProps extends BaseComponentProps {
|
|
|
631
661
|
};
|
|
632
662
|
}
|
|
633
663
|
|
|
634
|
-
/**
|
|
635
|
-
* Block component properties (legacy - use BlockProps from component instead)
|
|
636
|
-
* @deprecated Use BlockProps from '@atomix/components/Block' instead
|
|
637
|
-
*/
|
|
638
|
-
export interface LegacyBlockProps extends BaseComponentProps {
|
|
639
|
-
/**
|
|
640
|
-
* The content to be rendered within the block
|
|
641
|
-
*/
|
|
642
|
-
children: ReactNode;
|
|
643
|
-
|
|
644
|
-
/**
|
|
645
|
-
* The HTML element to render as
|
|
646
|
-
* @default 'section'
|
|
647
|
-
*/
|
|
648
|
-
as?: 'section' | 'div' | 'article' | 'aside' | 'main';
|
|
649
|
-
|
|
650
|
-
/**
|
|
651
|
-
* Spacing size for vertical padding
|
|
652
|
-
* @default 'md'
|
|
653
|
-
*/
|
|
654
|
-
spacing?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'none';
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* Container configuration
|
|
658
|
-
*/
|
|
659
|
-
container?: {
|
|
660
|
-
/**
|
|
661
|
-
* Container type for content width
|
|
662
|
-
*/
|
|
663
|
-
type?: 'sm' | 'md' | 'lg' | 'xl' | 'fluid';
|
|
664
|
-
/**
|
|
665
|
-
* Additional container classes
|
|
666
|
-
*/
|
|
667
|
-
className?: string;
|
|
668
|
-
};
|
|
669
|
-
|
|
670
|
-
/**
|
|
671
|
-
* Whether to enable full-width content
|
|
672
|
-
* @default false
|
|
673
|
-
*/
|
|
674
|
-
fullWidth?: boolean;
|
|
675
|
-
|
|
676
|
-
/**
|
|
677
|
-
* Background color variant
|
|
678
|
-
*/
|
|
679
|
-
background?:
|
|
680
|
-
| 'primary'
|
|
681
|
-
| 'secondary'
|
|
682
|
-
| 'tertiary'
|
|
683
|
-
| 'invert'
|
|
684
|
-
| 'brand'
|
|
685
|
-
| 'error'
|
|
686
|
-
| 'success'
|
|
687
|
-
| 'warning'
|
|
688
|
-
| 'info'
|
|
689
|
-
| 'light';
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* Custom style for the block
|
|
693
|
-
*/
|
|
694
|
-
style?: React.CSSProperties;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
664
|
/**
|
|
698
665
|
* Callout component properties
|
|
699
666
|
*/
|
|
@@ -1098,42 +1065,6 @@ export type PhosphorIconsType = Exclude<
|
|
|
1098
1065
|
'IconContext' | 'IconBase' | 'createIcon' | 'default' | 'SSR'
|
|
1099
1066
|
>;
|
|
1100
1067
|
|
|
1101
|
-
/**
|
|
1102
|
-
* Icon component properties (legacy - use IconProps from component instead)
|
|
1103
|
-
* @deprecated Use IconProps from '@atomix/components/Icon' instead
|
|
1104
|
-
*/
|
|
1105
|
-
export interface LegacyIconProps extends BaseComponentProps {
|
|
1106
|
-
/**
|
|
1107
|
-
* Icon name from Phosphor Icons
|
|
1108
|
-
*/
|
|
1109
|
-
name: PhosphorIconsType;
|
|
1110
|
-
|
|
1111
|
-
/**
|
|
1112
|
-
* Icon size
|
|
1113
|
-
*/
|
|
1114
|
-
size?: IconSize | number;
|
|
1115
|
-
|
|
1116
|
-
/**
|
|
1117
|
-
* Icon weight/style
|
|
1118
|
-
*/
|
|
1119
|
-
weight?: IconWeight;
|
|
1120
|
-
|
|
1121
|
-
/**
|
|
1122
|
-
* Icon color
|
|
1123
|
-
*/
|
|
1124
|
-
color?: string;
|
|
1125
|
-
|
|
1126
|
-
/**
|
|
1127
|
-
* Alt text for accessibility
|
|
1128
|
-
*/
|
|
1129
|
-
alt?: string;
|
|
1130
|
-
|
|
1131
|
-
/**
|
|
1132
|
-
* Custom style
|
|
1133
|
-
*/
|
|
1134
|
-
style?: React.CSSProperties;
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
1068
|
/**
|
|
1138
1069
|
* Navbar position options
|
|
1139
1070
|
*/
|
|
@@ -1840,6 +1771,16 @@ export interface PaginationProps extends BaseComponentProps {
|
|
|
1840
1771
|
*/
|
|
1841
1772
|
showPrevNextButtons?: boolean;
|
|
1842
1773
|
|
|
1774
|
+
/**
|
|
1775
|
+
* Whether to show search input for jumping to a specific page
|
|
1776
|
+
*/
|
|
1777
|
+
showSearch?: boolean;
|
|
1778
|
+
|
|
1779
|
+
/**
|
|
1780
|
+
* Placeholder text for the search input
|
|
1781
|
+
*/
|
|
1782
|
+
searchPlaceholder?: string;
|
|
1783
|
+
|
|
1843
1784
|
/**
|
|
1844
1785
|
* Custom class for the pagination container
|
|
1845
1786
|
*/
|
|
@@ -2886,37 +2827,6 @@ export interface BreadcrumbItem {
|
|
|
2886
2827
|
className?: string;
|
|
2887
2828
|
}
|
|
2888
2829
|
|
|
2889
|
-
/**
|
|
2890
|
-
* Breadcrumb component properties (legacy - use BreadcrumbProps from component instead)
|
|
2891
|
-
* @deprecated Use BreadcrumbProps from '@atomix/components/Breadcrumb' instead
|
|
2892
|
-
*/
|
|
2893
|
-
export interface LegacyBreadcrumbProps extends BaseComponentProps {
|
|
2894
|
-
/**
|
|
2895
|
-
* Array of breadcrumb items
|
|
2896
|
-
*/
|
|
2897
|
-
items: BreadcrumbItem[];
|
|
2898
|
-
|
|
2899
|
-
/**
|
|
2900
|
-
* Custom divider character or element
|
|
2901
|
-
*/
|
|
2902
|
-
divider?: ReactNode;
|
|
2903
|
-
|
|
2904
|
-
/**
|
|
2905
|
-
* Aria label for the navigation
|
|
2906
|
-
*/
|
|
2907
|
-
ariaLabel?: string;
|
|
2908
|
-
|
|
2909
|
-
/**
|
|
2910
|
-
* Optional custom link component
|
|
2911
|
-
*/
|
|
2912
|
-
LinkComponent?: React.ElementType;
|
|
2913
|
-
|
|
2914
|
-
/**
|
|
2915
|
-
* Custom style for the breadcrumb
|
|
2916
|
-
*/
|
|
2917
|
-
style?: React.CSSProperties;
|
|
2918
|
-
}
|
|
2919
|
-
|
|
2920
2830
|
/**
|
|
2921
2831
|
* Breadcrumb options interface (for vanilla JS)
|
|
2922
2832
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import type { PartStyleProps } from '../types/partProps';
|
|
9
|
-
import { cssVarsToStyle } from '../theme/cssVariableMapper';
|
|
9
|
+
import { cssVarsToStyle } from '../theme/adapters/cssVariableMapper';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Merge multiple class names
|
|
@@ -195,7 +195,10 @@ $theme-font-weight: (
|
|
|
195
195
|
|
|
196
196
|
// scss-docs-start utilities-colors
|
|
197
197
|
|
|
198
|
-
//
|
|
198
|
+
// Note: Future enhancement - Consider using CSS custom properties (--atomix-*)
|
|
199
|
+
// generated from $theme-colors instead of SCSS maps for utilities generation.
|
|
200
|
+
// This would enable runtime theme switching for utility classes.
|
|
201
|
+
// Current implementation uses SCSS maps which is correct for build-time generation.
|
|
199
202
|
|
|
200
203
|
$utilities-colors: $theme-colors !default;
|
|
201
204
|
|