@workday/canvas-kit-react 12.0.0-alpha.841-next.0 → 12.0.0-alpha.852-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 (164) hide show
  1. package/avatar/lib/Avatar.tsx +1 -0
  2. package/common/lib/utils/getTranslateFromOrigin.ts +22 -2
  3. package/dist/commonjs/avatar/lib/Avatar.d.ts.map +1 -1
  4. package/dist/commonjs/avatar/lib/Avatar.js +1 -1
  5. package/dist/commonjs/button/lib/BaseButton.d.ts +5 -5
  6. package/dist/commonjs/button/lib/BaseButton.js +1 -1
  7. package/dist/commonjs/button/lib/DeleteButton.js +1 -1
  8. package/dist/commonjs/button/lib/PrimaryButton.js +2 -2
  9. package/dist/commonjs/button/lib/SecondaryButton.js +2 -2
  10. package/dist/commonjs/button/lib/TertiaryButton.js +4 -4
  11. package/dist/commonjs/checkbox/lib/CheckboxCheck.js +2 -2
  12. package/dist/commonjs/combobox/lib/hooks/useComboboxInput.d.ts +1 -1
  13. package/dist/commonjs/common/lib/CanvasProvider.d.ts +6 -6
  14. package/dist/commonjs/common/lib/utils/getTranslateFromOrigin.d.ts +11 -0
  15. package/dist/commonjs/common/lib/utils/getTranslateFromOrigin.d.ts.map +1 -1
  16. package/dist/commonjs/common/lib/utils/getTranslateFromOrigin.js +19 -3
  17. package/dist/commonjs/icon/lib/SystemIcon.d.ts +2 -1
  18. package/dist/commonjs/icon/lib/SystemIcon.d.ts.map +1 -1
  19. package/dist/commonjs/icon/lib/SystemIcon.js +3 -3
  20. package/dist/commonjs/icon/lib/SystemIconCircle.js +1 -1
  21. package/dist/commonjs/menu/lib/MenuItem.d.ts +1 -1
  22. package/dist/commonjs/modal/lib/ModalBody.d.ts +1 -0
  23. package/dist/commonjs/modal/lib/ModalBody.d.ts.map +1 -1
  24. package/dist/commonjs/modal/lib/ModalBody.js +8 -12
  25. package/dist/commonjs/modal/lib/ModalCard.d.ts +1 -0
  26. package/dist/commonjs/modal/lib/ModalCard.d.ts.map +1 -1
  27. package/dist/commonjs/modal/lib/ModalCard.js +8 -14
  28. package/dist/commonjs/modal/lib/ModalHeading.d.ts +1 -0
  29. package/dist/commonjs/modal/lib/ModalHeading.d.ts.map +1 -1
  30. package/dist/commonjs/modal/lib/ModalHeading.js +8 -12
  31. package/dist/commonjs/modal/lib/ModalOverflowOverlay.d.ts +1 -0
  32. package/dist/commonjs/modal/lib/ModalOverflowOverlay.d.ts.map +1 -1
  33. package/dist/commonjs/modal/lib/ModalOverflowOverlay.js +7 -9
  34. package/dist/commonjs/modal/lib/ModalOverlay.d.ts +9 -4
  35. package/dist/commonjs/modal/lib/ModalOverlay.d.ts.map +1 -1
  36. package/dist/commonjs/modal/lib/ModalOverlay.js +19 -65
  37. package/dist/commonjs/popup/lib/Popper.js +2 -4
  38. package/dist/commonjs/popup/lib/PopupBody.d.ts +1 -0
  39. package/dist/commonjs/popup/lib/PopupBody.d.ts.map +1 -1
  40. package/dist/commonjs/popup/lib/PopupBody.js +8 -2
  41. package/dist/commonjs/popup/lib/PopupCard.d.ts +9 -0
  42. package/dist/commonjs/popup/lib/PopupCard.d.ts.map +1 -1
  43. package/dist/commonjs/popup/lib/PopupCard.js +28 -41
  44. package/dist/commonjs/popup/lib/PopupCloseIcon.d.ts +1 -0
  45. package/dist/commonjs/popup/lib/PopupCloseIcon.d.ts.map +1 -1
  46. package/dist/commonjs/popup/lib/PopupCloseIcon.js +8 -3
  47. package/dist/commonjs/popup/lib/PopupHeading.d.ts +1 -0
  48. package/dist/commonjs/popup/lib/PopupHeading.d.ts.map +1 -1
  49. package/dist/commonjs/popup/lib/PopupHeading.js +8 -2
  50. package/dist/commonjs/select/lib/Select.d.ts.map +1 -1
  51. package/dist/commonjs/select/lib/Select.js +9 -7
  52. package/dist/commonjs/select/lib/hooks/useSelectInput.d.ts +1 -1
  53. package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
  54. package/dist/commonjs/text-input/index.d.ts +0 -1
  55. package/dist/commonjs/text-input/index.d.ts.map +1 -1
  56. package/dist/commonjs/text-input/index.js +0 -1
  57. package/dist/commonjs/toast/lib/Toast.d.ts.map +1 -1
  58. package/dist/commonjs/toast/lib/Toast.js +7 -2
  59. package/dist/commonjs/toast/lib/ToastBody.d.ts +1 -0
  60. package/dist/commonjs/toast/lib/ToastBody.d.ts.map +1 -1
  61. package/dist/commonjs/toast/lib/ToastBody.js +7 -2
  62. package/dist/commonjs/toast/lib/ToastCloseIcon.d.ts +1 -0
  63. package/dist/commonjs/toast/lib/ToastCloseIcon.d.ts.map +1 -1
  64. package/dist/commonjs/toast/lib/ToastCloseIcon.js +7 -2
  65. package/dist/commonjs/toast/lib/ToastIcon.d.ts +1 -0
  66. package/dist/commonjs/toast/lib/ToastIcon.d.ts.map +1 -1
  67. package/dist/commonjs/toast/lib/ToastIcon.js +7 -2
  68. package/dist/commonjs/toast/lib/ToastMessage.d.ts +1 -0
  69. package/dist/commonjs/toast/lib/ToastMessage.d.ts.map +1 -1
  70. package/dist/commonjs/toast/lib/ToastMessage.js +8 -2
  71. package/dist/es6/avatar/lib/Avatar.d.ts.map +1 -1
  72. package/dist/es6/avatar/lib/Avatar.js +1 -1
  73. package/dist/es6/button/lib/BaseButton.d.ts +5 -5
  74. package/dist/es6/button/lib/BaseButton.js +1 -1
  75. package/dist/es6/button/lib/DeleteButton.js +1 -1
  76. package/dist/es6/button/lib/PrimaryButton.js +2 -2
  77. package/dist/es6/button/lib/SecondaryButton.js +2 -2
  78. package/dist/es6/button/lib/TertiaryButton.js +4 -4
  79. package/dist/es6/checkbox/lib/CheckboxCheck.js +2 -2
  80. package/dist/es6/combobox/lib/hooks/useComboboxInput.d.ts +1 -1
  81. package/dist/es6/common/lib/CanvasProvider.d.ts +6 -6
  82. package/dist/es6/common/lib/utils/getTranslateFromOrigin.d.ts +11 -0
  83. package/dist/es6/common/lib/utils/getTranslateFromOrigin.d.ts.map +1 -1
  84. package/dist/es6/common/lib/utils/getTranslateFromOrigin.js +17 -2
  85. package/dist/es6/icon/lib/SystemIcon.d.ts +2 -1
  86. package/dist/es6/icon/lib/SystemIcon.d.ts.map +1 -1
  87. package/dist/es6/icon/lib/SystemIcon.js +3 -3
  88. package/dist/es6/icon/lib/SystemIconCircle.js +1 -1
  89. package/dist/es6/menu/lib/MenuItem.d.ts +1 -1
  90. package/dist/es6/modal/lib/ModalBody.d.ts +1 -0
  91. package/dist/es6/modal/lib/ModalBody.d.ts.map +1 -1
  92. package/dist/es6/modal/lib/ModalBody.js +8 -12
  93. package/dist/es6/modal/lib/ModalCard.d.ts +1 -0
  94. package/dist/es6/modal/lib/ModalCard.d.ts.map +1 -1
  95. package/dist/es6/modal/lib/ModalCard.js +8 -14
  96. package/dist/es6/modal/lib/ModalHeading.d.ts +1 -0
  97. package/dist/es6/modal/lib/ModalHeading.d.ts.map +1 -1
  98. package/dist/es6/modal/lib/ModalHeading.js +8 -12
  99. package/dist/es6/modal/lib/ModalOverflowOverlay.d.ts +1 -0
  100. package/dist/es6/modal/lib/ModalOverflowOverlay.d.ts.map +1 -1
  101. package/dist/es6/modal/lib/ModalOverflowOverlay.js +6 -5
  102. package/dist/es6/modal/lib/ModalOverlay.d.ts +9 -4
  103. package/dist/es6/modal/lib/ModalOverlay.d.ts.map +1 -1
  104. package/dist/es6/modal/lib/ModalOverlay.js +20 -66
  105. package/dist/es6/popup/lib/Popper.js +2 -4
  106. package/dist/es6/popup/lib/PopupBody.d.ts +1 -0
  107. package/dist/es6/popup/lib/PopupBody.d.ts.map +1 -1
  108. package/dist/es6/popup/lib/PopupBody.js +7 -1
  109. package/dist/es6/popup/lib/PopupCard.d.ts +9 -0
  110. package/dist/es6/popup/lib/PopupCard.d.ts.map +1 -1
  111. package/dist/es6/popup/lib/PopupCard.js +30 -43
  112. package/dist/es6/popup/lib/PopupCloseIcon.d.ts +1 -0
  113. package/dist/es6/popup/lib/PopupCloseIcon.d.ts.map +1 -1
  114. package/dist/es6/popup/lib/PopupCloseIcon.js +7 -2
  115. package/dist/es6/popup/lib/PopupHeading.d.ts +1 -0
  116. package/dist/es6/popup/lib/PopupHeading.d.ts.map +1 -1
  117. package/dist/es6/popup/lib/PopupHeading.js +7 -1
  118. package/dist/es6/select/lib/Select.d.ts.map +1 -1
  119. package/dist/es6/select/lib/Select.js +9 -7
  120. package/dist/es6/select/lib/hooks/useSelectInput.d.ts +1 -1
  121. package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
  122. package/dist/es6/text-input/index.d.ts +0 -1
  123. package/dist/es6/text-input/index.d.ts.map +1 -1
  124. package/dist/es6/text-input/index.js +0 -1
  125. package/dist/es6/toast/lib/Toast.d.ts.map +1 -1
  126. package/dist/es6/toast/lib/Toast.js +7 -2
  127. package/dist/es6/toast/lib/ToastBody.d.ts +1 -0
  128. package/dist/es6/toast/lib/ToastBody.d.ts.map +1 -1
  129. package/dist/es6/toast/lib/ToastBody.js +7 -2
  130. package/dist/es6/toast/lib/ToastCloseIcon.d.ts +1 -0
  131. package/dist/es6/toast/lib/ToastCloseIcon.d.ts.map +1 -1
  132. package/dist/es6/toast/lib/ToastCloseIcon.js +6 -1
  133. package/dist/es6/toast/lib/ToastIcon.d.ts +1 -0
  134. package/dist/es6/toast/lib/ToastIcon.d.ts.map +1 -1
  135. package/dist/es6/toast/lib/ToastIcon.js +6 -1
  136. package/dist/es6/toast/lib/ToastMessage.d.ts +1 -0
  137. package/dist/es6/toast/lib/ToastMessage.d.ts.map +1 -1
  138. package/dist/es6/toast/lib/ToastMessage.js +7 -1
  139. package/icon/lib/SystemIcon.tsx +2 -1
  140. package/modal/lib/ModalBody.tsx +11 -16
  141. package/modal/lib/ModalCard.tsx +16 -18
  142. package/modal/lib/ModalHeading.tsx +11 -16
  143. package/modal/lib/ModalOverflowOverlay.tsx +9 -5
  144. package/modal/lib/ModalOverlay.tsx +57 -65
  145. package/package.json +4 -4
  146. package/popup/lib/Popper.tsx +2 -4
  147. package/popup/lib/PopupBody.tsx +11 -1
  148. package/popup/lib/PopupCard.tsx +64 -63
  149. package/popup/lib/PopupCloseIcon.tsx +12 -5
  150. package/popup/lib/PopupHeading.tsx +11 -1
  151. package/select/lib/Select.tsx +8 -6
  152. package/text-input/index.ts +0 -1
  153. package/toast/lib/Toast.tsx +14 -7
  154. package/toast/lib/ToastBody.tsx +16 -12
  155. package/toast/lib/ToastCloseIcon.tsx +14 -1
  156. package/toast/lib/ToastIcon.tsx +10 -11
  157. package/toast/lib/ToastMessage.tsx +12 -3
  158. package/dist/commonjs/text-input/lib/InputIconContainer.d.ts +0 -18
  159. package/dist/commonjs/text-input/lib/InputIconContainer.d.ts.map +0 -1
  160. package/dist/commonjs/text-input/lib/InputIconContainer.js +0 -46
  161. package/dist/es6/text-input/lib/InputIconContainer.d.ts +0 -18
  162. package/dist/es6/text-input/lib/InputIconContainer.d.ts.map +0 -1
  163. package/dist/es6/text-input/lib/InputIconContainer.js +0 -20
  164. package/text-input/lib/InputIconContainer.tsx +0 -39
