@ohos-ports/instructure-ui-breadcrumb 11.7.5-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +1330 -0
  2. package/LICENSE.md +28 -0
  3. package/README.md +46 -0
  4. package/es/Breadcrumb/v1/BreadcrumbLink/index.js +119 -0
  5. package/es/Breadcrumb/v1/BreadcrumbLink/props.js +26 -0
  6. package/es/Breadcrumb/v1/index.js +113 -0
  7. package/es/Breadcrumb/v1/props.js +26 -0
  8. package/es/Breadcrumb/v1/styles.js +106 -0
  9. package/es/Breadcrumb/v1/theme.js +49 -0
  10. package/es/Breadcrumb/v2/BreadcrumbLink/index.js +121 -0
  11. package/es/Breadcrumb/v2/BreadcrumbLink/props.js +26 -0
  12. package/es/Breadcrumb/v2/index.js +133 -0
  13. package/es/Breadcrumb/v2/props.js +26 -0
  14. package/es/Breadcrumb/v2/styles.js +77 -0
  15. package/es/exports/a.js +24 -0
  16. package/es/exports/b.js +24 -0
  17. package/lib/Breadcrumb/v1/BreadcrumbLink/index.js +125 -0
  18. package/lib/Breadcrumb/v1/BreadcrumbLink/props.js +31 -0
  19. package/lib/Breadcrumb/v1/index.js +125 -0
  20. package/lib/Breadcrumb/v1/props.js +31 -0
  21. package/lib/Breadcrumb/v1/styles.js +112 -0
  22. package/lib/Breadcrumb/v1/theme.js +55 -0
  23. package/lib/Breadcrumb/v2/BreadcrumbLink/index.js +127 -0
  24. package/lib/Breadcrumb/v2/BreadcrumbLink/props.js +31 -0
  25. package/lib/Breadcrumb/v2/index.js +145 -0
  26. package/lib/Breadcrumb/v2/props.js +31 -0
  27. package/lib/Breadcrumb/v2/styles.js +83 -0
  28. package/lib/exports/a.js +18 -0
  29. package/lib/exports/b.js +18 -0
  30. package/lib/package.json +1 -0
  31. package/package.json +90 -0
  32. package/scripts/fix-instructure-exports.js +137 -0
  33. package/src/Breadcrumb/v1/BreadcrumbLink/index.tsx +122 -0
  34. package/src/Breadcrumb/v1/BreadcrumbLink/props.ts +102 -0
  35. package/src/Breadcrumb/v1/README.md +141 -0
  36. package/src/Breadcrumb/v1/index.tsx +143 -0
  37. package/src/Breadcrumb/v1/props.ts +63 -0
  38. package/src/Breadcrumb/v1/styles.ts +116 -0
  39. package/src/Breadcrumb/v1/theme.ts +55 -0
  40. package/src/Breadcrumb/v2/BreadcrumbLink/index.tsx +123 -0
  41. package/src/Breadcrumb/v2/BreadcrumbLink/props.ts +101 -0
  42. package/src/Breadcrumb/v2/README.md +141 -0
  43. package/src/Breadcrumb/v2/index.tsx +157 -0
  44. package/src/Breadcrumb/v2/props.ts +64 -0
  45. package/src/Breadcrumb/v2/styles.ts +86 -0
  46. package/src/exports/a.ts +27 -0
  47. package/src/exports/b.ts +27 -0
  48. package/tsconfig.build.json +24 -0
  49. package/tsconfig.build.tsbuildinfo +1 -0
  50. package/tsconfig.json +4 -0
  51. package/types/Breadcrumb/v1/BreadcrumbLink/index.d.ts +31 -0
  52. package/types/Breadcrumb/v1/BreadcrumbLink/index.d.ts.map +1 -0
  53. package/types/Breadcrumb/v1/BreadcrumbLink/props.d.ts +49 -0
  54. package/types/Breadcrumb/v1/BreadcrumbLink/props.d.ts.map +1 -0
  55. package/types/Breadcrumb/v1/index.d.ts +35 -0
  56. package/types/Breadcrumb/v1/index.d.ts.map +1 -0
  57. package/types/Breadcrumb/v1/props.d.ts +30 -0
  58. package/types/Breadcrumb/v1/props.d.ts.map +1 -0
  59. package/types/Breadcrumb/v1/styles.d.ts +15 -0
  60. package/types/Breadcrumb/v1/styles.d.ts.map +1 -0
  61. package/types/Breadcrumb/v1/theme.d.ts +10 -0
  62. package/types/Breadcrumb/v1/theme.d.ts.map +1 -0
  63. package/types/Breadcrumb/v2/BreadcrumbLink/index.d.ts +31 -0
  64. package/types/Breadcrumb/v2/BreadcrumbLink/index.d.ts.map +1 -0
  65. package/types/Breadcrumb/v2/BreadcrumbLink/props.d.ts +49 -0
  66. package/types/Breadcrumb/v2/BreadcrumbLink/props.d.ts.map +1 -0
  67. package/types/Breadcrumb/v2/index.d.ts +35 -0
  68. package/types/Breadcrumb/v2/index.d.ts.map +1 -0
  69. package/types/Breadcrumb/v2/props.d.ts +30 -0
  70. package/types/Breadcrumb/v2/props.d.ts.map +1 -0
  71. package/types/Breadcrumb/v2/styles.d.ts +14 -0
  72. package/types/Breadcrumb/v2/styles.d.ts.map +1 -0
  73. package/types/exports/a.d.ts +4 -0
  74. package/types/exports/a.d.ts.map +1 -0
  75. package/types/exports/b.d.ts +4 -0
  76. package/types/exports/b.d.ts.map +1 -0
