@workday/canvas-kit-react 8.0.0-alpha.180-next.0 → 8.0.0-alpha.184-next.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 (65) hide show
  1. package/dist/commonjs/card/lib/Card.d.ts +1 -1
  2. package/dist/commonjs/card/lib/CardBody.d.ts +1 -1
  3. package/dist/commonjs/card/lib/CardBody.d.ts.map +1 -1
  4. package/dist/commonjs/dialog/lib/Dialog.d.ts +1 -1
  5. package/dist/commonjs/layout/lib/Box.d.ts +3 -2
  6. package/dist/commonjs/layout/lib/Box.d.ts.map +1 -1
  7. package/dist/commonjs/layout/lib/Box.js +4 -2
  8. package/dist/commonjs/layout/lib/Flex.d.ts +1 -1
  9. package/dist/commonjs/layout/lib/Flex.d.ts.map +1 -1
  10. package/dist/commonjs/layout/lib/Grid.d.ts +2 -2
  11. package/dist/commonjs/layout/lib/Grid.d.ts.map +1 -1
  12. package/dist/commonjs/layout/lib/Grid.js +1 -3
  13. package/dist/commonjs/layout/lib/Stack.d.ts +4 -4
  14. package/dist/commonjs/layout/lib/utils/grid.d.ts +14 -5
  15. package/dist/commonjs/layout/lib/utils/grid.d.ts.map +1 -1
  16. package/dist/commonjs/layout/lib/utils/grid.js +42 -6
  17. package/dist/commonjs/menu/lib/MenuCard.d.ts.map +1 -1
  18. package/dist/commonjs/menu/lib/MenuCard.js +1 -1
  19. package/dist/commonjs/modal/lib/Modal.d.ts +1 -1
  20. package/dist/commonjs/popup/lib/Popup.d.ts +1 -1
  21. package/dist/commonjs/popup/lib/PopupBody.d.ts +1 -1
  22. package/dist/commonjs/popup/lib/PopupBody.js +1 -1
  23. package/dist/commonjs/popup/lib/PopupCard.d.ts +3 -2
  24. package/dist/commonjs/popup/lib/PopupCard.d.ts.map +1 -1
  25. package/dist/commonjs/popup/lib/PopupCard.js +3 -3
  26. package/dist/commonjs/popup/lib/PopupHeading.js +1 -1
  27. package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
  28. package/dist/commonjs/toast/lib/Toast.js +1 -1
  29. package/dist/es6/card/lib/Card.d.ts +1 -1
  30. package/dist/es6/card/lib/CardBody.d.ts +1 -1
  31. package/dist/es6/card/lib/CardBody.d.ts.map +1 -1
  32. package/dist/es6/dialog/lib/Dialog.d.ts +1 -1
  33. package/dist/es6/layout/lib/Box.d.ts +3 -2
  34. package/dist/es6/layout/lib/Box.d.ts.map +1 -1
  35. package/dist/es6/layout/lib/Box.js +4 -2
  36. package/dist/es6/layout/lib/Flex.d.ts +1 -1
  37. package/dist/es6/layout/lib/Flex.d.ts.map +1 -1
  38. package/dist/es6/layout/lib/Grid.d.ts +2 -2
  39. package/dist/es6/layout/lib/Grid.d.ts.map +1 -1
  40. package/dist/es6/layout/lib/Grid.js +1 -3
  41. package/dist/es6/layout/lib/Stack.d.ts +4 -4
  42. package/dist/es6/layout/lib/utils/grid.d.ts +14 -5
  43. package/dist/es6/layout/lib/utils/grid.d.ts.map +1 -1
  44. package/dist/es6/layout/lib/utils/grid.js +42 -6
  45. package/dist/es6/menu/lib/MenuCard.d.ts.map +1 -1
  46. package/dist/es6/menu/lib/MenuCard.js +1 -1
  47. package/dist/es6/modal/lib/Modal.d.ts +1 -1
  48. package/dist/es6/popup/lib/Popup.d.ts +1 -1
  49. package/dist/es6/popup/lib/PopupBody.d.ts +1 -1
  50. package/dist/es6/popup/lib/PopupBody.js +1 -1
  51. package/dist/es6/popup/lib/PopupCard.d.ts +3 -2
  52. package/dist/es6/popup/lib/PopupCard.d.ts.map +1 -1
  53. package/dist/es6/popup/lib/PopupCard.js +4 -4
  54. package/dist/es6/popup/lib/PopupHeading.js +1 -1
  55. package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
  56. package/dist/es6/toast/lib/Toast.js +1 -1
  57. package/layout/lib/Box.tsx +5 -0
  58. package/layout/lib/Grid.tsx +4 -6
  59. package/layout/lib/utils/grid.ts +48 -12
  60. package/menu/lib/MenuCard.tsx +1 -0
  61. package/package.json +3 -3
  62. package/popup/lib/PopupBody.tsx +1 -1
  63. package/popup/lib/PopupCard.tsx +6 -6
  64. package/popup/lib/PopupHeading.tsx +1 -1
  65. package/toast/lib/Toast.tsx +1 -1