@@ -3,10 +3,20 @@ import * as React from 'react';
3
3
  import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common';
4
4
  import {Card} from '@workday/canvas-kit-react/card';
5
5
  import {usePopupModel} from './hooks';
6
+ import {createStencil} from '@workday/canvas-kit-styling';
7
+ import {mergeStyles} from '../../layout';
8
+ import {system} from '@workday/canvas-tokens-web';
9
+
10
+ export const popupBodyStencil = createStencil({
11
+ base: {
12
+ overflowY: 'auto',
13
+ padding: system.space.x2,
14
+ },
15
+ });
6
16
 
7
17
  export const PopupBody = createSubcomponent('div')({
8
18
  displayName: 'Popup.Body',
9
19
  modelHook: usePopupModel,
10
20
  })<ExtractProps<typeof Card.Body>>(elemProps => {
11
- return <Card.Body overflowY="auto" padding="xxs" {...elemProps} />;
21
+ return <Card.Body {...mergeStyles(elemProps, popupBodyStencil())} />;
12
22
  });
@@ -1,65 +1,38 @@
1
1
  import * as React from 'react';
2
- import {keyframes} from '@emotion/react';
3
2
 
4
3
  import {Card} from '@workday/canvas-kit-react/card';
5
- import {space, type} from '@workday/canvas-kit-react/tokens';
4
+ import {space} from '@workday/canvas-kit-react/tokens';
6
5
  import {
7
- styled,
8
- TransformOrigin,
9
- getTranslateFromOrigin,
10
- StyledType,
11
6
  ExtractProps,
12
- useConstant,
13
7
  createSubcomponent,
8
+ getTransformOrigin,
14
9
  } from '@workday/canvas-kit-react/common';
