@workday/canvas-kit-react 9.0.0-alpha.348-next.3 → 9.0.0-alpha.350-next.4

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 (51) hide show
  1. package/common/lib/styles/focusRing.ts +0 -9
  2. package/common/lib/theming/createCanvasTheme.ts +39 -42
  3. package/common/lib/theming/getObjectProxy.ts +31 -19
  4. package/common/lib/theming/useTheme.ts +1 -2
  5. package/common/lib/utils/deepMerge.ts +21 -0
  6. package/common/lib/utils/memoize.ts +23 -0
  7. package/dist/commonjs/common/lib/styles/focusRing.d.ts +0 -3
  8. package/dist/commonjs/common/lib/styles/focusRing.d.ts.map +1 -1
  9. package/dist/commonjs/common/lib/styles/focusRing.js +2 -16
  10. package/dist/commonjs/common/lib/theming/createCanvasTheme.d.ts +7 -6
  11. package/dist/commonjs/common/lib/theming/createCanvasTheme.d.ts.map +1 -1
  12. package/dist/commonjs/common/lib/theming/createCanvasTheme.js +34 -30
  13. package/dist/commonjs/common/lib/theming/getObjectProxy.d.ts +9 -3
  14. package/dist/commonjs/common/lib/theming/getObjectProxy.d.ts.map +1 -1
  15. package/dist/commonjs/common/lib/theming/getObjectProxy.js +20 -20
  16. package/dist/commonjs/common/lib/theming/useTheme.d.ts.map +1 -1
  17. package/dist/commonjs/common/lib/theming/useTheme.js +2 -5
  18. package/dist/commonjs/common/lib/utils/deepMerge.d.ts +2 -0
  19. package/dist/commonjs/common/lib/utils/deepMerge.d.ts.map +1 -0
  20. package/dist/commonjs/common/lib/utils/deepMerge.js +24 -0
  21. package/dist/commonjs/common/lib/utils/memoize.d.ts +6 -0
  22. package/dist/commonjs/common/lib/utils/memoize.d.ts.map +1 -0
  23. package/dist/commonjs/common/lib/utils/memoize.js +24 -0
  24. package/dist/commonjs/side-panel/lib/SidePanel.d.ts.map +1 -1
  25. package/dist/commonjs/side-panel/lib/SidePanel.js +1 -2
  26. package/dist/commonjs/tokens/lib/type/fontFamilies.d.ts.map +1 -1
  27. package/dist/commonjs/tokens/lib/type/fontFamilies.js +5 -6
  28. package/dist/es6/common/lib/styles/focusRing.d.ts +0 -3
  29. package/dist/es6/common/lib/styles/focusRing.d.ts.map +1 -1
  30. package/dist/es6/common/lib/styles/focusRing.js +1 -12
  31. package/dist/es6/common/lib/theming/createCanvasTheme.d.ts +7 -6
  32. package/dist/es6/common/lib/theming/createCanvasTheme.d.ts.map +1 -1
  33. package/dist/es6/common/lib/theming/createCanvasTheme.js +32 -27
  34. package/dist/es6/common/lib/theming/getObjectProxy.d.ts +9 -3
  35. package/dist/es6/common/lib/theming/getObjectProxy.d.ts.map +1 -1
  36. package/dist/es6/common/lib/theming/getObjectProxy.js +20 -20
  37. package/dist/es6/common/lib/theming/useTheme.d.ts.map +1 -1
  38. package/dist/es6/common/lib/theming/useTheme.js +2 -2
  39. package/dist/es6/common/lib/utils/deepMerge.d.ts +2 -0
  40. package/dist/es6/common/lib/utils/deepMerge.d.ts.map +1 -0
  41. package/dist/es6/common/lib/utils/deepMerge.js +20 -0
  42. package/dist/es6/common/lib/utils/memoize.d.ts +6 -0
  43. package/dist/es6/common/lib/utils/memoize.d.ts.map +1 -0
  44. package/dist/es6/common/lib/utils/memoize.js +20 -0
  45. package/dist/es6/side-panel/lib/SidePanel.d.ts.map +1 -1
  46. package/dist/es6/side-panel/lib/SidePanel.js +1 -2
  47. package/dist/es6/tokens/lib/type/fontFamilies.d.ts.map +1 -1
  48. package/dist/es6/tokens/lib/type/fontFamilies.js +5 -3
  49. package/package.json +3 -4
  50. package/side-panel/lib/SidePanel.tsx +1 -2
  51. package/tokens/lib/type/fontFamilies.ts +5 -4
@@ -1,7 +1,6 @@
1
1
  import {keyframes, Theme, CSSObject} from '@emotion/react';
2
2
  import {canvas} from '@workday/canvas-kit-react/tokens';
3
3
  import {defaultCanvasTheme} from '../theming/index';
4
- import memoize from 'lodash/memoize';
5
4
 
