@instructure/ui-navigation 8.22.1-snapshot.4 → 8.23.1-snapshot.1
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 +4 -0
- package/es/Navigation/NavigationItem/index.js +17 -8
- package/es/Navigation/NavigationItem/props.js +6 -1
- package/lib/Navigation/NavigationItem/index.js +17 -8
- package/lib/Navigation/NavigationItem/props.js +6 -1
- package/package.json +24 -24
- package/src/Navigation/NavigationItem/index.tsx +15 -10
- package/src/Navigation/NavigationItem/props.ts +6 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Navigation/NavigationItem/index.d.ts +4 -1
- package/types/Navigation/NavigationItem/index.d.ts.map +1 -1
- package/types/Navigation/NavigationItem/props.d.ts +1 -0
- package/types/Navigation/NavigationItem/props.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [8.23.0](https://github.com/instructure/instructure-ui/compare/v8.22.0...v8.23.0) (2022-04-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-navigation
|
|
9
|
+
|
|
6
10
|
# [8.22.0](https://github.com/instructure/instructure-ui/compare/v8.21.0...v8.22.0) (2022-03-31)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/ui-navigation
|
|
@@ -45,6 +45,15 @@ let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
45
45
|
constructor() {
|
|
46
46
|
super(...arguments);
|
|
47
47
|
this.ref = null;
|
|
48
|
+
|
|
49
|
+
this.handleRef = el => {
|
|
50
|
+
const elementRef = this.props.elementRef;
|
|
51
|
+
this.ref = el;
|
|
52
|
+
|
|
53
|
+
if (typeof elementRef === 'function') {
|
|
54
|
+
elementRef(el);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
componentDidMount() {
|
|
@@ -63,7 +72,7 @@ let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
63
72
|
});
|
|
64
73
|
}
|
|
65
74
|
|
|
66
|
-
renderLink() {
|
|
75
|
+
renderLink(addRef) {
|
|
67
76
|
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
68
77
|
|
|
69
78
|
const ElementType = getElementType(NavigationItem, this.props);
|
|
@@ -76,11 +85,9 @@ let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
76
85
|
return jsx(ElementType, Object.assign({}, props, {
|
|
77
86
|
href: href,
|
|
78
87
|
onClick: onClick,
|
|
88
|
+
ref: addRef ? this.handleRef : void 0,
|
|
79
89
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.navigationItem,
|
|
80
|
-
"aria-label": this.props.minimized ? label : void 0
|
|
81
|
-
ref: element => {
|
|
82
|
-
this.ref = element;
|
|
83
|
-
}
|
|
90
|
+
"aria-label": this.props.minimized ? label : void 0
|
|
84
91
|
}), jsx("div", {
|
|
85
92
|
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.icon,
|
|
86
93
|
"aria-hidden": "true"
|
|
@@ -93,10 +100,12 @@ let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
93
100
|
const _this$props4 = this.props,
|
|
94
101
|
minimized = _this$props4.minimized,
|
|
95
102
|
label = _this$props4.label;
|
|
96
|
-
const
|
|
97
|
-
|
|
103
|
+
const hasTooltip = minimized && hasVisibleChildren(label);
|
|
104
|
+
const link = this.renderLink(!hasTooltip);
|
|
105
|
+
return hasTooltip ? jsx(Tooltip, {
|
|
98
106
|
renderTip: label,
|
|
99
|
-
placement: "end"
|
|
107
|
+
placement: "end",
|
|
108
|
+
elementRef: this.handleRef
|
|
100
109
|
}, link) : link;
|
|
101
110
|
}
|
|
102
111
|
|
|
@@ -23,6 +23,11 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
const propTypes = {
|
|
26
|
+
/**
|
|
27
|
+
* The reference to the underlying HTML element
|
|
28
|
+
*/
|
|
29
|
+
elementRef: PropTypes.func,
|
|
30
|
+
|
|
26
31
|
/**
|
|
27
32
|
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
28
33
|
*/
|
|
@@ -58,5 +63,5 @@ const propTypes = {
|
|
|
58
63
|
*/
|
|
59
64
|
minimized: PropTypes.bool
|
|
60
65
|
};
|
|
61
|
-
const allowedProps = ['icon', 'label', 'as', 'href', 'onClick', 'selected', 'minimized'];
|
|
66
|
+
const allowedProps = ['elementRef', 'icon', 'label', 'as', 'href', 'onClick', 'selected', 'minimized'];
|
|
62
67
|
export { propTypes, allowedProps };
|
|
@@ -39,6 +39,15 @@ let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
39
39
|
constructor() {
|
|
40
40
|
super(...arguments);
|
|
41
41
|
this.ref = null;
|
|
42
|
+
|
|
43
|
+
this.handleRef = el => {
|
|
44
|
+
const elementRef = this.props.elementRef;
|
|
45
|
+
this.ref = el;
|
|
46
|
+
|
|
47
|
+
if (typeof elementRef === 'function') {
|
|
48
|
+
elementRef(el);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
componentDidMount() {
|
|
@@ -57,7 +66,7 @@ let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
57
66
|
});
|
|
58
67
|
}
|
|
59
68
|
|
|
60
|
-
renderLink() {
|
|
69
|
+
renderLink(addRef) {
|
|
61
70
|
var _this$props$styles, _this$props$styles2, _this$props$styles3;
|
|
62
71
|
|
|
63
72
|
const ElementType = (0, _getElementType.getElementType)(NavigationItem, this.props);
|
|
@@ -70,11 +79,9 @@ let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
70
79
|
return (0, _emotion.jsx)(ElementType, Object.assign({}, props, {
|
|
71
80
|
href: href,
|
|
72
81
|
onClick: onClick,
|
|
82
|
+
ref: addRef ? this.handleRef : void 0,
|
|
73
83
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.navigationItem,
|
|
74
|
-
"aria-label": this.props.minimized ? label : void 0
|
|
75
|
-
ref: element => {
|
|
76
|
-
this.ref = element;
|
|
77
|
-
}
|
|
84
|
+
"aria-label": this.props.minimized ? label : void 0
|
|
78
85
|
}), (0, _emotion.jsx)("div", {
|
|
79
86
|
css: (_this$props$styles2 = this.props.styles) === null || _this$props$styles2 === void 0 ? void 0 : _this$props$styles2.icon,
|
|
80
87
|
"aria-hidden": "true"
|
|
@@ -87,10 +94,12 @@ let NavigationItem = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.def
|
|
|
87
94
|
const _this$props4 = this.props,
|
|
88
95
|
minimized = _this$props4.minimized,
|
|
89
96
|
label = _this$props4.label;
|
|
90
|
-
const
|
|
91
|
-
|
|
97
|
+
const hasTooltip = minimized && (0, _hasVisibleChildren.hasVisibleChildren)(label);
|
|
98
|
+
const link = this.renderLink(!hasTooltip);
|
|
99
|
+
return hasTooltip ? (0, _emotion.jsx)(_Tooltip.Tooltip, {
|
|
92
100
|
renderTip: label,
|
|
93
|
-
placement: "end"
|
|
101
|
+
placement: "end",
|
|
102
|
+
elementRef: this.handleRef
|
|
94
103
|
}, link) : link;
|
|
95
104
|
}
|
|
96
105
|
|
|
@@ -33,6 +33,11 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
33
33
|
* SOFTWARE.
|
|
34
34
|
*/
|
|
35
35
|
const propTypes = {
|
|
36
|
+
/**
|
|
37
|
+
* The reference to the underlying HTML element
|
|
38
|
+
*/
|
|
39
|
+
elementRef: _propTypes.default.func,
|
|
40
|
+
|
|
36
41
|
/**
|
|
37
42
|
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
38
43
|
*/
|
|
@@ -69,5 +74,5 @@ const propTypes = {
|
|
|
69
74
|
minimized: _propTypes.default.bool
|
|
70
75
|
};
|
|
71
76
|
exports.propTypes = propTypes;
|
|
72
|
-
const allowedProps = ['icon', 'label', 'as', 'href', 'onClick', 'selected', 'minimized'];
|
|
77
|
+
const allowedProps = ['elementRef', 'icon', 'label', 'as', 'href', 'onClick', 'selected', 'minimized'];
|
|
73
78
|
exports.allowedProps = allowedProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-navigation",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.23.1-snapshot.1+cca389181",
|
|
4
4
|
"description": "Main and application level navigational components",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -23,31 +23,31 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@instructure/ui-babel-preset": "8.
|
|
27
|
-
"@instructure/ui-color-utils": "8.
|
|
28
|
-
"@instructure/ui-test-locator": "8.
|
|
29
|
-
"@instructure/ui-test-utils": "8.
|
|
30
|
-
"@instructure/ui-themes": "8.
|
|
26
|
+
"@instructure/ui-babel-preset": "8.23.1-snapshot.1+cca389181",
|
|
27
|
+
"@instructure/ui-color-utils": "8.23.1-snapshot.1+cca389181",
|
|
28
|
+
"@instructure/ui-test-locator": "8.23.1-snapshot.1+cca389181",
|
|
29
|
+
"@instructure/ui-test-utils": "8.23.1-snapshot.1+cca389181",
|
|
30
|
+
"@instructure/ui-themes": "8.23.1-snapshot.1+cca389181"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.13.10",
|
|
34
|
-
"@instructure/console": "8.
|
|
35
|
-
"@instructure/debounce": "8.
|
|
36
|
-
"@instructure/emotion": "8.
|
|
37
|
-
"@instructure/shared-types": "8.
|
|
38
|
-
"@instructure/ui-a11y-content": "8.
|
|
39
|
-
"@instructure/ui-a11y-utils": "8.
|
|
40
|
-
"@instructure/ui-badge": "8.
|
|
41
|
-
"@instructure/ui-dom-utils": "8.
|
|
42
|
-
"@instructure/ui-focusable": "8.
|
|
43
|
-
"@instructure/ui-icons": "8.
|
|
44
|
-
"@instructure/ui-menu": "8.
|
|
45
|
-
"@instructure/ui-prop-types": "8.
|
|
46
|
-
"@instructure/ui-react-utils": "8.
|
|
47
|
-
"@instructure/ui-testable": "8.
|
|
48
|
-
"@instructure/ui-tooltip": "8.
|
|
49
|
-
"@instructure/ui-utils": "8.
|
|
50
|
-
"@instructure/ui-view": "8.
|
|
34
|
+
"@instructure/console": "8.23.1-snapshot.1+cca389181",
|
|
35
|
+
"@instructure/debounce": "8.23.1-snapshot.1+cca389181",
|
|
36
|
+
"@instructure/emotion": "8.23.1-snapshot.1+cca389181",
|
|
37
|
+
"@instructure/shared-types": "8.23.1-snapshot.1+cca389181",
|
|
38
|
+
"@instructure/ui-a11y-content": "8.23.1-snapshot.1+cca389181",
|
|
39
|
+
"@instructure/ui-a11y-utils": "8.23.1-snapshot.1+cca389181",
|
|
40
|
+
"@instructure/ui-badge": "8.23.1-snapshot.1+cca389181",
|
|
41
|
+
"@instructure/ui-dom-utils": "8.23.1-snapshot.1+cca389181",
|
|
42
|
+
"@instructure/ui-focusable": "8.23.1-snapshot.1+cca389181",
|
|
43
|
+
"@instructure/ui-icons": "8.23.1-snapshot.1+cca389181",
|
|
44
|
+
"@instructure/ui-menu": "8.23.1-snapshot.1+cca389181",
|
|
45
|
+
"@instructure/ui-prop-types": "8.23.1-snapshot.1+cca389181",
|
|
46
|
+
"@instructure/ui-react-utils": "8.23.1-snapshot.1+cca389181",
|
|
47
|
+
"@instructure/ui-testable": "8.23.1-snapshot.1+cca389181",
|
|
48
|
+
"@instructure/ui-tooltip": "8.23.1-snapshot.1+cca389181",
|
|
49
|
+
"@instructure/ui-utils": "8.23.1-snapshot.1+cca389181",
|
|
50
|
+
"@instructure/ui-view": "8.23.1-snapshot.1+cca389181",
|
|
51
51
|
"prop-types": "^15"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
59
|
"sideEffects": false,
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "cca3891819b4261fc5748838ab764506acec33fd"
|
|
61
61
|
}
|
|
@@ -59,6 +59,14 @@ class NavigationItem extends Component<NavigationItemProps> {
|
|
|
59
59
|
|
|
60
60
|
ref: Element | null = null
|
|
61
61
|
|
|
62
|
+
handleRef = (el: Element | null) => {
|
|
63
|
+
const { elementRef } = this.props
|
|
64
|
+
this.ref = el
|
|
65
|
+
if (typeof elementRef === 'function') {
|
|
66
|
+
elementRef(el)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
62
70
|
componentDidMount() {
|
|
63
71
|
this.props.makeStyles?.({ minimized: this.props.minimized })
|
|
64
72
|
}
|
|
@@ -67,7 +75,7 @@ class NavigationItem extends Component<NavigationItemProps> {
|
|
|
67
75
|
this.props.makeStyles?.({ minimized: this.props.minimized })
|
|
68
76
|
}
|
|
69
77
|
|
|
70
|
-
renderLink() {
|
|
78
|
+
renderLink(addRef: boolean) {
|
|
71
79
|
const ElementType = getElementType(NavigationItem, this.props)
|
|
72
80
|
|
|
73
81
|
const { href, onClick, icon, label } = this.props
|
|
@@ -77,15 +85,13 @@ class NavigationItem extends Component<NavigationItemProps> {
|
|
|
77
85
|
return (
|
|
78
86
|
//@ts-expect-error TODO: INSTUI-3245
|
|
79
87
|
<ElementType
|
|
88
|
+
// @ts-expect-error TODO: fix TS2590: Expression produces a union type that is too complex to represent.
|
|
80
89
|
{...props}
|
|
81
90
|
href={href}
|
|
82
91
|
onClick={onClick}
|
|
92
|
+
ref={addRef ? this.handleRef : undefined}
|
|
83
93
|
css={this.props.styles?.navigationItem}
|
|
84
94
|
aria-label={this.props.minimized ? label : undefined}
|
|
85
|
-
// @ts-expect-error TODO: fix TS2590: Expression produces a union type that is too complex to represent.
|
|
86
|
-
ref={(element) => {
|
|
87
|
-
this.ref = element
|
|
88
|
-
}}
|
|
89
95
|
>
|
|
90
96
|
<div css={this.props.styles?.icon} aria-hidden="true">
|
|
91
97
|
{icon}
|
|
@@ -99,11 +105,10 @@ class NavigationItem extends Component<NavigationItemProps> {
|
|
|
99
105
|
|
|
100
106
|
render() {
|
|
101
107
|
const { minimized, label } = this.props
|
|
102
|
-
|
|
103
|
-
const link = this.renderLink()
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<Tooltip renderTip={label} placement="end">
|
|
108
|
+
const hasTooltip: boolean = minimized! && hasVisibleChildren(label)
|
|
109
|
+
const link = this.renderLink(!hasTooltip)
|
|
110
|
+
return hasTooltip ? (
|
|
111
|
+
<Tooltip renderTip={label} placement="end" elementRef={this.handleRef}>
|
|
107
112
|
{link}
|
|
108
113
|
</Tooltip>
|
|
109
114
|
) : (
|
|
@@ -32,6 +32,7 @@ import type {
|
|
|
32
32
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
33
33
|
|
|
34
34
|
type NavigationItemOwnProps = {
|
|
35
|
+
elementRef?: (el: Element | null) => void
|
|
35
36
|
icon: React.ReactNode
|
|
36
37
|
label: React.ReactNode
|
|
37
38
|
as?: AsElementType
|
|
@@ -52,6 +53,10 @@ type NavigationItemProps = NavigationItemOwnProps &
|
|
|
52
53
|
type NavigationItemStyle = ComponentStyle<'navigationItem' | 'icon' | 'label'>
|
|
53
54
|
|
|
54
55
|
const propTypes: PropValidators<PropKeys> = {
|
|
56
|
+
/**
|
|
57
|
+
* The reference to the underlying HTML element
|
|
58
|
+
*/
|
|
59
|
+
elementRef: PropTypes.func,
|
|
55
60
|
/**
|
|
56
61
|
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
57
62
|
*/
|
|
@@ -83,6 +88,7 @@ const propTypes: PropValidators<PropKeys> = {
|
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
const allowedProps: AllowedPropKeys = [
|
|
91
|
+
'elementRef',
|
|
86
92
|
'icon',
|
|
87
93
|
'label',
|
|
88
94
|
'as',
|