@cloudscape-design/components-themeable 3.0.379 → 3.0.380
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/app-layout/visual-refresh/drawers.scss +13 -1
- package/lib/internal/scss/app-layout/visual-refresh/trigger-button.scss +21 -0
- package/lib/internal/template/app-layout/drawer/drawers-helpers.d.ts +7 -0
- package/lib/internal/template/app-layout/drawer/drawers-helpers.d.ts.map +1 -0
- package/lib/internal/template/app-layout/drawer/drawers-helpers.js +24 -0
- package/lib/internal/template/app-layout/drawer/drawers-helpers.js.map +1 -0
- package/lib/internal/template/app-layout/drawer/index.d.ts +1 -1
- package/lib/internal/template/app-layout/drawer/index.d.ts.map +1 -1
- package/lib/internal/template/app-layout/drawer/index.js +38 -9
- package/lib/internal/template/app-layout/drawer/index.js.map +1 -1
- package/lib/internal/template/app-layout/drawer/interfaces.d.ts +3 -2
- package/lib/internal/template/app-layout/drawer/interfaces.d.ts.map +1 -1
- package/lib/internal/template/app-layout/drawer/interfaces.js.map +1 -1
- package/lib/internal/template/app-layout/drawer/overflow-menu.d.ts +13 -0
- package/lib/internal/template/app-layout/drawer/overflow-menu.d.ts.map +1 -0
- package/lib/internal/template/app-layout/drawer/overflow-menu.js +17 -0
- package/lib/internal/template/app-layout/drawer/overflow-menu.js.map +1 -0
- package/lib/internal/template/app-layout/index.js +3 -1
- package/lib/internal/template/app-layout/index.js.map +1 -1
- package/lib/internal/template/app-layout/mobile-toolbar/index.d.ts +1 -0
- package/lib/internal/template/app-layout/mobile-toolbar/index.d.ts.map +1 -1
- package/lib/internal/template/app-layout/mobile-toolbar/index.js +15 -5
- package/lib/internal/template/app-layout/mobile-toolbar/index.js.map +1 -1
- package/lib/internal/template/app-layout/toggles/index.js +2 -2
- package/lib/internal/template/app-layout/toggles/index.js.map +1 -1
- package/lib/internal/template/app-layout/toggles/interfaces.d.ts +1 -0
- package/lib/internal/template/app-layout/toggles/interfaces.d.ts.map +1 -1
- package/lib/internal/template/app-layout/toggles/interfaces.js.map +1 -1
- package/lib/internal/template/app-layout/utils/use-drawers.d.ts +1 -0
- package/lib/internal/template/app-layout/utils/use-drawers.d.ts.map +1 -1
- package/lib/internal/template/app-layout/utils/use-drawers.js +1 -0
- package/lib/internal/template/app-layout/utils/use-drawers.js.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh/context.d.ts +1 -0
- package/lib/internal/template/app-layout/visual-refresh/context.d.ts.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh/context.js +1 -1
- package/lib/internal/template/app-layout/visual-refresh/context.js.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh/drawers.d.ts.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh/drawers.js +49 -17
- package/lib/internal/template/app-layout/visual-refresh/drawers.js.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh/styles.css.js +74 -69
- package/lib/internal/template/app-layout/visual-refresh/styles.scoped.css +196 -167
- package/lib/internal/template/app-layout/visual-refresh/styles.selectors.js +74 -69
- package/lib/internal/template/app-layout/visual-refresh/trigger-button.d.ts +1 -0
- package/lib/internal/template/app-layout/visual-refresh/trigger-button.d.ts.map +1 -1
- package/lib/internal/template/app-layout/visual-refresh/trigger-button.js +8 -5
- package/lib/internal/template/app-layout/visual-refresh/trigger-button.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/popover/interfaces.d.ts +4 -0
- package/lib/internal/template/popover/interfaces.d.ts.map +1 -1
- package/lib/internal/template/popover/interfaces.js.map +1 -1
- package/lib/internal/template/popover/internal.js +2 -2
- package/lib/internal/template/popover/internal.js.map +1 -1
- package/package.json +1 -1
|
@@ -85,6 +85,10 @@
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
.drawers-mobile-triggers-container {
|
|
89
|
+
display: flex;
|
|
90
|
+
}
|
|
91
|
+
|
|
88
92
|
.drawers-trigger-content {
|
|
89
93
|
align-items: center;
|
|
90
94
|
display: flex;
|
|
@@ -105,12 +109,20 @@
|
|
|
105
109
|
transition-delay: calc(awsui.$motion-duration-refresh-only-fast / 1.5);
|
|
106
110
|
}
|
|
107
111
|
}
|
|
112
|
+
|
|
113
|
+
> .drawers-trigger-overflow {
|
|
114
|
+
padding: 0 1px;
|
|
115
|
+
display: flex;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
}
|
|
108
119
|
}
|
|
109
120
|
|
|
110
121
|
.drawers-trigger {
|
|
111
122
|
@include styles.media-breakpoint-down(styles.$breakpoint-x-small) {
|
|
112
123
|
width: constants.$sidebar-size-closed;
|
|
113
|
-
|
|
124
|
+
display: flex;
|
|
125
|
+
justify-content: center;
|
|
114
126
|
}
|
|
115
127
|
}
|
|
116
128
|
|
|
@@ -23,6 +23,7 @@ handleSplitPanelMaxWidth function in the context.
|
|
|
23
23
|
padding: 0 awsui.$space-s;
|
|
24
24
|
pointer-events: auto;
|
|
25
25
|
width: awsui.$space-layout-toggle-diameter;
|
|
26
|
+
position: relative;
|
|
26
27
|
|
|
27
28
|
@include focus-visible.when-visible {
|
|
28
29
|
@include styles.focus-highlight(3px);
|
|
@@ -51,4 +52,24 @@ handleSplitPanelMaxWidth function in the context.
|
|
|
51
52
|
background: awsui.$color-background-layout-toggle-selected-active;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
55
|
+
|
|
56
|
+
&.badge {
|
|
57
|
+
clip-path: path(
|
|
58
|
+
'M38.0215 11.3161C37.1068 11.7545 36.0821 12 35 12C31.134 12 28 8.86599 28 5C28 3.91794 28.2455 2.89322 28.6839 1.97851C26.0575 0.710652 23.1118 0 20 0C8.9543 0 0 8.9543 0 20C0 31.0457 8.9543 40 20 40C31.0457 40 40 31.0457 40 20C40 16.8882 39.2893 13.9425 38.0215 11.3161Z'
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.trigger-wrapper {
|
|
64
|
+
position: relative;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.dot {
|
|
68
|
+
position: absolute;
|
|
69
|
+
width: 10px;
|
|
70
|
+
height: 10px;
|
|
71
|
+
border-radius: 8px;
|
|
72
|
+
background-color: awsui.$color-background-badge-icon;
|
|
73
|
+
top: 0;
|
|
74
|
+
right: 0;
|
|
54
75
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function splitItems<T extends {
|
|
2
|
+
id: string;
|
|
3
|
+
}>(maybeItems: Array<T> | undefined, splitIndex: number, activeId: string | null | undefined, isMobile?: boolean): {
|
|
4
|
+
visibleItems: T[];
|
|
5
|
+
overflowItems: T[];
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=drawers-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawers-helpers.d.ts","sourceRoot":"lib/default/","sources":["app-layout/drawer/drawers-helpers.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACjD,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,EAChC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,QAAQ,UAAQ;;;EAwBjB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
export function splitItems(maybeItems, splitIndex, activeId, isMobile = false) {
|
|
4
|
+
const items = maybeItems !== null && maybeItems !== void 0 ? maybeItems : [];
|
|
5
|
+
let visibleItems = items.slice(0, splitIndex);
|
|
6
|
+
let overflowItems = items.slice(splitIndex, items.length);
|
|
7
|
+
if (overflowItems.length === 1) {
|
|
8
|
+
visibleItems = items.slice(0, splitIndex + 1);
|
|
9
|
+
overflowItems = [];
|
|
10
|
+
}
|
|
11
|
+
if (isMobile && items.length === 3) {
|
|
12
|
+
splitIndex = splitIndex + 1;
|
|
13
|
+
}
|
|
14
|
+
if (activeId && overflowItems.length > 0 && visibleItems.length > 0) {
|
|
15
|
+
const activeInOverflow = overflowItems.find(item => item.id === activeId);
|
|
16
|
+
if (activeInOverflow) {
|
|
17
|
+
overflowItems.splice(overflowItems.indexOf(activeInOverflow), 1);
|
|
18
|
+
overflowItems.unshift(visibleItems.pop());
|
|
19
|
+
visibleItems.push(activeInOverflow);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return { visibleItems, overflowItems };
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=drawers-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawers-helpers.js","sourceRoot":"lib/default/","sources":["app-layout/drawer/drawers-helpers.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,MAAM,UAAU,UAAU,CACxB,UAAgC,EAChC,UAAkB,EAClB,QAAmC,EACnC,QAAQ,GAAG,KAAK;IAEhB,MAAM,KAAK,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,CAAC;IAC/B,IAAI,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;IAC9C,IAAI,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE1D,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;QAC9B,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC;QAC9C,aAAa,GAAG,EAAE,CAAC;KACpB;IAED,IAAI,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QAClC,UAAU,GAAG,UAAU,GAAG,CAAC,CAAC;KAC7B;IAED,IAAI,QAAQ,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;QACnE,MAAM,gBAAgB,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC;QAC1E,IAAI,gBAAgB,EAAE;YACpB,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC;YACjE,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAG,CAAC,CAAC;YAC3C,YAAY,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACrC;KACF;IACD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;AACzC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nexport function splitItems<T extends { id: string }>(\n maybeItems: Array<T> | undefined,\n splitIndex: number,\n activeId: string | null | undefined,\n isMobile = false\n) {\n const items = maybeItems ?? [];\n let visibleItems = items.slice(0, splitIndex);\n let overflowItems = items.slice(splitIndex, items.length);\n\n if (overflowItems.length === 1) {\n visibleItems = items.slice(0, splitIndex + 1);\n overflowItems = [];\n }\n\n if (isMobile && items.length === 3) {\n splitIndex = splitIndex + 1;\n }\n\n if (activeId && overflowItems.length > 0 && visibleItems.length > 0) {\n const activeInOverflow = overflowItems.find(item => item.id === activeId);\n if (activeInOverflow) {\n overflowItems.splice(overflowItems.indexOf(activeInOverflow), 1);\n overflowItems.unshift(visibleItems.pop()!);\n visibleItems.push(activeInOverflow);\n }\n }\n return { visibleItems, overflowItems };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DesktopDrawerProps, DrawerTriggersBarProps } from './interfaces';
|
|
3
3
|
export declare const Drawer: React.ForwardRefExoticComponent<DesktopDrawerProps & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
-
export declare
|
|
4
|
+
export declare const DrawerTriggersBar: ({ isMobile, topOffset, bottomOffset, drawers }: DrawerTriggersBarProps) => JSX.Element;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["app-layout/drawer/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAKtC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAc,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"lib/default/","sources":["app-layout/drawer/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAKtC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAc,MAAM,cAAc,CAAC;AAsBtF,eAAO,MAAM,MAAM,2FAkGlB,CAAC;AAiCF,eAAO,MAAM,iBAAiB,mDAAoD,sBAAsB,gBA2EvG,CAAC"}
|
|
@@ -5,6 +5,10 @@ import React, { useRef } from 'react';
|
|
|
5
5
|
import { ToggleButton, CloseButton, togglesConfig } from '../toggles';
|
|
6
6
|
import testutilStyles from '../test-classes/styles.css.js';
|
|
7
7
|
import styles from './styles.css.js';
|
|
8
|
+
import OverflowMenu from './overflow-menu';
|
|
9
|
+
import { useContainerQuery } from '@cloudscape-design/component-toolkit';
|
|
10
|
+
import { useDensityMode } from '@cloudscape-design/component-toolkit/internal';
|
|
11
|
+
import { splitItems } from './drawers-helpers';
|
|
8
12
|
// We are using two landmarks per drawer, i.e. two NAVs and two ASIDEs, because of several
|
|
9
13
|
// known bugs in NVDA that cause focus changes within a container to sometimes not be
|
|
10
14
|
// announced. As a result, we use one region for the open button and one region for the
|
|
@@ -62,15 +66,40 @@ export const Drawer = React.forwardRef(({ contentClassName, toggleClassName, clo
|
|
|
62
66
|
} }),
|
|
63
67
|
children))));
|
|
64
68
|
});
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
const DrawerTrigger = React.forwardRef(({ testUtilsClassName, ariaLabel, ariaExpanded, badge, itemId, isActive, trigger, onClick }, ref) => (React.createElement("div", { className: clsx(styles['drawer-trigger'], isActive && styles['drawer-trigger-active']), onClick: onClick },
|
|
70
|
+
React.createElement(ToggleButton, { ref: ref, className: testUtilsClassName, iconName: trigger.iconName, iconSvg: trigger.iconSvg, ariaLabel: ariaLabel, ariaExpanded: ariaExpanded, badge: badge, testId: itemId && `awsui-app-layout-trigger-${itemId}` }))));
|
|
71
|
+
export const DrawerTriggersBar = ({ isMobile, topOffset, bottomOffset, drawers }) => {
|
|
72
|
+
const containerRef = React.useRef(null);
|
|
73
|
+
const [containerHeight, triggersContainerRef] = useContainerQuery(rect => rect.contentBoxHeight);
|
|
74
|
+
const isCompactMode = useDensityMode(containerRef) === 'compact';
|
|
75
|
+
const getIndexOfOverflowItem = () => {
|
|
76
|
+
if (containerHeight) {
|
|
77
|
+
const ITEM_HEIGHT = isCompactMode ? 34 : 38;
|
|
78
|
+
const overflowSpot = containerHeight / 1.5;
|
|
79
|
+
const index = Math.floor(overflowSpot / ITEM_HEIGHT);
|
|
80
|
+
return index;
|
|
81
|
+
}
|
|
82
|
+
return 0;
|
|
83
|
+
};
|
|
84
|
+
const { visibleItems, overflowItems } = splitItems(drawers === null || drawers === void 0 ? void 0 : drawers.items, getIndexOfOverflowItem(), drawers === null || drawers === void 0 ? void 0 : drawers.activeDrawerId);
|
|
67
85
|
return (React.createElement("div", { className: clsx(styles.drawer, styles['drawer-closed'], testutilStyles['drawer-closed'], {
|
|
68
86
|
[styles['drawer-mobile']]: isMobile,
|
|
69
|
-
}) },
|
|
70
|
-
React.createElement("div", { style: { top: topOffset, bottom: bottomOffset }, className: styles['drawer-content'] }, !isMobile && (React.createElement("aside", { "aria-label": drawers === null || drawers === void 0 ? void 0 : drawers.ariaLabel, className: clsx(styles['drawer-triggers-wrapper'],
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
}), ref: containerRef },
|
|
88
|
+
React.createElement("div", { ref: triggersContainerRef, style: { top: topOffset, bottom: bottomOffset }, className: clsx(styles['drawer-content']) }, !isMobile && (React.createElement("aside", { "aria-label": drawers === null || drawers === void 0 ? void 0 : drawers.ariaLabel, className: clsx(styles['drawer-triggers-wrapper'], testutilStyles['drawers-desktop-triggers-container']) },
|
|
89
|
+
React.createElement(React.Fragment, null,
|
|
90
|
+
visibleItems.map((item, index) => {
|
|
91
|
+
var _a;
|
|
92
|
+
return (React.createElement(DrawerTrigger, { key: index, testUtilsClassName: testutilStyles['drawers-trigger'], ariaExpanded: (drawers === null || drawers === void 0 ? void 0 : drawers.activeDrawerId) !== undefined, ariaLabel: (_a = item.ariaLabels) === null || _a === void 0 ? void 0 : _a.triggerButton, trigger: item.trigger, badge: item.badge, itemId: item.id, isActive: (drawers === null || drawers === void 0 ? void 0 : drawers.activeDrawerId) === item.id, onClick: () => {
|
|
93
|
+
drawers === null || drawers === void 0 ? void 0 : drawers.onChange({
|
|
94
|
+
activeDrawerId: item.id !== drawers.activeDrawerId ? item.id : undefined,
|
|
95
|
+
});
|
|
96
|
+
} }));
|
|
97
|
+
}),
|
|
98
|
+
overflowItems.length > 0 && (React.createElement("div", { className: clsx(styles['drawer-trigger']) },
|
|
99
|
+
React.createElement(OverflowMenu, { ariaLabel: drawers === null || drawers === void 0 ? void 0 : drawers.overflowAriaLabel, items: overflowItems, onItemClick: ({ detail }) => {
|
|
100
|
+
drawers === null || drawers === void 0 ? void 0 : drawers.onChange({
|
|
101
|
+
activeDrawerId: detail.id !== drawers.activeDrawerId ? detail.id : undefined,
|
|
102
|
+
});
|
|
103
|
+
} })))))))));
|
|
104
|
+
};
|
|
76
105
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index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MAAM,EAAE,YAAY,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,gBAAgB,CAAC,IACtF,CAAC,QAAQ,IAAI,CACZ,6CAAmB,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,EAAE,gBAAgB,CAAC,IACxG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,0CAAE,GAAG,CAAC,CAAC,IAAgB,EAAE,KAAa,EAAE,EAAE;;YAAC,OAAA,CACxD,8BACE,GAAG,EAAE,KAAK,EACV,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,gBAAgB,CAAC,EACxB,OAAO,CAAC,cAAc,KAAK,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,uBAAuB,CAAC,CACtE,EACD,OAAO,EAAE,GAAG,EAAE,CACZ,OAAO,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;gBAGhG,oBAAC,YAAY,IACX,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAC/B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAC7B,SAAS,EAAE,MAAA,IAAI,CAAC,UAAU,0CAAE,aAAa,EACzC,YAAY,EAAE,OAAO,CAAC,cAAc,KAAK,SAAS,EAClD,MAAM,EAAE,4BAA4B,IAAI,CAAC,EAAE,EAAE,GAC7C,CACG,CACR,CAAA;SAAA,CAAC,CACI,CACT,CACG,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useRef } from 'react';\nimport { ToggleButton, CloseButton, togglesConfig } from '../toggles';\n\nimport testutilStyles from '../test-classes/styles.css.js';\nimport styles from './styles.css.js';\nimport { DesktopDrawerProps, DrawerTriggersBarProps, DrawerItem } from './interfaces';\n\n// We are using two landmarks per drawer, i.e. two NAVs and two ASIDEs, because of several\n// known bugs in NVDA that cause focus changes within a container to sometimes not be\n// announced. As a result, we use one region for the open button and one region for the\n// actual drawer content, always hiding the other one when it's not visible.\n// An alternative solution to follow a more classic implementation here to only have one\n// button that triggers the opening/closing of the drawer also did not work due to another\n// series of bugs in NVDA (together with Firefox) which prevent the changed expanded state\n// from being announced.\n// Even with this workaround in place, the announcement of the close button when opening a\n// panel in NVDA is not working correctly. The suspected root cause is one of the bugs below\n// as well.\n// Relevant tickets:\n// * https://github.com/nvaccess/nvda/issues/6606\n// * https://github.com/nvaccess/nvda/issues/5825\n// * https://github.com/nvaccess/nvda/issues/5247\n// * https://github.com/nvaccess/nvda/pull/8869 (reverted PR that was going to fix it)\nexport const Drawer = React.forwardRef(\n (\n {\n contentClassName,\n toggleClassName,\n closeClassName,\n width,\n type,\n toggleRefs,\n topOffset,\n bottomOffset,\n ariaLabels,\n drawersAriaLabels,\n children,\n isOpen,\n isMobile,\n onToggle,\n onClick,\n onLoseFocus,\n drawers,\n resizeHandle,\n }: DesktopDrawerProps,\n ref: React.Ref<HTMLDivElement>\n ) => {\n const openButtonWrapperRef = useRef<HTMLElement | null>(null);\n const { TagName, iconName, getLabels } = togglesConfig[type];\n const { mainLabel, closeLabel, openLabel } = drawersAriaLabels ?? getLabels(ariaLabels);\n const drawerContentWidthOpen = isMobile ? undefined : width;\n const drawerContentWidth = isOpen ? drawerContentWidthOpen : undefined;\n\n const regularOpenButton = (\n <TagName ref={openButtonWrapperRef} aria-label={mainLabel} className={styles.toggle} aria-hidden={isOpen}>\n <ToggleButton\n ref={toggleRefs.toggle}\n className={toggleClassName}\n iconName={iconName}\n ariaLabel={openLabel}\n onClick={() => onToggle(true)}\n ariaExpanded={false}\n />\n </TagName>\n );\n\n return (\n <div\n ref={ref}\n className={clsx(styles.drawer, {\n [styles['drawer-closed']]: !isOpen,\n [testutilStyles['drawer-closed']]: !isOpen,\n [styles['drawer-mobile']]: isMobile,\n })}\n style={{ width: drawerContentWidth }}\n onBlur={\n onLoseFocus\n ? e => {\n if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {\n onLoseFocus(e);\n }\n }\n : undefined\n }\n onClick={event => {\n if (onClick) {\n onClick(event);\n }\n if (!isOpen) {\n // to prevent calling onToggle from the drawer when it's called from the toggle button\n if (\n openButtonWrapperRef.current === event.target ||\n !openButtonWrapperRef.current?.contains(event.target as Node)\n ) {\n onToggle(true);\n }\n }\n }}\n >\n <div\n style={{ width: drawerContentWidth, top: topOffset, bottom: bottomOffset }}\n className={clsx(styles['drawer-content'], styles['drawer-content-clickable'], contentClassName)}\n >\n {!isMobile && regularOpenButton}\n {resizeHandle}\n <TagName aria-label={mainLabel} aria-hidden={!isOpen}>\n <CloseButton\n ref={toggleRefs.close}\n className={closeClassName}\n ariaLabel={closeLabel}\n onClick={() => {\n onToggle(false);\n drawers?.onChange({ activeDrawerId: undefined });\n }}\n />\n {children}\n </TagName>\n </div>\n </div>\n );\n }\n);\n\nexport function DrawerTriggersBar({\n isMobile,\n topOffset,\n bottomOffset,\n drawers,\n contentClassName,\n toggleClassName,\n}: DrawerTriggersBarProps) {\n return (\n <div\n className={clsx(styles.drawer, styles['drawer-closed'], testutilStyles['drawer-closed'], {\n [styles['drawer-mobile']]: isMobile,\n })}\n >\n <div style={{ top: topOffset, bottom: bottomOffset }} className={styles['drawer-content']}>\n {!isMobile && (\n <aside aria-label={drawers?.ariaLabel} className={clsx(styles['drawer-triggers-wrapper'], contentClassName)}>\n {drawers?.items?.map((item: DrawerItem, index: number) => (\n <span\n key={index}\n className={clsx(\n styles['drawer-trigger'],\n drawers.activeDrawerId === item.id && styles['drawer-trigger-active']\n )}\n onClick={() =>\n drawers.onChange({ activeDrawerId: item.id !== drawers.activeDrawerId ? item.id : undefined })\n }\n >\n <ToggleButton\n className={toggleClassName}\n iconName={item.trigger.iconName}\n iconSvg={item.trigger.iconSvg}\n ariaLabel={item.ariaLabels?.triggerButton}\n ariaExpanded={drawers.activeDrawerId !== undefined}\n testId={`awsui-app-layout-trigger-${item.id}`}\n />\n </span>\n ))}\n </aside>\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"lib/default/","sources":["app-layout/drawer/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,cAAc,MAAM,+BAA+B,CAAC;AAC3D,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,0FAA0F;AAC1F,qFAAqF;AACrF,uFAAuF;AACvF,4EAA4E;AAC5E,wFAAwF;AACxF,0FAA0F;AAC1F,0FAA0F;AAC1F,wBAAwB;AACxB,0FAA0F;AAC1F,4FAA4F;AAC5F,WAAW;AACX,oBAAoB;AACpB,iDAAiD;AACjD,iDAAiD;AACjD,iDAAiD;AACjD,sFAAsF;AACtF,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CACpC,CACE,EACE,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,KAAK,EACL,IAAI,EACJ,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACN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I,CAAC,UAAU,0CAAE,aAAa,EACzC,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,MAAM,EAAE,IAAI,CAAC,EAAE,EACf,QAAQ,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,MAAK,IAAI,CAAC,EAAE,EAC7C,OAAO,EAAE,GAAG,EAAE;4BACZ,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,CAAC;gCAChB,cAAc,EAAE,IAAI,CAAC,EAAE,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;6BACzE,CAAC,CAAC;wBACL,CAAC,GACD,CACH,CAAC;gBACJ,CAAC,CAAC;gBACD,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,CAC3B,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;oBAC5C,oBAAC,YAAY,IACX,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,EACrC,KAAK,EAAE,aAAa,EACpB,WAAW,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;4BAC1B,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,CAAC;gCAChB,cAAc,EAAE,MAAM,CAAC,EAAE,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;6BAC7E,CAAC,CAAC;wBACL,CAAC,GACD,CACE,CACP,CACA,CACG,CACT,CACG,CACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport clsx from 'clsx';\nimport React, { useRef } from 'react';\nimport { ToggleButton, CloseButton, togglesConfig } from '../toggles';\n\nimport testutilStyles from '../test-classes/styles.css.js';\nimport styles from './styles.css.js';\nimport { DesktopDrawerProps, DrawerTriggersBarProps, DrawerItem } from './interfaces';\nimport OverflowMenu from './overflow-menu';\nimport { useContainerQuery } from '@cloudscape-design/component-toolkit';\nimport { useDensityMode } from '@cloudscape-design/component-toolkit/internal';\nimport { splitItems } from './drawers-helpers';\n\n// We are using two landmarks per drawer, i.e. two NAVs and two ASIDEs, because of several\n// known bugs in NVDA that cause focus changes within a container to sometimes not be\n// announced. As a result, we use one region for the open button and one region for the\n// actual drawer content, always hiding the other one when it's not visible.\n// An alternative solution to follow a more classic implementation here to only have one\n// button that triggers the opening/closing of the drawer also did not work due to another\n// series of bugs in NVDA (together with Firefox) which prevent the changed expanded state\n// from being announced.\n// Even with this workaround in place, the announcement of the close button when opening a\n// panel in NVDA is not working correctly. The suspected root cause is one of the bugs below\n// as well.\n// Relevant tickets:\n// * https://github.com/nvaccess/nvda/issues/6606\n// * https://github.com/nvaccess/nvda/issues/5825\n// * https://github.com/nvaccess/nvda/issues/5247\n// * https://github.com/nvaccess/nvda/pull/8869 (reverted PR that was going to fix it)\nexport const Drawer = React.forwardRef(\n (\n {\n contentClassName,\n toggleClassName,\n closeClassName,\n width,\n type,\n toggleRefs,\n topOffset,\n bottomOffset,\n ariaLabels,\n drawersAriaLabels,\n children,\n isOpen,\n isMobile,\n onToggle,\n onClick,\n onLoseFocus,\n drawers,\n resizeHandle,\n }: DesktopDrawerProps,\n ref: React.Ref<HTMLDivElement>\n ) => {\n const openButtonWrapperRef = useRef<HTMLElement | null>(null);\n const { TagName, iconName, getLabels } = togglesConfig[type];\n const { mainLabel, closeLabel, openLabel } = drawersAriaLabels ?? getLabels(ariaLabels);\n const drawerContentWidthOpen = isMobile ? undefined : width;\n const drawerContentWidth = isOpen ? drawerContentWidthOpen : undefined;\n\n const regularOpenButton = (\n <TagName ref={openButtonWrapperRef} aria-label={mainLabel} className={styles.toggle} aria-hidden={isOpen}>\n <ToggleButton\n ref={toggleRefs.toggle}\n className={toggleClassName}\n iconName={iconName}\n ariaLabel={openLabel}\n onClick={() => onToggle(true)}\n ariaExpanded={false}\n />\n </TagName>\n );\n\n return (\n <div\n ref={ref}\n className={clsx(styles.drawer, {\n [styles['drawer-closed']]: !isOpen,\n [testutilStyles['drawer-closed']]: !isOpen,\n [styles['drawer-mobile']]: isMobile,\n })}\n style={{ width: drawerContentWidth }}\n onBlur={\n onLoseFocus\n ? e => {\n if (!e.relatedTarget || !e.currentTarget.contains(e.relatedTarget)) {\n onLoseFocus(e);\n }\n }\n : undefined\n }\n onClick={event => {\n if (onClick) {\n onClick(event);\n }\n if (!isOpen) {\n // to prevent calling onToggle from the drawer when it's called from the toggle button\n if (\n openButtonWrapperRef.current === event.target ||\n !openButtonWrapperRef.current?.contains(event.target as Node)\n ) {\n onToggle(true);\n }\n }\n }}\n >\n <div\n style={{ width: drawerContentWidth, top: topOffset, bottom: bottomOffset }}\n className={clsx(styles['drawer-content'], styles['drawer-content-clickable'], contentClassName)}\n >\n {!isMobile && regularOpenButton}\n {resizeHandle}\n <TagName aria-label={mainLabel} aria-hidden={!isOpen}>\n <CloseButton\n ref={toggleRefs.close}\n className={closeClassName}\n ariaLabel={closeLabel}\n onClick={() => {\n onToggle(false);\n drawers?.onChange({ activeDrawerId: undefined });\n }}\n />\n {children}\n </TagName>\n </div>\n </div>\n );\n }\n);\n\ninterface DrawerTriggerProps {\n testUtilsClassName?: string;\n ariaLabel: string | undefined;\n ariaExpanded: boolean;\n badge: boolean | undefined;\n itemId?: string;\n isActive: boolean;\n trigger: DrawerItem['trigger'];\n onClick: () => void;\n}\n\nconst DrawerTrigger = React.forwardRef(\n (\n { testUtilsClassName, ariaLabel, ariaExpanded, badge, itemId, isActive, trigger, onClick }: DrawerTriggerProps,\n ref: React.Ref<{ focus: () => void }>\n ) => (\n <div className={clsx(styles['drawer-trigger'], isActive && styles['drawer-trigger-active'])} onClick={onClick}>\n <ToggleButton\n ref={ref}\n className={testUtilsClassName}\n iconName={trigger.iconName}\n iconSvg={trigger.iconSvg}\n ariaLabel={ariaLabel}\n ariaExpanded={ariaExpanded}\n badge={badge}\n testId={itemId && `awsui-app-layout-trigger-${itemId}`}\n />\n </div>\n )\n);\n\nexport const DrawerTriggersBar = ({ isMobile, topOffset, bottomOffset, drawers }: DrawerTriggersBarProps) => {\n const containerRef = React.useRef<HTMLDivElement>(null);\n const [containerHeight, triggersContainerRef] = useContainerQuery(rect => rect.contentBoxHeight);\n const isCompactMode = useDensityMode(containerRef) === 'compact';\n\n const getIndexOfOverflowItem = () => {\n if (containerHeight) {\n const ITEM_HEIGHT = isCompactMode ? 34 : 38;\n const overflowSpot = containerHeight / 1.5;\n\n const index = Math.floor(overflowSpot / ITEM_HEIGHT);\n\n return index;\n }\n return 0;\n };\n\n const { visibleItems, overflowItems } = splitItems(drawers?.items, getIndexOfOverflowItem(), drawers?.activeDrawerId);\n\n return (\n <div\n className={clsx(styles.drawer, styles['drawer-closed'], testutilStyles['drawer-closed'], {\n [styles['drawer-mobile']]: isMobile,\n })}\n ref={containerRef}\n >\n <div\n ref={triggersContainerRef}\n style={{ top: topOffset, bottom: bottomOffset }}\n className={clsx(styles['drawer-content'])}\n >\n {!isMobile && (\n <aside\n aria-label={drawers?.ariaLabel}\n className={clsx(styles['drawer-triggers-wrapper'], testutilStyles['drawers-desktop-triggers-container'])}\n >\n <>\n {visibleItems.map((item, index) => {\n return (\n <DrawerTrigger\n key={index}\n testUtilsClassName={testutilStyles['drawers-trigger']}\n ariaExpanded={drawers?.activeDrawerId !== undefined}\n ariaLabel={item.ariaLabels?.triggerButton}\n trigger={item.trigger}\n badge={item.badge}\n itemId={item.id}\n isActive={drawers?.activeDrawerId === item.id}\n onClick={() => {\n drawers?.onChange({\n activeDrawerId: item.id !== drawers.activeDrawerId ? item.id : undefined,\n });\n }}\n />\n );\n })}\n {overflowItems.length > 0 && (\n <div className={clsx(styles['drawer-trigger'])}>\n <OverflowMenu\n ariaLabel={drawers?.overflowAriaLabel}\n items={overflowItems}\n onItemClick={({ detail }) => {\n drawers?.onChange({\n activeDrawerId: detail.id !== drawers.activeDrawerId ? detail.id : undefined,\n });\n }}\n />\n </div>\n )}\n </>\n </aside>\n )}\n </div>\n </div>\n );\n};\n"]}
|
|
@@ -52,8 +52,6 @@ export interface ResizableDrawerProps extends DesktopDrawerProps {
|
|
|
52
52
|
refs: DrawerFocusControlRefs;
|
|
53
53
|
}
|
|
54
54
|
export interface DrawerTriggersBarProps {
|
|
55
|
-
contentClassName: string;
|
|
56
|
-
toggleClassName: string;
|
|
57
55
|
topOffset: number | undefined;
|
|
58
56
|
bottomOffset: number | undefined;
|
|
59
57
|
isMobile: boolean;
|
|
@@ -64,6 +62,7 @@ export interface DrawerTriggersBarProps {
|
|
|
64
62
|
activeDrawerId: string | undefined;
|
|
65
63
|
}) => void;
|
|
66
64
|
ariaLabel?: string;
|
|
65
|
+
overflowAriaLabel?: string;
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
68
|
export interface DrawerItemAriaLabels {
|
|
@@ -86,6 +85,7 @@ export interface DrawerItem {
|
|
|
86
85
|
size: number;
|
|
87
86
|
id: string;
|
|
88
87
|
}>;
|
|
88
|
+
badge?: boolean;
|
|
89
89
|
}
|
|
90
90
|
export interface InternalDrawerProps {
|
|
91
91
|
drawers?: {
|
|
@@ -97,6 +97,7 @@ export interface InternalDrawerProps {
|
|
|
97
97
|
id: string;
|
|
98
98
|
}>;
|
|
99
99
|
ariaLabel?: string;
|
|
100
|
+
overflowAriaLabel?: string;
|
|
100
101
|
};
|
|
101
102
|
}
|
|
102
103
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"lib/default/","sources":["app-layout/drawer/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE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O,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE,yBAAyB,CAAC,MAAM,CAAC,CAAC;QAC7C,QAAQ,CAAC,EAAE,yBAAyB,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QACnE,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["app-layout/drawer/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { togglesConfig } from '../toggles';\nimport { AppLayoutProps } from '../interfaces';\nimport { IconProps } from '../../icon/interfaces';\nimport { NonCancelableEventHandler } from '../../internal/events';\n\nimport { DrawerFocusControlRefs } from '../utils/use-drawer-focus-control';\n\nexport interface DesktopDrawerProps {\n contentClassName: string;\n toggleClassName: string;\n closeClassName: string;\n toggleRefs: {\n toggle: React.Ref<{ focus(): void }>;\n close: React.Ref<{ focus(): void }>;\n };\n width: number;\n topOffset: number | undefined;\n bottomOffset: number | undefined;\n ariaLabels: AppLayoutProps.Labels | undefined;\n drawersAriaLabels?: { mainLabel: string | undefined; closeLabel: string | undefined; openLabel: string | undefined };\n children: React.ReactNode;\n type: keyof typeof togglesConfig;\n isMobile: boolean;\n isOpen: boolean;\n onToggle: (isOpen: boolean) => void;\n onClick?: (event: React.MouseEvent) => void;\n onLoseFocus?: (event: React.FocusEvent) => void;\n drawers?: {\n items: Array<DrawerItem>;\n activeDrawerId: string | undefined;\n onChange: (changeDetail: { activeDrawerId: string | undefined }) => void;\n };\n resizeHandle?: React.ReactNode;\n}\n\nexport interface ResizableDrawerProps extends DesktopDrawerProps {\n activeDrawer?: DrawerItem;\n onResize: (resizeDetail: { size: number; id: string }) => void;\n size: number;\n getMaxWidth: () => number;\n refs: DrawerFocusControlRefs;\n}\n\nexport interface DrawerTriggersBarProps {\n
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"lib/default/","sources":["app-layout/drawer/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport { togglesConfig } from '../toggles';\nimport { AppLayoutProps } from '../interfaces';\nimport { IconProps } from '../../icon/interfaces';\nimport { NonCancelableEventHandler } from '../../internal/events';\n\nimport { DrawerFocusControlRefs } from '../utils/use-drawer-focus-control';\n\nexport interface DesktopDrawerProps {\n contentClassName: string;\n toggleClassName: string;\n closeClassName: string;\n toggleRefs: {\n toggle: React.Ref<{ focus(): void }>;\n close: React.Ref<{ focus(): void }>;\n };\n width: number;\n topOffset: number | undefined;\n bottomOffset: number | undefined;\n ariaLabels: AppLayoutProps.Labels | undefined;\n drawersAriaLabels?: { mainLabel: string | undefined; closeLabel: string | undefined; openLabel: string | undefined };\n children: React.ReactNode;\n type: keyof typeof togglesConfig;\n isMobile: boolean;\n isOpen: boolean;\n onToggle: (isOpen: boolean) => void;\n onClick?: (event: React.MouseEvent) => void;\n onLoseFocus?: (event: React.FocusEvent) => void;\n drawers?: {\n items: Array<DrawerItem>;\n activeDrawerId: string | undefined;\n onChange: (changeDetail: { activeDrawerId: string | undefined }) => void;\n };\n resizeHandle?: React.ReactNode;\n}\n\nexport interface ResizableDrawerProps extends DesktopDrawerProps {\n activeDrawer?: DrawerItem;\n onResize: (resizeDetail: { size: number; id: string }) => void;\n size: number;\n getMaxWidth: () => number;\n refs: DrawerFocusControlRefs;\n}\n\nexport interface DrawerTriggersBarProps {\n topOffset: number | undefined;\n bottomOffset: number | undefined;\n isMobile: boolean;\n drawers?: {\n items: Array<DrawerItem>;\n activeDrawerId?: string;\n onChange: (changeDetail: { activeDrawerId: string | undefined }) => void;\n ariaLabel?: string;\n overflowAriaLabel?: string;\n };\n}\n\nexport interface DrawerItemAriaLabels {\n content?: string;\n closeButton?: string;\n triggerButton?: string;\n resizeHandle?: string;\n}\n\nexport interface DrawerItem {\n id: string;\n content: React.ReactNode;\n trigger: {\n iconName?: IconProps.Name;\n iconSvg?: React.ReactNode;\n };\n ariaLabels: DrawerItemAriaLabels;\n resizable?: boolean;\n defaultSize?: number;\n onResize?: NonCancelableEventHandler<{ size: number; id: string }>;\n badge?: boolean;\n}\n\nexport interface InternalDrawerProps {\n drawers?: {\n items: Array<DrawerItem>;\n activeDrawerId?: string;\n onChange?: NonCancelableEventHandler<string>;\n onResize?: NonCancelableEventHandler<{ size: number; id: string }>;\n ariaLabel?: string;\n overflowAriaLabel?: string;\n };\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonDropdownProps, InternalButtonDropdownProps } from '../../button-dropdown/interfaces';
|
|
3
|
+
import { CancelableEventHandler } from '../../internal/events';
|
|
4
|
+
import { DrawerItem } from './interfaces';
|
|
5
|
+
interface OverflowMenuProps {
|
|
6
|
+
items: DrawerItem[];
|
|
7
|
+
onItemClick: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;
|
|
8
|
+
customTriggerBuilder?: InternalButtonDropdownProps['customTriggerBuilder'];
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
}
|
|
11
|
+
export default function OverflowMenu({ items, onItemClick, customTriggerBuilder, ariaLabel }: OverflowMenuProps): JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=overflow-menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overflow-menu.d.ts","sourceRoot":"lib/default/","sources":["app-layout/drawer/overflow-menu.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACpG,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,UAAU,iBAAiB;IACzB,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,WAAW,EAAE,sBAAsB,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAC1E,oBAAoB,CAAC,EAAE,2BAA2B,CAAC,sBAAsB,CAAC,CAAC;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,SAAS,EAAE,EAAE,iBAAiB,eAiB9G"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import InternalButtonDropdown from '../../button-dropdown/internal';
|
|
5
|
+
export default function OverflowMenu({ items, onItemClick, customTriggerBuilder, ariaLabel }) {
|
|
6
|
+
return (React.createElement(InternalButtonDropdown, { items: items.map(item => {
|
|
7
|
+
var _a;
|
|
8
|
+
return ({
|
|
9
|
+
id: item.id,
|
|
10
|
+
text: ((_a = item.ariaLabels) === null || _a === void 0 ? void 0 : _a.content) || 'Content',
|
|
11
|
+
iconName: item.trigger.iconName,
|
|
12
|
+
iconSvg: item.trigger.iconSvg,
|
|
13
|
+
badge: item.badge,
|
|
14
|
+
});
|
|
15
|
+
}), onItemClick: onItemClick, ariaLabel: ariaLabel, variant: "icon", customTriggerBuilder: customTriggerBuilder, expandToViewport: true }));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=overflow-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overflow-menu.js","sourceRoot":"lib/default/","sources":["app-layout/drawer/overflow-menu.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,sBAAsB,MAAM,gCAAgC,CAAC;AAYpE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,SAAS,EAAqB;IAC7G,OAAO,CACL,oBAAC,sBAAsB,IACrB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;;YAAC,OAAA,CAAC;gBACxB,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,IAAI,EAAE,CAAA,MAAA,IAAI,CAAC,UAAU,0CAAE,OAAO,KAAI,SAAS;gBAC3C,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;gBAC/B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;gBAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAC,CAAA;SAAA,CAAC,EACH,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAC,MAAM,EACd,oBAAoB,EAAE,oBAAoB,EAC1C,gBAAgB,EAAE,IAAI,GACtB,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport InternalButtonDropdown from '../../button-dropdown/internal';\nimport { ButtonDropdownProps, InternalButtonDropdownProps } from '../../button-dropdown/interfaces';\nimport { CancelableEventHandler } from '../../internal/events';\nimport { DrawerItem } from './interfaces';\n\ninterface OverflowMenuProps {\n items: DrawerItem[];\n onItemClick: CancelableEventHandler<ButtonDropdownProps.ItemClickDetails>;\n customTriggerBuilder?: InternalButtonDropdownProps['customTriggerBuilder'];\n ariaLabel?: string;\n}\n\nexport default function OverflowMenu({ items, onItemClick, customTriggerBuilder, ariaLabel }: OverflowMenuProps) {\n return (\n <InternalButtonDropdown\n items={items.map(item => ({\n id: item.id,\n text: item.ariaLabels?.content || 'Content',\n iconName: item.trigger.iconName,\n iconSvg: item.trigger.iconSvg,\n badge: item.badge,\n }))}\n onItemClick={onItemClick}\n ariaLabel={ariaLabel}\n variant=\"icon\"\n customTriggerBuilder={customTriggerBuilder}\n expandToViewport={true}\n />\n );\n}\n"]}
|
|
@@ -306,6 +306,7 @@ const OldAppLayout = React.forwardRef((_a, ref) => {
|
|
|
306
306
|
}
|
|
307
307
|
},
|
|
308
308
|
ariaLabel: drawersProps.ariaLabel,
|
|
309
|
+
overflowAriaLabel: drawersProps.overflowAriaLabel,
|
|
309
310
|
}
|
|
310
311
|
: undefined }, breadcrumbs)),
|
|
311
312
|
React.createElement("div", { className: clsx(styles.layout, disableBodyScroll && styles['layout-no-scroll']) },
|
|
@@ -357,7 +358,7 @@ const OldAppLayout = React.forwardRef((_a, ref) => {
|
|
|
357
358
|
onActiveDrawerChange(changeDetail.activeDrawerId);
|
|
358
359
|
},
|
|
359
360
|
}, size: !isResizeInvalid ? activeDrawerSize : toolsWidth, onResize: changeDetail => onActiveDrawerResize(changeDetail), refs: drawerRefs, getMaxWidth: getDrawerMaxWidth }, activeDrawer === null || activeDrawer === void 0 ? void 0 : activeDrawer.content)) : (React.createElement(Drawer, { contentClassName: testutilStyles.tools, toggleClassName: testutilStyles['tools-toggle'], closeClassName: testutilStyles['tools-close'], ariaLabels: ariaLabels, width: effectiveToolsWidth, bottomOffset: footerHeight, topOffset: headerHeight, isMobile: isMobile, onToggle: onToolsToggle, isOpen: toolsOpen, toggleRefs: toolsRefs, type: "tools", onLoseFocus: loseToolsFocus }, tools))),
|
|
360
|
-
hasDrawers && (React.createElement(DrawerTriggersBar, {
|
|
361
|
+
hasDrawers && (React.createElement(DrawerTriggersBar, { bottomOffset: footerHeight, topOffset: headerHeight, isMobile: isMobile, drawers: {
|
|
361
362
|
items: drawers,
|
|
362
363
|
activeDrawerId: activeDrawerId,
|
|
363
364
|
onChange: changeDetail => {
|
|
@@ -369,6 +370,7 @@ const OldAppLayout = React.forwardRef((_a, ref) => {
|
|
|
369
370
|
onActiveDrawerChange(changeDetail.activeDrawerId);
|
|
370
371
|
},
|
|
371
372
|
ariaLabel: drawersProps.ariaLabel,
|
|
373
|
+
overflowAriaLabel: drawersProps.overflowAriaLabel,
|
|
372
374
|
} }))))));
|
|
373
375
|
});
|
|
374
376
|
applyDisplayName(AppLayout, 'AppLayout');
|