diff --git a/packages/core/.storybook/main.ts b/packages/core/.storybook/main.ts index 1821352210..fb99f651f0 100644 --- a/packages/core/.storybook/main.ts +++ b/packages/core/.storybook/main.ts @@ -39,6 +39,12 @@ const config: StorybookConfig = { docs: { autodocs: false }, + typescript: { + check: true, + checkOptions: { + async: false + } + }, async webpackFinal(config, { configType }) { if (configType === "DEVELOPMENT") { if (config.resolve) { diff --git a/packages/core/docs/vibe-3-changelog.md b/packages/core/docs/vibe-3-changelog.md index 5b5b5b1ae5..2dbee77327 100644 --- a/packages/core/docs/vibe-3-changelog.md +++ b/packages/core/docs/vibe-3-changelog.md @@ -270,10 +270,6 @@ codemod: `search-component-import-migration` - `dataTestId` -> `data-testid` [codemod] -### useSwitch - -- `onChange` type changed to `(value: boolean, event?: ChangeEvent) => void` - ## monday-ui-style - Remove `color-warning`, `color-warning-hover`, `color-warning-select`, `color-warning-select-hover` from colors.json diff --git a/packages/core/src/components/Menu/MenuItem/MenuItem.tsx b/packages/core/src/components/Menu/MenuItem/MenuItem.tsx index 0f357d1d55..9d4d8f0920 100644 --- a/packages/core/src/components/Menu/MenuItem/MenuItem.tsx +++ b/packages/core/src/components/Menu/MenuItem/MenuItem.tsx @@ -11,7 +11,7 @@ import styles from "./MenuItem.module.scss"; import BaseMenuItem from "./components/BaseMenuItem/BaseMenuItem"; import MenuItemIcon from "./components/MenuItemIcon/MenuItemIcon"; import { TooltipPositions } from "../../Tooltip/Tooltip.types"; -import { SubmenuPosition } from "./MenuItem.Types"; +import { SubmenuPosition } from "./MenuItem.types"; export interface MenuItemProps extends VibeComponentProps { title?: string; diff --git a/packages/core/src/components/Menu/MenuItem/MenuItem.Types.ts b/packages/core/src/components/Menu/MenuItem/MenuItem.types.ts similarity index 100% rename from packages/core/src/components/Menu/MenuItem/MenuItem.Types.ts rename to packages/core/src/components/Menu/MenuItem/MenuItem.types.ts diff --git a/packages/core/src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.types.ts b/packages/core/src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.types.ts index 3a9ab99364..d99f47797c 100644 --- a/packages/core/src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.types.ts +++ b/packages/core/src/components/Menu/MenuItem/components/MenuItemSubMenu/MenuItemSubMenu.types.ts @@ -1,6 +1,6 @@ import React from "react"; import { CloseMenuOption, MenuChild } from "../../../Menu/MenuConstants"; -import { SubmenuPosition } from "../../MenuItem.Types"; +import { SubmenuPosition } from "../../MenuItem.types"; export interface MenuItemSubMenuProps { /** diff --git a/packages/core/src/components/MultiStepIndicator/MultiStep.types.ts b/packages/core/src/components/MultiStepIndicator/MultiStep.types.ts index 4df3186051..1a3445ea37 100644 --- a/packages/core/src/components/MultiStepIndicator/MultiStep.types.ts +++ b/packages/core/src/components/MultiStepIndicator/MultiStep.types.ts @@ -5,3 +5,9 @@ export type StepStatus = "pending" | "active" | "fulfilled"; export type TextPlacement = "horizontal" | "vertical"; export type MultiStepSize = "regular" | "compact"; + +export type Step = { + titleText: string; + subtitleText: string; + status: StepStatus; +}; diff --git a/packages/core/src/components/MultiStepIndicator/MultiStepIndicator.tsx b/packages/core/src/components/MultiStepIndicator/MultiStepIndicator.tsx index b7b2756eb9..ad0c02388a 100644 --- a/packages/core/src/components/MultiStepIndicator/MultiStepIndicator.tsx +++ b/packages/core/src/components/MultiStepIndicator/MultiStepIndicator.tsx @@ -10,18 +10,12 @@ import { StepStatus as StepStatusEnum, TextPlacement as TextPlacementEnum } from "./MultiStepConstants"; -import { MultiStepType, MultiStepSize, StepStatus, TextPlacement } from "./MultiStep.types"; +import { MultiStepType, MultiStepSize, TextPlacement, Step } from "./MultiStep.types"; import { getTestId } from "../../tests/test-ids-utils"; import { ComponentDefaultTestId } from "../../tests/constants"; import { SubIcon, VibeComponent, VibeComponentProps, withStaticProps } from "../../types"; import styles from "./MultiStepIndicator.module.scss"; -export type Step = { - titleText: string; - subtitleText: string; - status: StepStatus; -}; - export interface MultiStepIndicatorProps extends VibeComponentProps { steps?: Step[]; type?: MultiStepType; diff --git a/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.mdx b/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.mdx index 40c4d59aad..5f02bdb607 100644 --- a/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.mdx +++ b/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.mdx @@ -1,5 +1,5 @@ import MultiStepIndicator from "../MultiStepIndicator"; -import { Canvas, Meta } from "@storybook/blocks"; +import { Meta } from "@storybook/blocks"; import { BREADCRUBMS, STEPS, TABS } from "../../../storybook/components/related-components/component-description-map"; import { firstSteps, secondSteps, thirdSteps, TipNotWhatYouAreLookingFor } from "./MultiStepIndicator.stories.helpers"; import * as MultiStepIndicatorStories from "./MultiStepIndicator.stories"; diff --git a/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.stories.helpers.tsx b/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.stories.helpers.tsx index d3af97e378..4ca1e1f60d 100644 --- a/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.stories.helpers.tsx +++ b/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.stories.helpers.tsx @@ -1,6 +1,6 @@ import React from "react"; import { StorybookLink, Tip } from "vibe-storybook-components"; -import { Step } from "../MultiStepIndicator"; +import { Step } from "../MultiStep.types"; export const firstSteps: Step[] = [ { diff --git a/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.stories.tsx b/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.stories.tsx index 83153c11b4..9972f78e53 100644 --- a/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.stories.tsx +++ b/packages/core/src/components/MultiStepIndicator/__stories__/MultiStepIndicator.stories.tsx @@ -6,6 +6,7 @@ import { createComponentTemplate, StoryDescription } from "vibe-storybook-compon import { Upgrade } from "../../Icon/Icons"; import Flex from "../../Flex/Flex"; import "./MultiStepIndicator.stories.scss"; +import { Step } from "../MultiStep.types"; export default { title: "Navigation/MultiStepIndicator", @@ -39,12 +40,19 @@ export const Overview = { subtitleText: "Subtitle" } ] + }, + parameters: { + docs: { + liveEdit: { + isEnabled: false + } + } } }; export const Placements = { render: () => { - const steps = useMemo( + const steps: Step[] = useMemo( () => [ { key: "FULFILLED", @@ -91,7 +99,7 @@ export const Placements = { export const Types = { render: () => { - const steps = useMemo( + const steps: Step[] = useMemo( () => [ { key: "FULFILLED", @@ -142,7 +150,7 @@ export const Types = { export const Sizes = { render: () => { - const steps = useMemo( + const steps: Step[] = useMemo( () => [ { key: "FULFILLED", @@ -183,7 +191,7 @@ export const Sizes = { export const FulfilledIcons = { render: () => { - const steps = useMemo( + const steps: Step[] = useMemo( () => [ { key: "FULFILLED", @@ -230,7 +238,7 @@ export const FulfilledIcons = { export const TransitionAnimation = { render: () => { - const exampleSteps = useMemo( + const exampleSteps = useMemo>( () => ({ firstStep: { key: "PENDING", @@ -256,7 +264,7 @@ export const TransitionAnimation = { [] ); - const [steps, setSteps] = useState([ + const [steps, setSteps] = useState([ { ...exampleSteps.firstStep }, @@ -355,7 +363,7 @@ export const TransitionAnimation = { export const MultiStepWizard = { render: () => { - const steps = useMemo( + const steps: Step[] = useMemo( () => [ { key: "FULFILLED", diff --git a/packages/core/src/components/MultiStepIndicator/__tests__/MultiStepIndicator.snapshot.test.tsx b/packages/core/src/components/MultiStepIndicator/__tests__/MultiStepIndicator.snapshot.test.tsx index 42e3275ddd..682f39113b 100644 --- a/packages/core/src/components/MultiStepIndicator/__tests__/MultiStepIndicator.snapshot.test.tsx +++ b/packages/core/src/components/MultiStepIndicator/__tests__/MultiStepIndicator.snapshot.test.tsx @@ -1,7 +1,8 @@ import React from "react"; import renderer from "react-test-renderer"; import { Upgrade } from "../../Icon/Icons"; -import MultiStepIndicator, { Step } from "../MultiStepIndicator"; +import MultiStepIndicator from "../MultiStepIndicator"; +import { Step } from "../MultiStep.types"; const exampleSteps: Step[] = [ { diff --git a/packages/core/src/components/MultiStepIndicator/__tests__/MultiStepIndicator.test.tsx b/packages/core/src/components/MultiStepIndicator/__tests__/MultiStepIndicator.test.tsx index 9a24fae408..897ca3dd0d 100644 --- a/packages/core/src/components/MultiStepIndicator/__tests__/MultiStepIndicator.test.tsx +++ b/packages/core/src/components/MultiStepIndicator/__tests__/MultiStepIndicator.test.tsx @@ -1,7 +1,8 @@ import React from "react"; import { fireEvent, render } from "@testing-library/react"; import { act } from "@testing-library/react-hooks"; -import MultiStepIndicator, { Step } from "../MultiStepIndicator"; +import MultiStepIndicator from "../MultiStepIndicator"; +import { Step } from "../MultiStep.types"; describe("MultiStepIndicator tests", () => { it("onClick works and is called once", () => { diff --git a/packages/core/src/components/Skeleton/__stories__/Skeleton.mdx b/packages/core/src/components/Skeleton/__stories__/Skeleton.mdx index 7dc7552ece..afe7aaf121 100644 --- a/packages/core/src/components/Skeleton/__stories__/Skeleton.mdx +++ b/packages/core/src/components/Skeleton/__stories__/Skeleton.mdx @@ -1,5 +1,5 @@ import Skeleton from "../Skeleton"; -import { Canvas, Meta } from "@storybook/blocks"; +import { Meta } from "@storybook/blocks"; import { COUNTER, LINEAR_PROGRESS_BAR, @@ -115,6 +115,10 @@ Presents a classic menu or equivalent picker ## Use cases and examples +### Complex Example + + + ### Update in the system Use this menu to allow a user to either select one or more items from the list. diff --git a/packages/core/src/components/Skeleton/__stories__/Skeleton.stories.tsx b/packages/core/src/components/Skeleton/__stories__/Skeleton.stories.tsx index 647e935e72..c8df5e7152 100644 --- a/packages/core/src/components/Skeleton/__stories__/Skeleton.stories.tsx +++ b/packages/core/src/components/Skeleton/__stories__/Skeleton.stories.tsx @@ -5,6 +5,7 @@ import person from "./assets/person.png"; import Button from "../../Button/Button"; import { Replay, ThumbsUp } from "../../Icon/Icons"; import "./Skeleton.stories.scss"; +import { Flex } from "../../Flex"; export default { title: "Feedback/Skeleton", @@ -12,41 +13,54 @@ export default { }; const skeletonTemplate = (args: SkeletonProps) => { + return ( + + + + + + ); +}; + +export const Overview = { + render: skeletonTemplate.bind({}), + args: { + size: "h1", + type: "text" + }, + name: "Overview", + parameters: { + docs: { + liveEdit: { + isEnabled: false + } + } + } +}; + +export const ComplexExample = () => { return (
- - + +
- - - - - + + + + +
); }; -export const Overview = { - render: skeletonTemplate.bind({}), - name: "Overview", - - args: { - typeText: "text", - typeCircle: "circle", - smallSize: "small", - sizeH4: "h4", - sizeH1: "h1" - } -}; - export const Shapes = { render: () => (
diff --git a/packages/core/src/components/Steps/Steps.tsx b/packages/core/src/components/Steps/Steps.tsx index 14d1cbed30..511fc2867b 100644 --- a/packages/core/src/components/Steps/Steps.tsx +++ b/packages/core/src/components/Steps/Steps.tsx @@ -25,9 +25,9 @@ export interface StepsProps extends VibeComponentProps { color?: StepsColor; isContentOnTop?: boolean; areButtonsIconsHidden?: boolean; - backButtonProps?: ButtonProps; - nextButtonProps?: ButtonProps; - finishButtonProps?: ButtonProps; + backButtonProps?: Partial; + nextButtonProps?: Partial; + finishButtonProps?: Partial; onFinish?: (e: React.MouseEvent | React.KeyboardEvent) => void; } @@ -45,9 +45,9 @@ const Steps: VibeComponent & { types?: typeof StepsTypeEnum; colors? color, areNavigationButtonsHidden = false, isContentOnTop = false, - backButtonProps = { children: "" }, - nextButtonProps = { children: "" }, - finishButtonProps = { children: "" }, + backButtonProps = {}, + nextButtonProps = {}, + finishButtonProps = {}, areButtonsIconsHidden = false }: StepsProps, ref diff --git a/packages/core/src/components/Steps/StepsCommand.tsx b/packages/core/src/components/Steps/StepsCommand.tsx index 524d1bb8f7..1954c26d18 100644 --- a/packages/core/src/components/Steps/StepsCommand.tsx +++ b/packages/core/src/components/Steps/StepsCommand.tsx @@ -19,7 +19,7 @@ export interface StepsCommandProps extends VibeComponentProps { activeStepIndex: number; stepsCount: number; isIconHidden?: boolean; - buttonProps?: ButtonProps; + buttonProps?: Partial; color?: StepsColor; } @@ -29,7 +29,7 @@ export const StepsCommand: FC = ({ activeStepIndex, stepsCount, isIconHidden = false, - buttonProps = { children: "" }, + buttonProps = {}, color = "primary" }: StepsCommandProps) => { const { children: buttonChildren, ...otherButtonProps } = buttonProps; diff --git a/packages/core/src/components/Steps/StepsHeader.tsx b/packages/core/src/components/Steps/StepsHeader.tsx index 2c2eeb1f3c..8a9c2ab805 100644 --- a/packages/core/src/components/Steps/StepsHeader.tsx +++ b/packages/core/src/components/Steps/StepsHeader.tsx @@ -15,9 +15,9 @@ export interface StepsHeaderProps extends VibeComponentProps { onChangeActiveStep: (e: React.MouseEvent, stepIndex: number) => void; stepsCount: number; areNavigationButtonsHidden: boolean; - backButtonProps: ButtonProps; - nextButtonProps: ButtonProps; - finishButtonProps: ButtonProps; + backButtonProps: Partial; + nextButtonProps: Partial; + finishButtonProps: Partial; areButtonsIconsHidden: boolean; color?: StepsColor; onFinish?: (e: React.MouseEvent) => void; diff --git a/packages/core/src/components/Toast/__stories__/Toast.stories.tsx b/packages/core/src/components/Toast/__stories__/Toast.stories.tsx index a2653843a7..023910e798 100644 --- a/packages/core/src/components/Toast/__stories__/Toast.stories.tsx +++ b/packages/core/src/components/Toast/__stories__/Toast.stories.tsx @@ -6,6 +6,7 @@ import { createStoryMetaSettingsDecorator } from "../../../storybook"; import Button from "../../Button/Button"; import { Delete } from "../../Icon/Icons"; import "./Toast.stories.scss"; +import { ToastAction } from "../Toast.types"; const metaSettings = createStoryMetaSettingsDecorator({ component: Toast, @@ -42,7 +43,7 @@ export const Overview = { export const DefaultWithButton = { render: () => { - const actions = useMemo( + const actions: ToastAction[] = useMemo( () => [ { type: "button", @@ -64,7 +65,7 @@ export const DefaultWithButton = { export const ToastWithLink = { render: () => { - const actions = useMemo( + const actions: ToastAction[] = useMemo( () => [ { type: "link", @@ -100,7 +101,7 @@ export const ToastWithLoading = { export const SuccessMessage = { render: () => { - const actions = useMemo( + const actions: ToastAction[] = useMemo( () => [ { type: "button", @@ -122,7 +123,7 @@ export const SuccessMessage = { export const ErrorMessage = { render: () => { - const actions = useMemo( + const actions: ToastAction[] = useMemo( () => [ { type: "button", @@ -144,7 +145,7 @@ export const ErrorMessage = { export const WarningMessage = { render: () => { - const actions = useMemo( + const actions: ToastAction[] = useMemo( () => [ { type: "button", @@ -166,7 +167,7 @@ export const WarningMessage = { export const DarkMessage = { render: () => { - const actions = useMemo( + const actions: ToastAction[] = useMemo( () => [ { type: "button", @@ -193,7 +194,7 @@ export const FeedbackLoop = { const onClickCallback = useCallback(() => setToastOpen(toastOpen => !toastOpen), [setToastOpen]); const onCloseCallback = useCallback(() => setToastOpen(false), [setToastOpen]); - const actions = useMemo( + const actions = useMemo( () => [ { type: "button", diff --git a/packages/core/src/hooks/useSwitch/__tests__/useSwitch.test.ts b/packages/core/src/hooks/useSwitch/__tests__/useSwitch.test.ts index 07f4827b82..c3b56a6dbe 100644 --- a/packages/core/src/hooks/useSwitch/__tests__/useSwitch.test.ts +++ b/packages/core/src/hooks/useSwitch/__tests__/useSwitch.test.ts @@ -3,8 +3,6 @@ import useSwitch, { UseSwitchProps } from "../index"; import { ChangeEvent } from "react"; describe("useSwitch", () => { - const mockEvent = {} as ChangeEvent; - afterEach(() => { cleanup(); }); @@ -73,7 +71,7 @@ describe("useSwitch", () => { const { result } = renderHookForTest({ defaultChecked: true, onChange }); callOnChange(result); expect(onChange).toBeCalledTimes(1); - expect(onChange).toBeCalledWith(false, mockEvent); + expect(onChange).toBeCalledWith(false); }); }); @@ -82,6 +80,7 @@ describe("useSwitch", () => { } function callOnChange(result: RenderResult>) { + const mockEvent = {} as ChangeEvent; act(() => { result.current.onChange(mockEvent); }); diff --git a/packages/core/src/hooks/useSwitch/index.ts b/packages/core/src/hooks/useSwitch/index.ts index 064d2ed377..b489484050 100644 --- a/packages/core/src/hooks/useSwitch/index.ts +++ b/packages/core/src/hooks/useSwitch/index.ts @@ -8,7 +8,7 @@ enum SwitchRole { export interface UseSwitchProps { isChecked?: boolean; defaultChecked?: boolean; - onChange?: (value: boolean, event?: ChangeEvent) => void; + onChange?: (value: boolean, event?: ChangeEvent | unknown) => void; isDisabled?: boolean; } @@ -18,7 +18,7 @@ export default function useSwitch({ isChecked, defaultChecked, onChange, isDisab const [overrideChecked, setOverrideChecked] = useState(overrideCheckedInitial); const overrideOnChange = useCallback( - (event?: ChangeEvent) => { + (event?: ChangeEvent | unknown) => { if (isDisabled) { return; } @@ -26,7 +26,11 @@ export default function useSwitch({ isChecked, defaultChecked, onChange, isDisab if (isChecked === undefined) { setOverrideChecked(newChecked); } - onChange?.(newChecked, event); + if (event && typeof event === "object" && "target" in event) { + onChange?.(newChecked, event); + } else { + onChange?.(newChecked); + } }, [isChecked, isDisabled, onChange, overrideChecked] ); diff --git a/packages/core/types/files.d.ts b/packages/core/types/files.d.ts index 0b9bfee343..af57053aa0 100644 --- a/packages/core/types/files.d.ts +++ b/packages/core/types/files.d.ts @@ -12,3 +12,4 @@ declare module "*.svg" { declare module "*.png"; declare module "*.mp4"; +declare module "*.pdf";