@workday/canvas-kit-preview-react 9.0.0-alpha.364-next.3 → 9.0.0-alpha.382-next.2

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 (97) hide show
  1. package/dist/commonjs/color-picker/lib/ColorPicker.js +24 -47
  2. package/dist/commonjs/color-picker/lib/parts/ColorReset.js +32 -23
  3. package/dist/commonjs/color-picker/lib/parts/SwatchBook.js +26 -39
  4. package/dist/commonjs/form-field/lib/FormField.js +10 -33
  5. package/dist/commonjs/form-field/lib/FormFieldHint.js +8 -31
  6. package/dist/commonjs/form-field/lib/FormFieldInput.js +6 -17
  7. package/dist/commonjs/form-field/lib/FormFieldLabel.js +8 -31
  8. package/dist/commonjs/form-field/lib/hooks/useFormFieldHint.js +4 -5
  9. package/dist/commonjs/form-field/lib/hooks/useFormFieldInput.js +5 -6
  10. package/dist/commonjs/form-field/lib/hooks/useFormFieldLabel.js +4 -5
  11. package/dist/commonjs/form-field/lib/hooks/useFormFieldModel.js +8 -16
  12. package/dist/commonjs/form-field/lib/hooks/useFormFieldOrientation.js +3 -3
  13. package/dist/commonjs/menu/lib/Menu.js +96 -129
  14. package/dist/commonjs/menu/lib/MenuItem.js +94 -109
  15. package/dist/commonjs/pill/lib/Pill.js +55 -60
  16. package/dist/commonjs/pill/lib/PillAvatar.js +6 -17
  17. package/dist/commonjs/pill/lib/PillCount.js +7 -30
  18. package/dist/commonjs/pill/lib/PillIcon.js +8 -31
  19. package/dist/commonjs/pill/lib/PillIconButton.js +13 -36
  20. package/dist/commonjs/pill/lib/PillLabel.js +10 -33
  21. package/dist/commonjs/pill/lib/usePillModel.js +8 -16
  22. package/dist/commonjs/segmented-control/lib/SegmentedControl.js +6 -7
  23. package/dist/commonjs/segmented-control/lib/SegmentedControlItem.js +24 -49
  24. package/dist/commonjs/segmented-control/lib/SegmentedControlList.js +13 -38
  25. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.js +8 -10
  26. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.js +31 -31
  27. package/dist/commonjs/select/lib/Select.js +147 -189
  28. package/dist/commonjs/select/lib/SelectBase.js +106 -101
  29. package/dist/commonjs/select/lib/SelectMenu.js +53 -84
  30. package/dist/commonjs/select/lib/SelectOption.js +33 -47
  31. package/dist/commonjs/select/lib/scrolling.js +6 -7
  32. package/dist/commonjs/select/lib/utils.js +4 -4
  33. package/dist/commonjs/side-panel/lib/SidePanel.js +36 -51
  34. package/dist/commonjs/side-panel/lib/SidePanelToggleButton.js +17 -40
  35. package/dist/commonjs/side-panel/lib/hooks.js +20 -20
  36. package/dist/commonjs/status-indicator/lib/StatusIndicator.js +10 -34
  37. package/dist/commonjs/status-indicator/lib/StatusIndicatorIcon.js +9 -21
  38. package/dist/commonjs/status-indicator/lib/StatusIndicatorLabel.js +5 -28
  39. package/dist/commonjs/status-indicator/lib/hooks/useStatusIndicatorModel.js +6 -15
  40. package/dist/commonjs/text-area/lib/TextArea.js +8 -31
  41. package/dist/commonjs/text-area/lib/TextAreaField.d.ts.map +1 -1
  42. package/dist/commonjs/text-area/lib/TextAreaField.js +12 -36
  43. package/dist/commonjs/text-input/lib/TextInput.js +8 -31
  44. package/dist/commonjs/text-input/lib/TextInputField.d.ts.map +1 -1
  45. package/dist/commonjs/text-input/lib/TextInputField.js +12 -24
  46. package/dist/commonjs/text-input/lib/hooks/useTextInputField.js +3 -3
  47. package/dist/commonjs/text-input/lib/hooks/useTextInputModel.js +1 -1
  48. package/dist/es6/color-picker/lib/ColorPicker.js +15 -38
  49. package/dist/es6/color-picker/lib/parts/ColorReset.js +27 -18
  50. package/dist/es6/color-picker/lib/parts/SwatchBook.js +21 -34
  51. package/dist/es6/form-field/lib/FormField.js +4 -27
  52. package/dist/es6/form-field/lib/FormFieldHint.js +4 -27
  53. package/dist/es6/form-field/lib/FormFieldInput.js +3 -14
  54. package/dist/es6/form-field/lib/FormFieldLabel.js +4 -27
  55. package/dist/es6/form-field/lib/hooks/useFormFieldHint.js +2 -3
  56. package/dist/es6/form-field/lib/hooks/useFormFieldInput.js +3 -4
  57. package/dist/es6/form-field/lib/hooks/useFormFieldLabel.js +2 -3
  58. package/dist/es6/form-field/lib/hooks/useFormFieldModel.js +8 -16
  59. package/dist/es6/form-field/lib/hooks/useFormFieldOrientation.js +2 -2
  60. package/dist/es6/menu/lib/Menu.js +91 -125
  61. package/dist/es6/menu/lib/MenuItem.js +90 -106
  62. package/dist/es6/pill/lib/Pill.js +45 -50
  63. package/dist/es6/pill/lib/PillAvatar.js +3 -14
  64. package/dist/es6/pill/lib/PillCount.js +4 -27
  65. package/dist/es6/pill/lib/PillIcon.js +3 -26
  66. package/dist/es6/pill/lib/PillIconButton.js +7 -30
  67. package/dist/es6/pill/lib/PillLabel.js +5 -28
  68. package/dist/es6/pill/lib/usePillModel.js +8 -16
  69. package/dist/es6/segmented-control/lib/SegmentedControl.js +2 -3
  70. package/dist/es6/segmented-control/lib/SegmentedControlItem.js +17 -42
  71. package/dist/es6/segmented-control/lib/SegmentedControlList.js +9 -34
  72. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.js +5 -7
  73. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.js +29 -29
  74. package/dist/es6/select/lib/Select.js +144 -186
  75. package/dist/es6/select/lib/SelectBase.js +99 -94
  76. package/dist/es6/select/lib/SelectMenu.js +49 -80
  77. package/dist/es6/select/lib/SelectOption.js +30 -44
  78. package/dist/es6/select/lib/scrolling.js +6 -7
  79. package/dist/es6/select/lib/utils.js +4 -4
  80. package/dist/es6/side-panel/lib/SidePanel.js +31 -46
  81. package/dist/es6/side-panel/lib/SidePanelToggleButton.js +10 -33
  82. package/dist/es6/side-panel/lib/hooks.js +19 -19
  83. package/dist/es6/status-indicator/lib/StatusIndicator.js +5 -29
  84. package/dist/es6/status-indicator/lib/StatusIndicatorIcon.js +6 -18
  85. package/dist/es6/status-indicator/lib/StatusIndicatorLabel.js +3 -26
  86. package/dist/es6/status-indicator/lib/hooks/useStatusIndicatorModel.js +6 -15
  87. package/dist/es6/text-area/lib/TextArea.js +4 -27
  88. package/dist/es6/text-area/lib/TextAreaField.d.ts.map +1 -1
  89. package/dist/es6/text-area/lib/TextAreaField.js +9 -33
  90. package/dist/es6/text-input/lib/TextInput.js +4 -27
  91. package/dist/es6/text-input/lib/TextInputField.d.ts.map +1 -1
  92. package/dist/es6/text-input/lib/TextInputField.js +9 -21
  93. package/dist/es6/text-input/lib/hooks/useTextInputField.js +1 -1
  94. package/dist/es6/text-input/lib/hooks/useTextInputModel.js +1 -1
  95. package/package.json +3 -4
  96. package/text-area/lib/TextAreaField.tsx +6 -2
  97. package/text-input/lib/TextInputField.tsx +6 -2
