Skip to content

Commit 958bd5a

Browse files
authored
Merge branch 'main' into components-themeable
2 parents b54e254 + 70d1aab commit 958bd5a

File tree

15 files changed

+520
-735
lines changed

15 files changed

+520
-735
lines changed

package-lock.json

Lines changed: 433 additions & 643 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@
7676
"@types/react-dom": "^18.0.10",
7777
"@typescript-eslint/eslint-plugin": "^8.24.1",
7878
"@typescript-eslint/parser": "^8.24.1",
79-
"@vitejs/plugin-react": "^4.2.1",
80-
"@vitest/coverage-v8": "^3.0.7",
81-
"@vitest/eslint-plugin": "^1.1.31",
79+
"@vitejs/plugin-react": "^4.7.0",
80+
"@vitest/coverage-v8": "^3.2.4",
81+
"@vitest/eslint-plugin": "^1.3.13",
8282
"change-case": "^4.1.2",
8383
"chokidar-cli": "^3.0.0",
8484
"deep-freeze-es6": "^1.4.1",
@@ -111,12 +111,13 @@
111111
"stylelint-config-recommended-scss": "^14.1.0",
112112
"stylelint-prettier": "^5.0.2",
113113
"typescript": "^4.9.4",
114-
"vite": "^6.3.4",
115-
"vitest": "^3.0.7"
114+
"vite": "^6.4.1",
115+
"vitest": "^3.2.4"
116116
},
117117
"//": "ensure that typedoc uses latest typescript. It prints a warning, but works",
118118
"overrides": {
119-
"typescript": "^4.9.4"
119+
"typescript": "^4.9.4",
120+
"glob": "^10.5.0"
120121
},
121122
"lint-staged": {
122123
"*.{js,jsx,ts,tsx}": [

pages/app/app-context.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface AppUrlParams {
1313
direction: "ltr" | "rtl";
1414
motionDisabled: boolean;
1515
i18n: boolean;
16+
screenshotMode: boolean;
1617
}
1718

1819
export interface AppContextType<T = unknown> {
@@ -29,6 +30,7 @@ const appContextDefaults: AppContextType = {
2930
direction: "ltr",
3031
motionDisabled: false,
3132
i18n: true,
33+
screenshotMode: false,
3234
},
3335
setUrlParams: () => {},
3436
};

pages/app/page-layout.module.css

Lines changed: 0 additions & 8 deletions
This file was deleted.

pages/app/page-layout.tsx

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/*
7+
Spinner animations do not follow our general motion configuration, we need to disable them explicitly to get stable
8+
screenshot testing results
9+
*/
10+
.no-animation {
11+
*,
12+
*:before,
13+
*:after {
14+
animation: none !important;
15+
transition: none !important;
16+
}
17+
}

pages/app/screenshot-area.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { ReactNode } from "react";
4+
import { ReactNode, useContext } from "react";
5+
import clsx from "clsx";
6+
7+
import AppContext from "./app-context";
8+
9+
import styles from "./screenshot-area.module.css";
510

611
export function ScreenshotArea({ children }: { children: ReactNode }) {
7-
return <div className="screenshot-area">{children}</div>;
12+
const { urlParams } = useContext(AppContext);
13+
return <div className={clsx("screenshot-area", urlParams.screenshotMode && styles["no-animation"])}>{children}</div>;
814
}

scripts/docs.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33
import path from "node:path";
44

5-
import { documentTestUtils, writeComponentsDocumentation } from "@cloudscape-design/documenter";
6-
7-
import { writeSourceFile } from "./utils/files.js";
5+
import { writeComponentsDocumentation, writeTestUtilsDocumentation } from "@cloudscape-design/documenter";
86

97
const targetDir = "lib/components/internal/api-docs";
108

@@ -20,16 +18,16 @@ function componentDocs() {
2018
}
2119

2220
function testUtilDocs() {
23-
const tsconfig = path.resolve("src/test-utils/tsconfig.json");
24-
["dom", "selectors"].forEach((testUtilType) => {
25-
const componentWrapperDefinitions = documentTestUtils({ tsconfig }, `**/{${testUtilType},types}/**/*`);
26-
27-
const indexContent = `module.exports = {
28-
classes: ${JSON.stringify(componentWrapperDefinitions)}
29-
}
30-
`;
31-
32-
const outPath = path.join(targetDir, "test-utils-doc", `${testUtilType}.js`);
33-
writeSourceFile(outPath, indexContent);
21+
writeTestUtilsDocumentation({
22+
outDir: path.join(targetDir, "test-utils-doc"),
23+
tsconfigPath: path.resolve("src/test-utils/tsconfig.json"),
24+
domUtils: {
25+
root: "src/test-utils/dom/index.ts",
26+
extraExports: ["default", "ElementWrapper"],
27+
},
28+
selectorsUtils: {
29+
root: "src/test-utils/selectors/index.ts",
30+
extraExports: ["default", "ElementWrapper"],
31+
},
3432
});
3533
}

src/__tests__/__snapshots__/documenter.test.ts.snap

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,6 @@ Use it to define initials that uniquely identify the avatar's owner.",
7878
"type": "boolean",
7979
},
8080
{
81-
"description": "Specifies an object of selectors and properties that are used to apply custom styles.
82-
83-
- \`root.background\` (string) - (Optional) Background of the avatar.
84-
- \`root.borderColor\` (string) - (Optional) Border color of the avatar.
85-
- \`root.borderRadius\` (string) - (Optional) Border radius of the avatar.
86-
- \`root.borderWidth\` (string) - (Optional) Border width of the avatar.
87-
- \`root.boxShadow\` (string) - (Optional) Box shadow of the avatar.
88-
- \`root.color\` (string) - (Optional) Text color of the avatar.
89-
- \`root.focusRing.borderColor\` (string) - (Optional) Focus ring border color.
90-
- \`root.focusRing.borderRadius\` (string) - (Optional) Focus ring border radius.
91-
- \`root.focusRing.borderWidth\` (string) - (Optional) Focus ring border width.",
9281
"inlineType": {
9382
"name": "AvatarProps.Style",
9483
"properties": [

src/__tests__/__snapshots__/test-utils-wrappers.test.tsx.snap

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ findAllSupportPromptGroups(selector?: string): Array<SupportPromptGroupWrapper>;
104104
105105
106106
ElementWrapper.prototype.findAvatar = function(selector) {
107-
const rootSelector = \`.\${AvatarWrapper.rootSelector}\`;
107+
let rootSelector = \`.\${AvatarWrapper.rootSelector}\`;
108+
if("legacyRootSelector" in AvatarWrapper && AvatarWrapper.legacyRootSelector){
109+
rootSelector = \`:is(.\${AvatarWrapper.rootSelector}, .\${AvatarWrapper.legacyRootSelector})\`;
110+
}
108111
// casting to 'any' is needed to avoid this issue with generics
109112
// https://github.com/microsoft/TypeScript/issues/29132
110113
return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, AvatarWrapper);
@@ -114,7 +117,10 @@ ElementWrapper.prototype.findAllAvatars = function(selector) {
114117
return this.findAllComponents(AvatarWrapper, selector);
115118
};
116119
ElementWrapper.prototype.findChatBubble = function(selector) {
117-
const rootSelector = \`.\${ChatBubbleWrapper.rootSelector}\`;
120+
let rootSelector = \`.\${ChatBubbleWrapper.rootSelector}\`;
121+
if("legacyRootSelector" in ChatBubbleWrapper && ChatBubbleWrapper.legacyRootSelector){
122+
rootSelector = \`:is(.\${ChatBubbleWrapper.rootSelector}, .\${ChatBubbleWrapper.legacyRootSelector})\`;
123+
}
118124
// casting to 'any' is needed to avoid this issue with generics
119125
// https://github.com/microsoft/TypeScript/issues/29132
120126
return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, ChatBubbleWrapper);
@@ -124,7 +130,10 @@ ElementWrapper.prototype.findAllChatBubbles = function(selector) {
124130
return this.findAllComponents(ChatBubbleWrapper, selector);
125131
};
126132
ElementWrapper.prototype.findLoadingBar = function(selector) {
127-
const rootSelector = \`.\${LoadingBarWrapper.rootSelector}\`;
133+
let rootSelector = \`.\${LoadingBarWrapper.rootSelector}\`;
134+
if("legacyRootSelector" in LoadingBarWrapper && LoadingBarWrapper.legacyRootSelector){
135+
rootSelector = \`:is(.\${LoadingBarWrapper.rootSelector}, .\${LoadingBarWrapper.legacyRootSelector})\`;
136+
}
128137
// casting to 'any' is needed to avoid this issue with generics
129138
// https://github.com/microsoft/TypeScript/issues/29132
130139
return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, LoadingBarWrapper);
@@ -134,7 +143,10 @@ ElementWrapper.prototype.findAllLoadingBars = function(selector) {
134143
return this.findAllComponents(LoadingBarWrapper, selector);
135144
};
136145
ElementWrapper.prototype.findSupportPromptGroup = function(selector) {
137-
const rootSelector = \`.\${SupportPromptGroupWrapper.rootSelector}\`;
146+
let rootSelector = \`.\${SupportPromptGroupWrapper.rootSelector}\`;
147+
if("legacyRootSelector" in SupportPromptGroupWrapper && SupportPromptGroupWrapper.legacyRootSelector){
148+
rootSelector = \`:is(.\${SupportPromptGroupWrapper.rootSelector}, .\${SupportPromptGroupWrapper.legacyRootSelector})\`;
149+
}
138150
// casting to 'any' is needed to avoid this issue with generics
139151
// https://github.com/microsoft/TypeScript/issues/29132
140152
return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, SupportPromptGroupWrapper);
@@ -250,7 +262,10 @@ findAllSupportPromptGroups(selector?: string): MultiElementWrapper<SupportPrompt
250262
251263
252264
ElementWrapper.prototype.findAvatar = function(selector) {
253-
const rootSelector = \`.\${AvatarWrapper.rootSelector}\`;
265+
let rootSelector = \`.\${AvatarWrapper.rootSelector}\`;
266+
if("legacyRootSelector" in AvatarWrapper && AvatarWrapper.legacyRootSelector){
267+
rootSelector = \`:is(.\${AvatarWrapper.rootSelector}, .\${AvatarWrapper.legacyRootSelector})\`;
268+
}
254269
// casting to 'any' is needed to avoid this issue with generics
255270
// https://github.com/microsoft/TypeScript/issues/29132
256271
return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, AvatarWrapper);
@@ -260,7 +275,10 @@ ElementWrapper.prototype.findAllAvatars = function(selector) {
260275
return this.findAllComponents(AvatarWrapper, selector);
261276
};
262277
ElementWrapper.prototype.findChatBubble = function(selector) {
263-
const rootSelector = \`.\${ChatBubbleWrapper.rootSelector}\`;
278+
let rootSelector = \`.\${ChatBubbleWrapper.rootSelector}\`;
279+
if("legacyRootSelector" in ChatBubbleWrapper && ChatBubbleWrapper.legacyRootSelector){
280+
rootSelector = \`:is(.\${ChatBubbleWrapper.rootSelector}, .\${ChatBubbleWrapper.legacyRootSelector})\`;
281+
}
264282
// casting to 'any' is needed to avoid this issue with generics
265283
// https://github.com/microsoft/TypeScript/issues/29132
266284
return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, ChatBubbleWrapper);
@@ -270,7 +288,10 @@ ElementWrapper.prototype.findAllChatBubbles = function(selector) {
270288
return this.findAllComponents(ChatBubbleWrapper, selector);
271289
};
272290
ElementWrapper.prototype.findLoadingBar = function(selector) {
273-
const rootSelector = \`.\${LoadingBarWrapper.rootSelector}\`;
291+
let rootSelector = \`.\${LoadingBarWrapper.rootSelector}\`;
292+
if("legacyRootSelector" in LoadingBarWrapper && LoadingBarWrapper.legacyRootSelector){
293+
rootSelector = \`:is(.\${LoadingBarWrapper.rootSelector}, .\${LoadingBarWrapper.legacyRootSelector})\`;
294+
}
274295
// casting to 'any' is needed to avoid this issue with generics
275296
// https://github.com/microsoft/TypeScript/issues/29132
276297
return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, LoadingBarWrapper);
@@ -280,7 +301,10 @@ ElementWrapper.prototype.findAllLoadingBars = function(selector) {
280301
return this.findAllComponents(LoadingBarWrapper, selector);
281302
};
282303
ElementWrapper.prototype.findSupportPromptGroup = function(selector) {
283-
const rootSelector = \`.\${SupportPromptGroupWrapper.rootSelector}\`;
304+
let rootSelector = \`.\${SupportPromptGroupWrapper.rootSelector}\`;
305+
if("legacyRootSelector" in SupportPromptGroupWrapper && SupportPromptGroupWrapper.legacyRootSelector){
306+
rootSelector = \`:is(.\${SupportPromptGroupWrapper.rootSelector}, .\${SupportPromptGroupWrapper.legacyRootSelector})\`;
307+
}
284308
// casting to 'any' is needed to avoid this issue with generics
285309
// https://github.com/microsoft/TypeScript/issues/29132
286310
return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, SupportPromptGroupWrapper);

0 commit comments

Comments
 (0)