@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.
- package/common/lib/theming/index.ts +1 -1
- package/common/lib/theming/styled.ts +6 -3
- package/common/lib/utils/index.ts +0 -1
- package/dist/commonjs/common/lib/theming/index.d.ts +1 -1
- package/dist/commonjs/common/lib/theming/index.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/styled.d.ts +2 -0
- package/dist/commonjs/common/lib/theming/styled.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/styled.js +1 -2
- package/dist/commonjs/common/lib/utils/index.d.ts +0 -1
- package/dist/commonjs/common/lib/utils/index.d.ts.map +1 -1
- package/dist/commonjs/common/lib/utils/index.js +0 -1
- package/dist/commonjs/index.d.ts +1 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/popup/lib/hooks/useReturnFocus.d.ts.map +1 -1
- package/dist/commonjs/popup/lib/hooks/useReturnFocus.js +21 -27
- package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
- package/dist/commonjs/testing/index.d.ts +5 -0
- package/dist/commonjs/testing/index.d.ts.map +1 -0
- package/dist/commonjs/testing/index.js +16 -0
- package/dist/commonjs/testing/lib/ComponentStatesTable.d.ts +26 -0
- package/dist/commonjs/testing/lib/ComponentStatesTable.d.ts.map +1 -0
- package/dist/commonjs/testing/lib/ComponentStatesTable.js +48 -0
- package/dist/commonjs/testing/lib/StaticStates.d.ts +7 -0
- package/dist/commonjs/testing/lib/StaticStates.d.ts.map +1 -0
- package/dist/commonjs/{common/lib/utils → testing/lib}/StaticStates.js +1 -1
- package/dist/commonjs/testing/lib/permutateProps.d.ts +5 -0
- package/dist/commonjs/testing/lib/permutateProps.d.ts.map +1 -0
- package/dist/commonjs/testing/lib/permutateProps.js +47 -0
- package/dist/commonjs/testing/lib/propTypes.d.ts +15 -0
- package/dist/commonjs/testing/lib/propTypes.d.ts.map +1 -0
- package/dist/commonjs/testing/lib/propTypes.js +2 -0
- package/dist/es6/common/lib/theming/index.d.ts +1 -1
- package/dist/es6/common/lib/theming/index.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/styled.d.ts +2 -0
- package/dist/es6/common/lib/theming/styled.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/styled.js +1 -2
- package/dist/es6/common/lib/utils/index.d.ts +0 -1
- package/dist/es6/common/lib/utils/index.d.ts.map +1 -1
- package/dist/es6/common/lib/utils/index.js +0 -1
- package/dist/es6/index.d.ts +1 -0
- package/dist/es6/index.d.ts.map +1 -1
- package/dist/es6/index.js +1 -0
- package/dist/es6/popup/lib/hooks/useReturnFocus.d.ts.map +1 -1
- package/dist/es6/popup/lib/hooks/useReturnFocus.js +21 -27
- package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
- package/dist/es6/testing/index.d.ts +5 -0
- package/dist/es6/testing/index.d.ts.map +1 -0
- package/dist/es6/testing/index.js +4 -0
- package/dist/es6/testing/lib/ComponentStatesTable.d.ts +26 -0
- package/dist/es6/testing/lib/ComponentStatesTable.d.ts.map +1 -0
- package/dist/es6/testing/lib/ComponentStatesTable.js +41 -0
- package/dist/es6/testing/lib/StaticStates.d.ts +7 -0
- package/dist/es6/testing/lib/StaticStates.d.ts.map +1 -0
- package/dist/es6/{common/lib/utils → testing/lib}/StaticStates.js +1 -1
- package/dist/es6/testing/lib/permutateProps.d.ts +5 -0
- package/dist/es6/testing/lib/permutateProps.d.ts.map +1 -0
- package/dist/es6/testing/lib/permutateProps.js +43 -0
- package/dist/es6/testing/lib/propTypes.d.ts +15 -0
- package/dist/es6/testing/lib/propTypes.d.ts.map +1 -0
- package/dist/es6/testing/lib/propTypes.js +1 -0
- package/index.ts +1 -0
- package/package.json +3 -3
- package/popup/lib/hooks/useReturnFocus.tsx +25 -30
- package/testing/LICENSE +52 -0
- package/testing/README.md +6 -0
- package/testing/index.ts +4 -0
- package/testing/lib/ComponentStatesTable.tsx +80 -0
- package/{common/lib/utils → testing/lib}/StaticStates.tsx +5 -4
- package/testing/lib/permutateProps.ts +47 -0
- package/testing/lib/propTypes.ts +15 -0
- package/testing/package.json +6 -0
- package/dist/commonjs/common/lib/utils/StaticStates.d.ts +0 -8
- package/dist/commonjs/common/lib/utils/StaticStates.d.ts.map +0 -1
- package/dist/es6/common/lib/utils/StaticStates.d.ts +0 -8
- 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 =
|
|
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 & {
|
|
36
|
-
localTheme.
|
|
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
|
+
};
|
|
@@ -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"}
|