From 81b477850d29f5187b180cf6958dd61b2c0b2f34 Mon Sep 17 00:00:00 2001 From: Boris Serdiuk Date: Tue, 12 Dec 2023 18:11:45 +0100 Subject: [PATCH] replace @cloudscape-design/components with subpath imports --- .eslintrc | 6 +++++- pages/conditional/conditional.page.tsx | 5 ++++- pages/dnd/commons.tsx | 4 +++- pages/dnd/engine-query-test.page.tsx | 8 ++++++-- pages/dnd/events-table.tsx | 4 +++- pages/dnd/items.tsx | 4 +++- pages/dnd/update-layout-test.page.tsx | 2 +- pages/grid/with-widget-containers-compact.page.tsx | 2 +- pages/grid/with-widget-containers.page.tsx | 2 +- pages/micro-frontend/integration.page.tsx | 7 ++++++- pages/widget-container/permutations.page.tsx | 5 ++++- pages/with-app-layout/app-layout.tsx | 8 +++++++- pages/with-app-layout/delete-confirmation-modal.tsx | 5 ++++- pages/with-app-layout/widgets-board.tsx | 3 ++- pages/with-app-layout/widgets-palette.tsx | 2 +- src/board-item/__tests__/board-item.test.tsx | 2 +- src/board/__tests__/board.test.tsx | 2 +- src/internal/drag-handle/index.tsx | 2 +- src/internal/resize-handle/index.tsx | 2 +- 19 files changed, 55 insertions(+), 20 deletions(-) diff --git a/.eslintrc b/.eslintrc index b0245c8c..47585a46 100644 --- a/.eslintrc +++ b/.eslintrc @@ -58,13 +58,17 @@ [" Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.", " SPDX-License-Identifier: Apache-2.0"] ], "no-restricted-imports": [ - "warn", + "error", { "paths": [ { "name": "react", "importNames": ["default"], "message": "Prefer named imports." + }, + { + "name": "@cloudscape-design/components", + "message": "Prefer subpath imports." } ] } diff --git a/pages/conditional/conditional.page.tsx b/pages/conditional/conditional.page.tsx index f06df3c9..a07387ac 100644 --- a/pages/conditional/conditional.page.tsx +++ b/pages/conditional/conditional.page.tsx @@ -1,6 +1,9 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Box, Button, Container, Header } from "@cloudscape-design/components"; +import Box from "@cloudscape-design/components/box"; +import Button from "@cloudscape-design/components/button"; +import Container from "@cloudscape-design/components/container"; +import Header from "@cloudscape-design/components/header"; import { useState } from "react"; import { Board, BoardItem, BoardProps } from "../../lib/components"; import { boardI18nStrings, boardItemI18nStrings } from "../shared/i18n"; diff --git a/pages/dnd/commons.tsx b/pages/dnd/commons.tsx index 2c63304e..735ae16f 100644 --- a/pages/dnd/commons.tsx +++ b/pages/dnd/commons.tsx @@ -1,7 +1,9 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Button, FormField, SpaceBetween } from "@cloudscape-design/components"; import Box from "@cloudscape-design/components/box"; +import Button from "@cloudscape-design/components/button"; +import FormField from "@cloudscape-design/components/form-field"; +import SpaceBetween from "@cloudscape-design/components/space-between"; import { useState } from "react"; export function Counter() { diff --git a/pages/dnd/engine-query-test.page.tsx b/pages/dnd/engine-query-test.page.tsx index 6ad6a317..baf7692e 100644 --- a/pages/dnd/engine-query-test.page.tsx +++ b/pages/dnd/engine-query-test.page.tsx @@ -1,7 +1,11 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 - -import { Button, Form, FormField, Header, SpaceBetween, Textarea } from "@cloudscape-design/components"; +import Button from "@cloudscape-design/components/button"; +import Form from "@cloudscape-design/components/form"; +import FormField from "@cloudscape-design/components/form-field"; +import Header from "@cloudscape-design/components/header"; +import SpaceBetween from "@cloudscape-design/components/space-between"; +import Textarea from "@cloudscape-design/components/textarea"; import { useState } from "react"; import { useSearchParams } from "react-router-dom"; import PageLayout from "../app/page-layout"; diff --git a/pages/dnd/events-table.tsx b/pages/dnd/events-table.tsx index c5d65511..0d0fd58e 100644 --- a/pages/dnd/events-table.tsx +++ b/pages/dnd/events-table.tsx @@ -1,6 +1,8 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Link, StatusIndicator, Table } from "@cloudscape-design/components"; +import Link from "@cloudscape-design/components/link"; +import StatusIndicator from "@cloudscape-design/components/status-indicator"; +import Table from "@cloudscape-design/components/table"; interface EventItem { id: string; diff --git a/pages/dnd/items.tsx b/pages/dnd/items.tsx index d745259e..e2c9b548 100644 --- a/pages/dnd/items.tsx +++ b/pages/dnd/items.tsx @@ -1,6 +1,8 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Box, Link, SpaceBetween } from "@cloudscape-design/components"; +import Box from "@cloudscape-design/components/box"; +import Link from "@cloudscape-design/components/link"; +import SpaceBetween from "@cloudscape-design/components/space-between"; import { BoardProps, ItemsPaletteProps } from "../../lib/components"; import { fromMatrix } from "../../lib/components/internal/debug-tools"; import { BoardItemDefinition, BoardItemDefinitionBase } from "../../lib/components/internal/interfaces"; diff --git a/pages/dnd/update-layout-test.page.tsx b/pages/dnd/update-layout-test.page.tsx index f97f87f2..dcd9afb4 100644 --- a/pages/dnd/update-layout-test.page.tsx +++ b/pages/dnd/update-layout-test.page.tsx @@ -1,7 +1,7 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Header } from "@cloudscape-design/components"; +import Header from "@cloudscape-design/components/header"; import { useState } from "react"; import { Board, BoardItem, BoardProps, ItemsPalette, ItemsPaletteProps } from "../../lib/components"; import PageLayout from "../app/page-layout"; diff --git a/pages/grid/with-widget-containers-compact.page.tsx b/pages/grid/with-widget-containers-compact.page.tsx index 2420d5a5..77c0aed9 100644 --- a/pages/grid/with-widget-containers-compact.page.tsx +++ b/pages/grid/with-widget-containers-compact.page.tsx @@ -1,6 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Header } from "@cloudscape-design/components"; +import Header from "@cloudscape-design/components/header"; import { Board, BoardItem } from "../../lib/components"; import PageLayout from "../app/page-layout"; import { TestBed } from "../app/test-bed"; diff --git a/pages/grid/with-widget-containers.page.tsx b/pages/grid/with-widget-containers.page.tsx index 6c63778f..befcceec 100644 --- a/pages/grid/with-widget-containers.page.tsx +++ b/pages/grid/with-widget-containers.page.tsx @@ -1,6 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Header } from "@cloudscape-design/components"; +import Header from "@cloudscape-design/components/header"; import { Board, BoardItem } from "../../lib/components"; import PageLayout from "../app/page-layout"; import { TestBed } from "../app/test-bed"; diff --git a/pages/micro-frontend/integration.page.tsx b/pages/micro-frontend/integration.page.tsx index cab76c7c..5c5ba112 100644 --- a/pages/micro-frontend/integration.page.tsx +++ b/pages/micro-frontend/integration.page.tsx @@ -1,7 +1,12 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { AppLayout, Box, Button, ContentLayout, Header, SplitPanel } from "@cloudscape-design/components"; +import AppLayout from "@cloudscape-design/components/app-layout"; +import Box from "@cloudscape-design/components/box"; +import Button from "@cloudscape-design/components/button"; +import ContentLayout from "@cloudscape-design/components/content-layout"; +import Header from "@cloudscape-design/components/header"; +import SplitPanel from "@cloudscape-design/components/split-panel"; import { ReactNode, useLayoutEffect, useRef, useState } from "react"; import { createRoot } from "react-dom/client"; import { Board, BoardItem, ItemsPalette } from "../../lib/components"; diff --git a/pages/widget-container/permutations.page.tsx b/pages/widget-container/permutations.page.tsx index 19a129e9..c88bccff 100644 --- a/pages/widget-container/permutations.page.tsx +++ b/pages/widget-container/permutations.page.tsx @@ -1,7 +1,10 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Box, Button, ButtonDropdown, SpaceBetween } from "@cloudscape-design/components"; +import Box from "@cloudscape-design/components/box"; +import Button from "@cloudscape-design/components/button"; +import ButtonDropdown from "@cloudscape-design/components/button-dropdown"; import Header from "@cloudscape-design/components/header"; +import SpaceBetween from "@cloudscape-design/components/space-between"; import { Board, BoardItem } from "../../lib/components"; import PageLayout from "../app/page-layout"; import { ScreenshotArea } from "../screenshot-area"; diff --git a/pages/with-app-layout/app-layout.tsx b/pages/with-app-layout/app-layout.tsx index 751b0511..f959fb94 100644 --- a/pages/with-app-layout/app-layout.tsx +++ b/pages/with-app-layout/app-layout.tsx @@ -1,7 +1,13 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { AppLayout, Box, Button, ContentLayout, Header, SpaceBetween, SplitPanel } from "@cloudscape-design/components"; +import AppLayout from "@cloudscape-design/components/app-layout"; +import Box from "@cloudscape-design/components/box"; +import Button from "@cloudscape-design/components/button"; +import ContentLayout from "@cloudscape-design/components/content-layout"; +import Header from "@cloudscape-design/components/header"; +import SpaceBetween from "@cloudscape-design/components/space-between"; +import SplitPanel from "@cloudscape-design/components/split-panel"; import { ReactNode, useState } from "react"; import { appLayoutI18nStrings, clientI18nStrings, splitPanelI18nStrings } from "../shared/i18n"; diff --git a/pages/with-app-layout/delete-confirmation-modal.tsx b/pages/with-app-layout/delete-confirmation-modal.tsx index 656b7a7d..592aa82e 100644 --- a/pages/with-app-layout/delete-confirmation-modal.tsx +++ b/pages/with-app-layout/delete-confirmation-modal.tsx @@ -1,7 +1,10 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Button, Form, Modal, SpaceBetween } from "@cloudscape-design/components"; +import Button from "@cloudscape-design/components/button"; +import Form from "@cloudscape-design/components/form"; +import Modal from "@cloudscape-design/components/modal"; +import SpaceBetween from "@cloudscape-design/components/space-between"; import { clientI18nStrings } from "../shared/i18n"; export function DeleteConfirmationModal({ diff --git a/pages/with-app-layout/widgets-board.tsx b/pages/with-app-layout/widgets-board.tsx index 0e4c4da6..79fac5be 100644 --- a/pages/with-app-layout/widgets-board.tsx +++ b/pages/with-app-layout/widgets-board.tsx @@ -1,8 +1,9 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Box, Header } from "@cloudscape-design/components"; +import Box from "@cloudscape-design/components/box"; import ButtonDropdown from "@cloudscape-design/components/button-dropdown"; +import Header from "@cloudscape-design/components/header"; import { useState } from "react"; import { Board, BoardItem, BoardProps } from "../../lib/components"; import LiveRegion from "../../lib/components/internal/live-region"; diff --git a/pages/with-app-layout/widgets-palette.tsx b/pages/with-app-layout/widgets-palette.tsx index 83616c4b..f447cafc 100644 --- a/pages/with-app-layout/widgets-palette.tsx +++ b/pages/with-app-layout/widgets-palette.tsx @@ -1,7 +1,7 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Header } from "@cloudscape-design/components"; +import Header from "@cloudscape-design/components/header"; import { BoardItem, ItemsPalette, ItemsPaletteProps } from "../../lib/components"; import LiveRegion from "../../lib/components/internal/live-region"; import { boardItemI18nStrings, clientI18nStrings, itemsPaletteI18nStrings } from "../shared/i18n"; diff --git a/src/board-item/__tests__/board-item.test.tsx b/src/board-item/__tests__/board-item.test.tsx index cf0fc756..6fc3a10d 100644 --- a/src/board-item/__tests__/board-item.test.tsx +++ b/src/board-item/__tests__/board-item.test.tsx @@ -1,6 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Container } from "@cloudscape-design/components"; +import Container from "@cloudscape-design/components/container"; import { cleanup, render as libRender } from "@testing-library/react"; import { ReactElement } from "react"; import { afterEach, describe, expect, test } from "vitest"; diff --git a/src/board/__tests__/board.test.tsx b/src/board/__tests__/board.test.tsx index 072bdba9..ef0490a7 100644 --- a/src/board/__tests__/board.test.tsx +++ b/src/board/__tests__/board.test.tsx @@ -1,6 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Button } from "@cloudscape-design/components"; +import Button from "@cloudscape-design/components/button"; import { KeyCode } from "@cloudscape-design/test-utils-core/utils"; import { cleanup, fireEvent, render, waitFor } from "@testing-library/react"; import { vi } from "vitest"; diff --git a/src/internal/drag-handle/index.tsx b/src/internal/drag-handle/index.tsx index ecf530b3..8f4568c8 100644 --- a/src/internal/drag-handle/index.tsx +++ b/src/internal/drag-handle/index.tsx @@ -1,6 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Icon } from "@cloudscape-design/components"; +import Icon from "@cloudscape-design/components/icon"; import clsx from "clsx"; import { ForwardedRef, KeyboardEvent, PointerEvent, forwardRef } from "react"; diff --git a/src/internal/resize-handle/index.tsx b/src/internal/resize-handle/index.tsx index bbea96b1..a81d2d0c 100644 --- a/src/internal/resize-handle/index.tsx +++ b/src/internal/resize-handle/index.tsx @@ -1,6 +1,6 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import { Icon } from "@cloudscape-design/components"; +import Icon from "@cloudscape-design/components/icon"; import clsx from "clsx"; import { KeyboardEvent, PointerEvent } from "react"; import Handle from "../handle";