@wise/components-theming 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { PropsWithChildren } from 'react';
2
- import type { ComponentTheme, BaseTheme, ExtraTheme, ScreenMode, Theming } from './const';
2
+ import type { ScreenMode, Theming } from './const';
3
3
  export declare const ThemeContext: import("react").Context<{
4
- theme: ComponentTheme | BaseTheme | ExtraTheme;
4
+ theme: Theming['theme'];
5
5
  screenMode: ScreenMode;
6
6
  } | undefined>;
7
7
  type ThemeProviderProps = PropsWithChildren<Theming> & {
@@ -1 +1 @@
1
- {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,iBAAiB,EAAkC,MAAM,OAAO,CAAC;AAGzF,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAI1F,eAAO,MAAM,YAAY;WAEZ,cAAc,GAAG,SAAS,GAAG,UAAU;gBAClC,UAAU;cAGhB,CAAC;AAEb,KAAK,kBAAkB,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E,eAAO,MAAM,aAAa,mEAMvB,kBAAkB,gCA6BpB,CAAC"}
1
+ {"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../src/ThemeProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,iBAAiB,EAAkC,MAAM,OAAO,CAAC;AAGzF,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAInD,eAAO,MAAM,YAAY;WAEZ,OAAO,CAAC,OAAO,CAAC;gBACX,UAAU;cAGhB,CAAC;AAEb,KAAK,kBAAkB,GAAG,iBAAiB,CAAC,OAAO,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E,eAAO,MAAM,aAAa,mEAMvB,kBAAkB,gCA6BpB,CAAC"}
package/dist/const.d.ts CHANGED
@@ -2,6 +2,7 @@ export declare const baseThemes: readonly ["light", "personal"];
2
2
  export declare const extraThemes: readonly ["forest-green", "bright-green"];
3
3
  export declare const screenModes: readonly ["light", "dark"];
4
4
  export declare const modernThemes: readonly ["personal", "forest-green", "bright-green"];
5
+ export declare const platformThemes: readonly ["platform", "platform--forest-green"];
5
6
  export type ComponentTheme = (typeof baseThemes)[number];
6
7
  export type ModernTheme = (typeof modernThemes)[number];
7
8
  export type BaseTheme = (typeof baseThemes)[number];
@@ -9,10 +10,12 @@ export type ExtraTheme = (typeof extraThemes)[number];
9
10
  export type ForestGreenTheme = (typeof extraThemes)[0];
10
11
  export type ScreenMode = (typeof screenModes)[number];
11
12
  export type ScreenModeDark = (typeof screenModes)[1];
13
+ export type PlatformTheme = (typeof platformThemes)[0];
14
+ export type PlatformForestGreenTheme = (typeof platformThemes)[1];
12
15
  export declare const DEFAULT_BASE_THEME: "light";
13
16
  export declare const DEFAULT_SCREEN_MODE: "light";
14
17
  export type Theming = {
15
- theme?: ComponentTheme | BaseTheme | ExtraTheme;
18
+ theme?: ComponentTheme | BaseTheme | ExtraTheme | PlatformTheme | PlatformForestGreenTheme;
16
19
  screenMode?: ScreenMode;
17
20
  isNotRootProvider?: boolean | undefined;
18
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../src/const.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU,gCAAiC,CAAC;AACzD,eAAO,MAAM,WAAW,2CAA4C,CAAC;AACrE,eAAO,MAAM,WAAW,4BAA6B,CAAC;AACtD,eAAO,MAAM,YAAY,uDAA2C,CAAC;AAGrE,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;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AC;AACpD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AACtD,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAElE,eAAO,MAAM,kBAAkB,SAAmB,CAAC;AACnD,eAAO,MAAM,mBAAmB,SAAmB,CAAC;AAEpD,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,CAAC,EAAE,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,aAAa,GAAG,wBAAwB,CAAC;IAC3F,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACzC,CAAC"}
package/dist/helpers.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { ComponentTheme, BaseTheme, ExtraTheme, ScreenMode } from './const';
2
- export declare const isThemeModern: (theme: ComponentTheme | BaseTheme | ExtraTheme) => theme is "personal" | "forest-green" | "bright-green";
3
- export declare const isExtraTheme: (theme: ComponentTheme | BaseTheme | ExtraTheme) => theme is "forest-green" | "bright-green";
4
- export declare const isForestGreenTheme: (theme: ComponentTheme | BaseTheme | ExtraTheme) => theme is "forest-green";
5
- export declare const isScreenModeDark: (theme: ComponentTheme | BaseTheme | ExtraTheme, screenMode: ScreenMode) => screenMode is "dark";
6
- export declare const getThemeClassName: (theme: ComponentTheme | BaseTheme | ExtraTheme, screenMode: ScreenMode) => string;
1
+ import type { ScreenMode, Theming } from './const';
2
+ export declare const isThemeModern: (theme: Theming['theme']) => theme is "personal" | "forest-green" | "bright-green";
3
+ export declare const isExtraTheme: (theme: Theming['theme']) => theme is "forest-green" | "bright-green";
4
+ export declare const isForestGreenTheme: (theme: Theming['theme']) => theme is "forest-green";
5
+ export declare const isScreenModeDark: (theme: Theming['theme'], screenMode: ScreenMode) => screenMode is "dark";
6
+ export declare const getThemeClassName: (theme: Theming['theme'], screenMode: ScreenMode) => string;
7
7
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAEd,SAAS,EACT,UAAU,EAEV,UAAU,EAEX,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,aAAa,UACjB,cAAc,GAAG,SAAS,GAAG,UAAU,0DACsB,CAAC;AAEvE,eAAO,MAAM,YAAY,UAAW,cAAc,GAAG,SAAS,GAAG,UAAU,6CAChC,CAAC;AAE5C,eAAO,MAAM,kBAAkB,UACtB,cAAc,GAAG,SAAS,GAAG,UAAU,4BACQ,CAAC;AAEzD,eAAO,MAAM,gBAAgB,UACpB,cAAc,GAAG,SAAS,GAAG,UAAU,cAClC,UAAU,yBAE8C,CAAC;AAEvE,eAAO,MAAM,iBAAiB,UACrB,cAAc,GAAG,SAAS,GAAG,UAAU,cAClC,UAAU,WAevB,CAAC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,UAAU,EAEV,OAAO,EACR,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,aAAa,UAAW,OAAO,CAAC,OAAO,CAAC,0DACR,CAAC;AAE9C,eAAO,MAAM,YAAY,UAAW,OAAO,CAAC,OAAO,CAAC,6CACT,CAAC;AAE5C,eAAO,MAAM,kBAAkB,UAAW,OAAO,CAAC,OAAO,CAAC,4BAChC,CAAC;AAE3B,eAAO,MAAM,gBAAgB,UACpB,OAAO,CAAC,OAAO,CAAC,cACX,UAAU,yBAE8C,CAAC;AAEvE,eAAO,MAAM,iBAAiB,UAAW,OAAO,CAAC,OAAO,CAAC,cAAc,UAAU,WAchF,CAAC"}
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ const isForestGreenTheme = theme => theme === extraThemes[0];
22
22
  const isScreenModeDark = (theme, screenMode) => isThemeModern(theme) && screenModes[1] === screenMode;
23
23
  const getThemeClassName = (theme, screenMode) => {
24
24
  if (!isThemeModern(theme)) {
25
- return `np-theme-${theme}`;
25
+ return `np-theme-${theme || 'personal'}`;
26
26
  }
27
27
  let classes = `np-theme-personal`;
28
28
  if (isExtraTheme(theme)) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/const.ts","../src/helpers.ts","../src/useTheme.ts","../src/ThemedChildren.tsx","../src/ThemeProvider.tsx"],"sourcesContent":[null,null,null,null,null],"names":["baseThemes","extraThemes","screenModes","modernThemes","DEFAULT_BASE_THEME","DEFAULT_SCREEN_MODE","isThemeModern","includes","theme","isExtraTheme","isForestGreenTheme","isScreenModeDark","screenMode","getThemeClassName","FALLBACK_VALUES","isNotProduction","ThemedChildren","className","undefined","children","themeClass","useTheme","_jsx","classNames","createContext","ThemeProvider","isNotRootProvider","useContext","ThemeContext","RegExp"],"mappings":";;;;;;;;;;AACA;AACO,MAAAA,UAAiB,GAAA,CAAA,OAAA,EAAA,UAAA,CAAA,CAAA;AACjB,MAAAC,WAAiB,GAAA,CAAA,cAAA,EAAA,cAAA,CAAA,CAAA;AACjB,MAAAC,WAAkB,GAAA,CAAA,OAAA,EAAA,MAAA,CAAA,CAAA;AAGnB,MAAoBC,YAAA,GAAA,CAAGH,kBAAkBC,WAAU,CAAA,CAAA;AACnD,MAAiBG,kBAAI,GAAO;AAC5B,MAAeC,mBAAW,UAAU;;ACEnC,MAAAC,qBAC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;AAAqB;EAE9E,MAAAE,UAAa,GAAA,IAAAS,MAAA,CAAa,sBAMvB,EAAA,GAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/const.ts","../src/helpers.ts","../src/useTheme.ts","../src/ThemedChildren.tsx","../src/ThemeProvider.tsx"],"sourcesContent":[null,null,null,null,null],"names":["baseThemes","extraThemes","screenModes","modernThemes","DEFAULT_BASE_THEME","DEFAULT_SCREEN_MODE","isThemeModern","includes","isExtraTheme","isForestGreenTheme","theme","isScreenModeDark","screenMode","getThemeClassName","FALLBACK_VALUES","isNotProduction","ThemedChildren","className","undefined","children","themeClass","useTheme","_jsx","classNames","createContext","ThemeProvider","isNotRootProvider","useContext","ThemeContext","RegExp"],"mappings":";;;;;;;;;;AACA;AACO,MAAAA,UAAiB,GAAA,CAAA,OAAA,EAAA,UAAA,CAAA,CAAA;AACjB,MAAAC,WAAiB,GAAA,CAAA,cAAA,EAAA,cAAA,CAAA,CAAA;AACjB,MAAAC,WAAkB,GAAA,CAAA,OAAA,EAAA,MAAA,CAAA,CAAA;AAClB,MAAAC,YAAoB,GAAA,CAAAH,UAAA,CAAA,CAAA,CAAA,EAAA,GAAAC,WAAA,CAAA,CAAA;AAIrB,MAAiBG,kBAAI,GAAO;AAC5B,MAAeC,mBAAW,UAAU;;ACAnC,MAAAC,qBAA8B,IAAAH,YAAQ,CAAOI;AAG7C,MAAAC,oBAA6B,IAAAP,WAAO,CAACM,QAAQ;AAG7C,MAAAE,0BAAmC,IAAAC,KAAA,KAAAT;MAGnCU,gBAAsB,GAAAA,CAAAD,KAAA,EAAAE,UACb,KAACN,aAAQ,CAAAI,KAAA,CAAA,IACDR,WAAA,CAAA,CAAA,CAAA,KAAAU,WAAA;MAIjBC,iBAAuB,GAAAA,CAAAH,KAAA,EAAAE,UAAkB,KAAC;;;;;;;;;;;;;MCfvCE,eAAS,GAAC;AAClBJ,EAAAA,KAAkB,EAAAN;AAClBQ,EAAAA,UAAgB,EAAAP,mBAAAA;;AAEjB,MAAAU,eAAA,GAAAA,MAAA;EAeD,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxBsC,MAAAC,cAAU,GAAAA,CAAA;AAAAC,EAAAA,SAAA,GAAAC,SAAA;AAAAC,EAAAA,QAAAA;AAAA,CAAA,KAAA;EAAC,MAAQ;AAAAF,IAAAA,WAAWG,UAAAA;GAAA,GAAAC,QAAA,EAAA,CAAA;AAAG,EAAA,oBAAAC,cAAA,CAAA,KAAA,EAAA;AAAAL,IAAAA,SAAA,EAAAM,2BAAA,CAAAH,UAAA,EAAAH,SAAA,CAAA;AAAAE,IAAAA,QAAA,EAAAA,QAAAA;AAAA,GAAA,CAAA,CAAA;AAEvE,CAAA;;kBCG4B,gBAAAK,mBAAA,CAAAN,SAAA,CAAA,CAAA;mBAGf,GAAAO,CAAA;AAAAf,EAAAA,KAAA,GAAAN,kBAAA;AAAAQ,EAAAA,UAAA,GAAAP,mBAAA;AAAAqB,EAAAA,iBAAA,GAAA,KAAA;EAAAP,QAAA;AAAAF,EAAAA,SAAA,GAAAC,SAAAA;AAAA,CAAA,KAAA;AAEb,EAAA,mBAAuB,GAAGS,gBAAA,CAAAC,YAAkB,CAAA,KAAWV,SAAA,CAAA;AAAE;AAAqB;EAE9E,MAAAE,UAAa,GAAA,IAAAS,MAAA,CAAa,sBAMvB,EAAA,GAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -16,7 +16,7 @@ const isForestGreenTheme = theme => theme === extraThemes[0];
16
16
  const isScreenModeDark = (theme, screenMode) => isThemeModern(theme) && screenModes[1] === screenMode;
17
17
  const getThemeClassName = (theme, screenMode) => {
18
18
  if (!isThemeModern(theme)) {
19
- return `np-theme-${theme}`;
19
+ return `np-theme-${theme || 'personal'}`;
20
20
  }
21
21
  let classes = `np-theme-personal`;
22
22
  if (isExtraTheme(theme)) {
@@ -110,4 +110,4 @@ const ThemeProvider = ({
110
110
  };
111
111
 
112
112
  export { ThemeProvider, getThemeClassName, isExtraTheme, isForestGreenTheme, isScreenModeDark, isThemeModern, useTheme };
113
- //# sourceMappingURL=index.esm.js.map
113
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/const.ts","../src/helpers.ts","../src/useTheme.ts","../src/ThemedChildren.tsx","../src/ThemeProvider.tsx"],"sourcesContent":[null,null,null,null,null],"names":["baseThemes","extraThemes","screenModes","modernThemes","DEFAULT_BASE_THEME","DEFAULT_SCREEN_MODE","isThemeModern","includes","isExtraTheme","isForestGreenTheme","theme","isScreenModeDark","screenMode","getThemeClassName","FALLBACK_VALUES","isNotProduction","ThemedChildren","className","undefined","children","themeClass","useTheme","_jsx","classNames","createContext","ThemeProvider","isNotRootProvider","useContext","ThemeContext","RegExp"],"mappings":";;;;AACA;AACO,MAAAA,UAAiB,GAAA,CAAA,OAAA,EAAA,UAAA,CAAA,CAAA;AACjB,MAAAC,WAAiB,GAAA,CAAA,cAAA,EAAA,cAAA,CAAA,CAAA;AACjB,MAAAC,WAAkB,GAAA,CAAA,OAAA,EAAA,MAAA,CAAA,CAAA;AAClB,MAAAC,YAAoB,GAAA,CAAAH,UAAA,CAAA,CAAA,CAAA,EAAA,GAAAC,WAAA,CAAA,CAAA;AAIrB,MAAiBG,kBAAI,GAAO;AAC5B,MAAeC,mBAAW,UAAU;;ACAnC,MAAAC,qBAA8B,IAAAH,YAAQ,CAAOI;AAG7C,MAAAC,oBAA6B,IAAAP,WAAO,CAACM,QAAQ;AAG7C,MAAAE,0BAAmC,IAAAC,KAAA,KAAAT;MAGnCU,gBAAsB,GAAAA,CAAAD,KAAA,EAAAE,UACb,KAACN,aAAQ,CAAAI,KAAA,CAAA,IACDR,WAAA,CAAA,CAAA,CAAA,KAAAU,WAAA;MAIjBC,iBAAuB,GAAAA,CAAAH,KAAA,EAAAE,UAAkB,KAAC;;;;;;;;;;;;;MCfvCE,eAAS,GAAC;AAClBJ,EAAAA,KAAkB,EAAAN;AAClBQ,EAAAA,UAAgB,EAAAP,mBAAAA;;AAEjB,MAAAU,eAAA,GAAAA,MAAA;EAeD,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;ACxBsC,MAAAC,cAAU,GAAAA,CAAA;AAAAC,EAAAA,SAAA,GAAAC,SAAA;AAAAC,EAAAA,QAAAA;AAAA,CAAA,KAAA;EAAC,MAAQ;AAAAF,IAAAA,WAAWG,UAAAA;GAAA,GAAAC,QAAA,EAAA,CAAA;AAAG,EAAA,oBAAAC,GAAA,CAAA,KAAA,EAAA;AAAAL,IAAAA,SAAA,EAAAM,UAAA,CAAAH,UAAA,EAAAH,SAAA,CAAA;AAAAE,IAAAA,QAAA,EAAAA,QAAAA;AAAA,GAAA,CAAA,CAAA;AAEvE,CAAA;;kBCG4B,gBAAAK,aAAA,CAAAN,SAAA,CAAA,CAAA;mBAGf,GAAAO,CAAA;AAAAf,EAAAA,KAAA,GAAAN,kBAAA;AAAAQ,EAAAA,UAAA,GAAAP,mBAAA;AAAAqB,EAAAA,iBAAA,GAAA,KAAA;EAAAP,QAAA;AAAAF,EAAAA,SAAA,GAAAC,SAAAA;AAAA,CAAA,KAAA;AAEb,EAAA,mBAAuB,GAAGS,UAAA,CAAAC,YAAkB,CAAA,KAAWV,SAAA,CAAA;AAAE;AAAqB;EAE9E,MAAAE,UAAa,GAAA,IAAAS,MAAA,CAAa,sBAMvB,EAAA,GAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,6 @@
1
- import type { ComponentTheme, BaseTheme, ScreenMode, ExtraTheme } from './const';
1
+ import type { ScreenMode, Theming } from './const';
2
2
  interface ThemeHookValue {
3
- theme: ComponentTheme | BaseTheme | ExtraTheme;
3
+ theme: Theming['theme'];
4
4
  screenMode: ScreenMode;
5
5
  isModern: boolean;
6
6
  isForestGreenTheme: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../src/useTheme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAIjF,UAAU,cAAc;IACtB,KAAK,EAAE,cAAc,GAAG,SAAS,GAAG,UAAU,CAAC;IAC/C,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,OAAO,CAAC,OAAO,CAAC,CAAC;IACxB,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/components-theming",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Provides theming support for the Wise Design system components",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -26,16 +26,16 @@
26
26
  "@testing-library/jest-dom": "^5.14.1",
27
27
  "@testing-library/react": "^12.0.0",
28
28
  "@testing-library/react-hooks": "^8.0.0",
29
- "@transferwise/eslint-config": "^7.4.0",
30
29
  "@tsconfig/recommended": "^1.0.2",
31
30
  "@types/babel__core": "^7.20.1",
32
- "@types/jest": "^27.5.2",
31
+ "@types/jest": "^29.5.12",
33
32
  "@types/node": "^18.15.12",
34
33
  "@types/react": "^17.0.65",
35
34
  "@types/react-dom": "^17.0.20",
36
35
  "@types/testing-library__jest-dom": "^5.14.5",
37
36
  "classnames": "^2.3.2",
38
- "jest": "^27.0.6",
37
+ "jest": "^29.7.0",
38
+ "jest-environment-jsdom": "^29.7.0",
39
39
  "rollup": "^3.28.1",
40
40
  "typescript": "4.9.4"
41
41
  },
@@ -47,8 +47,15 @@
47
47
  "*.css"
48
48
  ],
49
49
  "main": "./dist/index.js",
50
- "module": "./dist/index.esm.js",
50
+ "module": "./dist/index.mjs",
51
51
  "types": "./dist/index.d.ts",
52
+ "exports": {
53
+ ".": {
54
+ "types": "./dist/index.d.ts",
55
+ "import": "./dist/index.mjs",
56
+ "require": "./dist/index.js"
57
+ }
58
+ },
52
59
  "files": [
53
60
  "dist/",
54
61
  "src/",
@@ -59,12 +66,12 @@
59
66
  },
60
67
  "scripts": {
61
68
  "build": "rollup --config --sourcemap",
62
- "test": "jest --maxWorkers=4",
63
- "test:watch": "jest --watch --env=jsdom",
69
+ "test": "jest",
70
+ "test:watch": "jest --watch",
64
71
  "lint": "pnpm run lint:check",
65
72
  "lint:check": "npm-run-all --parallel lint:check:*",
66
73
  "lint:check:format": "prettier --check --ignore-path ../../.prettierignore .",
67
- "lint:check:js+ts": "eslint --ext .js,.jsx,.mjs,.ts,.tsx,.mts --ignore-path ../../.gitignore .",
74
+ "lint:check:js+ts": "eslint --ext .js,.jsx,.mjs,.cjs,.ts,.tsx,.mts,.cts --ignore-path ../../.gitignore .",
68
75
  "lint:check:types": "tsc --noEmit --emitDeclarationOnly false",
69
76
  "lint:fix": "npm-run-all --serial lint:fix:*",
70
77
  "lint:fix:format": "prettier --write --ignore-path ../../.prettierignore .",
@@ -26,6 +26,29 @@ describe('ThemeProvider', () => {
26
26
  expect(screen.getAllByText('light')[1].parentElement).toHaveClass('np-theme-light');
27
27
  });
28
28
 
29
+ it('sets platform themes', () => {
30
+ render(
31
+ <ThemeProvider theme="personal">
32
+ <div>personal</div>
33
+ <ThemeProvider theme="platform">
34
+ <div>platform</div>
35
+ </ThemeProvider>
36
+ <ThemeProvider theme="platform--forest-green">
37
+ <div>platform--forest-green</div>
38
+ </ThemeProvider>
39
+ </ThemeProvider>,
40
+ );
41
+
42
+ // eslint-disable-next-line testing-library/no-node-access
43
+ expect(screen.getByText('personal').parentElement).toHaveClass('np-theme-personal');
44
+ // eslint-disable-next-line testing-library/no-node-access
45
+ expect(screen.getByText('platform').parentElement).toHaveClass('np-theme-platform');
46
+ // eslint-disable-next-line testing-library/no-node-access
47
+ expect(screen.getByText('platform--forest-green').parentElement).toHaveClass(
48
+ 'np-theme-platform--forest-green',
49
+ );
50
+ });
51
+
29
52
  it('matches snapshot', () => {
30
53
  const { asFragment } = render(
31
54
  <ThemeProvider theme="light">
@@ -1,13 +1,13 @@
1
1
  import { createContext, PropsWithChildren, useContext, useEffect, useMemo } from 'react';
2
2
 
3
3
  import { ThemedChildren } from './ThemedChildren';
4
- import type { ComponentTheme, BaseTheme, ExtraTheme, ScreenMode, Theming } from './const';
4
+ import type { ScreenMode, Theming } from './const';
5
5
  import { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const';
6
6
  import { getThemeClassName } from './helpers';
7
7
 
8
8
  export const ThemeContext = createContext<
9
9
  | {
10
- theme: ComponentTheme | BaseTheme | ExtraTheme;
10
+ theme: Theming['theme'];
11
11
  screenMode: ScreenMode;
12
12
  }
13
13
  | undefined
package/src/const.ts CHANGED
@@ -3,6 +3,7 @@ export const baseThemes = ['light', 'personal'] as const;
3
3
  export const extraThemes = ['forest-green', 'bright-green'] as const;
4
4
  export const screenModes = ['light', 'dark'] as const;
5
5
  export const modernThemes = [baseThemes[1], ...extraThemes] as const;
6
+ export const platformThemes = ['platform', 'platform--forest-green'] as const;
6
7
 
7
8
  // TODO: componentThemes returned back for backward compatibility, refactor this place in the future
8
9
  export type ComponentTheme = (typeof baseThemes)[number];
@@ -12,12 +13,14 @@ export type ExtraTheme = (typeof extraThemes)[number];
12
13
  export type ForestGreenTheme = (typeof extraThemes)[0];
13
14
  export type ScreenMode = (typeof screenModes)[number];
14
15
  export type ScreenModeDark = (typeof screenModes)[1];
16
+ export type PlatformTheme = (typeof platformThemes)[0];
17
+ export type PlatformForestGreenTheme = (typeof platformThemes)[1];
15
18
 
16
19
  export const DEFAULT_BASE_THEME = 'light' as const;
17
20
  export const DEFAULT_SCREEN_MODE = 'light' as const;
18
21
 
19
22
  export type Theming = {
20
- theme?: ComponentTheme | BaseTheme | ExtraTheme;
23
+ theme?: ComponentTheme | BaseTheme | ExtraTheme | PlatformTheme | PlatformForestGreenTheme;
21
24
  screenMode?: ScreenMode;
22
25
  isNotRootProvider?: boolean | undefined;
23
26
  };
package/src/helpers.ts CHANGED
@@ -1,37 +1,31 @@
1
1
  import type {
2
- ComponentTheme,
3
2
  ModernTheme,
4
- BaseTheme,
5
3
  ExtraTheme,
6
4
  ForestGreenTheme,
7
5
  ScreenMode,
8
6
  ScreenModeDark,
7
+ Theming,
9
8
  } from './const';
10
9
  import { extraThemes, screenModes, modernThemes } from './const';
11
10
 
12
- export const isThemeModern = (
13
- theme: ComponentTheme | BaseTheme | ExtraTheme,
14
- ): theme is ModernTheme => modernThemes.includes(theme as ModernTheme);
11
+ export const isThemeModern = (theme: Theming['theme']): theme is ModernTheme =>
12
+ modernThemes.includes(theme as ModernTheme);
15
13
 
16
- export const isExtraTheme = (theme: ComponentTheme | BaseTheme | ExtraTheme): theme is ExtraTheme =>
14
+ export const isExtraTheme = (theme: Theming['theme']): theme is ExtraTheme =>
17
15
  extraThemes.includes(theme as ExtraTheme);
18
16
 
19
- export const isForestGreenTheme = (
20
- theme: ComponentTheme | BaseTheme | ExtraTheme,
21
- ): theme is ForestGreenTheme => theme === extraThemes[0];
17
+ export const isForestGreenTheme = (theme: Theming['theme']): theme is ForestGreenTheme =>
18
+ theme === extraThemes[0];
22
19
 
23
20
  export const isScreenModeDark = (
24
- theme: ComponentTheme | BaseTheme | ExtraTheme,
21
+ theme: Theming['theme'],
25
22
  screenMode: ScreenMode,
26
23
  ): screenMode is ScreenModeDark =>
27
24
  isThemeModern(theme as ModernTheme) && screenModes[1] === screenMode;
28
25
 
29
- export const getThemeClassName = (
30
- theme: ComponentTheme | BaseTheme | ExtraTheme,
31
- screenMode: ScreenMode,
32
- ) => {
26
+ export const getThemeClassName = (theme: Theming['theme'], screenMode: ScreenMode) => {
33
27
  if (!isThemeModern(theme)) {
34
- return `np-theme-${theme}`;
28
+ return `np-theme-${theme || 'personal'}`;
35
29
  }
36
30
 
37
31
  let classes = `np-theme-personal`;
package/src/useTheme.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { useContext, useMemo } from 'react';
2
2
 
3
3
  import { ThemeContext } from './ThemeProvider';
4
- import type { ComponentTheme, BaseTheme, ScreenMode, ExtraTheme } from './const';
4
+ import type { ScreenMode, Theming } from './const';
5
5
  import { DEFAULT_BASE_THEME, DEFAULT_SCREEN_MODE } from './const';
6
6
  import { isThemeModern, isForestGreenTheme, isScreenModeDark, getThemeClassName } from './helpers';
7
7
 
8
8
  interface ThemeHookValue {
9
- theme: ComponentTheme | BaseTheme | ExtraTheme;
9
+ theme: Theming['theme'];
10
10
  screenMode: ScreenMode;
11
11
  isModern: boolean;
12
12
  isForestGreenTheme: boolean;
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/const.ts","../src/helpers.ts","../src/useTheme.ts","../src/ThemedChildren.tsx","../src/ThemeProvider.tsx"],"sourcesContent":[null,null,null,null,null],"names":["baseThemes","extraThemes","screenModes","modernThemes","DEFAULT_BASE_THEME","DEFAULT_SCREEN_MODE","isThemeModern","includes","theme","isExtraTheme","isForestGreenTheme","isScreenModeDark","screenMode","getThemeClassName","FALLBACK_VALUES","isNotProduction","ThemedChildren","className","undefined","children","themeClass","useTheme","_jsx","classNames","createContext","ThemeProvider","isNotRootProvider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