@instructure/ui-menu 11.7.3 → 11.7.4-pr-snapshot-1781695314229

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 (94) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/LICENSE.md +1 -0
  3. package/{lib/Menu/v1/MenuItemSeparator/props.js → babel.config.cjs} +12 -10
  4. package/es/Menu/v1/MenuItem/index.js +5 -5
  5. package/es/Menu/v1/MenuItemGroup/index.js +5 -5
  6. package/es/Menu/v1/MenuItemSeparator/index.js +4 -4
  7. package/es/Menu/v1/index.js +8 -8
  8. package/es/Menu/v2/MenuItem/index.js +4 -7
  9. package/es/Menu/v2/MenuItemGroup/index.js +4 -4
  10. package/es/Menu/v2/MenuItemSeparator/index.js +3 -3
  11. package/es/Menu/v2/index.js +7 -7
  12. package/es/exports/a.js +1 -1
  13. package/es/exports/b.js +1 -1
  14. package/package.json +18 -23
  15. package/src/Menu/v1/MenuItem/index.tsx +5 -4
  16. package/src/Menu/v1/MenuItem/props.ts +1 -1
  17. package/src/Menu/v1/MenuItemGroup/index.tsx +6 -5
  18. package/src/Menu/v1/MenuItemGroup/props.ts +1 -1
  19. package/src/Menu/v1/MenuItemSeparator/index.tsx +4 -3
  20. package/src/Menu/v1/index.tsx +8 -7
  21. package/src/Menu/v1/props.ts +1 -1
  22. package/src/Menu/v2/MenuItem/index.tsx +4 -11
  23. package/src/Menu/v2/MenuItem/props.ts +1 -1
  24. package/src/Menu/v2/MenuItemGroup/index.tsx +5 -4
  25. package/src/Menu/v2/MenuItemGroup/props.ts +1 -1
  26. package/src/Menu/v2/MenuItemSeparator/index.tsx +3 -2
  27. package/src/Menu/v2/index.tsx +7 -6
  28. package/src/Menu/v2/props.ts +1 -1
  29. package/src/exports/a.ts +1 -1
  30. package/src/exports/b.ts +1 -1
  31. package/tsconfig.build.tsbuildinfo +1 -1
  32. package/types/Menu/v1/MenuItem/index.d.ts +3 -2
  33. package/types/Menu/v1/MenuItem/index.d.ts.map +1 -1
  34. package/types/Menu/v1/MenuItem/props.d.ts +1 -1
  35. package/types/Menu/v1/MenuItem/props.d.ts.map +1 -1
  36. package/types/Menu/v1/MenuItemGroup/index.d.ts +3 -2
  37. package/types/Menu/v1/MenuItemGroup/index.d.ts.map +1 -1
  38. package/types/Menu/v1/MenuItemGroup/props.d.ts +1 -1
  39. package/types/Menu/v1/MenuItemGroup/props.d.ts.map +1 -1
  40. package/types/Menu/v1/MenuItemSeparator/index.d.ts +1 -0
  41. package/types/Menu/v1/MenuItemSeparator/index.d.ts.map +1 -1
  42. package/types/Menu/v1/index.d.ts +4 -3
  43. package/types/Menu/v1/index.d.ts.map +1 -1
  44. package/types/Menu/v1/props.d.ts +1 -1
  45. package/types/Menu/v1/props.d.ts.map +1 -1
  46. package/types/Menu/v2/MenuItem/index.d.ts +3 -3
  47. package/types/Menu/v2/MenuItem/index.d.ts.map +1 -1
  48. package/types/Menu/v2/MenuItem/props.d.ts +1 -1
  49. package/types/Menu/v2/MenuItem/props.d.ts.map +1 -1
  50. package/types/Menu/v2/MenuItemGroup/index.d.ts +3 -2
  51. package/types/Menu/v2/MenuItemGroup/index.d.ts.map +1 -1
  52. package/types/Menu/v2/MenuItemGroup/props.d.ts +1 -1
  53. package/types/Menu/v2/MenuItemGroup/props.d.ts.map +1 -1
  54. package/types/Menu/v2/MenuItemSeparator/index.d.ts +1 -0
  55. package/types/Menu/v2/MenuItemSeparator/index.d.ts.map +1 -1
  56. package/types/Menu/v2/index.d.ts +4 -3
  57. package/types/Menu/v2/index.d.ts.map +1 -1
  58. package/types/Menu/v2/props.d.ts +1 -1
  59. package/types/Menu/v2/props.d.ts.map +1 -1
  60. package/types/exports/a.d.ts +1 -1
  61. package/types/exports/a.d.ts.map +1 -1
  62. package/types/exports/b.d.ts +1 -1
  63. package/types/exports/b.d.ts.map +1 -1
  64. package/lib/Menu/v1/MenuItem/index.js +0 -235
  65. package/lib/Menu/v1/MenuItem/props.js +0 -31
  66. package/lib/Menu/v1/MenuItem/styles.js +0 -142
  67. package/lib/Menu/v1/MenuItem/theme.js +0 -71
  68. package/lib/Menu/v1/MenuItemGroup/index.js +0 -191
  69. package/lib/Menu/v1/MenuItemGroup/props.js +0 -31
  70. package/lib/Menu/v1/MenuItemGroup/styles.js +0 -66
  71. package/lib/Menu/v1/MenuItemGroup/theme.js +0 -61
  72. package/lib/Menu/v1/MenuItemSeparator/index.js +0 -73
  73. package/lib/Menu/v1/MenuItemSeparator/styles.js +0 -52
  74. package/lib/Menu/v1/MenuItemSeparator/theme.js +0 -51
  75. package/lib/Menu/v1/index.js +0 -438
  76. package/lib/Menu/v1/props.js +0 -31
  77. package/lib/Menu/v1/styles.js +0 -82
  78. package/lib/Menu/v1/theme.js +0 -56
  79. package/lib/Menu/v2/MenuItem/index.js +0 -277
  80. package/lib/Menu/v2/MenuItem/props.js +0 -31
  81. package/lib/Menu/v2/MenuItem/styles.js +0 -154
  82. package/lib/Menu/v2/MenuItemGroup/index.js +0 -190
  83. package/lib/Menu/v2/MenuItemGroup/props.js +0 -31
  84. package/lib/Menu/v2/MenuItemGroup/styles.js +0 -66
  85. package/lib/Menu/v2/MenuItemSeparator/index.js +0 -72
  86. package/lib/Menu/v2/MenuItemSeparator/props.js +0 -34
  87. package/lib/Menu/v2/MenuItemSeparator/styles.js +0 -52
  88. package/lib/Menu/v2/index.js +0 -437
  89. package/lib/Menu/v2/props.js +0 -31
  90. package/lib/Menu/v2/styles.js +0 -64
  91. package/lib/exports/a.js +0 -30
  92. package/lib/exports/b.js +0 -30
  93. package/lib/package.json +0 -1
  94. package/lib/utils/v1/MenuContext.js +0 -43
