@veritone-ce/design-system 2.1.4 → 2.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.
Files changed (41) hide show
  1. package/dist/cjs/Button/index.js +15 -4
  2. package/dist/cjs/Button/styles.module.scss.js +1 -1
  3. package/dist/cjs/Chip/index.js +61 -0
  4. package/dist/cjs/Chip/styles.module.scss.js +7 -0
  5. package/dist/cjs/Drawer/components.js +35 -11
  6. package/dist/cjs/Drawer/styles.module.scss.js +1 -1
  7. package/dist/cjs/IconButton/index.js +25 -7
  8. package/dist/cjs/IconButton/styles.module.scss.js +1 -1
  9. package/dist/cjs/index.js +27 -23
  10. package/dist/cjs/styles/createPalette.js +219 -0
  11. package/dist/cjs/styles/createTheme.js +2 -2
  12. package/dist/cjs/styles/palette.js +13 -196
  13. package/dist/cjs/styles.css +4 -3
  14. package/dist/cjs/utils/recursive.js +25 -0
  15. package/dist/esm/Button/index.js +15 -4
  16. package/dist/esm/Button/styles.module.scss.js +1 -1
  17. package/dist/esm/Chip/index.js +57 -0
  18. package/dist/esm/Chip/styles.module.scss.js +3 -0
  19. package/dist/esm/Drawer/components.js +36 -12
  20. package/dist/esm/Drawer/styles.module.scss.js +1 -1
  21. package/dist/esm/IconButton/index.js +25 -7
  22. package/dist/esm/IconButton/styles.module.scss.js +1 -1
  23. package/dist/esm/index.js +3 -1
  24. package/dist/esm/styles/createPalette.js +217 -0
  25. package/dist/esm/styles/createTheme.js +1 -1
  26. package/dist/esm/styles/palette.js +13 -196
  27. package/dist/esm/styles/scss/theme.generated.scss +72 -20
  28. package/dist/esm/styles.css +4 -3
  29. package/dist/esm/utils/recursive.js +23 -0
  30. package/dist/types/Button/index.d.ts +3 -1
  31. package/dist/types/Chip/index.d.ts +11 -0
  32. package/dist/types/Drawer/components.d.ts +13 -1
  33. package/dist/types/IconButton/index.d.ts +5 -1
  34. package/dist/types/index.d.ts +2 -0
  35. package/dist/types/styles/createPalette.d.ts +50 -0
  36. package/dist/types/styles/createTheme.d.ts +2 -1
  37. package/dist/types/styles/css-vars.d.ts +4 -2
  38. package/dist/types/styles/index.d.ts +3 -2
  39. package/dist/types/styles/palette.d.ts +13 -55
  40. package/dist/types/utils/recursive.d.ts +10 -0
  41. package/package.json +1 -1
@@ -13,19 +13,21 @@ require('../styles/css-vars.js');
13
13
  var cx = require('../styles/cx.js');
14
14
  require('../styles/defaultTheme.js');
15
15
  require('@mui/system');
16
+ var palette = require('../styles/palette.js');
16
17
  require('../styles/styled.js');
17
18
 
