@shohojdhara/atomix 0.3.9 → 0.3.11
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 +14 -3
- package/dist/index.d.ts +2 -80
- package/dist/index.esm.js +14 -262
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +58 -303
- 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 +1 -32
- package/dist/theme.js +12 -159
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/config/index.ts +5 -5
- package/src/lib/theme/config/index.ts +1 -1
- package/src/lib/theme/core/createTheme.ts +11 -40
- package/src/lib/theme/generators/index.ts +1 -4
- package/src/lib/theme/index.ts +4 -16
- package/src/lib/theme/runtime/ThemeProvider.tsx +1 -16
- package/src/lib/config/loader.ts +0 -147
- package/src/lib/theme/config/__tests__/configLoader.test.ts +0 -207
- package/src/lib/theme/config/configLoader.ts +0 -113
- package/src/lib/theme/config/loader.ts +0 -293
- package/src/lib/theme/generators/cssFile.ts +0 -79
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var jsxRuntime = require("react/jsx-runtime"), React = require("react"), PhosphorIcons = require("@phosphor-icons/react"), reactDom = require("react-dom")
|
|
7
|
+
var jsxRuntime = require("react/jsx-runtime"), React = require("react"), PhosphorIcons = require("@phosphor-icons/react"), reactDom = require("react-dom");
|
|
8
8
|
|
|
9
9
|
function _interopDefaultCompat(e) {
|
|
10
10
|
return e && "object" == typeof e && "default" in e ? e : {
|
|
@@ -19337,39 +19337,13 @@ class ThemeLogger {
|
|
|
19337
19337
|
tokens = input;
|
|
19338
19338
|
}
|
|
19339
19339
|
// Merge with defaults and generate CSS
|
|
19340
|
-
else
|
|
19341
|
-
|
|
19342
|
-
|
|
19343
|
-
|
|
19344
|
-
|
|
19345
|
-
|
|
19346
|
-
|
|
19347
|
-
try {
|
|
19348
|
-
const configLoaderModule = require("../config/configLoader"), loaderModule = require("../../config/loader");
|
|
19349
|
-
// Get prefix from config if needed
|
|
19350
|
-
if (loadThemeFromConfigSync = configLoaderModule.loadThemeFromConfigSync, loadAtomixConfig = loaderModule.loadAtomixConfig,
|
|
19351
|
-
tokens = loadThemeFromConfigSync(), !options?.prefix) try {
|
|
19352
|
-
const config = loadAtomixConfig({
|
|
19353
|
-
configPath: "atomix.config.ts",
|
|
19354
|
-
required: !1
|
|
19355
|
-
});
|
|
19356
|
-
options = {
|
|
19357
|
-
...options,
|
|
19358
|
-
prefix: config?.prefix || "atomix"
|
|
19359
|
-
};
|
|
19360
|
-
} catch (error) {
|
|
19361
|
-
// If config loading fails, use default prefix
|
|
19362
|
-
options = {
|
|
19363
|
-
...options,
|
|
19364
|
-
prefix: "atomix"
|
|
19365
|
-
};
|
|
19366
|
-
}
|
|
19367
|
-
} catch (error) {
|
|
19368
|
-
throw new ThemeError("No input provided and config loading is not available in this environment. Please provide tokens explicitly.", ThemeErrorCode.CONFIG_LOAD_FAILED, {
|
|
19369
|
-
error: error instanceof Error ? error.message : String(error)
|
|
19370
|
-
});
|
|
19371
|
-
}
|
|
19372
|
-
}
|
|
19340
|
+
else
|
|
19341
|
+
// Auto-loading config from file system is removed for browser compatibility.
|
|
19342
|
+
// If no input is provided, we return an empty theme (using defaults only) or user must provide tokens.
|
|
19343
|
+
// This allows createTheme to be isomorphic.
|
|
19344
|
+
// Warn in development if no input provided
|
|
19345
|
+
"production" !== process.env.NODE_ENV && "undefined" != typeof window && console.warn("Atomix: createTheme() called without tokens. Using default tokens only."),
|
|
19346
|
+
tokens = {};
|
|
19373
19347
|
const allTokens = createTokens(tokens), prefix = options?.prefix ?? "atomix";
|
|
19374
19348
|
// Get prefix from options or use default
|
|
19375
19349
|
return generateCSSVariables$1(allTokens, {
|
|
@@ -19600,24 +19574,12 @@ class ThemeLogger {
|
|
|
19600
19574
|
}
|
|
19601
19575
|
|
|
19602
19576
|
/**
|
|
19603
|
-
*
|
|
19577
|
+
* Theme System Constants
|
|
19604
19578
|
*
|
|
19605
|
-
*
|
|
19579
|
+
* Centralized constants for the theme system to avoid magic numbers and strings.
|
|
19606
19580
|
*/
|
|
19607
19581
|
/**
|
|
19608
|
-
*
|
|
19609
|
-
*
|
|
19610
|
-
* Writes CSS string to a file. Only works in Node.js environment.
|
|
19611
|
-
*
|
|
19612
|
-
* @param css - CSS string to save
|
|
19613
|
-
* @param filePath - Output file path
|
|
19614
|
-
* @throws Error if called in browser environment
|
|
19615
|
-
*
|
|
19616
|
-
* @example
|
|
19617
|
-
* ```typescript
|
|
19618
|
-
* const css = ':root { --atomix-color-primary: #7AFFD7; }';
|
|
19619
|
-
* await saveCSSFile(css, './themes/custom.css');
|
|
19620
|
-
* ```
|
|
19582
|
+
* Default storage key for theme persistence
|
|
19621
19583
|
*/ "undefined" != typeof process && process.env;
|
|
19622
19584
|
|
|
19623
19585
|
/**
|
|
@@ -20392,79 +20354,6 @@ function generateClassName(block, element, modifiers) {
|
|
|
20392
20354
|
return property => getComponentThemeValue(component, property, variant, size);
|
|
20393
20355
|
}
|
|
20394
20356
|
|
|
20395
|
-
/**
|
|
20396
|
-
* Theme Configuration Loader
|
|
20397
|
-
*
|
|
20398
|
-
* Provides functions to load theme configurations from atomix.config.ts
|
|
20399
|
-
* Includes both sync and async versions, with automatic fallbacks
|
|
20400
|
-
*/
|
|
20401
|
-
/**
|
|
20402
|
-
* Load theme from config file (synchronous, Node.js only)
|
|
20403
|
-
* @param configPath - Path to config file (default: atomix.config.ts)
|
|
20404
|
-
* @returns DesignTokens from theme configuration
|
|
20405
|
-
* @throws Error if config loading is not available in browser environment
|
|
20406
|
-
*/ function loadThemeFromConfigSync(options) {
|
|
20407
|
-
// Check if we're in a browser environment
|
|
20408
|
-
if ("undefined" != typeof window) throw new Error("loadThemeFromConfigSync: Not available in browser environment. Config loading requires Node.js/SSR environment.");
|
|
20409
|
-
// Use static import - the function handles browser environment checks internally
|
|
20410
|
-
let config;
|
|
20411
|
-
try {
|
|
20412
|
-
config = loader.loadAtomixConfig({
|
|
20413
|
-
configPath: options?.configPath || "atomix.config.ts",
|
|
20414
|
-
required: !1 !== options?.required
|
|
20415
|
-
});
|
|
20416
|
-
} catch (error) {
|
|
20417
|
-
if (!1 !== options?.required) throw new Error("Config loader module not available");
|
|
20418
|
-
// Return empty tokens if config is not required
|
|
20419
|
-
return createTokens({});
|
|
20420
|
-
}
|
|
20421
|
-
if (!config?.theme) return createTokens({});
|
|
20422
|
-
// Extract tokens from config.theme structure
|
|
20423
|
-
// config.theme can have: { extend?: ThemeTokens, tokens?: ThemeTokens, themes?: ... }
|
|
20424
|
-
// We need to extract the actual DesignTokens (flat structure)
|
|
20425
|
-
const themeConfig = config.theme;
|
|
20426
|
-
// Check if theme is directly a flat object (DesignTokens format)
|
|
20427
|
-
// This handles the case where config.theme might be passed as DesignTokens directly
|
|
20428
|
-
return createTokens(!themeConfig || "object" != typeof themeConfig || "extend" in themeConfig || "tokens" in themeConfig || "themes" in themeConfig ? {} : themeConfig);
|
|
20429
|
-
// If theme has nested structure (extend/tokens/themes), we can't directly use it
|
|
20430
|
-
// Return empty tokens - the theme system will use defaults
|
|
20431
|
-
// TODO: Add proper conversion from ThemeTokens to DesignTokens if needed
|
|
20432
|
-
}
|
|
20433
|
-
|
|
20434
|
-
/**
|
|
20435
|
-
* Load theme from config file (asynchronous)
|
|
20436
|
-
* @param configPath - Path to config file (default: atomix.config.ts)
|
|
20437
|
-
* @returns Promise resolving to DesignTokens from theme configuration
|
|
20438
|
-
*/ async function loadThemeFromConfig(options) {
|
|
20439
|
-
// Check if we're in a browser environment
|
|
20440
|
-
if ("undefined" != typeof window) throw new Error("loadThemeFromConfig: Not available in browser environment. Config loading requires Node.js/SSR environment.");
|
|
20441
|
-
// Use static import with runtime check
|
|
20442
|
-
// The function will handle browser environment checks internally
|
|
20443
|
-
let config;
|
|
20444
|
-
try {
|
|
20445
|
-
// loadAtomixConfig is synchronous, not async
|
|
20446
|
-
config = loader.loadAtomixConfig({
|
|
20447
|
-
configPath: options?.configPath || "atomix.config.ts",
|
|
20448
|
-
required: !1 !== options?.required
|
|
20449
|
-
});
|
|
20450
|
-
} catch (error) {
|
|
20451
|
-
if (!1 !== options?.required) throw new Error("Config loader module not available");
|
|
20452
|
-
// Return empty tokens if config is not required
|
|
20453
|
-
return createTokens({});
|
|
20454
|
-
}
|
|
20455
|
-
if (!config?.theme) return createTokens({});
|
|
20456
|
-
// Extract tokens from config.theme structure
|
|
20457
|
-
// config.theme can have: { extend?: ThemeTokens, tokens?: ThemeTokens, themes?: ... }
|
|
20458
|
-
// We need to extract the actual DesignTokens (flat structure)
|
|
20459
|
-
const themeConfig = config.theme;
|
|
20460
|
-
// Check if theme is directly a flat object (DesignTokens format)
|
|
20461
|
-
// This handles the case where config.theme might be passed as DesignTokens directly
|
|
20462
|
-
return createTokens(!themeConfig || "object" != typeof themeConfig || "extend" in themeConfig || "tokens" in themeConfig || "themes" in themeConfig ? {} : themeConfig);
|
|
20463
|
-
// If theme has nested structure (extend/tokens/themes), we can't directly use it
|
|
20464
|
-
// Return empty tokens - the theme system will use defaults
|
|
20465
|
-
// TODO: Add proper conversion from ThemeTokens to DesignTokens if needed
|
|
20466
|
-
}
|
|
20467
|
-
|
|
20468
20357
|
/**
|
|
20469
20358
|
* Theme Context
|
|
20470
20359
|
*
|
|
@@ -20506,21 +20395,9 @@ const ThemeProvider = ({children: children, defaultTheme: defaultTheme, themes:
|
|
|
20506
20395
|
if (stored) return stored;
|
|
20507
20396
|
}
|
|
20508
20397
|
// If defaultTheme is provided, use it
|
|
20509
|
-
|
|
20510
|
-
// Try to load from atomix.config.ts as fallback, but only in Node.js/SSR environments
|
|
20511
|
-
if ("undefined" == typeof window) try {
|
|
20512
|
-
// Dynamically import the config loader to avoid bundling issues in browser
|
|
20513
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
20514
|
-
const {loadThemeFromConfigSync: loadThemeFromConfigSync} = require("../config/configLoader"), configTokens = loadThemeFromConfigSync();
|
|
20515
|
-
if (configTokens && Object.keys(configTokens).length > 0)
|
|
20516
|
-
// For simplicity, we'll treat config tokens as a special theme name
|
|
20517
|
-
return "config-theme";
|
|
20518
|
-
} catch (error) {
|
|
20519
|
-
// Failed to load theme from config, using default
|
|
20520
|
-
}
|
|
20398
|
+
return null != defaultTheme ? defaultTheme : "default";
|
|
20521
20399
|
// Default fallback
|
|
20522
|
-
|
|
20523
|
-
}), [ defaultTheme, enablePersistence, storageKey ]), [currentTheme, setCurrentTheme] = React.useState((() => "string" == typeof initialDefaultTheme ? initialDefaultTheme : "tokens-theme")), [activeTokens, setActiveTokens] = React.useState((() =>
|
|
20400
|
+
}), [ defaultTheme, enablePersistence, storageKey ]), [currentTheme, setCurrentTheme] = React.useState((() => "string" == typeof initialDefaultTheme ? initialDefaultTheme : "tokens-theme")), [activeTokens, setActiveTokens] = React.useState((() =>
|
|
20524
20401
|
// If defaultTheme is DesignTokens, store them
|
|
20525
20402
|
defaultTheme && "string" != typeof defaultTheme ? createTokens(defaultTheme) : null)), [isLoading, setIsLoading] = React.useState(!1), [error, setError] = React.useState(null), loadedThemesRef = React.useRef(new Set), themePromisesRef = React.useRef({}), abortControllerRef = React.useRef(null);
|
|
20526
20403
|
// Handle initial DesignTokens defaultTheme
|
|
@@ -23515,6 +23392,7 @@ class RTLManager {
|
|
|
23515
23392
|
// Core Theme Functions
|
|
23516
23393
|
// ============================================================================
|
|
23517
23394
|
// Create theme CSS from DesignTokens
|
|
23395
|
+
// File saving utilities removed to prevent bundling Node.js modules in browser
|
|
23518
23396
|
/**
|
|
23519
23397
|
* Inject theme CSS into DOM
|
|
23520
23398
|
*/ function injectTheme(css, id = "atomix-theme") {
|
|
@@ -23527,30 +23405,6 @@ class RTLManager {
|
|
|
23527
23405
|
removeCSS(id);
|
|
23528
23406
|
}
|
|
23529
23407
|
|
|
23530
|
-
/**
|
|
23531
|
-
* Save theme to CSS file
|
|
23532
|
-
*/ async function saveTheme(css, filePath) {
|
|
23533
|
-
await async function(css, filePath) {
|
|
23534
|
-
// Check if in browser environment
|
|
23535
|
-
if ("undefined" != typeof window) throw new Error("saveCSSFile can only be used in Node.js environment. Use injectCSS() for browser environments.");
|
|
23536
|
-
// Dynamic import to avoid bundling Node.js modules in browser builds
|
|
23537
|
-
const fs = await import("fs/promises"), dir = (await import("path")).dirname(filePath);
|
|
23538
|
-
await fs.mkdir(dir, {
|
|
23539
|
-
recursive: !0
|
|
23540
|
-
}),
|
|
23541
|
-
// Write file
|
|
23542
|
-
await fs.writeFile(filePath, css, "utf8");
|
|
23543
|
-
}
|
|
23544
|
-
/**
|
|
23545
|
-
* Theme System Constants
|
|
23546
|
-
*
|
|
23547
|
-
* Centralized constants for the theme system to avoid magic numbers and strings.
|
|
23548
|
-
*/
|
|
23549
|
-
/**
|
|
23550
|
-
* Default storage key for theme persistence
|
|
23551
|
-
*/ (css, filePath);
|
|
23552
|
-
}
|
|
23553
|
-
|
|
23554
23408
|
/**
|
|
23555
23409
|
* CSS Variables Constants
|
|
23556
23410
|
*
|
|
@@ -23927,8 +23781,6 @@ const composables = composablesImport, utils = utilsImport, types = typesImport,
|
|
|
23927
23781
|
isCSSInjected: isCSSInjected,
|
|
23928
23782
|
isDesignTokens: isDesignTokens,
|
|
23929
23783
|
isValidCSSVariableName: isValidCSSVariableName,
|
|
23930
|
-
loadThemeFromConfig: loadThemeFromConfig,
|
|
23931
|
-
loadThemeFromConfigSync: loadThemeFromConfigSync,
|
|
23932
23784
|
mapSCSSTokensToCSSVars: mapSCSSTokensToCSSVars,
|
|
23933
23785
|
mergeCSSVars: mergeCSSVars,
|
|
23934
23786
|
mergeTheme: mergeTheme,
|
|
@@ -23937,7 +23789,6 @@ const composables = composablesImport, utils = utilsImport, types = typesImport,
|
|
|
23937
23789
|
removeCSS: removeCSS,
|
|
23938
23790
|
removeCSSVariables: removeCSSVariables,
|
|
23939
23791
|
removeTheme: removeTheme,
|
|
23940
|
-
saveTheme: saveTheme,
|
|
23941
23792
|
themePropertyToCSSVar: themePropertyToCSSVar,
|
|
23942
23793
|
unregisterTheme: unregisterTheme,
|
|
23943
23794
|
useComponentTheme: useComponentTheme,
|
|
@@ -24024,27 +23875,56 @@ function(cssVars, baseStyle) {
|
|
|
24024
23875
|
};
|
|
24025
23876
|
}
|
|
24026
23877
|
/**
|
|
24027
|
-
* Atomix
|
|
23878
|
+
* Atomix Configuration System
|
|
23879
|
+
*
|
|
23880
|
+
* Tailwind-like configuration for customizing the Atomix Design System.
|
|
23881
|
+
*
|
|
23882
|
+
* External developers can create `atomix.config.ts` in their project root
|
|
23883
|
+
* to customize design tokens, similar to Tailwind's tailwind.config.js
|
|
23884
|
+
*
|
|
23885
|
+
* @example
|
|
23886
|
+
* ```typescript
|
|
23887
|
+
* // atomix.config.ts (in your project)
|
|
23888
|
+
* import { defineConfig } from '@shohojdhara/atomix/config';
|
|
23889
|
+
*
|
|
23890
|
+
* export default defineConfig({
|
|
23891
|
+
* theme: {
|
|
23892
|
+
* extend: {
|
|
23893
|
+
* colors: {
|
|
23894
|
+
* primary: { main: '#7AFFD7' },
|
|
23895
|
+
* },
|
|
23896
|
+
* },
|
|
23897
|
+
* },
|
|
23898
|
+
* });
|
|
23899
|
+
* ```
|
|
23900
|
+
*/
|
|
23901
|
+
/**
|
|
23902
|
+
* Helper function to define Atomix configuration with type safety
|
|
24028
23903
|
*
|
|
24029
|
-
*
|
|
24030
|
-
*
|
|
23904
|
+
* @param config - Atomix configuration object
|
|
23905
|
+
* @returns The configuration object
|
|
24031
23906
|
*/
|
|
24032
23907
|
/**
|
|
24033
|
-
*
|
|
23908
|
+
* Helper function to define Atomix configuration with type safety
|
|
24034
23909
|
*
|
|
24035
|
-
*
|
|
24036
|
-
* Falls back to default config if file doesn't exist.
|
|
23910
|
+
* Similar to Tailwind's defineConfig, provides autocomplete and type checking.
|
|
24037
23911
|
*
|
|
24038
|
-
* @param
|
|
24039
|
-
* @returns
|
|
23912
|
+
* @param config - Atomix configuration object
|
|
23913
|
+
* @returns The configuration object
|
|
24040
23914
|
*
|
|
24041
23915
|
* @example
|
|
24042
23916
|
* ```typescript
|
|
24043
|
-
* import {
|
|
24044
|
-
* import { createTheme } from '@shohojdhara/atomix/theme';
|
|
23917
|
+
* import { defineConfig } from '@shohojdhara/atomix/config';
|
|
24045
23918
|
*
|
|
24046
|
-
*
|
|
24047
|
-
*
|
|
23919
|
+
* export default defineConfig({
|
|
23920
|
+
* theme: {
|
|
23921
|
+
* extend: {
|
|
23922
|
+
* colors: {
|
|
23923
|
+
* primary: { main: '#7AFFD7' },
|
|
23924
|
+
* },
|
|
23925
|
+
* },
|
|
23926
|
+
* },
|
|
23927
|
+
* });
|
|
24048
23928
|
* ```
|
|
24049
23929
|
*/ , exports.applyComponentTheme = applyComponentTheme, exports.applyPartStyles = applyPartStyles,
|
|
24050
23930
|
exports.applyTheme = applyTheme, exports.camelToKebab = camelToKebab, exports.clearThemes = clearThemes,
|
|
@@ -24112,61 +23992,7 @@ function(defaultElement = "div") {
|
|
|
24112
23992
|
* Hook to manage slot rendering
|
|
24113
23993
|
*/ , exports.createTheme = createTheme, exports.createThemeRegistry = createThemeRegistry,
|
|
24114
23994
|
exports.createTokens = createTokens, exports.cssVarsToStyle = cssVarsToStyle, exports.deepMerge = deepMerge,
|
|
24115
|
-
exports.default = atomix, exports.defaultTokens = defaultTokens, exports.defineConfig =
|
|
24116
|
-
/**
|
|
24117
|
-
* Atomix Configuration System
|
|
24118
|
-
*
|
|
24119
|
-
* Tailwind-like configuration for customizing the Atomix Design System.
|
|
24120
|
-
*
|
|
24121
|
-
* External developers can create `atomix.config.ts` in their project root
|
|
24122
|
-
* to customize design tokens, similar to Tailwind's tailwind.config.js
|
|
24123
|
-
*
|
|
24124
|
-
* @example
|
|
24125
|
-
* ```typescript
|
|
24126
|
-
* // atomix.config.ts (in your project)
|
|
24127
|
-
* import { defineConfig } from '@shohojdhara/atomix/config';
|
|
24128
|
-
*
|
|
24129
|
-
* export default defineConfig({
|
|
24130
|
-
* theme: {
|
|
24131
|
-
* extend: {
|
|
24132
|
-
* colors: {
|
|
24133
|
-
* primary: { main: '#7AFFD7' },
|
|
24134
|
-
* },
|
|
24135
|
-
* },
|
|
24136
|
-
* },
|
|
24137
|
-
* });
|
|
24138
|
-
* ```
|
|
24139
|
-
*/
|
|
24140
|
-
/**
|
|
24141
|
-
* Helper function to define Atomix configuration with type safety
|
|
24142
|
-
*
|
|
24143
|
-
* @param config - Atomix configuration object
|
|
24144
|
-
* @returns The configuration object
|
|
24145
|
-
*/
|
|
24146
|
-
/**
|
|
24147
|
-
* Helper function to define Atomix configuration with type safety
|
|
24148
|
-
*
|
|
24149
|
-
* Similar to Tailwind's defineConfig, provides autocomplete and type checking.
|
|
24150
|
-
*
|
|
24151
|
-
* @param config - Atomix configuration object
|
|
24152
|
-
* @returns The configuration object
|
|
24153
|
-
*
|
|
24154
|
-
* @example
|
|
24155
|
-
* ```typescript
|
|
24156
|
-
* import { defineConfig } from '@shohojdhara/atomix/config';
|
|
24157
|
-
*
|
|
24158
|
-
* export default defineConfig({
|
|
24159
|
-
* theme: {
|
|
24160
|
-
* extend: {
|
|
24161
|
-
* colors: {
|
|
24162
|
-
* primary: { main: '#7AFFD7' },
|
|
24163
|
-
* },
|
|
24164
|
-
* },
|
|
24165
|
-
* },
|
|
24166
|
-
* });
|
|
24167
|
-
* ```
|
|
24168
|
-
*/
|
|
24169
|
-
function(config) {
|
|
23995
|
+
exports.default = atomix, exports.defaultTokens = defaultTokens, exports.defineConfig = function(config) {
|
|
24170
23996
|
return config;
|
|
24171
23997
|
}, exports.designTokensToCSSVars = designTokensToCSSVars, exports.exportTheme =
|
|
24172
23998
|
/**
|
|
@@ -24228,43 +24054,6 @@ exports.isDesignTokens = isDesignTokens, exports.isSlot = function(value) {
|
|
|
24228
24054
|
* Merge multiple slot configurations
|
|
24229
24055
|
* Later slots override earlier ones
|
|
24230
24056
|
*/ , exports.isValidCSSVariableName = isValidCSSVariableName, exports.isYouTubeUrl = isYouTubeUrl,
|
|
24231
|
-
exports.loadAtomixConfig = function(options = {}) {
|
|
24232
|
-
const {configPath: configPath = "atomix.config.ts", required: required = !1} = options, defaultConfig = {
|
|
24233
|
-
prefix: "atomix",
|
|
24234
|
-
theme: {
|
|
24235
|
-
extend: {}
|
|
24236
|
-
}
|
|
24237
|
-
};
|
|
24238
|
-
// Default config
|
|
24239
|
-
// In browser environments, config loading is not supported
|
|
24240
|
-
if ("undefined" != typeof window) {
|
|
24241
|
-
if (required) throw new Error("loadAtomixConfig: Not available in browser environment. Config loading requires Node.js/SSR environment.");
|
|
24242
|
-
return defaultConfig;
|
|
24243
|
-
}
|
|
24244
|
-
// Try to load config file
|
|
24245
|
-
try {
|
|
24246
|
-
// Use dynamic import for ESM compatibility
|
|
24247
|
-
const configModule = require(configPath), config = configModule.default || configModule;
|
|
24248
|
-
// Validate it's an AtomixConfig
|
|
24249
|
-
if (config && "object" == typeof config) return config;
|
|
24250
|
-
throw new Error("Invalid config format");
|
|
24251
|
-
} catch (error) {
|
|
24252
|
-
if (required) throw new Error(`Failed to load config from ${configPath}: ${error.message}`);
|
|
24253
|
-
// Return default config if not required
|
|
24254
|
-
return defaultConfig;
|
|
24255
|
-
}
|
|
24256
|
-
}
|
|
24257
|
-
/**
|
|
24258
|
-
* Resolve config path
|
|
24259
|
-
*
|
|
24260
|
-
* Finds atomix.config.ts in the project, checking common locations.
|
|
24261
|
-
* Returns null in browser environments where file system access is not available.
|
|
24262
|
-
*
|
|
24263
|
-
* This function is designed to work in Node.js environments only.
|
|
24264
|
-
* In browser builds, it will always return null without attempting to access Node.js modules.
|
|
24265
|
-
*
|
|
24266
|
-
* @internal This function uses Node.js modules and should not be called in browser environments.
|
|
24267
|
-
*/ , exports.loadThemeFromConfig = loadThemeFromConfig, exports.loadThemeFromConfigSync = loadThemeFromConfigSync,
|
|
24268
24057
|
exports.mapSCSSTokensToCSSVars = mapSCSSTokensToCSSVars, exports.mergeCSSVars = mergeCSSVars,
|
|
24269
24058
|
exports.mergeClassNames = mergeClassNames, exports.mergeComponentProps = mergeComponentProps,
|
|
24270
24059
|
exports.mergePartStyles = mergePartStyles, exports.mergeSlots = function(...slots) {
|
|
@@ -24291,42 +24080,8 @@ function(name, primaryColor, secondaryColor) {
|
|
|
24291
24080
|
}
|
|
24292
24081
|
});
|
|
24293
24082
|
}, exports.registerTheme = registerTheme, exports.removeCSS = removeCSS, exports.removeCSSVariables = removeCSSVariables,
|
|
24294
|
-
exports.removeTheme = removeTheme, exports.renderSlot = renderSlot, exports.
|
|
24295
|
-
|
|
24296
|
-
// This check happens before any require() calls, preventing bundlers from analyzing them
|
|
24297
|
-
if ("undefined" != typeof window || "undefined" == typeof process || !process.cwd) return null;
|
|
24298
|
-
// Only attempt to load Node.js modules in Node.js runtime
|
|
24299
|
-
// Use a lazy-loading pattern that prevents static analysis by bundlers
|
|
24300
|
-
try {
|
|
24301
|
-
// Create a function that only executes in Node.js runtime
|
|
24302
|
-
// Use string-based module names to prevent static analysis by bundlers
|
|
24303
|
-
const modules = (() => {
|
|
24304
|
-
// These requires are only executed at runtime in Node.js environments
|
|
24305
|
-
// They are marked as external in Rollup config and should not be bundled
|
|
24306
|
-
// Using string concatenation and computed property access to prevent static analysis
|
|
24307
|
-
if ("undefined" == typeof require) return null;
|
|
24308
|
-
// Use a try-catch wrapper to safely access require
|
|
24309
|
-
try {
|
|
24310
|
-
// Build module names dynamically to prevent static analysis
|
|
24311
|
-
const moduleNames = [ "fs", "path" ];
|
|
24312
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
24313
|
-
return {
|
|
24314
|
-
fs: require(moduleNames[0]),
|
|
24315
|
-
path: require(moduleNames[1])
|
|
24316
|
-
};
|
|
24317
|
-
} catch {
|
|
24318
|
-
return null;
|
|
24319
|
-
}
|
|
24320
|
-
})();
|
|
24321
|
-
if (!modules) return null;
|
|
24322
|
-
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") ];
|
|
24323
|
-
for (const configPath of possiblePaths) if (fs.existsSync(configPath)) return configPath;
|
|
24324
|
-
} catch (error) {
|
|
24325
|
-
// Silently fail in browser environments or when modules are unavailable
|
|
24326
|
-
return null;
|
|
24327
|
-
}
|
|
24328
|
-
return null;
|
|
24329
|
-
}, exports.saveTheme = saveTheme, exports.sliderConstants = sliderConstants, exports.supportsDarkMode = function(theme) {
|
|
24083
|
+
exports.removeTheme = removeTheme, exports.renderSlot = renderSlot, exports.sliderConstants = sliderConstants,
|
|
24084
|
+
exports.supportsDarkMode = function(theme) {
|
|
24330
24085
|
var _context;
|
|
24331
24086
|
return "dark" === theme.palette?.mode || !0 === theme.supportsDarkMode || Boolean((null == (_context = theme.a11y?.modes) ? void 0 : Function.call.bind(_includesInstanceProperty(_context), _context))?.("dark"));
|
|
24332
24087
|
}, exports.theme = theme, exports.themePropertyToCSSVar = themePropertyToCSSVar,
|