@instructure/ui-navigation 11.7.8 → 11.7.9-pr-snapshot-1792147648392

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.
@@ -1,28 +1,5 @@
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
-
1
+ import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
26
3
  import { Component } from 'react';
27
4
  import { withStyle } from '@instructure/emotion';
28
5
  import { callRenderProp, omitProps } from '@instructure/ui-react-utils';
@@ -33,95 +10,100 @@ import generateStyle from './styles.js';
33
10
  import generateComponentTheme from './theme.js';
34
11
  import { allowedProps } from './props.js';
35
12
  import { TruncateList } from '@instructure/ui-truncate-list';
36
-
37
- /**
38
- ---
39
- category: components
40
- ---
41
- **/
42
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
43
- let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec(_class = class AppNav extends Component {
44
- static displayName = 'AppNav';
45
- static componentId = 'AppNav';
46
- static allowedProps = allowedProps;
47
- static defaultProps = {
48
- children: null,
49
- debounce: 300,
50
- margin: '0',
51
- renderTruncateLabel: () => 'More',
52
- visibleItemsCount: 0
53
- };
54
- static Item = Item;
55
- state = {
56
- isMeasuring: false
57
- };
58
- ref = null;
59
- componentDidMount() {
60
- this.props.makeStyles?.();
61
- }
62
- componentDidUpdate() {
63
- this.props.makeStyles?.();
64
- }
65
- handleRef = el => {
66
- const {
67
- elementRef
68
- } = this.props;
69
- this.ref = el;
70
- if (typeof elementRef === 'function') {
71
- elementRef(el);
13
+ class AppNav extends Component {
14
+ static{
15
+ this.displayName = 'AppNav';
16
+ }
17
+ static{
18
+ this.componentId = 'AppNav';
19
+ }
20
+ static{
21
+ this.allowedProps = allowedProps;
22
+ }
23
+ static{
24
+ this.defaultProps = {
25
+ children: null,
26
+ debounce: 300,
27
+ margin: '0',
28
+ renderTruncateLabel: ()=>'More',
29
+ visibleItemsCount: 0
30
+ };
31
+ }
32
+ static{
33
+ this.Item = Item;
34
+ }
35
+ componentDidMount() {
36
+ this.props.makeStyles?.();
37
+ }
38
+ componentDidUpdate() {
39
+ this.props.makeStyles?.();
40
+ }
41
+ renderMenu(items) {
42
+ return /*#__PURE__*/ _jsx(Menu, {
43
+ trigger: /*#__PURE__*/ _jsx(AppNav.Item, {
44
+ renderLabel: callRenderProp(this.props.renderTruncateLabel)
45
+ }),
46
+ children: items.map((item, index)=>{
47
+ return /*#__PURE__*/ _jsx(Menu.Item, {
48
+ href: item.props.href ? item.props.href : undefined,
49
+ onClick: item.props.onClick && !item.props.href ? item.props.onClick : undefined,
50
+ children: callRenderProp(item.props.renderLabel)
51
+ }, index);
52
+ })
53
+ });
54
+ }
55
+ render() {
56
+ const { visibleItemsCount, screenReaderLabel, margin, debounce, styles } = this.props;
57
+ const passthroughProps = View.omitViewProps(omitProps(this.props, AppNav.allowedProps), AppNav);
58
+ const renderBeforeItems = callRenderProp(this.props.renderBeforeItems);
59
+ const renderAfterItems = callRenderProp(this.props.renderAfterItems);
60
+ const hasRenderedContent = renderBeforeItems || renderAfterItems;
61
+ return /*#__PURE__*/ _jsxs(View, {
62
+ ...passthroughProps,
63
+ as: "nav",
64
+ css: [
65
+ styles?.appNav,
66
+ hasRenderedContent ? styles?.alignCenter : ''
67
+ ],
68
+ margin: margin,
69
+ display: hasRenderedContent ? 'flex' : 'block',
70
+ elementRef: this.handleRef,
71
+ "data-cid": "AppNav",
72
+ children: [
73
+ renderBeforeItems && /*#__PURE__*/ _jsx("span", {
74
+ children: renderBeforeItems
75
+ }),
76
+ /*#__PURE__*/ _jsx(TruncateList, {
77
+ visibleItemsCount: visibleItemsCount,
78
+ debounce: debounce,
79
+ onUpdate: this.props.onUpdate,
80
+ renderHiddenItemMenu: (hiddenChildren)=>this.renderMenu(hiddenChildren),
81
+ itemSpacing: styles?.horizontalMargin,
82
+ fixMenuTriggerWidth: styles?.menuTriggerWidth,
83
+ css: styles?.list,
84
+ "aria-label": callRenderProp(screenReaderLabel),
85
+ children: this.props.children
86
+ }),
87
+ renderAfterItems && /*#__PURE__*/ _jsx("span", {
88
+ children: renderAfterItems
89
+ })
90
+ ]
91
+ });
92
+ }
93
+ constructor(...args){
94
+ super(...args), this.state = {
95
+ isMeasuring: false
96
+ }, this.ref = null, this.handleRef = (el)=>{
97
+ const { elementRef } = this.props;
98
+ this.ref = el;
99
+ if (typeof elementRef === 'function') {
100
+ elementRef(el);
101
+ }
102
+ };
72
103
  }
73
- };
74
- renderMenu(items) {
75
- return _jsx(Menu, {
76
- trigger: _jsx(AppNav.Item, {
77
- renderLabel: callRenderProp(this.props.renderTruncateLabel)
78
- }),
79
- children: items.map((item, index) => {
80
- return _jsx(Menu.Item, {
81
- href: item.props.href ? item.props.href : undefined,
82
- onClick: item.props.onClick && !item.props.href ? item.props.onClick : undefined,
83
- children: callRenderProp(item.props.renderLabel)
84
- }, index);
85
- })
86
- });
87
- }
88
- render() {
89
- const {
90
- visibleItemsCount,
91
- screenReaderLabel,
92
- margin,
93
- debounce,
94
- styles
95
- } = this.props;
96
- const passthroughProps = View.omitViewProps(omitProps(this.props, AppNav.allowedProps), AppNav);
97
- const renderBeforeItems = callRenderProp(this.props.renderBeforeItems);
98
- const renderAfterItems = callRenderProp(this.props.renderAfterItems);
99
- const hasRenderedContent = renderBeforeItems || renderAfterItems;
100
- return _jsxs(View, {
101
- ...passthroughProps,
102
- as: "nav",
103
- css: [styles?.appNav, hasRenderedContent ? styles?.alignCenter : ''],
104
- margin: margin,
105
- display: hasRenderedContent ? 'flex' : 'block',
106
- elementRef: this.handleRef,
107
- "data-cid": "AppNav",
108
- children: [renderBeforeItems && _jsx("span", {
109
- children: renderBeforeItems
110
- }), _jsx(TruncateList, {
111
- visibleItemsCount: visibleItemsCount,
112
- debounce: debounce,
113
- onUpdate: this.props.onUpdate,
114
- renderHiddenItemMenu: hiddenChildren => this.renderMenu(hiddenChildren),
115
- itemSpacing: styles?.horizontalMargin,
116
- fixMenuTriggerWidth: styles?.menuTriggerWidth,
117
- css: styles?.list,
118
- "aria-label": callRenderProp(screenReaderLabel),
119
- children: this.props.children
120
- }), renderAfterItems && _jsx("span", {
121
- children: renderAfterItems
122
- })]
123
- });
124
- }
125
- }) || _class);
104
+ }
105
+ AppNav = _ts_decorate([
106
+ withStyle(generateStyle, generateComponentTheme)
107
+ ], AppNav);
126
108
  export { AppNav };
