diff --git a/packages/components/src/Checkbox/Checkbox.stories.tsx b/packages/components/src/Checkbox/Checkbox.stories.tsx deleted file mode 100644 index 91fcc0c32e..0000000000 --- a/packages/components/src/Checkbox/Checkbox.stories.tsx +++ /dev/null @@ -1,124 +0,0 @@ -import React, { useState } from "react"; -import type { Meta, StoryObj } from "@storybook/react-vite"; -import { Text } from "@jobber/components/Text"; -import { Link } from "@jobber/components/Link"; -import { Checkbox } from "@jobber/components/Checkbox"; - -const meta = { - title: "Components/Selections/Checkbox", - component: Checkbox, -} satisfies Meta; -export default meta; -type Story = StoryObj; - -const BasicTemplate = (args: Story["args"]) => { - const [checked, setChecked] = useState(true); - - return ; -}; - -export const Basic: Story = { - render: BasicTemplate, - args: { - label: "Save card for future use", - name: "save-card", - }, -}; - -const Invalid_v2Template = (args: Story["args"]) => { - const [checked, setChecked] = useState(true); - - return ; -}; - -export const Invalid_v2: Story = { - render: Invalid_v2Template, - args: { - label: "Invalid checkbox (requires version 2 prop)", - invalid: true, - indeterminate: false, - disabled: false, - version: 2, - }, -}; - -const IndeterminateTemplate = () => { - const [items, setItems] = useState([true, false, false]); - - return ( - <> - -
    - {items.map((value, index) => ( -
  • - -
  • - ))} -
- - ); - - function toggleIndex(index: number) { - return (newValue: boolean) => { - const updatedItems = Array.from(items); - updatedItems[index] = newValue; - setItems(updatedItems); - }; - } - - function toggleAll(newValue: boolean) { - setItems(Array(items.length).fill(newValue)); - } -}; - -export const Indeterminate: Story = { - render: IndeterminateTemplate, - args: {}, -}; - -export const WithDescription: Story = { - render: BasicTemplate, - args: { - label: "Save card for future use", - description: - "If you save your card now, you'll never need to save it again.", - }, -}; - -export const Disabled: Story = { - render: BasicTemplate, - args: { - label: "Subscribe on marketing emails", - disabled: true, - defaultChecked: true, - }, -}; - -const ChildrenAsLabelTemplate = () => { - const [checked, setChecked] = useState(false); - - return ( - - - I agree to the{" "} - - terms of service - - - - ); -}; - -export const ChildrenAsLabel: Story = { - render: ChildrenAsLabelTemplate, - args: {}, -}; diff --git a/packages/components/src/Checkbox/Checkbox.tsx b/packages/components/src/Checkbox/Checkbox.tsx index 6c13a060fe..6a320dcccd 100644 --- a/packages/components/src/Checkbox/Checkbox.tsx +++ b/packages/components/src/Checkbox/Checkbox.tsx @@ -3,6 +3,8 @@ import React, { useEffect, useId, useState } from "react"; import classnames from "classnames"; import { Controller, useForm, useFormContext } from "react-hook-form"; import styles from "./Checkbox.module.css"; +// TODO: Temporary disable — this V1 component will be deleted as part of V1/V2 consolidation +// eslint-disable-next-line import/no-deprecated import type { CheckboxLegacyProps } from "./Checkbox.types"; import { Icon } from "../Icon"; import { Text } from "../Text"; @@ -20,7 +22,8 @@ export function CheckboxLegacy({ onBlur, onChange, onFocus, -}: CheckboxLegacyProps) { +}: // eslint-disable-next-line import/no-deprecated +CheckboxLegacyProps) { const { control, setValue, watch } = useFormContext() != undefined ? useFormContext() diff --git a/packages/components/src/Checkbox/Checkbox.types.ts b/packages/components/src/Checkbox/Checkbox.types.ts index 394259f4ea..019bfbf0ae 100644 --- a/packages/components/src/Checkbox/Checkbox.types.ts +++ b/packages/components/src/Checkbox/Checkbox.types.ts @@ -127,6 +127,9 @@ export type CheckboxRebuiltProps = CheckboxCoreProps & ): void; }; +/** + * @deprecated Use the v2 Checkbox component instead (version={2}). + */ export type CheckboxLegacyProps = XOR< CheckboxLabelProps, CheckboxChildrenProps diff --git a/packages/components/src/Checkbox/index.tsx b/packages/components/src/Checkbox/index.tsx index 87d2183765..7beca0e0cc 100644 --- a/packages/components/src/Checkbox/index.tsx +++ b/packages/components/src/Checkbox/index.tsx @@ -1,11 +1,14 @@ import React, { forwardRef } from "react"; import { CheckboxLegacy } from "./Checkbox"; import { CheckboxRebuilt } from "./Checkbox.rebuilt"; +// TODO: Temporary disable — this V1 component will be deleted as part of V1/V2 consolidation import type { + // eslint-disable-next-line import/no-deprecated CheckboxLegacyProps, CheckboxRebuiltProps, } from "./Checkbox.types"; +// eslint-disable-next-line import/no-deprecated type CheckboxShimProps = CheckboxLegacyProps | CheckboxRebuiltProps; function isNewCheckboxProps( @@ -27,4 +30,5 @@ export const Checkbox = forwardRef(function CheckboxShim( Checkbox.displayName = "Checkbox"; +// eslint-disable-next-line import/no-deprecated export type { CheckboxLegacyProps, CheckboxRebuiltProps }; diff --git a/packages/components/src/InputEmail/InputEmail.stories.tsx b/packages/components/src/InputEmail/InputEmail.stories.tsx deleted file mode 100644 index 3b31ce3659..0000000000 --- a/packages/components/src/InputEmail/InputEmail.stories.tsx +++ /dev/null @@ -1,267 +0,0 @@ -import React, { useState } from "react"; -import type { Meta, StoryObj } from "@storybook/react-vite"; -import { InputEmail } from "@jobber/components/InputEmail"; -import { Content } from "@jobber/components/Content"; -import { Grid } from "@jobber/components/Grid"; -import { Button } from "@jobber/components/Button"; - -const meta = { - title: "Components/Forms and Inputs/InputEmail", - component: InputEmail, -} satisfies Meta; -export default meta; -type Story = StoryObj>>; - -const BasicTemplate = (args: Story["args"]) => ; - -export const Basic: Story = { - render: BasicTemplate, - args: { - placeholder: "Enter your email", - }, -}; - -export const VersionComparison: Story = { - render: () => { - const [values, setValues] = useState({ - basic: "", - disabled: "", - invalid: "", - withDescription: "", - inline: "", - prefix: "", - suffix: "", - both: "", - rightAlign: "", - centerAlign: "", - sizeSmall: "", - sizeLarge: "", - loading: "", - maxLength: "", - clearable: "", - readonly: "readonly@example.com", - }); - - const [inline, setInline] = useState(false); - const [invalid, setInvalid] = useState(undefined); - const [disabled, setDisabled] = useState(false); - const [description, setDescription] = useState(""); - const [error, setError] = useState(""); - - const extraProps = { - invalid, - inline, - disabled, - description, - error, - }; - - const handleChange = (field: keyof typeof values) => (value: string) => { - setValues(prev => ({ ...prev, [field]: value })); - }; - - const renderBothVersions = ( - title: string, - props: Record, - field: keyof typeof values, - ) => ( - - -

