@cloudscape-design/components-themeable 3.0.769 → 3.0.770
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/lib/internal/manifest.json +1 -1
- package/lib/internal/scss/breadcrumb-group/item/styles.scss +10 -15
- package/lib/internal/scss/breadcrumb-group/styles.scss +15 -35
- package/lib/internal/scss/side-navigation/analytics-metadata/styles.scss +9 -0
- package/lib/internal/template/breadcrumb-group/implementation.d.ts.map +1 -1
- package/lib/internal/template/breadcrumb-group/implementation.js +61 -12
- package/lib/internal/template/breadcrumb-group/implementation.js.map +1 -1
- package/lib/internal/template/breadcrumb-group/interfaces.d.ts +3 -2
- package/lib/internal/template/breadcrumb-group/interfaces.d.ts.map +1 -1
- package/lib/internal/template/breadcrumb-group/interfaces.js.map +1 -1
- package/lib/internal/template/breadcrumb-group/item/funnel.d.ts +1 -0
- package/lib/internal/template/breadcrumb-group/item/funnel.d.ts.map +1 -1
- package/lib/internal/template/breadcrumb-group/item/funnel.js +3 -3
- package/lib/internal/template/breadcrumb-group/item/funnel.js.map +1 -1
- package/lib/internal/template/breadcrumb-group/item/item.d.ts +1 -1
- package/lib/internal/template/breadcrumb-group/item/item.d.ts.map +1 -1
- package/lib/internal/template/breadcrumb-group/item/item.js +19 -38
- package/lib/internal/template/breadcrumb-group/item/item.js.map +1 -1
- package/lib/internal/template/breadcrumb-group/item/styles.css.js +8 -9
- package/lib/internal/template/breadcrumb-group/item/styles.scoped.css +33 -32
- package/lib/internal/template/breadcrumb-group/item/styles.selectors.js +8 -9
- package/lib/internal/template/breadcrumb-group/styles.css.js +8 -7
- package/lib/internal/template/breadcrumb-group/styles.scoped.css +17 -57
- package/lib/internal/template/breadcrumb-group/styles.selectors.js +8 -7
- package/lib/internal/template/breadcrumb-group/utils.d.ts +5 -0
- package/lib/internal/template/breadcrumb-group/utils.d.ts.map +1 -1
- package/lib/internal/template/breadcrumb-group/utils.js +56 -0
- package/lib/internal/template/breadcrumb-group/utils.js.map +1 -1
- package/lib/internal/template/internal/environment.js +1 -1
- package/lib/internal/template/internal/environment.json +1 -1
- package/lib/internal/template/side-navigation/analytics-metadata/interfaces.d.ts +19 -0
- package/lib/internal/template/side-navigation/analytics-metadata/interfaces.d.ts.map +1 -0
- package/lib/internal/template/side-navigation/analytics-metadata/interfaces.js +4 -0
- package/lib/internal/template/side-navigation/analytics-metadata/interfaces.js.map +1 -0
- package/lib/internal/template/side-navigation/analytics-metadata/styles.css.js +7 -0
- package/lib/internal/template/side-navigation/analytics-metadata/styles.scoped.css +8 -0
- package/lib/internal/template/side-navigation/analytics-metadata/styles.selectors.js +8 -0
- package/lib/internal/template/side-navigation/index.d.ts.map +1 -1
- package/lib/internal/template/side-navigation/index.js +10 -1
- package/lib/internal/template/side-navigation/index.js.map +1 -1
- package/lib/internal/template/side-navigation/parts.d.ts +2 -1
- package/lib/internal/template/side-navigation/parts.d.ts.map +1 -1
- package/lib/internal/template/side-navigation/parts.js +42 -21
- package/lib/internal/template/side-navigation/parts.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
+
import { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
|
|
5
6
|
import InternalBox from '../box/internal';
|
|
6
7
|
import InternalExpandableSection from '../expandable-section/internal';
|
|
7
8
|
import InternalIcon from '../icon/internal';
|
|
@@ -9,6 +10,7 @@ import { isPlainLeftClick } from '../internal/events';
|
|
|
9
10
|
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
10
11
|
import { checkSafeUrl } from '../internal/utils/check-safe-url';
|
|
11
12
|
import { hasActiveLink } from './util';
|
|
13
|
+
import analyticsSelectors from './analytics-metadata/styles.css.js';
|
|
12
14
|
import styles from './styles.css.js';
|
|
13
15
|
export function Header({ definition, activeHref, fireFollow }) {
|
|
14
16
|
checkSafeUrl('SideNavigation', definition.href);
|
|
@@ -17,16 +19,25 @@ export function Header({ definition, activeHref, fireFollow }) {
|
|
|
17
19
|
fireFollow(definition, event);
|
|
18
20
|
}
|
|
19
21
|
}, [fireFollow, definition]);
|
|
22
|
+
const clickActionAnalyticsMetadata = {
|
|
23
|
+
action: 'click',
|
|
24
|
+
detail: {
|
|
25
|
+
label: `.${analyticsSelectors['header-link-text']}`,
|
|
26
|
+
external: 'false',
|
|
27
|
+
href: definition.href,
|
|
28
|
+
position: 'header',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
20
31
|
return (React.createElement(React.Fragment, null,
|
|
21
32
|
React.createElement("h2", { className: styles.header },
|
|
22
|
-
React.createElement("a", { href: definition.href, className: clsx(styles['header-link'], { [styles['header-link--has-logo']]: !!definition.logo }), "aria-current": definition.href === activeHref ? 'page' : undefined, onClick: onClick },
|
|
33
|
+
React.createElement("a", Object.assign({ href: definition.href, className: clsx(styles['header-link'], { [styles['header-link--has-logo']]: !!definition.logo }), "aria-current": definition.href === activeHref ? 'page' : undefined, onClick: onClick }, getAnalyticsMetadataAttribute(clickActionAnalyticsMetadata)),
|
|
23
34
|
definition.logo && (React.createElement("img", Object.assign({ className: clsx(styles['header-logo'], {
|
|
24
35
|
[styles['header-logo--stretched']]: !definition.text,
|
|
25
36
|
}) }, definition.logo))),
|
|
26
|
-
React.createElement("span", { className: styles['header-link-text'] }, definition.text))),
|
|
37
|
+
React.createElement("span", { className: clsx(styles['header-link-text'], analyticsSelectors['header-link-text']) }, definition.text))),
|
|
27
38
|
React.createElement(Divider, { isPresentational: true, variant: "header" })));
|
|
28
39
|
}
|
|
29
|
-
export function NavigationItemsList({ items, variant, activeHref, fireChange, fireFollow }) {
|
|
40
|
+
export function NavigationItemsList({ items, variant, activeHref, fireChange, fireFollow, position = '', }) {
|
|
30
41
|
const lists = [];
|
|
31
42
|
let currentListIndex = 0;
|
|
32
43
|
lists[currentListIndex] = {
|
|
@@ -36,6 +47,7 @@ export function NavigationItemsList({ items, variant, activeHref, fireChange, fi
|
|
|
36
47
|
items.forEach((item, index) => {
|
|
37
48
|
var _a, _b, _c, _d, _e;
|
|
38
49
|
const itemid = index + 1;
|
|
50
|
+
const itemPosition = `${position ? `${position},` : ''}${itemid}`;
|
|
39
51
|
switch (item.type) {
|
|
40
52
|
case 'divider': {
|
|
41
53
|
const dividerIndex = lists.length;
|
|
@@ -53,35 +65,35 @@ export function NavigationItemsList({ items, variant, activeHref, fireChange, fi
|
|
|
53
65
|
case 'link': {
|
|
54
66
|
(_a = lists[currentListIndex].items) === null || _a === void 0 ? void 0 : _a.push({
|
|
55
67
|
element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: styles['list-item'] },
|
|
56
|
-
React.createElement(Link, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow }))),
|
|
68
|
+
React.createElement(Link, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition }))),
|
|
57
69
|
});
|
|
58
70
|
return;
|
|
59
71
|
}
|
|
60
72
|
case 'section': {
|
|
61
73
|
(_b = lists[currentListIndex].items) === null || _b === void 0 ? void 0 : _b.push({
|
|
62
74
|
element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: styles['list-item'] },
|
|
63
|
-
React.createElement(Section, { definition: item, activeHref: activeHref, variant: variant, fireChange: fireChange, fireFollow: fireFollow }))),
|
|
75
|
+
React.createElement(Section, { definition: item, activeHref: activeHref, variant: variant, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition }))),
|
|
64
76
|
});
|
|
65
77
|
return;
|
|
66
78
|
}
|
|
67
79
|
case 'section-group': {
|
|
68
80
|
(_c = lists[currentListIndex].items) === null || _c === void 0 ? void 0 : _c.push({
|
|
69
81
|
element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: styles['list-item'] },
|
|
70
|
-
React.createElement(SectionGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow }))),
|
|
82
|
+
React.createElement(SectionGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition }))),
|
|
71
83
|
});
|
|
72
84
|
return;
|
|
73
85
|
}
|
|
74
86
|
case 'link-group': {
|
|
75
87
|
(_d = lists[currentListIndex].items) === null || _d === void 0 ? void 0 : _d.push({
|
|
76
88
|
element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: styles['list-item'] },
|
|
77
|
-
React.createElement(LinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow }))),
|
|
89
|
+
React.createElement(LinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, position: itemPosition }))),
|
|
78
90
|
});
|
|
79
91
|
return;
|
|
80
92
|
}
|
|
81
93
|
case 'expandable-link-group': {
|
|
82
94
|
(_e = lists[currentListIndex].items) === null || _e === void 0 ? void 0 : _e.push({
|
|
83
95
|
element: (React.createElement("li", { key: index, "data-itemid": `item-${itemid}`, className: styles['list-item'] },
|
|
84
|
-
React.createElement(ExpandableLinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, variant: variant }))),
|
|
96
|
+
React.createElement(ExpandableLinkGroup, { definition: item, activeHref: activeHref, fireChange: fireChange, fireFollow: fireFollow, variant: variant, position: itemPosition }))),
|
|
85
97
|
});
|
|
86
98
|
return;
|
|
87
99
|
}
|
|
@@ -104,7 +116,7 @@ export function NavigationItemsList({ items, variant, activeHref, fireChange, fi
|
|
|
104
116
|
function Divider({ variant = 'default', isPresentational = false }) {
|
|
105
117
|
return (React.createElement("hr", { className: clsx(styles.divider, styles[`divider-${variant}`]), role: isPresentational ? 'presentation' : undefined }));
|
|
106
118
|
}
|
|
107
|
-
function Link({ definition, expanded, activeHref, fireFollow }) {
|
|
119
|
+
function Link({ definition, expanded, activeHref, fireFollow, position }) {
|
|
108
120
|
checkSafeUrl('SideNavigation', definition.href);
|
|
109
121
|
const isActive = definition.href === activeHref;
|
|
110
122
|
const onClick = useCallback((event) => {
|
|
@@ -112,14 +124,23 @@ function Link({ definition, expanded, activeHref, fireFollow }) {
|
|
|
112
124
|
fireFollow(definition, event);
|
|
113
125
|
}
|
|
114
126
|
}, [fireFollow, definition]);
|
|
127
|
+
const clickActionAnalyticsMetadata = {
|
|
128
|
+
action: 'click',
|
|
129
|
+
detail: {
|
|
130
|
+
label: `.${analyticsSelectors['link-text']}`,
|
|
131
|
+
external: `${!!definition.external}`,
|
|
132
|
+
href: definition.href,
|
|
133
|
+
position,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
115
136
|
return (React.createElement(React.Fragment, null,
|
|
116
|
-
React.createElement("a", { href: definition.href, className: clsx(styles.link, { [styles['link-active']]: isActive }), target: definition.external ? '_blank' : undefined, rel: definition.external ? 'noopener noreferrer' : undefined, "aria-expanded": expanded, "aria-current": definition.href === activeHref ? 'page' : undefined, onClick: onClick },
|
|
117
|
-
definition.text,
|
|
137
|
+
React.createElement("a", Object.assign({ href: definition.href, className: clsx(styles.link, { [styles['link-active']]: isActive }), target: definition.external ? '_blank' : undefined, rel: definition.external ? 'noopener noreferrer' : undefined, "aria-expanded": expanded, "aria-current": definition.href === activeHref ? 'page' : undefined, onClick: onClick }, getAnalyticsMetadataAttribute(clickActionAnalyticsMetadata)),
|
|
138
|
+
React.createElement("span", { className: analyticsSelectors['link-text'] }, definition.text),
|
|
118
139
|
definition.external && (React.createElement("span", { "aria-label": definition.externalIconAriaLabel, role: definition.externalIconAriaLabel ? 'img' : undefined },
|
|
119
140
|
React.createElement(InternalIcon, { name: "external", className: styles['external-icon'] })))),
|
|
120
141
|
definition.info && React.createElement("span", { className: styles.info }, definition.info)));
|
|
121
142
|
}
|
|
122
|
-
function Section({ definition, activeHref, fireFollow, fireChange, variant }) {
|
|
143
|
+
function Section({ definition, activeHref, fireFollow, fireChange, variant, position }) {
|
|
123
144
|
var _a;
|
|
124
145
|
const [expanded, setExpanded] = useState((_a = definition.defaultExpanded) !== null && _a !== void 0 ? _a : true);
|
|
125
146
|
const isVisualRefresh = useVisualRefresh();
|
|
@@ -132,20 +153,20 @@ function Section({ definition, activeHref, fireFollow, fireChange, variant }) {
|
|
|
132
153
|
setExpanded((_a = definition.defaultExpanded) !== null && _a !== void 0 ? _a : true);
|
|
133
154
|
}, [definition]);
|
|
134
155
|
return (React.createElement(InternalExpandableSection, { variant: "footer", expanded: expanded, onChange: onExpandedChange, className: clsx(styles.section, variant === 'section-group' && styles['section--no-ident'], isVisualRefresh && styles.refresh), headerText: definition.text },
|
|
135
|
-
React.createElement(NavigationItemsList, { variant: "section", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref })));
|
|
156
|
+
React.createElement(NavigationItemsList, { variant: "section", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref, position: position })));
|
|
136
157
|
}
|
|
137
|
-
function SectionGroup({ definition, activeHref, fireFollow, fireChange }) {
|
|
158
|
+
function SectionGroup({ definition, activeHref, fireFollow, fireChange, position }) {
|
|
138
159
|
return (React.createElement("div", { className: styles['section-group'] },
|
|
139
160
|
React.createElement(InternalBox, { className: styles['section-group-title'], variant: "h3" }, definition.title),
|
|
140
|
-
React.createElement(NavigationItemsList, { variant: "section-group", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref })));
|
|
161
|
+
React.createElement(NavigationItemsList, { variant: "section-group", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref, position: position })));
|
|
141
162
|
}
|
|
142
|
-
function LinkGroup({ definition, activeHref, fireFollow, fireChange }) {
|
|
163
|
+
function LinkGroup({ definition, activeHref, fireFollow, fireChange, position }) {
|
|
143
164
|
checkSafeUrl('SideNavigation', definition.href);
|
|
144
165
|
return (React.createElement(React.Fragment, null,
|
|
145
|
-
React.createElement(Link, { definition: { type: 'link', href: definition.href, text: definition.text, info: definition.info }, fireFollow: (_, event) => fireFollow(definition, event), fireChange: fireChange, activeHref: activeHref }),
|
|
146
|
-
React.createElement(NavigationItemsList, { variant: "link-group", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref })));
|
|
166
|
+
React.createElement(Link, { definition: { type: 'link', href: definition.href, text: definition.text, info: definition.info }, fireFollow: (_, event) => fireFollow(definition, event), fireChange: fireChange, activeHref: activeHref, position: position }),
|
|
167
|
+
React.createElement(NavigationItemsList, { variant: "link-group", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref, position: position })));
|
|
147
168
|
}
|
|
148
|
-
function ExpandableLinkGroup({ definition, fireFollow, fireChange, activeHref, variant }) {
|
|
169
|
+
function ExpandableLinkGroup({ definition, fireFollow, fireChange, activeHref, variant, position, }) {
|
|
149
170
|
// Check whether the definition contains an active link and memoize it to avoid
|
|
150
171
|
// rechecking every time.
|
|
151
172
|
const containsActiveLink = useMemo(() => {
|
|
@@ -179,7 +200,7 @@ function ExpandableLinkGroup({ definition, fireFollow, fireChange, activeHref, v
|
|
|
179
200
|
fireChange(definition, true);
|
|
180
201
|
}
|
|
181
202
|
};
|
|
182
|
-
return (React.createElement(InternalExpandableSection, { className: clsx(styles['expandable-link-group'], variant === 'section-group' && styles['expandable-link-group--no-ident']), variant: "navigation", expanded: userExpanded !== null && userExpanded !== void 0 ? userExpanded : expanded, onChange: onExpandedChange, headerText: React.createElement(Link, { definition: { type: 'link', href: definition.href, text: definition.text }, expanded: userExpanded !== null && userExpanded !== void 0 ? userExpanded : expanded, fireFollow: onHeaderFollow, fireChange: fireChange, activeHref: activeHref }) },
|
|
183
|
-
React.createElement(NavigationItemsList, { variant: "expandable-link-group", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref })));
|
|
203
|
+
return (React.createElement(InternalExpandableSection, { className: clsx(styles['expandable-link-group'], variant === 'section-group' && styles['expandable-link-group--no-ident']), variant: "navigation", expanded: userExpanded !== null && userExpanded !== void 0 ? userExpanded : expanded, onChange: onExpandedChange, headerText: React.createElement(Link, { definition: { type: 'link', href: definition.href, text: definition.text }, expanded: userExpanded !== null && userExpanded !== void 0 ? userExpanded : expanded, fireFollow: onHeaderFollow, fireChange: fireChange, activeHref: activeHref, position: position }) },
|
|
204
|
+
React.createElement(NavigationItemsList, { variant: "expandable-link-group", items: definition.items, fireFollow: fireFollow, fireChange: fireChange, activeHref: activeHref, position: position })));
|
|
184
205
|
}
|
|
185
206
|
//# sourceMappingURL=parts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parts.js","sourceRoot":"","sources":["../../../src/side-navigation/parts.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAa,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,yBAAyB,MAAM,gCAAgC,CAAC;AACvE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAA4B,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAmBrC,MAAM,UAAU,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAe;IACxE,YAAY,CAAC,gBAAgB,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,WAAW,CACzB,CAAC,KAAuB,EAAE,EAAE;QAC1B,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;YAC3B,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;SAC/B;IACH,CA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AAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC,EACD,CAAC,UAAU,EAAE,UAAU,CAAC,CACzB,CAAC;IAEF,MAAM,cAAc,GAA4B,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;QAC3D,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC9B,eAAe,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,QAAQ,EAAE;YACb,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;SAC9B;IACH,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,yBAAyB,IACxB,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,uBAAuB,CAAC,EAC/B,OAAO,KAAK,eAAe,IAAI,MAAM,CAAC,iCAAiC,CAAC,CACzE,EACD,OAAO,EAAC,YAAY,EACpB,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EACR,oBAAC,IAAI,IACH,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,EAC1E,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,UAAU,EAAE,cAAc,EAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACtB;QAGJ,oBAAC,mBAAmB,IAClB,OAAO,EAAC,uBAAuB,EAC/B,KAAK,EAAE,UAAU,CAAC,KAAK,EACvB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACtB,CACwB,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ReactNode, useCallback, useEffect, useMemo, useState } from 'react';\nimport clsx from 'clsx';\n\nimport InternalBox from '../box/internal';\nimport { ExpandableSectionProps } from '../expandable-section/interfaces';\nimport InternalExpandableSection from '../expandable-section/internal';\nimport InternalIcon from '../icon/internal';\nimport { isPlainLeftClick, NonCancelableCustomEvent } from '../internal/events';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { SideNavigationProps } from './interfaces';\nimport { hasActiveLink } from './util';\n\nimport styles from './styles.css.js';\n\ninterface BaseItemComponentProps {\n activeHref?: string;\n fireChange: (item: SideNavigationProps.Section | SideNavigationProps.ExpandableLinkGroup, expanded: boolean) => void;\n fireFollow: (\n item:\n | SideNavigationProps.Link\n | SideNavigationProps.Header\n | SideNavigationProps.LinkGroup\n | SideNavigationProps.ExpandableLinkGroup,\n event: React.SyntheticEvent | Event\n ) => void;\n}\n\nexport interface HeaderProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Header;\n}\n\nexport function Header({ definition, activeHref, fireFollow }: HeaderProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n return (\n <>\n <h2 className={styles.header}>\n <a\n href={definition.href}\n className={clsx(styles['header-link'], { [styles['header-link--has-logo']]: !!definition.logo })}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n >\n {definition.logo && (\n <img\n className={clsx(styles['header-logo'], {\n [styles['header-logo--stretched']]: !definition.text,\n })}\n {...definition.logo}\n />\n )}\n <span className={styles['header-link-text']}>{definition.text}</span>\n </a>\n </h2>\n <Divider isPresentational={true} variant=\"header\" />\n </>\n );\n}\n\nexport interface NavigationItemsListProps extends BaseItemComponentProps {\n items: ReadonlyArray<SideNavigationProps.Item>;\n variant: 'section' | 'section-group' | 'link-group' | 'expandable-link-group' | 'root';\n}\n\ninterface Item {\n element?: ReactNode;\n listVariant?: 'section' | 'section-group' | 'link-group' | 'expandable-link-group' | 'root';\n items?: Array<Item>;\n}\n\nexport function NavigationItemsList({ items, variant, activeHref, fireChange, fireFollow }: NavigationItemsListProps) {\n const lists: Array<Item> = [];\n let currentListIndex = 0;\n lists[currentListIndex] = {\n listVariant: variant,\n items: [],\n };\n\n items.forEach((item, index) => {\n const itemid = index + 1;\n switch (item.type) {\n case 'divider': {\n const dividerIndex = lists.length;\n lists[dividerIndex] = {\n element: (\n <div data-itemid={`item-${itemid}`}>\n <Divider variant=\"default\" />\n </div>\n ),\n };\n currentListIndex = lists.length;\n lists[currentListIndex] = {\n listVariant: variant,\n items: [],\n };\n return;\n }\n case 'link': {\n lists[currentListIndex].items?.push({\n element: (\n <li key={index} data-itemid={`item-${itemid}`} className={styles['list-item']}>\n <Link definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n </li>\n ),\n });\n return;\n }\n case 'section': {\n lists[currentListIndex].items?.push({\n element: (\n <li key={index} data-itemid={`item-${itemid}`} className={styles['list-item']}>\n <Section\n definition={item}\n activeHref={activeHref}\n variant={variant}\n fireChange={fireChange}\n fireFollow={fireFollow}\n />\n </li>\n ),\n });\n return;\n }\n case 'section-group': {\n lists[currentListIndex].items?.push({\n element: (\n <li key={index} data-itemid={`item-${itemid}`} className={styles['list-item']}>\n <SectionGroup definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n </li>\n ),\n });\n return;\n }\n case 'link-group': {\n lists[currentListIndex].items?.push({\n element: (\n <li key={index} data-itemid={`item-${itemid}`} className={styles['list-item']}>\n <LinkGroup definition={item} activeHref={activeHref} fireChange={fireChange} fireFollow={fireFollow} />\n </li>\n ),\n });\n return;\n }\n case 'expandable-link-group': {\n lists[currentListIndex].items?.push({\n element: (\n <li key={index} data-itemid={`item-${itemid}`} className={styles['list-item']}>\n <ExpandableLinkGroup\n definition={item}\n activeHref={activeHref}\n fireChange={fireChange}\n fireFollow={fireFollow}\n variant={variant}\n />\n </li>\n ),\n });\n return;\n }\n }\n });\n\n const lastListIndex = lists.length - 1;\n\n return (\n <>\n {lists.map((list, index) => {\n if (!list.items || list.items.length === 0) {\n return (\n <div\n key={`hr-${index}`}\n className={clsx(styles.list, styles[`list-variant-${variant}`], {\n [styles['list-variant-root--last']]: list.listVariant === 'root' && index === lastListIndex,\n })}\n >\n {list.element}\n </div>\n );\n } else {\n return (\n <ul\n key={`list-${index}`}\n className={clsx(styles.list, styles[`list-variant-${list.listVariant}`], {\n [styles['list-variant-root--last']]: list.listVariant === 'root' && index === lastListIndex,\n })}\n >\n {list.items.map(item => item.element)}\n </ul>\n );\n }\n })}\n </>\n );\n}\n\ninterface DividerProps {\n variant: 'default' | 'header';\n isPresentational?: boolean;\n}\n\nfunction Divider({ variant = 'default', isPresentational = false }: DividerProps) {\n return (\n <hr\n className={clsx(styles.divider, styles[`divider-${variant}`])}\n role={isPresentational ? 'presentation' : undefined}\n />\n );\n}\n\ninterface LinkProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Link;\n expanded?: boolean;\n}\n\nfunction Link({ definition, expanded, activeHref, fireFollow }: LinkProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const isActive = definition.href === activeHref;\n\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n return (\n <>\n <a\n href={definition.href}\n className={clsx(styles.link, { [styles['link-active']]: isActive })}\n target={definition.external ? '_blank' : undefined}\n rel={definition.external ? 'noopener noreferrer' : undefined}\n aria-expanded={expanded}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n >\n {definition.text}\n {definition.external && (\n <span\n aria-label={definition.externalIconAriaLabel}\n role={definition.externalIconAriaLabel ? 'img' : undefined}\n >\n <InternalIcon name=\"external\" className={styles['external-icon']} />\n </span>\n )}\n </a>\n {definition.info && <span className={styles.info}>{definition.info}</span>}\n </>\n );\n}\n\ninterface SectionProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Section;\n variant: 'section' | 'section-group' | 'link-group' | 'expandable-link-group' | 'root';\n}\n\nfunction Section({ definition, activeHref, fireFollow, fireChange, variant }: SectionProps) {\n const [expanded, setExpanded] = useState<boolean>(definition.defaultExpanded ?? true);\n const isVisualRefresh = useVisualRefresh();\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n useEffect(() => {\n setExpanded(definition.defaultExpanded ?? true);\n }, [definition]);\n\n return (\n <InternalExpandableSection\n variant=\"footer\"\n expanded={expanded}\n onChange={onExpandedChange}\n className={clsx(\n styles.section,\n variant === 'section-group' && styles['section--no-ident'],\n isVisualRefresh && styles.refresh\n )}\n headerText={definition.text}\n >\n <NavigationItemsList\n variant=\"section\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </InternalExpandableSection>\n );\n}\n\ninterface SectionGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.SectionGroup;\n}\n\nfunction SectionGroup({ definition, activeHref, fireFollow, fireChange }: SectionGroupProps) {\n return (\n <div className={styles['section-group']}>\n <InternalBox className={styles['section-group-title']} variant=\"h3\">\n {definition.title}\n </InternalBox>\n <NavigationItemsList\n variant=\"section-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </div>\n );\n}\n\ninterface LinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.LinkGroup;\n}\n\nfunction LinkGroup({ definition, activeHref, fireFollow, fireChange }: LinkGroupProps) {\n checkSafeUrl('SideNavigation', definition.href);\n\n return (\n <>\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text, info: definition.info }}\n fireFollow={(_, event) => fireFollow(definition, event)}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n <NavigationItemsList\n variant=\"link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </>\n );\n}\n\ninterface ExpandableLinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.ExpandableLinkGroup;\n variant: 'section' | 'section-group' | 'link-group' | 'expandable-link-group' | 'root';\n}\n\nfunction ExpandableLinkGroup({ definition, fireFollow, fireChange, activeHref, variant }: ExpandableLinkGroupProps) {\n // Check whether the definition contains an active link and memoize it to avoid\n // rechecking every time.\n const containsActiveLink = useMemo(() => {\n return activeHref ? hasActiveLink(definition.items, activeHref) : false;\n }, [activeHref, definition.items]);\n\n const [expanded, setExpanded] = useState<boolean>(() => {\n return definition.defaultExpanded ?? (definition.href === activeHref || containsActiveLink);\n });\n\n const [userExpanded, setUserExpanded] = useState<boolean | undefined>();\n\n // Reset user expansion status when the items property is updated.\n useEffect(() => setUserExpanded(undefined), [definition]);\n\n // By default, the expandable section is open when there's an active link inside.\n useEffect(() => {\n setExpanded(definition.href === activeHref || containsActiveLink);\n }, [definition.href, containsActiveLink, activeHref]);\n\n // If the definition object itself is updated, reset the expansion state to default.\n useEffect(() => {\n if (definition.defaultExpanded !== undefined) {\n setExpanded(definition.defaultExpanded);\n }\n }, [definition]);\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setUserExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n const onHeaderFollow: LinkProps['fireFollow'] = (_, event) => {\n fireFollow(definition, event);\n setUserExpanded(true);\n if (!expanded) {\n fireChange(definition, true);\n }\n };\n\n return (\n <InternalExpandableSection\n className={clsx(\n styles['expandable-link-group'],\n variant === 'section-group' && styles['expandable-link-group--no-ident']\n )}\n variant=\"navigation\"\n expanded={userExpanded ?? expanded}\n onChange={onExpandedChange}\n headerText={\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text }}\n expanded={userExpanded ?? expanded}\n fireFollow={onHeaderFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n }\n >\n <NavigationItemsList\n variant=\"expandable-link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n />\n </InternalExpandableSection>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parts.js","sourceRoot":"","sources":["../../../src/side-navigation/parts.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAa,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpF,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,WAAW,MAAM,iBAAiB,CAAC;AAE1C,OAAO,yBAAyB,MAAM,gCAAgC,CAAC;AACvE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAA4B,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGhE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,kBAAkB,MAAM,oCAAoC,CAAC;AACpE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAoBrC,MAAM,UAAU,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAe;IACxE,YAAY,CAAC,gBAAgB,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,WAAW,CACzB,CAAC,KAAuB,EAAE,EAAE;QAC1B,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;YAC3B,UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;SAC/B;IACH,CAAC,EACD,CAAC,UAAU,EAAE,UAAU,C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UAAU,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC9B,eAAe,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,QAAQ,EAAE;YACb,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;SAC9B;IACH,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,yBAAyB,IACxB,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,uBAAuB,CAAC,EAC/B,OAAO,KAAK,eAAe,IAAI,MAAM,CAAC,iCAAiC,CAAC,CACzE,EACD,OAAO,EAAC,YAAY,EACpB,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,QAAQ,EAAE,gBAAgB,EAC1B,UAAU,EACR,oBAAC,IAAI,IACH,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,EAC1E,QAAQ,EAAE,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,QAAQ,EAClC,UAAU,EAAE,cAAc,EAC1B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,GAClB;QAGJ,oBAAC,mBAAmB,IAClB,OAAO,EAAC,uBAAuB,EAC/B,KAAK,EAAE,UAAU,CAAC,KAAK,EACvB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,QAAQ,GAClB,CACwB,CAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ReactNode, useCallback, useEffect, useMemo, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport InternalBox from '../box/internal';\nimport { ExpandableSectionProps } from '../expandable-section/interfaces';\nimport InternalExpandableSection from '../expandable-section/internal';\nimport InternalIcon from '../icon/internal';\nimport { isPlainLeftClick, NonCancelableCustomEvent } from '../internal/events';\nimport { useVisualRefresh } from '../internal/hooks/use-visual-mode';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { GeneratedAnalyticsMetadataSideNavigationClick } from './analytics-metadata/interfaces';\nimport { SideNavigationProps } from './interfaces';\nimport { hasActiveLink } from './util';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface BaseItemComponentProps {\n activeHref?: string;\n fireChange: (item: SideNavigationProps.Section | SideNavigationProps.ExpandableLinkGroup, expanded: boolean) => void;\n fireFollow: (\n item:\n | SideNavigationProps.Link\n | SideNavigationProps.Header\n | SideNavigationProps.LinkGroup\n | SideNavigationProps.ExpandableLinkGroup,\n event: React.SyntheticEvent | Event\n ) => void;\n position?: string;\n}\n\nexport interface HeaderProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Header;\n}\n\nexport function Header({ definition, activeHref, fireFollow }: HeaderProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n const clickActionAnalyticsMetadata: GeneratedAnalyticsMetadataSideNavigationClick = {\n action: 'click',\n detail: {\n label: `.${analyticsSelectors['header-link-text']}`,\n external: 'false',\n href: definition.href,\n position: 'header',\n },\n };\n\n return (\n <>\n <h2 className={styles.header}>\n <a\n href={definition.href}\n className={clsx(styles['header-link'], { [styles['header-link--has-logo']]: !!definition.logo })}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n {...getAnalyticsMetadataAttribute(clickActionAnalyticsMetadata)}\n >\n {definition.logo && (\n <img\n className={clsx(styles['header-logo'], {\n [styles['header-logo--stretched']]: !definition.text,\n })}\n {...definition.logo}\n />\n )}\n <span className={clsx(styles['header-link-text'], analyticsSelectors['header-link-text'])}>\n {definition.text}\n </span>\n </a>\n </h2>\n <Divider isPresentational={true} variant=\"header\" />\n </>\n );\n}\n\nexport interface NavigationItemsListProps extends BaseItemComponentProps {\n items: ReadonlyArray<SideNavigationProps.Item>;\n variant: 'section' | 'section-group' | 'link-group' | 'expandable-link-group' | 'root';\n}\n\ninterface Item {\n element?: ReactNode;\n listVariant?: 'section' | 'section-group' | 'link-group' | 'expandable-link-group' | 'root';\n items?: Array<Item>;\n}\n\nexport function NavigationItemsList({\n items,\n variant,\n activeHref,\n fireChange,\n fireFollow,\n position = '',\n}: NavigationItemsListProps) {\n const lists: Array<Item> = [];\n let currentListIndex = 0;\n lists[currentListIndex] = {\n listVariant: variant,\n items: [],\n };\n\n items.forEach((item, index) => {\n const itemid = index + 1;\n const itemPosition = `${position ? `${position},` : ''}${itemid}`;\n switch (item.type) {\n case 'divider': {\n const dividerIndex = lists.length;\n lists[dividerIndex] = {\n element: (\n <div data-itemid={`item-${itemid}`}>\n <Divider variant=\"default\" />\n </div>\n ),\n };\n currentListIndex = lists.length;\n lists[currentListIndex] = {\n listVariant: variant,\n items: [],\n };\n return;\n }\n case 'link': {\n lists[currentListIndex].items?.push({\n element: (\n <li key={index} data-itemid={`item-${itemid}`} className={styles['list-item']}>\n <Link\n definition={item}\n activeHref={activeHref}\n fireChange={fireChange}\n fireFollow={fireFollow}\n position={itemPosition}\n />\n </li>\n ),\n });\n return;\n }\n case 'section': {\n lists[currentListIndex].items?.push({\n element: (\n <li key={index} data-itemid={`item-${itemid}`} className={styles['list-item']}>\n <Section\n definition={item}\n activeHref={activeHref}\n variant={variant}\n fireChange={fireChange}\n fireFollow={fireFollow}\n position={itemPosition}\n />\n </li>\n ),\n });\n return;\n }\n case 'section-group': {\n lists[currentListIndex].items?.push({\n element: (\n <li key={index} data-itemid={`item-${itemid}`} className={styles['list-item']}>\n <SectionGroup\n definition={item}\n activeHref={activeHref}\n fireChange={fireChange}\n fireFollow={fireFollow}\n position={itemPosition}\n />\n </li>\n ),\n });\n return;\n }\n case 'link-group': {\n lists[currentListIndex].items?.push({\n element: (\n <li key={index} data-itemid={`item-${itemid}`} className={styles['list-item']}>\n <LinkGroup\n definition={item}\n activeHref={activeHref}\n fireChange={fireChange}\n fireFollow={fireFollow}\n position={itemPosition}\n />\n </li>\n ),\n });\n return;\n }\n case 'expandable-link-group': {\n lists[currentListIndex].items?.push({\n element: (\n <li key={index} data-itemid={`item-${itemid}`} className={styles['list-item']}>\n <ExpandableLinkGroup\n definition={item}\n activeHref={activeHref}\n fireChange={fireChange}\n fireFollow={fireFollow}\n variant={variant}\n position={itemPosition}\n />\n </li>\n ),\n });\n return;\n }\n }\n });\n\n const lastListIndex = lists.length - 1;\n\n return (\n <>\n {lists.map((list, index) => {\n if (!list.items || list.items.length === 0) {\n return (\n <div\n key={`hr-${index}`}\n className={clsx(styles.list, styles[`list-variant-${variant}`], {\n [styles['list-variant-root--last']]: list.listVariant === 'root' && index === lastListIndex,\n })}\n >\n {list.element}\n </div>\n );\n } else {\n return (\n <ul\n key={`list-${index}`}\n className={clsx(styles.list, styles[`list-variant-${list.listVariant}`], {\n [styles['list-variant-root--last']]: list.listVariant === 'root' && index === lastListIndex,\n })}\n >\n {list.items.map(item => item.element)}\n </ul>\n );\n }\n })}\n </>\n );\n}\n\ninterface DividerProps {\n variant: 'default' | 'header';\n isPresentational?: boolean;\n}\n\nfunction Divider({ variant = 'default', isPresentational = false }: DividerProps) {\n return (\n <hr\n className={clsx(styles.divider, styles[`divider-${variant}`])}\n role={isPresentational ? 'presentation' : undefined}\n />\n );\n}\n\ninterface LinkProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Link;\n expanded?: boolean;\n}\n\nfunction Link({ definition, expanded, activeHref, fireFollow, position }: LinkProps) {\n checkSafeUrl('SideNavigation', definition.href);\n const isActive = definition.href === activeHref;\n\n const onClick = useCallback(\n (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireFollow(definition, event);\n }\n },\n [fireFollow, definition]\n );\n\n const clickActionAnalyticsMetadata: GeneratedAnalyticsMetadataSideNavigationClick = {\n action: 'click',\n detail: {\n label: `.${analyticsSelectors['link-text']}`,\n external: `${!!definition.external}`,\n href: definition.href,\n position,\n },\n };\n\n return (\n <>\n <a\n href={definition.href}\n className={clsx(styles.link, { [styles['link-active']]: isActive })}\n target={definition.external ? '_blank' : undefined}\n rel={definition.external ? 'noopener noreferrer' : undefined}\n aria-expanded={expanded}\n aria-current={definition.href === activeHref ? 'page' : undefined}\n onClick={onClick}\n {...getAnalyticsMetadataAttribute(clickActionAnalyticsMetadata)}\n >\n <span className={analyticsSelectors['link-text']}>{definition.text}</span>\n {definition.external && (\n <span\n aria-label={definition.externalIconAriaLabel}\n role={definition.externalIconAriaLabel ? 'img' : undefined}\n >\n <InternalIcon name=\"external\" className={styles['external-icon']} />\n </span>\n )}\n </a>\n {definition.info && <span className={styles.info}>{definition.info}</span>}\n </>\n );\n}\n\ninterface SectionProps extends BaseItemComponentProps {\n definition: SideNavigationProps.Section;\n variant: 'section' | 'section-group' | 'link-group' | 'expandable-link-group' | 'root';\n}\n\nfunction Section({ definition, activeHref, fireFollow, fireChange, variant, position }: SectionProps) {\n const [expanded, setExpanded] = useState<boolean>(definition.defaultExpanded ?? true);\n const isVisualRefresh = useVisualRefresh();\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n useEffect(() => {\n setExpanded(definition.defaultExpanded ?? true);\n }, [definition]);\n\n return (\n <InternalExpandableSection\n variant=\"footer\"\n expanded={expanded}\n onChange={onExpandedChange}\n className={clsx(\n styles.section,\n variant === 'section-group' && styles['section--no-ident'],\n isVisualRefresh && styles.refresh\n )}\n headerText={definition.text}\n >\n <NavigationItemsList\n variant=\"section\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n position={position}\n />\n </InternalExpandableSection>\n );\n}\n\ninterface SectionGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.SectionGroup;\n}\n\nfunction SectionGroup({ definition, activeHref, fireFollow, fireChange, position }: SectionGroupProps) {\n return (\n <div className={styles['section-group']}>\n <InternalBox className={styles['section-group-title']} variant=\"h3\">\n {definition.title}\n </InternalBox>\n <NavigationItemsList\n variant=\"section-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n position={position}\n />\n </div>\n );\n}\n\ninterface LinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.LinkGroup;\n}\n\nfunction LinkGroup({ definition, activeHref, fireFollow, fireChange, position }: LinkGroupProps) {\n checkSafeUrl('SideNavigation', definition.href);\n\n return (\n <>\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text, info: definition.info }}\n fireFollow={(_, event) => fireFollow(definition, event)}\n fireChange={fireChange}\n activeHref={activeHref}\n position={position}\n />\n <NavigationItemsList\n variant=\"link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n position={position}\n />\n </>\n );\n}\n\ninterface ExpandableLinkGroupProps extends BaseItemComponentProps {\n definition: SideNavigationProps.ExpandableLinkGroup;\n variant: 'section' | 'section-group' | 'link-group' | 'expandable-link-group' | 'root';\n}\n\nfunction ExpandableLinkGroup({\n definition,\n fireFollow,\n fireChange,\n activeHref,\n variant,\n position,\n}: ExpandableLinkGroupProps) {\n // Check whether the definition contains an active link and memoize it to avoid\n // rechecking every time.\n const containsActiveLink = useMemo(() => {\n return activeHref ? hasActiveLink(definition.items, activeHref) : false;\n }, [activeHref, definition.items]);\n\n const [expanded, setExpanded] = useState<boolean>(() => {\n return definition.defaultExpanded ?? (definition.href === activeHref || containsActiveLink);\n });\n\n const [userExpanded, setUserExpanded] = useState<boolean | undefined>();\n\n // Reset user expansion status when the items property is updated.\n useEffect(() => setUserExpanded(undefined), [definition]);\n\n // By default, the expandable section is open when there's an active link inside.\n useEffect(() => {\n setExpanded(definition.href === activeHref || containsActiveLink);\n }, [definition.href, containsActiveLink, activeHref]);\n\n // If the definition object itself is updated, reset the expansion state to default.\n useEffect(() => {\n if (definition.defaultExpanded !== undefined) {\n setExpanded(definition.defaultExpanded);\n }\n }, [definition]);\n\n const onExpandedChange = useCallback(\n (e: NonCancelableCustomEvent<ExpandableSectionProps.ChangeDetail>) => {\n fireChange(definition, e.detail.expanded);\n setUserExpanded(e.detail.expanded);\n },\n [definition, fireChange]\n );\n\n const onHeaderFollow: LinkProps['fireFollow'] = (_, event) => {\n fireFollow(definition, event);\n setUserExpanded(true);\n if (!expanded) {\n fireChange(definition, true);\n }\n };\n\n return (\n <InternalExpandableSection\n className={clsx(\n styles['expandable-link-group'],\n variant === 'section-group' && styles['expandable-link-group--no-ident']\n )}\n variant=\"navigation\"\n expanded={userExpanded ?? expanded}\n onChange={onExpandedChange}\n headerText={\n <Link\n definition={{ type: 'link', href: definition.href, text: definition.text }}\n expanded={userExpanded ?? expanded}\n fireFollow={onHeaderFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n position={position}\n />\n }\n >\n <NavigationItemsList\n variant=\"expandable-link-group\"\n items={definition.items}\n fireFollow={fireFollow}\n fireChange={fireChange}\n activeHref={activeHref}\n position={position}\n />\n </InternalExpandableSection>\n );\n}\n"]}
|