18
19
  const Button = React.forwardRef(
19
20
  ({
20
21
  variant = "primary",
22
+ palette: paletteInput = variant === "primary" ? "action.primary" : "action.text",
21
23
  size = "large",
22
24
  disabled = false,
23
25
  loading = false,
24
- destructive = false,
25
26
  active = false,
26
27
  ...props
27
28
  }, ref) => {
28
29
  const variantCn = styles_module.default[variant];
30
+ const palette$1 = palette.resolvePaletteValue(paletteInput);
29
31
  return /* @__PURE__ */ jsxRuntime.jsxs(
30
32
  "button",
31
33
  {
@@ -35,13 +37,22 @@ const Button = React.forwardRef(
35
37
  "data-loading": loading,
36
38
  "data-active": active,
37
39
  disabled: loading || disabled,
38
- "data-destructive": destructive,
39
40
  onClick: props.onClick,
40
41
  "data-testid": props["data-testid"],
41
- style: props.style,
42
+ style: {
43
+ ...{
44
+ "--vt-ce-button-palette-base-surface": palette$1.base.surface,
45
+ "--vt-ce-button-palette-base-on": palette$1.base.on,
46
+ "--vt-ce-button-palette-hover-surface": palette$1.hover.surface,
47
+ "--vt-ce-button-palette-hover-on": palette$1.hover.on,
48
+ "--vt-ce-button-palette-disabled-surface": palette$1.disabled.surface,
49
+ "--vt-ce-button-palette-disabled-on": palette$1.disabled.on
50
+ },
51
+ ...props.style
52
+ },
42
53
  className: cx.cx(styles_module.default["button"], variantCn, props.className),
43
54
  children: [
44
- loading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles_module.default["loading-container"], children: /* @__PURE__ */ jsxRuntime.jsx(index.default, { size: "1.4em", color: "inherit" }) }),
55
+ loading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles_module.default["loading-container"], children: /* @__PURE__ */ jsxRuntime.jsx(index.default, { size: "1.4em" }) }),
45
56
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: styles_module.default["inner-container"], children: [
46
57
  props.startIcon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles_module.default["button-icon"], children: props.startIcon }),
47
58
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: props.children }),
@@ -2,6 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var modules_efc4e723 = {"button":"vt_ce_Button_button__0157fdfe","primary":"vt_ce_Button_primary__0157fdfe","secondary":"vt_ce_Button_secondary__0157fdfe","tertiary":"vt_ce_Button_tertiary__0157fdfe","inner-container":"vt_ce_Button_innerContainer__0157fdfe","loading-container":"vt_ce_Button_loadingContainer__0157fdfe","button-icon":"vt_ce_Button_buttonIcon__0157fdfe"};
5
+ var modules_efc4e723 = {"button":"vt_ce_Button_button__83b29f90","primary":"vt_ce_Button_primary__83b29f90","secondary":"vt_ce_Button_secondary__83b29f90","tertiary":"vt_ce_Button_tertiary__83b29f90","inner-container":"vt_ce_Button_innerContainer__83b29f90","loading-container":"vt_ce_Button_loadingContainer__83b29f90","button-icon":"vt_ce_Button_buttonIcon__83b29f90"};
6
6
 
7
7
  exports.default = modules_efc4e723;
@@ -0,0 +1,61 @@
1
+ 'use strict';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+ var React = require('react');
8
+ var styles_module = require('./styles.module.scss.js');
9
+ require('color2k');
10
+ require('../styles/css-vars.js');
11
+ var cx = require('../styles/cx.js');
12
+ require('../styles/defaultTheme.js');
13
+ require('@mui/system');
14
+ require('../styles/styled.js');
15
+ require('@mui/utils');
16
+ require('../Button/index.js');
17
+ var index = require('../IconButton/index.js');
18
+ var internal = require('../Icon/internal.js');
19
+ require('../Box/index.js');
20
+ require('../Checkbox/index.js');
21
+ require('../Dialog/components.js');
22
+ require('../Drawer/components.js');
23
+ require('../Icon/factory.js');
24
+ require('../Input/index.js');
25
+ require('../Menu/controlled.js');
26
+ require('@mui/material/usePagination');
27
+ require('../RadioButton/index.js');
28
+ require('../Select/controlled.js');
29
+ require('../Textarea/index.js');
30
+ require('@mui/material');
31
+ require('../Toast/hook.js');
32
+ require('@floating-ui/react');
33
+ require('../Typography/index.js');
34
+
35
+ const Chip = React.forwardRef(
36
+ ({ clearable = true, ...props }, ref) => {
37
+ return /* @__PURE__ */ jsxRuntime.jsxs(
38
+ "span",
39
+ {
40
+ ref,
41
+ className: cx.cx(styles_module.default["chip"], props.className),
42
+ "data-testid": props["data-testid"],
43
+ style: props.style,
44
+ children: [
45
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles_module.default["chip-text"], children: props.children }),
46
+ clearable && /* @__PURE__ */ jsxRuntime.jsx(
47
+ index.default,
48
+ {
49
+ className: styles_module.default["button-icon"],
50
+ style: { padding: "0px" },
51
+ onClick: props.onClear,
52
+ children: /* @__PURE__ */ jsxRuntime.jsx(internal.DSIcon, { name: "close" })
53
+ }
54
+ )
55
+ ]
56
+ }
57
+ );
58
+ }
59
+ );
60
+
61
+ exports.default = Chip;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var modules_efc4e723 = {"chip":"vt_ce_Chip_chip__323b4046","chip-text":"vt_ce_Chip_chipText__323b4046","button-icon":"vt_ce_Chip_buttonIcon__323b4046"};
6
+
7
+ exports.default = modules_efc4e723;
@@ -14,6 +14,7 @@ require('../styles/css-vars.js');
14
14
  var cx = require('../styles/cx.js');
