@shohojdhara/atomix 0.3.6 → 0.3.7
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/charts.js +50 -142
- package/dist/charts.js.map +1 -1
- 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 +669 -703
- package/dist/index.esm.js +966 -1649
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1211 -1890
- 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 +163 -334
- package/dist/theme.js +774 -1473
- 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/lib/composables/useAtomixGlass.ts +7 -7
- package/src/lib/config/loader.ts +2 -3
- package/src/lib/constants/components.ts +7 -0
- package/src/lib/hooks/usePerformanceMonitor.ts +1 -1
- package/src/lib/hooks/useThemeTokens.ts +105 -0
- package/src/lib/theme/config/configLoader.ts +60 -219
- 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 +14 -64
- package/src/lib/theme/core/createTheme.ts +54 -40
- package/src/lib/theme/core/createThemeObject.ts +2 -2
- package/src/lib/theme/core/index.ts +15 -1
- package/src/lib/theme/errors/errors.ts +1 -1
- package/src/lib/theme/generators/generateCSSNested.ts +130 -0
- package/src/lib/theme/generators/index.ts +6 -0
- package/src/lib/theme/index.ts +35 -10
- package/src/lib/theme/runtime/ThemeApplicator.ts +1 -1
- package/src/lib/theme/runtime/ThemeErrorBoundary.tsx +4 -4
- package/src/lib/theme/runtime/ThemeProvider.tsx +261 -554
- package/src/lib/theme/runtime/index.ts +1 -0
- package/src/lib/theme/runtime/useThemeTokens.ts +131 -0
- package/src/lib/theme/utils/componentTheming.ts +132 -0
- package/src/lib/theme/utils/naming.ts +100 -0
- package/src/lib/theme/utils/themeUtils.ts +6 -6
- package/src/lib/utils/componentUtils.ts +1 -1
- package/src/lib/utils/memoryMonitor.ts +3 -3
- package/src/lib/utils/themeNaming.ts +135 -0
package/dist/theme.d.ts
CHANGED
|
@@ -302,7 +302,7 @@ declare function createTokens(overrides?: Partial<DesignTokens>): DesignTokens;
|
|
|
302
302
|
/**
|
|
303
303
|
* Theme metadata interface matching themes.config.js structure
|
|
304
304
|
*/
|
|
305
|
-
interface ThemeMetadata {
|
|
305
|
+
interface ThemeMetadata$1 {
|
|
306
306
|
/** Display name of the theme */
|
|
307
307
|
name: string;
|
|
308
308
|
/** Unique identifier/class name for the theme */
|
|
@@ -385,7 +385,7 @@ interface UseThemeReturn {
|
|
|
385
385
|
/** Function to change theme (supports string, Theme, or DesignTokens) */
|
|
386
386
|
setTheme: (theme: string | Theme | DesignTokens | Partial<DesignTokens>, options?: ThemeLoadOptions) => Promise<void>;
|
|
387
387
|
/** Available themes */
|
|
388
|
-
availableThemes: ThemeMetadata[];
|
|
388
|
+
availableThemes: ThemeMetadata$1[];
|
|
389
389
|
/** Whether a theme is currently loading */
|
|
390
390
|
isLoading: boolean;
|
|
391
391
|
/** Current error, if any */
|
|
@@ -454,7 +454,7 @@ interface ThemeProviderProps {
|
|
|
454
454
|
/** Default theme */
|
|
455
455
|
defaultTheme?: string | Theme;
|
|
456
456
|
/** Available themes */
|
|
457
|
-
themes?: Record<string, ThemeMetadata>;
|
|
457
|
+
themes?: Record<string, ThemeMetadata$1>;
|
|
458
458
|
/** Base path for theme CSS */
|
|
459
459
|
basePath?: string;
|
|
460
460
|
/** CDN path for theme CSS */
|
|
@@ -487,7 +487,7 @@ interface ThemeContextValue {
|
|
|
487
487
|
/** Set theme function (supports string, Theme, or DesignTokens) */
|
|
488
488
|
setTheme: (theme: string | Theme | DesignTokens | Partial<DesignTokens>, options?: ThemeLoadOptions) => Promise<void>;
|
|
489
489
|
/** Available themes */
|
|
490
|
-
availableThemes: ThemeMetadata[];
|
|
490
|
+
availableThemes: ThemeMetadata$1[];
|
|
491
491
|
/** Loading state */
|
|
492
492
|
isLoading: boolean;
|
|
493
493
|
/** Error state */
|
|
@@ -714,7 +714,7 @@ interface ThemeCustomProperties {
|
|
|
714
714
|
* Theme configuration options for createTheme
|
|
715
715
|
* Extends ThemeMetadata to support both CSS and JS theme properties
|
|
716
716
|
*/
|
|
717
|
-
interface ThemeOptions extends Partial<ThemeMetadata> {
|
|
717
|
+
interface ThemeOptions extends Partial<ThemeMetadata$1> {
|
|
718
718
|
/** Color palette configuration */
|
|
719
719
|
palette?: PaletteOptions;
|
|
720
720
|
/** Typography configuration */
|
|
@@ -738,7 +738,7 @@ interface ThemeOptions extends Partial<ThemeMetadata> {
|
|
|
738
738
|
* Complete theme object with computed values
|
|
739
739
|
* Generated by createTheme function
|
|
740
740
|
*/
|
|
741
|
-
interface Theme extends ThemeMetadata {
|
|
741
|
+
interface Theme extends ThemeMetadata$1 {
|
|
742
742
|
/** Color palette with computed values */
|
|
743
743
|
palette: {
|
|
744
744
|
primary: PaletteColor;
|
|
@@ -864,7 +864,7 @@ declare function generateCSSVariablesForSelector(tokens: DesignTokens, selector:
|
|
|
864
864
|
/**
|
|
865
865
|
* Core Theme Functions
|
|
866
866
|
*
|
|
867
|
-
*
|
|
867
|
+
* Simplified theme system that handles both DesignTokens and Theme objects.
|
|
868
868
|
* Config-first approach: loads from atomix.config.ts when no input is provided.
|
|
869
869
|
* Config file is required for automatic loading.
|
|
870
870
|
*/
|
|
@@ -936,14 +936,14 @@ declare function createThemeObject(...options: ThemeOptions[]): Theme;
|
|
|
936
936
|
/**
|
|
937
937
|
* Theme Composition Utilities
|
|
938
938
|
*
|
|
939
|
-
*
|
|
939
|
+
* Simplified utilities for composing, merging, and extending themes.
|
|
940
940
|
*/
|
|
941
941
|
|
|
942
942
|
/**
|
|
943
943
|
* Deep merge multiple objects
|
|
944
944
|
* Later objects override earlier ones
|
|
945
945
|
*/
|
|
946
|
-
declare function deepMerge<T extends Record<string,
|
|
946
|
+
declare function deepMerge<T extends Record<string, unknown>>(...objects: Partial<T>[]): T;
|
|
947
947
|
/**
|
|
948
948
|
* Merge multiple theme options into a single theme options object
|
|
949
949
|
*
|
|
@@ -976,286 +976,130 @@ declare function mergeTheme(...themes: ThemeOptions[]): ThemeOptions;
|
|
|
976
976
|
declare function extendTheme(baseTheme: Theme | ThemeOptions, extension: ThemeOptions): Theme;
|
|
977
977
|
|
|
978
978
|
/**
|
|
979
|
-
*
|
|
980
|
-
*
|
|
981
|
-
* Tailwind-like configuration for customizing the Atomix Design System.
|
|
982
|
-
*
|
|
983
|
-
* External developers can create `atomix.config.ts` in their project root
|
|
984
|
-
* to customize design tokens, similar to Tailwind's tailwind.config.js
|
|
985
|
-
*
|
|
986
|
-
* @example
|
|
987
|
-
* ```typescript
|
|
988
|
-
* // atomix.config.ts (in your project)
|
|
989
|
-
* import { defineConfig } from '@shohojdhara/atomix/config';
|
|
990
|
-
*
|
|
991
|
-
* export default defineConfig({
|
|
992
|
-
* theme: {
|
|
993
|
-
* extend: {
|
|
994
|
-
* colors: {
|
|
995
|
-
* primary: { main: '#7AFFD7' },
|
|
996
|
-
* },
|
|
997
|
-
* },
|
|
998
|
-
* },
|
|
999
|
-
* });
|
|
1000
|
-
* ```
|
|
1001
|
-
*/
|
|
1002
|
-
|
|
1003
|
-
/**
|
|
1004
|
-
* CSS Theme Definition
|
|
979
|
+
* Theme Metadata interface
|
|
1005
980
|
*/
|
|
1006
|
-
interface
|
|
1007
|
-
type: 'css';
|
|
981
|
+
interface ThemeMetadata {
|
|
1008
982
|
name: string;
|
|
1009
|
-
class
|
|
983
|
+
class: string;
|
|
1010
984
|
description?: string;
|
|
1011
|
-
author?: string;
|
|
1012
985
|
version?: string;
|
|
1013
|
-
|
|
1014
|
-
supportsDarkMode?: boolean;
|
|
1015
|
-
status?: 'stable' | 'beta' | 'experimental' | 'deprecated';
|
|
1016
|
-
a11y?: {
|
|
1017
|
-
contrastTarget?: number;
|
|
1018
|
-
modes?: string[];
|
|
1019
|
-
};
|
|
1020
|
-
color?: string;
|
|
1021
|
-
features?: string[];
|
|
1022
|
-
dependencies?: string[];
|
|
1023
|
-
cssPath?: string;
|
|
986
|
+
[key: string]: any;
|
|
1024
987
|
}
|
|
1025
988
|
/**
|
|
1026
|
-
*
|
|
989
|
+
* Theme Registry type - a record of theme IDs to metadata
|
|
1027
990
|
*/
|
|
1028
|
-
|
|
1029
|
-
type: 'js';
|
|
1030
|
-
name: string;
|
|
1031
|
-
class?: string;
|
|
1032
|
-
description?: string;
|
|
1033
|
-
author?: string;
|
|
1034
|
-
version?: string;
|
|
1035
|
-
tags?: string[];
|
|
1036
|
-
supportsDarkMode?: boolean;
|
|
1037
|
-
status?: 'stable' | 'beta' | 'experimental' | 'deprecated';
|
|
1038
|
-
a11y?: {
|
|
1039
|
-
contrastTarget?: number;
|
|
1040
|
-
modes?: string[];
|
|
1041
|
-
};
|
|
1042
|
-
color?: string;
|
|
1043
|
-
features?: string[];
|
|
1044
|
-
dependencies?: string[];
|
|
1045
|
-
createTheme: () => Theme;
|
|
1046
|
-
}
|
|
991
|
+
type ThemeRegistry = Record<string, ThemeMetadata>;
|
|
1047
992
|
/**
|
|
1048
|
-
*
|
|
993
|
+
* Create a new theme registry
|
|
1049
994
|
*/
|
|
1050
|
-
|
|
995
|
+
declare function createThemeRegistry(): ThemeRegistry;
|
|
1051
996
|
/**
|
|
1052
|
-
*
|
|
997
|
+
* Register a theme
|
|
998
|
+
* @param registry - Theme registry object
|
|
999
|
+
* @param id - Theme identifier
|
|
1000
|
+
* @param metadata - Theme metadata
|
|
1053
1001
|
*/
|
|
1054
|
-
|
|
1055
|
-
output?: {
|
|
1056
|
-
directory?: string;
|
|
1057
|
-
formats?: {
|
|
1058
|
-
expanded?: string;
|
|
1059
|
-
compressed?: string;
|
|
1060
|
-
};
|
|
1061
|
-
};
|
|
1062
|
-
sass?: {
|
|
1063
|
-
style?: 'expanded' | 'compressed';
|
|
1064
|
-
sourceMap?: boolean;
|
|
1065
|
-
loadPaths?: string[];
|
|
1066
|
-
};
|
|
1067
|
-
}
|
|
1002
|
+
declare function registerTheme(registry: ThemeRegistry, id: string, metadata: ThemeMetadata): void;
|
|
1068
1003
|
/**
|
|
1069
|
-
*
|
|
1004
|
+
* Unregister a theme
|
|
1005
|
+
* @param registry - Theme registry object
|
|
1006
|
+
* @param id - Theme identifier
|
|
1070
1007
|
*/
|
|
1071
|
-
|
|
1072
|
-
basePath?: string;
|
|
1073
|
-
cdnPath?: string | null;
|
|
1074
|
-
preload?: string[];
|
|
1075
|
-
lazy?: boolean;
|
|
1076
|
-
defaultTheme?: string;
|
|
1077
|
-
storageKey?: string;
|
|
1078
|
-
dataAttribute?: string;
|
|
1079
|
-
enablePersistence?: boolean;
|
|
1080
|
-
useMinified?: boolean;
|
|
1081
|
-
}
|
|
1008
|
+
declare function unregisterTheme(registry: ThemeRegistry, id: string): boolean;
|
|
1082
1009
|
/**
|
|
1083
|
-
*
|
|
1010
|
+
* Check if a theme is registered
|
|
1011
|
+
* @param registry - Theme registry object
|
|
1012
|
+
* @param id - Theme identifier
|
|
1084
1013
|
*/
|
|
1085
|
-
|
|
1086
|
-
cssVariables?: Record<string, string>;
|
|
1087
|
-
classNames?: {
|
|
1088
|
-
theme?: string;
|
|
1089
|
-
colorMode?: string;
|
|
1090
|
-
};
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1014
|
+
declare function hasTheme(registry: ThemeRegistry, id: string): boolean;
|
|
1093
1015
|
/**
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
*
|
|
1016
|
+
* Get theme metadata
|
|
1017
|
+
* @param registry - Theme registry object
|
|
1018
|
+
* @param id - Theme identifier
|
|
1019
|
+
*/
|
|
1020
|
+
declare function getTheme(registry: ThemeRegistry, id: string): ThemeMetadata | undefined;
|
|
1021
|
+
/**
|
|
1022
|
+
* Get all registered theme metadata
|
|
1023
|
+
* @param registry - Theme registry object
|
|
1024
|
+
*/
|
|
1025
|
+
declare function getAllThemes(registry: ThemeRegistry): ThemeMetadata[];
|
|
1026
|
+
/**
|
|
1027
|
+
* Get all registered theme IDs
|
|
1028
|
+
* @param registry - Theme registry object
|
|
1029
|
+
*/
|
|
1030
|
+
declare function getThemeIds(registry: ThemeRegistry): string[];
|
|
1031
|
+
/**
|
|
1032
|
+
* Clear all registered themes
|
|
1033
|
+
* @param registry - Theme registry object
|
|
1097
1034
|
*/
|
|
1035
|
+
declare function clearThemes(registry: ThemeRegistry): void;
|
|
1036
|
+
/**
|
|
1037
|
+
* Get the number of registered themes
|
|
1038
|
+
* @param registry - Theme registry object
|
|
1039
|
+
*/
|
|
1040
|
+
declare function getThemeCount(registry: ThemeRegistry): number;
|
|
1098
1041
|
|
|
1099
1042
|
/**
|
|
1100
|
-
*
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
/** Integration settings */
|
|
1110
|
-
integration: IntegrationConfig;
|
|
1111
|
-
/** Theme dependencies mapping */
|
|
1112
|
-
dependencies: Record<string, string[]>;
|
|
1113
|
-
/** Whether config was validated */
|
|
1114
|
-
validated: boolean;
|
|
1115
|
-
/** Validation errors (if any) */
|
|
1116
|
-
errors?: string[];
|
|
1117
|
-
/** Validation warnings (if any) */
|
|
1118
|
-
warnings?: string[];
|
|
1119
|
-
/** Internal tokens (for generator) */
|
|
1120
|
-
__tokens?: any;
|
|
1121
|
-
/** Internal extensions (for generator) */
|
|
1122
|
-
__extend?: any;
|
|
1043
|
+
* Naming Utilities
|
|
1044
|
+
*
|
|
1045
|
+
* Provides consistent naming conventions across the theme system
|
|
1046
|
+
*/
|
|
1047
|
+
interface NamingOptions {
|
|
1048
|
+
prefix?: string;
|
|
1049
|
+
component?: string;
|
|
1050
|
+
variant?: string;
|
|
1051
|
+
state?: string;
|
|
1123
1052
|
}
|
|
1053
|
+
/**
|
|
1054
|
+
* Generate consistent CSS class names following BEM methodology
|
|
1055
|
+
*/
|
|
1056
|
+
declare function generateClassName(block: string, element?: string, modifiers?: Record<string, boolean | string>): string;
|
|
1057
|
+
/**
|
|
1058
|
+
* Generate consistent CSS variable names
|
|
1059
|
+
*/
|
|
1060
|
+
declare function generateCSSVariableName(property: string, options?: NamingOptions): string;
|
|
1061
|
+
/**
|
|
1062
|
+
* Normalize theme tokens to consistent naming convention
|
|
1063
|
+
*/
|
|
1064
|
+
declare function normalizeThemeTokens(tokens: Record<string, any>): Record<string, any>;
|
|
1065
|
+
/**
|
|
1066
|
+
* Convert camelCase to kebab-case for CSS custom properties
|
|
1067
|
+
*/
|
|
1068
|
+
declare function camelToKebab(str: string): string;
|
|
1069
|
+
/**
|
|
1070
|
+
* Convert theme property to CSS variable name
|
|
1071
|
+
*/
|
|
1072
|
+
declare function themePropertyToCSSVar(propertyPath: string, prefix?: string): string;
|
|
1124
1073
|
|
|
1125
1074
|
/**
|
|
1126
|
-
*
|
|
1075
|
+
* Component Theming Utilities
|
|
1127
1076
|
*
|
|
1128
|
-
*
|
|
1077
|
+
* Provides consistent patterns for applying theme values to components
|
|
1129
1078
|
*/
|
|
1130
1079
|
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
id: string;
|
|
1137
|
-
/** Theme definition from config */
|
|
1138
|
-
definition: ThemeDefinition;
|
|
1139
|
-
/** Resolved theme object (for JS themes) */
|
|
1140
|
-
theme?: Theme;
|
|
1141
|
-
/** Whether theme is loaded */
|
|
1142
|
-
loaded: boolean;
|
|
1143
|
-
/** Loading promise (if currently loading) */
|
|
1144
|
-
loading?: Promise<Theme | void>;
|
|
1145
|
-
/** Dependencies */
|
|
1146
|
-
dependencies: string[];
|
|
1147
|
-
/** Dependent themes (themes that depend on this one) */
|
|
1148
|
-
dependents: string[];
|
|
1080
|
+
interface ComponentThemeOptions {
|
|
1081
|
+
component: string;
|
|
1082
|
+
variant?: string;
|
|
1083
|
+
size?: string;
|
|
1084
|
+
theme: Theme;
|
|
1149
1085
|
}
|
|
1150
1086
|
/**
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
-
* Manages theme registration, discovery, and dependency resolution
|
|
1087
|
+
* Get a theme value for a specific component using CSS variables
|
|
1088
|
+
* This ensures all components access theme values consistently
|
|
1154
1089
|
*/
|
|
1155
|
-
declare
|
|
1156
|
-
private entries;
|
|
1157
|
-
private config;
|
|
1158
|
-
private initialized;
|
|
1159
|
-
/**
|
|
1160
|
-
* Initialize registry from config
|
|
1161
|
-
*/
|
|
1162
|
-
initialize(config?: LoadedThemeConfig): Promise<void>;
|
|
1163
|
-
/**
|
|
1164
|
-
* Register a theme
|
|
1165
|
-
*/
|
|
1166
|
-
register(themeId: string, definition: ThemeDefinition): void;
|
|
1167
|
-
/**
|
|
1168
|
-
* Get theme entry
|
|
1169
|
-
*/
|
|
1170
|
-
get(themeId: string): RegistryEntry | undefined;
|
|
1171
|
-
/**
|
|
1172
|
-
* Check if theme exists
|
|
1173
|
-
*/
|
|
1174
|
-
has(themeId: string): boolean;
|
|
1175
|
-
/**
|
|
1176
|
-
* Get all theme IDs
|
|
1177
|
-
*/
|
|
1178
|
-
getAllIds(): string[];
|
|
1179
|
-
/**
|
|
1180
|
-
* Get all theme metadata
|
|
1181
|
-
*/
|
|
1182
|
-
getAllMetadata(): ThemeMetadata[];
|
|
1183
|
-
/**
|
|
1184
|
-
* Get theme definition
|
|
1185
|
-
*/
|
|
1186
|
-
getDefinition(themeId: string): ThemeDefinition | undefined;
|
|
1187
|
-
/**
|
|
1188
|
-
* Check if a theme is loaded
|
|
1189
|
-
*/
|
|
1190
|
-
isThemeLoaded(themeId: string): boolean;
|
|
1191
|
-
/**
|
|
1192
|
-
* Mark a theme as loaded
|
|
1193
|
-
*/
|
|
1194
|
-
markLoaded(themeId: string, theme?: Theme): void;
|
|
1195
|
-
/**
|
|
1196
|
-
* Get theme object (for JS themes)
|
|
1197
|
-
*/
|
|
1198
|
-
getTheme(themeId: string): Theme | undefined;
|
|
1199
|
-
/**
|
|
1200
|
-
* Get dependencies for a theme
|
|
1201
|
-
*/
|
|
1202
|
-
getDependencies(themeId: string): string[];
|
|
1203
|
-
/**
|
|
1204
|
-
* Get dependents for a theme (themes that depend on this one)
|
|
1205
|
-
*/
|
|
1206
|
-
getDependents(themeId: string): string[];
|
|
1207
|
-
/**
|
|
1208
|
-
* Resolve all dependencies in correct order
|
|
1209
|
-
*/
|
|
1210
|
-
resolveDependencyOrder(themeId: string): string[];
|
|
1211
|
-
/**
|
|
1212
|
-
* Resolve dependencies and build dependency graph
|
|
1213
|
-
*/
|
|
1214
|
-
private resolveDependencies;
|
|
1215
|
-
/**
|
|
1216
|
-
* Validate all themes
|
|
1217
|
-
*/
|
|
1218
|
-
validate(): {
|
|
1219
|
-
valid: boolean;
|
|
1220
|
-
errors: string[];
|
|
1221
|
-
};
|
|
1222
|
-
/**
|
|
1223
|
-
* Clear registry
|
|
1224
|
-
*/
|
|
1225
|
-
clear(): void;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1090
|
+
declare function getComponentThemeValue(component: string, property: string, variant?: string, size?: string): string;
|
|
1228
1091
|
/**
|
|
1229
|
-
* CSS
|
|
1230
|
-
*
|
|
1231
|
-
* Save CSS to file system (Node.js only).
|
|
1092
|
+
* Generate component-specific CSS variables from theme
|
|
1232
1093
|
*/
|
|
1094
|
+
declare function generateComponentCSSVars(component: string, theme: Theme, variant?: string, size?: string): Record<string, string>;
|
|
1233
1095
|
/**
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1236
|
-
* Writes CSS string to a file. Only works in Node.js environment.
|
|
1237
|
-
*
|
|
1238
|
-
* @param css - CSS string to save
|
|
1239
|
-
* @param filePath - Output file path
|
|
1240
|
-
* @throws Error if called in browser environment
|
|
1241
|
-
*
|
|
1242
|
-
* @example
|
|
1243
|
-
* ```typescript
|
|
1244
|
-
* const css = ':root { --atomix-color-primary: #7AFFD7; }';
|
|
1245
|
-
* await saveCSSFile(css, './themes/custom.css');
|
|
1246
|
-
* ```
|
|
1096
|
+
* Apply consistent theme to component style object
|
|
1247
1097
|
*/
|
|
1248
|
-
declare function
|
|
1098
|
+
declare function applyComponentTheme(component: string, style?: React.CSSProperties, variant?: string, size?: string, theme?: Theme): React.CSSProperties;
|
|
1249
1099
|
/**
|
|
1250
|
-
*
|
|
1251
|
-
*
|
|
1252
|
-
* Synchronous version of saveCSSFile. Only works in Node.js environment.
|
|
1253
|
-
*
|
|
1254
|
-
* @param css - CSS string to save
|
|
1255
|
-
* @param filePath - Output file path
|
|
1256
|
-
* @throws Error if called in browser environment
|
|
1100
|
+
* Create a hook for consistent component theming
|
|
1257
1101
|
*/
|
|
1258
|
-
declare function
|
|
1102
|
+
declare function useComponentTheme(component: string, variant?: string, size?: string, theme?: Theme): (property: string) => string;
|
|
1259
1103
|
|
|
1260
1104
|
/**
|
|
1261
1105
|
* CSS Injection Utilities
|
|
@@ -1304,78 +1148,49 @@ declare function removeCSS(id?: string): void;
|
|
|
1304
1148
|
declare function isCSSInjected(id?: string): boolean;
|
|
1305
1149
|
|
|
1306
1150
|
/**
|
|
1307
|
-
*
|
|
1151
|
+
* Theme Configuration Loader
|
|
1308
1152
|
*
|
|
1309
|
-
*
|
|
1153
|
+
* Provides functions to load theme configurations from atomix.config.ts
|
|
1154
|
+
* Includes both sync and async versions, with automatic fallbacks
|
|
1310
1155
|
*/
|
|
1311
1156
|
|
|
1312
1157
|
/**
|
|
1313
|
-
* Load theme
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
*
|
|
1318
|
-
* @param configPath - Optional custom config path (default: 'atomix.config.ts')
|
|
1319
|
-
* @returns Partial DesignTokens from config
|
|
1320
|
-
* @throws Error if config file is not found or cannot be loaded
|
|
1321
|
-
*
|
|
1322
|
-
* @example
|
|
1323
|
-
* ```typescript
|
|
1324
|
-
* const tokens = await loadThemeFromConfig();
|
|
1325
|
-
* const css = createTheme(tokens);
|
|
1326
|
-
* injectTheme(css);
|
|
1327
|
-
* ```
|
|
1158
|
+
* Load theme from config file (synchronous, Node.js only)
|
|
1159
|
+
* @param configPath - Path to config file (default: atomix.config.ts)
|
|
1160
|
+
* @returns DesignTokens from theme configuration
|
|
1161
|
+
* @throws Error if config loading is not available in browser environment
|
|
1328
1162
|
*/
|
|
1329
|
-
declare function
|
|
1163
|
+
declare function loadThemeFromConfigSync(options?: {
|
|
1164
|
+
configPath?: string;
|
|
1165
|
+
required?: boolean;
|
|
1166
|
+
}): DesignTokens;
|
|
1330
1167
|
/**
|
|
1331
|
-
* Load theme
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1334
|
-
* Only works in Node.js environment.
|
|
1335
|
-
* Config file is required - throws error if not found.
|
|
1336
|
-
*
|
|
1337
|
-
* @param configPath - Optional custom config path
|
|
1338
|
-
* @returns Partial DesignTokens from config
|
|
1339
|
-
* @throws Error if config file is not found or cannot be loaded
|
|
1168
|
+
* Load theme from config file (asynchronous)
|
|
1169
|
+
* @param configPath - Path to config file (default: atomix.config.ts)
|
|
1170
|
+
* @returns Promise resolving to DesignTokens from theme configuration
|
|
1340
1171
|
*/
|
|
1341
|
-
declare function
|
|
1172
|
+
declare function loadThemeFromConfig(options?: {
|
|
1173
|
+
configPath?: string;
|
|
1174
|
+
required?: boolean;
|
|
1175
|
+
}): Promise<DesignTokens>;
|
|
1342
1176
|
|
|
1343
1177
|
/**
|
|
1344
1178
|
* Theme Provider
|
|
1345
1179
|
*
|
|
1346
|
-
* React context provider for theme management
|
|
1180
|
+
* React context provider for theme management with separated concerns
|
|
1181
|
+
* Updated to use the new simplified theme system
|
|
1347
1182
|
*/
|
|
1348
1183
|
|
|
1349
1184
|
/**
|
|
1350
|
-
*
|
|
1351
|
-
*
|
|
1352
|
-
* Provides theme context to child components and manages theme state.
|
|
1353
|
-
*
|
|
1354
|
-
* **Config-First Approach**: If `defaultTheme` is not provided, loads from `atomix.config.ts`.
|
|
1355
|
-
* Config file is required when `defaultTheme` is not provided.
|
|
1356
|
-
*
|
|
1357
|
-
* @example
|
|
1358
|
-
* ```tsx
|
|
1359
|
-
* import { ThemeProvider } from '@shohojdhara/atomix/theme';
|
|
1185
|
+
* Theme Provider
|
|
1360
1186
|
*
|
|
1361
|
-
*
|
|
1362
|
-
*
|
|
1363
|
-
*
|
|
1364
|
-
*
|
|
1365
|
-
*
|
|
1366
|
-
* </ThemeProvider>
|
|
1367
|
-
* );
|
|
1368
|
-
* }
|
|
1187
|
+
* React context provider for theme management with separated concerns.
|
|
1188
|
+
* Simplified version focusing on core functionality:
|
|
1189
|
+
* - String-based themes (CSS files)
|
|
1190
|
+
* - JS Theme objects
|
|
1191
|
+
* - Persistence via localStorage
|
|
1369
1192
|
*
|
|
1370
|
-
*
|
|
1371
|
-
* function App() {
|
|
1372
|
-
* return (
|
|
1373
|
-
* <ThemeProvider defaultTheme="dark">
|
|
1374
|
-
* <YourApp />
|
|
1375
|
-
* </ThemeProvider>
|
|
1376
|
-
* );
|
|
1377
|
-
* }
|
|
1378
|
-
* ```
|
|
1193
|
+
* Falls back to 'default' theme if no configuration is found.
|
|
1379
1194
|
*/
|
|
1380
1195
|
declare const ThemeProvider: React__default.FC<ThemeProviderProps>;
|
|
1381
1196
|
|
|
@@ -1408,6 +1223,39 @@ declare const ThemeProvider: React__default.FC<ThemeProviderProps>;
|
|
|
1408
1223
|
*/
|
|
1409
1224
|
declare function useTheme(): UseThemeReturn;
|
|
1410
1225
|
|
|
1226
|
+
/**
|
|
1227
|
+
* Standardized hook for accessing theme tokens in components
|
|
1228
|
+
*
|
|
1229
|
+
* Provides consistent access to theme values across all components
|
|
1230
|
+
* using either CSS custom properties or theme object values.
|
|
1231
|
+
*/
|
|
1232
|
+
type ThemeTokens = {
|
|
1233
|
+
theme: string;
|
|
1234
|
+
activeTheme: Theme | null;
|
|
1235
|
+
getToken: (tokenName: string, fallback?: string) => string;
|
|
1236
|
+
getThemeValue: (path: string, fallback?: any) => any;
|
|
1237
|
+
colors: {
|
|
1238
|
+
primary: string;
|
|
1239
|
+
secondary: string;
|
|
1240
|
+
error: string;
|
|
1241
|
+
success: string;
|
|
1242
|
+
warning: string;
|
|
1243
|
+
info: string;
|
|
1244
|
+
light: string;
|
|
1245
|
+
dark: string;
|
|
1246
|
+
};
|
|
1247
|
+
spacing: Record<string, string>;
|
|
1248
|
+
borderRadius: Record<string, string>;
|
|
1249
|
+
typography: {
|
|
1250
|
+
fontFamily: Record<string, string>;
|
|
1251
|
+
fontSize: Record<string, string>;
|
|
1252
|
+
fontWeight: Record<string, string>;
|
|
1253
|
+
};
|
|
1254
|
+
shadows: Record<string, string>;
|
|
1255
|
+
transitions: Record<string, string>;
|
|
1256
|
+
};
|
|
1257
|
+
declare function useThemeTokens(): ThemeTokens;
|
|
1258
|
+
|
|
1411
1259
|
/**
|
|
1412
1260
|
* Theme context with default values
|
|
1413
1261
|
*/
|
|
@@ -1529,7 +1377,7 @@ declare function getThemeApplicator(): ThemeApplicator;
|
|
|
1529
1377
|
/**
|
|
1530
1378
|
* Apply theme using global applicator
|
|
1531
1379
|
*/
|
|
1532
|
-
declare function applyTheme(theme: Theme): void;
|
|
1380
|
+
declare function applyTheme(theme: Theme | DesignTokens): void;
|
|
1533
1381
|
|
|
1534
1382
|
/**
|
|
1535
1383
|
* Theme Preview Component
|
|
@@ -1698,7 +1546,7 @@ declare class ThemeValidator {
|
|
|
1698
1546
|
/**
|
|
1699
1547
|
* Validate theme
|
|
1700
1548
|
*/
|
|
1701
|
-
validate(theme: Theme, metadata?: ThemeMetadata): ValidationResult;
|
|
1549
|
+
validate(theme: Theme, metadata?: ThemeMetadata$1): ValidationResult;
|
|
1702
1550
|
/**
|
|
1703
1551
|
* Validate palette
|
|
1704
1552
|
*/
|
|
@@ -1866,25 +1714,6 @@ interface CSSVariableNamingOptions {
|
|
|
1866
1714
|
/** Whether to include component name in variable (default: true) */
|
|
1867
1715
|
includeComponent?: boolean;
|
|
1868
1716
|
}
|
|
1869
|
-
/**
|
|
1870
|
-
* Generate CSS variable name from parts
|
|
1871
|
-
*
|
|
1872
|
-
* @example
|
|
1873
|
-
* generateCSSVariableName('button', 'bg', { prefix: 'atomix' })
|
|
1874
|
-
* // Returns: '--atomix-button-bg'
|
|
1875
|
-
*/
|
|
1876
|
-
declare function generateCSSVariableName(component: string, property: string, options?: CSSVariableNamingOptions): string;
|
|
1877
|
-
/**
|
|
1878
|
-
* Generate CSS variables object from configuration
|
|
1879
|
-
*
|
|
1880
|
-
* @example
|
|
1881
|
-
* const vars = generateComponentCSSVars({
|
|
1882
|
-
* component: 'button',
|
|
1883
|
-
* properties: { bg: '#000', color: '#fff' }
|
|
1884
|
-
* })
|
|
1885
|
-
* // Returns: { '--atomix-button-bg': '#000', '--atomix-button-color': '#fff' }
|
|
1886
|
-
*/
|
|
1887
|
-
declare function generateComponentCSSVars(config: CSSVariableConfig, options?: CSSVariableNamingOptions): Record<string, string>;
|
|
1888
1717
|
/**
|
|
1889
1718
|
* Map SCSS tokens to CSS custom properties
|
|
1890
1719
|
*
|
|
@@ -2118,5 +1947,5 @@ declare function removeTheme(id?: string): void;
|
|
|
2118
1947
|
*/
|
|
2119
1948
|
declare function saveTheme(css: string, filePath: string): Promise<void>;
|
|
2120
1949
|
|
|
2121
|
-
export { RTLManager, ThemeApplicator, ThemeComparator, ThemeContext, ThemeErrorBoundary, ThemeInspector, ThemeLiveEditor, ThemePreview, ThemeProvider,
|
|
2122
|
-
export type { A11yIssue, CSSVariableConfig, CSSVariableNamingOptions, ComponentThemeOverride, DesignTokens, GenerateCSSVariablesOptions, RTLConfig, Theme, ThemeChangeEvent, ThemeComparatorProps, ThemeComponentOverrides, ThemeContextValue, ThemeErrorBoundaryProps, ThemeInspectorProps, ThemeLiveEditorProps, ThemeLoadOptions,
|
|
1950
|
+
export { RTLManager, ThemeApplicator, ThemeComparator, ThemeContext, ThemeErrorBoundary, ThemeInspector, ThemeLiveEditor, ThemePreview, ThemeProvider, ThemeValidator, applyCSSVariables, applyComponentTheme, applyTheme, camelToKebab, clearThemes, createDesignTokensFromTheme, createTheme, createThemeObject, createThemeRegistry, createTokens, cssVarsToStyle, deepMerge, defaultTokens, designTokensToCSSVars, designTokensToTheme, extendTheme, extractComponentName, generateCSSVariableName, generateCSSVariables, generateCSSVariablesForSelector, generateClassName, generateComponentCSSVars, getAllThemes, getCSSVariable, getComponentThemeValue, getDesignTokensFromTheme, getTheme, getThemeApplicator, getThemeCount, getThemeIds, hasTheme, injectCSS, injectTheme, isCSSInjected, isDesignTokens, isThemeObject, isValidCSSVariableName, loadThemeFromConfig, loadThemeFromConfigSync, mapSCSSTokensToCSSVars, mergeCSSVars, mergeTheme, normalizeThemeTokens, registerTheme, removeCSS, removeCSSVariables, removeTheme, saveTheme, themePropertyToCSSVar, themeToDesignTokens, unregisterTheme, useComponentTheme, useHistory, useTheme, useThemeTokens };
|
|
1951
|
+
export type { A11yIssue, CSSVariableConfig, CSSVariableNamingOptions, ComponentThemeOptions, ComponentThemeOverride, DesignTokens, GenerateCSSVariablesOptions, NamingOptions, RTLConfig, Theme, ThemeChangeEvent, ThemeComparatorProps, ThemeComponentOverrides, ThemeContextValue, ThemeErrorBoundaryProps, ThemeInspectorProps, ThemeLiveEditorProps, ThemeLoadOptions, ThemePreviewProps, ThemeProviderProps, ThemeValidationResult, UseHistoryOptions, UseHistoryReturn, UseThemeReturn, ValidationResult };
|