15
- import {Flex, FlexStyleProps} from '@workday/canvas-kit-react/layout';
10
+ import {FlexStyleProps, mergeStyles} from '@workday/canvas-kit-react/layout';
16
11
 
17
12
  import {getTransformFromPlacement} from './getTransformFromPlacement';
18
13
  import {usePopupCard, usePopupModel} from './hooks';
14
+ import {createStencil, createVars, cssVar, keyframes} from '@workday/canvas-kit-styling';
15
+ import {system} from '@workday/canvas-tokens-web';
19
16
 
20
17
  export type FlexAndBoxProps = ExtractProps<typeof Card, never> & FlexStyleProps;
21
18
  export interface PopupCardProps extends FlexAndBoxProps {
22
19
  children?: React.ReactNode;
23
20
  }
24
21
 
25
- const popupAnimation = (transformOrigin: TransformOrigin) => {
26
- const translate = getTranslateFromOrigin(transformOrigin, space.xxs);
22
+ const translateVars = createVars('positionX', 'positionY');
27
23
 
28
- return keyframes`
29
- 0% {
30
- opacity: 0;
31
- transform: translate(${translate.x}px, ${translate.y}px);
32
- }
33
- 100% {
34
- opacity: 1;
35
- transform: translate(0);
36
- }
37
- `;
38
- };
39
-
40
- const StyledPopupCard = styled(Card)<
41
- StyledType & {width?: number | string; transformOrigin?: TransformOrigin}
42
- >(({transformOrigin, theme}) => {
43
- if (transformOrigin == null) {
44
- return {};
45
- }
46
-
47
- return {
48
- animation: popupAnimation(transformOrigin),
49
- animationDuration: '150ms',
50
- animationTimingFunction: 'ease-out',
51
- transformOrigin: `${transformOrigin.vertical} ${transformOrigin.horizontal}`,
52
- [theme.canvas.breakpoints.down('s')]: {
53
- animation: popupAnimation({vertical: 'bottom', horizontal: 'center'}),
54
- animationDuration: '150ms',
55
- animationTimingFunction: 'ease-out',
56
- transformOrigin: 'bottom center',
57
- },
58
- // Allow overriding of animation in special cases
59
- '.wd-no-animation &': {
60
- animation: 'none',
61
- },
62
- };
24
+ /**
25
+ * Keyframe for the dots loading animation.
26
+ */
27
+ const fadeIn = keyframes({
28
+ '0%': {
29
+ opacity: 1,
30
+ transform: `translate(${cssVar(translateVars.positionX)}, ${cssVar(translateVars.positionY)})`,
31
+ },
32
+ '100%': {
33
+ opacity: 1,
34
+ transform: `translate(0)`,
35
+ },
63
36
  });
64
37
 
65
38
  function getSpace(value?: string | number) {
@@ -72,7 +45,7 @@ function getSpace(value?: string | number) {
72
45
 
73
46
  function getMaxHeight(margin?: string | number) {
74
47
  // set the default margin offset to space.xl
75
- let marginOffset: string | number = space.xl;
48
+ let marginOffset: string | number = cssVar(system.space.x10);
76
49
 
77
50
  if (margin) {
78
51
  // parse the margin prop
@@ -91,33 +64,61 @@ function getMaxHeight(margin?: string | number) {
91
64
  return `calc(100vh - ${marginOffset})`;
92
65
  }
93
66
 
67
+ export const popupCardStencil = createStencil({
68
+ vars: {
69
+ maxHeight: '',
70
+ transformOriginHorizontal: '',
71
+ transformOriginVertical: '',
72
+ },
73
+ base: ({maxHeight, transformOriginHorizontal, transformOriginVertical}) => ({
74
+ ...system.type.subtext.large,
75
+ display: 'flex',
76
+ position: 'relative',
77
+ maxWidth: `calc(100vw - ${system.space.x8})`,
78
+ flexDirection: 'column',
79
+ boxShadow: system.depth[5],
80
+ minHeight: system.space.zero,
81
+ padding: system.space.x6,
82
+ maxHeight: maxHeight,
83
+ overflowY: 'auto',
84
+ animationName: fadeIn,
85
+ animationDuration: '150ms',
86
+ animationTimingFunction: 'ease-out',
87
+ transformOrigin: `${transformOriginVertical} ${transformOriginHorizontal}`,
88
+ // Allow overriding of animation in special cases
89
+ '.wd-no-animation &': {
90
+ animation: 'none',
91
+ },
92
+ '@media screen and (max-width: 768px)': {
93
+ transformOrigin: 'bottom center',
94
+ },
95
+ }),
96
+ });
97
+
94
98
  export const PopupCard = createSubcomponent('div')({
95
99
  displayName: 'Popup.Card',
96
100
  modelHook: usePopupModel,
97
101
  elemPropsHook: usePopupCard,
98
- })<PopupCardProps>(({children, ...elemProps}, Element, model) => {
102
+ })<PopupCardProps>(({children, ref, ...elemProps}, Element, model) => {
99
103
  const transformOrigin = React.useMemo(() => {
100
104
  return getTransformFromPlacement(model.state.placement || 'bottom');
101
105
  }, [model.state.placement]);
106
+ const translate = getTransformOrigin(transformOrigin, cssVar(system.space.x2));
107
+ const cardMaxHeight = getMaxHeight(elemProps.margin);
102
108
 
103
- // As is a Flex that will render an element of `Element`
104
- const As = useConstant(() => Flex.as(Element));
105
109
  return (
106
- <StyledPopupCard
107
- as={As}
108
- transformOrigin={transformOrigin}
109
- position="relative"
110
- depth={5}
111
- maxWidth={`calc(100vw - ${space.l})`}
112
- flexDirection="column"
113
- minHeight={0}
114
- padding="m"
115
- maxHeight={getMaxHeight(elemProps.margin)}
116
- overflowY="auto"
117
- {...type.levels.subtext.large}
118
- {...elemProps}
110
+ <Card
111
+ ref={ref}
112
+ {...mergeStyles(elemProps, [
113
+ popupCardStencil({
114
+ transformOriginHorizontal: transformOrigin.horizontal,
115
+ transformOriginVertical: transformOrigin.vertical,
116
+ maxHeight: cardMaxHeight,
117
+ }),
118
+ translateVars({positionX: translate.x, positionY: translate.y}),
119
+ ])}
119
120
  >
120
121
  {children}
121
- </StyledPopupCard>
122
+ </Card>
122
123
  );
123
124
  });
@@ -3,12 +3,22 @@ import React from 'react';
3
3
  import {xIcon} from '@workday/canvas-system-icons-web';
4
4
  import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common';
5
5
  import {TertiaryButton} from '@workday/canvas-kit-react/button';
6
- import {space} from '@workday/canvas-kit-react/tokens';
7
6
 
8
7
  import {usePopupCloseButton, usePopupModel} from './hooks';
8
+ import {createStencil} from '@workday/canvas-kit-styling';
9
+ import {system} from '@workday/canvas-tokens-web';
10
+ import {mergeStyles} from '../../layout';
9
11
 
10
12
  export interface PopupCloseIconProps extends ExtractProps<typeof TertiaryButton, never> {}
11
13
 
14
+ export const popupCloseIconStencil = createStencil({
15
+ base: {
16
+ position: 'absolute',
17
+ insetInlineEnd: system.space.x1,
18
+ top: system.space.x1,
19
+ },
20
+ });
21
+
12
22
  export const PopupCloseIcon = createSubcomponent('button')({
13
23
  displayName: 'Popup.CloseIcon',
14
24
  modelHook: usePopupModel,
@@ -20,10 +30,7 @@ export const PopupCloseIcon = createSubcomponent('button')({
20
30
  size="medium"
21
31
  icon={xIcon}
22
32
  type="button"
23
- position="absolute"
24
- insetInlineEnd={space.xxxs}
25
- top={space.xxxs}
26
- {...elemProps}
33
+ {...mergeStyles(elemProps, popupCloseIconStencil())}
27
34
  />
28
35
  );
29
36
  });
@@ -4,18 +4,28 @@ import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common
4
4
  import {Card} from '@workday/canvas-kit-react/card';
5
5
 
6
6
  import {usePopupHeading, usePopupModel} from './hooks';
7
+ import {createStencil} from '@workday/canvas-kit-styling';
8
+ import {system} from '@workday/canvas-tokens-web';
9
+ import {mergeStyles} from '../../layout';
7
10
 
8
11
  export interface PopupHeadingProps extends ExtractProps<typeof Card.Heading, never> {
9
12
  children?: React.ReactNode;
10
13
  }
11
14
 
15
+ export const popupHeadingStencil = createStencil({
16
+ base: {
17
+ marginBlockEnd: system.space.x2,
18
+ padding: system.space.x2,
19
+ },
20
+ });
21
+
12
22
  export const PopupHeading = createSubcomponent('h2')({
13
23
  displayName: 'Popup.Heading',
14
24
  modelHook: usePopupModel,
15
25
  elemPropsHook: usePopupHeading,
16
26
  })<PopupHeadingProps>(({children, ...elemProps}, Element) => {
17
27
  return (
18
- <Card.Heading as={Element} marginBottom="xxs" padding="xxs" {...elemProps}>
28
+ <Card.Heading as={Element} {...mergeStyles(elemProps, popupHeadingStencil())}>
19
29
  {children}
20
30
  </Card.Heading>
21
31
  );
@@ -86,12 +86,14 @@ export const SelectInput = createSubcomponent(TextInput)({
86
86
  React.useImperativeHandle(
87
87
  elementRef,
88
88
  () => {
89
- localRef.current!.focus = (options?: FocusOptions) => {
90
- textInputProps.ref.current!.focus(options);
91
- };
92
- localRef.current!.blur = () => {
93
- textInputProps.ref.current!.blur();
94
- };
89
+ if (localRef.current) {
90
+ localRef.current.focus = (options?: FocusOptions) => {
91
+ textInputProps.ref.current!.focus(options);
92
+ };
93
+ localRef.current.blur = () => {
94
+ textInputProps.ref.current!.blur();
95
+ };
96
+ }
95
97
 
96
98
  return localRef.current!;
97
99
  },
@@ -1,3 +1,2 @@
1
- export * from './lib/InputIconContainer';
2
1
  export * from './lib/TextInput';
3
2
  export {InputGroup, useInputGroupModel} from './lib/InputGroup';
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
3
  import {createContainer, ExtractProps} from '@workday/canvas-kit-react/common';
4
- import {Flex} from '@workday/canvas-kit-react/layout';
5
4
  import {Popup} from '@workday/canvas-kit-react/popup';
6
5
 
7
6
  import {ToastCloseIcon} from './ToastCloseIcon';
@@ -10,6 +9,9 @@ import {ToastMessage} from './ToastMessage';
10
9
  import {ToastLink} from './ToastLink';
11
10
  import {ToastBody} from './ToastBody';
12
11
  import {useToastModel} from './hooks/useToastModel';
12
+ import {calc, createStencil} from '@workday/canvas-kit-styling';
13
+ import {system} from '@workday/canvas-tokens-web';
14
+ import {mergeStyles} from '@workday/canvas-kit-react/layout';
13
15
 
14
16
  export interface ToastProps extends Omit<ExtractProps<typeof Popup.Card, never>, 'model'> {}
15
17
 
@@ -45,6 +47,16 @@ const getAriaAttributes = (mode: string, id: string): React.HtmlHTMLAttributes<H
45
47
  }
46
48
  };
47
49
 
50
+ const toastStencil = createStencil({
51
+ base: {
52
+ display: 'flex',
53
+ flexDirection: 'row',
54
+ width: calc.add(calc.multiply(system.space.x20, 4), system.space.x10),
55
+ padding: system.space.zero,
56
+ gap: system.space.x1,
57
+ },
58
+ });
59
+
48
60
  /**
49
61
  * Toast is a compound component that has different modes based on its contents. The modes add the proper aria attributes for accessibility
50
62
  *
@@ -99,13 +111,8 @@ export const Toast = createContainer('div')({
99
111
  })<ToastProps>(({children, ...elemProps}, _, model) => {
100
112
  return (
101
113
  <Popup.Card
102
- as={Flex}
103
- width={360}
104
- padding="0"
105
114
  {...getAriaAttributes(model.state.mode, model.state.id)}
106
- flexDirection="row"
107
- gap="xxxs"
108
- {...elemProps}
115
+ {...mergeStyles(elemProps, toastStencil())}
109
116
  >
110
117
  {children}
111
118
  </Popup.Card>
@@ -2,25 +2,29 @@ import React from 'react';
2
2
 
3
3
  import {createComponent, ExtractProps} from '@workday/canvas-kit-react/common';
4
4
  import {Popup} from '@workday/canvas-kit-react/popup';
5
- import {Flex} from '@workday/canvas-kit-react/layout';
5
+ import {Flex, mergeStyles} from '@workday/canvas-kit-react/layout';
6
+ import {createStencil} from '@workday/canvas-kit-styling';
7
+ import {system} from '@workday/canvas-tokens-web';
6
8
 
7
9
  export interface ToastBodyProps extends ExtractProps<typeof Popup.Body> {}
8
10
 
11
+ export const toastBodyStencil = createStencil({
12
+ base: {
13
+ alignItems: 'flex-start',
14
+ flexDirection: 'column',
15
+ justifyContent: 'center',
16
+ paddingTop: system.space.x4,
17
+ paddingBottom: system.space.x4,
18
+ flexGrow: 1,
19
+ gap: system.space.x1,
20
+ },
21
+ });
22
+
9
23
  export const ToastBody = createComponent('div')({
10
24
  displayName: 'Toast.Body',
11
25
  Component: ({children, ...elemProps}: ToastBodyProps, ref, Element) => {
12
26
  return (
13
- <Flex
14
- alignItems="flex-start"
15
- flexDirection="column"
16
- justifyContent="center"
17
- paddingY="s"
18
- ref={ref}
19
- as={Element}
20
- flexGrow={1}
21
- gap="xxxs"
22
- {...elemProps}
23
- >
27
+ <Flex ref={ref} as={Element} {...mergeStyles(elemProps, toastBodyStencil())}>
24
28
  {children}
25
29
  </Flex>
26
30
  );
@@ -1,14 +1,27 @@
1
1
  import React from 'react';
2
2
  import {createComponent, ExtractProps} from '@workday/canvas-kit-react/common';
3
3
  import {Popup} from '@workday/canvas-kit-react/popup';
4
+ import {createStencil} from '@workday/canvas-kit-styling';
5
+ import {mergeStyles} from '@workday/canvas-kit-react/layout';
4
6
 
5
7
  export interface ToastCloseIconProps extends ExtractProps<typeof Popup.CloseIcon, never> {}
6
8
 
9
+ export const toastCloseIconStencil = createStencil({
10
+ base: {
11
+ position: 'relative',
12
+ },
13
+ });
14
+
7
15
  export const ToastCloseIcon = createComponent('button')({
8
16
  displayName: 'Toast.CloseIcon',
9
17
  Component: (elemProps: ToastCloseIconProps, ref, Element) => {
10
18
  return (
11
- <Popup.CloseIcon as={Element} ref={ref} size="small" position="relative" {...elemProps} />
19
+ <Popup.CloseIcon
20
+ as={Element}
21
+ ref={ref}
22
+ size="small"
23
+ {...mergeStyles(elemProps, toastCloseIconStencil())}
24
+ />
12
25
  );
13
26
  },
14
27
  });
@@ -2,22 +2,21 @@ import React from 'react';
2
2
 
3
3
  import {createComponent} from '@workday/canvas-kit-react/common';
4
4
  import {SystemIcon, SystemIconProps} from '@workday/canvas-kit-react/icon';
5
+ import {createStencil, handleCsProp} from '@workday/canvas-kit-styling';
6
+ import {system} from '@workday/canvas-tokens-web';
5
7
 
6
8
  export interface ToastIconProps extends Omit<SystemIconProps, 'colorHover'> {}
7
9
 
10
+ export const toastIconStencil = createStencil({
11
+ base: {
12
+ alignSelf: 'start',
13
+ margin: `${system.space.x4} ${system.space.x3}`,
14
+ },
15
+ });
16
+
8
17
  export const ToastIcon = createComponent('div')({
9
18
  displayName: 'Toast.Icon',
10
19
  Component: (elemProps: ToastIconProps, ref, Element) => {
11
- return (
12
- <SystemIcon
13
- colorHover={elemProps.color}
14
- marginY="s"
15
- marginX="xs"
16
- alignSelf="start"
17
- ref={ref}
18
- as={Element}
19
- {...elemProps}
20
- />
21
- );
20
+ return <SystemIcon ref={ref} as={Element} {...handleCsProp(elemProps, toastIconStencil())} />;
22
21
  },
23
22
  });
@@ -3,20 +3,29 @@ import React from 'react';
3
3
  import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common';
4
4
  import {useToastModel} from './hooks/useToastModel';
5
5
  import {Subtext} from '@workday/canvas-kit-react/text';
6
+ import {createStencil} from '@workday/canvas-kit-styling';
7
+ import {mergeStyles} from '@workday/canvas-kit-react/layout';
8
+ import {system} from '@workday/canvas-tokens-web';
6
9
 
7
10
  export interface ToastMessageProps extends Omit<ExtractProps<typeof Subtext>, 'size'> {}
8
11
 
12
+ export const toastMessageStencil = createStencil({
13
+ base: {
14
+ wordBreak: 'break-word',
15
+ marginBlockStart: system.space.zero,
16
+ marginBlockEnd: system.space.zero,
17
+ },
18
+ });
19
+
9
20
  export const ToastMessage = createSubcomponent('p')({
10
21
  modelHook: useToastModel,
11
22
  })<ToastMessageProps>(({children, ...elemProps}, Element, model) => {
12
23
  return (
13
24
  <Subtext
14
25
  size="large"
15
- wordBreak="break-word"
16
- marginY="zero"
17
26
  id={model.state.id}
18
27
  as={Element}
19
- {...elemProps}
28
+ {...mergeStyles(elemProps, toastMessageStencil())}
20
29
  >
21
30
  {children}
22
31
  </Subtext>
@@ -1,18 +0,0 @@
1
- import * as React from 'react';
2
- import { GrowthBehavior } from '@workday/canvas-kit-react/common';
3
- import { SystemIcon } from '@workday/canvas-kit-react/icon';
4
- /**
5
- * ### ⚠️ We've deprecated `InputIconContainerProps` from Main because it doesn't handle bidirectionality or icons at the start of an input. ⚠️
6
- * Please consider using [`InputGroup`](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-text-input--icons) instead.
7
- * @deprecated
8
- */
9
- export interface InputIconContainerProps extends GrowthBehavior {
10
- icon?: React.ReactElement<typeof SystemIcon>;
11
- }
12
- /**
13
- * ### ⚠️ We've deprecated `InputIconContainer` from Main because it doesn't handle bidirectionality or icons at the start of an input. ⚠️
14
- * Please consider using [`InputGroup`](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-text-input--icons) instead.
15
- * @deprecated
16
- */
17
- export declare const InputIconContainer: React.FunctionComponent<React.PropsWithChildren<InputIconContainerProps>>;
18
- //# sourceMappingURL=InputIconContainer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InputIconContainer.d.ts","sourceRoot":"","sources":["../../../../text-input/lib/InputIconContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAC,UAAU,EAAC,MAAM,gCAAgC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,cAAc;IAC7D,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;CAC9C;AAaD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,iBAAiB,CACtD,KAAK,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,CAMjD,CAAC"}
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.InputIconContainer = void 0;
26
- const React = __importStar(require("react"));
27
- const styled_1 = __importDefault(require("@emotion/styled"));
28
- const tokens_1 = require("@workday/canvas-kit-react/tokens");
29
- const Container = styled_1.default('div')(({ grow }) => ({
30
- display: grow ? 'block' : 'inline-block',
31
- position: 'relative',
32
- }));
33
- const IconContainer = styled_1.default('div')({
34
- position: 'absolute',
35
- top: tokens_1.space.xxs,
36
- right: tokens_1.space.xxs,
37
- });
38
- /**
39
- * ### ⚠️ We've deprecated `InputIconContainer` from Main because it doesn't handle bidirectionality or icons at the start of an input. ⚠️
40
- * Please consider using [`InputGroup`](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-text-input--icons) instead.
41
- * @deprecated
42
- */
43
- const InputIconContainer = ({ grow, children, icon }) => (React.createElement(Container, { grow: grow },
44
- children,
45
- icon && React.createElement(IconContainer, null, icon)));
46
- exports.InputIconContainer = InputIconContainer;
@@ -1,18 +0,0 @@
1
- import * as React from 'react';
2
- import { GrowthBehavior } from '@workday/canvas-kit-react/common';
3
- import { SystemIcon } from '@workday/canvas-kit-react/icon';
4
- /**
5
- * ### ⚠️ We've deprecated `InputIconContainerProps` from Main because it doesn't handle bidirectionality or icons at the start of an input. ⚠️
6
- * Please consider using [`InputGroup`](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-text-input--icons) instead.
7
- * @deprecated
8
- */
9
- export interface InputIconContainerProps extends GrowthBehavior {
10
- icon?: React.ReactElement<typeof SystemIcon>;
11
- }
12
- /**
13
- * ### ⚠️ We've deprecated `InputIconContainer` from Main because it doesn't handle bidirectionality or icons at the start of an input. ⚠️
14
- * Please consider using [`InputGroup`](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-text-input--icons) instead.
15
- * @deprecated
16
- */
17
- export declare const InputIconContainer: React.FunctionComponent<React.PropsWithChildren<InputIconContainerProps>>;
18
- //# sourceMappingURL=InputIconContainer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InputIconContainer.d.ts","sourceRoot":"","sources":["../../../../text-input/lib/InputIconContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAC,UAAU,EAAC,MAAM,gCAAgC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,cAAc;IAC7D,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;CAC9C;AAaD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,iBAAiB,CACtD,KAAK,CAAC,iBAAiB,CAAC,uBAAuB,CAAC,CAMjD,CAAC"}
@@ -1,20 +0,0 @@
1
- import * as React from 'react';
2
- import styled from '@emotion/styled';
3
- import { space } from '@workday/canvas-kit-react/tokens';
4
- const Container = styled('div')(({ grow }) => ({
5
- display: grow ? 'block' : 'inline-block',
6
- position: 'relative',
7
- }));
8
- const IconContainer = styled('div')({
9
- position: 'absolute',
10
- top: space.xxs,
11
- right: space.xxs,
12
- });
13
- /**
14
- * ### ⚠️ We've deprecated `InputIconContainer` from Main because it doesn't handle bidirectionality or icons at the start of an input. ⚠️
15
- * Please consider using [`InputGroup`](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-text-input--icons) instead.
16
- * @deprecated
17
- */
18
- export const InputIconContainer = ({ grow, children, icon }) => (React.createElement(Container, { grow: grow },
19
- children,
20
- icon && React.createElement(IconContainer, null, icon)));
@@ -1,39 +0,0 @@
1
- import * as React from 'react';
2
- import styled from '@emotion/styled';
3
- import {GrowthBehavior} from '@workday/canvas-kit-react/common';
4
- import {space} from '@workday/canvas-kit-react/tokens';
5
- import {SystemIcon} from '@workday/canvas-kit-react/icon';
6
-
7
- /**
8
- * ### ⚠️ We've deprecated `InputIconContainerProps` from Main because it doesn't handle bidirectionality or icons at the start of an input. ⚠️
9
- * Please consider using [`InputGroup`](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-text-input--icons) instead.
10
- * @deprecated
11
- */
12
- export interface InputIconContainerProps extends GrowthBehavior {
13
- icon?: React.ReactElement<typeof SystemIcon>;
14
- }
15
-
16
- const Container = styled('div')<InputIconContainerProps>(({grow}) => ({
17
- display: grow ? 'block' : 'inline-block',
18
- position: 'relative',
19
- }));
20
-
21
- const IconContainer = styled('div')({
22
- position: 'absolute',
23
- top: space.xxs,
24
- right: space.xxs,
25
- });
26
-
27
- /**
28
- * ### ⚠️ We've deprecated `InputIconContainer` from Main because it doesn't handle bidirectionality or icons at the start of an input. ⚠️
29
- * Please consider using [`InputGroup`](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-text-input--icons) instead.
30
- * @deprecated
31
- */
32
- export const InputIconContainer: React.FunctionComponent<
33
- React.PropsWithChildren<InputIconContainerProps>
34
- > = ({grow, children, icon}) => (
35
- <Container grow={grow}>
36
- {children}
37
- {icon && <IconContainer>{icon}</IconContainer>}
38
- </Container>
39
- );