@instructure/ui-navigation 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 (95) hide show
  1. package/CHANGELOG.md +36 -286
  2. package/es/AppNav/{Item → v1/Item}/index.js +2 -2
  3. package/es/AppNav/{index.js → v1/index.js} +3 -3
  4. package/es/AppNav/v2/Item/index.js +115 -0
  5. package/{src/index.ts → es/AppNav/v2/Item/props.js} +2 -5
  6. package/es/AppNav/v2/Item/styles.js +85 -0
  7. package/es/AppNav/v2/index.js +123 -0
  8. package/es/AppNav/v2/props.js +26 -0
  9. package/es/AppNav/v2/styles.js +58 -0
  10. package/es/{index.js → exports/a.js} +2 -2
  11. package/es/exports/b.js +25 -0
  12. package/lib/AppNav/v1/Item/index.js +124 -0
  13. package/lib/AppNav/{index.js → v1/index.js} +7 -7
  14. package/lib/AppNav/{Item → v2/Item}/index.js +3 -4
  15. package/lib/AppNav/v2/Item/props.js +31 -0
  16. package/lib/AppNav/v2/Item/styles.js +91 -0
  17. package/lib/AppNav/v2/index.js +128 -0
  18. package/lib/AppNav/v2/props.js +31 -0
  19. package/lib/AppNav/v2/styles.js +64 -0
  20. package/lib/{index.js → exports/a.js} +3 -3
  21. package/lib/exports/b.js +19 -0
  22. package/package.json +51 -29
  23. package/src/AppNav/{Item → v1/Item}/index.tsx +2 -2
  24. package/src/AppNav/{index.tsx → v1/index.tsx} +3 -3
  25. package/src/AppNav/v2/Item/index.tsx +144 -0
  26. package/src/AppNav/v2/Item/props.ts +103 -0
  27. package/src/AppNav/v2/Item/styles.ts +97 -0
  28. package/src/AppNav/v2/README.md +103 -0
  29. package/src/AppNav/v2/index.tsx +166 -0
  30. package/src/AppNav/v2/props.ts +113 -0
  31. package/src/AppNav/v2/styles.ts +62 -0
  32. package/src/exports/a.ts +29 -0
  33. package/src/exports/b.ts +29 -0
  34. package/tsconfig.build.tsbuildinfo +1 -1
  35. package/types/AppNav/v1/Item/index.d.ts.map +1 -0
  36. package/types/AppNav/v1/Item/props.d.ts.map +1 -0
  37. package/types/AppNav/v1/Item/styles.d.ts.map +1 -0
  38. package/types/AppNav/v1/Item/theme.d.ts.map +1 -0
  39. package/types/AppNav/v1/index.d.ts.map +1 -0
  40. package/types/AppNav/v1/props.d.ts.map +1 -0
  41. package/types/AppNav/v1/styles.d.ts.map +1 -0
  42. package/types/AppNav/v1/theme.d.ts.map +1 -0
  43. package/types/AppNav/v2/Item/index.d.ts +39 -0
  44. package/types/AppNav/v2/Item/index.d.ts.map +1 -0
  45. package/types/AppNav/v2/Item/props.d.ts +57 -0
  46. package/types/AppNav/v2/Item/props.d.ts.map +1 -0
  47. package/types/AppNav/v2/Item/styles.d.ts +15 -0
  48. package/types/AppNav/v2/Item/styles.d.ts.map +1 -0
  49. package/types/AppNav/v2/index.d.ts +46 -0
  50. package/types/AppNav/v2/index.d.ts.map +1 -0
  51. package/types/AppNav/v2/props.d.ts +66 -0
  52. package/types/AppNav/v2/props.d.ts.map +1 -0
  53. package/types/AppNav/v2/styles.d.ts +15 -0
  54. package/types/AppNav/v2/styles.d.ts.map +1 -0
  55. package/types/exports/a.d.ts +5 -0
  56. package/types/exports/a.d.ts.map +1 -0
  57. package/types/exports/b.d.ts +5 -0
  58. package/types/exports/b.d.ts.map +1 -0
  59. package/types/AppNav/Item/index.d.ts.map +0 -1
  60. package/types/AppNav/Item/props.d.ts.map +0 -1
  61. package/types/AppNav/Item/styles.d.ts.map +0 -1
  62. package/types/AppNav/Item/theme.d.ts.map +0 -1
  63. package/types/AppNav/index.d.ts.map +0 -1
  64. package/types/AppNav/props.d.ts.map +0 -1
  65. package/types/AppNav/styles.d.ts.map +0 -1
  66. package/types/AppNav/theme.d.ts.map +0 -1
  67. package/types/index.d.ts +0 -5
  68. package/types/index.d.ts.map +0 -1
  69. /package/es/AppNav/{Item → v1/Item}/props.js +0 -0
  70. /package/es/AppNav/{Item → v1/Item}/styles.js +0 -0
  71. /package/es/AppNav/{Item → v1/Item}/theme.js +0 -0
  72. /package/es/AppNav/{props.js → v1/props.js} +0 -0
  73. /package/es/AppNav/{styles.js → v1/styles.js} +0 -0
  74. /package/es/AppNav/{theme.js → v1/theme.js} +0 -0
  75. /package/lib/AppNav/{Item → v1/Item}/props.js +0 -0
  76. /package/lib/AppNav/{Item → v1/Item}/styles.js +0 -0
  77. /package/lib/AppNav/{Item → v1/Item}/theme.js +0 -0
  78. /package/lib/AppNav/{props.js → v1/props.js} +0 -0
  79. /package/lib/AppNav/{styles.js → v1/styles.js} +0 -0
  80. /package/lib/AppNav/{theme.js → v1/theme.js} +0 -0
  81. /package/src/AppNav/{Item → v1/Item}/props.ts +0 -0
  82. /package/src/AppNav/{Item → v1/Item}/styles.ts +0 -0
  83. /package/src/AppNav/{Item → v1/Item}/theme.ts +0 -0
  84. /package/src/AppNav/{README.md → v1/README.md} +0 -0
  85. /package/src/AppNav/{props.ts → v1/props.ts} +0 -0
  86. /package/src/AppNav/{styles.ts → v1/styles.ts} +0 -0
  87. /package/src/AppNav/{theme.ts → v1/theme.ts} +0 -0
  88. /package/types/AppNav/{Item → v1/Item}/index.d.ts +0 -0
  89. /package/types/AppNav/{Item → v1/Item}/props.d.ts +0 -0
  90. /package/types/AppNav/{Item → v1/Item}/styles.d.ts +0 -0
  91. /package/types/AppNav/{Item → v1/Item}/theme.d.ts +0 -0
  92. /package/types/AppNav/{index.d.ts → v1/index.d.ts} +0 -0
  93. /package/types/AppNav/{props.d.ts → v1/props.d.ts} +0 -0
  94. /package/types/AppNav/{styles.d.ts → v1/styles.d.ts} +0 -0
  95. /package/types/AppNav/{theme.d.ts → v1/theme.d.ts} +0 -0