127
- export default AppNav;
109
+ export default AppNav;
@@ -1,26 +1,13 @@
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 = ['screenReaderLabel', 'children', 'debounce', 'renderBeforeItems', 'renderAfterItems', 'margin', 'elementRef', 'renderTruncateLabel', 'onUpdate', 'visibleItemsCount'];
26
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'screenReaderLabel',
3
+ 'children',
4
+ 'debounce',
5
+ 'renderBeforeItems',
6
+ 'renderAfterItems',
7
+ 'margin',
8
+ 'elementRef',
9
+ 'renderTruncateLabel',
10
+ 'onUpdate',
11
+ 'visibleItemsCount'
12
+ ];
13
+ export { allowedProps };
@@ -1,58 +1,24 @@
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 => {
36
- return {
37
- appNav: {
38
- label: 'appNav',
39
- fontFamily: componentTheme.fontFamily,
40
- borderBottom: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`
41
- },
42
- alignCenter: {
43
- alignItems: 'center'
44
- },
45
- list: {
46
- label: 'appNav__list',
47
- height: componentTheme.height,
48
- flexGrow: 1,
49
- flexShrink: 1,
50
- flexBasis: '0',
51
- minWidth: '0.0625rem',
52
- paddingInlineStart: componentTheme.horizontalMargin
53
- },
54
- horizontalMargin: componentTheme.horizontalMargin.toString(),
55
- menuTriggerWidth: componentTheme.menuTriggerWidth.toString()
56
- };
1
+ const generateStyle = (componentTheme)=>{
2
+ return {
3
+ appNav: {
4
+ label: 'appNav',
5
+ fontFamily: componentTheme.fontFamily,
6
+ borderBottom: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`
7
+ },
8
+ alignCenter: {
9
+ alignItems: 'center'
10
+ },
11
+ list: {
12
+ label: 'appNav__list',
13
+ height: componentTheme.height,
14
+ flexGrow: 1,
15
+ flexShrink: 1,
16
+ flexBasis: '0',
17
+ minWidth: '0.0625rem',
18
+ paddingInlineStart: componentTheme.horizontalMargin
19
+ },
20
+ horizontalMargin: componentTheme.horizontalMargin.toString(),
21
+ menuTriggerWidth: componentTheme.menuTriggerWidth.toString()
22
+ };
57
23
  };