@@ -1,438 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.Menu = void 0;
8
- Object.defineProperty(exports, "MenuItem", {
9
- enumerable: true,
10
- get: function () {
11
- return _MenuItem.MenuItem;
12
- }
13
- });
14
- Object.defineProperty(exports, "MenuItemGroup", {
15
- enumerable: true,
16
- get: function () {
17
- return _MenuItemGroup.MenuItemGroup;
18
- }
19
- });
20
- Object.defineProperty(exports, "MenuItemSeparator", {
21
- enumerable: true,
22
- get: function () {
23
- return _MenuItemSeparator.MenuItemSeparator;
24
- }
25
- });
26
- exports.default = void 0;
27
- var _react = require("react");
28
- var _keycode = _interopRequireDefault(require("keycode"));
29
- var _v11_ = require("@instructure/ui-popover/v11_6");
30
- var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
31
- var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
32
- var _withDeterministicId = require("@instructure/ui-react-utils/lib/DeterministicIdContext/withDeterministicId.js");
33
- var _console = require("@instructure/console");
34
- var _containsActiveElement = require("@instructure/ui-dom-utils/lib/containsActiveElement.js");
35
- var _MenuContext = require("../../utils/v1/MenuContext");
36
- var _MenuItem = require("./MenuItem");
37
- var _MenuItemGroup = require("./MenuItemGroup");
38
- var _MenuItemSeparator = require("./MenuItemSeparator");
39
- var _emotion = require("@instructure/emotion");
40
- var _styles = _interopRequireDefault(require("./styles"));
41
- var _theme = _interopRequireDefault(require("./theme"));
42
- var _props = require("./props");
43
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
44
- var _dec, _dec2, _class;
45
- /*
46
- * The MIT License (MIT)
47
- *
48
- * Copyright (c) 2015 - present Instructure, Inc.
49
- *
50
- * Permission is hereby granted, free of charge, to any person obtaining a copy
51
- * of this software and associated documentation files (the "Software"), to deal
52
- * in the Software without restriction, including without limitation the rights
53
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
54
- * copies of the Software, and to permit persons to whom the Software is
55
- * furnished to do so, subject to the following conditions:
56
- *
57
- * The above copyright notice and this permission notice shall be included in all
58
- * copies or substantial portions of the Software.
59
- *
60
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
61
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
62
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
63
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
64
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
65
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
66
- * SOFTWARE.
67
- */
68
- /**
69
- ---
70
- category: components
71
- ---
72
- **/
73
- let Menu = exports.Menu = (_dec = (0, _withDeterministicId.withDeterministicId)(), _dec2 = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = _dec2(_class = class Menu extends _react.Component {
74
- static displayName = "Menu";
75
- static componentId = 'Menu';
76
- static allowedProps = _props.allowedProps;
77
- static defaultProps = {
78
- label: null,
79
- disabled: false,
80
- trigger: null,
81
- placement: 'bottom center',
82
- defaultShow: false,
83
- mountNode: null,
84
- constrain: 'window',
85
- shouldHideOnSelect: true,
86
- shouldFocusTriggerOnClose: true,
87
- withArrow: true,
88
- offsetX: 0,
89
- offsetY: 0
90
- };
91
- static Item = _MenuItem.MenuItem;
92
- static Group = _MenuItemGroup.MenuItemGroup;
93
- static Separator = _MenuItemSeparator.MenuItemSeparator;
94
- state = {
95
- hasFocus: false
96
- };
97
- _rootNode = null;
98
- _menuItems = [];
99
- _popover = null;
100
- _trigger = null;
101
- _menu = null;
102
- _labelId = this.props.deterministicId('Menu__label');
103
- _activeSubMenu;
104
- _id;
105
- ref = null;
106
- handleRef = el => {
107
- const {
108
- menuRef
109
- } = this.props;
110
- this._menu = el;
111
- if (typeof menuRef === 'function') {
112
- menuRef(el);
113
- }
114
- // If there is no trigger `<ul>` is the ref, otherwise the trigger
115
- if (!this.props.trigger) {
116
- this.ref = el;
117
- }
118
- };
119
- constructor(props) {
120
- super(props);
121
- this._id = this.props.id || props.deterministicId();
122
- }
123
- componentDidMount() {
124
- this.props.makeStyles?.();
125
- }
126
- componentDidUpdate() {
127
- this.props.makeStyles?.();
128
- }
129
- static contextType = _MenuContext.MenuContext;
130
- registerMenuItem = item => {
131
- this._menuItems.push(item);
132
- };
133
- removeMenuItem = item => {
134
- const index = this.getMenuItemIndex(item);
135
- (0, _console.logError)(index >= 0, '[Menu] Could not find registered menu item.');
136
- if (index >= 0) {
137
- this._menuItems.splice(index, 1);
138
- }
139
- };
140
- get menuItems() {
141
- return this._menuItems;
142
- }
143
- getMenuItemIndex = item => {
144
- return this._menuItems.findIndex(i => i === item);
145
- };
146
- handleTriggerKeyDown = event => {
147
- if (this.props.type === 'flyout' && event.keyCode === _keycode.default.codes.right) {
148
- event.persist();
149
- this.show(event);
150
- }
151
- };
152
- handleTriggerMouseOver = event => {
153
- if (this.props.type === 'flyout') {
154
- this.show(event);
155
- }
156
- };
157
- handleToggle = shown => {
158
- if (typeof this.props.onToggle === 'function') {
159
- this.props.onToggle(shown, this);
160
- }
161
- };
162
- handleMenuKeyDown = event => {
163
- const key = event && event.keyCode;
164
- const {
165
- down,
166
- up,
167
- tab,
168
- left
169
- } = _keycode.default.codes;
170
- const pgdn = _keycode.default.codes['page down'];
171
- const pgup = _keycode.default.codes['page up'];
172
- if (key === down || key === pgdn) {
173
- event.preventDefault();
174
- event.stopPropagation();
175
- this.moveFocus(1);
176
- this.hideActiveSubMenu(event);
177
- } else if (key === up || key === pgup) {
178
- event.preventDefault();
179
- event.stopPropagation();
180
- this.moveFocus(-1);
181
- this.hideActiveSubMenu(event);
182
- } else if (key === tab || key === left) {
183
- event.persist();
184
- this.hide(event);
185
- }
186
- if (typeof this.props.onKeyDown === 'function') {
187
- this.props.onKeyDown(event);
188
- }
189
- };
190
- handleMenuItemSelect = (event, value, selected, item) => {
191
- if (this.props.shouldHideOnSelect) {
192
- this.hide(event);
193
- }
194
- if (typeof this.props.onSelect === 'function') {
195
- this.props.onSelect(event, value, selected, item);
196
- }
197
- };
198
- handleMenuItemFocus = () => {
199
- this.setState({
200
- hasFocus: true
201
- });
202
- };
203
- handleMenuItemBlur = () => {
204
- this.setState({
205
- hasFocus: this.focusedIndex >= 0
206
- });
207
- };
208
- handleMenuItemMouseOver = (event, menuItem) => {
209
- if (this._activeSubMenu && menuItem !== this._activeSubMenu._trigger) {
210
- this.hideActiveSubMenu(event);
211
- }
212
- };
213
- hideActiveSubMenu = event => {
214
- if (this._activeSubMenu) {
215
- this._activeSubMenu.hide(event);
216
- this._activeSubMenu = null;
217
- }
218
- };
219
- handleSubMenuToggle = (shown, subMenu) => {
220
- if (shown) {
221
- this._activeSubMenu = subMenu;
222
- }
223
- };
224
- handleSubMenuDismiss = (event, documentClick) => {
225
- if (event && event.keyCode === _keycode.default.codes.tab || documentClick) {
226
- this.hide(event);
227
- }
228
- };
229
- hide = event => {
230
- if (this._popover) {
231
- this._popover.hide(event);
232
- }
233
- };
234
- show = event => {
235
- if (this._popover) {
236
- this._popover.show(event);
237
- }
238
- };
239
- focus() {
240
- if (this.shown) {
241
- (0, _console.logError)(!!this._menu?.focus, '[Menu] Could not focus the menu.');
242
- this._menu.focus();
243
- } else {
244
- (0, _console.logError)(!!this._trigger?.focus, '[Menu] Could not focus the trigger.');
245
- this._trigger.focus();
246
- }
247
- }
248
- focused() {
249
- if (this.shown) {
250
- return (0, _containsActiveElement.containsActiveElement)(this._menu) || this.state.hasFocus;
251
- } else {
252
- return (0, _containsActiveElement.containsActiveElement)(this._trigger);
253
- }
254
- }
255
- get focusedIndex() {
256
- return this.menuItems.findIndex(item => {
257
- return item && item.focused === true;
258
- });
259
- }
260
- moveFocus(step) {
261
- const count = this.menuItems ? this.menuItems.length : 0;
262
- if (count <= 0) {
263
- return;
264
- }
265
- const current = this.focusedIndex < 0 && step < 0 ? 0 : this.focusedIndex;
266
- const nextItem = this.menuItems[(current + count + step) % count];
267
- (0, _console.logError)(typeof nextItem !== 'undefined' && typeof nextItem.focus !== 'undefined', '[Menu] Could not focus next menu item.');
268
- nextItem.focus();
269
- }
270
- get shown() {
271
- return this._popover ? this._popover.shown : true;
272
- }
273
- renderChildren() {
274
- const {
275
- children,
276
- disabled
277
- } = this.props;
278
- let count = 0;
279
- return _react.Children.map(children, child => {
280
- if (!(0, _matchComponentTypes.matchComponentTypes)(child, ['MenuItemSeparator', 'MenuItem', 'MenuItemGroup', 'Menu'])) {
281
- return;
282
- }
283
- count += 1;
284
- const isTabbable = !this.state.hasFocus && count === 1;
285
- if ((0, _matchComponentTypes.matchComponentTypes)(child, ['MenuItemSeparator'])) {
286
- return child;
287
- }
288
- const menuItemChild = child;
289
- const controls = menuItemChild.props['aria-controls'] || menuItemChild.props.controls || this.props['aria-controls'] || this.props.controls;
290
- if ((0, _matchComponentTypes.matchComponentTypes)(child, ['MenuItem'])) {
291
- return (0, _safeCloneElement.safeCloneElement)(child, {
292
- controls,
293
- children: child.props.children,
294
- disabled: disabled || child.props.disabled,
295
- onFocus: this.handleMenuItemFocus,
296
- onBlur: this.handleMenuItemBlur,
297
- onSelect: this.handleMenuItemSelect,
298
- onMouseOver: this.handleMenuItemMouseOver,
299
- tabIndex: isTabbable ? 0 : -1
300
- });
301
- }
302
- if ((0, _matchComponentTypes.matchComponentTypes)(child, ['MenuItemGroup'])) {
303
- return (0, _safeCloneElement.safeCloneElement)(child, {
304
- label: child.props.label,
305
- controls,
306
- disabled: disabled || child.props.disabled,
307
- onFocus: this.handleMenuItemFocus,
308
- onBlur: this.handleMenuItemBlur,
309
- onSelect: this.handleMenuItemSelect,
310
- onMouseOver: this.handleMenuItemMouseOver,
311
- isTabbable
312
- });
313
- }
314
- if ((0, _matchComponentTypes.matchComponentTypes)(child, ['Menu'])) {
315
- const submenuDisabled = disabled || child.props.disabled;
316
- return (0, _safeCloneElement.safeCloneElement)(child, {
317
- type: 'flyout',
318
- controls,
319
- disabled: submenuDisabled,
320
- onSelect: this.handleMenuItemSelect,
321
- placement: 'end top',
322
- offsetX: -5,
323
- offsetY: 5,
324
- withArrow: false,
325
- onToggle: this.handleSubMenuToggle,
326
- onDismiss: this.handleSubMenuDismiss,
327
- trigger: (0, _jsxRuntime.jsx)(_MenuItem.MenuItem, {
328
- onMouseOver: this.handleMenuItemMouseOver,
329
- onFocus: this.handleMenuItemFocus,
330
- onBlur: this.handleMenuItemBlur,
331
- tabIndex: isTabbable ? 0 : -1,
332
- type: "flyout",
333
- disabled: submenuDisabled,
334
- renderLabelInfo: child.props.renderLabelInfo,
335
- children: child.props.title || child.props.label
336
- })
337
- });
338
- }
339
- return;
340
- });
341
- }
342
- renderMenu() {
343
- const {
344
- disabled,
345
- label,
346
- trigger,
347
- onKeyUp
348
- } = this.props;
349
- const labelledBy = this.props['aria-labelledby'];
350
- const controls = this.props['aria-controls'];
351
- return (0, _jsxRuntime.jsx)(_MenuContext.MenuContext.Provider, {
352
- value: {
353
- removeMenuItem: this.removeMenuItem,
354
- registerMenuItem: this.registerMenuItem
355
- },
356
- children: (0, _jsxRuntime.jsx)("div", {
357
- role: "menu",
358
- "aria-label": label,
359
- tabIndex: 0,
360
- css: this.props.styles?.menu,
361
- "aria-labelledby": labelledBy || (trigger ? this._labelId : undefined),
362
- "aria-controls": controls,
363
- "aria-disabled": disabled ? 'true' : undefined,
364
- onKeyDown: this.handleMenuKeyDown,
365
- onKeyUp: onKeyUp,
366
- ref: this.handleRef,
367
- "data-cid": "Menu",
368
- children: this.renderChildren()
369
- })
370
- });
371
- }
372
- render() {
373
- const {
374
- show,
375
- defaultShow,
376
- placement,
377
- withArrow,
378
- trigger,
379
- mountNode,
380
- popoverRef,
381
- disabled,
382
- onDismiss,
383
- onFocus,
384
- onMouseOver,
385
- positionContainerDisplay,
386
- offsetX,
387
- offsetY
388
- } = this.props;
389
- return trigger ? (0, _jsxRuntime.jsx)(_v11_.Popover, {
390
- "data-cid": "Menu",
391
- isShowingContent: show,
392
- defaultIsShowingContent: defaultShow,
393
- onHideContent: (event, {
394
- documentClick
395
- }) => {
396
- if (typeof onDismiss === 'function') {
397
- onDismiss(event, documentClick);
398
- }
399
- this.handleToggle(false);
400
- },
401
- onShowContent: () => this.handleToggle(true),
402
- mountNode: mountNode,
403
- placement: placement,
404
- withArrow: withArrow,
405
- id: this._id,
406
- on: ['click'],
407
- shouldContainFocus: true,
408
- shouldReturnFocus: true,
409
- onFocus: onFocus,
410
- onMouseOver: onMouseOver,
411
- positionContainerDisplay: positionContainerDisplay,
412
- offsetX: offsetX,
413
- offsetY: offsetY,
414
- elementRef: element => {
415
- this.ref = element;
416
- },
417
- ref: el => {
418
- this._popover = el;
419
- if (typeof popoverRef === 'function') {
420
- popoverRef(el);
421
- }
422
- },
423
- renderTrigger: (0, _safeCloneElement.safeCloneElement)(trigger, {
424
- ref: el => {
425
- this._trigger = el;
426
- },
427
- 'aria-haspopup': true,
428
- id: this._labelId,
429
- onMouseOver: this.handleTriggerMouseOver,
430
- onKeyDown: this.handleTriggerKeyDown,
431
- disabled: trigger.props.disabled || disabled
432
- }),
433
- defaultFocusElement: () => this._popover?._contentElement?.querySelector('[class$="menuItem"]'),
434
- children: this.renderMenu()
435
- }) : this.renderMenu();
436
- }
437
- }) || _class) || _class);
438
- var _default = exports.default = Menu;
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.allowedProps = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- const allowedProps = exports.allowedProps = ['children', 'label', 'disabled', 'trigger', 'placement', 'defaultShow', 'show', 'onToggle', 'onSelect', 'onDismiss', 'onFocus', 'onMouseOver', 'onKeyDown', 'onKeyUp', 'menuRef', 'popoverRef', 'mountNode', 'constrain', 'shouldHideOnSelect', 'shouldFocusTriggerOnClose', 'positionContainerDisplay', 'type', 'id', 'withArrow', 'offsetX', 'offsetY', 'maxHeight', 'renderLabelInfo'];
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * ---
33
- * private: true
34
- * ---
35
- * Generates the style object from the theme and provided additional information
36
- * @param {Object} componentTheme The theme variable object.
37
- * @param {Object} props the props of the component, the style is applied to
38
- * @param {Object} state the state of the component, the style is applied to
39
- * @return {Object} The final style object, which will be used in the component
40
- */
41
- const generateStyle = (componentTheme, props) => {
42
- const maxHeight = props.maxHeight ? {
43
- maxHeight: props.maxHeight,
44
- overflow: 'auto'
45
- } : {};
46
- return {
47
- menu: {
48
- label: 'menu',
49
- ...maxHeight,
50
- minWidth: componentTheme.minWidth,
51
- maxWidth: componentTheme.maxWidth,
52
- listStyleType: 'none',
53
- margin: '0',
54
- padding: '0.25rem 0',
55
- background: componentTheme.background,
56
- borderRadius: componentTheme.borderRadius,
57
- display: 'block',
58
- position: 'relative',
59
- '&::before': {
60
- content: '""',
61
- position: 'absolute',
62
- top: '-0.25rem',
63
- left: '-0.25rem',
64
- right: '-0.25rem',
65
- bottom: '-0.25rem',
66
- border: `${componentTheme.focusBorderWidth} ${componentTheme.focusBorderStyle} ${componentTheme.focusBorderColor}`,
67
- borderRadius: componentTheme.focusBorderRadius,
68
- opacity: 0,
69
- transform: 'scale(0.9)',
70
- pointerEvents: 'none'
71
- },
72
- '&:focus': {
73
- outline: 'none',
74
- '&::before': {
75
- opacity: 1,
76
- transform: 'scale(1)'
77
- }
78
- }
79
- }
80
- };
81
- };
82
- var _default = exports.default = generateStyle;
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- /**
32
- * Generates the theme object for the component from the theme and provided additional information
33
- * @param {Object} theme The actual theme object.
34
- * @return {Object} The final theme object with the overrides and component variables
35
- */
36
- const generateComponentTheme = theme => {
37
- const {
38
- colors,
39
- breakpoints,
40
- borders
41
- } = theme;
42
- const componentVariables = {
43
- minWidth: breakpoints?.xxSmall,
44
- maxWidth: breakpoints?.xSmall,
45
- background: colors?.contrasts?.white1010,
46
- borderRadius: borders?.radiusMedium,
47
- focusBorderStyle: borders?.style,
48
- focusBorderWidth: borders?.widthMedium,
49
- focusBorderColor: colors?.contrasts?.blue4570,
50
- focusBorderRadius: borders?.radiusMedium
51
- };
52
- return {
53
- ...componentVariables
54
- };
55
- };
56
- var _default = exports.default = generateComponentTheme;