From 9a344ae949186817d92ee36d4d659ab5c2986af4 Mon Sep 17 00:00:00 2001 From: Arno V Date: Sat, 28 Sep 2024 18:42:13 -0400 Subject: [PATCH] fix: removing remaining redundant dev dependencies (#707) --- packages/ui-menu/package.json | 4 - packages/ui-menu/src/components/Menu/Menu.tsx | 14 +- .../components/Menu/__tests__/Menu.test.tsx | 24 ++- packages/ui-textinput/package.json | 12 +- .../__tests__/TextInputMask.test.tsx | 174 ++++++++++-------- pnpm-lock.yaml | 14 -- 6 files changed, 126 insertions(+), 116 deletions(-) diff --git a/packages/ui-menu/package.json b/packages/ui-menu/package.json index 61bc1e1c..d32fc842 100644 --- a/packages/ui-menu/package.json +++ b/packages/ui-menu/package.json @@ -37,10 +37,6 @@ "react": "^18.3.1", "react-dom": "^18.3.1" }, - "devDependencies": { - "@versini/ui-button": "workspace:../ui-button", - "@versini/ui-icons": "workspace:../ui-icons" - }, "dependencies": { "@floating-ui/react": "0.26.24", "@tailwindcss/typography": "0.5.15", diff --git a/packages/ui-menu/src/components/Menu/Menu.tsx b/packages/ui-menu/src/components/Menu/Menu.tsx index bd327190..c46238ba 100644 --- a/packages/ui-menu/src/components/Menu/Menu.tsx +++ b/packages/ui-menu/src/components/Menu/Menu.tsx @@ -102,11 +102,17 @@ export const MenuComponent = forwardRef< getDisplayName(trigger) === "Button" || getDisplayName(trigger) === "ButtonIcon"; + const uiButtonsExtraProps = noInternalClick + ? { + noInternalClick, + focusMode, + mode, + spacing, + } + : {}; + const triggerElement = React.cloneElement(trigger as React.ReactElement, { - mode, - focusMode, - spacing, - noInternalClick, + ...uiButtonsExtraProps, "aria-label": label, "data-open": isOpen ? "" : undefined, "data-focus-inside": hasFocusInside ? "" : undefined, diff --git a/packages/ui-menu/src/components/Menu/__tests__/Menu.test.tsx b/packages/ui-menu/src/components/Menu/__tests__/Menu.test.tsx index bdf3c21a..ada17bbc 100644 --- a/packages/ui-menu/src/components/Menu/__tests__/Menu.test.tsx +++ b/packages/ui-menu/src/components/Menu/__tests__/Menu.test.tsx @@ -1,7 +1,5 @@ import { render, screen, waitFor } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; -import { Button, ButtonIcon } from "@versini/ui-button"; -import { IconSettings } from "@versini/ui-icons"; import { Menu, MenuItem, MenuSeparator } from "../.."; @@ -12,8 +10,18 @@ const THIRD_MENU_ITEM = "Menu 3"; const FOURTH_MENU_ITEM = "Menu 4"; const FIFTH_MENU_ITEM = "Menu 5"; +const ButtonIcon = ({ + children, + noInternalClick, + focusMode, + mode, + spacing, + ...props +}: any) => ; +ButtonIcon.displayName = "ButtonIcon"; + const SimpleMenu = ({ ...props }) => ( - Click Me} {...props}> + Click Me} {...props}> @@ -27,7 +35,9 @@ const SimpleMenuIcon = ({ ...props }) => ( - + + + } {...props} @@ -160,7 +170,7 @@ describe("Menu behaviors", () => { const onOpenChange = vi.fn(); const { user } = renderWithUserEvent( Click Me} + trigger={} label={MENU_TRIGGER_LABEL} onOpenChange={onOpenChange} > @@ -189,7 +199,7 @@ describe("Menu behaviors", () => { it("should trigger the MenuItem onClick callback when a menuitem is selected", async () => { const onClick = vi.fn(); const { user } = renderWithUserEvent( - Click Me} label={MENU_TRIGGER_LABEL}> + Click Me} label={MENU_TRIGGER_LABEL}> @@ -212,7 +222,7 @@ describe("Menu behaviors", () => { it("should trigger the MenuItem onFocus callback when a menuitem is selected", async () => { const onFocus = vi.fn(); const { user } = renderWithUserEvent( - Click Me} label={MENU_TRIGGER_LABEL}> + Click Me} label={MENU_TRIGGER_LABEL}> diff --git a/packages/ui-textinput/package.json b/packages/ui-textinput/package.json index 14a78352..14d30a75 100644 --- a/packages/ui-textinput/package.json +++ b/packages/ui-textinput/package.json @@ -14,9 +14,7 @@ "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", - "files": [ - "dist" - ], + "files": ["dist"], "scripts": { "build:check": "tsc", "build:js": "vite build", @@ -37,10 +35,6 @@ "react": "^18.3.1", "react-dom": "^18.3.1" }, - "devDependencies": { - "@versini/ui-button": "workspace:../ui-button", - "@versini/ui-icons": "workspace:../ui-icons" - }, "dependencies": { "@tailwindcss/typography": "0.5.15", "@versini/ui-hooks": "workspace:../ui-hooks", @@ -48,7 +42,5 @@ "clsx": "2.1.1", "tailwindcss": "3.4.13" }, - "sideEffects": [ - "**/*.css" - ] + "sideEffects": ["**/*.css"] } diff --git a/packages/ui-textinput/src/components/TextInput/__tests__/TextInputMask.test.tsx b/packages/ui-textinput/src/components/TextInput/__tests__/TextInputMask.test.tsx index 07ecd435..307cbad3 100644 --- a/packages/ui-textinput/src/components/TextInput/__tests__/TextInputMask.test.tsx +++ b/packages/ui-textinput/src/components/TextInput/__tests__/TextInputMask.test.tsx @@ -1,11 +1,30 @@ import { act, fireEvent, render, screen } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; -import { ButtonIcon } from "@versini/ui-button"; -import { IconHide } from "@versini/ui-icons"; import { TextInputMask } from "../.."; import { expectToHaveClasses } from "../../../../../../configuration/tests-helpers"; +const MyButtonIcon = ({ + children, + noInternalClick, + focusMode, + mode, + spacing, + label, + ...props +}: any) => ( + +); +MyButtonIcon.displayName = "ButtonIcon"; + +const MyIconHide = () => ( + + + +); + function renderWithUserEvent(jsx: JSX.Element) { return { user: userEvent.setup(), @@ -26,9 +45,9 @@ describe("TextInputMask modifiers", () => { label="hello world" name="toto" rightElement={ - - - + + + } />, ); @@ -51,9 +70,9 @@ describe("TextInputMask modifiers", () => { label="hello world" name="toto" rightElement={ - - - + + + } />, ); @@ -69,9 +88,9 @@ describe("TextInputMask modifiers", () => { noBorder data-testid="txtnpt-1" rightElement={ - - - + + + } />, ); @@ -87,9 +106,9 @@ describe("TextInputMask modifiers", () => { labelHidden data-testid="txtnpt-1" rightElement={ - - - + + + } />, ); @@ -106,9 +125,9 @@ describe("TextInputMask modifiers", () => { raw data-testid="txtnpt-1" rightElement={ - - - + + + } />, ); @@ -124,9 +143,9 @@ describe("TextInputMask modifiers", () => { className="toto" data-testid="txtnpt-1" rightElement={ - - - + + + } />, ); @@ -149,9 +168,9 @@ describe("TextInputMask modifiers", () => { inputClassName="toto" data-testid="txtnpt-1" rightElement={ - - - + + + } />, ); @@ -167,9 +186,9 @@ describe("TextInputMask modifiers", () => { label="hello world" name="toto" rightElement={ - - - + + + } />, ); @@ -204,9 +223,9 @@ describe("TextInputMask methods", () => { name="toto" data-testid="txtnpt-1" rightElement={ - - - + + + } />, ); @@ -225,9 +244,9 @@ describe("TextInputMask methods", () => { label="hello world" onMaskChange={onMaskChangeHandler} rightElement={ - - - + + + } />, ); @@ -249,9 +268,9 @@ describe("TextInputMask methods", () => { data-testid="txtnptmsk-1" onTextInputMaskBlur={onTextInputMaskBlurMock} rightElement={ - - - + + + } />, ); @@ -277,9 +296,9 @@ describe("TextInputMask methods", () => { data-testid="txtnptmsk-1" onTextInputMaskBlur={onTextInputMaskBlurMock} rightElement={ - - - + + + } />, ); @@ -306,9 +325,9 @@ describe("TextInputMask methods", () => { data-testid="txtnptmsk-1" onTextInputMaskBlur={onTextInputMaskBlurMock} rightElement={ - - - + + + } />, ); @@ -333,9 +352,9 @@ describe("TextInputMask methods", () => { data-testid="txtnptmsk-1" onTextInputMaskBlur={onTextInputMaskBlurMock} rightElement={ - - - + + + } />, ); @@ -361,9 +380,9 @@ describe("TextInputMask methods", () => { data-testid="txtnptmsk-1" onBlur={onBlurMock} rightElement={ - - - + + + } />, ); @@ -384,9 +403,9 @@ describe("TextInputMask methods", () => { data-testid="txtnptmsk-1" onFocus={onFocusMock} rightElement={ - - - + + + } />, ); @@ -407,9 +426,9 @@ describe("TextInputMask accessibility", () => { label="hello world" name="toto" rightElement={ - - - + + + } />, ); @@ -433,9 +452,9 @@ describe("TextInputMask accessibility", () => { label="hello world" name="toto" rightElement={ - - - + + + } />, ); @@ -456,13 +475,14 @@ describe("TextInputMask show/hide button tests", () => { name="hello" label="hello world" rightElement={ - - - + + + } />, ); + screen.debug(); const buttonLabel = screen.getByLabelText("Show"); expect(buttonLabel).toBeInTheDocument(); }); @@ -473,9 +493,9 @@ describe("TextInputMask show/hide button tests", () => { name="hello" label="hello world" rightElement={ - - - + + + } />, ); @@ -494,9 +514,9 @@ describe("TextInputMask show/hide button tests", () => { name="hello" label="hello world" rightElement={ - - - + + + } />, ); @@ -515,9 +535,9 @@ describe("TextInputMask show/hide button tests", () => { name="hello" label="hello world" rightElement={ - - - + + + } />, ); @@ -547,9 +567,9 @@ describe("TextInputMask timer tests", () => { name="hello" label="hello world" rightElement={ - - - + + + } />, ); @@ -578,9 +598,9 @@ describe("TextInputMask timer tests", () => { name="hello" label="hello world" rightElement={ - - - + + + } />, ); @@ -645,9 +665,9 @@ describe("TextInputMask timer tests", () => { label="hello world" onMaskChange={onMaskChangeHandler} rightElement={ - - - + + + } />, ); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index adce7f68..44ab5ee2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -553,13 +553,6 @@ importers: tailwindcss: specifier: 3.4.13 version: 3.4.13 - devDependencies: - '@versini/ui-button': - specifier: workspace:../ui-button - version: link:../ui-button - '@versini/ui-icons': - specifier: workspace:../ui-icons - version: link:../ui-icons packages/ui-panel: dependencies: @@ -746,13 +739,6 @@ importers: tailwindcss: specifier: 3.4.13 version: 3.4.13 - devDependencies: - '@versini/ui-button': - specifier: workspace:../ui-button - version: link:../ui-button - '@versini/ui-icons': - specifier: workspace:../ui-icons - version: link:../ui-icons packages/ui-toggle: dependencies: