@shohojdhara/atomix 0.3.6 → 0.3.8
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/atomix.css +77 -0
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +77 -0
- package/dist/atomix.min.css.map +1 -1
- package/dist/charts.js +50 -142
- package/dist/charts.js.map +1 -1
- package/dist/core.d.ts +2 -2
- 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 +1255 -1226
- package/dist/index.esm.js +2806 -2958
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3113 -3269
- 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 +313 -667
- package/dist/theme.js +1818 -2589
- 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/components/DataTable/DataTable.stories.tsx +238 -0
- package/src/components/DataTable/DataTable.test.tsx +450 -0
- package/src/components/DataTable/DataTable.tsx +384 -61
- package/src/components/DatePicker/DatePicker.tsx +29 -38
- package/src/components/Upload/Upload.tsx +539 -40
- package/src/lib/composables/useAtomixGlass.ts +7 -7
- package/src/lib/composables/useDataTable.ts +355 -15
- package/src/lib/composables/useDatePicker.ts +19 -0
- package/src/lib/config/loader.ts +2 -3
- package/src/lib/constants/components.ts +17 -0
- package/src/lib/hooks/usePerformanceMonitor.ts +1 -1
- package/src/lib/theme/adapters/cssVariableMapper.ts +29 -14
- package/src/lib/theme/adapters/index.ts +1 -4
- package/src/lib/theme/config/configLoader.ts +82 -223
- 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 +30 -88
- package/src/lib/theme/core/createTheme.ts +88 -51
- package/src/lib/theme/core/createThemeObject.ts +2 -2
- package/src/lib/theme/core/index.ts +15 -2
- package/src/lib/theme/errors/errors.ts +1 -1
- package/src/lib/theme/generators/generateCSSNested.ts +131 -0
- package/src/lib/theme/generators/generateCSSVariables.ts +24 -16
- package/src/lib/theme/generators/index.ts +6 -0
- package/src/lib/theme/index.ts +45 -27
- package/src/lib/theme/runtime/ThemeApplicator.ts +6 -109
- package/src/lib/theme/runtime/ThemeErrorBoundary.tsx +1 -1
- package/src/lib/theme/runtime/ThemeProvider.tsx +393 -544
- package/src/lib/theme/runtime/index.ts +1 -0
- package/src/lib/theme/runtime/useTheme.ts +1 -1
- package/src/lib/theme/runtime/useThemeTokens.ts +122 -0
- package/src/lib/theme/test/testTheme.ts +2 -1
- package/src/lib/theme/types.ts +14 -14
- package/src/lib/theme/utils/componentTheming.ts +140 -0
- package/src/lib/theme/utils/domUtils.ts +57 -15
- package/src/lib/theme/utils/injectCSS.ts +0 -1
- package/src/lib/theme/utils/naming.ts +100 -0
- package/src/lib/theme/utils/themeHelpers.ts +1 -39
- package/src/lib/theme/utils/themeUtils.ts +1 -170
- package/src/lib/types/components.ts +145 -0
- package/src/lib/utils/componentUtils.ts +1 -1
- package/src/lib/utils/dataTableExport.ts +143 -0
- package/src/lib/utils/memoryMonitor.ts +3 -3
- package/src/lib/utils/themeNaming.ts +135 -0
- package/src/styles/06-components/_components.data-table.scss +95 -0
package/dist/theme.d.ts
CHANGED
|
@@ -294,6 +294,203 @@ declare const defaultTokens: DesignTokens;
|
|
|
294
294
|
*/
|
|
295
295
|
declare function createTokens(overrides?: Partial<DesignTokens>): DesignTokens;
|
|
296
296
|
|
|
297
|
+
/**
|
|
298
|
+
* CSS Variable Generator
|
|
299
|
+
*
|
|
300
|
+
* Generates CSS custom properties from design tokens.
|
|
301
|
+
*/
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Options for CSS variable generation
|
|
305
|
+
*/
|
|
306
|
+
interface GenerateCSSVariablesOptions {
|
|
307
|
+
/** CSS selector for the variables (default: ':root') */
|
|
308
|
+
selector?: string;
|
|
309
|
+
/** Prefix for CSS variables (default: 'atomix') */
|
|
310
|
+
prefix?: string;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Generate CSS variables from tokens
|
|
314
|
+
*
|
|
315
|
+
* Converts flat token object to CSS custom properties.
|
|
316
|
+
*
|
|
317
|
+
* @param tokens - Design tokens object
|
|
318
|
+
* @param options - Generation options
|
|
319
|
+
* @returns CSS string with custom properties
|
|
320
|
+
*
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* const tokens = {
|
|
324
|
+
* 'primary': '#7c3aed',
|
|
325
|
+
* 'spacing-4': '1rem',
|
|
326
|
+
* };
|
|
327
|
+
*
|
|
328
|
+
* const css = generateCSSVariables(tokens);
|
|
329
|
+
* // Returns: ":root {\n --atomix-primary: #7c3aed;\n --atomix-spacing-4: 1rem;\n}"
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
declare function generateCSSVariables(tokens: DesignTokens, options?: GenerateCSSVariablesOptions): string;
|
|
333
|
+
/**
|
|
334
|
+
* Generate CSS variables with custom selector
|
|
335
|
+
*
|
|
336
|
+
* Useful for theme-specific selectors like `[data-theme="dark"]`
|
|
337
|
+
*
|
|
338
|
+
* @param tokens - Design tokens object
|
|
339
|
+
* @param selector - CSS selector (e.g., '[data-theme="dark"]')
|
|
340
|
+
* @param prefix - CSS variable prefix
|
|
341
|
+
* @returns CSS string
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```typescript
|
|
345
|
+
* const css = generateCSSVariablesForSelector(
|
|
346
|
+
* tokens,
|
|
347
|
+
* '[data-theme="dark"]',
|
|
348
|
+
* 'atomix'
|
|
349
|
+
* );
|
|
350
|
+
* ```
|
|
351
|
+
*/
|
|
352
|
+
declare function generateCSSVariablesForSelector(tokens: DesignTokens, selector: string, prefix?: string): string;
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Core Theme Functions
|
|
356
|
+
*
|
|
357
|
+
* Simplified theme system using DesignTokens only.
|
|
358
|
+
* Config-first approach: loads from atomix.config.ts when no input is provided.
|
|
359
|
+
*/
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Create theme CSS from DesignTokens
|
|
363
|
+
*
|
|
364
|
+
* **Config-First Approach**: If no input is provided, loads from `atomix.config.ts`.
|
|
365
|
+
*
|
|
366
|
+
* @param input - DesignTokens (partial) or undefined (loads from config)
|
|
367
|
+
* @param options - CSS generation options (prefix is automatically read from config if not provided)
|
|
368
|
+
* @returns CSS string with custom properties
|
|
369
|
+
* @throws Error if config loading fails when no input is provided
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```typescript
|
|
373
|
+
* // Loads from atomix.config.ts
|
|
374
|
+
* const css = createTheme();
|
|
375
|
+
*
|
|
376
|
+
* // Using DesignTokens
|
|
377
|
+
* const css = createTheme({
|
|
378
|
+
* 'primary': '#7c3aed',
|
|
379
|
+
* 'spacing-4': '1rem',
|
|
380
|
+
* });
|
|
381
|
+
*
|
|
382
|
+
* // With custom options
|
|
383
|
+
* const css = createTheme(undefined, { prefix: 'myapp', selector: ':root' });
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
386
|
+
declare function createTheme(input?: Partial<DesignTokens>, options?: GenerateCSSVariablesOptions): string;
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Theme Composition Utilities
|
|
390
|
+
*
|
|
391
|
+
* Simplified utilities for composing and merging DesignTokens.
|
|
392
|
+
*/
|
|
393
|
+
/**
|
|
394
|
+
* Deep merge multiple objects
|
|
395
|
+
* Later objects override earlier ones
|
|
396
|
+
*/
|
|
397
|
+
declare function deepMerge<T extends Record<string, unknown>>(...objects: Partial<T>[]): T;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Merge multiple DesignTokens objects into a single DesignTokens object
|
|
401
|
+
*
|
|
402
|
+
* @param tokens - DesignTokens objects to merge
|
|
403
|
+
* @returns Merged DesignTokens object
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```typescript
|
|
407
|
+
* const baseTokens = { 'primary': '#000', 'spacing-4': '1rem' };
|
|
408
|
+
* const customTokens = { 'secondary': '#fff', 'spacing-4': '1.5rem' };
|
|
409
|
+
* const merged = mergeTheme(baseTokens, customTokens);
|
|
410
|
+
* // Returns: { 'primary': '#000', 'secondary': '#fff', 'spacing-4': '1.5rem' }
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
declare function mergeTheme(...tokens: Partial<DesignTokens>[]): Partial<DesignTokens>;
|
|
414
|
+
/**
|
|
415
|
+
* Extend DesignTokens with additional tokens
|
|
416
|
+
*
|
|
417
|
+
* @param baseTokens - Base DesignTokens to extend
|
|
418
|
+
* @param extension - Additional DesignTokens to merge
|
|
419
|
+
* @returns Extended DesignTokens object
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```typescript
|
|
423
|
+
* const base = { 'primary': '#000' };
|
|
424
|
+
* const extended = extendTheme(base, { 'secondary': '#fff' });
|
|
425
|
+
* // Returns: { 'primary': '#000', 'secondary': '#fff' }
|
|
426
|
+
* ```
|
|
427
|
+
*/
|
|
428
|
+
declare function extendTheme(baseTokens: Partial<DesignTokens>, extension: Partial<DesignTokens>): Partial<DesignTokens>;
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Theme Metadata interface
|
|
432
|
+
*/
|
|
433
|
+
interface ThemeMetadata$1 {
|
|
434
|
+
name: string;
|
|
435
|
+
class: string;
|
|
436
|
+
description?: string;
|
|
437
|
+
version?: string;
|
|
438
|
+
[key: string]: any;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Theme Registry type - a record of theme IDs to metadata
|
|
442
|
+
*/
|
|
443
|
+
type ThemeRegistry = Record<string, ThemeMetadata$1>;
|
|
444
|
+
/**
|
|
445
|
+
* Create a new theme registry
|
|
446
|
+
*/
|
|
447
|
+
declare function createThemeRegistry(): ThemeRegistry;
|
|
448
|
+
/**
|
|
449
|
+
* Register a theme
|
|
450
|
+
* @param registry - Theme registry object
|
|
451
|
+
* @param id - Theme identifier
|
|
452
|
+
* @param metadata - Theme metadata
|
|
453
|
+
*/
|
|
454
|
+
declare function registerTheme(registry: ThemeRegistry, id: string, metadata: ThemeMetadata$1): void;
|
|
455
|
+
/**
|
|
456
|
+
* Unregister a theme
|
|
457
|
+
* @param registry - Theme registry object
|
|
458
|
+
* @param id - Theme identifier
|
|
459
|
+
*/
|
|
460
|
+
declare function unregisterTheme(registry: ThemeRegistry, id: string): boolean;
|
|
461
|
+
/**
|
|
462
|
+
* Check if a theme is registered
|
|
463
|
+
* @param registry - Theme registry object
|
|
464
|
+
* @param id - Theme identifier
|
|
465
|
+
*/
|
|
466
|
+
declare function hasTheme(registry: ThemeRegistry, id: string): boolean;
|
|
467
|
+
/**
|
|
468
|
+
* Get theme metadata
|
|
469
|
+
* @param registry - Theme registry object
|
|
470
|
+
* @param id - Theme identifier
|
|
471
|
+
*/
|
|
472
|
+
declare function getTheme(registry: ThemeRegistry, id: string): ThemeMetadata$1 | undefined;
|
|
473
|
+
/**
|
|
474
|
+
* Get all registered theme metadata
|
|
475
|
+
* @param registry - Theme registry object
|
|
476
|
+
*/
|
|
477
|
+
declare function getAllThemes(registry: ThemeRegistry): ThemeMetadata$1[];
|
|
478
|
+
/**
|
|
479
|
+
* Get all registered theme IDs
|
|
480
|
+
* @param registry - Theme registry object
|
|
481
|
+
*/
|
|
482
|
+
declare function getThemeIds(registry: ThemeRegistry): string[];
|
|
483
|
+
/**
|
|
484
|
+
* Clear all registered themes
|
|
485
|
+
* @param registry - Theme registry object
|
|
486
|
+
*/
|
|
487
|
+
declare function clearThemes(registry: ThemeRegistry): void;
|
|
488
|
+
/**
|
|
489
|
+
* Get the number of registered themes
|
|
490
|
+
* @param registry - Theme registry object
|
|
491
|
+
*/
|
|
492
|
+
declare function getThemeCount(registry: ThemeRegistry): number;
|
|
493
|
+
|
|
297
494
|
/**
|
|
298
495
|
* Theme Manager Type Definitions
|
|
299
496
|
*
|
|
@@ -341,8 +538,8 @@ interface ThemeChangeEvent {
|
|
|
341
538
|
previousTheme: string | null;
|
|
342
539
|
/** New theme name */
|
|
343
540
|
currentTheme: string;
|
|
344
|
-
/**
|
|
345
|
-
|
|
541
|
+
/** DesignTokens if using tokens-based theme */
|
|
542
|
+
tokens?: DesignTokens | null;
|
|
346
543
|
/** Timestamp of the change */
|
|
347
544
|
timestamp: number;
|
|
348
545
|
/** Whether the change was from user action or system */
|
|
@@ -380,10 +577,10 @@ interface ThemeValidationResult {
|
|
|
380
577
|
interface UseThemeReturn {
|
|
381
578
|
/** Current theme name */
|
|
382
579
|
theme: string;
|
|
383
|
-
/** Current active
|
|
384
|
-
|
|
385
|
-
/** Function to change theme (supports string
|
|
386
|
-
setTheme: (theme: string |
|
|
580
|
+
/** Current active DesignTokens (if using tokens-based theme) */
|
|
581
|
+
activeTokens: DesignTokens | null;
|
|
582
|
+
/** Function to change theme (supports string or DesignTokens) */
|
|
583
|
+
setTheme: (theme: string | DesignTokens | Partial<DesignTokens>, options?: ThemeLoadOptions) => Promise<void>;
|
|
387
584
|
/** Available themes */
|
|
388
585
|
availableThemes: ThemeMetadata[];
|
|
389
586
|
/** Whether a theme is currently loading */
|
|
@@ -451,8 +648,8 @@ interface ThemeComponentOverrides {
|
|
|
451
648
|
interface ThemeProviderProps {
|
|
452
649
|
/** Child components */
|
|
453
650
|
children: React.ReactNode;
|
|
454
|
-
/** Default theme */
|
|
455
|
-
defaultTheme?: string |
|
|
651
|
+
/** Default theme (string name or DesignTokens) */
|
|
652
|
+
defaultTheme?: string | DesignTokens | Partial<DesignTokens>;
|
|
456
653
|
/** Available themes */
|
|
457
654
|
themes?: Record<string, ThemeMetadata>;
|
|
458
655
|
/** Base path for theme CSS */
|
|
@@ -472,7 +669,7 @@ interface ThemeProviderProps {
|
|
|
472
669
|
/** Use minified CSS */
|
|
473
670
|
useMinified?: boolean;
|
|
474
671
|
/** Callback when theme changes */
|
|
475
|
-
onThemeChange?: (theme: string |
|
|
672
|
+
onThemeChange?: (theme: string | DesignTokens) => void;
|
|
476
673
|
/** Callback on error */
|
|
477
674
|
onError?: (error: Error, themeName: string) => void;
|
|
478
675
|
}
|
|
@@ -482,10 +679,10 @@ interface ThemeProviderProps {
|
|
|
482
679
|
interface ThemeContextValue {
|
|
483
680
|
/** Current theme name */
|
|
484
681
|
theme: string;
|
|
485
|
-
/** Current active
|
|
486
|
-
|
|
487
|
-
/** Set theme function (supports string
|
|
488
|
-
setTheme: (theme: string |
|
|
682
|
+
/** Current active DesignTokens (if using tokens-based theme) */
|
|
683
|
+
activeTokens: DesignTokens | null;
|
|
684
|
+
/** Set theme function (supports string or DesignTokens) */
|
|
685
|
+
setTheme: (theme: string | DesignTokens | Partial<DesignTokens>, options?: ThemeLoadOptions) => Promise<void>;
|
|
489
686
|
/** Available themes */
|
|
490
687
|
availableThemes: ThemeMetadata[];
|
|
491
688
|
/** Loading state */
|
|
@@ -510,36 +707,6 @@ interface PaletteColor {
|
|
|
510
707
|
/** Contrast text color (auto-generated if not provided) */
|
|
511
708
|
contrastText?: string;
|
|
512
709
|
}
|
|
513
|
-
/**
|
|
514
|
-
* Palette configuration options for createTheme
|
|
515
|
-
*/
|
|
516
|
-
interface PaletteOptions {
|
|
517
|
-
/** Primary color configuration */
|
|
518
|
-
primary?: Partial<PaletteColor> | string;
|
|
519
|
-
/** Secondary color configuration */
|
|
520
|
-
secondary?: Partial<PaletteColor> | string;
|
|
521
|
-
/** Error color configuration */
|
|
522
|
-
error?: Partial<PaletteColor> | string;
|
|
523
|
-
/** Warning color configuration */
|
|
524
|
-
warning?: Partial<PaletteColor> | string;
|
|
525
|
-
/** Info color configuration */
|
|
526
|
-
info?: Partial<PaletteColor> | string;
|
|
527
|
-
/** Success color configuration */
|
|
528
|
-
success?: Partial<PaletteColor> | string;
|
|
529
|
-
/** Background colors */
|
|
530
|
-
background?: {
|
|
531
|
-
default?: string;
|
|
532
|
-
subtle?: string;
|
|
533
|
-
};
|
|
534
|
-
/** Text colors */
|
|
535
|
-
text?: {
|
|
536
|
-
primary?: string;
|
|
537
|
-
secondary?: string;
|
|
538
|
-
disabled?: string;
|
|
539
|
-
};
|
|
540
|
-
/** Additional custom colors */
|
|
541
|
-
[key: string]: any;
|
|
542
|
-
}
|
|
543
710
|
/**
|
|
544
711
|
* Typography configuration options for createTheme
|
|
545
712
|
*/
|
|
@@ -609,10 +776,6 @@ interface TypographyOptions {
|
|
|
609
776
|
* Spacing function type
|
|
610
777
|
*/
|
|
611
778
|
type SpacingFunction = (...values: number[]) => string;
|
|
612
|
-
/**
|
|
613
|
-
* Spacing configuration options for createTheme
|
|
614
|
-
*/
|
|
615
|
-
type SpacingOptions = number | number[] | SpacingFunction;
|
|
616
779
|
/**
|
|
617
780
|
* Breakpoint values configuration
|
|
618
781
|
*/
|
|
@@ -624,15 +787,6 @@ interface BreakpointValues {
|
|
|
624
787
|
xl?: number;
|
|
625
788
|
[key: string]: number | undefined;
|
|
626
789
|
}
|
|
627
|
-
/**
|
|
628
|
-
* Breakpoints configuration options for createTheme
|
|
629
|
-
*/
|
|
630
|
-
interface BreakpointsOptions {
|
|
631
|
-
/** Breakpoint values in pixels */
|
|
632
|
-
values?: BreakpointValues;
|
|
633
|
-
/** Unit for breakpoints (default: 'px') */
|
|
634
|
-
unit?: string;
|
|
635
|
-
}
|
|
636
790
|
/**
|
|
637
791
|
* Shadow configuration
|
|
638
792
|
*/
|
|
@@ -710,30 +864,6 @@ interface BorderRadiusOptions {
|
|
|
710
864
|
interface ThemeCustomProperties {
|
|
711
865
|
[key: string]: any;
|
|
712
866
|
}
|
|
713
|
-
/**
|
|
714
|
-
* Theme configuration options for createTheme
|
|
715
|
-
* Extends ThemeMetadata to support both CSS and JS theme properties
|
|
716
|
-
*/
|
|
717
|
-
interface ThemeOptions extends Partial<ThemeMetadata> {
|
|
718
|
-
/** Color palette configuration */
|
|
719
|
-
palette?: PaletteOptions;
|
|
720
|
-
/** Typography configuration */
|
|
721
|
-
typography?: TypographyOptions;
|
|
722
|
-
/** Spacing configuration */
|
|
723
|
-
spacing?: SpacingOptions;
|
|
724
|
-
/** Breakpoints configuration */
|
|
725
|
-
breakpoints?: BreakpointsOptions;
|
|
726
|
-
/** Shadow configuration */
|
|
727
|
-
shadows?: ShadowOptions;
|
|
728
|
-
/** Transition configuration */
|
|
729
|
-
transitions?: TransitionOptions;
|
|
730
|
-
/** Z-index configuration */
|
|
731
|
-
zIndex?: ZIndexOptions;
|
|
732
|
-
/** Border radius configuration */
|
|
733
|
-
borderRadius?: BorderRadiusOptions;
|
|
734
|
-
/** Custom properties */
|
|
735
|
-
custom?: ThemeCustomProperties;
|
|
736
|
-
}
|
|
737
867
|
/**
|
|
738
868
|
* Complete theme object with computed values
|
|
739
869
|
* Generated by createTheme function
|
|
@@ -805,457 +935,67 @@ interface Theme extends ThemeMetadata {
|
|
|
805
935
|
}
|
|
806
936
|
|
|
807
937
|
/**
|
|
808
|
-
*
|
|
938
|
+
* Naming Utilities
|
|
809
939
|
*
|
|
810
|
-
*
|
|
940
|
+
* Provides consistent naming conventions across the theme system
|
|
811
941
|
*/
|
|
812
|
-
|
|
813
|
-
/**
|
|
814
|
-
* Options for CSS variable generation
|
|
815
|
-
*/
|
|
816
|
-
interface GenerateCSSVariablesOptions {
|
|
817
|
-
/** CSS selector for the variables (default: ':root') */
|
|
818
|
-
selector?: string;
|
|
819
|
-
/** Prefix for CSS variables (default: 'atomix') */
|
|
942
|
+
interface NamingOptions {
|
|
820
943
|
prefix?: string;
|
|
944
|
+
component?: string;
|
|
945
|
+
variant?: string;
|
|
946
|
+
state?: string;
|
|
821
947
|
}
|
|
822
948
|
/**
|
|
823
|
-
* Generate CSS
|
|
824
|
-
*
|
|
825
|
-
* Converts flat token object to CSS custom properties.
|
|
826
|
-
*
|
|
827
|
-
* @param tokens - Design tokens object
|
|
828
|
-
* @param options - Generation options
|
|
829
|
-
* @returns CSS string with custom properties
|
|
830
|
-
*
|
|
831
|
-
* @example
|
|
832
|
-
* ```typescript
|
|
833
|
-
* const tokens = {
|
|
834
|
-
* 'primary': '#7c3aed',
|
|
835
|
-
* 'spacing-4': '1rem',
|
|
836
|
-
* };
|
|
837
|
-
*
|
|
838
|
-
* const css = generateCSSVariables(tokens);
|
|
839
|
-
* // Returns: ":root {\n --atomix-primary: #7c3aed;\n --atomix-spacing-4: 1rem;\n}"
|
|
840
|
-
* ```
|
|
949
|
+
* Generate consistent CSS class names following BEM methodology
|
|
841
950
|
*/
|
|
842
|
-
declare function
|
|
951
|
+
declare function generateClassName(block: string, element?: string, modifiers?: Record<string, boolean | string>): string;
|
|
843
952
|
/**
|
|
844
|
-
* Generate CSS
|
|
845
|
-
*
|
|
846
|
-
* Useful for theme-specific selectors like `[data-theme="dark"]`
|
|
847
|
-
*
|
|
848
|
-
* @param tokens - Design tokens object
|
|
849
|
-
* @param selector - CSS selector (e.g., '[data-theme="dark"]')
|
|
850
|
-
* @param prefix - CSS variable prefix
|
|
851
|
-
* @returns CSS string
|
|
852
|
-
*
|
|
853
|
-
* @example
|
|
854
|
-
* ```typescript
|
|
855
|
-
* const css = generateCSSVariablesForSelector(
|
|
856
|
-
* tokens,
|
|
857
|
-
* '[data-theme="dark"]',
|
|
858
|
-
* 'atomix'
|
|
859
|
-
* );
|
|
860
|
-
* ```
|
|
953
|
+
* Generate consistent CSS variable names
|
|
861
954
|
*/
|
|
862
|
-
declare function
|
|
863
|
-
|
|
955
|
+
declare function generateCSSVariableName(property: string, options?: NamingOptions): string;
|
|
864
956
|
/**
|
|
865
|
-
*
|
|
866
|
-
*
|
|
867
|
-
* Unified theme system that handles both DesignTokens and Theme objects.
|
|
868
|
-
* Config-first approach: loads from atomix.config.ts when no input is provided.
|
|
869
|
-
* Config file is required for automatic loading.
|
|
957
|
+
* Normalize theme tokens to consistent naming convention
|
|
870
958
|
*/
|
|
871
|
-
|
|
959
|
+
declare function normalizeThemeTokens(tokens: Record<string, any>): Record<string, any>;
|
|
872
960
|
/**
|
|
873
|
-
*
|
|
874
|
-
*
|
|
875
|
-
* **Config-First Approach**: If no input is provided, loads from `atomix.config.ts`.
|
|
876
|
-
* Config file is required for automatic loading.
|
|
877
|
-
*
|
|
878
|
-
* @param input - DesignTokens (partial), Theme object, or undefined (loads from config)
|
|
879
|
-
* @param options - CSS generation options (prefix is automatically read from config if not provided)
|
|
880
|
-
* @returns CSS string with custom properties
|
|
881
|
-
* @throws Error if config loading fails when no input is provided
|
|
882
|
-
*
|
|
883
|
-
* @example
|
|
884
|
-
* ```typescript
|
|
885
|
-
* // Loads from atomix.config.ts (config file required)
|
|
886
|
-
* const css = createTheme();
|
|
887
|
-
*
|
|
888
|
-
* // Using DesignTokens
|
|
889
|
-
* const css = createTheme({
|
|
890
|
-
* 'primary': '#7c3aed',
|
|
891
|
-
* 'spacing-4': '1rem',
|
|
892
|
-
* });
|
|
893
|
-
*
|
|
894
|
-
* // Using Theme object
|
|
895
|
-
* const theme = createThemeObject({ palette: { primary: { main: '#7c3aed' } } });
|
|
896
|
-
* const css = createTheme(theme);
|
|
897
|
-
*
|
|
898
|
-
* // With custom options
|
|
899
|
-
* const css = createTheme(undefined, { prefix: 'myapp', selector: ':root' });
|
|
900
|
-
* ```
|
|
961
|
+
* Convert camelCase to kebab-case for CSS custom properties
|
|
901
962
|
*/
|
|
902
|
-
declare function
|
|
903
|
-
|
|
963
|
+
declare function camelToKebab(str: string): string;
|
|
904
964
|
/**
|
|
905
|
-
*
|
|
906
|
-
*
|
|
907
|
-
* Similar to Material-UI's createTheme, this function accepts theme configuration
|
|
908
|
-
* options and returns a complete theme object with computed values.
|
|
909
|
-
*
|
|
910
|
-
* NOTE: For most use cases, use the simple theme system's `createTheme` instead,
|
|
911
|
-
* which generates CSS from DesignTokens. This function is for advanced use cases
|
|
912
|
-
* that need the full Theme object structure.
|
|
913
|
-
*
|
|
914
|
-
* @example
|
|
915
|
-
* ```typescript
|
|
916
|
-
* const theme = createThemeObject({
|
|
917
|
-
* palette: {
|
|
918
|
-
* primary: { main: '#7AFFD7' },
|
|
919
|
-
* secondary: { main: '#FF5733' },
|
|
920
|
-
* },
|
|
921
|
-
* typography: {
|
|
922
|
-
* fontFamily: 'Inter, sans-serif',
|
|
923
|
-
* },
|
|
924
|
-
* });
|
|
925
|
-
* ```
|
|
965
|
+
* Convert theme property to CSS variable name
|
|
926
966
|
*/
|
|
967
|
+
declare function themePropertyToCSSVar(propertyPath: string, prefix?: string): string;
|
|
927
968
|
|
|
928
969
|
/**
|
|
929
|
-
*
|
|
970
|
+
* Component Theming Utilities
|
|
930
971
|
*
|
|
931
|
-
*
|
|
932
|
-
*
|
|
972
|
+
* Provides consistent patterns for applying theme values to components
|
|
973
|
+
* using DesignTokens and CSS variables
|
|
933
974
|
*/
|
|
934
|
-
declare function createThemeObject(...options: ThemeOptions[]): Theme;
|
|
935
975
|
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
/**
|
|
943
|
-
* Deep merge multiple objects
|
|
944
|
-
* Later objects override earlier ones
|
|
945
|
-
*/
|
|
946
|
-
declare function deepMerge<T extends Record<string, any>>(...objects: Partial<T>[]): T;
|
|
947
|
-
/**
|
|
948
|
-
* Merge multiple theme options into a single theme options object
|
|
949
|
-
*
|
|
950
|
-
* @param themes - Theme options to merge
|
|
951
|
-
* @returns Merged theme options
|
|
952
|
-
*
|
|
953
|
-
* @example
|
|
954
|
-
* ```typescript
|
|
955
|
-
* const baseTheme = { palette: { primary: { main: '#000' } } };
|
|
956
|
-
* const customTheme = { palette: { secondary: { main: '#fff' } } };
|
|
957
|
-
* const merged = mergeTheme(baseTheme, customTheme);
|
|
958
|
-
* ```
|
|
959
|
-
*/
|
|
960
|
-
declare function mergeTheme(...themes: ThemeOptions[]): ThemeOptions;
|
|
961
|
-
/**
|
|
962
|
-
* Extend an existing theme with new options
|
|
963
|
-
*
|
|
964
|
-
* @param baseTheme - Base theme to extend (can be Theme or ThemeOptions)
|
|
965
|
-
* @param extension - Theme options to extend with
|
|
966
|
-
* @returns New theme with extended options
|
|
967
|
-
*
|
|
968
|
-
* @example
|
|
969
|
-
* ```typescript
|
|
970
|
-
* const base = createTheme({ palette: { primary: { main: '#000' } } });
|
|
971
|
-
* const extended = extendTheme(base, {
|
|
972
|
-
* palette: { secondary: { main: '#fff' } }
|
|
973
|
-
* });
|
|
974
|
-
* ```
|
|
975
|
-
*/
|
|
976
|
-
declare function extendTheme(baseTheme: Theme | ThemeOptions, extension: ThemeOptions): Theme;
|
|
977
|
-
|
|
978
|
-
/**
|
|
979
|
-
* Atomix Configuration System
|
|
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
|
|
1005
|
-
*/
|
|
1006
|
-
interface CSSThemeDefinition {
|
|
1007
|
-
type: 'css';
|
|
1008
|
-
name: string;
|
|
1009
|
-
class?: string;
|
|
1010
|
-
description?: string;
|
|
1011
|
-
author?: string;
|
|
1012
|
-
version?: string;
|
|
1013
|
-
tags?: string[];
|
|
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;
|
|
1024
|
-
}
|
|
1025
|
-
/**
|
|
1026
|
-
* JavaScript Theme Definition
|
|
1027
|
-
*/
|
|
1028
|
-
interface JSThemeDefinition {
|
|
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
|
-
}
|
|
1047
|
-
/**
|
|
1048
|
-
* Theme Definition (CSS or JS)
|
|
1049
|
-
*/
|
|
1050
|
-
type ThemeDefinition = CSSThemeDefinition | JSThemeDefinition;
|
|
1051
|
-
/**
|
|
1052
|
-
* Build configuration (migrated from theme.config.ts)
|
|
1053
|
-
*/
|
|
1054
|
-
interface BuildConfig {
|
|
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
|
-
};
|
|
976
|
+
interface ComponentThemeOptions {
|
|
977
|
+
component: string;
|
|
978
|
+
variant?: string;
|
|
979
|
+
size?: string;
|
|
980
|
+
tokens?: Partial<DesignTokens>;
|
|
1067
981
|
}
|
|
1068
982
|
/**
|
|
1069
|
-
*
|
|
983
|
+
* Get a theme value for a specific component using CSS variables
|
|
984
|
+
* This ensures all components access theme values consistently
|
|
1070
985
|
*/
|
|
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
|
-
}
|
|
986
|
+
declare function getComponentThemeValue(component: string, property: string, variant?: string, size?: string): string;
|
|
1082
987
|
/**
|
|
1083
|
-
*
|
|
988
|
+
* Generate component-specific CSS variables from DesignTokens
|
|
1084
989
|
*/
|
|
1085
|
-
|
|
1086
|
-
cssVariables?: Record<string, string>;
|
|
1087
|
-
classNames?: {
|
|
1088
|
-
theme?: string;
|
|
1089
|
-
colorMode?: string;
|
|
1090
|
-
};
|
|
1091
|
-
}
|
|
1092
|
-
|
|
990
|
+
declare function generateComponentCSSVars(component: string, tokens?: Partial<DesignTokens>, variant?: string, size?: string): Record<string, string>;
|
|
1093
991
|
/**
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
* Type definitions for the theme configuration system
|
|
992
|
+
* Apply consistent theme to component style object using DesignTokens
|
|
1097
993
|
*/
|
|
1098
|
-
|
|
1099
|
-
/**
|
|
1100
|
-
* Loaded and validated theme configuration
|
|
1101
|
-
*/
|
|
1102
|
-
interface LoadedThemeConfig {
|
|
1103
|
-
/** Registered themes */
|
|
1104
|
-
themes: Record<string, ThemeDefinition>;
|
|
1105
|
-
/** Build configuration */
|
|
1106
|
-
build: BuildConfig;
|
|
1107
|
-
/** Runtime configuration */
|
|
1108
|
-
runtime: RuntimeConfig;
|
|
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;
|
|
1123
|
-
}
|
|
1124
|
-
|
|
994
|
+
declare function applyComponentTheme(component: string, style?: React.CSSProperties, variant?: string, size?: string, tokens?: Partial<DesignTokens>): React.CSSProperties;
|
|
1125
995
|
/**
|
|
1126
|
-
*
|
|
1127
|
-
*
|
|
1128
|
-
* Central registry for all themes with discovery and dependency management
|
|
996
|
+
* Create a hook for consistent component theming
|
|
1129
997
|
*/
|
|
1130
|
-
|
|
1131
|
-
/**
|
|
1132
|
-
* Registry entry
|
|
1133
|
-
*/
|
|
1134
|
-
interface RegistryEntry {
|
|
1135
|
-
/** Theme ID */
|
|
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[];
|
|
1149
|
-
}
|
|
1150
|
-
/**
|
|
1151
|
-
* Theme Registry
|
|
1152
|
-
*
|
|
1153
|
-
* Manages theme registration, discovery, and dependency resolution
|
|
1154
|
-
*/
|
|
1155
|
-
declare class ThemeRegistry {
|
|
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
|
-
|
|
1228
|
-
/**
|
|
1229
|
-
* CSS File Utilities
|
|
1230
|
-
*
|
|
1231
|
-
* Save CSS to file system (Node.js only).
|
|
1232
|
-
*/
|
|
1233
|
-
/**
|
|
1234
|
-
* Save CSS to file
|
|
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
|
-
* ```
|
|
1247
|
-
*/
|
|
1248
|
-
declare function saveCSSFile(css: string, filePath: string): Promise<void>;
|
|
1249
|
-
/**
|
|
1250
|
-
* Save CSS to file (synchronous version)
|
|
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
|
|
1257
|
-
*/
|
|
1258
|
-
declare function saveCSSFileSync(css: string, filePath: string): void;
|
|
998
|
+
declare function useComponentTheme(component: string, variant?: string, size?: string, tokens?: Partial<DesignTokens>): (property: string) => string;
|
|
1259
999
|
|
|
1260
1000
|
/**
|
|
1261
1001
|
* CSS Injection Utilities
|
|
@@ -1304,78 +1044,49 @@ declare function removeCSS(id?: string): void;
|
|
|
1304
1044
|
declare function isCSSInjected(id?: string): boolean;
|
|
1305
1045
|
|
|
1306
1046
|
/**
|
|
1307
|
-
*
|
|
1047
|
+
* Theme Configuration Loader
|
|
1308
1048
|
*
|
|
1309
|
-
*
|
|
1049
|
+
* Provides functions to load theme configurations from atomix.config.ts
|
|
1050
|
+
* Includes both sync and async versions, with automatic fallbacks
|
|
1310
1051
|
*/
|
|
1311
1052
|
|
|
1312
1053
|
/**
|
|
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
|
-
* ```
|
|
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
|
|
1328
1058
|
*/
|
|
1329
|
-
declare function
|
|
1059
|
+
declare function loadThemeFromConfigSync(options?: {
|
|
1060
|
+
configPath?: string;
|
|
1061
|
+
required?: boolean;
|
|
1062
|
+
}): DesignTokens;
|
|
1330
1063
|
/**
|
|
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
|
|
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
|
|
1340
1067
|
*/
|
|
1341
|
-
declare function
|
|
1068
|
+
declare function loadThemeFromConfig(options?: {
|
|
1069
|
+
configPath?: string;
|
|
1070
|
+
required?: boolean;
|
|
1071
|
+
}): Promise<DesignTokens>;
|
|
1342
1072
|
|
|
1343
1073
|
/**
|
|
1344
1074
|
* Theme Provider
|
|
1345
1075
|
*
|
|
1346
|
-
* React context provider for theme management
|
|
1076
|
+
* React context provider for theme management with separated concerns
|
|
1077
|
+
* Updated to use the new simplified theme system
|
|
1347
1078
|
*/
|
|
1348
1079
|
|
|
1349
1080
|
/**
|
|
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';
|
|
1081
|
+
* Theme Provider
|
|
1360
1082
|
*
|
|
1361
|
-
*
|
|
1362
|
-
*
|
|
1363
|
-
*
|
|
1364
|
-
*
|
|
1365
|
-
*
|
|
1366
|
-
* </ThemeProvider>
|
|
1367
|
-
* );
|
|
1368
|
-
* }
|
|
1083
|
+
* React context provider for theme management with separated concerns.
|
|
1084
|
+
* Simplified version focusing on core functionality:
|
|
1085
|
+
* - String-based themes (CSS files)
|
|
1086
|
+
* - DesignTokens (dynamic themes)
|
|
1087
|
+
* - Persistence via localStorage
|
|
1369
1088
|
*
|
|
1370
|
-
*
|
|
1371
|
-
* function App() {
|
|
1372
|
-
* return (
|
|
1373
|
-
* <ThemeProvider defaultTheme="dark">
|
|
1374
|
-
* <YourApp />
|
|
1375
|
-
* </ThemeProvider>
|
|
1376
|
-
* );
|
|
1377
|
-
* }
|
|
1378
|
-
* ```
|
|
1089
|
+
* Falls back to 'default' theme if no configuration is found.
|
|
1379
1090
|
*/
|
|
1380
1091
|
declare const ThemeProvider: React__default.FC<ThemeProviderProps>;
|
|
1381
1092
|
|
|
@@ -1408,6 +1119,38 @@ declare const ThemeProvider: React__default.FC<ThemeProviderProps>;
|
|
|
1408
1119
|
*/
|
|
1409
1120
|
declare function useTheme(): UseThemeReturn;
|
|
1410
1121
|
|
|
1122
|
+
/**
|
|
1123
|
+
* Standardized hook for accessing theme tokens in components
|
|
1124
|
+
*
|
|
1125
|
+
* Provides consistent access to theme values using CSS custom properties
|
|
1126
|
+
* and DesignTokens.
|
|
1127
|
+
*/
|
|
1128
|
+
type ThemeTokens = {
|
|
1129
|
+
theme: string;
|
|
1130
|
+
activeTokens: DesignTokens | null;
|
|
1131
|
+
getToken: (tokenName: string, fallback?: string) => string;
|
|
1132
|
+
colors: {
|
|
1133
|
+
primary: string;
|
|
1134
|
+
secondary: string;
|
|
1135
|
+
error: string;
|
|
1136
|
+
success: string;
|
|
1137
|
+
warning: string;
|
|
1138
|
+
info: string;
|
|
1139
|
+
light: string;
|
|
1140
|
+
dark: string;
|
|
1141
|
+
};
|
|
1142
|
+
spacing: Record<string, string>;
|
|
1143
|
+
borderRadius: Record<string, string>;
|
|
1144
|
+
typography: {
|
|
1145
|
+
fontFamily: Record<string, string>;
|
|
1146
|
+
fontSize: Record<string, string>;
|
|
1147
|
+
fontWeight: Record<string, string>;
|
|
1148
|
+
};
|
|
1149
|
+
shadows: Record<string, string>;
|
|
1150
|
+
transitions: Record<string, string>;
|
|
1151
|
+
};
|
|
1152
|
+
declare function useThemeTokens(): ThemeTokens;
|
|
1153
|
+
|
|
1411
1154
|
/**
|
|
1412
1155
|
* Theme context with default values
|
|
1413
1156
|
*/
|
|
@@ -1480,35 +1223,16 @@ declare class ThemeApplicator {
|
|
|
1480
1223
|
private styleId;
|
|
1481
1224
|
constructor(root?: HTMLElement);
|
|
1482
1225
|
/**
|
|
1483
|
-
* Apply a complete theme configuration
|
|
1226
|
+
* Apply a complete theme configuration using DesignTokens
|
|
1484
1227
|
*
|
|
1485
|
-
* Uses the unified theme system to
|
|
1228
|
+
* Uses the unified theme system to generate and inject CSS.
|
|
1486
1229
|
* Automatically respects atomix.config.ts when using DesignTokens.
|
|
1487
1230
|
*/
|
|
1488
|
-
applyTheme(
|
|
1489
|
-
/**
|
|
1490
|
-
* Apply DesignTokens using unified theme system
|
|
1491
|
-
*
|
|
1492
|
-
* Uses createTheme() which automatically loads from atomix.config.ts
|
|
1493
|
-
* if no tokens are provided, ensuring config is always respected.
|
|
1494
|
-
*/
|
|
1495
|
-
private applyDesignTokens;
|
|
1231
|
+
applyTheme(tokens: Partial<DesignTokens>): void;
|
|
1496
1232
|
/**
|
|
1497
|
-
*
|
|
1498
|
-
*/
|
|
1499
|
-
private isDesignTokens;
|
|
1500
|
-
/**
|
|
1501
|
-
* Apply global CSS variables (for component overrides)
|
|
1233
|
+
* Apply global CSS variables
|
|
1502
1234
|
*/
|
|
1503
1235
|
private applyGlobalCSSVars;
|
|
1504
|
-
/**
|
|
1505
|
-
* Apply component-level overrides
|
|
1506
|
-
*/
|
|
1507
|
-
private applyComponentOverrides;
|
|
1508
|
-
/**
|
|
1509
|
-
* Apply override for a specific component
|
|
1510
|
-
*/
|
|
1511
|
-
private applyComponentOverride;
|
|
1512
1236
|
/**
|
|
1513
1237
|
* Clear all applied CSS variables
|
|
1514
1238
|
*/
|
|
@@ -1529,7 +1253,7 @@ declare function getThemeApplicator(): ThemeApplicator;
|
|
|
1529
1253
|
/**
|
|
1530
1254
|
* Apply theme using global applicator
|
|
1531
1255
|
*/
|
|
1532
|
-
declare function applyTheme(
|
|
1256
|
+
declare function applyTheme(tokens: Partial<DesignTokens>): void;
|
|
1533
1257
|
|
|
1534
1258
|
/**
|
|
1535
1259
|
* Theme Preview Component
|
|
@@ -1794,22 +1518,6 @@ declare function useHistory<T>(options?: UseHistoryOptions): UseHistoryReturn<T>
|
|
|
1794
1518
|
* Converts between Theme objects and DesignTokens.
|
|
1795
1519
|
*/
|
|
1796
1520
|
|
|
1797
|
-
/**
|
|
1798
|
-
* Convert Theme object to DesignTokens
|
|
1799
|
-
*
|
|
1800
|
-
* Extracts values from a Theme object and converts them to flat DesignTokens format.
|
|
1801
|
-
*
|
|
1802
|
-
* @param theme - Theme object to convert
|
|
1803
|
-
* @returns Partial DesignTokens object
|
|
1804
|
-
*
|
|
1805
|
-
* @example
|
|
1806
|
-
* ```typescript
|
|
1807
|
-
* const theme = createTheme({ palette: { primary: { main: '#7c3aed' } } });
|
|
1808
|
-
* const tokens = themeToDesignTokens(theme);
|
|
1809
|
-
* // Returns: { 'primary': '#7c3aed', ... }
|
|
1810
|
-
* ```
|
|
1811
|
-
*/
|
|
1812
|
-
declare function themeToDesignTokens(theme: Theme): Partial<DesignTokens>;
|
|
1813
1521
|
/**
|
|
1814
1522
|
* Convert DesignTokens to Theme-compatible CSS variables
|
|
1815
1523
|
*
|
|
@@ -1817,22 +1525,6 @@ declare function themeToDesignTokens(theme: Theme): Partial<DesignTokens>;
|
|
|
1817
1525
|
* @returns CSS variables object compatible with Theme.cssVars
|
|
1818
1526
|
*/
|
|
1819
1527
|
declare function designTokensToCSSVars(tokens: Partial<DesignTokens>): Record<string, string>;
|
|
1820
|
-
/**
|
|
1821
|
-
* Create DesignTokens from Theme with defaults
|
|
1822
|
-
*
|
|
1823
|
-
* Converts a Theme to DesignTokens and merges with default tokens.
|
|
1824
|
-
*
|
|
1825
|
-
* @param theme - Theme object to convert
|
|
1826
|
-
* @returns Complete DesignTokens object
|
|
1827
|
-
*/
|
|
1828
|
-
declare function createDesignTokensFromTheme(theme: Theme): DesignTokens;
|
|
1829
|
-
/**
|
|
1830
|
-
* Create a minimal Theme object from DesignTokens
|
|
1831
|
-
*
|
|
1832
|
-
* @param tokens - DesignTokens to convert
|
|
1833
|
-
* @returns Minimal Theme object with cssVars populated
|
|
1834
|
-
*/
|
|
1835
|
-
declare function designTokensToTheme(tokens: Partial<DesignTokens>): Partial<Theme>;
|
|
1836
1528
|
|
|
1837
1529
|
/**
|
|
1838
1530
|
* CSS Variable Mapper
|
|
@@ -1866,25 +1558,6 @@ interface CSSVariableNamingOptions {
|
|
|
1866
1558
|
/** Whether to include component name in variable (default: true) */
|
|
1867
1559
|
includeComponent?: boolean;
|
|
1868
1560
|
}
|
|
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
1561
|
/**
|
|
1889
1562
|
* Map SCSS tokens to CSS custom properties
|
|
1890
1563
|
*
|
|
@@ -1897,8 +1570,8 @@ declare function mapSCSSTokensToCSSVars(tokens: Record<string, any>, options?: C
|
|
|
1897
1570
|
/**
|
|
1898
1571
|
* Apply CSS variables to an element
|
|
1899
1572
|
*
|
|
1900
|
-
* @param element - Target element (defaults to document.documentElement)
|
|
1901
1573
|
* @param vars - CSS variables to apply
|
|
1574
|
+
* @param element - Target element (defaults to document.documentElement)
|
|
1902
1575
|
*/
|
|
1903
1576
|
declare function applyCSSVariables(vars: Record<string, string | number>, element?: HTMLElement): void;
|
|
1904
1577
|
/**
|
|
@@ -1946,27 +1619,9 @@ declare function extractComponentName(varName: string, prefix?: string): string
|
|
|
1946
1619
|
/**
|
|
1947
1620
|
* Theme Helper Functions
|
|
1948
1621
|
*
|
|
1949
|
-
* Utility functions for working with
|
|
1622
|
+
* Utility functions for working with DesignTokens
|
|
1950
1623
|
*/
|
|
1951
1624
|
|
|
1952
|
-
/**
|
|
1953
|
-
* Get DesignTokens from current theme
|
|
1954
|
-
*
|
|
1955
|
-
* Converts a Theme object to DesignTokens. Useful when you need to
|
|
1956
|
-
* work with DesignTokens but have a Theme object.
|
|
1957
|
-
*
|
|
1958
|
-
* @param theme - Theme object to convert
|
|
1959
|
-
* @returns DesignTokens object
|
|
1960
|
-
*
|
|
1961
|
-
* @example
|
|
1962
|
-
* ```typescript
|
|
1963
|
-
* // If you have a Theme object, convert it to DesignTokens
|
|
1964
|
-
* const tokens = getDesignTokensFromTheme(theme);
|
|
1965
|
-
* // Now you can use tokens with unified theme system
|
|
1966
|
-
* const css = createTheme(tokens);
|
|
1967
|
-
* ```
|
|
1968
|
-
*/
|
|
1969
|
-
declare function getDesignTokensFromTheme(theme: Theme | null): DesignTokens | null;
|
|
1970
1625
|
/**
|
|
1971
1626
|
* Check if a value is DesignTokens
|
|
1972
1627
|
*
|
|
@@ -1976,15 +1631,6 @@ declare function getDesignTokensFromTheme(theme: Theme | null): DesignTokens | n
|
|
|
1976
1631
|
* @returns True if value is DesignTokens
|
|
1977
1632
|
*/
|
|
1978
1633
|
declare function isDesignTokens(value: unknown): value is DesignTokens;
|
|
1979
|
-
/**
|
|
1980
|
-
* Check if a value is a Theme object
|
|
1981
|
-
*
|
|
1982
|
-
* Type guard to check if an object is a Theme.
|
|
1983
|
-
*
|
|
1984
|
-
* @param value - Value to check
|
|
1985
|
-
* @returns True if value is Theme
|
|
1986
|
-
*/
|
|
1987
|
-
declare function isThemeObject(value: unknown): value is Theme;
|
|
1988
1634
|
|
|
1989
1635
|
/**
|
|
1990
1636
|
* RTL (Right-to-Left) Support Utilities
|
|
@@ -2088,13 +1734,13 @@ declare class RTLManager {
|
|
|
2088
1734
|
/**
|
|
2089
1735
|
* Theme System Exports
|
|
2090
1736
|
*
|
|
2091
|
-
*
|
|
1737
|
+
* Simplified theme system using DesignTokens only.
|
|
2092
1738
|
*
|
|
2093
1739
|
* @example
|
|
2094
1740
|
* ```typescript
|
|
2095
1741
|
* import { createTheme, injectTheme } from '@shohojdhara/atomix/theme';
|
|
2096
1742
|
*
|
|
2097
|
-
* // Using DesignTokens
|
|
1743
|
+
* // Using DesignTokens
|
|
2098
1744
|
* const css = createTheme({ 'primary': '#7AFFD7', 'spacing-4': '1rem' });
|
|
2099
1745
|
* injectTheme(css);
|
|
2100
1746
|
*
|
|
@@ -2118,5 +1764,5 @@ declare function removeTheme(id?: string): void;
|
|
|
2118
1764
|
*/
|
|
2119
1765
|
declare function saveTheme(css: string, filePath: string): Promise<void>;
|
|
2120
1766
|
|
|
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,
|
|
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 };
|
|
1768
|
+
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 };
|