@shohojdhara/atomix 0.3.10 → 0.3.12

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 (47) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/atomix.css +9 -6
  3. package/dist/atomix.css.map +1 -1
  4. package/dist/atomix.min.css +9 -6
  5. package/dist/atomix.min.css.map +1 -1
  6. package/dist/charts.js +82 -60
  7. package/dist/charts.js.map +1 -1
  8. package/dist/core.js +82 -60
  9. package/dist/core.js.map +1 -1
  10. package/dist/forms.js +82 -60
  11. package/dist/forms.js.map +1 -1
  12. package/dist/heavy.js +82 -60
  13. package/dist/heavy.js.map +1 -1
  14. package/dist/index.d.ts +11 -107
  15. package/dist/index.esm.js +165 -407
  16. package/dist/index.esm.js.map +1 -1
  17. package/dist/index.js +169 -412
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.min.js +1 -1
  20. package/dist/index.min.js.map +1 -1
  21. package/dist/theme.d.ts +1 -32
  22. package/dist/theme.js +12 -207
  23. package/dist/theme.js.map +1 -1
  24. package/package.json +1 -1
  25. package/src/components/AtomixGlass/AtomixGlass.tsx +124 -127
  26. package/src/components/AtomixGlass/AtomixGlassContainer.tsx +28 -32
  27. package/src/components/AtomixGlass/GlassFilter.tsx +15 -4
  28. package/src/components/EdgePanel/EdgePanel.stories.tsx +2 -7
  29. package/src/components/EdgePanel/EdgePanel.tsx +0 -10
  30. package/src/components/Form/Radio.stories.tsx +235 -103
  31. package/src/components/Navigation/Nav/NavDropdown.tsx +8 -4
  32. package/src/components/Navigation/SideMenu/SideMenu.tsx +2 -22
  33. package/src/components/Navigation/SideMenu/SideMenuItem.tsx +11 -15
  34. package/src/lib/config/index.ts +5 -5
  35. package/src/lib/theme/config/index.ts +1 -1
  36. package/src/lib/theme/core/createTheme.ts +11 -40
  37. package/src/lib/theme/generators/index.ts +1 -4
  38. package/src/lib/theme/index.ts +4 -16
  39. package/src/lib/theme/runtime/ThemeProvider.tsx +1 -16
  40. package/src/lib/types/components.ts +2 -26
  41. package/src/styles/06-components/_components.edge-panel.scss +4 -4
  42. package/src/styles/06-components/_components.nav.scss +3 -0
  43. package/src/lib/config/loader.ts +0 -147
  44. package/src/lib/theme/config/__tests__/configLoader.test.ts +0 -207
  45. package/src/lib/theme/config/configLoader.ts +0 -113
  46. package/src/lib/theme/config/loader.ts +0 -293
  47. package/src/lib/theme/generators/cssFile.ts +0 -79
package/dist/theme.d.ts CHANGED
@@ -1043,33 +1043,6 @@ declare function removeCSS(id?: string): void;
1043
1043
  */
1044
1044
  declare function isCSSInjected(id?: string): boolean;
1045
1045
 
1046
- /**
1047
- * Theme Configuration Loader
1048
- *
1049
- * Provides functions to load theme configurations from atomix.config.ts
1050
- * Includes both sync and async versions, with automatic fallbacks
1051
- */
1052
-
1053
- /**
1054
- * Load theme from config file (synchronous, Node.js only)
1055
- * @param configPath - Path to config file (default: atomix.config.ts)
1056
- * @returns DesignTokens from theme configuration
1057
- * @throws Error if config loading is not available in browser environment
1058
- */
1059
- declare function loadThemeFromConfigSync(options?: {
1060
- configPath?: string;
1061
- required?: boolean;
1062
- }): DesignTokens;
1063
- /**
1064
- * Load theme from config file (asynchronous)
1065
- * @param configPath - Path to config file (default: atomix.config.ts)
1066
- * @returns Promise resolving to DesignTokens from theme configuration
1067
- */
1068
- declare function loadThemeFromConfig(options?: {
1069
- configPath?: string;
1070
- required?: boolean;
1071
- }): Promise<DesignTokens>;
1072
-
1073
1046
  /**
1074
1047
  * Theme Provider
1075
1048
  *
@@ -1759,10 +1732,6 @@ declare function injectTheme(css: string, id?: string): void;
1759
1732
  * Remove theme from DOM
1760
1733
  */
1761
1734
  declare function removeTheme(id?: string): void;
