@workday/canvas-kit-react 11.0.0-alpha.726-next.0 → 11.0.0-alpha.758-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 (181) hide show
  1. package/breadcrumbs/lib/BreadcrumbsItem.tsx +1 -1
  2. package/breadcrumbs/lib/BreadcrumbsOverflowButton.tsx +1 -1
  3. package/button/lib/BaseButton.tsx +16 -1
  4. package/button/lib/DeleteButton.tsx +12 -11
  5. package/button/lib/ExternalHyperlink.tsx +1 -1
  6. package/button/lib/PrimaryButton.tsx +52 -45
  7. package/button/lib/SecondaryButton.tsx +58 -75
  8. package/button/lib/TertiaryButton.tsx +63 -54
  9. package/collection/lib/ListBox.tsx +9 -3
  10. package/combobox/lib/ComboboxMenuList.tsx +3 -4
  11. package/dist/commonjs/badge/lib/CountBadge.js +6 -6
  12. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsItem.js +1 -1
  13. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsOverflowButton.js +1 -1
  14. package/dist/commonjs/button/lib/BaseButton.d.ts.map +1 -1
  15. package/dist/commonjs/button/lib/BaseButton.js +18 -17
  16. package/dist/commonjs/button/lib/DeleteButton.d.ts.map +1 -1
  17. package/dist/commonjs/button/lib/DeleteButton.js +2 -1
  18. package/dist/commonjs/button/lib/ExternalHyperlink.js +1 -1
  19. package/dist/commonjs/button/lib/PrimaryButton.d.ts.map +1 -1
  20. package/dist/commonjs/button/lib/PrimaryButton.js +3 -2
  21. package/dist/commonjs/button/lib/SecondaryButton.d.ts.map +1 -1
  22. package/dist/commonjs/button/lib/SecondaryButton.js +3 -2
  23. package/dist/commonjs/button/lib/TertiaryButton.d.ts.map +1 -1
  24. package/dist/commonjs/button/lib/TertiaryButton.js +16 -15
  25. package/dist/commonjs/card/lib/Card.js +1 -1
  26. package/dist/commonjs/card/lib/CardHeading.js +1 -1
  27. package/dist/commonjs/checkbox/lib/CheckBackground.js +5 -5
  28. package/dist/commonjs/checkbox/lib/CheckboxCheck.js +9 -9
  29. package/dist/commonjs/checkbox/lib/CheckboxContainer.js +1 -1
  30. package/dist/commonjs/checkbox/lib/CheckboxInput.js +11 -11
  31. package/dist/commonjs/checkbox/lib/CheckboxRipple.js +1 -1
  32. package/dist/commonjs/collection/lib/ListBox.d.ts.map +1 -1
  33. package/dist/commonjs/collection/lib/ListBox.js +14 -8
  34. package/dist/commonjs/combobox/lib/ComboboxMenuItem.js +4 -4
  35. package/dist/commonjs/combobox/lib/ComboboxMenuList.d.ts.map +1 -1
  36. package/dist/commonjs/combobox/lib/ComboboxMenuList.js +4 -5
  37. package/dist/commonjs/common/lib/AccessibleHide.js +1 -1
  38. package/dist/commonjs/common/lib/CanvasProvider.js +1 -1
  39. package/dist/commonjs/icon/index.d.ts +1 -1
  40. package/dist/commonjs/icon/index.d.ts.map +1 -1
  41. package/dist/commonjs/icon/index.js +4 -1
  42. package/dist/commonjs/icon/lib/AccentIcon.d.ts +30 -4
  43. package/dist/commonjs/icon/lib/AccentIcon.d.ts.map +1 -1
  44. package/dist/commonjs/icon/lib/AccentIcon.js +28 -4
  45. package/dist/commonjs/icon/lib/AppletIcon.d.ts +31 -2
  46. package/dist/commonjs/icon/lib/AppletIcon.d.ts.map +1 -1
  47. package/dist/commonjs/icon/lib/AppletIcon.js +27 -4
  48. package/dist/commonjs/icon/lib/Graphic.d.ts +20 -1
  49. package/dist/commonjs/icon/lib/Graphic.d.ts.map +1 -1
  50. package/dist/commonjs/icon/lib/Graphic.js +25 -3
  51. package/dist/commonjs/icon/lib/Svg.d.ts +12 -2
  52. package/dist/commonjs/icon/lib/Svg.d.ts.map +1 -1
  53. package/dist/commonjs/icon/lib/Svg.js +25 -10
  54. package/dist/commonjs/icon/lib/SystemIcon.d.ts +79 -16
  55. package/dist/commonjs/icon/lib/SystemIcon.d.ts.map +1 -1
  56. package/dist/commonjs/icon/lib/SystemIcon.js +51 -14
  57. package/dist/commonjs/icon/lib/SystemIconCircle.d.ts +2 -3
  58. package/dist/commonjs/icon/lib/SystemIconCircle.d.ts.map +1 -1
  59. package/dist/commonjs/icon/lib/SystemIconCircle.js +20 -30
  60. package/dist/commonjs/loading-dots/lib/LoadingDots.js +3 -3
  61. package/dist/commonjs/menu/lib/MenuCard.js +2 -2
  62. package/dist/commonjs/menu/lib/MenuList.js +5 -5
  63. package/dist/commonjs/select/lib/Select.js +7 -7
  64. package/dist/commonjs/select/lib/hooks/useSelectInput.d.ts +4 -1
  65. package/dist/commonjs/select/lib/hooks/useSelectInput.d.ts.map +1 -1
  66. package/dist/commonjs/select/lib/hooks/useSelectInput.js +14 -5
  67. package/dist/commonjs/switch/lib/Switch.js +13 -13
  68. package/dist/commonjs/table/lib/Table.js +2 -2
  69. package/dist/commonjs/table/lib/TableBody.js +2 -2
  70. package/dist/commonjs/table/lib/TableCaption.js +2 -2
  71. package/dist/commonjs/table/lib/TableCell.js +2 -2
  72. package/dist/commonjs/table/lib/TableFooter.js +2 -2
  73. package/dist/commonjs/table/lib/TableHead.js +2 -2
  74. package/dist/commonjs/table/lib/TableHeader.js +2 -2
  75. package/dist/commonjs/table/lib/TableRow.js +2 -2
  76. package/dist/commonjs/tabs/lib/TabsItem.d.ts.map +1 -1
  77. package/dist/commonjs/tabs/lib/TabsItem.js +4 -12
  78. package/dist/commonjs/tabs/lib/useTabsModel.d.ts.map +1 -1
  79. package/dist/commonjs/text/lib/LabelText.d.ts.map +1 -1
  80. package/dist/commonjs/text/lib/LabelText.js +11 -27
  81. package/dist/commonjs/text/lib/Text.d.ts +103 -0
  82. package/dist/commonjs/text/lib/Text.d.ts.map +1 -1
  83. package/dist/commonjs/text/lib/Text.js +30 -27
  84. package/dist/commonjs/tooltip/lib/OverflowTooltip.d.ts.map +1 -1
  85. package/dist/commonjs/tooltip/lib/OverflowTooltip.js +2 -3
  86. package/dist/es6/badge/lib/CountBadge.js +6 -6
  87. package/dist/es6/breadcrumbs/lib/BreadcrumbsItem.js +1 -1
  88. package/dist/es6/breadcrumbs/lib/BreadcrumbsOverflowButton.js +1 -1
  89. package/dist/es6/button/lib/BaseButton.d.ts.map +1 -1
  90. package/dist/es6/button/lib/BaseButton.js +18 -17
  91. package/dist/es6/button/lib/DeleteButton.d.ts.map +1 -1
  92. package/dist/es6/button/lib/DeleteButton.js +2 -1
  93. package/dist/es6/button/lib/ExternalHyperlink.js +1 -1
  94. package/dist/es6/button/lib/PrimaryButton.d.ts.map +1 -1
  95. package/dist/es6/button/lib/PrimaryButton.js +3 -2
  96. package/dist/es6/button/lib/SecondaryButton.d.ts.map +1 -1
  97. package/dist/es6/button/lib/SecondaryButton.js +3 -2
  98. package/dist/es6/button/lib/TertiaryButton.d.ts.map +1 -1
  99. package/dist/es6/button/lib/TertiaryButton.js +16 -15
  100. package/dist/es6/card/lib/Card.js +1 -1
  101. package/dist/es6/card/lib/CardHeading.js +1 -1
  102. package/dist/es6/checkbox/lib/CheckBackground.js +5 -5
  103. package/dist/es6/checkbox/lib/CheckboxCheck.js +9 -9
  104. package/dist/es6/checkbox/lib/CheckboxContainer.js +1 -1
  105. package/dist/es6/checkbox/lib/CheckboxInput.js +11 -11
  106. package/dist/es6/checkbox/lib/CheckboxRipple.js +1 -1
  107. package/dist/es6/collection/lib/ListBox.d.ts.map +1 -1
  108. package/dist/es6/collection/lib/ListBox.js +15 -9
  109. package/dist/es6/combobox/lib/ComboboxMenuItem.js +4 -4
  110. package/dist/es6/combobox/lib/ComboboxMenuList.d.ts.map +1 -1
  111. package/dist/es6/combobox/lib/ComboboxMenuList.js +5 -6
  112. package/dist/es6/common/lib/AccessibleHide.js +1 -1
  113. package/dist/es6/common/lib/CanvasProvider.js +1 -1
  114. package/dist/es6/icon/index.d.ts +1 -1
  115. package/dist/es6/icon/index.d.ts.map +1 -1
  116. package/dist/es6/icon/index.js +1 -1
  117. package/dist/es6/icon/lib/AccentIcon.d.ts +30 -4
  118. package/dist/es6/icon/lib/AccentIcon.d.ts.map +1 -1
  119. package/dist/es6/icon/lib/AccentIcon.js +27 -3
  120. package/dist/es6/icon/lib/AppletIcon.d.ts +31 -2
  121. package/dist/es6/icon/lib/AppletIcon.d.ts.map +1 -1
  122. package/dist/es6/icon/lib/AppletIcon.js +26 -3
  123. package/dist/es6/icon/lib/Graphic.d.ts +20 -1
  124. package/dist/es6/icon/lib/Graphic.d.ts.map +1 -1
  125. package/dist/es6/icon/lib/Graphic.js +24 -2
  126. package/dist/es6/icon/lib/Svg.d.ts +12 -2
  127. package/dist/es6/icon/lib/Svg.d.ts.map +1 -1
  128. package/dist/es6/icon/lib/Svg.js +25 -11
  129. package/dist/es6/icon/lib/SystemIcon.d.ts +79 -16
  130. package/dist/es6/icon/lib/SystemIcon.d.ts.map +1 -1
  131. package/dist/es6/icon/lib/SystemIcon.js +50 -13
  132. package/dist/es6/icon/lib/SystemIconCircle.d.ts +2 -3
  133. package/dist/es6/icon/lib/SystemIconCircle.d.ts.map +1 -1
  134. package/dist/es6/icon/lib/SystemIconCircle.js +23 -30
  135. package/dist/es6/loading-dots/lib/LoadingDots.js +3 -3
  136. package/dist/es6/menu/lib/MenuCard.js +2 -2
  137. package/dist/es6/menu/lib/MenuList.js +5 -5
  138. package/dist/es6/select/lib/Select.js +7 -7
  139. package/dist/es6/select/lib/hooks/useSelectInput.d.ts +4 -1
  140. package/dist/es6/select/lib/hooks/useSelectInput.d.ts.map +1 -1
  141. package/dist/es6/select/lib/hooks/useSelectInput.js +14 -5
  142. package/dist/es6/switch/lib/Switch.js +13 -13
  143. package/dist/es6/table/lib/Table.js +2 -2
  144. package/dist/es6/table/lib/TableBody.js +2 -2
  145. package/dist/es6/table/lib/TableCaption.js +2 -2
  146. package/dist/es6/table/lib/TableCell.js +2 -2
  147. package/dist/es6/table/lib/TableFooter.js +2 -2
  148. package/dist/es6/table/lib/TableHead.js +2 -2
  149. package/dist/es6/table/lib/TableHeader.js +2 -2
  150. package/dist/es6/table/lib/TableRow.js +2 -2
  151. package/dist/es6/tabs/lib/TabsItem.d.ts.map +1 -1
  152. package/dist/es6/tabs/lib/TabsItem.js +5 -13
  153. package/dist/es6/tabs/lib/useTabsModel.d.ts.map +1 -1
  154. package/dist/es6/text/lib/LabelText.d.ts.map +1 -1
  155. package/dist/es6/text/lib/LabelText.js +12 -28
  156. package/dist/es6/text/lib/Text.d.ts +103 -0
  157. package/dist/es6/text/lib/Text.d.ts.map +1 -1
  158. package/dist/es6/text/lib/Text.js +31 -28
  159. package/dist/es6/tooltip/lib/OverflowTooltip.d.ts.map +1 -1
  160. package/dist/es6/tooltip/lib/OverflowTooltip.js +2 -3
  161. package/icon/index.ts +1 -1
  162. package/icon/lib/AccentIcon.tsx +48 -10
  163. package/icon/lib/AppletIcon.tsx +53 -12
  164. package/icon/lib/Graphic.tsx +43 -10
  165. package/icon/lib/Svg.tsx +36 -19
  166. package/icon/lib/SystemIcon.tsx +134 -39
  167. package/icon/lib/SystemIconCircle.tsx +42 -47
  168. package/package.json +5 -5
  169. package/select/lib/hooks/useSelectInput.ts +24 -8
  170. package/tabs/lib/TabsItem.tsx +6 -13
  171. package/tabs/lib/useTabsModel.tsx +0 -1
  172. package/text/lib/LabelText.tsx +11 -63
  173. package/text/lib/Text.tsx +65 -62
  174. package/tooltip/lib/OverflowTooltip.tsx +2 -3
  175. package/dist/commonjs/icon/lib/Icon.d.ts +0 -9
  176. package/dist/commonjs/icon/lib/Icon.d.ts.map +0 -1
  177. package/dist/commonjs/icon/lib/Icon.js +0 -40
  178. package/dist/es6/icon/lib/Icon.d.ts +0 -9
  179. package/dist/es6/icon/lib/Icon.d.ts.map +0 -1
  180. package/dist/es6/icon/lib/Icon.js +0 -18
  181. package/icon/lib/Icon.tsx +0 -38