58
- export default generateStyle;
24
+ export default generateStyle;
@@ -1,51 +1,16 @@
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
- borders,
34
- spacing,
35
- typography
36
- } = theme;
37
- const componentVariables = {
38
- fontFamily: typography?.fontFamily,
39
- height: '3.75rem',
40
- // 60px per product design
41
- borderColor: colors?.contrasts?.grey1424,
42
- borderStyle: borders?.style,
43
- borderWidth: borders?.widthSmall,
44
- horizontalMargin: spacing?.xxSmall,
45
- menuTriggerWidth: '7.5rem'
46
- };
47
- return {
48
- ...componentVariables
49
- };
1
+ const generateComponentTheme = (theme)=>{
2
+ const { colors, borders, spacing, typography } = theme;
3
+ const componentVariables = {
4
+ fontFamily: typography?.fontFamily,
5
+ height: '3.75rem',
6
+ borderColor: colors?.contrasts?.grey1424,
7
+ borderStyle: borders?.style,
8
+ borderWidth: borders?.widthSmall,
9
+ horizontalMargin: spacing?.xxSmall,
10
+ menuTriggerWidth: '7.5rem'
11
+ };
12
+ return {
13
+ ...componentVariables
14
+ };
50
15
  };
51
- export default generateComponentTheme;
16
+ export default generateComponentTheme;
@@ -1,28 +1,5 @@
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
-
1
+ import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
26
3
  import { Component } from 'react';
27
4
  import { logError as error } from '@instructure/console';
28
5
  import { callRenderProp, getElementType, matchComponentTypes, passthroughProps } from '@instructure/ui-react-utils';
@@ -32,99 +9,92 @@ import { ScreenReaderContent } from '@instructure/ui-a11y-content';
32
9
  import { withStyleNew } from '@instructure/emotion';
33
10
  import generateStyle from './styles.js';
34
11
  import { allowedProps } from './props.js';