{title}

-
- - - - - - -
- ); - - return ( - -
- - -

V1

-
- -

V2

-
-
- - {renderBothVersions( - "Basic Input", - { - placeholder: "Enter your email", - ...extraProps, - }, - "basic", - )} - - {renderBothVersions( - "Right Aligned", - { - placeholder: "Right aligned", - align: "right", - ...extraProps, - }, - "rightAlign", - )} - - {renderBothVersions( - "Center Aligned", - { - placeholder: "Center aligned", - align: "center", - ...extraProps, - }, - "centerAlign", - )} - - {renderBothVersions( - "With Prefix", - { - placeholder: "Input with prefix", - prefix: { icon: "search" }, - ...extraProps, - }, - "prefix", - )} - - {renderBothVersions( - "With Suffix", - { - placeholder: "Input with suffix", - suffix: { icon: "sparkles" }, - ...extraProps, - }, - "suffix", - )} - - {renderBothVersions( - "With Prefix and Suffix", - { - placeholder: "Input with both", - prefix: { label: "Pre" }, - suffix: { label: "Suf" }, - ...extraProps, - }, - "both", - )} - - {renderBothVersions( - "Size small", - { - placeholder: "Small input", - size: "small", - ...extraProps, - }, - "sizeSmall", - )} - - {renderBothVersions( - "Size large", - { - placeholder: "Large input", - size: "large", - ...extraProps, - }, - "sizeLarge", - )} - - {renderBothVersions( - "Loading", - { - placeholder: "Loading input", - loading: true, - ...extraProps, - }, - "loading", - )} - - {renderBothVersions( - "Max Length", - { - placeholder: "Max length input", - maxLength: 5, - ...extraProps, - }, - "maxLength", - )} - {renderBothVersions( - "Clearable", - { - placeholder: "Clearable input", - clearable: "always", - ...extraProps, - }, - "clearable", - )} - {renderBothVersions( - "Readonly", - { - placeholder: "Readonly", - ...extraProps, - // For version 1 - readonly: true, - // For version 2 - readOnly: true, - }, - "readonly", - )} -
- - - -