@workday/canvas-kit-react 8.0.0-alpha.216-next.4 → 8.0.0-alpha.224-next.7

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 (76) hide show
  1. package/common/lib/theming/index.ts +1 -1
  2. package/common/lib/theming/styled.ts +6 -3
  3. package/common/lib/utils/index.ts +0 -1
  4. package/dist/commonjs/common/lib/theming/index.d.ts +1 -1
  5. package/dist/commonjs/common/lib/theming/index.d.ts.map +1 -1
  6. package/dist/commonjs/common/lib/theming/styled.d.ts +2 -0
  7. package/dist/commonjs/common/lib/theming/styled.d.ts.map +1 -1
  8. package/dist/commonjs/common/lib/theming/styled.js +1 -2
  9. package/dist/commonjs/common/lib/utils/index.d.ts +0 -1
  10. package/dist/commonjs/common/lib/utils/index.d.ts.map +1 -1
  11. package/dist/commonjs/common/lib/utils/index.js +0 -1
  12. package/dist/commonjs/index.d.ts +1 -0
  13. package/dist/commonjs/index.d.ts.map +1 -1
  14. package/dist/commonjs/index.js +1 -0
  15. package/dist/commonjs/popup/lib/hooks/useReturnFocus.d.ts.map +1 -1
  16. package/dist/commonjs/popup/lib/hooks/useReturnFocus.js +21 -27
  17. package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
  18. package/dist/commonjs/testing/index.d.ts +5 -0
  19. package/dist/commonjs/testing/index.d.ts.map +1 -0
  20. package/dist/commonjs/testing/index.js +16 -0
  21. package/dist/commonjs/testing/lib/ComponentStatesTable.d.ts +26 -0
  22. package/dist/commonjs/testing/lib/ComponentStatesTable.d.ts.map +1 -0
  23. package/dist/commonjs/testing/lib/ComponentStatesTable.js +48 -0
  24. package/dist/commonjs/testing/lib/StaticStates.d.ts +7 -0
  25. package/dist/commonjs/testing/lib/StaticStates.d.ts.map +1 -0
  26. package/dist/commonjs/{common/lib/utils → testing/lib}/StaticStates.js +1 -1
  27. package/dist/commonjs/testing/lib/permutateProps.d.ts +5 -0
  28. package/dist/commonjs/testing/lib/permutateProps.d.ts.map +1 -0
  29. package/dist/commonjs/testing/lib/permutateProps.js +47 -0
  30. package/dist/commonjs/testing/lib/propTypes.d.ts +15 -0
  31. package/dist/commonjs/testing/lib/propTypes.d.ts.map +1 -0
  32. package/dist/commonjs/testing/lib/propTypes.js +2 -0
  33. package/dist/es6/common/lib/theming/index.d.ts +1 -1
  34. package/dist/es6/common/lib/theming/index.d.ts.map +1 -1
  35. package/dist/es6/common/lib/theming/styled.d.ts +2 -0
  36. package/dist/es6/common/lib/theming/styled.d.ts.map +1 -1
  37. package/dist/es6/common/lib/theming/styled.js +1 -2
  38. package/dist/es6/common/lib/utils/index.d.ts +0 -1
  39. package/dist/es6/common/lib/utils/index.d.ts.map +1 -1
  40. package/dist/es6/common/lib/utils/index.js +0 -1
  41. package/dist/es6/index.d.ts +1 -0
  42. package/dist/es6/index.d.ts.map +1 -1
  43. package/dist/es6/index.js +1 -0
  44. package/dist/es6/popup/lib/hooks/useReturnFocus.d.ts.map +1 -1
  45. package/dist/es6/popup/lib/hooks/useReturnFocus.js +21 -27
  46. package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
  47. package/dist/es6/testing/index.d.ts +5 -0
  48. package/dist/es6/testing/index.d.ts.map +1 -0
  49. package/dist/es6/testing/index.js +4 -0
  50. package/dist/es6/testing/lib/ComponentStatesTable.d.ts +26 -0
  51. package/dist/es6/testing/lib/ComponentStatesTable.d.ts.map +1 -0
  52. package/dist/es6/testing/lib/ComponentStatesTable.js +41 -0
  53. package/dist/es6/testing/lib/StaticStates.d.ts +7 -0
  54. package/dist/es6/testing/lib/StaticStates.d.ts.map +1 -0
  55. package/dist/es6/{common/lib/utils → testing/lib}/StaticStates.js +1 -1
  56. package/dist/es6/testing/lib/permutateProps.d.ts +5 -0
  57. package/dist/es6/testing/lib/permutateProps.d.ts.map +1 -0
  58. package/dist/es6/testing/lib/permutateProps.js +43 -0
  59. package/dist/es6/testing/lib/propTypes.d.ts +15 -0
  60. package/dist/es6/testing/lib/propTypes.d.ts.map +1 -0
  61. package/dist/es6/testing/lib/propTypes.js +1 -0
  62. package/index.ts +1 -0
  63. package/package.json +3 -3
  64. package/popup/lib/hooks/useReturnFocus.tsx +25 -30
  65. package/testing/LICENSE +52 -0
  66. package/testing/README.md +6 -0
  67. package/testing/index.ts +4 -0
  68. package/testing/lib/ComponentStatesTable.tsx +80 -0
  69. package/{common/lib/utils → testing/lib}/StaticStates.tsx +5 -4
  70. package/testing/lib/permutateProps.ts +47 -0
  71. package/testing/lib/propTypes.ts +15 -0
  72. package/testing/package.json +6 -0
  73. package/dist/commonjs/common/lib/utils/StaticStates.d.ts +0 -8
  74. package/dist/commonjs/common/lib/utils/StaticStates.d.ts.map +0 -1
  75. package/dist/es6/common/lib/utils/StaticStates.d.ts +0 -8
  76. package/dist/es6/common/lib/utils/StaticStates.d.ts.map +0 -1