@@ -1,40 +1,17 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
1
  import React from 'react';
24
2
  import { createSubcomponent, useTheme } from '@workday/canvas-kit-react/common';
25
3
  import { space } from '@workday/canvas-kit-react/tokens';
26
4
  import { useFormFieldHint, useFormFieldModel } from './hooks';
27
5
  import { Subtext } from '@workday/canvas-kit-react/text';
28
- export var FormFieldHint = createSubcomponent('p')({
6
+ export const FormFieldHint = createSubcomponent('p')({
29
7
  displayName: 'FormField.Hint',
30
8
  modelHook: useFormFieldModel,
31
9
  elemPropsHook: useFormFieldHint,
32
- })(function (_a, Element, model) {
33
- var children = _a.children, elemProps = __rest(_a, ["children"]);
34
- var theme = useTheme();
10
+ })(({ children, ...elemProps }, Element, model) => {
11
+ const theme = useTheme();
35
12
  if (!children) {
36
13
  // If there is no hint text just skip rendering
37
14
  return null;
38
15
  }
39
- return (React.createElement(Subtext, __assign({ as: Element, size: "medium", color: model.state.hasError ? theme.canvas.palette.error.main : undefined, marginY: space.xxs }, elemProps), children));
16
+ return (React.createElement(Subtext, Object.assign({ as: Element, size: "medium", color: model.state.hasError ? theme.canvas.palette.error.main : undefined, marginY: space.xxs }, elemProps), children));
40
17
  });
@@ -1,22 +1,11 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  import React from 'react';
13
2
  import { createSubcomponent } from '@workday/canvas-kit-react/common';
14
3
  import { Box } from '@workday/canvas-kit-react/layout';
15
4
  import { useFormFieldInput, useFormFieldModel } from './hooks';
16
- export var FormFieldInput = createSubcomponent('input')({
5
+ export const FormFieldInput = createSubcomponent('input')({
17
6
  displayName: 'FormField.Input',
18
7
  modelHook: useFormFieldModel,
19
8
  elemPropsHook: useFormFieldInput,
20
- })(function (elemProps, Element) {
21
- return React.createElement(Box, __assign({ as: Element }, elemProps));
9
+ })((elemProps, Element) => {
10
+ return React.createElement(Box, Object.assign({ as: Element }, elemProps));
22
11
  });
@@ -1,38 +1,15 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
1
  import React from 'react';
24
2
  import { createSubcomponent, useTheme } from '@workday/canvas-kit-react/common';
25
3
  import { Flex } from '@workday/canvas-kit-react/layout';
26
4
  import { LabelText, Text } from '@workday/canvas-kit-react/text';
27
5
  import { useFormFieldLabel, useFormFieldModel } from './hooks';
28
- export var FormFieldLabel = createSubcomponent('label')({
6
+ export const FormFieldLabel = createSubcomponent('label')({
29
7
  displayName: 'FormField.Label',
30
8
  modelHook: useFormFieldModel,
31
9
  elemPropsHook: useFormFieldLabel,
32
- })(function (_a, Element, model) {
33
- var _b = _a.gap, gap = _b === void 0 ? 'xxxs' : _b, children = _a.children, elemProps = __rest(_a, ["gap", "children"]);
34
- var theme = useTheme();
35
- return (React.createElement(Flex, __assign({ as: Element, gap: gap, minWidth: "180px" }, elemProps),
10
+ })(({ gap = 'xxxs', children, ...elemProps }, Element, model) => {
11
+ const theme = useTheme();
12
+ return (React.createElement(Flex, Object.assign({ as: Element, gap: gap, minWidth: "180px" }, elemProps),
36
13
  React.createElement(LabelText, { as: "span", fontWeight: "medium" }, children),
37
14
  model.state.isRequired && (React.createElement(Text, { fontSize: 20, fontWeight: "regular", textDecoration: "unset", color: theme.canvas.palette.error.main, "aria-hidden": "true" }, "*"))));
38
15
  });
@@ -4,9 +4,8 @@ import { useFormFieldModel } from './useFormFieldModel';
4
4
  * Adds the necessary props to a `Hint` component.
5
5
  * Used by the FormField.Hint subcomponent and other input type components
6
6
  */
7
- export var useFormFieldHint = createElemPropsHook(useFormFieldModel)(function (_a) {
8
- var state = _a.state;
7
+ export const useFormFieldHint = createElemPropsHook(useFormFieldModel)(({ state }) => {
9
8
  return {
10
- id: "hint-" + state.id,
9
+ id: `hint-${state.id}`,
11
10
  };
12
11
  });
@@ -4,12 +4,11 @@ import { useFormFieldModel } from './useFormFieldModel';
4
4
  * Adds the necessary props to an `Input` component.
5
5
  * Used by the FormField.Input subcomponent and other input type components
6
6
  */
7
- export var useFormFieldInput = createElemPropsHook(useFormFieldModel)(function (_a) {
8
- var state = _a.state;
7
+ export const useFormFieldInput = createElemPropsHook(useFormFieldModel)(({ state }) => {
9
8
  return {
10
9
  required: state.isRequired ? true : undefined,
11
10
  'aria-invalid': state.hasError ? true : undefined,
12
- 'aria-describedby': "hint-" + state.id,
13
- id: "input-" + state.id,
11
+ 'aria-describedby': `hint-${state.id}`,
12
+ id: `input-${state.id}`,
14
13
  };
15
14
  });
@@ -4,9 +4,8 @@ import { useFormFieldModel } from './useFormFieldModel';
4
4
  * Adds the necessary props to a `Label` component.
5
5
  * Used by the FormField.Label subcomponent and other input type components
6
6
  */
7
- export var useFormFieldLabel = createElemPropsHook(useFormFieldModel)(function (_a) {
8
- var state = _a.state;
7
+ export const useFormFieldLabel = createElemPropsHook(useFormFieldModel)(({ state }) => {
9
8
  return {
10
- htmlFor: "input-" + state.id,
9
+ htmlFor: `input-${state.id}`,
11
10
  };
12
11
  });
@@ -1,16 +1,5 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  import { createModelHook, useUniqueId } from '@workday/canvas-kit-react/common';
13
- export var useFormFieldModel = createModelHook({
2
+ export const useFormFieldModel = createModelHook({
14
3
  defaultConfig: {
15
4
  /**
16
5
  * Optional flag to denote if this field has an error to display. When true the `FormField.Input` will have
@@ -34,11 +23,14 @@ export var useFormFieldModel = createModelHook({
34
23
  */
35
24
  isRequired: false,
36
25
  },
37
- })(function (config) {
38
- var id = useUniqueId(config.id);
39
- var state = __assign(__assign({}, config), { id: id });
26
+ })(config => {
27
+ const id = useUniqueId(config.id);
28
+ const state = {
29
+ ...config,
30
+ id,
31
+ };
40
32
  return {
41
- state: state,
33
+ state,
42
34
  events: {},
43
35
  };
44
36
  });
@@ -2,8 +2,8 @@ import { space } from '@workday/canvas-kit-react/tokens';
2
2
  /**
3
3
  * Adds the necessary layout props to a `FormField` component.
4
4
  */
5
- export var useFormFieldOrientation = function (orientation) {
6
- var layoutProps;
5
+ export const useFormFieldOrientation = (orientation) => {
6
+ let layoutProps;
7
7
  if (orientation === 'horizontal') {
8
8
  layoutProps = {
9
9
  flexDirection: 'row',
@@ -1,48 +1,18 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- var __assign = (this && this.__assign) || function () {
17
- __assign = Object.assign || function(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
- t[p] = s[p];
22
- }
23
- return t;
24
- };
25
- return __assign.apply(this, arguments);
26
- };
27
- var __rest = (this && this.__rest) || function (s, e) {
28
- var t = {};
29
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
- t[p] = s[p];
31
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
- t[p[i]] = s[p[i]];
35
- }
36
- return t;
37
- };
38
1
  import * as React from 'react';
39
2
  import styled from '@emotion/styled';
40
3
  import { Card } from '@workday/canvas-kit-react/card';
41
4
  import { commonColors, space, borderRadius } from '@workday/canvas-kit-react/tokens';
42
5
  import { hideMouseFocus, generateUniqueId } from '@workday/canvas-kit-react/common';
43
- var List = styled('ul')(__assign({ background: commonColors.background, borderRadius: borderRadius.m, padding: 0, margin: space.xxs + " 0", '&:focus': {
6
+ const List = styled('ul')({
7
+ background: commonColors.background,
8
+ borderRadius: borderRadius.m,
9
+ padding: 0,
10
+ margin: `${space.xxs} 0`,
11
+ '&:focus': {
44
12
  outline: 'none',
45
- } }, hideMouseFocus));
13
+ },
14
+ ...hideMouseFocus,
15
+ });
46
16
  /**
47
17
  * As of Canvas Kit v8, this component is being soft-deprecated. It will be hard-deprecated
48
18
  * (completely removed) in v9. Please see the [upgrade
@@ -58,46 +28,45 @@ var List = styled('ul')(__assign({ background: commonColors.background, borderRa
58
28
  *
59
29
  * @deprecated
60
30
  */
61
- var DeprecatedMenu = /** @class */ (function (_super) {
62
- __extends(DeprecatedMenu, _super);
63
- function DeprecatedMenu(props) {
64
- var _this = _super.call(this, props) || this;
65
- _this.id = generateUniqueId();
66
- _this.getNormalizedItemIndex = function (index) {
67
- var itemCount = React.Children.count(_this.props.children);
68
- var firstItem = 0;
69
- var lastItem = itemCount - 1;
31
+ export class DeprecatedMenu extends React.Component {
32
+ constructor(props) {
33
+ super(props);
34
+ this.id = generateUniqueId();
35
+ this.getNormalizedItemIndex = (index) => {
36
+ const itemCount = React.Children.count(this.props.children);
37
+ const firstItem = 0;
38
+ const lastItem = itemCount - 1;
70
39
  if (!index) {
71
40
  return firstItem;
72
41
  }
73
42
  return index < 0 ? firstItem : index >= itemCount ? lastItem : index;
74
43
  };
75
- _this.setNormalizedItemIndex = function (index) {
76
- _this.setState({ selectedItemIndex: _this.getNormalizedItemIndex(index) });
44
+ this.setNormalizedItemIndex = (index) => {
45
+ this.setState({ selectedItemIndex: this.getNormalizedItemIndex(index) });
77
46
  };
78
- _this.handleKeyboardShortcuts = function (event) {
47
+ this.handleKeyboardShortcuts = (event) => {
79
48
  if (event.ctrlKey || event.altKey || event.metaKey) {
80
49
  return;
81
50
  }
82
- var children = React.Children.toArray(_this.props.children);
83
- var nextSelectedIndex = 0;
84
- var isShortcut = false;
85
- var interactiveItems = children.filter(function (child) {
51
+ const children = React.Children.toArray(this.props.children);
52
+ let nextSelectedIndex = 0;
53
+ let isShortcut = false;
54
+ const interactiveItems = children.filter(child => {
86
55
  var _a, _b;
87
56
  return !((_b = (_a = child) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.isHeader);
88
57
  });
89
- var interactiveItemCount = interactiveItems.length;
90
- var firstIndex = 0;
91
- var lastIndex = interactiveItemCount - 1;
58
+ const interactiveItemCount = interactiveItems.length;
59
+ const firstIndex = 0;
60
+ const lastIndex = interactiveItemCount - 1;
92
61
  if (event.key.length === 1 && event.key.match(/\S/)) {
93
- var start = _this.state.selectedItemIndex + 1;
94
- var searchIndex = void 0;
62
+ let start = this.state.selectedItemIndex + 1;
63
+ let searchIndex;
95
64
  if (start === children.length) {
96
65
  start = 0;
97
66
  }
98
- searchIndex = _this.getIndexFirstChars(start, event.key.toLowerCase());
67
+ searchIndex = this.getIndexFirstChars(start, event.key.toLowerCase());
99
68
  if (searchIndex === -1) {
100
- searchIndex = _this.getIndexFirstChars(0, event.key.toLowerCase(), start);
69
+ searchIndex = this.getIndexFirstChars(0, event.key.toLowerCase(), start);
101
70
  }
102
71
  if (searchIndex > -1) {
103
72
  isShortcut = true;
@@ -108,48 +77,48 @@ var DeprecatedMenu = /** @class */ (function (_super) {
108
77
  switch (event.key) {
109
78
  case 'ArrowUp':
110
79
  case 'ArrowDown':
111
- var direction = event.key === 'ArrowUp' ? -1 : 1;
80
+ const direction = event.key === 'ArrowUp' ? -1 : 1;
112
81
  isShortcut = true;
113
- var nextIndex = _this.state.selectedItemIndex + direction;
82
+ const nextIndex = this.state.selectedItemIndex + direction;
114
83
  nextSelectedIndex =
115
84
  nextIndex < 0 ? lastIndex : nextIndex >= interactiveItemCount ? firstIndex : nextIndex;
116
85
  break;
117
86
  case 'Home':
118
87
  case 'End':
119
- var skipTo = event.key === 'Home' ? firstIndex : lastIndex;
88
+ const skipTo = event.key === 'Home' ? firstIndex : lastIndex;
120
89
  isShortcut = true;
121
90
  nextSelectedIndex = skipTo;
122
91
  break;
123
92
  case 'Tab':
124
- if (_this.props.onClose) {
125
- _this.props.onClose();
93
+ if (this.props.onClose) {
94
+ this.props.onClose();
126
95
  }
127
96
  break;
128
97
  case 'Escape':
129
98
  case 'Esc': // IE/Edge specific value
130
99
  isShortcut = true;
131
- if (_this.props.onClose) {
132
- _this.props.onClose();
100
+ if (this.props.onClose) {
101
+ this.props.onClose();
133
102
  }
134
103
  break;
135
104
  case 'Spacebar':
136
105
  case ' ':
137
106
  case 'Enter':
138
- nextSelectedIndex = _this.state.selectedItemIndex;
139
- var child = interactiveItems[_this.state.selectedItemIndex];
140
- _this.handleClick(event, child.props);
107
+ nextSelectedIndex = this.state.selectedItemIndex;
108
+ const child = interactiveItems[this.state.selectedItemIndex];
109
+ this.handleClick(event, child.props);
141
110
  isShortcut = true;
142
111
  break;
143
112
  default:
144
113
  }
145
114
  }
146
115
  if (isShortcut) {
147
- _this.setNormalizedItemIndex(nextSelectedIndex);
116
+ this.setNormalizedItemIndex(nextSelectedIndex);
148
117
  event.stopPropagation();
149
118
  event.preventDefault();
150
119
  }
151
120
  };
152
- _this.handleClick = function (event, menuItemProps) {
121
+ this.handleClick = (event, menuItemProps) => {
153
122
  /* istanbul ignore next line for coverage */
154
123
  if (menuItemProps.isDisabled) {
155
124
  // You should only hit this point if you are using a custom DeprecatedMenuItem implementation.
@@ -158,27 +127,26 @@ var DeprecatedMenu = /** @class */ (function (_super) {
158
127
  if (menuItemProps.onClick) {
159
128
  menuItemProps.onClick(event);
160
129
  }
161
- if (_this.props.onSelect) {
162
- _this.props.onSelect();
130
+ if (this.props.onSelect) {
131
+ this.props.onSelect();
163
132
  }
164
- if (_this.props.onClose) {
133
+ if (this.props.onClose) {
165
134
  if (menuItemProps.shouldClose) {
166
- _this.props.onClose();
135
+ this.props.onClose();
167
136
  }
168
137
  }
169
138
  };
170
- _this.getIndexFirstChars = function (startIndex, character, lastIndex) {
171
- if (lastIndex === void 0) { lastIndex = _this.firstCharacters.length; }
172
- for (var i = startIndex; i < lastIndex; i++) {
173
- if (character === _this.firstCharacters[i]) {
139
+ this.getIndexFirstChars = (startIndex, character, lastIndex = this.firstCharacters.length) => {
140
+ for (let i = startIndex; i < lastIndex; i++) {
141
+ if (character === this.firstCharacters[i]) {
174
142
  return i;
175
143
  }
176
144
  }
177
145
  return -1;
178
146
  };
179
- _this.setFirstCharacters = function () {
180
- var getFirstCharacter = function (child) {
181
- var character = '';
147
+ this.setFirstCharacters = () => {
148
+ const getFirstCharacter = (child) => {
149
+ let character = '';
182
150
  if (!child || typeof child === 'boolean') {
183
151
  character = '';
184
152
  }
@@ -194,7 +162,7 @@ var DeprecatedMenu = /** @class */ (function (_super) {
194
162
  character = getFirstCharacter(child[0]);
195
163
  }
196
164
  else if ('props' in child) {
197
- var children = child.props.children;
165
+ const { children } = child.props;
198
166
  if (Array.isArray(children)) {
199
167
  character = getFirstCharacter(children[0]);
200
168
  }
@@ -204,43 +172,41 @@ var DeprecatedMenu = /** @class */ (function (_super) {
204
172
  }
205
173
  return character;
206
174
  };
207
- var firstCharacters = React.Children.map(_this.props.children, function (child) {
175
+ const firstCharacters = React.Children.map(this.props.children, child => {
208
176
  var _a, _b;
209
177
  if ((_b = (_a = child) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.isHeader) {
210
178
  return;
211
179
  }
212
180
  return getFirstCharacter(child);
213
181
  });
214
- _this.firstCharacters = firstCharacters;
182
+ this.firstCharacters = firstCharacters;
215
183
  };
216
- _this.getInitialSelectedItem = function () {
217
- var selected = _this.props.initialSelectedItem || 0;
218
- selected = selected < 0 ? React.Children.count(_this.props.children) + selected : selected;
184
+ this.getInitialSelectedItem = () => {
185
+ let selected = this.props.initialSelectedItem || 0;
186
+ selected = selected < 0 ? React.Children.count(this.props.children) + selected : selected;
219
187
  if (selected < 0) {
220
188
  selected = 0;
221
189
  }
222
- else if (selected > React.Children.count(_this.props.children) - 1) {
223
- selected = React.Children.count(_this.props.children) - 1;
190
+ else if (selected > React.Children.count(this.props.children) - 1) {
191
+ selected = React.Children.count(this.props.children) - 1;
224
192
  }
225
193
  return selected;
226
194
  };
227
- _this.setInitialSelectedItem = function () {
228
- var selected = _this.getInitialSelectedItem();
229
- _this.setState({ selectedItemIndex: selected });
195
+ this.setInitialSelectedItem = () => {
196
+ const selected = this.getInitialSelectedItem();
197
+ this.setState({ selectedItemIndex: selected });
230
198
  };
231
- _this.menuRef = React.createRef();
232
- var selected = _this.getInitialSelectedItem();
199
+ this.menuRef = React.createRef();
200
+ const selected = this.getInitialSelectedItem();
233
201
  // We track the active menu item by index so we can avoid setting a bunch of refs
234
202
  // for doing things like selecting an item by first character (or really calling .focus() at all)
235
203
  // It allows us to use the activedescendant design pattern
236
204
  // https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions-active-descendant.html
237
- _this.state = {
205
+ this.state = {
238
206
  selectedItemIndex: selected,
239
207
  };
240
- return _this;
241
208
  }
242
- DeprecatedMenu.prototype.componentDidUpdate = function (prevProps) {
243
- var _this = this;
209
+ componentDidUpdate(prevProps) {
244
210
  if (this.props.children !== prevProps.children) {
245
211
  this.setFirstCharacters();
246
212
  this.setInitialSelectedItem();
@@ -248,45 +214,45 @@ var DeprecatedMenu = /** @class */ (function (_super) {
248
214
  if (this.props.isOpen && !prevProps.isOpen) {
249
215
  this.setInitialSelectedItem();
250
216
  }
251
- this.animateId = requestAnimationFrame(function () {
252
- if (_this.props.isOpen && _this.menuRef.current) {
253
- _this.menuRef.current.focus();
217
+ this.animateId = requestAnimationFrame(() => {
218
+ if (this.props.isOpen && this.menuRef.current) {
219
+ this.menuRef.current.focus();
254
220
  }
255
221
  });
256
- };
257
- DeprecatedMenu.prototype.componentDidMount = function () {
258
- console.warn("This component is being deprecated and will be removed in Canvas Kit V9.\n\n For more information, please see the V8 upgrade guide:\n\n https://workday.github.io/canvas-kit/?path=/story/welcome-upgrade-guides-v8-0--page\n ");
222
+ }
223
+ componentDidMount() {
224
+ console.warn(`This component is being deprecated and will be removed in Canvas Kit V9.\n
225
+ For more information, please see the V8 upgrade guide:\n
226
+ https://workday.github.io/canvas-kit/?path=/story/welcome-upgrade-guides-v8-0--page
227
+ `);
259
228
  this.setFirstCharacters();
260
229
  this.setInitialSelectedItem();
261
- };
262
- DeprecatedMenu.prototype.componentWillUnmount = function () {
230
+ }
231
+ componentWillUnmount() {
263
232
  cancelAnimationFrame(this.animateId);
264
- };
265
- DeprecatedMenu.prototype.render = function () {
266
- var _this = this;
233
+ }
234
+ render() {
267
235
  // TODO: Standardize on prop spread location (see #150)
268
- var _a = this.props, _b = _a.id, id = _b === void 0 ? this.id : _b, _c = _a.isOpen, isOpen = _c === void 0 ? true : _c, children = _a.children, ariaLabelledby = _a["aria-labelledby"], grow = _a.grow, width = _a.width, onSelect = _a.onSelect, onClose = _a.onClose, initialSelectedItem = _a.initialSelectedItem, elemProps = __rest(_a, ["id", "isOpen", "children", 'aria-labelledby', "grow", "width", "onSelect", "onClose", "initialSelectedItem"]);
269
- var selectedItemIndex = this.state.selectedItemIndex;
270
- var cardWidth = grow ? '100%' : width;
271
- var interactiveItemIndex = null;
236
+ const { id = this.id, isOpen = true, children, 'aria-labelledby': ariaLabelledby, grow, width, onSelect, onClose, initialSelectedItem, ...elemProps } = this.props;
237
+ const { selectedItemIndex } = this.state;
238
+ const cardWidth = grow ? '100%' : width;
239
+ let interactiveItemIndex = null;
272
240
  return (React.createElement(Card, { display: "inline-block", padding: space.zero, width: cardWidth, depth: 3 },
273
241
  React.createElement(Card.Body, null,
274
- React.createElement(List, __assign({ role: "menu", tabIndex: 0, id: id, "aria-labelledby": ariaLabelledby, "aria-activedescendant": id + "-" + selectedItemIndex, onKeyDown: this.handleKeyboardShortcuts, ref: this.menuRef }, elemProps), React.Children.map(children, function (menuItem) {
242
+ React.createElement(List, Object.assign({ role: "menu", tabIndex: 0, id: id, "aria-labelledby": ariaLabelledby, "aria-activedescendant": `${id}-${selectedItemIndex}`, onKeyDown: this.handleKeyboardShortcuts, ref: this.menuRef }, elemProps), React.Children.map(children, menuItem => {
275
243
  if (!React.isValidElement(menuItem)) {
276
244
  return;
277
245
  }
278
- var itemId;
246
+ let itemId;
279
247
  if (!menuItem.props.isHeader) {
280
248
  interactiveItemIndex = (interactiveItemIndex !== null && interactiveItemIndex !== void 0 ? interactiveItemIndex : -1) + 1;
281
- itemId = id + "-" + interactiveItemIndex;
249
+ itemId = `${id}-${interactiveItemIndex}`;
282
250
  }
283
251
  return (React.createElement(React.Fragment, { key: itemId }, React.cloneElement(menuItem, {
284
- onClick: function (event) { return _this.handleClick(event, menuItem.props); },
252
+ onClick: (event) => this.handleClick(event, menuItem.props),
285
253
  id: itemId,
286
254
  isFocused: selectedItemIndex === interactiveItemIndex && !menuItem.props.isHeader,
287
255
  })));
288
256
  })))));
289
- };
290
- return DeprecatedMenu;
291
- }(React.Component));
292
- export { DeprecatedMenu };
257
+ }
258
+ }