35
-
36
- /**
37
- ---
38
- parent: AppNav
39
- id: AppNav.Item
40
- ---
41
- @module Item
42
- **/
43
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
44
- let Item = (_dec = withStyleNew(generateStyle), _dec(_class = class Item extends Component {
45
- static displayName = 'Item';
46
- static componentId = 'AppNav.Item';
47
- static allowedProps = allowedProps;
48
- static defaultProps = {
49
- children: null,
50
- isSelected: false,
51
- cursor: 'pointer',
52
- isDisabled: false
53
- };
54
- ref = null;
55
- componentDidMount() {
56
- this.props.makeStyles?.();
57
- }
58
- componentDidUpdate() {
59
- this.props.makeStyles?.();
60
- }
61
- handleRef = el => {
62
- const {
63
- elementRef
64
- } = this.props;
65
- this.ref = el;
66
- if (typeof elementRef === 'function') {
67
- elementRef(el);
12
+ class Item extends Component {
13
+ static{
14
+ this.displayName = 'Item';
15
+ }
16
+ static{
17
+ this.componentId = 'AppNav.Item';
18
+ }
19
+ static{
20
+ this.allowedProps = allowedProps;
21
+ }
22
+ static{
23
+ this.defaultProps = {
24
+ children: null,
25
+ isSelected: false,
26
+ cursor: 'pointer',
27
+ isDisabled: false
28
+ };
29
+ }
30
+ componentDidMount() {
31
+ this.props.makeStyles?.();
32
+ }
33
+ componentDidUpdate() {
34
+ this.props.makeStyles?.();
68
35
  }
69
- };
70
- handleClick = e => {
71
- const {
72
- isDisabled,
73
- onClick
74
- } = this.props;
75
- if (isDisabled) {
76
- e.preventDefault();
77
- e.stopPropagation();
78
- } else if (typeof onClick === 'function') {
79
- onClick(e);
36
+ render() {
37
+ const ElementType = getElementType(Item, this.props);
38
+ const { renderIcon, renderLabel, href: rawHref, renderAfter, cursor, isDisabled } = this.props;
39
+ const { href, rel } = safeLinkProps({
40
+ attr: 'href',
41
+ tag: typeof ElementType === 'string' ? ElementType : 'a',
42
+ href: rawHref,
43
+ target: this.props.target,
44
+ rel: this.props.rel
45
+ });
46
+ const icon = callRenderProp(renderIcon);
47
+ const label = callRenderProp(renderLabel);
48
+ const labelIsForScreenReaders = matchComponentTypes(label, [
49
+ ScreenReaderContent
50
+ ]);
51
+ if (icon) {
52
+ error(labelIsForScreenReaders, '[AppNav] If an icon is used, the label text should be wrapped in <ScreenReaderContent />.');
53
+ }
54
+ return /*#__PURE__*/ _jsxs(View, {
55
+ ...passthroughProps(this.props),
56
+ as: ElementType,
57
+ href: href,
58
+ rel: rel,
59
+ onClick: this.handleClick,
60
+ disabled: isDisabled,
61
+ elementRef: this.handleRef,
62
+ display: "flex",
63
+ position: "relative",
64
+ borderRadius: "medium",
65
+ cursor: isDisabled ? 'not-allowed' : cursor,
66
+ css: this.props.styles?.item,
67
+ "data-cid": "AppNav.Item",
68
+ children: [
69
+ icon,
70
+ labelIsForScreenReaders ? label : /*#__PURE__*/ _jsx("span", {
71
+ css: this.props.styles?.label,
72
+ children: label
73
+ }),
74
+ renderAfter && callRenderProp(renderAfter)
75
+ ]
76
+ });
80
77
  }
81
- };
82
- render() {
83
- const ElementType = getElementType(Item, this.props);
84
- const {
85
- renderIcon,
86
- renderLabel,
87
- href: rawHref,
88
- renderAfter,
89
- cursor,
90
- isDisabled
91
- } = this.props;
92
- const {
93
- href,
94
- rel
95
- } = safeLinkProps({
96
- attr: 'href',
97
- tag: typeof ElementType === 'string' ? ElementType : 'a',
98
- href: rawHref,
99
- target: this.props.target,
100
- rel: this.props.rel
101
- });
102
- const icon = callRenderProp(renderIcon);
103
- const label = callRenderProp(renderLabel);
104
- const labelIsForScreenReaders = matchComponentTypes(label, [ScreenReaderContent]);
105
- if (icon) {
106
- error(labelIsForScreenReaders, '[AppNav] If an icon is used, the label text should be wrapped in <ScreenReaderContent />.');
78
+ constructor(...args){
79
+ super(...args), this.ref = null, this.handleRef = (el)=>{
80
+ const { elementRef } = this.props;
81
+ this.ref = el;
82
+ if (typeof elementRef === 'function') {
83
+ elementRef(el);
84
+ }
85
+ }, this.handleClick = (e)=>{
86
+ const { isDisabled, onClick } = this.props;
87
+ if (isDisabled) {
88
+ e.preventDefault();
89
+ e.stopPropagation();
90
+ } else if (typeof onClick === 'function') {
91
+ onClick(e);
92
+ }
93
+ };
107
94
  }
108
- return _jsxs(View, {
109
- ...passthroughProps(this.props),
110
- as: ElementType,
111
- href: href,
112
- rel: rel,
113
- onClick: this.handleClick,
114
- disabled: isDisabled,
115
- elementRef: this.handleRef,
116
- display: "flex",
117
- position: "relative",
118
- borderRadius: "medium",
119
- cursor: isDisabled ? 'not-allowed' : cursor,
120
- css: this.props.styles?.item,
121
- "data-cid": "AppNav.Item",
122
- children: [icon, labelIsForScreenReaders ? label : _jsx("span", {
123
- css: this.props.styles?.label,
124
- children: label
125
- }), renderAfter && callRenderProp(renderAfter)]
126
- });
127
- }
128
- }) || _class);
95
+ }
96
+ Item = _ts_decorate([
97
+ withStyleNew(generateStyle)
98
+ ], Item);
129
99
  export default Item;
130
- export { Item };
100
+ export { Item };
@@ -1,26 +1,13 @@
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 = ['renderLabel', 'renderAfter', 'renderIcon', 'href', 'onClick', 'isSelected', 'elementRef', 'as', 'cursor', 'isDisabled'];
26
- export { allowedProps };
1
+ const allowedProps = [
2
+ 'renderLabel',
3
+ 'renderAfter',
4
+ 'renderIcon',
5
+ 'href',
6
+ 'onClick',
7
+ 'isSelected',
8
+ 'elementRef',
9
+ 'as',
10
+ 'cursor',
11
+ 'isDisabled'
12
+ ];
13
+ export { allowedProps };