@shohojdhara/atomix 0.3.8 → 0.3.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.10] - 2026-01-06
4
+
5
+ ### Fixed
6
+ - Fixed `Module not found: Can't resolve './lib/config/loader'` by bundling `loadAtomixConfig` instead of treating it as external.
7
+
8
+ ## [0.3.9] - 2026-01-06
9
+
10
+ ### Fixed
11
+ - Fixed `Module not found` error by replacing dynamic `require` with static import in `ThemeProvider`. This resolves build issues in external projects (e.g. Next.js).
3
12
  All notable changes to this project will be documented in this file.
4
13
 
5
14
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -12,7 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
12
21
  ### Added
13
22
 
14
23
  #### Theme Manager System
24
+
15
25
  - **Theme Manager Class**: Core theme management for vanilla JavaScript applications
26
+
16
27
  - Dynamic theme loading with CSS file management
17
28
  - Theme persistence using localStorage
18
29
  - Event system for theme changes (`themeChange`, `themeLoad`, `themeError`)
@@ -21,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21
32
  - Comprehensive error handling
22
33
 
23
34
  - **React Integration**:
35
+
24
36
  - `ThemeProvider` component for React applications
25
37
  - `useTheme` hook for accessing theme state
26
38
  - `ThemeContext` for context-based state management
@@ -28,15 +40,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
28
40
  - Automatic cleanup on unmount
29
41
 
30
42
  - **TypeScript Support**:
43
+
31
44
  - Complete type definitions for all theme utilities
32
45
  - `ThemeMetadata`, `ThemeManagerConfig`, `ThemeChangeEvent` interfaces
33
46
  - Type-safe event system
34
47
  - Full IntelliSense support
35
48
 
36
49
  - **Package Exports**:
50
+
37
51
  - `@shohojdhara/atomix/theme` - Theme manager utilities
38
52
 
39
53
  - **Documentation**:
54
+
40
55
  - Comprehensive theme manager guide (`docs/THEME_MANAGER.md`)
41
56
  - React usage examples
42
57
  - Vanilla JavaScript examples
@@ -51,11 +66,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
51
66
  - Theme dependencies mapping
52
67
 
53
68
  ### Changed
69
+
54
70
  - Updated `README.md` with theme manager usage examples
55
71
  - Enhanced `themes.config.js` with runtime configuration options
56
72
  - Updated `src/lib/index.ts` to export theme utilities
57
73
 
58
74
  ### Features
75
+
59
76
  - 🎨 Dynamic theme switching without page reload
60
77
  - 💾 Automatic theme persistence across sessions
61
78
  - ⚡ Theme preloading for instant switching
@@ -73,11 +90,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
73
90
  ## [0.1.25] - 2025-07-02
74
91
 
75
92
  ### Fixed
93
+
76
94
  - Fixed module parse error with undefined exports in ESM build
77
95
  - Fixed Tooltip component export issue (previously exported as `Tooltip_Tooltip as Tooltip`)
78
96
  - Added post-build script to ensure all components are properly exported
79
97
 
80
98
  ### Added
99
+
81
100
  - Added support for direct component imports via `@shohojdhara/atomix/components/*`
82
101
  - Added troubleshooting guide for common issues
83
102
 
@@ -86,6 +105,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
86
105
  ## [0.1.16] - 2025-07-02
87
106
 
88
107
  ### Added
108
+
89
109
  - Initial release of Atomix Design System
90
110
  - Core components library with React and vanilla JavaScript support
91
111
  - Multiple module formats: ESM, CJS, and UMD
@@ -94,4 +114,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
94
114
  ## [0.1.0] - 2023-06-09
95
115
 
96
116
  ### Added
97
- - Initial public release
117
+
118
+ - Initial public release
package/dist/core.d.ts CHANGED
@@ -1229,9 +1229,9 @@ type ButtonAsProp = {
1229
1229
  LinkComponent?: React$1.ComponentType<any>;
1230
1230
  [key: string]: any;
1231
1231
  };
1232
- declare const Button: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<Omit<ButtonProps & ButtonAsProp, "ref"> & React$1.RefAttributes<HTMLAnchorElement | HTMLButtonElement>>>;
1232
+ declare const Button: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<Omit<ButtonProps & ButtonAsProp, "ref"> & React$1.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>>;
1233
1233
 
1234
- declare const Card: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<CardProps & React$1.RefAttributes<HTMLDivElement | HTMLAnchorElement>>>;
1234
+ declare const Card: React$1.MemoExoticComponent<React$1.ForwardRefExoticComponent<CardProps & React$1.RefAttributes<HTMLAnchorElement | HTMLDivElement>>>;
1235
1235
 
1236
1236
  declare const ElevationCard: React$1.FC<ElevationCardProps>;
