@voicenter-team/voicenter-ui-plus 0.2.6 → 0.2.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.
@@ -1,4 +1,4 @@
1
- import { UIThemeConfig } from './theme.types';
1
+ import { themeType, UIThemeConfig } from './theme.types';
2
2
  export declare function overrideElementTheme(theme: {
3
3
  [key: string]: string;
4
4
  }): {
@@ -22,4 +22,5 @@ export declare function overrideElementTheme(theme: {
22
22
  export declare function appendGlobalCssVariables(cssData: {
23
23
  [key: string]: string;
24
24
  }, appendTo: HTMLElement): void;
25
+ export declare function getThemeConfigData(themeConfig?: UIThemeConfig): Promise<themeType>;
25
26
  export default function (themeConfig?: UIThemeConfig, appendTo?: HTMLElement): Promise<void>;
@@ -6,7 +6,7 @@ export type themesType = {
6
6
  };
7
7
  export type UIThemeBaseConfig = {
8
8
  type: string;
9
- onSetupCallback?: () => void;
9
+ onSetupCallback?: (loadedTheme: themeType) => void;
10
10
  };
11
11
  export type UIThemeLocalConfig = UIThemeBaseConfig & {
12
12
  type: 'local';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicenter-team/voicenter-ui-plus",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "scripts": {
5
5
  "dev": "vite",
6
6
  "build": "vue-tsc --declaration --emitDeclarationOnly && vite build",
@@ -41,7 +41,7 @@ export function appendGlobalCssVariables (cssData: { [key: string]: string }, ap
41
41
  })
42
42
  }
43
43
 
44
- export default async function (themeConfig?: UIThemeConfig, appendTo: HTMLElement = document.documentElement) {
44
+ export async function getThemeConfigData (themeConfig?: UIThemeConfig) {
45
45
  let currentTheme = _default
46
46
 
47
47
  if (themeConfig) {
@@ -98,12 +98,18 @@ export default async function (themeConfig?: UIThemeConfig, appendTo: HTMLElemen
98
98
  }
99
99
  }
100
100
 
101
+ return currentTheme
102
+ }
103
+
104
+ export default async function (themeConfig?: UIThemeConfig, appendTo: HTMLElement = document.documentElement) {
105
+ const currentTheme = await getThemeConfigData(themeConfig)
106
+
101
107
  appendGlobalCssVariables(
102
108
  { ...overrideElementTheme(currentTheme), ...globalVariables },
103
109
  appendTo
104
110
  )
105
111
 
106
112
  if (themeConfig?.onSetupCallback) {
107
- themeConfig.onSetupCallback()
113
+ themeConfig.onSetupCallback(currentTheme)
108
114
  }
109
115
  }
@@ -6,7 +6,7 @@ export type themesType = {
6
6
  }
7
7
  export type UIThemeBaseConfig = {
8
8
  type: string
9
- onSetupCallback?: () => void
9
+ onSetupCallback?: (loadedTheme: themeType) => void
10
10
  }
11
11
  export type UIThemeLocalConfig = UIThemeBaseConfig & {
12
12
  type: 'local'