@@ -2,52 +2,81 @@ import * as React from 'react';
2
2
  import {iconColors} from '@workday/canvas-kit-react/tokens';
3
3
  import {CanvasSystemIcon, CanvasIconTypes} from '@workday/design-assets-types';
4
4
  import {CSSObject} from '@emotion/styled';
5
- import {Icon, IconProps} from './Icon';
6
5
  import {createComponent, getColor} from '@workday/canvas-kit-react/common';
7
- import {SystemPropValues} from '@workday/canvas-kit-react/layout';
6
+ import {cssVar, createStencil, handleCsProp, px2rem, createVars} from '@workday/canvas-kit-styling';
7
+ import {base} from '@workday/canvas-tokens-web';
8
+ import {Svg, SvgProps, svgStencil, transformColorNameToToken} from './Svg';
8
9
 
10
+ /**
11
+ * @deprecated Interface `SystemIconStyles` will be removed in a future version. `accent`, `color`, background props will be moved inside `GraphicProps`.
12
+ */
9
13
  export interface SystemIconStyles {
10
14
  /**
11
15
  * The accent color of the SystemIcon. This overrides `color`.
12
16
  */
13
- accent?: SystemPropValues['color'];
17
+ accent?: string;
14
18
  /**
15
19
  * The accent color of the SystemIcon on hover. This overrides `colorHover`.
20
+ * @deprecated `accentHover` is deprecated and will be removed in a future version. Please use the following instead in your style overrides:
21
+ * ```tsx
22
+ * '&:hover': {
23
+ * [systemIconStencil.vars.accent]: desiredAccentHoverColor
24
+ * }
25
+ * ```
16
26
  */
17
- accentHover?: SystemPropValues['color'];
27
+ accentHover?: string;
18
28
  /**
19
29
  * The background color of the SystemIcon.
20
30
  * @default transparent
21
31
  */
22
- background?: SystemPropValues['color'];
32
+ background?: string;
23
33
  /**
24
34
  * The background color of the SystemIcon on hover.
25
35
  * @default transparent
36
+ * @deprecated `backgroundHover` is deprecated and will be removed in a future version. Please use the following instead in your style overrides:
37
+ * ```tsx
38
+ * '&:hover': {
39
+ * [systemIconStencil.vars.background]: desiredBackgroundHoverColor
40
+ * }
41
+ * ```
26
42
  */
27
- backgroundHover?: SystemPropValues['color'];
43
+ backgroundHover?: string;
28
44
  /**
29
- * The color of the SystemIcon. This defines `accent` and `fill`. `color` may be overriden by `accent` and `fill`.
30
- * @default iconColors.standard
45
+ * The color of the SystemIcon. This defines `accent` and `fill`. `color` may be overwritten by `accent` and `fill`.
46
+ * @default base.licorice200
31
47
  */
32
- color?: SystemPropValues['color'];
48
+ color?: string;
33
49
  /**
34
- * The hover color of the SystemIcon. This defines `accentHover` and `fillHover`. `colorHover` may be overriden by `accentHover` and `fillHover`.
35
- * @default iconColors.hover
50
+ * The hover color of the SystemIcon. This defines `accentHover` and `fillHover`. `colorHover` may be overwritten by `accentHover` and `fillHover`.
51
+ * @default base.licorice200
52
+ * @deprecated `colorHover` is deprecated and will be removed in a future version. Please use the following instead in your style overrides:
53
+ * ```tsx
54
+ * '&:hover': {
55
+ * [systemIconStencil.vars.color]: desiredColorHoverColor
56
+ * }
57
+ * ```
36
58
  */
37
- colorHover?: SystemPropValues['color'];
59
+ colorHover?: string;
38
60
  /**
39
61
  * The fill color of the SystemIcon. This overrides `color`.
62
+ * @deprecated `fill` is deprecated and will be removed in a future version. Please use `color` and specify `accent` color if you want `accent` to be different from `color`.
40
63
  */
41
- fill?: SystemPropValues['color'];
64
+ fill?: string;
42
65
  /**
43
66
  * The fill color of the SystemIcon on hover. This overrides `colorHover`.
67
+ * @deprecated `fillHover` is deprecated and will be removed in a future version. Please use the following instead in your style overrides:
68
+ * ```tsx
69
+ * '&:hover': {
70
+ * [systemIconStencil.vars.fill]: desiredFillHoverColor
71
+ * }
72
+ * ```
44
73
  */
45
- fillHover?: SystemPropValues['color'];
74
+ fillHover?: string;
46
75
  }
