@instructure/ui-top-nav-bar 10.26.1-snapshot-2 → 10.26.2
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 +5 -18
- package/es/TopNavBar/TopNavBarActionItems/index.js +5 -5
- package/es/TopNavBar/TopNavBarActionItems/props.js +12 -1
- package/es/TopNavBar/TopNavBarBrand/index.js +5 -5
- package/es/TopNavBar/TopNavBarBrand/props.js +11 -1
- package/es/TopNavBar/TopNavBarBreadcrumb/index.js +5 -6
- package/es/TopNavBar/TopNavBarBreadcrumb/props.js +9 -1
- package/es/TopNavBar/TopNavBarItem/index.js +6 -6
- package/es/TopNavBar/TopNavBarItem/props.js +44 -1
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +5 -5
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/props.js +7 -2
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +5 -5
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.js +7 -2
- package/es/TopNavBar/TopNavBarLayout/index.js +6 -5
- package/es/TopNavBar/TopNavBarLayout/props.js +45 -1
- package/es/TopNavBar/TopNavBarMenuItems/index.js +7 -8
- package/es/TopNavBar/TopNavBarMenuItems/props.js +11 -1
- package/es/TopNavBar/TopNavBarUser/index.js +5 -5
- package/es/TopNavBar/TopNavBarUser/props.js +8 -1
- package/es/TopNavBar/index.js +6 -18
- package/es/TopNavBar/props.js +9 -1
- package/es/TopNavBar/utils/mapItemsForDrilldown.js +1 -2
- package/lib/TopNavBar/TopNavBarActionItems/index.js +4 -4
- package/lib/TopNavBar/TopNavBarActionItems/props.js +13 -1
- package/lib/TopNavBar/TopNavBarBrand/index.js +4 -4
- package/lib/TopNavBar/TopNavBarBrand/props.js +12 -1
- package/lib/TopNavBar/TopNavBarBreadcrumb/index.js +4 -5
- package/lib/TopNavBar/TopNavBarBreadcrumb/props.js +10 -1
- package/lib/TopNavBar/TopNavBarItem/index.js +5 -5
- package/lib/TopNavBar/TopNavBarItem/props.js +45 -1
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +4 -4
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/props.js +6 -1
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +4 -4
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.js +6 -1
- package/lib/TopNavBar/TopNavBarLayout/index.js +5 -4
- package/lib/TopNavBar/TopNavBarLayout/props.js +47 -1
- package/lib/TopNavBar/TopNavBarMenuItems/index.js +6 -7
- package/lib/TopNavBar/TopNavBarMenuItems/props.js +12 -1
- package/lib/TopNavBar/TopNavBarUser/index.js +4 -4
- package/lib/TopNavBar/TopNavBarUser/props.js +9 -1
- package/lib/TopNavBar/index.js +5 -19
- package/lib/TopNavBar/props.js +10 -1
- package/lib/TopNavBar/utils/mapItemsForDrilldown.js +1 -2
- package/package.json +31 -28
- package/src/TopNavBar/TopNavBarActionItems/index.tsx +8 -2
- package/src/TopNavBar/TopNavBarActionItems/props.ts +22 -1
- package/src/TopNavBar/TopNavBarBrand/index.tsx +5 -6
- package/src/TopNavBar/TopNavBarBrand/props.ts +16 -1
- package/src/TopNavBar/TopNavBarBreadcrumb/index.tsx +9 -13
- package/src/TopNavBar/TopNavBarBreadcrumb/props.ts +15 -3
- package/src/TopNavBar/TopNavBarItem/index.tsx +5 -6
- package/src/TopNavBar/TopNavBarItem/props.ts +51 -1
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/index.tsx +4 -2
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/props.ts +19 -3
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.tsx +4 -2
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.ts +18 -3
- package/src/TopNavBar/TopNavBarLayout/index.tsx +5 -1
- package/src/TopNavBar/TopNavBarLayout/props.ts +60 -1
- package/src/TopNavBar/TopNavBarMenuItems/index.tsx +5 -10
- package/src/TopNavBar/TopNavBarMenuItems/props.ts +19 -1
- package/src/TopNavBar/TopNavBarUser/index.tsx +4 -2
- package/src/TopNavBar/TopNavBarUser/props.ts +14 -1
- package/src/TopNavBar/index.tsx +4 -2
- package/src/TopNavBar/props.ts +17 -2
- package/src/TopNavBar/utils/mapItemsForDrilldown.tsx +1 -1
- package/tsconfig.build.json +3 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/TopNavBar/TopNavBarActionItems/index.d.ts +1 -0
- package/types/TopNavBar/TopNavBarActionItems/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarActionItems/props.d.ts +3 -2
- package/types/TopNavBar/TopNavBarActionItems/props.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarBrand/index.d.ts +1 -0
- package/types/TopNavBar/TopNavBarBrand/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarBrand/props.d.ts +3 -2
- package/types/TopNavBar/TopNavBarBrand/props.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarBreadcrumb/index.d.ts +5 -0
- package/types/TopNavBar/TopNavBarBreadcrumb/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarBreadcrumb/props.d.ts +3 -2
- package/types/TopNavBar/TopNavBarBreadcrumb/props.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarItem/index.d.ts +1 -0
- package/types/TopNavBar/TopNavBarItem/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarItem/props.d.ts +13 -2
- package/types/TopNavBar/TopNavBarItem/props.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/index.d.ts +1 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/props.d.ts +3 -2
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/props.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.d.ts +1 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.d.ts +3 -2
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarLayout/index.d.ts +1 -0
- package/types/TopNavBar/TopNavBarLayout/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarLayout/props.d.ts +6 -2
- package/types/TopNavBar/TopNavBarLayout/props.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarMenuItems/index.d.ts +1 -0
- package/types/TopNavBar/TopNavBarMenuItems/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarMenuItems/props.d.ts +3 -2
- package/types/TopNavBar/TopNavBarMenuItems/props.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarUser/index.d.ts +1 -0
- package/types/TopNavBar/TopNavBarUser/index.d.ts.map +1 -1
- package/types/TopNavBar/TopNavBarUser/props.d.ts +3 -2
- package/types/TopNavBar/TopNavBarUser/props.d.ts.map +1 -1
- package/types/TopNavBar/index.d.ts +1 -0
- package/types/TopNavBar/index.d.ts.map +1 -1
- package/types/TopNavBar/props.d.ts +3 -2
- package/types/TopNavBar/props.d.ts.map +1 -1
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
withDeterministicId
|
|
34
34
|
} from '@instructure/ui-react-utils'
|
|
35
35
|
import { createChainedFunction } from '@instructure/ui-utils'
|
|
36
|
+
import { testable } from '@instructure/ui-testable'
|
|
36
37
|
import { warn, error } from '@instructure/console'
|
|
37
38
|
|
|
38
39
|
import { withStyle, InstUISettingsProvider } from '@instructure/emotion'
|
|
@@ -57,7 +58,7 @@ import { TopNavBarContext } from '../TopNavBarContext'
|
|
|
57
58
|
import generateStyle from './styles'
|
|
58
59
|
import generateComponentTheme from './theme'
|
|
59
60
|
|
|
60
|
-
import { allowedProps } from './props'
|
|
61
|
+
import { propTypes, allowedProps } from './props'
|
|
61
62
|
import type {
|
|
62
63
|
TopNavBarItemProps,
|
|
63
64
|
TopNavBarItemState,
|
|
@@ -79,9 +80,11 @@ id: TopNavBar.Item
|
|
|
79
80
|
**/
|
|
80
81
|
@withDeterministicId()
|
|
81
82
|
@withStyle(generateStyle, generateComponentTheme)
|
|
83
|
+
@testable()
|
|
82
84
|
class TopNavBarItem extends Component<TopNavBarItemProps, TopNavBarItemState> {
|
|
83
85
|
static readonly componentId = 'TopNavBar.Item'
|
|
84
86
|
|
|
87
|
+
static propTypes = propTypes
|
|
85
88
|
static allowedProps = allowedProps
|
|
86
89
|
static defaultProps = {
|
|
87
90
|
status: 'default',
|
|
@@ -741,11 +744,7 @@ class TopNavBarItem extends Component<TopNavBarItemProps, TopNavBarItemState> {
|
|
|
741
744
|
}
|
|
742
745
|
|
|
743
746
|
return (
|
|
744
|
-
<div
|
|
745
|
-
ref={this.handleRef}
|
|
746
|
-
css={styles?.topNavBarItem}
|
|
747
|
-
data-cid="TopNavBarItem"
|
|
748
|
-
>
|
|
747
|
+
<div ref={this.handleRef} css={styles?.topNavBarItem}>
|
|
749
748
|
{content}
|
|
750
749
|
</div>
|
|
751
750
|
)
|
|
@@ -23,12 +23,16 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
|
|
26
29
|
|
|
27
30
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
28
31
|
import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
|
|
29
32
|
import type {
|
|
30
33
|
TopNavBarItemTheme,
|
|
31
34
|
OtherHTMLAttributes,
|
|
35
|
+
PropValidators,
|
|
32
36
|
Renderable,
|
|
33
37
|
AsElementType
|
|
34
38
|
} from '@instructure/shared-types'
|
|
@@ -59,6 +63,19 @@ type TopNavBarItemTooltipType =
|
|
|
59
63
|
onHideContent?: TooltipProps['onHideContent']
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
const topNavBarItemTooltipPropType = PropTypes.oneOfType([
|
|
67
|
+
PropTypes.string,
|
|
68
|
+
PropTypes.shape({
|
|
69
|
+
renderTip: PropTypes.oneOfType([PropTypes.node, PropTypes.func]).isRequired,
|
|
70
|
+
color: PropTypes.oneOf(['primary', 'primary-inverse']),
|
|
71
|
+
placement: PropTypes.string,
|
|
72
|
+
offsetX: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
73
|
+
offsetY: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
74
|
+
onShowContent: PropTypes.func,
|
|
75
|
+
onHideContent: PropTypes.func
|
|
76
|
+
})
|
|
77
|
+
])
|
|
78
|
+
|
|
62
79
|
type TopNavBarItemOwnProps = {
|
|
63
80
|
/**
|
|
64
81
|
* the element type to render as (will default to `<a>` if href is provided)
|
|
@@ -279,6 +296,39 @@ type TopNavBarItemStyleProps = {
|
|
|
279
296
|
layout: TopNavBarContextType['layout']
|
|
280
297
|
inverseColor: TopNavBarContextType['inverseColor']
|
|
281
298
|
}
|
|
299
|
+
|
|
300
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
301
|
+
id: PropTypes.string.isRequired,
|
|
302
|
+
as: PropTypes.elementType,
|
|
303
|
+
children: PropTypes.node.isRequired,
|
|
304
|
+
variant: PropTypes.oneOf(['default', 'button', 'icon', 'avatar']),
|
|
305
|
+
status: PropTypes.oneOf(['default', 'active', 'disabled']),
|
|
306
|
+
renderSubmenu: ChildrenPropTypes.oneOf([Drilldown]),
|
|
307
|
+
showSubmenuChevron: PropTypes.bool,
|
|
308
|
+
customPopoverConfig: PropTypes.object,
|
|
309
|
+
tooltip: topNavBarItemTooltipPropType,
|
|
310
|
+
renderAvatar: PropTypes.shape({
|
|
311
|
+
avatarName: PropTypes.string.isRequired,
|
|
312
|
+
avatarSrc: PropTypes.string,
|
|
313
|
+
avatarAlt: PropTypes.string
|
|
314
|
+
}),
|
|
315
|
+
renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
316
|
+
href: PropTypes.string,
|
|
317
|
+
onClick: PropTypes.func,
|
|
318
|
+
onHiddenClick: PropTypes.func,
|
|
319
|
+
onSubmenuToggle: PropTypes.func,
|
|
320
|
+
onMouseOver: PropTypes.func,
|
|
321
|
+
onMouseOut: PropTypes.func,
|
|
322
|
+
onFocus: PropTypes.func,
|
|
323
|
+
onBlur: PropTypes.func,
|
|
324
|
+
onKeyDown: PropTypes.func,
|
|
325
|
+
onKeyUp: PropTypes.func,
|
|
326
|
+
elementRef: PropTypes.func,
|
|
327
|
+
itemRef: PropTypes.func,
|
|
328
|
+
shouldCloseOnClick: PropTypes.oneOf(['auto', 'always', 'never']),
|
|
329
|
+
withFocusOutline: PropTypes.bool
|
|
330
|
+
}
|
|
331
|
+
|
|
282
332
|
const allowedProps: AllowedPropKeys = [
|
|
283
333
|
'id',
|
|
284
334
|
'as',
|
|
@@ -317,4 +367,4 @@ export type {
|
|
|
317
367
|
DrilldownSubmenu,
|
|
318
368
|
TopNavBarItemTooltipType
|
|
319
369
|
}
|
|
320
|
-
export { allowedProps }
|
|
370
|
+
export { propTypes, allowedProps, topNavBarItemTooltipPropType }
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import { Children, Component } from 'react'
|
|
26
26
|
|
|
27
27
|
import { omitProps } from '@instructure/ui-react-utils'
|
|
28
|
+
import { testable } from '@instructure/ui-testable'
|
|
28
29
|
|
|
29
30
|
import { withStyle } from '@instructure/emotion'
|
|
30
31
|
|
|
@@ -33,7 +34,7 @@ import { TopNavBarContext } from '../../TopNavBarContext'
|
|
|
33
34
|
import generateStyle from './styles'
|
|
34
35
|
import generateComponentTheme from './theme'
|
|
35
36
|
|
|
36
|
-
import { allowedProps } from './props'
|
|
37
|
+
import { propTypes, allowedProps } from './props'
|
|
37
38
|
import type {
|
|
38
39
|
TopNavBarDesktopLayoutProps,
|
|
39
40
|
TopNavBarDesktopLayoutStyleProps
|
|
@@ -45,9 +46,11 @@ private: true
|
|
|
45
46
|
---
|
|
46
47
|
**/
|
|
47
48
|
@withStyle(generateStyle, generateComponentTheme)
|
|
49
|
+
@testable()
|
|
48
50
|
class TopNavBarDesktopLayout extends Component<TopNavBarDesktopLayoutProps> {
|
|
49
51
|
static readonly componentId = 'TopNavBar.DesktopLayout'
|
|
50
52
|
|
|
53
|
+
static propTypes = propTypes
|
|
51
54
|
static allowedProps = allowedProps
|
|
52
55
|
static defaultProps = {}
|
|
53
56
|
|
|
@@ -136,7 +139,6 @@ class TopNavBarDesktopLayout extends Component<TopNavBarDesktopLayoutProps> {
|
|
|
136
139
|
ref={this.handleRef}
|
|
137
140
|
css={styles?.topNavBarDesktopLayout}
|
|
138
141
|
aria-label={navLabel}
|
|
139
|
-
data-cid="TopNavBarDesktopLayout"
|
|
140
142
|
>
|
|
141
143
|
{this.hasBrandBlock && (
|
|
142
144
|
<div css={styles?.brandContainer}>{renderBrand}</div>
|
|
@@ -23,13 +23,22 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
+
|
|
26
27
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
27
28
|
import type {
|
|
28
29
|
TopNavBarLayoutDesktopTheme,
|
|
29
|
-
OtherHTMLAttributes
|
|
30
|
+
OtherHTMLAttributes,
|
|
31
|
+
PropValidators
|
|
30
32
|
} from '@instructure/shared-types'
|
|
33
|
+
|
|
31
34
|
import type { TopNavBarContextType } from '../../TopNavBarContext'
|
|
32
|
-
|
|
35
|
+
|
|
36
|
+
import {
|
|
37
|
+
commonPropTypes,
|
|
38
|
+
commonAllowedProps,
|
|
39
|
+
desktopPropTypes,
|
|
40
|
+
desktopAllowedProps
|
|
41
|
+
} from '../props'
|
|
33
42
|
import type { CommonTopNavBarLayoutProps } from '../props'
|
|
34
43
|
|
|
35
44
|
import { TopNavBarDesktopLayout } from './index'
|
|
@@ -73,6 +82,13 @@ type TopNavBarDesktopLayoutStyleProps = {
|
|
|
73
82
|
hasActionItemsBlock: boolean
|
|
74
83
|
hasUserBlock: boolean
|
|
75
84
|
}
|
|
85
|
+
|
|
86
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
87
|
+
// Edit PropTypes in TopNabBarLayout/props.ts
|
|
88
|
+
...commonPropTypes,
|
|
89
|
+
...desktopPropTypes
|
|
90
|
+
}
|
|
91
|
+
|
|
76
92
|
const allowedProps: AllowedPropKeys = [
|
|
77
93
|
// Edit allowed props in TopNabBarLayout/props.ts
|
|
78
94
|
...commonAllowedProps,
|
|
@@ -87,4 +103,4 @@ export type {
|
|
|
87
103
|
TopNavBarDesktopLayoutStyle,
|
|
88
104
|
TopNavBarDesktopLayoutStyleProps
|
|
89
105
|
}
|
|
90
|
-
export { allowedProps }
|
|
106
|
+
export { propTypes, allowedProps }
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
} from '@instructure/ui-react-utils'
|
|
32
32
|
import { px } from '@instructure/ui-utils'
|
|
33
33
|
import { warn } from '@instructure/console'
|
|
34
|
+
import { testable } from '@instructure/ui-testable'
|
|
34
35
|
import {
|
|
35
36
|
getBoundingClientRect,
|
|
36
37
|
requestAnimationFrame
|
|
@@ -65,7 +66,7 @@ import { TopNavBarContext } from '../../TopNavBarContext'
|
|
|
65
66
|
import generateStyle from './styles'
|
|
66
67
|
import generateComponentTheme from './theme'
|
|
67
68
|
|
|
68
|
-
import { allowedProps } from './props'
|
|
69
|
+
import { propTypes, allowedProps } from './props'
|
|
69
70
|
import type {
|
|
70
71
|
TopNavBarSmallViewportLayoutProps,
|
|
71
72
|
TopNavBarSmallViewportLayoutState,
|
|
@@ -79,12 +80,14 @@ private: true
|
|
|
79
80
|
**/
|
|
80
81
|
@withDeterministicId()
|
|
81
82
|
@withStyle(generateStyle, generateComponentTheme)
|
|
83
|
+
@testable()
|
|
82
84
|
class TopNavBarSmallViewportLayout extends Component<
|
|
83
85
|
TopNavBarSmallViewportLayoutProps,
|
|
84
86
|
TopNavBarSmallViewportLayoutState
|
|
85
87
|
> {
|
|
86
88
|
static readonly componentId = 'TopNavBar.SmallViewportLayout'
|
|
87
89
|
|
|
90
|
+
static propTypes = propTypes
|
|
88
91
|
static allowedProps = allowedProps
|
|
89
92
|
static defaultProps = {}
|
|
90
93
|
|
|
@@ -625,7 +628,6 @@ class TopNavBarSmallViewportLayout extends Component<
|
|
|
625
628
|
{...omitProps(this.props, allowedProps)}
|
|
626
629
|
ref={this.handleRef}
|
|
627
630
|
aria-label={navLabel}
|
|
628
|
-
data-cid="TopNavBarSmallViewportLayout"
|
|
629
631
|
>
|
|
630
632
|
<Global styles={styles?.globalStyles} />
|
|
631
633
|
|
|
@@ -23,18 +23,26 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
+
|
|
26
27
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
27
28
|
import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
|
|
28
29
|
import type {
|
|
29
30
|
TopNavBarLayoutSmallViewportTheme,
|
|
30
|
-
OtherHTMLAttributes
|
|
31
|
+
OtherHTMLAttributes,
|
|
32
|
+
PropValidators
|
|
31
33
|
} from '@instructure/shared-types'
|
|
32
34
|
|
|
33
35
|
import type { DrilldownProps } from '@instructure/ui-drilldown'
|
|
36
|
+
|
|
34
37
|
import type { TopNavBarItemTooltipType } from '../../TopNavBarItem/props'
|
|
35
38
|
import type { TopNavBarContextType } from '../../TopNavBarContext'
|
|
36
39
|
|
|
37
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
commonAllowedProps,
|
|
42
|
+
commonPropTypes,
|
|
43
|
+
smallViewportPropTypes,
|
|
44
|
+
smallViewportAllowedProps
|
|
45
|
+
} from '../props'
|
|
38
46
|
import type { CommonTopNavBarLayoutProps } from '../props'
|
|
39
47
|
|
|
40
48
|
import { TopNavBarSmallViewportLayout } from './index'
|
|
@@ -159,6 +167,13 @@ type TopNavBarSmallViewportLayoutStyleProps = {
|
|
|
159
167
|
menuBottomPosition: number
|
|
160
168
|
inverseColor: TopNavBarContextType['inverseColor']
|
|
161
169
|
}
|
|
170
|
+
|
|
171
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
172
|
+
// Edit PropTypes in TopNavBarLayout/props.ts
|
|
173
|
+
...commonPropTypes,
|
|
174
|
+
...smallViewportPropTypes
|
|
175
|
+
}
|
|
176
|
+
|
|
162
177
|
const allowedProps: AllowedPropKeys = [
|
|
163
178
|
// Edit allowed props in TopNavBarLayout/props.ts
|
|
164
179
|
...commonAllowedProps,
|
|
@@ -174,4 +189,4 @@ export type {
|
|
|
174
189
|
TopNavBarSmallViewportLayoutState,
|
|
175
190
|
TopNavBarSmallViewportLayoutStyleProps
|
|
176
191
|
}
|
|
177
|
-
export { allowedProps }
|
|
192
|
+
export { propTypes, allowedProps }
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
|
|
27
|
+
import { testable } from '@instructure/ui-testable'
|
|
28
|
+
|
|
27
29
|
import { withStyle } from '@instructure/emotion'
|
|
28
30
|
|
|
29
31
|
import type {
|
|
@@ -40,7 +42,7 @@ import type { TopNavBarSmallViewportLayoutProps } from './SmallViewportLayout/pr
|
|
|
40
42
|
import { TopNavBarDesktopLayout } from './DesktopLayout'
|
|
41
43
|
import type { TopNavBarDesktopLayoutProps } from './DesktopLayout/props'
|
|
42
44
|
|
|
43
|
-
import { allowedProps } from './props'
|
|
45
|
+
import { propTypes, allowedProps } from './props'
|
|
44
46
|
import type { TopNavBarLayoutProps } from './props'
|
|
45
47
|
|
|
46
48
|
/**
|
|
@@ -51,9 +53,11 @@ id: TopNavBar.Layout
|
|
|
51
53
|
@module TopNavBarLayout
|
|
52
54
|
**/
|
|
53
55
|
@withStyle(null, generateComponentTheme)
|
|
56
|
+
@testable()
|
|
54
57
|
class TopNavBarLayout extends Component<TopNavBarLayoutProps> {
|
|
55
58
|
static readonly componentId = 'TopNavBar.Layout'
|
|
56
59
|
|
|
60
|
+
static propTypes = propTypes
|
|
57
61
|
static allowedProps = allowedProps
|
|
58
62
|
static defaultProps = {
|
|
59
63
|
smallViewportConfig: {}
|
|
@@ -23,22 +23,37 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import {
|
|
29
|
+
Children as ChildrenPropTypes,
|
|
30
|
+
element
|
|
31
|
+
} from '@instructure/ui-prop-types'
|
|
26
32
|
|
|
27
33
|
import type { WithStyleProps } from '@instructure/emotion'
|
|
28
34
|
import type {
|
|
29
35
|
TopNavBarLayoutTheme,
|
|
30
|
-
OtherHTMLAttributes
|
|
36
|
+
OtherHTMLAttributes,
|
|
37
|
+
PropValidators
|
|
31
38
|
} from '@instructure/shared-types'
|
|
32
39
|
|
|
40
|
+
import { TopNavBarActionItems } from '../TopNavBarActionItems'
|
|
41
|
+
import { TopNavBarBrand } from '../TopNavBarBrand'
|
|
42
|
+
import { TopNavBarMenuItems } from '../TopNavBarMenuItems'
|
|
43
|
+
import { TopNavBarUser } from '../TopNavBarUser'
|
|
44
|
+
|
|
33
45
|
import type { ActionItemsChild } from '../TopNavBarActionItems/props'
|
|
34
46
|
import type { BrandChild } from '../TopNavBarBrand/props'
|
|
35
47
|
import type { MenuItemsChild } from '../TopNavBarMenuItems/props'
|
|
36
48
|
import type { UserChild } from '../TopNavBarUser/props'
|
|
37
49
|
import type { BreadcrumbChild } from '../TopNavBarBreadcrumb/props'
|
|
38
50
|
|
|
51
|
+
import { topNavBarItemTooltipPropType } from '../TopNavBarItem/props'
|
|
52
|
+
|
|
39
53
|
import { TopNavBarLayout } from './index'
|
|
40
54
|
import type { DesktopLayoutOwnProps } from './DesktopLayout/props'
|
|
41
55
|
import type { SmallViewportLayoutOwnProps } from './SmallViewportLayout/props'
|
|
56
|
+
import { TopNavBarBreadcrumb } from '../TopNavBarBreadcrumb'
|
|
42
57
|
|
|
43
58
|
type LayoutChild = React.ComponentElement<TopNavBarLayoutProps, TopNavBarLayout>
|
|
44
59
|
|
|
@@ -121,6 +136,46 @@ type TopNavBarLayoutProps = TopNavBarLayoutOwnProps &
|
|
|
121
136
|
WithStyleProps<TopNavBarLayoutTheme, null> &
|
|
122
137
|
OtherHTMLAttributes<TopNavBarLayoutOwnProps>
|
|
123
138
|
|
|
139
|
+
const commonPropTypes: PropValidators<CommonPropKeys> = {
|
|
140
|
+
renderBrand: ChildrenPropTypes.oneOf([TopNavBarBrand]),
|
|
141
|
+
renderMenuItems: ChildrenPropTypes.oneOf([TopNavBarMenuItems]),
|
|
142
|
+
renderActionItems: ChildrenPropTypes.oneOf([TopNavBarActionItems]),
|
|
143
|
+
renderUser: ChildrenPropTypes.oneOf([TopNavBarUser]),
|
|
144
|
+
renderBreadcrumb: ChildrenPropTypes.oneOf([TopNavBarBreadcrumb]),
|
|
145
|
+
navLabel: PropTypes.string,
|
|
146
|
+
elementRef: PropTypes.func
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const desktopPropTypes: PropValidators<DesktopPropKeys> = {
|
|
150
|
+
hideActionsUserSeparator: PropTypes.bool
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const smallViewportPropTypes: PropValidators<SmallViewportPropKeys> = {
|
|
154
|
+
dropdownMenuToggleButtonLabel: PropTypes.string.isRequired,
|
|
155
|
+
dropdownMenuToggleButtonTooltip: topNavBarItemTooltipPropType,
|
|
156
|
+
dropdownMenuLabel: PropTypes.string,
|
|
157
|
+
alternativeTitle: PropTypes.node,
|
|
158
|
+
renderInPlaceDialogConfig: PropTypes.shape({
|
|
159
|
+
open: PropTypes.bool.isRequired,
|
|
160
|
+
onClose: PropTypes.func.isRequired,
|
|
161
|
+
closeButtonLabel: PropTypes.string.isRequired,
|
|
162
|
+
content: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
163
|
+
returnFocusElement: PropTypes.func,
|
|
164
|
+
shouldContainFocus: PropTypes.bool,
|
|
165
|
+
shouldCloseOnDocumentClick: PropTypes.bool,
|
|
166
|
+
shouldCloseOnEscape: PropTypes.bool
|
|
167
|
+
}),
|
|
168
|
+
trayMountNode: PropTypes.oneOfType([element, PropTypes.func]),
|
|
169
|
+
onDropdownMenuToggle: PropTypes.func,
|
|
170
|
+
onDropdownMenuSelect: PropTypes.func,
|
|
171
|
+
renderNavbarStartDangerousHack: PropTypes.node
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
175
|
+
...commonPropTypes,
|
|
176
|
+
smallViewportConfig: PropTypes.shape(smallViewportPropTypes).isRequired
|
|
177
|
+
}
|
|
178
|
+
|
|
124
179
|
const commonAllowedProps: CommonAllowedPropKeys = [
|
|
125
180
|
'renderBrand',
|
|
126
181
|
'renderMenuItems',
|
|
@@ -151,8 +206,12 @@ const allowedProps: AllowedPropKeys = [
|
|
|
151
206
|
|
|
152
207
|
export type { LayoutChild, CommonTopNavBarLayoutProps, TopNavBarLayoutProps }
|
|
153
208
|
export {
|
|
209
|
+
propTypes,
|
|
154
210
|
allowedProps,
|
|
211
|
+
commonPropTypes,
|
|
155
212
|
commonAllowedProps,
|
|
213
|
+
desktopPropTypes,
|
|
214
|
+
smallViewportPropTypes,
|
|
156
215
|
desktopAllowedProps,
|
|
157
216
|
smallViewportAllowedProps
|
|
158
217
|
}
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
withDeterministicId
|
|
31
31
|
} from '@instructure/ui-react-utils'
|
|
32
32
|
import { warn, error } from '@instructure/console'
|
|
33
|
+
import { testable } from '@instructure/ui-testable'
|
|
33
34
|
|
|
34
35
|
import { withStyle } from '@instructure/emotion'
|
|
35
36
|
|
|
@@ -50,7 +51,7 @@ import type { RenderOptionContent } from '../utils/mapItemsForDrilldown'
|
|
|
50
51
|
import generateStyle from './styles'
|
|
51
52
|
import generateComponentTheme from './theme'
|
|
52
53
|
|
|
53
|
-
import { allowedProps } from './props'
|
|
54
|
+
import { propTypes, allowedProps } from './props'
|
|
54
55
|
import type { TopNavBarMenuItemsProps, TopNavBarMenuItemsState } from './props'
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -62,12 +63,14 @@ id: TopNavBar.MenuItems
|
|
|
62
63
|
**/
|
|
63
64
|
@withDeterministicId()
|
|
64
65
|
@withStyle(generateStyle, generateComponentTheme)
|
|
66
|
+
@testable()
|
|
65
67
|
class TopNavBarMenuItems extends Component<
|
|
66
68
|
TopNavBarMenuItemsProps,
|
|
67
69
|
TopNavBarMenuItemsState
|
|
68
70
|
> {
|
|
69
71
|
static readonly componentId = 'TopNavBar.MenuItems'
|
|
70
72
|
|
|
73
|
+
static propTypes = propTypes
|
|
71
74
|
static allowedProps = allowedProps
|
|
72
75
|
static defaultProps = {}
|
|
73
76
|
|
|
@@ -189,14 +192,7 @@ class TopNavBarMenuItems extends Component<
|
|
|
189
192
|
return
|
|
190
193
|
}
|
|
191
194
|
|
|
192
|
-
const {
|
|
193
|
-
id,
|
|
194
|
-
status,
|
|
195
|
-
variant = 'default', // workaround because after react 19 defaultProps are not working as expected
|
|
196
|
-
renderSubmenu,
|
|
197
|
-
renderAvatar
|
|
198
|
-
} = child.props
|
|
199
|
-
|
|
195
|
+
const { id, status, variant, renderSubmenu, renderAvatar } = child.props
|
|
200
196
|
const isCurrentPage = currentPageId === id
|
|
201
197
|
|
|
202
198
|
if (renderAvatar) {
|
|
@@ -267,7 +263,6 @@ class TopNavBarMenuItems extends Component<
|
|
|
267
263
|
itemSpacing: styles.itemSpacing
|
|
268
264
|
})}
|
|
269
265
|
aria-label={listLabel}
|
|
270
|
-
data-cid="TopNavBarMenuItems"
|
|
271
266
|
>
|
|
272
267
|
{this.renderChildren()}
|
|
273
268
|
</TruncateList>
|
|
@@ -23,14 +23,20 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
|
|
26
29
|
|
|
27
30
|
import type { WithDeterministicIdProps } from '@instructure/ui-react-utils'
|
|
28
31
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
29
32
|
import type {
|
|
30
33
|
TopNavBarMenuItemsTheme,
|
|
31
34
|
OtherHTMLAttributes,
|
|
35
|
+
PropValidators,
|
|
32
36
|
ChildrenOfType
|
|
33
37
|
} from '@instructure/shared-types'
|
|
38
|
+
|
|
39
|
+
import { TopNavBarItem } from '../TopNavBarItem'
|
|
34
40
|
import type { ItemChild } from '../TopNavBarItem/props'
|
|
35
41
|
|
|
36
42
|
import { TopNavBarMenuItems } from './index'
|
|
@@ -97,6 +103,18 @@ type TopNavBarMenuItemsState = {
|
|
|
97
103
|
key: number
|
|
98
104
|
visibleItemsCount?: number
|
|
99
105
|
}
|
|
106
|
+
|
|
107
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
108
|
+
children: ChildrenPropTypes.oneOf([TopNavBarItem]),
|
|
109
|
+
currentPageId: PropTypes.string,
|
|
110
|
+
renderHiddenItemsMenuTriggerLabel: PropTypes.oneOfType([
|
|
111
|
+
PropTypes.func,
|
|
112
|
+
PropTypes.string
|
|
113
|
+
]).isRequired,
|
|
114
|
+
listLabel: PropTypes.string,
|
|
115
|
+
elementRef: PropTypes.func
|
|
116
|
+
}
|
|
117
|
+
|
|
100
118
|
const allowedProps: AllowedPropKeys = [
|
|
101
119
|
'children',
|
|
102
120
|
'currentPageId',
|
|
@@ -112,4 +130,4 @@ export type {
|
|
|
112
130
|
TopNavBarMenuItemsStyle,
|
|
113
131
|
TopNavBarMenuItemsState
|
|
114
132
|
}
|
|
115
|
-
export { allowedProps }
|
|
133
|
+
export { propTypes, allowedProps }
|
|
@@ -26,6 +26,7 @@ import { Component, Children } from 'react'
|
|
|
26
26
|
|
|
27
27
|
import { error } from '@instructure/console'
|
|
28
28
|
import { omitProps } from '@instructure/ui-react-utils'
|
|
29
|
+
import { testable } from '@instructure/ui-testable'
|
|
29
30
|
|
|
30
31
|
import { withStyle } from '@instructure/emotion'
|
|
31
32
|
|
|
@@ -34,7 +35,7 @@ import type { ItemChild, TopNavBarItemProps } from '../TopNavBarItem/props'
|
|
|
34
35
|
|
|
35
36
|
import generateStyle from './styles'
|
|
36
37
|
|
|
37
|
-
import { allowedProps } from './props'
|
|
38
|
+
import { propTypes, allowedProps } from './props'
|
|
38
39
|
import type { TopNavBarUserProps } from './props'
|
|
39
40
|
|
|
40
41
|
/**
|
|
@@ -45,9 +46,11 @@ id: TopNavBar.User
|
|
|
45
46
|
@module TopNavBarUser
|
|
46
47
|
**/
|
|
47
48
|
@withStyle(generateStyle, null)
|
|
49
|
+
@testable()
|
|
48
50
|
class TopNavBarUser extends Component<TopNavBarUserProps> {
|
|
49
51
|
static readonly componentId = 'TopNavBar.User'
|
|
50
52
|
|
|
53
|
+
static propTypes = propTypes
|
|
51
54
|
static allowedProps = allowedProps
|
|
52
55
|
static defaultProps = {}
|
|
53
56
|
|
|
@@ -117,7 +120,6 @@ class TopNavBarUser extends Component<TopNavBarUserProps> {
|
|
|
117
120
|
{...omitProps(this.props, allowedProps)}
|
|
118
121
|
ref={this.handleRef}
|
|
119
122
|
css={styles?.topNavBarUser}
|
|
120
|
-
data-cid="TopNavBarUser"
|
|
121
123
|
>
|
|
122
124
|
{this.content}
|
|
123
125
|
</div>
|
|
@@ -23,11 +23,18 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import { Children as ChildrenPropTypes } from '@instructure/ui-prop-types'
|
|
29
|
+
|
|
26
30
|
import type { WithStyleProps, ComponentStyle } from '@instructure/emotion'
|
|
27
31
|
import type {
|
|
28
32
|
OtherHTMLAttributes,
|
|
33
|
+
PropValidators,
|
|
29
34
|
ChildrenOfType
|
|
30
35
|
} from '@instructure/shared-types'
|
|
36
|
+
|
|
37
|
+
import { TopNavBarItem } from '../TopNavBarItem'
|
|
31
38
|
import type { ItemChild } from '../TopNavBarItem/props'
|
|
32
39
|
|
|
33
40
|
import { TopNavBarUser } from './index'
|
|
@@ -59,6 +66,12 @@ type TopNavBarUserProps = TopNavBarUserOwnProps &
|
|
|
59
66
|
OtherHTMLAttributes<TopNavBarUserOwnProps>
|
|
60
67
|
|
|
61
68
|
type TopNavBarUserStyle = ComponentStyle<'topNavBarUser'>
|
|
69
|
+
|
|
70
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
71
|
+
children: ChildrenPropTypes.oneOf([TopNavBarItem]).isRequired,
|
|
72
|
+
elementRef: PropTypes.func
|
|
73
|
+
}
|
|
74
|
+
|
|
62
75
|
const allowedProps: AllowedPropKeys = ['children', 'elementRef']
|
|
63
76
|
|
|
64
77
|
export type {
|
|
@@ -67,4 +80,4 @@ export type {
|
|
|
67
80
|
TopNavBarUserOwnProps,
|
|
68
81
|
TopNavBarUserStyle
|
|
69
82
|
}
|
|
70
|
-
export { allowedProps }
|
|
83
|
+
export { propTypes, allowedProps }
|
package/src/TopNavBar/index.tsx
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
import { Component } from 'react'
|
|
26
26
|
|
|
27
27
|
import { error } from '@instructure/console'
|
|
28
|
+
import { testable } from '@instructure/ui-testable'
|
|
28
29
|
import { px } from '@instructure/ui-utils'
|
|
29
30
|
import { matchComponentTypes } from '@instructure/ui-react-utils'
|
|
30
31
|
|
|
@@ -41,7 +42,7 @@ import { TopNavBarBreadcrumb } from './TopNavBarBreadcrumb'
|
|
|
41
42
|
import { TopNavBarContext } from './TopNavBarContext'
|
|
42
43
|
import type { TopNavBarLayouts } from './TopNavBarContext'
|
|
43
44
|
|
|
44
|
-
import { allowedProps } from './props'
|
|
45
|
+
import { propTypes, allowedProps } from './props'
|
|
45
46
|
import type { TopNavBarProps } from './props'
|
|
46
47
|
|
|
47
48
|
/**
|
|
@@ -49,6 +50,7 @@ import type { TopNavBarProps } from './props'
|
|
|
49
50
|
category: components
|
|
50
51
|
---
|
|
51
52
|
**/
|
|
53
|
+
@testable()
|
|
52
54
|
class TopNavBar extends Component<TopNavBarProps> {
|
|
53
55
|
static readonly componentId = 'TopNavBar'
|
|
54
56
|
|
|
@@ -63,6 +65,7 @@ class TopNavBar extends Component<TopNavBarProps> {
|
|
|
63
65
|
|
|
64
66
|
static contextType = TopNavBarContext
|
|
65
67
|
|
|
68
|
+
static propTypes = propTypes
|
|
66
69
|
static allowedProps = allowedProps
|
|
67
70
|
static defaultProps = {
|
|
68
71
|
breakpoint: 1024,
|
|
@@ -91,7 +94,6 @@ class TopNavBar extends Component<TopNavBarProps> {
|
|
|
91
94
|
|
|
92
95
|
return (
|
|
93
96
|
<Responsive
|
|
94
|
-
data-cid="TopNavBar"
|
|
95
97
|
elementRef={this.handleRef}
|
|
96
98
|
match={mediaQueryMatch}
|
|
97
99
|
query={{
|
package/src/TopNavBar/props.ts
CHANGED
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import
|
|
25
|
+
import PropTypes from 'prop-types'
|
|
26
|
+
|
|
27
|
+
import type {
|
|
28
|
+
OtherHTMLAttributes,
|
|
29
|
+
PropValidators
|
|
30
|
+
} from '@instructure/shared-types'
|
|
26
31
|
|
|
27
32
|
import type { ActionItemsChild } from './TopNavBarActionItems/props'
|
|
28
33
|
import type { BrandChild } from './TopNavBarBrand/props'
|
|
@@ -30,6 +35,7 @@ import type { ItemChild } from './TopNavBarItem/props'
|
|
|
30
35
|
import type { LayoutChild } from './TopNavBarLayout/props'
|
|
31
36
|
import type { MenuItemsChild } from './TopNavBarMenuItems/props'
|
|
32
37
|
import type { UserChild } from './TopNavBarUser/props'
|
|
38
|
+
|
|
33
39
|
import type { TopNavBarContextType } from './TopNavBarContext'
|
|
34
40
|
|
|
35
41
|
type TopNavBarOwnProps = {
|
|
@@ -71,6 +77,15 @@ type PropKeys = keyof TopNavBarOwnProps
|
|
|
71
77
|
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
72
78
|
|
|
73
79
|
type TopNavBarProps = TopNavBarOwnProps & OtherHTMLAttributes<TopNavBarOwnProps>
|
|
80
|
+
|
|
81
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
82
|
+
children: PropTypes.func,
|
|
83
|
+
breakpoint: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
84
|
+
mediaQueryMatch: PropTypes.oneOf(['element', 'media']),
|
|
85
|
+
inverseColor: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
86
|
+
elementRef: PropTypes.func
|
|
87
|
+
}
|
|
88
|
+
|
|
74
89
|
const allowedProps: AllowedPropKeys = [
|
|
75
90
|
'children',
|
|
76
91
|
'breakpoint',
|
|
@@ -90,4 +105,4 @@ export type {
|
|
|
90
105
|
MenuItemsChild,
|
|
91
106
|
UserChild
|
|
92
107
|
}
|
|
93
|
-
export { allowedProps }
|
|
108
|
+
export { propTypes, allowedProps }
|