@wise/components-theming 0.0.0-experimental-c043dab → 0.0.0-experimental-10d0572

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, children, className, isNotRootProvider, }: ThemeProviderProps) => import("react").JSX.Element;
6
+ export declare const ThemeProvider: ({ theme, screenMode, 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,gCAqCpB,CAAC"}
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"}
@@ -11,9 +11,9 @@ const themeClass = /\bnp-theme-[a-z-]+\b/g;
11
11
  const ThemeProvider = ({
12
12
  theme = _const.DEFAULT_BASE_THEME,
13
13
  screenMode = _const.DEFAULT_SCREEN_MODE,
14
+ isNotRootProvider = false,
14
15
  children,
15
- className = undefined,
16
- isNotRootProvider = false
16
+ className = undefined
17
17
  }) => {
18
18
  const isContextRoot = react.useContext(ThemeProviderContext.ThemeContext) === undefined;
19
19
  // useEffect hook used to apply the theme class to the HTML element
@@ -23,19 +23,9 @@ const ThemeProvider = ({
23
23
  document.documentElement.className.match(themeClass)?.forEach(item => {
24
24
  document.documentElement.classList.remove(item);
25
25
  });
26
- const themeClasses = helpers.getThemeClassName(theme, screenMode).split(' ');
27
- // Auto-detection: Add np-theme-personal for business and platform themes when this is a root provider (page wrapper)
28
- const isBusinessTheme = theme === 'business' || theme?.startsWith('business');
29
- const isPlatformTheme = theme === 'platform' || theme?.startsWith('platform');
30
- const shouldAddPersonalClass = (isBusinessTheme || isPlatformTheme) && !isNotRootProvider;
31
- // Apply theme classes
32
- themeClasses.forEach(item => {
26
+ helpers.getThemeClassName(theme, screenMode).split(' ').forEach(item => {
33
27
  document.documentElement.classList.add(item);
34
28
  });
35
- // Add np-theme-personal for business and platform themes only in root provider (page wrapper)
36
- if (shouldAddPersonalClass) {
37
- document.documentElement.classList.add('np-theme-personal');
38
- }
39
29
  }
40
30
  }, [isNotRootProvider, isContextRoot, theme, screenMode]);
41
31
  const contextValue = react.useMemo(() => ({
@@ -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 children,\n className = undefined,\n isNotRootProvider = false,\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\n const themeClasses = getThemeClassName(theme, screenMode).split(' ');\n\n // Auto-detection: Add np-theme-personal for business and platform themes when this is a root provider (page wrapper)\n const isBusinessTheme = theme === 'business' || theme?.startsWith('business');\n const isPlatformTheme = theme === 'platform' || theme?.startsWith('platform');\n const shouldAddPersonalClass = (isBusinessTheme || isPlatformTheme) && !isNotRootProvider;\n\n // Apply theme classes\n themeClasses.forEach((item) => {\n document.documentElement.classList.add(item);\n });\n\n // Add np-theme-personal for business and platform themes only in root provider (page wrapper)\n if (shouldAddPersonalClass) {\n document.documentElement.classList.add('np-theme-personal');\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","children","className","undefined","isNotRootProvider","isContextRoot","useContext","ThemeContext","useEffect","document","documentElement","match","forEach","item","classList","remove","themeClasses","getThemeClassName","split","isBusinessTheme","startsWith","isPlatformTheme","shouldAddPersonalClass","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;EAChCC,QAAQ;AACRC,EAAAA,SAAS,GAAGC,SAAS;AACrBC,EAAAA,iBAAiB,GAAG;AAAK,CACN,KAAI;AACvB,EAAA,MAAMC,aAAa,GAAGC,gBAAU,CAACC,iCAAY,CAAC,KAAKJ,SAAS;AAE5D;AACAK,EAAAA,eAAS,CAAC,MAAK;AACb,IAAA,IAAI,CAACJ,iBAAiB,IAAIC,aAAa,EAAE;AACvC;AACAI,MAAAA,QAAQ,CAACC,eAAe,CAACR,SAAS,CAACS,KAAK,CAAChB,UAAU,CAAC,EAAEiB,OAAO,CAAEC,IAAI,IAAI;QACrEJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACC,MAAM,CAACF,IAAI,CAAC;AACjD,MAAA,CAAC,CAAC;AAEF,MAAA,MAAMG,YAAY,GAAGC,yBAAiB,CAACpB,KAAK,EAAEE,UAAU,CAAC,CAACmB,KAAK,CAAC,GAAG,CAAC;AAEpE;MACA,MAAMC,eAAe,GAAGtB,KAAK,KAAK,UAAU,IAAIA,KAAK,EAAEuB,UAAU,CAAC,UAAU,CAAC;MAC7E,MAAMC,eAAe,GAAGxB,KAAK,KAAK,UAAU,IAAIA,KAAK,EAAEuB,UAAU,CAAC,UAAU,CAAC;MAC7E,MAAME,sBAAsB,GAAG,CAACH,eAAe,IAAIE,eAAe,KAAK,CAACjB,iBAAiB;AAEzF;AACAY,MAAAA,YAAY,CAACJ,OAAO,CAAEC,IAAI,IAAI;QAC5BJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACS,GAAG,CAACV,IAAI,CAAC;AAC9C,MAAA,CAAC,CAAC;AAEF;AACA,MAAA,IAAIS,sBAAsB,EAAE;QAC1Bb,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACS,GAAG,CAAC,mBAAmB,CAAC;AAC7D,MAAA;AACF,IAAA;EACF,CAAC,EAAE,CAACnB,iBAAiB,EAAEC,aAAa,EAAER,KAAK,EAAEE,UAAU,CAAC,CAAC;AAEzD,EAAA,MAAMyB,YAAY,GAAGC,aAAO,CAAC,OAAO;IAAE5B,KAAK;AAAEE,IAAAA;AAAU,GAAE,CAAC,EAAE,CAACA,UAAU,EAAEF,KAAK,CAAC,CAAC;AAEhF,EAAA,oBACE6B,cAAA,CAACnB,iCAAY,CAACoB,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEJ,YAAa;IAAAvB,QAAA,eACzCyB,cAAA,CAACG,6BAAc,EAAA;AAAC3B,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 } 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,6 +1,6 @@
1
1
  import { useContext, useEffect, useMemo } from 'react';
2
2
  import { ThemedChildren } from './ThemedChildren.mjs';
3
- import { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const.mjs';
3
+ import { DEFAULT_SCREEN_MODE, DEFAULT_BASE_THEME } 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';
@@ -9,9 +9,9 @@ const themeClass = /\bnp-theme-[a-z-]+\b/g;
9
9
  const ThemeProvider = ({
10
10
  theme = DEFAULT_BASE_THEME,
11
11
  screenMode = DEFAULT_SCREEN_MODE,
12
+ isNotRootProvider = false,
12
13
  children,
13
- className = undefined,
14
- isNotRootProvider = false
14
+ className = undefined
15
15
  }) => {
16
16
  const isContextRoot = useContext(ThemeContext) === undefined;
17
17
  // useEffect hook used to apply the theme class to the HTML element
@@ -21,19 +21,9 @@ const ThemeProvider = ({
21
21
  document.documentElement.className.match(themeClass)?.forEach(item => {
22
22
  document.documentElement.classList.remove(item);
23
23
  });
24
- const themeClasses = getThemeClassName(theme, screenMode).split(' ');
25
- // Auto-detection: Add np-theme-personal for business and platform themes when this is a root provider (page wrapper)
26
- const isBusinessTheme = theme === 'business' || theme?.startsWith('business');
27
- const isPlatformTheme = theme === 'platform' || theme?.startsWith('platform');
28
- const shouldAddPersonalClass = (isBusinessTheme || isPlatformTheme) && !isNotRootProvider;
29
- // Apply theme classes
30
- themeClasses.forEach(item => {
24
+ getThemeClassName(theme, screenMode).split(' ').forEach(item => {
31
25
  document.documentElement.classList.add(item);
32
26
  });
33
- // Add np-theme-personal for business and platform themes only in root provider (page wrapper)
34
- if (shouldAddPersonalClass) {
35
- document.documentElement.classList.add('np-theme-personal');
36
- }
37
27
  }
38
28
  }, [isNotRootProvider, isContextRoot, theme, screenMode]);
39
29
  const contextValue = useMemo(() => ({
@@ -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 children,\n className = undefined,\n isNotRootProvider = false,\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\n const themeClasses = getThemeClassName(theme, screenMode).split(' ');\n\n // Auto-detection: Add np-theme-personal for business and platform themes when this is a root provider (page wrapper)\n const isBusinessTheme = theme === 'business' || theme?.startsWith('business');\n const isPlatformTheme = theme === 'platform' || theme?.startsWith('platform');\n const shouldAddPersonalClass = (isBusinessTheme || isPlatformTheme) && !isNotRootProvider;\n\n // Apply theme classes\n themeClasses.forEach((item) => {\n document.documentElement.classList.add(item);\n });\n\n // Add np-theme-personal for business and platform themes only in root provider (page wrapper)\n if (shouldAddPersonalClass) {\n document.documentElement.classList.add('np-theme-personal');\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","children","className","undefined","isNotRootProvider","isContextRoot","useContext","ThemeContext","useEffect","document","documentElement","match","forEach","item","classList","remove","themeClasses","getThemeClassName","split","isBusinessTheme","startsWith","isPlatformTheme","shouldAddPersonalClass","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;EAChCC,QAAQ;AACRC,EAAAA,SAAS,GAAGC,SAAS;AACrBC,EAAAA,iBAAiB,GAAG;AAAK,CACN,KAAI;AACvB,EAAA,MAAMC,aAAa,GAAGC,UAAU,CAACC,YAAY,CAAC,KAAKJ,SAAS;AAE5D;AACAK,EAAAA,SAAS,CAAC,MAAK;AACb,IAAA,IAAI,CAACJ,iBAAiB,IAAIC,aAAa,EAAE;AACvC;AACAI,MAAAA,QAAQ,CAACC,eAAe,CAACR,SAAS,CAACS,KAAK,CAAChB,UAAU,CAAC,EAAEiB,OAAO,CAAEC,IAAI,IAAI;QACrEJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACC,MAAM,CAACF,IAAI,CAAC;AACjD,MAAA,CAAC,CAAC;AAEF,MAAA,MAAMG,YAAY,GAAGC,iBAAiB,CAACpB,KAAK,EAAEE,UAAU,CAAC,CAACmB,KAAK,CAAC,GAAG,CAAC;AAEpE;MACA,MAAMC,eAAe,GAAGtB,KAAK,KAAK,UAAU,IAAIA,KAAK,EAAEuB,UAAU,CAAC,UAAU,CAAC;MAC7E,MAAMC,eAAe,GAAGxB,KAAK,KAAK,UAAU,IAAIA,KAAK,EAAEuB,UAAU,CAAC,UAAU,CAAC;MAC7E,MAAME,sBAAsB,GAAG,CAACH,eAAe,IAAIE,eAAe,KAAK,CAACjB,iBAAiB;AAEzF;AACAY,MAAAA,YAAY,CAACJ,OAAO,CAAEC,IAAI,IAAI;QAC5BJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACS,GAAG,CAACV,IAAI,CAAC;AAC9C,MAAA,CAAC,CAAC;AAEF;AACA,MAAA,IAAIS,sBAAsB,EAAE;QAC1Bb,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACS,GAAG,CAAC,mBAAmB,CAAC;AAC7D,MAAA;AACF,IAAA;EACF,CAAC,EAAE,CAACnB,iBAAiB,EAAEC,aAAa,EAAER,KAAK,EAAEE,UAAU,CAAC,CAAC;AAEzD,EAAA,MAAMyB,YAAY,GAAGC,OAAO,CAAC,OAAO;IAAE5B,KAAK;AAAEE,IAAAA;AAAU,GAAE,CAAC,EAAE,CAACA,UAAU,EAAEF,KAAK,CAAC,CAAC;AAEhF,EAAA,oBACE6B,GAAA,CAACnB,YAAY,CAACoB,QAAQ,EAAA;AAACC,IAAAA,KAAK,EAAEJ,YAAa;IAAAvB,QAAA,eACzCyB,GAAA,CAACG,cAAc,EAAA;AAAC3B,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 } 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;;;;"}
package/dist/const.js CHANGED
@@ -5,12 +5,14 @@ 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'];
8
9
  const DEFAULT_BASE_THEME = 'light';
9
10
  const DEFAULT_SCREEN_MODE = 'light';
10
11
 
11
12
  exports.DEFAULT_BASE_THEME = DEFAULT_BASE_THEME;
12
13
  exports.DEFAULT_SCREEN_MODE = DEFAULT_SCREEN_MODE;
13
14
  exports.baseThemes = baseThemes;
15
+ exports.businessThemes = businessThemes;
14
16
  exports.extraThemes = extraThemes;
15
17
  exports.modernThemes = modernThemes;
16
18
  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","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
+ {"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;;;;;;;;;;"}
package/dist/const.mjs CHANGED
@@ -3,8 +3,9 @@ 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'];
6
7
  const DEFAULT_BASE_THEME = 'light';
7
8
  const DEFAULT_SCREEN_MODE = 'light';
8
9
 
9
- export { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE, baseThemes, extraThemes, modernThemes, screenModes };
10
+ export { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE, baseThemes, businessThemes, extraThemes, modernThemes, screenModes };
10
11
  //# 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","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
+ {"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 +1 @@
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,WAc7F,CAAC"}
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"}
package/dist/helpers.js CHANGED
@@ -7,16 +7,38 @@ 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
- if (!isThemeModern(theme)) {
11
- return `np-theme-${theme || 'personal'}`;
10
+ // Legacy themes
11
+ if (theme === 'light') {
12
+ return `np-theme-${theme}`;
12
13
  }
13
- let classes = `np-theme-${theme === 'business' ? 'business' : 'personal'}`;
14
- if (isExtraTheme(theme)) {
15
- classes += ` ${classes}--${theme}`;
16
- } else if (_const.screenModes[1] === screenMode) {
17
- classes += ` ${classes}--${screenMode}`;
14
+ // Personal light is always there by default
15
+ const themeClasses = ['np-theme-personal'];
16
+ // Personal dark theme
17
+ if (theme === 'personal' && _const.screenModes[1] === screenMode) {
18
+ themeClasses.push(`np-theme-personal--${screenMode}`);
18
19
  }
19
- return classes;
20
+ // Personal forest-green and bright-green themes
21
+ else if (isExtraTheme(theme)) {
22
+ themeClasses.push(`np-theme-personal--${theme}`);
23
+ }
24
+ // Business light
25
+ else if (_const.businessThemes[0] === theme) {
26
+ themeClasses.push(`np-theme-business`);
27
+ // Business dark theme
28
+ if (_const.screenModes[1] === screenMode) {
29
+ themeClasses.push(`np-theme-business--${screenMode}`);
30
+ }
31
+ }
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)) {
35
+ themeClasses.push(`np-theme-${theme}`);
36
+ }
37
+ // Platform themes
38
+ else if (theme.startsWith('platform')) {
39
+ themeClasses.push(`np-theme-${theme}`);
40
+ }
41
+ return themeClasses.join(' ');
20
42
  };
21
43
 
22
44
  exports.getThemeClassName = getThemeClassName;
@@ -1 +1 @@
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 (!isThemeModern(theme)) {\n return `np-theme-${theme || 'personal'}`;\n }\n\n let classes = `np-theme-${theme === 'business' ? 'business' : 'personal'}`;\n\n if (isExtraTheme(theme)) {\n classes += ` ${classes}--${theme}`;\n } else if (screenModes[1] === screenMode) {\n classes += ` ${classes}--${screenMode}`;\n }\n\n return classes;\n};\n"],"names":["isThemeModern","theme","modernThemes","includes","isExtraTheme","extraThemes","isForestGreenTheme","isScreenModeDark","screenMode","screenModes","getThemeClassName","classes"],"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;AAChG,EAAA,IAAI,CAACR,aAAa,CAACC,KAAK,CAAC,EAAE;AACzB,IAAA,OAAO,CAAA,SAAA,EAAYA,KAAK,IAAI,UAAU,CAAA,CAAE;AAC1C,EAAA;EAEA,IAAIU,OAAO,GAAG,CAAA,SAAA,EAAYV,KAAK,KAAK,UAAU,GAAG,UAAU,GAAG,UAAU,CAAA,CAAE;AAE1E,EAAA,IAAIG,YAAY,CAACH,KAAK,CAAC,EAAE;AACvBU,IAAAA,OAAO,IAAI,CAAA,CAAA,EAAIA,OAAO,CAAA,EAAA,EAAKV,KAAK,CAAA,CAAE;EACpC,CAAC,MAAM,IAAIQ,kBAAW,CAAC,CAAC,CAAC,KAAKD,UAAU,EAAE;AACxCG,IAAAA,OAAO,IAAI,CAAA,CAAA,EAAIA,OAAO,CAAA,EAAA,EAAKH,UAAU,CAAA,CAAE;AACzC,EAAA;AAEA,EAAA,OAAOG,OAAO;AAChB;;;;;;;;"}
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;;;;;;;;"}
package/dist/helpers.mjs CHANGED
@@ -1,20 +1,42 @@
1
- import { modernThemes, extraThemes, screenModes } from './const.mjs';
1
+ import { modernThemes, extraThemes, screenModes, businessThemes } 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
- if (!isThemeModern(theme)) {
9
- return `np-theme-${theme || 'personal'}`;
8
+ // Legacy themes
9
+ if (theme === 'light') {
10
+ return `np-theme-${theme}`;
10
11
  }
11
- let classes = `np-theme-${theme === 'business' ? 'business' : 'personal'}`;
12
- if (isExtraTheme(theme)) {
13
- classes += ` ${classes}--${theme}`;
14
- } else if (screenModes[1] === screenMode) {
15
- classes += ` ${classes}--${screenMode}`;
12
+ // Personal light is always there by default
13
+ const themeClasses = ['np-theme-personal'];
14
+ // Personal dark theme
15
+ if (theme === 'personal' && screenModes[1] === screenMode) {
16
+ themeClasses.push(`np-theme-personal--${screenMode}`);
16
17
  }
17
- return classes;
18
+ // Personal forest-green and bright-green themes
19
+ else if (isExtraTheme(theme)) {
20
+ themeClasses.push(`np-theme-personal--${theme}`);
21
+ }
22
+ // Business light
23
+ else if (businessThemes[0] === theme) {
24
+ themeClasses.push(`np-theme-business`);
25
+ // Business dark theme
26
+ if (screenModes[1] === screenMode) {
27
+ themeClasses.push(`np-theme-business--${screenMode}`);
28
+ }
29
+ }
30
+ // Business forest-green and bright-green themes
31
+ // @ts-expect-error relax TS
32
+ else if ([businessThemes[1], businessThemes[2]].includes(theme)) {
33
+ themeClasses.push(`np-theme-${theme}`);
34
+ }
35
+ // Platform themes
36
+ else if (theme.startsWith('platform')) {
37
+ themeClasses.push(`np-theme-${theme}`);
38
+ }
39
+ return themeClasses.join(' ');
18
40
  };
19
41
 
20
42
  export { getThemeClassName, isExtraTheme, isForestGreenTheme, isScreenModeDark, isThemeModern };
@@ -1 +1 @@
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 (!isThemeModern(theme)) {\n return `np-theme-${theme || 'personal'}`;\n }\n\n let classes = `np-theme-${theme === 'business' ? 'business' : 'personal'}`;\n\n if (isExtraTheme(theme)) {\n classes += ` ${classes}--${theme}`;\n } else if (screenModes[1] === screenMode) {\n classes += ` ${classes}--${screenMode}`;\n }\n\n return classes;\n};\n"],"names":["isThemeModern","theme","modernThemes","includes","isExtraTheme","extraThemes","isForestGreenTheme","isScreenModeDark","screenMode","screenModes","getThemeClassName","classes"],"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;AAChG,EAAA,IAAI,CAACR,aAAa,CAACC,KAAK,CAAC,EAAE;AACzB,IAAA,OAAO,CAAA,SAAA,EAAYA,KAAK,IAAI,UAAU,CAAA,CAAE;AAC1C,EAAA;EAEA,IAAIU,OAAO,GAAG,CAAA,SAAA,EAAYV,KAAK,KAAK,UAAU,GAAG,UAAU,GAAG,UAAU,CAAA,CAAE;AAE1E,EAAA,IAAIG,YAAY,CAACH,KAAK,CAAC,EAAE;AACvBU,IAAAA,OAAO,IAAI,CAAA,CAAA,EAAIA,OAAO,CAAA,EAAA,EAAKV,KAAK,CAAA,CAAE;EACpC,CAAC,MAAM,IAAIQ,WAAW,CAAC,CAAC,CAAC,KAAKD,UAAU,EAAE;AACxCG,IAAAA,OAAO,IAAI,CAAA,CAAA,EAAIA,OAAO,CAAA,EAAA,EAAKH,UAAU,CAAA,CAAE;AACzC,EAAA;AAEA,EAAA,OAAOG,OAAO;AAChB;;;;"}
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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/components-theming",
3
- "version": "0.0.0-experimental-c043dab",
3
+ "version": "0.0.0-experimental-10d0572",
4
4
  "description": "Provides theming support for the Wise Design system components",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -14,9 +14,9 @@ const themeClass = /\bnp-theme-[a-z-]+\b/g;
14
14
  export const ThemeProvider = ({
15
15
  theme = DEFAULT_BASE_THEME,
16
16
  screenMode = DEFAULT_SCREEN_MODE,
17
+ isNotRootProvider = false,
17
18
  children,
18
19
  className = undefined,
19
- isNotRootProvider = false,
20
20
  }: ThemeProviderProps) => {
21
21
  const isContextRoot = useContext(ThemeContext) === undefined;
22
22
 
@@ -27,23 +27,11 @@ export const ThemeProvider = ({
27
27
  document.documentElement.className.match(themeClass)?.forEach((item) => {
28
28
  document.documentElement.classList.remove(item);
29
29
  });
30
-
31
- const themeClasses = getThemeClassName(theme, screenMode).split(' ');
32
-
33
- // Auto-detection: Add np-theme-personal for business and platform themes when this is a root provider (page wrapper)
34
- const isBusinessTheme = theme === 'business' || theme?.startsWith('business');
35
- const isPlatformTheme = theme === 'platform' || theme?.startsWith('platform');
36
- const shouldAddPersonalClass = (isBusinessTheme || isPlatformTheme) && !isNotRootProvider;
37
-
38
- // Apply theme classes
39
- themeClasses.forEach((item) => {
40
- document.documentElement.classList.add(item);
41
- });
42
-
43
- // Add np-theme-personal for business and platform themes only in root provider (page wrapper)
44
- if (shouldAddPersonalClass) {
45
- document.documentElement.classList.add('np-theme-personal');
46
- }
30
+ getThemeClassName(theme, screenMode)
31
+ .split(' ')
32
+ .forEach((item) => {
33
+ document.documentElement.classList.add(item);
34
+ });
47
35
  }
48
36
  }, [isNotRootProvider, isContextRoot, theme, screenMode]);
49
37
 
package/src/helpers.ts CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable functional/immutable-data */
1
2
  import type {
2
3
  ModernTheme,
3
4
  ExtraTheme,
@@ -6,7 +7,7 @@ import type {
6
7
  ScreenModeDark,
7
8
  Theming,
8
9
  } from './const';
9
- import { extraThemes, screenModes, modernThemes } from './const';
10
+ import { extraThemes, screenModes, modernThemes, businessThemes } from './const';
10
11
 
11
12
  export const isThemeModern = (theme: NonNullable<Theming['theme']>): theme is ModernTheme =>
12
13
  modernThemes.includes(theme as ModernTheme);
@@ -25,17 +26,43 @@ export const isScreenModeDark = (
25
26
  isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;
26
27
 
27
28
  export const getThemeClassName = (theme: NonNullable<Theming['theme']>, screenMode: ScreenMode) => {
28
- if (!isThemeModern(theme)) {
29
- return `np-theme-${theme || 'personal'}`;
29
+ // Legacy themes
30
+ if (theme === 'light') {
31
+ return `np-theme-${theme}`;
30
32
  }
31
33
 
32
- let classes = `np-theme-${theme === 'business' ? 'business' : 'personal'}`;
34
+ // Personal light is always there by default
35
+ const themeClasses = ['np-theme-personal'];
33
36
 
34
- if (isExtraTheme(theme)) {
35
- classes += ` ${classes}--${theme}`;
36
- } else if (screenModes[1] === screenMode) {
37
- classes += ` ${classes}--${screenMode}`;
37
+ // Personal dark theme
38
+ if (theme === 'personal' && screenModes[1] === screenMode) {
39
+ themeClasses.push(`np-theme-personal--${screenMode}`);
38
40
  }
39
41
 
40
- return classes;
42
+ // Personal forest-green and bright-green themes
43
+ else if (isExtraTheme(theme)) {
44
+ themeClasses.push(`np-theme-personal--${theme}`);
45
+ }
46
+
47
+ // Business light
48
+ else if (businessThemes[0] === theme) {
49
+ themeClasses.push(`np-theme-business`);
50
+ // Business dark theme
51
+ if (screenModes[1] === screenMode) {
52
+ themeClasses.push(`np-theme-business--${screenMode}`);
53
+ }
54
+ }
55
+
56
+ // Business forest-green and bright-green themes
57
+ // @ts-expect-error relax TS
58
+ else if ([businessThemes[1], businessThemes[2]].includes(theme)) {
59
+ themeClasses.push(`np-theme-${theme}`);
60
+ }
61
+
62
+ // Platform themes
63
+ else if (theme.startsWith('platform')) {
64
+ themeClasses.push(`np-theme-${theme}`);
65
+ }
66
+
67
+ return themeClasses.join(' ');
41
68
  };