47
76
 
48
77
  export interface SystemIconProps
49
78
  extends SystemIconStyles,
50
- Omit<IconProps, 'src' | 'fill' | 'type'> {
79
+ Omit<SvgProps, 'src' | 'type' | 'fill' | 'background' | 'color'> {
51
80
  /**
52
81
  * The icon to display from `@workday/canvas-system-icons-web`.
53
82
  */
@@ -55,9 +84,18 @@ export interface SystemIconProps
55
84
  /**
56
85
  * The size of the SystemIcon in `px`.
57
86
  */
58
- size?: number | string | undefined;
87
+ size?: number | string;
59
88
  }
60
89
 
90
+ /**
91
+ * @deprecated This style utility function is deprecated and will be removed in a future version. We'll track usage over time to prevent unnecessary burden on upgrading. Most of the time, this function is used in conjunction with styling `SystemIcon`. There are a few ways to override the colors used in `SystemIcon`.
92
+ * - Pass props directly to the `SystemIcon` component: `<SystemIcon color={color} {...etc} />
93
+ * - Style overrides using the `systemIconStencil`:
94
+ * ```tsx
95
+ * // styling container
96
+ *
97
+ * ```
98
+ */
61
99
  export const systemIconStyles = ({
62
100
  accent,
63
101
  accentHover,
@@ -88,47 +126,104 @@ export const systemIconStyles = ({
88
126
  },
89
127
  });
90
128
 
129
+ /**
130
+ * @deprecated These variables are being used for backward compatibility with existing hover props. Please use the following instead:
131
+ * ```tsx
132
+ * '&:hover': {
133
+ * [systemIconStencil.vars.color]: desiredHoverColor
134
+ * }
135
+ * ```
136
+ */
137
+ const deprecatedSystemIconVars = createVars(
138
+ 'colorHover',
139
+ 'fillHover',
140
+ 'accentHover',
141
+ 'backgroundHover'
142
+ );
143
+
144
+ export const systemIconStencil = createStencil({
145
+ extends: svgStencil,
146
+ vars: {
147
+ /**
148
+ * This will set the icon's color (both `.wd-icon-fill` and `.wd-icon-accent` SVG layers). Most
149
+ * of the time, this is the only color you need to change. Icons also have an accent layer. If you
150
+ * wish to change the accent layer independently, also set the `accentColor` variable
151
+ */
152
+ color: '',
153
+ accentColor: '',
154
+ backgroundColor: 'transparent',
155
+ },
156
+ base: ({accentColor, backgroundColor, color}) => ({
157
+ '& .wd-icon-fill': {
158
+ fill: cssVar(color, base.licorice200),
159
+ },
160
+ '& .wd-icon-accent, & .wd-icon-accent2': {
161
+ fill: cssVar(accentColor, cssVar(color, base.licorice200)),
162
+ },
163
+ '& .wd-icon-background': {
164
+ fill: backgroundColor,
165
+ },
166
+ // will be removed eventually
167
+ '&:where(:hover, .hover) .wd-icon-fill': {
168
+ fill: cssVar(
169
+ deprecatedSystemIconVars.fillHover,
170
+ cssVar(deprecatedSystemIconVars.colorHover, cssVar(color, base.licorice200))
171
+ ),
172
+ },
173
+ '&:where(:hover, .hover) .wd-icon-accent, & .wd-icon-accent2': {
174
+ fill: cssVar(
175
+ deprecatedSystemIconVars.accentHover,
176
+ cssVar(
177
+ deprecatedSystemIconVars.colorHover,
178
+ cssVar(accentColor, cssVar(color, base.licorice200))
179
+ )
180
+ ),
181
+ },
182
+ '&:where(:hover, .hover) .wd-icon-background': {
183
+ fill: cssVar(deprecatedSystemIconVars.backgroundHover, backgroundColor),
184
+ },
185
+ }),
186
+ });
187
+
91
188
  export const SystemIcon = createComponent('span')({
92
189
  displayName: 'SystemIcon',
93
190
  Component: (
94
191
  {
95
- background = 'transparent',
96
- backgroundHover = 'transparent',
97
- color = iconColors.standard,
98
- colorHover = iconColors.hover,
192
+ size,
193
+ background,
194
+ backgroundHover,
195
+ color,
196
+ colorHover,
99
197
  icon,
100
198
  accent,
101
199
  accentHover,
102
200
  fill,
103
201
  fillHover,
104
- size,
105
- shouldMirror,
106
202
  ...elemProps
107
203
  }: SystemIconProps,
108
204
  ref,
109
205
  Element
110
206
  ) => {
111
- const style = systemIconStyles({
112
- accent,
113
- accentHover,
114
- background,
115
- backgroundHover,
116
- color,
117
- colorHover,
118
- fill,
119
- fillHover,
120
- });
121
-
122
207
  return (
123
- <Icon
208
+ <Svg
209
+ as={Element}
124
210
  src={icon}
125
211
  type={CanvasIconTypes.System}
126
- size={size}
127
- as={Element}
128
- shouldMirror={shouldMirror}
129
212
  ref={ref}
130
- styles={style}
131
- {...elemProps}
213
+ {...handleCsProp(elemProps, [
214
+ systemIconStencil({
215
+ size: typeof size === 'number' ? px2rem(size) : size,
216
+ color: transformColorNameToToken(fill || color),
217
+ accentColor: transformColorNameToToken(accent || color),
218
+ backgroundColor: transformColorNameToToken(background),
219
+ }),
220
+ {
221
+ [deprecatedSystemIconVars.colorHover]: colorHover && cssVar(colorHover),
222
+ [deprecatedSystemIconVars.fillHover]: fillHover && cssVar(fillHover),
223
+ [deprecatedSystemIconVars.accentHover]: accentHover && cssVar(accentHover),
224
+ [deprecatedSystemIconVars.backgroundHover]: backgroundHover && cssVar(backgroundHover),
225
+ },
226
+ ])}
132
227
  />
133
228
  );
134
229
  },
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
- import styled from '@emotion/styled';
3
- import isPropValid from '@emotion/is-prop-valid';
4
- import {colors, borderRadius} from '@workday/canvas-kit-react/tokens';
5
- import {SystemIcon, SystemIconProps} from './SystemIcon';
2
+ import {colors} from '@workday/canvas-kit-react/tokens';
3
+ import {SystemIcon, SystemIconProps, systemIconStencil} from './SystemIcon';
6
4
  import {CanvasSystemIcon} from '@workday/design-assets-types';
7
- import {createComponent, getColor, pickForegroundColor} from '@workday/canvas-kit-react/common';
8
- import {SystemPropValues} from '@workday/canvas-kit-react/layout';
5
+ import {createComponent, pickForegroundColor} from '@workday/canvas-kit-react/common';
6
+ import {calc, createStencil, cssVar, px2rem} from '@workday/canvas-kit-styling';
7
+ import {base, system} from '@workday/canvas-tokens-web';
8
+ import {transformColorNameToToken} from './Svg';
9
9
 
10
10
  export enum SystemIconCircleSize {
11
11
  xs = 16,
@@ -19,9 +19,9 @@ export enum SystemIconCircleSize {
19
19
  export interface SystemIconCircleProps extends Pick<SystemIconProps, 'shouldMirror'> {
20
20
  /**
21
21
  * The background color of the SystemIconCircle from `@workday/canvas-colors-web`.
22
- * @default colors.soap300
22
+ * @default base.soap300
23
23
  */
24
- background?: SystemPropValues['color'];
24
+ background?: string;
25
25
  /**
26
26
  * The icon to display from `@workday/canvas-accent-icons-web`.
27
27
  */
@@ -33,60 +33,55 @@ export interface SystemIconCircleProps extends Pick<SystemIconProps, 'shouldMirr
33
33
  size?: SystemIconCircleSize | number;
34
34
  }
35
35
 
36
- const Container = styled('div', {
37
- shouldForwardProp: prop => isPropValid(prop) && prop !== 'size',
38
- })<Pick<SystemIconCircleProps, 'background' | 'size'>>(
39
- {
36
+ const systemIconCircleStencil = createStencil({
37
+ vars: {
38
+ containerSize: '',
39
+ backgroundColor: '',
40
+ iconColor: '',
41
+ },
42
+ base: ({backgroundColor, containerSize, iconColor}) => ({
43
+ background: cssVar(backgroundColor, base.soap200),
40
44
  display: 'flex',
41
45
  alignItems: 'center',
42
46
  justifyContent: 'center',
43
- padding: 0,
44
- border: 0,
45
- borderRadius: borderRadius.circle,
47
+ padding: system.space.zero,
48
+ border: 'none',
49
+ borderRadius: system.shape.round,
46
50
  boxSizing: 'border-box',
47
51
  overflow: 'hidden',
52
+ width: cssVar(containerSize, system.space.x10),
53
+ height: cssVar(containerSize, system.space.x10),
54
+ [systemIconStencil.vars.size]: calc.multiply(cssVar(containerSize, system.space.x10), 0.625),
55
+ [systemIconStencil.vars.color]: iconColor,
48
56
  '& img': {
49
57
  width: '100%',
50
58
  height: '100%',
51
59
  },
52
- },
53
- ({background}) => ({
54
- background: getColor(background),
55
60
  }),
56
- ({size}) => ({
57
- width: size,
58
- height: size,
59
- })
60
- );
61
+ });
61
62
 
62
63
  export const SystemIconCircle = createComponent('span')({
63
64
  displayName: 'SystemIconCircle',
64
- Component: (
65
- {
66
- background = colors.soap200,
67
- size = SystemIconCircleSize.l,
68
- icon,
65
+ Component: ({background, size, icon, shouldMirror}: SystemIconCircleProps, ref, Element) => {
66
+ // `pickForegroundColor` hasn't support to use css variables to generate foregroundColor
67
+ const backgroundFallback =
68
+ background && !background.startsWith('--') ? background : colors.soap200;
69
+ const iconColor = pickForegroundColor(
70
+ backgroundFallback,
71
+ 'rgba(0,0,0,0.65)',
72
+ colors.frenchVanilla100
73
+ );
69
74
 
70
- shouldMirror,
71
- ...elemProps
72
- }: SystemIconCircleProps,
73
- ref,
74
- Element
75
- ) => {
76
- const iconColor = pickForegroundColor(background, 'rgba(0,0,0,0.65)', colors.frenchVanilla100);
77
- const iconSize = size * 0.625;
78
75
  return (
79
- <Container background={background} size={size} {...elemProps}>
80
- <SystemIcon
81
- icon={icon}
82
- color={iconColor}
83
- colorHover={iconColor}
84
- as={Element}
85
- size={iconSize}
86
- ref={ref}
87
- shouldMirror={shouldMirror}
88
- />
89
- </Container>
76
+ <div
77
+ {...systemIconCircleStencil({
78
+ containerSize: typeof size === 'number' ? px2rem(size) : size,
79
+ backgroundColor: transformColorNameToToken(background),
80
+ iconColor,
81
+ })}
82
+ >
83
+ <SystemIcon as={Element} ref={ref} icon={icon} shouldMirror={shouldMirror} />
84
+ </div>
90
85
  );
91
86
  },
92
87
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-react",
3
- "version": "11.0.0-alpha.726-next.0",
3
+ "version": "11.0.0-alpha.758-next.0",
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,10 +49,10 @@
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": "^11.0.0-alpha.726-next.0",
53
- "@workday/canvas-kit-styling": "^11.0.0-alpha.726-next.0",
52
+ "@workday/canvas-kit-popup-stack": "^11.0.0-alpha.758-next.0",
53
+ "@workday/canvas-kit-styling": "^11.0.0-alpha.758-next.0",
54
54
  "@workday/canvas-system-icons-web": "^3.0.0",
55
- "@workday/canvas-tokens-web": "^1.0.2",
55
+ "@workday/canvas-tokens-web": "^1.3.0",
56
56
  "@workday/design-assets-types": "^0.2.8",
57
57
  "chroma-js": "^2.1.0",
58
58
  "csstype": "^3.0.2",
@@ -67,5 +67,5 @@
67
67
  "@workday/canvas-accent-icons-web": "^3.0.0",
68
68
  "@workday/canvas-applet-icons-web": "^2.0.0"
69
69
  },
70
- "gitHead": "92313a01b7703822a67e7c7f7aff5460237f8ce7"
70
+ "gitHead": "8d03e85b517b28f0f8dbf4918b9bda35a3e5d893"
71
71
  }
@@ -14,12 +14,16 @@ import {
14
14
  } from '@workday/canvas-kit-react/combobox';
15
15
  import {useSelectModel} from './useSelectModel';
16
16
 
17
+ function noop() {
18
+ // Do nothing
19
+ }
20
+
17
21
  /**
18
22
  * `useSelectInput` extends {@link useComboboxInput useComboboxInput} and {@link useComboboxKeyboardTypeAhead useComboboxKeyboardTypeAhead} and adds type ahead functionality and Select-specific [keyboard support](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/).
19
23
  */
20
24
  export const useSelectInput = composeHooks(
21
25
  createElemPropsHook(useSelectModel)(
22
- (model, ref, elemProps: {keySofar?: string; placeholder?: string} = {}) => {
26
+ (model, ref, elemProps: {keySofar?: string; placeholder?: string; value?: string} = {}) => {
23
27
  const {elementRef} = useLocalRef<HTMLInputElement>(ref as any);
24
28
  const textInputRef = React.useRef<HTMLInputElement>(null);
25
29
 
@@ -30,6 +34,7 @@ export const useSelectInput = composeHooks(
30
34
  Object.getPrototypeOf(textInputRef.current),
31
35
  'value'
32
36
  );
37
+
33
38
  if (nativeInputValue && nativeInputValue.set) {
34
39
  nativeInputValue.set.call(textInputRef.current, value);
35
40
  }
@@ -54,6 +59,19 @@ export const useSelectInput = composeHooks(
54
59
  model.state.selectedIds[0]
55
60
  ) {
56
61
  const value = model.navigation.getItem(model.state.selectedIds[0], model).id;
62
+
63
+ // force the hidden input to have the correct value
64
+ if (model.state.inputRef.current.value !== value) {
65
+ const nativeInputValue = Object.getOwnPropertyDescriptor(
66
+ Object.getPrototypeOf(model.state.inputRef.current),
67
+ 'value'
68
+ );
69
+
70
+ if (nativeInputValue && nativeInputValue.set) {
71
+ nativeInputValue.set.call(model.state.inputRef.current, value);
72
+ }
73
+ }
74
+
57
75
  if (
58
76
  model.state.selectedIds[0] !== value &&
59
77
  model.state.inputRef.current.value !== value
@@ -130,15 +148,13 @@ export const useSelectInput = composeHooks(
130
148
  },
131
149
  textInputProps: {
132
150
  ref: textInputRef,
151
+ onChange: noop,
152
+ value:
153
+ model.state.selectedIds.length > 0 && model.state.items.length > 0
154
+ ? model.navigation.getItem(model.state.selectedIds[0], model).textValue
155
+ : '',
133
156
  },
134
157
  ref: elementRef,
135
-
136
- // Account for the case where an initial item is selected when the Select first renders
137
- defaultValue:
138
- model.state.selectedIds.length > 0 && model.state.items.length > 0
139
- ? model.navigation.getItem(model.state.selectedIds[0], model).textValue ||
140
- model.state.value
141
- : undefined,
142
158
  } as const;
143
159
  }
144
160
  ),
@@ -17,7 +17,7 @@ import {
17
17
  } from '@workday/canvas-kit-react/common';
18
18
  import {Box, FlexProps} from '@workday/canvas-kit-react/layout';
19
19
  import {OverflowTooltip} from '@workday/canvas-kit-react/tooltip';
20
- import {SystemIcon} from '@workday/canvas-kit-react/icon';
20
+ import {SystemIcon, systemIconStencil} from '@workday/canvas-kit-react/icon';
21
21
  import {
22
22
  useListItemRegister,
23
23
  useListItemRovingFocus,
@@ -104,9 +104,8 @@ export const StyledTabItem = styled(Box.as('button'))<StyledType & Pick<TabsItem
104
104
  '&:hover, &:focus': {
105
105
  backgroundColor: colors.soap200,
106
106
  color: colors.blackPepper400,
107
- '.wd-icon-fill, .wd-icon-accent, .wd-icon-accent2': {
108
- fill: iconColors.hover,
109
- },
107
+
108
+ [systemIconStencil.vars.color]: iconColors.hover,
110
109
  },
111
110
 
112
111
  '&:focus': {
@@ -116,24 +115,18 @@ export const StyledTabItem = styled(Box.as('button'))<StyledType & Pick<TabsItem
116
115
 
117
116
  '&:disabled, &[aria-disabled]': {
118
117
  color: colors.licorice100,
119
- '.wd-icon-fill, .wd-icon-accent, .wd-icon-accent2': {
120
- fill: iconColors.disabled,
121
- },
118
+ [systemIconStencil.vars.color]: iconColors.disabled,
122
119
  '&:hover': {
123
120
  cursor: 'auto',
124
121
  backgroundColor: `transparent`,
125
- '.wd-icon-fill, .wd-icon-accent, .wd-icon-accent2': {
126
- fill: iconColors.disabled,
127
- },
122
+ [systemIconStencil.vars.color]: iconColors.disabled,
128
123
  },
129
124
  },
130
125
 
131
126
  '&[aria-selected=true]': {
132
127
  color: theme.canvas.palette.primary.main,
133
128
  cursor: 'default',
134
- '.wd-icon-fill, .wd-icon-accent, .wd-icon-accent2': {
135
- fill: theme.canvas.palette.primary.main,
136
- },
129
+ [systemIconStencil.vars.color]: theme.canvas.palette.primary.main,
137
130
  '&:after': {
138
131
  position: 'absolute',
139
132
  height: space.xxxs,
@@ -54,7 +54,6 @@ export const useTabsModel = createModelHook({
54
54
  const getId = config.getId || defaultGetId;
55
55
  const modality = useModalityType();
56
56
 
57
-
58
57
  const model = useOverflowListModel(
59
58
  useOverflowListModel.mergeConfig(config, {
60
59
  shouldCalculateOverflow: modality !== 'touch',
@@ -1,8 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import {createComponent} from '@workday/canvas-kit-react/common';
3
- import {base, system} from '@workday/canvas-tokens-web';
3
+ import {system} from '@workday/canvas-tokens-web';
4
4
  import {createStencil} from '@workday/canvas-kit-styling';
5
5
  import {BoxProps, mergeStyles} from '@workday/canvas-kit-react/layout';
6
+ import {textStencil} from './Text';
6
7
 
7
8
  /**
8
9
  * @deprecated ⚠️ `TypeLabelProps` has been deprecated and will be removed in a future major version.
@@ -28,83 +29,30 @@ export interface TypeLabelProps extends BoxProps {
28
29
  }
29
30
 
30
31
  const labelTextStencil = createStencil({
32
+ extends: textStencil,
31
33
  base: {
32
34
  ...system.type.subtext.large,
33
- color: base.blackPepper300,
35
+ color: system.color.text.default,
34
36
  },
35
37
  modifiers: {
36
- typeLevel: {
37
- // Title level styles
38
- 'title.large': {
39
- ...system.type.title.large,
40
- color: base.blackPepper400,
41
- },
42
- 'title.medium': {
43
- ...system.type.title.medium,
44
- color: base.blackPepper400,
45
- },
46
- 'title.small': {
47
- ...system.type.title.small,
48
- color: base.blackPepper400,
49
- },
50
- // Heading level styles
51
- 'heading.large': {
52
- ...system.type.heading.large,
53
- color: base.blackPepper400,
54
- },
55
- 'heading.medium': {
56
- ...system.type.heading.medium,
57
- color: base.blackPepper400,
58
- },
59
- 'heading.small': {
60
- ...system.type.heading.small,
61
- color: base.blackPepper400,
62
- },
63
- // Body level styles
64
- 'body.large': {
65
- ...system.type.body.large,
66
- color: base.blackPepper300,
67
- },
68
- 'body.medium': {
69
- ...system.type.body.medium,
70
- color: base.blackPepper300,
71
- },
72
- 'body.small': {
73
- ...system.type.body.small,
74
- color: base.blackPepper300,
75
- },
76
- // Subtext level styles
77
- 'subtext.large': {
78
- ...system.type.subtext.large,
79
- color: base.blackPepper300,
80
- },
81
- 'subtext.medium': {
82
- ...system.type.subtext.medium,
83
- color: base.blackPepper300,
84
- },
85
- 'subtext.small': {
86
- ...system.type.subtext.small,
87
- color: base.blackPepper300,
88
- },
89
- },
90
- variant: {
91
- error: {color: base.cinnamon500},
92
- hint: {color: base.licorice300},
93
- inverse: {color: base.frenchVanilla100},
94
- },
95
38
  disabled: {
96
39
  true: {
97
40
  cursor: 'default',
98
- color: base.licorice100,
41
+ color: system.color.text.disabled,
99
42
  },
100
43
  },
44
+ variant: {
45
+ inverse: {color: system.color.text.inverse},
46
+ error: {color: system.color.text.critical.default},
47
+ hint: {color: system.color.text.hint},
48
+ },
101
49
  },
102
50
  compound: [
103
51
  {
104
52
  modifiers: {variant: 'inverse', disabled: true},
105
53
  styles: {
106
54
  opacity: system.opacity.disabled,
107
- color: base.frenchVanilla100,
55
+ color: system.color.text.inverse,
108
56
  },
109
57
  },
110
58
  ],