@workday/canvas-kit-preview-react 10.0.0-alpha.516-next.0 → 10.0.0-alpha.517-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.
@@ -1,5 +1,6 @@
1
1
  export * from './color-picker';
2
2
  export * from './form-field';
3
+ export * from './menu';
3
4
  export * from './pill';
4
5
  export * from './segmented-control';
5
6
  export * from './select';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
@@ -12,6 +12,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./color-picker"), exports);
14
14
  __exportStar(require("./form-field"), exports);
15
+ __exportStar(require("./menu"), exports);
15
16
  __exportStar(require("./pill"), exports);
16
17
  __exportStar(require("./segmented-control"), exports);
17
18
  __exportStar(require("./select"), exports);
@@ -0,0 +1,3 @@
1
+ export * from './lib/Menu';
2
+ export * from './lib/MenuItem';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../menu/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,14 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./lib/Menu"), exports);
14
+ __exportStar(require("./lib/MenuItem"), exports);
@@ -0,0 +1,92 @@
1
+ import * as React from 'react';
2
+ import { DeprecatedMenuItemProps } from './MenuItem';
3
+ import { GrowthBehavior } from '@workday/canvas-kit-react/common';
4
+ /**
5
+ * ### Deprecated Menu
6
+ *
7
+ * As of Canvas Kit v8, Menu is being deprecated.
8
+ * It will be removed in a future major version. Please see the
9
+ * [upgrade guide](https://workday.github.io/canvas-kit/?path=/story/welcome-upgrade-guides-v8-0--page)
10
+ * for more information.
11
+ */
12
+ export interface DeprecatedMenuProps extends GrowthBehavior, React.HTMLAttributes<HTMLUListElement> {
13
+ /**
14
+ * The DeprecatedMenuItem children of the DeprecatedMenu (must be at least one). Also accepts other components which share the same interface as `DeprecatedMenuItem`.
15
+ */
16
+ children?: React.ReactElement<DeprecatedMenuItemProps> | React.ReactElement<DeprecatedMenuItemProps>[];
17
+ /**
18
+ * If true, set the DeprecatedMenu to the open state. Useful for showing and hiding the DeprecatedMenu from a parent component such as a menu button.
19
+ * @default true
20
+ */
21
+ isOpen?: boolean;
22
+ /**
23
+ * The width of the DeprecatedMenu. If no value is provided, the DeprecatedMenu will collapse around its content.
24
+ */
25
+ width?: number | string;
26
+ /**
27
+ * The function called when a menu item is selected.
28
+ */
29
+ onSelect?: () => void;
30
+ /**
31
+ * The function called when the DeprecatedMenu should close. This is called after a menu item is selected or if the escape shortcut key is used. This will not fire if the menu item sets `shouldClose` to false.
32
+ */
33
+ onClose?: () => void;
34
+ /**
35
+ * The zero-based index of the menu item which should initially receive focus.
36
+ */
37
+ initialSelectedItem?: number;
38
+ /**
39
+ * The unique id of the DeprecatedMenu used for ARIA and HTML `id` attributes.
40
+ */
41
+ id?: string;
42
+ /**
43
+ * The HTML `id` of the element that labels the DeprecatedMenu. Often used with menu buttons.
44
+ */
45
+ 'aria-labelledby'?: string;
46
+ }
47
+ /**
48
+ * ### Deprecated Menu State
49
+ *
50
+ * As of Canvas Kit v8, Menu is being deprecated.
51
+ * It will be removed in a future major version. Please see the
52
+ * [upgrade guide](https://workday.github.io/canvas-kit/?path=/story/welcome-upgrade-guides-v8-0--page)
53
+ * for more information.
54
+ */
55
+ export interface DeprecatedMenuState {
56
+ selectedItemIndex: number;
57
+ }
58
+ /**
59
+ * As of Canvas Kit v8, Menu is being deprecated.
60
+ * It will be removed in a future major version. Please see the [upgrade
61
+ * guide](https://workday.github.io/canvas-kit/?path=/story/welcome-upgrade-guides-v8-0--page) for
62
+ * more information.
63
+ *
64
+ * `DeprecatedMenu` renders a styled `<ul role="menu">` element within a {@link Card} and follows
65
+ * the [Active Menu
66
+ * pattern](https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions-active-descendant.html)
67
+ * using `aria-activedescendant`.
68
+ *
69
+ * Undocumented props are spread to the underlying `<ul>` element.
70
+ *
71
+ * @deprecated
72
+ */
73
+ export declare class DeprecatedMenu extends React.Component<DeprecatedMenuProps, DeprecatedMenuState> {
74
+ private id;
75
+ private animateId;
76
+ private menuRef;
77
+ private firstCharacters;
78
+ constructor(props: DeprecatedMenuProps);
79
+ componentDidUpdate(prevProps: DeprecatedMenuProps): void;
80
+ componentDidMount(): void;
81
+ componentWillUnmount(): void;
82
+ render(): JSX.Element;
83
+ getNormalizedItemIndex: (index: number | undefined) => number;
84
+ setNormalizedItemIndex: (index: number | undefined) => void;
85
+ private handleKeyboardShortcuts;
86
+ private handleClick;
87
+ private getIndexFirstChars;
88
+ private setFirstCharacters;
89
+ private getInitialSelectedItem;
90
+ private setInitialSelectedItem;
91
+ }
92
+ //# sourceMappingURL=Menu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../../menu/lib/Menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAC,uBAAuB,EAAC,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAiB,cAAc,EAAmB,MAAM,kCAAkC,CAAC;AAElG;;;;;;;GAOG;AACH,MAAM,WAAW,mBACf,SAAQ,cAAc,EACpB,KAAK,CAAC,cAAc,CAAC,gBAAgB,CAAC;IACxC;;OAEG;IACH,QAAQ,CAAC,EACL,KAAK,CAAC,YAAY,CAAC,uBAAuB,CAAC,GAC3C,KAAK,CAAC,YAAY,CAAC,uBAAuB,CAAC,EAAE,CAAC;IAClD;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAaD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAe,SAAQ,KAAK,CAAC,SAAS,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;IAC3F,OAAO,CAAC,EAAE,CAAsB;IAChC,OAAO,CAAC,SAAS,CAAU;IAE3B,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,eAAe,CAAY;gBAEvB,KAAK,EAAE,mBAAmB;IAetC,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;IAejD,iBAAiB;IAYjB,oBAAoB;IAIb,MAAM;IAyDN,sBAAsB,UAAW,MAAM,GAAG,SAAS,KAAG,MAAM,CAQjE;IAEK,sBAAsB,UAAW,MAAM,GAAG,SAAS,KAAG,IAAI,CAE/D;IAEF,OAAO,CAAC,uBAAuB,CA+E7B;IAEF,OAAO,CAAC,WAAW,CAoBjB;IAEF,OAAO,CAAC,kBAAkB,CAWxB;IAEF,OAAO,CAAC,kBAAkB,CAkCxB;IAEF,OAAO,CAAC,sBAAsB,CAU5B;IAEF,OAAO,CAAC,sBAAsB,CAG5B;CACH"}
@@ -0,0 +1,284 @@
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.DeprecatedMenu = void 0;
26
+ const React = __importStar(require("react"));
27
+ const styled_1 = __importDefault(require("@emotion/styled"));
28
+ const card_1 = require("@workday/canvas-kit-react/card");
29
+ const tokens_1 = require("@workday/canvas-kit-react/tokens");
30
+ const common_1 = require("@workday/canvas-kit-react/common");
31
+ const List = styled_1.default('ul')({
32
+ background: tokens_1.commonColors.background,
33
+ borderRadius: tokens_1.borderRadius.m,
34
+ padding: 0,
35
+ margin: `${tokens_1.space.xxs} 0`,
36
+ '&:focus': {
37
+ outline: 'none',
38
+ },
39
+ ...common_1.hideMouseFocus,
40
+ });
41
+ /**
42
+ * As of Canvas Kit v8, Menu is being deprecated.
43
+ * It will be removed in a future major version. Please see the [upgrade
44
+ * guide](https://workday.github.io/canvas-kit/?path=/story/welcome-upgrade-guides-v8-0--page) for
45
+ * more information.
46
+ *
47
+ * `DeprecatedMenu` renders a styled `<ul role="menu">` element within a {@link Card} and follows
48
+ * the [Active Menu
49
+ * pattern](https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions-active-descendant.html)
50
+ * using `aria-activedescendant`.
51
+ *
52
+ * Undocumented props are spread to the underlying `<ul>` element.
53
+ *
54
+ * @deprecated
55
+ */
56
+ class DeprecatedMenu extends React.Component {
57
+ constructor(props) {
58
+ super(props);
59
+ this.id = common_1.generateUniqueId();
60
+ this.getNormalizedItemIndex = (index) => {
61
+ const itemCount = React.Children.count(this.props.children);
62
+ const firstItem = 0;
63
+ const lastItem = itemCount - 1;
64
+ if (!index) {
65
+ return firstItem;
66
+ }
67
+ return index < 0 ? firstItem : index >= itemCount ? lastItem : index;
68
+ };
69
+ this.setNormalizedItemIndex = (index) => {
70
+ this.setState({ selectedItemIndex: this.getNormalizedItemIndex(index) });
71
+ };
72
+ this.handleKeyboardShortcuts = (event) => {
73
+ if (event.ctrlKey || event.altKey || event.metaKey) {
74
+ return;
75
+ }
76
+ const children = React.Children.toArray(this.props.children);
77
+ let nextSelectedIndex = 0;
78
+ let isShortcut = false;
79
+ const interactiveItems = children.filter(child => {
80
+ var _a, _b;
81
+ return !((_b = (_a = child) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.isHeader);
82
+ });
83
+ const interactiveItemCount = interactiveItems.length;
84
+ const firstIndex = 0;
85
+ const lastIndex = interactiveItemCount - 1;
86
+ if (event.key.length === 1 && event.key.match(/\S/)) {
87
+ let start = this.state.selectedItemIndex + 1;
88
+ let searchIndex;
89
+ if (start === children.length) {
90
+ start = 0;
91
+ }
92
+ searchIndex = this.getIndexFirstChars(start, event.key.toLowerCase());
93
+ if (searchIndex === -1) {
94
+ searchIndex = this.getIndexFirstChars(0, event.key.toLowerCase(), start);
95
+ }
96
+ if (searchIndex > -1) {
97
+ isShortcut = true;
98
+ nextSelectedIndex = searchIndex;
99
+ }
100
+ }
101
+ else {
102
+ switch (event.key) {
103
+ case 'ArrowUp':
104
+ case 'ArrowDown':
105
+ const direction = event.key === 'ArrowUp' ? -1 : 1;
106
+ isShortcut = true;
107
+ const nextIndex = this.state.selectedItemIndex + direction;
108
+ nextSelectedIndex =
109
+ nextIndex < 0 ? lastIndex : nextIndex >= interactiveItemCount ? firstIndex : nextIndex;
110
+ break;
111
+ case 'Home':
112
+ case 'End':
113
+ const skipTo = event.key === 'Home' ? firstIndex : lastIndex;
114
+ isShortcut = true;
115
+ nextSelectedIndex = skipTo;
116
+ break;
117
+ case 'Tab':
118
+ if (this.props.onClose) {
119
+ this.props.onClose();
120
+ }
121
+ break;
122
+ case 'Escape':
123
+ case 'Esc': // IE/Edge specific value
124
+ isShortcut = true;
125
+ if (this.props.onClose) {
126
+ this.props.onClose();
127
+ }
128
+ break;
129
+ case 'Spacebar':
130
+ case ' ':
131
+ case 'Enter':
132
+ nextSelectedIndex = this.state.selectedItemIndex;
133
+ const child = interactiveItems[this.state.selectedItemIndex];
134
+ this.handleClick(event, child.props);
135
+ isShortcut = true;
136
+ break;
137
+ default:
138
+ }
139
+ }
140
+ if (isShortcut) {
141
+ this.setNormalizedItemIndex(nextSelectedIndex);
142
+ event.stopPropagation();
143
+ event.preventDefault();
144
+ }
145
+ };
146
+ this.handleClick = (event, menuItemProps) => {
147
+ /* istanbul ignore next line for coverage */
148
+ if (menuItemProps.isDisabled) {
149
+ // You should only hit this point if you are using a custom DeprecatedMenuItem implementation.
150
+ return;
151
+ }
152
+ if (menuItemProps.onClick) {
153
+ menuItemProps.onClick(event);
154
+ }
155
+ if (this.props.onSelect) {
156
+ this.props.onSelect();
157
+ }
158
+ if (this.props.onClose) {
159
+ if (menuItemProps.shouldClose) {
160
+ this.props.onClose();
161
+ }
162
+ }
163
+ };
164
+ this.getIndexFirstChars = (startIndex, character, lastIndex = this.firstCharacters.length) => {
165
+ for (let i = startIndex; i < lastIndex; i++) {
166
+ if (character === this.firstCharacters[i]) {
167
+ return i;
168
+ }
169
+ }
170
+ return -1;
171
+ };
172
+ this.setFirstCharacters = () => {
173
+ const getFirstCharacter = (child) => {
174
+ let character = '';
175
+ if (!child || typeof child === 'boolean') {
176
+ character = '';
177
+ }
178
+ else if (typeof child === 'string' || typeof child === 'number') {
179
+ character = child
180
+ .toString()
181
+ .trim()
182
+ .substring(0, 1)
183
+ .toLowerCase();
184
+ }
185
+ else if (Array.isArray(child) && child[0]) {
186
+ // TODO test React.ReactNodeArray
187
+ character = getFirstCharacter(child[0]);
188
+ }
189
+ else if ('props' in child) {
190
+ const { children } = child.props;
191
+ if (Array.isArray(children)) {
192
+ character = getFirstCharacter(children[0]);
193
+ }
194
+ else {
195
+ character = getFirstCharacter(children);
196
+ }
197
+ }
198
+ return character;
199
+ };
200
+ const firstCharacters = React.Children.map(this.props.children, child => {
201
+ var _a, _b;
202
+ if ((_b = (_a = child) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.isHeader) {
203
+ return;
204
+ }
205
+ return getFirstCharacter(child);
206
+ });
207
+ this.firstCharacters = firstCharacters;
208
+ };
209
+ this.getInitialSelectedItem = () => {
210
+ let selected = this.props.initialSelectedItem || 0;
211
+ selected = selected < 0 ? React.Children.count(this.props.children) + selected : selected;
212
+ if (selected < 0) {
213
+ selected = 0;
214
+ }
215
+ else if (selected > React.Children.count(this.props.children) - 1) {
216
+ selected = React.Children.count(this.props.children) - 1;
217
+ }
218
+ return selected;
219
+ };
220
+ this.setInitialSelectedItem = () => {
221
+ const selected = this.getInitialSelectedItem();
222
+ this.setState({ selectedItemIndex: selected });
223
+ };
224
+ this.menuRef = React.createRef();
225
+ const selected = this.getInitialSelectedItem();
226
+ // We track the active menu item by index so we can avoid setting a bunch of refs
227
+ // for doing things like selecting an item by first character (or really calling .focus() at all)
228
+ // It allows us to use the activedescendant design pattern
229
+ // https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions-active-descendant.html
230
+ this.state = {
231
+ selectedItemIndex: selected,
232
+ };
233
+ }
234
+ componentDidUpdate(prevProps) {
235
+ if (this.props.children !== prevProps.children) {
236
+ this.setFirstCharacters();
237
+ this.setInitialSelectedItem();
238
+ }
239
+ if (this.props.isOpen && !prevProps.isOpen) {
240
+ this.setInitialSelectedItem();
241
+ }
242
+ this.animateId = requestAnimationFrame(() => {
243
+ if (this.props.isOpen && this.menuRef.current) {
244
+ this.menuRef.current.focus();
245
+ }
246
+ });
247
+ }
248
+ componentDidMount() {
249
+ console.warn(`This component is being deprecated and will be removed in a future major version.\n
250
+ For more information, please see the V8 upgrade guide:\n
251
+ https://workday.github.io/canvas-kit/?path=/story/welcome-upgrade-guides-v8-0--page
252
+ `);
253
+ this.setFirstCharacters();
254
+ this.setInitialSelectedItem();
255
+ }
256
+ componentWillUnmount() {
257
+ cancelAnimationFrame(this.animateId);
258
+ }
259
+ render() {
260
+ // TODO: Standardize on prop spread location (see #150)
261
+ const { id = this.id, isOpen = true, children, 'aria-labelledby': ariaLabelledby, grow, width, onSelect, onClose, initialSelectedItem, ...elemProps } = this.props;
262
+ const { selectedItemIndex } = this.state;
263
+ const cardWidth = grow ? '100%' : width;
264
+ let interactiveItemIndex = null;
265
+ return (React.createElement(card_1.Card, { display: "inline-block", padding: tokens_1.space.zero, width: cardWidth, depth: 3 },
266
+ React.createElement(card_1.Card.Body, null,
267
+ 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 => {
268
+ if (!React.isValidElement(menuItem)) {
269
+ return;
270
+ }
271
+ let itemId;
272
+ if (!menuItem.props.isHeader) {
273
+ interactiveItemIndex = (interactiveItemIndex !== null && interactiveItemIndex !== void 0 ? interactiveItemIndex : -1) + 1;
274
+ itemId = `${id}-${interactiveItemIndex}`;
275
+ }
276
+ return (React.createElement(React.Fragment, { key: itemId }, React.cloneElement(menuItem, {
277
+ onClick: (event) => this.handleClick(event, menuItem.props),
278
+ id: itemId,
279
+ isFocused: selectedItemIndex === interactiveItemIndex && !menuItem.props.isHeader,
280
+ })));
281
+ })))));
282
+ }
283
+ }
284
+ exports.DeprecatedMenu = DeprecatedMenu;
@@ -0,0 +1,84 @@
1
+ import * as React from 'react';
2
+ import { CanvasSystemIcon } from '@workday/design-assets-types';
3
+ /**
4
+ * ### Deprecated Menu Item Props
5
+ *
6
+ * As of Canvas Kit v8, Menu is being deprecated.
7
+ * It will be removed in a future major version. Please see the
8
+ * [upgrade guide](https://workday.github.io/canvas-kit/?path=/story/welcome-upgrade-guides-v8-0--page)
9
+ * for more information.
10
+ */
11
+ export interface DeprecatedMenuItemProps extends React.LiHTMLAttributes<HTMLLIElement> {
12
+ /**
13
+ * 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).
14
+ */
15
+ onClick?: (event: React.MouseEvent) => void;
16
+ /**
17
+ * 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.
18
+ */
19
+ id?: string;
20
+ /**
21
+ * The icon of the DeprecatedMenuItem. This icon is displayed before what you supplied for the children.
22
+ */
23
+ icon?: CanvasSystemIcon;
24
+ /**
25
+ * The secondary icon of the DeprecatedMenuItem. This icon is displayed after what you supplied for the children.
26
+ */
27
+ secondaryIcon?: CanvasSystemIcon;
28
+ /**
29
+ * If true, render a top border on the DeprecatedMenuItem.
30
+ * @default false
31
+ */
32
+ hasDivider?: boolean;
33
+ /**
34
+ * If true, render a header to group data, this menu item will not be intractable.
35
+ * @default false
36
+ */
37
+ isHeader?: boolean;
38
+ /**
39
+ * If true, set the DeprecatedMenuItem to the disabled state so it is not clickable.
40
+ * @default false
41
+ */
42
+ isDisabled?: boolean;
43
+ /**
44
+ * 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.
45
+ * @default false
46
+ */
47
+ isFocused?: boolean;
48
+ /**
49
+ * 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).
50
+ * @default menuItem
51
+ */
52
+ role?: string;
53
+ /**
54
+ * If true, allow the onClose DeprecatedMenu callback to be fired after the DeprecatedMenuItem has been clicked.
55
+ * @default true
56
+ */
57
+ shouldClose?: boolean;
58
+ }
59
+ /**
60
+ * `DeprecatedMenuItem` renders an `<li>` element with the correct attributes to ensure it is
61
+ * accessible. If you choose to implement your own custom menu items, be sure to use semantic `<li>`
62
+ * elements with the following attributes:
63
+ *
64
+ * - `role="menuitem"`
65
+ * - `tabindex={-1}`
66
+ * - `id`s following this pattern: `${MenuId}-${index}`
67
+ *
68
+ * As of Canvas Kit v8, Menu is being deprecated.
69
+ * It will be removed in a future major version. Please see the [upgrade
70
+ * guide](https://workday.github.io/canvas-kit/?path=/story/welcome-upgrade-guides-v8-0--page) for
71
+ * more information.
72
+ *
73
+ * Undocumented props are spread to the underlying `<li>` element.
74
+ *
75
+ * @deprecated
76
+ */
77
+ export declare class DeprecatedMenuItem extends React.Component<DeprecatedMenuItemProps> {
78
+ ref: React.RefObject<HTMLLIElement>;
79
+ componentDidMount(): void;
80
+ componentDidUpdate: (prevProps: DeprecatedMenuItemProps) => void;
81
+ render(): JSX.Element;
82
+ private handleClick;
83
+ }
84
+ //# sourceMappingURL=MenuItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItem.d.ts","sourceRoot":"","sources":["../../../../menu/lib/MenuItem.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAG9D;;;;;;;GAOG;AACH,MAAM,WAAW,uBAAwB,SAAQ,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC;IACpF;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAC5C;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;OAEG;IACH,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AA2LD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,kBAAmB,SAAQ,KAAK,CAAC,SAAS,CAAC,uBAAuB,CAAC;IAC9E,GAAG,iCAAoC;IAEvC,iBAAiB;IASjB,kBAAkB,cAAe,uBAAuB,UAMtD;IAEF,MAAM;IA4CN,OAAO,CAAC,WAAW,CAOjB;CACH"}