Skip to content

Commit c9dd827

Browse files
author
Ruben Carvalho
committed
Merge branch 'main' into line_wrap
2 parents 6b9b6e7 + 019c5cd commit c9dd827

File tree

10 files changed

+1825
-1171
lines changed

10 files changed

+1825
-1171
lines changed

package-lock.json

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

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
"preview": "vite preview",
2121
"start": "run-p start:server start:watch:ts start:watch:css",
2222
"start:server": "vite",
23-
"start:watch:ts": "tsc --watch",
23+
"start:watch:ts": "npm run build:src:js -- --watch",
2424
"start:watch:css": "chokidar \"./src/**/*.scss\" -c \"npm run build:src:css\"",
2525
"build:pkg": "node scripts/package-json.js",
26-
"build:src:js": "tsc -p tsconfig.json",
26+
"build:src:js": "tsc -p tsconfig.json --inlineSources --sourceMap",
2727
"build:src:css": "node scripts/compile-styles.js",
2828
"build:src:test-utils": "node scripts/test-utils.js",
2929
"build:src:copy": "cp README.md lib/components/",
@@ -45,7 +45,6 @@
4545
"./highlight/java": "./code-view/highlight/java.js",
4646
"./highlight/javascript": "./code-view/highlight/javascript.js",
4747
"./highlight/json": "./code-view/highlight/json.js",
48-
"./highlight/jsx": "./code-view/highlight/jsx.js",
4948
"./highlight/kotlin": "./code-view/highlight/kotlin.js",
5049
"./highlight/markdown": "./code-view/highlight/markdown.js",
5150
"./highlight/php": "./code-view/highlight/php.js",

scripts/test-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ function generateIndexFileContent({ testUtilType, buildFinderInterface }) {
8181

8282
function compileTypescript() {
8383
const config = path.resolve("src/test-utils/tsconfig.json");
84-
execaSync("tsc", ["-p", config, "--sourceMap"], { stdio: "inherit" });
84+
execaSync("tsc", ["-p", config, "--sourceMap", "--inlineSources"], { stdio: "inherit" });
8585
}

src/__tests__/base-props-support.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ describe(`base props support for code-view`, async () => {
1919
expect(container.firstElementChild).toHaveAttribute("data-testid", "example");
2020
});
2121

22-
test("should allow id", () => {
22+
test("should not allow id", () => {
2323
const { container } = renderComponent(<Component {...props} id="example" />);
24-
expect(container.querySelector("#example")).not.toBeNull();
24+
expect(container.querySelector("#example")).toBeNull();
2525
});
2626

2727
test("should not allow className", () => {

src/code-view/highlight/jsx.ts

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

src/code-view/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import { InternalCodeView } from "./internal";
88
export type { CodeViewProps };
99

1010
export default function CodeView(props: CodeViewProps) {
11-
const baseComponentProps = useBaseComponent("CodeView");
11+
const baseComponentProps = useBaseComponent("CodeView", {
12+
props: { lineNumbers: props.lineNumbers },
13+
});
1214
return <InternalCodeView {...props} {...baseComponentProps} />;
1315
}
1416

src/internal/base-component/get-data-attributes.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { initAwsUiVersions, useComponentMetadata } from "@cloudscape-design/component-toolkit/internal";
4+
import {
5+
ComponentConfiguration,
6+
initAwsUiVersions,
7+
useComponentMetadata,
8+
} from "@cloudscape-design/component-toolkit/internal";
59
import { MutableRefObject } from "react";
610
import { PACKAGE_SOURCE, PACKAGE_VERSION } from "../environment";
711
import { useTelemetry } from "./use-telemetry";
@@ -17,34 +21,24 @@ export interface InternalBaseComponentProps {
1721
* attached to the (internal) component's root DOM node. The hook takes care of attaching the metadata to this
1822
* root DOM node and emits the telemetry for this component.
1923
*/
20-
export default function useBaseComponent<T = any>(componentName: string) {
21-
useTelemetry(componentName);
24+
export default function useBaseComponent<T = any>(componentName: string, config?: ComponentConfiguration) {
25+
useTelemetry(componentName, config);
2226
const elementRef = useComponentMetadata<T>(componentName, PACKAGE_VERSION);
2327
return { __internalRootRef: elementRef };
2428
}
2529

26-
export interface BaseComponentProps {
27-
/**
28-
* Adds the specified classes to the root element of the component.
29-
* @deprecated Custom CSS is not supported. For other use cases, use [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes).
30-
*/
31-
className?: string;
32-
/**
33-
* Adds the specified ID to the root element of the component.
34-
* @deprecated Custom CSS is not supported. For other use cases, use [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes).
35-
*/
36-
id?: string;
37-
// we also support data-* attributes, but they are always implicitly allowed by typescript
38-
// http://www.typescriptlang.org/docs/handbook/jsx.html#attribute-type-checking
39-
// "Note: If an attribute name is not a valid JS identifier (like a data-* attribute), it is not considered to be an error"
40-
}
30+
// we also support data-* attributes, but they are always implicitly allowed by typescript
31+
// http://www.typescriptlang.org/docs/handbook/jsx.html#attribute-type-checking
32+
// "Note: If an attribute name is not a valid JS identifier (like a data-* attribute), it is not considered to be an error"
33+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
34+
export interface BaseComponentProps {}
4135

4236
export function getBaseProps(props: BaseComponentProps) {
43-
const baseProps: Record<string, any> = {};
37+
const baseProps: Record<string, string> = {};
4438
Object.keys(props).forEach((prop) => {
45-
if (prop === "id" || prop.match(/^data-/)) {
46-
baseProps[prop] = (props as Record<string, any>)[prop];
39+
if (prop.startsWith("data-")) {
40+
baseProps[prop] = (props as Record<string, string>)[prop];
4741
}
4842
});
49-
return baseProps as BaseComponentProps;
43+
return baseProps;
5044
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import { useComponentMetrics } from "@cloudscape-design/component-toolkit/internal";
4+
import { ComponentConfiguration, useComponentMetrics } from "@cloudscape-design/component-toolkit/internal";
55
import { PACKAGE_SOURCE, PACKAGE_VERSION, THEME } from "../environment";
66
import { useVisualRefresh } from "./use-visual-refresh";
77

8-
export function useTelemetry(componentName: string) {
8+
export function useTelemetry(componentName: string, config?: ComponentConfiguration) {
99
const theme = useVisualRefresh() ? "vr" : THEME;
10-
useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme });
10+
useComponentMetrics(componentName, { packageSource: PACKAGE_SOURCE, packageVersion: PACKAGE_VERSION, theme }, config);
1111
}

vite.unit.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export default defineConfig({
1616
coverage: {
1717
enabled: process.env.CI === "true",
1818
provider: "istanbul",
19-
include: ["src/**"],
20-
exclude: ["**/debug-tools/**", "**/__tests__/**"],
19+
include: ["src/**", "lib/components/**"],
20+
exclude: ["**/__tests__/**", "**/*.d.ts", "**/api-docs/**", "**/test-utils/selectors/**"],
2121
},
2222
},
2323
});

0 commit comments

Comments
 (0)