@@ -0,0 +1,115 @@
1
+ var _dec, _class, _Item;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import { Component } from 'react';
27
+ import { logError as error } from '@instructure/console';
28
+ import { callRenderProp, getElementType, matchComponentTypes, passthroughProps } from '@instructure/ui-react-utils';
29
+ import { View } from '@instructure/ui-view/latest';
30
+ import { ScreenReaderContent } from '@instructure/ui-a11y-content';
31
+ import { withStyle } from '@instructure/emotion';
32
+ import generateStyle from "./styles.js";
33
+ import { allowedProps } from "./props.js";
34
+ /**
35
+ ---
36
+ parent: AppNav
37
+ id: AppNav.Item
38
+ ---
39
+ @module Item
40
+ **/
41
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
42
+ let Item = (_dec = withStyle(generateStyle), _dec(_class = (_Item = class Item extends Component {
43
+ constructor(...args) {
44
+ super(...args);
45
+ this.ref = null;
46
+ this.handleRef = el => {
47
+ const elementRef = this.props.elementRef;
48
+ this.ref = el;
49
+ if (typeof elementRef === 'function') {
50
+ elementRef(el);
51
+ }
52
+ };
53
+ this.handleClick = e => {
54
+ const _this$props = this.props,
55
+ isDisabled = _this$props.isDisabled,
56
+ onClick = _this$props.onClick;
57
+ if (isDisabled) {
58
+ e.preventDefault();
59
+ e.stopPropagation();
60
+ } else if (typeof onClick === 'function') {
61
+ onClick(e);
62
+ }
63
+ };
64
+ }
65
+ componentDidMount() {
66
+ var _this$props$makeStyle, _this$props2;
67
+ (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
68
+ }
69
+ componentDidUpdate() {
70
+ var _this$props$makeStyle2, _this$props3;
71
+ (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
72
+ }
73
+ render() {
74
+ var _this$props$styles, _this$props$styles2;
75
+ const ElementType = getElementType(Item, this.props);
76
+ const _this$props4 = this.props,
77
+ renderIcon = _this$props4.renderIcon,
78
+ renderLabel = _this$props4.renderLabel,
79
+ href = _this$props4.href,
80
+ renderAfter = _this$props4.renderAfter,
81
+ cursor = _this$props4.cursor,
82
+ isDisabled = _this$props4.isDisabled;
83
+ const icon = callRenderProp(renderIcon);
84
+ const label = callRenderProp(renderLabel);
85
+ const labelIsForScreenReaders = matchComponentTypes(label, [ScreenReaderContent]);
86
+ if (icon) {
87
+ error(labelIsForScreenReaders, '[AppNav] If an icon is used, the label text should be wrapped in <ScreenReaderContent />.');
88
+ }
89
+ return _jsxs(View, {
90
+ ...passthroughProps(this.props),
91
+ as: ElementType,
92
+ href: href,
93
+ onClick: this.handleClick,
94
+ disabled: isDisabled,
95
+ elementRef: this.handleRef,
96
+ display: "flex",
97
+ position: "relative",
98
+ borderRadius: "medium",
99
+ cursor: isDisabled ? 'not-allowed' : cursor,
100
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.item,
101
+ "data-cid": "AppNav.Item",
102
+ children: [icon, labelIsForScreenReaders ? label : _jsx("span", {
103
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.label,
104
+ children: label
105
+ }), renderAfter && callRenderProp(renderAfter)]
106
+ });
107
+ }
108
+ }, _Item.displayName = "Item", _Item.componentId = 'AppNav.Item', _Item.allowedProps = allowedProps, _Item.defaultProps = {
109
+ children: null,
110
+ isSelected: false,
111
+ cursor: 'pointer',
112
+ isDisabled: false
113
+ }, _Item)) || _class);
114
+ export default Item;
115
+ export { Item };
@@ -22,8 +22,5 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- export { AppNav } from './AppNav'
26
- export { Item as AppNavItem } from './AppNav/Item'
27
-
28
- export type { AppNavProps } from './AppNav/props'
29
- export type { AppNavItemProps } from './AppNav/Item/props'
25
+ const allowedProps = ['renderLabel', 'renderAfter', 'renderIcon', 'href', 'onClick', 'isSelected', 'elementRef', 'as', 'cursor', 'isDisabled'];
26
+ export { allowedProps };
@@ -0,0 +1,85 @@
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
+ /**
26
+ * ---
27
+ * private: true
28
+ * ---
29
+ * Generates the style object from the theme and provided additional information
30
+ * @param {Object} componentTheme The theme variable object.
31
+ * @param {Object} props the props of the component, the style is applied to
32
+ * @param {Object} state the state of the component, the style is applied to
33
+ * @return {Object} The final style object, which will be used in the component
34
+ */
35
+ const generateStyle = (componentTheme, props) => {
36
+ const isSelected = props.isSelected,
37
+ isDisabled = props.isDisabled;
38
+ const itemStyles = {
39
+ appearance: 'none',
40
+ overflow: 'visible',
41
+ direction: 'inherit',
42
+ margin: '0',
43
+ textDecoration: 'none',
44
+ userSelect: 'none',
45
+ touchAction: 'manipulation',
46
+ background: 'transparent',
47
+ border: 'none',
48
+ outline: 'none',
49
+ lineHeight: componentTheme.height,
50
+ padding: `0 ${componentTheme.padding}`,
51
+ alignItems: 'flex-start',
52
+ '&:hover': {
53
+ textDecoration: 'underline',
54
+ textDecorationColor: componentTheme.textColor
55
+ },
56
+ ...(isDisabled && {
57
+ pointerEvents: 'none',
58
+ opacity: 0.5
59
+ })
60
+ };
61
+ return {
62
+ item: {
63
+ label: 'item',
64
+ ...itemStyles,
65
+ // NOTE: needs separate groups for `:is()` and `:-webkit-any()` because of css selector group validation (see https://www.w3.org/TR/selectors-3/#grouping)
66
+ '&:is(a), &:is(button)': itemStyles,
67
+ '&:-webkit-any(a), &:-webkit-any(button)': itemStyles
68
+ },
69
+ label: {
70
+ label: 'item__label',
71
+ whiteSpace: 'nowrap',
72
+ overflow: 'hidden',
73
+ textOverflow: 'ellipsis',
74
+ fontFamily: componentTheme.fontFamily,
75
+ fontSize: componentTheme.fontSize,
76
+ fontWeight: componentTheme.fontWeight,
77
+ color: componentTheme.textColor,
78
+ ...(isSelected && {
79
+ color: componentTheme.textColorSelected,
80
+ textDecoration: 'underline'
81
+ })
82
+ }
83
+ };
84
+ };
85
+ export default generateStyle;
@@ -0,0 +1,123 @@
1
+ var _dec, _class, _AppNav;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import { Component } from 'react';
27
+ import { withStyle } from '@instructure/emotion';
28
+ import { callRenderProp, omitProps } from '@instructure/ui-react-utils';
29
+ import { View } from '@instructure/ui-view/latest';
30
+ import { Menu } from '@instructure/ui-menu/latest';
31
+ import { Item } from "./Item/index.js";
32
+ import generateStyle from "./styles.js";
33
+ import { allowedProps } from "./props.js";
34
+ import { TruncateList } from '@instructure/ui-truncate-list';
35
+
36
+ /**
37
+ ---
38
+ category: components
39
+ ---
40
+ **/
41
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
42
+ let AppNav = (_dec = withStyle(generateStyle), _dec(_class = (_AppNav = class AppNav extends Component {
43
+ constructor(...args) {
44
+ super(...args);
45
+ this.state = {
46
+ isMeasuring: false
47
+ };
48
+ this.ref = null;
49
+ this.handleRef = el => {
50
+ const elementRef = this.props.elementRef;
51
+ this.ref = el;
52
+ if (typeof elementRef === 'function') {
53
+ elementRef(el);
54
+ }
55
+ };
56
+ }
57
+ componentDidMount() {
58
+ var _this$props$makeStyle, _this$props;
59
+ (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
60
+ }
61
+ componentDidUpdate() {
62
+ var _this$props$makeStyle2, _this$props2;
63
+ (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
64
+ }
65
+ renderMenu(items) {
66
+ return _jsx(Menu, {
67
+ trigger: _jsx(AppNav.Item, {
68
+ renderLabel: callRenderProp(this.props.renderTruncateLabel)
69
+ }),
70
+ children: items.map((item, index) => {
71
+ return _jsx(Menu.Item, {
72
+ href: item.props.href ? item.props.href : void 0,
73
+ onClick: item.props.onClick && !item.props.href ? item.props.onClick : void 0,
74
+ children: callRenderProp(item.props.renderLabel)
75
+ }, index);
76
+ })
77
+ });
78
+ }
79
+ render() {
80
+ const _this$props3 = this.props,
81
+ visibleItemsCount = _this$props3.visibleItemsCount,
82
+ screenReaderLabel = _this$props3.screenReaderLabel,
83
+ margin = _this$props3.margin,
84
+ debounce = _this$props3.debounce,
85
+ styles = _this$props3.styles;
86
+ const passthroughProps = View.omitViewProps(omitProps(this.props, AppNav.allowedProps), AppNav);
87
+ const renderBeforeItems = callRenderProp(this.props.renderBeforeItems);
88
+ const renderAfterItems = callRenderProp(this.props.renderAfterItems);
89
+ const hasRenderedContent = renderBeforeItems || renderAfterItems;
90
+ return _jsxs(View, {
91
+ ...passthroughProps,
92
+ as: "nav",
93
+ css: [styles === null || styles === void 0 ? void 0 : styles.appNav, hasRenderedContent ? styles === null || styles === void 0 ? void 0 : styles.alignCenter : ''],
94
+ margin: margin,
95
+ display: hasRenderedContent ? 'flex' : 'block',
96
+ elementRef: this.handleRef,
97
+ "data-cid": "AppNav",
98
+ children: [renderBeforeItems && _jsx("span", {
99
+ children: renderBeforeItems
100
+ }), _jsx(TruncateList, {
101
+ visibleItemsCount: visibleItemsCount,
102
+ debounce: debounce,
103
+ onUpdate: this.props.onUpdate,
104
+ renderHiddenItemMenu: hiddenChildren => this.renderMenu(hiddenChildren),
105
+ itemSpacing: styles === null || styles === void 0 ? void 0 : styles.horizontalMargin,
106
+ fixMenuTriggerWidth: styles === null || styles === void 0 ? void 0 : styles.menuTriggerWidth,
107
+ css: styles === null || styles === void 0 ? void 0 : styles.list,
108
+ "aria-label": callRenderProp(screenReaderLabel),
109
+ children: this.props.children
110
+ }), renderAfterItems && _jsx("span", {
111
+ children: renderAfterItems
112
+ })]
113
+ });
114
+ }
115
+ }, _AppNav.displayName = "AppNav", _AppNav.componentId = 'AppNav', _AppNav.allowedProps = allowedProps, _AppNav.defaultProps = {
116
+ children: null,
117
+ debounce: 300,
118
+ margin: '0',
119
+ renderTruncateLabel: () => 'More',
120
+ visibleItemsCount: 0
121
+ }, _AppNav.Item = Item, _AppNav)) || _class);
122
+ export { AppNav };
123
+ export default AppNav;
@@ -0,0 +1,26 @@
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
+ const allowedProps = ['screenReaderLabel', 'children', 'debounce', 'renderBeforeItems', 'renderAfterItems', 'margin', 'elementRef', 'renderTruncateLabel', 'onUpdate', 'visibleItemsCount'];
26
+ export { allowedProps };
@@ -0,0 +1,58 @@
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
+ /**
26
+ * ---
27
+ * private: true
28
+ * ---
29
+ * Generates the style object from the theme and provided additional information
30
+ * @param {Object} componentTheme The theme variable object.
31
+ * @param {Object} props the props of the component, the style is applied to
32
+ * @param {Object} state the state of the component, the style is applied to
33
+ * @return {Object} The final style object, which will be used in the component
34
+ */
35
+ const generateStyle = componentTheme => {
36
+ return {
37
+ appNav: {
38
+ label: 'appNav',
39
+ fontFamily: componentTheme.fontFamily,
40
+ borderBottom: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`
41
+ },
42
+ alignCenter: {
43
+ alignItems: 'center'
44
+ },
45
+ list: {
46
+ label: 'appNav__list',
47
+ height: componentTheme.height,
48
+ flexGrow: 1,
49
+ flexShrink: 1,
50
+ flexBasis: '0',
51
+ minWidth: '0.0625rem',
52
+ paddingInlineStart: componentTheme.horizontalMargin
53
+ },
54
+ horizontalMargin: componentTheme.horizontalMargin,
55
+ menuTriggerWidth: componentTheme.menuTriggerWidth
56
+ };
57
+ };
58
+ export default generateStyle;
@@ -21,5 +21,5 @@
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 { AppNav } from "./AppNav/index.js";
25
- export { Item as AppNavItem } from "./AppNav/Item/index.js";
24
+ export { AppNav } from "../AppNav/v1/index.js";
25
+ export { Item as AppNavItem } from "../AppNav/v1/Item/index.js";
@@ -0,0 +1,25 @@
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 { AppNav } from "../AppNav/v2/index.js";
25
+ export { Item as AppNavItem } from "../AppNav/v2/Item/index.js";
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.Item = void 0;
8
+ var _react = require("react");
9
+ var _console = require("@instructure/console");
10
+ var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
11
+ var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
12
+ var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
13
+ var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
14
+ var _v11_ = require("@instructure/ui-view/v11_6");
15
+ var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
16
+ var _emotion = require("@instructure/emotion");
17
+ var _styles = _interopRequireDefault(require("./styles"));
18
+ var _theme = _interopRequireDefault(require("./theme"));
19
+ var _props = require("./props");
20
+ var _jsxRuntime = require("@emotion/react/jsx-runtime");
21
+ var _dec, _class, _Item;
22
+ /*
23
+ * The MIT License (MIT)
24
+ *
25
+ * Copyright (c) 2015 - present Instructure, Inc.
26
+ *
27
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
28
+ * of this software and associated documentation files (the "Software"), to deal
29
+ * in the Software without restriction, including without limitation the rights
30
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
31
+ * copies of the Software, and to permit persons to whom the Software is
32
+ * furnished to do so, subject to the following conditions:
33
+ *
34
+ * The above copyright notice and this permission notice shall be included in all
35
+ * copies or substantial portions of the Software.
36
+ *
37
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
42
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43
+ * SOFTWARE.
44
+ */
45
+ /**
46
+ ---
47
+ parent: AppNav
48
+ id: AppNav.Item
49
+ ---
50
+ @module Item
51
+ **/
52
+ let Item = exports.Item = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_Item = class Item extends _react.Component {
53
+ constructor(...args) {
54
+ super(...args);
55
+ this.ref = null;
56
+ this.handleRef = el => {
57
+ const elementRef = this.props.elementRef;
58
+ this.ref = el;
59
+ if (typeof elementRef === 'function') {
60
+ elementRef(el);
61
+ }
62
+ };
63
+ this.handleClick = e => {
64
+ const _this$props = this.props,
65
+ isDisabled = _this$props.isDisabled,
66
+ onClick = _this$props.onClick;
67
+ if (isDisabled) {
68
+ e.preventDefault();
69
+ e.stopPropagation();
70
+ } else if (typeof onClick === 'function') {
71
+ onClick(e);
72
+ }
73
+ };
74
+ }
75
+ componentDidMount() {
76
+ var _this$props$makeStyle, _this$props2;
77
+ (_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
78
+ }
79
+ componentDidUpdate() {
80
+ var _this$props$makeStyle2, _this$props3;
81
+ (_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
82
+ }
83
+ render() {
84
+ var _this$props$styles, _this$props$styles2;
85
+ const ElementType = (0, _getElementType.getElementType)(Item, this.props);
86
+ const _this$props4 = this.props,
87
+ renderIcon = _this$props4.renderIcon,
88
+ renderLabel = _this$props4.renderLabel,
89
+ href = _this$props4.href,
90
+ renderAfter = _this$props4.renderAfter,
91
+ cursor = _this$props4.cursor,
92
+ isDisabled = _this$props4.isDisabled;
93
+ const icon = (0, _callRenderProp.callRenderProp)(renderIcon);
94
+ const label = (0, _callRenderProp.callRenderProp)(renderLabel);
95
+ const labelIsForScreenReaders = (0, _matchComponentTypes.matchComponentTypes)(label, [_ScreenReaderContent.ScreenReaderContent]);
96
+ if (icon) {
97
+ (0, _console.logError)(labelIsForScreenReaders, '[AppNav] If an icon is used, the label text should be wrapped in <ScreenReaderContent />.');
98
+ }
99
+ return (0, _jsxRuntime.jsxs)(_v11_.View, {
100
+ ...(0, _passthroughProps.passthroughProps)(this.props),
101
+ as: ElementType,
102
+ href: href,
103
+ onClick: this.handleClick,
104
+ disabled: isDisabled,
105
+ elementRef: this.handleRef,
106
+ display: "flex",
107
+ position: "relative",
108
+ borderRadius: "medium",
109
+ cursor: isDisabled ? 'not-allowed' : cursor,
110
+ css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.item,
111
+ "data-cid": "AppNav.Item",
112
+ children: [icon, labelIsForScreenReaders ? label : (0, _jsxRuntime.jsx)("span", {
113
+ css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.label,
114
+ children: label
115
+ }), renderAfter && (0, _callRenderProp.callRenderProp)(renderAfter)]
116
+ });
117
+ }
118
+ }, _Item.displayName = "Item", _Item.componentId = 'AppNav.Item', _Item.allowedProps = _props.allowedProps, _Item.defaultProps = {
119
+ children: null,
120
+ isSelected: false,
121
+ cursor: 'pointer',
122
+ isDisabled: false
123
+ }, _Item)) || _class);
124
+ var _default = exports.default = Item;
@@ -9,8 +9,8 @@ var _react = require("react");
9
9
  var _emotion = require("@instructure/emotion");
10
10
  var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
11
11
  var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
12
- var _View = require("@instructure/ui-view/lib/View");
13
- var _Menu = require("@instructure/ui-menu/lib/Menu");
12
+ var _v11_ = require("@instructure/ui-view/v11_6");
13
+ var _v11_2 = require("@instructure/ui-menu/v11_6");
14
14
  var _Item = require("./Item");
15
15
  var _styles = _interopRequireDefault(require("./styles"));
16
16
  var _theme = _interopRequireDefault(require("./theme"));
@@ -46,7 +46,7 @@ var _dec, _class, _AppNav;
46
46
  category: components
47
47
  ---
48
48
  **/
49
- let AppNav = exports.AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_AppNav = class AppNav extends _react.Component {
49
+ let AppNav = exports.AppNav = (_dec = (0, _emotion.withStyleLegacy)(_styles.default, _theme.default), _dec(_class = (_AppNav = class AppNav extends _react.Component {
50
50
  constructor(...args) {
51
51
  super(...args);
52
52
  this.state = {
@@ -70,12 +70,12 @@ let AppNav = exports.AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _
70
70
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
71
71
  }
72
72
  renderMenu(items) {
73
- return (0, _jsxRuntime.jsx)(_Menu.Menu, {
73
+ return (0, _jsxRuntime.jsx)(_v11_2.Menu, {
74
74
  trigger: (0, _jsxRuntime.jsx)(AppNav.Item, {
75
75
  renderLabel: (0, _callRenderProp.callRenderProp)(this.props.renderTruncateLabel)
76
76
  }),
77
77
  children: items.map((item, index) => {
78
- return (0, _jsxRuntime.jsx)(_Menu.Menu.Item, {
78
+ return (0, _jsxRuntime.jsx)(_v11_2.Menu.Item, {
79
79
  href: item.props.href ? item.props.href : void 0,
80
80
  onClick: item.props.onClick && !item.props.href ? item.props.onClick : void 0,
81
81
  children: (0, _callRenderProp.callRenderProp)(item.props.renderLabel)
@@ -90,11 +90,11 @@ let AppNav = exports.AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _
90
90
  margin = _this$props3.margin,
91
91
  debounce = _this$props3.debounce,
92
92
  styles = _this$props3.styles;
93
- const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, AppNav.allowedProps), AppNav);
93
+ const passthroughProps = _v11_.View.omitViewProps((0, _omitProps.omitProps)(this.props, AppNav.allowedProps), AppNav);
94
94
  const renderBeforeItems = (0, _callRenderProp.callRenderProp)(this.props.renderBeforeItems);
95
95
  const renderAfterItems = (0, _callRenderProp.callRenderProp)(this.props.renderAfterItems);
96
96
  const hasRenderedContent = renderBeforeItems || renderAfterItems;
97
- return (0, _jsxRuntime.jsxs)(_View.View, {
97
+ return (0, _jsxRuntime.jsxs)(_v11_.View, {
98
98
  ...passthroughProps,
99
99
  as: "nav",
100
100
  css: [styles === null || styles === void 0 ? void 0 : styles.appNav, hasRenderedContent ? styles === null || styles === void 0 ? void 0 : styles.alignCenter : ''],
@@ -11,11 +11,10 @@ var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js
11
11
  var _getElementType = require("@instructure/ui-react-utils/lib/getElementType.js");
12
12
  var _matchComponentTypes = require("@instructure/ui-react-utils/lib/matchComponentTypes.js");
13
13
  var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
14
- var _View = require("@instructure/ui-view/lib/View");
14
+ var _latest = require("@instructure/ui-view/latest");
15
15
  var _ScreenReaderContent = require("@instructure/ui-a11y-content/lib/ScreenReaderContent");
16
16
  var _emotion = require("@instructure/emotion");
17
17
  var _styles = _interopRequireDefault(require("./styles"));
18
- var _theme = _interopRequireDefault(require("./theme"));
19
18
  var _props = require("./props");
20
19
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
21
20
  var _dec, _class, _Item;
@@ -49,7 +48,7 @@ id: AppNav.Item
49
48
  ---
50
49
  @module Item
51
50
  **/
52
- let Item = exports.Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec(_class = (_Item = class Item extends _react.Component {
51
+ let Item = exports.Item = (_dec = (0, _emotion.withStyle)(_styles.default), _dec(_class = (_Item = class Item extends _react.Component {
53
52
  constructor(...args) {
54
53
  super(...args);
55
54
  this.ref = null;
@@ -96,7 +95,7 @@ let Item = exports.Item = (_dec = (0, _emotion.withStyle)(_styles.default, _them
96
95
  if (icon) {
97
96
  (0, _console.logError)(labelIsForScreenReaders, '[AppNav] If an icon is used, the label text should be wrapped in <ScreenReaderContent />.');
98
97
  }
99
- return (0, _jsxRuntime.jsxs)(_View.View, {
98
+ return (0, _jsxRuntime.jsxs)(_latest.View, {
100
99
  ...(0, _passthroughProps.passthroughProps)(this.props),
101
100
  as: ElementType,
102
101
  href: href,