@instructure/ui-top-nav-bar 8.30.1-snapshot-15
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 +57 -0
- package/README.md +30 -0
- package/es/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.js +47 -0
- package/es/TopNavBar/TopNavBarActionItems/index.js +215 -0
- package/es/TopNavBar/TopNavBarActionItems/props.js +36 -0
- package/es/TopNavBar/TopNavBarActionItems/styles.js +76 -0
- package/es/TopNavBar/TopNavBarActionItems/theme.js +46 -0
- package/es/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.js +57 -0
- package/es/TopNavBar/TopNavBarBrand/index.js +117 -0
- package/es/TopNavBar/TopNavBarBrand/props.js +37 -0
- package/es/TopNavBar/TopNavBarBrand/styles.js +91 -0
- package/es/TopNavBar/TopNavBarBrand/theme.js +42 -0
- package/es/TopNavBar/TopNavBarContext.js +37 -0
- package/es/TopNavBar/TopNavBarItem/TopNavBarItemLocator.js +114 -0
- package/es/TopNavBar/TopNavBarItem/index.js +634 -0
- package/es/TopNavBar/TopNavBarItem/props.js +64 -0
- package/es/TopNavBar/TopNavBarItem/styles.js +124 -0
- package/es/TopNavBar/TopNavBarItem/theme.js +54 -0
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.js +86 -0
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +119 -0
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/props.js +31 -0
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/styles.js +115 -0
- package/es/TopNavBar/TopNavBarLayout/DesktopLayout/theme.js +61 -0
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.js +126 -0
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +454 -0
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.js +31 -0
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.js +158 -0
- package/es/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.js +61 -0
- package/es/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.js +36 -0
- package/es/TopNavBar/TopNavBarLayout/index.js +118 -0
- package/es/TopNavBar/TopNavBarLayout/props.js +69 -0
- package/es/TopNavBar/TopNavBarLayout/theme.js +40 -0
- package/es/TopNavBar/TopNavBarLocator.js +29 -0
- package/es/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.js +54 -0
- package/es/TopNavBar/TopNavBarMenuItems/index.js +210 -0
- package/es/TopNavBar/TopNavBarMenuItems/props.js +35 -0
- package/es/TopNavBar/TopNavBarMenuItems/styles.js +65 -0
- package/es/TopNavBar/TopNavBarMenuItems/theme.js +45 -0
- package/es/TopNavBar/TopNavBarUser/TopNavBarUserLocator.js +29 -0
- package/es/TopNavBar/TopNavBarUser/index.js +109 -0
- package/es/TopNavBar/TopNavBarUser/props.js +32 -0
- package/es/TopNavBar/TopNavBarUser/styles.js +45 -0
- package/es/TopNavBar/index.js +110 -0
- package/es/TopNavBar/props.js +33 -0
- package/es/TopNavBar/utils/exampleHelpers.js +211 -0
- package/es/TopNavBar/utils/exampleSvgFiles.js +86 -0
- package/es/TopNavBar/utils/mapItemsForDrilldown.js +142 -0
- package/es/index.js +24 -0
- package/lib/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.js +59 -0
- package/lib/TopNavBar/TopNavBarActionItems/index.js +222 -0
- package/lib/TopNavBar/TopNavBarActionItems/props.js +50 -0
- package/lib/TopNavBar/TopNavBarActionItems/styles.js +84 -0
- package/lib/TopNavBar/TopNavBarActionItems/theme.js +54 -0
- package/lib/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.js +68 -0
- package/lib/TopNavBar/TopNavBarBrand/index.js +115 -0
- package/lib/TopNavBar/TopNavBarBrand/props.js +48 -0
- package/lib/TopNavBar/TopNavBarBrand/styles.js +99 -0
- package/lib/TopNavBar/TopNavBarBrand/theme.js +50 -0
- package/lib/TopNavBar/TopNavBarContext.js +46 -0
- package/lib/TopNavBar/TopNavBarItem/TopNavBarItemLocator.js +131 -0
- package/lib/TopNavBar/TopNavBarItem/index.js +650 -0
- package/lib/TopNavBar/TopNavBarItem/props.js +79 -0
- package/lib/TopNavBar/TopNavBarItem/styles.js +132 -0
- package/lib/TopNavBar/TopNavBarItem/theme.js +62 -0
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.js +102 -0
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/index.js +113 -0
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/props.js +40 -0
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/styles.js +123 -0
- package/lib/TopNavBar/TopNavBarLayout/DesktopLayout/theme.js +69 -0
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.js +143 -0
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.js +472 -0
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.js +40 -0
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.js +166 -0
- package/lib/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.js +69 -0
- package/lib/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.js +48 -0
- package/lib/TopNavBar/TopNavBarLayout/index.js +113 -0
- package/lib/TopNavBar/TopNavBarLayout/props.js +94 -0
- package/lib/TopNavBar/TopNavBarLayout/theme.js +52 -0
- package/lib/TopNavBar/TopNavBarLocator.js +39 -0
- package/lib/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.js +66 -0
- package/lib/TopNavBar/TopNavBarMenuItems/index.js +213 -0
- package/lib/TopNavBar/TopNavBarMenuItems/props.js +48 -0
- package/lib/TopNavBar/TopNavBarMenuItems/styles.js +73 -0
- package/lib/TopNavBar/TopNavBarMenuItems/theme.js +53 -0
- package/lib/TopNavBar/TopNavBarUser/TopNavBarUserLocator.js +39 -0
- package/lib/TopNavBar/TopNavBarUser/index.js +104 -0
- package/lib/TopNavBar/TopNavBarUser/props.js +45 -0
- package/lib/TopNavBar/TopNavBarUser/styles.js +53 -0
- package/lib/TopNavBar/index.js +110 -0
- package/lib/TopNavBar/props.js +44 -0
- package/lib/TopNavBar/utils/exampleHelpers.js +255 -0
- package/lib/TopNavBar/utils/exampleSvgFiles.js +75 -0
- package/lib/TopNavBar/utils/mapItemsForDrilldown.js +165 -0
- package/lib/index.js +13 -0
- package/lib/package.json +1 -0
- package/package.json +64 -0
- package/src/TopNavBar/README.md +2329 -0
- package/src/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.ts +53 -0
- package/src/TopNavBar/TopNavBarActionItems/index.tsx +299 -0
- package/src/TopNavBar/TopNavBarActionItems/props.ts +152 -0
- package/src/TopNavBar/TopNavBarActionItems/styles.ts +92 -0
- package/src/TopNavBar/TopNavBarActionItems/theme.ts +51 -0
- package/src/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.ts +44 -0
- package/src/TopNavBar/TopNavBarBrand/index.tsx +139 -0
- package/src/TopNavBar/TopNavBarBrand/props.ts +146 -0
- package/src/TopNavBar/TopNavBarBrand/styles.ts +102 -0
- package/src/TopNavBar/TopNavBarBrand/theme.ts +48 -0
- package/src/TopNavBar/TopNavBarContext.ts +47 -0
- package/src/TopNavBar/TopNavBarItem/TopNavBarItemLocator.ts +111 -0
- package/src/TopNavBar/TopNavBarItem/index.tsx +752 -0
- package/src/TopNavBar/TopNavBarItem/props.ts +331 -0
- package/src/TopNavBar/TopNavBarItem/styles.ts +142 -0
- package/src/TopNavBar/TopNavBarItem/theme.ts +60 -0
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.ts +84 -0
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/index.tsx +148 -0
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/props.ts +104 -0
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/styles.ts +136 -0
- package/src/TopNavBar/TopNavBarLayout/DesktopLayout/theme.ts +66 -0
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.ts +125 -0
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.tsx +600 -0
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.ts +187 -0
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.ts +184 -0
- package/src/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.ts +69 -0
- package/src/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.ts +46 -0
- package/src/TopNavBar/TopNavBarLayout/index.tsx +149 -0
- package/src/TopNavBar/TopNavBarLayout/props.ts +209 -0
- package/src/TopNavBar/TopNavBarLayout/theme.ts +47 -0
- package/src/TopNavBar/TopNavBarLocator.ts +31 -0
- package/src/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.ts +56 -0
- package/src/TopNavBar/TopNavBarMenuItems/index.tsx +275 -0
- package/src/TopNavBar/TopNavBarMenuItems/props.ts +133 -0
- package/src/TopNavBar/TopNavBarMenuItems/styles.ts +72 -0
- package/src/TopNavBar/TopNavBarMenuItems/theme.ts +51 -0
- package/src/TopNavBar/TopNavBarUser/TopNavBarUserLocator.ts +32 -0
- package/src/TopNavBar/TopNavBarUser/index.tsx +133 -0
- package/src/TopNavBar/TopNavBarUser/props.ts +83 -0
- package/src/TopNavBar/TopNavBarUser/styles.ts +47 -0
- package/src/TopNavBar/index.tsx +142 -0
- package/src/TopNavBar/props.ts +108 -0
- package/src/TopNavBar/utils/exampleHelpers.tsx +342 -0
- package/src/TopNavBar/utils/exampleSvgFiles.tsx +76 -0
- package/src/TopNavBar/utils/mapItemsForDrilldown.tsx +228 -0
- package/src/index.ts +62 -0
- package/tsconfig.build.json +37 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +4 -0
- package/types/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.d.ts +2116 -0
- package/types/TopNavBar/TopNavBarActionItems/TopNavBarActionItemsLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarActionItems/index.d.ts +40 -0
- package/types/TopNavBar/TopNavBarActionItems/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarActionItems/props.d.ts +59 -0
- package/types/TopNavBar/TopNavBarActionItems/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarActionItems/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarActionItems/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarActionItems/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarActionItems/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.d.ts +592 -0
- package/types/TopNavBar/TopNavBarBrand/TopNavBarBrandLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarBrand/index.d.ts +30 -0
- package/types/TopNavBar/TopNavBarBrand/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarBrand/props.d.ts +60 -0
- package/types/TopNavBar/TopNavBarBrand/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarBrand/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarBrand/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarBrand/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarBrand/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarContext.d.ts +17 -0
- package/types/TopNavBar/TopNavBarContext.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarItem/TopNavBarItemLocator.d.ts +642 -0
- package/types/TopNavBar/TopNavBarItem/TopNavBarItemLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarItem/index.d.ts +64 -0
- package/types/TopNavBar/TopNavBarItem/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarItem/props.d.ts +188 -0
- package/types/TopNavBar/TopNavBarItem/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarItem/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarItem/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarItem/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarItem/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.d.ts +5737 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/TopNavBarDesktopLayoutLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/index.d.ts +31 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/props.d.ts +29 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarLayout/DesktopLayout/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.d.ts +4357 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/TopNavBarSmallViewportLayoutLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.d.ts +58 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.d.ts +89 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarLayout/SmallViewportLayout/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.d.ts +7 -0
- package/types/TopNavBar/TopNavBarLayout/TopNavBarLayoutLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/index.d.ts +34 -0
- package/types/TopNavBar/TopNavBarLayout/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/props.d.ts +83 -0
- package/types/TopNavBar/TopNavBarLayout/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLayout/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarLayout/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarLocator.d.ts +566 -0
- package/types/TopNavBar/TopNavBarLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.d.ts +1351 -0
- package/types/TopNavBar/TopNavBarMenuItems/TopNavBarMenuItemsLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarMenuItems/index.d.ts +38 -0
- package/types/TopNavBar/TopNavBarMenuItems/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarMenuItems/props.d.ts +53 -0
- package/types/TopNavBar/TopNavBarMenuItems/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarMenuItems/styles.d.ts +15 -0
- package/types/TopNavBar/TopNavBarMenuItems/styles.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarMenuItems/theme.d.ts +10 -0
- package/types/TopNavBar/TopNavBarMenuItems/theme.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarUser/TopNavBarUserLocator.d.ts +566 -0
- package/types/TopNavBar/TopNavBarUser/TopNavBarUserLocator.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarUser/index.d.ts +31 -0
- package/types/TopNavBar/TopNavBarUser/index.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarUser/props.d.ts +29 -0
- package/types/TopNavBar/TopNavBarUser/props.d.ts.map +1 -0
- package/types/TopNavBar/TopNavBarUser/styles.d.ts +14 -0
- package/types/TopNavBar/TopNavBarUser/styles.d.ts.map +1 -0
- package/types/TopNavBar/index.d.ts +38 -0
- package/types/TopNavBar/index.d.ts.map +1 -0
- package/types/TopNavBar/props.d.ts +43 -0
- package/types/TopNavBar/props.d.ts.map +1 -0
- package/types/TopNavBar/utils/exampleHelpers.d.ts +70 -0
- package/types/TopNavBar/utils/exampleHelpers.d.ts.map +1 -0
- package/types/TopNavBar/utils/exampleSvgFiles.d.ts +7 -0
- package/types/TopNavBar/utils/exampleSvgFiles.d.ts.map +1 -0
- package/types/TopNavBar/utils/mapItemsForDrilldown.d.ts +19 -0
- package/types/TopNavBar/utils/mapItemsForDrilldown.d.ts.map +1 -0
- package/types/index.d.ts +11 -0
- package/types/index.d.ts.map +1 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import React from 'react'
|
|
26
|
+
import PropTypes from 'prop-types'
|
|
27
|
+
|
|
28
|
+
import {
|
|
29
|
+
Children as ChildrenPropTypes,
|
|
30
|
+
element
|
|
31
|
+
} from '@instructure/ui-prop-types'
|
|
32
|
+
|
|
33
|
+
import type { WithStyleProps } from '@instructure/emotion'
|
|
34
|
+
import type {
|
|
35
|
+
TopNavBarLayoutTheme,
|
|
36
|
+
OtherHTMLAttributes,
|
|
37
|
+
PropValidators
|
|
38
|
+
} from '@instructure/shared-types'
|
|
39
|
+
|
|
40
|
+
import { TopNavBarActionItems } from '../TopNavBarActionItems'
|
|
41
|
+
import { TopNavBarBrand } from '../TopNavBarBrand'
|
|
42
|
+
import { TopNavBarMenuItems } from '../TopNavBarMenuItems'
|
|
43
|
+
import { TopNavBarUser } from '../TopNavBarUser'
|
|
44
|
+
|
|
45
|
+
import type { ActionItemsChild } from '../TopNavBarActionItems/props'
|
|
46
|
+
import type { BrandChild } from '../TopNavBarBrand/props'
|
|
47
|
+
import type { MenuItemsChild } from '../TopNavBarMenuItems/props'
|
|
48
|
+
import type { UserChild } from '../TopNavBarUser/props'
|
|
49
|
+
|
|
50
|
+
import { topNavBarItemTooltipPropType } from '../TopNavBarItem/props'
|
|
51
|
+
|
|
52
|
+
import { TopNavBarLayout } from './index'
|
|
53
|
+
import type { DesktopLayoutOwnProps } from './DesktopLayout/props'
|
|
54
|
+
import type { SmallViewportLayoutOwnProps } from './SmallViewportLayout/props'
|
|
55
|
+
|
|
56
|
+
type LayoutChild = React.ComponentElement<TopNavBarLayoutProps, TopNavBarLayout>
|
|
57
|
+
|
|
58
|
+
type CommonTopNavBarLayoutProps = {
|
|
59
|
+
/**
|
|
60
|
+
* Displays the app/product/brand/company/etc. name and/or logo.
|
|
61
|
+
*
|
|
62
|
+
* Accepts a `<TopNavBar.Brand>` component.
|
|
63
|
+
*/
|
|
64
|
+
renderBrand?: BrandChild
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Displays the main navbar items.
|
|
68
|
+
*
|
|
69
|
+
* In __desktop__ mode the items are listed on the navbar,
|
|
70
|
+
* in __smallViewport__ mode the items are accessible under the main "hamburger" menu.
|
|
71
|
+
*
|
|
72
|
+
* Accepts a `<TopNavBar.MenuItems>` component.
|
|
73
|
+
*/
|
|
74
|
+
renderMenuItems?: MenuItemsChild
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Displays the action items, icons, buttons, etc.
|
|
78
|
+
*
|
|
79
|
+
* Renders in the top right corner of the navbar in both __desktop__ and __smallViewport__ mode.
|
|
80
|
+
*
|
|
81
|
+
* Accepts a `<TopNavBar.ActionItems>` component.
|
|
82
|
+
*/
|
|
83
|
+
renderActionItems?: ActionItemsChild
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Displays the user menu.
|
|
87
|
+
*
|
|
88
|
+
* In __desktop__ mode it renders in the top right corner of the navbar,
|
|
89
|
+
* in __smallViewport__ mode it is rendered under the main "hamburger" menu, above the menu items.
|
|
90
|
+
*
|
|
91
|
+
* Accepts a `<TopNavBar.User>` component.
|
|
92
|
+
*/
|
|
93
|
+
renderUser?: UserChild
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The 'aria-label' for the underlying `<nav>` element
|
|
97
|
+
*/
|
|
98
|
+
navLabel?: string
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* A function that returns a reference to root HTML element
|
|
102
|
+
*/
|
|
103
|
+
elementRef?: (el: HTMLElement | null) => void
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
type TopNavBarLayoutOwnProps = CommonTopNavBarLayoutProps & {
|
|
107
|
+
/**
|
|
108
|
+
* Config object for the "desktop" mode:
|
|
109
|
+
*/
|
|
110
|
+
desktopConfig?: DesktopLayoutOwnProps
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Config object for the "small viewport" mode:
|
|
114
|
+
*/
|
|
115
|
+
smallViewportConfig: SmallViewportLayoutOwnProps
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
type CommonPropKeys = keyof CommonTopNavBarLayoutProps
|
|
119
|
+
type PropKeys = keyof TopNavBarLayoutOwnProps
|
|
120
|
+
type DesktopPropKeys = keyof DesktopLayoutOwnProps
|
|
121
|
+
type SmallViewportPropKeys = keyof SmallViewportLayoutOwnProps
|
|
122
|
+
|
|
123
|
+
type CommonAllowedPropKeys = Readonly<Array<CommonPropKeys>>
|
|
124
|
+
type DesktopAllowedPropKeys = Readonly<Array<DesktopPropKeys>>
|
|
125
|
+
type SmallViewportAllowedPropKeys = Readonly<Array<SmallViewportPropKeys>>
|
|
126
|
+
type AllowedPropKeys = Readonly<Array<PropKeys>>
|
|
127
|
+
|
|
128
|
+
type TopNavBarLayoutProps = TopNavBarLayoutOwnProps &
|
|
129
|
+
WithStyleProps<TopNavBarLayoutTheme, null> &
|
|
130
|
+
OtherHTMLAttributes<TopNavBarLayoutOwnProps>
|
|
131
|
+
|
|
132
|
+
const commonPropTypes: PropValidators<CommonPropKeys> = {
|
|
133
|
+
renderBrand: ChildrenPropTypes.oneOf([TopNavBarBrand]),
|
|
134
|
+
renderMenuItems: ChildrenPropTypes.oneOf([TopNavBarMenuItems]),
|
|
135
|
+
renderActionItems: ChildrenPropTypes.oneOf([TopNavBarActionItems]),
|
|
136
|
+
renderUser: ChildrenPropTypes.oneOf([TopNavBarUser]),
|
|
137
|
+
navLabel: PropTypes.string,
|
|
138
|
+
elementRef: PropTypes.func
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const desktopPropTypes: PropValidators<DesktopPropKeys> = {
|
|
142
|
+
hideActionsUserSeparator: PropTypes.bool
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const smallViewportPropTypes: PropValidators<SmallViewportPropKeys> = {
|
|
146
|
+
dropdownMenuToggleButtonLabel: PropTypes.string.isRequired,
|
|
147
|
+
dropdownMenuToggleButtonTooltip: topNavBarItemTooltipPropType,
|
|
148
|
+
dropdownMenuLabel: PropTypes.string,
|
|
149
|
+
alternativeTitle: PropTypes.node,
|
|
150
|
+
renderInPlaceDialogConfig: PropTypes.shape({
|
|
151
|
+
open: PropTypes.bool.isRequired,
|
|
152
|
+
onClose: PropTypes.func.isRequired,
|
|
153
|
+
closeButtonLabel: PropTypes.string.isRequired,
|
|
154
|
+
content: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
|
|
155
|
+
returnFocusElement: PropTypes.func,
|
|
156
|
+
shouldContainFocus: PropTypes.bool,
|
|
157
|
+
shouldCloseOnDocumentClick: PropTypes.bool,
|
|
158
|
+
shouldCloseOnEscape: PropTypes.bool
|
|
159
|
+
}),
|
|
160
|
+
trayMountNode: PropTypes.oneOfType([element, PropTypes.func]),
|
|
161
|
+
onDropdownMenuToggle: PropTypes.func,
|
|
162
|
+
onDropdownMenuSelect: PropTypes.func
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const propTypes: PropValidators<PropKeys> = {
|
|
166
|
+
...commonPropTypes,
|
|
167
|
+
desktopConfig: PropTypes.shape(desktopPropTypes),
|
|
168
|
+
smallViewportConfig: PropTypes.shape(smallViewportPropTypes).isRequired
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const commonAllowedProps: CommonAllowedPropKeys = [
|
|
172
|
+
'renderBrand',
|
|
173
|
+
'renderMenuItems',
|
|
174
|
+
'renderActionItems',
|
|
175
|
+
'renderUser',
|
|
176
|
+
'navLabel',
|
|
177
|
+
'elementRef'
|
|
178
|
+
]
|
|
179
|
+
|
|
180
|
+
const desktopAllowedProps: DesktopAllowedPropKeys = ['hideActionsUserSeparator']
|
|
181
|
+
|
|
182
|
+
const smallViewportAllowedProps: SmallViewportAllowedPropKeys = [
|
|
183
|
+
'dropdownMenuToggleButtonLabel',
|
|
184
|
+
'dropdownMenuToggleButtonTooltip',
|
|
185
|
+
'dropdownMenuLabel',
|
|
186
|
+
'alternativeTitle',
|
|
187
|
+
'renderInPlaceDialogConfig',
|
|
188
|
+
'trayMountNode',
|
|
189
|
+
'onDropdownMenuToggle',
|
|
190
|
+
'onDropdownMenuSelect'
|
|
191
|
+
]
|
|
192
|
+
|
|
193
|
+
const allowedProps: AllowedPropKeys = [
|
|
194
|
+
...commonAllowedProps,
|
|
195
|
+
'desktopConfig',
|
|
196
|
+
'smallViewportConfig'
|
|
197
|
+
]
|
|
198
|
+
|
|
199
|
+
export type { LayoutChild, CommonTopNavBarLayoutProps, TopNavBarLayoutProps }
|
|
200
|
+
export {
|
|
201
|
+
propTypes,
|
|
202
|
+
allowedProps,
|
|
203
|
+
commonPropTypes,
|
|
204
|
+
commonAllowedProps,
|
|
205
|
+
desktopPropTypes,
|
|
206
|
+
smallViewportPropTypes,
|
|
207
|
+
desktopAllowedProps,
|
|
208
|
+
smallViewportAllowedProps
|
|
209
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { Theme } from '@instructure/ui-themes'
|
|
26
|
+
import type { TopNavBarLayoutTheme } from '@instructure/shared-types'
|
|
27
|
+
|
|
28
|
+
import desktopTheme from './DesktopLayout/theme'
|
|
29
|
+
import smallViewportTheme from './SmallViewportLayout/theme'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Generates the theme object for the component from the theme and provided additional information
|
|
33
|
+
* @param {Object} theme The actual theme object.
|
|
34
|
+
* @return {Object} The final theme object with the overrides and component variables
|
|
35
|
+
*/
|
|
36
|
+
const generateComponentTheme = (theme: Theme): TopNavBarLayoutTheme => {
|
|
37
|
+
const componentVariables: TopNavBarLayoutTheme = {
|
|
38
|
+
...desktopTheme(theme),
|
|
39
|
+
...smallViewportTheme(theme)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
...componentVariables
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default generateComponentTheme
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
import { locator } from '@instructure/ui-test-locator'
|
|
25
|
+
|
|
26
|
+
import { TopNavBar } from './index'
|
|
27
|
+
|
|
28
|
+
// @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
|
+
export const TopNavBarLocator = locator(TopNavBar.selector, {
|
|
30
|
+
/* custom component query methods go here */
|
|
31
|
+
})
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { locator } from '@instructure/ui-test-locator'
|
|
26
|
+
|
|
27
|
+
/* eslint-disable no-restricted-imports */
|
|
28
|
+
// @ts-expect-error bypass no type definition found error
|
|
29
|
+
import { TruncateListLocator } from '@instructure/ui-truncate-list/es/TruncateList/TruncateListLocator'
|
|
30
|
+
/* eslint-enable no-restricted-imports */
|
|
31
|
+
|
|
32
|
+
import { TopNavBarItemLocator } from '../TopNavBarItem/TopNavBarItemLocator'
|
|
33
|
+
|
|
34
|
+
import { TopNavBarMenuItems } from './index'
|
|
35
|
+
|
|
36
|
+
// @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
|
+
export const TopNavBarMenuItemsLocator = locator(TopNavBarMenuItems.selector, {
|
|
38
|
+
findAllMenuItems: (...args: any[]) => {
|
|
39
|
+
return TopNavBarItemLocator.findAll(...args)
|
|
40
|
+
},
|
|
41
|
+
findTruncateList: (...args: any[]) => {
|
|
42
|
+
return TruncateListLocator.find(...args)
|
|
43
|
+
},
|
|
44
|
+
findTruncateListTriggerItem: async (...args: any[]) => {
|
|
45
|
+
const truncateList = await TruncateListLocator.find(...args)
|
|
46
|
+
|
|
47
|
+
if (truncateList) {
|
|
48
|
+
return TopNavBarItemLocator.find(
|
|
49
|
+
'[id^=TopNavBarMenuItems-hiddenMenuItemsMenuTrigger_]',
|
|
50
|
+
...args
|
|
51
|
+
)
|
|
52
|
+
} else {
|
|
53
|
+
return truncateList
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
})
|
|
@@ -0,0 +1,275 @@
|
|
|
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
|
+
/** @jsx jsx */
|
|
26
|
+
import React, { Component } from 'react'
|
|
27
|
+
|
|
28
|
+
import {
|
|
29
|
+
omitProps,
|
|
30
|
+
safeCloneElement,
|
|
31
|
+
withDeterministicId
|
|
32
|
+
} from '@instructure/ui-react-utils'
|
|
33
|
+
import { warn, error } from '@instructure/console'
|
|
34
|
+
import { testable } from '@instructure/ui-testable'
|
|
35
|
+
|
|
36
|
+
import { withStyle, jsx } from '@instructure/emotion'
|
|
37
|
+
|
|
38
|
+
import { Drilldown } from '@instructure/ui-drilldown'
|
|
39
|
+
import { TruncateList } from '@instructure/ui-truncate-list'
|
|
40
|
+
|
|
41
|
+
import { TopNavBarContext } from '../TopNavBarContext'
|
|
42
|
+
import { TopNavBarItem } from '../TopNavBarItem'
|
|
43
|
+
import type { ItemChild } from '../TopNavBarItem/props'
|
|
44
|
+
|
|
45
|
+
import {
|
|
46
|
+
mapItemsForDrilldown,
|
|
47
|
+
renderMappedItemDrilldownSubpages,
|
|
48
|
+
renderMappedItemsAsDrilldownOptions
|
|
49
|
+
} from '../utils/mapItemsForDrilldown'
|
|
50
|
+
import type { RenderOptionContent } from '../utils/mapItemsForDrilldown'
|
|
51
|
+
|
|
52
|
+
import generateStyle from './styles'
|
|
53
|
+
import generateComponentTheme from './theme'
|
|
54
|
+
|
|
55
|
+
import { propTypes, allowedProps } from './props'
|
|
56
|
+
import type { TopNavBarMenuItemsProps, TopNavBarMenuItemsState } from './props'
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
---
|
|
60
|
+
parent: TopNavBar
|
|
61
|
+
id: TopNavBar.MenuItems
|
|
62
|
+
---
|
|
63
|
+
@module TopNavBarMenuItems
|
|
64
|
+
@tsProps
|
|
65
|
+
**/
|
|
66
|
+
@withDeterministicId()
|
|
67
|
+
@withStyle(generateStyle, generateComponentTheme)
|
|
68
|
+
@testable()
|
|
69
|
+
class TopNavBarMenuItems extends Component<
|
|
70
|
+
TopNavBarMenuItemsProps,
|
|
71
|
+
TopNavBarMenuItemsState
|
|
72
|
+
> {
|
|
73
|
+
static readonly componentId = 'TopNavBar.MenuItems'
|
|
74
|
+
|
|
75
|
+
static propTypes = propTypes
|
|
76
|
+
static allowedProps = allowedProps
|
|
77
|
+
static defaultProps = {}
|
|
78
|
+
|
|
79
|
+
declare context: React.ContextType<typeof TopNavBarContext>
|
|
80
|
+
static contextType = TopNavBarContext
|
|
81
|
+
|
|
82
|
+
private readonly _hiddenMenuItemsMenuTriggerId: string
|
|
83
|
+
private readonly _hiddenItemsMenuId: string
|
|
84
|
+
|
|
85
|
+
ref: HTMLUListElement | Element | null = null
|
|
86
|
+
|
|
87
|
+
handleRef = (el: HTMLUListElement | null) => {
|
|
88
|
+
const { elementRef } = this.props
|
|
89
|
+
|
|
90
|
+
this.ref = el
|
|
91
|
+
|
|
92
|
+
if (typeof elementRef === 'function') {
|
|
93
|
+
elementRef(el)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
constructor(props: TopNavBarMenuItemsProps) {
|
|
98
|
+
super(props)
|
|
99
|
+
|
|
100
|
+
this._hiddenMenuItemsMenuTriggerId = props.deterministicId!(
|
|
101
|
+
'TopNavBarMenuItems-hiddenMenuItemsMenuTrigger'
|
|
102
|
+
)
|
|
103
|
+
this._hiddenItemsMenuId = props.deterministicId!(
|
|
104
|
+
'TopNavBarSmallViewportLayout-drilldown'
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
this.state = {
|
|
108
|
+
key: 0,
|
|
109
|
+
visibleItemsCount: undefined
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
componentDidMount() {
|
|
114
|
+
this.props.makeStyles?.()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
componentDidUpdate(prevProps: TopNavBarMenuItemsProps) {
|
|
118
|
+
this.props.makeStyles?.()
|
|
119
|
+
|
|
120
|
+
if (
|
|
121
|
+
React.Children.count(prevProps.children) !== this.childrenArray.length
|
|
122
|
+
) {
|
|
123
|
+
this.setState({ key: this.state.key + 1 })
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
get childrenArray() {
|
|
128
|
+
return React.Children.toArray(this.props.children) as ItemChild[]
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
renderOptionContent: RenderOptionContent = (children, itemProps) => {
|
|
132
|
+
const { styles } = this.props
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<span
|
|
136
|
+
css={
|
|
137
|
+
itemProps?.status === 'active'
|
|
138
|
+
? styles?.submenuOptionActive
|
|
139
|
+
: styles?.submenuOption
|
|
140
|
+
}
|
|
141
|
+
>
|
|
142
|
+
{children}
|
|
143
|
+
</span>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
renderHiddenItemsMenu(hiddenItems: ItemChild[]) {
|
|
148
|
+
const { renderHiddenItemsMenuTriggerLabel, currentPageId } = this.props
|
|
149
|
+
|
|
150
|
+
if (!hiddenItems.length) {
|
|
151
|
+
return <span></span>
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const mappedItems = mapItemsForDrilldown(hiddenItems, {
|
|
155
|
+
renderOptionContent: this.renderOptionContent,
|
|
156
|
+
currentPageId
|
|
157
|
+
})
|
|
158
|
+
const subPages = renderMappedItemDrilldownSubpages(mappedItems)
|
|
159
|
+
const options = renderMappedItemsAsDrilldownOptions(mappedItems)
|
|
160
|
+
|
|
161
|
+
const hasActiveChild = hiddenItems.find(
|
|
162
|
+
(child) => child.props.status === 'active'
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<TopNavBarItem
|
|
167
|
+
id={this._hiddenMenuItemsMenuTriggerId}
|
|
168
|
+
status={hasActiveChild ? 'active' : 'default'}
|
|
169
|
+
renderSubmenu={
|
|
170
|
+
<Drilldown rootPageId={this._hiddenItemsMenuId}>
|
|
171
|
+
{[
|
|
172
|
+
<Drilldown.Page
|
|
173
|
+
id={this._hiddenItemsMenuId}
|
|
174
|
+
key={this._hiddenItemsMenuId}
|
|
175
|
+
>
|
|
176
|
+
{options}
|
|
177
|
+
</Drilldown.Page>,
|
|
178
|
+
...subPages
|
|
179
|
+
]}
|
|
180
|
+
</Drilldown>
|
|
181
|
+
}
|
|
182
|
+
>
|
|
183
|
+
{renderHiddenItemsMenuTriggerLabel(hiddenItems.length)}
|
|
184
|
+
</TopNavBarItem>
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
renderChildren() {
|
|
189
|
+
const { currentPageId } = this.props
|
|
190
|
+
|
|
191
|
+
return this.childrenArray.map((child) => {
|
|
192
|
+
if (!child) {
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const { id, status, variant, renderSubmenu, renderAvatar } = child.props
|
|
197
|
+
const isCurrentPage = currentPageId === id
|
|
198
|
+
|
|
199
|
+
if (renderAvatar) {
|
|
200
|
+
error(
|
|
201
|
+
false,
|
|
202
|
+
`Items in <TopNavBar.MenuItems> are not allowed to have avatars, but item with id: "${id}" has \`renderAvatar\` prop.`
|
|
203
|
+
)
|
|
204
|
+
return null
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (!isCurrentPage) {
|
|
208
|
+
return child
|
|
209
|
+
} else {
|
|
210
|
+
if (variant !== 'default') {
|
|
211
|
+
warn(
|
|
212
|
+
false,
|
|
213
|
+
`Only \`variant="default"\` items can be set to current/active, but the item with id "${id}" is "${variant}" variant.`
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
return child
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (status === 'disabled') {
|
|
220
|
+
warn(
|
|
221
|
+
false,
|
|
222
|
+
`Disabled items can not be set to current/active, but the item with id "${id}" is disabled.`
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
return child
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return safeCloneElement(child, {
|
|
229
|
+
status: 'active',
|
|
230
|
+
// if it has submenu, the root item cannot be current,
|
|
231
|
+
// just a link inside the submenu
|
|
232
|
+
'aria-current': renderSubmenu ? undefined : 'page'
|
|
233
|
+
})
|
|
234
|
+
}
|
|
235
|
+
})
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
render() {
|
|
239
|
+
const { listLabel, styles } = this.props
|
|
240
|
+
|
|
241
|
+
if (!this.childrenArray.length) {
|
|
242
|
+
return null
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (this.context.layout === 'smallViewport') {
|
|
246
|
+
// in smallViewport mode it is rendered as a Drilldown
|
|
247
|
+
return null
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<TruncateList
|
|
252
|
+
{...omitProps(this.props, allowedProps)}
|
|
253
|
+
key={this.state.key} // rerender if child count changes
|
|
254
|
+
elementRef={this.handleRef}
|
|
255
|
+
css={styles?.topNavBarMenuItems}
|
|
256
|
+
visibleItemsCount={this.state.visibleItemsCount}
|
|
257
|
+
onUpdate={({ visibleItemsCount }) => {
|
|
258
|
+
this.setState({ visibleItemsCount })
|
|
259
|
+
}}
|
|
260
|
+
renderHiddenItemMenu={(hiddenChildren) =>
|
|
261
|
+
this.renderHiddenItemsMenu(hiddenChildren as ItemChild[])
|
|
262
|
+
}
|
|
263
|
+
{...(styles?.itemSpacing && {
|
|
264
|
+
itemSpacing: styles.itemSpacing
|
|
265
|
+
})}
|
|
266
|
+
aria-label={listLabel}
|
|
267
|
+
>
|
|
268
|
+
{this.renderChildren()}
|
|
269
|
+
</TruncateList>
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export { TopNavBarMenuItems }
|
|
275
|
+
export default TopNavBarMenuItems
|