@maz-ui/themes 5.0.0-beta.4 → 5.0.0-beta.5

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.
@@ -9,12 +9,15 @@ export interface BuildThemeOptions {
9
9
  prefix?: string;
10
10
  /** Dark class name */
11
11
  darkClass?: string;
12
+ /** Whether to generate color scales */
13
+ scaleColorVariables?: boolean;
12
14
  }
13
15
  export declare function buildThemeCSS(options: BuildThemeOptions): string;
14
16
  export declare function generateThemeBundle(presets: ThemePreset[], options?: {
15
17
  mode?: 'light' | 'dark' | 'both';
16
18
  darkSelector?: 'class' | 'media';
17
19
  prefix?: string;
20
+ scaleColorVariables?: boolean;
18
21
  }): Record<string, string>;
19
22
  export declare function createThemeStylesheet(css: string, options?: {
20
23
  id?: string;
@@ -24,6 +27,7 @@ export declare function buildSeparateThemeFiles(preset: ThemePreset, options?: {
24
27
  prefix?: string;
25
28
  darkSelector?: 'class' | 'media';
26
29
  darkClass?: string;
30
+ scaleColorVariables?: boolean;
27
31
  }): {
28
32
  full: string;
29
33
  lightOnly: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAG3C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,WAAW,CAAA;IACnB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;IAChC,6DAA6D;IAC7D,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAChC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sBAAsB;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAehE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,OAAO,GAAE;IACnE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;IAChC,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;CACX,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgB9B;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;IAC1D,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;CACV,GAAG,MAAM,CAYd;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;CACd,GAAG;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAMA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAG3C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,WAAW,CAAA;IACnB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;IAChC,6DAA6D;IAC7D,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAChC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sBAAsB;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uCAAuC;IACvC,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAiBhE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,OAAO,GAAE;IACnE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;IAChC,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,mBAAmB,CAAC,EAAE,OAAO,CAAA;CACzB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB9B;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;IAC1D,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;CACV,GAAG,MAAM,CAYd;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,mBAAmB,CAAC,EAAE,OAAO,CAAA;CACzB,GAAG;IACP,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAMA"}
@@ -1 +1 @@
1
- import{generateCSS}from"../utils/css-generator.js";function buildThemeCSS(options){let{preset,mode=`both`,darkSelector=`class`,prefix=`maz`,darkClass=`dark`}=options;return generateCSS(preset,{mode,darkSelectorStrategy:darkSelector,prefix,darkClass})}function generateThemeBundle(presets,options={}){let{mode=`both`,darkSelector=`class`,prefix=`maz`}=options;return presets.reduce((bundle,preset)=>(bundle[preset.name]=buildThemeCSS({preset,mode,darkSelector,prefix}),bundle),{})}function createThemeStylesheet(css,options={}){let{id=`maz-theme`,media}=options;let styleTag=`<style id="${id}"`;return media&&(styleTag+=` media="${media}"`),styleTag+=`>\n${css}\n</style>`,styleTag}function buildSeparateThemeFiles(preset,options={}){return{full:buildThemeCSS({preset,mode:`both`,...options}),lightOnly:buildThemeCSS({preset,mode:`light`,...options}),darkOnly:buildThemeCSS({preset,mode:`dark`,...options})}}export{buildSeparateThemeFiles,buildThemeCSS,createThemeStylesheet,generateThemeBundle};
1
+ import{generateCSS}from"../utils/css-generator.js";function buildThemeCSS(options){let{preset,mode=`both`,darkSelector=`class`,prefix=`maz`,darkClass=`dark`,scaleColorVariables=!0}=options;return generateCSS(preset,{mode,darkSelectorStrategy:darkSelector,prefix,darkClass,scaleColorVariables})}function generateThemeBundle(presets,options={}){let{mode=`both`,darkSelector=`class`,prefix=`maz`,scaleColorVariables=!0}=options;return presets.reduce((bundle,preset)=>(bundle[preset.name]=buildThemeCSS({preset,mode,darkSelector,prefix,scaleColorVariables}),bundle),{})}function createThemeStylesheet(css,options={}){let{id=`maz-theme`,media}=options;let styleTag=`<style id="${id}"`;return media&&(styleTag+=` media="${media}"`),styleTag+=`>\n${css}\n</style>`,styleTag}function buildSeparateThemeFiles(preset,options={}){return{full:buildThemeCSS({preset,mode:`both`,...options}),lightOnly:buildThemeCSS({preset,mode:`light`,...options}),darkOnly:buildThemeCSS({preset,mode:`dark`,...options})}}export{buildSeparateThemeFiles,buildThemeCSS,createThemeStylesheet,generateThemeBundle};
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/composables/useTheme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAc,MAAM,UAAU,CAAA;AA0BzG,iBAAe,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,oBAAoB,GAAG,eAAe,iBA+BtF;AAED,iBAAS,YAAY,CAAC,SAAS,EAAE,SAAS,QAWzC;AAED,iBAAS,cAAc,SAEtB;AAiCD,wBAAgB,QAAQ;IAkBpB;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;OAIG;wBACiB,WAAW,GAAG,oBAAoB,GAAG,eAAe,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC;IAGzG;;;;OAIG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;OAEG;;EAGN"}
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/composables/useTheme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAc,MAAM,UAAU,CAAA;AA0BzG,iBAAe,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,oBAAoB,GAAG,eAAe,iBAgCtF;AAED,iBAAS,YAAY,CAAC,SAAS,EAAE,SAAS,QAWzC;AAED,iBAAS,cAAc,SAEtB;AAiCD,wBAAgB,QAAQ;IAkBpB;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;OAIG;wBACiB,WAAW,GAAG,oBAAoB,GAAG,eAAe,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC;IAGzG;;;;OAIG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;OAEG;;EAGN"}
@@ -1 +1 @@
1
- import{saveResolvedPresetName,setCookie}from"../utils/cookie-storage.js";import{CSS_ID,generateCSS,injectCSS}from"../utils/css-generator.js";import{getPreset}from"../utils/get-preset.js";import{noTransition}from"../utils/no-transition.js";import{mergePresets}from"../utils/preset-merger.js";import{getSystemColorMode,saveResolvedColorMode}from"../utils/get-color-mode.js";import{isServer}from"@maz-ui/utils/helpers/isServer";import{computed,getCurrentInstance,inject,ref,watch}from"vue";var themeState=ref();var colorMode=computed({get:()=>themeState.value?.colorMode,set:mode=>setColorMode(mode)});var isDark=computed(()=>themeState.value?.isDark||!1);var strategy=computed(()=>themeState.value?.strategy);var mode=computed(()=>themeState.value?.mode);var darkModeStrategy=computed(()=>themeState.value?.darkModeStrategy);var preset=computed(()=>themeState.value?.preset);var presetName=computed(()=>preset.value?.name);async function updateTheme(preset){if(!themeState.value)return;let _preset=typeof preset==`string`?await getPreset(preset):preset;if(!_preset||!themeState.value.preset){console.error(`[@maz-ui/themes] No preset found - If you are using the buildtime strategy, you must provide a complete preset`);return}let newPreset=`name`in _preset&&_preset.name!==themeState.value.preset.name?_preset:mergePresets(themeState.value.preset,_preset);themeState.value.preset=newPreset,themeState.value.persistPreset&&saveResolvedPresetName(newPreset.name),themeState.value.strategy===`runtime`&&injectCSS(CSS_ID,generateCSS(newPreset,{mode:themeState.value.mode,darkSelectorStrategy:themeState.value.darkModeStrategy,prefix:`maz`,darkClass:themeState.value.darkClass}))}function setColorMode(colorMode){themeState.value&&(themeState.value.colorMode=colorMode,setCookie(`maz-color-mode`,colorMode),colorMode===`auto`&&saveResolvedColorMode(getSystemColorMode()===`dark`?`dark`:`light`))}function toggleDarkMode(){setColorMode(isDark.value?`light`:`dark`)}var stopInjectedWatch;function setThemeStateFromGlobalProperties(){themeState.value=void 0,stopInjectedWatch?.(),stopInjectedWatch=void 0;try{let injectedState=inject(`mazThemeState`,void 0);if(themeState.value=injectedState?.value,injectedState&&(stopInjectedWatch=watch(injectedState,newState=>{newState&&(themeState.value=newState)},{deep:!0})),!themeState.value)throw Error(`mazThemeState not found`)}catch{let instance=getCurrentInstance();instance?.appContext?.app?.config?.globalProperties&&(themeState.value=instance.appContext.app.config.globalProperties.$mazThemeState.value)}}function useTheme(){isServer()&&(themeState.value=void 0);try{if(themeState.value||setThemeStateFromGlobalProperties(),!themeState.value)throw Error(`[@maz-ui/themes] no theme state found`)}catch{throw Error(`[@maz-ui/themes] You must install the MazUi or MazUiTheme plugin, or wrap your components in a MazUiProvider, before using useTheme composable`)}return{preset,presetName,colorMode,isDark,strategy,updateTheme(preset){return noTransition(updateTheme,preset)},setColorMode,toggleDarkMode,mode,darkModeStrategy,currentPreset:preset}}export{useTheme};
1
+ import{saveResolvedPresetName,setCookie}from"../utils/cookie-storage.js";import{CSS_ID,generateCSS,injectCSS}from"../utils/css-generator.js";import{getPreset}from"../utils/get-preset.js";import{noTransition}from"../utils/no-transition.js";import{mergePresets}from"../utils/preset-merger.js";import{getSystemColorMode,saveResolvedColorMode}from"../utils/get-color-mode.js";import{isServer}from"@maz-ui/utils/helpers/isServer";import{computed,getCurrentInstance,inject,ref,watch}from"vue";var themeState=ref();var colorMode=computed({get:()=>themeState.value?.colorMode,set:mode=>setColorMode(mode)});var isDark=computed(()=>themeState.value?.isDark||!1);var strategy=computed(()=>themeState.value?.strategy);var mode=computed(()=>themeState.value?.mode);var darkModeStrategy=computed(()=>themeState.value?.darkModeStrategy);var preset=computed(()=>themeState.value?.preset);var presetName=computed(()=>preset.value?.name);async function updateTheme(preset){if(!themeState.value)return;let _preset=typeof preset==`string`?await getPreset(preset):preset;if(!_preset||!themeState.value.preset){console.error(`[@maz-ui/themes] No preset found - If you are using the buildtime strategy, you must provide a complete preset`);return}let newPreset=`name`in _preset&&_preset.name!==themeState.value.preset.name?_preset:mergePresets(themeState.value.preset,_preset);themeState.value.preset=newPreset,themeState.value.persistPreset&&saveResolvedPresetName(newPreset.name),themeState.value.strategy===`runtime`&&injectCSS(CSS_ID,generateCSS(newPreset,{mode:themeState.value.mode,darkSelectorStrategy:themeState.value.darkModeStrategy,prefix:`maz`,scaleColorVariables:!0,darkClass:themeState.value.darkClass}))}function setColorMode(colorMode){themeState.value&&(themeState.value.colorMode=colorMode,setCookie(`maz-color-mode`,colorMode),colorMode===`auto`&&saveResolvedColorMode(getSystemColorMode()===`dark`?`dark`:`light`))}function toggleDarkMode(){setColorMode(isDark.value?`light`:`dark`)}var stopInjectedWatch;function setThemeStateFromGlobalProperties(){themeState.value=void 0,stopInjectedWatch?.(),stopInjectedWatch=void 0;try{let injectedState=inject(`mazThemeState`,void 0);if(themeState.value=injectedState?.value,injectedState&&(stopInjectedWatch=watch(injectedState,newState=>{newState&&(themeState.value=newState)},{deep:!0})),!themeState.value)throw Error(`mazThemeState not found`)}catch{let instance=getCurrentInstance();instance?.appContext?.app?.config?.globalProperties&&(themeState.value=instance.appContext.app.config.globalProperties.$mazThemeState.value)}}function useTheme(){isServer()&&(themeState.value=void 0);try{if(themeState.value||setThemeStateFromGlobalProperties(),!themeState.value)throw Error(`[@maz-ui/themes] no theme state found`)}catch{throw Error(`[@maz-ui/themes] You must install the MazUi or MazUiTheme plugin, or wrap your components in a MazUiProvider, before using useTheme composable`)}return{preset,presetName,colorMode,isDark,strategy,updateTheme(preset){return noTransition(updateTheme,preset)},setColorMode,toggleDarkMode,mode,darkModeStrategy,currentPreset:preset}}export{useTheme};
@@ -8,6 +8,8 @@ export interface CSSOptions {
8
8
  prefix?: string;
9
9
  /** Dark class name */
10
10
  darkClass: string;
11
+ /** Whether to generate color scales */
12
+ scaleColorVariables: boolean;
11
13
  }
12
14
  export declare function generateCSS(preset: ThemePreset, options?: CSSOptions): string;
13
15
  export declare const CSS_ID = "maz-theme-css";
@@ -1 +1 @@
1
- {"version":3,"file":"css-generator.d.ts","sourceRoot":"","sources":["../../src/utils/css-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAiD,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAMvH,MAAM,WAAW,UAAU;IACzB,6BAA6B;IAC7B,IAAI,EAAE,SAAS,CAAA;IACf,6DAA6D;IAC7D,oBAAoB,EAAE,gBAAgB,CAAA;IACtC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAA;CAClB;AAID,wBAAgB,WAAW,CACzB,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,UAIR,GACA,MAAM,CAwCR;AAoID,eAAO,MAAM,MAAM,kBAAkB,CAAA;AAErC,wBAAgB,SAAS,CAAC,EAAE,oBAAS,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CA2BxD;AAED,wBAAgB,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAK3C"}
1
+ {"version":3,"file":"css-generator.d.ts","sourceRoot":"","sources":["../../src/utils/css-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAiD,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAMvH,MAAM,WAAW,UAAU;IACzB,6BAA6B;IAC7B,IAAI,EAAE,SAAS,CAAA;IACf,6DAA6D;IAC7D,oBAAoB,EAAE,gBAAgB,CAAA;IACtC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,uCAAuC;IACvC,mBAAmB,EAAE,OAAO,CAAA;CAC7B;AAID,wBAAgB,WAAW,CACzB,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,UAKR,GACA,MAAM,CA2CR;AAsID,eAAO,MAAM,MAAM,kBAAkB,CAAA;AAErC,wBAAgB,SAAS,CAAC,EAAE,oBAAS,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CA2BxD;AAED,wBAAgB,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAK3C"}
@@ -1,4 +1,4 @@
1
- import{normalizeColor}from"./color-parser.js";import{generateColorScale}from"./color-utils.js";import{DEFAULT_ROUNDED_RATIOS}from"../presets/_defaults.js";import{isServer}from"@maz-ui/utils/helpers/isServer";var scaleColors=[`primary`,`secondary`,`accent`,`destructive`,`success`,`warning`,`info`,`contrast`,`surface`,`foreground`,`divider`,`muted`,`overlay`,`shadow`];function generateCSS(preset,options={mode:`both`,darkSelectorStrategy:`class`,darkClass:`dark`}){let{mode,darkSelectorStrategy,prefix=`maz`,darkClass=`dark`}=options;let css=`@layer theme {
2
- `;let rootSelector=`:root`;let darkClassSelector=`.${darkClass}`;return(mode===`light`||mode===`both`)&&(css+=generateVariablesBlock({selector:rootSelector,colors:preset.colors.light,foundation:preset.foundation,prefix,preset,mode:`light`})),(mode===`dark`||mode===`both`)&&(css+=generateVariablesBlock({selector:darkSelectorStrategy===`media`?rootSelector:darkClassSelector,mediaQuery:darkSelectorStrategy===`media`?`@media (prefers-color-scheme: dark)`:void 0,colors:preset.colors.dark,foundation:mode===`dark`?preset.foundation:void 0,prefix,preset,isDark:!0,mode:`dark`})),css+=`}
3
- `,css}function generateVariablesBlock({selector,mediaQuery,colors,foundation,prefix,preset,isDark=!1,mode=`light`}){let variables=[];colors&&Object.entries(colors).forEach(([key,value])=>{value&&variables.push(` --${prefix}-${key}: ${normalizeColor(value)};`)}),foundation&&Object.entries(foundation).forEach(([key,value])=>{value&&variables.push(` --${prefix}-${key}: ${value};`)}),!isDark&&preset?.scales&&variables.push(...generateScaleVariables(preset.scales,prefix)),preset?.components&&variables.push(...generateComponentVariables(preset.components,mode,prefix)),preset&&variables.push(...generateAllColorScales(isDark?preset.colors.dark:preset.colors.light,prefix));let content=variables.join(`
1
+ import{normalizeColor}from"./color-parser.js";import{generateColorScale}from"./color-utils.js";import{DEFAULT_ROUNDED_RATIOS}from"../presets/_defaults.js";import{isServer}from"@maz-ui/utils/helpers/isServer";var scaleColors=[`primary`,`secondary`,`accent`,`destructive`,`success`,`warning`,`info`,`contrast`,`surface`,`foreground`,`divider`,`muted`,`overlay`,`shadow`];function generateCSS(preset,options={mode:`both`,darkSelectorStrategy:`class`,darkClass:`dark`,scaleColorVariables:!0}){let{mode,darkSelectorStrategy,prefix=`maz`,darkClass=`dark`,scaleColorVariables=!0}=options;let css=`@layer theme {
2
+ `;let rootSelector=`:root`;let darkClassSelector=`.${darkClass}`;return(mode===`light`||mode===`both`)&&(css+=generateVariablesBlock({selector:rootSelector,colors:preset.colors.light,foundation:preset.foundation,prefix,preset,mode:`light`,scaleColorVariables})),(mode===`dark`||mode===`both`)&&(css+=generateVariablesBlock({selector:darkSelectorStrategy===`media`?rootSelector:darkClassSelector,mediaQuery:darkSelectorStrategy===`media`?`@media (prefers-color-scheme: dark)`:void 0,colors:preset.colors.dark,foundation:mode===`dark`?preset.foundation:void 0,prefix,preset,isDark:!0,mode:`dark`,scaleColorVariables})),css+=`}
3
+ `,css}function generateVariablesBlock({selector,mediaQuery,colors,foundation,prefix,preset,isDark=!1,scaleColorVariables=!0,mode=`light`}){let variables=[];colors&&Object.entries(colors).forEach(([key,value])=>{value&&variables.push(` --${prefix}-${key}: ${normalizeColor(value)};`)}),foundation&&Object.entries(foundation).forEach(([key,value])=>{value&&variables.push(` --${prefix}-${key}: ${value};`)}),!isDark&&preset?.scales&&variables.push(...generateScaleVariables(preset.scales,prefix)),preset?.components&&variables.push(...generateComponentVariables(preset.components,mode,prefix)),preset&&scaleColorVariables&&variables.push(...generateAllColorScales(isDark?preset.colors.dark:preset.colors.light,prefix));let content=variables.join(`
4
4
  `);return mediaQuery?`\n ${mediaQuery} {\n ${selector} {\n${content.replace(/^/gm,` `)}\n }\n }\n`:`\n ${selector} {\n${content}\n }\n`}var ROUNDED_KEYS=[`xs`,`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`];function generateScaleVariables(scales,prefix){let lines=[];for(let key of ROUNDED_KEYS){let value=scales.rounded?.[key];value?lines.push(` --${prefix}-rounded-${key}: ${value};`):key!==`md`&&lines.push(` --${prefix}-rounded-${key}: calc(var(--${prefix}-rounded-md) * ${DEFAULT_ROUNDED_RATIOS[key]});`)}return Object.entries(scales.shadow??{}).forEach(([key,value])=>{value&&lines.push(` --${prefix}-shadow-style-${key}: ${value};`)}),lines}function generateComponentVariables(components,mode,prefix){let lines=[];components.btn?.[`font-weight`]&&lines.push(` --${prefix}-btn-font-weight: ${components.btn[`font-weight`]};`);let containerBg=components.container?.bg?.[mode];containerBg&&lines.push(` --${prefix}-container-bg: ${normalizeColor(containerBg)};`);let inputBg=components.input?.bg?.[mode];inputBg&&lines.push(` --${prefix}-input-bg: ${normalizeColor(inputBg)};`);let inputTopLabelFontWeight=components.input?.[`top-label-font-weight`];return inputTopLabelFontWeight&&lines.push(` --${prefix}-input-top-label-font-weight: ${inputTopLabelFontWeight};`),lines}function generateAllColorScales(colors,prefix){let colorScales=[];return scaleColors.forEach(colorName=>{let baseColor=colors[colorName];if(baseColor){let scale=generateColorScale(baseColor);Object.entries(scale).forEach(([scaleKey,scaleValue])=>{colorScales.push(` --${prefix}-${colorName}-${scaleKey}: ${scaleValue};`)})}}),colorScales}var CSS_ID=`maz-theme-css`;function injectCSS(id=CSS_ID,css){if(isServer())return;let styleElements=[...document.querySelectorAll(`#${id}`)];if(styleElements.length===0){let element=document.createElement(`style`);element.id=id,element.textContent=css,document.head.appendChild(element);return}if(styleElements.length===1){styleElements[0].textContent=css;return}let lastElement=styleElements.at(-1);for(let i=0;i<styleElements.length-1;i++)styleElements[i].remove();lastElement&&(lastElement.textContent=css)}function removeCSS(id=CSS_ID){isServer()||document.querySelectorAll(`#${id}`).forEach(el=>el.remove())}export{CSS_ID,generateCSS,injectCSS,removeCSS};
@@ -1 +1 @@
1
- {"version":3,"file":"inject-theme-css.d.ts","sourceRoot":"","sources":["../../src/utils/inject-theme-css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAG3C,wBAAgB,cAAc,CAC5B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,QAUxF"}
1
+ {"version":3,"file":"inject-theme-css.d.ts","sourceRoot":"","sources":["../../src/utils/inject-theme-css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAG3C,wBAAgB,cAAc,CAC5B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,QAWxF"}
@@ -1 +1 @@
1
- import{CSS_ID,generateCSS,injectCSS}from"./css-generator.js";function injectThemeCSS(finalPreset,config){typeof document>`u`||config.strategy===`buildtime`||injectCSS(CSS_ID,generateCSS(finalPreset,{mode:config.mode,darkSelectorStrategy:config.darkModeStrategy,darkClass:config.darkClass}))}export{injectThemeCSS};
1
+ import{CSS_ID,generateCSS,injectCSS}from"./css-generator.js";function injectThemeCSS(finalPreset,config){typeof document>`u`||config.strategy===`buildtime`||injectCSS(CSS_ID,generateCSS(finalPreset,{mode:config.mode,darkSelectorStrategy:config.darkModeStrategy,darkClass:config.darkClass,scaleColorVariables:!0}))}export{injectThemeCSS};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maz-ui/themes",
3
3
  "type": "module",
4
- "version": "5.0.0-beta.4",
4
+ "version": "5.0.0-beta.5",
5
5
  "description": "Theme system for Maz-UI with TypeScript support and CSS variables",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",
@@ -88,7 +88,7 @@
88
88
  "vue": ">=3.5.0 <4.0.0"
89
89
  },
90
90
  "dependencies": {
91
- "@maz-ui/utils": "5.0.0-beta.4"
91
+ "@maz-ui/utils": "5.0.0-beta.5"
92
92
  },
93
93
  "lint-staged": {
94
94
  "*.{js,ts,vue,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix"