@cloudscape-design/components 3.0.756 → 3.0.758
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/breadcrumb-group/implementation.d.ts.map +1 -1
- package/breadcrumb-group/implementation.js +61 -12
- package/breadcrumb-group/implementation.js.map +1 -1
- package/breadcrumb-group/interfaces.d.ts +3 -2
- package/breadcrumb-group/interfaces.d.ts.map +1 -1
- package/breadcrumb-group/interfaces.js.map +1 -1
- package/breadcrumb-group/item/funnel.d.ts +1 -0
- package/breadcrumb-group/item/funnel.d.ts.map +1 -1
- package/breadcrumb-group/item/funnel.js +3 -3
- package/breadcrumb-group/item/funnel.js.map +1 -1
- package/breadcrumb-group/item/item.d.ts +1 -1
- package/breadcrumb-group/item/item.d.ts.map +1 -1
- package/breadcrumb-group/item/item.js +19 -38
- package/breadcrumb-group/item/item.js.map +1 -1
- package/breadcrumb-group/item/styles.css.js +8 -9
- package/breadcrumb-group/item/styles.scoped.css +33 -32
- package/breadcrumb-group/item/styles.selectors.js +8 -9
- package/breadcrumb-group/styles.css.js +8 -7
- package/breadcrumb-group/styles.scoped.css +17 -57
- package/breadcrumb-group/styles.selectors.js +8 -7
- package/breadcrumb-group/utils.d.ts +5 -0
- package/breadcrumb-group/utils.d.ts.map +1 -1
- package/breadcrumb-group/utils.js +56 -0
- package/breadcrumb-group/utils.js.map +1 -1
- package/file-upload/internal.js +5 -3
- package/file-upload/internal.js.map +1 -1
- package/internal/components/button-trigger/index.d.ts +1 -1
- package/internal/components/button-trigger/index.d.ts.map +1 -1
- package/internal/components/button-trigger/index.js +1 -1
- package/internal/components/button-trigger/index.js.map +1 -1
- package/internal/components/button-trigger/styles.css.js +13 -11
- package/internal/components/button-trigger/styles.scoped.css +30 -26
- package/internal/components/button-trigger/styles.selectors.js +13 -11
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/hooks/use-list-focus-controller.d.ts +3 -3
- package/internal/hooks/use-list-focus-controller.d.ts.map +1 -1
- package/internal/hooks/use-list-focus-controller.js +7 -8
- package/internal/hooks/use-list-focus-controller.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/package.json +1 -1
- package/property-filter/filtering-token/index.d.ts.map +1 -1
- package/property-filter/filtering-token/index.js +6 -4
- package/property-filter/filtering-token/index.js.map +1 -1
- package/property-filter/interfaces.d.ts +4 -2
- package/property-filter/interfaces.d.ts.map +1 -1
- package/property-filter/interfaces.js.map +1 -1
- package/property-filter/internal.d.ts.map +1 -1
- package/property-filter/internal.js +11 -3
- package/property-filter/internal.js.map +1 -1
- package/property-filter/token-editor.d.ts.map +1 -1
- package/property-filter/token-editor.js +5 -3
- package/property-filter/token-editor.js.map +1 -1
- package/select/internal.d.ts +1 -1
- package/select/internal.d.ts.map +1 -1
- package/select/internal.js +1 -1
- package/select/internal.js.map +1 -1
- package/select/parts/trigger.d.ts +1 -1
- package/select/parts/trigger.d.ts.map +1 -1
- package/select/parts/trigger.js.map +1 -1
- package/side-navigation/analytics-metadata/interfaces.d.ts +19 -0
- package/side-navigation/analytics-metadata/interfaces.d.ts.map +1 -0
- package/side-navigation/analytics-metadata/interfaces.js +4 -0
- package/side-navigation/analytics-metadata/interfaces.js.map +1 -0
- package/side-navigation/analytics-metadata/styles.css.js +7 -0
- package/side-navigation/analytics-metadata/styles.scoped.css +8 -0
- package/side-navigation/analytics-metadata/styles.selectors.js +8 -0
- package/side-navigation/index.d.ts.map +1 -1
- package/side-navigation/index.js +10 -1
- package/side-navigation/index.js.map +1 -1
- package/side-navigation/parts.d.ts +2 -1
- package/side-navigation/parts.d.ts.map +1 -1
- package/side-navigation/parts.js +42 -21
- package/side-navigation/parts.js.map +1 -1
- package/token-group/internal.d.ts.map +1 -1
- package/token-group/internal.js +4 -2
- package/token-group/internal.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/breadcrumb-group/implementation.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"implementation.d.ts","sourceRoot":"","sources":["../../../src/breadcrumb-group/implementation.tsx"],"names":[],"mappings":";AAuBA,OAAO,EAAE,oBAAoB,EAAyB,4BAA4B,EAAE,MAAM,cAAc,CAAC;AA4FzG,wBAAgB,6BAA6B,CAAC,CAAC,SAAS,oBAAoB,CAAC,IAAI,GAAG,oBAAoB,CAAC,IAAI,EAAE,EAC7G,KAAU,EACV,SAAS,EACT,eAAe,EACf,OAAO,EACP,QAAQ,EACR,iBAAiB,EACjB,kCAAkC,EAClC,GAAG,KAAK,EACT,EAAE,4BAA4B,CAAC,CAAC,CAAC,eA2IjC;AAED,eAAO,MAAM,+BAA+B,qGAA2D,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import React from 'react';
|
|
4
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
+
import { useContainerQuery } from '@cloudscape-design/component-toolkit';
|
|
7
|
+
import { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';
|
|
6
8
|
import { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';
|
|
7
9
|
import { InternalButton } from '../button/internal';
|
|
8
10
|
import InternalButtonDropdown from '../button-dropdown/internal';
|
|
@@ -10,11 +12,11 @@ import { useInternalI18n } from '../i18n/context';
|
|
|
10
12
|
import InternalIcon from '../icon/internal';
|
|
11
13
|
import { getBaseProps } from '../internal/base-component';
|
|
12
14
|
import { fireCancelableEvent } from '../internal/events';
|
|
13
|
-
import {
|
|
15
|
+
import { useMergeRefs } from '../internal/hooks/use-merge-refs';
|
|
14
16
|
import { checkSafeUrl } from '../internal/utils/check-safe-url';
|
|
15
17
|
import { createWidgetizedComponent } from '../internal/widgets';
|
|
16
18
|
import { BreadcrumbItem } from './item/item';
|
|
17
|
-
import { getEventDetail } from './utils';
|
|
19
|
+
import { getEventDetail, getItemsDisplayProperties } from './utils';
|
|
18
20
|
import analyticsSelectors from './analytics-metadata/styles.css.js';
|
|
19
21
|
import styles from './styles.css.js';
|
|
20
22
|
/**
|
|
@@ -27,10 +29,10 @@ const getDropdownTrigger = ({ ariaLabel, triggerRef, disabled, testUtilsClass, i
|
|
|
27
29
|
onClick();
|
|
28
30
|
}, ariaExpanded: isOpen, "aria-haspopup": true, ariaLabel: ariaLabel, variant: "breadcrumb-group", formAction: "none" }, "..."));
|
|
29
31
|
};
|
|
30
|
-
const EllipsisDropdown = ({ ariaLabel, dropdownItems, onDropdownItemClick, onDropdownItemFollow, }) => {
|
|
32
|
+
const EllipsisDropdown = ({ ariaLabel, dropdownItems, onDropdownItemClick, onDropdownItemFollow, visible, }) => {
|
|
31
33
|
var _a;
|
|
32
34
|
const i18n = useInternalI18n('breadcrumb-group');
|
|
33
|
-
return (React.createElement("li", { className: styles.ellipsis },
|
|
35
|
+
return (React.createElement("li", { className: clsx(styles.ellipsis, visible && styles.visible) },
|
|
34
36
|
React.createElement(InternalButtonDropdown, { ariaLabel: (_a = i18n('expandAriaLabel', ariaLabel)) !== null && _a !== void 0 ? _a : DEFAULT_EXPAND_ARIA_LABEL, items: dropdownItems, onItemClick: onDropdownItemClick, onItemFollow: onDropdownItemFollow, customTriggerBuilder: getDropdownTrigger, linkStyle: true, analyticsMetadataTransformer: metadata => {
|
|
35
37
|
var _a, _b;
|
|
36
38
|
if ((_a = metadata.detail) === null || _a === void 0 ? void 0 : _a.id) {
|
|
@@ -44,15 +46,56 @@ const EllipsisDropdown = ({ ariaLabel, dropdownItems, onDropdownItemClick, onDro
|
|
|
44
46
|
React.createElement("span", { className: styles.icon },
|
|
45
47
|
React.createElement(InternalIcon, { name: "angle-right" }))));
|
|
46
48
|
};
|
|
49
|
+
const areArrayEqual = (first, second) => {
|
|
50
|
+
if (first.length !== second.length) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return first.every((item, index) => item === second[index]);
|
|
54
|
+
};
|
|
47
55
|
export function BreadcrumbGroupImplementation(_a) {
|
|
48
56
|
var { items = [], ariaLabel, expandAriaLabel, onClick, onFollow, __internalRootRef, __injectAnalyticsComponentMetadata } = _a, props = __rest(_a, ["items", "ariaLabel", "expandAriaLabel", "onClick", "onFollow", "__internalRootRef", "__injectAnalyticsComponentMetadata"]);
|
|
49
57
|
for (const item of items) {
|
|
50
58
|
checkSafeUrl('BreadcrumbGroup', item.href);
|
|
51
59
|
}
|
|
52
60
|
const baseProps = getBaseProps(props);
|
|
53
|
-
const
|
|
61
|
+
const [navWidth, navRef] = useContainerQuery(rect => rect.borderBoxWidth);
|
|
62
|
+
const mergedRef = useMergeRefs(navRef, __internalRootRef);
|
|
63
|
+
const itemsRefs = useRef({ ghost: {}, real: {} });
|
|
64
|
+
const setBreadcrumb = (type, index, node) => {
|
|
65
|
+
if (node) {
|
|
66
|
+
itemsRefs.current[type][index] = node;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
delete itemsRefs.current[type][index];
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const [itemsWidths, setItemsWidths] = useState({ ghost: [], real: [] });
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (itemsRefs.current) {
|
|
75
|
+
const newItemsWidths = { ghost: [], real: [] };
|
|
76
|
+
for (const node of Object.values(itemsRefs.current.ghost)) {
|
|
77
|
+
const width = getLogicalBoundingClientRect(node).inlineSize;
|
|
78
|
+
newItemsWidths.ghost.push(width);
|
|
79
|
+
}
|
|
80
|
+
for (const node of Object.values(itemsRefs.current.real)) {
|
|
81
|
+
const width = getLogicalBoundingClientRect(node).inlineSize;
|
|
82
|
+
newItemsWidths.real.push(width);
|
|
83
|
+
}
|
|
84
|
+
setItemsWidths(oldWidths => {
|
|
85
|
+
if (!areArrayEqual(newItemsWidths.ghost, oldWidths.ghost) ||
|
|
86
|
+
!areArrayEqual(newItemsWidths.real, oldWidths.real)) {
|
|
87
|
+
return newItemsWidths;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return oldWidths;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}, [items, navWidth]);
|
|
95
|
+
const { shrinkFactors, minWidths, collapsed } = getItemsDisplayProperties(itemsWidths.ghost, navWidth);
|
|
54
96
|
let breadcrumbItems = items.map((item, index) => {
|
|
55
97
|
const isLast = index === items.length - 1;
|
|
98
|
+
const isDisplayed = index === 0 || index > collapsed;
|
|
56
99
|
const clickAnalyticsMetadata = {
|
|
57
100
|
action: 'click',
|
|
58
101
|
detail: {
|
|
@@ -61,8 +104,13 @@ export function BreadcrumbGroupImplementation(_a) {
|
|
|
61
104
|
href: item.href || '',
|
|
62
105
|
},
|
|
63
106
|
};
|
|
64
|
-
return (React.createElement("li", Object.assign({ className: styles.item, key: index }, (isLast ? {} : getAnalyticsMetadataAttribute(clickAnalyticsMetadata))),
|
|
65
|
-
React.createElement(BreadcrumbItem, { item: item, onClick: onClick, onFollow: onFollow,
|
|
107
|
+
return (React.createElement("li", Object.assign({ className: clsx(styles.item, !isDisplayed && styles.hide), key: index }, (isLast ? {} : getAnalyticsMetadataAttribute(clickAnalyticsMetadata)), { style: { flexShrink: shrinkFactors[index], minWidth: `${minWidths[index]}px` }, ref: node => setBreadcrumb('real', `${index}`, node) }),
|
|
108
|
+
React.createElement(BreadcrumbItem, { item: item, onClick: onClick, onFollow: onFollow, isLast: isLast, isTruncated: itemsWidths.ghost[index] - itemsWidths.real[index] > 0 })));
|
|
109
|
+
});
|
|
110
|
+
const hiddenBreadcrumbItems = items.map((item, index) => {
|
|
111
|
+
const isLast = index === items.length - 1;
|
|
112
|
+
return (React.createElement("li", { className: styles.item, key: index, ref: node => setBreadcrumb('ghost', `${index}`, node) },
|
|
113
|
+
React.createElement(BreadcrumbItem, { item: item, isLast: isLast, isGhost: true })));
|
|
66
114
|
});
|
|
67
115
|
const getEventItem = (e) => {
|
|
68
116
|
const { id } = e.detail;
|
|
@@ -71,7 +119,7 @@ export function BreadcrumbGroupImplementation(_a) {
|
|
|
71
119
|
// Add ellipsis
|
|
72
120
|
if (breadcrumbItems.length >= 2) {
|
|
73
121
|
const dropdownItems = items
|
|
74
|
-
.slice(1,
|
|
122
|
+
.slice(1, 1 + collapsed)
|
|
75
123
|
.map((item, index) => ({
|
|
76
124
|
id: (index + 1).toString(),
|
|
77
125
|
text: item.text,
|
|
@@ -79,7 +127,7 @@ export function BreadcrumbGroupImplementation(_a) {
|
|
|
79
127
|
}));
|
|
80
128
|
breadcrumbItems = [
|
|
81
129
|
breadcrumbItems[0],
|
|
82
|
-
React.createElement(EllipsisDropdown, { key: 'ellipsis', ariaLabel: expandAriaLabel, dropdownItems: dropdownItems, onDropdownItemClick: e => fireCancelableEvent(onClick, getEventDetail(getEventItem(e)), e), onDropdownItemFollow: e => fireCancelableEvent(onFollow, getEventDetail(getEventItem(e)), e) }),
|
|
130
|
+
React.createElement(EllipsisDropdown, { key: 'ellipsis', visible: collapsed > 0, ariaLabel: expandAriaLabel, dropdownItems: dropdownItems, onDropdownItemClick: e => fireCancelableEvent(onClick, getEventDetail(getEventItem(e)), e), onDropdownItemFollow: e => fireCancelableEvent(onFollow, getEventDetail(getEventItem(e)), e) }),
|
|
83
131
|
...breadcrumbItems.slice(1),
|
|
84
132
|
];
|
|
85
133
|
}
|
|
@@ -87,11 +135,12 @@ export function BreadcrumbGroupImplementation(_a) {
|
|
|
87
135
|
name: 'awsui.BreadcrumbGroup',
|
|
88
136
|
label: { root: 'self' },
|
|
89
137
|
};
|
|
90
|
-
return (React.createElement("nav", Object.assign({}, baseProps, { className: clsx(styles['breadcrumb-group'],
|
|
138
|
+
return (React.createElement("nav", Object.assign({}, baseProps, { className: clsx(styles['breadcrumb-group'], baseProps.className), "aria-label": ariaLabel || undefined, ref: mergedRef }, (__injectAnalyticsComponentMetadata
|
|
91
139
|
? Object.assign({}, getAnalyticsMetadataAttribute({
|
|
92
140
|
component: componentAnalyticsMetadata,
|
|
93
141
|
})) : {})),
|
|
94
|
-
React.createElement("ol", { className: styles['breadcrumb-group-list'] }, breadcrumbItems)
|
|
142
|
+
React.createElement("ol", { className: styles['breadcrumb-group-list'] }, breadcrumbItems),
|
|
143
|
+
React.createElement("ol", { className: clsx(styles['breadcrumb-group-list'], styles.ghost), "aria-hidden": true, tabIndex: -1 }, hiddenBreadcrumbItems)));
|
|
95
144
|
}
|
|
96
145
|
export const createWidgetizedBreadcrumbGroup = createWidgetizedComponent(BreadcrumbGroupImplementation);
|
|
97
146
|
//# sourceMappingURL=implementation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/breadcrumb-group/implementation.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,sBAAsB,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAMhE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,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AAoB,EAAE,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,QAAQ,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5F;YACF,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;SAC5B,CAAC;KACH;IAED,MAAM,0BAA0B,GAAuD;QACrF,IAAI,EAAE,uBAAuB;QAC7B,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;KACxB,CAAC;IAEF,OAAO,CACL,6CACM,SAAS,IACb,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,kBAAkB,CAAC,EAC1B,QAAQ,IAAI,MAAM,CAAC,MAAM,EACzB,KAAK,CAAC,MAAM,IAAI,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC,EAC3C,SAAS,CAAC,SAAS,CACpB,gBACW,SAAS,IAAI,SAAS,EAClC,GAAG,EAAE,iBAAiB,IAClB,CAAC,kCAAkC;QACrC,CAAC,mBACM,6BAA6B,CAAC;YAC/B,SAAS,EAAE,0BAA0B;SACtC,CAAC,EAEN,CAAC,CAAC,EAAE,CAAC;QAEP,4BAAI,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,IAAG,eAAe,CAAM,CAClE,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,yBAAyB,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { InternalButton } from '../button/internal';\nimport { CustomTriggerProps, LinkItem } from '../button-dropdown/interfaces';\nimport InternalButtonDropdown from '../button-dropdown/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport InternalIcon from '../icon/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireCancelableEvent } from '../internal/events';\nimport { useMobile } from '../internal/hooks/use-mobile';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { createWidgetizedComponent } from '../internal/widgets';\nimport {\n GeneratedAnalyticsMetadataBreadcrumbGroupClick,\n GeneratedAnalyticsMetadataBreadcrumbGroupComponent,\n} from './analytics-metadata/interfaces';\nimport { BreadcrumbGroupProps, EllipsisDropdownProps, InternalBreadcrumbGroupProps } from './interfaces';\nimport { BreadcrumbItem } from './item/item';\nimport { getEventDetail } from './utils';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\n/**\n * Provided for backwards compatibility\n */\nconst DEFAULT_EXPAND_ARIA_LABEL = 'Show path';\n\nconst getDropdownTrigger = ({\n ariaLabel,\n triggerRef,\n disabled,\n testUtilsClass,\n isOpen,\n onClick,\n}: CustomTriggerProps) => {\n return (\n <InternalButton\n ref={triggerRef}\n className={testUtilsClass}\n disabled={disabled}\n onClick={event => {\n event.preventDefault();\n onClick();\n }}\n ariaExpanded={isOpen}\n aria-haspopup={true}\n ariaLabel={ariaLabel}\n variant=\"breadcrumb-group\"\n formAction=\"none\"\n >\n ...\n </InternalButton>\n );\n};\n\nconst EllipsisDropdown = ({\n ariaLabel,\n dropdownItems,\n onDropdownItemClick,\n onDropdownItemFollow,\n}: EllipsisDropdownProps) => {\n const i18n = useInternalI18n('breadcrumb-group');\n\n return (\n <li className={styles.ellipsis}>\n <InternalButtonDropdown\n ariaLabel={i18n('expandAriaLabel', ariaLabel) ?? DEFAULT_EXPAND_ARIA_LABEL}\n items={dropdownItems}\n onItemClick={onDropdownItemClick}\n onItemFollow={onDropdownItemFollow}\n customTriggerBuilder={getDropdownTrigger}\n linkStyle={true}\n analyticsMetadataTransformer={metadata => {\n if (metadata.detail?.id) {\n delete metadata.detail.id;\n }\n if (metadata.detail?.position) {\n metadata.detail.position = `${parseInt(metadata.detail.position as string, 10) + 1}`;\n }\n return metadata;\n }}\n />\n <span className={styles.icon}>\n <InternalIcon name=\"angle-right\" />\n </span>\n </li>\n );\n};\n\nexport function BreadcrumbGroupImplementation<T extends BreadcrumbGroupProps.Item = BreadcrumbGroupProps.Item>({\n items = [],\n ariaLabel,\n expandAriaLabel,\n onClick,\n onFollow,\n __internalRootRef,\n __injectAnalyticsComponentMetadata,\n ...props\n}: InternalBreadcrumbGroupProps<T>) {\n for (const item of items) {\n checkSafeUrl('BreadcrumbGroup', item.href);\n }\n const baseProps = getBaseProps(props);\n const isMobile = useMobile();\n\n let breadcrumbItems = items.map((item, index) => {\n const isLast = index === items.length - 1;\n\n const clickAnalyticsMetadata: GeneratedAnalyticsMetadataBreadcrumbGroupClick = {\n action: 'click',\n detail: {\n position: `${index + 1}`,\n label: `.${analyticsSelectors['breadcrumb-item']}`,\n href: item.href || '',\n },\n };\n\n return (\n <li\n className={styles.item}\n key={index}\n {...(isLast ? {} : getAnalyticsMetadataAttribute(clickAnalyticsMetadata))}\n >\n <BreadcrumbItem\n item={item}\n onClick={onClick}\n onFollow={onFollow}\n isCompressed={isMobile}\n isLast={isLast}\n isDisplayed={!isMobile || isLast || index === 0}\n />\n </li>\n );\n });\n\n const getEventItem = (e: CustomEvent<{ id: string }>) => {\n const { id } = e.detail;\n return items[parseInt(id)];\n };\n\n // Add ellipsis\n if (breadcrumbItems.length >= 2) {\n const dropdownItems: Array<LinkItem> = items\n .slice(1, items.length - 1)\n .map((item: BreadcrumbGroupProps.Item, index: number) => ({\n id: (index + 1).toString(), // the first item doesn't get inside dropdown\n text: item.text,\n href: item.href || '#',\n }));\n\n breadcrumbItems = [\n breadcrumbItems[0],\n <EllipsisDropdown\n key={'ellipsis'}\n ariaLabel={expandAriaLabel}\n dropdownItems={dropdownItems}\n onDropdownItemClick={e => fireCancelableEvent(onClick, getEventDetail(getEventItem(e)), e)}\n onDropdownItemFollow={e => fireCancelableEvent(onFollow, getEventDetail(getEventItem(e)), e)}\n />,\n ...breadcrumbItems.slice(1),\n ];\n }\n\n const componentAnalyticsMetadata: GeneratedAnalyticsMetadataBreadcrumbGroupComponent = {\n name: 'awsui.BreadcrumbGroup',\n label: { root: 'self' },\n };\n\n return (\n <nav\n {...baseProps}\n className={clsx(\n styles['breadcrumb-group'],\n isMobile && styles.mobile,\n items.length <= 2 && styles['mobile-short'],\n baseProps.className\n )}\n aria-label={ariaLabel || undefined}\n ref={__internalRootRef}\n {...(__injectAnalyticsComponentMetadata\n ? {\n ...getAnalyticsMetadataAttribute({\n component: componentAnalyticsMetadata,\n }),\n }\n : {})}\n >\n <ol className={styles['breadcrumb-group-list']}>{breadcrumbItems}</ol>\n </nav>\n );\n}\n\nexport const createWidgetizedBreadcrumbGroup = createWidgetizedComponent(BreadcrumbGroupImplementation);\n"]}
|
|
1
|
+
{"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../../src/breadcrumb-group/implementation.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAC7F,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,sBAAsB,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAk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AE,0BAA0B;SACtC,CAAC,EAEN,CAAC,CAAC,EAAE,CAAC;QAEP,4BAAI,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,IAAG,eAAe,CAAM;QACtE,4BAAI,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,iBAAe,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,IAChG,qBAAqB,CACnB,CACD,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,yBAAyB,CAAC,6BAA6B,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { InternalButton } from '../button/internal';\nimport { CustomTriggerProps, LinkItem } from '../button-dropdown/interfaces';\nimport InternalButtonDropdown from '../button-dropdown/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport InternalIcon from '../icon/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireCancelableEvent } from '../internal/events';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { createWidgetizedComponent } from '../internal/widgets';\nimport {\n GeneratedAnalyticsMetadataBreadcrumbGroupClick,\n GeneratedAnalyticsMetadataBreadcrumbGroupComponent,\n} from './analytics-metadata/interfaces';\nimport { BreadcrumbGroupProps, EllipsisDropdownProps, InternalBreadcrumbGroupProps } from './interfaces';\nimport { BreadcrumbItem } from './item/item';\nimport { getEventDetail, getItemsDisplayProperties } from './utils';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\n/**\n * Provided for backwards compatibility\n */\nconst DEFAULT_EXPAND_ARIA_LABEL = 'Show path';\n\nconst getDropdownTrigger = ({\n ariaLabel,\n triggerRef,\n disabled,\n testUtilsClass,\n isOpen,\n onClick,\n}: CustomTriggerProps) => {\n return (\n <InternalButton\n ref={triggerRef}\n className={testUtilsClass}\n disabled={disabled}\n onClick={event => {\n event.preventDefault();\n onClick();\n }}\n ariaExpanded={isOpen}\n aria-haspopup={true}\n ariaLabel={ariaLabel}\n variant=\"breadcrumb-group\"\n formAction=\"none\"\n >\n ...\n </InternalButton>\n );\n};\n\nconst EllipsisDropdown = ({\n ariaLabel,\n dropdownItems,\n onDropdownItemClick,\n onDropdownItemFollow,\n visible,\n}: EllipsisDropdownProps) => {\n const i18n = useInternalI18n('breadcrumb-group');\n\n return (\n <li className={clsx(styles.ellipsis, visible && styles.visible)}>\n <InternalButtonDropdown\n ariaLabel={i18n('expandAriaLabel', ariaLabel) ?? DEFAULT_EXPAND_ARIA_LABEL}\n items={dropdownItems}\n onItemClick={onDropdownItemClick}\n onItemFollow={onDropdownItemFollow}\n customTriggerBuilder={getDropdownTrigger}\n linkStyle={true}\n analyticsMetadataTransformer={metadata => {\n if (metadata.detail?.id) {\n delete metadata.detail.id;\n }\n if (metadata.detail?.position) {\n metadata.detail.position = `${parseInt(metadata.detail.position as string, 10) + 1}`;\n }\n return metadata;\n }}\n />\n <span className={styles.icon}>\n <InternalIcon name=\"angle-right\" />\n </span>\n </li>\n );\n};\n\ninterface ItemsRefsType {\n ghost: Record<string, HTMLLIElement>;\n real: Record<string, HTMLLIElement>;\n}\n\ninterface ItemsWidthsType {\n ghost: Array<number>;\n real: Array<number>;\n}\n\nconst areArrayEqual = (first: Array<number>, second: Array<number>) => {\n if (first.length !== second.length) {\n return false;\n }\n return first.every((item, index) => item === second[index]);\n};\n\nexport function BreadcrumbGroupImplementation<T extends BreadcrumbGroupProps.Item = BreadcrumbGroupProps.Item>({\n items = [],\n ariaLabel,\n expandAriaLabel,\n onClick,\n onFollow,\n __internalRootRef,\n __injectAnalyticsComponentMetadata,\n ...props\n}: InternalBreadcrumbGroupProps<T>) {\n for (const item of items) {\n checkSafeUrl('BreadcrumbGroup', item.href);\n }\n const baseProps = getBaseProps(props);\n const [navWidth, navRef] = useContainerQuery<number>(rect => rect.borderBoxWidth);\n const mergedRef = useMergeRefs(navRef, __internalRootRef);\n\n const itemsRefs = useRef<ItemsRefsType>({ ghost: {}, real: {} });\n const setBreadcrumb = (type: keyof ItemsRefsType, index: string, node: null | HTMLLIElement) => {\n if (node) {\n itemsRefs.current[type][index] = node;\n } else {\n delete itemsRefs.current[type][index];\n }\n };\n\n const [itemsWidths, setItemsWidths] = useState<ItemsWidthsType>({ ghost: [], real: [] });\n\n useEffect(() => {\n if (itemsRefs.current) {\n const newItemsWidths: ItemsWidthsType = { ghost: [], real: [] };\n for (const node of Object.values(itemsRefs.current.ghost)) {\n const width = getLogicalBoundingClientRect(node).inlineSize;\n newItemsWidths.ghost.push(width);\n }\n for (const node of Object.values(itemsRefs.current.real)) {\n const width = getLogicalBoundingClientRect(node).inlineSize;\n newItemsWidths.real.push(width);\n }\n setItemsWidths(oldWidths => {\n if (\n !areArrayEqual(newItemsWidths.ghost, oldWidths.ghost) ||\n !areArrayEqual(newItemsWidths.real, oldWidths.real)\n ) {\n return newItemsWidths;\n } else {\n return oldWidths;\n }\n });\n }\n }, [items, navWidth]);\n\n const { shrinkFactors, minWidths, collapsed } = getItemsDisplayProperties(itemsWidths.ghost, navWidth);\n\n let breadcrumbItems = items.map((item, index) => {\n const isLast = index === items.length - 1;\n const isDisplayed = index === 0 || index > collapsed;\n\n const clickAnalyticsMetadata: GeneratedAnalyticsMetadataBreadcrumbGroupClick = {\n action: 'click',\n detail: {\n position: `${index + 1}`,\n label: `.${analyticsSelectors['breadcrumb-item']}`,\n href: item.href || '',\n },\n };\n return (\n <li\n className={clsx(styles.item, !isDisplayed && styles.hide)}\n key={index}\n {...(isLast ? {} : getAnalyticsMetadataAttribute(clickAnalyticsMetadata))}\n style={{ flexShrink: shrinkFactors[index], minWidth: `${minWidths[index]}px` }}\n ref={node => setBreadcrumb('real', `${index}`, node)}\n >\n <BreadcrumbItem\n item={item}\n onClick={onClick}\n onFollow={onFollow}\n isLast={isLast}\n isTruncated={itemsWidths.ghost[index] - itemsWidths.real[index] > 0}\n />\n </li>\n );\n });\n\n const hiddenBreadcrumbItems = items.map((item, index) => {\n const isLast = index === items.length - 1;\n return (\n <li className={styles.item} key={index} ref={node => setBreadcrumb('ghost', `${index}`, node)}>\n <BreadcrumbItem item={item} isLast={isLast} isGhost={true} />\n </li>\n );\n });\n\n const getEventItem = (e: CustomEvent<{ id: string }>) => {\n const { id } = e.detail;\n return items[parseInt(id)];\n };\n\n // Add ellipsis\n if (breadcrumbItems.length >= 2) {\n const dropdownItems: Array<LinkItem> = items\n .slice(1, 1 + collapsed)\n .map((item: BreadcrumbGroupProps.Item, index: number) => ({\n id: (index + 1).toString(), // the first item doesn't get inside dropdown\n text: item.text,\n href: item.href || '#',\n }));\n\n breadcrumbItems = [\n breadcrumbItems[0],\n <EllipsisDropdown\n key={'ellipsis'}\n visible={collapsed > 0}\n ariaLabel={expandAriaLabel}\n dropdownItems={dropdownItems}\n onDropdownItemClick={e => fireCancelableEvent(onClick, getEventDetail(getEventItem(e)), e)}\n onDropdownItemFollow={e => fireCancelableEvent(onFollow, getEventDetail(getEventItem(e)), e)}\n />,\n ...breadcrumbItems.slice(1),\n ];\n }\n\n const componentAnalyticsMetadata: GeneratedAnalyticsMetadataBreadcrumbGroupComponent = {\n name: 'awsui.BreadcrumbGroup',\n label: { root: 'self' },\n };\n\n return (\n <nav\n {...baseProps}\n className={clsx(styles['breadcrumb-group'], baseProps.className)}\n aria-label={ariaLabel || undefined}\n ref={mergedRef}\n {...(__injectAnalyticsComponentMetadata\n ? {\n ...getAnalyticsMetadataAttribute({\n component: componentAnalyticsMetadata,\n }),\n }\n : {})}\n >\n <ol className={styles['breadcrumb-group-list']}>{breadcrumbItems}</ol>\n <ol className={clsx(styles['breadcrumb-group-list'], styles.ghost)} aria-hidden={true} tabIndex={-1}>\n {hiddenBreadcrumbItems}\n </ol>\n </nav>\n );\n}\n\nexport const createWidgetizedBreadcrumbGroup = createWidgetizedComponent(BreadcrumbGroupImplementation);\n"]}
|
|
@@ -51,9 +51,9 @@ export type InternalBreadcrumbGroupProps<T extends BreadcrumbGroupProps.Item = B
|
|
|
51
51
|
};
|
|
52
52
|
export interface BreadcrumbItemProps<T extends BreadcrumbGroupProps.Item> {
|
|
53
53
|
item: T;
|
|
54
|
-
|
|
54
|
+
isTruncated?: boolean;
|
|
55
55
|
isLast?: boolean;
|
|
56
|
-
|
|
56
|
+
isGhost?: boolean;
|
|
57
57
|
onClick?: CancelableEventHandler<BreadcrumbGroupProps.ClickDetail<T>>;
|
|
58
58
|
onFollow?: CancelableEventHandler<BreadcrumbGroupProps.ClickDetail<T>>;
|
|
59
59
|
}
|
|
@@ -66,5 +66,6 @@ export interface EllipsisDropdownProps {
|
|
|
66
66
|
onDropdownItemFollow: CancelableEventHandler<{
|
|
67
67
|
id: string;
|
|
68
68
|
}>;
|
|
69
|
+
visible?: boolean;
|
|
69
70
|
}
|
|
70
71
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/breadcrumb-group/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,oBAAoB,CAAC,IAAI,GAAG,oBAAoB,CAAC,IAAI,CAC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W,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,sBAAsB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,QAAQ,CAAC,EAAE,sBAAsB,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;CACxE;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IACpD,aAAa,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACvC,mBAAmB,EAAE,sBAAsB,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5D,oBAAoB,EAAE,sBAAsB,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/breadcrumb-group/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { LinkItem } from '../button-dropdown/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { BaseNavigationDetail, CancelableEventHandler } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\n\nexport interface BreadcrumbGroupProps<T extends BreadcrumbGroupProps.Item = BreadcrumbGroupProps.Item>\n extends BaseComponentProps {\n /**\n * An array of breadcrumb items that describes the link hierarchy for this navigation.\n * Each option has the following properties:\n\n * * `text` (string) - Specifies the title text of the breadcrumb item.\n * * `href` (string) - Specifies the URL for the link in the breadcrumb item.\n * You should specify the link even if you have a click handler for a breadcrumb item\n * to ensure that valid markup is generated.\n\n * Note: The last breadcrumb item is automatically considered the current item, and it's\n * not a link.\n */\n items: ReadonlyArray<T>;\n /**\n * Provides an `aria-label` to the breadcrumb group that screen readers can read (for accessibility).\n */\n ariaLabel?: string;\n\n /**\n * Provides an `aria-label` to the ellipsis button that screen readers can read (for accessibility).\n * @i18n\n */\n expandAriaLabel?: string;\n /**\n * Called when the user clicks on a breadcrumb item.\n */\n onClick?: CancelableEventHandler<BreadcrumbGroupProps.ClickDetail<T>>;\n /**\n * Called when the user clicks on a breadcrumb item with the left mouse button\n * without pressing modifier keys (that is, CTRL, ALT, SHIFT, META).\n */\n onFollow?: CancelableEventHandler<BreadcrumbGroupProps.ClickDetail<T>>;\n}\n\nexport namespace BreadcrumbGroupProps {\n export interface Item {\n text: string;\n href: string;\n }\n\n export interface ClickDetail<T extends BreadcrumbGroupProps.Item = BreadcrumbGroupProps.Item>\n extends BaseNavigationDetail {\n item: T;\n text: string;\n href: string;\n }\n}\n\nexport type InternalBreadcrumbGroupProps<T extends BreadcrumbGroupProps.Item = BreadcrumbGroupProps.Item> =\n BreadcrumbGroupProps<T> &\n InternalBaseComponentProps & {\n __injectAnalyticsComponentMetadata?: boolean;\n };\n\nexport interface BreadcrumbItemProps<T extends BreadcrumbGroupProps.Item> {\n item: T;\n
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/breadcrumb-group/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { LinkItem } from '../button-dropdown/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { BaseNavigationDetail, CancelableEventHandler } from '../internal/events';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\n\nexport interface BreadcrumbGroupProps<T extends BreadcrumbGroupProps.Item = BreadcrumbGroupProps.Item>\n extends BaseComponentProps {\n /**\n * An array of breadcrumb items that describes the link hierarchy for this navigation.\n * Each option has the following properties:\n\n * * `text` (string) - Specifies the title text of the breadcrumb item.\n * * `href` (string) - Specifies the URL for the link in the breadcrumb item.\n * You should specify the link even if you have a click handler for a breadcrumb item\n * to ensure that valid markup is generated.\n\n * Note: The last breadcrumb item is automatically considered the current item, and it's\n * not a link.\n */\n items: ReadonlyArray<T>;\n /**\n * Provides an `aria-label` to the breadcrumb group that screen readers can read (for accessibility).\n */\n ariaLabel?: string;\n\n /**\n * Provides an `aria-label` to the ellipsis button that screen readers can read (for accessibility).\n * @i18n\n */\n expandAriaLabel?: string;\n /**\n * Called when the user clicks on a breadcrumb item.\n */\n onClick?: CancelableEventHandler<BreadcrumbGroupProps.ClickDetail<T>>;\n /**\n * Called when the user clicks on a breadcrumb item with the left mouse button\n * without pressing modifier keys (that is, CTRL, ALT, SHIFT, META).\n */\n onFollow?: CancelableEventHandler<BreadcrumbGroupProps.ClickDetail<T>>;\n}\n\nexport namespace BreadcrumbGroupProps {\n export interface Item {\n text: string;\n href: string;\n }\n\n export interface ClickDetail<T extends BreadcrumbGroupProps.Item = BreadcrumbGroupProps.Item>\n extends BaseNavigationDetail {\n item: T;\n text: string;\n href: string;\n }\n}\n\nexport type InternalBreadcrumbGroupProps<T extends BreadcrumbGroupProps.Item = BreadcrumbGroupProps.Item> =\n BreadcrumbGroupProps<T> &\n InternalBaseComponentProps & {\n __injectAnalyticsComponentMetadata?: boolean;\n };\n\nexport interface BreadcrumbItemProps<T extends BreadcrumbGroupProps.Item> {\n item: T;\n isTruncated?: boolean;\n isLast?: boolean;\n isGhost?: boolean;\n onClick?: CancelableEventHandler<BreadcrumbGroupProps.ClickDetail<T>>;\n onFollow?: CancelableEventHandler<BreadcrumbGroupProps.ClickDetail<T>>;\n}\n\nexport interface EllipsisDropdownProps {\n ariaLabel?: BreadcrumbGroupProps['expandAriaLabel'];\n dropdownItems: ReadonlyArray<LinkItem>;\n onDropdownItemClick: CancelableEventHandler<{ id: string }>;\n onDropdownItemFollow: CancelableEventHandler<{ id: string }>;\n visible?: boolean;\n}\n"]}
|
|
@@ -3,6 +3,7 @@ interface FunnelBreadcrumbItemProps {
|
|
|
3
3
|
text: string;
|
|
4
4
|
last: boolean;
|
|
5
5
|
hidden?: boolean;
|
|
6
|
+
ghost?: boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare const FunnelBreadcrumbItem: React.ForwardRefExoticComponent<FunnelBreadcrumbItemProps & React.RefAttributes<HTMLSpanElement>>;
|
|
8
9
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"funnel.d.ts","sourceRoot":"","sources":["../../../../src/breadcrumb-group/item/funnel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,UAAU,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"funnel.d.ts","sourceRoot":"","sources":["../../../../src/breadcrumb-group/item/funnel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,UAAU,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,eAAO,MAAM,oBAAoB,mGAiBhC,CAAC"}
|
|
@@ -5,11 +5,11 @@ import clsx from 'clsx';
|
|
|
5
5
|
import { DATA_ATTR_FUNNEL_KEY, FUNNEL_KEY_FUNNEL_NAME } from '../../internal/analytics/selectors';
|
|
6
6
|
import analyticsSelectors from '../analytics-metadata/styles.css.js';
|
|
7
7
|
import styles from './styles.css.js';
|
|
8
|
-
export const FunnelBreadcrumbItem = React.forwardRef(({ text, hidden, last }, ref) => {
|
|
8
|
+
export const FunnelBreadcrumbItem = React.forwardRef(({ text, hidden, last, ghost }, ref) => {
|
|
9
9
|
const funnelAttributes = {};
|
|
10
|
-
if (last) {
|
|
10
|
+
if (last && !ghost) {
|
|
11
11
|
funnelAttributes[DATA_ATTR_FUNNEL_KEY] = FUNNEL_KEY_FUNNEL_NAME;
|
|
12
12
|
}
|
|
13
|
-
return (React.createElement("span", Object.assign({}, funnelAttributes, { className: clsx(styles.text, hidden && styles['text-hidden'], analyticsSelectors['breadcrumb-item']), ref: ref }), text));
|
|
13
|
+
return (React.createElement("span", Object.assign({}, funnelAttributes, { className: clsx(styles.text, hidden && styles['text-hidden'], !ghost && analyticsSelectors['breadcrumb-item']), ref: ref }), text));
|
|
14
14
|
});
|
|
15
15
|
//# sourceMappingURL=funnel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"funnel.js","sourceRoot":"","sources":["../../../../src/breadcrumb-group/item/funnel.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAElG,OAAO,kBAAkB,MAAM,qCAAqC,CAAC;AACrE,OAAO,MAAM,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"funnel.js","sourceRoot":"","sources":["../../../../src/breadcrumb-group/item/funnel.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAElG,OAAO,kBAAkB,MAAM,qCAAqC,CAAC;AACrE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AASrC,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,CAAC,UAAU,CAClD,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE;IACrC,MAAM,gBAAgB,GAA2B,EAAE,CAAC;IACpD,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE;QAClB,gBAAgB,CAAC,oBAAoB,CAAC,GAAG,sBAAsB,CAAC;KACjE;IAED,OAAO,CACL,8CACM,gBAAgB,IACpB,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,IAAI,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,IAAI,kBAAkB,CAAC,iBAAiB,CAAC,CAAC,EAC9G,GAAG,EAAE,GAAG,KAEP,IAAI,CACA,CACR,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { DATA_ATTR_FUNNEL_KEY, FUNNEL_KEY_FUNNEL_NAME } from '../../internal/analytics/selectors';\n\nimport analyticsSelectors from '../analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\ninterface FunnelBreadcrumbItemProps {\n text: string;\n last: boolean;\n hidden?: boolean;\n ghost?: boolean;\n}\n\nexport const FunnelBreadcrumbItem = React.forwardRef<HTMLSpanElement, FunnelBreadcrumbItemProps>(\n ({ text, hidden, last, ghost }, ref) => {\n const funnelAttributes: Record<string, string> = {};\n if (last && !ghost) {\n funnelAttributes[DATA_ATTR_FUNNEL_KEY] = FUNNEL_KEY_FUNNEL_NAME;\n }\n\n return (\n <span\n {...funnelAttributes}\n className={clsx(styles.text, hidden && styles['text-hidden'], !ghost && analyticsSelectors['breadcrumb-item'])}\n ref={ref}\n >\n {text}\n </span>\n );\n }\n);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BreadcrumbGroupProps, BreadcrumbItemProps } from '../interfaces';
|
|
3
|
-
export declare function BreadcrumbItem<T extends BreadcrumbGroupProps.Item>({ item, onClick, onFollow,
|
|
3
|
+
export declare function BreadcrumbItem<T extends BreadcrumbGroupProps.Item>({ item, onClick, onFollow, isLast, isGhost, isTruncated, }: BreadcrumbItemProps<T>): JSX.Element;
|
|
4
4
|
//# sourceMappingURL=item.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../../src/breadcrumb-group/item/item.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../../src/breadcrumb-group/item/item.tsx"],"names":[],"mappings":";AASA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAkE1E,wBAAgB,cAAc,CAAC,CAAC,SAAS,oBAAoB,CAAC,IAAI,EAAE,EAClE,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,MAAc,EACd,OAAe,EACf,WAAmB,GACpB,EAAE,mBAAmB,CAAC,CAAC,CAAC,eAiCxB"}
|
|
@@ -5,55 +5,36 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import InternalIcon from '../../icon/internal';
|
|
7
7
|
import Tooltip from '../../internal/components/tooltip';
|
|
8
|
+
import { registerTooltip } from '../../internal/components/tooltip/registry';
|
|
8
9
|
import { fireCancelableEvent, isPlainLeftClick } from '../../internal/events';
|
|
9
10
|
import { getEventDetail } from '../utils';
|
|
10
11
|
import { FunnelBreadcrumbItem } from './funnel';
|
|
11
12
|
import styles from './styles.css.js';
|
|
12
|
-
const BreadcrumbItemWithPopover = (
|
|
13
|
-
var { item, isLast, anchorAttributes } = _a, itemAttributes = __rest(_a, ["item", "isLast", "anchorAttributes"]);
|
|
13
|
+
const BreadcrumbItemWithPopover = ({ item, isLast, anchorAttributes, }) => {
|
|
14
14
|
const [showPopover, setShowPopover] = useState(false);
|
|
15
15
|
const textRef = useRef(null);
|
|
16
|
-
const
|
|
17
|
-
const isTruncated = (textRef, virtualTextRef) => {
|
|
18
|
-
if (!textRef || !virtualTextRef || !textRef.current || !virtualTextRef.current) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
const virtualTextWidth = virtualTextRef.current.getBoundingClientRect().width;
|
|
22
|
-
const textWidth = textRef.current.getBoundingClientRect().width;
|
|
23
|
-
if (virtualTextWidth > textWidth) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
};
|
|
28
|
-
const popoverContent = React.createElement(Tooltip, { trackRef: textRef, value: item.text });
|
|
16
|
+
const popoverContent = React.createElement(Tooltip, { trackRef: textRef, value: item.text, size: "medium" });
|
|
29
17
|
useEffect(() => {
|
|
30
|
-
const onKeyDown = (event) => {
|
|
31
|
-
if (event.key === 'Escape') {
|
|
32
|
-
setShowPopover(false);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
18
|
if (showPopover) {
|
|
36
|
-
|
|
19
|
+
return registerTooltip(() => {
|
|
20
|
+
setShowPopover(false);
|
|
21
|
+
});
|
|
37
22
|
}
|
|
38
|
-
return () => {
|
|
39
|
-
document.removeEventListener('keydown', onKeyDown);
|
|
40
|
-
};
|
|
41
23
|
}, [showPopover]);
|
|
42
24
|
return (React.createElement(React.Fragment, null,
|
|
43
|
-
React.createElement(Item, Object.assign({ isLast: isLast
|
|
44
|
-
|
|
25
|
+
React.createElement(Item, Object.assign({ isLast: isLast, onFocus: () => {
|
|
26
|
+
setShowPopover(true);
|
|
45
27
|
}, onBlur: () => setShowPopover(false), onMouseEnter: () => {
|
|
46
|
-
|
|
47
|
-
}, onMouseLeave: () => setShowPopover(false), anchorAttributes: anchorAttributes }),
|
|
48
|
-
React.createElement(FunnelBreadcrumbItem, { ref: textRef, text: item.text, last: isLast }),
|
|
49
|
-
React.createElement("span", { className: styles['virtual-item'], ref: virtualTextRef }, item.text)),
|
|
28
|
+
setShowPopover(true);
|
|
29
|
+
}, onMouseLeave: () => setShowPopover(false), anchorAttributes: anchorAttributes }, (isLast ? { tabIndex: 0 } : {})),
|
|
30
|
+
React.createElement(FunnelBreadcrumbItem, { ref: textRef, text: item.text, last: isLast })),
|
|
50
31
|
showPopover && popoverContent));
|
|
51
32
|
};
|
|
52
33
|
const Item = (_a) => {
|
|
53
34
|
var { anchorAttributes, children, isLast } = _a, itemAttributes = __rest(_a, ["anchorAttributes", "children", "isLast"]);
|
|
54
|
-
return isLast ? (React.createElement("span", Object.assign({}, itemAttributes), children)) : (React.createElement("a", Object.assign({}, itemAttributes, anchorAttributes), children));
|
|
35
|
+
return isLast ? (React.createElement("span", Object.assign({ className: styles.anchor }, itemAttributes), children)) : (React.createElement("a", Object.assign({ className: styles.anchor }, itemAttributes, anchorAttributes), children));
|
|
55
36
|
};
|
|
56
|
-
export function BreadcrumbItem({ item, onClick, onFollow,
|
|
37
|
+
export function BreadcrumbItem({ item, onClick, onFollow, isLast = false, isGhost = false, isTruncated = false, }) {
|
|
57
38
|
const preventDefault = (event) => event.preventDefault();
|
|
58
39
|
const onClickHandler = (event) => {
|
|
59
40
|
if (isPlainLeftClick(event)) {
|
|
@@ -61,16 +42,16 @@ export function BreadcrumbItem({ item, onClick, onFollow, isDisplayed, isLast =
|
|
|
61
42
|
}
|
|
62
43
|
fireCancelableEvent(onClick, getEventDetail(item), event);
|
|
63
44
|
};
|
|
64
|
-
const itemAttributes = {
|
|
65
|
-
className: clsx(styles.anchor, { [styles.compressed]: isCompressed }),
|
|
66
|
-
};
|
|
67
45
|
const anchorAttributes = {
|
|
68
46
|
href: item.href || '#',
|
|
69
47
|
onClick: isLast ? preventDefault : onClickHandler,
|
|
70
48
|
};
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
49
|
+
if (isGhost) {
|
|
50
|
+
anchorAttributes.tabIndex = -1;
|
|
51
|
+
}
|
|
52
|
+
return (React.createElement("div", { className: clsx(!isGhost && styles.breadcrumb, isGhost && styles['ghost-breadcrumb'], isLast && styles.last) },
|
|
53
|
+
isTruncated && !isGhost ? (React.createElement(BreadcrumbItemWithPopover, { item: item, isLast: isLast, anchorAttributes: anchorAttributes })) : (React.createElement(Item, { isLast: isLast, anchorAttributes: anchorAttributes },
|
|
54
|
+
React.createElement(FunnelBreadcrumbItem, { text: item.text, last: isLast, ghost: isGhost }))),
|
|
74
55
|
!isLast ? (React.createElement("span", { className: styles.icon },
|
|
75
56
|
React.createElement(InternalIcon, { name: "angle-right" }))) : null));
|
|
76
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sourceRoot":"","sources":["../../../../src/breadcrumb-group/item/item.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,OAAO,MAAM,mCAAmC,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAQrC,MAAM,yBAAyB,GAAG,CAAsC,
|
|
1
|
+
{"version":3,"file":"item.js","sourceRoot":"","sources":["../../../../src/breadcrumb-group/item/item.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,YAAY,MAAM,qBAAqB,CAAC;AAC/C,OAAO,OAAO,MAAM,mCAAmC,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E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ACF,IAAI,OAAO,EAAE;QACX,gBAAgB,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;KAChC;IAED,OAAO,CACL,6BAAK,SAAS,EAAE,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,UAAU,EAAE,OAAO,IAAI,MAAM,CAAC,kBAAkB,CAAC,EAAE,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC;QAC9G,WAAW,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CACzB,oBAAC,yBAAyB,IAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,GAAI,CAC9F,CAAC,CAAC,CAAC,CACF,oBAAC,IAAI,IAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB;YACtD,oBAAC,oBAAoB,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAI,CAClE,CACR;QACA,CAAC,MAAM,CAAC,CAAC,CAAC,CACT,8BAAM,SAAS,EAAE,MAAM,CAAC,IAAI;YAC1B,oBAAC,YAAY,IAAC,IAAI,EAAC,aAAa,GAAG,CAC9B,CACR,CAAC,CAAC,CAAC,IAAI,CACJ,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport InternalIcon from '../../icon/internal';\nimport Tooltip from '../../internal/components/tooltip';\nimport { registerTooltip } from '../../internal/components/tooltip/registry';\nimport { fireCancelableEvent, isPlainLeftClick } from '../../internal/events';\nimport { BreadcrumbGroupProps, BreadcrumbItemProps } from '../interfaces';\nimport { getEventDetail } from '../utils';\nimport { FunnelBreadcrumbItem } from './funnel';\n\nimport styles from './styles.css.js';\n\ninterface BreadcrumbItemWithPopoverProps<T extends BreadcrumbGroupProps.Item> {\n item: T;\n isLast: boolean;\n anchorAttributes: React.AnchorHTMLAttributes<HTMLAnchorElement>;\n}\n\nconst BreadcrumbItemWithPopover = <T extends BreadcrumbGroupProps.Item>({\n item,\n isLast,\n anchorAttributes,\n}: BreadcrumbItemWithPopoverProps<T>) => {\n const [showPopover, setShowPopover] = useState(false);\n const textRef = useRef<HTMLElement>(null);\n const popoverContent = <Tooltip trackRef={textRef} value={item.text} size=\"medium\" />;\n\n useEffect(() => {\n if (showPopover) {\n return registerTooltip(() => {\n setShowPopover(false);\n });\n }\n }, [showPopover]);\n\n return (\n <>\n <Item\n isLast={isLast}\n onFocus={() => {\n setShowPopover(true);\n }}\n onBlur={() => setShowPopover(false)}\n onMouseEnter={() => {\n setShowPopover(true);\n }}\n onMouseLeave={() => setShowPopover(false)}\n anchorAttributes={anchorAttributes}\n {...(isLast ? { tabIndex: 0 } : {})}\n >\n <FunnelBreadcrumbItem ref={textRef} text={item.text} last={isLast} />\n </Item>\n {showPopover && popoverContent}\n </>\n );\n};\n\ntype ItemProps = React.HTMLAttributes<HTMLElement> & {\n anchorAttributes: React.AnchorHTMLAttributes<HTMLAnchorElement>;\n isLast: boolean;\n};\nconst Item = ({ anchorAttributes, children, isLast, ...itemAttributes }: ItemProps) =>\n isLast ? (\n <span className={styles.anchor} {...itemAttributes}>\n {children}\n </span>\n ) : (\n <a className={styles.anchor} {...itemAttributes} {...anchorAttributes}>\n {children}\n </a>\n );\n\nexport function BreadcrumbItem<T extends BreadcrumbGroupProps.Item>({\n item,\n onClick,\n onFollow,\n isLast = false,\n isGhost = false,\n isTruncated = false,\n}: BreadcrumbItemProps<T>) {\n const preventDefault = (event: React.MouseEvent) => event.preventDefault();\n const onClickHandler = (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireCancelableEvent(onFollow, getEventDetail(item), event);\n }\n fireCancelableEvent(onClick, getEventDetail(item), event);\n };\n\n const anchorAttributes: React.AnchorHTMLAttributes<HTMLAnchorElement> = {\n href: item.href || '#',\n onClick: isLast ? preventDefault : onClickHandler,\n };\n if (isGhost) {\n anchorAttributes.tabIndex = -1;\n }\n\n return (\n <div className={clsx(!isGhost && styles.breadcrumb, isGhost && styles['ghost-breadcrumb'], isLast && styles.last)}>\n {isTruncated && !isGhost ? (\n <BreadcrumbItemWithPopover item={item} isLast={isLast} anchorAttributes={anchorAttributes} />\n ) : (\n <Item isLast={isLast} anchorAttributes={anchorAttributes}>\n <FunnelBreadcrumbItem text={item.text} last={isLast} ghost={isGhost} />\n </Item>\n )}\n {!isLast ? (\n <span className={styles.icon}>\n <InternalIcon name=\"angle-right\" />\n </span>\n ) : null}\n </div>\n );\n}\n"]}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
import './styles.scoped.css';
|
|
3
3
|
export default {
|
|
4
|
-
"link": "
|
|
5
|
-
"breadcrumb": "
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"text-hidden": "awsui_text-hidden_1kosq_15j42_227"
|
|
4
|
+
"link": "awsui_link_1kosq_e4knh_141",
|
|
5
|
+
"breadcrumb": "awsui_breadcrumb_1kosq_e4knh_145",
|
|
6
|
+
"ghost-breadcrumb": "awsui_ghost-breadcrumb_1kosq_e4knh_146",
|
|
7
|
+
"icon": "awsui_icon_1kosq_e4knh_149",
|
|
8
|
+
"anchor": "awsui_anchor_1kosq_e4knh_155",
|
|
9
|
+
"text": "awsui_text_1kosq_e4knh_202",
|
|
10
|
+
"last": "awsui_last_1kosq_e4knh_221",
|
|
11
|
+
"text-hidden": "awsui_text-hidden_1kosq_e4knh_233"
|
|
13
12
|
};
|
|
14
13
|
|
|
@@ -138,19 +138,22 @@
|
|
|
138
138
|
*/
|
|
139
139
|
/* Style used for links in slots/components that are text heavy, to help links stand out among
|
|
140
140
|
surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F73#description */
|
|
141
|
-
.
|
|
141
|
+
.awsui_link_1kosq_e4knh_141:not(#\9):after {
|
|
142
142
|
display: none;
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
.
|
|
145
|
+
.awsui_breadcrumb_1kosq_e4knh_145:not(#\9),
|
|
146
|
+
.awsui_ghost-breadcrumb_1kosq_e4knh_146:not(#\9) {
|
|
146
147
|
display: flex;
|
|
147
148
|
}
|
|
148
|
-
.
|
|
149
|
+
.awsui_breadcrumb_1kosq_e4knh_145 > .awsui_icon_1kosq_e4knh_149:not(#\9),
|
|
150
|
+
.awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_icon_1kosq_e4knh_149:not(#\9) {
|
|
149
151
|
margin-block: 0;
|
|
150
152
|
margin-inline: var(--space-xs-zb16t3, 8px);
|
|
151
153
|
color: var(--color-text-breadcrumb-icon-ma8w3r, #7d8998);
|
|
152
154
|
}
|
|
153
|
-
.
|
|
155
|
+
.awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155:not(#\9),
|
|
156
|
+
.awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155:not(#\9) {
|
|
154
157
|
color: var(--color-text-link-default-latg1a, #0972d3);
|
|
155
158
|
font-weight: inherit;
|
|
156
159
|
letter-spacing: normal;
|
|
@@ -162,32 +165,46 @@ surrounding text. (WCAG F73) https://www.w3.org/WAI/WCAG21/Techniques/failures/F
|
|
|
162
165
|
transition-duration: var(--motion-duration-refresh-only-medium-nf6485, 165ms);
|
|
163
166
|
text-underline-offset: 0.25em;
|
|
164
167
|
text-decoration-thickness: 1px;
|
|
168
|
+
min-inline-size: 0;
|
|
169
|
+
overflow: hidden;
|
|
165
170
|
}
|
|
166
171
|
@media (prefers-reduced-motion: reduce) {
|
|
167
|
-
.
|
|
172
|
+
.awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155:not(#\9),
|
|
173
|
+
.awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155:not(#\9) {
|
|
168
174
|
animation: none;
|
|
169
175
|
transition: none;
|
|
170
176
|
}
|
|
171
177
|
}
|
|
172
|
-
.awsui-motion-disabled .
|
|
178
|
+
.awsui-motion-disabled .awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155:not(#\9), .awsui-mode-entering .awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155:not(#\9), .awsui-motion-disabled .awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155:not(#\9), .awsui-mode-entering .awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155:not(#\9) {
|
|
173
179
|
animation: none;
|
|
174
180
|
transition: none;
|
|
175
181
|
}
|
|
176
|
-
.
|
|
182
|
+
.awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155:not(#\9):hover,
|
|
183
|
+
.awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155:not(#\9):hover {
|
|
177
184
|
cursor: pointer;
|
|
178
185
|
color: var(--color-text-link-hover-8j6p14, #033160);
|
|
179
186
|
}
|
|
180
|
-
.
|
|
187
|
+
.awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155:not(#\9):focus,
|
|
188
|
+
.awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155:not(#\9):focus {
|
|
181
189
|
outline: none;
|
|
182
190
|
}
|
|
183
|
-
.
|
|
191
|
+
.awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155:not(#\9):active,
|
|
192
|
+
.awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155:not(#\9):active {
|
|
184
193
|
color: var(--color-text-link-hover-8j6p14, #033160);
|
|
185
194
|
}
|
|
186
|
-
.
|
|
195
|
+
.awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155:not(#\9):active, .awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155:not(#\9):focus, .awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155:not(#\9):hover, .awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155:not(#\9):active, .awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155:not(#\9):focus, .awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155:not(#\9):hover {
|
|
187
196
|
text-decoration-line: underline;
|
|
188
197
|
text-decoration-color: currentColor;
|
|
189
198
|
}
|
|
190
|
-
|
|
199
|
+
.awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155 > .awsui_text_1kosq_e4knh_202:not(#\9),
|
|
200
|
+
.awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155 > .awsui_text_1kosq_e4knh_202:not(#\9) {
|
|
201
|
+
overflow: hidden;
|
|
202
|
+
text-overflow: ellipsis;
|
|
203
|
+
white-space: nowrap;
|
|
204
|
+
display: block;
|
|
205
|
+
}
|
|
206
|
+
body[data-awsui-focus-visible=true] .awsui_breadcrumb_1kosq_e4knh_145 > .awsui_anchor_1kosq_e4knh_155:not(#\9):focus,
|
|
207
|
+
body[data-awsui-focus-visible=true] .awsui_ghost-breadcrumb_1kosq_e4knh_146 > .awsui_anchor_1kosq_e4knh_155:not(#\9):focus {
|
|
191
208
|
outline: thin dotted;
|
|
192
209
|
outline: var(--border-link-focus-ring-outline-kkfop6, 0);
|
|
193
210
|
outline-offset: 2px;
|
|
@@ -198,34 +215,18 @@ body[data-awsui-focus-visible=true] .awsui_breadcrumb_1kosq_15j42_145 > .awsui_a
|
|
|
198
215
|
border-end-end-radius: var(--border-radius-control-default-focus-ring-u8zbsz, 4px);
|
|
199
216
|
box-shadow: 0 0 0 var(--border-link-focus-ring-shadow-spread-v8hkrl, 2px) var(--color-border-item-focused-b2ntyl, #0972d3);
|
|
200
217
|
}
|
|
201
|
-
.
|
|
218
|
+
.awsui_breadcrumb_1kosq_e4knh_145.awsui_last_1kosq_e4knh_221 > .awsui_icon_1kosq_e4knh_149:not(#\9),
|
|
219
|
+
.awsui_ghost-breadcrumb_1kosq_e4knh_146.awsui_last_1kosq_e4knh_221 > .awsui_icon_1kosq_e4knh_149:not(#\9) {
|
|
202
220
|
display: none;
|
|
203
221
|
}
|
|
204
|
-
.
|
|
222
|
+
.awsui_breadcrumb_1kosq_e4knh_145.awsui_last_1kosq_e4knh_221 > .awsui_anchor_1kosq_e4knh_155:not(#\9),
|
|
223
|
+
.awsui_ghost-breadcrumb_1kosq_e4knh_146.awsui_last_1kosq_e4knh_221 > .awsui_anchor_1kosq_e4knh_155:not(#\9) {
|
|
205
224
|
color: var(--color-text-breadcrumb-current-bnqeha, #5f6b7a);
|
|
206
225
|
font-weight: 700;
|
|
207
226
|
text-decoration: none;
|
|
208
227
|
cursor: default;
|
|
209
228
|
}
|
|
210
229
|
|
|
211
|
-
.
|
|
212
|
-
min-inline-size: 0;
|
|
213
|
-
overflow: hidden;
|
|
214
|
-
}
|
|
215
|
-
.awsui_compressed_1kosq_15j42_209 > .awsui_text_1kosq_15j42_213:not(#\9) {
|
|
216
|
-
overflow: hidden;
|
|
217
|
-
text-overflow: ellipsis;
|
|
218
|
-
white-space: nowrap;
|
|
219
|
-
display: block;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.awsui_virtual-item_1kosq_15j42_220:not(#\9) {
|
|
223
|
-
position: absolute !important;
|
|
224
|
-
inset-block-start: -9999px !important;
|
|
225
|
-
inset-inline-start: -9999px !important;
|
|
226
|
-
visibility: hidden;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.awsui_text-hidden_1kosq_15j42_227:not(#\9) {
|
|
230
|
+
.awsui_text-hidden_1kosq_e4knh_233:not(#\9) {
|
|
230
231
|
display: none;
|
|
231
232
|
}
|