15
15
  require('../styles/defaultTheme.js');
16
16
  require('@mui/system');
17
+ var palette = require('../styles/palette.js');
17
18
  require('../styles/styled.js');
18
19
  var index$1 = require('../Button/index.js');
19
20
  var index = require('../Typography/index.js');
@@ -114,25 +115,48 @@ const DrawerEnd = React__namespace.forwardRef(
114
115
  );
115
116
  }
116
117
  );
117
- const DrawerTitle = React__namespace.forwardRef(function DrawerTitle2({ children, ...props }, ref) {
118
+ const DrawerTitle = React__namespace.forwardRef(function DrawerTitle2({
119
+ children,
120
+ actions,
121
+ container = "text",
122
+ palette: paletteInput = "brand.1.base",
123
+ ...props
124
+ }, ref) {
125
+ const palette$1 = palette.resolvePaletteValue(paletteInput);
118
126
  const { setLabelId } = state.useDrawerContext();
119
127
  const id = React__namespace.useId();
120
128
  React__namespace.useLayoutEffect(() => {
121
129
  setLabelId(id);
122
130
  return () => setLabelId(void 0);
123
131
  }, [id, setLabelId]);
124
- return /* @__PURE__ */ jsxRuntime.jsx(DrawerStart, { children: /* @__PURE__ */ jsxRuntime.jsx(
125
- index.default,
132
+ return /* @__PURE__ */ jsxRuntime.jsxs(
133
+ DrawerStart,
126
134
  {
127
- variant: "title",
128
- ref,
129
- id,
130
- color: "primary",
131
- ...props,
132
- className: cx.cx(styles_module.default["drawer-title"], props.className),
133
- children
135
+ "data-container": container,
136
+ style: {
137
+ ...{
138
+ "--vt-ce-drawer-palette-surface": palette$1.surface,
139
+ "--vt-ce-drawer-palette-on": palette$1.on
140
+ }
141
+ },
142
+ className: styles_module.default["drawer-title-container"],
143
+ children: [
144
+ /* @__PURE__ */ jsxRuntime.jsx(
145
+ index.default,
146
+ {
147
+ variant: "title",
148
+ ref,
149
+ id,
150
+ color: "inherit",
151
+ ...props,
152
+ className: cx.cx(styles_module.default["drawer-title"], props.className),
153
+ children
154
+ }
155
+ ),
156
+ actions && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles_module.default["drawer-title-actions"], children: actions })
157
+ ]
134
158
  }
135
- ) });
159
+ );
136
160
  });
