@wise/components-theming 0.0.0-experimental-17de653 → 0.0.0-experimental-aa6bd68

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.
@@ -3,6 +3,6 @@ import type { Theming } from './const';
3
3
  type ThemeProviderProps = PropsWithChildren<Theming> & {
4
4
  className?: string;
5
5
  };
6
- export declare const ThemeProvider: ({ theme, screenMode, isNotRootProvider, children, className, }: ThemeProviderProps) => import("react").JSX.Element;
6
+ export declare const ThemeProvider: ({ theme: initialTheme, screenMode: initialScreenMode, isNotRootProvider, children, className, }: ThemeProviderProps) => import("react").JSX.Element;
7
7
  export {};
8
8
  //# sourceMappingURL=ThemeProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkC,MAAM,OAAO,CAAC;AAG1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAKvC,KAAK,kBAAkB,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAK9E,eAAO,MAAM,aAAa,GAAI,gEAM3B,kBAAkB,gCAyBpB,CAAC"}
1
+ {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA4C,MAAM,OAAO,CAAC;AAGpF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAKvC,KAAK,kBAAkB,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAK9E,eAAO,MAAM,aAAa,GAAI,iGAM3B,kBAAkB,gCAuCpB,CAAC"}
@@ -9,13 +9,22 @@ var jsxRuntime = require('react/jsx-runtime');
9
9
 
10
10
  const themeClass = /\bnp-theme-[a-z-]+\b/g;
11
11
  const ThemeProvider = ({
12
- theme = _const.DEFAULT_BASE_THEME,
13
- screenMode = _const.DEFAULT_SCREEN_MODE,
12
+ theme: initialTheme = _const.DEFAULT_BASE_THEME,
13
+ screenMode: initialScreenMode = _const.DEFAULT_SCREEN_MODE,
14
14
  isNotRootProvider = false,
15
15
  children,
16
16
  className = undefined
17
17
  }) => {
18
18
  const isContextRoot = react.useContext(ThemeProviderContext.ThemeContext) === undefined;
19
+ const [theme, setTheme] = react.useState(initialTheme);
20
+ const [screenMode, setScreenMode] = react.useState(initialScreenMode);
21
+ // Update state when props change (for controlled usage)
22
+ react.useEffect(() => {
23
+ setTheme(initialTheme);
24
+ }, [initialTheme]);
25
+ react.useEffect(() => {
26
+ setScreenMode(initialScreenMode);
27
+ }, [initialScreenMode]);
19
28
  // useEffect hook used to apply the theme class to the HTML element
20
29
  react.useEffect(() => {
21
30
  if (!isNotRootProvider && isContextRoot) {
@@ -30,8 +39,10 @@ const ThemeProvider = ({
30
39
  }, [isNotRootProvider, isContextRoot, theme, screenMode]);
31
40
  const contextValue = react.useMemo(() => ({
32
41
  theme,
33
- screenMode
34
- }), [screenMode, theme]);
42
+ screenMode,
43
+ setTheme,
44
+ setScreenMode
45
+ }), [theme, screenMode]);
35
46
  return /*#__PURE__*/jsxRuntime.jsx(ThemeProviderContext.ThemeContext.Provider, {
36
47
  value: contextValue,
37
48
  children: /*#__PURE__*/jsxRuntime.jsx(ThemedChildren.ThemedChildren, {
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.js","sources":["../src/ThemeProvider.tsx"],"sourcesContent":["import { PropsWithChildren, useContext, useEffect, useMemo } from 'react';\n\nimport { ThemedChildren } from './ThemedChildren';\nimport type { Theming } from './const';\nimport { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const';\nimport { getThemeClassName } from './helpers';\nimport { ThemeContext } from './ThemeProviderContext';\n\ntype ThemeProviderProps = PropsWithChildren<Theming> & { className?: string };\n\n// RegEx to check for `np-theme-` class name\nconst themeClass = /\\bnp-theme-[a-z-]+\\b/g;\n\nexport const ThemeProvider = ({\n theme = DEFAULT_BASE_THEME,\n screenMode = DEFAULT_SCREEN_MODE,\n isNotRootProvider = false,\n children,\n className = undefined,\n}: ThemeProviderProps) => {\n const isContextRoot = useContext(ThemeContext) === undefined;\n\n // useEffect hook used to apply the theme class to the HTML element\n useEffect(() => {\n if (!isNotRootProvider && isContextRoot) {\n // Remove all the theme classes from the documentElement\n document.documentElement.className.match(themeClass)?.forEach((item) => {\n document.documentElement.classList.remove(item);\n });\n getThemeClassName(theme, screenMode)\n .split(' ')\n .forEach((item) => {\n document.documentElement.classList.add(item);\n });\n }\n }, [isNotRootProvider, isContextRoot, theme, screenMode]);\n\n const contextValue = useMemo(() => ({ theme, screenMode }), [screenMode, theme]);\n\n return (\n <ThemeContext.Provider value={contextValue}>\n <ThemedChildren className={className}>{children}</ThemedChildren>\n </ThemeContext.Provider>\n );\n};\n"],"names":["themeClass","ThemeProvider","theme","DEFAULT_BASE_THEME","screenMode","DEFAULT_SCREEN_MODE","isNotRootProvider","children","className","undefined","isContextRoot","useContext","ThemeContext","useEffect","document","documentElement","match","forEach","item","classList","remove","getThemeClassName","split","add","contextValue","useMemo","_jsx","Provider","value","ThemedChildren"],"mappings":";;;;;;;;;AAWA,MAAMA,UAAU,GAAG,uBAAuB;AAEnC,MAAMC,aAAa,GAAGA,CAAC;AAC5BC,EAAAA,KAAK,GAAGC,yBAAkB;AAC1BC,EAAAA,UAAU,GAAGC,0BAAmB;AAChCC,EAAAA,iBAAiB,GAAG,KAAK;EACzBC,QAAQ;AACRC,EAAAA,SAAS,GAAGC;AAAS,CACF,KAAI;AACvB,EAAA,MAAMC,aAAa,GAAGC,gBAAU,CAACC,iCAAY,CAAC,KAAKH,SAAS;AAE5D;AACAI,EAAAA,eAAS,CAAC,MAAK;AACb,IAAA,IAAI,CAACP,iBAAiB,IAAII,aAAa,EAAE;AACvC;AACAI,MAAAA,QAAQ,CAACC,eAAe,CAACP,SAAS,CAACQ,KAAK,CAAChB,UAAU,CAAC,EAAEiB,OAAO,CAAEC,IAAI,IAAI;QACrEJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACC,MAAM,CAACF,IAAI,CAAC;AACjD,MAAA,CAAC,CAAC;AACFG,MAAAA,yBAAiB,CAACnB,KAAK,EAAEE,UAAU,CAAC,CACjCkB,KAAK,CAAC,GAAG,CAAC,CACVL,OAAO,CAAEC,IAAI,IAAI;QAChBJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACI,GAAG,CAACL,IAAI,CAAC;AAC9C,MAAA,CAAC,CAAC;AACN,IAAA;EACF,CAAC,EAAE,CAACZ,iBAAiB,EAAEI,aAAa,EAAER,KAAK,EAAEE,UAAU,CAAC,CAAC;AAEzD,EAAA,MAAMoB,YAAY,GAAGC,aAAO,CAAC,OAAO;IAAEvB,KAAK;AAAEE,IAAAA;AAAU,GAAE,CAAC,EAAE,CAACA,UAAU,EAAEF,KAAK,CAAC,CAAC;AAEhF,EAAA,oBACEwB,cAAA,CAACd,iCAAY,CAACe,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEJ,YAAa;IAAAjB,QAAA,eACzCmB,cAAA,CAACG,6BAAc,EAAA;AAACrB,MAAAA,SAAS,EAAEA,SAAU;AAAAD,MAAAA,QAAA,EAAEA;KAAyB;AAClE,GAAuB,CAAC;AAE5B;;;;"}
1
+ {"version":3,"file":"ThemeProvider.js","sources":["../src/ThemeProvider.tsx"],"sourcesContent":["import { PropsWithChildren, useContext, useEffect, useMemo, useState } from 'react';\n\nimport { ThemedChildren } from './ThemedChildren';\nimport type { Theming } from './const';\nimport { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const';\nimport { getThemeClassName } from './helpers';\nimport { ThemeContext } from './ThemeProviderContext';\n\ntype ThemeProviderProps = PropsWithChildren<Theming> & { className?: string };\n\n// RegEx to check for `np-theme-` class name\nconst themeClass = /\\bnp-theme-[a-z-]+\\b/g;\n\nexport const ThemeProvider = ({\n theme: initialTheme = DEFAULT_BASE_THEME,\n screenMode: initialScreenMode = DEFAULT_SCREEN_MODE,\n isNotRootProvider = false,\n children,\n className = undefined,\n}: ThemeProviderProps) => {\n const isContextRoot = useContext(ThemeContext) === undefined;\n const [theme, setTheme] = useState(initialTheme);\n const [screenMode, setScreenMode] = useState(initialScreenMode);\n\n // Update state when props change (for controlled usage)\n useEffect(() => {\n setTheme(initialTheme);\n }, [initialTheme]);\n\n useEffect(() => {\n setScreenMode(initialScreenMode);\n }, [initialScreenMode]);\n\n // useEffect hook used to apply the theme class to the HTML element\n useEffect(() => {\n if (!isNotRootProvider && isContextRoot) {\n // Remove all the theme classes from the documentElement\n document.documentElement.className.match(themeClass)?.forEach((item) => {\n document.documentElement.classList.remove(item);\n });\n getThemeClassName(theme, screenMode)\n .split(' ')\n .forEach((item) => {\n document.documentElement.classList.add(item);\n });\n }\n }, [isNotRootProvider, isContextRoot, theme, screenMode]);\n\n const contextValue = useMemo(\n () => ({ theme, screenMode, setTheme, setScreenMode }),\n [theme, screenMode],\n );\n\n return (\n <ThemeContext.Provider value={contextValue}>\n <ThemedChildren className={className}>{children}</ThemedChildren>\n </ThemeContext.Provider>\n );\n};\n"],"names":["themeClass","ThemeProvider","theme","initialTheme","DEFAULT_BASE_THEME","screenMode","initialScreenMode","DEFAULT_SCREEN_MODE","isNotRootProvider","children","className","undefined","isContextRoot","useContext","ThemeContext","setTheme","useState","setScreenMode","useEffect","document","documentElement","match","forEach","item","classList","remove","getThemeClassName","split","add","contextValue","useMemo","_jsx","Provider","value","ThemedChildren"],"mappings":";;;;;;;;;AAWA,MAAMA,UAAU,GAAG,uBAAuB;AAEnC,MAAMC,aAAa,GAAGA,CAAC;EAC5BC,KAAK,EAAEC,YAAY,GAAGC,yBAAkB;EACxCC,UAAU,EAAEC,iBAAiB,GAAGC,0BAAmB;AACnDC,EAAAA,iBAAiB,GAAG,KAAK;EACzBC,QAAQ;AACRC,EAAAA,SAAS,GAAGC;AAAS,CACF,KAAI;AACvB,EAAA,MAAMC,aAAa,GAAGC,gBAAU,CAACC,iCAAY,CAAC,KAAKH,SAAS;EAC5D,MAAM,CAACT,KAAK,EAAEa,QAAQ,CAAC,GAAGC,cAAQ,CAACb,YAAY,CAAC;EAChD,MAAM,CAACE,UAAU,EAAEY,aAAa,CAAC,GAAGD,cAAQ,CAACV,iBAAiB,CAAC;AAE/D;AACAY,EAAAA,eAAS,CAAC,MAAK;IACbH,QAAQ,CAACZ,YAAY,CAAC;AACxB,EAAA,CAAC,EAAE,CAACA,YAAY,CAAC,CAAC;AAElBe,EAAAA,eAAS,CAAC,MAAK;IACbD,aAAa,CAACX,iBAAiB,CAAC;AAClC,EAAA,CAAC,EAAE,CAACA,iBAAiB,CAAC,CAAC;AAEvB;AACAY,EAAAA,eAAS,CAAC,MAAK;AACb,IAAA,IAAI,CAACV,iBAAiB,IAAII,aAAa,EAAE;AACvC;AACAO,MAAAA,QAAQ,CAACC,eAAe,CAACV,SAAS,CAACW,KAAK,CAACrB,UAAU,CAAC,EAAEsB,OAAO,CAAEC,IAAI,IAAI;QACrEJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACC,MAAM,CAACF,IAAI,CAAC;AACjD,MAAA,CAAC,CAAC;AACFG,MAAAA,yBAAiB,CAACxB,KAAK,EAAEG,UAAU,CAAC,CACjCsB,KAAK,CAAC,GAAG,CAAC,CACVL,OAAO,CAAEC,IAAI,IAAI;QAChBJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACI,GAAG,CAACL,IAAI,CAAC;AAC9C,MAAA,CAAC,CAAC;AACN,IAAA;EACF,CAAC,EAAE,CAACf,iBAAiB,EAAEI,aAAa,EAAEV,KAAK,EAAEG,UAAU,CAAC,CAAC;AAEzD,EAAA,MAAMwB,YAAY,GAAGC,aAAO,CAC1B,OAAO;IAAE5B,KAAK;IAAEG,UAAU;IAAEU,QAAQ;AAAEE,IAAAA;AAAa,GAAE,CAAC,EACtD,CAACf,KAAK,EAAEG,UAAU,CAAC,CACpB;AAED,EAAA,oBACE0B,cAAA,CAACjB,iCAAY,CAACkB,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEJ,YAAa;IAAApB,QAAA,eACzCsB,cAAA,CAACG,6BAAc,EAAA;AAACxB,MAAAA,SAAS,EAAEA,SAAU;AAAAD,MAAAA,QAAA,EAAEA;KAAyB;AAClE,GAAuB,CAAC;AAE5B;;;;"}
@@ -1,19 +1,28 @@
1
- import { useContext, useEffect, useMemo } from 'react';
1
+ import { useContext, useState, useEffect, useMemo } from 'react';
2
2
  import { ThemedChildren } from './ThemedChildren.mjs';
3
- import { DEFAULT_SCREEN_MODE, DEFAULT_BASE_THEME } from './const.mjs';
3
+ import { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const.mjs';
4
4
  import { getThemeClassName } from './helpers.mjs';
5
5
  import { ThemeContext } from './ThemeProviderContext.mjs';
6
6
  import { jsx } from 'react/jsx-runtime';
7
7
 
8
8
  const themeClass = /\bnp-theme-[a-z-]+\b/g;
9
9
  const ThemeProvider = ({
10
- theme = DEFAULT_BASE_THEME,
11
- screenMode = DEFAULT_SCREEN_MODE,
10
+ theme: initialTheme = DEFAULT_BASE_THEME,
11
+ screenMode: initialScreenMode = DEFAULT_SCREEN_MODE,
12
12
  isNotRootProvider = false,
13
13
  children,
14
14
  className = undefined
15
15
  }) => {
16
16
  const isContextRoot = useContext(ThemeContext) === undefined;
17
+ const [theme, setTheme] = useState(initialTheme);
18
+ const [screenMode, setScreenMode] = useState(initialScreenMode);
19
+ // Update state when props change (for controlled usage)
20
+ useEffect(() => {
21
+ setTheme(initialTheme);
22
+ }, [initialTheme]);
23
+ useEffect(() => {
24
+ setScreenMode(initialScreenMode);
25
+ }, [initialScreenMode]);
17
26
  // useEffect hook used to apply the theme class to the HTML element
18
27
  useEffect(() => {
19
28
  if (!isNotRootProvider && isContextRoot) {
@@ -28,8 +37,10 @@ const ThemeProvider = ({
28
37
  }, [isNotRootProvider, isContextRoot, theme, screenMode]);
29
38
  const contextValue = useMemo(() => ({
30
39
  theme,
31
- screenMode
32
- }), [screenMode, theme]);
40
+ screenMode,
41
+ setTheme,
42
+ setScreenMode
43
+ }), [theme, screenMode]);
33
44
  return /*#__PURE__*/jsx(ThemeContext.Provider, {
34
45
  value: contextValue,
35
46
  children: /*#__PURE__*/jsx(ThemedChildren, {
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.mjs","sources":["../src/ThemeProvider.tsx"],"sourcesContent":["import { PropsWithChildren, useContext, useEffect, useMemo } from 'react';\n\nimport { ThemedChildren } from './ThemedChildren';\nimport type { Theming } from './const';\nimport { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const';\nimport { getThemeClassName } from './helpers';\nimport { ThemeContext } from './ThemeProviderContext';\n\ntype ThemeProviderProps = PropsWithChildren<Theming> & { className?: string };\n\n// RegEx to check for `np-theme-` class name\nconst themeClass = /\\bnp-theme-[a-z-]+\\b/g;\n\nexport const ThemeProvider = ({\n theme = DEFAULT_BASE_THEME,\n screenMode = DEFAULT_SCREEN_MODE,\n isNotRootProvider = false,\n children,\n className = undefined,\n}: ThemeProviderProps) => {\n const isContextRoot = useContext(ThemeContext) === undefined;\n\n // useEffect hook used to apply the theme class to the HTML element\n useEffect(() => {\n if (!isNotRootProvider && isContextRoot) {\n // Remove all the theme classes from the documentElement\n document.documentElement.className.match(themeClass)?.forEach((item) => {\n document.documentElement.classList.remove(item);\n });\n getThemeClassName(theme, screenMode)\n .split(' ')\n .forEach((item) => {\n document.documentElement.classList.add(item);\n });\n }\n }, [isNotRootProvider, isContextRoot, theme, screenMode]);\n\n const contextValue = useMemo(() => ({ theme, screenMode }), [screenMode, theme]);\n\n return (\n <ThemeContext.Provider value={contextValue}>\n <ThemedChildren className={className}>{children}</ThemedChildren>\n </ThemeContext.Provider>\n );\n};\n"],"names":["themeClass","ThemeProvider","theme","DEFAULT_BASE_THEME","screenMode","DEFAULT_SCREEN_MODE","isNotRootProvider","children","className","undefined","isContextRoot","useContext","ThemeContext","useEffect","document","documentElement","match","forEach","item","classList","remove","getThemeClassName","split","add","contextValue","useMemo","_jsx","Provider","value","ThemedChildren"],"mappings":";;;;;;;AAWA,MAAMA,UAAU,GAAG,uBAAuB;AAEnC,MAAMC,aAAa,GAAGA,CAAC;AAC5BC,EAAAA,KAAK,GAAGC,kBAAkB;AAC1BC,EAAAA,UAAU,GAAGC,mBAAmB;AAChCC,EAAAA,iBAAiB,GAAG,KAAK;EACzBC,QAAQ;AACRC,EAAAA,SAAS,GAAGC;AAAS,CACF,KAAI;AACvB,EAAA,MAAMC,aAAa,GAAGC,UAAU,CAACC,YAAY,CAAC,KAAKH,SAAS;AAE5D;AACAI,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,IAAI,CAACP,iBAAiB,IAAII,aAAa,EAAE;AACvC;AACAI,MAAAA,QAAQ,CAACC,eAAe,CAACP,SAAS,CAACQ,KAAK,CAAChB,UAAU,CAAC,EAAEiB,OAAO,CAAEC,IAAI,IAAI;QACrEJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACC,MAAM,CAACF,IAAI,CAAC;AACjD,MAAA,CAAC,CAAC;AACFG,MAAAA,iBAAiB,CAACnB,KAAK,EAAEE,UAAU,CAAC,CACjCkB,KAAK,CAAC,GAAG,CAAC,CACVL,OAAO,CAAEC,IAAI,IAAI;QAChBJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACI,GAAG,CAACL,IAAI,CAAC;AAC9C,MAAA,CAAC,CAAC;AACN,IAAA;EACF,CAAC,EAAE,CAACZ,iBAAiB,EAAEI,aAAa,EAAER,KAAK,EAAEE,UAAU,CAAC,CAAC;AAEzD,EAAA,MAAMoB,YAAY,GAAGC,OAAO,CAAC,OAAO;IAAEvB,KAAK;AAAEE,IAAAA;AAAU,GAAE,CAAC,EAAE,CAACA,UAAU,EAAEF,KAAK,CAAC,CAAC;AAEhF,EAAA,oBACEwB,GAAA,CAACd,YAAY,CAACe,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEJ,YAAa;IAAAjB,QAAA,eACzCmB,GAAA,CAACG,cAAc,EAAA;AAACrB,MAAAA,SAAS,EAAEA,SAAU;AAAAD,MAAAA,QAAA,EAAEA;KAAyB;AAClE,GAAuB,CAAC;AAE5B;;;;"}
1
+ {"version":3,"file":"ThemeProvider.mjs","sources":["../src/ThemeProvider.tsx"],"sourcesContent":["import { PropsWithChildren, useContext, useEffect, useMemo, useState } from 'react';\n\nimport { ThemedChildren } from './ThemedChildren';\nimport type { Theming } from './const';\nimport { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const';\nimport { getThemeClassName } from './helpers';\nimport { ThemeContext } from './ThemeProviderContext';\n\ntype ThemeProviderProps = PropsWithChildren<Theming> & { className?: string };\n\n// RegEx to check for `np-theme-` class name\nconst themeClass = /\\bnp-theme-[a-z-]+\\b/g;\n\nexport const ThemeProvider = ({\n theme: initialTheme = DEFAULT_BASE_THEME,\n screenMode: initialScreenMode = DEFAULT_SCREEN_MODE,\n isNotRootProvider = false,\n children,\n className = undefined,\n}: ThemeProviderProps) => {\n const isContextRoot = useContext(ThemeContext) === undefined;\n const [theme, setTheme] = useState(initialTheme);\n const [screenMode, setScreenMode] = useState(initialScreenMode);\n\n // Update state when props change (for controlled usage)\n useEffect(() => {\n setTheme(initialTheme);\n }, [initialTheme]);\n\n useEffect(() => {\n setScreenMode(initialScreenMode);\n }, [initialScreenMode]);\n\n // useEffect hook used to apply the theme class to the HTML element\n useEffect(() => {\n if (!isNotRootProvider && isContextRoot) {\n // Remove all the theme classes from the documentElement\n document.documentElement.className.match(themeClass)?.forEach((item) => {\n document.documentElement.classList.remove(item);\n });\n getThemeClassName(theme, screenMode)\n .split(' ')\n .forEach((item) => {\n document.documentElement.classList.add(item);\n });\n }\n }, [isNotRootProvider, isContextRoot, theme, screenMode]);\n\n const contextValue = useMemo(\n () => ({ theme, screenMode, setTheme, setScreenMode }),\n [theme, screenMode],\n );\n\n return (\n <ThemeContext.Provider value={contextValue}>\n <ThemedChildren className={className}>{children}</ThemedChildren>\n </ThemeContext.Provider>\n );\n};\n"],"names":["themeClass","ThemeProvider","theme","initialTheme","DEFAULT_BASE_THEME","screenMode","initialScreenMode","DEFAULT_SCREEN_MODE","isNotRootProvider","children","className","undefined","isContextRoot","useContext","ThemeContext","setTheme","useState","setScreenMode","useEffect","document","documentElement","match","forEach","item","classList","remove","getThemeClassName","split","add","contextValue","useMemo","_jsx","Provider","value","ThemedChildren"],"mappings":";;;;;;;AAWA,MAAMA,UAAU,GAAG,uBAAuB;AAEnC,MAAMC,aAAa,GAAGA,CAAC;EAC5BC,KAAK,EAAEC,YAAY,GAAGC,kBAAkB;EACxCC,UAAU,EAAEC,iBAAiB,GAAGC,mBAAmB;AACnDC,EAAAA,iBAAiB,GAAG,KAAK;EACzBC,QAAQ;AACRC,EAAAA,SAAS,GAAGC;AAAS,CACF,KAAI;AACvB,EAAA,MAAMC,aAAa,GAAGC,UAAU,CAACC,YAAY,CAAC,KAAKH,SAAS;EAC5D,MAAM,CAACT,KAAK,EAAEa,QAAQ,CAAC,GAAGC,QAAQ,CAACb,YAAY,CAAC;EAChD,MAAM,CAACE,UAAU,EAAEY,aAAa,CAAC,GAAGD,QAAQ,CAACV,iBAAiB,CAAC;AAE/D;AACAY,EAAAA,SAAS,CAAC,MAAK;IACbH,QAAQ,CAACZ,YAAY,CAAC;AACxB,EAAA,CAAC,EAAE,CAACA,YAAY,CAAC,CAAC;AAElBe,EAAAA,SAAS,CAAC,MAAK;IACbD,aAAa,CAACX,iBAAiB,CAAC;AAClC,EAAA,CAAC,EAAE,CAACA,iBAAiB,CAAC,CAAC;AAEvB;AACAY,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,IAAI,CAACV,iBAAiB,IAAII,aAAa,EAAE;AACvC;AACAO,MAAAA,QAAQ,CAACC,eAAe,CAACV,SAAS,CAACW,KAAK,CAACrB,UAAU,CAAC,EAAEsB,OAAO,CAAEC,IAAI,IAAI;QACrEJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACC,MAAM,CAACF,IAAI,CAAC;AACjD,MAAA,CAAC,CAAC;AACFG,MAAAA,iBAAiB,CAACxB,KAAK,EAAEG,UAAU,CAAC,CACjCsB,KAAK,CAAC,GAAG,CAAC,CACVL,OAAO,CAAEC,IAAI,IAAI;QAChBJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACI,GAAG,CAACL,IAAI,CAAC;AAC9C,MAAA,CAAC,CAAC;AACN,IAAA;EACF,CAAC,EAAE,CAACf,iBAAiB,EAAEI,aAAa,EAAEV,KAAK,EAAEG,UAAU,CAAC,CAAC;AAEzD,EAAA,MAAMwB,YAAY,GAAGC,OAAO,CAC1B,OAAO;IAAE5B,KAAK;IAAEG,UAAU;IAAEU,QAAQ;AAAEE,IAAAA;AAAa,GAAE,CAAC,EACtD,CAACf,KAAK,EAAEG,UAAU,CAAC,CACpB;AAED,EAAA,oBACE0B,GAAA,CAACjB,YAAY,CAACkB,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEJ,YAAa;IAAApB,QAAA,eACzCsB,GAAA,CAACG,cAAc,EAAA;AAACxB,MAAAA,SAAS,EAAEA,SAAU;AAAAD,MAAAA,QAAA,EAAEA;KAAyB;AAClE,GAAuB,CAAC;AAE5B;;;;"}
@@ -2,5 +2,7 @@ import type { ScreenMode, Theming } from './const';
2
2
  export declare const ThemeContext: import("react").Context<{
3
3
  theme: NonNullable<Theming["theme"]>;
4
4
  screenMode: ScreenMode;
5
+ setTheme: (theme: NonNullable<Theming["theme"]>) => void;
6
+ setScreenMode: (screenMode: ScreenMode) => void;
5
7
  } | undefined>;
6
8
  //# sourceMappingURL=ThemeProviderContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProviderContext.d.ts","sourceRoot":"","sources":["../src/ThemeProviderContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEnD,eAAO,MAAM,YAAY;WAEZ,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBACxB,UAAU;cAGhB,CAAC"}
1
+ {"version":3,"file":"ThemeProviderContext.d.ts","sourceRoot":"","sources":["../src/ThemeProviderContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEnD,eAAO,MAAM,YAAY;WAEZ,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBACxB,UAAU;cACZ,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI;mBACzC,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI;cAGzC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProviderContext.js","sources":["../src/ThemeProviderContext.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport type { ScreenMode, Theming } from './const';\n\nexport const ThemeContext = createContext<\n | {\n theme: NonNullable<Theming['theme']>;\n screenMode: ScreenMode;\n }\n | undefined\n>(undefined);\n"],"names":["ThemeContext","createContext","undefined"],"mappings":";;;;MAGaA,YAAY,gBAAGC,mBAAa,CAMvCC,SAAS;;;;"}
1
+ {"version":3,"file":"ThemeProviderContext.js","sources":["../src/ThemeProviderContext.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport type { ScreenMode, Theming } from './const';\n\nexport const ThemeContext = createContext<\n | {\n theme: NonNullable<Theming['theme']>;\n screenMode: ScreenMode;\n setTheme: (theme: NonNullable<Theming['theme']>) => void;\n setScreenMode: (screenMode: ScreenMode) => void;\n }\n | undefined\n>(undefined);\n"],"names":["ThemeContext","createContext","undefined"],"mappings":";;;;MAGaA,YAAY,gBAAGC,mBAAa,CAQvCC,SAAS;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProviderContext.mjs","sources":["../src/ThemeProviderContext.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport type { ScreenMode, Theming } from './const';\n\nexport const ThemeContext = createContext<\n | {\n theme: NonNullable<Theming['theme']>;\n screenMode: ScreenMode;\n }\n | undefined\n>(undefined);\n"],"names":["ThemeContext","createContext","undefined"],"mappings":";;MAGaA,YAAY,gBAAGC,aAAa,CAMvCC,SAAS;;;;"}
1
+ {"version":3,"file":"ThemeProviderContext.mjs","sources":["../src/ThemeProviderContext.tsx"],"sourcesContent":["import { createContext } from 'react';\nimport type { ScreenMode, Theming } from './const';\n\nexport const ThemeContext = createContext<\n | {\n theme: NonNullable<Theming['theme']>;\n screenMode: ScreenMode;\n setTheme: (theme: NonNullable<Theming['theme']>) => void;\n setScreenMode: (screenMode: ScreenMode) => void;\n }\n | undefined\n>(undefined);\n"],"names":["ThemeContext","createContext","undefined"],"mappings":";;MAGaA,YAAY,gBAAGC,aAAa,CAQvCC,SAAS;;;;"}
package/dist/const.js CHANGED
@@ -5,14 +5,12 @@ const baseThemes = ['light', 'personal', 'business'];
5
5
  const extraThemes = ['forest-green', 'bright-green'];
6
6
  const screenModes = ['light', 'dark'];
7
7
  const modernThemes = [baseThemes[1], baseThemes[2], ...extraThemes];
8
- const businessThemes = ['business', 'business--forest-green', 'business--bright-green'];
9
8
  const DEFAULT_BASE_THEME = 'light';
10
9
  const DEFAULT_SCREEN_MODE = 'light';
11
10
 
12
11
  exports.DEFAULT_BASE_THEME = DEFAULT_BASE_THEME;
13
12
  exports.DEFAULT_SCREEN_MODE = DEFAULT_SCREEN_MODE;
14
13
  exports.baseThemes = baseThemes;
15
- exports.businessThemes = businessThemes;
16
14
  exports.extraThemes = extraThemes;
17
15
  exports.modernThemes = modernThemes;
18
16
  exports.screenModes = screenModes;
package/dist/const.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"const.js","sources":["../src/const.ts"],"sourcesContent":["// TODO: Change 'light' with 'legacy' in the future\nexport const baseThemes = ['light', 'personal', 'business'] as const;\nexport const extraThemes = ['forest-green', 'bright-green'] as const;\nexport const screenModes = ['light', 'dark'] as const;\nexport const modernThemes = [baseThemes[1], baseThemes[2], ...extraThemes] as const;\nexport const businessThemes = [\n 'business',\n 'business--forest-green',\n 'business--bright-green',\n] as const;\nexport const platformThemes = ['platform', 'platform--forest-green'] as const;\n\n// TODO: componentThemes returned back for backward compatibility, refactor this place in the future\nexport type ComponentTheme = (typeof baseThemes)[number];\nexport type ModernTheme = (typeof modernThemes)[number];\nexport type BaseTheme = (typeof baseThemes)[number];\nexport type ExtraTheme = (typeof extraThemes)[number];\nexport type ForestGreenTheme = (typeof extraThemes)[0];\nexport type ScreenMode = (typeof screenModes)[number];\nexport type ScreenModeDark = (typeof screenModes)[1];\nexport type PlatformTheme = (typeof platformThemes)[0];\nexport type PlatformForestGreenTheme = (typeof platformThemes)[1];\nexport type BusinessTheme = (typeof businessThemes)[0];\nexport type BusinessForestGreenTheme = (typeof businessThemes)[1];\nexport type BusinessBrightGreenTheme = (typeof businessThemes)[2];\n\nexport const DEFAULT_BASE_THEME = 'light';\nexport const DEFAULT_SCREEN_MODE = 'light';\n\nexport type Theming = {\n theme?:\n | ComponentTheme\n | BaseTheme\n | ExtraTheme\n | BusinessTheme\n | BusinessForestGreenTheme\n | BusinessBrightGreenTheme\n | PlatformTheme\n | PlatformForestGreenTheme;\n screenMode?: ScreenMode;\n isNotRootProvider?: boolean | undefined;\n};\n"],"names":["baseThemes","extraThemes","screenModes","modernThemes","businessThemes","DEFAULT_BASE_THEME","DEFAULT_SCREEN_MODE"],"mappings":";;AAAA;AACO,MAAMA,UAAU,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU;MAC7CC,WAAW,GAAG,CAAC,cAAc,EAAE,cAAc;MAC7CC,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM;MAC9BC,YAAY,GAAG,CAACH,UAAU,CAAC,CAAC,CAAC,EAAEA,UAAU,CAAC,CAAC,CAAC,EAAE,GAAGC,WAAW;AAClE,MAAMG,cAAc,GAAG,CAC5B,UAAU,EACV,wBAAwB,EACxB,wBAAwB;AAkBnB,MAAMC,kBAAkB,GAAG;AAC3B,MAAMC,mBAAmB,GAAG;;;;;;;;;;"}
1
+ {"version":3,"file":"const.js","sources":["../src/const.ts"],"sourcesContent":["// TODO: Change 'light' with 'legacy' in the future\nexport const baseThemes = ['light', 'personal', 'business'] as const;\nexport const extraThemes = ['forest-green', 'bright-green'] as const;\nexport const screenModes = ['light', 'dark'] as const;\nexport const modernThemes = [baseThemes[1], baseThemes[2], ...extraThemes] as const;\nexport const businessThemes = [\n 'business',\n 'business--forest-green',\n 'business--bright-green',\n] as const;\nexport const platformThemes = ['platform', 'platform--forest-green'] as const;\n\n// TODO: componentThemes returned back for backward compatibility, refactor this place in the future\nexport type ComponentTheme = (typeof baseThemes)[number];\nexport type ModernTheme = (typeof modernThemes)[number];\nexport type BaseTheme = (typeof baseThemes)[number];\nexport type ExtraTheme = (typeof extraThemes)[number];\nexport type ForestGreenTheme = (typeof extraThemes)[0];\nexport type ScreenMode = (typeof screenModes)[number];\nexport type ScreenModeDark = (typeof screenModes)[1];\nexport type PlatformTheme = (typeof platformThemes)[0];\nexport type PlatformForestGreenTheme = (typeof platformThemes)[1];\nexport type BusinessTheme = (typeof businessThemes)[0];\nexport type BusinessForestGreenTheme = (typeof businessThemes)[1];\nexport type BusinessBrightGreenTheme = (typeof businessThemes)[2];\n\nexport const DEFAULT_BASE_THEME = 'light';\nexport const DEFAULT_SCREEN_MODE = 'light';\n\nexport type Theming = {\n theme?:\n | ComponentTheme\n | BaseTheme\n | ExtraTheme\n | BusinessTheme\n | BusinessForestGreenTheme\n | BusinessBrightGreenTheme\n | PlatformTheme\n | PlatformForestGreenTheme;\n screenMode?: ScreenMode;\n isNotRootProvider?: boolean | undefined;\n};\n"],"names":["baseThemes","extraThemes","screenModes","modernThemes","DEFAULT_BASE_THEME","DEFAULT_SCREEN_MODE"],"mappings":";;AAAA;AACO,MAAMA,UAAU,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU;MAC7CC,WAAW,GAAG,CAAC,cAAc,EAAE,cAAc;MAC7CC,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM;MAC9BC,YAAY,GAAG,CAACH,UAAU,CAAC,CAAC,CAAC,EAAEA,UAAU,CAAC,CAAC,CAAC,EAAE,GAAGC,WAAW;AAsBlE,MAAMG,kBAAkB,GAAG;AAC3B,MAAMC,mBAAmB,GAAG;;;;;;;;;"}
package/dist/const.mjs CHANGED
@@ -3,9 +3,8 @@ const baseThemes = ['light', 'personal', 'business'];
3
3
  const extraThemes = ['forest-green', 'bright-green'];
4
4
  const screenModes = ['light', 'dark'];
5
5
  const modernThemes = [baseThemes[1], baseThemes[2], ...extraThemes];
6
- const businessThemes = ['business', 'business--forest-green', 'business--bright-green'];
7
6
  const DEFAULT_BASE_THEME = 'light';
8
7
  const DEFAULT_SCREEN_MODE = 'light';
9
8
 
10
- export { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE, baseThemes, businessThemes, extraThemes, modernThemes, screenModes };
9
+ export { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE, baseThemes, extraThemes, modernThemes, screenModes };
11
10
  //# sourceMappingURL=const.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"const.mjs","sources":["../src/const.ts"],"sourcesContent":["// TODO: Change 'light' with 'legacy' in the future\nexport const baseThemes = ['light', 'personal', 'business'] as const;\nexport const extraThemes = ['forest-green', 'bright-green'] as const;\nexport const screenModes = ['light', 'dark'] as const;\nexport const modernThemes = [baseThemes[1], baseThemes[2], ...extraThemes] as const;\nexport const businessThemes = [\n 'business',\n 'business--forest-green',\n 'business--bright-green',\n] as const;\nexport const platformThemes = ['platform', 'platform--forest-green'] as const;\n\n// TODO: componentThemes returned back for backward compatibility, refactor this place in the future\nexport type ComponentTheme = (typeof baseThemes)[number];\nexport type ModernTheme = (typeof modernThemes)[number];\nexport type BaseTheme = (typeof baseThemes)[number];\nexport type ExtraTheme = (typeof extraThemes)[number];\nexport type ForestGreenTheme = (typeof extraThemes)[0];\nexport type ScreenMode = (typeof screenModes)[number];\nexport type ScreenModeDark = (typeof screenModes)[1];\nexport type PlatformTheme = (typeof platformThemes)[0];\nexport type PlatformForestGreenTheme = (typeof platformThemes)[1];\nexport type BusinessTheme = (typeof businessThemes)[0];\nexport type BusinessForestGreenTheme = (typeof businessThemes)[1];\nexport type BusinessBrightGreenTheme = (typeof businessThemes)[2];\n\nexport const DEFAULT_BASE_THEME = 'light';\nexport const DEFAULT_SCREEN_MODE = 'light';\n\nexport type Theming = {\n theme?:\n | ComponentTheme\n | BaseTheme\n | ExtraTheme\n | BusinessTheme\n | BusinessForestGreenTheme\n | BusinessBrightGreenTheme\n | PlatformTheme\n | PlatformForestGreenTheme;\n screenMode?: ScreenMode;\n isNotRootProvider?: boolean | undefined;\n};\n"],"names":["baseThemes","extraThemes","screenModes","modernThemes","businessThemes","DEFAULT_BASE_THEME","DEFAULT_SCREEN_MODE"],"mappings":"AAAA;AACO,MAAMA,UAAU,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU;MAC7CC,WAAW,GAAG,CAAC,cAAc,EAAE,cAAc;MAC7CC,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM;MAC9BC,YAAY,GAAG,CAACH,UAAU,CAAC,CAAC,CAAC,EAAEA,UAAU,CAAC,CAAC,CAAC,EAAE,GAAGC,WAAW;AAClE,MAAMG,cAAc,GAAG,CAC5B,UAAU,EACV,wBAAwB,EACxB,wBAAwB;AAkBnB,MAAMC,kBAAkB,GAAG;AAC3B,MAAMC,mBAAmB,GAAG;;;;"}
1
+ {"version":3,"file":"const.mjs","sources":["../src/const.ts"],"sourcesContent":["// TODO: Change 'light' with 'legacy' in the future\nexport const baseThemes = ['light', 'personal', 'business'] as const;\nexport const extraThemes = ['forest-green', 'bright-green'] as const;\nexport const screenModes = ['light', 'dark'] as const;\nexport const modernThemes = [baseThemes[1], baseThemes[2], ...extraThemes] as const;\nexport const businessThemes = [\n 'business',\n 'business--forest-green',\n 'business--bright-green',\n] as const;\nexport const platformThemes = ['platform', 'platform--forest-green'] as const;\n\n// TODO: componentThemes returned back for backward compatibility, refactor this place in the future\nexport type ComponentTheme = (typeof baseThemes)[number];\nexport type ModernTheme = (typeof modernThemes)[number];\nexport type BaseTheme = (typeof baseThemes)[number];\nexport type ExtraTheme = (typeof extraThemes)[number];\nexport type ForestGreenTheme = (typeof extraThemes)[0];\nexport type ScreenMode = (typeof screenModes)[number];\nexport type ScreenModeDark = (typeof screenModes)[1];\nexport type PlatformTheme = (typeof platformThemes)[0];\nexport type PlatformForestGreenTheme = (typeof platformThemes)[1];\nexport type BusinessTheme = (typeof businessThemes)[0];\nexport type BusinessForestGreenTheme = (typeof businessThemes)[1];\nexport type BusinessBrightGreenTheme = (typeof businessThemes)[2];\n\nexport const DEFAULT_BASE_THEME = 'light';\nexport const DEFAULT_SCREEN_MODE = 'light';\n\nexport type Theming = {\n theme?:\n | ComponentTheme\n | BaseTheme\n | ExtraTheme\n | BusinessTheme\n | BusinessForestGreenTheme\n | BusinessBrightGreenTheme\n | PlatformTheme\n | PlatformForestGreenTheme;\n screenMode?: ScreenMode;\n isNotRootProvider?: boolean | undefined;\n};\n"],"names":["baseThemes","extraThemes","screenModes","modernThemes","DEFAULT_BASE_THEME","DEFAULT_SCREEN_MODE"],"mappings":"AAAA;AACO,MAAMA,UAAU,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU;MAC7CC,WAAW,GAAG,CAAC,cAAc,EAAE,cAAc;MAC7CC,WAAW,GAAG,CAAC,OAAO,EAAE,MAAM;MAC9BC,YAAY,GAAG,CAACH,UAAU,CAAC,CAAC,CAAC,EAAEA,UAAU,CAAC,CAAC,CAAC,EAAE,GAAGC,WAAW;AAsBlE,MAAMG,kBAAkB,GAAG;AAC3B,MAAMC,mBAAmB,GAAG;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,OAAO,EACR,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,aAAa,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAG,KAAK,IAAI,WACjC,CAAC;AAE9C,eAAO,MAAM,YAAY,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAG,KAAK,IAAI,UAClC,CAAC;AAE5C,eAAO,MAAM,kBAAkB,GAC7B,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KACnC,KAAK,IAAI,gBAA4C,CAAC;AAEzD,eAAO,MAAM,gBAAgB,GAC3B,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EACpC,YAAY,UAAU,KACrB,UAAU,IAAI,cACqD,CAAC;AAEvE,eAAO,MAAM,iBAAiB,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,YAAY,UAAU,WAwC7F,CAAC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,OAAO,EACR,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,aAAa,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAG,KAAK,IAAI,WACjC,CAAC;AAE9C,eAAO,MAAM,YAAY,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAG,KAAK,IAAI,UAClC,CAAC;AAE5C,eAAO,MAAM,kBAAkB,GAC7B,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KACnC,KAAK,IAAI,gBAA4C,CAAC;AAEzD,eAAO,MAAM,gBAAgB,GAC3B,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EACpC,YAAY,UAAU,KACrB,UAAU,IAAI,cACqD,CAAC;AAEvE,eAAO,MAAM,iBAAiB,GAAI,OAAO,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,YAAY,UAAU,WAuC7F,CAAC"}
package/dist/helpers.js CHANGED
@@ -7,37 +7,37 @@ const isExtraTheme = theme => _const.extraThemes.includes(theme);
7
7
  const isForestGreenTheme = theme => theme === _const.extraThemes[0];
8
8
  const isScreenModeDark = (theme, screenMode) => isThemeModern(theme) && _const.screenModes[1] === screenMode;
9
9
  const getThemeClassName = (theme, screenMode) => {
10
- // Legacy themes
11
- if (theme === 'light') {
10
+ if (['light'].includes(theme)) {
12
11
  return `np-theme-${theme}`;
13
12
  }
14
13
  // Personal light is always there by default
15
14
  const themeClasses = ['np-theme-personal'];
15
+ /* eslint-disable functional/immutable-data */
16
16
  // Personal dark theme
17
- if (theme === 'personal' && _const.screenModes[1] === screenMode) {
17
+ if (theme === 'personal' && screenMode === 'dark') {
18
18
  themeClasses.push(`np-theme-personal--${screenMode}`);
19
19
  }
20
20
  // Personal forest-green and bright-green themes
21
- else if (isExtraTheme(theme)) {
21
+ else if (['forest-green', 'bright-green'].includes(theme)) {
22
22
  themeClasses.push(`np-theme-personal--${theme}`);
23
23
  }
24
24
  // Business light
25
- else if (_const.businessThemes[0] === theme) {
25
+ else if (theme === 'business') {
26
26
  themeClasses.push(`np-theme-business`);
27
27
  // Business dark theme
28
- if (_const.screenModes[1] === screenMode) {
28
+ if (screenMode === 'dark') {
29
29
  themeClasses.push(`np-theme-business--${screenMode}`);
30
30
  }
31
31
  }
32
32
  // Business forest-green and bright-green themes
33
- // @ts-expect-error relax TS
34
- else if ([_const.businessThemes[1], _const.businessThemes[2]].includes(theme)) {
33
+ else if (['business--forest-green', 'business--bright-green'].includes(theme)) {
35
34
  themeClasses.push(`np-theme-${theme}`);
36
35
  }
37
36
  // Platform themes
38
37
  else if (theme.startsWith('platform')) {
39
38
  themeClasses.push(`np-theme-${theme}`);
40
39
  }
40
+ /* eslint-enable functional/immutable-data */
41
41
  return themeClasses.join(' ');
42
42
  };
43
43
 
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sources":["../src/helpers.ts"],"sourcesContent":["/* eslint-disable functional/immutable-data */\nimport type {\n ModernTheme,\n ExtraTheme,\n ForestGreenTheme,\n ScreenMode,\n ScreenModeDark,\n Theming,\n} from './const';\nimport { extraThemes, screenModes, modernThemes, businessThemes } from './const';\n\nexport const isThemeModern = (theme: NonNullable<Theming['theme']>): theme is ModernTheme =>\n modernThemes.includes(theme as ModernTheme);\n\nexport const isExtraTheme = (theme: NonNullable<Theming['theme']>): theme is ExtraTheme =>\n extraThemes.includes(theme as ExtraTheme);\n\nexport const isForestGreenTheme = (\n theme: NonNullable<Theming['theme']>,\n): theme is ForestGreenTheme => theme === extraThemes[0];\n\nexport const isScreenModeDark = (\n theme: NonNullable<Theming['theme']>,\n screenMode: ScreenMode,\n): screenMode is ScreenModeDark =>\n isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;\n\nexport const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMode: ScreenMode) => {\n // Legacy themes\n if (theme === 'light') {\n return `np-theme-${theme}`;\n }\n\n // Personal light is always there by default\n const themeClasses = ['np-theme-personal'];\n\n // Personal dark theme\n if (theme === 'personal' && screenModes[1] === screenMode) {\n themeClasses.push(`np-theme-personal--${screenMode}`);\n }\n\n // Personal forest-green and bright-green themes\n else if (isExtraTheme(theme)) {\n themeClasses.push(`np-theme-personal--${theme}`);\n }\n\n // Business light\n else if (businessThemes[0] === theme) {\n themeClasses.push(`np-theme-business`);\n // Business dark theme\n if (screenModes[1] === screenMode) {\n themeClasses.push(`np-theme-business--${screenMode}`);\n }\n }\n\n // Business forest-green and bright-green themes\n // @ts-expect-error relax TS\n else if ([businessThemes[1], businessThemes[2]].includes(theme)) {\n themeClasses.push(`np-theme-${theme}`);\n }\n\n // Platform themes\n else if (theme.startsWith('platform')) {\n themeClasses.push(`np-theme-${theme}`);\n }\n\n return themeClasses.join(' ');\n};\n"],"names":["isThemeModern","theme","modernThemes","includes","isExtraTheme","extraThemes","isForestGreenTheme","isScreenModeDark","screenMode","screenModes","getThemeClassName","themeClasses","push","businessThemes","startsWith","join"],"mappings":";;;;AAWO,MAAMA,aAAa,GAAIC,KAAoC,IAChEC,mBAAY,CAACC,QAAQ,CAACF,KAAoB;AAErC,MAAMG,YAAY,GAAIH,KAAoC,IAC/DI,kBAAW,CAACF,QAAQ,CAACF,KAAmB;AAEnC,MAAMK,kBAAkB,GAC7BL,KAAoC,IACNA,KAAK,KAAKI,kBAAW,CAAC,CAAC;MAE1CE,gBAAgB,GAAGA,CAC9BN,KAAoC,EACpCO,UAAsB,KAEtBR,aAAa,CAACC,KAAoB,CAAC,IAAIQ,kBAAW,CAAC,CAAC,CAAC,KAAKD;MAE/CE,iBAAiB,GAAGA,CAACT,KAAoC,EAAEO,UAAsB,KAAI;AAChG;EACA,IAAIP,KAAK,KAAK,OAAO,EAAE;IACrB,OAAO,CAAA,SAAA,EAAYA,KAAK,CAAA,CAAE;AAC5B,EAAA;AAEA;AACA,EAAA,MAAMU,YAAY,GAAG,CAAC,mBAAmB,CAAC;AAE1C;EACA,IAAIV,KAAK,KAAK,UAAU,IAAIQ,kBAAW,CAAC,CAAC,CAAC,KAAKD,UAAU,EAAE;AACzDG,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBJ,UAAU,EAAE,CAAC;AACvD,EAAA;AAEA;AAAA,OACK,IAAIJ,YAAY,CAACH,KAAK,CAAC,EAAE;AAC5BU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBX,KAAK,EAAE,CAAC;AAClD,EAAA;AAEA;AAAA,OACK,IAAIY,qBAAc,CAAC,CAAC,CAAC,KAAKZ,KAAK,EAAE;AACpCU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,iBAAA,CAAmB,CAAC;AACtC;AACA,IAAA,IAAIH,kBAAW,CAAC,CAAC,CAAC,KAAKD,UAAU,EAAE;AACjCG,MAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBJ,UAAU,EAAE,CAAC;AACvD,IAAA;AACF,EAAA;AAEA;AACA;AAAA,OACK,IAAI,CAACK,qBAAc,CAAC,CAAC,CAAC,EAAEA,qBAAc,CAAC,CAAC,CAAC,CAAC,CAACV,QAAQ,CAACF,KAAK,CAAC,EAAE;AAC/DU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AAEA;AAAA,OACK,IAAIA,KAAK,CAACa,UAAU,CAAC,UAAU,CAAC,EAAE;AACrCH,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AAEA,EAAA,OAAOU,YAAY,CAACI,IAAI,CAAC,GAAG,CAAC;AAC/B;;;;;;;;"}
1
+ {"version":3,"file":"helpers.js","sources":["../src/helpers.ts"],"sourcesContent":["import type {\n ModernTheme,\n ExtraTheme,\n ForestGreenTheme,\n ScreenMode,\n ScreenModeDark,\n Theming,\n} from './const';\nimport { extraThemes, screenModes, modernThemes } from './const';\n\nexport const isThemeModern = (theme: NonNullable<Theming['theme']>): theme is ModernTheme =>\n modernThemes.includes(theme as ModernTheme);\n\nexport const isExtraTheme = (theme: NonNullable<Theming['theme']>): theme is ExtraTheme =>\n extraThemes.includes(theme as ExtraTheme);\n\nexport const isForestGreenTheme = (\n theme: NonNullable<Theming['theme']>,\n): theme is ForestGreenTheme => theme === extraThemes[0];\n\nexport const isScreenModeDark = (\n theme: NonNullable<Theming['theme']>,\n screenMode: ScreenMode,\n): screenMode is ScreenModeDark =>\n isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;\n\nexport const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMode: ScreenMode) => {\n if (['light'].includes(theme)) {\n return `np-theme-${theme}`;\n }\n\n // Personal light is always there by default\n const themeClasses = ['np-theme-personal'];\n\n /* eslint-disable functional/immutable-data */\n // Personal dark theme\n if (theme === 'personal' && screenMode === 'dark') {\n themeClasses.push(`np-theme-personal--${screenMode}`);\n }\n\n // Personal forest-green and bright-green themes\n else if (['forest-green', 'bright-green'].includes(theme)) {\n themeClasses.push(`np-theme-personal--${theme}`);\n }\n\n // Business light\n else if (theme === 'business') {\n themeClasses.push(`np-theme-business`);\n // Business dark theme\n if (screenMode === 'dark') {\n themeClasses.push(`np-theme-business--${screenMode}`);\n }\n }\n\n // Business forest-green and bright-green themes\n else if (['business--forest-green', 'business--bright-green'].includes(theme)) {\n themeClasses.push(`np-theme-${theme}`);\n }\n\n // Platform themes\n else if (theme.startsWith('platform')) {\n themeClasses.push(`np-theme-${theme}`);\n }\n /* eslint-enable functional/immutable-data */\n return themeClasses.join(' ');\n};\n"],"names":["isThemeModern","theme","modernThemes","includes","isExtraTheme","extraThemes","isForestGreenTheme","isScreenModeDark","screenMode","screenModes","getThemeClassName","themeClasses","push","startsWith","join"],"mappings":";;;;AAUO,MAAMA,aAAa,GAAIC,KAAoC,IAChEC,mBAAY,CAACC,QAAQ,CAACF,KAAoB;AAErC,MAAMG,YAAY,GAAIH,KAAoC,IAC/DI,kBAAW,CAACF,QAAQ,CAACF,KAAmB;AAEnC,MAAMK,kBAAkB,GAC7BL,KAAoC,IACNA,KAAK,KAAKI,kBAAW,CAAC,CAAC;MAE1CE,gBAAgB,GAAGA,CAC9BN,KAAoC,EACpCO,UAAsB,KAEtBR,aAAa,CAACC,KAAoB,CAAC,IAAIQ,kBAAW,CAAC,CAAC,CAAC,KAAKD;MAE/CE,iBAAiB,GAAGA,CAACT,KAAoC,EAAEO,UAAsB,KAAI;EAChG,IAAI,CAAC,OAAO,CAAC,CAACL,QAAQ,CAACF,KAAK,CAAC,EAAE;IAC7B,OAAO,CAAA,SAAA,EAAYA,KAAK,CAAA,CAAE;AAC5B,EAAA;AAEA;AACA,EAAA,MAAMU,YAAY,GAAG,CAAC,mBAAmB,CAAC;AAE1C;AACA;AACA,EAAA,IAAIV,KAAK,KAAK,UAAU,IAAIO,UAAU,KAAK,MAAM,EAAE;AACjDG,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBJ,UAAU,EAAE,CAAC;AACvD,EAAA;AAEA;OACK,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,CAACL,QAAQ,CAACF,KAAK,CAAC,EAAE;AACzDU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBX,KAAK,EAAE,CAAC;AAClD,EAAA;AAEA;AAAA,OACK,IAAIA,KAAK,KAAK,UAAU,EAAE;AAC7BU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,iBAAA,CAAmB,CAAC;AACtC;IACA,IAAIJ,UAAU,KAAK,MAAM,EAAE;AACzBG,MAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBJ,UAAU,EAAE,CAAC;AACvD,IAAA;AACF,EAAA;AAEA;OACK,IAAI,CAAC,wBAAwB,EAAE,wBAAwB,CAAC,CAACL,QAAQ,CAACF,KAAK,CAAC,EAAE;AAC7EU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AAEA;AAAA,OACK,IAAIA,KAAK,CAACY,UAAU,CAAC,UAAU,CAAC,EAAE;AACrCF,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AACA;AACA,EAAA,OAAOU,YAAY,CAACG,IAAI,CAAC,GAAG,CAAC;AAC/B;;;;;;;;"}
package/dist/helpers.mjs CHANGED
@@ -1,41 +1,41 @@
1
- import { modernThemes, extraThemes, screenModes, businessThemes } from './const.mjs';
1
+ import { modernThemes, extraThemes, screenModes } from './const.mjs';
2
2
 
3
3
  const isThemeModern = theme => modernThemes.includes(theme);
4
4
  const isExtraTheme = theme => extraThemes.includes(theme);
5
5
  const isForestGreenTheme = theme => theme === extraThemes[0];
6
6
  const isScreenModeDark = (theme, screenMode) => isThemeModern(theme) && screenModes[1] === screenMode;
7
7
  const getThemeClassName = (theme, screenMode) => {
8
- // Legacy themes
9
- if (theme === 'light') {
8
+ if (['light'].includes(theme)) {
10
9
  return `np-theme-${theme}`;
11
10
  }
12
11
  // Personal light is always there by default
13
12
  const themeClasses = ['np-theme-personal'];
13
+ /* eslint-disable functional/immutable-data */
14
14
  // Personal dark theme
15
- if (theme === 'personal' && screenModes[1] === screenMode) {
15
+ if (theme === 'personal' && screenMode === 'dark') {
16
16
  themeClasses.push(`np-theme-personal--${screenMode}`);
17
17
  }
18
18
  // Personal forest-green and bright-green themes
19
- else if (isExtraTheme(theme)) {
19
+ else if (['forest-green', 'bright-green'].includes(theme)) {
20
20
  themeClasses.push(`np-theme-personal--${theme}`);
21
21
  }
22
22
  // Business light
23
- else if (businessThemes[0] === theme) {
23
+ else if (theme === 'business') {
24
24
  themeClasses.push(`np-theme-business`);
25
25
  // Business dark theme
26
- if (screenModes[1] === screenMode) {
26
+ if (screenMode === 'dark') {
27
27
  themeClasses.push(`np-theme-business--${screenMode}`);
28
28
  }
29
29
  }
30
30
  // Business forest-green and bright-green themes
31
- // @ts-expect-error relax TS
32
- else if ([businessThemes[1], businessThemes[2]].includes(theme)) {
31
+ else if (['business--forest-green', 'business--bright-green'].includes(theme)) {
33
32
  themeClasses.push(`np-theme-${theme}`);
34
33
  }
35
34
  // Platform themes
36
35
  else if (theme.startsWith('platform')) {
37
36
  themeClasses.push(`np-theme-${theme}`);
38
37
  }
38
+ /* eslint-enable functional/immutable-data */
39
39
  return themeClasses.join(' ');
40
40
  };
41
41
 
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","sources":["../src/helpers.ts"],"sourcesContent":["/* eslint-disable functional/immutable-data */\nimport type {\n ModernTheme,\n ExtraTheme,\n ForestGreenTheme,\n ScreenMode,\n ScreenModeDark,\n Theming,\n} from './const';\nimport { extraThemes, screenModes, modernThemes, businessThemes } from './const';\n\nexport const isThemeModern = (theme: NonNullable<Theming['theme']>): theme is ModernTheme =>\n modernThemes.includes(theme as ModernTheme);\n\nexport const isExtraTheme = (theme: NonNullable<Theming['theme']>): theme is ExtraTheme =>\n extraThemes.includes(theme as ExtraTheme);\n\nexport const isForestGreenTheme = (\n theme: NonNullable<Theming['theme']>,\n): theme is ForestGreenTheme => theme === extraThemes[0];\n\nexport const isScreenModeDark = (\n theme: NonNullable<Theming['theme']>,\n screenMode: ScreenMode,\n): screenMode is ScreenModeDark =>\n isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;\n\nexport const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMode: ScreenMode) => {\n // Legacy themes\n if (theme === 'light') {\n return `np-theme-${theme}`;\n }\n\n // Personal light is always there by default\n const themeClasses = ['np-theme-personal'];\n\n // Personal dark theme\n if (theme === 'personal' && screenModes[1] === screenMode) {\n themeClasses.push(`np-theme-personal--${screenMode}`);\n }\n\n // Personal forest-green and bright-green themes\n else if (isExtraTheme(theme)) {\n themeClasses.push(`np-theme-personal--${theme}`);\n }\n\n // Business light\n else if (businessThemes[0] === theme) {\n themeClasses.push(`np-theme-business`);\n // Business dark theme\n if (screenModes[1] === screenMode) {\n themeClasses.push(`np-theme-business--${screenMode}`);\n }\n }\n\n // Business forest-green and bright-green themes\n // @ts-expect-error relax TS\n else if ([businessThemes[1], businessThemes[2]].includes(theme)) {\n themeClasses.push(`np-theme-${theme}`);\n }\n\n // Platform themes\n else if (theme.startsWith('platform')) {\n themeClasses.push(`np-theme-${theme}`);\n }\n\n return themeClasses.join(' ');\n};\n"],"names":["isThemeModern","theme","modernThemes","includes","isExtraTheme","extraThemes","isForestGreenTheme","isScreenModeDark","screenMode","screenModes","getThemeClassName","themeClasses","push","businessThemes","startsWith","join"],"mappings":";;AAWO,MAAMA,aAAa,GAAIC,KAAoC,IAChEC,YAAY,CAACC,QAAQ,CAACF,KAAoB;AAErC,MAAMG,YAAY,GAAIH,KAAoC,IAC/DI,WAAW,CAACF,QAAQ,CAACF,KAAmB;AAEnC,MAAMK,kBAAkB,GAC7BL,KAAoC,IACNA,KAAK,KAAKI,WAAW,CAAC,CAAC;MAE1CE,gBAAgB,GAAGA,CAC9BN,KAAoC,EACpCO,UAAsB,KAEtBR,aAAa,CAACC,KAAoB,CAAC,IAAIQ,WAAW,CAAC,CAAC,CAAC,KAAKD;MAE/CE,iBAAiB,GAAGA,CAACT,KAAoC,EAAEO,UAAsB,KAAI;AAChG;EACA,IAAIP,KAAK,KAAK,OAAO,EAAE;IACrB,OAAO,CAAA,SAAA,EAAYA,KAAK,CAAA,CAAE;AAC5B,EAAA;AAEA;AACA,EAAA,MAAMU,YAAY,GAAG,CAAC,mBAAmB,CAAC;AAE1C;EACA,IAAIV,KAAK,KAAK,UAAU,IAAIQ,WAAW,CAAC,CAAC,CAAC,KAAKD,UAAU,EAAE;AACzDG,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBJ,UAAU,EAAE,CAAC;AACvD,EAAA;AAEA;AAAA,OACK,IAAIJ,YAAY,CAACH,KAAK,CAAC,EAAE;AAC5BU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBX,KAAK,EAAE,CAAC;AAClD,EAAA;AAEA;AAAA,OACK,IAAIY,cAAc,CAAC,CAAC,CAAC,KAAKZ,KAAK,EAAE;AACpCU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,iBAAA,CAAmB,CAAC;AACtC;AACA,IAAA,IAAIH,WAAW,CAAC,CAAC,CAAC,KAAKD,UAAU,EAAE;AACjCG,MAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBJ,UAAU,EAAE,CAAC;AACvD,IAAA;AACF,EAAA;AAEA;AACA;AAAA,OACK,IAAI,CAACK,cAAc,CAAC,CAAC,CAAC,EAAEA,cAAc,CAAC,CAAC,CAAC,CAAC,CAACV,QAAQ,CAACF,KAAK,CAAC,EAAE;AAC/DU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AAEA;AAAA,OACK,IAAIA,KAAK,CAACa,UAAU,CAAC,UAAU,CAAC,EAAE;AACrCH,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AAEA,EAAA,OAAOU,YAAY,CAACI,IAAI,CAAC,GAAG,CAAC;AAC/B;;;;"}
1
+ {"version":3,"file":"helpers.mjs","sources":["../src/helpers.ts"],"sourcesContent":["import type {\n ModernTheme,\n ExtraTheme,\n ForestGreenTheme,\n ScreenMode,\n ScreenModeDark,\n Theming,\n} from './const';\nimport { extraThemes, screenModes, modernThemes } from './const';\n\nexport const isThemeModern = (theme: NonNullable<Theming['theme']>): theme is ModernTheme =>\n modernThemes.includes(theme as ModernTheme);\n\nexport const isExtraTheme = (theme: NonNullable<Theming['theme']>): theme is ExtraTheme =>\n extraThemes.includes(theme as ExtraTheme);\n\nexport const isForestGreenTheme = (\n theme: NonNullable<Theming['theme']>,\n): theme is ForestGreenTheme => theme === extraThemes[0];\n\nexport const isScreenModeDark = (\n theme: NonNullable<Theming['theme']>,\n screenMode: ScreenMode,\n): screenMode is ScreenModeDark =>\n isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;\n\nexport const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMode: ScreenMode) => {\n if (['light'].includes(theme)) {\n return `np-theme-${theme}`;\n }\n\n // Personal light is always there by default\n const themeClasses = ['np-theme-personal'];\n\n /* eslint-disable functional/immutable-data */\n // Personal dark theme\n if (theme === 'personal' && screenMode === 'dark') {\n themeClasses.push(`np-theme-personal--${screenMode}`);\n }\n\n // Personal forest-green and bright-green themes\n else if (['forest-green', 'bright-green'].includes(theme)) {\n themeClasses.push(`np-theme-personal--${theme}`);\n }\n\n // Business light\n else if (theme === 'business') {\n themeClasses.push(`np-theme-business`);\n // Business dark theme\n if (screenMode === 'dark') {\n themeClasses.push(`np-theme-business--${screenMode}`);\n }\n }\n\n // Business forest-green and bright-green themes\n else if (['business--forest-green', 'business--bright-green'].includes(theme)) {\n themeClasses.push(`np-theme-${theme}`);\n }\n\n // Platform themes\n else if (theme.startsWith('platform')) {\n themeClasses.push(`np-theme-${theme}`);\n }\n /* eslint-enable functional/immutable-data */\n return themeClasses.join(' ');\n};\n"],"names":["isThemeModern","theme","modernThemes","includes","isExtraTheme","extraThemes","isForestGreenTheme","isScreenModeDark","screenMode","screenModes","getThemeClassName","themeClasses","push","startsWith","join"],"mappings":";;AAUO,MAAMA,aAAa,GAAIC,KAAoC,IAChEC,YAAY,CAACC,QAAQ,CAACF,KAAoB;AAErC,MAAMG,YAAY,GAAIH,KAAoC,IAC/DI,WAAW,CAACF,QAAQ,CAACF,KAAmB;AAEnC,MAAMK,kBAAkB,GAC7BL,KAAoC,IACNA,KAAK,KAAKI,WAAW,CAAC,CAAC;MAE1CE,gBAAgB,GAAGA,CAC9BN,KAAoC,EACpCO,UAAsB,KAEtBR,aAAa,CAACC,KAAoB,CAAC,IAAIQ,WAAW,CAAC,CAAC,CAAC,KAAKD;MAE/CE,iBAAiB,GAAGA,CAACT,KAAoC,EAAEO,UAAsB,KAAI;EAChG,IAAI,CAAC,OAAO,CAAC,CAACL,QAAQ,CAACF,KAAK,CAAC,EAAE;IAC7B,OAAO,CAAA,SAAA,EAAYA,KAAK,CAAA,CAAE;AAC5B,EAAA;AAEA;AACA,EAAA,MAAMU,YAAY,GAAG,CAAC,mBAAmB,CAAC;AAE1C;AACA;AACA,EAAA,IAAIV,KAAK,KAAK,UAAU,IAAIO,UAAU,KAAK,MAAM,EAAE;AACjDG,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBJ,UAAU,EAAE,CAAC;AACvD,EAAA;AAEA;OACK,IAAI,CAAC,cAAc,EAAE,cAAc,CAAC,CAACL,QAAQ,CAACF,KAAK,CAAC,EAAE;AACzDU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBX,KAAK,EAAE,CAAC;AAClD,EAAA;AAEA;AAAA,OACK,IAAIA,KAAK,KAAK,UAAU,EAAE;AAC7BU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,iBAAA,CAAmB,CAAC;AACtC;IACA,IAAIJ,UAAU,KAAK,MAAM,EAAE;AACzBG,MAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,mBAAA,EAAsBJ,UAAU,EAAE,CAAC;AACvD,IAAA;AACF,EAAA;AAEA;OACK,IAAI,CAAC,wBAAwB,EAAE,wBAAwB,CAAC,CAACL,QAAQ,CAACF,KAAK,CAAC,EAAE;AAC7EU,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AAEA;AAAA,OACK,IAAIA,KAAK,CAACY,UAAU,CAAC,UAAU,CAAC,EAAE;AACrCF,IAAAA,YAAY,CAACC,IAAI,CAAC,CAAA,SAAA,EAAYX,KAAK,EAAE,CAAC;AACxC,EAAA;AACA;AACA,EAAA,OAAOU,YAAY,CAACG,IAAI,CAAC,GAAG,CAAC;AAC/B;;;;"}
@@ -6,6 +6,8 @@ interface ThemeHookValue {
6
6
  isForestGreenTheme: boolean;
7
7
  isScreenModeDark: boolean;
8
8
  className: string;
9
+ setTheme: (theme: NonNullable<Theming['theme']>) => void;
10
+ setScreenMode: (screenMode: ScreenMode) => void;
9
11
  }
10
12
  export declare const useTheme: () => ThemeHookValue;
11
13
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../src/useTheme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAInD,UAAU,cAAc;IACtB,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACrC,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB;AAeD,eAAO,MAAM,QAAQ,QAAO,cAuB3B,CAAC"}
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../src/useTheme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAInD,UAAU,cAAc;IACtB,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACrC,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC;IACzD,aAAa,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;CACjD;AAiBD,eAAO,MAAM,QAAQ,QAAO,cA8B3B,CAAC"}
package/dist/useTheme.js CHANGED
@@ -7,7 +7,9 @@ var helpers = require('./helpers.js');
7
7
 
8
8
  const FALLBACK_VALUES = {
9
9
  theme: _const.DEFAULT_BASE_THEME,
10
- screenMode: _const.DEFAULT_SCREEN_MODE
10
+ screenMode: _const.DEFAULT_SCREEN_MODE,
11
+ setTheme: () => {},
12
+ setScreenMode: () => {}
11
13
  };
12
14
  const isNotProduction = () => {
13
15
  try {
@@ -24,7 +26,9 @@ const useTheme = () => {
24
26
  }
25
27
  const {
26
28
  theme,
27
- screenMode: contextScreenMode
29
+ screenMode: contextScreenMode,
30
+ setTheme,
31
+ setScreenMode
28
32
  } = theming ?? FALLBACK_VALUES;
29
33
  const screenMode = theme === _const.DEFAULT_BASE_THEME ? _const.DEFAULT_SCREEN_MODE : contextScreenMode;
30
34
  return react.useMemo(() => ({
@@ -33,8 +37,10 @@ const useTheme = () => {
33
37
  isModern: helpers.isThemeModern(theme),
34
38
  isForestGreenTheme: helpers.isForestGreenTheme(theme),
35
39
  isScreenModeDark: helpers.isScreenModeDark(theme, screenMode),
36
- className: helpers.getThemeClassName(theme, screenMode)
37
- }), [theme, screenMode]);
40
+ className: helpers.getThemeClassName(theme, screenMode),
41
+ setTheme,
42
+ setScreenMode
43
+ }), [theme, screenMode, setTheme, setScreenMode]);
38
44
  };
39
45
 
40
46
  exports.useTheme = useTheme;
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.js","sources":["../src/useTheme.ts"],"sourcesContent":["import { useContext, useMemo } from 'react';\n\nimport { ThemeContext } from './ThemeProviderContext';\nimport type { ScreenMode, Theming } from './const';\nimport { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const';\nimport { isThemeModern, isForestGreenTheme, isScreenModeDark, getThemeClassName } from './helpers';\n\ninterface ThemeHookValue {\n theme: NonNullable<Theming['theme']>;\n screenMode: ScreenMode;\n isModern: boolean;\n isForestGreenTheme: boolean;\n isScreenModeDark: boolean;\n className: string;\n}\n\nconst FALLBACK_VALUES = {\n theme: DEFAULT_BASE_THEME,\n screenMode: DEFAULT_SCREEN_MODE,\n} as const;\n\nconst isNotProduction = () => {\n try {\n return ['localhost', 'dev-wi.se'].includes(window.location.hostname);\n } catch {\n return false;\n }\n};\n\nexport const useTheme = (): ThemeHookValue => {\n const theming = useContext(ThemeContext);\n\n if (!theming && isNotProduction()) {\n // eslint-disable-next-line no-console\n console.warn('Call to useTheme outside a ThemeProvider');\n }\n\n const { theme, screenMode: contextScreenMode } = theming ?? FALLBACK_VALUES;\n\n const screenMode = theme === DEFAULT_BASE_THEME ? DEFAULT_SCREEN_MODE : contextScreenMode;\n\n return useMemo(\n () => ({\n theme,\n screenMode,\n isModern: isThemeModern(theme),\n isForestGreenTheme: isForestGreenTheme(theme),\n isScreenModeDark: isScreenModeDark(theme, screenMode),\n className: getThemeClassName(theme, screenMode),\n }),\n [theme, screenMode],\n );\n};\n"],"names":["FALLBACK_VALUES","theme","DEFAULT_BASE_THEME","screenMode","DEFAULT_SCREEN_MODE","isNotProduction","includes","window","location","hostname","useTheme","theming","useContext","ThemeContext","console","warn","contextScreenMode","useMemo","isModern","isThemeModern","isForestGreenTheme","isScreenModeDark","className","getThemeClassName"],"mappings":";;;;;;;AAgBA,MAAMA,eAAe,GAAG;AACtBC,EAAAA,KAAK,EAAEC,yBAAkB;AACzBC,EAAAA,UAAU,EAAEC;CACJ;AAEV,MAAMC,eAAe,GAAGA,MAAK;EAC3B,IAAI;AACF,IAAA,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,CAACC,QAAQ,CAACC,MAAM,CAACC,QAAQ,CAACC,QAAQ,CAAC;AACtE,EAAA,CAAC,CAAC,MAAM;AACN,IAAA,OAAO,KAAK;AACd,EAAA;AACF,CAAC;AAEM,MAAMC,QAAQ,GAAGA,MAAqB;AAC3C,EAAA,MAAMC,OAAO,GAAGC,gBAAU,CAACC,iCAAY,CAAC;AAExC,EAAA,IAAI,CAACF,OAAO,IAAIN,eAAe,EAAE,EAAE;AACjC;AACAS,IAAAA,OAAO,CAACC,IAAI,CAAC,0CAA0C,CAAC;AAC1D,EAAA;EAEA,MAAM;IAAEd,KAAK;AAAEE,IAAAA,UAAU,EAAEa;GAAmB,GAAGL,OAAO,IAAIX,eAAe;EAE3E,MAAMG,UAAU,GAAGF,KAAK,KAAKC,yBAAkB,GAAGE,0BAAmB,GAAGY,iBAAiB;EAEzF,OAAOC,aAAO,CACZ,OAAO;IACLhB,KAAK;IACLE,UAAU;AACVe,IAAAA,QAAQ,EAAEC,qBAAa,CAAClB,KAAK,CAAC;AAC9BmB,IAAAA,kBAAkB,EAAEA,0BAAkB,CAACnB,KAAK,CAAC;AAC7CoB,IAAAA,gBAAgB,EAAEA,wBAAgB,CAACpB,KAAK,EAAEE,UAAU,CAAC;AACrDmB,IAAAA,SAAS,EAAEC,yBAAiB,CAACtB,KAAK,EAAEE,UAAU;AAC/C,GAAA,CAAC,EACF,CAACF,KAAK,EAAEE,UAAU,CAAC,CACpB;AACH;;;;"}
1
+ {"version":3,"file":"useTheme.js","sources":["../src/useTheme.ts"],"sourcesContent":["import { useContext, useMemo } from 'react';\n\nimport { ThemeContext } from './ThemeProviderContext';\nimport type { ScreenMode, Theming } from './const';\nimport { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const';\nimport { isThemeModern, isForestGreenTheme, isScreenModeDark, getThemeClassName } from './helpers';\n\ninterface ThemeHookValue {\n theme: NonNullable<Theming['theme']>;\n screenMode: ScreenMode;\n isModern: boolean;\n isForestGreenTheme: boolean;\n isScreenModeDark: boolean;\n className: string;\n setTheme: (theme: NonNullable<Theming['theme']>) => void;\n setScreenMode: (screenMode: ScreenMode) => void;\n}\n\nconst FALLBACK_VALUES = {\n theme: DEFAULT_BASE_THEME,\n screenMode: DEFAULT_SCREEN_MODE,\n setTheme: () => {},\n setScreenMode: () => {},\n} as const;\n\nconst isNotProduction = () => {\n try {\n return ['localhost', 'dev-wi.se'].includes(window.location.hostname);\n } catch {\n return false;\n }\n};\n\nexport const useTheme = (): ThemeHookValue => {\n const theming = useContext(ThemeContext);\n\n if (!theming && isNotProduction()) {\n // eslint-disable-next-line no-console\n console.warn('Call to useTheme outside a ThemeProvider');\n }\n\n const {\n theme,\n screenMode: contextScreenMode,\n setTheme,\n setScreenMode,\n } = theming ?? FALLBACK_VALUES;\n\n const screenMode = theme === DEFAULT_BASE_THEME ? DEFAULT_SCREEN_MODE : contextScreenMode;\n\n return useMemo(\n () => ({\n theme,\n screenMode,\n isModern: isThemeModern(theme),\n isForestGreenTheme: isForestGreenTheme(theme),\n isScreenModeDark: isScreenModeDark(theme, screenMode),\n className: getThemeClassName(theme, screenMode),\n setTheme,\n setScreenMode,\n }),\n [theme, screenMode, setTheme, setScreenMode],\n );\n};\n"],"names":["FALLBACK_VALUES","theme","DEFAULT_BASE_THEME","screenMode","DEFAULT_SCREEN_MODE","setTheme","setScreenMode","isNotProduction","includes","window","location","hostname","useTheme","theming","useContext","ThemeContext","console","warn","contextScreenMode","useMemo","isModern","isThemeModern","isForestGreenTheme","isScreenModeDark","className","getThemeClassName"],"mappings":";;;;;;;AAkBA,MAAMA,eAAe,GAAG;AACtBC,EAAAA,KAAK,EAAEC,yBAAkB;AACzBC,EAAAA,UAAU,EAAEC,0BAAmB;AAC/BC,EAAAA,QAAQ,EAAEA,MAAK,CAAE,CAAC;EAClBC,aAAa,EAAEA,MAAK,CAAE;CACd;AAEV,MAAMC,eAAe,GAAGA,MAAK;EAC3B,IAAI;AACF,IAAA,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,CAACC,QAAQ,CAACC,MAAM,CAACC,QAAQ,CAACC,QAAQ,CAAC;AACtE,EAAA,CAAC,CAAC,MAAM;AACN,IAAA,OAAO,KAAK;AACd,EAAA;AACF,CAAC;AAEM,MAAMC,QAAQ,GAAGA,MAAqB;AAC3C,EAAA,MAAMC,OAAO,GAAGC,gBAAU,CAACC,iCAAY,CAAC;AAExC,EAAA,IAAI,CAACF,OAAO,IAAIN,eAAe,EAAE,EAAE;AACjC;AACAS,IAAAA,OAAO,CAACC,IAAI,CAAC,0CAA0C,CAAC;AAC1D,EAAA;EAEA,MAAM;IACJhB,KAAK;AACLE,IAAAA,UAAU,EAAEe,iBAAiB;IAC7Bb,QAAQ;AACRC,IAAAA;GACD,GAAGO,OAAO,IAAIb,eAAe;EAE9B,MAAMG,UAAU,GAAGF,KAAK,KAAKC,yBAAkB,GAAGE,0BAAmB,GAAGc,iBAAiB;EAEzF,OAAOC,aAAO,CACZ,OAAO;IACLlB,KAAK;IACLE,UAAU;AACViB,IAAAA,QAAQ,EAAEC,qBAAa,CAACpB,KAAK,CAAC;AAC9BqB,IAAAA,kBAAkB,EAAEA,0BAAkB,CAACrB,KAAK,CAAC;AAC7CsB,IAAAA,gBAAgB,EAAEA,wBAAgB,CAACtB,KAAK,EAAEE,UAAU,CAAC;AACrDqB,IAAAA,SAAS,EAAEC,yBAAiB,CAACxB,KAAK,EAAEE,UAAU,CAAC;IAC/CE,QAAQ;AACRC,IAAAA;GACD,CAAC,EACF,CAACL,KAAK,EAAEE,UAAU,EAAEE,QAAQ,EAAEC,aAAa,CAAC,CAC7C;AACH;;;;"}
package/dist/useTheme.mjs CHANGED
@@ -1,11 +1,13 @@
1
1
  import { useContext, useMemo } from 'react';
2
2
  import { ThemeContext } from './ThemeProviderContext.mjs';
3
- import { DEFAULT_SCREEN_MODE, DEFAULT_BASE_THEME } from './const.mjs';
3
+ import { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const.mjs';
4
4
  import { getThemeClassName, isScreenModeDark, isForestGreenTheme, isThemeModern } from './helpers.mjs';
5
5
 
6
6
  const FALLBACK_VALUES = {
7
7
  theme: DEFAULT_BASE_THEME,
8
- screenMode: DEFAULT_SCREEN_MODE
8
+ screenMode: DEFAULT_SCREEN_MODE,
9
+ setTheme: () => {},
10
+ setScreenMode: () => {}
9
11
  };
10
12
  const isNotProduction = () => {
11
13
  try {
@@ -22,7 +24,9 @@ const useTheme = () => {
22
24
  }
23
25
  const {
24
26
  theme,
25
- screenMode: contextScreenMode
27
+ screenMode: contextScreenMode,
28
+ setTheme,
29
+ setScreenMode
26
30
  } = theming ?? FALLBACK_VALUES;
27
31
  const screenMode = theme === DEFAULT_BASE_THEME ? DEFAULT_SCREEN_MODE : contextScreenMode;
28
32
  return useMemo(() => ({
@@ -31,8 +35,10 @@ const useTheme = () => {
31
35
  isModern: isThemeModern(theme),
32
36
  isForestGreenTheme: isForestGreenTheme(theme),
33
37
  isScreenModeDark: isScreenModeDark(theme, screenMode),
34
- className: getThemeClassName(theme, screenMode)
35
- }), [theme, screenMode]);
38
+ className: getThemeClassName(theme, screenMode),
39
+ setTheme,
40
+ setScreenMode
41
+ }), [theme, screenMode, setTheme, setScreenMode]);
36
42
  };
37
43
 
38
44
  export { useTheme };
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.mjs","sources":["../src/useTheme.ts"],"sourcesContent":["import { useContext, useMemo } from 'react';\n\nimport { ThemeContext } from './ThemeProviderContext';\nimport type { ScreenMode, Theming } from './const';\nimport { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const';\nimport { isThemeModern, isForestGreenTheme, isScreenModeDark, getThemeClassName } from './helpers';\n\ninterface ThemeHookValue {\n theme: NonNullable<Theming['theme']>;\n screenMode: ScreenMode;\n isModern: boolean;\n isForestGreenTheme: boolean;\n isScreenModeDark: boolean;\n className: string;\n}\n\nconst FALLBACK_VALUES = {\n theme: DEFAULT_BASE_THEME,\n screenMode: DEFAULT_SCREEN_MODE,\n} as const;\n\nconst isNotProduction = () => {\n try {\n return ['localhost', 'dev-wi.se'].includes(window.location.hostname);\n } catch {\n return false;\n }\n};\n\nexport const useTheme = (): ThemeHookValue => {\n const theming = useContext(ThemeContext);\n\n if (!theming && isNotProduction()) {\n // eslint-disable-next-line no-console\n console.warn('Call to useTheme outside a ThemeProvider');\n }\n\n const { theme, screenMode: contextScreenMode } = theming ?? FALLBACK_VALUES;\n\n const screenMode = theme === DEFAULT_BASE_THEME ? DEFAULT_SCREEN_MODE : contextScreenMode;\n\n return useMemo(\n () => ({\n theme,\n screenMode,\n isModern: isThemeModern(theme),\n isForestGreenTheme: isForestGreenTheme(theme),\n isScreenModeDark: isScreenModeDark(theme, screenMode),\n className: getThemeClassName(theme, screenMode),\n }),\n [theme, screenMode],\n );\n};\n"],"names":["FALLBACK_VALUES","theme","DEFAULT_BASE_THEME","screenMode","DEFAULT_SCREEN_MODE","isNotProduction","includes","window","location","hostname","useTheme","theming","useContext","ThemeContext","console","warn","contextScreenMode","useMemo","isModern","isThemeModern","isForestGreenTheme","isScreenModeDark","className","getThemeClassName"],"mappings":";;;;;AAgBA,MAAMA,eAAe,GAAG;AACtBC,EAAAA,KAAK,EAAEC,kBAAkB;AACzBC,EAAAA,UAAU,EAAEC;CACJ;AAEV,MAAMC,eAAe,GAAGA,MAAK;EAC3B,IAAI;AACF,IAAA,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,CAACC,QAAQ,CAACC,MAAM,CAACC,QAAQ,CAACC,QAAQ,CAAC;AACtE,EAAA,CAAC,CAAC,MAAM;AACN,IAAA,OAAO,KAAK;AACd,EAAA;AACF,CAAC;AAEM,MAAMC,QAAQ,GAAGA,MAAqB;AAC3C,EAAA,MAAMC,OAAO,GAAGC,UAAU,CAACC,YAAY,CAAC;AAExC,EAAA,IAAI,CAACF,OAAO,IAAIN,eAAe,EAAE,EAAE;AACjC;AACAS,IAAAA,OAAO,CAACC,IAAI,CAAC,0CAA0C,CAAC;AAC1D,EAAA;EAEA,MAAM;IAAEd,KAAK;AAAEE,IAAAA,UAAU,EAAEa;GAAmB,GAAGL,OAAO,IAAIX,eAAe;EAE3E,MAAMG,UAAU,GAAGF,KAAK,KAAKC,kBAAkB,GAAGE,mBAAmB,GAAGY,iBAAiB;EAEzF,OAAOC,OAAO,CACZ,OAAO;IACLhB,KAAK;IACLE,UAAU;AACVe,IAAAA,QAAQ,EAAEC,aAAa,CAAClB,KAAK,CAAC;AAC9BmB,IAAAA,kBAAkB,EAAEA,kBAAkB,CAACnB,KAAK,CAAC;AAC7CoB,IAAAA,gBAAgB,EAAEA,gBAAgB,CAACpB,KAAK,EAAEE,UAAU,CAAC;AACrDmB,IAAAA,SAAS,EAAEC,iBAAiB,CAACtB,KAAK,EAAEE,UAAU;AAC/C,GAAA,CAAC,EACF,CAACF,KAAK,EAAEE,UAAU,CAAC,CACpB;AACH;;;;"}
1
+ {"version":3,"file":"useTheme.mjs","sources":["../src/useTheme.ts"],"sourcesContent":["import { useContext, useMemo } from 'react';\n\nimport { ThemeContext } from './ThemeProviderContext';\nimport type { ScreenMode, Theming } from './const';\nimport { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const';\nimport { isThemeModern, isForestGreenTheme, isScreenModeDark, getThemeClassName } from './helpers';\n\ninterface ThemeHookValue {\n theme: NonNullable<Theming['theme']>;\n screenMode: ScreenMode;\n isModern: boolean;\n isForestGreenTheme: boolean;\n isScreenModeDark: boolean;\n className: string;\n setTheme: (theme: NonNullable<Theming['theme']>) => void;\n setScreenMode: (screenMode: ScreenMode) => void;\n}\n\nconst FALLBACK_VALUES = {\n theme: DEFAULT_BASE_THEME,\n screenMode: DEFAULT_SCREEN_MODE,\n setTheme: () => {},\n setScreenMode: () => {},\n} as const;\n\nconst isNotProduction = () => {\n try {\n return ['localhost', 'dev-wi.se'].includes(window.location.hostname);\n } catch {\n return false;\n }\n};\n\nexport const useTheme = (): ThemeHookValue => {\n const theming = useContext(ThemeContext);\n\n if (!theming && isNotProduction()) {\n // eslint-disable-next-line no-console\n console.warn('Call to useTheme outside a ThemeProvider');\n }\n\n const {\n theme,\n screenMode: contextScreenMode,\n setTheme,\n setScreenMode,\n } = theming ?? FALLBACK_VALUES;\n\n const screenMode = theme === DEFAULT_BASE_THEME ? DEFAULT_SCREEN_MODE : contextScreenMode;\n\n return useMemo(\n () => ({\n theme,\n screenMode,\n isModern: isThemeModern(theme),\n isForestGreenTheme: isForestGreenTheme(theme),\n isScreenModeDark: isScreenModeDark(theme, screenMode),\n className: getThemeClassName(theme, screenMode),\n setTheme,\n setScreenMode,\n }),\n [theme, screenMode, setTheme, setScreenMode],\n );\n};\n"],"names":["FALLBACK_VALUES","theme","DEFAULT_BASE_THEME","screenMode","DEFAULT_SCREEN_MODE","setTheme","setScreenMode","isNotProduction","includes","window","location","hostname","useTheme","theming","useContext","ThemeContext","console","warn","contextScreenMode","useMemo","isModern","isThemeModern","isForestGreenTheme","isScreenModeDark","className","getThemeClassName"],"mappings":";;;;;AAkBA,MAAMA,eAAe,GAAG;AACtBC,EAAAA,KAAK,EAAEC,kBAAkB;AACzBC,EAAAA,UAAU,EAAEC,mBAAmB;AAC/BC,EAAAA,QAAQ,EAAEA,MAAK,CAAE,CAAC;EAClBC,aAAa,EAAEA,MAAK,CAAE;CACd;AAEV,MAAMC,eAAe,GAAGA,MAAK;EAC3B,IAAI;AACF,IAAA,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,CAACC,QAAQ,CAACC,MAAM,CAACC,QAAQ,CAACC,QAAQ,CAAC;AACtE,EAAA,CAAC,CAAC,MAAM;AACN,IAAA,OAAO,KAAK;AACd,EAAA;AACF,CAAC;AAEM,MAAMC,QAAQ,GAAGA,MAAqB;AAC3C,EAAA,MAAMC,OAAO,GAAGC,UAAU,CAACC,YAAY,CAAC;AAExC,EAAA,IAAI,CAACF,OAAO,IAAIN,eAAe,EAAE,EAAE;AACjC;AACAS,IAAAA,OAAO,CAACC,IAAI,CAAC,0CAA0C,CAAC;AAC1D,EAAA;EAEA,MAAM;IACJhB,KAAK;AACLE,IAAAA,UAAU,EAAEe,iBAAiB;IAC7Bb,QAAQ;AACRC,IAAAA;GACD,GAAGO,OAAO,IAAIb,eAAe;EAE9B,MAAMG,UAAU,GAAGF,KAAK,KAAKC,kBAAkB,GAAGE,mBAAmB,GAAGc,iBAAiB;EAEzF,OAAOC,OAAO,CACZ,OAAO;IACLlB,KAAK;IACLE,UAAU;AACViB,IAAAA,QAAQ,EAAEC,aAAa,CAACpB,KAAK,CAAC;AAC9BqB,IAAAA,kBAAkB,EAAEA,kBAAkB,CAACrB,KAAK,CAAC;AAC7CsB,IAAAA,gBAAgB,EAAEA,gBAAgB,CAACtB,KAAK,EAAEE,UAAU,CAAC;AACrDqB,IAAAA,SAAS,EAAEC,iBAAiB,CAACxB,KAAK,EAAEE,UAAU,CAAC;IAC/CE,QAAQ;AACRC,IAAAA;GACD,CAAC,EACF,CAACL,KAAK,EAAEE,UAAU,EAAEE,QAAQ,EAAEC,aAAa,CAAC,CAC7C;AACH;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/components-theming",
3
- "version": "0.0.0-experimental-17de653",
3
+ "version": "0.0.0-experimental-aa6bd68",
4
4
  "description": "Provides theming support for the Wise Design system components",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -40,9 +40,13 @@ describe('ThemeProvider', () => {
40
40
  // eslint-disable-next-line testing-library/no-node-access
41
41
  expect(screen.getByText('personal').parentElement).toHaveClass('np-theme-personal');
42
42
  // eslint-disable-next-line testing-library/no-node-access
43
- expect(screen.getByText('platform').parentElement).toHaveClass('np-theme-platform');
43
+ expect(screen.getByText('platform').parentElement).toHaveClass(
44
+ 'np-theme-personal',
45
+ 'np-theme-platform',
46
+ );
44
47
  // eslint-disable-next-line testing-library/no-node-access
45
48
  expect(screen.getByText('platform--forest-green').parentElement).toHaveClass(
49
+ 'np-theme-personal',
46
50
  'np-theme-platform--forest-green',
47
51
  );
48
52
  });
@@ -64,153 +68,28 @@ describe('ThemeProvider', () => {
64
68
  );
65
69
 
66
70
  // eslint-disable-next-line testing-library/no-node-access
67
- expect(screen.getByText('business').parentElement).toHaveClass('np-theme-business');
71
+ expect(screen.getByText('business').parentElement).toHaveClass(
72
+ 'np-theme-personal',
73
+ 'np-theme-business',
74
+ );
68
75
  // eslint-disable-next-line testing-library/no-node-access
69
- expect(screen.getByText('business-dark').parentElement).toHaveClass('np-theme-business--dark');
76
+ expect(screen.getByText('business-dark').parentElement).toHaveClass(
77
+ 'np-theme-personal',
78
+ 'np-theme-business',
79
+ 'np-theme-business--dark',
80
+ );
70
81
  // eslint-disable-next-line testing-library/no-node-access
71
82
  expect(screen.getByText('business--bright-green').parentElement).toHaveClass(
83
+ 'np-theme-personal',
72
84
  'np-theme-business--bright-green',
73
85
  );
74
86
  // eslint-disable-next-line testing-library/no-node-access
75
87
  expect(screen.getByText('business--forest-green').parentElement).toHaveClass(
88
+ 'np-theme-personal',
76
89
  'np-theme-business--forest-green',
77
90
  );
78
91
  });
79
92
 
80
- it('adds personal class for business theme when isNotRootProvider=false (default)', () => {
81
- const mockClassList = {
82
- add: jest.fn(),
83
- remove: jest.fn(),
84
- };
85
-
86
- Object.defineProperty(document, 'documentElement', {
87
- value: { className: '', classList: mockClassList },
88
- writable: true,
89
- });
90
-
91
- render(
92
- <ThemeProvider theme="business">
93
- <div>business-auto-fix</div>
94
- </ThemeProvider>,
95
- );
96
-
97
- expect(mockClassList.add).toHaveBeenCalledWith('np-theme-personal');
98
- expect(mockClassList.add).toHaveBeenCalledWith('np-theme-business');
99
- });
100
-
101
- it('does not add personal class for business theme with isNotRootProvider=true', () => {
102
- const mockClassList = {
103
- add: jest.fn(),
104
- remove: jest.fn(),
105
- };
106
-
107
- Object.defineProperty(document, 'documentElement', {
108
- value: { className: '', classList: mockClassList },
109
- writable: true,
110
- });
111
-
112
- render(
113
- <ThemeProvider theme="business" isNotRootProvider>
114
- <div>business-component</div>
115
- </ThemeProvider>,
116
- );
117
-
118
- expect(mockClassList.add).not.toHaveBeenCalledWith('np-theme-personal');
119
- expect(mockClassList.add).not.toHaveBeenCalled();
120
-
121
- // The component wrapper should still get the business theme class via ThemedChildren
122
- expect(screen.getByText('business-component')).toBeInTheDocument();
123
- // Note: We can't easily test the wrapper class without direct node access,
124
- // but the functionality is verified by the existing integration tests
125
- });
126
-
127
- it('adds personal class for personal theme', () => {
128
- const mockClassList = {
129
- add: jest.fn(),
130
- remove: jest.fn(),
131
- };
132
-
133
- Object.defineProperty(document, 'documentElement', {
134
- value: { className: '', classList: mockClassList },
135
- writable: true,
136
- });
137
-
138
- render(
139
- <ThemeProvider theme="personal">
140
- <div>personal</div>
141
- </ThemeProvider>,
142
- );
143
-
144
- expect(mockClassList.add).toHaveBeenCalledWith('np-theme-personal');
145
- });
146
-
147
- it('does not add personal class for light theme', () => {
148
- const mockClassList = {
149
- add: jest.fn(),
150
- remove: jest.fn(),
151
- };
152
-
153
- Object.defineProperty(document, 'documentElement', {
154
- value: { className: '', classList: mockClassList },
155
- writable: true,
156
- });
157
-
158
- render(
159
- <ThemeProvider theme="light">
160
- <div>light</div>
161
- </ThemeProvider>,
162
- );
163
-
164
- expect(mockClassList.add).toHaveBeenCalledWith('np-theme-light');
165
- expect(mockClassList.add).not.toHaveBeenCalledWith('np-theme-personal');
166
- });
167
-
168
- it('adds personal class for platform theme when isNotRootProvider=false (default)', () => {
169
- const mockClassList = {
170
- add: jest.fn(),
171
- remove: jest.fn(),
172
- };
173
-
174
- Object.defineProperty(document, 'documentElement', {
175
- value: { className: '', classList: mockClassList },
176
- writable: true,
177
- });
178
-
179
- render(
180
- <ThemeProvider theme="platform">
181
- <div>platform-auto-fix</div>
182
- </ThemeProvider>,
183
- );
184
-
185
- expect(mockClassList.add).toHaveBeenCalledWith('np-theme-personal');
186
- expect(mockClassList.add).toHaveBeenCalledWith('np-theme-platform');
187
- });
188
-
189
- it('does not add personal class for platform theme with isNotRootProvider=true', () => {
190
- const mockClassList = {
191
- add: jest.fn(),
192
- remove: jest.fn(),
193
- };
194
-
195
- Object.defineProperty(document, 'documentElement', {
196
- value: { className: '', classList: mockClassList },
197
- writable: true,
198
- });
199
-
200
- render(
201
- <ThemeProvider theme="platform" isNotRootProvider>
202
- <div>platform-component</div>
203
- </ThemeProvider>,
204
- );
205
-
206
- expect(mockClassList.add).not.toHaveBeenCalledWith('np-theme-personal');
207
- expect(mockClassList.add).not.toHaveBeenCalled();
208
-
209
- // The component wrapper should still get the platform theme class via ThemedChildren
210
- expect(screen.getByText('platform-component')).toBeInTheDocument();
211
- // Note: We can't easily test the wrapper class without direct node access,
212
- // but the functionality is verified by the existing integration tests
213
- });
214
93
  it('matches snapshot', () => {
215
94
  const { asFragment } = render(
216
95
  <ThemeProvider theme="light">
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren, useContext, useEffect, useMemo } from 'react';
1
+ import { PropsWithChildren, useContext, useEffect, useMemo, useState } from 'react';
2
2
 
3
3
  import { ThemedChildren } from './ThemedChildren';
4
4
  import type { Theming } from './const';
@@ -12,13 +12,24 @@ type ThemeProviderProps = PropsWithChildren<Theming> & { className?: string };
12
12
  const themeClass = /\bnp-theme-[a-z-]+\b/g;
13
13
 
14
14
  export const ThemeProvider = ({
15
- theme = DEFAULT_BASE_THEME,
16
- screenMode = DEFAULT_SCREEN_MODE,
15
+ theme: initialTheme = DEFAULT_BASE_THEME,
16
+ screenMode: initialScreenMode = DEFAULT_SCREEN_MODE,
17
17
  isNotRootProvider = false,
18
18
  children,
19
19
  className = undefined,
20
20
  }: ThemeProviderProps) => {
21
21
  const isContextRoot = useContext(ThemeContext) === undefined;
22
+ const [theme, setTheme] = useState(initialTheme);
23
+ const [screenMode, setScreenMode] = useState(initialScreenMode);
24
+
25
+ // Update state when props change (for controlled usage)
26
+ useEffect(() => {
27
+ setTheme(initialTheme);
28
+ }, [initialTheme]);
29
+
30
+ useEffect(() => {
31
+ setScreenMode(initialScreenMode);
32
+ }, [initialScreenMode]);
22
33
 
23
34
  // useEffect hook used to apply the theme class to the HTML element
24
35
  useEffect(() => {
@@ -35,7 +46,10 @@ export const ThemeProvider = ({
35
46
  }
36
47
  }, [isNotRootProvider, isContextRoot, theme, screenMode]);
37
48
 
38
- const contextValue = useMemo(() => ({ theme, screenMode }), [screenMode, theme]);
49
+ const contextValue = useMemo(
50
+ () => ({ theme, screenMode, setTheme, setScreenMode }),
51
+ [theme, screenMode],
52
+ );
39
53
 
40
54
  return (
41
55
  <ThemeContext.Provider value={contextValue}>
@@ -5,6 +5,8 @@ export const ThemeContext = createContext<
5
5
  | {
6
6
  theme: NonNullable<Theming['theme']>;
7
7
  screenMode: ScreenMode;
8
+ setTheme: (theme: NonNullable<Theming['theme']>) => void;
9
+ setScreenMode: (screenMode: ScreenMode) => void;
8
10
  }
9
11
  | undefined
10
12
  >(undefined);
package/src/helpers.ts CHANGED
@@ -1,4 +1,3 @@
1
- /* eslint-disable functional/immutable-data */
2
1
  import type {
3
2
  ModernTheme,
4
3
  ExtraTheme,
@@ -7,7 +6,7 @@ import type {
7
6
  ScreenModeDark,
8
7
  Theming,
9
8
  } from './const';
10
- import { extraThemes, screenModes, modernThemes, businessThemes } from './const';
9
+ import { extraThemes, screenModes, modernThemes } from './const';
11
10
 
12
11
  export const isThemeModern = (theme: NonNullable<Theming['theme']>): theme is ModernTheme =>
13
12
  modernThemes.includes(theme as ModernTheme);
@@ -26,36 +25,35 @@ export const isScreenModeDark = (
26
25
  isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;
27
26
 
28
27
  export const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMode: ScreenMode) => {
29
- // Legacy themes
30
- if (theme === 'light') {
28
+ if (['light'].includes(theme)) {
31
29
  return `np-theme-${theme}`;
32
30
  }
33
31
 
34
32
  // Personal light is always there by default
35
33
  const themeClasses = ['np-theme-personal'];
36
34
 
35
+ /* eslint-disable functional/immutable-data */
37
36
  // Personal dark theme
38
- if (theme === 'personal' && screenModes[1] === screenMode) {
37
+ if (theme === 'personal' && screenMode === 'dark') {
39
38
  themeClasses.push(`np-theme-personal--${screenMode}`);
40
39
  }
41
40
 
42
41
  // Personal forest-green and bright-green themes
43
- else if (isExtraTheme(theme)) {
42
+ else if (['forest-green', 'bright-green'].includes(theme)) {
44
43
  themeClasses.push(`np-theme-personal--${theme}`);
45
44
  }
46
45
 
47
46
  // Business light
48
- else if (businessThemes[0] === theme) {
47
+ else if (theme === 'business') {
49
48
  themeClasses.push(`np-theme-business`);
50
49
  // Business dark theme
51
- if (screenModes[1] === screenMode) {
50
+ if (screenMode === 'dark') {
52
51
  themeClasses.push(`np-theme-business--${screenMode}`);
53
52
  }
54
53
  }
55
54
 
56
55
  // Business forest-green and bright-green themes
57
- // @ts-expect-error relax TS
58
- else if ([businessThemes[1], businessThemes[2]].includes(theme)) {
56
+ else if (['business--forest-green', 'business--bright-green'].includes(theme)) {
59
57
  themeClasses.push(`np-theme-${theme}`);
60
58
  }
61
59
 
@@ -63,6 +61,6 @@ export const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMo
63
61
  else if (theme.startsWith('platform')) {
64
62
  themeClasses.push(`np-theme-${theme}`);
65
63
  }
66
-
64
+ /* eslint-enable functional/immutable-data */
67
65
  return themeClasses.join(' ');
68
66
  };
@@ -12,7 +12,7 @@ describe('useTheme', () => {
12
12
  result: { current },
13
13
  } = renderHook(() => useTheme());
14
14
 
15
- expect(current).toStrictEqual({
15
+ expect(current).toMatchObject({
16
16
  theme: DEFAULT_BASE_THEME,
17
17
  screenMode: DEFAULT_SCREEN_MODE,
18
18
  isModern: false,
@@ -20,6 +20,8 @@ describe('useTheme', () => {
20
20
  isScreenModeDark: false,
21
21
  className: 'np-theme-light',
22
22
  });
23
+ expect(current.setTheme).toBeInstanceOf(Function);
24
+ expect(current.setScreenMode).toBeInstanceOf(Function);
23
25
 
24
26
  jest.clearAllMocks();
25
27
  });
@@ -31,7 +33,7 @@ describe('useTheme', () => {
31
33
  wrapper: (props) => <ThemeProvider theme="personal" {...props} />,
32
34
  });
33
35
 
34
- expect(current).toStrictEqual({
36
+ expect(current).toMatchObject({
35
37
  theme: 'personal',
36
38
  screenMode: DEFAULT_SCREEN_MODE,
37
39
  isModern: true,
@@ -39,6 +41,8 @@ describe('useTheme', () => {
39
41
  isScreenModeDark: false,
40
42
  className: 'np-theme-personal',
41
43
  });
44
+ expect(current.setTheme).toBeInstanceOf(Function);
45
+ expect(current.setScreenMode).toBeInstanceOf(Function);
42
46
  });
43
47
 
44
48
  it('returns forest-green theme', () => {
@@ -48,7 +52,7 @@ describe('useTheme', () => {
48
52
  wrapper: (props) => <ThemeProvider theme="forest-green" {...props} />,
49
53
  });
50
54
 
51
- expect(current).toStrictEqual({
55
+ expect(current).toMatchObject({
52
56
  theme: 'forest-green',
53
57
  screenMode: DEFAULT_SCREEN_MODE,
54
58
  isModern: true,
@@ -56,6 +60,8 @@ describe('useTheme', () => {
56
60
  isScreenModeDark: false,
57
61
  className: 'np-theme-personal np-theme-personal--forest-green',
58
62
  });
63
+ expect(current.setTheme).toBeInstanceOf(Function);
64
+ expect(current.setScreenMode).toBeInstanceOf(Function);
59
65
  });
60
66
 
61
67
  it('returns bright-green theme', () => {
@@ -65,7 +71,7 @@ describe('useTheme', () => {
65
71
  wrapper: (props) => <ThemeProvider theme="bright-green" {...props} />,
66
72
  });
67
73
 
68
- expect(current).toStrictEqual({
74
+ expect(current).toMatchObject({
69
75
  theme: 'bright-green',
70
76
  screenMode: DEFAULT_SCREEN_MODE,
71
77
  isModern: true,
@@ -73,6 +79,8 @@ describe('useTheme', () => {
73
79
  isScreenModeDark: false,
74
80
  className: 'np-theme-personal np-theme-personal--bright-green',
75
81
  });
82
+ expect(current.setTheme).toBeInstanceOf(Function);
83
+ expect(current.setScreenMode).toBeInstanceOf(Function);
76
84
  });
77
85
 
78
86
  it('returns default screen mode if used default light theme', () => {
@@ -82,7 +90,7 @@ describe('useTheme', () => {
82
90
  wrapper: (props) => <ThemeProvider theme={DEFAULT_BASE_THEME} screenMode="dark" {...props} />,
83
91
  });
84
92
 
85
- expect(current).toStrictEqual({
93
+ expect(current).toMatchObject({
86
94
  theme: DEFAULT_BASE_THEME,
87
95
  screenMode: DEFAULT_SCREEN_MODE,
88
96
  isModern: false,
@@ -90,6 +98,8 @@ describe('useTheme', () => {
90
98
  isScreenModeDark: false,
91
99
  className: 'np-theme-light',
92
100
  });
101
+ expect(current.setTheme).toBeInstanceOf(Function);
102
+ expect(current.setScreenMode).toBeInstanceOf(Function);
93
103
  });
94
104
 
95
105
  it('returns dark screen mode', () => {
@@ -99,7 +109,7 @@ describe('useTheme', () => {
99
109
  wrapper: (props) => <ThemeProvider theme="personal" screenMode="dark" {...props} />,
100
110
  });
101
111
 
102
- expect(current).toStrictEqual({
112
+ expect(current).toMatchObject({
103
113
  theme: 'personal',
104
114
  screenMode: 'dark',
105
115
  isModern: true,
@@ -107,8 +117,9 @@ describe('useTheme', () => {
107
117
  isScreenModeDark: true,
108
118
  className: 'np-theme-personal np-theme-personal--dark',
109
119
  });
120
+ expect(current.setTheme).toBeInstanceOf(Function);
121
+ expect(current.setScreenMode).toBeInstanceOf(Function);
110
122
  });
111
-
112
123
  it('warns when used outside a theme provider on staging or localhost', () => {
113
124
  jest.spyOn(console, 'warn').mockImplementation();
114
125
 
@@ -123,7 +134,7 @@ describe('useTheme', () => {
123
134
  result: { current: productionValue },
124
135
  } = renderHook(() => useTheme());
125
136
 
126
- expect(productionValue).toStrictEqual({
137
+ expect(productionValue).toMatchObject({
127
138
  theme: DEFAULT_BASE_THEME,
128
139
  screenMode: DEFAULT_SCREEN_MODE,
129
140
  isModern: false,
@@ -131,6 +142,8 @@ describe('useTheme', () => {
131
142
  isScreenModeDark: false,
132
143
  className: 'np-theme-light',
133
144
  });
145
+ expect(productionValue.setTheme).toBeInstanceOf(Function);
146
+ expect(productionValue.setScreenMode).toBeInstanceOf(Function);
134
147
 
135
148
  // eslint-disable-next-line no-console
136
149
  expect(console.warn).not.toHaveBeenCalled();
@@ -146,7 +159,7 @@ describe('useTheme', () => {
146
159
  result: { current: stagingValue },
147
160
  } = renderHook(() => useTheme());
148
161
 
149
- expect(stagingValue).toStrictEqual({
162
+ expect(stagingValue).toMatchObject({
150
163
  theme: DEFAULT_BASE_THEME,
151
164
  screenMode: DEFAULT_SCREEN_MODE,
152
165
  isModern: false,
@@ -154,6 +167,8 @@ describe('useTheme', () => {
154
167
  isScreenModeDark: false,
155
168
  className: 'np-theme-light',
156
169
  });
170
+ expect(stagingValue.setTheme).toBeInstanceOf(Function);
171
+ expect(stagingValue.setScreenMode).toBeInstanceOf(Function);
157
172
 
158
173
  // eslint-disable-next-line no-console
159
174
  expect(console.warn).toHaveBeenCalledTimes(1);
@@ -169,7 +184,7 @@ describe('useTheme', () => {
169
184
  result: { current: localhostValue },
170
185
  } = renderHook(() => useTheme());
171
186
 
172
- expect(localhostValue).toStrictEqual({
187
+ expect(localhostValue).toMatchObject({
173
188
  theme: DEFAULT_BASE_THEME,
174
189
  screenMode: DEFAULT_SCREEN_MODE,
175
190
  isModern: false,
@@ -177,6 +192,8 @@ describe('useTheme', () => {
177
192
  isScreenModeDark: false,
178
193
  className: 'np-theme-light',
179
194
  });
195
+ expect(localhostValue.setTheme).toBeInstanceOf(Function);
196
+ expect(localhostValue.setScreenMode).toBeInstanceOf(Function);
180
197
 
181
198
  // eslint-disable-next-line no-console
182
199
  expect(console.warn).toHaveBeenCalledTimes(2);
@@ -190,7 +207,7 @@ describe('useTheme', () => {
190
207
  result: { current: noHostnameValue },
191
208
  } = renderHook(() => useTheme());
192
209
 
193
- expect(noHostnameValue).toStrictEqual({
210
+ expect(noHostnameValue).toMatchObject({
194
211
  theme: DEFAULT_BASE_THEME,
195
212
  screenMode: DEFAULT_SCREEN_MODE,
196
213
  isModern: false,
@@ -198,6 +215,8 @@ describe('useTheme', () => {
198
215
  isScreenModeDark: false,
199
216
  className: 'np-theme-light',
200
217
  });
218
+ expect(noHostnameValue.setTheme).toBeInstanceOf(Function);
219
+ expect(noHostnameValue.setScreenMode).toBeInstanceOf(Function);
201
220
 
202
221
  // eslint-disable-next-line no-console
203
222
  expect(console.warn).toHaveBeenCalledTimes(2);
package/src/useTheme.ts CHANGED
@@ -12,11 +12,15 @@ interface ThemeHookValue {
12
12
  isForestGreenTheme: boolean;
13
13
  isScreenModeDark: boolean;
14
14
  className: string;
15
+ setTheme: (theme: NonNullable<Theming['theme']>) => void;
16
+ setScreenMode: (screenMode: ScreenMode) => void;
15
17
  }
16
18
 
17
19
  const FALLBACK_VALUES = {
18
20
  theme: DEFAULT_BASE_THEME,
19
21
  screenMode: DEFAULT_SCREEN_MODE,
22
+ setTheme: () => {},
23
+ setScreenMode: () => {},
20
24
  } as const;
21
25
 
22
26
  const isNotProduction = () => {
@@ -35,7 +39,12 @@ export const useTheme = (): ThemeHookValue => {
35
39
  console.warn('Call to useTheme outside a ThemeProvider');
36
40
  }
37
41
 
38
- const { theme, screenMode: contextScreenMode } = theming ?? FALLBACK_VALUES;
42
+ const {
43
+ theme,
44
+ screenMode: contextScreenMode,
45
+ setTheme,
46
+ setScreenMode,
47
+ } = theming ?? FALLBACK_VALUES;
39
48
 
40
49
  const screenMode = theme === DEFAULT_BASE_THEME ? DEFAULT_SCREEN_MODE : contextScreenMode;
41
50
 
@@ -47,7 +56,9 @@ export const useTheme = (): ThemeHookValue => {
47
56
  isForestGreenTheme: isForestGreenTheme(theme),
48
57
  isScreenModeDark: isScreenModeDark(theme, screenMode),
49
58
  className: getThemeClassName(theme, screenMode),
59
+ setTheme,
60
+ setScreenMode,
50
61
  }),
51
- [theme, screenMode],
62
+ [theme, screenMode, setTheme, setScreenMode],
52
63
  );
53
64
  };