package/LICENSE.md ADDED
@@ -0,0 +1,28 @@
1
+ ---
2
+ title: The MIT License (MIT)
3
+ category: Getting Started
4
+ order: 9
5
+ isWIP: true
6
+ ---
7
+
8
+ # The MIT License (MIT)
9
+
10
+ Copyright (c) 2015 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.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ ## ui-breadcrumb
2
+
3
+ [![npm][npm]][npm-url]
4
+ [![MIT License][license-badge]][license]
5
+ [![Code of Conduct][coc-badge]][coc]
6
+
7
+ A breadcrumb component.
8
+
9
+ ### Components
10
+
11
+ The `ui-breadcrumb` package contains the following:
12
+
13
+ - [Breadcrumb](Breadcrumb)
14
+
15
+ ### Installation
16
+
17
+ ```sh
18
+ npm install @instructure/ui-breadcrumb
19
+ ```
20
+
21
+ ### Usage
22
+
23
+ ```jsx
24
+ ---
25
+ type: code
26
+ ---
27
+ import React from 'react'
28
+ import { Breadcrumb } from '@instructure/ui-breadcrumb'
29
+
30
+ const MyBreadcrumb = () => {
31
+ return (
32
+ <Breadcrumb label="You are here">
33
+ <Breadcrumb.Link href="https://instructure.github.io/instructure-ui/">Course A</Breadcrumb.Link>
34
+ <Breadcrumb.Link href="https://instructure.github.io/instructure-ui/">Modules</Breadcrumb.Link>
35
+ <Breadcrumb.Link>A Great Module</Breadcrumb.Link>
36
+ </Breadcrumb>
37
+ )
38
+ }
39
+ ```
40
+
41
+ [npm]: https://img.shields.io/npm/v/@instructure/ui-breadcrumb.svg
42
+ [npm-url]: https://npmjs.com/package/@instructure/ui-breadcrumb
43
+ [license-badge]: https://img.shields.io/npm/l/instructure-ui.svg?style=flat-square
44
+ [license]: https://github.com/instructure/instructure-ui/blob/master/LICENSE.md
45
+ [coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
46
+ [coc]: https://github.com/instructure/instructure-ui/blob/master/CODE_OF_CONDUCT.md
@@ -0,0 +1,119 @@
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 { Component } from 'react';
26
+ import { TruncateText } from '@instructure/ui-truncate-text/v11_6';
27
+ import { Link } from '@instructure/ui-link/v11_6';
28
+ import { omitProps } from '@instructure/ui-react-utils';
29
+ import { Tooltip } from '@instructure/ui-tooltip/v11_6';
30
+ import { allowedProps } from './props.js';
31
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
32
+ /**
33
+ ---
34
+ parent: Breadcrumb
35
+ id: Breadcrumb.Link
36
+ ---
37
+ **/
38
+
39
+ class BreadcrumbLink extends Component {
40
+ static displayName = 'BreadcrumbLink';
41
+ static componentId = 'Breadcrumb.Link';
42
+ static allowedProps = allowedProps;
43
+ static defaultProps = {};
44
+ ref = null;
45
+ handleRef = el => {
46
+ this.ref = el;
47
+ };
48
+ constructor(props) {
49
+ super(props);
50
+ this.state = {
51
+ isTruncated: false
52
+ };
53
+ }
54
+ handleTruncation(isTruncated) {
55
+ if (isTruncated !== this.state.isTruncated) {
56
+ this.setState({
57
+ isTruncated
58
+ });
59
+ }
60
+ }
61
+ render() {
62
+ const {
63
+ children,
64
+ href,
65
+ renderIcon,
66
+ iconPlacement,
67
+ onClick,
68
+ onMouseEnter,
69
+ isCurrentPage
70
+ } = this.props;
71
+ const {
72
+ isTruncated
73
+ } = this.state;
74
+ const props = omitProps(this.props, BreadcrumbLink.allowedProps);
75
+ const isInteractive = onClick || href;
76
+ return _jsx(Tooltip, {
77
+ renderTip: children,
78
+ preventTooltip: !isTruncated
79
+ // this wraps the achor/button tag in a span and puts the aria-describedby on that instead of the anchor/button tag
80
+ // to avoid SRs reading the text twice when there is already an aria-label
81
+ ,
82
+ ...(isInteractive && {
83
+ as: 'span'
84
+ }),
85
+ children: _jsx(Link, {
86
+ ...props,
87
+ href: href,
88
+ renderIcon: renderIcon,
89
+ iconPlacement: iconPlacement,
90
+ onClick: onClick,
91
+ onMouseEnter: onMouseEnter,
92
+ isWithinText: false,
93
+ elementRef: this.handleRef,
94
+ forceButtonRole: false,
95
+ ...(isCurrentPage && {
96
+ 'aria-current': 'page'
97
+ }),
98
+ ...(isTruncated && {
99
+ ...(typeof children === 'string' && {
100
+ 'aria-label': children
101
+ }),
102
+ ...(!isInteractive && {
103
+ role: 'text'
104
+ })
105
+ }),
106
+ "data-cid": "BreadcrumbLink",
107
+ children: _jsx(TruncateText, {
108
+ onUpdate: isTruncated => this.handleTruncation(isTruncated),
109
+ children: _jsx("span", {
110
+ "aria-hidden": isTruncated,
111
+ children: children
112
+ })
113
+ })
114
+ })
115
+ });
116
+ }
117
+ }
118
+ export default BreadcrumbLink;
119
+ export { BreadcrumbLink };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const allowedProps = ['children', 'href', 'iconPlacement', 'onClick', 'onMouseEnter', 'renderIcon', 'size', 'isCurrentPage'];
26
+ export { allowedProps };
@@ -0,0 +1,113 @@
1
+ var _dec, _class;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import { isValidElement, cloneElement, Children, Component } from 'react';
27
+ import { View } from '@instructure/ui-view/v11_6';
28
+ import { withStyle } from '@instructure/emotion';
29
+ import { IconArrowOpenEndSolid } from '@instructure/ui-icons';
30
+ import { BreadcrumbLink } from './BreadcrumbLink/index.js';
31
+ import generateStyle from './styles.js';
32
+ import generateComponentTheme from './theme.js';
33
+ import { allowedProps } from './props.js';
34
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
35
+ /**
36
+ ---
37
+ category: components
38
+ ---
39
+ **/
40
+ let Breadcrumb = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = class Breadcrumb extends Component {
41
+ static displayName = 'Breadcrumb';
42
+ static componentId = 'Breadcrumb';
43
+ static allowedProps = allowedProps;
44
+ static defaultProps = {
45
+ size: 'medium',
46
+ children: null
47
+ };
48
+ ref = null;
49
+ handleRef = el => {
50
+ this.ref = el;
51
+ };
52
+ addAriaCurrent = child => {
53
+ const updatedChild = /*#__PURE__*/cloneElement(child, {
54
+ 'aria-current': 'page'
55
+ });
56
+ return updatedChild;
57
+ };
58
+ componentDidMount() {
59
+ this.props.makeStyles?.();
60
+ }
61
+ componentDidUpdate() {
62
+ this.props.makeStyles?.();
63
+ }
64
+ static Link = BreadcrumbLink;
65
+ renderChildren() {
66
+ const {
67
+ styles,
68
+ children
69
+ } = this.props;
70
+ const numChildren = Children.count(children);
71
+ const inlineStyle = {
72
+ maxWidth: `${Math.floor(100 / numChildren)}%`
73
+ };
74
+ let isAriaCurrentSet = false;
75
+ return Children.map(children, (child, index) => {
76
+ const isLastElement = index === numChildren - 1;
77
+ if (/*#__PURE__*/isValidElement(child)) {
78
+ const isCurrentPage = child.props.isCurrentPage || false;
79
+ if (isAriaCurrentSet && isCurrentPage) {}
80
+ if (isCurrentPage) {
81
+ isAriaCurrentSet = true;
82
+ }
83
+ }
84
+ return _jsxs("li", {
85
+ css: styles?.crumb,
86
+ style: inlineStyle,
87
+ children: [!isAriaCurrentSet && isLastElement && child.props.isCurrentPage !== false ? this.addAriaCurrent(child) : child, index < numChildren - 1 && _jsx(IconArrowOpenEndSolid, {
88
+ color: "auto",
89
+ css: styles?.separator
90
+ })]
91
+ });
92
+ });
93
+ }
94
+ render() {
95
+ const {
96
+ styles
97
+ } = this.props;
98
+ return _jsx(View, {
99
+ role: "navigation",
100
+ as: "div",
101
+ margin: this.props.margin,
102
+ "aria-label": this.props.label,
103
+ elementRef: this.handleRef,
104
+ "data-cid": "Breadcrumb",
105
+ children: _jsx("ol", {
106
+ css: styles?.breadcrumb,
107
+ children: this.renderChildren()
108
+ })
109
+ });
110
+ }
111
+ }) || _class);
112
+ export default Breadcrumb;
113
+ export { Breadcrumb, BreadcrumbLink };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const allowedProps = ['children', 'label', 'margin', 'size'];
26
+ export { allowedProps };
@@ -0,0 +1,106 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ /**
26
+ * ---
27
+ * private: true
28
+ * ---
29
+ * Generates the style object from the theme and provided additional information
30
+ * @param {Object} componentTheme The theme variable object.
31
+ * @param {Object} props the props of the component, the style is applied to
32
+ * @param {Object} state the state of the component, the style is applied to
33
+ * @return {Object} The final style object, which will be used in the component
34
+ */
35
+ const generateStyle = (componentTheme, props) => {
36
+ const {
37
+ size
38
+ } = props;
39
+ const crumbSizeVariants = {
40
+ small: {
41
+ fontSize: componentTheme.smallFontSize,
42
+ paddingInlineEnd: `calc(${componentTheme.smallSeparatorFontSize} * 2)`,
43
+ paddingInlineStart: 0
44
+ },
45
+ medium: {
46
+ fontSize: componentTheme.mediumFontSize,
47
+ paddingInlineEnd: `calc(${componentTheme.mediumSeparatorFontSize} * 2)`,
48
+ paddingInlineStart: 0
49
+ },
50
+ large: {
51
+ fontSize: componentTheme.largeFontSize,
52
+ paddingInlineEnd: `calc(${componentTheme.largeSeparatorFontSize} * 2)`,
53
+ paddingInlineStart: 0
54
+ }
55
+ };
56
+ const separatorSizeVariants = {
57
+ small: {
58
+ fontSize: componentTheme.smallSeparatorFontSize,
59
+ insetInlineEnd: `calc(${componentTheme.smallSeparatorFontSize} / 2)`,
60
+ insetInlineStart: 'auto',
61
+ marginTop: `calc(-1 * (${componentTheme.smallSeparatorFontSize} / 2))`
62
+ },
63
+ medium: {
64
+ fontSize: componentTheme.mediumSeparatorFontSize,
65
+ insetInlineEnd: `calc(${componentTheme.mediumSeparatorFontSize} / 2)`,
66
+ insetInlineStart: 'auto',
67
+ marginTop: `calc(-1 * (${componentTheme.mediumSeparatorFontSize} / 2))`
68
+ },
69
+ large: {
70
+ fontSize: componentTheme.largeSeparatorFontSize,
71
+ insetInlineEnd: `calc(${componentTheme.largeSeparatorFontSize} / 2)`,
72
+ insetInlineStart: 'auto',
73
+ marginTop: `calc(-1 * (${componentTheme.largeSeparatorFontSize} / 2))`
74
+ }
75
+ };
76
+ return {
77
+ breadcrumb: {
78
+ label: 'breadcrumb',
79
+ fontFamily: componentTheme.fontFamily,
80
+ margin: 0,
81
+ padding: 0,
82
+ listStyleType: 'none',
83
+ overflow: 'visible',
84
+ display: 'flex',
85
+ alignItems: 'center'
86
+ },
87
+ crumb: {
88
+ label: 'breadcrumb__crumb',
89
+ boxSizing: 'border-box',
90
+ position: 'relative',
91
+ ...crumbSizeVariants[size],
92
+ '&:last-child': {
93
+ paddingInlineEnd: 0
94
+ }
95
+ },
96
+ separator: {
97
+ label: 'breadcrumb__separator',
98
+ boxSizing: 'border-box',
99
+ position: 'absolute',
100
+ top: '50%',
101
+ color: componentTheme.separatorColor,
102
+ ...separatorSizeVariants[size]
103
+ }
104
+ };
105
+ };
106
+ export default generateStyle;
@@ -0,0 +1,49 @@
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
+ * Generates the theme object for the component from the theme and provided additional information
27
+ * @param {Object} theme The actual theme object.
28
+ * @return {Object} The final theme object with the overrides and component variables
29
+ */
30
+ const generateComponentTheme = theme => {
31
+ const {
32
+ colors,
33
+ typography
34
+ } = theme;
35
+ const componentVariables = {
36
+ fontFamily: typography?.fontFamily,
37
+ separatorColor: colors?.contrasts?.grey4570,
38
+ smallSeparatorFontSize: '0.5rem',
39
+ smallFontSize: typography?.fontSizeSmall,
40
+ mediumSeparatorFontSize: '0.75rem',
41
+ mediumFontSize: typography?.fontSizeMedium,
42
+ largeSeparatorFontSize: '1rem',
43
+ largeFontSize: typography?.fontSizeLarge
44
+ };
45
+ return {
46
+ ...componentVariables
47
+ };
48
+ };
49
+ export default generateComponentTheme;
@@ -0,0 +1,121 @@
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 { Component } from 'react';
26
+ import { TruncateText } from '@instructure/ui-truncate-text/latest';
27
+ import { Link } from '@instructure/ui-link/latest';
28
+ import { omitProps } from '@instructure/ui-react-utils';
29
+ import { Tooltip } from '@instructure/ui-tooltip/latest';
30
+ import { allowedProps } from './props.js';
31
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
32
+ /**
33
+ ---
34
+ parent: Breadcrumb
35
+ id: Breadcrumb.Link
36
+ ---
37
+ **/
38
+
39
+ class BreadcrumbLink extends Component {
40
+ static displayName = 'BreadcrumbLink';
41
+ static componentId = 'Breadcrumb.Link';
42
+ static allowedProps = allowedProps;
43
+ static defaultProps = {};
44
+ ref = null;
45
+ handleRef = el => {
46
+ this.ref = el;
47
+ };
48
+ constructor(props) {
49
+ super(props);
50
+ this.state = {
51
+ isTruncated: false
52
+ };
53
+ }
54
+ handleTruncation(isTruncated) {
55
+ if (isTruncated !== this.state.isTruncated) {
56
+ this.setState({
57
+ isTruncated
58
+ });
59
+ }
60
+ }
61
+ render() {
62
+ const {
63
+ children,
64
+ href,
65
+ renderIcon,
66
+ iconPlacement,
67
+ onClick,
68
+ onMouseEnter,
69
+ isCurrentPage,
70
+ size
71
+ } = this.props;
72
+ const {
73
+ isTruncated
74
+ } = this.state;
75
+ const props = omitProps(this.props, BreadcrumbLink.allowedProps);
76
+ const isInteractive = onClick || href;
77
+ return _jsx(Tooltip, {
78
+ renderTip: children,
79
+ preventTooltip: !isTruncated
80
+ // 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 when there is already an aria-label
82
+ ,
83
+ ...(isInteractive && {
84
+ as: 'span'
85
+ }),
86
+ children: _jsx(Link, {
87
+ ...props,
88
+ href: href,
89
+ renderIcon: renderIcon,
90
+ iconPlacement: iconPlacement,
91
+ onClick: onClick,
92
+ onMouseEnter: onMouseEnter,
93
+ variant: "standalone",
94
+ elementRef: this.handleRef,
95
+ forceButtonRole: false,
96
+ size: size,
97
+ ...(isCurrentPage && {
98
+ 'aria-current': 'page'
99
+ }),
100
+ ...(isTruncated && {
101
+ ...(typeof children === 'string' && {
102
+ 'aria-label': children
103
+ }),
104
+ ...(!isInteractive && {
105
+ role: 'text'
106
+ })
107
+ }),
108
+ "data-cid": "BreadcrumbLink",
109
+ children: _jsx(TruncateText, {
110
+ onUpdate: isTruncated => this.handleTruncation(isTruncated),
111
+ children: _jsx("span", {
112
+ "aria-hidden": isTruncated,
113
+ children: children
114
+ })
115
+ })
116
+ })
117
+ });
118
+ }
119
+ }
120
+ export default BreadcrumbLink;
121
+ export { BreadcrumbLink };
@@ -0,0 +1,26 @@
1
+ /*
2
+ * The MIT License (MIT)
3
+ *
4
+ * Copyright (c) 2015 - present Instructure, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ const allowedProps = ['children', 'href', 'iconPlacement', 'onClick', 'onMouseEnter', 'renderIcon', 'size', 'isCurrentPage'];
26
+ export { allowedProps };