@instructure/ui-navigation 8.23.1-snapshot.9 → 8.24.1-snapshot.17
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/AppNav/AppNavLocator.js +2 -1
- package/es/AppNav/Item/AppNavItemLocator.js +2 -1
- package/es/AppNav/Item/index.js +1 -3
- package/es/AppNav/Item/props.js +1 -42
- package/es/AppNav/index.js +12 -10
- package/es/AppNav/props.js +0 -46
- package/es/Navigation/NavigationItem/NavigationItemLocator.js +4 -2
- package/es/Navigation/NavigationItem/index.js +3 -2
- package/es/Navigation/NavigationItem/props.js +0 -31
- package/es/Navigation/NavigationLocator.js +2 -1
- package/es/Navigation/index.js +9 -6
- package/es/Navigation/props.js +0 -27
- package/lib/AppNav/AppNavLocator.js +1 -0
- package/lib/AppNav/Item/AppNavItemLocator.js +1 -0
- package/lib/AppNav/Item/index.js +1 -3
- package/lib/AppNav/Item/props.js +1 -42
- package/lib/AppNav/index.js +11 -9
- package/lib/AppNav/props.js +0 -46
- package/lib/Navigation/NavigationItem/NavigationItemLocator.js +2 -0
- package/lib/Navigation/NavigationItem/index.js +3 -2
- package/lib/Navigation/NavigationItem/props.js +0 -31
- package/lib/Navigation/NavigationLocator.js +1 -0
- package/lib/Navigation/index.js +11 -6
- package/lib/Navigation/props.js +0 -27
- package/package.json +24 -24
- package/src/AppNav/Item/index.tsx +2 -8
- package/src/AppNav/Item/props.ts +37 -32
- package/src/AppNav/index.tsx +21 -35
- package/src/AppNav/props.ts +41 -41
- package/src/Navigation/NavigationItem/index.tsx +2 -4
- package/src/Navigation/NavigationItem/props.ts +26 -26
- package/src/Navigation/index.tsx +14 -17
- package/src/Navigation/props.ts +24 -24
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/AppNav/Item/index.d.ts +10 -10
- package/types/AppNav/Item/index.d.ts.map +1 -1
- package/types/AppNav/Item/props.d.ts +37 -5
- package/types/AppNav/Item/props.d.ts.map +1 -1
- package/types/AppNav/index.d.ts +20 -13
- package/types/AppNav/index.d.ts.map +1 -1
- package/types/AppNav/props.d.ts +43 -4
- package/types/AppNav/props.d.ts.map +1 -1
- package/types/Navigation/NavigationItem/index.d.ts +3 -3
- package/types/Navigation/NavigationItem/index.d.ts.map +1 -1
- package/types/Navigation/NavigationItem/props.d.ts +26 -2
- package/types/Navigation/NavigationItem/props.d.ts.map +1 -1
- package/types/Navigation/index.d.ts +14 -14
- package/types/Navigation/index.d.ts.map +1 -1
- package/types/Navigation/props.d.ts +24 -3
- package/types/Navigation/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.24.0](https://github.com/instructure/instructure-ui/compare/v8.23.0...v8.24.0) (2022-04-26)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-navigation
|
|
9
|
+
|
|
6
10
|
# [8.23.0](https://github.com/instructure/instructure-ui/compare/v8.22.0...v8.23.0) (2022-04-07)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/ui-navigation
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
25
|
import { AppNav } from './index';
|
|
26
|
-
import { AppNavItemLocator } from './Item/AppNavItemLocator';
|
|
26
|
+
import { AppNavItemLocator } from './Item/AppNavItemLocator'; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
27
|
+
|
|
27
28
|
export const AppNavLocator = locator(AppNav.selector, {
|
|
28
29
|
findAllItems: function () {
|
|
29
30
|
return AppNavItemLocator.findAll(...arguments);
|
|
@@ -22,5 +22,6 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
|
-
import { Item } from './index';
|
|
25
|
+
import { Item } from './index'; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
26
|
+
|
|
26
27
|
export const AppNavItemLocator = locator(Item.selector);
|
package/es/AppNav/Item/index.js
CHANGED
|
@@ -40,6 +40,7 @@ import { allowedProps, propTypes } from './props';
|
|
|
40
40
|
parent: AppNav
|
|
41
41
|
id: AppNav.Item
|
|
42
42
|
---
|
|
43
|
+
@tsProps
|
|
43
44
|
@module Item
|
|
44
45
|
**/
|
|
45
46
|
|
|
@@ -111,8 +112,6 @@ let Item = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
111
112
|
display: "flex",
|
|
112
113
|
position: "relative",
|
|
113
114
|
borderRadius: "medium",
|
|
114
|
-
onFocus: this.handleFocus,
|
|
115
|
-
onBlur: this.handleBlur,
|
|
116
115
|
cursor: isDisabled ? 'not-allowed' : cursor,
|
|
117
116
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.item
|
|
118
117
|
}), icon, labelIsForScreenReaders ? label : jsx("span", {
|
|
@@ -122,7 +121,6 @@ let Item = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
|
|
|
122
121
|
|
|
123
122
|
}, _class2.displayName = "Item", _class2.componentId = 'AppNav.Item', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
124
123
|
children: null,
|
|
125
|
-
onClick: function (event) {},
|
|
126
124
|
isSelected: false,
|
|
127
125
|
cursor: 'pointer',
|
|
128
126
|
isDisabled: false
|
package/es/AppNav/Item/props.js
CHANGED
|
@@ -23,56 +23,15 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
const propTypes = {
|
|
26
|
-
|
|
27
|
-
* The text to display. If the `icon` prop is used, label text must be wrapped
|
|
28
|
-
* in `ScreenReaderContent`.
|
|
29
|
-
*/
|
|
30
|
-
renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Content to display after the renderLabel text, such as a badge
|
|
34
|
-
*/
|
|
26
|
+
renderLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.string, PropTypes.func]).isRequired,
|
|
35
27
|
renderAfter: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
39
|
-
*/
|
|
40
28
|
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* If the item goes to a new page, pass an href
|
|
44
|
-
*/
|
|
45
29
|
href: PropTypes.string,
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* If the item does not go to a new page, pass an onClick
|
|
49
|
-
*/
|
|
50
30
|
onClick: PropTypes.func,
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Denotes which item is currently selected
|
|
54
|
-
*/
|
|
55
31
|
isSelected: PropTypes.bool,
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* provides a reference to the underlying focusable (`button` or `a`) element
|
|
59
|
-
*/
|
|
60
32
|
elementRef: PropTypes.func,
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
64
|
-
*/
|
|
65
33
|
as: PropTypes.elementType,
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Specify the mouse cursor to use on :hover.
|
|
69
|
-
* The `pointer` cursor is used by default.
|
|
70
|
-
*/
|
|
71
34
|
cursor: PropTypes.string,
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Disables the link or button visually and functionally
|
|
75
|
-
*/
|
|
76
35
|
isDisabled: PropTypes.bool
|
|
77
36
|
};
|
|
78
37
|
const allowedProps = ['renderLabel', 'renderAfter', 'renderIcon', 'href', 'onClick', 'isSelected', 'elementRef', 'as', 'cursor', 'isDisabled'];
|
package/es/AppNav/index.js
CHANGED
|
@@ -38,12 +38,13 @@ import { Item } from './Item';
|
|
|
38
38
|
import generateStyle from './styles';
|
|
39
39
|
import generateComponentTheme from './theme';
|
|
40
40
|
import { allowedProps, propTypes } from './props';
|
|
41
|
+
|
|
41
42
|
/**
|
|
42
43
|
---
|
|
43
44
|
category: components
|
|
44
45
|
---
|
|
46
|
+
@tsProps
|
|
45
47
|
**/
|
|
46
|
-
|
|
47
48
|
let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class AppNav extends Component {
|
|
48
49
|
constructor() {
|
|
49
50
|
super(...arguments);
|
|
@@ -52,6 +53,8 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
52
53
|
};
|
|
53
54
|
this.ref = null;
|
|
54
55
|
this._list = null;
|
|
56
|
+
this._debounced = void 0;
|
|
57
|
+
this._resizeListener = void 0;
|
|
55
58
|
|
|
56
59
|
this.measureItems = () => {
|
|
57
60
|
var _this$props$styles;
|
|
@@ -95,9 +98,12 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
95
98
|
const _this$measureItems = this.measureItems(),
|
|
96
99
|
visibleItemsCount = _this$measureItems.visibleItemsCount;
|
|
97
100
|
|
|
98
|
-
this.props.onUpdate
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
if (typeof this.props.onUpdate === 'function') {
|
|
102
|
+
this.props.onUpdate({
|
|
103
|
+
visibleItemsCount
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
101
107
|
this.setState({
|
|
102
108
|
isMeasuring: false
|
|
103
109
|
});
|
|
@@ -168,19 +174,17 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
168
174
|
|
|
169
175
|
renderMenu(items) {
|
|
170
176
|
const menu = jsx(Menu, {
|
|
171
|
-
onDismiss: this.handleMenuDismiss // TODO: remove when INSTUI-2262 is resolved
|
|
172
|
-
,
|
|
173
177
|
trigger: jsx(AppNav.Item, {
|
|
174
178
|
renderLabel: callRenderProp(this.props.renderTruncateLabel)
|
|
175
179
|
})
|
|
176
180
|
}, items.map((item, index) => {
|
|
177
181
|
return jsx(Menu.Item, {
|
|
178
182
|
href: item.props.href ? item.props.href : void 0,
|
|
179
|
-
onClick: item.props.onClick && !item.props.href ? item.props.onClick :
|
|
183
|
+
onClick: item.props.onClick && !item.props.href ? item.props.onClick : void 0,
|
|
180
184
|
key: index
|
|
181
185
|
}, callRenderProp(item.props.renderLabel));
|
|
182
186
|
}));
|
|
183
|
-
return this.renderListItem(menu, true
|
|
187
|
+
return this.renderListItem(menu, true);
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
render() {
|
|
@@ -218,9 +222,7 @@ let AppNav = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = t
|
|
|
218
222
|
children: null,
|
|
219
223
|
debounce: 300,
|
|
220
224
|
margin: '0',
|
|
221
|
-
elementRef: el => {},
|
|
222
225
|
renderTruncateLabel: () => 'More',
|
|
223
|
-
onUpdate: () => {},
|
|
224
226
|
visibleItemsCount: 0
|
|
225
227
|
}, _class2.Item = Item, _class2)) || _class) || _class);
|
|
226
228
|
export { AppNav };
|
package/es/AppNav/props.js
CHANGED
|
@@ -26,61 +26,15 @@ import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
|
26
26
|
import { ThemeablePropTypes } from '@instructure/emotion';
|
|
27
27
|
import { Item } from './Item';
|
|
28
28
|
const propTypes = {
|
|
29
|
-
/**
|
|
30
|
-
* Screenreader label for the overall navigation
|
|
31
|
-
*/
|
|
32
29
|
screenReaderLabel: PropTypes.string.isRequired,
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Only accepts `AppNav.Item` as children
|
|
36
|
-
*/
|
|
37
30
|
children: ChildrenPropTypes.oneOf([Item]),
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* The rate (in ms) the component responds to container resizing or
|
|
41
|
-
* an update to one of its child items
|
|
42
|
-
*/
|
|
43
31
|
debounce: PropTypes.number,
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Content to display before the navigation items, such as a logo
|
|
47
|
-
*/
|
|
48
32
|
renderBeforeItems: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Content to display after the navigation items, aligned to the far end
|
|
52
|
-
* of the navigation
|
|
53
|
-
*/
|
|
54
33
|
renderAfterItems: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
58
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
59
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
60
|
-
*/
|
|
61
34
|
margin: ThemeablePropTypes.spacing,
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Provides a reference to the underlying nav element
|
|
65
|
-
*/
|
|
66
35
|
elementRef: PropTypes.func,
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Customize the text displayed in the menu trigger when links overflow
|
|
70
|
-
* the overall nav width.
|
|
71
|
-
*/
|
|
72
36
|
renderTruncateLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Called whenever the navigation items are updated or the size of
|
|
76
|
-
* the navigation changes. Passes in the `visibleItemsCount` as
|
|
77
|
-
* a parameter.
|
|
78
|
-
*/
|
|
79
37
|
onUpdate: PropTypes.func,
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Sets the number of navigation items that are visible.
|
|
83
|
-
*/
|
|
84
38
|
visibleItemsCount: PropTypes.number
|
|
85
39
|
};
|
|
86
40
|
const allowedProps = ['screenReaderLabel', 'children', 'debounce', 'renderBeforeItems', 'renderAfterItems', 'margin', 'elementRef', 'renderTruncateLabel', 'onUpdate', 'visibleItemsCount'];
|
|
@@ -21,10 +21,12 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
import { locator } from '@instructure/ui-test-locator'; //
|
|
24
|
+
import { locator } from '@instructure/ui-test-locator'; // @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module '@ins... Remove this comment to see the full error message
|
|
25
|
+
// eslint-disable-next-line no-restricted-imports
|
|
25
26
|
|
|
26
27
|
import { TooltipLocator } from '@instructure/ui-tooltip/es/Tooltip/TooltipLocator';
|
|
27
|
-
import { NavigationItem } from './index';
|
|
28
|
+
import { NavigationItem } from './index'; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
29
|
+
|
|
28
30
|
export const NavigationItemLocator = locator(NavigationItem.selector, {
|
|
29
31
|
findTooltipContent: function () {
|
|
30
32
|
return TooltipLocator.findContent(...arguments);
|
|
@@ -39,6 +39,7 @@ import { allowedProps, propTypes } from './props';
|
|
|
39
39
|
parent: Navigation
|
|
40
40
|
id: Navigation.Item
|
|
41
41
|
---
|
|
42
|
+
@tsProps
|
|
42
43
|
**/
|
|
43
44
|
|
|
44
45
|
let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class NavigationItem extends Component {
|
|
@@ -82,7 +83,8 @@ let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
82
83
|
icon = _this$props3.icon,
|
|
83
84
|
label = _this$props3.label;
|
|
84
85
|
const props = omitProps(this.props, NavigationItem.allowedProps);
|
|
85
|
-
return jsx(ElementType
|
|
86
|
+
return jsx(ElementType // @ts-expect-error TODO: fix TS2590: Expression produces a union type that is too complex to represent.
|
|
87
|
+
, Object.assign({}, props, {
|
|
86
88
|
href: href,
|
|
87
89
|
onClick: onClick,
|
|
88
90
|
ref: addRef ? this.handleRef : void 0,
|
|
@@ -111,7 +113,6 @@ let NavigationItem = (_dec = withStyle(generateStyle, generateComponentTheme), _
|
|
|
111
113
|
|
|
112
114
|
}, _class2.displayName = "NavigationItem", _class2.componentId = 'Navigation.Item', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
113
115
|
as: 'a',
|
|
114
|
-
onClick: function (e, selected) {},
|
|
115
116
|
selected: false,
|
|
116
117
|
minimized: false
|
|
117
118
|
}, _class2)) || _class) || _class);
|
|
@@ -23,44 +23,13 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import PropTypes from 'prop-types';
|
|
25
25
|
const propTypes = {
|
|
26
|
-
/**
|
|
27
|
-
* The reference to the underlying HTML element
|
|
28
|
-
*/
|
|
29
26
|
elementRef: PropTypes.func,
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
33
|
-
*/
|
|
34
27
|
icon: PropTypes.node.isRequired,
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* The text to display for the Navigation Link
|
|
38
|
-
*/
|
|
39
28
|
label: PropTypes.node.isRequired,
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
43
|
-
*/
|
|
44
29
|
as: PropTypes.elementType,
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* If the NavigationItem goes to a new page, pass an href
|
|
48
|
-
*/
|
|
49
30
|
href: PropTypes.string,
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* If the NavigationItem does not go to a new page pass an onClick
|
|
53
|
-
*/
|
|
54
31
|
onClick: PropTypes.func,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Denotes which NavigationItem is currently selected
|
|
58
|
-
*/
|
|
59
32
|
selected: PropTypes.bool,
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* When minimized is set to true, the `<Navigation />` shows icons only while the text becomes a tooltip. When it is set to false, the `<Navigation />` shows text in addition to the icons
|
|
63
|
-
*/
|
|
64
33
|
minimized: PropTypes.bool
|
|
65
34
|
};
|
|
66
35
|
const allowedProps = ['elementRef', 'icon', 'label', 'as', 'href', 'onClick', 'selected', 'minimized'];
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
25
|
import { Navigation } from './index';
|
|
26
26
|
import { NavigationItemLocator } from './NavigationItem/NavigationItemLocator';
|
|
27
|
-
export { NavigationItemLocator };
|
|
27
|
+
export { NavigationItemLocator }; // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
28
|
+
|
|
28
29
|
export const NavigationLocator = locator(Navigation.selector, {
|
|
29
30
|
findAllItems: function () {
|
|
30
31
|
return NavigationItemLocator.findAll(...arguments);
|
package/es/Navigation/index.js
CHANGED
|
@@ -25,7 +25,7 @@ var _dec, _dec2, _dec3, _class, _class2;
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/** @jsx jsx */
|
|
28
|
-
import { Component, Children } from 'react';
|
|
28
|
+
import React, { Component, Children } from 'react';
|
|
29
29
|
import { testable } from '@instructure/ui-testable';
|
|
30
30
|
import { deprecated, omitProps, safeCloneElement } from '@instructure/ui-react-utils';
|
|
31
31
|
import { IconMoveStartLine } from '@instructure/ui-icons';
|
|
@@ -46,12 +46,13 @@ const navMinimized = _ref => {
|
|
|
46
46
|
---
|
|
47
47
|
category: components/deprecated
|
|
48
48
|
---
|
|
49
|
+
@tsProps
|
|
49
50
|
**/
|
|
50
51
|
|
|
51
52
|
|
|
52
53
|
let Navigation = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec3 = deprecated('9.0.0', null, 'No one uses <Navigation>, so we will deprecate it.'), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class Navigation extends Component {
|
|
53
54
|
constructor(props) {
|
|
54
|
-
super();
|
|
55
|
+
super(props);
|
|
55
56
|
this.ref = null;
|
|
56
57
|
|
|
57
58
|
this.handleNavToggle = event => {
|
|
@@ -59,11 +60,13 @@ let Navigation = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
59
60
|
this.setState(navMinimized);
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
this.props.onMinimized
|
|
63
|
+
if (typeof this.props.onMinimized === 'function') {
|
|
64
|
+
this.props.onMinimized(event, !this.minimized);
|
|
65
|
+
}
|
|
63
66
|
};
|
|
64
67
|
|
|
65
68
|
this.state = {
|
|
66
|
-
minimized: this.isControlled(props) ? props.minimized : !!props.defaultMinimized
|
|
69
|
+
minimized: this.isControlled(props) ? !!props.minimized : !!props.defaultMinimized
|
|
67
70
|
};
|
|
68
71
|
}
|
|
69
72
|
|
|
@@ -142,8 +145,8 @@ let Navigation = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2
|
|
|
142
145
|
}, _class2.displayName = "Navigation", _class2.componentId = 'Navigation', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
143
146
|
children: null,
|
|
144
147
|
defaultMinimized: false,
|
|
145
|
-
|
|
146
|
-
onClick: function (
|
|
148
|
+
// TODO we should investigate later if it used or not
|
|
149
|
+
onClick: function (_e) {}
|
|
147
150
|
}, _class2.Item = NavigationItem, _class2)) || _class) || _class) || _class);
|
|
148
151
|
export default Navigation;
|
|
149
152
|
export { Navigation, NavigationItem };
|
package/es/Navigation/props.js
CHANGED
|
@@ -25,43 +25,16 @@ import PropTypes from 'prop-types';
|
|
|
25
25
|
import { controllable, Children as ChildrenPropTypes } from '@instructure/ui-prop-types';
|
|
26
26
|
import { NavigationItem } from './NavigationItem';
|
|
27
27
|
const propTypes = {
|
|
28
|
-
/**
|
|
29
|
-
* children of type Navigation.Item
|
|
30
|
-
*/
|
|
31
28
|
children: ChildrenPropTypes.oneOf([NavigationItem]),
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* When minimized is set to true, the `<Navigation />` shows icons only while the text becomes a tooltip. When it is set to false, the `<Navigation />` shows text in addition to the icons
|
|
35
|
-
*/
|
|
36
29
|
minimized: controllable(PropTypes.bool, 'onMinimized', 'defaultMinimized'),
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Whether the `<Navigation />` is initially minimized (uncontrolled)
|
|
40
|
-
*/
|
|
41
30
|
defaultMinimized: PropTypes.bool,
|
|
42
31
|
onMinimized: PropTypes.func,
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Screen reader label for the main Navigation
|
|
46
|
-
*/
|
|
47
32
|
label: PropTypes.string.isRequired,
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Screen reader label for the toggle button expanded/minimized state
|
|
51
|
-
*/
|
|
52
33
|
toggleLabel: PropTypes.shape({
|
|
53
34
|
expandedLabel: PropTypes.string,
|
|
54
35
|
minimizedLabel: PropTypes.string
|
|
55
36
|
}).isRequired,
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* If the `<Navigation.Item>` goes to a new page, pass an href
|
|
59
|
-
*/
|
|
60
37
|
href: PropTypes.string,
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* If the `<Navigation.Item>` does not go to a new page pass an onClick
|
|
64
|
-
*/
|
|
65
38
|
onClick: PropTypes.func
|
|
66
39
|
};
|
|
67
40
|
const allowedProps = ['children', 'minimized', 'defaultMinimized', 'onMinimized', 'label', 'toggleLabel', 'href', 'onClick'];
|
|
@@ -34,6 +34,7 @@ var _AppNavItemLocator = require("./Item/AppNavItemLocator");
|
|
|
34
34
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
35
|
* SOFTWARE.
|
|
36
36
|
*/
|
|
37
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
37
38
|
const AppNavLocator = (0, _locator.locator)(_index.AppNav.selector, {
|
|
38
39
|
findAllItems: function () {
|
|
39
40
|
return _AppNavItemLocator.AppNavItemLocator.findAll(...arguments);
|
|
@@ -32,5 +32,6 @@ var _index = require("./index");
|
|
|
32
32
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
33
|
* SOFTWARE.
|
|
34
34
|
*/
|
|
35
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
35
36
|
const AppNavItemLocator = (0, _locator.locator)(_index.Item.selector);
|
|
36
37
|
exports.AppNavItemLocator = AppNavItemLocator;
|
package/lib/AppNav/Item/index.js
CHANGED
|
@@ -42,6 +42,7 @@ var _dec, _dec2, _class, _class2;
|
|
|
42
42
|
parent: AppNav
|
|
43
43
|
id: AppNav.Item
|
|
44
44
|
---
|
|
45
|
+
@tsProps
|
|
45
46
|
@module Item
|
|
46
47
|
**/
|
|
47
48
|
let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class Item extends _react.Component {
|
|
@@ -112,8 +113,6 @@ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
112
113
|
display: "flex",
|
|
113
114
|
position: "relative",
|
|
114
115
|
borderRadius: "medium",
|
|
115
|
-
onFocus: this.handleFocus,
|
|
116
|
-
onBlur: this.handleBlur,
|
|
117
116
|
cursor: isDisabled ? 'not-allowed' : cursor,
|
|
118
117
|
css: (_this$props$styles = this.props.styles) === null || _this$props$styles === void 0 ? void 0 : _this$props$styles.item
|
|
119
118
|
}), icon, labelIsForScreenReaders ? label : (0, _emotion.jsx)("span", {
|
|
@@ -123,7 +122,6 @@ let Item = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _de
|
|
|
123
122
|
|
|
124
123
|
}, _class2.displayName = "Item", _class2.componentId = 'AppNav.Item', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
125
124
|
children: null,
|
|
126
|
-
onClick: function (event) {},
|
|
127
125
|
isSelected: false,
|
|
128
126
|
cursor: 'pointer',
|
|
129
127
|
isDisabled: false
|
package/lib/AppNav/Item/props.js
CHANGED
|
@@ -33,56 +33,15 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
33
33
|
* SOFTWARE.
|
|
34
34
|
*/
|
|
35
35
|
const propTypes = {
|
|
36
|
-
|
|
37
|
-
* The text to display. If the `icon` prop is used, label text must be wrapped
|
|
38
|
-
* in `ScreenReaderContent`.
|
|
39
|
-
*/
|
|
40
|
-
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Content to display after the renderLabel text, such as a badge
|
|
44
|
-
*/
|
|
36
|
+
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string, _propTypes.default.func]).isRequired,
|
|
45
37
|
renderAfter: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
49
|
-
*/
|
|
50
38
|
renderIcon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* If the item goes to a new page, pass an href
|
|
54
|
-
*/
|
|
55
39
|
href: _propTypes.default.string,
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* If the item does not go to a new page, pass an onClick
|
|
59
|
-
*/
|
|
60
40
|
onClick: _propTypes.default.func,
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Denotes which item is currently selected
|
|
64
|
-
*/
|
|
65
41
|
isSelected: _propTypes.default.bool,
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* provides a reference to the underlying focusable (`button` or `a`) element
|
|
69
|
-
*/
|
|
70
42
|
elementRef: _propTypes.default.func,
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
74
|
-
*/
|
|
75
43
|
as: _propTypes.default.elementType,
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Specify the mouse cursor to use on :hover.
|
|
79
|
-
* The `pointer` cursor is used by default.
|
|
80
|
-
*/
|
|
81
44
|
cursor: _propTypes.default.string,
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Disables the link or button visually and functionally
|
|
85
|
-
*/
|
|
86
45
|
isDisabled: _propTypes.default.bool
|
|
87
46
|
};
|
|
88
47
|
exports.propTypes = propTypes;
|
package/lib/AppNav/index.js
CHANGED
|
@@ -41,6 +41,7 @@ var _dec, _dec2, _class, _class2;
|
|
|
41
41
|
---
|
|
42
42
|
category: components
|
|
43
43
|
---
|
|
44
|
+
@tsProps
|
|
44
45
|
**/
|
|
45
46
|
let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_class2 = class AppNav extends _react.Component {
|
|
46
47
|
constructor() {
|
|
@@ -50,6 +51,8 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
50
51
|
};
|
|
51
52
|
this.ref = null;
|
|
52
53
|
this._list = null;
|
|
54
|
+
this._debounced = void 0;
|
|
55
|
+
this._resizeListener = void 0;
|
|
53
56
|
|
|
54
57
|
this.measureItems = () => {
|
|
55
58
|
var _this$props$styles;
|
|
@@ -93,9 +96,12 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
93
96
|
const _this$measureItems = this.measureItems(),
|
|
94
97
|
visibleItemsCount = _this$measureItems.visibleItemsCount;
|
|
95
98
|
|
|
96
|
-
this.props.onUpdate
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
if (typeof this.props.onUpdate === 'function') {
|
|
100
|
+
this.props.onUpdate({
|
|
101
|
+
visibleItemsCount
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
99
105
|
this.setState({
|
|
100
106
|
isMeasuring: false
|
|
101
107
|
});
|
|
@@ -166,19 +172,17 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
166
172
|
|
|
167
173
|
renderMenu(items) {
|
|
168
174
|
const menu = (0, _emotion.jsx)(_Menu.Menu, {
|
|
169
|
-
onDismiss: this.handleMenuDismiss // TODO: remove when INSTUI-2262 is resolved
|
|
170
|
-
,
|
|
171
175
|
trigger: (0, _emotion.jsx)(AppNav.Item, {
|
|
172
176
|
renderLabel: (0, _callRenderProp.callRenderProp)(this.props.renderTruncateLabel)
|
|
173
177
|
})
|
|
174
178
|
}, items.map((item, index) => {
|
|
175
179
|
return (0, _emotion.jsx)(_Menu.Menu.Item, {
|
|
176
180
|
href: item.props.href ? item.props.href : void 0,
|
|
177
|
-
onClick: item.props.onClick && !item.props.href ? item.props.onClick :
|
|
181
|
+
onClick: item.props.onClick && !item.props.href ? item.props.onClick : void 0,
|
|
178
182
|
key: index
|
|
179
183
|
}, (0, _callRenderProp.callRenderProp)(item.props.renderLabel));
|
|
180
184
|
}));
|
|
181
|
-
return this.renderListItem(menu, true
|
|
185
|
+
return this.renderListItem(menu, true);
|
|
182
186
|
}
|
|
183
187
|
|
|
184
188
|
render() {
|
|
@@ -220,9 +224,7 @@ let AppNav = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _
|
|
|
220
224
|
children: null,
|
|
221
225
|
debounce: 300,
|
|
222
226
|
margin: '0',
|
|
223
|
-
elementRef: el => {},
|
|
224
227
|
renderTruncateLabel: () => 'More',
|
|
225
|
-
onUpdate: () => {},
|
|
226
228
|
visibleItemsCount: 0
|
|
227
229
|
}, _class2.Item = _Item.Item, _class2)) || _class) || _class);
|
|
228
230
|
exports.AppNav = AppNav;
|
package/lib/AppNav/props.js
CHANGED
|
@@ -39,61 +39,15 @@ var _Item = require("./Item");
|
|
|
39
39
|
* SOFTWARE.
|
|
40
40
|
*/
|
|
41
41
|
const propTypes = {
|
|
42
|
-
/**
|
|
43
|
-
* Screenreader label for the overall navigation
|
|
44
|
-
*/
|
|
45
42
|
screenReaderLabel: _propTypes.default.string.isRequired,
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Only accepts `AppNav.Item` as children
|
|
49
|
-
*/
|
|
50
43
|
children: _Children.Children.oneOf([_Item.Item]),
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* The rate (in ms) the component responds to container resizing or
|
|
54
|
-
* an update to one of its child items
|
|
55
|
-
*/
|
|
56
44
|
debounce: _propTypes.default.number,
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Content to display before the navigation items, such as a logo
|
|
60
|
-
*/
|
|
61
45
|
renderBeforeItems: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Content to display after the navigation items, aligned to the far end
|
|
65
|
-
* of the navigation
|
|
66
|
-
*/
|
|
67
46
|
renderAfterItems: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
71
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
72
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
73
|
-
*/
|
|
74
47
|
margin: _emotion.ThemeablePropTypes.spacing,
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Provides a reference to the underlying nav element
|
|
78
|
-
*/
|
|
79
48
|
elementRef: _propTypes.default.func,
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Customize the text displayed in the menu trigger when links overflow
|
|
83
|
-
* the overall nav width.
|
|
84
|
-
*/
|
|
85
49
|
renderTruncateLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]),
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Called whenever the navigation items are updated or the size of
|
|
89
|
-
* the navigation changes. Passes in the `visibleItemsCount` as
|
|
90
|
-
* a parameter.
|
|
91
|
-
*/
|
|
92
50
|
onUpdate: _propTypes.default.func,
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Sets the number of navigation items that are visible.
|
|
96
|
-
*/
|
|
97
51
|
visibleItemsCount: _propTypes.default.number
|
|
98
52
|
};
|
|
99
53
|
exports.propTypes = propTypes;
|