@datarobot/design-system 30.8.0 → 30.9.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.
package/cjs/index.d.ts CHANGED
@@ -73,6 +73,7 @@ export * from './range-slider';
73
73
  export * from './react-popper';
74
74
  export * from './refresh-button';
75
75
  export * from './scheduler';
76
+ export * from './scoped-theme';
76
77
  export * from './search';
77
78
  export * from './searchable-list';
78
79
  export * from './selectable-tiles';
package/cjs/index.js CHANGED
@@ -828,6 +828,17 @@ Object.keys(_scheduler).forEach(function (key) {
828
828
  }
829
829
  });
830
830
  });
831
+ var _scopedTheme = require("./scoped-theme");
832
+ Object.keys(_scopedTheme).forEach(function (key) {
833
+ if (key === "default" || key === "__esModule") return;
834
+ if (key in exports && exports[key] === _scopedTheme[key]) return;
835
+ Object.defineProperty(exports, key, {
836
+ enumerable: true,
837
+ get: function () {
838
+ return _scopedTheme[key];
839
+ }
840
+ });
841
+ });
831
842
  var _search = require("./search");
832
843
  Object.keys(_search).forEach(function (key) {
833
844
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1 @@
1
+ export { ScopedTheme, useSyncDesignSystemTheme, syncDesignSystemTheme, } from './scoped-theme';
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ScopedTheme", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _scopedTheme.ScopedTheme;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "syncDesignSystemTheme", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _scopedTheme.syncDesignSystemTheme;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "useSyncDesignSystemTheme", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _scopedTheme.useSyncDesignSystemTheme;
22
+ }
23
+ });
24
+ var _scopedTheme = require("./scoped-theme");
@@ -0,0 +1,14 @@
1
+ export declare const defaultThemeMapping: {
2
+ 'midnight-gray': string;
3
+ 'alpine-light': string;
4
+ dark: string;
5
+ light: string;
6
+ };
7
+ export declare const syncDesignSystemTheme: (theme: string, themeMapping?: Record<string, string>) => void;
8
+ export declare const useSyncDesignSystemTheme: (theme: string, themeMapping?: Record<string, string>) => void;
9
+ export declare function ScopedTheme(props: {
10
+ children: React.ReactNode;
11
+ theme: keyof typeof defaultThemeMapping;
12
+ className?: string;
13
+ themeMapping?: Record<string, string>;
14
+ } & React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ScopedTheme = ScopedTheme;
7
+ exports.useSyncDesignSystemTheme = exports.syncDesignSystemTheme = exports.defaultThemeMapping = void 0;
8
+ var _react = require("react");
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ const defaultThemeMapping = exports.defaultThemeMapping = {
11
+ 'midnight-gray': 'midnight-gray',
12
+ 'alpine-light': 'alpine-light',
13
+ dark: 'midnight-gray',
14
+ light: 'alpine-light'
15
+ };
16
+ const syncDesignSystemTheme = (theme, themeMapping = defaultThemeMapping) => {
17
+ if (theme && theme in themeMapping) {
18
+ for (const container of document.querySelectorAll('[data-ds]')) {
19
+ container.setAttribute('data-theme', themeMapping[theme]);
20
+ }
21
+ }
22
+ };
23
+ exports.syncDesignSystemTheme = syncDesignSystemTheme;
24
+ const useSyncDesignSystemTheme = (theme, themeMapping = defaultThemeMapping) => {
25
+ (0, _react.useLayoutEffect)(() => {
26
+ syncDesignSystemTheme(theme, themeMapping);
27
+ }, [theme, themeMapping]);
28
+ };
29
+ exports.useSyncDesignSystemTheme = useSyncDesignSystemTheme;
30
+ function ScopedTheme(props) {
31
+ const {
32
+ children,
33
+ theme,
34
+ className = '',
35
+ themeMapping = defaultThemeMapping,
36
+ ...rest
37
+ } = props;
38
+ const scopedTheme = themeMapping[theme] || theme;
39
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
40
+ "data-ds": true,
41
+ "data-theme": scopedTheme,
42
+ className: className,
43
+ ...rest,
44
+ children: children
45
+ });
46
+ }
package/esm/index.d.ts CHANGED
@@ -73,6 +73,7 @@ export * from './range-slider';
73
73
  export * from './react-popper';
74
74
  export * from './refresh-button';
75
75
  export * from './scheduler';
76
+ export * from './scoped-theme';
76
77
  export * from './search';
77
78
  export * from './searchable-list';
78
79
  export * from './selectable-tiles';
package/esm/index.js CHANGED
@@ -73,6 +73,7 @@ export * from './range-slider';
73
73
  export * from './react-popper';
74
74
  export * from './refresh-button';
75
75
  export * from './scheduler';
76
+ export * from './scoped-theme';
76
77
  export * from './search';
77
78
  export * from './searchable-list';
78
79
  export * from './selectable-tiles';
@@ -0,0 +1 @@
1
+ export { ScopedTheme, useSyncDesignSystemTheme, syncDesignSystemTheme, } from './scoped-theme';
@@ -0,0 +1 @@
1
+ export { ScopedTheme, useSyncDesignSystemTheme, syncDesignSystemTheme } from './scoped-theme';
@@ -0,0 +1,14 @@
1
+ export declare const defaultThemeMapping: {
2
+ 'midnight-gray': string;
3
+ 'alpine-light': string;
4
+ dark: string;
5
+ light: string;
6
+ };
7
+ export declare const syncDesignSystemTheme: (theme: string, themeMapping?: Record<string, string>) => void;
8
+ export declare const useSyncDesignSystemTheme: (theme: string, themeMapping?: Record<string, string>) => void;
9
+ export declare function ScopedTheme(props: {
10
+ children: React.ReactNode;
11
+ theme: keyof typeof defaultThemeMapping;
12
+ className?: string;
13
+ themeMapping?: Record<string, string>;
14
+ } & React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { useLayoutEffect } from 'react';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export const defaultThemeMapping = {
4
+ 'midnight-gray': 'midnight-gray',
5
+ 'alpine-light': 'alpine-light',
6
+ dark: 'midnight-gray',
7
+ light: 'alpine-light'
8
+ };
9
+ export const syncDesignSystemTheme = (theme, themeMapping = defaultThemeMapping) => {
10
+ if (theme && theme in themeMapping) {
11
+ for (const container of document.querySelectorAll('[data-ds]')) {
12
+ container.setAttribute('data-theme', themeMapping[theme]);
13
+ }
14
+ }
15
+ };
16
+ export const useSyncDesignSystemTheme = (theme, themeMapping = defaultThemeMapping) => {
17
+ useLayoutEffect(() => {
18
+ syncDesignSystemTheme(theme, themeMapping);
19
+ }, [theme, themeMapping]);
20
+ };
21
+ export function ScopedTheme(props) {
22
+ const {
23
+ children,
24
+ theme,
25
+ className = '',
26
+ themeMapping = defaultThemeMapping,
27
+ ...rest
28
+ } = props;
29
+ const scopedTheme = themeMapping[theme] || theme;
30
+ return /*#__PURE__*/_jsx("div", {
31
+ "data-ds": true,
32
+ "data-theme": scopedTheme,
33
+ className: className,
34
+ ...rest,
35
+ children: children
36
+ });
37
+ }