@intlayer/design-system 5.7.3 → 5.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Form-CriPBaZk.js.map +1 -1
- package/dist/Form-DJrUK3mm.cjs.map +1 -1
- package/dist/components/CopyToClipboard/index.cjs +32 -23
- package/dist/components/CopyToClipboard/index.cjs.map +1 -1
- package/dist/components/CopyToClipboard/index.d.ts.map +1 -1
- package/dist/components/CopyToClipboard/index.mjs +32 -23
- package/dist/components/CopyToClipboard/index.mjs.map +1 -1
- package/dist/components/Form/elements/CheckboxElement.d.ts +2 -2
- package/dist/components/Form/elements/CheckboxElement.d.ts.map +1 -1
- package/dist/components/Input/Checkbox.cjs +29 -22
- package/dist/components/Input/Checkbox.cjs.map +1 -1
- package/dist/components/Input/Checkbox.d.ts +3 -2
- package/dist/components/Input/Checkbox.d.ts.map +1 -1
- package/dist/components/Input/Checkbox.mjs +30 -23
- package/dist/components/Input/Checkbox.mjs.map +1 -1
- package/dist/hooks/index.cjs +2 -1
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.mjs +3 -2
- package/dist/hooks/intlayerAPIHooks.cjs +8 -6
- package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
- package/dist/hooks/intlayerAPIHooks.d.ts +222 -17
- package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
- package/dist/hooks/intlayerAPIHooks.mjs +8 -6
- package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
- package/dist/hooks/useAuth/useAuth.cjs.map +1 -1
- package/dist/hooks/useAuth/useAuth.d.ts +6 -6
- package/dist/hooks/useAuth/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth/useAuth.mjs.map +1 -1
- package/dist/hooks/useAuth/useSession.cjs.map +1 -1
- package/dist/hooks/useAuth/useSession.d.ts +354 -6
- package/dist/hooks/useAuth/useSession.d.ts.map +1 -1
- package/dist/hooks/useAuth/useSession.mjs.map +1 -1
- package/dist/hooks/useUser/index.d.ts +18 -2
- package/dist/hooks/useUser/index.d.ts.map +1 -1
- package/package.json +17 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form-CriPBaZk.js","sources":["../src/components/Form/layout/FormItemLayout.tsx","../src/components/Form/elements/FormElement.tsx","../src/components/Form/elements/InputElement.tsx","../src/components/Form/elements/InputPasswordElement.tsx","../src/components/Form/elements/TextAreaElement.tsx","../src/components/Form/elements/EditableFieldInputElement.tsx","../src/components/Form/elements/EditableFieldTextAreaElement.tsx","../src/components/Form/elements/AutoSizeTextAreaElement.tsx","../src/components/Form/elements/CheckboxElement.tsx","../src/components/Form/elements/MultiselectElement.tsx","../src/components/Form/elements/SelectElement.tsx","../src/components/Form/elements/SwitchSelectorElement.tsx","../src/components/Form/Form.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { Form } from '../Form';\nimport { FormLabelLayout, type FormLabelLayoutProps } from './FormLabelLayout';\n\nexport type FormItemLayoutProps = Omit<FormLabelLayoutProps, 'children'> & {\n label?: ReactNode;\n description?: ReactNode;\n children: ReactNode;\n showErrorMessage?: boolean;\n};\n\nexport const FormItemLayout: FC<FormItemLayoutProps> = ({\n label,\n description,\n isRequired,\n info,\n children,\n showErrorMessage = true,\n htmlFor,\n}) => (\n <Form.Item className=\"flex w-full flex-col gap-2 p-2\">\n {(description || label) && (\n <div className=\"flex flex-col gap-1 p-1 leading-none\">\n {label && (\n <FormLabelLayout\n isRequired={isRequired}\n info={info}\n htmlFor={htmlFor}\n >\n {label}\n </FormLabelLayout>\n )}\n {description && <Form.Description>{description}</Form.Description>}\n </div>\n )}\n <Form.Control>{children}</Form.Control>\n\n {showErrorMessage && <Form.Message data-testid=\"error-message\" />}\n </Form.Item>\n);\n","'use client';\n\nimport type { ComponentProps, ElementType, ReactNode } from 'react';\nimport {\n useFormContext,\n type ControllerRenderProps,\n type FieldValues,\n} from 'react-hook-form';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { type FormItemLayoutProps, FormItemLayout } from '../layout';\n\nexport type FormElementProps<T extends ElementType> = {\n name: string;\n Element: T;\n label?: ReactNode;\n isRequired?: boolean;\n info?: string;\n showErrorMessage?: boolean;\n focus?: boolean;\n} & Omit<FormItemLayoutProps, 'children'>;\n\ntype FormFieldElementProps<T extends ElementType> = FormElementProps<T> &\n ComponentProps<T> & {\n field: ControllerRenderProps<FieldValues, string>;\n };\n\nconst FormFieldElement = <T extends ElementType>({\n field,\n name,\n label,\n Element,\n isRequired = false,\n info,\n description,\n showErrorMessage = true,\n ...props\n}: FormFieldElementProps<T>) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Element data-testid=\"element\" id={name} {...field} {...props}>\n {props.children}\n </Element>\n </FormItemLayout>\n );\n};\n\n/**\n * FormElement is a component that allows you to create a form element with a label, description, error message, and validation.\n *\n * The Element prop is the type of the element that will be rendered.\n * This element will interact with the FormContext and will be controlled by the FormControl component.\n * The props used to control the element will be `value` and `onChange`.\n */\nexport const FormElement = <T extends ElementType>(\n props: FormElementProps<T> & ComponentProps<T>\n) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={props.name}\n render={({ field }) => <FormFieldElement {...props} field={field} />}\n />\n );\n};\n","import type { ComponentProps, FC } from 'react';\nimport { Input } from '../../../components/Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputElementProps = Omit<FormElementProps<typeof Input>, 'Element'> &\n Omit<\n ComponentProps<typeof Input> & {\n name: string;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const InputElement: FC<InputElementProps> = (props) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n Element={Input}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n {...props}\n />\n);\n","import type { ComponentProps, FC } from 'react';\nimport { InputPassword } from '../../Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputPasswordElementProps = Omit<\n FormElementProps<typeof InputPassword>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof InputPassword> & {\n name: string;\n autoComplete: 'current-password' | 'new-password';\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const InputPasswordElement: FC<InputPasswordElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={InputPassword}\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","import type { ComponentProps, FC } from 'react';\nimport { TextArea } from '../../TextArea/TextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype TextAreaElementsProps = Omit<\n FormElementProps<typeof TextArea>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof TextArea> & {\n name: string;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const TextAreaElement: FC<TextAreaElementsProps> = (props) => (\n <FormElement\n Element={TextArea}\n id={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldInput } from '../../EditableField/EditableFieldInput';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldInputElementProps = Omit<\n FormElementProps<typeof EditableFieldInput>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof EditableFieldInput> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const EditableFieldInputElement = (\n props: EditableFieldInputElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n Element={EditableFieldInput}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldTextArea } from '../../EditableField/EditableFieldTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldTextAreaElementProps = Omit<\n FormElementProps<typeof EditableFieldTextArea>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof EditableFieldTextArea> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const EditableFieldTextAreaElement = (\n props: EditableFieldTextAreaElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n Element={EditableFieldTextArea}\n {...props}\n />\n);\n","import type { FC } from 'react';\nimport { AutoSizedTextArea } from '../../TextArea/AutoSizeTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype AutoSizedTextAreaElementsProps = Omit<\n FormElementProps<typeof AutoSizedTextArea>,\n 'Element'\n> &\n React.ComponentProps<typeof AutoSizedTextArea> & {\n name: string;\n };\n\nexport const AutoSizedTextAreaElement: FC<AutoSizedTextAreaElementsProps> = (\n props\n) => (\n <FormElement\n Element={AutoSizedTextArea}\n id={props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import { type ComponentProps, type FC } from 'react';\nimport { Checkbox } from '../../Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype CheckboxElementProps = Omit<FormElementProps<typeof Checkbox>, 'Element'> &\n ComponentProps<typeof Checkbox> & {\n name: string;\n inputLabel?: string;\n };\n\ntype CheckboxComponentProps = Omit<ComponentProps<typeof Checkbox>, 'label'> & {\n name: string;\n inputLabel?: ComponentProps<typeof Checkbox>['label'];\n};\n\nconst CheckboxComponent: FC<CheckboxComponentProps> = ({\n inputLabel,\n ...props\n}) => <Checkbox {...props} label={inputLabel} />;\n\nexport const CheckboxElement: FC<CheckboxElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={CheckboxComponent}\n id={props.name}\n data-testid={props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { MultiSelect } from '../../Select/Multiselect';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<\n FormElementProps<typeof MultiSelect>,\n 'Element'\n> &\n ComponentProps<typeof MultiSelect> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const MultiSelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <MultiSelect\n onValueChange={field.onChange}\n values={field.value}\n {...props}\n >\n {children}\n </MultiSelect>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { Select } from '../../Select/Select';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<FormElementProps<typeof Select>, 'Element'> &\n ComponentProps<typeof Select> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Select\n onValueChange={field.onChange}\n defaultValue={field.value}\n {...props}\n >\n {children}\n </Select>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { SwitchSelector } from '../../SwitchSelector';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SwitchSelectorElementProps = Omit<\n FormElementProps<typeof SwitchSelector>,\n 'Element'\n> &\n ComponentProps<typeof SwitchSelector> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SwitchSelectorElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SwitchSelectorElementProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <SwitchSelector {...field} {...props}>\n {children}\n </SwitchSelector>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","import { Button } from '../Button';\nimport {\n FormElement,\n InputElement,\n InputPasswordElement,\n TextAreaElement,\n} from './elements';\nimport { AutoSizedTextAreaElement } from './elements/AutoSizeTextAreaElement';\nimport { CheckboxElement } from './elements/CheckboxElement';\nimport { EditableFieldInputElement } from './elements/EditableFieldInputElement';\nimport { EditableFieldTextAreaElement } from './elements/EditableFieldTextAreaElement';\nimport { MultiSelectElement } from './elements/MultiselectElement';\nimport { SelectElement } from './elements/SelectElement';\nimport { SwitchSelectorElement } from './elements/SwitchSelectorElement';\nimport { Form as FormRoot } from './FormBase';\nimport { FormControl } from './FormControl';\nimport { FormDescription } from './FormDescription';\nimport { FormField } from './FormField';\nimport { FormItem } from './FormItem';\nimport { FormMessage } from './FormMessage';\nimport { FormLabelLayout } from './layout';\n\ntype FormType = typeof FormRoot & {\n Description: typeof FormDescription;\n Control: typeof FormControl;\n Field: typeof FormField;\n Item: typeof FormItem;\n Label: typeof FormLabelLayout;\n Message: typeof FormMessage;\n Element: typeof FormElement;\n Button: typeof Button;\n Input: typeof InputElement;\n InputPassword: typeof InputPasswordElement;\n Checkbox: typeof CheckboxElement;\n TextArea: typeof TextAreaElement;\n AutoSizedTextArea: typeof AutoSizedTextAreaElement;\n MultiSelect: typeof MultiSelectElement;\n Select: typeof SelectElement;\n EditableFieldInput: typeof EditableFieldInputElement;\n EditableFieldTextArea: typeof EditableFieldTextAreaElement;\n SwitchSelector: typeof SwitchSelectorElement;\n};\n\n/**\n * Form components\n *\n * Example of usage:\n * ```jsx\n * <Form\n * schema={ZodSchema}\n * onSubmitSuccess={onSubmitSuccess}\n * onSubmitError={onSubmitError}\n * autoComplete\n * >\n * <Form.Input name=\"name\" label=\"Name\" />\n * <Form.Button type=\"submit\" label=\"Click to submit\">\n * Submit\n * </Form.Button>\n * </Form>\n * ```\n */\nexport const Form = FormRoot as FormType;\nForm.Description = FormDescription;\nForm.Control = FormControl;\nForm.Field = FormField;\nForm.Item = FormItem;\nForm.Label = FormLabelLayout;\nForm.Message = FormMessage;\nForm.Element = FormElement;\nForm.Input = InputElement;\nForm.InputPassword = InputPasswordElement;\nForm.Checkbox = CheckboxElement;\nForm.TextArea = TextAreaElement;\nForm.AutoSizedTextArea = AutoSizedTextAreaElement;\nForm.Button = Button;\nForm.Select = SelectElement;\nForm.MultiSelect = MultiSelectElement;\nForm.EditableFieldInput = EditableFieldInputElement;\nForm.EditableFieldTextArea = EditableFieldTextAreaElement;\nForm.SwitchSelector = SwitchSelectorElement;\n"],"names":["FormRoot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,iBAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB;AACF,MACG,qBAAA,KAAK,MAAL,EAAU,WAAU,kCACjB,UAAA;AAAA,GAAA,eAAe,UACf,qBAAC,OAAI,EAAA,WAAU,wCACZ,UAAA;AAAA,IACC,SAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IACH;AAAA,IAED,eAAe,oBAAC,KAAK,aAAL,EAAkB,UAAY,YAAA,CAAA;AAAA,EAAA,GACjD;AAAA,EAED,oBAAA,KAAK,SAAL,EAAc,SAAS,CAAA;AAAA,EAEvB,oBAAqB,oBAAA,KAAK,SAAL,EAAa,eAAY,gBAAgB,CAAA;AAAA,EACjE,CAAA;ACXF,MAAM,mBAAmB,CAAwB;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB,GAAG;AACL,MAAgC;AACxB,QAAA,EAAE,MAAM,IAAI,aAAa;AAG7B,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAc,CAAC,CAAC;AAAA,MAEhB,UAAA,oBAAC,SAAQ,EAAA,eAAY,WAAU,IAAI,MAAO,GAAG,OAAQ,GAAG,OACrD,UAAA,MAAM,SACT,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;AASa,MAAA,cAAc,CACzB,UACG;AACG,QAAA,EAAE,QAAQ,IAAI,eAAe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AAC;AAAA,UAAA;AAAA,YACC,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,gBAAc,CAAC,CAAC;AAAA,YAEhB,8BAAC,gBAAgB,EAAA,GAAG,OAAQ,GAAG,OAC5B,SACH,CAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAEJ;ACEO,MAAM,OAAOA;AACpB,KAAK,cAAc;AACnB,KAAK,UAAU;AACf,KAAK,QAAQ;AACb,KAAK,OAAO;AACZ,KAAK,QAAQ;AACb,KAAK,UAAU;AACf,KAAK,UAAU;AACf,KAAK,QAAQ;AACb,KAAK,gBAAgB;AACrB,KAAK,WAAW;AAChB,KAAK,WAAW;AAChB,KAAK,oBAAoB;AACzB,KAAK,SAAS;AACd,KAAK,SAAS;AACd,KAAK,cAAc;AACnB,KAAK,qBAAqB;AAC1B,KAAK,wBAAwB;AAC7B,KAAK,iBAAiB;"}
|
|
1
|
+
{"version":3,"file":"Form-CriPBaZk.js","sources":["../src/components/Form/layout/FormItemLayout.tsx","../src/components/Form/elements/FormElement.tsx","../src/components/Form/elements/InputElement.tsx","../src/components/Form/elements/InputPasswordElement.tsx","../src/components/Form/elements/TextAreaElement.tsx","../src/components/Form/elements/EditableFieldInputElement.tsx","../src/components/Form/elements/EditableFieldTextAreaElement.tsx","../src/components/Form/elements/AutoSizeTextAreaElement.tsx","../src/components/Form/elements/CheckboxElement.tsx","../src/components/Form/elements/MultiselectElement.tsx","../src/components/Form/elements/SelectElement.tsx","../src/components/Form/elements/SwitchSelectorElement.tsx","../src/components/Form/Form.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { Form } from '../Form';\nimport { FormLabelLayout, type FormLabelLayoutProps } from './FormLabelLayout';\n\nexport type FormItemLayoutProps = Omit<FormLabelLayoutProps, 'children'> & {\n label?: ReactNode;\n description?: ReactNode;\n children: ReactNode;\n showErrorMessage?: boolean;\n};\n\nexport const FormItemLayout: FC<FormItemLayoutProps> = ({\n label,\n description,\n isRequired,\n info,\n children,\n showErrorMessage = true,\n htmlFor,\n}) => (\n <Form.Item className=\"flex w-full flex-col gap-2 p-2\">\n {(description || label) && (\n <div className=\"flex flex-col gap-1 p-1 leading-none\">\n {label && (\n <FormLabelLayout\n isRequired={isRequired}\n info={info}\n htmlFor={htmlFor}\n >\n {label}\n </FormLabelLayout>\n )}\n {description && <Form.Description>{description}</Form.Description>}\n </div>\n )}\n <Form.Control>{children}</Form.Control>\n\n {showErrorMessage && <Form.Message data-testid=\"error-message\" />}\n </Form.Item>\n);\n","'use client';\n\nimport type { ComponentProps, ElementType, ReactNode } from 'react';\nimport {\n useFormContext,\n type ControllerRenderProps,\n type FieldValues,\n} from 'react-hook-form';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { type FormItemLayoutProps, FormItemLayout } from '../layout';\n\nexport type FormElementProps<T extends ElementType> = {\n name: string;\n Element: T;\n label?: ReactNode;\n isRequired?: boolean;\n info?: string;\n showErrorMessage?: boolean;\n focus?: boolean;\n} & Omit<FormItemLayoutProps, 'children'>;\n\ntype FormFieldElementProps<T extends ElementType> = FormElementProps<T> &\n ComponentProps<T> & {\n field: ControllerRenderProps<FieldValues, string>;\n };\n\nconst FormFieldElement = <T extends ElementType>({\n field,\n name,\n label,\n Element,\n isRequired = false,\n info,\n description,\n showErrorMessage = true,\n ...props\n}: FormFieldElementProps<T>) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Element data-testid=\"element\" id={name} {...field} {...props}>\n {props.children}\n </Element>\n </FormItemLayout>\n );\n};\n\n/**\n * FormElement is a component that allows you to create a form element with a label, description, error message, and validation.\n *\n * The Element prop is the type of the element that will be rendered.\n * This element will interact with the FormContext and will be controlled by the FormControl component.\n * The props used to control the element will be `value` and `onChange`.\n */\nexport const FormElement = <T extends ElementType>(\n props: FormElementProps<T> & ComponentProps<T>\n) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={props.name}\n render={({ field }) => <FormFieldElement {...props} field={field} />}\n />\n );\n};\n","import type { ComponentProps, FC } from 'react';\nimport { Input } from '../../../components/Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputElementProps = Omit<FormElementProps<typeof Input>, 'Element'> &\n Omit<\n ComponentProps<typeof Input> & {\n name: string;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const InputElement: FC<InputElementProps> = (props) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n Element={Input}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n {...props}\n />\n);\n","import type { ComponentProps, FC } from 'react';\nimport { InputPassword } from '../../Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputPasswordElementProps = Omit<\n FormElementProps<typeof InputPassword>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof InputPassword> & {\n name: string;\n autoComplete: 'current-password' | 'new-password';\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const InputPasswordElement: FC<InputPasswordElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={InputPassword}\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","import type { ComponentProps, FC } from 'react';\nimport { TextArea } from '../../TextArea/TextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype TextAreaElementsProps = Omit<\n FormElementProps<typeof TextArea>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof TextArea> & {\n name: string;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const TextAreaElement: FC<TextAreaElementsProps> = (props) => (\n <FormElement\n Element={TextArea}\n id={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldInput } from '../../EditableField/EditableFieldInput';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldInputElementProps = Omit<\n FormElementProps<typeof EditableFieldInput>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof EditableFieldInput> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const EditableFieldInputElement = (\n props: EditableFieldInputElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n Element={EditableFieldInput}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldTextArea } from '../../EditableField/EditableFieldTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldTextAreaElementProps = Omit<\n FormElementProps<typeof EditableFieldTextArea>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof EditableFieldTextArea> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const EditableFieldTextAreaElement = (\n props: EditableFieldTextAreaElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n Element={EditableFieldTextArea}\n {...props}\n />\n);\n","import type { FC } from 'react';\nimport { AutoSizedTextArea } from '../../TextArea/AutoSizeTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype AutoSizedTextAreaElementsProps = Omit<\n FormElementProps<typeof AutoSizedTextArea>,\n 'Element'\n> &\n React.ComponentProps<typeof AutoSizedTextArea> & {\n name: string;\n };\n\nexport const AutoSizedTextAreaElement: FC<AutoSizedTextAreaElementsProps> = (\n props\n) => (\n <FormElement\n Element={AutoSizedTextArea}\n id={props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import { type ComponentProps, type FC, type ReactNode } from 'react';\nimport { Checkbox } from '../../Input';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype CheckboxElementProps = Omit<FormElementProps<typeof Checkbox>, 'Element'> &\n ComponentProps<typeof Checkbox> & {\n name: string;\n inputLabel?: ReactNode;\n };\n\ntype CheckboxComponentProps = Omit<ComponentProps<typeof Checkbox>, 'label'> & {\n name: string;\n inputLabel?: ComponentProps<typeof Checkbox>['label'];\n};\n\nconst CheckboxComponent: FC<CheckboxComponentProps> = ({\n inputLabel,\n ...props\n}) => <Checkbox {...props} label={inputLabel} />;\n\nexport const CheckboxElement: FC<CheckboxElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={CheckboxComponent}\n id={props.name}\n data-testid={props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { MultiSelect } from '../../Select/Multiselect';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<\n FormElementProps<typeof MultiSelect>,\n 'Element'\n> &\n ComponentProps<typeof MultiSelect> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const MultiSelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <MultiSelect\n onValueChange={field.onChange}\n values={field.value}\n {...props}\n >\n {children}\n </MultiSelect>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { Select } from '../../Select/Select';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<FormElementProps<typeof Select>, 'Element'> &\n ComponentProps<typeof Select> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Select\n onValueChange={field.onChange}\n defaultValue={field.value}\n {...props}\n >\n {children}\n </Select>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { SwitchSelector } from '../../SwitchSelector';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SwitchSelectorElementProps = Omit<\n FormElementProps<typeof SwitchSelector>,\n 'Element'\n> &\n ComponentProps<typeof SwitchSelector> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SwitchSelectorElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SwitchSelectorElementProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <SwitchSelector {...field} {...props}>\n {children}\n </SwitchSelector>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","import { Button } from '../Button';\nimport {\n FormElement,\n InputElement,\n InputPasswordElement,\n TextAreaElement,\n} from './elements';\nimport { AutoSizedTextAreaElement } from './elements/AutoSizeTextAreaElement';\nimport { CheckboxElement } from './elements/CheckboxElement';\nimport { EditableFieldInputElement } from './elements/EditableFieldInputElement';\nimport { EditableFieldTextAreaElement } from './elements/EditableFieldTextAreaElement';\nimport { MultiSelectElement } from './elements/MultiselectElement';\nimport { SelectElement } from './elements/SelectElement';\nimport { SwitchSelectorElement } from './elements/SwitchSelectorElement';\nimport { Form as FormRoot } from './FormBase';\nimport { FormControl } from './FormControl';\nimport { FormDescription } from './FormDescription';\nimport { FormField } from './FormField';\nimport { FormItem } from './FormItem';\nimport { FormMessage } from './FormMessage';\nimport { FormLabelLayout } from './layout';\n\ntype FormType = typeof FormRoot & {\n Description: typeof FormDescription;\n Control: typeof FormControl;\n Field: typeof FormField;\n Item: typeof FormItem;\n Label: typeof FormLabelLayout;\n Message: typeof FormMessage;\n Element: typeof FormElement;\n Button: typeof Button;\n Input: typeof InputElement;\n InputPassword: typeof InputPasswordElement;\n Checkbox: typeof CheckboxElement;\n TextArea: typeof TextAreaElement;\n AutoSizedTextArea: typeof AutoSizedTextAreaElement;\n MultiSelect: typeof MultiSelectElement;\n Select: typeof SelectElement;\n EditableFieldInput: typeof EditableFieldInputElement;\n EditableFieldTextArea: typeof EditableFieldTextAreaElement;\n SwitchSelector: typeof SwitchSelectorElement;\n};\n\n/**\n * Form components\n *\n * Example of usage:\n * ```jsx\n * <Form\n * schema={ZodSchema}\n * onSubmitSuccess={onSubmitSuccess}\n * onSubmitError={onSubmitError}\n * autoComplete\n * >\n * <Form.Input name=\"name\" label=\"Name\" />\n * <Form.Button type=\"submit\" label=\"Click to submit\">\n * Submit\n * </Form.Button>\n * </Form>\n * ```\n */\nexport const Form = FormRoot as FormType;\nForm.Description = FormDescription;\nForm.Control = FormControl;\nForm.Field = FormField;\nForm.Item = FormItem;\nForm.Label = FormLabelLayout;\nForm.Message = FormMessage;\nForm.Element = FormElement;\nForm.Input = InputElement;\nForm.InputPassword = InputPasswordElement;\nForm.Checkbox = CheckboxElement;\nForm.TextArea = TextAreaElement;\nForm.AutoSizedTextArea = AutoSizedTextAreaElement;\nForm.Button = Button;\nForm.Select = SelectElement;\nForm.MultiSelect = MultiSelectElement;\nForm.EditableFieldInput = EditableFieldInputElement;\nForm.EditableFieldTextArea = EditableFieldTextAreaElement;\nForm.SwitchSelector = SwitchSelectorElement;\n"],"names":["FormRoot"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,iBAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB;AACF,MACG,qBAAA,KAAK,MAAL,EAAU,WAAU,kCACjB,UAAA;AAAA,GAAA,eAAe,UACf,qBAAC,OAAI,EAAA,WAAU,wCACZ,UAAA;AAAA,IACC,SAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IACH;AAAA,IAED,eAAe,oBAAC,KAAK,aAAL,EAAkB,UAAY,YAAA,CAAA;AAAA,EAAA,GACjD;AAAA,EAED,oBAAA,KAAK,SAAL,EAAc,SAAS,CAAA;AAAA,EAEvB,oBAAqB,oBAAA,KAAK,SAAL,EAAa,eAAY,gBAAgB,CAAA;AAAA,EACjE,CAAA;ACXF,MAAM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out.tsx","../src/components/Form/elements/FormElement.tsx","../src/components/Form/elements/InputElement.tsx","../src/components/Form/elements/InputPasswordElement.tsx","../src/components/Form/elements/TextAreaElement.tsx","../src/components/Form/elements/EditableFieldInputElement.tsx","../src/components/Form/elements/EditableFieldTextAreaElement.tsx","../src/components/Form/elements/AutoSizeTextAreaElement.tsx","../src/components/Form/elements/CheckboxElement.tsx","../src/components/Form/elements/MultiselectElement.tsx","../src/components/Form/elements/SelectElement.tsx","../src/components/Form/elements/SwitchSelectorElement.tsx","../src/components/Form/Form.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { Form } from '../Form';\nimport { FormLabelLayout, type FormLabelLayoutProps } from './FormLabelLayout';\n\nexport type FormItemLayoutProps = Omit<FormLabelLayoutProps, 'children'> & {\n label?: ReactNode;\n description?: ReactNode;\n children: ReactNode;\n showErrorMessage?: boolean;\n};\n\nexport const FormItemLayout: FC<FormItemLayoutProps> = ({\n label,\n description,\n isRequired,\n info,\n children,\n showErrorMessage = true,\n htmlFor,\n}) => (\n <Form.Item className=\"flex w-full flex-col gap-2 p-2\">\n {(description || label) && (\n <div className=\"flex flex-col gap-1 p-1 leading-none\">\n {label && (\n <FormLabelLayout\n isRequired={isRequired}\n info={info}\n htmlFor={htmlFor}\n >\n {label}\n </FormLabelLayout>\n )}\n {description && <Form.Description>{description}</Form.Description>}\n </div>\n )}\n <Form.Control>{children}</Form.Control>\n\n {showErrorMessage && <Form.Message data-testid=\"error-message\" />}\n </Form.Item>\n);\n","'use client';\n\nimport type { ComponentProps, ElementType, ReactNode } from 'react';\nimport {\n useFormContext,\n type ControllerRenderProps,\n type FieldValues,\n} from 'react-hook-form';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { type FormItemLayoutProps, FormItemLayout } from '../layout';\n\nexport type FormElementProps<T extends ElementType> = {\n name: string;\n Element: T;\n label?: ReactNode;\n isRequired?: boolean;\n info?: string;\n showErrorMessage?: boolean;\n focus?: boolean;\n} & Omit<FormItemLayoutProps, 'children'>;\n\ntype FormFieldElementProps<T extends ElementType> = FormElementProps<T> &\n ComponentProps<T> & {\n field: ControllerRenderProps<FieldValues, string>;\n };\n\nconst FormFieldElement = <T extends ElementType>({\n field,\n name,\n label,\n Element,\n isRequired = false,\n info,\n description,\n showErrorMessage = true,\n ...props\n}: FormFieldElementProps<T>) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Element data-testid=\"element\" id={name} {...field} {...props}>\n {props.children}\n </Element>\n </FormItemLayout>\n );\n};\n\n/**\n * FormElement is a component that allows you to create a form element with a label, description, error message, and validation.\n *\n * The Element prop is the type of the element that will be rendered.\n * This element will interact with the FormContext and will be controlled by the FormControl component.\n * The props used to control the element will be `value` and `onChange`.\n */\nexport const FormElement = <T extends ElementType>(\n props: FormElementProps<T> & ComponentProps<T>\n) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={props.name}\n render={({ field }) => <FormFieldElement {...props} field={field} />}\n />\n );\n};\n","import type { ComponentProps, FC } from 'react';\nimport { Input } from '../../../components/Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputElementProps = Omit<FormElementProps<typeof Input>, 'Element'> &\n Omit<\n ComponentProps<typeof Input> & {\n name: string;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const InputElement: FC<InputElementProps> = (props) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n Element={Input}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n {...props}\n />\n);\n","import type { ComponentProps, FC } from 'react';\nimport { InputPassword } from '../../Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputPasswordElementProps = Omit<\n FormElementProps<typeof InputPassword>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof InputPassword> & {\n name: string;\n autoComplete: 'current-password' | 'new-password';\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const InputPasswordElement: FC<InputPasswordElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={InputPassword}\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","import type { ComponentProps, FC } from 'react';\nimport { TextArea } from '../../TextArea/TextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype TextAreaElementsProps = Omit<\n FormElementProps<typeof TextArea>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof TextArea> & {\n name: string;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const TextAreaElement: FC<TextAreaElementsProps> = (props) => (\n <FormElement\n Element={TextArea}\n id={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldInput } from '../../EditableField/EditableFieldInput';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldInputElementProps = Omit<\n FormElementProps<typeof EditableFieldInput>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof EditableFieldInput> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const EditableFieldInputElement = (\n props: EditableFieldInputElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n Element={EditableFieldInput}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldTextArea } from '../../EditableField/EditableFieldTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldTextAreaElementProps = Omit<\n FormElementProps<typeof EditableFieldTextArea>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof EditableFieldTextArea> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const EditableFieldTextAreaElement = (\n props: EditableFieldTextAreaElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n Element={EditableFieldTextArea}\n {...props}\n />\n);\n","import type { FC } from 'react';\nimport { AutoSizedTextArea } from '../../TextArea/AutoSizeTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype AutoSizedTextAreaElementsProps = Omit<\n FormElementProps<typeof AutoSizedTextArea>,\n 'Element'\n> &\n React.ComponentProps<typeof AutoSizedTextArea> & {\n name: string;\n };\n\nexport const AutoSizedTextAreaElement: FC<AutoSizedTextAreaElementsProps> = (\n props\n) => (\n <FormElement\n Element={AutoSizedTextArea}\n id={props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import { type ComponentProps, type FC } from 'react';\nimport { Checkbox } from '../../Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype CheckboxElementProps = Omit<FormElementProps<typeof Checkbox>, 'Element'> &\n ComponentProps<typeof Checkbox> & {\n name: string;\n inputLabel?: string;\n };\n\ntype CheckboxComponentProps = Omit<ComponentProps<typeof Checkbox>, 'label'> & {\n name: string;\n inputLabel?: ComponentProps<typeof Checkbox>['label'];\n};\n\nconst CheckboxComponent: FC<CheckboxComponentProps> = ({\n inputLabel,\n ...props\n}) => <Checkbox {...props} label={inputLabel} />;\n\nexport const CheckboxElement: FC<CheckboxElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={CheckboxComponent}\n id={props.name}\n data-testid={props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { MultiSelect } from '../../Select/Multiselect';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<\n FormElementProps<typeof MultiSelect>,\n 'Element'\n> &\n ComponentProps<typeof MultiSelect> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const MultiSelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <MultiSelect\n onValueChange={field.onChange}\n values={field.value}\n {...props}\n >\n {children}\n </MultiSelect>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { Select } from '../../Select/Select';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<FormElementProps<typeof Select>, 'Element'> &\n ComponentProps<typeof Select> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Select\n onValueChange={field.onChange}\n defaultValue={field.value}\n {...props}\n >\n {children}\n </Select>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { SwitchSelector } from '../../SwitchSelector';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SwitchSelectorElementProps = Omit<\n FormElementProps<typeof SwitchSelector>,\n 'Element'\n> &\n ComponentProps<typeof SwitchSelector> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SwitchSelectorElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SwitchSelectorElementProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <SwitchSelector {...field} {...props}>\n {children}\n </SwitchSelector>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","import { Button } from '../Button';\nimport {\n FormElement,\n InputElement,\n InputPasswordElement,\n TextAreaElement,\n} from './elements';\nimport { AutoSizedTextAreaElement } from './elements/AutoSizeTextAreaElement';\nimport { CheckboxElement } from './elements/CheckboxElement';\nimport { EditableFieldInputElement } from './elements/EditableFieldInputElement';\nimport { EditableFieldTextAreaElement } from './elements/EditableFieldTextAreaElement';\nimport { MultiSelectElement } from './elements/MultiselectElement';\nimport { SelectElement } from './elements/SelectElement';\nimport { SwitchSelectorElement } from './elements/SwitchSelectorElement';\nimport { Form as FormRoot } from './FormBase';\nimport { FormControl } from './FormControl';\nimport { FormDescription } from './FormDescription';\nimport { FormField } from './FormField';\nimport { FormItem } from './FormItem';\nimport { FormMessage } from './FormMessage';\nimport { FormLabelLayout } from './layout';\n\ntype FormType = typeof FormRoot & {\n Description: typeof FormDescription;\n Control: typeof FormControl;\n Field: typeof FormField;\n Item: typeof FormItem;\n Label: typeof FormLabelLayout;\n Message: typeof FormMessage;\n Element: typeof FormElement;\n Button: typeof Button;\n Input: typeof InputElement;\n InputPassword: typeof InputPasswordElement;\n Checkbox: typeof CheckboxElement;\n TextArea: typeof TextAreaElement;\n AutoSizedTextArea: typeof AutoSizedTextAreaElement;\n MultiSelect: typeof MultiSelectElement;\n Select: typeof SelectElement;\n EditableFieldInput: typeof EditableFieldInputElement;\n EditableFieldTextArea: typeof EditableFieldTextAreaElement;\n SwitchSelector: typeof SwitchSelectorElement;\n};\n\n/**\n * Form components\n *\n * Example of usage:\n * ```jsx\n * <Form\n * schema={ZodSchema}\n * onSubmitSuccess={onSubmitSuccess}\n * onSubmitError={onSubmitError}\n * autoComplete\n * >\n * <Form.Input name=\"name\" label=\"Name\" />\n * <Form.Button type=\"submit\" label=\"Click to submit\">\n * Submit\n * </Form.Button>\n * </Form>\n * ```\n */\nexport const Form = FormRoot as FormType;\nForm.Description = FormDescription;\nForm.Control = FormControl;\nForm.Field = FormField;\nForm.Item = FormItem;\nForm.Label = FormLabelLayout;\nForm.Message = FormMessage;\nForm.Element = FormElement;\nForm.Input = InputElement;\nForm.InputPassword = InputPasswordElement;\nForm.Checkbox = CheckboxElement;\nForm.TextArea = TextAreaElement;\nForm.AutoSizedTextArea = AutoSizedTextAreaElement;\nForm.Button = Button;\nForm.Select = SelectElement;\nForm.MultiSelect = MultiSelectElement;\nForm.EditableFieldInput = EditableFieldInputElement;\nForm.EditableFieldTextArea = EditableFieldTextAreaElement;\nForm.SwitchSelector = SwitchSelectorElement;\n"],"names":["jsxs","jsx","FormLabelLayout","useFormField","useFormContext","Input","InputPassword","TextArea","EditableFieldInput","EditableFieldTextArea","AutoSizedTextArea","Checkbox","MultiSelect","Select","SwitchSelector","FormRoot","FormDescription","FormControl","FormField","FormItem","FormMessage","Button"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,iBAA0C,CAAC;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB;AACF,MACGA,2BAAAA,KAAA,KAAK,MAAL,EAAU,WAAU,kCACjB,UAAA;AAAA,GAAA,eAAe,UACfA,2BAAA,KAAC,OAAI,EAAA,WAAU,wCACZ,UAAA;AAAA,IACC,SAAAC,2BAAA;AAAA,MAACC,uCAAA;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QAEC,UAAA;AAAA,MAAA;AAAA,IACH;AAAA,IAED,eAAeD,2BAAA,IAAC,KAAK,aAAL,EAAkB,UAAY,YAAA,CAAA;AAAA,EAAA,GACjD;AAAA,EAEDA,2BAAAA,IAAA,KAAK,SAAL,EAAc,SAAS,CAAA;AAAA,EAEvB,oBAAqBA,2BAAA,IAAA,KAAK,SAAL,EAAa,eAAY,gBAAgB,CAAA;AAAA,EACjE,CAAA;ACXF,MAAM,mBAAmB,CAAwB;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA,mBAAmB;AAAA,EACnB,GAAG;AACL,MAAgC;AACxB,QAAA,EAAE,MAAM,IAAIE,uCAAa;AAG7B,SAAAF,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAc,CAAC,CAAC;AAAA,MAEhB,UAAAA,2BAAAA,IAAC,SAAQ,EAAA,eAAY,WAAU,IAAI,MAAO,GAAG,OAAQ,GAAG,OACrD,UAAA,MAAM,SACT,CAAA;AAAA,IAAA;AAAA,EACF;AA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,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAkC;AAC1B,QAAA,EAAE,QAAQ,IAAIT,6BAAe;AAGjC,SAAAH,2BAAA;AAAA,IAAC,KAAK;AAAA,IAAL;AAAA,MACC;AAAA,MACA;AAAA,MACA,QAAQ,CAAC,EAAE,YAAY;AACf,cAAA,EAAE,MAAM,IAAIE,uCAAa;AAG7B,eAAAF,2BAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,gBAAc,CAAC,CAAC;AAAA,YAEhB,yCAACa,gDAAgB,EAAA,GAAG,OAAQ,GAAG,OAC5B,SACH,CAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAEJ;ACEO,MAAM,OAAOC,yBAAAA;AACpB,KAAK,cAAcC,gCAAA;AACnB,KAAK,UAAUC,4BAAA;AACf,KAAK,QAAQC,0BAAA;AACb,KAAK,OAAOC,yBAAA;AACZ,KAAK,QAAQjB,uCAAA;AACb,KAAK,UAAUkB,4BAAA;AACf,KAAK,UAAU;AACf,KAAK,QAAQ;AACb,KAAK,gBAAgB;AACrB,KAAK,WAAW;AAChB,KAAK,WAAW;AAChB,KAAK,oBAAoB;AACzB,KAAK,SAASC,yBAAA;AACd,KAAK,SAAS;AACd,KAAK,cAAc;AACnB,KAAK,qBAAqB;AAC1B,KAAK,wBAAwB;AAC7B,KAAK,iBAAiB;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Form-DJrUK3mm.cjs","sources":["../src/components/Form/layout/FormItemLayout.tsx","../src/components/Form/elements/FormElement.tsx","../src/components/Form/elements/InputElement.tsx","../src/components/Form/elements/InputPasswordElement.tsx","../src/components/Form/elements/TextAreaElement.tsx","../src/components/Form/elements/EditableFieldInputElement.tsx","../src/components/Form/elements/EditableFieldTextAreaElement.tsx","../src/components/Form/elements/AutoSizeTextAreaElement.tsx","../src/components/Form/elements/CheckboxElement.tsx","../src/components/Form/elements/MultiselectElement.tsx","../src/components/Form/elements/SelectElement.tsx","../src/components/Form/elements/SwitchSelectorElement.tsx","../src/components/Form/Form.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { Form } from '../Form';\nimport { FormLabelLayout, type FormLabelLayoutProps } from './FormLabelLayout';\n\nexport type FormItemLayoutProps = Omit<FormLabelLayoutProps, 'children'> & {\n label?: ReactNode;\n description?: ReactNode;\n children: ReactNode;\n showErrorMessage?: boolean;\n};\n\nexport const FormItemLayout: FC<FormItemLayoutProps> = ({\n label,\n description,\n isRequired,\n info,\n children,\n showErrorMessage = true,\n htmlFor,\n}) => (\n <Form.Item className=\"flex w-full flex-col gap-2 p-2\">\n {(description || label) && (\n <div className=\"flex flex-col gap-1 p-1 leading-none\">\n {label && (\n <FormLabelLayout\n isRequired={isRequired}\n info={info}\n htmlFor={htmlFor}\n >\n {label}\n </FormLabelLayout>\n )}\n {description && <Form.Description>{description}</Form.Description>}\n </div>\n )}\n <Form.Control>{children}</Form.Control>\n\n {showErrorMessage && <Form.Message data-testid=\"error-message\" />}\n </Form.Item>\n);\n","'use client';\n\nimport type { ComponentProps, ElementType, ReactNode } from 'react';\nimport {\n useFormContext,\n type ControllerRenderProps,\n type FieldValues,\n} from 'react-hook-form';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { type FormItemLayoutProps, FormItemLayout } from '../layout';\n\nexport type FormElementProps<T extends ElementType> = {\n name: string;\n Element: T;\n label?: ReactNode;\n isRequired?: boolean;\n info?: string;\n showErrorMessage?: boolean;\n focus?: boolean;\n} & Omit<FormItemLayoutProps, 'children'>;\n\ntype FormFieldElementProps<T extends ElementType> = FormElementProps<T> &\n ComponentProps<T> & {\n field: ControllerRenderProps<FieldValues, string>;\n };\n\nconst FormFieldElement = <T extends ElementType>({\n field,\n name,\n label,\n Element,\n isRequired = false,\n info,\n description,\n showErrorMessage = true,\n ...props\n}: FormFieldElementProps<T>) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Element data-testid=\"element\" id={name} {...field} {...props}>\n {props.children}\n </Element>\n </FormItemLayout>\n );\n};\n\n/**\n * FormElement is a component that allows you to create a form element with a label, description, error message, and validation.\n *\n * The Element prop is the type of the element that will be rendered.\n * This element will interact with the FormContext and will be controlled by the FormControl component.\n * The props used to control the element will be `value` and `onChange`.\n */\nexport const FormElement = <T extends ElementType>(\n props: FormElementProps<T> & ComponentProps<T>\n) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={props.name}\n render={({ field }) => <FormFieldElement {...props} field={field} />}\n />\n );\n};\n","import type { ComponentProps, FC } from 'react';\nimport { Input } from '../../../components/Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputElementProps = Omit<FormElementProps<typeof Input>, 'Element'> &\n Omit<\n ComponentProps<typeof Input> & {\n name: string;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const InputElement: FC<InputElementProps> = (props) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n Element={Input}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n {...props}\n />\n);\n","import type { ComponentProps, FC } from 'react';\nimport { InputPassword } from '../../Input';\nimport { type FormElementProps, FormElement } from './FormElement';\n\ntype InputPasswordElementProps = Omit<\n FormElementProps<typeof InputPassword>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof InputPassword> & {\n name: string;\n autoComplete: 'current-password' | 'new-password';\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const InputPasswordElement: FC<InputPasswordElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={InputPassword}\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","import type { ComponentProps, FC } from 'react';\nimport { TextArea } from '../../TextArea/TextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype TextAreaElementsProps = Omit<\n FormElementProps<typeof TextArea>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof TextArea> & {\n name: string;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const TextAreaElement: FC<TextAreaElementsProps> = (props) => (\n <FormElement\n Element={TextArea}\n id={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldInput } from '../../EditableField/EditableFieldInput';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldInputElementProps = Omit<\n FormElementProps<typeof EditableFieldInput>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof EditableFieldInput> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const EditableFieldInputElement = (\n props: EditableFieldInputElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n Element={EditableFieldInput}\n {...props}\n />\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport { EditableFieldTextArea } from '../../EditableField/EditableFieldTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype EditableFieldTextAreaElementProps = Omit<\n FormElementProps<typeof EditableFieldTextArea>,\n 'Element'\n> &\n Omit<\n ComponentProps<typeof EditableFieldTextArea> & {\n name: string;\n description?: ReactNode;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n },\n 'aria-label' | 'aria-labelledby'\n >;\n\nexport const EditableFieldTextAreaElement = (\n props: EditableFieldTextAreaElementProps\n) => (\n <FormElement\n id={props.name}\n data-testid={props.name}\n aria-labelledby={props.label ? `${props.name}-label` : undefined}\n aria-label={props.label ? undefined : props.name}\n Element={EditableFieldTextArea}\n {...props}\n />\n);\n","import type { FC } from 'react';\nimport { AutoSizedTextArea } from '../../TextArea/AutoSizeTextArea';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype AutoSizedTextAreaElementsProps = Omit<\n FormElementProps<typeof AutoSizedTextArea>,\n 'Element'\n> &\n React.ComponentProps<typeof AutoSizedTextArea> & {\n name: string;\n };\n\nexport const AutoSizedTextAreaElement: FC<AutoSizedTextAreaElementsProps> = (\n props\n) => (\n <FormElement\n Element={AutoSizedTextArea}\n id={props.name}\n data-testid={props.name}\n {...props}\n />\n);\n","import { type ComponentProps, type FC, type ReactNode } from 'react';\nimport { Checkbox } from '../../Input';\nimport { FormElement, type FormElementProps } from './FormElement';\n\ntype CheckboxElementProps = Omit<FormElementProps<typeof Checkbox>, 'Element'> &\n ComponentProps<typeof Checkbox> & {\n name: string;\n inputLabel?: ReactNode;\n };\n\ntype CheckboxComponentProps = Omit<ComponentProps<typeof Checkbox>, 'label'> & {\n name: string;\n inputLabel?: ComponentProps<typeof Checkbox>['label'];\n};\n\nconst CheckboxComponent: FC<CheckboxComponentProps> = ({\n inputLabel,\n ...props\n}) => <Checkbox {...props} label={inputLabel} />;\n\nexport const CheckboxElement: FC<CheckboxElementProps> = ({\n autoComplete,\n ...props\n}) => (\n <FormElement\n Element={CheckboxComponent}\n id={props.name}\n data-testid={props.name}\n autoComplete={autoComplete}\n minLength={6}\n maxLength={255}\n {...props}\n />\n);\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { MultiSelect } from '../../Select/Multiselect';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<\n FormElementProps<typeof MultiSelect>,\n 'Element'\n> &\n ComponentProps<typeof MultiSelect> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const MultiSelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <MultiSelect\n onValueChange={field.onChange}\n values={field.value}\n {...props}\n >\n {children}\n </MultiSelect>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { Select } from '../../Select/Select';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SelectElementsProps = Omit<FormElementProps<typeof Select>, 'Element'> &\n ComponentProps<typeof Select> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SelectElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SelectElementsProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <Select\n onValueChange={field.onChange}\n defaultValue={field.value}\n {...props}\n >\n {children}\n </Select>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","/* eslint-disable react-hooks/rules-of-hooks */\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { SwitchSelector } from '../../SwitchSelector';\nimport { Form } from '../Form';\nimport { useFormField } from '../FormField';\nimport { FormItemLayout } from '../layout/FormItemLayout';\nimport type { FormElementProps } from './FormElement';\n\ntype SwitchSelectorElementProps = Omit<\n FormElementProps<typeof SwitchSelector>,\n 'Element'\n> &\n ComponentProps<typeof SwitchSelector> & {\n name: string;\n description?: string;\n placeholder?: string;\n className?: string;\n children?: ReactNode;\n };\n\nexport const SwitchSelectorElement = ({\n name,\n description,\n label,\n isRequired,\n info,\n showErrorMessage,\n children,\n ...props\n}: SwitchSelectorElementProps) => {\n const { control } = useFormContext();\n\n return (\n <Form.Field\n control={control}\n name={name}\n render={({ field }) => {\n const { error } = useFormField();\n\n return (\n <FormItemLayout\n htmlFor={name}\n label={label}\n description={description}\n isRequired={isRequired}\n info={info}\n showErrorMessage={showErrorMessage}\n aria-invalid={!!error}\n >\n <SwitchSelector {...field} {...props}>\n {children}\n </SwitchSelector>\n </FormItemLayout>\n );\n }}\n />\n );\n};\n","import { Button } from '../Button';\nimport {\n FormElement,\n InputElement,\n InputPasswordElement,\n TextAreaElement,\n} from './elements';\nimport { AutoSizedTextAreaElement } from './elements/AutoSizeTextAreaElement';\nimport { CheckboxElement } from './elements/CheckboxElement';\nimport { EditableFieldInputElement } from './elements/EditableFieldInputElement';\nimport { EditableFieldTextAreaElement } from './elements/EditableFieldTextAreaElement';\nimport { MultiSelectElement } from './elements/MultiselectElement';\nimport { SelectElement } from './elements/SelectElement';\nimport { SwitchSelectorElement } from './elements/SwitchSelectorElement';\nimport { Form as FormRoot } from './FormBase';\nimport { FormControl } from './FormControl';\nimport { FormDescription } from './FormDescription';\nimport { FormField } from './FormField';\nimport { FormItem } from './FormItem';\nimport { FormMessage } from './FormMessage';\nimport { FormLabelLayout } from './layout';\n\ntype FormType = typeof FormRoot & {\n Description: typeof FormDescription;\n Control: typeof FormControl;\n Field: typeof FormField;\n Item: typeof FormItem;\n Label: typeof FormLabelLayout;\n Message: typeof FormMessage;\n Element: typeof FormElement;\n Button: typeof Button;\n Input: typeof InputElement;\n InputPassword: typeof InputPasswordElement;\n Checkbox: typeof CheckboxElement;\n TextArea: typeof TextAreaElement;\n AutoSizedTextArea: typeof AutoSizedTextAreaElement;\n MultiSelect: typeof MultiSelectElement;\n Select: typeof SelectElement;\n EditableFieldInput: typeof EditableFieldInputElement;\n EditableFieldTextArea: typeof EditableFieldTextAreaElement;\n SwitchSelector: typeof SwitchSelectorElement;\n};\n\n/**\n * Form components\n *\n * Example of usage:\n * ```jsx\n * <Form\n * schema={ZodSchema}\n * onSubmitSuccess={onSubmitSuccess}\n * onSubmitError={onSubmitError}\n * autoComplete\n * >\n * <Form.Input name=\"name\" label=\"Name\" />\n * <Form.Button type=\"submit\" label=\"Click to submit\">\n * Submit\n * </Form.Button>\n * </Form>\n * ```\n */\nexport const Form = FormRoot as FormType;\nForm.Description = FormDescription;\nForm.Control = FormControl;\nForm.Field = FormField;\nForm.Item = FormItem;\nForm.Label = FormLabelLayout;\nForm.Message = FormMessage;\nForm.Element = FormElement;\nForm.Input = InputElement;\nForm.InputPassword = InputPasswordElement;\nForm.Checkbox = CheckboxElement;\nForm.TextArea = TextAreaElement;\nForm.AutoSizedTextArea = AutoSizedTextAreaElement;\nForm.Button = Button;\nForm.Select = SelectElement;\nForm.MultiSelect = MultiSelectElement;\nForm.EditableFieldInput = EditableFieldInputElement;\nForm.EditableFieldTextArea = EditableFieldTextAreaElement;\nForm.SwitchSelector = SwitchSelectorElement;\n"],"names":["jsxs","jsx","FormLabelLayout","useFormField","useFormContext","Input","InputPassword","TextArea","EditableFieldInput","EditableFieldTextArea","AutoSizedTextArea","Checkbox","MultiSelect","Select","SwitchSelector","FormRoot","FormDescription","FormControl","FormField","FormItem","FormMessage","Button"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAM,iBAA0C,C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;AAAA,IAAC,KAAK;AAAA,IAAL;AAAA,MACC;AAAA,MACA;AAAA,MACA,QAAQ,CAAC,EAAE,YAAY;AACf,cAAA,EAAE,MAAM,IAAIE,uCAAa;AAG7B,eAAAF,2BAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,SAAS;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,gBAAc,CAAC,CAAC;AAAA,YAEhB,yCAACa,gDAAgB,EAAA,GAAG,OAAQ,GAAG,OAC5B,SACH,CAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAEJ;ACEO,MAAM,OAAOC,yBAAAA;AACpB,KAAK,cAAcC,gCAAA;AACnB,KAAK,UAAUC,4BAAA;AACf,KAAK,QAAQC,0BAAA;AACb,KAAK,OAAOC,yBAAA;AACZ,KAAK,QAAQjB,uCAAA;AACb,KAAK,UAAUkB,4BAAA;AACf,KAAK,UAAU;AACf,KAAK,QAAQ;AACb,KAAK,gBAAgB;AACrB,KAAK,WAAW;AAChB,KAAK,WAAW;AAChB,KAAK,oBAAoB;AACzB,KAAK,SAASC,yBAAA;AACd,KAAK,SAAS;AACd,KAAK,cAAc;AACnB,KAAK,qBAAqB;AAC1B,KAAK,wBAAwB;AAC7B,KAAK,iBAAiB;;;;;;;;;;;;;;"}
|
|
@@ -17,29 +17,38 @@ const CopyToClipboard = ({
|
|
|
17
17
|
setTimeout(() => setIsCopied(false), 1e3);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
21
|
+
"span",
|
|
22
|
+
{
|
|
23
|
+
className: utils_cn.cn(
|
|
24
|
+
"inline-block gap-2 hover:cursor-pointer hover:bg-neutral/10 rounded-md p-0.5",
|
|
25
|
+
className
|
|
26
|
+
),
|
|
27
|
+
onClick: handleCopy,
|
|
28
|
+
children: [
|
|
29
|
+
children,
|
|
30
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex", children: text && (isCopied ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
31
|
+
lucideReact.CopyCheck,
|
|
32
|
+
{
|
|
33
|
+
size: 12,
|
|
34
|
+
"aria-label": "copied",
|
|
35
|
+
role: "button",
|
|
36
|
+
"data-testid": "copy-to-clipboard",
|
|
37
|
+
className: "ml-1 mt-1"
|
|
38
|
+
}
|
|
39
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
40
|
+
lucideReact.CopyIcon,
|
|
41
|
+
{
|
|
42
|
+
size: 12,
|
|
43
|
+
"aria-label": "copy",
|
|
44
|
+
role: "button",
|
|
45
|
+
"data-testid": "copy-to-clipboard",
|
|
46
|
+
className: "ml-1 mt-1 cursor-pointer"
|
|
47
|
+
}
|
|
48
|
+
)) })
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
);
|
|
43
52
|
};
|
|
44
53
|
exports.CopyToClipboard = CopyToClipboard;
|
|
45
54
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/components/CopyToClipboard/index.tsx"],"sourcesContent":["'use client';\n\nimport { CopyCheck, CopyIcon } from 'lucide-react';\nimport { type FC, type PropsWithChildren, useState } from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type CopyToClipboardProps = PropsWithChildren<{\n text: string;\n className?: string;\n}>;\n\nexport const CopyToClipboard: FC<CopyToClipboardProps> = ({\n text,\n children,\n className,\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n\n const handleCopy = () => {\n navigator.clipboard.writeText(text).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 1000);\n });\n };\n\n return (\n <span
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/components/CopyToClipboard/index.tsx"],"sourcesContent":["'use client';\n\nimport { CopyCheck, CopyIcon } from 'lucide-react';\nimport { type FC, type PropsWithChildren, useState } from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type CopyToClipboardProps = PropsWithChildren<{\n text: string;\n className?: string;\n}>;\n\nexport const CopyToClipboard: FC<CopyToClipboardProps> = ({\n text,\n children,\n className,\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n\n const handleCopy = () => {\n navigator.clipboard.writeText(text).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 1000);\n });\n };\n\n return (\n <span\n className={cn(\n 'inline-block gap-2 hover:cursor-pointer hover:bg-neutral/10 rounded-md p-0.5',\n className\n )}\n onClick={handleCopy}\n >\n {children}\n\n <span className=\"inline-flex\">\n {text &&\n (isCopied ? (\n <CopyCheck\n size={12}\n aria-label=\"copied\"\n role=\"button\"\n data-testid=\"copy-to-clipboard\"\n className=\"ml-1 mt-1\"\n />\n ) : (\n <CopyIcon\n size={12}\n aria-label=\"copy\"\n role=\"button\"\n data-testid=\"copy-to-clipboard\"\n className=\"ml-1 mt-1 cursor-pointer\"\n />\n ))}\n </span>\n </span>\n );\n};\n"],"names":["useState","jsxs","cn","jsx","CopyCheck","CopyIcon"],"mappings":";;;;;;;AAWO,MAAM,kBAA4C,CAAC;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,CAAC,UAAU,WAAW,IAAIA,aAAAA,SAAS,KAAK;AAE9C,QAAM,aAAa,MAAM;AACvB,cAAU,UAAU,UAAU,IAAI,EAAE,KAAK,MAAM;AAC7C,kBAAY,IAAI;AAChB,iBAAW,MAAM,YAAY,KAAK,GAAG,GAAI;AAAA,IAAA,CAC1C;AAAA,EACH;AAGE,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,SAAA;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACA,SAAS;AAAA,MAER,UAAA;AAAA,QAAA;AAAA,QAEAC,2BAAA,IAAA,QAAA,EAAK,WAAU,eACb,mBACE,WACCA,2BAAA;AAAA,UAACC,YAAA;AAAA,UAAA;AAAA,YACC,MAAM;AAAA,YACN,cAAW;AAAA,YACX,MAAK;AAAA,YACL,eAAY;AAAA,YACZ,WAAU;AAAA,UAAA;AAAA,QAAA,IAGZD,2BAAA;AAAA,UAACE,YAAA;AAAA,UAAA;AAAA,YACC,MAAM;AAAA,YACN,cAAW;AAAA,YACX,MAAK;AAAA,YACL,eAAY;AAAA,YACZ,WAAU;AAAA,UAAA;AAAA,QAAA,GAGlB,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CopyToClipboard/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAGlE,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CopyToClipboard/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAGlE,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CA8CpD,CAAC"}
|
|
@@ -15,29 +15,38 @@ const CopyToClipboard = ({
|
|
|
15
15
|
setTimeout(() => setIsCopied(false), 1e3);
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
|
-
return /* @__PURE__ */ jsxs(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
return /* @__PURE__ */ jsxs(
|
|
19
|
+
"span",
|
|
20
|
+
{
|
|
21
|
+
className: cn(
|
|
22
|
+
"inline-block gap-2 hover:cursor-pointer hover:bg-neutral/10 rounded-md p-0.5",
|
|
23
|
+
className
|
|
24
|
+
),
|
|
25
|
+
onClick: handleCopy,
|
|
26
|
+
children: [
|
|
27
|
+
children,
|
|
28
|
+
/* @__PURE__ */ jsx("span", { className: "inline-flex", children: text && (isCopied ? /* @__PURE__ */ jsx(
|
|
29
|
+
CopyCheck,
|
|
30
|
+
{
|
|
31
|
+
size: 12,
|
|
32
|
+
"aria-label": "copied",
|
|
33
|
+
role: "button",
|
|
34
|
+
"data-testid": "copy-to-clipboard",
|
|
35
|
+
className: "ml-1 mt-1"
|
|
36
|
+
}
|
|
37
|
+
) : /* @__PURE__ */ jsx(
|
|
38
|
+
CopyIcon,
|
|
39
|
+
{
|
|
40
|
+
size: 12,
|
|
41
|
+
"aria-label": "copy",
|
|
42
|
+
role: "button",
|
|
43
|
+
"data-testid": "copy-to-clipboard",
|
|
44
|
+
className: "ml-1 mt-1 cursor-pointer"
|
|
45
|
+
}
|
|
46
|
+
)) })
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
);
|
|
41
50
|
};
|
|
42
51
|
export {
|
|
43
52
|
CopyToClipboard
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/components/CopyToClipboard/index.tsx"],"sourcesContent":["'use client';\n\nimport { CopyCheck, CopyIcon } from 'lucide-react';\nimport { type FC, type PropsWithChildren, useState } from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type CopyToClipboardProps = PropsWithChildren<{\n text: string;\n className?: string;\n}>;\n\nexport const CopyToClipboard: FC<CopyToClipboardProps> = ({\n text,\n children,\n className,\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n\n const handleCopy = () => {\n navigator.clipboard.writeText(text).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 1000);\n });\n };\n\n return (\n <span
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/components/CopyToClipboard/index.tsx"],"sourcesContent":["'use client';\n\nimport { CopyCheck, CopyIcon } from 'lucide-react';\nimport { type FC, type PropsWithChildren, useState } from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type CopyToClipboardProps = PropsWithChildren<{\n text: string;\n className?: string;\n}>;\n\nexport const CopyToClipboard: FC<CopyToClipboardProps> = ({\n text,\n children,\n className,\n}) => {\n const [isCopied, setIsCopied] = useState(false);\n\n const handleCopy = () => {\n navigator.clipboard.writeText(text).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 1000);\n });\n };\n\n return (\n <span\n className={cn(\n 'inline-block gap-2 hover:cursor-pointer hover:bg-neutral/10 rounded-md p-0.5',\n className\n )}\n onClick={handleCopy}\n >\n {children}\n\n <span className=\"inline-flex\">\n {text &&\n (isCopied ? (\n <CopyCheck\n size={12}\n aria-label=\"copied\"\n role=\"button\"\n data-testid=\"copy-to-clipboard\"\n className=\"ml-1 mt-1\"\n />\n ) : (\n <CopyIcon\n size={12}\n aria-label=\"copy\"\n role=\"button\"\n data-testid=\"copy-to-clipboard\"\n className=\"ml-1 mt-1 cursor-pointer\"\n />\n ))}\n </span>\n </span>\n );\n};\n"],"names":[],"mappings":";;;;;AAWO,MAAM,kBAA4C,CAAC;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAE9C,QAAM,aAAa,MAAM;AACvB,cAAU,UAAU,UAAU,IAAI,EAAE,KAAK,MAAM;AAC7C,kBAAY,IAAI;AAChB,iBAAW,MAAM,YAAY,KAAK,GAAG,GAAI;AAAA,IAAA,CAC1C;AAAA,EACH;AAGE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACA,SAAS;AAAA,MAER,UAAA;AAAA,QAAA;AAAA,QAEA,oBAAA,QAAA,EAAK,WAAU,eACb,mBACE,WACC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAM;AAAA,YACN,cAAW;AAAA,YACX,MAAK;AAAA,YACL,eAAY;AAAA,YACZ,WAAU;AAAA,UAAA;AAAA,QAAA,IAGZ;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAM;AAAA,YACN,cAAW;AAAA,YACX,MAAK;AAAA,YACL,eAAY;AAAA,YACZ,WAAU;AAAA,UAAA;AAAA,QAAA,GAGlB,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ComponentProps, FC } from 'react';
|
|
1
|
+
import { ComponentProps, FC, ReactNode } from 'react';
|
|
2
2
|
import { Checkbox } from '../../Input';
|
|
3
3
|
import { FormElementProps } from './FormElement';
|
|
4
4
|
type CheckboxElementProps = Omit<FormElementProps<typeof Checkbox>, 'Element'> & ComponentProps<typeof Checkbox> & {
|
|
5
5
|
name: string;
|
|
6
|
-
inputLabel?:
|
|
6
|
+
inputLabel?: ReactNode;
|
|
7
7
|
};
|
|
8
8
|
export declare const CheckboxElement: FC<CheckboxElementProps>;
|
|
9
9
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxElement.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/elements/CheckboxElement.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CheckboxElement.d.ts","sourceRoot":"","sources":["../../../../src/components/Form/elements/CheckboxElement.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,EAAE,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEnE,KAAK,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,QAAQ,CAAC,EAAE,SAAS,CAAC,GAC5E,cAAc,CAAC,OAAO,QAAQ,CAAC,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB,CAAC;AAYJ,eAAO,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAapD,CAAC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
4
|
const classVarianceAuthority = require("class-variance-authority");
|
|
5
|
-
const ReactExports = require("react");
|
|
6
5
|
const checkboxVariants = classVarianceAuthority.cva("", {
|
|
7
6
|
variants: {
|
|
8
7
|
variant: {
|
|
@@ -42,34 +41,42 @@ const checkboxVariants = classVarianceAuthority.cva("", {
|
|
|
42
41
|
size: "md"
|
|
43
42
|
}
|
|
44
43
|
});
|
|
45
|
-
const
|
|
44
|
+
const Input = ({
|
|
46
45
|
validationStyleEnabled = false,
|
|
47
46
|
label,
|
|
48
47
|
size,
|
|
49
48
|
color,
|
|
49
|
+
name,
|
|
50
50
|
variant,
|
|
51
51
|
className,
|
|
52
52
|
...props
|
|
53
|
-
}) =>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
53
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
54
|
+
"input",
|
|
55
|
+
{
|
|
56
|
+
type: "checkbox",
|
|
57
|
+
className: checkboxVariants({
|
|
58
|
+
variant,
|
|
59
|
+
size,
|
|
60
|
+
color,
|
|
61
|
+
validationStyleEnabled: validationStyleEnabled ? "enabled" : "disabled",
|
|
62
|
+
className
|
|
63
|
+
}),
|
|
64
|
+
...props
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
const Checkbox = (props) => {
|
|
68
|
+
const { label, name, id } = props;
|
|
69
|
+
return label ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
70
|
+
"label",
|
|
71
|
+
{
|
|
72
|
+
htmlFor: id ?? name,
|
|
73
|
+
className: "flex items-center gap-x-4 font-medium text-sm cursor-pointer",
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsxRuntime.jsx(Input, { id: id ?? name, ...props }),
|
|
76
|
+
label
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(Input, { id: id ?? name, ...props });
|
|
73
80
|
};
|
|
74
81
|
exports.Checkbox = Checkbox;
|
|
75
82
|
exports.checkboxVariants = checkboxVariants;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.cjs","sources":["../../../src/components/Input/Checkbox.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport {\n
|
|
1
|
+
{"version":3,"file":"Checkbox.cjs","sources":["../../../src/components/Input/Checkbox.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority';\nimport {\n ReactNode,\n type DetailedHTMLProps,\n type FC,\n type InputHTMLAttributes,\n} from 'react';\n\nexport const checkboxVariants = cva('', {\n variants: {\n variant: {\n default: [\n 'pointer rounded border-2 bg-input-background text-input-text shadow-none outline-0 transition-all',\n 'border-input-border hover:border-input-border-hover focus:border-input-border-focus focus:outline-0 focus:[box-shadow:none]',\n 'checked:bg-checkbox-checked checked:border-checkbox-checked-border',\n 'disabled:opacity-50',\n ],\n },\n size: {\n sm: 'size-4',\n md: 'size-5',\n lg: 'size-6',\n },\n color: {\n primary: 'accent-primary',\n secondary: 'accent-secondary',\n destructive: 'accent-destructive',\n neutral: 'accent-neutral',\n light: 'accent-light',\n text: 'accent-text',\n dark: 'accent-dark',\n error: 'accent-error',\n success: 'accent-success',\n custom: 'accent-custom',\n },\n validationStyleEnabled: {\n disabled: '',\n enabled: 'valid:border-success invalid:border-error',\n },\n },\n defaultVariants: {\n variant: 'default',\n color: 'primary',\n validationStyleEnabled: 'disabled',\n size: 'md',\n },\n});\n\nexport type CheckboxProps = Omit<\n DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,\n 'size'\n> & {\n name: string;\n validationStyleEnabled?: boolean;\n label?: ReactNode;\n} & Omit<VariantProps<typeof checkboxVariants>, 'validationStyleEnabled'>;\n\nconst Input: FC<CheckboxProps> = ({\n validationStyleEnabled = false,\n label,\n size,\n color,\n name,\n variant,\n className,\n ...props\n}) => (\n <input\n type=\"checkbox\"\n className={checkboxVariants({\n variant,\n size,\n color,\n validationStyleEnabled: validationStyleEnabled ? 'enabled' : 'disabled',\n className,\n })}\n {...props}\n />\n);\n\nexport const Checkbox: FC<CheckboxProps> = (props) => {\n const { label, name, id } = props;\n\n return label ? (\n <label\n htmlFor={id ?? name}\n className=\"flex items-center gap-x-4 font-medium text-sm cursor-pointer\"\n >\n <Input id={id ?? name} {...props} />\n {label}\n </label>\n ) : (\n <Input id={id ?? name} {...props} />\n );\n};\n"],"names":["cva","jsx","jsxs"],"mappings":";;;;AAQa,MAAA,mBAAmBA,2BAAI,IAAI;AAAA,EACtC,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS;AAAA,QACP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ;AAAA,IACA,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IACN;AAAA,IACA,OAAO;AAAA,MACL,SAAS;AAAA,MACT,WAAW;AAAA,MACX,aAAa;AAAA,MACb,SAAS;AAAA,MACT,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO;AAAA,MACP,SAAS;AAAA,MACT,QAAQ;AAAA,IACV;AAAA,IACA,wBAAwB;AAAA,MACtB,UAAU;AAAA,MACV,SAAS;AAAA,IAAA;AAAA,EAEb;AAAA,EACA,iBAAiB;AAAA,IACf,SAAS;AAAA,IACT,OAAO;AAAA,IACP,wBAAwB;AAAA,IACxB,MAAM;AAAA,EAAA;AAEV,CAAC;AAWD,MAAM,QAA2B,CAAC;AAAA,EAChC,yBAAyB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MACEC,2BAAA;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,MAAK;AAAA,IACL,WAAW,iBAAiB;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,wBAAwB,yBAAyB,YAAY;AAAA,MAC7D;AAAA,IAAA,CACD;AAAA,IACA,GAAG;AAAA,EAAA;AACN;AAGW,MAAA,WAA8B,CAAC,UAAU;AACpD,QAAM,EAAE,OAAO,MAAM,GAAO,IAAA;AAE5B,SAAO,QACLC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,SAAS,MAAM;AAAA,MACf,WAAU;AAAA,MAEV,UAAA;AAAA,QAAAD,2BAAA,IAAC,OAAM,EAAA,IAAI,MAAM,MAAO,GAAG,OAAO;AAAA,QACjC;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,IAGFA,2BAAAA,IAAA,OAAA,EAAM,IAAI,MAAM,MAAO,GAAG,OAAO;AAEtC;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
|
2
|
-
import {
|
|
2
|
+
import { ReactNode, DetailedHTMLProps, FC, InputHTMLAttributes } from 'react';
|
|
3
3
|
export declare const checkboxVariants: (props?: ({
|
|
4
4
|
variant?: "default" | null | undefined;
|
|
5
5
|
size?: "sm" | "md" | "lg" | null | undefined;
|
|
@@ -7,8 +7,9 @@ export declare const checkboxVariants: (props?: ({
|
|
|
7
7
|
validationStyleEnabled?: "disabled" | "enabled" | null | undefined;
|
|
8
8
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
9
9
|
export type CheckboxProps = Omit<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, 'size'> & {
|
|
10
|
+
name: string;
|
|
10
11
|
validationStyleEnabled?: boolean;
|
|
11
|
-
label?:
|
|
12
|
+
label?: ReactNode;
|
|
12
13
|
} & Omit<VariantProps<typeof checkboxVariants>, 'validationStyleEnabled'>;
|
|
13
14
|
export declare const Checkbox: FC<CheckboxProps>;
|
|
14
15
|
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/Input/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EACL,SAAS,EACT,KAAK,iBAAiB,EACtB,KAAK,EAAE,EACP,KAAK,mBAAmB,EACzB,MAAM,OAAO,CAAC;AAEf,eAAO,MAAM,gBAAgB;;;;;8EAsC3B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,iBAAiB,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,EAC1E,MAAM,CACP,GAAG;IACF,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,gBAAgB,CAAC,EAAE,wBAAwB,CAAC,CAAC;AAyB1E,eAAO,MAAM,QAAQ,EAAE,EAAE,CAAC,aAAa,CActC,CAAC"}
|