@instructure/ui-global-nav 0.0.0-stage → 11.7.10
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 +0 -0
- package/LICENSE.md +28 -0
- package/README.md +25 -2
- package/es/GlobalNav/v1/CollapseButton/index.js +80 -0
- package/es/GlobalNav/v1/CollapseButton/props.js +1 -0
- package/es/GlobalNav/v1/CollapseButton/styles.js +64 -0
- package/es/GlobalNav/v1/CollapsedSubNav/index.js +59 -0
- package/es/GlobalNav/v1/CollapsedSubNav/props.js +1 -0
- package/es/GlobalNav/v1/CollapsedSubNav/styles.js +82 -0
- package/es/GlobalNav/v1/InstitutionLogo/index.js +93 -0
- package/es/GlobalNav/v1/InstitutionLogo/props.js +1 -0
- package/es/GlobalNav/v1/InstitutionLogo/styles.js +69 -0
- package/es/GlobalNav/v1/MainNavItem/index.js +129 -0
- package/es/GlobalNav/v1/MainNavItem/props.js +1 -0
- package/es/GlobalNav/v1/MainNavItem/styles.js +117 -0
- package/es/GlobalNav/v1/SubNav/index.js +121 -0
- package/es/GlobalNav/v1/SubNav/props.js +1 -0
- package/es/GlobalNav/v1/SubNav/styles.js +52 -0
- package/es/GlobalNav/v1/SubNavItem/index.js +78 -0
- package/es/GlobalNav/v1/SubNavItem/props.js +1 -0
- package/es/GlobalNav/v1/SubNavItem/styles.js +94 -0
- package/es/GlobalNav/v1/SubNavLevel/index.js +160 -0
- package/es/GlobalNav/v1/SubNavLevel/props.js +1 -0
- package/es/GlobalNav/v1/SubNavLevel/styles.js +94 -0
- package/es/GlobalNav/v1/index.js +222 -0
- package/es/GlobalNav/v1/props.js +28 -0
- package/es/GlobalNav/v1/styles.js +110 -0
- package/es/GlobalNav/v1/utils/getItemElementProps.js +64 -0
- package/es/exports/a.js +24 -0
- package/lib/GlobalNav/v1/CollapseButton/index.js +85 -0
- package/lib/GlobalNav/v1/CollapseButton/props.js +5 -0
- package/lib/GlobalNav/v1/CollapseButton/styles.js +70 -0
- package/lib/GlobalNav/v1/CollapsedSubNav/index.js +64 -0
- package/lib/GlobalNav/v1/CollapsedSubNav/props.js +5 -0
- package/lib/GlobalNav/v1/CollapsedSubNav/styles.js +88 -0
- package/lib/GlobalNav/v1/InstitutionLogo/index.js +98 -0
- package/lib/GlobalNav/v1/InstitutionLogo/props.js +5 -0
- package/lib/GlobalNav/v1/InstitutionLogo/styles.js +75 -0
- package/lib/GlobalNav/v1/MainNavItem/index.js +134 -0
- package/lib/GlobalNav/v1/MainNavItem/props.js +5 -0
- package/lib/GlobalNav/v1/MainNavItem/styles.js +123 -0
- package/lib/GlobalNav/v1/SubNav/index.js +128 -0
- package/lib/GlobalNav/v1/SubNav/props.js +5 -0
- package/lib/GlobalNav/v1/SubNav/styles.js +58 -0
- package/lib/GlobalNav/v1/SubNavItem/index.js +83 -0
- package/lib/GlobalNav/v1/SubNavItem/props.js +5 -0
- package/lib/GlobalNav/v1/SubNavItem/styles.js +100 -0
- package/lib/GlobalNav/v1/SubNavLevel/index.js +165 -0
- package/lib/GlobalNav/v1/SubNavLevel/props.js +5 -0
- package/lib/GlobalNav/v1/SubNavLevel/styles.js +100 -0
- package/lib/GlobalNav/v1/index.js +228 -0
- package/lib/GlobalNav/v1/props.js +33 -0
- package/lib/GlobalNav/v1/styles.js +116 -0
- package/lib/GlobalNav/v1/utils/getItemElementProps.js +70 -0
- package/lib/exports/a.js +12 -0
- package/lib/package.json +1 -0
- package/package.json +77 -3
- package/src/GlobalNav/v1/CollapseButton/index.tsx +87 -0
- package/src/GlobalNav/v1/CollapseButton/props.ts +64 -0
- package/src/GlobalNav/v1/CollapseButton/styles.ts +76 -0
- package/src/GlobalNav/v1/CollapsedSubNav/index.tsx +60 -0
- package/src/GlobalNav/v1/CollapsedSubNav/props.ts +42 -0
- package/src/GlobalNav/v1/CollapsedSubNav/styles.ts +92 -0
- package/src/GlobalNav/v1/InstitutionLogo/index.tsx +86 -0
- package/src/GlobalNav/v1/InstitutionLogo/props.ts +42 -0
- package/src/GlobalNav/v1/InstitutionLogo/styles.ts +82 -0
- package/src/GlobalNav/v1/MainNavItem/index.tsx +132 -0
- package/src/GlobalNav/v1/MainNavItem/props.ts +65 -0
- package/src/GlobalNav/v1/MainNavItem/styles.ts +137 -0
- package/src/GlobalNav/v1/README.md +234 -0
- package/src/GlobalNav/v1/SubNav/index.tsx +132 -0
- package/src/GlobalNav/v1/SubNav/props.ts +81 -0
- package/src/GlobalNav/v1/SubNav/styles.ts +58 -0
- package/src/GlobalNav/v1/SubNavItem/index.tsx +79 -0
- package/src/GlobalNav/v1/SubNavItem/props.ts +48 -0
- package/src/GlobalNav/v1/SubNavItem/styles.ts +110 -0
- package/src/GlobalNav/v1/SubNavLevel/index.tsx +193 -0
- package/src/GlobalNav/v1/SubNavLevel/props.ts +75 -0
- package/src/GlobalNav/v1/SubNavLevel/styles.ts +103 -0
- package/src/GlobalNav/v1/index.tsx +256 -0
- package/src/GlobalNav/v1/props.ts +328 -0
- package/src/GlobalNav/v1/styles.ts +132 -0
- package/src/GlobalNav/v1/utils/getItemElementProps.ts +80 -0
- package/src/exports/a.ts +35 -0
- package/tsconfig.build.json +53 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +4 -0
- package/types/GlobalNav/v1/CollapseButton/index.d.ts +11 -0
- package/types/GlobalNav/v1/CollapseButton/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/CollapseButton/props.d.ts +31 -0
- package/types/GlobalNav/v1/CollapseButton/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/CollapseButton/styles.d.ts +22 -0
- package/types/GlobalNav/v1/CollapseButton/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/CollapsedSubNav/index.d.ts +11 -0
- package/types/GlobalNav/v1/CollapsedSubNav/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/CollapsedSubNav/props.d.ts +15 -0
- package/types/GlobalNav/v1/CollapsedSubNav/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/CollapsedSubNav/styles.d.ts +14 -0
- package/types/GlobalNav/v1/CollapsedSubNav/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/InstitutionLogo/index.d.ts +11 -0
- package/types/GlobalNav/v1/InstitutionLogo/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/InstitutionLogo/props.d.ts +15 -0
- package/types/GlobalNav/v1/InstitutionLogo/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/InstitutionLogo/styles.d.ts +20 -0
- package/types/GlobalNav/v1/InstitutionLogo/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/MainNavItem/index.d.ts +11 -0
- package/types/GlobalNav/v1/MainNavItem/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/MainNavItem/props.d.ts +32 -0
- package/types/GlobalNav/v1/MainNavItem/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/MainNavItem/styles.d.ts +19 -0
- package/types/GlobalNav/v1/MainNavItem/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNav/index.d.ts +11 -0
- package/types/GlobalNav/v1/SubNav/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNav/props.d.ts +52 -0
- package/types/GlobalNav/v1/SubNav/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNav/styles.d.ts +13 -0
- package/types/GlobalNav/v1/SubNav/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavItem/index.d.ts +11 -0
- package/types/GlobalNav/v1/SubNavItem/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavItem/props.d.ts +20 -0
- package/types/GlobalNav/v1/SubNavItem/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavItem/styles.d.ts +18 -0
- package/types/GlobalNav/v1/SubNavItem/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavLevel/index.d.ts +11 -0
- package/types/GlobalNav/v1/SubNavLevel/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavLevel/props.d.ts +45 -0
- package/types/GlobalNav/v1/SubNavLevel/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/SubNavLevel/styles.d.ts +14 -0
- package/types/GlobalNav/v1/SubNavLevel/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/index.d.ts +59 -0
- package/types/GlobalNav/v1/index.d.ts.map +1 -0
- package/types/GlobalNav/v1/props.d.ts +247 -0
- package/types/GlobalNav/v1/props.d.ts.map +1 -0
- package/types/GlobalNav/v1/styles.d.ts +23 -0
- package/types/GlobalNav/v1/styles.d.ts.map +1 -0
- package/types/GlobalNav/v1/utils/getItemElementProps.d.ts +37 -0
- package/types/GlobalNav/v1/utils/getItemElementProps.d.ts.map +1 -0
- package/types/exports/a.d.ts +3 -0
- package/types/exports/a.d.ts.map +1 -0
|
@@ -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.SubNav = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _emotion = require("@instructure/emotion");
|
|
10
|
+
var _index = require("../SubNavLevel/index.js");
|
|
11
|
+
var _styles = _interopRequireDefault(require("./styles.js"));
|
|
12
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
13
|
+
/*
|
|
14
|
+
* The MIT License (MIT)
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
17
|
+
*
|
|
18
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
19
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
20
|
+
* in the Software without restriction, including without limitation the rights
|
|
21
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
22
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
23
|
+
* furnished to do so, subject to the following conditions:
|
|
24
|
+
*
|
|
25
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
26
|
+
* copies or substantial portions of the Software.
|
|
27
|
+
*
|
|
28
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
29
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
30
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
31
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
32
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
33
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
34
|
+
* SOFTWARE.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
// the itemIDs of the levels to open so the deepest current item shows, or undefined without one
|
|
38
|
+
const findCurrentPath = subNav => {
|
|
39
|
+
const items = subNav.items ?? [];
|
|
40
|
+
for (const item of items) {
|
|
41
|
+
if (item.subNav) {
|
|
42
|
+
const deeperPath = findCurrentPath(item.subNav);
|
|
43
|
+
if (deeperPath) return [item.itemID, ...deeperPath];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return items.some(item => item.current) ? [] : undefined;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// stops at an itemID that the latest data no longer has, so the deepest level that still exists shows
|
|
50
|
+
const resolveLevels = (subNav, path) => {
|
|
51
|
+
const levels = [{
|
|
52
|
+
subNav
|
|
53
|
+
}];
|
|
54
|
+
for (const itemID of path) {
|
|
55
|
+
const parent = levels[levels.length - 1].subNav;
|
|
56
|
+
const item = parent.items?.find(i => i.itemID === itemID);
|
|
57
|
+
if (!item?.subNav) break;
|
|
58
|
+
levels.push({
|
|
59
|
+
subNav: item.subNav,
|
|
60
|
+
itemID
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return levels;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
---
|
|
68
|
+
private: true
|
|
69
|
+
id: GlobalNav.SubNav
|
|
70
|
+
---
|
|
71
|
+
**/
|
|
72
|
+
const SubNav = props => {
|
|
73
|
+
const {
|
|
74
|
+
subNav,
|
|
75
|
+
subNavId,
|
|
76
|
+
titleId,
|
|
77
|
+
collapsible,
|
|
78
|
+
closeSubNavLabel,
|
|
79
|
+
backLabel,
|
|
80
|
+
onClose,
|
|
81
|
+
focusIntentRef
|
|
82
|
+
} = props;
|
|
83
|
+
const styles = (0, _emotion.useStyleNew)({
|
|
84
|
+
generateStyle: _styles.default,
|
|
85
|
+
componentId: 'SubNav'
|
|
86
|
+
});
|
|
87
|
+
const [path, setPath] = (0, _react.useState)(() => findCurrentPath(subNav) ?? []);
|
|
88
|
+
const levels = resolveLevels(subNav, path);
|
|
89
|
+
const resolvedPath = levels.slice(1).map(level => level.itemID);
|
|
90
|
+
const level = levels[levels.length - 1];
|
|
91
|
+
const parent = levels.length > 1 ? levels[levels.length - 2] : undefined;
|
|
92
|
+
const handleDrillIn = (_event, item) => {
|
|
93
|
+
focusIntentRef.current = {
|
|
94
|
+
target: 'first'
|
|
95
|
+
};
|
|
96
|
+
setPath([...resolvedPath, item.itemID]);
|
|
97
|
+
};
|
|
98
|
+
const handleBack = _event => {
|
|
99
|
+
focusIntentRef.current = {
|
|
100
|
+
target: 'item',
|
|
101
|
+
itemID: resolvedPath[resolvedPath.length - 1]
|
|
102
|
+
};
|
|
103
|
+
setPath(resolvedPath.slice(0, -1));
|
|
104
|
+
};
|
|
105
|
+
return (0, _jsxRuntime.jsx)("nav", {
|
|
106
|
+
id: subNavId,
|
|
107
|
+
"aria-labelledby": titleId,
|
|
108
|
+
css: styles?.subNav,
|
|
109
|
+
children: (0, _jsxRuntime.jsx)(_index.SubNavLevel
|
|
110
|
+
// a new level remounts, which resets its refs, focus and scroll position
|
|
111
|
+
, {
|
|
112
|
+
subNav: level.subNav,
|
|
113
|
+
titleId: titleId,
|
|
114
|
+
collapsible: collapsible,
|
|
115
|
+
closeSubNavLabel: closeSubNavLabel,
|
|
116
|
+
onClose: onClose,
|
|
117
|
+
back: parent && {
|
|
118
|
+
title: parent.subNav.title,
|
|
119
|
+
label: backLabel(parent.subNav.title),
|
|
120
|
+
onClick: handleBack
|
|
121
|
+
},
|
|
122
|
+
onDrillIn: handleDrillIn,
|
|
123
|
+
focusIntentRef: focusIntentRef
|
|
124
|
+
}, JSON.stringify(resolvedPath))
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
exports.SubNav = SubNav;
|
|
128
|
+
var _default = exports.default = SubNav;
|
|
@@ -0,0 +1,58 @@
|
|
|
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 componentTheme The theme variable object.
|
|
37
|
+
* @return The final style object, which will be used in the component
|
|
38
|
+
*/
|
|
39
|
+
const generateStyle = componentTheme => {
|
|
40
|
+
return {
|
|
41
|
+
subNav: {
|
|
42
|
+
label: 'subNav',
|
|
43
|
+
width: componentTheme.width,
|
|
44
|
+
flexShrink: 0,
|
|
45
|
+
boxSizing: 'border-box',
|
|
46
|
+
display: 'flex',
|
|
47
|
+
flexDirection: 'column',
|
|
48
|
+
minHeight: 0,
|
|
49
|
+
backgroundColor: componentTheme.backgroundColor,
|
|
50
|
+
color: componentTheme.textColor,
|
|
51
|
+
borderInlineStart: `0.0625rem solid ${componentTheme.borderColor}`,
|
|
52
|
+
// the panel is the end of the rail card, so it takes the card's end corners
|
|
53
|
+
borderStartEndRadius: 'inherit',
|
|
54
|
+
borderEndEndRadius: 'inherit'
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
var _default = exports.default = generateStyle;
|
|
@@ -0,0 +1,83 @@
|
|
|
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.SubNavItem = void 0;
|
|
8
|
+
var _emotion = require("@instructure/emotion");
|
|
9
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
10
|
+
var _getItemElementProps = require("../utils/getItemElementProps.js");
|
|
11
|
+
var _styles = _interopRequireDefault(require("./styles.js"));
|
|
12
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
13
|
+
/*
|
|
14
|
+
* The MIT License (MIT)
|
|
15
|
+
*
|
|
16
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
17
|
+
*
|
|
18
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
19
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
20
|
+
* in the Software without restriction, including without limitation the rights
|
|
21
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
22
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
23
|
+
* furnished to do so, subject to the following conditions:
|
|
24
|
+
*
|
|
25
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
26
|
+
* copies or substantial portions of the Software.
|
|
27
|
+
*
|
|
28
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
29
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
30
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
31
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
32
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
33
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
34
|
+
* SOFTWARE.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
---
|
|
39
|
+
private: true
|
|
40
|
+
id: GlobalNav.SubNavItem
|
|
41
|
+
---
|
|
42
|
+
**/const SubNavItem = props => {
|
|
43
|
+
const {
|
|
44
|
+
item,
|
|
45
|
+
elementRef,
|
|
46
|
+
onDrillIn
|
|
47
|
+
} = props;
|
|
48
|
+
const styles = (0, _emotion.useStyleNew)({
|
|
49
|
+
generateStyle: _styles.default,
|
|
50
|
+
params: {
|
|
51
|
+
current: !!item.current
|
|
52
|
+
},
|
|
53
|
+
componentId: 'SubNavItem'
|
|
54
|
+
});
|
|
55
|
+
const {
|
|
56
|
+
isLink,
|
|
57
|
+
props: elementProps
|
|
58
|
+
} = (0, _getItemElementProps.getItemElementProps)(item, item.subNav ? event => onDrillIn(event, item) : undefined);
|
|
59
|
+
const content = (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
60
|
+
children: [(0, _jsxRuntime.jsx)("span", {
|
|
61
|
+
css: styles?.label,
|
|
62
|
+
children: item.label
|
|
63
|
+
}), item.subNav && (0, _jsxRuntime.jsx)("span", {
|
|
64
|
+
css: styles?.chevron,
|
|
65
|
+
children: (0, _jsxRuntime.jsx)(_uiIcons.ChevronRightInstUIIcon, {})
|
|
66
|
+
})]
|
|
67
|
+
});
|
|
68
|
+
return (0, _jsxRuntime.jsx)("li", {
|
|
69
|
+
children: isLink ? (0, _jsxRuntime.jsx)("a", {
|
|
70
|
+
...elementProps,
|
|
71
|
+
ref: elementRef,
|
|
72
|
+
css: styles?.item,
|
|
73
|
+
children: content
|
|
74
|
+
}) : (0, _jsxRuntime.jsx)("button", {
|
|
75
|
+
...elementProps,
|
|
76
|
+
ref: elementRef,
|
|
77
|
+
css: styles?.item,
|
|
78
|
+
children: content
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
exports.SubNavItem = SubNavItem;
|
|
83
|
+
var _default = exports.default = SubNavItem;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _emotion = require("@instructure/emotion");
|
|
8
|
+
/*
|
|
9
|
+
* The MIT License (MIT)
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
* furnished to do so, subject to the following conditions:
|
|
19
|
+
*
|
|
20
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
* copies or substantial portions of the Software.
|
|
22
|
+
*
|
|
23
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
* SOFTWARE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* ---
|
|
34
|
+
* private: true
|
|
35
|
+
* ---
|
|
36
|
+
* Generates the style object from the theme and provided additional information
|
|
37
|
+
* @param componentTheme The theme variable object.
|
|
38
|
+
* @param params Additional parameters to customize the style.
|
|
39
|
+
* @param sharedTokens Shared token object that stores common values for the theme.
|
|
40
|
+
* @return The final style object, which will be used in the component
|
|
41
|
+
*/
|
|
42
|
+
const generateStyle = (componentTheme, params, sharedTokens) => {
|
|
43
|
+
const {
|
|
44
|
+
current
|
|
45
|
+
} = params;
|
|
46
|
+
return {
|
|
47
|
+
item: {
|
|
48
|
+
label: 'subNavItem',
|
|
49
|
+
display: 'flex',
|
|
50
|
+
alignItems: 'center',
|
|
51
|
+
gap: componentTheme.gap,
|
|
52
|
+
boxSizing: 'border-box',
|
|
53
|
+
width: '100%',
|
|
54
|
+
margin: 0,
|
|
55
|
+
padding: componentTheme.padding,
|
|
56
|
+
border: 'none',
|
|
57
|
+
borderRadius: componentTheme.borderRadius,
|
|
58
|
+
backgroundColor: current ? componentTheme.selectedBackgroundColor : componentTheme.backgroundColor,
|
|
59
|
+
color: current ? componentTheme.selectedTextColor : componentTheme.textColor,
|
|
60
|
+
fontFamily: componentTheme.fontFamily,
|
|
61
|
+
fontSize: componentTheme.fontSize,
|
|
62
|
+
fontWeight: componentTheme.fontWeight,
|
|
63
|
+
lineHeight: componentTheme.lineHeight,
|
|
64
|
+
textAlign: 'start',
|
|
65
|
+
textDecoration: 'none',
|
|
66
|
+
cursor: 'pointer',
|
|
67
|
+
...(0, _emotion.calcFocusOutlineStyles)({
|
|
68
|
+
...sharedTokens.focusOutline,
|
|
69
|
+
// the `inset` token is 0, so the ring would sit outside the item, where the scrolling panel body clips it
|
|
70
|
+
inset: `calc(-1 * ${sharedTokens.focusOutline.width})`
|
|
71
|
+
}, {
|
|
72
|
+
focusPosition: 'inset'
|
|
73
|
+
}),
|
|
74
|
+
'&:hover': {
|
|
75
|
+
// a page-wide a:hover rule is more specific than the base class
|
|
76
|
+
textDecoration: 'none',
|
|
77
|
+
...(!current && {
|
|
78
|
+
backgroundColor: componentTheme.hoverBackgroundColor,
|
|
79
|
+
color: componentTheme.hoverTextColor
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
...(!current && {
|
|
83
|
+
'&:active': {
|
|
84
|
+
backgroundColor: componentTheme.activeBackgroundColor,
|
|
85
|
+
color: componentTheme.activeTextColor
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
},
|
|
89
|
+
label: {
|
|
90
|
+
label: 'subNavItem__label',
|
|
91
|
+
flex: 1
|
|
92
|
+
},
|
|
93
|
+
chevron: {
|
|
94
|
+
label: 'subNavItem__chevron',
|
|
95
|
+
display: 'flex',
|
|
96
|
+
flexShrink: 0
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
var _default = exports.default = generateStyle;
|
|
@@ -0,0 +1,165 @@
|
|
|
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.SubNavLevel = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _emotion = require("@instructure/emotion");
|
|
10
|
+
var _latest = require("@instructure/ui-buttons/latest");
|
|
11
|
+
var _uiDomUtils = require("@instructure/ui-dom-utils");
|
|
12
|
+
var _uiIcons = require("@instructure/ui-icons");
|
|
13
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
|
14
|
+
var _index = require("../SubNavItem/index.js");
|
|
15
|
+
var _styles = _interopRequireDefault(require("./styles.js"));
|
|
16
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
17
|
+
/*
|
|
18
|
+
* The MIT License (MIT)
|
|
19
|
+
*
|
|
20
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
21
|
+
*
|
|
22
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
23
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
24
|
+
* in the Software without restriction, including without limitation the rights
|
|
25
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
26
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
27
|
+
* furnished to do so, subject to the following conditions:
|
|
28
|
+
*
|
|
29
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
30
|
+
* copies or substantial portions of the Software.
|
|
31
|
+
*
|
|
32
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
33
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
34
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
35
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
36
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
37
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
38
|
+
* SOFTWARE.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
---
|
|
43
|
+
private: true
|
|
44
|
+
id: GlobalNav.SubNavLevel
|
|
45
|
+
---
|
|
46
|
+
**/const SubNavLevel = props => {
|
|
47
|
+
const {
|
|
48
|
+
subNav,
|
|
49
|
+
titleId,
|
|
50
|
+
collapsible,
|
|
51
|
+
closeSubNavLabel,
|
|
52
|
+
onClose,
|
|
53
|
+
back,
|
|
54
|
+
onDrillIn,
|
|
55
|
+
focusIntentRef
|
|
56
|
+
} = props;
|
|
57
|
+
const styles = (0, _emotion.useStyleNew)({
|
|
58
|
+
generateStyle: _styles.default,
|
|
59
|
+
componentId: 'SubNav'
|
|
60
|
+
});
|
|
61
|
+
const itemRefs = (0, _react.useRef)(new Map());
|
|
62
|
+
const closeRef = (0, _react.useRef)(null);
|
|
63
|
+
const focusInsideRef = (0, _react.useRef)(false);
|
|
64
|
+
const rootRef = (0, _react.useRef)(null);
|
|
65
|
+
const bodyRef = (0, _react.useRef)(null);
|
|
66
|
+
(0, _react.useEffect)(() => {
|
|
67
|
+
const root = rootRef.current;
|
|
68
|
+
const intent = focusIntentRef.current;
|
|
69
|
+
const firstElement = (0, _uiDomUtils.findTabbable)(bodyRef.current)[0] ?? closeRef.current;
|
|
70
|
+
if (intent?.target === 'rescue' || intent?.target === 'first') {
|
|
71
|
+
focusIntentRef.current = undefined;
|
|
72
|
+
firstElement?.focus();
|
|
73
|
+
} else if (intent?.target === 'item') {
|
|
74
|
+
focusIntentRef.current = undefined;
|
|
75
|
+
(itemRefs.current.get(intent.itemID) ?? firstElement)?.focus();
|
|
76
|
+
}
|
|
77
|
+
return () => {
|
|
78
|
+
// React fires no blur event for an element it removes, so the flag still says whether focus was inside
|
|
79
|
+
// StrictMode runs this cleanup without removing the level, and then focus is still in it
|
|
80
|
+
if (focusInsideRef.current && !focusIntentRef.current && !root?.contains(document.activeElement)) {
|
|
81
|
+
focusIntentRef.current = {
|
|
82
|
+
target: 'rescue'
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}, [focusIntentRef]);
|
|
87
|
+
const handleBlur = event => {
|
|
88
|
+
focusInsideRef.current = event.currentTarget.contains(event.relatedTarget);
|
|
89
|
+
};
|
|
90
|
+
const handleCloseRef = element => {
|
|
91
|
+
closeRef.current = element;
|
|
92
|
+
};
|
|
93
|
+
const items = subNav.items ?? [];
|
|
94
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
95
|
+
ref: rootRef,
|
|
96
|
+
css: styles?.level,
|
|
97
|
+
onFocus: () => {
|
|
98
|
+
focusInsideRef.current = true;
|
|
99
|
+
},
|
|
100
|
+
onBlur: handleBlur,
|
|
101
|
+
children: [(0, _jsxRuntime.jsxs)("div", {
|
|
102
|
+
css: styles?.header,
|
|
103
|
+
children: [back && (0, _jsxRuntime.jsx)("span", {
|
|
104
|
+
css: styles?.back,
|
|
105
|
+
children: (0, _jsxRuntime.jsx)(_latest.CondensedButton, {
|
|
106
|
+
color: "secondary",
|
|
107
|
+
size: "small"
|
|
108
|
+
// the design shows it as plain text, without a hover background
|
|
109
|
+
,
|
|
110
|
+
themeOverride: {
|
|
111
|
+
secondaryGhostHoverBackground: 'transparent'
|
|
112
|
+
},
|
|
113
|
+
renderIcon: (0, _jsxRuntime.jsx)(_uiIcons.ChevronLeftInstUIIcon, {}),
|
|
114
|
+
"aria-label": back.label
|
|
115
|
+
// the cast is safe: the click event is typed for ViewProps, but React passes the DOM button's event
|
|
116
|
+
,
|
|
117
|
+
onClick: event => back.onClick(event),
|
|
118
|
+
children: back.title
|
|
119
|
+
})
|
|
120
|
+
}), collapsible ? (0, _jsxRuntime.jsx)(_latest.IconButton, {
|
|
121
|
+
screenReaderLabel: closeSubNavLabel,
|
|
122
|
+
renderIcon: _uiIcons.PanelLeftCloseInstUIIcon,
|
|
123
|
+
withBackground: false,
|
|
124
|
+
withBorder: false,
|
|
125
|
+
size: "small",
|
|
126
|
+
elementRef: handleCloseRef
|
|
127
|
+
// the cast is safe: the click event is typed for ViewProps, but React passes the DOM button's event
|
|
128
|
+
,
|
|
129
|
+
onClick: event => onClose(event)
|
|
130
|
+
}) : (0, _jsxRuntime.jsx)(_latest.CloseButton, {
|
|
131
|
+
screenReaderLabel: closeSubNavLabel,
|
|
132
|
+
size: "small",
|
|
133
|
+
elementRef: handleCloseRef
|
|
134
|
+
// the cast is safe: the click event is typed for ViewProps, but React passes the DOM button's event
|
|
135
|
+
,
|
|
136
|
+
onClick: event => onClose(event)
|
|
137
|
+
})]
|
|
138
|
+
}), (0, _jsxRuntime.jsx)("h2", {
|
|
139
|
+
id: titleId,
|
|
140
|
+
css: styles?.title,
|
|
141
|
+
children: subNav.title
|
|
142
|
+
}), (0, _jsxRuntime.jsx)("div", {
|
|
143
|
+
css: styles?.divider
|
|
144
|
+
}), (0, _jsxRuntime.jsx)("div", {
|
|
145
|
+
ref: bodyRef,
|
|
146
|
+
css: styles?.body,
|
|
147
|
+
children: subNav.renderContent !== undefined ? (0, _uiReactUtils.callRenderProp)(subNav.renderContent) : items.length > 0 && (0, _jsxRuntime.jsx)("ul", {
|
|
148
|
+
css: styles?.items,
|
|
149
|
+
children: items.map(item => (0, _jsxRuntime.jsx)(_index.SubNavItem, {
|
|
150
|
+
item: item,
|
|
151
|
+
elementRef: element => {
|
|
152
|
+
if (element) {
|
|
153
|
+
itemRefs.current.set(item.itemID, element);
|
|
154
|
+
} else {
|
|
155
|
+
itemRefs.current.delete(item.itemID);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
onDrillIn: onDrillIn
|
|
159
|
+
}, item.itemID))
|
|
160
|
+
})
|
|
161
|
+
})]
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
exports.SubNavLevel = SubNavLevel;
|
|
165
|
+
var _default = exports.default = SubNavLevel;
|
|
@@ -0,0 +1,100 @@
|
|
|
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 componentTheme The theme variable object.
|
|
37
|
+
* @param sharedTokens Shared token object that stores common values for the theme.
|
|
38
|
+
* @return The final style object, which will be used in the component
|
|
39
|
+
*/
|
|
40
|
+
const generateStyle = (componentTheme, _params, sharedTokens) => {
|
|
41
|
+
const focusRingSize = `calc(${sharedTokens.focusOutline.width} + ${sharedTokens.focusOutline.offset})`;
|
|
42
|
+
return {
|
|
43
|
+
level: {
|
|
44
|
+
label: 'subNavLevel',
|
|
45
|
+
display: 'flex',
|
|
46
|
+
flexDirection: 'column',
|
|
47
|
+
flex: 1,
|
|
48
|
+
minHeight: 0,
|
|
49
|
+
boxSizing: 'border-box',
|
|
50
|
+
gap: componentTheme.gap,
|
|
51
|
+
padding: componentTheme.padding,
|
|
52
|
+
// GlobalNav sets the variable, so the close handle lines up with the rail's collapse button
|
|
53
|
+
paddingTop: `var(--globalNav-collapseButtonTop, ${componentTheme.padding})`
|
|
54
|
+
},
|
|
55
|
+
header: {
|
|
56
|
+
label: 'subNavLevel__header',
|
|
57
|
+
display: 'flex',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
justifyContent: 'flex-end'
|
|
60
|
+
},
|
|
61
|
+
back: {
|
|
62
|
+
label: 'subNavLevel__back',
|
|
63
|
+
// pushes the close handle to the end, and lets a long parent title shrink
|
|
64
|
+
marginInlineEnd: 'auto',
|
|
65
|
+
minWidth: 0
|
|
66
|
+
},
|
|
67
|
+
title: {
|
|
68
|
+
label: 'subNavLevel__title',
|
|
69
|
+
margin: 0,
|
|
70
|
+
fontFamily: componentTheme.titleFontFamily,
|
|
71
|
+
fontSize: componentTheme.titleFontSize,
|
|
72
|
+
fontWeight: componentTheme.titleFontWeight,
|
|
73
|
+
lineHeight: componentTheme.titleLineHeight
|
|
74
|
+
},
|
|
75
|
+
divider: {
|
|
76
|
+
label: 'subNavLevel__divider',
|
|
77
|
+
// SubNav has no divider width token
|
|
78
|
+
borderTop: `0.0625rem solid ${componentTheme.strokeColor}`
|
|
79
|
+
},
|
|
80
|
+
body: {
|
|
81
|
+
label: 'subNavLevel__body',
|
|
82
|
+
flex: 1,
|
|
83
|
+
minHeight: 0,
|
|
84
|
+
overflowY: 'auto',
|
|
85
|
+
// the scroll container clips focus rings that reach past its edges
|
|
86
|
+
padding: focusRingSize,
|
|
87
|
+
margin: `calc(-1 * ${focusRingSize})`
|
|
88
|
+
},
|
|
89
|
+
items: {
|
|
90
|
+
label: 'subNavLevel__items',
|
|
91
|
+
display: 'flex',
|
|
92
|
+
flexDirection: 'column',
|
|
93
|
+
gap: componentTheme.navItemsGap,
|
|
94
|
+
listStyle: 'none',
|
|
95
|
+
margin: 0,
|
|
96
|
+
padding: 0
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
var _default = exports.default = generateStyle;
|