@@ -1,4 +1,7 @@
1
1
  import {Property} from 'csstype';
2
+ import {space as spaceTokens, CanvasSpace, CanvasSpaceKeys} from '@workday/canvas-kit-react/tokens';
3
+
4
+ export type GridSpacePropsValues = CanvasSpaceKeys | number | (string & {});
2
5
 
3
6
  /** style props to for grid container properties */
4
7
  export type GridStyleProps = {
@@ -25,12 +28,12 @@ export type GridStyleProps = {
25
28
  gridTemplateColumns?: Property.GridTemplateColumns;
26
29
  /** sets `grid-template-rows` property */
27
30
  gridTemplateRows?: Property.GridTemplateRows;
28
- /** sets `gap` property */
29
- gridGap?: Property.GridGap;
30
31
  /** sets `column-gap` property */
31
- gridColumnGap?: Property.GridColumnGap;
32
+ gridColumnGap?: Property.GridColumnGap | GridSpacePropsValues;
32
33
  /** sets `row-gap` property */
33
- gridRowGap?: Property.GridRowGap;
34
+ gridRowGap?: Property.GridRowGap | GridSpacePropsValues;
35
+ /** sets `gap` property */
36
+ gridGap?: Property.GridGap | GridSpacePropsValues;
34
37
  /** sets `place-items` property */
35
38
  gridPlaceItems?: Property.PlaceItems;
36
39
  /** sets `grid-auto-columns` property */
@@ -45,6 +48,29 @@ export type GridStyleProps = {
45
48
  grid?: Property.Grid;
46
49
  };
47
50
 
51
+ export type gridSpaceProps = {
52
+ /** sets `gap` property */
53
+ gridGap?: Property.GridGap | GridSpacePropsValues;
54
+ };
55
+
56
+ const gridGap = (value: GridSpacePropsValues) => {
57
+ return {gridGap: spaceTokens[value as keyof CanvasSpace] || value};
58
+ };
59
+ const gridRowGap = (value: GridSpacePropsValues) => {
60
+ return {gridRowGap: spaceTokens[value as keyof CanvasSpace] || value};
61
+ };
62
+ const gridColumnGap = (value: GridSpacePropsValues) => {
63
+ return {gridColumnGap: spaceTokens[value as keyof CanvasSpace] || value};
64
+ };
65
+
66
+ const gridSpaceStyleProps = {
67
+ gridGap,
68
+ gridRowGap,
69
+ gridColumnGap,
70
+ };
71
+
72
+ export type SpaceStyleProps = gridSpaceProps & GridStyleProps;
73
+
48
74
  const gridProps = {
49
75
  alignContent: 'alignContent',
50
76
  alignItems: 'alignItems',
@@ -55,9 +81,9 @@ const gridProps = {
55
81
  gridTemplate: 'gridTemplate',
56
82
  gridTemplateColumns: 'gridTemplateColumns',
57
83
  gridTemplateRows: 'gridTemplateRows',
58
- gridGap: 'gridGap',
59
84
  gridColumnGap: 'gridColumnGap',
60
85
  gridRowGap: 'gridRowGap',
86
+ gridGap: 'gridGap',
61
87
  gridPlaceItems: 'gridPlaceItems',
62
88
  gridAutoColumns: 'gridAutoColumns',
63
89
  gridAutoRows: 'gridAutoRows',
@@ -69,6 +95,8 @@ const gridProps = {
69
95
  /**
70
96
  * A style prop function that takes component props and returns grid styles.
71
97
  * If no `GridStyleProps` are found, it returns an empty object.
98
+ * Space tokens are available for `gridGap`, `gridRowGap`, `gridColumnGap` (`zero`, `xxxs`, `xxs`, `xs`, `s`, `m`, `l`, `xl`, `xxl`, `xxxl`).
99
+ * Values: `zero: 0px`, `xxxs: 4px`, `xxs: 8px`, `xs: 12px`, `s: 16px`, `m: 24px`, `l: 32px`, `xl: 40px`, `xxl: 64px`, `xxxl: 80px`.
72
100
  *
73
101
  * @example
74
102
  * // You'll most likely use `grid` with low-level, styled components
@@ -79,14 +107,22 @@ const gridProps = {
79
107
  * );
80
108
  *
81
109
  */
82
- export function grid<P extends GridStyleProps>(props: P) {
83
- const styles = {};
110
+ export function grid<P extends SpaceStyleProps>(props: P) {
111
+ let styles = {};
84
112
  for (const key in props) {
85
- if (key in gridProps) {
86
- const attr = gridProps[key as keyof GridStyleProps];
87
- const value = props[key];
88
- // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
89
- styles[attr] = value;
113
+ if (props.hasOwnProperty(key)) {
114
+ if (key in gridProps) {
115
+ const attr = gridProps[key as keyof GridStyleProps];
116
+ const value = props[key];
117
+ // @ts-ignore TS doesn't like adding a potentially unknown key to an object, but because we own this object, it's fine.
118
+ styles[attr] = value;
119
+ }
120
+ if (key in gridSpaceStyleProps) {
121
+ const value = props[key as keyof gridSpaceProps] as GridSpacePropsValues;
122
+ const spaceFn = gridSpaceStyleProps[key as keyof gridSpaceProps];
123
+ const style = spaceFn(value);
124
+ styles = {...styles, ...style};
125
+ }
90
126
  }
91
127
  }
92
128
  return styles;
@@ -61,6 +61,7 @@ export const MenuCard = createSubcomponent('div')({
61
61
  maxWidth={`calc(100vw - ${space.l})`}
62
62
  transformOrigin={transformOrigin}
63
63
  padding="zero"
64
+ depth={3}
64
65
  {...elemProps}
65
66
  >
66
67
  {elemProps.children}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "8.0.0-alpha.180-next.0+b4047c4e",
3
+ "version": "8.0.0-alpha.184-next.0+9277b9ca",
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,7 +49,7 @@
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": "^8.0.0-alpha.180-next.0+b4047c4e",
52
+ "@workday/canvas-kit-popup-stack": "^8.0.0-alpha.184-next.0+9277b9ca",
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",
@@ -68,5 +68,5 @@
68
68
  "@workday/canvas-accent-icons-web": "^3.0.0",
69
69
  "@workday/canvas-applet-icons-web": "^2.0.0"
70
70
  },
71
- "gitHead": "b4047c4eca7a87327093767ea2af3fde03d686af"
71
+ "gitHead": "9277b9cababf447cdd3dcb7bceefbe92172d0a0a"
72
72
  }
@@ -8,5 +8,5 @@ export const PopupBody = createSubcomponent('div')({
8
8
  displayName: 'Popup.Body',
9
9
  modelHook: usePopupModel,
10
10
  })<ExtractProps<typeof Card.Body>>(elemProps => {
11
- return <Card.Body overflowY="auto" {...elemProps} />;
11
+ return <Card.Body overflowY="auto" padding="xxs" {...elemProps} />;
12
12
  });
@@ -12,12 +12,13 @@ import {
12
12
  useConstant,
13
13
  createSubcomponent,
14
14
  } from '@workday/canvas-kit-react/common';
15
- import {Stack, StackStyleProps} from '@workday/canvas-kit-react/layout';
15
+ import {Flex, FlexStyleProps} from '@workday/canvas-kit-react/layout';
16
16
 
17
17
  import {getTransformFromPlacement} from './getTransformFromPlacement';
18
18
  import {usePopupCard, usePopupModel} from './hooks';
19
19
 
20
- export interface PopupCardProps extends ExtractProps<typeof Card, never>, Partial<StackStyleProps> {
20
+ export type FlexAndBoxProps = ExtractProps<typeof Card, never> & FlexStyleProps;
21
+ export interface PopupCardProps extends FlexAndBoxProps {
21
22
  children?: React.ReactNode;
22
23
  }
23
24
 
@@ -70,20 +71,19 @@ export const PopupCard = createSubcomponent('div')({
70
71
  return getTransformFromPlacement(model.state.placement || 'bottom');
71
72
  }, [model.state.placement]);
72
73
 
73
- // As is a Stack that will render an element of `Element`
74
- const As = useConstant(() => Stack.as(Element));
74
+ // As is a Flex that will render an element of `Element`
75
+ const As = useConstant(() => Flex.as(Element));
75
76
 
76
77
  return (
77
78
  <StyledPopupCard
78
79
  as={As}
79
80
  transformOrigin={transformOrigin}
80
81
  position="relative"
81
- padding="l"
82
82
  depth={5}
83
83
  maxWidth={`calc(100vw - ${space.l})`}
84
- spacing={0}
85
84
  flexDirection="column"
86
85
  minHeight={0}
86
+ padding="m"
87
87
  maxHeight={`calc(100vh - ${
88
88
  elemProps.margin ? space[elemProps.margin as CanvasSpaceKeys] || elemProps.margin : space.xl
89
89
  } * 2)`}
@@ -15,7 +15,7 @@ export const PopupHeading = createSubcomponent('h2')({
15
15
  elemPropsHook: usePopupHeading,
16
16
  })<PopupHeadingProps>(({children, ...elemProps}, Element) => {
17
17
  return (
18
- <Card.Heading as={Element} marginBottom="s" {...elemProps}>
18
+ <Card.Heading as={Element} marginBottom="xxs" padding="xxs" {...elemProps}>
19
19
  {children}
20
20
  </Card.Heading>
21
21
  );
@@ -92,11 +92,11 @@ export const Toast = createComponent('div')({
92
92
  ref={ref}
93
93
  as={Element}
94
94
  width={toastWidth}
95
- padding="s"
96
95
  depth={5}
97
96
  role={isInteractive ? 'dialog' : isError ? 'alert' : 'status'}
98
97
  aria-live={isInteractive ? 'off' : isError ? 'assertive' : 'polite'}
99
98
  aria-atomic={!isInteractive}
99
+ padding="xxs"
100
100
  {...elemProps}
101
101
  >
102
102
  {onClose && <Popup.CloseIcon aria-label="Close" onClick={onClose} size="small" />}