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