Skip to content

Commit 0dd82de

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat/widgetize-app-layout-skeleton-event-base
2 parents 48af088 + 1b216f5 commit 0dd82de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+784
-508
lines changed

build-tools/tasks/package-json.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ module.exports = parallel([
121121
]),
122122
generatePackageJson(path.join(workspace.targetPath, 'components-definitions'), {
123123
name: '@cloudscape-design/components-definitions',
124+
exports: {
125+
'./components': './components/index.js',
126+
'./test-utils-doc/dom': './test-utils-doc/dom.js',
127+
'./test-utils-doc/selectors': './test-utils-doc/selectors.js',
128+
// this directory is generated down the line in other builds
129+
'./styles/*.json': './styles/*.json',
130+
},
124131
}),
125132
styleDictionaryPackageJson,
126133
componentsThemeablePackageJson,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
{
165165
"path": "lib/components/internal/widget-exports.js",
166166
"brotli": false,
167-
"limit": "786 kB",
167+
"limit": "790 kB",
168168
"ignore": "react-dom"
169169
}
170170
],

pages/funnel-analytics/with-table.page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default function WithTablePage() {
9191
}}
9292
selectionType="multi"
9393
header={
94-
<Header headingTagOverride="h1" counter={`(${allItems.length})`}>
94+
<Header headingTagOverride="h1" counter={`(1/${allItems.length})`}>
9595
Table title
9696
</Header>
9797
}

