@instructure/ui-menu 11.6.0 → 11.6.1-snapshot-129
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/CHANGELOG.md +41 -297
- package/es/Menu/{MenuItem → v1/MenuItem}/index.js +2 -2
- package/es/Menu/{MenuItemGroup → v1/MenuItemGroup}/index.js +1 -1
- package/es/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/index.js +1 -1
- package/es/Menu/{index.js → v1/index.js} +3 -3
- package/es/Menu/v2/MenuItem/index.js +262 -0
- package/es/Menu/v2/MenuItem/props.js +26 -0
- package/es/Menu/v2/MenuItem/styles.js +146 -0
- package/es/Menu/v2/MenuItemGroup/index.js +175 -0
- package/es/Menu/v2/MenuItemGroup/props.js +26 -0
- package/es/Menu/v2/MenuItemGroup/styles.js +60 -0
- package/es/Menu/v2/MenuItemSeparator/index.js +70 -0
- package/es/Menu/v2/MenuItemSeparator/props.js +29 -0
- package/es/Menu/v2/MenuItemSeparator/styles.js +46 -0
- package/es/Menu/v2/index.js +405 -0
- package/es/Menu/v2/props.js +26 -0
- package/es/Menu/v2/styles.js +61 -0
- package/es/{index.js → exports/a.js} +1 -1
- package/es/exports/b.js +24 -0
- package/es/{MenuContext.js → utils/v1/MenuContext.js} +2 -0
- package/lib/Menu/{MenuItem → v1/MenuItem}/index.js +4 -4
- package/lib/Menu/{MenuItemGroup → v1/MenuItemGroup}/index.js +1 -1
- package/lib/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/index.js +1 -1
- package/lib/Menu/v1/index.js +432 -0
- package/lib/Menu/v2/MenuItem/index.js +271 -0
- package/lib/Menu/v2/MenuItem/props.js +31 -0
- package/lib/Menu/v2/MenuItem/styles.js +152 -0
- package/lib/Menu/v2/MenuItemGroup/index.js +183 -0
- package/lib/Menu/v2/MenuItemGroup/props.js +31 -0
- package/lib/Menu/v2/MenuItemGroup/styles.js +66 -0
- package/lib/Menu/v2/MenuItemSeparator/index.js +75 -0
- package/lib/Menu/v2/MenuItemSeparator/props.js +34 -0
- package/lib/Menu/v2/MenuItemSeparator/styles.js +52 -0
- package/lib/Menu/{index.js → v2/index.js} +4 -5
- package/lib/Menu/v2/props.js +31 -0
- package/lib/Menu/v2/styles.js +66 -0
- package/lib/{index.js → exports/a.js} +5 -5
- package/lib/exports/b.js +30 -0
- package/lib/{MenuContext.js → utils/v1/MenuContext.js} +1 -0
- package/package.json +45 -23
- package/src/Menu/{MenuItem → v1/MenuItem}/index.tsx +2 -2
- package/src/Menu/{MenuItemGroup → v1/MenuItemGroup}/index.tsx +1 -1
- package/src/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/index.tsx +1 -1
- package/src/Menu/{index.tsx → v1/index.tsx} +3 -3
- package/src/Menu/{props.ts → v1/props.ts} +1 -1
- package/src/Menu/v2/MenuItem/index.tsx +318 -0
- package/src/Menu/v2/MenuItem/props.ts +132 -0
- package/src/Menu/v2/MenuItem/styles.ts +172 -0
- package/src/Menu/v2/MenuItemGroup/index.tsx +245 -0
- package/src/Menu/v2/MenuItemGroup/props.ts +105 -0
- package/src/Menu/v2/MenuItemGroup/styles.ts +66 -0
- package/src/Menu/v2/MenuItemSeparator/index.tsx +79 -0
- package/src/Menu/v2/MenuItemSeparator/props.ts +48 -0
- package/src/Menu/v2/MenuItemSeparator/styles.ts +52 -0
- package/src/Menu/v2/README.md +104 -0
- package/src/Menu/v2/index.tsx +514 -0
- package/src/Menu/v2/props.ts +213 -0
- package/src/Menu/v2/styles.ts +68 -0
- package/src/{index.ts → exports/a.ts} +5 -5
- package/src/exports/b.ts +29 -0
- package/src/{MenuContext.ts → utils/v1/MenuContext.ts} +3 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Menu/{MenuItem → v1/MenuItem}/index.d.ts +3 -3
- package/types/Menu/v1/MenuItem/index.d.ts.map +1 -0
- package/types/Menu/v1/MenuItem/props.d.ts.map +1 -0
- package/types/Menu/v1/MenuItem/styles.d.ts.map +1 -0
- package/types/Menu/v1/MenuItem/theme.d.ts.map +1 -0
- package/types/Menu/v1/MenuItemGroup/index.d.ts.map +1 -0
- package/types/Menu/v1/MenuItemGroup/props.d.ts.map +1 -0
- package/types/Menu/v1/MenuItemGroup/styles.d.ts.map +1 -0
- package/types/Menu/v1/MenuItemGroup/theme.d.ts.map +1 -0
- package/types/Menu/v1/MenuItemSeparator/index.d.ts.map +1 -0
- package/types/Menu/v1/MenuItemSeparator/props.d.ts.map +1 -0
- package/types/Menu/v1/MenuItemSeparator/styles.d.ts.map +1 -0
- package/types/Menu/v1/MenuItemSeparator/theme.d.ts.map +1 -0
- package/types/Menu/{index.d.ts → v1/index.d.ts} +3 -3
- package/types/Menu/v1/index.d.ts.map +1 -0
- package/types/Menu/{props.d.ts → v1/props.d.ts} +1 -1
- package/types/Menu/v1/props.d.ts.map +1 -0
- package/types/Menu/v1/styles.d.ts.map +1 -0
- package/types/Menu/v1/theme.d.ts.map +1 -0
- package/types/Menu/v2/MenuItem/index.d.ts +66 -0
- package/types/Menu/v2/MenuItem/index.d.ts.map +1 -0
- package/types/Menu/v2/MenuItem/props.d.ts +73 -0
- package/types/Menu/v2/MenuItem/props.d.ts.map +1 -0
- package/types/Menu/v2/MenuItem/styles.d.ts +15 -0
- package/types/Menu/v2/MenuItem/styles.d.ts.map +1 -0
- package/types/Menu/v2/MenuItemGroup/index.d.ts +52 -0
- package/types/Menu/v2/MenuItemGroup/index.d.ts.map +1 -0
- package/types/Menu/v2/MenuItemGroup/props.d.ts +51 -0
- package/types/Menu/v2/MenuItemGroup/props.d.ts.map +1 -0
- package/types/Menu/v2/MenuItemGroup/styles.d.ts +15 -0
- package/types/Menu/v2/MenuItemGroup/styles.d.ts.map +1 -0
- package/types/Menu/v2/MenuItemSeparator/index.d.ts +21 -0
- package/types/Menu/v2/MenuItemSeparator/index.d.ts.map +1 -0
- package/types/Menu/v2/MenuItemSeparator/props.d.ts +11 -0
- package/types/Menu/v2/MenuItemSeparator/props.d.ts.map +1 -0
- package/types/Menu/v2/MenuItemSeparator/styles.d.ts +15 -0
- package/types/Menu/v2/MenuItemSeparator/styles.d.ts.map +1 -0
- package/types/Menu/v2/index.d.ts +118 -0
- package/types/Menu/v2/index.d.ts.map +1 -0
- package/types/Menu/v2/props.d.ts +138 -0
- package/types/Menu/v2/props.d.ts.map +1 -0
- package/types/Menu/v2/styles.d.ts +15 -0
- package/types/Menu/v2/styles.d.ts.map +1 -0
- package/types/exports/a.d.ts +6 -0
- package/types/exports/a.d.ts.map +1 -0
- package/types/exports/b.d.ts +6 -0
- package/types/exports/b.d.ts.map +1 -0
- package/types/utils/v1/MenuContext.d.ts +13 -0
- package/types/utils/v1/MenuContext.d.ts.map +1 -0
- package/types/Menu/MenuItem/index.d.ts.map +0 -1
- package/types/Menu/MenuItem/props.d.ts.map +0 -1
- package/types/Menu/MenuItem/styles.d.ts.map +0 -1
- package/types/Menu/MenuItem/theme.d.ts.map +0 -1
- package/types/Menu/MenuItemGroup/index.d.ts.map +0 -1
- package/types/Menu/MenuItemGroup/props.d.ts.map +0 -1
- package/types/Menu/MenuItemGroup/styles.d.ts.map +0 -1
- package/types/Menu/MenuItemGroup/theme.d.ts.map +0 -1
- package/types/Menu/MenuItemSeparator/index.d.ts.map +0 -1
- package/types/Menu/MenuItemSeparator/props.d.ts.map +0 -1
- package/types/Menu/MenuItemSeparator/styles.d.ts.map +0 -1
- package/types/Menu/MenuItemSeparator/theme.d.ts.map +0 -1
- package/types/Menu/index.d.ts.map +0 -1
- package/types/Menu/props.d.ts.map +0 -1
- package/types/Menu/styles.d.ts.map +0 -1
- package/types/Menu/theme.d.ts.map +0 -1
- package/types/MenuContext.d.ts +0 -14
- package/types/MenuContext.d.ts.map +0 -1
- package/types/index.d.ts +0 -6
- package/types/index.d.ts.map +0 -1
- /package/es/Menu/{MenuItem → v1/MenuItem}/props.js +0 -0
- /package/es/Menu/{MenuItem → v1/MenuItem}/styles.js +0 -0
- /package/es/Menu/{MenuItem → v1/MenuItem}/theme.js +0 -0
- /package/es/Menu/{MenuItemGroup → v1/MenuItemGroup}/props.js +0 -0
- /package/es/Menu/{MenuItemGroup → v1/MenuItemGroup}/styles.js +0 -0
- /package/es/Menu/{MenuItemGroup → v1/MenuItemGroup}/theme.js +0 -0
- /package/es/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/props.js +0 -0
- /package/es/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/styles.js +0 -0
- /package/es/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/theme.js +0 -0
- /package/es/Menu/{props.js → v1/props.js} +0 -0
- /package/es/Menu/{styles.js → v1/styles.js} +0 -0
- /package/es/Menu/{theme.js → v1/theme.js} +0 -0
- /package/lib/Menu/{MenuItem → v1/MenuItem}/props.js +0 -0
- /package/lib/Menu/{MenuItem → v1/MenuItem}/styles.js +0 -0
- /package/lib/Menu/{MenuItem → v1/MenuItem}/theme.js +0 -0
- /package/lib/Menu/{MenuItemGroup → v1/MenuItemGroup}/props.js +0 -0
- /package/lib/Menu/{MenuItemGroup → v1/MenuItemGroup}/styles.js +0 -0
- /package/lib/Menu/{MenuItemGroup → v1/MenuItemGroup}/theme.js +0 -0
- /package/lib/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/props.js +0 -0
- /package/lib/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/styles.js +0 -0
- /package/lib/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/theme.js +0 -0
- /package/lib/Menu/{props.js → v1/props.js} +0 -0
- /package/lib/Menu/{styles.js → v1/styles.js} +0 -0
- /package/lib/Menu/{theme.js → v1/theme.js} +0 -0
- /package/src/Menu/{MenuItem → v1/MenuItem}/props.ts +0 -0
- /package/src/Menu/{MenuItem → v1/MenuItem}/styles.ts +0 -0
- /package/src/Menu/{MenuItem → v1/MenuItem}/theme.ts +0 -0
- /package/src/Menu/{MenuItemGroup → v1/MenuItemGroup}/props.ts +0 -0
- /package/src/Menu/{MenuItemGroup → v1/MenuItemGroup}/styles.ts +0 -0
- /package/src/Menu/{MenuItemGroup → v1/MenuItemGroup}/theme.ts +0 -0
- /package/src/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/props.ts +0 -0
- /package/src/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/styles.ts +0 -0
- /package/src/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/theme.ts +0 -0
- /package/src/Menu/{README.md → v1/README.md} +0 -0
- /package/src/Menu/{styles.ts → v1/styles.ts} +0 -0
- /package/src/Menu/{theme.ts → v1/theme.ts} +0 -0
- /package/types/Menu/{MenuItem → v1/MenuItem}/props.d.ts +0 -0
- /package/types/Menu/{MenuItem → v1/MenuItem}/styles.d.ts +0 -0
- /package/types/Menu/{MenuItem → v1/MenuItem}/theme.d.ts +0 -0
- /package/types/Menu/{MenuItemGroup → v1/MenuItemGroup}/index.d.ts +0 -0
- /package/types/Menu/{MenuItemGroup → v1/MenuItemGroup}/props.d.ts +0 -0
- /package/types/Menu/{MenuItemGroup → v1/MenuItemGroup}/styles.d.ts +0 -0
- /package/types/Menu/{MenuItemGroup → v1/MenuItemGroup}/theme.d.ts +0 -0
- /package/types/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/index.d.ts +0 -0
- /package/types/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/props.d.ts +0 -0
- /package/types/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/styles.d.ts +0 -0
- /package/types/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/theme.d.ts +0 -0
- /package/types/Menu/{styles.d.ts → v1/styles.d.ts} +0 -0
- /package/types/Menu/{theme.d.ts → v1/theme.d.ts} +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
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
|
+
|
|
25
|
+
import React from 'react'
|
|
26
|
+
|
|
27
|
+
import type { MenuTheme, OtherHTMLAttributes } from '@instructure/shared-types'
|
|
28
|
+
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
29
|
+
import type {
|
|
30
|
+
PlacementPropValues,
|
|
31
|
+
PositionConstraint,
|
|
32
|
+
PositionMountNode
|
|
33
|
+
} from '@instructure/ui-position'
|
|
34
|
+
import type { Popover } from '@instructure/ui-popover/latest'
|
|
35
|
+
import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
|
|
36
|
+
|
|
37
|
+
import { MenuItem } from './MenuItem'
|
|
38
|
+
import type { Menu } from './index'
|
|
39
|
+
import type { MenuItemProps } from './MenuItem/props'
|
|
40
|
+
|
|
41
|
+
type MenuOwnProps = {
|
|
42
|
+
/**
|
|
43
|
+
* Children of type `Menu.Item`, `Menu.Group`, `Menu.Separator`, or `Menu`
|
|
44
|
+
*/
|
|
45
|
+
children?: React.ReactNode // TODO: oneOf(['MenuItem', 'MenuItemGroup', 'MenuItemSeparator', 'Menu'])
|
|
46
|
+
/**
|
|
47
|
+
* Description of the `<Menu />`. The component uses it to add its value to
|
|
48
|
+
* the `aria-label` attribute.
|
|
49
|
+
*/
|
|
50
|
+
label?: string
|
|
51
|
+
/**
|
|
52
|
+
* Is the `<Menu />` disabled
|
|
53
|
+
*/
|
|
54
|
+
disabled?: boolean
|
|
55
|
+
/**
|
|
56
|
+
* The trigger element, if the `<Menu />` is to render as a popover
|
|
57
|
+
*/
|
|
58
|
+
trigger?: React.ReactNode
|
|
59
|
+
/**
|
|
60
|
+
* If a trigger is supplied, where should the `<Menu />` be placed (relative to the trigger)
|
|
61
|
+
*/
|
|
62
|
+
placement?: PlacementPropValues
|
|
63
|
+
/**
|
|
64
|
+
* Should the `<Menu />` be open for the initial render
|
|
65
|
+
*/
|
|
66
|
+
defaultShow?: boolean
|
|
67
|
+
/**
|
|
68
|
+
* Is the `<Menu />` open (should be accompanied by `onToggle`)
|
|
69
|
+
*/
|
|
70
|
+
show?: boolean // TODO: controllable(PropTypes.bool, 'onToggle', 'defaultShow')
|
|
71
|
+
/**
|
|
72
|
+
* Callback fired when the `<Menu />` is toggled open/closed. When used with `show`,
|
|
73
|
+
* the component will not control its own state.
|
|
74
|
+
*/
|
|
75
|
+
onToggle?: (show: boolean, menu: Menu) => void
|
|
76
|
+
/**
|
|
77
|
+
* Callback fired when an item within the `<Menu />` is selected
|
|
78
|
+
*/
|
|
79
|
+
onSelect?: (
|
|
80
|
+
e: React.MouseEvent,
|
|
81
|
+
value: MenuItemProps['value'] | MenuItemProps['value'][],
|
|
82
|
+
selected: MenuItemProps['selected'],
|
|
83
|
+
args: MenuItem
|
|
84
|
+
) => void
|
|
85
|
+
/**
|
|
86
|
+
* If a trigger is supplied, callback fired when the `<Menu />` is closed
|
|
87
|
+
*/
|
|
88
|
+
onDismiss?: (
|
|
89
|
+
event: React.UIEvent | React.FocusEvent,
|
|
90
|
+
documentClick: boolean
|
|
91
|
+
) => void
|
|
92
|
+
/**
|
|
93
|
+
* If a trigger is supplied, callback fired when the `<Menu />` trigger is focused
|
|
94
|
+
*/
|
|
95
|
+
onFocus?: (event: React.FocusEvent) => void
|
|
96
|
+
/**
|
|
97
|
+
* If a trigger is supplied, callback fired onMouseOver for the `<Menu />` trigger
|
|
98
|
+
*/
|
|
99
|
+
onMouseOver?: (event: React.MouseEvent) => void
|
|
100
|
+
/**
|
|
101
|
+
* Callback fired on the onKeyDown of the `<Menu />`
|
|
102
|
+
*/
|
|
103
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLElement>) => void
|
|
104
|
+
/**
|
|
105
|
+
* Callback fired on the onKeyUp of the `<Menu />`
|
|
106
|
+
*/
|
|
107
|
+
onKeyUp?: (event: React.KeyboardEvent<HTMLElement>) => void
|
|
108
|
+
/**
|
|
109
|
+
* A function that returns a reference to the `<Menu />`
|
|
110
|
+
*/
|
|
111
|
+
menuRef?: (el: HTMLElement | null) => void
|
|
112
|
+
/**
|
|
113
|
+
* A function that returns a reference to the `<Popover />`
|
|
114
|
+
*/
|
|
115
|
+
popoverRef?: (el: Popover | null) => void
|
|
116
|
+
/**
|
|
117
|
+
* If a trigger is supplied, an element or a function returning an element to use as the mount node
|
|
118
|
+
* for the `<Menu />` (defaults to `document.body`)
|
|
119
|
+
*/
|
|
120
|
+
mountNode?: PositionMountNode
|
|
121
|
+
/**
|
|
122
|
+
* The parent in which to constrain the menu.
|
|
123
|
+
* One of: 'window', 'scroll-parent', 'parent', 'none', an element,
|
|
124
|
+
* or a function returning an element
|
|
125
|
+
*/
|
|
126
|
+
constrain?: PositionConstraint
|
|
127
|
+
/**
|
|
128
|
+
* If a trigger is supplied, should the `<Menu />` hide when an item is selected
|
|
129
|
+
*/
|
|
130
|
+
shouldHideOnSelect?: boolean
|
|
131
|
+
/**
|
|
132
|
+
* If a trigger is supplied, should the `<Menu />` focus the trigger on after closing
|
|
133
|
+
*/
|
|
134
|
+
shouldFocusTriggerOnClose?: boolean
|
|
135
|
+
/**
|
|
136
|
+
* If a trigger is supplied, this prop can set the CSS `display` property on the `<span>` container element of the underlying Position component
|
|
137
|
+
*/
|
|
138
|
+
positionContainerDisplay?: 'inline-block' | 'block'
|
|
139
|
+
/**
|
|
140
|
+
* The type of `<Menu />`
|
|
141
|
+
*/
|
|
142
|
+
type?: 'flyout'
|
|
143
|
+
id?: string
|
|
144
|
+
/**
|
|
145
|
+
* Whether or not an arrow pointing to the trigger should be rendered
|
|
146
|
+
*/
|
|
147
|
+
withArrow?: boolean
|
|
148
|
+
/**
|
|
149
|
+
* The horizontal offset for the positioned content.
|
|
150
|
+
* Works only if `trigger` is provided.
|
|
151
|
+
*/
|
|
152
|
+
offsetX?: string | number
|
|
153
|
+
/**
|
|
154
|
+
* The vertical offset for the positioned content.
|
|
155
|
+
* Works only if `trigger` is provided.
|
|
156
|
+
*/
|
|
157
|
+
offsetY?: string | number
|
|
158
|
+
/**
|
|
159
|
+
* The maximum height the menu can be. If not set, the menu won't
|
|
160
|
+
* scroll and will be as tall as the content requires
|
|
161
|
+
*/
|
|
162
|
+
maxHeight?: string | number
|
|
163
|
+
/**
|
|
164
|
+
* Content to render in the label's info region. It is only visible on nested Menus.
|
|
165
|
+
*/
|
|
166
|
+
renderLabelInfo?: React.ReactNode | (() => React.ReactNode)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
type PropKeys = keyof MenuOwnProps
|
|
170
|
+
|
|
171
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
172
|
+
|
|
173
|
+
type MenuProps = MenuOwnProps &
|
|
174
|
+
WithStyleProps<MenuTheme, MenuStyle> &
|
|
175
|
+
// controls can be passed in renderChildren and used later as aria-controls
|
|
176
|
+
Omit<OtherHTMLAttributes<MenuOwnProps>, 'controls'> & {
|
|
177
|
+
controls?: React.AriaAttributes['aria-controls']
|
|
178
|
+
} & WithDeterministicIdProps
|
|
179
|
+
|
|
180
|
+
type MenuStyle = ComponentStyle<'menu'>
|
|
181
|
+
const allowedProps: AllowedPropKeys = [
|
|
182
|
+
'children',
|
|
183
|
+
'label',
|
|
184
|
+
'disabled',
|
|
185
|
+
'trigger',
|
|
186
|
+
'placement',
|
|
187
|
+
'defaultShow',
|
|
188
|
+
'show',
|
|
189
|
+
'onToggle',
|
|
190
|
+
'onSelect',
|
|
191
|
+
'onDismiss',
|
|
192
|
+
'onFocus',
|
|
193
|
+
'onMouseOver',
|
|
194
|
+
'onKeyDown',
|
|
195
|
+
'onKeyUp',
|
|
196
|
+
'menuRef',
|
|
197
|
+
'popoverRef',
|
|
198
|
+
'mountNode',
|
|
199
|
+
'constrain',
|
|
200
|
+
'shouldHideOnSelect',
|
|
201
|
+
'shouldFocusTriggerOnClose',
|
|
202
|
+
'positionContainerDisplay',
|
|
203
|
+
'type',
|
|
204
|
+
'id',
|
|
205
|
+
'withArrow',
|
|
206
|
+
'offsetX',
|
|
207
|
+
'offsetY',
|
|
208
|
+
'maxHeight',
|
|
209
|
+
'renderLabelInfo'
|
|
210
|
+
]
|
|
211
|
+
|
|
212
|
+
export type { MenuProps, MenuStyle }
|
|
213
|
+
export { allowedProps }
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
|
|
25
|
+
import type { NewComponentTypes, SharedTokens } from '@instructure/ui-themes'
|
|
26
|
+
import type { MenuStyle, MenuProps } from './props'
|
|
27
|
+
import { calcFocusOutlineStyles } from '@instructure/emotion'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* ---
|
|
31
|
+
* private: true
|
|
32
|
+
* ---
|
|
33
|
+
* Generates the style object from the theme and provided additional information
|
|
34
|
+
* @param {Object} componentTheme The theme variable object.
|
|
35
|
+
* @param {Object} props the props of the component, the style is applied to
|
|
36
|
+
* @param {Object} state the state of the component, the style is applied to
|
|
37
|
+
* @return {Object} The final style object, which will be used in the component
|
|
38
|
+
*/
|
|
39
|
+
const generateStyle = (
|
|
40
|
+
componentTheme: NewComponentTypes['Menu'],
|
|
41
|
+
props: MenuProps,
|
|
42
|
+
sharedTokens: SharedTokens
|
|
43
|
+
): MenuStyle => {
|
|
44
|
+
const maxHeight = props.maxHeight
|
|
45
|
+
? { maxHeight: props.maxHeight, overflow: 'auto' }
|
|
46
|
+
: {}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
menu: {
|
|
50
|
+
label: 'menu',
|
|
51
|
+
minWidth: componentTheme.minWidth,
|
|
52
|
+
maxWidth: componentTheme.maxWidth,
|
|
53
|
+
listStyleType: 'none',
|
|
54
|
+
margin: '0',
|
|
55
|
+
padding: '0.25rem 0',
|
|
56
|
+
// TODO-rework
|
|
57
|
+
//background: componentTheme.background,
|
|
58
|
+
//borderRadius: componentTheme.borderRadius,
|
|
59
|
+
display: 'block',
|
|
60
|
+
position: 'relative',
|
|
61
|
+
overflow: 'hidden',
|
|
62
|
+
...maxHeight,
|
|
63
|
+
...calcFocusOutlineStyles(sharedTokens.focusOutline)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default generateStyle
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
export { Menu, MenuItem, MenuItemGroup, MenuItemSeparator } from '
|
|
24
|
+
export { Menu, MenuItem, MenuItemGroup, MenuItemSeparator } from '../Menu/v1'
|
|
25
25
|
|
|
26
|
-
export type { MenuProps } from '
|
|
27
|
-
export type { MenuItemProps } from '
|
|
28
|
-
export type { MenuGroupProps } from '
|
|
29
|
-
export type { MenuSeparatorProps } from '
|
|
26
|
+
export type { MenuProps } from '../Menu/v1/props'
|
|
27
|
+
export type { MenuItemProps } from '../Menu/v1/MenuItem/props'
|
|
28
|
+
export type { MenuGroupProps } from '../Menu/v1/MenuItemGroup/props'
|
|
29
|
+
export type { MenuSeparatorProps } from '../Menu/v1/MenuItemSeparator/props'
|
package/src/exports/b.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
export { Menu, MenuItem, MenuItemGroup, MenuItemSeparator } from '../Menu/v2'
|
|
25
|
+
|
|
26
|
+
export type { MenuProps } from '../Menu/v2/props'
|
|
27
|
+
export type { MenuItemProps } from '../Menu/v2/MenuItem/props'
|
|
28
|
+
export type { MenuGroupProps } from '../Menu/v2/MenuItemGroup/props'
|
|
29
|
+
export type { MenuSeparatorProps } from '../Menu/v2/MenuItemSeparator/props'
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import { createContext } from 'react'
|
|
26
|
-
import { MenuItem } from './Menu/MenuItem'
|
|
27
26
|
|
|
28
27
|
/**
|
|
29
28
|
---
|
|
@@ -32,8 +31,9 @@ private: true
|
|
|
32
31
|
@module MenuContext
|
|
33
32
|
**/
|
|
34
33
|
const MenuContext = createContext({
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
// This is actually a `MenuItem`, but we dont want to version this one
|
|
35
|
+
registerMenuItem: (_value: any) => {},
|
|
36
|
+
removeMenuItem: (_value: any) => {}
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
export default MenuContext
|