@@ -4,10 +4,11 @@ import {
4
4
  CanvasProvider,
5
5
  EmotionCanvasTheme,
6
6
  PartialEmotionCanvasTheme,
7
+ StyleRewriteFn,
7
8
  } from '@workday/canvas-kit-react/common';
8
9
  import {CSSProperties} from '@workday/canvas-kit-react/tokens';
9
10
 
10
- export const convertToStaticStates = (obj?: CSSProperties): CSSProperties | undefined => {
11
+ export const convertToStaticStates: StyleRewriteFn = obj => {
11
12
  if (!obj) {
12
13
  return obj;
13
14
  }
@@ -26,14 +27,14 @@ export const convertToStaticStates = (obj?: CSSProperties): CSSProperties | unde
26
27
  typeof obj[key] === 'object' ? convertToStaticStates(obj[key] as CSSProperties) : obj[key];
27
28
  const newObj = {...result, [newKey]: value};
28
29
  return newObj;
29
- }, {});
30
+ }, {} as CSSProperties);
30
31
  };
31
32
 
32
33
  export const StaticStates: React.FC<React.PropsWithChildren<
33
34
  {theme?: PartialEmotionCanvasTheme} & React.HTMLAttributes<HTMLElement>
34
35
  >> = ({children, theme, ...elemProps}) => {
35
- const localTheme: EmotionCanvasTheme & {_staticStates?: boolean} = useTheme(theme);
36
- localTheme._staticStates = true;
36
+ const localTheme: EmotionCanvasTheme & {_styleRewriteFn?: StyleRewriteFn} = useTheme(theme);
37
+ localTheme._styleRewriteFn = convertToStaticStates;
37
38
 
38
39
  return (
39
40
  <CanvasProvider theme={localTheme} {...elemProps}>
@@ -0,0 +1,47 @@
1
+ import {PropCombination, PropDeclaration, Props, PropsDeclaration} from './propTypes';
2
+
3
+ export const permutateProps = (
4
+ allProps: PropsDeclaration,
5
+ filter?: (props: Props) => boolean,
6
+ remainingProps: string[] = Object.keys(allProps),
7
+ values: {[key: string]: PropDeclaration} = {}
8
+ ): PropCombination[] => {
9
+ // When there are no more props to combine with, return result
10
+ const prop = remainingProps[0];
11
+ if (!prop) {
12
+ const props: Props = {};
13
+ Object.keys(values).forEach(prop => {
14
+ props[prop] = values?.[prop]?.value;
15
+ });
16
+
17
+ if (filter && !filter(props)) {
18
+ return [];
19
+ }
20
+
21
+ const label = Object.keys(values)
22
+ .map(prop => values?.[prop]?.label)
23
+ .join(' ');
24
+
25
+ return [
26
+ {
27
+ label,
28
+ props,
29
+ },
30
+ ];
31
+ }
32
+ const possiblePropValues = allProps[prop];
33
+
34
+ const permutations = possiblePropValues?.map((value: PropDeclaration) => {
35
+ const newValues = {...values}; // Required so we don't overwrite previous references
36
+ newValues[prop] = value;
37
+
38
+ return permutateProps(
39
+ allProps,
40
+ filter,
41
+ remainingProps!.slice(1, remainingProps!.length),
42
+ newValues
43
+ );
44
+ });
45
+
46
+ return (permutations as any).flat();
47
+ };
@@ -0,0 +1,15 @@
1
+ export type PropDeclaration = {
2
+ value: any;
3
+ label: string;
4
+ };
5
+
6
+ export type PropsDeclaration = {[key: string]: PropDeclaration[]};
7
+
8
+ export type Props = {
9
+ [key: string]: any;
10
+ };
11
+
12
+ export type PropCombination = {
13
+ label: string;
14
+ props: Props;
15
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../dist/commonjs/testing",
3
+ "module": "../dist/es6/testing",
4
+ "sideEffects": false,
5
+ "types": "../dist/es6/testing"
6
+ }
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- import { PartialEmotionCanvasTheme } from '@workday/canvas-kit-react/common';
3
- import { CSSProperties } from '@workday/canvas-kit-react/tokens';
4
- export declare const convertToStaticStates: (obj?: CSSProperties | undefined) => CSSProperties | undefined;
5
- export declare const StaticStates: React.FC<React.PropsWithChildren<{
6
- theme?: PartialEmotionCanvasTheme;
7
- } & React.HTMLAttributes<HTMLElement>>>;
8
- //# sourceMappingURL=StaticStates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StaticStates.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/StaticStates.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAIL,yBAAyB,EAC1B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAE/D,eAAO,MAAM,qBAAqB,uCAA0B,aAAa,GAAG,SAoB3E,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CACzD;IAAC,KAAK,CAAC,EAAE,yBAAyB,CAAA;CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CACxE,CASA,CAAC"}
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- import { PartialEmotionCanvasTheme } from '@workday/canvas-kit-react/common';
3
- import { CSSProperties } from '@workday/canvas-kit-react/tokens';
4
- export declare const convertToStaticStates: (obj?: CSSProperties | undefined) => CSSProperties | undefined;
5
- export declare const StaticStates: React.FC<React.PropsWithChildren<{
6
- theme?: PartialEmotionCanvasTheme;
7
- } & React.HTMLAttributes<HTMLElement>>>;
8
- //# sourceMappingURL=StaticStates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StaticStates.d.ts","sourceRoot":"","sources":["../../../../../common/lib/utils/StaticStates.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAIL,yBAAyB,EAC1B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAE/D,eAAO,MAAM,qBAAqB,uCAA0B,aAAa,GAAG,SAoB3E,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CACzD;IAAC,KAAK,CAAC,EAAE,yBAAyB,CAAA;CAAC,GAAG,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CACxE,CASA,CAAC"}