1762
- /**
1763
- * Save theme to CSS file
1764
- */
1765
- declare function saveTheme(css: string, filePath: string): Promise<void>;
1766
1735
 
1767
- export { RTLManager, ThemeApplicator, ThemeComparator, ThemeContext, ThemeErrorBoundary, ThemeInspector, ThemeLiveEditor, ThemePreview, ThemeProvider, ThemeValidator, applyCSSVariables, applyComponentTheme, applyTheme, camelToKebab, clearThemes, createTheme, createThemeRegistry, createTokens, cssVarsToStyle, deepMerge, defaultTokens, designTokensToCSSVars, extendTheme, extractComponentName, generateCSSVariableName, generateCSSVariables, generateCSSVariablesForSelector, generateClassName, generateComponentCSSVars, getAllThemes, getCSSVariable, getComponentThemeValue, getTheme, getThemeApplicator, getThemeCount, getThemeIds, hasTheme, injectCSS, injectTheme, isCSSInjected, isDesignTokens, isValidCSSVariableName, loadThemeFromConfig, loadThemeFromConfigSync, mapSCSSTokensToCSSVars, mergeCSSVars, mergeTheme, normalizeThemeTokens, registerTheme, removeCSS, removeCSSVariables, removeTheme, saveTheme, themePropertyToCSSVar, unregisterTheme, useComponentTheme, useHistory, useTheme, useThemeTokens };
1736
+ export { RTLManager, ThemeApplicator, ThemeComparator, ThemeContext, ThemeErrorBoundary, ThemeInspector, ThemeLiveEditor, ThemePreview, ThemeProvider, ThemeValidator, applyCSSVariables, applyComponentTheme, applyTheme, camelToKebab, clearThemes, createTheme, createThemeRegistry, createTokens, cssVarsToStyle, deepMerge, defaultTokens, designTokensToCSSVars, extendTheme, extractComponentName, generateCSSVariableName, generateCSSVariables, generateCSSVariablesForSelector, generateClassName, generateComponentCSSVars, getAllThemes, getCSSVariable, getComponentThemeValue, getTheme, getThemeApplicator, getThemeCount, getThemeIds, hasTheme, injectCSS, injectTheme, isCSSInjected, isDesignTokens, isValidCSSVariableName, mapSCSSTokensToCSSVars, mergeCSSVars, mergeTheme, normalizeThemeTokens, registerTheme, removeCSS, removeCSSVariables, removeTheme, themePropertyToCSSVar, unregisterTheme, useComponentTheme, useHistory, useTheme, useThemeTokens };
1768
1737
  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 };
package/dist/theme.js CHANGED
@@ -555,39 +555,13 @@ class ThemeLogger {
555
555
  tokens = input;
556
556
  }
557
557
  // Merge with defaults and generate CSS
558
- else {
559
- // Check if we're in a browser environment
560
- if ("undefined" != typeof window) throw new ThemeError("No input provided and config loading is not available in browser environment. Please provide tokens explicitly or use Node.js/SSR environment.", ThemeErrorCode.CONFIG_LOAD_FAILED, {
561
- environment: "browser"
562
- });
563
- // Load from config when no input provided
564
- let loadThemeFromConfigSync, loadAtomixConfig;
565
- try {
566
- const configLoaderModule = require("../config/configLoader"), loaderModule = require("../../config/loader");
567
- // Get prefix from config if needed
568
- if (loadThemeFromConfigSync = configLoaderModule.loadThemeFromConfigSync, loadAtomixConfig = loaderModule.loadAtomixConfig,
569
- tokens = loadThemeFromConfigSync(), !options?.prefix) try {
570
- const config = loadAtomixConfig({
571
- configPath: "atomix.config.ts",
572
- required: !1
573
- });
574
- options = {
575
- ...options,
576
- prefix: config?.prefix || "atomix"
577
- };
578
- } catch (error) {
579
- // If config loading fails, use default prefix
580
- options = {
581
- ...options,
582
- prefix: "atomix"
583
- };
584
- }
585
- } catch (error) {
586
- throw new ThemeError("No input provided and config loading is not available in this environment. Please provide tokens explicitly.", ThemeErrorCode.CONFIG_LOAD_FAILED, {
587
- error: error instanceof Error ? error.message : String(error)
588
- });
589
- }
590
- }
558
+ else
559
+ // Auto-loading config from file system is removed for browser compatibility.
560
+ // If no input is provided, we return an empty theme (using defaults only) or user must provide tokens.
561
+ // This allows createTheme to be isomorphic.
562
+ // Warn in development if no input provided
563
+ "production" !== process.env.NODE_ENV && "undefined" != typeof window && console.warn("Atomix: createTheme() called without tokens. Using default tokens only."),
564
+ tokens = {};
591
565
  const allTokens = createTokens(tokens), prefix = options?.prefix ?? "atomix";