137
161
  const DrawerTypography = React__namespace.forwardRef(function DrawerTypography2({ children, ...props }, ref) {
138
162
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -2,6 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var modules_efc4e723 = {"drawer-overlay":"vt_ce_Drawer_drawerOverlay__6d49b031","drawer":"vt_ce_Drawer_drawer__6d49b031","drawer-start":"vt_ce_Drawer_drawerStart__6d49b031","drawer-end":"vt_ce_Drawer_drawerEnd__6d49b031","drawer-content":"vt_ce_Drawer_drawerContent__6d49b031","drawer-title":"vt_ce_Drawer_drawerTitle__6d49b031","drawer-typography":"vt_ce_Drawer_drawerTypography__6d49b031","drawer-actions":"vt_ce_Drawer_drawerActions__6d49b031"};
5
+ var modules_efc4e723 = {"drawer-overlay":"vt_ce_Drawer_drawerOverlay__711dd4dc","drawer":"vt_ce_Drawer_drawer__711dd4dc","drawer-start":"vt_ce_Drawer_drawerStart__711dd4dc","drawer-end":"vt_ce_Drawer_drawerEnd__711dd4dc","drawer-content":"vt_ce_Drawer_drawerContent__711dd4dc","drawer-title-container":"vt_ce_Drawer_drawerTitleContainer__711dd4dc","drawer-title":"vt_ce_Drawer_drawerTitle__711dd4dc","drawer-title-actions":"vt_ce_Drawer_drawerTitleActions__711dd4dc","drawer-typography":"vt_ce_Drawer_drawerTypography__711dd4dc","drawer-actions":"vt_ce_Drawer_drawerActions__711dd4dc"};
6
6
 
7
7
  exports.default = modules_efc4e723;
@@ -13,24 +13,42 @@ require('../styles/css-vars.js');
13
13
  var cx = require('../styles/cx.js');
14
14
  require('../styles/defaultTheme.js');
15
15
  require('@mui/system');
16
+ var palette = require('../styles/palette.js');
16
17
  require('../styles/styled.js');
17
18
 
18
19
  const IconButton = React.forwardRef(
19
- (props, ref) => {
20
+ ({
21
+ variant = "primary",
22
+ palette: paletteInput = "action.text",
23
+ loading = false,
24
+ disabled = false,
25
+ ...props
26
+ }, ref) => {
27
+ const variantCn = styles_module.default[variant];
28
+ const palette$1 = palette.resolvePaletteValue(paletteInput);
20
29
  return /* @__PURE__ */ jsxRuntime.jsxs(
21
30
  "button",
22
31
  {
23
32
  ref,
24
33
  type: props.type,
25
- "data-loading": props.loading ?? false,
26
- disabled: props.loading || props.disabled,
27
- "data-destructive": props.destructive ?? false,
34
+ "data-loading": loading,
35
+ disabled: loading || disabled,
28
36
  onClick: props.onClick,
29
37
  "data-testid": props["data-testid"],
30
- style: props.style,
31
- className: cx.cx(styles_module.default["button"], props.className),
38
+ style: {
39
+ ...{
40
+ "--vt-ce-icon-button-palette-base-surface": palette$1.base.surface,
41
+ "--vt-ce-icon-button-palette-base-on": palette$1.base.on,
42
+ "--vt-ce-icon-button-palette-hover-surface": palette$1.hover.surface,
43
+ "--vt-ce-icon-button-palette-hover-on": palette$1.hover.on,
44
+ "--vt-ce-icon-button-palette-disabled-surface": palette$1.disabled.surface,
45
+ "--vt-ce-icon-button-palette-disabled-on": palette$1.disabled.on
46
+ },
47
+ ...props.style
48
+ },
49
+ className: cx.cx(styles_module.default["button"], variantCn, props.className),
32
50
  children: [
33
- props.loading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles_module.default["loading-container"], children: /* @__PURE__ */ jsxRuntime.jsx(index.default, { color: "inherit", fillParentHeight: true }) }),
51
+ loading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles_module.default["loading-container"], children: /* @__PURE__ */ jsxRuntime.jsx(index.default, { fillParentHeight: true }) }),
34
52
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles_module.default["inner-icon"], children: props.children })
35
53
  ]
36
54
  }
