@instructure/ui-menu 8.13.1-snapshot.3 → 8.13.1-snapshot.41

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 (45) hide show
  1. package/es/Menu/MenuItem/index.js +28 -21
  2. package/es/Menu/MenuItem/props.js +0 -23
  3. package/es/Menu/MenuItemGroup/index.js +17 -13
  4. package/es/Menu/MenuItemGroup/props.js +1 -30
  5. package/es/Menu/MenuItemSeparator/index.js +6 -2
  6. package/es/Menu/index.js +56 -52
  7. package/es/Menu/props.js +1 -113
  8. package/es/MenuContext.js +3 -3
  9. package/lib/Menu/MenuItem/index.js +28 -21
  10. package/lib/Menu/MenuItem/props.js +0 -23
  11. package/lib/Menu/MenuItemGroup/index.js +17 -13
  12. package/lib/Menu/MenuItemGroup/props.js +1 -30
  13. package/lib/Menu/MenuItemSeparator/index.js +6 -2
  14. package/lib/Menu/index.js +58 -52
  15. package/lib/Menu/props.js +1 -113
  16. package/lib/MenuContext.js +2 -2
  17. package/package.json +21 -21
  18. package/src/Menu/MenuItem/index.tsx +24 -34
  19. package/src/Menu/MenuItem/props.ts +36 -27
  20. package/src/Menu/MenuItemGroup/index.tsx +28 -48
  21. package/src/Menu/MenuItemGroup/props.ts +37 -30
  22. package/src/Menu/MenuItemSeparator/index.tsx +2 -4
  23. package/src/Menu/index.tsx +79 -133
  24. package/src/Menu/props.ts +76 -84
  25. package/src/MenuContext.ts +3 -2
  26. package/tsconfig.build.json +25 -2
  27. package/tsconfig.build.tsbuildinfo +1 -0
  28. package/types/Menu/MenuItem/MenuItemLocator.d.ts +52 -52
  29. package/types/Menu/MenuItem/index.d.ts +24 -23
  30. package/types/Menu/MenuItem/index.d.ts.map +1 -1
  31. package/types/Menu/MenuItem/props.d.ts +30 -7
  32. package/types/Menu/MenuItem/props.d.ts.map +1 -1
  33. package/types/Menu/MenuItemGroup/MenuItemGroupLocator.d.ts +182 -182
  34. package/types/Menu/MenuItemGroup/index.d.ts +22 -22
  35. package/types/Menu/MenuItemGroup/index.d.ts.map +1 -1
  36. package/types/Menu/MenuItemGroup/props.d.ts +33 -8
  37. package/types/Menu/MenuItemGroup/props.d.ts.map +1 -1
  38. package/types/Menu/MenuItemSeparator/index.d.ts.map +1 -1
  39. package/types/Menu/MenuLocator.d.ts +576 -576
  40. package/types/Menu/index.d.ts +57 -67
  41. package/types/Menu/index.d.ts.map +1 -1
  42. package/types/Menu/props.d.ts +94 -16
  43. package/types/Menu/props.d.ts.map +1 -1
  44. package/types/MenuContext.d.ts +3 -2
  45. package/types/MenuContext.d.ts.map +1 -1
package/src/Menu/props.ts CHANGED
@@ -29,175 +29,169 @@ import {
29
29
  controllable,
30
30
  Children as ChildrenPropTypes
31
31
  } from '@instructure/ui-prop-types'
32
+ import type { Menu } from './index'
32
33
 
33
- import type { PropValidators, MenuTheme } from '@instructure/shared-types'
34
+ import type {
35
+ PropValidators,
36
+ MenuTheme,
37
+ OtherHTMLAttributes
38
+ } from '@instructure/shared-types'
34
39
  import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
35
40
  import type {
36
41
  PlacementPropValues,
37
42
  PositionConstraint,
38
43
  PositionMountNode
39
44
  } from '@instructure/ui-position'
45
+ import type { OnMenuItemSelect } from './MenuItem/props'
46
+ import type { Popover } from '@instructure/ui-popover'
47
+ import React from 'react'
40
48
 
