@instructure/ui-breadcrumb 11.7.8-snapshot-2 → 11.7.8-snapshot-3
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 +3 -4
- package/es/Breadcrumb/v2/BreadcrumbLink/index.js +44 -23
- package/es/Breadcrumb/v2/BreadcrumbLink/styles.js +44 -0
- package/es/Breadcrumb/v2/styles.js +1 -10
- package/lib/Breadcrumb/v2/BreadcrumbLink/index.js +49 -29
- package/lib/Breadcrumb/v2/BreadcrumbLink/styles.js +50 -0
- package/lib/Breadcrumb/v2/styles.js +1 -10
- package/package.json +14 -14
- package/src/Breadcrumb/v2/BreadcrumbLink/index.tsx +45 -13
- package/src/Breadcrumb/v2/BreadcrumbLink/props.ts +5 -1
- package/src/Breadcrumb/v2/BreadcrumbLink/styles.ts +47 -0
- package/src/Breadcrumb/v2/styles.ts +1 -12
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Breadcrumb/v2/BreadcrumbLink/index.d.ts +7 -1
- package/types/Breadcrumb/v2/BreadcrumbLink/index.d.ts.map +1 -1
- package/types/Breadcrumb/v2/BreadcrumbLink/props.d.ts +4 -2
- package/types/Breadcrumb/v2/BreadcrumbLink/props.d.ts.map +1 -1
- package/types/Breadcrumb/v2/BreadcrumbLink/styles.d.ts +12 -0
- package/types/Breadcrumb/v2/BreadcrumbLink/styles.d.ts.map +1 -0
- package/types/Breadcrumb/v2/styles.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,12 +3,11 @@
|
|
|
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
|
-
## [11.7.8-snapshot-
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @instructure/ui-breadcrumb
|
|
9
|
-
|
|
6
|
+
## [11.7.8-snapshot-3](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8-snapshot-3) (2026-09-28)
|
|
10
7
|
|
|
8
|
+
### Bug Fixes
|
|
11
9
|
|
|
10
|
+
* **ui-link,ui-breadcrumb,ui-table:** avoid layout shifts on SSR hydration ([d90cd09](https://github.com/instructure/instructure-ui/commit/d90cd09fcf63775879830a1809cd5169acf91b5f))
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
## [11.7.7](https://github.com/instructure/instructure-ui/compare/v11.7.6...v11.7.7) (2026-09-23)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _dec, _class;
|
|
1
2
|
/*
|
|
2
3
|
* The MIT License (MIT)
|
|
3
4
|
*
|
|
@@ -23,10 +24,11 @@
|
|
|
23
24
|
*/
|
|
24
25
|
|
|
25
26
|
import { Component } from 'react';
|
|
26
|
-
import { TruncateText } from '@instructure/ui-truncate-text/latest';
|
|
27
27
|
import { Link } from '@instructure/ui-link/latest';
|
|
28
28
|
import { omitProps } from '@instructure/ui-react-utils';
|
|
29
29
|
import { Tooltip } from '@instructure/ui-tooltip/latest';
|
|
30
|
+
import { withStyleNew } from '@instructure/emotion';
|
|
31
|
+
import generateStyle from './styles.js';
|
|
30
32
|
import { allowedProps } from './props.js';
|
|
31
33
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
34
|
/**
|
|
@@ -35,29 +37,52 @@ parent: Breadcrumb
|
|
|
35
37
|
id: Breadcrumb.Link
|
|
36
38
|
---
|
|
37
39
|
**/
|
|
38
|
-
|
|
39
|
-
class BreadcrumbLink extends Component {
|
|
40
|
+
let BreadcrumbLink = (_dec = withStyleNew(generateStyle), _dec(_class = class BreadcrumbLink extends Component {
|
|
40
41
|
static displayName = 'BreadcrumbLink';
|
|
41
42
|
static componentId = 'Breadcrumb.Link';
|
|
42
43
|
static allowedProps = allowedProps;
|
|
43
44
|
static defaultProps = {};
|
|
44
45
|
ref = null;
|
|
46
|
+
_textRef = null;
|
|
47
|
+
_resizeObserver;
|
|
45
48
|
handleRef = el => {
|
|
46
49
|
this.ref = el;
|
|
47
50
|
};
|
|
51
|
+
handleTextRef = el => {
|
|
52
|
+
this._textRef = el;
|
|
53
|
+
};
|
|
48
54
|
constructor(props) {
|
|
49
55
|
super(props);
|
|
50
56
|
this.state = {
|
|
51
57
|
isTruncated: false
|
|
52
58
|
};
|
|
53
59
|
}
|
|
54
|
-
|
|
60
|
+
componentDidMount() {
|
|
61
|
+
this.props.makeStyles?.();
|
|
62
|
+
if (this._textRef && typeof ResizeObserver !== 'undefined') {
|
|
63
|
+
this._resizeObserver = new ResizeObserver(this.checkTruncation);
|
|
64
|
+
this._resizeObserver.observe(this._textRef);
|
|
65
|
+
}
|
|
66
|
+
this.checkTruncation();
|
|
67
|
+
}
|
|
68
|
+
componentDidUpdate() {
|
|
69
|
+
this.props.makeStyles?.();
|
|
70
|
+
this.checkTruncation();
|
|
71
|
+
}
|
|
72
|
+
componentWillUnmount() {
|
|
73
|
+
this._resizeObserver?.disconnect();
|
|
74
|
+
}
|
|
75
|
+
checkTruncation = () => {
|
|
76
|
+
if (!this._textRef) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const isTruncated = this._textRef.scrollWidth > this._textRef.clientWidth;
|
|
55
80
|
if (isTruncated !== this.state.isTruncated) {
|
|
56
81
|
this.setState({
|
|
57
82
|
isTruncated
|
|
58
83
|
});
|
|
59
84
|
}
|
|
60
|
-
}
|
|
85
|
+
};
|
|
61
86
|
render() {
|
|
62
87
|
const {
|
|
63
88
|
children,
|
|
@@ -67,7 +92,8 @@ class BreadcrumbLink extends Component {
|
|
|
67
92
|
onClick,
|
|
68
93
|
onMouseEnter,
|
|
69
94
|
isCurrentPage,
|
|
70
|
-
size
|
|
95
|
+
size,
|
|
96
|
+
styles
|
|
71
97
|
} = this.props;
|
|
72
98
|
const {
|
|
73
99
|
isTruncated
|
|
@@ -78,7 +104,7 @@ class BreadcrumbLink extends Component {
|
|
|
78
104
|
renderTip: children,
|
|
79
105
|
preventTooltip: !isTruncated
|
|
80
106
|
// this wraps the achor/button tag in a span and puts the aria-describedby on that instead of the anchor/button tag
|
|
81
|
-
// to avoid SRs reading the text twice
|
|
107
|
+
// to avoid SRs reading the text twice
|
|
82
108
|
,
|
|
83
109
|
...(isInteractive && {
|
|
84
110
|
as: 'span'
|
|
@@ -93,29 +119,24 @@ class BreadcrumbLink extends Component {
|
|
|
93
119
|
variant: "standalone",
|
|
94
120
|
elementRef: this.handleRef,
|
|
95
121
|
forceButtonRole: false,
|
|
96
|
-
size: size
|
|
122
|
+
size: size
|
|
123
|
+
// needed so the focus ring shows up
|
|
124
|
+
,
|
|
125
|
+
...(!renderIcon && {
|
|
126
|
+
display: 'block'
|
|
127
|
+
}),
|
|
97
128
|
...(isCurrentPage && {
|
|
98
129
|
'aria-current': 'page'
|
|
99
130
|
}),
|
|
100
|
-
...(isTruncated && {
|
|
101
|
-
...(typeof children === 'string' && {
|
|
102
|
-
'aria-label': children
|
|
103
|
-
}),
|
|
104
|
-
...(!isInteractive && {
|
|
105
|
-
role: 'text'
|
|
106
|
-
})
|
|
107
|
-
}),
|
|
108
131
|
"data-cid": "BreadcrumbLink",
|
|
109
|
-
children: _jsx(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
children: children
|
|
114
|
-
})
|
|
132
|
+
children: _jsx("span", {
|
|
133
|
+
css: styles?.text,
|
|
134
|
+
ref: this.handleTextRef,
|
|
135
|
+
children: children
|
|
115
136
|
})
|
|
116
137
|
})
|
|
117
138
|
});
|
|
118
139
|
}
|
|
119
|
-
}
|
|
140
|
+
}) || _class);
|
|
120
141
|
export default BreadcrumbLink;
|
|
121
142
|
export { BreadcrumbLink };
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
* @return {Object} The final style object, which will be used in the component
|
|
32
|
+
*/
|
|
33
|
+
const generateStyle = _componentTheme => {
|
|
34
|
+
return {
|
|
35
|
+
text: {
|
|
36
|
+
label: 'breadcrumbLink__text',
|
|
37
|
+
display: 'block',
|
|
38
|
+
overflow: 'hidden',
|
|
39
|
+
textOverflow: 'ellipsis',
|
|
40
|
+
whiteSpace: 'nowrap'
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export default generateStyle;
|
|
@@ -54,16 +54,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
54
54
|
crumb: {
|
|
55
55
|
label: 'breadcrumb__crumb',
|
|
56
56
|
boxSizing: 'border-box',
|
|
57
|
-
display: '
|
|
58
|
-
alignItems: 'center',
|
|
59
|
-
// prevent text clipping
|
|
60
|
-
'[data-cid~="TruncateText"]': {
|
|
61
|
-
overflow: 'visible',
|
|
62
|
-
// prevent extra spacing after the '...'
|
|
63
|
-
'& [class*="truncateText__spacer"]': {
|
|
64
|
-
display: 'inline'
|
|
65
|
-
}
|
|
66
|
-
}
|
|
57
|
+
display: 'block'
|
|
67
58
|
},
|
|
68
59
|
separator: {
|
|
69
60
|
label: 'breadcrumb__separator',
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = exports.BreadcrumbLink = void 0;
|
|
7
8
|
var _react = require("react");
|
|
8
|
-
var _latest = require("@instructure/ui-
|
|
9
|
-
var _latest2 = require("@instructure/ui-link/latest");
|
|
9
|
+
var _latest = require("@instructure/ui-link/latest");
|
|
10
10
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
11
|
-
var
|
|
11
|
+
var _latest2 = require("@instructure/ui-tooltip/latest");
|
|
12
|
+
var _emotion = require("@instructure/emotion");
|
|
13
|
+
var _styles = _interopRequireDefault(require("./styles.js"));
|
|
12
14
|
var _props = require("./props.js");
|
|
13
15
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
16
|
+
var _dec, _class;
|
|
14
17
|
/*
|
|
15
18
|
* The MIT License (MIT)
|
|
16
19
|
*
|
|
@@ -34,36 +37,58 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
34
37
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
38
|
* SOFTWARE.
|
|
36
39
|
*/
|
|
37
|
-
|
|
38
40
|
/**
|
|
39
41
|
---
|
|
40
42
|
parent: Breadcrumb
|
|
41
43
|
id: Breadcrumb.Link
|
|
42
44
|
---
|
|
43
45
|
**/
|
|
44
|
-
|
|
45
|
-
class BreadcrumbLink extends _react.Component {
|
|
46
|
+
let BreadcrumbLink = exports.BreadcrumbLink = (_dec = (0, _emotion.withStyleNew)(_styles.default), _dec(_class = class BreadcrumbLink extends _react.Component {
|
|
46
47
|
static displayName = 'BreadcrumbLink';
|
|
47
48
|
static componentId = 'Breadcrumb.Link';
|
|
48
49
|
static allowedProps = _props.allowedProps;
|
|
49
50
|
static defaultProps = {};
|
|
50
51
|
ref = null;
|
|
52
|
+
_textRef = null;
|
|
53
|
+
_resizeObserver;
|
|
51
54
|
handleRef = el => {
|
|
52
55
|
this.ref = el;
|
|
53
56
|
};
|
|
57
|
+
handleTextRef = el => {
|
|
58
|
+
this._textRef = el;
|
|
59
|
+
};
|
|
54
60
|
constructor(props) {
|
|
55
61
|
super(props);
|
|
56
62
|
this.state = {
|
|
57
63
|
isTruncated: false
|
|
58
64
|
};
|
|
59
65
|
}
|
|
60
|
-
|
|
66
|
+
componentDidMount() {
|
|
67
|
+
this.props.makeStyles?.();
|
|
68
|
+
if (this._textRef && typeof ResizeObserver !== 'undefined') {
|
|
69
|
+
this._resizeObserver = new ResizeObserver(this.checkTruncation);
|
|
70
|
+
this._resizeObserver.observe(this._textRef);
|
|
71
|
+
}
|
|
72
|
+
this.checkTruncation();
|
|
73
|
+
}
|
|
74
|
+
componentDidUpdate() {
|
|
75
|
+
this.props.makeStyles?.();
|
|
76
|
+
this.checkTruncation();
|
|
77
|
+
}
|
|
78
|
+
componentWillUnmount() {
|
|
79
|
+
this._resizeObserver?.disconnect();
|
|
80
|
+
}
|
|
81
|
+
checkTruncation = () => {
|
|
82
|
+
if (!this._textRef) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const isTruncated = this._textRef.scrollWidth > this._textRef.clientWidth;
|
|
61
86
|
if (isTruncated !== this.state.isTruncated) {
|
|
62
87
|
this.setState({
|
|
63
88
|
isTruncated
|
|
64
89
|
});
|
|
65
90
|
}
|
|
66
|
-
}
|
|
91
|
+
};
|
|
67
92
|
render() {
|
|
68
93
|
const {
|
|
69
94
|
children,
|
|
@@ -73,23 +98,24 @@ class BreadcrumbLink extends _react.Component {
|
|
|
73
98
|
onClick,
|
|
74
99
|
onMouseEnter,
|
|
75
100
|
isCurrentPage,
|
|
76
|
-
size
|
|
101
|
+
size,
|
|
102
|
+
styles
|
|
77
103
|
} = this.props;
|
|
78
104
|
const {
|
|
79
105
|
isTruncated
|
|
80
106
|
} = this.state;
|
|
81
107
|
const props = (0, _omitProps.omitProps)(this.props, BreadcrumbLink.allowedProps);
|
|
82
108
|
const isInteractive = onClick || href;
|
|
83
|
-
return (0, _jsxRuntime.jsx)(
|
|
109
|
+
return (0, _jsxRuntime.jsx)(_latest2.Tooltip, {
|
|
84
110
|
renderTip: children,
|
|
85
111
|
preventTooltip: !isTruncated
|
|
86
112
|
// this wraps the achor/button tag in a span and puts the aria-describedby on that instead of the anchor/button tag
|
|
87
|
-
// to avoid SRs reading the text twice
|
|
113
|
+
// to avoid SRs reading the text twice
|
|
88
114
|
,
|
|
89
115
|
...(isInteractive && {
|
|
90
116
|
as: 'span'
|
|
91
117
|
}),
|
|
92
|
-
children: (0, _jsxRuntime.jsx)(
|
|
118
|
+
children: (0, _jsxRuntime.jsx)(_latest.Link, {
|
|
93
119
|
...props,
|
|
94
120
|
href: href,
|
|
95
121
|
renderIcon: renderIcon,
|
|
@@ -99,29 +125,23 @@ class BreadcrumbLink extends _react.Component {
|
|
|
99
125
|
variant: "standalone",
|
|
100
126
|
elementRef: this.handleRef,
|
|
101
127
|
forceButtonRole: false,
|
|
102
|
-
size: size
|
|
128
|
+
size: size
|
|
129
|
+
// needed so the focus ring shows up
|
|
130
|
+
,
|
|
131
|
+
...(!renderIcon && {
|
|
132
|
+
display: 'block'
|
|
133
|
+
}),
|
|
103
134
|
...(isCurrentPage && {
|
|
104
135
|
'aria-current': 'page'
|
|
105
136
|
}),
|
|
106
|
-
...(isTruncated && {
|
|
107
|
-
...(typeof children === 'string' && {
|
|
108
|
-
'aria-label': children
|
|
109
|
-
}),
|
|
110
|
-
...(!isInteractive && {
|
|
111
|
-
role: 'text'
|
|
112
|
-
})
|
|
113
|
-
}),
|
|
114
137
|
"data-cid": "BreadcrumbLink",
|
|
115
|
-
children: (0, _jsxRuntime.jsx)(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
children: children
|
|
120
|
-
})
|
|
138
|
+
children: (0, _jsxRuntime.jsx)("span", {
|
|
139
|
+
css: styles?.text,
|
|
140
|
+
ref: this.handleTextRef,
|
|
141
|
+
children: children
|
|
121
142
|
})
|
|
122
143
|
})
|
|
123
144
|
});
|
|
124
145
|
}
|
|
125
|
-
}
|
|
126
|
-
exports.BreadcrumbLink = BreadcrumbLink;
|
|
146
|
+
}) || _class);
|
|
127
147
|
var _default = exports.default = BreadcrumbLink;
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
* @return {Object} The final style object, which will be used in the component
|
|
38
|
+
*/
|
|
39
|
+
const generateStyle = _componentTheme => {
|
|
40
|
+
return {
|
|
41
|
+
text: {
|
|
42
|
+
label: 'breadcrumbLink__text',
|
|
43
|
+
display: 'block',
|
|
44
|
+
overflow: 'hidden',
|
|
45
|
+
textOverflow: 'ellipsis',
|
|
46
|
+
whiteSpace: 'nowrap'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
var _default = exports.default = generateStyle;
|
|
@@ -60,16 +60,7 @@ const generateStyle = (componentTheme, props) => {
|
|
|
60
60
|
crumb: {
|
|
61
61
|
label: 'breadcrumb__crumb',
|
|
62
62
|
boxSizing: 'border-box',
|
|
63
|
-
display: '
|
|
64
|
-
alignItems: 'center',
|
|
65
|
-
// prevent text clipping
|
|
66
|
-
'[data-cid~="TruncateText"]': {
|
|
67
|
-
overflow: 'visible',
|
|
68
|
-
// prevent extra spacing after the '...'
|
|
69
|
-
'& [class*="truncateText__spacer"]': {
|
|
70
|
-
display: 'inline'
|
|
71
|
-
}
|
|
72
|
-
}
|
|
63
|
+
display: 'block'
|
|
73
64
|
},
|
|
74
65
|
separator: {
|
|
75
66
|
label: 'breadcrumb__separator',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-breadcrumb",
|
|
3
|
-
"version": "11.7.8-snapshot-
|
|
3
|
+
"version": "11.7.8-snapshot-3",
|
|
4
4
|
"description": "A breadcrumb component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -15,22 +15,22 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.29.7",
|
|
18
|
-
"@instructure/
|
|
19
|
-
"@instructure/
|
|
20
|
-
"@instructure/
|
|
21
|
-
"@instructure/ui-
|
|
22
|
-
"@instructure/ui-
|
|
23
|
-
"@instructure/
|
|
24
|
-
"@instructure/ui-
|
|
25
|
-
"@instructure/ui-
|
|
26
|
-
"@instructure/ui-utils": "11.7.8-snapshot-
|
|
27
|
-
"@instructure/ui-view": "11.7.8-snapshot-
|
|
18
|
+
"@instructure/emotion": "11.7.8-snapshot-3",
|
|
19
|
+
"@instructure/shared-types": "11.7.8-snapshot-3",
|
|
20
|
+
"@instructure/ui-link": "11.7.8-snapshot-3",
|
|
21
|
+
"@instructure/ui-icons": "11.7.8-snapshot-3",
|
|
22
|
+
"@instructure/ui-react-utils": "11.7.8-snapshot-3",
|
|
23
|
+
"@instructure/ui-tooltip": "11.7.8-snapshot-3",
|
|
24
|
+
"@instructure/ui-themes": "11.7.8-snapshot-3",
|
|
25
|
+
"@instructure/ui-truncate-text": "11.7.8-snapshot-3",
|
|
26
|
+
"@instructure/ui-utils": "11.7.8-snapshot-3",
|
|
27
|
+
"@instructure/ui-view": "11.7.8-snapshot-3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"vitest": "^5.0.0",
|
|
31
|
-
"@instructure/ui-
|
|
32
|
-
"@instructure/ui-
|
|
33
|
-
"@instructure/ui-axe-check": "11.7.8-snapshot-
|
|
31
|
+
"@instructure/ui-babel-preset": "11.7.8-snapshot-3",
|
|
32
|
+
"@instructure/ui-scripts": "11.7.8-snapshot-3",
|
|
33
|
+
"@instructure/ui-axe-check": "11.7.8-snapshot-3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": ">=18 <=19"
|
|
@@ -24,10 +24,12 @@
|
|
|
24
24
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
|
|
27
|
-
import { TruncateText } from '@instructure/ui-truncate-text/latest'
|
|
28
27
|
import { Link } from '@instructure/ui-link/latest'
|
|
29
28
|
import { omitProps } from '@instructure/ui-react-utils'
|
|
30
29
|
import { Tooltip } from '@instructure/ui-tooltip/latest'
|
|
30
|
+
import { withStyleNew } from '@instructure/emotion'
|
|
31
|
+
|
|
32
|
+
import generateStyle from './styles.js'
|
|
31
33
|
|
|
32
34
|
import { allowedProps } from './props.js'
|
|
33
35
|
import type { BreadcrumbLinkProps, BreadcrumbLinkState } from './props'
|
|
@@ -39,6 +41,7 @@ id: Breadcrumb.Link
|
|
|
39
41
|
---
|
|
40
42
|
**/
|
|
41
43
|
|
|
44
|
+
@withStyleNew(generateStyle)
|
|
42
45
|
class BreadcrumbLink extends Component<
|
|
43
46
|
BreadcrumbLinkProps,
|
|
44
47
|
BreadcrumbLinkState
|
|
@@ -50,10 +53,17 @@ class BreadcrumbLink extends Component<
|
|
|
50
53
|
static defaultProps = {}
|
|
51
54
|
|
|
52
55
|
ref: Element | null = null
|
|
56
|
+
private _textRef: HTMLSpanElement | null = null
|
|
57
|
+
private _resizeObserver?: ResizeObserver
|
|
53
58
|
|
|
54
59
|
handleRef = (el: Element | null) => {
|
|
55
60
|
this.ref = el
|
|
56
61
|
}
|
|
62
|
+
|
|
63
|
+
handleTextRef = (el: HTMLSpanElement | null) => {
|
|
64
|
+
this._textRef = el
|
|
65
|
+
}
|
|
66
|
+
|
|
57
67
|
constructor(props: BreadcrumbLinkProps) {
|
|
58
68
|
super(props)
|
|
59
69
|
|
|
@@ -61,7 +71,32 @@ class BreadcrumbLink extends Component<
|
|
|
61
71
|
isTruncated: false
|
|
62
72
|
}
|
|
63
73
|
}
|
|
64
|
-
|
|
74
|
+
|
|
75
|
+
componentDidMount() {
|
|
76
|
+
this.props.makeStyles?.()
|
|
77
|
+
|
|
78
|
+
if (this._textRef && typeof ResizeObserver !== 'undefined') {
|
|
79
|
+
this._resizeObserver = new ResizeObserver(this.checkTruncation)
|
|
80
|
+
this._resizeObserver.observe(this._textRef)
|
|
81
|
+
}
|
|
82
|
+
this.checkTruncation()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
componentDidUpdate() {
|
|
86
|
+
this.props.makeStyles?.()
|
|
87
|
+
this.checkTruncation()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
componentWillUnmount() {
|
|
91
|
+
this._resizeObserver?.disconnect()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
checkTruncation = () => {
|
|
95
|
+
if (!this._textRef) {
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
const isTruncated = this._textRef.scrollWidth > this._textRef.clientWidth
|
|
99
|
+
|
|
65
100
|
if (isTruncated !== this.state.isTruncated) {
|
|
66
101
|
this.setState({ isTruncated })
|
|
67
102
|
}
|
|
@@ -76,7 +111,8 @@ class BreadcrumbLink extends Component<
|
|
|
76
111
|
onClick,
|
|
77
112
|
onMouseEnter,
|
|
78
113
|
isCurrentPage,
|
|
79
|
-
size
|
|
114
|
+
size,
|
|
115
|
+
styles
|
|
80
116
|
} = this.props
|
|
81
117
|
const { isTruncated } = this.state
|
|
82
118
|
const props = omitProps(this.props, BreadcrumbLink.allowedProps)
|
|
@@ -87,7 +123,7 @@ class BreadcrumbLink extends Component<
|
|
|
87
123
|
renderTip={children}
|
|
88
124
|
preventTooltip={!isTruncated}
|
|
89
125
|
// this wraps the achor/button tag in a span and puts the aria-describedby on that instead of the anchor/button tag
|
|
90
|
-
// to avoid SRs reading the text twice
|
|
126
|
+
// to avoid SRs reading the text twice
|
|
91
127
|
{...(isInteractive && { as: 'span' })}
|
|
92
128
|
>
|
|
93
129
|
<Link
|
|
@@ -101,18 +137,14 @@ class BreadcrumbLink extends Component<
|
|
|
101
137
|
elementRef={this.handleRef}
|
|
102
138
|
forceButtonRole={false}
|
|
103
139
|
size={size}
|
|
140
|
+
// needed so the focus ring shows up
|
|
141
|
+
{...(!renderIcon && { display: 'block' })}
|
|
104
142
|
{...(isCurrentPage && { 'aria-current': 'page' })}
|
|
105
|
-
{...(isTruncated && {
|
|
106
|
-
...(typeof children === 'string' && { 'aria-label': children }),
|
|
107
|
-
...(!isInteractive && { role: 'text' })
|
|
108
|
-
})}
|
|
109
143
|
data-cid="BreadcrumbLink"
|
|
110
144
|
>
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
>
|
|
114
|
-
<span aria-hidden={isTruncated}>{children}</span>
|
|
115
|
-
</TruncateText>
|
|
145
|
+
<span css={styles?.text} ref={this.handleTextRef}>
|
|
146
|
+
{children}
|
|
147
|
+
</span>
|
|
116
148
|
</Link>
|
|
117
149
|
</Tooltip>
|
|
118
150
|
)
|
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
} from '@instructure/shared-types'
|
|
31
31
|
import type { ViewOwnProps } from '@instructure/ui-view/latest'
|
|
32
32
|
import type { LinkProps } from '@instructure/ui-link/latest'
|
|
33
|
+
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
33
34
|
|
|
34
35
|
type BreadcrumbLinkOwnProps = {
|
|
35
36
|
/**
|
|
@@ -81,7 +82,10 @@ type BreadcrumbLinkProps = PickPropsWithExceptions<
|
|
|
81
82
|
| 'elementRef'
|
|
82
83
|
> &
|
|
83
84
|
BreadcrumbLinkOwnProps &
|
|
85
|
+
WithStyleProps<null, BreadcrumbLinkStyle> &
|
|
84
86
|
OtherHTMLAttributes<BreadcrumbLinkOwnProps & LinkProps>
|
|
87
|
+
|
|
88
|
+
type BreadcrumbLinkStyle = ComponentStyle<'text'>
|
|
85
89
|
const allowedProps: AllowedPropKeys = [
|
|
86
90
|
'children',
|
|
87
91
|
'href',
|
|
@@ -97,5 +101,5 @@ type BreadcrumbLinkState = {
|
|
|
97
101
|
isTruncated: boolean
|
|
98
102
|
}
|
|
99
103
|
|
|
100
|
-
export type { BreadcrumbLinkProps, BreadcrumbLinkState }
|
|
104
|
+
export type { BreadcrumbLinkProps, BreadcrumbLinkState, BreadcrumbLinkStyle }
|
|
101
105
|
export { allowedProps }
|
|
@@ -0,0 +1,47 @@
|
|
|
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 type { BreadcrumbLinkStyle } from './props'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* ---
|
|
29
|
+
* private: true
|
|
30
|
+
* ---
|
|
31
|
+
* Generates the style object from the theme and provided additional information
|
|
32
|
+
* @param {Object} _componentTheme The theme variable object.
|
|
33
|
+
* @return {Object} The final style object, which will be used in the component
|
|
34
|
+
*/
|
|
35
|
+
const generateStyle = (_componentTheme: never): BreadcrumbLinkStyle => {
|
|
36
|
+
return {
|
|
37
|
+
text: {
|
|
38
|
+
label: 'breadcrumbLink__text',
|
|
39
|
+
display: 'block',
|
|
40
|
+
overflow: 'hidden',
|
|
41
|
+
textOverflow: 'ellipsis',
|
|
42
|
+
whiteSpace: 'nowrap'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default generateStyle
|