@workday/canvas-kit-preview-react 14.0.0-alpha.1147-next.0 → 14.0.0-alpha.1149-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 (82) hide show
  1. package/dist/commonjs/color-picker/lib/ColorPicker.js +1 -1
  2. package/dist/commonjs/color-picker/lib/parts/ColorReset.js +1 -1
  3. package/dist/commonjs/color-picker/lib/parts/SwatchBook.js +1 -1
  4. package/dist/commonjs/divider/lib/Divider.js +1 -1
  5. package/dist/commonjs/index.d.ts +0 -1
  6. package/dist/commonjs/index.d.ts.map +1 -1
  7. package/dist/commonjs/index.js +0 -1
  8. package/dist/commonjs/information-highlight/lib/InformationHighlight.js +7 -7
  9. package/dist/commonjs/information-highlight/lib/parts/Body.js +1 -1
  10. package/dist/commonjs/information-highlight/lib/parts/Heading.js +1 -1
  11. package/dist/commonjs/information-highlight/lib/parts/Link.js +1 -1
  12. package/dist/commonjs/loading-sparkles/lib/LoadingSparkles.js +2 -2
  13. package/dist/commonjs/multi-select/lib/MultiSelectInput.js +3 -3
  14. package/dist/commonjs/pill/lib/Pill.js +3 -3
  15. package/dist/commonjs/pill/lib/PillAvatar.js +1 -1
  16. package/dist/commonjs/pill/lib/PillCount.js +1 -1
  17. package/dist/commonjs/pill/lib/PillIcon.js +1 -1
  18. package/dist/commonjs/pill/lib/PillIconButton.js +1 -1
  19. package/dist/commonjs/pill/lib/PillLabel.js +1 -1
  20. package/dist/commonjs/radio/lib/RadioGroup.js +3 -3
  21. package/dist/commonjs/radio/lib/RadioLabel.js +1 -1
  22. package/dist/commonjs/radio/lib/RadioText.js +4 -4
  23. package/dist/commonjs/radio/lib/StyledRadioButton.js +5 -5
  24. package/dist/commonjs/segmented-control/lib/SegmentedControlItem.js +16 -16
  25. package/dist/commonjs/segmented-control/lib/SegmentedControlList.js +4 -4
  26. package/dist/commonjs/side-panel/lib/SidePanel.js +7 -7
  27. package/dist/commonjs/side-panel/lib/SidePanelToggleButton.js +11 -11
  28. package/dist/commonjs/status-indicator/lib/StatusIndicator.js +13 -13
  29. package/dist/commonjs/status-indicator/lib/StatusIndicatorLabel.js +1 -1
  30. package/dist/es6/color-picker/lib/ColorPicker.js +1 -1
  31. package/dist/es6/color-picker/lib/parts/ColorReset.js +1 -1
  32. package/dist/es6/color-picker/lib/parts/SwatchBook.js +1 -1
  33. package/dist/es6/divider/lib/Divider.js +1 -1
  34. package/dist/es6/index.d.ts +0 -1
  35. package/dist/es6/index.d.ts.map +1 -1
  36. package/dist/es6/index.js +0 -1
  37. package/dist/es6/information-highlight/lib/InformationHighlight.js +7 -7
  38. package/dist/es6/information-highlight/lib/parts/Body.js +1 -1
  39. package/dist/es6/information-highlight/lib/parts/Heading.js +1 -1
  40. package/dist/es6/information-highlight/lib/parts/Link.js +1 -1
  41. package/dist/es6/loading-sparkles/lib/LoadingSparkles.js +2 -2
  42. package/dist/es6/multi-select/lib/MultiSelectInput.js +3 -3
  43. package/dist/es6/pill/lib/Pill.js +3 -3
  44. package/dist/es6/pill/lib/PillAvatar.js +1 -1
  45. package/dist/es6/pill/lib/PillCount.js +1 -1
  46. package/dist/es6/pill/lib/PillIcon.js +1 -1
  47. package/dist/es6/pill/lib/PillIconButton.js +1 -1
  48. package/dist/es6/pill/lib/PillLabel.js +1 -1
  49. package/dist/es6/radio/lib/RadioGroup.js +3 -3
  50. package/dist/es6/radio/lib/RadioLabel.js +1 -1
  51. package/dist/es6/radio/lib/RadioText.js +4 -4
  52. package/dist/es6/radio/lib/StyledRadioButton.js +5 -5
  53. package/dist/es6/segmented-control/lib/SegmentedControlItem.js +16 -16
  54. package/dist/es6/segmented-control/lib/SegmentedControlList.js +4 -4
  55. package/dist/es6/side-panel/lib/SidePanel.js +7 -7
  56. package/dist/es6/side-panel/lib/SidePanelToggleButton.js +11 -11
  57. package/dist/es6/status-indicator/lib/StatusIndicator.js +13 -13
  58. package/dist/es6/status-indicator/lib/StatusIndicatorLabel.js +1 -1
  59. package/index.ts +0 -1
  60. package/package.json +4 -4
  61. package/dist/commonjs/menu/index.d.ts +0 -3
  62. package/dist/commonjs/menu/index.d.ts.map +0 -1
  63. package/dist/commonjs/menu/index.js +0 -18
  64. package/dist/commonjs/menu/lib/Menu.d.ts +0 -78
  65. package/dist/commonjs/menu/lib/Menu.d.ts.map +0 -1
  66. package/dist/commonjs/menu/lib/Menu.js +0 -277
  67. package/dist/commonjs/menu/lib/MenuItem.d.ts +0 -75
  68. package/dist/commonjs/menu/lib/MenuItem.d.ts.map +0 -1
  69. package/dist/commonjs/menu/lib/MenuItem.js +0 -249
  70. package/dist/es6/menu/index.d.ts +0 -3
  71. package/dist/es6/menu/index.d.ts.map +0 -1
  72. package/dist/es6/menu/index.js +0 -2
  73. package/dist/es6/menu/lib/Menu.d.ts +0 -78
  74. package/dist/es6/menu/lib/Menu.d.ts.map +0 -1
  75. package/dist/es6/menu/lib/Menu.js +0 -247
  76. package/dist/es6/menu/lib/MenuItem.d.ts +0 -75
  77. package/dist/es6/menu/lib/MenuItem.d.ts.map +0 -1
  78. package/dist/es6/menu/lib/MenuItem.js +0 -219
  79. package/menu/index.ts +0 -2
  80. package/menu/lib/Menu.tsx +0 -368
  81. package/menu/lib/MenuItem.tsx +0 -351
  82. package/menu/package.json +0 -6
