@wise/components-theming 0.0.0-experimental-128143a → 0.0.0-experimental-161f697

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, }: ThemeProviderProps) => import("react").JSX.Element;
6
+ export declare const ThemeProvider: ({ theme, screenMode, children, className, isNotRootProvider, }: 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,6CAK3B,kBAAkB,gCAyBpB,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,gCAkCpB,CAAC"}
@@ -12,9 +12,11 @@ const ThemeProvider = ({
12
12
  theme = _const.DEFAULT_BASE_THEME,
13
13
  screenMode = _const.DEFAULT_SCREEN_MODE,
14
14
  children,
15
- className = undefined
15
+ className = undefined,
16
+ isNotRootProvider = undefined
16
17
  }) => {
17
- const isContextRoot = react.useContext(ThemeProviderContext.ThemeContext) === undefined;
18
+ const contextExists = react.useContext(ThemeProviderContext.ThemeContext) !== undefined;
19
+ const isContextRoot = isNotRootProvider !== undefined ? !isNotRootProvider : !contextExists;
18
20
  // useEffect hook used to apply the theme class to the HTML element
19
21
  react.useEffect(() => {
20
22
  if (isContextRoot) {
@@ -22,9 +24,16 @@ const ThemeProvider = ({
22
24
  document.documentElement.className.match(themeClass)?.forEach(item => {
23
25
  document.documentElement.classList.remove(item);
24
26
  });
25
- helpers.getThemeClassName(theme, screenMode).split(' ').forEach(item => {
27
+ const themeClasses = helpers.getThemeClassName(theme, screenMode).split(' ');
28
+ themeClasses.forEach(item => {
26
29
  document.documentElement.classList.add(item);
27
30
  });
31
+ // Add np-theme-personal for business and platform themes at root level only
32
+ const isBusinessTheme = theme === 'business' || theme?.startsWith('business');
33
+ const isPlatformTheme = theme === 'platform' || theme?.startsWith('platform');
34
+ if (isBusinessTheme || isPlatformTheme) {
35
+ document.documentElement.classList.add('np-theme-personal');
36
+ }
28
37
  }
29
38
  }, [isContextRoot, theme, screenMode]);
30
39
  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}: 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 (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 }, [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","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;EAChCC,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,IAAIH,aAAa,EAAE;AACjB;AACAI,MAAAA,QAAQ,CAACC,eAAe,CAACP,SAAS,CAACQ,KAAK,CAACf,UAAU,CAAC,EAAEgB,OAAO,CAAEC,IAAI,IAAI;QACrEJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACC,MAAM,CAACF,IAAI,CAAC;AACjD,MAAA,CAAC,CAAC;AACFG,MAAAA,yBAAiB,CAAClB,KAAK,EAAEE,UAAU,CAAC,CACjCiB,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,CAACR,aAAa,EAAEP,KAAK,EAAEE,UAAU,CAAC,CAAC;AAEtC,EAAA,MAAMmB,YAAY,GAAGC,aAAO,CAAC,OAAO;IAAEtB,KAAK;AAAEE,IAAAA;AAAU,GAAE,CAAC,EAAE,CAACA,UAAU,EAAEF,KAAK,CAAC,CAAC;AAEhF,EAAA,oBACEuB,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 } 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 = undefined,\n}: ThemeProviderProps) => {\n const contextExists = useContext(ThemeContext) !== undefined;\n const isContextRoot = isNotRootProvider !== undefined ? !isNotRootProvider : !contextExists;\n\n // useEffect hook used to apply the theme class to the HTML element\n useEffect(() => {\n if (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 themeClasses.forEach((item) => {\n document.documentElement.classList.add(item);\n });\n\n // Add np-theme-personal for business and platform themes at root level only\n const isBusinessTheme = theme === 'business' || theme?.startsWith('business');\n const isPlatformTheme = theme === 'platform' || theme?.startsWith('platform');\n\n if (isBusinessTheme || isPlatformTheme) {\n document.documentElement.classList.add('np-theme-personal');\n }\n }\n }, [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","contextExists","useContext","ThemeContext","isContextRoot","useEffect","document","documentElement","match","forEach","item","classList","remove","themeClasses","getThemeClassName","split","add","isBusinessTheme","startsWith","isPlatformTheme","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,GAAGD;AAAS,CACV,KAAI;AACvB,EAAA,MAAME,aAAa,GAAGC,gBAAU,CAACC,iCAAY,CAAC,KAAKJ,SAAS;EAC5D,MAAMK,aAAa,GAAGJ,iBAAiB,KAAKD,SAAS,GAAG,CAACC,iBAAiB,GAAG,CAACC,aAAa;AAE3F;AACAI,EAAAA,eAAS,CAAC,MAAK;AACb,IAAA,IAAID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AAuB,CAAC;AAE5B;;;;"}
@@ -10,9 +10,11 @@ const ThemeProvider = ({
10
10
  theme = DEFAULT_BASE_THEME,
11
11
  screenMode = DEFAULT_SCREEN_MODE,
12
12
  children,
13
- className = undefined
13
+ className = undefined,
14
+ isNotRootProvider = undefined
14
15
  }) => {
15
- const isContextRoot = useContext(ThemeContext) === undefined;
16
+ const contextExists = useContext(ThemeContext) !== undefined;
17
+ const isContextRoot = isNotRootProvider !== undefined ? !isNotRootProvider : !contextExists;
16
18
  // useEffect hook used to apply the theme class to the HTML element
17
19
  useEffect(() => {
18
20
  if (isContextRoot) {
@@ -20,9 +22,16 @@ const ThemeProvider = ({
20
22
  document.documentElement.className.match(themeClass)?.forEach(item => {
21
23
  document.documentElement.classList.remove(item);
22
24
  });
23
- getThemeClassName(theme, screenMode).split(' ').forEach(item => {
25
+ const themeClasses = getThemeClassName(theme, screenMode).split(' ');
26
+ themeClasses.forEach(item => {
24
27
  document.documentElement.classList.add(item);
25
28
  });
29
+ // Add np-theme-personal for business and platform themes at root level only
30
+ const isBusinessTheme = theme === 'business' || theme?.startsWith('business');
31
+ const isPlatformTheme = theme === 'platform' || theme?.startsWith('platform');
32
+ if (isBusinessTheme || isPlatformTheme) {
33
+ document.documentElement.classList.add('np-theme-personal');
34
+ }
26
35
  }
27
36
  }, [isContextRoot, theme, screenMode]);
28
37
  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}: 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 (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 }, [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","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;EAChCC,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,IAAIH,aAAa,EAAE;AACjB;AACAI,MAAAA,QAAQ,CAACC,eAAe,CAACP,SAAS,CAACQ,KAAK,CAACf,UAAU,CAAC,EAAEgB,OAAO,CAAEC,IAAI,IAAI;QACrEJ,QAAQ,CAACC,eAAe,CAACI,SAAS,CAACC,MAAM,CAACF,IAAI,CAAC;AACjD,MAAA,CAAC,CAAC;AACFG,MAAAA,iBAAiB,CAAClB,KAAK,EAAEE,UAAU,CAAC,CACjCiB,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,CAACR,aAAa,EAAEP,KAAK,EAAEE,UAAU,CAAC,CAAC;AAEtC,EAAA,MAAMmB,YAAY,GAAGC,OAAO,CAAC,OAAO;IAAEtB,KAAK;AAAEE,IAAAA;AAAU,GAAE,CAAC,EAAE,CAACA,UAAU,EAAEF,KAAK,CAAC,CAAC;AAEhF,EAAA,oBACEuB,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 } 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 = undefined,\n}: ThemeProviderProps) => {\n const contextExists = useContext(ThemeContext) !== undefined;\n const isContextRoot = isNotRootProvider !== undefined ? !isNotRootProvider : !contextExists;\n\n // useEffect hook used to apply the theme class to the HTML element\n useEffect(() => {\n if (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 themeClasses.forEach((item) => {\n document.documentElement.classList.add(item);\n });\n\n // Add np-theme-personal for business and platform themes at root level only\n const isBusinessTheme = theme === 'business' || theme?.startsWith('business');\n const isPlatformTheme = theme === 'platform' || theme?.startsWith('platform');\n\n if (isBusinessTheme || isPlatformTheme) {\n document.documentElement.classList.add('np-theme-personal');\n }\n }\n }, [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","contextExists","useContext","ThemeContext","isContextRoot","useEffect","document","documentElement","match","forEach","item","classList","remove","themeClasses","getThemeClassName","split","add","isBusinessTheme","startsWith","isPlatformTheme","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,GAAGD;AAAS,CACV,KAAI;AACvB,EAAA,MAAME,aAAa,GAAGC,UAAU,CAACC,YAAY,CAAC,KAAKJ,SAAS;EAC5D,MAAMK,aAAa,GAAGJ,iBAAiB,KAAKD,SAAS,GAAG,CAACC,iBAAiB,GAAG,CAACC,aAAa;AAE3F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AU;AAAAD,MAAAA,QAAA,EAAEA;KAAyB;AAClE,GAAuB,CAAC;AAE5B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/components-theming",
3
- "version": "0.0.0-experimental-128143a",
3
+ "version": "0.0.0-experimental-161f697",
4
4
  "description": "Provides theming support for the Wise Design system components",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -16,8 +16,10 @@ export const ThemeProvider = ({
16
16
  screenMode = DEFAULT_SCREEN_MODE,
17
17
  children,
18
18
  className = undefined,
19
+ isNotRootProvider = undefined,
19
20
  }: ThemeProviderProps) => {
20
- const isContextRoot = useContext(ThemeContext) === undefined;
21
+ const contextExists = useContext(ThemeContext) !== undefined;
22
+ const isContextRoot = isNotRootProvider !== undefined ? !isNotRootProvider : !contextExists;
21
23
 
22
24
  // useEffect hook used to apply the theme class to the HTML element
23
25
  useEffect(() => {
@@ -26,11 +28,19 @@ export const ThemeProvider = ({
26
28
  document.documentElement.className.match(themeClass)?.forEach((item) => {
27
29
  document.documentElement.classList.remove(item);
28
30
  });
29
- getThemeClassName(theme, screenMode)
30
- .split(' ')
31
- .forEach((item) => {
32
- document.documentElement.classList.add(item);
33
- });
31
+
32
+ const themeClasses = getThemeClassName(theme, screenMode).split(' ');
33
+ themeClasses.forEach((item) => {
34
+ document.documentElement.classList.add(item);
35
+ });
36
+
37
+ // Add np-theme-personal for business and platform themes at root level only
38
+ const isBusinessTheme = theme === 'business' || theme?.startsWith('business');
39
+ const isPlatformTheme = theme === 'platform' || theme?.startsWith('platform');
40
+
41
+ if (isBusinessTheme || isPlatformTheme) {
42
+ document.documentElement.classList.add('np-theme-personal');
43
+ }
34
44
  }
35
45
  }, [isContextRoot, theme, screenMode]);
36
46