1237
1237
 
package/dist/index.esm.js CHANGED
@@ -8,8 +8,6 @@ import { Pause, Play, SkipBack, SkipForward, SpeakerX, SpeakerHigh, Gear, Downlo
8
8
 
9
9
  import { createPortal } from "react-dom";
10
10
 
11
- import { loadAtomixConfig as loadAtomixConfig$1 } from "./lib/config/loader";
12
-
13
11
  /**
14
12
  * Default theme colors for components
15
13
  */ const THEME_COLORS = [ "primary", "secondary", "success", "info", "warning", "error", "light", "dark" ], SIZES = [ "sm", "md", "lg" ], CLASS_PREFIX = {
@@ -19021,14 +19019,6 @@ function createTokens(overrides) {
19021
19019
  };
19022
19020
  }
19023
19021
 
19024
- const tokens = Object.freeze( Object.defineProperty({
19025
- __proto__: null,
19026
- createTokens: createTokens,
19027
- defaultTokens: defaultTokens
19028
- }, Symbol.toStringTag, {
19029
- value: "Module"
19030
- }));
19031
-
19032
19022
  /**
19033
19023
  * CSS Variable Generator
19034
19024
  *
@@ -20324,6 +20314,103 @@ function generateClassName(block, element, modifiers) {
20324
20314
  return property => getComponentThemeValue(component, property, variant, size);
20325
20315
  }
20326
20316
 
20317
+ /**
20318
+ * Atomix Config Loader
20319
+ *
20320
+ * Helper functions to load atomix.config.ts from external projects.
20321
+ * Similar to how Tailwind loads tailwind.config.js
20322
+ */
20323
+ /**
20324
+ * Load Atomix configuration from project root
20325
+ *
20326
+ * Attempts to load atomix.config.ts from the current working directory.
20327
+ * Falls back to default config if file doesn't exist.
20328
+ *
20329
+ * @param options - Loader options
20330
+ * @returns Loaded configuration or default
20331
+ *
20332
+ * @example
20333
+ * ```typescript
20334
+ * import { loadAtomixConfig } from '@shohojdhara/atomix/config';
20335
+ * import { createTheme } from '@shohojdhara/atomix/theme';
20336
+ *
20337
+ * const config = loadAtomixConfig();
20338
+ * const theme = createTheme(config.theme?.tokens || {});
20339
+ * ```
20340
+ */ function loadAtomixConfig(options = {}) {
20341
+ const {configPath: configPath = "atomix.config.ts", required: required = !1} = options, defaultConfig = {
20342
+ prefix: "atomix",
20343
+ theme: {
20344
+ extend: {}
20345
+ }
20346
+ };
20347
+ // Default config
20348
+ // In browser environments, config loading is not supported
20349
+ if ("undefined" != typeof window) {
20350
+ if (required) throw new Error("loadAtomixConfig: Not available in browser environment. Config loading requires Node.js/SSR environment.");
20351
+ return defaultConfig;
20352
+ }
20353
+ // Try to load config file
20354
+ try {
20355
+ // Use dynamic import for ESM compatibility
20356
+ const configModule = require(configPath), config = configModule.default || configModule;
20357
+ // Validate it's an AtomixConfig
20358
+ if (config && "object" == typeof config) return config;
20359
+ throw new Error("Invalid config format");
20360
+ } catch (error) {
20361
+ if (required) throw new Error(`Failed to load config from ${configPath}: ${error.message}`);
20362
+ // Return default config if not required
20363
+ return defaultConfig;
20364
+ }
20365
+ }
20366
+
20367
+ /**
20368
+ * Resolve config path
20369
+ *
20370
+ * Finds atomix.config.ts in the project, checking common locations.
20371
+ * Returns null in browser environments where file system access is not available.
20372
+ *
20373
+ * This function is designed to work in Node.js environments only.
20374
+ * In browser builds, it will always return null without attempting to access Node.js modules.
20375
+ *
20376
+ * @internal This function uses Node.js modules and should not be called in browser environments.
20377
+ */ function resolveConfigPath() {
20378
+ // Early return for browser environments - prevents any Node.js module access
20379
+ // This check happens before any require() calls, preventing bundlers from analyzing them
20380
+ if ("undefined" != typeof window || "undefined" == typeof process || !process.cwd) return null;
20381
+ // Only attempt to load Node.js modules in Node.js runtime
20382
+ // Use a lazy-loading pattern that prevents static analysis by bundlers
20383
+ try {
20384
+ // Create a function that only executes in Node.js runtime
20385
+ // Use string-based module names to prevent static analysis by bundlers
20386
+ const modules = (() => {
20387
+ // These requires are only executed at runtime in Node.js environments
20388
+ // They are marked as external in Rollup config and should not be bundled
20389
+ // Using string concatenation and computed property access to prevent static analysis
20390
+ if ("undefined" == typeof require) return null;
20391
+ // Use a try-catch wrapper to safely access require
20392
+ try {
20393
+ // Build module names dynamically to prevent static analysis
20394
+ const moduleNames = [ "fs", "path" ];
20395
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
20396
+ return {
20397
+ fs: require(moduleNames[0]),
20398
+ path: require(moduleNames[1])
20399
+ };
20400
+ } catch {
20401
+ return null;
20402
+ }
20403
+ })();
20404
+ if (!modules) return null;
20405
+ const {fs: fs, path: path} = modules, cwd = process.cwd(), possiblePaths = [ path.join(cwd, "atomix.config.ts"), path.join(cwd, "atomix.config.js"), path.join(cwd, "atomix.config.mjs") ];
20406
+ for (const configPath of possiblePaths) if (fs.existsSync(configPath)) return configPath;
20407
+ } catch (error) {
20408
+ // Silently fail in browser environments or when modules are unavailable
20409
+ return null;
20410
+ }
20411
+ return null;
20412
+ }
20413
+
20327
20414
  /**
20328
20415
  * Theme Configuration Loader
20329
20416
  *
@@ -20341,7 +20428,7 @@ function generateClassName(block, element, modifiers) {
20341
20428
  // Use static import - the function handles browser environment checks internally
20342
20429
  let config;
20343
20430
  try {
20344
- config = loadAtomixConfig$1({
20431
+ config = loadAtomixConfig({
20345
20432
  configPath: options?.configPath || "atomix.config.ts",
20346
20433
  required: !1 !== options?.required
20347
20434
  });
@@ -20375,7 +20462,7 @@ function generateClassName(block, element, modifiers) {
20375
20462
  let config;
20376
20463
  try {
20377
20464
  // loadAtomixConfig is synchronous, not async
20378
- config = loadAtomixConfig$1({
20465
+ config = loadAtomixConfig({
20379
20466
  configPath: options?.configPath || "atomix.config.ts",
20380
20467
  required: !1 !== options?.required
20381
20468
  });
@@ -20452,14 +20539,9 @@ const ThemeProvider = ({children: children, defaultTheme: defaultTheme, themes:
20452
20539
  }
20453
20540
  // Default fallback
20454
20541
  return "default";
20455
- }), [ defaultTheme, enablePersistence, storageKey ]), [currentTheme, setCurrentTheme] = useState((() => "string" == typeof initialDefaultTheme ? initialDefaultTheme : "tokens-theme")), [activeTokens, setActiveTokens] = useState((() => {
20456
- // If defaultTheme is DesignTokens, store them
20457
- if (defaultTheme && "string" != typeof defaultTheme) {
20458
- const {createTokens: createTokens} = require("../tokens/tokens");
20459
- return createTokens(defaultTheme);
20460
- }
20461
- return null;
20462
- })), [isLoading, setIsLoading] = useState(!1), [error, setError] = useState(null), loadedThemesRef = useRef(new Set), themePromisesRef = useRef({}), abortControllerRef = useRef(null);
20542
+ }), [ defaultTheme, enablePersistence, storageKey ]), [currentTheme, setCurrentTheme] = useState((() => "string" == typeof initialDefaultTheme ? initialDefaultTheme : "tokens-theme")), [activeTokens, setActiveTokens] = useState((() =>
20543
+ // If defaultTheme is DesignTokens, store them
20544
+ defaultTheme && "string" != typeof defaultTheme ? createTokens(defaultTheme) : null)), [isLoading, setIsLoading] = useState(!1), [error, setError] = useState(null), loadedThemesRef = useRef(new Set), themePromisesRef = useRef({}), abortControllerRef = useRef(null);
20463
20545
  // Handle initial DesignTokens defaultTheme
20464
20546
  useEffect((() => {
20465
20547
  defaultTheme && "string" != typeof defaultTheme && activeTokens && !isServer() && injectCSS$1(createTheme(defaultTheme), "theme-tokens-theme");
@@ -20501,9 +20583,9 @@ const ThemeProvider = ({children: children, defaultTheme: defaultTheme, themes:
20501
20583
  // Inject new theme CSS
20502
20584
  injectCSS$1(css, `theme-${themeId}`);
20503
20585
  // Store tokens for reference
20504
- const {createTokens: createTokens} = await Promise.resolve().then((() => tokens)), fullTokens = createTokens(theme);
20586
+ const fullTokens = createTokens(theme);
20505
20587
  // Check if aborted before state update
20506
- if (abortController.signal.aborted) return;
20588
+ if (abortController.signal.aborted) return;
20507
20589
  return setActiveTokens(fullTokens), setCurrentTheme(themeId), handleThemeChange(fullTokens),
20508
20590
  void setIsLoading(!1);
20509
20591
  }
@@ -23996,103 +24078,6 @@ function getComponentCSSVars(component) {
23996
24078
  };
23997
24079
  }
23998
24080
 
23999
- /**
24000
- * Atomix Config Loader
24001
- *
24002
- * Helper functions to load atomix.config.ts from external projects.
24003
- * Similar to how Tailwind loads tailwind.config.js
24004
- */
24005
- /**
24006
- * Load Atomix configuration from project root
24007
- *
24008
- * Attempts to load atomix.config.ts from the current working directory.
24009
- * Falls back to default config if file doesn't exist.
24010
- *
24011
- * @param options - Loader options
24012
- * @returns Loaded configuration or default
24013
- *
24014
- * @example
24015
- * ```typescript
24016
- * import { loadAtomixConfig } from '@shohojdhara/atomix/config';
24017
- * import { createTheme } from '@shohojdhara/atomix/theme';
24018
- *
24019
- * const config = loadAtomixConfig();
24020
- * const theme = createTheme(config.theme?.tokens || {});
24021
- * ```
24022
- */ function loadAtomixConfig(options = {}) {
24023
- const {configPath: configPath = "atomix.config.ts", required: required = !1} = options, defaultConfig = {
24024
- prefix: "atomix",
24025
- theme: {
24026
- extend: {}
24027
- }
24028
- };
24029
- // Default config
24030
- // In browser environments, config loading is not supported
24031
- if ("undefined" != typeof window) {
24032
- if (required) throw new Error("loadAtomixConfig: Not available in browser environment. Config loading requires Node.js/SSR environment.");
24033
- return defaultConfig;
24034
- }
24035
- // Try to load config file
24036
- try {
24037
- // Use dynamic import for ESM compatibility
24038
- const configModule = require(configPath), config = configModule.default || configModule;
24039
- // Validate it's an AtomixConfig
24040
- if (config && "object" == typeof config) return config;
24041
- throw new Error("Invalid config format");
24042
- } catch (error) {
24043
- if (required) throw new Error(`Failed to load config from ${configPath}: ${error.message}`);
24044
- // Return default config if not required
24045
- return defaultConfig;
24046
- }
24047
- }
24048
-
24049
- /**
24050
- * Resolve config path
24051
- *
24052
- * Finds atomix.config.ts in the project, checking common locations.
24053
- * Returns null in browser environments where file system access is not available.
24054
- *
24055
- * This function is designed to work in Node.js environments only.
24056
- * In browser builds, it will always return null without attempting to access Node.js modules.
24057
- *
24058
- * @internal This function uses Node.js modules and should not be called in browser environments.
24059
- */ function resolveConfigPath() {
24060
- // Early return for browser environments - prevents any Node.js module access
24061
- // This check happens before any require() calls, preventing bundlers from analyzing them
24062
- if ("undefined" != typeof window || "undefined" == typeof process || !process.cwd) return null;
24063
- // Only attempt to load Node.js modules in Node.js runtime
24064
- // Use a lazy-loading pattern that prevents static analysis by bundlers
24065
- try {
24066
- // Create a function that only executes in Node.js runtime
24067
- // Use string-based module names to prevent static analysis by bundlers
24068
- const modules = (() => {
24069
- // These requires are only executed at runtime in Node.js environments
24070
- // They are marked as external in Rollup config and should not be bundled
24071
- // Using string concatenation and computed property access to prevent static analysis
24072
- if ("undefined" == typeof require) return null;
24073
- // Use a try-catch wrapper to safely access require
24074
- try {
24075
- // Build module names dynamically to prevent static analysis
24076
- const moduleNames = [ "fs", "path" ];
24077
- // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
24078
- return {
24079
- fs: require(moduleNames[0]),
24080
- path: require(moduleNames[1])
24081
- };
24082
- } catch {
24083
- return null;
24084
- }
24085
- })();
24086
- if (!modules) return null;
24087
- const {fs: fs, path: path} = modules, cwd = process.cwd(), possiblePaths = [ path.join(cwd, "atomix.config.ts"), path.join(cwd, "atomix.config.js"), path.join(cwd, "atomix.config.mjs") ];
24088
- for (const configPath of possiblePaths) if (fs.existsSync(configPath)) return configPath;
24089
- } catch (error) {
24090
- // Silently fail in browser environments or when modules are unavailable
24091
- return null;
24092
- }
24093
- return null;
24094
- }
24095
-
24096
24081
  /**
24097
24082
  * Atomix Configuration System
24098
24083
  *