41
49
  type MenuOwnProps = {
42
- children?: React.ReactNode // TODO: oneOf(['MenuItem', 'MenuItemGroup', 'MenuItemSeparator', 'Menu'])
43
- label?: string
44
- disabled?: boolean
45
- trigger?: React.ReactNode
46
- placement?: PlacementPropValues
47
- defaultShow?: boolean
48
- show?: any // TODO: controllable(PropTypes.bool, 'onToggle', 'defaultShow')
49
- onToggle?: (...args: any[]) => any
50
- onSelect?: (...args: any[]) => any
51
- onDismiss?: (...args: any[]) => any
52
- onBlur?: (...args: any[]) => any
53
- onFocus?: (...args: any[]) => any
54
- onMouseOver?: (...args: any[]) => any
55
- onKeyDown?: (...args: any[]) => any
56
- onKeyUp?: (...args: any[]) => any
57
- menuRef?: (...args: any[]) => any
58
- popoverRef?: (...args: any[]) => any
59
- mountNode?: PositionMountNode
60
- constrain?: PositionConstraint
61
- liveRegion?: // TODO check whether this is used
62
- React.ReactElement[] | React.ReactElement | ((...args: any[]) => any)
63
- shouldHideOnSelect?: boolean
64
- shouldFocusTriggerOnClose?: boolean
65
- type?: 'flyout'
66
- id?: string
67
- withArrow?: boolean
68
- offsetX?: string | number
69
- offsetY?: string | number
70
- }
71
-
72
- type PropKeys = keyof MenuOwnProps
73
-
74
- type AllowedPropKeys = Readonly<Array<PropKeys>>
75
-
76
- type MenuProps = MenuOwnProps & WithStyleProps<MenuTheme, MenuStyle>
77
-
78
- type MenuStyle = ComponentStyle<'menu'>
79
-
80
- const propTypes: PropValidators<PropKeys> = {
81
50
  /**
82
51
  * Children of type `Menu.Item`, `Menu.Group`, `Menu.Separator`, or `Menu`
83
52
  */
84
- children: ChildrenPropTypes.oneOf([
85
- 'MenuItem',
86
- 'MenuItemGroup',
87
- 'MenuItemSeparator',
88
- 'Menu'
89
- ]),
53
+ children?: React.ReactNode // TODO: oneOf(['MenuItem', 'MenuItemGroup', 'MenuItemSeparator', 'Menu'])
90
54
  /**
91
55
  * Description of the `<Menu />`
92
56
  */
93
- label: PropTypes.string,
57
+ label?: string
94
58
  /**
95
59
  * Is the `<Menu />` disabled
96
60
  */
97
- disabled: PropTypes.bool,
61
+ disabled?: boolean
98
62
  /**
99
63
  * The trigger element, if the `<Menu />` is to render as a popover
100
64
  */
101
- trigger: PropTypes.node,
65
+ trigger?: React.ReactNode
102
66
  /**
103
67
  * If a trigger is supplied, where should the `<Menu />` be placed (relative to the trigger)
104
68
  */
105
- placement: PositionPropTypes.placement,
69
+ placement?: PlacementPropValues
106
70
  /**
107
71
  * Should the `<Menu />` be open for the initial render
108
72
  */
109
- defaultShow: PropTypes.bool,
73
+ defaultShow?: boolean
110
74
  /**
111
75
  * Is the `<Menu />` open (should be accompanied by `onToggle`)
112
76
  */
113
- show: controllable(PropTypes.bool, 'onToggle', 'defaultShow'),
77
+ show?: boolean // TODO: controllable(PropTypes.bool, 'onToggle', 'defaultShow')
114
78
  /**
115
79
  * Callback fired when the `<Menu />` is toggled open/closed. When used with `show`,
116
80
  * the component will not control its own state.
117
81
  */
118
- onToggle: PropTypes.func,
82
+ onToggle?: (show: boolean, menu: Menu) => void
119
83
  /**
120
84
  * Callback fired when an item within the `<Menu />` is selected
121
85
  */
122
- onSelect: PropTypes.func,
86
+ onSelect?: OnMenuItemSelect
123
87
  /**
124
88
  * If a trigger is supplied, callback fired when the `<Menu />` is closed
125
89
  */
126
- onDismiss: PropTypes.func,
127
- /**
128
- * If a trigger is supplied, callback fired when the `<Menu />` trigger is blurred
129
- */
130
- onBlur: PropTypes.func,
90
+ onDismiss?: (event: Event, documentClick: boolean) => void
131
91
  /**
132
92
  * If a trigger is supplied, callback fired when the `<Menu />` trigger is focused
133
93
  */
134
- onFocus: PropTypes.func,
94
+ onFocus?: (event: Event) => void
135
95
  /**
136
96
  * If a trigger is supplied, callback fired onMouseOver for the `<Menu />` trigger
137
97
  */
138
- onMouseOver: PropTypes.func,
98
+ onMouseOver?: (event: Event) => void
139
99
  /**
140
100
  * Callback fired on the onKeyDown of the `<Menu />`
141
101
  */
142
- onKeyDown: PropTypes.func,
102
+ onKeyDown?: (event: React.KeyboardEvent) => void
143
103
  /**
144
104
  * Callback fired on the onKeyUp of the `<Menu />`
145
105
  */
146
- onKeyUp: PropTypes.func,
106
+ onKeyUp?: (event: React.KeyboardEvent<HTMLUListElement>) => void
147
107
  /**
148
108
  * A function that returns a reference to the `<Menu />`
149
109
  */
150
- menuRef: PropTypes.func,
110
+ menuRef?: (el: HTMLUListElement | null) => void
151
111
  /**
152
112
  * A function that returns a reference to the `<Popover />`
153
113
  */
154
- popoverRef: PropTypes.func,
114
+ popoverRef?: (el: Popover | null) => void
155
115
  /**
156
116
  * If a trigger is supplied, an element or a function returning an element to use as the mount node
157
117
  * for the `<Menu />` (defaults to `document.body`)
158
118
  */
159
- mountNode: PositionPropTypes.mountNode,
119
+ mountNode?: PositionMountNode
160
120
  /**
161
121
  * The parent in which to constrain the menu.
162
122
  * One of: 'window', 'scroll-parent', 'parent', 'none', an element,
163
123
  * or a function returning an element
164
124
  */
165
- constrain: PositionPropTypes.constrain,
166
- /**
167
- * If a trigger is supplied, an element, function returning an element, or array of elements that will not
168
- * be hidden from the screen reader when the `<Menu />` is open
169
- */
170
- liveRegion: PropTypes.oneOfType([
171
- PropTypes.arrayOf(PropTypes.element),
172
- PropTypes.element,
173
- PropTypes.func
174
- ]),
125
+ constrain?: PositionConstraint
175
126
  /**
176
127
  * If a trigger is supplied, should the `<Menu />` hide when an item is selected
177
128
  */
178
- shouldHideOnSelect: PropTypes.bool,
129
+ shouldHideOnSelect?: boolean
179
130
  /**
180
131
  * If a trigger is supplied, should the `<Menu />` focus the trigger on after closing
181
132
  */
182
- shouldFocusTriggerOnClose: PropTypes.bool,
133
+ shouldFocusTriggerOnClose?: boolean
183
134
  /**
184
135
  * The type of `<Menu />`
185
136
  */
186
- type: PropTypes.oneOf(['flyout']),
187
- id: PropTypes.string,
137
+ type?: 'flyout'
138
+ id?: string
188
139
  /**
189
140
  * Whether or not an arrow pointing to the trigger should be rendered
190
141
  */
191
- withArrow: PropTypes.bool,
142
+ withArrow?: boolean
192
143
  /**
193
144
  * The horizontal offset for the positioned content.
194
145
  * Works only if `trigger` is provided.
195
146
  */
196
- offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
147
+ offsetX?: string | number
197
148
  /**
198
149
  * The vertical offset for the positioned content.
199
150
  * Works only if `trigger` is provided.
200
151
  */
152
+ offsetY?: string | number
153
+ }
154
+
155
+ type PropKeys = keyof MenuOwnProps
156
+
157
+ type AllowedPropKeys = Readonly<Array<PropKeys>>
158
+
159
+ type MenuProps = MenuOwnProps &
160
+ WithStyleProps<MenuTheme, MenuStyle> &
161
+ OtherHTMLAttributes<MenuOwnProps>
162
+
163
+ type MenuStyle = ComponentStyle<'menu'>
164
+
165
+ const propTypes: PropValidators<PropKeys> = {
166
+ children: ChildrenPropTypes.oneOf([
167
+ 'MenuItem',
168
+ 'MenuItemGroup',
169
+ 'MenuItemSeparator',
170
+ 'Menu'
171
+ ]),
172
+ label: PropTypes.string,
173
+ disabled: PropTypes.bool,
174
+ trigger: PropTypes.node,
175
+ placement: PositionPropTypes.placement,
176
+ defaultShow: PropTypes.bool,
177
+ show: controllable(PropTypes.bool, 'onToggle', 'defaultShow'),
178
+ onToggle: PropTypes.func,
179
+ onSelect: PropTypes.func,
180
+ onDismiss: PropTypes.func,
181
+ onFocus: PropTypes.func,
182
+ onMouseOver: PropTypes.func,
183
+ onKeyDown: PropTypes.func,
184
+ onKeyUp: PropTypes.func,
185
+ menuRef: PropTypes.func,
186
+ popoverRef: PropTypes.func,
187
+ mountNode: PositionPropTypes.mountNode,
188
+ constrain: PositionPropTypes.constrain,
189
+ shouldHideOnSelect: PropTypes.bool,
190
+ shouldFocusTriggerOnClose: PropTypes.bool,
191
+ type: PropTypes.oneOf(['flyout']),
192
+ id: PropTypes.string,
193
+ withArrow: PropTypes.bool,
194
+ offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
201
195
  offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
202
196
  }
