@instructure/ui-menu 8.8.0 → 8.8.1-snapshot.63
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.
- package/LICENSE.md +27 -0
- package/es/Menu/MenuItem/index.js +14 -60
- package/es/Menu/MenuItem/props.js +67 -0
- package/es/Menu/MenuItemGroup/index.js +10 -57
- package/es/Menu/MenuItemGroup/props.js +71 -0
- package/es/Menu/MenuItemSeparator/index.js +5 -8
- package/{src/Menu/MenuItemSeparator/types.ts → es/Menu/MenuItemSeparator/props.js} +5 -5
- package/es/Menu/index.js +5 -151
- package/es/Menu/props.js +167 -0
- package/lib/Menu/MenuItem/index.js +15 -62
- package/lib/Menu/MenuItem/props.js +79 -0
- package/lib/Menu/MenuItemGroup/index.js +11 -62
- package/lib/Menu/MenuItemGroup/props.js +87 -0
- package/lib/Menu/MenuItemSeparator/index.js +6 -9
- package/{src/Menu/MenuItemGroup/types.ts → lib/Menu/MenuItemSeparator/props.js} +13 -16
- package/lib/Menu/index.js +6 -156
- package/lib/Menu/props.js +182 -0
- package/package.json +22 -21
- package/src/Menu/MenuItem/index.tsx +14 -56
- package/src/Menu/MenuItem/props.ts +109 -0
- package/src/Menu/MenuItem/styles.ts +1 -1
- package/src/Menu/MenuItem/theme.ts +1 -1
- package/src/Menu/MenuItemGroup/index.tsx +9 -56
- package/src/Menu/MenuItemGroup/props.ts +110 -0
- package/src/Menu/MenuItemGroup/theme.ts +1 -1
- package/src/Menu/MenuItemSeparator/index.tsx +6 -9
- package/src/Menu/{MenuItem/types.ts → MenuItemSeparator/props.ts} +19 -19
- package/src/Menu/MenuItemSeparator/theme.ts +1 -1
- package/src/Menu/index.tsx +6 -139
- package/src/Menu/props.ts +235 -0
- package/src/Menu/theme.ts +1 -1
- package/src/index.ts +4 -4
- package/types/Menu/MenuItem/index.d.ts +37 -45
- package/types/Menu/MenuItem/index.d.ts.map +1 -1
- package/types/Menu/MenuItem/props.d.ts +27 -0
- package/types/Menu/MenuItem/props.d.ts.map +1 -0
- package/types/Menu/MenuItem/styles.d.ts +1 -1
- package/types/Menu/MenuItem/theme.d.ts +1 -1
- package/types/Menu/MenuItem/theme.d.ts.map +1 -1
- package/types/Menu/MenuItemGroup/index.d.ts +29 -46
- package/types/Menu/MenuItemGroup/index.d.ts.map +1 -1
- package/types/Menu/MenuItemGroup/props.d.ts +25 -0
- package/types/Menu/MenuItemGroup/props.d.ts.map +1 -0
- package/types/Menu/MenuItemGroup/theme.d.ts +1 -1
- package/types/Menu/MenuItemGroup/theme.d.ts.map +1 -1
- package/types/Menu/MenuItemSeparator/index.d.ts +3 -6
- package/types/Menu/MenuItemSeparator/index.d.ts.map +1 -1
- package/types/Menu/MenuItemSeparator/props.d.ts +11 -0
- package/types/Menu/MenuItemSeparator/props.d.ts.map +1 -0
- package/types/Menu/MenuItemSeparator/theme.d.ts +1 -1
- package/types/Menu/MenuItemSeparator/theme.d.ts.map +1 -1
- package/types/Menu/index.d.ts +60 -122
- package/types/Menu/index.d.ts.map +1 -1
- package/types/Menu/{types.d.ts → props.d.ts} +13 -5
- package/types/Menu/props.d.ts.map +1 -0
- package/types/Menu/theme.d.ts +1 -1
- package/types/Menu/theme.d.ts.map +1 -1
- package/types/index.d.ts +4 -4
- package/es/Menu/MenuItem/types.js +0 -1
- package/es/Menu/MenuItemGroup/types.js +0 -1
- package/es/Menu/MenuItemSeparator/types.js +0 -1
- package/es/Menu/types.js +0 -1
- package/lib/Menu/MenuItem/types.js +0 -1
- package/lib/Menu/MenuItemGroup/types.js +0 -1
- package/lib/Menu/MenuItemSeparator/types.js +0 -1
- package/lib/Menu/types.js +0 -1
- package/src/Menu/types.ts +0 -63
- package/types/Menu/MenuItem/types.d.ts +0 -19
- package/types/Menu/MenuItem/types.d.ts.map +0 -1
- package/types/Menu/MenuItemGroup/types.d.ts +0 -17
- package/types/Menu/MenuItemGroup/types.d.ts.map +0 -1
- package/types/Menu/MenuItemSeparator/types.d.ts +0 -5
- package/types/Menu/MenuItemSeparator/types.d.ts.map +0 -1
- package/types/Menu/types.d.ts.map +0 -1
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
24
|
+
// keeping here to keep the structure of props.ts
|
|
25
|
+
// eslint-disable-next-line
|
|
26
|
+
const propTypes = {};
|
|
27
|
+
const allowedProps = [];
|
|
28
|
+
export { propTypes, allowedProps };
|
package/es/Menu/index.js
CHANGED
|
@@ -26,12 +26,9 @@ var _dec, _dec2, _class, _class2, _temp;
|
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
28
|
import { Children, Component } from 'react';
|
|
29
|
-
import PropTypes from 'prop-types';
|
|
30
29
|
import keycode from 'keycode';
|
|
31
30
|
import { Popover } from '@instructure/ui-popover';
|
|
32
31
|
import { uid } from '@instructure/uid';
|
|
33
|
-
import { controllable, Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
34
|
-
import { PositionPropTypes } from '@instructure/ui-position';
|
|
35
32
|
import { safeCloneElement, matchComponentTypes } from '@instructure/ui-react-utils';
|
|
36
33
|
import { logError as error } from '@instructure/console';
|
|
37
34
|
import { containsActiveElement } from '@instructure/ui-dom-utils';
|
|
@@ -43,6 +40,7 @@ import { MenuItemSeparator } from './MenuItemSeparator';
|
|
|
43
40
|
import { withStyle, jsx } from '@instructure/emotion';
|
|
44
41
|
import generateStyle from './styles';
|
|
45
42
|
import generateComponentTheme from './theme';
|
|
43
|
+
import { propTypes, allowedProps } from './props';
|
|
46
44
|
|
|
47
45
|
/**
|
|
48
46
|
---
|
|
@@ -326,6 +324,8 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
326
324
|
}
|
|
327
325
|
|
|
328
326
|
renderMenu() {
|
|
327
|
+
var _this$props$styles;
|
|
328
|
+
|
|
329
329
|
const _this$props2 = this.props,
|
|
330
330
|
menuRef = _this$props2.menuRef,
|
|
331
331
|
disabled = _this$props2.disabled,
|
|
@@ -346,7 +346,7 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
346
346
|
role: "menu",
|
|
347
347
|
"aria-label": label,
|
|
348
348
|
tabIndex: "0",
|
|
349
|
-
css: this.props.styles.menu,
|
|
349
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.menu,
|
|
350
350
|
"aria-labelledby": labelledBy || trigger && this._labelId,
|
|
351
351
|
"aria-controls": controls,
|
|
352
352
|
"aria-disabled": disabled ? 'true' : null,
|
|
@@ -422,150 +422,7 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
422
422
|
}, this.renderMenu()) : this.renderMenu();
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
}, _class2.displayName = "Menu", _class2.componentId = 'Menu', _class2.propTypes = {
|
|
426
|
-
// eslint-disable-next-line react/require-default-props
|
|
427
|
-
makeStyles: PropTypes.func,
|
|
428
|
-
// eslint-disable-next-line react/require-default-props
|
|
429
|
-
styles: PropTypes.object,
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* Children of type `Menu.Item`, `Menu.Group`, `Menu.Separator`, or `Menu`
|
|
433
|
-
*/
|
|
434
|
-
children: ChildrenPropTypes.oneOf(['MenuItem', 'MenuItemGroup', 'MenuItemSeparator', 'Menu']),
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Description of the `<Menu />`
|
|
438
|
-
*/
|
|
439
|
-
label: PropTypes.string,
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* Is the `<Menu />` disabled
|
|
443
|
-
*/
|
|
444
|
-
disabled: PropTypes.bool,
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* The trigger element, if the `<Menu />` is to render as a popover
|
|
448
|
-
*/
|
|
449
|
-
trigger: PropTypes.node,
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* If a trigger is supplied, where should the `<Menu />` be placed (relative to the trigger)
|
|
453
|
-
*/
|
|
454
|
-
placement: PositionPropTypes.placement,
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Should the `<Menu />` be open for the initial render
|
|
458
|
-
*/
|
|
459
|
-
defaultShow: PropTypes.bool,
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Is the `<Menu />` open (should be accompanied by `onToggle`)
|
|
463
|
-
*/
|
|
464
|
-
show: controllable(PropTypes.bool, 'onToggle', 'defaultShow'),
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* Callback fired when the `<Menu />` is toggled open/closed. When used with `show`,
|
|
468
|
-
* the component will not control its own state.
|
|
469
|
-
*/
|
|
470
|
-
onToggle: PropTypes.func,
|
|
471
|
-
|
|
472
|
-
/**
|
|
473
|
-
* Callback fired when an item within the `<Menu />` is selected
|
|
474
|
-
*/
|
|
475
|
-
onSelect: PropTypes.func,
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* If a trigger is supplied, callback fired when the `<Menu />` is closed
|
|
479
|
-
*/
|
|
480
|
-
onDismiss: PropTypes.func,
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* If a trigger is supplied, callback fired when the `<Menu />` trigger is blurred
|
|
484
|
-
*/
|
|
485
|
-
onBlur: PropTypes.func,
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* If a trigger is supplied, callback fired when the `<Menu />` trigger is focused
|
|
489
|
-
*/
|
|
490
|
-
onFocus: PropTypes.func,
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* If a trigger is supplied, callback fired onMouseOver for the `<Menu />` trigger
|
|
494
|
-
*/
|
|
495
|
-
onMouseOver: PropTypes.func,
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Callback fired on the onKeyDown of the `<Menu />`
|
|
499
|
-
*/
|
|
500
|
-
onKeyDown: PropTypes.func,
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* Callback fired on the onKeyUp of the `<Menu />`
|
|
504
|
-
*/
|
|
505
|
-
onKeyUp: PropTypes.func,
|
|
506
|
-
|
|
507
|
-
/*
|
|
508
|
-
* A function that returns a reference to the `<Menu />`
|
|
509
|
-
*/
|
|
510
|
-
menuRef: PropTypes.func,
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* A function that returns a reference to the `<Popover />`
|
|
514
|
-
*/
|
|
515
|
-
popoverRef: PropTypes.func,
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* If a trigger is supplied, an element or a function returning an element to use as the mount node
|
|
519
|
-
* for the `<Menu />` (defaults to `document.body`)
|
|
520
|
-
*/
|
|
521
|
-
mountNode: PositionPropTypes.mountNode,
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* The parent in which to constrain the menu.
|
|
525
|
-
* One of: 'window', 'scroll-parent', 'parent', 'none', an element,
|
|
526
|
-
* or a function returning an element
|
|
527
|
-
*/
|
|
528
|
-
constrain: PositionPropTypes.constrain,
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* If a trigger is supplied, an element, function returning an element, or array of elements that will not
|
|
532
|
-
* be hidden from the screen reader when the `<Menu />` is open
|
|
533
|
-
*/
|
|
534
|
-
liveRegion: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element, PropTypes.func]),
|
|
535
|
-
|
|
536
|
-
/**
|
|
537
|
-
* If a trigger is supplied, should the `<Menu />` hide when an item is selected
|
|
538
|
-
*/
|
|
539
|
-
shouldHideOnSelect: PropTypes.bool,
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* If a trigger is supplied, should the `<Menu />` focus the trigger on after closing
|
|
543
|
-
*/
|
|
544
|
-
shouldFocusTriggerOnClose: PropTypes.bool,
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* The type of `<Menu />`
|
|
548
|
-
*/
|
|
549
|
-
type: PropTypes.oneOf(['flyout']),
|
|
550
|
-
id: PropTypes.string,
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Whether or not an arrow pointing to the trigger should be rendered
|
|
554
|
-
*/
|
|
555
|
-
withArrow: PropTypes.bool,
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* The horizontal offset for the positioned content.
|
|
559
|
-
* Works only if `trigger` is provided.
|
|
560
|
-
*/
|
|
561
|
-
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* The vertical offset for the positioned content.
|
|
565
|
-
* Works only if `trigger` is provided.
|
|
566
|
-
*/
|
|
567
|
-
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
568
|
-
}, _class2.defaultProps = {
|
|
425
|
+
}, _class2.displayName = "Menu", _class2.componentId = 'Menu', _class2.propTypes = propTypes, _class2.allowedProps = allowedProps, _class2.defaultProps = {
|
|
569
426
|
children: null,
|
|
570
427
|
label: null,
|
|
571
428
|
disabled: false,
|
|
@@ -587,9 +444,6 @@ let Menu = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
587
444
|
liveRegion: null,
|
|
588
445
|
shouldHideOnSelect: true,
|
|
589
446
|
shouldFocusTriggerOnClose: true,
|
|
590
|
-
show: void 0,
|
|
591
|
-
id: void 0,
|
|
592
|
-
type: void 0,
|
|
593
447
|
withArrow: true,
|
|
594
448
|
offsetX: 0,
|
|
595
449
|
offsetY: 0
|
package/es/Menu/props.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import PropTypes from 'prop-types';
|
|
25
|
+
import { PositionPropTypes } from '@instructure/ui-position';
|
|
26
|
+
import { controllable, Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
27
|
+
const propTypes = {
|
|
28
|
+
/**
|
|
29
|
+
* Children of type `Menu.Item`, `Menu.Group`, `Menu.Separator`, or `Menu`
|
|
30
|
+
*/
|
|
31
|
+
children: ChildrenPropTypes.oneOf(['MenuItem', 'MenuItemGroup', 'MenuItemSeparator', 'Menu']),
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Description of the `<Menu />`
|
|
35
|
+
*/
|
|
36
|
+
label: PropTypes.string,
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Is the `<Menu />` disabled
|
|
40
|
+
*/
|
|
41
|
+
disabled: PropTypes.bool,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The trigger element, if the `<Menu />` is to render as a popover
|
|
45
|
+
*/
|
|
46
|
+
trigger: PropTypes.node,
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* If a trigger is supplied, where should the `<Menu />` be placed (relative to the trigger)
|
|
50
|
+
*/
|
|
51
|
+
placement: PositionPropTypes.placement,
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Should the `<Menu />` be open for the initial render
|
|
55
|
+
*/
|
|
56
|
+
defaultShow: PropTypes.bool,
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Is the `<Menu />` open (should be accompanied by `onToggle`)
|
|
60
|
+
*/
|
|
61
|
+
show: controllable(PropTypes.bool, 'onToggle', 'defaultShow'),
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Callback fired when the `<Menu />` is toggled open/closed. When used with `show`,
|
|
65
|
+
* the component will not control its own state.
|
|
66
|
+
*/
|
|
67
|
+
onToggle: PropTypes.func,
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Callback fired when an item within the `<Menu />` is selected
|
|
71
|
+
*/
|
|
72
|
+
onSelect: PropTypes.func,
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* If a trigger is supplied, callback fired when the `<Menu />` is closed
|
|
76
|
+
*/
|
|
77
|
+
onDismiss: PropTypes.func,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* If a trigger is supplied, callback fired when the `<Menu />` trigger is blurred
|
|
81
|
+
*/
|
|
82
|
+
onBlur: PropTypes.func,
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* If a trigger is supplied, callback fired when the `<Menu />` trigger is focused
|
|
86
|
+
*/
|
|
87
|
+
onFocus: PropTypes.func,
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* If a trigger is supplied, callback fired onMouseOver for the `<Menu />` trigger
|
|
91
|
+
*/
|
|
92
|
+
onMouseOver: PropTypes.func,
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Callback fired on the onKeyDown of the `<Menu />`
|
|
96
|
+
*/
|
|
97
|
+
onKeyDown: PropTypes.func,
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Callback fired on the onKeyUp of the `<Menu />`
|
|
101
|
+
*/
|
|
102
|
+
onKeyUp: PropTypes.func,
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A function that returns a reference to the `<Menu />`
|
|
106
|
+
*/
|
|
107
|
+
menuRef: PropTypes.func,
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A function that returns a reference to the `<Popover />`
|
|
111
|
+
*/
|
|
112
|
+
popoverRef: PropTypes.func,
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* If a trigger is supplied, an element or a function returning an element to use as the mount node
|
|
116
|
+
* for the `<Menu />` (defaults to `document.body`)
|
|
117
|
+
*/
|
|
118
|
+
mountNode: PositionPropTypes.mountNode,
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The parent in which to constrain the menu.
|
|
122
|
+
* One of: 'window', 'scroll-parent', 'parent', 'none', an element,
|
|
123
|
+
* or a function returning an element
|
|
124
|
+
*/
|
|
125
|
+
constrain: PositionPropTypes.constrain,
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* If a trigger is supplied, an element, function returning an element, or array of elements that will not
|
|
129
|
+
* be hidden from the screen reader when the `<Menu />` is open
|
|
130
|
+
*/
|
|
131
|
+
liveRegion: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element), PropTypes.element, PropTypes.func]),
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* If a trigger is supplied, should the `<Menu />` hide when an item is selected
|
|
135
|
+
*/
|
|
136
|
+
shouldHideOnSelect: PropTypes.bool,
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* If a trigger is supplied, should the `<Menu />` focus the trigger on after closing
|
|
140
|
+
*/
|
|
141
|
+
shouldFocusTriggerOnClose: PropTypes.bool,
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The type of `<Menu />`
|
|
145
|
+
*/
|
|
146
|
+
type: PropTypes.oneOf(['flyout']),
|
|
147
|
+
id: PropTypes.string,
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Whether or not an arrow pointing to the trigger should be rendered
|
|
151
|
+
*/
|
|
152
|
+
withArrow: PropTypes.bool,
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The horizontal offset for the positioned content.
|
|
156
|
+
* Works only if `trigger` is provided.
|
|
157
|
+
*/
|
|
158
|
+
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The vertical offset for the positioned content.
|
|
162
|
+
* Works only if `trigger` is provided.
|
|
163
|
+
*/
|
|
164
|
+
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
165
|
+
};
|
|
166
|
+
const allowedProps = ['children', 'label', 'disabled', 'trigger', 'placement', 'defaultShow', 'show', 'onToggle', 'onSelect', 'onDismiss', 'onBlur', 'onFocus', 'onMouseOver', 'onKeyDown', 'onKeyUp', 'menuRef', 'popoverRef', 'mountNode', 'constrain', 'liveRegion', 'shouldHideOnSelect', 'shouldFocusTriggerOnClose', 'type', 'id', 'withArrow', 'offsetX', 'offsetY'];
|
|
167
|
+
export { propTypes, allowedProps };
|
|
@@ -9,8 +9,6 @@ exports.MenuItem = exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = require("react");
|
|
11
11
|
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
12
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
15
13
|
|
|
16
14
|
var _IconCheckSolid2 = require("@instructure/ui-icons/lib/IconCheckSolid.js");
|
|
@@ -19,8 +17,6 @@ var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/IconArrowOpenEnd
|
|
|
19
17
|
|
|
20
18
|
var _uid = require("@instructure/uid");
|
|
21
19
|
|
|
22
|
-
var _controllable = require("@instructure/ui-prop-types/lib/controllable.js");
|
|
23
|
-
|
|
24
20
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
25
21
|
|
|
26
22
|
var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
|
|
@@ -41,6 +37,8 @@ var _styles = _interopRequireDefault(require("./styles"));
|
|
|
41
37
|
|
|
42
38
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
43
39
|
|
|
40
|
+
var _props = require("./props");
|
|
41
|
+
|
|
44
42
|
var _dec, _dec2, _class, _class2, _temp, _IconCheckSolid, _IconArrowOpenEndSoli;
|
|
45
43
|
|
|
46
44
|
/**
|
|
@@ -182,20 +180,24 @@ let MenuItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
182
180
|
}
|
|
183
181
|
|
|
184
182
|
renderContent() {
|
|
183
|
+
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
184
|
+
|
|
185
185
|
const _this$props2 = this.props,
|
|
186
186
|
children = _this$props2.children,
|
|
187
187
|
type = _this$props2.type;
|
|
188
188
|
return (0, _emotion.jsx)("span", null, (type === 'checkbox' || type === 'radio') && (0, _emotion.jsx)("span", {
|
|
189
|
-
css: this.props.styles.icon
|
|
189
|
+
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.icon
|
|
190
190
|
}, this.selected && (_IconCheckSolid || (_IconCheckSolid = (0, _emotion.jsx)(_IconCheckSolid2.IconCheckSolid, null)))), (0, _emotion.jsx)("span", {
|
|
191
|
-
css: this.props.styles.label,
|
|
191
|
+
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.label,
|
|
192
192
|
id: this.labelId
|
|
193
193
|
}, children), type === 'flyout' && (0, _emotion.jsx)("span", {
|
|
194
|
-
css: this.props.styles.icon
|
|
194
|
+
css: (_this$props$styles3 = this.props.styles) === null || _this$props$styles3 === void 0 ? void 0 : _this$props$styles3.icon
|
|
195
195
|
}, _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = (0, _emotion.jsx)(_IconArrowOpenEndSolid.IconArrowOpenEndSolid, null))));
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
render() {
|
|
199
|
+
var _this$props$styles4;
|
|
200
|
+
|
|
199
201
|
const _this$props3 = this.props,
|
|
200
202
|
disabled = _this$props3.disabled,
|
|
201
203
|
controls = _this$props3.controls,
|
|
@@ -207,79 +209,30 @@ let MenuItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default),
|
|
|
207
209
|
const ElementType = this.elementType;
|
|
208
210
|
return (0, _emotion.jsx)(ElementType // eslint-disable-line jsx-a11y/mouse-events-have-key-events
|
|
209
211
|
, Object.assign({
|
|
210
|
-
tabIndex:
|
|
212
|
+
tabIndex: -1 // note: tabIndex can be overridden by Menu or MenuItemGroup components
|
|
211
213
|
|
|
212
214
|
}, props, {
|
|
213
215
|
href: href,
|
|
214
216
|
role: this.role,
|
|
215
217
|
"aria-labelledby": this.labelId,
|
|
216
|
-
"aria-disabled": disabled ? 'true' :
|
|
218
|
+
"aria-disabled": disabled ? 'true' : void 0,
|
|
217
219
|
"aria-controls": controls,
|
|
218
|
-
"aria-checked": type === 'checkbox' || type === 'radio' ? this.selected ? 'true' : 'false' :
|
|
220
|
+
"aria-checked": type === 'checkbox' || type === 'radio' ? this.selected ? 'true' : 'false' : void 0,
|
|
219
221
|
onClick: this.handleClick,
|
|
220
222
|
onKeyUp: (0, _createChainedFunction.createChainedFunction)(onKeyUp, this.handleKeyUp),
|
|
221
223
|
onKeyDown: (0, _createChainedFunction.createChainedFunction)(onKeyDown, this.handleKeyDown),
|
|
222
224
|
ref: c => {
|
|
223
225
|
this._node = c;
|
|
224
226
|
},
|
|
225
|
-
css: this.props.styles.menuItem,
|
|
227
|
+
css: (_this$props$styles4 = this.props.styles) === null || _this$props$styles4 === void 0 ? void 0 : _this$props$styles4.menuItem,
|
|
226
228
|
onMouseOver: this.handleMouseOver
|
|
227
229
|
}), this.renderContent());
|
|
228
230
|
}
|
|
229
231
|
|
|
230
|
-
}, _class2.displayName = "MenuItem", _class2.componentId = 'Menu.Item', _class2.propTypes = {
|
|
231
|
-
// eslint-disable-next-line react/require-default-props
|
|
232
|
-
makeStyles: _propTypes.default.func,
|
|
233
|
-
// eslint-disable-next-line react/require-default-props
|
|
234
|
-
styles: _propTypes.default.object,
|
|
235
|
-
|
|
236
|
-
/* the menu item label */
|
|
237
|
-
children: _propTypes.default.node.isRequired,
|
|
238
|
-
|
|
239
|
-
/* whether to set the menu item state to selected or not on initial render */
|
|
240
|
-
defaultSelected: _propTypes.default.bool,
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* whether the menu item is selected or not (must be accompanied by an `onSelect` prop)
|
|
244
|
-
*/
|
|
245
|
-
selected: (0, _controllable.controllable)(_propTypes.default.bool, 'onSelect', 'defaultSelected'),
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* when used with the `selected` prop, the component will not control its own state
|
|
249
|
-
*/
|
|
250
|
-
onSelect: _propTypes.default.func,
|
|
251
|
-
onClick: _propTypes.default.func,
|
|
252
|
-
onKeyDown: _propTypes.default.func,
|
|
253
|
-
onKeyUp: _propTypes.default.func,
|
|
254
|
-
onMouseOver: _propTypes.default.func,
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* the id of the element that the menu item will act upon
|
|
258
|
-
*/
|
|
259
|
-
controls: _propTypes.default.string,
|
|
260
|
-
disabled: _propTypes.default.bool,
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* the element type to render as (will default to `<a>` if href is provided)
|
|
264
|
-
*/
|
|
265
|
-
as: _propTypes.default.elementType,
|
|
266
|
-
// eslint-disable-line react/require-default-props
|
|
267
|
-
type: _propTypes.default.oneOf(['button', 'checkbox', 'radio', 'flyout']),
|
|
268
|
-
value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
|
|
269
|
-
href: _propTypes.default.string
|
|
270
|
-
}, _class2.defaultProps = {
|
|
232
|
+
}, _class2.displayName = "MenuItem", _class2.componentId = 'Menu.Item', _class2.propTypes = _props.propTypes, _class2.allowedProps = _props.allowedProps, _class2.defaultProps = {
|
|
271
233
|
type: 'button',
|
|
272
234
|
disabled: false,
|
|
273
|
-
onSelect: function (e, value, selected, item) {}
|
|
274
|
-
defaultSelected: void 0,
|
|
275
|
-
selected: void 0,
|
|
276
|
-
onClick: void 0,
|
|
277
|
-
onKeyDown: void 0,
|
|
278
|
-
onKeyUp: void 0,
|
|
279
|
-
onMouseOver: void 0,
|
|
280
|
-
controls: void 0,
|
|
281
|
-
value: void 0,
|
|
282
|
-
href: void 0
|
|
235
|
+
onSelect: function (e, value, selected, item) {}
|
|
283
236
|
}, _class2.contextType = _MenuContext.MenuContext, _temp)) || _class) || _class);
|
|
284
237
|
exports.MenuItem = MenuItem;
|
|
285
238
|
var _default = MenuItem;
|