@instructure/ui-navigation 8.24.0 → 8.24.1-snapshot.19
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/LICENSE.md +27 -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 +25 -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/src/AppNav/props.ts
CHANGED
|
@@ -41,15 +41,52 @@ import type {
|
|
|
41
41
|
} from '@instructure/shared-types'
|
|
42
42
|
|
|
43
43
|
type AppNavOwnProps = {
|
|
44
|
+
/**
|
|
45
|
+
* Screenreader label for the overall navigation
|
|
46
|
+
*/
|
|
44
47
|
screenReaderLabel: string
|
|
48
|
+
/**
|
|
49
|
+
* The rate (in ms) the component responds to container resizing or
|
|
50
|
+
* an update to one of its child items
|
|
51
|
+
*/
|
|
45
52
|
debounce?: number
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Content to display before the navigation items, such as a logo
|
|
55
|
+
*/
|
|
56
|
+
renderBeforeItems?: React.ReactNode | (() => React.ReactNode)
|
|
57
|
+
/**
|
|
58
|
+
* Content to display after the navigation items, aligned to the far end
|
|
59
|
+
* of the navigation
|
|
60
|
+
*/
|
|
61
|
+
renderAfterItems?: React.ReactNode | (() => React.ReactNode)
|
|
62
|
+
/**
|
|
63
|
+
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
64
|
+
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
65
|
+
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
66
|
+
*/
|
|
48
67
|
margin?: Spacing
|
|
68
|
+
/**
|
|
69
|
+
* Provides a reference to the underlying nav element
|
|
70
|
+
*/
|
|
49
71
|
elementRef?: (element: Element | null) => void
|
|
50
|
-
|
|
51
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Customize the text displayed in the menu trigger when links overflow
|
|
74
|
+
* the overall nav width.
|
|
75
|
+
*/
|
|
76
|
+
renderTruncateLabel?: React.ReactNode | (() => React.ReactNode)
|
|
77
|
+
/**
|
|
78
|
+
* Called whenever the navigation items are updated or the size of
|
|
79
|
+
* the navigation changes. Passes in the `visibleItemsCount` as
|
|
80
|
+
* a parameter.
|
|
81
|
+
*/
|
|
82
|
+
onUpdate?: ({ visibleItemsCount }: { visibleItemsCount: number }) => void
|
|
83
|
+
/**
|
|
84
|
+
* Sets the number of navigation items that are visible.
|
|
85
|
+
*/
|
|
52
86
|
visibleItemsCount?: number
|
|
87
|
+
/**
|
|
88
|
+
* Only accepts `AppNav.Item` as children
|
|
89
|
+
*/
|
|
53
90
|
children?: React.ReactNode
|
|
54
91
|
}
|
|
55
92
|
|
|
@@ -71,52 +108,15 @@ type AppNavStyle = ComponentStyle<
|
|
|
71
108
|
>
|
|
72
109
|
|
|
73
110
|
const propTypes: PropValidators<PropKeys> = {
|
|
74
|
-
/**
|
|
75
|
-
* Screenreader label for the overall navigation
|
|
76
|
-
*/
|
|
77
111
|
screenReaderLabel: PropTypes.string.isRequired,
|
|
78
|
-
/**
|
|
79
|
-
* Only accepts `AppNav.Item` as children
|
|
80
|
-
*/
|
|
81
112
|
children: ChildrenPropTypes.oneOf([Item]),
|
|
82
|
-
/**
|
|
83
|
-
* The rate (in ms) the component responds to container resizing or
|
|
84
|
-
* an update to one of its child items
|
|
85
|
-
*/
|
|
86
113
|
debounce: PropTypes.number,
|
|
87
|
-
/**
|
|
88
|
-
* Content to display before the navigation items, such as a logo
|
|
89
|
-
*/
|
|
90
114
|
renderBeforeItems: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
91
|
-
/**
|
|
92
|
-
* Content to display after the navigation items, aligned to the far end
|
|
93
|
-
* of the navigation
|
|
94
|
-
*/
|
|
95
115
|
renderAfterItems: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
96
|
-
/**
|
|
97
|
-
* Valid values are `0`, `none`, `auto`, `xxx-small`, `xx-small`, `x-small`,
|
|
98
|
-
* `small`, `medium`, `large`, `x-large`, `xx-large`. Apply these values via
|
|
99
|
-
* familiar CSS-like shorthand. For example: `margin="small auto large"`.
|
|
100
|
-
*/
|
|
101
116
|
margin: ThemeablePropTypes.spacing,
|
|
102
|
-
/**
|
|
103
|
-
* Provides a reference to the underlying nav element
|
|
104
|
-
*/
|
|
105
117
|
elementRef: PropTypes.func,
|
|
106
|
-
/**
|
|
107
|
-
* Customize the text displayed in the menu trigger when links overflow
|
|
108
|
-
* the overall nav width.
|
|
109
|
-
*/
|
|
110
118
|
renderTruncateLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
111
|
-
/**
|
|
112
|
-
* Called whenever the navigation items are updated or the size of
|
|
113
|
-
* the navigation changes. Passes in the `visibleItemsCount` as
|
|
114
|
-
* a parameter.
|
|
115
|
-
*/
|
|
116
119
|
onUpdate: PropTypes.func,
|
|
117
|
-
/**
|
|
118
|
-
* Sets the number of navigation items that are visible.
|
|
119
|
-
*/
|
|
120
120
|
visibleItemsCount: PropTypes.number
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -40,6 +40,7 @@ import { allowedProps, propTypes } from './props'
|
|
|
40
40
|
parent: Navigation
|
|
41
41
|
id: Navigation.Item
|
|
42
42
|
---
|
|
43
|
+
@tsProps
|
|
43
44
|
**/
|
|
44
45
|
@withStyle(generateStyle, generateComponentTheme)
|
|
45
46
|
@testable()
|
|
@@ -51,8 +52,6 @@ class NavigationItem extends Component<NavigationItemProps> {
|
|
|
51
52
|
|
|
52
53
|
static defaultProps = {
|
|
53
54
|
as: 'a',
|
|
54
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'e' is declared but its value is never read.
|
|
55
|
-
onClick: function (e, selected) {},
|
|
56
55
|
selected: false,
|
|
57
56
|
minimized: false
|
|
58
57
|
} as const
|
|
@@ -83,7 +82,6 @@ class NavigationItem extends Component<NavigationItemProps> {
|
|
|
83
82
|
const props = omitProps(this.props, NavigationItem.allowedProps)
|
|
84
83
|
|
|
85
84
|
return (
|
|
86
|
-
//@ts-expect-error TODO: INSTUI-3245
|
|
87
85
|
<ElementType
|
|
88
86
|
// @ts-expect-error TODO: fix TS2590: Expression produces a union type that is too complex to represent.
|
|
89
87
|
{...props}
|
|
@@ -91,7 +89,7 @@ class NavigationItem extends Component<NavigationItemProps> {
|
|
|
91
89
|
onClick={onClick}
|
|
92
90
|
ref={addRef ? this.handleRef : undefined}
|
|
93
91
|
css={this.props.styles?.navigationItem}
|
|
94
|
-
aria-label={this.props.minimized ? label : undefined}
|
|
92
|
+
aria-label={this.props.minimized ? (label as string) : undefined}
|
|
95
93
|
>
|
|
96
94
|
<div css={this.props.styles?.icon} aria-hidden="true">
|
|
97
95
|
{icon}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import PropTypes from 'prop-types'
|
|
25
|
-
|
|
25
|
+
import React from 'react'
|
|
26
26
|
import type {
|
|
27
27
|
AsElementType,
|
|
28
28
|
PropValidators,
|
|
@@ -32,13 +32,37 @@ import type {
|
|
|
32
32
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
33
33
|
|
|
34
34
|
type NavigationItemOwnProps = {
|
|
35
|
+
/**
|
|
36
|
+
* The reference to the underlying HTML element
|
|
37
|
+
*/
|
|
35
38
|
elementRef?: (el: Element | null) => void
|
|
39
|
+
/**
|
|
40
|
+
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
41
|
+
*/
|
|
36
42
|
icon: React.ReactNode
|
|
43
|
+
/**
|
|
44
|
+
* The text to display for the Navigation Link
|
|
45
|
+
*/
|
|
37
46
|
label: React.ReactNode
|
|
47
|
+
/**
|
|
48
|
+
* The element type to render as (will default to `<a>` if href is provided)
|
|
49
|
+
*/
|
|
38
50
|
as?: AsElementType
|
|
51
|
+
/**
|
|
52
|
+
* If the NavigationItem goes to a new page, pass an href
|
|
53
|
+
*/
|
|
39
54
|
href?: string
|
|
40
|
-
|
|
55
|
+
/**
|
|
56
|
+
* If the NavigationItem does not go to a new page pass an onClick
|
|
57
|
+
*/
|
|
58
|
+
onClick?: (event: React.MouseEvent) => void
|
|
59
|
+
/**
|
|
60
|
+
* Denotes which NavigationItem is currently selected
|
|
61
|
+
*/
|
|
41
62
|
selected?: boolean
|
|
63
|
+
/**
|
|
64
|
+
* 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
|
|
65
|
+
*/
|
|
42
66
|
minimized?: boolean
|
|
43
67
|
}
|
|
44
68
|
|
|
@@ -53,37 +77,13 @@ type NavigationItemProps = NavigationItemOwnProps &
|
|
|
53
77
|
type NavigationItemStyle = ComponentStyle<'navigationItem' | 'icon' | 'label'>
|
|
54
78
|
|
|
55
79
|
const propTypes: PropValidators<PropKeys> = {
|
|
56
|
-
/**
|
|
57
|
-
* The reference to the underlying HTML element
|
|
58
|
-
*/
|
|
59
80
|
elementRef: PropTypes.func,
|
|
60
|
-
/**
|
|
61
|
-
* The visual to display (ex. an Image, Logo, Avatar, or Icon)
|
|
62
|
-
*/
|
|
63
81
|
icon: PropTypes.node.isRequired,
|
|
64
|
-
/**
|
|
65
|
-
* The text to display for the Navigation Link
|
|
66
|
-
*/
|
|
67
82
|
label: PropTypes.node.isRequired,
|
|
68
|
-
/**
|
|
69
|
-
* The element type to render as (will default to `<a>` if href is provided)
|
|
70
|
-
*/
|
|
71
83
|
as: PropTypes.elementType,
|
|
72
|
-
/**
|
|
73
|
-
* If the NavigationItem goes to a new page, pass an href
|
|
74
|
-
*/
|
|
75
84
|
href: PropTypes.string,
|
|
76
|
-
/**
|
|
77
|
-
* If the NavigationItem does not go to a new page pass an onClick
|
|
78
|
-
*/
|
|
79
85
|
onClick: PropTypes.func,
|
|
80
|
-
/**
|
|
81
|
-
* Denotes which NavigationItem is currently selected
|
|
82
|
-
*/
|
|
83
86
|
selected: PropTypes.bool,
|
|
84
|
-
/**
|
|
85
|
-
* 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
|
|
86
|
-
*/
|
|
87
87
|
minimized: PropTypes.bool
|
|
88
88
|
}
|
|
89
89
|
|
package/src/Navigation/index.tsx
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
/** @jsx jsx */
|
|
25
|
-
import { Component, Children, ReactElement } from 'react'
|
|
25
|
+
import React, { Component, Children, ReactElement } from 'react'
|
|
26
26
|
|
|
27
27
|
import { testable } from '@instructure/ui-testable'
|
|
28
28
|
|
|
@@ -42,13 +42,15 @@ import generateComponentTheme from './theme'
|
|
|
42
42
|
import type { NavigationProps, NavigationState } from './props'
|
|
43
43
|
import { allowedProps, propTypes } from './props'
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
const navMinimized = ({ minimized }: { minimized: boolean }) => ({
|
|
46
|
+
minimized: !minimized
|
|
47
|
+
})
|
|
47
48
|
|
|
48
49
|
/**
|
|
49
50
|
---
|
|
50
51
|
category: components/deprecated
|
|
51
52
|
---
|
|
53
|
+
@tsProps
|
|
52
54
|
**/
|
|
53
55
|
|
|
54
56
|
@withStyle(generateStyle, generateComponentTheme)
|
|
@@ -63,24 +65,20 @@ class Navigation extends Component<NavigationProps, NavigationState> {
|
|
|
63
65
|
static defaultProps = {
|
|
64
66
|
children: null,
|
|
65
67
|
defaultMinimized: false,
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
// @ts-expect-error ts-migrate(6133) FIXME: 'e' is declared but its value is never read.
|
|
69
|
-
onClick: function (e) {}
|
|
68
|
+
// TODO we should investigate later if it used or not
|
|
69
|
+
onClick: function (_e: React.MouseEvent) {}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
static Item = NavigationItem
|
|
73
73
|
|
|
74
74
|
ref: Element | null = null
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1-2 arguments, but got 0.
|
|
79
|
-
super()
|
|
76
|
+
constructor(props: NavigationProps) {
|
|
77
|
+
super(props)
|
|
80
78
|
|
|
81
79
|
this.state = {
|
|
82
80
|
minimized: this.isControlled(props)
|
|
83
|
-
? props.minimized
|
|
81
|
+
? !!props.minimized
|
|
84
82
|
: !!props.defaultMinimized
|
|
85
83
|
}
|
|
86
84
|
}
|
|
@@ -104,14 +102,13 @@ class Navigation extends Component<NavigationProps, NavigationState> {
|
|
|
104
102
|
return typeof props.minimized === 'boolean'
|
|
105
103
|
}
|
|
106
104
|
|
|
107
|
-
|
|
108
|
-
handleNavToggle = (event) => {
|
|
105
|
+
handleNavToggle = (event: React.SyntheticEvent) => {
|
|
109
106
|
if (!this.isControlled()) {
|
|
110
107
|
this.setState(navMinimized)
|
|
111
108
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
109
|
+
if (typeof this.props.onMinimized === 'function') {
|
|
110
|
+
this.props.onMinimized(event, !this.minimized)
|
|
111
|
+
}
|
|
115
112
|
}
|
|
116
113
|
|
|
117
114
|
renderChildren() {
|
package/src/Navigation/props.ts
CHANGED
|
@@ -39,16 +39,37 @@ import type {
|
|
|
39
39
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
40
40
|
|
|
41
41
|
type NavigationOwnProps = {
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* 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
|
|
44
|
+
*/
|
|
45
|
+
minimized?: boolean
|
|
46
|
+
/**
|
|
47
|
+
* Whether the `<Navigation />` is initially minimized (uncontrolled)
|
|
48
|
+
*/
|
|
43
49
|
defaultMinimized?: boolean
|
|
44
|
-
onMinimized?: (
|
|
50
|
+
onMinimized?: (event: React.SyntheticEvent, minimized: boolean) => void
|
|
51
|
+
/**
|
|
52
|
+
* Screen reader label for the main Navigation
|
|
53
|
+
*/
|
|
45
54
|
label: string
|
|
55
|
+
/**
|
|
56
|
+
* Screen reader label for the toggle button expanded/minimized state
|
|
57
|
+
*/
|
|
46
58
|
toggleLabel: {
|
|
47
59
|
expandedLabel?: string
|
|
48
60
|
minimizedLabel?: string
|
|
49
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* If the `<Navigation.Item>` goes to a new page, pass an href
|
|
64
|
+
*/
|
|
50
65
|
href?: string
|
|
51
|
-
|
|
66
|
+
/**
|
|
67
|
+
* If the `<Navigation.Item>` does not go to a new page pass an onClick
|
|
68
|
+
*/
|
|
69
|
+
onClick?: (event: React.MouseEvent) => void
|
|
70
|
+
/**
|
|
71
|
+
* children of type Navigation.Item
|
|
72
|
+
*/
|
|
52
73
|
children?: React.ReactNode
|
|
53
74
|
}
|
|
54
75
|
|
|
@@ -69,37 +90,16 @@ type NavigationStyle = ComponentStyle<
|
|
|
69
90
|
>
|
|
70
91
|
|
|
71
92
|
const propTypes: PropValidators<PropKeys> = {
|
|
72
|
-
/**
|
|
73
|
-
* children of type Navigation.Item
|
|
74
|
-
*/
|
|
75
93
|
children: ChildrenPropTypes.oneOf([NavigationItem]),
|
|
76
|
-
/**
|
|
77
|
-
* 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
|
|
78
|
-
*/
|
|
79
94
|
minimized: controllable(PropTypes.bool, 'onMinimized', 'defaultMinimized'),
|
|
80
|
-
/**
|
|
81
|
-
* Whether the `<Navigation />` is initially minimized (uncontrolled)
|
|
82
|
-
*/
|
|
83
95
|
defaultMinimized: PropTypes.bool,
|
|
84
96
|
onMinimized: PropTypes.func,
|
|
85
|
-
/**
|
|
86
|
-
* Screen reader label for the main Navigation
|
|
87
|
-
*/
|
|
88
97
|
label: PropTypes.string.isRequired,
|
|
89
|
-
/**
|
|
90
|
-
* Screen reader label for the toggle button expanded/minimized state
|
|
91
|
-
*/
|
|
92
98
|
toggleLabel: PropTypes.shape({
|
|
93
99
|
expandedLabel: PropTypes.string,
|
|
94
100
|
minimizedLabel: PropTypes.string
|
|
95
101
|
}).isRequired,
|
|
96
|
-
/**
|
|
97
|
-
* If the `<Navigation.Item>` goes to a new page, pass an href
|
|
98
|
-
*/
|
|
99
102
|
href: PropTypes.string,
|
|
100
|
-
/**
|
|
101
|
-
* If the `<Navigation.Item>` does not go to a new page pass an onClick
|
|
102
|
-
*/
|
|
103
103
|
onClick: PropTypes.func
|
|
104
104
|
}
|
|
105
105
|
|