203
197
 
@@ -212,7 +206,6 @@ const allowedProps: AllowedPropKeys = [
212
206
  'onToggle',
213
207
  'onSelect',
214
208
  'onDismiss',
215
- 'onBlur',
216
209
  'onFocus',
217
210
  'onMouseOver',
218
211
  'onKeyDown',
@@ -221,7 +214,6 @@ const allowedProps: AllowedPropKeys = [
221
214
  'popoverRef',
222
215
  'mountNode',
223
216
  'constrain',
224
- 'liveRegion',
225
217
  'shouldHideOnSelect',
226
218
  'shouldFocusTriggerOnClose',
227
219
  'type',
@@ -23,6 +23,7 @@
23
23
  */
24
24
 
25
25
  import { createContext } from 'react'
26
+ import { MenuItem } from './Menu/MenuItem'
26
27
 
27
28
  /**
28
29
  ---
@@ -31,8 +32,8 @@ private: true
31
32
  @module MenuContext
32
33
  **/
33
34
  const MenuContext = createContext({
34
- registerMenuItem: () => {},
35
- removeMenuItem: () => {}
35
+ registerMenuItem: (_value: MenuItem) => {},
36
+ removeMenuItem: (_value: MenuItem) => {}
36
37
  })
37
38
 
38
39
  export default MenuContext
@@ -1,7 +1,30 @@
1
1
  {
2
2
  "extends": "../../tsconfig.build.json",
3
3
  "compilerOptions": {
4
- "outDir": "./types"
4
+ "outDir": "./types",
5
+ "rootDir": "./src",
6
+ "composite": true
5
7
  },
6
- "include": ["src/**/*"]
8
+ "include": ["src"],
9
+ "references": [
10
+ { "path": "../ui-babel-preset/tsconfig.build.json" },
11
+ { "path": "../ui-color-utils/tsconfig.build.json" },
12
+ { "path": "../ui-test-locator/tsconfig.build.json" },
13
+ { "path": "../ui-test-queries/tsconfig.build.json" },
14
+ { "path": "../ui-test-utils/tsconfig.build.json" },
15
+ { "path": "../ui-themes/tsconfig.build.json" },
16
+ { "path": "../console/tsconfig.build.json" },
17
+ { "path": "../emotion/tsconfig.build.json" },
18
+ { "path": "../shared-types/tsconfig.build.json" },
19
+ { "path": "../ui-a11y-utils/tsconfig.build.json" },
20
+ { "path": "../ui-dom-utils/tsconfig.build.json" },
21
+ { "path": "../ui-icons/tsconfig.build.json" },
22
+ { "path": "../ui-popover/tsconfig.build.json" },
23
+ { "path": "../ui-position/tsconfig.build.json" },
24
+ { "path": "../ui-prop-types/tsconfig.build.json" },
25
+ { "path": "../ui-react-utils/tsconfig.build.json" },
26
+ { "path": "../ui-testable/tsconfig.build.json" },
27
+ { "path": "../ui-utils/tsconfig.build.json" },
28
+ { "path": "../uid/tsconfig.build.json" }
29
+ ]
7
30
  }