@@ -2,6 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var modules_efc4e723 = {"button":"vt_ce_IconButton_button__b5583457","inner-icon":"vt_ce_IconButton_innerIcon__b5583457","loading-container":"vt_ce_IconButton_loadingContainer__b5583457"};
5
+ var modules_efc4e723 = {"button":"vt_ce_IconButton_button__8407c5d8","primary":"vt_ce_IconButton_primary__8407c5d8","secondary":"vt_ce_IconButton_secondary__8407c5d8","inner-icon":"vt_ce_IconButton_innerIcon__8407c5d8","loading-container":"vt_ce_IconButton_loadingContainer__8407c5d8"};
6
6
 
7
7
  exports.default = modules_efc4e723;
package/dist/cjs/index.js CHANGED
@@ -8,6 +8,7 @@ var cx = require('./styles/cx.js');
8
8
  var defaultTheme = require('./styles/defaultTheme.js');
9
9
  var useTheme = require('./styles/useTheme.js');
10
10
  var palette = require('./styles/palette.js');
11
+ var createPalette = require('./styles/createPalette.js');
11
12
  var styled = require('./styles/styled.js');
12
13
  var provider_client = require('./styles/provider.client.js');
13
14
  var provider_cssVars = require('./styles/provider.css-vars.js');
@@ -17,29 +18,30 @@ var index = require('./Alert/index.js');
17
18
  var index$1 = require('./Box/index.js');
18
19
  var index$2 = require('./Button/index.js');
19
20
  var index$3 = require('./Checkbox/index.js');
20
- var index$4 = require('./CircularProgress/index.js');
21
+ var index$4 = require('./Chip/index.js');
22
+ var index$5 = require('./CircularProgress/index.js');
21
23
  var components = require('./Dialog/components.js');
22
24
  var factory = require('./Dialog/factory.js');
23
25
  var components$1 = require('./Drawer/components.js');
24
26
  var factory$1 = require('./Drawer/factory.js');
25
- var index$5 = require('./GlobalStyles/index.js');
27
+ var index$6 = require('./GlobalStyles/index.js');
26
28
  var wrappers = require('./Icon/wrappers.js');
27
29
  var factory$2 = require('./Icon/factory.js');
28
- var index$6 = require('./IconButton/index.js');
29
- var index$7 = require('./Input/index.js');
30
+ var index$7 = require('./IconButton/index.js');
31
+ var index$8 = require('./Input/index.js');
30
32
  var controlled = require('./Menu/controlled.js');
31
33
  var factory$3 = require('./Menu/factory.js');
32
- var index$8 = require('./Pagination/index.js');
33
- var index$9 = require('./RadioButton/index.js');
34
+ var index$9 = require('./Pagination/index.js');
35
+ var index$a = require('./RadioButton/index.js');
34
36
  var controlled$1 = require('./Select/controlled.js');
35
37
  var uncontrolled = require('./Select/uncontrolled.js');
36
38
  var factory$4 = require('./Select/factory.js');
37
- var index$a = require('./TablePagination/index.js');
38
- var index$b = require('./Textarea/index.js');
39
- var index$c = require('./Toast/index.js');
39
+ var index$b = require('./TablePagination/index.js');
40
+ var index$c = require('./Textarea/index.js');
41
+ var index$d = require('./Toast/index.js');
40
42
  var hook = require('./Toast/hook.js');
41
- var index$d = require('./Tooltip/index.js');
42
- var index$e = require('./Typography/index.js');
43
+ var index$e = require('./Tooltip/index.js');
44
+ var index$f = require('./Typography/index.js');
43
45
 
44
46
 
45
47
 
@@ -52,7 +54,8 @@ exports.ThemeVars = defaultTheme.defaultThemeCssVariableUsages;
52
54
  exports.defaultDarkTheme = defaultTheme.defaultDarkTheme;
53
55
  exports.defaultTheme = defaultTheme.default;
54
56
  exports.useTheme = useTheme.default;
55
- exports.createPalette = palette.createPalette;
57
+ exports.resolvePaletteValue = palette.resolvePaletteValue;
58
+ exports.createPalette = createPalette.createPalette;
56
59
  exports.experimentalStyled = styled.default;
57
60
  exports.styled = styled.default;
58
61
  exports.ThemeContextProvider = provider_client.ThemeContextProvider;