src/__tests__/snapshot-tests/__snapshots__/documenter.test.ts.snap

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17368,13 +17368,10 @@ scroll parent scrolls to reveal the first row of the table.",
1736817368
{
1736917369
"description": "Specifies alternative text for the selection components (checkboxes and radio buttons) as follows:
1737017370
* \`itemSelectionLabel\` ((SelectionState, Item) => string) - Specifies the alternative text for an item.
17371+
You can use the first argument of type \`SelectionState\` to access the current selection state of the component
17372+
(for example, the \`selectedItems\` list). The second argument is the corresponding \`Item\` object.
1737117373
* \`allItemsSelectionLabel\` ((SelectionState) => string) - Specifies the alternative text for multi-selection column header.
1737217374
* \`selectionGroupLabel\` (string) - Specifies the alternative text for the whole selection and single-selection column header.
17373-
It is prefixed to \`itemSelectionLabel\` and \`allItemsSelectionLabel\` when they are set.
17374-
You can use the first argument of type \`SelectionState\` to access the current selection
17375-
state of the component (for example, the \`selectedItems\` list). The \`itemSelectionLabel\` for individual
17376-
items also receives the corresponding \`Item\` object. You can use the \`selectionGroupLabel\` to
17377-
add a meaningful description to the whole selection.
1737817375
* \`tableLabel\` (string) - Provides an alternative text for the table. If you use a header for this table, you may reuse the string
1737917376
to provide a caption-like description. For example, tableLabel=Instances will be announced as 'Instances table'.
1738017377
* \`resizerRoleDescription\` (string) - Provides role description for table column resizer buttons.

src/__tests__/snapshot-tests/documenter.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
import { getAllComponents, requireComponentDefinition } from '../utils';
3+
import definitions from '../../../lib/components-definitions/components';
4+
import { getAllComponents } from '../utils';
5+
6+
function requireComponentDefinition(componentName: string) {
7+
return definitions[componentName];
8+
}
49

510
describe('Documenter', () => {
611
test.each<string>(getAllComponents())(`definition for %s matches the snapshot`, (componentName: string) => {

src/__tests__/utils.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import fs from 'fs';
55
import path from 'path';
66

77
import { SplitPanelContextProvider } from '../../lib/components/internal/context/split-panel-context';
8-
import definitions from '../../lib/components-definitions/components';
98
import { defaultSplitPanelContextProps } from './required-props-for-components';
109

1110
const componentsDir = path.resolve(__dirname, '../../lib/components');
@@ -68,10 +67,6 @@ export function requireComponent(componentName: string): any {
6867
return require(path.join(componentsDir, componentName));
6968
}
7069

71-
export function requireComponentDefinition(componentName: string) {
72-
return definitions[componentName];
73-
}
74-
7570
export function requireDesignTokensFile(fileName: string): any {
7671
// eslint-disable-next-line @typescript-eslint/no-require-imports
7772
return require(path.join(designTokensDir, fileName));

src/annotation-context/__integ__/annotation-scroll.test.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ import createWrapper from '../../../lib/components/test-utils/selectors';
88
const wrapper = createWrapper();
99
const annotationWrapper = wrapper.findAnnotation();
1010

11+
function setupTest(testFn: (page: BasePageObject) => Promise<void>) {
12+
return useBrowser(async browser => {
13+
const page = new BasePageObject(browser);
14+
await browser.url('#/light/annotation-context/annotation-scroll');
15+
await testFn(page);
16+
});
17+
}
18+
1119
test(
1220
'scrolls annotation in view with fixed elements',
13-
useBrowser(async browser => {
14-
await browser.url('#/light/annotation-context/annotation-scroll');
15-
const page = new BasePageObject(browser);
21+
setupTest(async page => {
1622
const nextButtonSelector = annotationWrapper.findNextButton().toSelector();
1723
await page.waitForVisible(nextButtonSelector);
1824
await page.click(nextButtonSelector);
@@ -37,6 +43,21 @@ test(
3743
})
3844
);
3945

46+
test(
47+
'does not update popover position when annotation is rendered offscreen',
48+
setupTest(async page => {
49+
await expect(page.isDisplayedInViewport(annotationWrapper.toSelector())).resolves.toEqual(true);
50+
// scroll to the page bottom to make annotation offscreen
51+
await page.windowScrollTo({ top: 1200 });
52+
await expect(page.isDisplayedInViewport(annotationWrapper.toSelector())).resolves.toEqual(false);
53+
const positionBefore = await page.getBoundingBox(annotationWrapper.toSelector());
54+
// click somewhere to trigger the regression
55+
await page.click('main');
56+
const positionAfter = await page.getBoundingBox(annotationWrapper.toSelector());
57+
expect(positionBefore).toEqual(positionAfter);
58+
})
59+
);
60+
4061
function overlap(one: ElementRect, two: ElementRect) {
4162
if (one.right < two.left || one.left > two.right) {
4263
return false;

src/app-layout/__tests__/mobile.test.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ import visualRefreshRefactoredStyles from '../../../lib/components/app-layout/vi
2626
import toolbarNotificationsStyles from '../../../lib/components/app-layout/visual-refresh-toolbar/notifications/styles.css.js';
2727
import toolbarSkeletonStyles from '../../../lib/components/app-layout/visual-refresh-toolbar/skeleton/styles.css.js';
2828
import toolbarStyles from '../../../lib/components/app-layout/visual-refresh-toolbar/toolbar/styles.css.js';
29-
import toolbarTriggerButtonStyles from '../../../lib/components/app-layout/visual-refresh-toolbar/toolbar/trigger-button/styles.css.js';
30-
import iconStyles from '../../../lib/components/icon/styles.css.js';
3129

3230
function AppLayoutWithControlledNavigation({
3331
initialNavigationOpen,
@@ -77,8 +75,6 @@ describeEachAppLayout({ sizes: ['mobile'] }, ({ theme }) => {
7775
classic: `.${styles['notifications-sticky']}`,
7876
};
7977

80-
const triggerBadgeClassName =
81-
theme === 'refresh-toolbar' ? toolbarTriggerButtonStyles['trigger-badge-wrapper'] : iconStyles.badge;
8278
const isUnfocusable = (element: HTMLElement) =>
8379
!!findUpUntil(element, current => current.classList.contains(unfocusableClassName));
8480

@@ -577,7 +573,8 @@ describeEachAppLayout({ sizes: ['mobile'] }, ({ theme }) => {
577573

578574
test('should render badge when defined', () => {
579575
const { wrapper } = renderComponent(<AppLayout drawers={manyDrawers} />);
580-
expect(wrapper.findDrawerTriggerById('security')!.getElement().children[0]).toHaveClass(triggerBadgeClassName);
576+
expect(wrapper.findDrawerTriggerById('security')).toBeTruthy();
577+
expect(wrapper.findDrawerTriggerById('security', { hasBadge: true })).toBeTruthy();
581578
});
582579

583580
test('renders roles only when aria labels are not provided', () => {

src/app-layout/__tests__/runtime-drawers.test.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ import {
2222
testDrawer,
2323
} from './utils';
2424

25-
import triggerStyles from '../../../lib/components/app-layout/visual-refresh/styles.selectors.js';
2625
import skeletonStyles from '../../../lib/components/app-layout/visual-refresh-toolbar/skeleton/styles.selectors.js';
2726
import toolbarStyles from '../../../lib/components/app-layout/visual-refresh-toolbar/toolbar/styles.selectors.js';
2827
import toolbarTriggerStyles from '../../../lib/components/app-layout/visual-refresh-toolbar/toolbar/trigger-button/styles.selectors.js';
29-
import iconStyles from '../../../lib/components/icon/styles.selectors.js';
3028

3129
beforeEach(() => {
3230
awsuiPluginsInternal.appLayout.clearRegisteredDrawers();
@@ -64,7 +62,7 @@ const drawerDefaults: DrawerConfig = {
6462
unmountContent: () => {},
6563
};
6664

67-
describeEachAppLayout(({ theme, size }) => {
65+
describeEachAppLayout(({ size }) => {
6866
test('does not render runtime drawers when it is explicitly disabled', async () => {
6967
awsuiPlugins.appLayout.registerDrawer(drawerDefaults);
7068
const { wrapper } = await renderComponent(<AppLayout {...({ __disableRuntimeDrawers: true } as any)} />);
@@ -111,33 +109,21 @@ describeEachAppLayout(({ theme, size }) => {
111109
const { wrapper } = await renderComponent(<AppLayout />);
112110
// the 2nd trigger is for tools
113111
expect(wrapper.findDrawersTriggers()).toHaveLength(2);
114-
const drawerTrigger = wrapper.findDrawerTriggerById(drawerDefaults.id);
115-
116-
const triggerParent = drawerTrigger!.getElement().parentElement;
117-
const triggerParentWrapper = createWrapper(triggerParent!);
118112

119113
awsuiPlugins.appLayout.updateDrawer({
120114
id: drawerDefaults.id,
121115
badge: true,
122116
});
123117
await delay();
124-
const badgeSelector =
125-
theme === 'refresh-toolbar'
126-
? toolbarTriggerStyles.badge
127-
: theme === 'refresh' && size === 'desktop'
128-
? triggerStyles.badge
129-
: iconStyles.badge;
130-
131-
expect(triggerParentWrapper!.findByClassName(badgeSelector)!.getElement()).toBeInTheDocument();
118+
expect(wrapper.findDrawerTriggerById(drawerDefaults.id, { hasBadge: true })).toBeTruthy();
132119

133120
awsuiPlugins.appLayout.updateDrawer({
134121
id: drawerDefaults.id,
135122
badge: false,
136123
});
137124
await delay();
138125

139-
// re-querying the dot element
140-
expect(triggerParentWrapper!.findByClassName(badgeSelector)).toBeNull();
126+
expect(wrapper.findDrawerTriggerById(drawerDefaults.id, { hasBadge: false })).toBeTruthy();
141127
});
142128

143129
(size === 'desktop' ? test : test.skip)('update runtime drawers config resizable validation', async () => {

src/app-layout/visual-refresh-toolbar/drawer/styles.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ $drawer-resize-handle-size: awsui.$space-m;
206206
> .drawer-actions {
207207
position: absolute;
208208
display: flex;
209-
align-self: flex-start;
210-
justify-self: flex-end;
209+
inset-block-start: 0;
210+
inset-inline-end: 0;
211211
padding-inline-end: awsui.$space-m;
212212
padding-block-start: constants.$toolbar-vertical-panel-icon-offset;
213213
}

0 commit comments

Comments
 (0)