@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.
Files changed (180) hide show
  1. package/CHANGELOG.md +41 -297
  2. package/es/Menu/{MenuItem → v1/MenuItem}/index.js +2 -2
  3. package/es/Menu/{MenuItemGroup → v1/MenuItemGroup}/index.js +1 -1
  4. package/es/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/index.js +1 -1
  5. package/es/Menu/{index.js → v1/index.js} +3 -3
  6. package/es/Menu/v2/MenuItem/index.js +262 -0
  7. package/es/Menu/v2/MenuItem/props.js +26 -0
  8. package/es/Menu/v2/MenuItem/styles.js +146 -0
  9. package/es/Menu/v2/MenuItemGroup/index.js +175 -0
  10. package/es/Menu/v2/MenuItemGroup/props.js +26 -0
  11. package/es/Menu/v2/MenuItemGroup/styles.js +60 -0
  12. package/es/Menu/v2/MenuItemSeparator/index.js +70 -0
  13. package/es/Menu/v2/MenuItemSeparator/props.js +29 -0
  14. package/es/Menu/v2/MenuItemSeparator/styles.js +46 -0
  15. package/es/Menu/v2/index.js +405 -0
  16. package/es/Menu/v2/props.js +26 -0
  17. package/es/Menu/v2/styles.js +61 -0
  18. package/es/{index.js → exports/a.js} +1 -1
  19. package/es/exports/b.js +24 -0
  20. package/es/{MenuContext.js → utils/v1/MenuContext.js} +2 -0
  21. package/lib/Menu/{MenuItem → v1/MenuItem}/index.js +4 -4
  22. package/lib/Menu/{MenuItemGroup → v1/MenuItemGroup}/index.js +1 -1
  23. package/lib/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/index.js +1 -1
  24. package/lib/Menu/v1/index.js +432 -0
  25. package/lib/Menu/v2/MenuItem/index.js +271 -0
  26. package/lib/Menu/v2/MenuItem/props.js +31 -0
  27. package/lib/Menu/v2/MenuItem/styles.js +152 -0
  28. package/lib/Menu/v2/MenuItemGroup/index.js +183 -0
  29. package/lib/Menu/v2/MenuItemGroup/props.js +31 -0
  30. package/lib/Menu/v2/MenuItemGroup/styles.js +66 -0
  31. package/lib/Menu/v2/MenuItemSeparator/index.js +75 -0
  32. package/lib/Menu/v2/MenuItemSeparator/props.js +34 -0
  33. package/lib/Menu/v2/MenuItemSeparator/styles.js +52 -0
  34. package/lib/Menu/{index.js → v2/index.js} +4 -5
  35. package/lib/Menu/v2/props.js +31 -0
  36. package/lib/Menu/v2/styles.js +66 -0
  37. package/lib/{index.js → exports/a.js} +5 -5
  38. package/lib/exports/b.js +30 -0
  39. package/lib/{MenuContext.js → utils/v1/MenuContext.js} +1 -0
  40. package/package.json +45 -23
  41. package/src/Menu/{MenuItem → v1/MenuItem}/index.tsx +2 -2
  42. package/src/Menu/{MenuItemGroup → v1/MenuItemGroup}/index.tsx +1 -1
  43. package/src/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/index.tsx +1 -1
  44. package/src/Menu/{index.tsx → v1/index.tsx} +3 -3
  45. package/src/Menu/{props.ts → v1/props.ts} +1 -1
  46. package/src/Menu/v2/MenuItem/index.tsx +318 -0
  47. package/src/Menu/v2/MenuItem/props.ts +132 -0
  48. package/src/Menu/v2/MenuItem/styles.ts +172 -0
  49. package/src/Menu/v2/MenuItemGroup/index.tsx +245 -0
  50. package/src/Menu/v2/MenuItemGroup/props.ts +105 -0
  51. package/src/Menu/v2/MenuItemGroup/styles.ts +66 -0
  52. package/src/Menu/v2/MenuItemSeparator/index.tsx +79 -0
  53. package/src/Menu/v2/MenuItemSeparator/props.ts +48 -0
  54. package/src/Menu/v2/MenuItemSeparator/styles.ts +52 -0
  55. package/src/Menu/v2/README.md +104 -0
  56. package/src/Menu/v2/index.tsx +514 -0
  57. package/src/Menu/v2/props.ts +213 -0
  58. package/src/Menu/v2/styles.ts +68 -0
  59. package/src/{index.ts → exports/a.ts} +5 -5
  60. package/src/exports/b.ts +29 -0
  61. package/src/{MenuContext.ts → utils/v1/MenuContext.ts} +3 -3
  62. package/tsconfig.build.tsbuildinfo +1 -1
  63. package/types/Menu/{MenuItem → v1/MenuItem}/index.d.ts +3 -3
  64. package/types/Menu/v1/MenuItem/index.d.ts.map +1 -0
  65. package/types/Menu/v1/MenuItem/props.d.ts.map +1 -0
  66. package/types/Menu/v1/MenuItem/styles.d.ts.map +1 -0
  67. package/types/Menu/v1/MenuItem/theme.d.ts.map +1 -0
  68. package/types/Menu/v1/MenuItemGroup/index.d.ts.map +1 -0
  69. package/types/Menu/v1/MenuItemGroup/props.d.ts.map +1 -0
  70. package/types/Menu/v1/MenuItemGroup/styles.d.ts.map +1 -0
  71. package/types/Menu/v1/MenuItemGroup/theme.d.ts.map +1 -0
  72. package/types/Menu/v1/MenuItemSeparator/index.d.ts.map +1 -0
  73. package/types/Menu/v1/MenuItemSeparator/props.d.ts.map +1 -0
  74. package/types/Menu/v1/MenuItemSeparator/styles.d.ts.map +1 -0
  75. package/types/Menu/v1/MenuItemSeparator/theme.d.ts.map +1 -0
  76. package/types/Menu/{index.d.ts → v1/index.d.ts} +3 -3
  77. package/types/Menu/v1/index.d.ts.map +1 -0
  78. package/types/Menu/{props.d.ts → v1/props.d.ts} +1 -1
  79. package/types/Menu/v1/props.d.ts.map +1 -0
  80. package/types/Menu/v1/styles.d.ts.map +1 -0
  81. package/types/Menu/v1/theme.d.ts.map +1 -0
  82. package/types/Menu/v2/MenuItem/index.d.ts +66 -0
  83. package/types/Menu/v2/MenuItem/index.d.ts.map +1 -0
  84. package/types/Menu/v2/MenuItem/props.d.ts +73 -0
  85. package/types/Menu/v2/MenuItem/props.d.ts.map +1 -0
  86. package/types/Menu/v2/MenuItem/styles.d.ts +15 -0
  87. package/types/Menu/v2/MenuItem/styles.d.ts.map +1 -0
  88. package/types/Menu/v2/MenuItemGroup/index.d.ts +52 -0
  89. package/types/Menu/v2/MenuItemGroup/index.d.ts.map +1 -0
  90. package/types/Menu/v2/MenuItemGroup/props.d.ts +51 -0
  91. package/types/Menu/v2/MenuItemGroup/props.d.ts.map +1 -0
  92. package/types/Menu/v2/MenuItemGroup/styles.d.ts +15 -0
  93. package/types/Menu/v2/MenuItemGroup/styles.d.ts.map +1 -0
  94. package/types/Menu/v2/MenuItemSeparator/index.d.ts +21 -0
  95. package/types/Menu/v2/MenuItemSeparator/index.d.ts.map +1 -0
  96. package/types/Menu/v2/MenuItemSeparator/props.d.ts +11 -0
  97. package/types/Menu/v2/MenuItemSeparator/props.d.ts.map +1 -0
  98. package/types/Menu/v2/MenuItemSeparator/styles.d.ts +15 -0
  99. package/types/Menu/v2/MenuItemSeparator/styles.d.ts.map +1 -0
  100. package/types/Menu/v2/index.d.ts +118 -0
  101. package/types/Menu/v2/index.d.ts.map +1 -0
  102. package/types/Menu/v2/props.d.ts +138 -0
  103. package/types/Menu/v2/props.d.ts.map +1 -0
  104. package/types/Menu/v2/styles.d.ts +15 -0
  105. package/types/Menu/v2/styles.d.ts.map +1 -0
  106. package/types/exports/a.d.ts +6 -0
  107. package/types/exports/a.d.ts.map +1 -0
  108. package/types/exports/b.d.ts +6 -0
  109. package/types/exports/b.d.ts.map +1 -0
  110. package/types/utils/v1/MenuContext.d.ts +13 -0
  111. package/types/utils/v1/MenuContext.d.ts.map +1 -0
  112. package/types/Menu/MenuItem/index.d.ts.map +0 -1
  113. package/types/Menu/MenuItem/props.d.ts.map +0 -1
  114. package/types/Menu/MenuItem/styles.d.ts.map +0 -1
  115. package/types/Menu/MenuItem/theme.d.ts.map +0 -1
  116. package/types/Menu/MenuItemGroup/index.d.ts.map +0 -1
  117. package/types/Menu/MenuItemGroup/props.d.ts.map +0 -1
  118. package/types/Menu/MenuItemGroup/styles.d.ts.map +0 -1
  119. package/types/Menu/MenuItemGroup/theme.d.ts.map +0 -1
  120. package/types/Menu/MenuItemSeparator/index.d.ts.map +0 -1
  121. package/types/Menu/MenuItemSeparator/props.d.ts.map +0 -1
  122. package/types/Menu/MenuItemSeparator/styles.d.ts.map +0 -1
  123. package/types/Menu/MenuItemSeparator/theme.d.ts.map +0 -1
  124. package/types/Menu/index.d.ts.map +0 -1
  125. package/types/Menu/props.d.ts.map +0 -1
  126. package/types/Menu/styles.d.ts.map +0 -1
  127. package/types/Menu/theme.d.ts.map +0 -1
  128. package/types/MenuContext.d.ts +0 -14
  129. package/types/MenuContext.d.ts.map +0 -1
  130. package/types/index.d.ts +0 -6
  131. package/types/index.d.ts.map +0 -1
  132. /package/es/Menu/{MenuItem → v1/MenuItem}/props.js +0 -0
  133. /package/es/Menu/{MenuItem → v1/MenuItem}/styles.js +0 -0
  134. /package/es/Menu/{MenuItem → v1/MenuItem}/theme.js +0 -0
  135. /package/es/Menu/{MenuItemGroup → v1/MenuItemGroup}/props.js +0 -0
  136. /package/es/Menu/{MenuItemGroup → v1/MenuItemGroup}/styles.js +0 -0
  137. /package/es/Menu/{MenuItemGroup → v1/MenuItemGroup}/theme.js +0 -0
  138. /package/es/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/props.js +0 -0
  139. /package/es/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/styles.js +0 -0
  140. /package/es/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/theme.js +0 -0
  141. /package/es/Menu/{props.js → v1/props.js} +0 -0
  142. /package/es/Menu/{styles.js → v1/styles.js} +0 -0
  143. /package/es/Menu/{theme.js → v1/theme.js} +0 -0
  144. /package/lib/Menu/{MenuItem → v1/MenuItem}/props.js +0 -0
  145. /package/lib/Menu/{MenuItem → v1/MenuItem}/styles.js +0 -0
  146. /package/lib/Menu/{MenuItem → v1/MenuItem}/theme.js +0 -0
  147. /package/lib/Menu/{MenuItemGroup → v1/MenuItemGroup}/props.js +0 -0
  148. /package/lib/Menu/{MenuItemGroup → v1/MenuItemGroup}/styles.js +0 -0
  149. /package/lib/Menu/{MenuItemGroup → v1/MenuItemGroup}/theme.js +0 -0
  150. /package/lib/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/props.js +0 -0
  151. /package/lib/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/styles.js +0 -0
  152. /package/lib/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/theme.js +0 -0
  153. /package/lib/Menu/{props.js → v1/props.js} +0 -0
  154. /package/lib/Menu/{styles.js → v1/styles.js} +0 -0
  155. /package/lib/Menu/{theme.js → v1/theme.js} +0 -0
  156. /package/src/Menu/{MenuItem → v1/MenuItem}/props.ts +0 -0
  157. /package/src/Menu/{MenuItem → v1/MenuItem}/styles.ts +0 -0
  158. /package/src/Menu/{MenuItem → v1/MenuItem}/theme.ts +0 -0
  159. /package/src/Menu/{MenuItemGroup → v1/MenuItemGroup}/props.ts +0 -0
  160. /package/src/Menu/{MenuItemGroup → v1/MenuItemGroup}/styles.ts +0 -0
  161. /package/src/Menu/{MenuItemGroup → v1/MenuItemGroup}/theme.ts +0 -0
  162. /package/src/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/props.ts +0 -0
  163. /package/src/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/styles.ts +0 -0
  164. /package/src/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/theme.ts +0 -0
  165. /package/src/Menu/{README.md → v1/README.md} +0 -0
  166. /package/src/Menu/{styles.ts → v1/styles.ts} +0 -0
  167. /package/src/Menu/{theme.ts → v1/theme.ts} +0 -0
  168. /package/types/Menu/{MenuItem → v1/MenuItem}/props.d.ts +0 -0
  169. /package/types/Menu/{MenuItem → v1/MenuItem}/styles.d.ts +0 -0
  170. /package/types/Menu/{MenuItem → v1/MenuItem}/theme.d.ts +0 -0
  171. /package/types/Menu/{MenuItemGroup → v1/MenuItemGroup}/index.d.ts +0 -0
  172. /package/types/Menu/{MenuItemGroup → v1/MenuItemGroup}/props.d.ts +0 -0
  173. /package/types/Menu/{MenuItemGroup → v1/MenuItemGroup}/styles.d.ts +0 -0
  174. /package/types/Menu/{MenuItemGroup → v1/MenuItemGroup}/theme.d.ts +0 -0
  175. /package/types/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/index.d.ts +0 -0
  176. /package/types/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/props.d.ts +0 -0
  177. /package/types/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/styles.d.ts +0 -0
  178. /package/types/Menu/{MenuItemSeparator → v1/MenuItemSeparator}/theme.d.ts +0 -0
  179. /package/types/Menu/{styles.d.ts → v1/styles.d.ts} +0 -0
  180. /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 './Menu'
24
+ export { Menu, MenuItem, MenuItemGroup, MenuItemSeparator } from '../Menu/v1'
25
25
 
26
- export type { MenuProps } from './Menu/props'
27
- export type { MenuItemProps } from './Menu/MenuItem/props'
28
- export type { MenuGroupProps } from './Menu/MenuItemGroup/props'
29
- export type { MenuSeparatorProps } from './Menu/MenuItemSeparator/props'
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'
@@ -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
- registerMenuItem: (_value: MenuItem) => {},
36
- removeMenuItem: (_value: MenuItem) => {}
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