@@ -67,7 +70,8 @@ exports.Alert = index.default;
67
70
  exports.Box = index$1.default;
68
71
  exports.Button = index$2.default;
69
72
  exports.Checkbox = index$3.default;
70
- exports.CircularProgress = index$4.default;
73
+ exports.Chip = index$4.default;
74
+ exports.CircularProgress = index$5.default;
71
75
  exports.Dialog = components.default;
72
76
  exports.DialogActions = components.DialogActions;
73
77
  exports.DialogCloseButton = components.DialogCloseButton;
@@ -90,26 +94,26 @@ exports.DrawerStart = components$1.DrawerStart;
90
94
  exports.DrawerTitle = components$1.DrawerTitle;
91
95
  exports.DrawerTypography = components$1.DrawerTypography;
92
96
  exports.createDrawerComponent = factory$1.createDrawerComponent;
93
- exports.GlobalStyles = index$5.default;
97
+ exports.GlobalStyles = index$6.default;
94
98
  exports.adaptMuiSvgIcon = wrappers.adaptMuiSvgIcon;
95
99
  exports.adaptSvgIcon = wrappers.adaptSvgIcon;
96
100
  exports.DefaultIconFallback = factory$2.DefaultIconFallback;
97
101
  exports.createIconComponent = factory$2.createIconComponent;
98
- exports.IconButton = index$6.default;
99
- exports.Input = index$7.default;
102
+ exports.IconButton = index$7.default;
103
+ exports.Input = index$8.default;
100
104
  exports.Menu = controlled.default;
101
105
  exports.MenuItem = controlled.MenuItem;
102
106
  exports.createMenuComponent = factory$3.createMenuComponent;
103
- exports.Pagination = index$8.default;
104
- exports.RadioButton = index$9.default;
107
+ exports.Pagination = index$9.default;
108
+ exports.RadioButton = index$a.default;
105
109
  exports.ControlledSelect = controlled$1.default;
106
110
  exports.Select = uncontrolled.default;
107
111
  exports.createControlledSelectComponent = factory$4.createControlledSelectComponent;
108
112
  exports.createSelectComponent = factory$4.createSelectComponent;
109
- exports.TablePagination = index$a.default;
110
- exports.Textarea = index$b.default;
111
- exports.Toast = index$c.default;
113
+ exports.TablePagination = index$b.default;
114
+ exports.Textarea = index$c.default;
115
+ exports.Toast = index$d.default;
112
116
  exports.ToastProvider = hook.ToastProvider;
113
117
  exports.useToast = hook.useToast;