@@ -1,351 +0,0 @@
1
- import * as React from 'react';
2
- import styled from '@emotion/styled';
3
- import {
4
- colors,
5
- commonColors,
6
- iconColors,
7
- typeColors,
8
- space,
9
- type,
10
- } from '@workday/canvas-kit-react/tokens';
11
- import {CanvasSystemIcon} from '@workday/design-assets-types';
12
- import {SystemIcon, SystemIconProps} from '@workday/canvas-kit-react/icon';
13
-
14
- /**
15
- * @deprecated ⚠️ `DeprecatedMenuItemProps` has been deprecated and will be removed in a future major version. Please use [Menu in Main](https://workday.github.io/canvas-kit/?path=/docs/components-popups-menu--basic) instead.
16
- */
17
- export interface DeprecatedMenuItemProps extends React.LiHTMLAttributes<HTMLLIElement> {
18
- /**
19
- * The function called when the DeprecatedMenuItem is clicked. If the item is a child of the DeprecatedMenu component, this callback will be decorated with the onSelect and onClose DeprecatedMenu callbacks. This callback will not fire if the item is disabled (see below).
20
- */
21
- onClick?: (event: React.MouseEvent) => void;
22
- /**
23
- * The unique id for the DeprecatedMenuItem used for ARIA attributes. If the item is a child of the `DeprecatedMenu` component, this property will be generated and overridden.
24
- */
25
- id?: string;
26
- /**
27
- * The icon of the DeprecatedMenuItem. This icon is displayed before what you supplied for the children.
28
- */
29
- icon?: CanvasSystemIcon;
30
- /**
31
- * The secondary icon of the DeprecatedMenuItem. This icon is displayed after what you supplied for the children.
32
- */
33
- secondaryIcon?: CanvasSystemIcon;
34
- /**
35
- * If true, render a top border on the DeprecatedMenuItem.
36
- * @default false
37
- */
38
- hasDivider?: boolean;
39
- /**
40
- * If true, render a header to group data, this menu item will not be intractable.
41
- * @default false
42
- */
43
- isHeader?: boolean;
44
- /**
45
- * If true, set the DeprecatedMenuItem to the disabled state so it is not clickable.
46
- * @default false
47
- */
48
- isDisabled?: boolean;
49
- /**
50
- * If true, set the DeprecatedMenuItem to be the currently selected item. If the item is a child of the DeprecatedMenu component, this property will be generated and overridden.
51
- * @default false
52
- */
53
- isFocused?: boolean;
54
- /**
55
- * The role of the DeprecatedMenuItem. Use this to override the role of the item (e.g. you can use this element as an option in a Combobox).
56
- * @default menuItem
57
- */
58
- role?: string;
59
- /**
60
- * If true, allow the onClose DeprecatedMenu callback to be fired after the DeprecatedMenuItem has been clicked.
61
- * @default true
62
- */
63
- shouldClose?: boolean;
64
- }
65
-
66
- const Item = styled('li')<Pick<DeprecatedMenuItemProps, 'isDisabled' | 'isFocused' | 'isHeader'>>(
67
- {
68
- ...type.levels.subtext.large,
69
- padding: `${space.xxs} ${space.s}`,
70
- height: space.xl,
71
- boxSizing: 'border-box',
72
- cursor: 'pointer',
73
- color: colors.blackPepper300,
74
- display: 'flex',
75
- flexDirection: 'row',
76
- alignItems: 'center',
77
- transition: 'background-color 80ms, color 80ms',
78
- '&:focus': {
79
- outline: 'none',
80
- },
81
- },
82
- ({isHeader}) => {
83
- return {pointerEvents: isHeader ? 'none' : 'all'};
84
- },
85
- ({isFocused, isDisabled}) => {
86
- if (!isFocused && !isDisabled) {
87
- return {
88
- backgroundColor: 'inherit',
89
- '&:hover': {
90
- backgroundColor: commonColors.hoverBackground,
91
- color: colors.blackPepper300,
92
- '.wd-icon-fill, .wd-icon-accent, .wd-icon-accent2': {
93
- fill: iconColors.hover,
94
- },
95
- },
96
- };
97
- } else if (isDisabled && !isFocused) {
98
- return {
99
- color: colors.licorice100,
100
- cursor: 'default',
101
- };
102
- } else {
103
- // Is focused or focused and disabled
104
- return {
105
- backgroundColor: isDisabled ? colors.blueberry200 : commonColors.focusBackground,
106
- color: typeColors.inverse,
107
- 'span .wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
108
- fill: isDisabled ? iconColors.disabled : iconColors.active,
109
- },
110
- '&:hover': {
111
- 'span .wd-icon-fill, span .wd-icon-accent, span .wd-icon-accent2': {
112
- fill: iconColors.inverse,
113
- },
114
- 'span .wd-icon-background ~ .wd-icon-accent, span .wd-icon-background ~ .wd-icon-accent2':
115
- {
116
- fill: isDisabled ? iconColors.disabled : iconColors.active,
117
- },
118
- 'span .wd-icon-background': {
119
- fill: iconColors.inverse,
120
- },
121
- },
122
- [`[data-whatinput='mouse'] &,
123
- [data-whatinput='touch'] &,
124
- [data-whatinput='pointer'] &`]: {
125
- backgroundColor: 'inherit',
126
- color: colors.blackPepper300,
127
- 'span .wd-icon-background ~ .wd-icon-accent, span .wd-icon-background ~ .wd-icon-accent2':
128
- {
129
- fill: iconColors.standard,
130
- },
131
- '&:hover': {
132
- backgroundColor: commonColors.hoverBackground,
133
- 'span .wd-icon-fill, span .wd-icon-accent, span .wd-icon-accent2': {
134
- fill: iconColors.hover,
135
- },
136
- },
137
- '.wd-icon-fill, .wd-icon-accent, .wd-icon-accent2': {
138
- fill: iconColors.standard,
139
- },
140
- },
141
- };
142
- }
143
- }
144
- );
145
-
146
- const LabelContainer = styled('span')({
147
- flex: '1 1 auto',
148
- overflow: 'hidden',
149
- whiteSpace: 'nowrap',
150
- textOverflow: 'ellipsis',
151
- });
152
-
153
- const Divider = styled('hr')({
154
- display: 'block',
155
- height: 1,
156
- border: 0,
157
- borderTop: `1px solid ${colors.soap400}`,
158
- margin: `${space.xxs} 0`,
159
- });
160
-
161
- const iconSize = 24;
162
- const iconPadding = 16;
163
- const StyledSystemIcon = styled(SystemIcon)({
164
- minWidth: iconSize + iconPadding, // gives padding between LabelContainer, no matter the direction
165
- });
166
-
167
- const SecondaryStyledSystemIcon = styled(SystemIcon)({
168
- display: `flex`,
169
- minWidth: iconSize + iconPadding, // gives padding between LabelContainer, no matter the direction
170
- justifyContent: `flex-end`,
171
- });
172
-
173
- let iconProps: SystemIconProps | null = null;
174
- let secondaryIconProps: SystemIconProps | null = null;
175
- const setIconProps = (
176
- icon?: CanvasSystemIcon,
177
- isDisabled?: boolean,
178
- isFocused?: boolean
179
- ): SystemIconProps | null => {
180
- if (!icon) {
181
- return null;
182
- }
183
- let props: SystemIconProps = {
184
- icon: icon,
185
- size: iconSize,
186
- };
187
- if (isDisabled) {
188
- props = {
189
- ...props,
190
- fill: iconColors.disabled,
191
- fillHover: iconColors.disabled,
192
- accent: iconColors.disabled,
193
- accentHover: iconColors.disabled,
194
- };
195
- }
196
- if (isFocused) {
197
- props = {
198
- ...props,
199
- fill: iconColors.inverse,
200
- fillHover: iconColors.inverse,
201
- accent: iconColors.inverse,
202
- accentHover: iconColors.inverse,
203
- background: iconColors.inverse,
204
- };
205
- }
206
- return props;
207
- };
208
-
209
- const scrollIntoViewIfNeeded = (elem: HTMLElement, centerIfNeeded = true): void => {
210
- const parent: HTMLElement | null = elem.parentElement;
211
-
212
- if (elem && parent) {
213
- const parentComputedStyle = window.getComputedStyle(parent, null),
214
- parentBorderTopWidth = parseInt(parentComputedStyle.getPropertyValue('border-top-width'), 10),
215
- parentBorderLeftWidth = parseInt(
216
- parentComputedStyle.getPropertyValue('border-left-width'),
217
- 10
218
- ),
219
- overTop = elem.offsetTop - parent.offsetTop < parent.scrollTop,
220
- overBottom =
221
- elem.offsetTop - parent.offsetTop + elem.clientHeight - parentBorderTopWidth >
222
- parent.scrollTop + parent.clientHeight,
223
- overLeft = elem.offsetLeft - parent.offsetLeft < parent.scrollLeft,
224
- overRight =
225
- elem.offsetLeft - parent.offsetLeft + elem.clientWidth - parentBorderLeftWidth >
226
- parent.scrollLeft + parent.clientWidth,
227
- alignWithTop = overTop && !overBottom;
228
-
229
- if ((overTop || overBottom) && centerIfNeeded) {
230
- parent.scrollTop =
231
- elem.offsetTop -
232
- parent.offsetTop -
233
- parent.clientHeight / 2 -
234
- parentBorderTopWidth +
235
- elem.clientHeight / 2;
236
- }
237
-
238
- if ((overLeft || overRight) && centerIfNeeded) {
239
- parent.scrollLeft =
240
- elem.offsetLeft -
241
- parent.offsetLeft -
242
- parent.clientWidth / 2 -
243
- parentBorderLeftWidth +
244
- elem.clientWidth / 2;
245
- }
246
-
247
- if ((overTop || overBottom || overLeft || overRight) && !centerIfNeeded) {
248
- elem.scrollIntoView(alignWithTop);
249
- }
250
- }
251
- };
252
-
253
- /**
254
- * `DeprecatedMenuItem` renders an `<li>` element with the correct attributes to ensure it is
255
- * accessible. If you choose to implement your own custom menu items, be sure to use semantic `<li>`
256
- * elements with the following attributes:
257
- *
258
- * - `role="menuitem"`
259
- * - `tabindex={-1}`
260
- * - `id`s following this pattern: `${MenuId}-${index}`
261
- *
262
- * Undocumented props are spread to the underlying `<li>` element.
263
- *
264
- * @deprecated ⚠️ `DeprecatedMenuItem` has been deprecated and will be removed in a future major version. Please use [Menu in Main](https://workday.github.io/canvas-kit/?path=/docs/components-popups-menu--basic) instead.
265
- *
266
- */
267
- export class DeprecatedMenuItem extends React.Component<DeprecatedMenuItemProps> {
268
- ref = React.createRef<HTMLLIElement>();
269
-
270
- componentDidMount() {
271
- console.warn(
272
- `This component is being deprecated and will be removed in a future major version.\n
273
- For more information, please see the V8 upgrade guide:\n
274
- https://workday.github.io/canvas-kit/?path=/docs/guides-upgrade-guides-v8-0--docs#menu-preview
275
- `
276
- );
277
- }
278
-
279
- componentDidUpdate = (prevProps: DeprecatedMenuItemProps) => {
280
- if (!prevProps.isFocused && this.props.isFocused) {
281
- if (this.ref.current) {
282
- scrollIntoViewIfNeeded(this.ref.current);
283
- }
284
- }
285
- };
286
-
287
- render() {
288
- const {
289
- onClick,
290
- children,
291
- id,
292
- icon,
293
- secondaryIcon,
294
- hasDivider,
295
- isDisabled,
296
- isFocused,
297
- isHeader,
298
- role,
299
- ...elemProps
300
- } = this.props;
301
-
302
- iconProps = setIconProps(icon, isDisabled, isFocused);
303
- secondaryIconProps = setIconProps(secondaryIcon, isDisabled, isFocused);
304
-
305
- return (
306
- <>
307
- {hasDivider && <Divider aria-hidden="true" />}
308
- <Item
309
- ref={this.ref}
310
- tabIndex={-1}
311
- id={id}
312
- role={isHeader ? 'presentation' : role}
313
- aria-hidden={isHeader ? true : undefined}
314
- onClick={this.handleClick}
315
- aria-disabled={isDisabled ? true : undefined}
316
- isDisabled={!!isDisabled}
317
- isFocused={!!isFocused}
318
- isHeader={!!isHeader}
319
- {...elemProps}
320
- >
321
- {icon && iconProps && <StyledSystemIcon {...iconProps} />}
322
- <LabelContainer>{children}</LabelContainer>
323
- {secondaryIcon && secondaryIconProps && (
324
- <SecondaryStyledSystemIcon {...secondaryIconProps} />
325
- )}
326
- </Item>
327
- </>
328
- );
329
- }
330
-
331
- private handleClick = (event: React.MouseEvent): void => {
332
- if (this.props.isDisabled) {
333
- return;
334
- }
335
- if (this.props.onClick) {
336
- this.props.onClick(event);
337
- }
338
- };
339
- }
340
-
341
- /**
342
- * If we destructure props, shouldClose will be undefined because the value is only applied for the render method only.
343
- * We have to use defaultProps so that the value of shouldClose is applied for every method and therefore references in the Menu component.
344
- * For reference: https://github.com/Workday/canvas-kit/blob/f6d4d29e9bb2eb2af0b204e6f4ce2e5ed5a98e57/modules/_labs/menu/react/lib/Menu.tsx#L259,
345
- */
346
- // TODO: Remove this ts-ignore when we convert to a functional component
347
- // @ts-ignore
348
- DeprecatedMenuItem.defaultProps = {
349
- shouldClose: true,
350
- role: 'menuitem',
351
- };
package/menu/package.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "main": "../dist/commonjs/menu",
3
- "module": "../dist/es6/menu",
4
- "sideEffects": false,
5
- "types": "../dist/es6/menu"
6
- }