6
5
  interface FocusRingOptions {
7
6
  width?: number;
@@ -16,7 +15,6 @@ interface FocusRingOptions {
16
15
  inset?: 'inner' | 'outer';
17
16
  innerColor?: string;
18
17
  outerColor?: string;
19
- memoize?: boolean;
20
18
  }
21
19
 
22
20
  function calculateFocusRing({
@@ -62,8 +60,6 @@ function calculateFocusRing({
62
60
  return {boxShadow};
63
61
  }
64
62
 
65
- export const memoizedFocusRing = memoize(calculateFocusRing, (...args) => JSON.stringify(args));
66
-
67
63
  /**
68
64
  * A utility to create a canvas style focus ring around your widget.
69
65
  * By default, this mixin will create a 2px focus ring tightly wrapped
@@ -96,7 +92,6 @@ export function focusRing(options: FocusRingOptions = {}, theme?: Theme): CSSObj
96
92
  outerColor = theme && theme.canvas
97
93
  ? theme.canvas.palette.common.focusOutline
98
94
  : defaultCanvasTheme.palette.common.focusOutline,
99
- memoize = true,
100
95
  inset,
101
96
  } = options;
102
97
 
@@ -109,9 +104,5 @@ export function focusRing(options: FocusRingOptions = {}, theme?: Theme): CSSObj
109
104
  inset,
110
105
  };
111
106
 
112
- if (memoize) {
113
- return memoizedFocusRing(args);
114
- }
115
-
116
107
  return calculateFocusRing(args);
117
108
  }
@@ -1,7 +1,4 @@
1
1
  import chroma from 'chroma-js';
2
- import merge from 'lodash/merge';
3
- import memoize from 'lodash/memoize';
4
- import findKey from 'lodash/findKey';
5
2
  import colors from '@workday/canvas-colors-web';
6
3
  import {defaultCanvasTheme} from './theme';
7
4
  import {
@@ -14,40 +11,43 @@ import {
14
11
  import {CanvasColor} from '@workday/canvas-kit-react/tokens';
15
12
  import {pickForegroundColor} from '../utils';
16
13
 
17
- export enum ColorDirection {
18
- Darken,
19
- Brighten,
20
- }
21
-
22
- export function shiftColor(hexColor: string, direction: ColorDirection) {
23
- const canvasColor = findKey(colors, color => color === hexColor);
14
+ // Should these be exported?
15
+ import { deepMerge } from '../utils/deepMerge';
16
+ import { memoize } from '../utils/memoize';
24
17
 
25
- const darken = direction === ColorDirection.Darken;
18
+ export const shiftColor = memoize(
19
+ (hexColor: string, amount = 100) => {
20
+ const canvasColor = Object.keys(colors).find(color => colors[color] === hexColor);
26
21
 
27
- if (canvasColor) {
28
- const colorRegex = /([a-zAz]*)(\d{3})/g;
29
- const match = colorRegex.exec(canvasColor);
22
+ if (canvasColor) {
23
+ const colorRegex = /([a-zAz]*)(\d{3})/g;
24
+ const match = colorRegex.exec(canvasColor);
30
25
 
31
- if (match) {
32
- const baseColor = match[1];
33
- const shadeNumber = parseInt(match[2], 10);
26
+ if (match) {
27
+ const baseColor = match[1];
28
+ const shadeNumber = parseInt(match[2], 10);
34
29
 
35
- const newShade = darken ? shadeNumber + 100 : shadeNumber - 100;
30
+ const newShade = shadeNumber + amount;
36
31
 
37
- if (newShade >= 100 && newShade <= 600) {
38
- return colors[(baseColor + newShade) as CanvasColor];
32
+ if (newShade >= 100 && newShade <= 600) {
33
+ return colors[(baseColor + newShade) as CanvasColor];
34
+ }
39
35
  }
40
36
  }
41
- }
42
37
 
43
- try {
44
- const newColor = darken ? chroma(hexColor).darken() : chroma(hexColor).brighten();
45
- return newColor.hex();
46
- } catch (e) {
47
- console.warn(`Invalid color '${hexColor}' used in theme`);
48
- return hexColor;
49
- }
50
- }
38
+ try {
39
+ const newColor =
40
+ amount > 0
41
+ ? chroma(hexColor).darken(amount / 100)
42
+ : chroma(hexColor).brighten(-amount / 100);
43
+ return newColor.hex();
44
+ } catch (e) {
45
+ console.warn(`Invalid color '${hexColor}' used in theme`);
46
+ return hexColor;
47
+ }
48
+ },
49
+ (color, value) => `${color}.${value}`
50
+ );
51
51
 
52
52
  function fillPalette(
53
53
  defaultPalette: CanvasThemePalette,
@@ -59,21 +59,13 @@ function fillPalette(
59
59
 
60
60
  const main = palette.main || defaultPalette.main;
61
61
  const dark =
62
- palette.dark ||
63
- (palette.main && shiftColor(palette.main, ColorDirection.Darken)) ||
64
- defaultPalette.dark;
62
+ palette.dark || (palette.main && shiftColor(palette.main, 100)) || defaultPalette.dark;
65
63
  const darkest =
66
- palette.darkest ||
67
- (palette.main && shiftColor(dark, ColorDirection.Darken)) ||
68
- defaultPalette.darkest;
64
+ palette.darkest || (palette.main && shiftColor(palette.main, 200)) || defaultPalette.darkest;
69
65
  const light =
70
- palette.light ||
71
- (palette.main && shiftColor(palette.main, ColorDirection.Brighten)) ||
72
- defaultPalette.light;
66
+ palette.light || (palette.main && shiftColor(palette.main, -100)) || defaultPalette.light;
73
67
  const lightest =
74
- palette.lightest ||
75
- (palette.main && shiftColor(light, ColorDirection.Brighten)) ||
76
- defaultPalette.lightest;
68
+ palette.lightest || (palette.main && shiftColor(palette.main, -200)) || defaultPalette.lightest;
77
69
  const contrast = palette.contrast || pickForegroundColor(main) || defaultPalette.contrast;
78
70
 
79
71
  return {
@@ -103,7 +95,12 @@ function calculateCanvasTheme(partialTheme: PartialCanvasTheme): CanvasTheme {
103
95
  direction: direction === ContentDirection.RTL ? direction : ContentDirection.LTR,
104
96
  };
105
97
 
106
- return merge({}, defaultCanvasTheme, mergeable, extraFields) as CanvasTheme;
98
+ return deepMerge(deepMerge({}, defaultCanvasTheme), {...mergeable, ...extraFields});
107
99
  }
108
100
 
101
+ /**
102
+ * Creates a full {@link CanvasTheme} from any partial theme by deeply merging with the
103
+ * `defaultCanvasTheme` object. The function is memoized, but it is best to run this function
104
+ * only once and save the result.
105
+ */
109
106
  export const createCanvasTheme = memoize(calculateCanvasTheme, (...args) => JSON.stringify(args));
@@ -1,25 +1,37 @@
1
+ /**
2
+ * For custom themes that do not overwrite every default.
3
+ */
4
+ export type RecursivePartial<T> = {
5
+ [P in keyof T]?: RecursivePartial<T[P]>;
6
+ };
7
+
1
8
  /**
2
9
  * The functions gets a new object proxy. This is used for theme to ensure regardless of a partial theme object
3
10
  * there will be a fallback theme object so that properties aren't undefined regardless of the `target` object.
4
11
  * This function will also handle nested properties.
5
- * @param target Any custom theme object
6
- * @param fallback A fallback theme object
12
+ * @param target A partial object with up to the same shape as the `fallback` object
13
+ * @param fallback A fallback object. If a property to be accessed from the proxy is not available on the target object, the fallback object will be used
7
14
  */
8
- /* eslint-disable compat/compat */
9
- export function getObjectProxy<T extends {}>(target: unknown, fallback: T): T {
10
- return new Proxy(target as any, {
11
- get(target, p: string) {
12
- const prop = p as keyof T; // keep Typescript happy - the `get` signature cannot contain `keyof T`
13
- if (typeof fallback[prop] === 'object' && typeof target[prop] === 'object') {
14
- return getObjectProxy(target[prop] || {}, fallback[prop]);
15
- } else if (target[prop] !== undefined) {
16
- return target[prop];
17
- } else {
18
- return fallback[prop];
19
- }
20
- },
21
- ownKeys(target) {
22
- return Object.keys(fallback);
23
- },
24
- }) as T;
15
+ export function getObjectProxy<T extends {}>(
16
+ target: RecursivePartial<T> | undefined,
17
+ fallback: T
18
+ ): T {
19
+ if (target) {
20
+ return new Proxy(target, {
21
+ get<T>(target: T, prop: string | symbol, receiver: any) {
22
+ if (typeof (fallback as any)[prop] === 'object') {
23
+ return getObjectProxy(target[prop as keyof T], (fallback as any)[prop]);
24
+ }
25
+ const targetProp = target[prop as keyof T];
26
+ if (targetProp !== undefined) {
27
+ return targetProp;
28
+ }
29
+ return Reflect.get(fallback, prop, receiver);
30
+ },
31
+ ownKeys() {
32
+ return Reflect.ownKeys(fallback);
33
+ },
34
+ }) as T;
35
+ }
36
+ return fallback;
25
37
  }
@@ -1,4 +1,3 @@
1
- import get from 'lodash/get';
2
1
  import {useTheme as useEmotionTheme} from '@emotion/react';
3
2
  import {
4
3
  defaultCanvasTheme,
@@ -45,7 +44,7 @@ export function useTheme(theme?: PartialEmotionCanvasTheme): EmotionCanvasTheme
45
44
  // Context not supported or invalid (probably called from within a class component)
46
45
  }
47
46
 
48
- const windowTheme = typeof window !== 'undefined' && get(window, 'window.workday.canvas.theme');
47
+ const windowTheme = typeof window !== 'undefined' && (window as any)?.workday?.canvas?.theme;
49
48
  if (windowTheme) {
50
49
  return getFilledTheme({canvas: windowTheme});
51
50
  }
@@ -0,0 +1,21 @@
1
+ const isObject = (obj: any): boolean => obj && typeof obj === 'object';
2
+ export function deepMerge<T, S>(target: T, source: S): T & S {
3
+ if (!isObject(target) || !isObject(source)) {
4
+ return source as T & S;
5
+ }
6
+
7
+ Object.keys(source).forEach(key => {
8
+ const targetValue = target[key as keyof T];
9
+ const sourceValue = source[key as keyof S];
10
+
11
+ if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
12
+ (target as any)[key] = targetValue.concat(sourceValue);
13
+ } else if (isObject(targetValue) && isObject(sourceValue)) {
14
+ (target as any)[key] = deepMerge(Object.assign({}, targetValue), sourceValue);
15
+ } else {
16
+ (target as any)[key] = sourceValue;
17
+ }
18
+ });
19
+
20
+ return target as T & S;
21
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Simple memoize function. It takes a function and a resolver function to generate a
3
+ * cache key
4
+ */
5
+ export function memoize<T extends (...args: any) => any>(
6
+ func: T,
7
+ resolver: (...args: Parameters<T>) => string
8
+ ): T {
9
+ const cache = new Map<string, ReturnType<T>>();
10
+
11
+ return function(...args: Parameters<T>): ReturnType<T> {
12
+ const key = resolver(...args);
13
+
14
+ if (cache.has(key)) {
15
+ return cache.get(key)!;
16
+ }
17
+
18
+ const result = func(...args);
19
+ cache.set(key, result);
20
+
21
+ return result;
22
+ } as T;
23
+ }
@@ -12,10 +12,7 @@ interface FocusRingOptions {
12
12
  inset?: 'inner' | 'outer';
13
13
  innerColor?: string;
14
14
  outerColor?: string;
15
- memoize?: boolean;
16
15
  }
17
- declare function calculateFocusRing({ width, separation, animate, inset, innerColor, outerColor, }: Required<Omit<FocusRingOptions, 'memoize' | 'inset'>> & Pick<FocusRingOptions, 'inset'>): CSSObject;
18
- export declare const memoizedFocusRing: typeof calculateFocusRing & import("lodash").MemoizedFunction;
19
16
  /**
20
17
  * A utility to create a canvas style focus ring around your widget.
21
18
  * By default, this mixin will create a 2px focus ring tightly wrapped
@@ -1 +1 @@
1
- {"version":3,"file":"focusRing.d.ts","sourceRoot":"","sources":["../../../../../common/lib/styles/focusRing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,EAAE,SAAS,EAA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B,SAAS,CAAC,OAAO,GAAE,gBAAqB,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAsBlF"}
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.focusRing = exports.memoizedFocusRing = void 0;
3
+ exports.focusRing = void 0;
7
4
  var react_1 = require("@emotion/react");
8
5
  var tokens_1 = require("@workday/canvas-kit-react/tokens");
9
6
  var index_1 = require("../theming/index");
10
- var memoize_1 = __importDefault(require("lodash/memoize"));
11
7
  function calculateFocusRing(_a) {
12
8
  var width = _a.width, separation = _a.separation, animate = _a.animate, inset = _a.inset, innerColor = _a.innerColor, outerColor = _a.outerColor;
13
9
  var boxShadow, innerWidth, outerWidth;
@@ -37,13 +33,6 @@ function calculateFocusRing(_a) {
37
33
  }
38
34
  return { boxShadow: boxShadow };
39
35
  }
40
- exports.memoizedFocusRing = memoize_1.default(calculateFocusRing, function () {
41
- var args = [];
42
- for (var _i = 0; _i < arguments.length; _i++) {
43
- args[_i] = arguments[_i];
44
- }
45
- return JSON.stringify(args);
46
- });
47
36
  /**
48
37
  * A utility to create a canvas style focus ring around your widget.
49
38
  * By default, this mixin will create a 2px focus ring tightly wrapped
@@ -70,7 +59,7 @@ function focusRing(options, theme) {
70
59
  if (options === void 0) { options = {}; }
71
60
  var _a = options.width, width = _a === void 0 ? 2 : _a, _b = options.separation, separation = _b === void 0 ? 0 : _b, _c = options.animate, animate = _c === void 0 ? true : _c, _d = options.innerColor, innerColor = _d === void 0 ? tokens_1.canvas.colors.frenchVanilla100 : _d, _e = options.outerColor, outerColor = _e === void 0 ? theme && theme.canvas
72
61
  ? theme.canvas.palette.common.focusOutline
73
- : index_1.defaultCanvasTheme.palette.common.focusOutline : _e, _f = options.memoize, memoize = _f === void 0 ? true : _f, inset = options.inset;
62
+ : index_1.defaultCanvasTheme.palette.common.focusOutline : _e, inset = options.inset;
74
63
  var args = {
75
64
  width: width,
76
65
  separation: separation,
@@ -79,9 +68,6 @@ function focusRing(options, theme) {
79
68
  animate: animate,
80
69
  inset: inset,
81
70
  };
82
- if (memoize) {
83
- return exports.memoizedFocusRing(args);
84
- }
85
71
  return calculateFocusRing(args);
86
72
  }
87
73
  exports.focusRing = focusRing;
@@ -1,10 +1,11 @@
1
1
  import { CanvasTheme, PartialCanvasTheme } from './types';
2
- export declare enum ColorDirection {
3
- Darken = 0,
4
- Brighten = 1
5
- }
6
- export declare function shiftColor(hexColor: string, direction: ColorDirection): string;
2
+ export declare const shiftColor: (hexColor: string, amount?: any) => string;
7
3
  declare function calculateCanvasTheme(partialTheme: PartialCanvasTheme): CanvasTheme;
8
- export declare const createCanvasTheme: typeof calculateCanvasTheme & import("lodash").MemoizedFunction;
4
+ /**
5
+ * Creates a full {@link CanvasTheme} from any partial theme by deeply merging with the
6
+ * `defaultCanvasTheme` object. The function is memoized, but it is best to run this function
7
+ * only once and save the result.
8
+ */
9
+ export declare const createCanvasTheme: typeof calculateCanvasTheme;
9
10
  export {};
10
11
  //# sourceMappingURL=createCanvasTheme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createCanvasTheme.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/createCanvasTheme.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,WAAW,EACX,kBAAkB,EAInB,MAAM,SAAS,CAAC;AAIjB,oBAAY,cAAc;IACxB,MAAM,IAAA;IACN,QAAQ,IAAA;CACT;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,UA4BrE;AAuCD,iBAAS,oBAAoB,CAAC,YAAY,EAAE,kBAAkB,GAAG,WAAW,CAkB3E;AAED,eAAO,MAAM,iBAAiB,iEAAmE,CAAC"}
1
+ {"version":3,"file":"createCanvasTheme.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/createCanvasTheme.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,kBAAkB,EAInB,MAAM,SAAS,CAAC;AAQjB,eAAO,MAAM,UAAU,aACV,MAAM,yBA+BlB,CAAC;AA+BF,iBAAS,oBAAoB,CAAC,YAAY,EAAE,kBAAkB,GAAG,WAAW,CAkB3E;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,6BAAmE,CAAC"}
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __rest = (this && this.__rest) || function (s, e) {
3
14
  var t = {};
4
15
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -14,62 +25,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
26
  };
16
27
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.createCanvasTheme = exports.shiftColor = exports.ColorDirection = void 0;
28
+ exports.createCanvasTheme = exports.shiftColor = void 0;
18
29
  var chroma_js_1 = __importDefault(require("chroma-js"));
19
- var merge_1 = __importDefault(require("lodash/merge"));
20
- var memoize_1 = __importDefault(require("lodash/memoize"));
21
- var findKey_1 = __importDefault(require("lodash/findKey"));
22
30
  var canvas_colors_web_1 = __importDefault(require("@workday/canvas-colors-web"));
23
31
  var theme_1 = require("./theme");
24
32
  var types_1 = require("./types");
25
33
  var utils_1 = require("../utils");
26
- var ColorDirection;
27
- (function (ColorDirection) {
28
- ColorDirection[ColorDirection["Darken"] = 0] = "Darken";
29
- ColorDirection[ColorDirection["Brighten"] = 1] = "Brighten";
30
- })(ColorDirection = exports.ColorDirection || (exports.ColorDirection = {}));
31
- function shiftColor(hexColor, direction) {
32
- var canvasColor = findKey_1.default(canvas_colors_web_1.default, function (color) { return color === hexColor; });
33
- var darken = direction === ColorDirection.Darken;
34
+ // Should these be exported?
35
+ var deepMerge_1 = require("../utils/deepMerge");
36
+ var memoize_1 = require("../utils/memoize");
37
+ exports.shiftColor = memoize_1.memoize(function (hexColor, amount) {
38
+ if (amount === void 0) { amount = 100; }
39
+ var canvasColor = Object.keys(canvas_colors_web_1.default).find(function (color) { return canvas_colors_web_1.default[color] === hexColor; });
34
40
  if (canvasColor) {
35
41
  var colorRegex = /([a-zAz]*)(\d{3})/g;
36
42
  var match = colorRegex.exec(canvasColor);
37
43
  if (match) {
38
44
  var baseColor = match[1];
39
45
  var shadeNumber = parseInt(match[2], 10);
40
- var newShade = darken ? shadeNumber + 100 : shadeNumber - 100;
46
+ var newShade = shadeNumber + amount;
41
47
  if (newShade >= 100 && newShade <= 600) {
42
48
  return canvas_colors_web_1.default[(baseColor + newShade)];
43
49
  }
44
50
  }
45
51
  }
46
52
  try {
47
- var newColor = darken ? chroma_js_1.default(hexColor).darken() : chroma_js_1.default(hexColor).brighten();
53
+ var newColor = amount > 0
54
+ ? chroma_js_1.default(hexColor).darken(amount / 100)
55
+ : chroma_js_1.default(hexColor).brighten(-amount / 100);
48
56
  return newColor.hex();
49
57
  }
50
58
  catch (e) {
51
59
  console.warn("Invalid color '" + hexColor + "' used in theme");
52
60
  return hexColor;
53
61
  }
54
- }
55
- exports.shiftColor = shiftColor;
62
+ }, function (color, value) { return color + "." + value; });
56
63
  function fillPalette(defaultPalette, palette) {
57
64
  if (!palette) {
58
65
  return {};
59
66
  }
60
67
  var main = palette.main || defaultPalette.main;
61
- var dark = palette.dark ||
62
- (palette.main && shiftColor(palette.main, ColorDirection.Darken)) ||
63
- defaultPalette.dark;
64
- var darkest = palette.darkest ||
65
- (palette.main && shiftColor(dark, ColorDirection.Darken)) ||
66
- defaultPalette.darkest;
67
- var light = palette.light ||
68
- (palette.main && shiftColor(palette.main, ColorDirection.Brighten)) ||
69
- defaultPalette.light;
70
- var lightest = palette.lightest ||
71
- (palette.main && shiftColor(light, ColorDirection.Brighten)) ||
72
- defaultPalette.lightest;
68
+ var dark = palette.dark || (palette.main && exports.shiftColor(palette.main, 100)) || defaultPalette.dark;
69
+ var darkest = palette.darkest || (palette.main && exports.shiftColor(palette.main, 200)) || defaultPalette.darkest;
70
+ var light = palette.light || (palette.main && exports.shiftColor(palette.main, -100)) || defaultPalette.light;
71
+ var lightest = palette.lightest || (palette.main && exports.shiftColor(palette.main, -200)) || defaultPalette.lightest;
73
72
  var contrast = palette.contrast || utils_1.pickForegroundColor(main) || defaultPalette.contrast;
74
73
  return {
75
74
  lightest: lightest,
@@ -95,9 +94,14 @@ function calculateCanvasTheme(partialTheme) {
95
94
  breakpoints: breakpoints,
96
95
  direction: direction === types_1.ContentDirection.RTL ? direction : types_1.ContentDirection.LTR,
97
96
  };
98
- return merge_1.default({}, theme_1.defaultCanvasTheme, mergeable, extraFields);
97
+ return deepMerge_1.deepMerge(deepMerge_1.deepMerge({}, theme_1.defaultCanvasTheme), __assign(__assign({}, mergeable), extraFields));
99
98
  }
100
- exports.createCanvasTheme = memoize_1.default(calculateCanvasTheme, function () {
99
+ /**
100
+ * Creates a full {@link CanvasTheme} from any partial theme by deeply merging with the
101
+ * `defaultCanvasTheme` object. The function is memoized, but it is best to run this function
102
+ * only once and save the result.
103
+ */
104
+ exports.createCanvasTheme = memoize_1.memoize(calculateCanvasTheme, function () {
101
105
  var args = [];
102
106
  for (var _i = 0; _i < arguments.length; _i++) {
103
107
  args[_i] = arguments[_i];
@@ -1,9 +1,15 @@
1
+ /**
2
+ * For custom themes that do not overwrite every default.
3
+ */
4
+ export declare type RecursivePartial<T> = {
5
+ [P in keyof T]?: RecursivePartial<T[P]>;
6
+ };
1
7
  /**
2
8
  * The functions gets a new object proxy. This is used for theme to ensure regardless of a partial theme object
3
9
  * there will be a fallback theme object so that properties aren't undefined regardless of the `target` object.
4
10
  * This function will also handle nested properties.
5
- * @param target Any custom theme object
6
- * @param fallback A fallback theme object
11
+ * @param target A partial object with up to the same shape as the `fallback` object
12
+ * @param fallback A fallback object. If a property to be accessed from the proxy is not available on the target object, the fallback object will be used
7
13
  */
8
- export declare function getObjectProxy<T extends {}>(target: unknown, fallback: T): T;
14
+ export declare function getObjectProxy<T extends {}>(target: RecursivePartial<T> | undefined, fallback: T): T;
9
15
  //# sourceMappingURL=getObjectProxy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getObjectProxy.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/getObjectProxy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,cAAc,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAgB5E"}
1
+ {"version":3,"file":"getObjectProxy.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/getObjectProxy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,gBAAgB,CAAC,CAAC,IAAI;KAC/B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,EAAE,EACzC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,EACvC,QAAQ,EAAE,CAAC,GACV,CAAC,CAmBH"}
@@ -5,27 +5,27 @@ exports.getObjectProxy = void 0;
5
5
  * The functions gets a new object proxy. This is used for theme to ensure regardless of a partial theme object
6
6
  * there will be a fallback theme object so that properties aren't undefined regardless of the `target` object.
7
7
  * This function will also handle nested properties.
8
- * @param target Any custom theme object
9
- * @param fallback A fallback theme object
8
+ * @param target A partial object with up to the same shape as the `fallback` object
9
+ * @param fallback A fallback object. If a property to be accessed from the proxy is not available on the target object, the fallback object will be used
10
10
  */
11
- /* eslint-disable compat/compat */
12
11
  function getObjectProxy(target, fallback) {
13
- return new Proxy(target, {
14
- get: function (target, p) {
15
- var prop = p; // keep Typescript happy - the `get` signature cannot contain `keyof T`
16
- if (typeof fallback[prop] === 'object' && typeof target[prop] === 'object') {
17
- return getObjectProxy(target[prop] || {}, fallback[prop]);
18
- }
19
- else if (target[prop] !== undefined) {
20
- return target[prop];
21
- }
22
- else {
23
- return fallback[prop];
24
- }
25
- },
26
- ownKeys: function (target) {
27
- return Object.keys(fallback);
28
- },
29
- });
12
+ if (target) {
13
+ return new Proxy(target, {
14
+ get: function (target, prop, receiver) {
15
+ if (typeof fallback[prop] === 'object') {
16
+ return getObjectProxy(target[prop], fallback[prop]);
17
+ }
18
+ var targetProp = target[prop];
19
+ if (targetProp !== undefined) {
20
+ return targetProp;
21
+ }
22
+ return Reflect.get(fallback, prop, receiver);
23
+ },
24
+ ownKeys: function () {
25
+ return Reflect.ownKeys(fallback);
26
+ },
27
+ });
28
+ }
29
+ return fallback;
30
30
  }
31
31
  exports.getObjectProxy = getObjectProxy;
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/useTheme.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAOjB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,yBAAyB,GAAG,kBAAkB,CAqB9E"}
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/useTheme.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAOjB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,yBAAyB,GAAG,kBAAkB,CAqB9E"}
@@ -10,12 +10,8 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
13
  Object.defineProperty(exports, "__esModule", { value: true });
17
14
  exports.useTheme = void 0;
18
- var get_1 = __importDefault(require("lodash/get"));
19
15
  var react_1 = require("@emotion/react");
20
16
  var index_1 = require("./index");
21
17
  var getFilledTheme = function (theme) { return (__assign(__assign({}, theme), { canvas: index_1.createCanvasTheme(theme.canvas) })); };
@@ -38,6 +34,7 @@ var getFilledTheme = function (theme) { return (__assign(__assign({}, theme), {
38
34
  * Tracked on https://github.com/emotion-js/emotion/issues/1193.
39
35
  */
40
36
  function useTheme(theme) {
37
+ var _a, _b, _c;
41
38
  if (theme && theme.canvas) {
42
39
  return getFilledTheme(theme);
43
40
  }
@@ -51,7 +48,7 @@ function useTheme(theme) {
51
48
  catch (e) {
52
49
  // Context not supported or invalid (probably called from within a class component)
53
50
  }
54
- var windowTheme = typeof window !== 'undefined' && get_1.default(window, 'window.workday.canvas.theme');
51
+ var windowTheme = typeof window !== 'undefined' && ((_c = (_b = (_a = window) === null || _a === void 0 ? void 0 : _a.workday) === null || _b === void 0 ? void 0 : _b.canvas) === null || _c === void 0 ? void 0 : _c.theme);
55
52
  if (windowTheme) {
56
53
  return getFilledTheme({ canvas: windowTheme });
57
54
  }
@@ -0,0 +1,2 @@
1
+ export declare function deepMerge<T, S>(target: T, source: S): T & S;
2
+ //# sourceMappingURL=deepMerge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepMerge.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/deepMerge.ts"],"names":[],"mappings":"AACA,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAmB3D"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deepMerge = void 0;
4
+ var isObject = function (obj) { return obj && typeof obj === 'object'; };
5
+ function deepMerge(target, source) {
6
+ if (!isObject(target) || !isObject(source)) {
7
+ return source;
8
+ }
9
+ Object.keys(source).forEach(function (key) {
10
+ var targetValue = target[key];
11
+ var sourceValue = source[key];
12
+ if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
13
+ target[key] = targetValue.concat(sourceValue);
14
+ }
15
+ else if (isObject(targetValue) && isObject(sourceValue)) {
16
+ target[key] = deepMerge(Object.assign({}, targetValue), sourceValue);
17
+ }
18
+ else {
19
+ target[key] = sourceValue;
20
+ }
21
+ });
22
+ return target;
23
+ }
24
+ exports.deepMerge = deepMerge;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Simple memoize function. It takes a function and a resolver function to generate a
3
+ * cache key
4
+ */
5
+ export declare function memoize<T extends (...args: any) => any>(func: T, resolver: (...args: Parameters<T>) => string): T;
6
+ //# sourceMappingURL=memoize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/memoize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EACrD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,GAC3C,CAAC,CAeH"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.memoize = void 0;
4
+ /**
5
+ * Simple memoize function. It takes a function and a resolver function to generate a
6
+ * cache key
7
+ */
8
+ function memoize(func, resolver) {
9
+ var cache = new Map();
10
+ return function () {
11
+ var args = [];
12
+ for (var _i = 0; _i < arguments.length; _i++) {
13
+ args[_i] = arguments[_i];
14
+ }
15
+ var key = resolver.apply(void 0, args);
16
+ if (cache.has(key)) {
17
+ return cache.get(key);
18
+ }
19
+ var result = func.apply(void 0, args);
20
+ cache.set(key, result);
21
+ return result;
22
+ };
23
+ }
24
+ exports.memoize = memoize;
@@ -1 +1 @@
1
- {"version":3,"file":"SidePanel.d.ts","sourceRoot":"","sources":["../../../../side-panel/lib/SidePanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAgB,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AAKlF,MAAM,WAAW,cAAe,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC1E;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IAClC;;;OAGG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC;;OAEG;IACH,kBAAkB,CAAC,EAAE,CAAC,eAAe,EAAE,OAAO,KAAK,IAAI,CAAC;IACxD;;OAEG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,oBAAY,sBAAsB;IAChC,IAAI,IAAA;IACJ,KAAK,IAAA;CACN;AAED,oBAAY,wBAAwB;IAClC,KAAK,IAAA;IACL,WAAW,IAAA;IACX,IAAI,IAAA;CACL;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7B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,oBAAY,sBAAsB;IAChC,IAAI,IAAA;IACJ,KAAK,IAAA;CACN;AAED,oBAAY,wBAAwB;IAClC,KAAK,IAAA;IACL,WAAW,IAAA;IACX,IAAI,IAAA;CACL;AAwFD,qBAAa,SAAU,SAAQ,KAAK,CAAC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IAC5E,MAAM,CAAC,aAAa,gCAA0B;IAC9C,MAAM,CAAC,eAAe,kCAA4B;gBAEtC,KAAK,EAAE,cAAc;IAKjC,KAAK;;MAEH;IAEK,iBAAiB;IAGjB,oBAAoB;IAIpB,MAAM;IAgDb,OAAO,CAAC,YAAY,CAWlB;IAEF,OAAO,CAAC,aAAa,CAInB;IAEF,OAAO,CAAC,qBAAqB,CAS3B;CACH"}
@@ -62,7 +62,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
62
62
  exports.SidePanel = exports.SidePanelBackgroundColor = exports.SidePanelOpenDirection = void 0;
63
63
  var React = __importStar(require("react"));
64
64
  var styled_1 = __importDefault(require("@emotion/styled"));
65
- var throttle_1 = __importDefault(require("lodash/throttle"));
66
65
  var tokens_1 = require("@workday/canvas-kit-react/tokens");
67
66
  var button_1 = require("@workday/canvas-kit-react/button");
68
67
  var canvas_system_icons_web_1 = require("@workday/canvas-system-icons-web");
@@ -190,7 +189,7 @@ var SidePanel = /** @class */ (function (_super) {
190
189
  return open ? canvas_system_icons_web_1.chevronRightIcon : canvas_system_icons_web_1.chevronLeftIcon;
191
190
  }
192
191
  };
193
- _this.handleResize = throttle_1.default(_this.handleResize.bind(_this), 150);
192
+ _this.handleResize = _this.handleResize.bind(_this);
194
193
  return _this;
195
194
  }
196
195
  SidePanel.prototype.componentDidMount = function () {
@@ -1 +1 @@
1
- {"version":3,"file":"fontFamilies.d.ts","sourceRoot":"","sources":["../../../../../tokens/lib/type/fontFamilies.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU,QAEyC,CAAC;AACjE,eAAO,MAAM,cAAc,QAGgD,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B;;;SAGK;IACL,OAAO,EAAE,OAAO,UAAU,CAAC;IAC3B;;;SAGK;IACL,SAAS,EAAE,OAAO,cAAc,CAAC;CAClC,CAAC"}
1
+ {"version":3,"file":"fontFamilies.d.ts","sourceRoot":"","sources":["../../../../../tokens/lib/type/fontFamilies.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,UAAU,QAEyC,CAAC;AACjE,eAAO,MAAM,cAAc,QAGgD,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B;;;SAGK;IACL,OAAO,EAAE,OAAO,UAAU,CAAC;IAC3B;;;SAGK;IACL,SAAS,EAAE,OAAO,cAAc,CAAC;CAClC,CAAC"}
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.fontFamilies = exports.monoFontFamily = exports.fontFamily = void 0;
7
- var get_1 = __importDefault(require("lodash/get"));
8
- var inheritFont = typeof window !== 'undefined' && get_1.default(window, 'window.workday.canvas.inheritFontFamily');
9
- var inheritMonoFont = typeof window !== 'undefined' && get_1.default(window, 'window.workday.canvas.inheritMonoFontFamily');
4
+ // prettier-ignore
5
+ //@ts-ignore
6
+ var canvasObject = typeof window !== 'undefined' && window.workday && window.workday.canvas && window.workday.canvas;
7
+ var inheritFont = typeof canvasObject !== 'undefined' && canvasObject.inheritFontFamily;
8
+ var inheritMonoFont = typeof canvasObject !== 'undefined' && canvasObject.inheritMonoFontFamily;
10
9
  exports.fontFamily = inheritFont
11
10
  ? 'inherit'
12
11
  : '"Roboto", "Helvetica Neue", "Helvetica", Arial, sans-serif';
@@ -12,10 +12,7 @@ interface FocusRingOptions {
12
12
  inset?: 'inner' | 'outer';
13
13
  innerColor?: string;
14
14
  outerColor?: string;
15
- memoize?: boolean;
16
15
  }
17
- declare function calculateFocusRing({ width, separation, animate, inset, innerColor, outerColor, }: Required<Omit<FocusRingOptions, 'memoize' | 'inset'>> & Pick<FocusRingOptions, 'inset'>): CSSObject;
18
- export declare const memoizedFocusRing: typeof calculateFocusRing & import("lodash").MemoizedFunction;
19
16
  /**
20
17
  * A utility to create a canvas style focus ring around your widget.
21
18
  * By default, this mixin will create a 2px focus ring tightly wrapped
@@ -1 +1 @@
1
- {"version":3,"file":"focusRing.d.ts","sourceRoot":"","sources":["../../../../../common/lib/styles/focusRing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAK3D,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,iBAAS,kBAAkB,CAAC,EAC1B,KAAK,EACL,UAAU,EACV,OAAO,EACP,KAAK,EACL,UAAU,EACV,UAAU,GACX,EAAE,QAAQ,CAAC,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,GACtD,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG,SAAS,CAiC5C;AAED,eAAO,MAAM,iBAAiB,+DAAiE,CAAC;AAEhG;;;;;;;;;;;;;;GAcG;AAEH;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CA2BlF"}
1
+ {"version":3,"file":"focusRing.d.ts","sourceRoot":"","sources":["../../../../../common/lib/styles/focusRing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,EAAE,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAI3D,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AA6CD;;;;;;;;;;;;;;GAcG;AAEH;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,SAAS,CAsBlF"}
@@ -1,7 +1,6 @@
1
1
  import { keyframes } from '@emotion/react';
2
2
  import { canvas } from '@workday/canvas-kit-react/tokens';
3
3
  import { defaultCanvasTheme } from '../theming/index';
4
- import memoize from 'lodash/memoize';
5
4
  function calculateFocusRing(_a) {
6
5
  var width = _a.width, separation = _a.separation, animate = _a.animate, inset = _a.inset, innerColor = _a.innerColor, outerColor = _a.outerColor;
7
6
  var boxShadow, innerWidth, outerWidth;
@@ -31,13 +30,6 @@ function calculateFocusRing(_a) {
31
30
  }
32
31
  return { boxShadow: boxShadow };
33
32
  }
34
- export var memoizedFocusRing = memoize(calculateFocusRing, function () {
35
- var args = [];
36
- for (var _i = 0; _i < arguments.length; _i++) {
37
- args[_i] = arguments[_i];
38
- }
39
- return JSON.stringify(args);
40
- });
41
33
  /**
42
34
  * A utility to create a canvas style focus ring around your widget.
43
35
  * By default, this mixin will create a 2px focus ring tightly wrapped
@@ -64,7 +56,7 @@ export function focusRing(options, theme) {
64
56
  if (options === void 0) { options = {}; }
65
57
  var _a = options.width, width = _a === void 0 ? 2 : _a, _b = options.separation, separation = _b === void 0 ? 0 : _b, _c = options.animate, animate = _c === void 0 ? true : _c, _d = options.innerColor, innerColor = _d === void 0 ? canvas.colors.frenchVanilla100 : _d, _e = options.outerColor, outerColor = _e === void 0 ? theme && theme.canvas
66
58
  ? theme.canvas.palette.common.focusOutline
67
- : defaultCanvasTheme.palette.common.focusOutline : _e, _f = options.memoize, memoize = _f === void 0 ? true : _f, inset = options.inset;
59
+ : defaultCanvasTheme.palette.common.focusOutline : _e, inset = options.inset;
68
60
  var args = {
69
61
  width: width,
70
62
  separation: separation,
@@ -73,8 +65,5 @@ export function focusRing(options, theme) {
73
65
  animate: animate,
74
66
  inset: inset,
75
67
  };
76
- if (memoize) {
77
- return memoizedFocusRing(args);
78
- }
79
68
  return calculateFocusRing(args);
80
69
  }
@@ -1,10 +1,11 @@
1
1
  import { CanvasTheme, PartialCanvasTheme } from './types';
2
- export declare enum ColorDirection {
3
- Darken = 0,
4
- Brighten = 1
5
- }
6
- export declare function shiftColor(hexColor: string, direction: ColorDirection): string;
2
+ export declare const shiftColor: (hexColor: string, amount?: any) => string;
7
3
  declare function calculateCanvasTheme(partialTheme: PartialCanvasTheme): CanvasTheme;
8
- export declare const createCanvasTheme: typeof calculateCanvasTheme & import("lodash").MemoizedFunction;
4
+ /**
5
+ * Creates a full {@link CanvasTheme} from any partial theme by deeply merging with the
6
+ * `defaultCanvasTheme` object. The function is memoized, but it is best to run this function
7
+ * only once and save the result.
8
+ */
9
+ export declare const createCanvasTheme: typeof calculateCanvasTheme;
9
10
  export {};
10
11
  //# sourceMappingURL=createCanvasTheme.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createCanvasTheme.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/createCanvasTheme.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,WAAW,EACX,kBAAkB,EAInB,MAAM,SAAS,CAAC;AAIjB,oBAAY,cAAc;IACxB,MAAM,IAAA;IACN,QAAQ,IAAA;CACT;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,UA4BrE;AAuCD,iBAAS,oBAAoB,CAAC,YAAY,EAAE,kBAAkB,GAAG,WAAW,CAkB3E;AAED,eAAO,MAAM,iBAAiB,iEAAmE,CAAC"}
1
+ {"version":3,"file":"createCanvasTheme.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/createCanvasTheme.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,kBAAkB,EAInB,MAAM,SAAS,CAAC;AAQjB,eAAO,MAAM,UAAU,aACV,MAAM,yBA+BlB,CAAC;AA+BF,iBAAS,oBAAoB,CAAC,YAAY,EAAE,kBAAkB,GAAG,WAAW,CAkB3E;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,6BAAmE,CAAC"}
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  var __rest = (this && this.__rest) || function (s, e) {
2
13
  var t = {};
3
14
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -10,59 +21,48 @@ var __rest = (this && this.__rest) || function (s, e) {
10
21
  return t;
11
22
  };
12
23
  import chroma from 'chroma-js';
13
- import merge from 'lodash/merge';
14
- import memoize from 'lodash/memoize';
15
- import findKey from 'lodash/findKey';
16
24
  import colors from '@workday/canvas-colors-web';
17
25
  import { defaultCanvasTheme } from './theme';
18
26
  import { ContentDirection, } from './types';
19
27
  import { pickForegroundColor } from '../utils';
20
- export var ColorDirection;
21
- (function (ColorDirection) {
22
- ColorDirection[ColorDirection["Darken"] = 0] = "Darken";
23
- ColorDirection[ColorDirection["Brighten"] = 1] = "Brighten";
24
- })(ColorDirection || (ColorDirection = {}));
25
- export function shiftColor(hexColor, direction) {
26
- var canvasColor = findKey(colors, function (color) { return color === hexColor; });
27
- var darken = direction === ColorDirection.Darken;
28
+ // Should these be exported?
29
+ import { deepMerge } from '../utils/deepMerge';
30
+ import { memoize } from '../utils/memoize';
31
+ export var shiftColor = memoize(function (hexColor, amount) {
32
+ if (amount === void 0) { amount = 100; }
33
+ var canvasColor = Object.keys(colors).find(function (color) { return colors[color] === hexColor; });
28
34
  if (canvasColor) {
29
35
  var colorRegex = /([a-zAz]*)(\d{3})/g;
30
36
  var match = colorRegex.exec(canvasColor);
31
37
  if (match) {
32
38
  var baseColor = match[1];
33
39
  var shadeNumber = parseInt(match[2], 10);
34
- var newShade = darken ? shadeNumber + 100 : shadeNumber - 100;
40
+ var newShade = shadeNumber + amount;
35
41
  if (newShade >= 100 && newShade <= 600) {
36
42
  return colors[(baseColor + newShade)];
37
43
  }
38
44
  }
39
45
  }
40
46
  try {
41
- var newColor = darken ? chroma(hexColor).darken() : chroma(hexColor).brighten();
47
+ var newColor = amount > 0
48
+ ? chroma(hexColor).darken(amount / 100)
49
+ : chroma(hexColor).brighten(-amount / 100);
42
50
  return newColor.hex();
43
51
  }
44
52
  catch (e) {
45
53
  console.warn("Invalid color '" + hexColor + "' used in theme");
46
54
  return hexColor;
47
55
  }
48
- }
56
+ }, function (color, value) { return color + "." + value; });
49
57
  function fillPalette(defaultPalette, palette) {
50
58
  if (!palette) {
51
59
  return {};
52
60
  }
53
61
  var main = palette.main || defaultPalette.main;
54
- var dark = palette.dark ||
55
- (palette.main && shiftColor(palette.main, ColorDirection.Darken)) ||
56
- defaultPalette.dark;
57
- var darkest = palette.darkest ||
58
- (palette.main && shiftColor(dark, ColorDirection.Darken)) ||
59
- defaultPalette.darkest;
60
- var light = palette.light ||
61
- (palette.main && shiftColor(palette.main, ColorDirection.Brighten)) ||
62
- defaultPalette.light;
63
- var lightest = palette.lightest ||
64
- (palette.main && shiftColor(light, ColorDirection.Brighten)) ||
65
- defaultPalette.lightest;
62
+ var dark = palette.dark || (palette.main && shiftColor(palette.main, 100)) || defaultPalette.dark;
63
+ var darkest = palette.darkest || (palette.main && shiftColor(palette.main, 200)) || defaultPalette.darkest;
64
+ var light = palette.light || (palette.main && shiftColor(palette.main, -100)) || defaultPalette.light;
65
+ var lightest = palette.lightest || (palette.main && shiftColor(palette.main, -200)) || defaultPalette.lightest;
66
66
  var contrast = palette.contrast || pickForegroundColor(main) || defaultPalette.contrast;
67
67
  return {
68
68
  lightest: lightest,
@@ -88,8 +88,13 @@ function calculateCanvasTheme(partialTheme) {
88
88
  breakpoints: breakpoints,
89
89
  direction: direction === ContentDirection.RTL ? direction : ContentDirection.LTR,
90
90
  };
91
- return merge({}, defaultCanvasTheme, mergeable, extraFields);
91
+ return deepMerge(deepMerge({}, defaultCanvasTheme), __assign(__assign({}, mergeable), extraFields));
92
92
  }
93
+ /**
94
+ * Creates a full {@link CanvasTheme} from any partial theme by deeply merging with the
95
+ * `defaultCanvasTheme` object. The function is memoized, but it is best to run this function
96
+ * only once and save the result.
97
+ */
93
98
  export var createCanvasTheme = memoize(calculateCanvasTheme, function () {
94
99
  var args = [];
95
100
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1,9 +1,15 @@
1
+ /**
2
+ * For custom themes that do not overwrite every default.
3
+ */
4
+ export declare type RecursivePartial<T> = {
5
+ [P in keyof T]?: RecursivePartial<T[P]>;
6
+ };
1
7
  /**
2
8
  * The functions gets a new object proxy. This is used for theme to ensure regardless of a partial theme object
3
9
  * there will be a fallback theme object so that properties aren't undefined regardless of the `target` object.
4
10
  * This function will also handle nested properties.
5
- * @param target Any custom theme object
6
- * @param fallback A fallback theme object
11
+ * @param target A partial object with up to the same shape as the `fallback` object
12
+ * @param fallback A fallback object. If a property to be accessed from the proxy is not available on the target object, the fallback object will be used
7
13
  */
8
- export declare function getObjectProxy<T extends {}>(target: unknown, fallback: T): T;
14
+ export declare function getObjectProxy<T extends {}>(target: RecursivePartial<T> | undefined, fallback: T): T;
9
15
  //# sourceMappingURL=getObjectProxy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getObjectProxy.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/getObjectProxy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wBAAgB,cAAc,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAgB5E"}
1
+ {"version":3,"file":"getObjectProxy.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/getObjectProxy.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,gBAAgB,CAAC,CAAC,IAAI;KAC/B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,EAAE,EACzC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,EACvC,QAAQ,EAAE,CAAC,GACV,CAAC,CAmBH"}
@@ -2,26 +2,26 @@
2
2
  * The functions gets a new object proxy. This is used for theme to ensure regardless of a partial theme object
3
3
  * there will be a fallback theme object so that properties aren't undefined regardless of the `target` object.
4
4
  * This function will also handle nested properties.
5
- * @param target Any custom theme object
6
- * @param fallback A fallback theme object
5
+ * @param target A partial object with up to the same shape as the `fallback` object
6
+ * @param fallback A fallback object. If a property to be accessed from the proxy is not available on the target object, the fallback object will be used
7
7
  */
8
- /* eslint-disable compat/compat */
9
8
  export function getObjectProxy(target, fallback) {
10
- return new Proxy(target, {
11
- get: function (target, p) {
12
- var prop = p; // keep Typescript happy - the `get` signature cannot contain `keyof T`
13
- if (typeof fallback[prop] === 'object' && typeof target[prop] === 'object') {
14
- return getObjectProxy(target[prop] || {}, fallback[prop]);
15
- }
16
- else if (target[prop] !== undefined) {
17
- return target[prop];
18
- }
19
- else {
20
- return fallback[prop];
21
- }
22
- },
23
- ownKeys: function (target) {
24
- return Object.keys(fallback);
25
- },
26
- });
9
+ if (target) {
10
+ return new Proxy(target, {
11
+ get: function (target, prop, receiver) {
12
+ if (typeof fallback[prop] === 'object') {
13
+ return getObjectProxy(target[prop], fallback[prop]);
14
+ }
15
+ var targetProp = target[prop];
16
+ if (targetProp !== undefined) {
17
+ return targetProp;
18
+ }
19
+ return Reflect.get(fallback, prop, receiver);
20
+ },
21
+ ownKeys: function () {
22
+ return Reflect.ownKeys(fallback);
23
+ },
24
+ });
25
+ }
26
+ return fallback;
27
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/useTheme.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAOjB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,yBAAyB,GAAG,kBAAkB,CAqB9E"}
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../../../../common/lib/theming/useTheme.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAClB,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAOjB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,KAAK,CAAC,EAAE,yBAAyB,GAAG,kBAAkB,CAqB9E"}
@@ -9,7 +9,6 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import get from 'lodash/get';
13
12
  import { useTheme as useEmotionTheme } from '@emotion/react';
14
13
  import { defaultCanvasTheme, createCanvasTheme, } from './index';
15
14
  var getFilledTheme = function (theme) { return (__assign(__assign({}, theme), { canvas: createCanvasTheme(theme.canvas) })); };
@@ -32,6 +31,7 @@ var getFilledTheme = function (theme) { return (__assign(__assign({}, theme), {
32
31
  * Tracked on https://github.com/emotion-js/emotion/issues/1193.
33
32
  */
34
33
  export function useTheme(theme) {
34
+ var _a, _b, _c;
35
35
  if (theme && theme.canvas) {
36
36
  return getFilledTheme(theme);
37
37
  }
@@ -45,7 +45,7 @@ export function useTheme(theme) {
45
45
  catch (e) {
46
46
  // Context not supported or invalid (probably called from within a class component)
47
47
  }
48
- var windowTheme = typeof window !== 'undefined' && get(window, 'window.workday.canvas.theme');
48
+ var windowTheme = typeof window !== 'undefined' && ((_c = (_b = (_a = window) === null || _a === void 0 ? void 0 : _a.workday) === null || _b === void 0 ? void 0 : _b.canvas) === null || _c === void 0 ? void 0 : _c.theme);
49
49
  if (windowTheme) {
50
50
  return getFilledTheme({ canvas: windowTheme });
51
51
  }
@@ -0,0 +1,2 @@
1
+ export declare function deepMerge<T, S>(target: T, source: S): T & S;
2
+ //# sourceMappingURL=deepMerge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepMerge.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/deepMerge.ts"],"names":[],"mappings":"AACA,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAmB3D"}
@@ -0,0 +1,20 @@
1
+ var isObject = function (obj) { return obj && typeof obj === 'object'; };
2
+ export function deepMerge(target, source) {
3
+ if (!isObject(target) || !isObject(source)) {
4
+ return source;
5
+ }
6
+ Object.keys(source).forEach(function (key) {
7
+ var targetValue = target[key];
8
+ var sourceValue = source[key];
9
+ if (Array.isArray(targetValue) && Array.isArray(sourceValue)) {
10
+ target[key] = targetValue.concat(sourceValue);
11
+ }
12
+ else if (isObject(targetValue) && isObject(sourceValue)) {
13
+ target[key] = deepMerge(Object.assign({}, targetValue), sourceValue);
14
+ }
15
+ else {
16
+ target[key] = sourceValue;
17
+ }
18
+ });
19
+ return target;
20
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Simple memoize function. It takes a function and a resolver function to generate a
3
+ * cache key
4
+ */
5
+ export declare function memoize<T extends (...args: any) => any>(func: T, resolver: (...args: Parameters<T>) => string): T;
6
+ //# sourceMappingURL=memoize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/memoize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,EACrD,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,GAC3C,CAAC,CAeH"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Simple memoize function. It takes a function and a resolver function to generate a
3
+ * cache key
4
+ */
5
+ export function memoize(func, resolver) {
6
+ var cache = new Map();
7
+ return function () {
8
+ var args = [];
9
+ for (var _i = 0; _i < arguments.length; _i++) {
10
+ args[_i] = arguments[_i];
11
+ }
12
+ var key = resolver.apply(void 0, args);
13
+ if (cache.has(key)) {
14
+ return cache.get(key);
15
+ }
16
+ var result = func.apply(void 0, args);
17
+ cache.set(key, result);
18
+ return result;
19
+ };
20
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"SidePanel.d.ts","sourceRoot":"","sources":["../../../../side-panel/lib/SidePanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EAAgB,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AAKlF,MAAM,WAAW,cAAe,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC1E;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,aAAa,CAAC,EAAE,MAA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;CACH"}
@@ -37,7 +37,6 @@ var __rest = (this && this.__rest) || function (s, e) {
37
37
  };
38
38
  import * as React from 'react';
39
39
  import styled from '@emotion/styled';
40
- import throttle from 'lodash/throttle';
41
40
  import { colors, space } from '@workday/canvas-kit-react/tokens';
42
41
  import { TertiaryButton } from '@workday/canvas-kit-react/button';
43
42
  import { chevronLeftIcon, chevronRightIcon } from '@workday/canvas-system-icons-web';
@@ -165,7 +164,7 @@ var SidePanel = /** @class */ (function (_super) {
165
164
  return open ? chevronRightIcon : chevronLeftIcon;
166
165
  }
167
166
  };
168
- _this.handleResize = throttle(_this.handleResize.bind(_this), 150);
167
+ _this.handleResize = _this.handleResize.bind(_this);
169
168
  return _this;
170
169
  }
171
170
  SidePanel.prototype.componentDidMount = function () {
@@ -1 +1 @@
1
- {"version":3,"file":"fontFamilies.d.ts","sourceRoot":"","sources":["../../../../../tokens/lib/type/fontFamilies.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,UAAU,QAEyC,CAAC;AACjE,eAAO,MAAM,cAAc,QAGgD,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B;;;SAGK;IACL,OAAO,EAAE,OAAO,UAAU,CAAC;IAC3B;;;SAGK;IACL,SAAS,EAAE,OAAO,cAAc,CAAC;CAClC,CAAC"}
1
+ {"version":3,"file":"fontFamilies.d.ts","sourceRoot":"","sources":["../../../../../tokens/lib/type/fontFamilies.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,UAAU,QAEyC,CAAC;AACjE,eAAO,MAAM,cAAc,QAGgD,CAAC;AAE5E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,YAAY,EAAE,kBAG1B,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B;;;SAGK;IACL,OAAO,EAAE,OAAO,UAAU,CAAC;IAC3B;;;SAGK;IACL,SAAS,EAAE,OAAO,cAAc,CAAC;CAClC,CAAC"}
@@ -1,6 +1,8 @@
1
- import get from 'lodash/get';
2
- var inheritFont = typeof window !== 'undefined' && get(window, 'window.workday.canvas.inheritFontFamily');
3
- var inheritMonoFont = typeof window !== 'undefined' && get(window, 'window.workday.canvas.inheritMonoFontFamily');
1
+ // prettier-ignore
2
+ //@ts-ignore
3
+ var canvasObject = typeof window !== 'undefined' && window.workday && window.workday.canvas && window.workday.canvas;
4
+ var inheritFont = typeof canvasObject !== 'undefined' && canvasObject.inheritFontFamily;
5
+ var inheritMonoFont = typeof canvasObject !== 'undefined' && canvasObject.inheritMonoFontFamily;
4
6
  export var fontFamily = inheritFont
5
7
  ? 'inherit'
6
8
  : '"Roboto", "Helvetica Neue", "Helvetica", Arial, sans-serif';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "9.0.0-alpha.348-next.3+62cb7fef",
3
+ "version": "9.0.0-alpha.350-next.4+832dc1ee",
4
4
  "description": "The parent module that contains all Workday Canvas Kit React components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -49,12 +49,11 @@
49
49
  "@emotion/styled": "^11.6.0",
50
50
  "@popperjs/core": "^2.5.4",
51
51
  "@workday/canvas-colors-web": "^2.0.0",
52
- "@workday/canvas-kit-popup-stack": "^9.0.0-alpha.348-next.3+62cb7fef",
52
+ "@workday/canvas-kit-popup-stack": "^9.0.0-alpha.350-next.4+832dc1ee",
53
53
  "@workday/canvas-system-icons-web": "^3.0.0",
54
54
  "@workday/design-assets-types": "^0.2.8",
55
55
  "chroma-js": "^2.1.0",
56
56
  "csstype": "^3.0.2",
57
- "lodash": "^4.17.14",
58
57
  "polished": "^4.1.3",
59
58
  "react-innertext": "^1.1.5",
60
59
  "react-virtual": "^2.10.4",
@@ -67,5 +66,5 @@
67
66
  "@workday/canvas-accent-icons-web": "^3.0.0",
68
67
  "@workday/canvas-applet-icons-web": "^2.0.0"
69
68
  },
70
- "gitHead": "62cb7fefb41fcc2ba937163d06d22deb7bf77203"
69
+ "gitHead": "832dc1ee25b3e7f7bbd551e7566829c823b73aa8"
71
70
  }
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import styled from '@emotion/styled';
3
- import throttle from 'lodash/throttle';
4
3
 
5
4
  import {CanvasSystemIcon} from '@workday/design-assets-types';
6
5
  import {colors, space, CanvasSpaceValues} from '@workday/canvas-kit-react/tokens';
@@ -169,7 +168,7 @@ export class SidePanel extends React.Component<SidePanelProps, SidePanelState> {
169
168
 
170
169
  constructor(props: SidePanelProps) {
171
170
  super(props);
172
- this.handleResize = throttle(this.handleResize.bind(this), 150);
171
+ this.handleResize = this.handleResize.bind(this);
173
172
  }
174
173
 
175
174
  state = {
@@ -1,9 +1,10 @@
1
- import get from 'lodash/get';
1
+ // prettier-ignore
2
+ //@ts-ignore
3
+ const canvasObject = typeof window !== 'undefined' && window.workday && window.workday.canvas && window.workday.canvas;
2
4
 
3
- const inheritFont: boolean =
4
- typeof window !== 'undefined' && get(window, 'window.workday.canvas.inheritFontFamily');
5
+ const inheritFont: boolean = typeof canvasObject !== 'undefined' && canvasObject.inheritFontFamily;
5
6
  const inheritMonoFont: boolean | string =
6
- typeof window !== 'undefined' && get(window, 'window.workday.canvas.inheritMonoFontFamily');
7
+ typeof canvasObject !== 'undefined' && canvasObject.inheritMonoFontFamily;
7
8
 
8
9
  export const fontFamily = inheritFont
9
10
  ? 'inherit'