592
566
  // Get prefix from options or use default
593
567
  return generateCSSVariables$1(allTokens, {
@@ -819,26 +793,7 @@ class ThemeLogger {
819
793
  return !!isBrowser$1() && null !== document.getElementById(id);
820
794
  }
821
795
 
822
- /**
823
- * CSS File Utilities
824
- *
825
- * Save CSS to file system (Node.js only).
826
- */
827
- /**
828
- * Save CSS to file
829
- *
830
- * Writes CSS string to a file. Only works in Node.js environment.
831
- *
832
- * @param css - CSS string to save
833
- * @param filePath - Output file path
834
- * @throws Error if called in browser environment
835
- *
836
- * @example
837
- * ```typescript
838
- * const css = ':root { --atomix-color-primary: #7AFFD7; }';
839
- * await saveCSSFile(css, './themes/custom.css');
840
- * ```
841
- */ var commonjsGlobal = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};
796
+ var commonjsGlobal = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};
842
797
 
843
798
  function getDefaultExportFromCjs(x) {
844
799
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
@@ -1995,129 +1950,6 @@ function generateClassName(block, element, modifiers) {
1995
1950
  return property => getComponentThemeValue(component, property, variant, size);
1996
1951
  }
1997
1952
 
1998
- /**
1999
- * Atomix Config Loader
2000
- *
2001
- * Helper functions to load atomix.config.ts from external projects.
2002
- * Similar to how Tailwind loads tailwind.config.js
2003
- */
2004
- /**
2005
- * Load Atomix configuration from project root
2006
- *
2007
- * Attempts to load atomix.config.ts from the current working directory.
2008
- * Falls back to default config if file doesn't exist.
2009
- *
2010
- * @param options - Loader options
2011
- * @returns Loaded configuration or default
2012
- *
2013
- * @example
2014
- * ```typescript
2015
- * import { loadAtomixConfig } from '@shohojdhara/atomix/config';
2016
- * import { createTheme } from '@shohojdhara/atomix/theme';
2017
- *
2018
- * const config = loadAtomixConfig();
2019
- * const theme = createTheme(config.theme?.tokens || {});
2020
- * ```
2021
- */ function loadAtomixConfig(options = {}) {
2022
- const {configPath: configPath = "atomix.config.ts", required: required = !1} = options, defaultConfig = {
2023
- prefix: "atomix",
2024
- theme: {
2025
- extend: {}
2026
- }
2027
- };
2028
- // Default config
2029
- // In browser environments, config loading is not supported
2030
- if ("undefined" != typeof window) {
2031
- if (required) throw new Error("loadAtomixConfig: Not available in browser environment. Config loading requires Node.js/SSR environment.");
2032
- return defaultConfig;
2033
- }
2034
- // Try to load config file
2035
- try {
2036
- // Use dynamic import for ESM compatibility
2037
- const configModule = require(configPath), config = configModule.default || configModule;
2038
- // Validate it's an AtomixConfig
2039
- if (config && "object" == typeof config) return config;
2040
- throw new Error("Invalid config format");
2041
- } catch (error) {
2042
- if (required) throw new Error(`Failed to load config from ${configPath}: ${error.message}`);
2043
- // Return default config if not required
2044
- return defaultConfig;
2045
- }
2046
- }
2047
-
2048
- /**
2049
- * Theme Configuration Loader
2050
- *
2051
- * Provides functions to load theme configurations from atomix.config.ts
2052
- * Includes both sync and async versions, with automatic fallbacks
2053
- */
2054
- /**
2055
- * Load theme from config file (synchronous, Node.js only)
2056
- * @param configPath - Path to config file (default: atomix.config.ts)
2057
- * @returns DesignTokens from theme configuration
2058
- * @throws Error if config loading is not available in browser environment
2059
- */ function loadThemeFromConfigSync(options) {
2060
- // Check if we're in a browser environment
2061
- if ("undefined" != typeof window) throw new Error("loadThemeFromConfigSync: Not available in browser environment. Config loading requires Node.js/SSR environment.");
2062
- // Use static import - the function handles browser environment checks internally
2063
- let config;
2064
- try {
2065
- config = loadAtomixConfig({
2066
- configPath: options?.configPath || "atomix.config.ts",
2067
- required: !1 !== options?.required
2068
- });
2069
- } catch (error) {
2070
- if (!1 !== options?.required) throw new Error("Config loader module not available");
2071
- // Return empty tokens if config is not required
2072
- return createTokens({});
2073
- }
2074
- if (!config?.theme) return createTokens({});
2075
- // Extract tokens from config.theme structure
2076
- // config.theme can have: { extend?: ThemeTokens, tokens?: ThemeTokens, themes?: ... }
2077
- // We need to extract the actual DesignTokens (flat structure)
2078
- const themeConfig = config.theme;
2079
- // Check if theme is directly a flat object (DesignTokens format)
2080
- // This handles the case where config.theme might be passed as DesignTokens directly
2081
- return createTokens(!themeConfig || "object" != typeof themeConfig || "extend" in themeConfig || "tokens" in themeConfig || "themes" in themeConfig ? {} : themeConfig);
2082
- // If theme has nested structure (extend/tokens/themes), we can't directly use it
2083
- // Return empty tokens - the theme system will use defaults
2084
- // TODO: Add proper conversion from ThemeTokens to DesignTokens if needed
2085
- }
2086
-
2087
- /**
2088
- * Load theme from config file (asynchronous)
2089
- * @param configPath - Path to config file (default: atomix.config.ts)
2090
- * @returns Promise resolving to DesignTokens from theme configuration
2091
- */ async function loadThemeFromConfig(options) {
2092
- // Check if we're in a browser environment
2093
- if ("undefined" != typeof window) throw new Error("loadThemeFromConfig: Not available in browser environment. Config loading requires Node.js/SSR environment.");
2094
- // Use static import with runtime check
2095
- // The function will handle browser environment checks internally
2096
- let config;
2097
- try {
2098
- // loadAtomixConfig is synchronous, not async
2099
- config = loadAtomixConfig({
2100
- configPath: options?.configPath || "atomix.config.ts",
2101
- required: !1 !== options?.required
2102
- });
2103
- } catch (error) {
2104
- if (!1 !== options?.required) throw new Error("Config loader module not available");
2105
- // Return empty tokens if config is not required
2106
- return createTokens({});
2107
- }
2108
- if (!config?.theme) return createTokens({});
2109
- // Extract tokens from config.theme structure
2110
- // config.theme can have: { extend?: ThemeTokens, tokens?: ThemeTokens, themes?: ... }
2111
- // We need to extract the actual DesignTokens (flat structure)
2112
- const themeConfig = config.theme;
2113
- // Check if theme is directly a flat object (DesignTokens format)
2114
- // This handles the case where config.theme might be passed as DesignTokens directly
2115
- return createTokens(!themeConfig || "object" != typeof themeConfig || "extend" in themeConfig || "tokens" in themeConfig || "themes" in themeConfig ? {} : themeConfig);
2116
- // If theme has nested structure (extend/tokens/themes), we can't directly use it
2117
- // Return empty tokens - the theme system will use defaults
2118
- // TODO: Add proper conversion from ThemeTokens to DesignTokens if needed
2119
- }
2120
-
2121
1953
  /**
2122
1954
  * Theme Context
2123
1955
  *
@@ -2159,21 +1991,9 @@ const ThemeProvider = ({children: children, defaultTheme: defaultTheme, themes:
2159
1991
  if (stored) return stored;
2160
1992
  }
2161
1993
  // If defaultTheme is provided, use it
2162
- if (null != defaultTheme) return defaultTheme;
2163
- // Try to load from atomix.config.ts as fallback, but only in Node.js/SSR environments
2164
- if ("undefined" == typeof window) try {
2165
- // Dynamically import the config loader to avoid bundling issues in browser
2166
- // eslint-disable-next-line @typescript-eslint/no-var-requires
2167
- const {loadThemeFromConfigSync: loadThemeFromConfigSync} = require("../config/configLoader"), configTokens = loadThemeFromConfigSync();
2168
- if (configTokens && Object.keys(configTokens).length > 0)
2169
- // For simplicity, we'll treat config tokens as a special theme name
2170
- return "config-theme";
2171
- } catch (error) {
2172
- // Failed to load theme from config, using default
2173
- }
1994
+ return null != defaultTheme ? defaultTheme : "default";
2174
1995
  // Default fallback
2175
- return "default";
2176
- }), [ defaultTheme, enablePersistence, storageKey ]), [currentTheme, setCurrentTheme] = useState((() => "string" == typeof initialDefaultTheme ? initialDefaultTheme : "tokens-theme")), [activeTokens, setActiveTokens] = useState((() =>
1996
+ }), [ defaultTheme, enablePersistence, storageKey ]), [currentTheme, setCurrentTheme] = useState((() => "string" == typeof initialDefaultTheme ? initialDefaultTheme : "tokens-theme")), [activeTokens, setActiveTokens] = useState((() =>
2177
1997
  // If defaultTheme is DesignTokens, store them
2178
1998
  defaultTheme && "string" != typeof defaultTheme ? createTokens(defaultTheme) : null)), [isLoading, setIsLoading] = useState(!1), [error, setError] = useState(null), loadedThemesRef = useRef(new Set), themePromisesRef = useRef({}), abortControllerRef = useRef(null);
2179
1999
  // Handle initial DesignTokens defaultTheme
@@ -5316,6 +5136,7 @@ class RTLManager {
5316
5136
  // Core Theme Functions
5317
5137
  // ============================================================================
5318
5138
  // Create theme CSS from DesignTokens
5139
+ // File saving utilities removed to prevent bundling Node.js modules in browser
5319
5140
  /**
5320
5141
  * Inject theme CSS into DOM
5321
5142
  */ function injectTheme(css, id = "atomix-theme") {
@@ -5328,21 +5149,5 @@ class RTLManager {
5328
5149
  removeCSS(id);
5329
5150
  }
5330
5151
 
5331
- /**
5332
- * Save theme to CSS file
5333
- */ async function saveTheme(css, filePath) {
5334
- await async function(css, filePath) {
5335
- // Check if in browser environment
5336
- if ("undefined" != typeof window) throw new Error("saveCSSFile can only be used in Node.js environment. Use injectCSS() for browser environments.");
5337
- // Dynamic import to avoid bundling Node.js modules in browser builds
5338
- const fs = await import("fs/promises"), dir = (await import("path")).dirname(filePath);
5339
- await fs.mkdir(dir, {
5340
- recursive: !0
5341
- }),
5342
- // Write file
5343
- await fs.writeFile(filePath, css, "utf8");
5344
- }(css, filePath);
5345
- }
5346
-
5347
- export { RTLManager, ThemeApplicator, ThemeComparator, ThemeContext, ThemeErrorBoundary, ThemeInspector, ThemeLiveEditor, ThemePreview, ThemeProvider, ThemeValidator, applyCSSVariables, applyComponentTheme, applyTheme, camelToKebab, clearThemes, createTheme, createThemeRegistry, createTokens, cssVarsToStyle, deepMerge, defaultTokens, designTokensToCSSVars, extendTheme, extractComponentName, generateCSSVariableName, generateCSSVariables$1 as generateCSSVariables, generateCSSVariablesForSelector, generateClassName, generateComponentCSSVars, getAllThemes, getCSSVariable, getComponentThemeValue, getTheme, getThemeApplicator, getThemeCount, getThemeIds, hasTheme, injectCSS$1 as injectCSS, injectTheme, isCSSInjected, isDesignTokens, isValidCSSVariableName, loadThemeFromConfig, loadThemeFromConfigSync, mapSCSSTokensToCSSVars, mergeCSSVars, mergeTheme, normalizeThemeTokens, registerTheme, removeCSS, removeCSSVariables, removeTheme, saveTheme, themePropertyToCSSVar, unregisterTheme, useComponentTheme, useHistory, useTheme, useThemeTokens };
5152
+ export { RTLManager, ThemeApplicator, ThemeComparator, ThemeContext, ThemeErrorBoundary, ThemeInspector, ThemeLiveEditor, ThemePreview, ThemeProvider, ThemeValidator, applyCSSVariables, applyComponentTheme, applyTheme, camelToKebab, clearThemes, createTheme, createThemeRegistry, createTokens, cssVarsToStyle, deepMerge, defaultTokens, designTokensToCSSVars, extendTheme, extractComponentName, generateCSSVariableName, generateCSSVariables$1 as generateCSSVariables, generateCSSVariablesForSelector, generateClassName, generateComponentCSSVars, getAllThemes, getCSSVariable, getComponentThemeValue, getTheme, getThemeApplicator, getThemeCount, getThemeIds, hasTheme, injectCSS$1 as injectCSS, injectTheme, isCSSInjected, isDesignTokens, isValidCSSVariableName, mapSCSSTokensToCSSVars, mergeCSSVars, mergeTheme, normalizeThemeTokens, registerTheme, removeCSS, removeCSSVariables, removeTheme, themePropertyToCSSVar, unregisterTheme, useComponentTheme, useHistory, useTheme, useThemeTokens };
5348
5153
  //# sourceMappingURL=theme.js.map