114
- exports.Tooltip = index$d.default;
115
- exports.Typography = index$e.default;
118
+ exports.Tooltip = index$e.default;
119
+ exports.Typography = index$f.default;
@@ -0,0 +1,219 @@
1
+ 'use strict';
2
+ 'use strict';
3
+
4
+ var color2k = require('color2k');
5
+
6
+ function isPaletteColorOptions(obj) {
7
+ return typeof obj === "string";
8
+ }
9
+ function createPaletteColor(options) {
10
+ return options;
11
+ }
12
+ function contrastColor(surface) {
13
+ return color2k.readableColor(surface);
14
+ }
15
+ function isPaletteSurfaceColorsOptions(obj) {
16
+ return typeof obj === "string" || obj["surface"] !== void 0;
17
+ }
18
+ function createPaletteSurfaceColors(options) {
19
+ if (typeof options === "string") {
20
+ const surface = createPaletteColor(options);
21
+ return {
22
+ surface,
23
+ on: contrastColor(surface)
24
+ };
25
+ } else {
26
+ const surface = createPaletteColor(options.surface);
27
+ return {
28
+ surface,
29
+ on: options.on ? createPaletteColor(options.on) : contrastColor(surface)
30
+ };
31
+ }
32
+ }
33
+ function isPaletteActionVariantsColorsOptions(obj) {
34
+ return isPaletteSurfaceColorsOptions(obj) || obj["base"] !== void 0;
35
+ }
36
+ function createPaletteActionVariantsColors(options, disabled) {
37
+ const hoverFromBase = (b) => ({
38
+ surface: color2k.toHex(color2k.desaturate(color2k.darken(b.surface, 1 / 10), 1 / 4)),
39
+ on: b.on
40
+ });
41
+ if (isPaletteSurfaceColorsOptions(options)) {
42
+ const resolved = createPaletteSurfaceColors(options);
43
+ return {
44
+ base: resolved,
45
+ hover: hoverFromBase(resolved),
46
+ disabled
47
+ };
48
+ } else {
49
+ const base = createPaletteSurfaceColors(options.base);
50
+ return {
51
+ base,
52
+ hover: options.hover ? createPaletteSurfaceColors(options.hover) : hoverFromBase(base),
53
+ disabled
54
+ };
55
+ }
56
+ }
57
+ function createPaletteBrand(options, disabled) {
58
+ const brandColorStepFromBase = (b, step) => createPaletteActionVariantsColors(
59
+ step >= 1 ? color2k.toHex(color2k.darken(b.base.surface, step / 20)) : color2k.toHex(color2k.lighten(b.base.surface, step / 2)),
60
+ disabled
61
+ );
62
+ if (isPaletteActionVariantsColorsOptions(options)) {
63
+ const resolved = createPaletteActionVariantsColors(options, disabled);
64
+ return {
65
+ 1: resolved,
66
+ 2: brandColorStepFromBase(resolved, 1),
67
+ 3: brandColorStepFromBase(resolved, 2),
68
+ 4: brandColorStepFromBase(resolved, 0.5),
69
+ 5: brandColorStepFromBase(resolved, 0.25)
70
+ };
71
+ } else {
72
+ const base = createPaletteActionVariantsColors(options[1], disabled);
73
+ return {
74
+ 1: base,
75
+ 2: options[2] ? createPaletteActionVariantsColors(options[2], disabled) : brandColorStepFromBase(base, 1),
76
+ 3: options[3] ? createPaletteActionVariantsColors(options[3], disabled) : brandColorStepFromBase(base, 2),
77
+ 4: options[4] ? createPaletteActionVariantsColors(options[4], disabled) : brandColorStepFromBase(base, 0.5),
78
+ 5: options[5] ? createPaletteActionVariantsColors(options[5], disabled) : brandColorStepFromBase(base, 0.25)
79
+ };
80
+ }
81
+ }
82
+ function createPaletteText(options) {
83
+ const textColorStepFromBase = (b, _step) => {
84
+ return b;
85
+ };
86
+ if (isPaletteColorOptions(options)) {
87
+ const resolved = createPaletteColor(options);
88
+ return {
89
+ primary: resolved,
90
+ secondary: textColorStepFromBase(resolved),
91
+ tertiary: textColorStepFromBase(resolved)
92
+ };
93
+ } else {
94
+ const base = createPaletteColor(options.primary);
95
+ return {
96
+ primary: base,
97
+ secondary: options.secondary ? createPaletteColor(options.secondary) : textColorStepFromBase(base),
98
+ tertiary: options.tertiary ? createPaletteColor(options.tertiary) : textColorStepFromBase(base)
99
+ };
100
+ }
101
+ }
102
+ function createPaletteAction(options, disabled, text) {
103
+ const destructiveDefault = createPaletteActionVariantsColors(
104
+ {
105
+ base: {
106
+ surface: "#EB0000",
107
+ on: "#FFFFFF"
108
+ },
109
+ hover: {
110
+ surface: "#a63737",
111
+ on: "#FFFFFF"
112
+ }
113
+ },
114
+ disabled
115
+ );
116
+ const primary = createPaletteActionVariantsColors(options.primary, disabled);
117
+ return {
118
+ primary,
119
+ destructive: options.destructive ? createPaletteActionVariantsColors(options.destructive, disabled) : destructiveDefault,
120
+ text: options.text ? createPaletteActionVariantsColors(options.text, disabled) : createPaletteActionVariantsColors(
121
+ {
122
+ ...primary,
123
+ base: {
124
+ surface: text,
125
+ on: contrastColor(text)
126
+ }
127
+ },
128
+ disabled
129
+ )
130
+ };
131
+ }
132
+ function createPaletteIndicator(options, disabled) {
133
+ return {
134
+ success: options.success ? createPaletteActionVariantsColors(options.success, disabled) : createPaletteActionVariantsColors("#28BA3F", disabled),
135
+ info: options.info ? createPaletteActionVariantsColors(options.info, disabled) : createPaletteActionVariantsColors("#335B89", disabled),
136
+ warning: options.warning ? createPaletteActionVariantsColors(options.warning, disabled) : createPaletteActionVariantsColors("#FFBB0A", disabled),
137
+ error: options.error ? createPaletteActionVariantsColors(options.error, disabled) : createPaletteActionVariantsColors("#EB0000", disabled)
138
+ };
139
+ }
140
+ function createPaletteTable(options, disabled) {
141
+ return createPaletteActionVariantsColors(options, disabled);
142
+ }
143
+ function createPaletteBackground(options) {
144
+ const backgroundStepFromBase = (b, step) => {
145
+ return color2k.toHex(color2k.darken(b, step / 20));
146
+ };
147
+ if (isPaletteColorOptions(options)) {
148
+ const resolved = createPaletteColor(options);
149
+ return {
150
+ primary: resolved,
151
+ secondary: backgroundStepFromBase(resolved, 1)
152
+ };
153
+ } else {
154
+ const base = createPaletteColor(options.primary);
155
+ return {
156
+ primary: base,
157
+ secondary: options.secondary ? createPaletteColor(options.secondary) : backgroundStepFromBase(base, 1)
158
+ };
159
+ }
160
+ }
161
+ function createPalette(options = {}) {
162
+ const disabled = options.disabled ? createPaletteSurfaceColors(options.disabled) : createPaletteSurfaceColors({
163
+ surface: "#FAFAFA",
164
+ on: "#7C848D"
165
+ });
166
+ const text = createPaletteText(
167
+ options.text ?? {
168
+ primary: "#2A323C",
169
+ secondary: "#5C6269",
170
+ tertiary: "#465364"
171
+ }
172
+ );
173
+ return {
174
+ brand: createPaletteBrand(
175
+ options.brand ?? {
176
+ 1: "#214167",
177
+ 2: "#335B89"
178
+ },
179
+ disabled
180
+ ),
181
+ text,
182
+ action: createPaletteAction(
183
+ options.action ?? {
184
+ primary: {
185
+ base: {
186
+ surface: "#1871E8",
187
+ on: "#FFFFFF"
188
+ },
189
+ hover: {
190
+ surface: "#335B89",
191
+ on: "#FFFFFF"
192
+ }
193
+ }
194
+ },
195
+ disabled,
196
+ text.tertiary
197
+ ),
198
+ indicator: createPaletteIndicator(options.indicator ?? {}, disabled),
199
+ disabled,
200
+ background: createPaletteBackground(
201
+ options.background ?? {
202
+ primary: "#FFFFFF",
203
+ secondary: "#E0E8F0"
204
+ }
205
+ ),
206
+ table: createPaletteTable(
207
+ options.table ?? {
208
+ base: {
209
+ surface: "#FFFFFF",
210
+ on: "#2A323C"
211
+ },
212
+ hover: "#EAF1FA"
213
+ },
214
+ disabled
215
+ )
216
+ };
217
+ }
218
+
219
+ exports.createPalette = createPalette;
@@ -3,13 +3,13 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var palette = require('./palette.js');
7
6
  var typography = require('./typography.js');
7
+ var createPalette = require('./createPalette.js');
8
8
 
9
9
  const defaultThemeOptions = {};
10
10
  function createTheme(options = defaultThemeOptions) {
11
11
  return {
12
- palette: palette.createPalette(options.palette),
12
+ palette: createPalette.createPalette(options.palette),
13
13
  typography: typography.createTypography(options.typography)
14
14
  };
15
15
  }