@me1a/ui 2.2.0 → 2.2.2
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/atoms/accordion.d.mts +94 -0
- package/dist/atoms/accordion.d.ts +94 -0
- package/dist/atoms/accordion.js +2 -0
- package/dist/atoms/accordion.js.map +1 -0
- package/dist/atoms/accordion.mjs +2 -0
- package/dist/atoms/accordion.mjs.map +1 -0
- package/dist/atoms/avatar.d.mts +34 -0
- package/dist/atoms/avatar.d.ts +34 -0
- package/dist/atoms/avatar.js +2 -0
- package/dist/atoms/avatar.js.map +1 -0
- package/dist/atoms/avatar.mjs +2 -0
- package/dist/atoms/avatar.mjs.map +1 -0
- package/dist/atoms/badge.d.mts +40 -0
- package/dist/atoms/badge.d.ts +40 -0
- package/dist/atoms/badge.js +2 -0
- package/dist/atoms/badge.js.map +1 -0
- package/dist/atoms/badge.mjs +2 -0
- package/dist/atoms/badge.mjs.map +1 -0
- package/dist/atoms/box.d.mts +50 -0
- package/dist/atoms/box.d.ts +50 -0
- package/dist/atoms/box.js +2 -0
- package/dist/atoms/box.js.map +1 -0
- package/dist/atoms/box.mjs +2 -0
- package/dist/atoms/box.mjs.map +1 -0
- package/dist/atoms/breadcrumb.d.mts +35 -0
- package/dist/atoms/breadcrumb.d.ts +35 -0
- package/dist/atoms/breadcrumb.js +2 -0
- package/dist/atoms/breadcrumb.js.map +1 -0
- package/dist/atoms/breadcrumb.mjs +2 -0
- package/dist/atoms/breadcrumb.mjs.map +1 -0
- package/dist/{tooltip-B4jzaurK.d.mts → atoms/button.d.mts} +1 -23
- package/dist/{tooltip-B4jzaurK.d.ts → atoms/button.d.ts} +1 -23
- package/dist/atoms/button.js +2 -0
- package/dist/atoms/button.js.map +1 -0
- package/dist/atoms/button.mjs +2 -0
- package/dist/atoms/button.mjs.map +1 -0
- package/dist/atoms/checkbox.d.mts +21 -0
- package/dist/atoms/checkbox.d.ts +21 -0
- package/dist/atoms/checkbox.js +2 -0
- package/dist/atoms/checkbox.js.map +1 -0
- package/dist/atoms/checkbox.mjs +2 -0
- package/dist/atoms/checkbox.mjs.map +1 -0
- package/dist/atoms/collapsible.d.mts +26 -0
- package/dist/atoms/collapsible.d.ts +26 -0
- package/dist/atoms/collapsible.js +2 -0
- package/dist/atoms/collapsible.js.map +1 -0
- package/dist/atoms/collapsible.mjs +2 -0
- package/dist/atoms/collapsible.mjs.map +1 -0
- package/dist/atoms/command.d.mts +122 -0
- package/dist/atoms/command.d.ts +122 -0
- package/dist/atoms/command.js +2 -0
- package/dist/atoms/command.js.map +1 -0
- package/dist/atoms/command.mjs +2 -0
- package/dist/atoms/command.mjs.map +1 -0
- package/dist/atoms/container.js +2 -0
- package/dist/atoms/container.js.map +1 -0
- package/dist/atoms/container.mjs +2 -0
- package/dist/atoms/container.mjs.map +1 -0
- package/dist/atoms/dialog.d.mts +35 -0
- package/dist/atoms/dialog.d.ts +35 -0
- package/dist/atoms/dialog.js +2 -0
- package/dist/atoms/dialog.js.map +1 -0
- package/dist/atoms/dialog.mjs +2 -0
- package/dist/atoms/dialog.mjs.map +1 -0
- package/dist/atoms/input.d.mts +12 -0
- package/dist/atoms/input.d.ts +12 -0
- package/dist/atoms/input.js +2 -0
- package/dist/atoms/input.js.map +1 -0
- package/dist/atoms/input.mjs +2 -0
- package/dist/atoms/input.mjs.map +1 -0
- package/dist/atoms/label.d.mts +18 -0
- package/dist/atoms/label.d.ts +18 -0
- package/dist/atoms/label.js +2 -0
- package/dist/atoms/label.js.map +1 -0
- package/dist/atoms/label.mjs +2 -0
- package/dist/atoms/label.mjs.map +1 -0
- package/dist/atoms/page-loader.d.mts +29 -0
- package/dist/atoms/page-loader.d.ts +29 -0
- package/dist/atoms/page-loader.js +2 -0
- package/dist/atoms/page-loader.js.map +1 -0
- package/dist/atoms/page-loader.mjs +2 -0
- package/dist/atoms/page-loader.mjs.map +1 -0
- package/dist/atoms/pagination.d.mts +105 -0
- package/dist/atoms/pagination.d.ts +105 -0
- package/dist/atoms/pagination.js +2 -0
- package/dist/atoms/pagination.js.map +1 -0
- package/dist/atoms/pagination.mjs +2 -0
- package/dist/atoms/pagination.mjs.map +1 -0
- package/dist/atoms/popover.d.mts +30 -0
- package/dist/atoms/popover.d.ts +30 -0
- package/dist/atoms/popover.js +2 -0
- package/dist/atoms/popover.js.map +1 -0
- package/dist/atoms/popover.mjs +2 -0
- package/dist/atoms/popover.mjs.map +1 -0
- package/dist/{checkbox-DxgDKaHx.d.mts → atoms/radio-group.d.mts} +4 -50
- package/dist/{checkbox-DxgDKaHx.d.ts → atoms/radio-group.d.ts} +4 -50
- package/dist/atoms/radio-group.js +2 -0
- package/dist/atoms/radio-group.js.map +1 -0
- package/dist/atoms/radio-group.mjs +2 -0
- package/dist/atoms/radio-group.mjs.map +1 -0
- package/dist/atoms/resizable.d.mts +53 -0
- package/dist/atoms/resizable.d.ts +53 -0
- package/dist/atoms/resizable.js +2 -0
- package/dist/atoms/resizable.js.map +1 -0
- package/dist/atoms/resizable.mjs +2 -0
- package/dist/atoms/resizable.mjs.map +1 -0
- package/dist/atoms/separator.d.mts +13 -0
- package/dist/atoms/separator.d.ts +13 -0
- package/dist/atoms/separator.js +2 -0
- package/dist/atoms/separator.js.map +1 -0
- package/dist/atoms/separator.mjs +2 -0
- package/dist/atoms/separator.mjs.map +1 -0
- package/dist/atoms/sheet.d.mts +42 -0
- package/dist/atoms/sheet.d.ts +42 -0
- package/dist/atoms/sheet.js +2 -0
- package/dist/atoms/sheet.js.map +1 -0
- package/dist/atoms/sheet.mjs +2 -0
- package/dist/atoms/sheet.mjs.map +1 -0
- package/dist/atoms/skeleton.js +2 -0
- package/dist/atoms/skeleton.js.map +1 -0
- package/dist/atoms/skeleton.mjs +2 -0
- package/dist/atoms/skeleton.mjs.map +1 -0
- package/dist/atoms/stack.d.mts +121 -0
- package/dist/atoms/stack.d.ts +121 -0
- package/dist/atoms/stack.js +2 -0
- package/dist/atoms/stack.js.map +1 -0
- package/dist/atoms/stack.mjs +2 -0
- package/dist/atoms/stack.mjs.map +1 -0
- package/dist/atoms/switch.d.mts +21 -0
- package/dist/atoms/switch.d.ts +21 -0
- package/dist/atoms/switch.js +2 -0
- package/dist/atoms/switch.js.map +1 -0
- package/dist/atoms/switch.mjs +2 -0
- package/dist/atoms/switch.mjs.map +1 -0
- package/dist/atoms/table.d.mts +53 -0
- package/dist/atoms/table.d.ts +53 -0
- package/dist/atoms/table.js +2 -0
- package/dist/atoms/table.js.map +1 -0
- package/dist/atoms/table.mjs +2 -0
- package/dist/atoms/table.mjs.map +1 -0
- package/dist/atoms/text-field.d.mts +65 -0
- package/dist/atoms/text-field.d.ts +65 -0
- package/dist/atoms/text-field.js +2 -0
- package/dist/atoms/text-field.js.map +1 -0
- package/dist/atoms/text-field.mjs +2 -0
- package/dist/atoms/text-field.mjs.map +1 -0
- package/dist/atoms/textarea.js +2 -0
- package/dist/atoms/textarea.js.map +1 -0
- package/dist/atoms/textarea.mjs +2 -0
- package/dist/atoms/textarea.mjs.map +1 -0
- package/dist/{toast-2xT7L1tJ.d.mts → atoms/toast.d.mts} +1 -1
- package/dist/{toast-2xT7L1tJ.d.ts → atoms/toast.d.ts} +1 -1
- package/dist/atoms/toast.js +2 -0
- package/dist/atoms/toast.js.map +1 -0
- package/dist/atoms/toast.mjs +2 -0
- package/dist/atoms/toast.mjs.map +1 -0
- package/dist/atoms/toaster.d.mts +26 -0
- package/dist/atoms/toaster.d.ts +26 -0
- package/dist/atoms/toaster.js +2 -0
- package/dist/atoms/toaster.js.map +1 -0
- package/dist/atoms/toaster.mjs +2 -0
- package/dist/atoms/toaster.mjs.map +1 -0
- package/dist/atoms/tooltip.d.mts +25 -0
- package/dist/atoms/tooltip.d.ts +25 -0
- package/dist/atoms/tooltip.js +2 -0
- package/dist/atoms/tooltip.js.map +1 -0
- package/dist/atoms/tooltip.mjs +2 -0
- package/dist/atoms/tooltip.mjs.map +1 -0
- package/dist/atoms/typography.d.mts +24 -0
- package/dist/atoms/typography.d.ts +24 -0
- package/dist/atoms/typography.js +2 -0
- package/dist/atoms/typography.js.map +1 -0
- package/dist/atoms/typography.mjs +2 -0
- package/dist/atoms/typography.mjs.map +1 -0
- package/dist/atoms.d.mts +213 -27
- package/dist/atoms.d.ts +213 -27
- package/dist/atoms.js +2 -0
- package/dist/atoms.js.map +1 -0
- package/dist/atoms.mjs +2 -0
- package/dist/atoms.mjs.map +1 -0
- package/dist/hooks.d.mts +10 -4
- package/dist/hooks.d.ts +10 -4
- package/dist/hooks.js +2 -0
- package/dist/hooks.js.map +1 -0
- package/dist/hooks.mjs +2 -0
- package/dist/hooks.mjs.map +1 -0
- package/dist/index.d.mts +2619 -30
- package/dist/index.d.ts +2619 -30
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/molecules/card.d.mts +72 -0
- package/dist/molecules/card.d.ts +72 -0
- package/dist/molecules/card.js +2 -0
- package/dist/molecules/card.js.map +1 -0
- package/dist/molecules/card.mjs +2 -0
- package/dist/molecules/card.mjs.map +1 -0
- package/dist/molecules/navigation-menu.d.mts +103 -0
- package/dist/molecules/navigation-menu.d.ts +103 -0
- package/dist/molecules/navigation-menu.js +2 -0
- package/dist/molecules/navigation-menu.js.map +1 -0
- package/dist/molecules/navigation-menu.mjs +2 -0
- package/dist/molecules/navigation-menu.mjs.map +1 -0
- package/dist/molecules/tabs.d.mts +32 -0
- package/dist/molecules/tabs.d.ts +32 -0
- package/dist/molecules/tabs.js +2 -0
- package/dist/molecules/tabs.js.map +1 -0
- package/dist/molecules/tabs.mjs +2 -0
- package/dist/molecules/tabs.mjs.map +1 -0
- package/dist/molecules.d.mts +1 -1
- package/dist/molecules.d.ts +1 -1
- package/dist/molecules.js +2 -0
- package/dist/molecules.js.map +1 -0
- package/dist/molecules.mjs +2 -0
- package/dist/molecules.mjs.map +1 -0
- package/dist/organisms/drawer.d.mts +63 -0
- package/dist/organisms/drawer.d.ts +63 -0
- package/dist/organisms/drawer.js +2 -0
- package/dist/organisms/drawer.js.map +1 -0
- package/dist/organisms/drawer.mjs +2 -0
- package/dist/organisms/drawer.mjs.map +1 -0
- package/dist/organisms/dropdown-menu.d.mts +335 -0
- package/dist/organisms/dropdown-menu.d.ts +335 -0
- package/dist/organisms/dropdown-menu.js +2 -0
- package/dist/organisms/dropdown-menu.js.map +1 -0
- package/dist/organisms/dropdown-menu.mjs +2 -0
- package/dist/organisms/dropdown-menu.mjs.map +1 -0
- package/dist/organisms/sidebar.d.mts +328 -0
- package/dist/organisms/sidebar.d.ts +328 -0
- package/dist/organisms/sidebar.js +2 -0
- package/dist/organisms/sidebar.js.map +1 -0
- package/dist/organisms/sidebar.mjs +2 -0
- package/dist/organisms/sidebar.mjs.map +1 -0
- package/dist/organisms.d.mts +56 -12
- package/dist/organisms.d.ts +56 -12
- package/dist/organisms.js +2 -0
- package/dist/organisms.js.map +1 -0
- package/dist/organisms.mjs +2 -0
- package/dist/organisms.mjs.map +1 -0
- package/dist/rhf/form.d.mts +96 -0
- package/dist/rhf/form.d.ts +96 -0
- package/dist/rhf/form.js +2 -0
- package/dist/rhf/form.js.map +1 -0
- package/dist/rhf/form.mjs +2 -0
- package/dist/rhf/form.mjs.map +1 -0
- package/dist/rhf/rhf-checkbox.d.mts +57 -0
- package/dist/rhf/rhf-checkbox.d.ts +57 -0
- package/dist/rhf/rhf-checkbox.js +2 -0
- package/dist/rhf/rhf-checkbox.js.map +1 -0
- package/dist/rhf/rhf-checkbox.mjs +2 -0
- package/dist/rhf/rhf-checkbox.mjs.map +1 -0
- package/dist/rhf/rhf-multi-select.d.mts +84 -0
- package/dist/rhf/rhf-multi-select.d.ts +84 -0
- package/dist/rhf/rhf-multi-select.js +2 -0
- package/dist/rhf/rhf-multi-select.js.map +1 -0
- package/dist/rhf/rhf-multi-select.mjs +2 -0
- package/dist/rhf/rhf-multi-select.mjs.map +1 -0
- package/dist/rhf/rhf-radio-button-group.d.mts +73 -0
- package/dist/rhf/rhf-radio-button-group.d.ts +73 -0
- package/dist/rhf/rhf-radio-button-group.js +2 -0
- package/dist/rhf/rhf-radio-button-group.js.map +1 -0
- package/dist/rhf/rhf-radio-button-group.mjs +2 -0
- package/dist/rhf/rhf-radio-button-group.mjs.map +1 -0
- package/dist/rhf/rhf-radio-group.d.mts +103 -0
- package/dist/rhf/rhf-radio-group.d.ts +103 -0
- package/dist/rhf/rhf-radio-group.js +2 -0
- package/dist/rhf/rhf-radio-group.js.map +1 -0
- package/dist/rhf/rhf-radio-group.mjs +2 -0
- package/dist/rhf/rhf-radio-group.mjs.map +1 -0
- package/dist/rhf/rhf-select.d.mts +80 -0
- package/dist/rhf/rhf-select.d.ts +80 -0
- package/dist/rhf/rhf-select.js +2 -0
- package/dist/rhf/rhf-select.js.map +1 -0
- package/dist/rhf/rhf-select.mjs +2 -0
- package/dist/rhf/rhf-select.mjs.map +1 -0
- package/dist/rhf/rhf-switch.d.mts +57 -0
- package/dist/rhf/rhf-switch.d.ts +57 -0
- package/dist/rhf/rhf-switch.js +2 -0
- package/dist/rhf/rhf-switch.js.map +1 -0
- package/dist/rhf/rhf-switch.mjs +2 -0
- package/dist/rhf/rhf-switch.mjs.map +1 -0
- package/dist/rhf/rhf-textarea.d.mts +66 -0
- package/dist/rhf/rhf-textarea.d.ts +66 -0
- package/dist/rhf/rhf-textarea.js +2 -0
- package/dist/rhf/rhf-textarea.js.map +1 -0
- package/dist/rhf/rhf-textarea.mjs +2 -0
- package/dist/rhf/rhf-textarea.mjs.map +1 -0
- package/dist/rhf.d.mts +213 -7
- package/dist/rhf.d.ts +213 -7
- package/dist/rhf.js +2 -0
- package/dist/rhf.js.map +1 -0
- package/dist/rhf.mjs +2 -0
- package/dist/rhf.mjs.map +1 -0
- package/dist/types.js +2 -0
- package/dist/{types.cjs.js.map → types.js.map} +1 -1
- package/dist/types.mjs +2 -0
- package/dist/{types.esm.js.map → types.mjs.map} +1 -1
- package/dist/{chunk-SL2ZUI4G.cjs.js → utils.js} +2 -2
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +2 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +241 -15
- package/dist/atoms.cjs.js +0 -2
- package/dist/atoms.cjs.js.map +0 -1
- package/dist/atoms.esm.js +0 -2
- package/dist/atoms.esm.js.map +0 -1
- package/dist/chunk-23T2PH5G.esm.js +0 -2
- package/dist/chunk-23T2PH5G.esm.js.map +0 -1
- package/dist/chunk-2QG3QTSW.cjs.js +0 -2
- package/dist/chunk-2QG3QTSW.cjs.js.map +0 -1
- package/dist/chunk-C26U3FL4.esm.js +0 -2
- package/dist/chunk-C26U3FL4.esm.js.map +0 -1
- package/dist/chunk-DTM5LZHM.cjs.js +0 -2
- package/dist/chunk-DTM5LZHM.cjs.js.map +0 -1
- package/dist/chunk-HW32JE75.cjs.js +0 -2
- package/dist/chunk-HW32JE75.cjs.js.map +0 -1
- package/dist/chunk-J5A6PILI.cjs.js +0 -2
- package/dist/chunk-J5A6PILI.cjs.js.map +0 -1
- package/dist/chunk-JIRS6MWF.cjs.js +0 -2
- package/dist/chunk-JIRS6MWF.cjs.js.map +0 -1
- package/dist/chunk-JKTYFZ5M.esm.js +0 -2
- package/dist/chunk-JKTYFZ5M.esm.js.map +0 -1
- package/dist/chunk-JUZG25DH.esm.js +0 -2
- package/dist/chunk-JUZG25DH.esm.js.map +0 -1
- package/dist/chunk-KOYJODOP.cjs.js +0 -2
- package/dist/chunk-KOYJODOP.cjs.js.map +0 -1
- package/dist/chunk-M4S5YZ56.esm.js +0 -2
- package/dist/chunk-M4S5YZ56.esm.js.map +0 -1
- package/dist/chunk-MOYOCJW6.esm.js +0 -2
- package/dist/chunk-MOYOCJW6.esm.js.map +0 -1
- package/dist/chunk-MVWMLXLL.cjs.js +0 -2
- package/dist/chunk-MVWMLXLL.cjs.js.map +0 -1
- package/dist/chunk-Q76IMLQ3.esm.js +0 -2
- package/dist/chunk-Q76IMLQ3.esm.js.map +0 -1
- package/dist/chunk-SL2ZUI4G.cjs.js.map +0 -1
- package/dist/chunk-STRDPP3B.esm.js +0 -2
- package/dist/chunk-STRDPP3B.esm.js.map +0 -1
- package/dist/chunk-U4NMIMU7.esm.js +0 -2
- package/dist/chunk-U4NMIMU7.esm.js.map +0 -1
- package/dist/chunk-UK47BFA3.cjs.js +0 -2
- package/dist/chunk-UK47BFA3.cjs.js.map +0 -1
- package/dist/chunk-WJNYKJP6.cjs.js +0 -2
- package/dist/chunk-WJNYKJP6.cjs.js.map +0 -1
- package/dist/chunk-YEZB7AOJ.esm.js +0 -2
- package/dist/chunk-YEZB7AOJ.esm.js.map +0 -1
- package/dist/hooks.cjs.js +0 -2
- package/dist/hooks.cjs.js.map +0 -1
- package/dist/hooks.esm.js +0 -2
- package/dist/hooks.esm.js.map +0 -1
- package/dist/index.cjs.js +0 -2
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js +0 -2
- package/dist/index.esm.js.map +0 -1
- package/dist/molecules.cjs.js +0 -2
- package/dist/molecules.cjs.js.map +0 -1
- package/dist/molecules.esm.js +0 -2
- package/dist/molecules.esm.js.map +0 -1
- package/dist/organisms.cjs.js +0 -2
- package/dist/organisms.cjs.js.map +0 -1
- package/dist/organisms.esm.js +0 -2
- package/dist/organisms.esm.js.map +0 -1
- package/dist/rhf.cjs.js +0 -2
- package/dist/rhf.cjs.js.map +0 -1
- package/dist/rhf.esm.js +0 -2
- package/dist/rhf.esm.js.map +0 -1
- package/dist/types.cjs.js +0 -2
- package/dist/types.d.mts +0 -2
- package/dist/types.d.ts +0 -2
- package/dist/types.esm.js +0 -2
- package/dist/utils.cjs.js +0 -2
- package/dist/utils.cjs.js.map +0 -1
- package/dist/utils.d.mts +0 -5
- package/dist/utils.d.ts +0 -5
- package/dist/utils.esm.js +0 -2
- package/dist/utils.esm.js.map +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { FieldValues, FieldPath } from 'react-hook-form';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* RadioGroup component that allows users to select a single option from a list.
|
|
8
|
+
* Built on top of Radix UI's RadioGroup primitive.
|
|
9
|
+
*
|
|
10
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-radio-group--docs
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <RadioGroup defaultValue="option-1">
|
|
15
|
+
* <RadioGroupItem value="option-1">Option 1</RadioGroupItem>
|
|
16
|
+
* <RadioGroupItem value="option-2">Option 2</RadioGroupItem>
|
|
17
|
+
* </RadioGroup>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare const RadioGroup: React.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
|
|
22
|
+
interface RHFRadioGroupOption {
|
|
23
|
+
label: string;
|
|
24
|
+
id: string;
|
|
25
|
+
}
|
|
26
|
+
interface RHFRadioGroupWithChildrenProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<React.ComponentProps<typeof RadioGroup>, "name"> {
|
|
27
|
+
/** The name of the field in the form */
|
|
28
|
+
name: TName;
|
|
29
|
+
/** Optional label for the field */
|
|
30
|
+
label?: string;
|
|
31
|
+
/** Optional description text below the field */
|
|
32
|
+
description?: string;
|
|
33
|
+
/** Optional warning text to display */
|
|
34
|
+
warningText?: string;
|
|
35
|
+
/** Whether the field is required */
|
|
36
|
+
required?: boolean;
|
|
37
|
+
/** Whether the field is disabled */
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/** Whether the field is read-only */
|
|
40
|
+
readOnly?: boolean;
|
|
41
|
+
/** Optional aria-label for accessibility */
|
|
42
|
+
"aria-label"?: string;
|
|
43
|
+
/** Optional aria-describedby for accessibility */
|
|
44
|
+
"aria-describedby"?: string;
|
|
45
|
+
/** Children must be RadioGroupItem components */
|
|
46
|
+
children: React.ReactNode;
|
|
47
|
+
}
|
|
48
|
+
interface RHFRadioGroupWithOptionsProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<React.ComponentProps<typeof RadioGroup>, "name"> {
|
|
49
|
+
/** The name of the field in the form */
|
|
50
|
+
name: TName;
|
|
51
|
+
/** Optional label for the field */
|
|
52
|
+
label?: string;
|
|
53
|
+
/** radio group options */
|
|
54
|
+
options: RHFRadioGroupOption[];
|
|
55
|
+
/** Optional description text below the field */
|
|
56
|
+
description?: string;
|
|
57
|
+
/** Optional warning text to display */
|
|
58
|
+
warningText?: string;
|
|
59
|
+
/** Whether the field is required */
|
|
60
|
+
required?: boolean;
|
|
61
|
+
/** Whether the field is disabled */
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
/** Whether the field is read-only */
|
|
64
|
+
readOnly?: boolean;
|
|
65
|
+
/** Optional aria-label for accessibility */
|
|
66
|
+
"aria-label"?: string;
|
|
67
|
+
/** Optional aria-describedby for accessibility */
|
|
68
|
+
"aria-describedby"?: string;
|
|
69
|
+
}
|
|
70
|
+
type RHFRadioGroupProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = RHFRadioGroupWithChildrenProps<TFieldValues, TName> | RHFRadioGroupWithOptionsProps<TFieldValues, TName>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A radio group component that integrates with React Hook Form.
|
|
74
|
+
* Provides form validation, error handling, and accessibility features.
|
|
75
|
+
*
|
|
76
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhfradiogroup--docs
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* // Using children
|
|
81
|
+
* <Form>
|
|
82
|
+
* <RHFRadioGroup name="preference" label="Select your preference">
|
|
83
|
+
* <RadioGroupItem value="option1" label="Option 1" />
|
|
84
|
+
* <RadioGroupItem value="option2" label="Option 2" />
|
|
85
|
+
* </RHFRadioGroup>
|
|
86
|
+
* </Form>
|
|
87
|
+
*
|
|
88
|
+
* // Using options prop
|
|
89
|
+
* <Form>
|
|
90
|
+
* <RHFRadioGroup
|
|
91
|
+
* name="preference"
|
|
92
|
+
* label="Select your preference"
|
|
93
|
+
* options={[
|
|
94
|
+
* { id: "option1", label: "Option 1" },
|
|
95
|
+
* { id: "option2", label: "Option 2" }
|
|
96
|
+
* ]}
|
|
97
|
+
* />
|
|
98
|
+
* </Form>
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function RHFRadioGroup<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, label, description, className, warningText, required, disabled, readOnly, "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, children, ...other }: RHFRadioGroupProps<TFieldValues, TName>): react_jsx_runtime.JSX.Element;
|
|
102
|
+
|
|
103
|
+
export { RHFRadioGroup };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { FieldValues, FieldPath } from 'react-hook-form';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* RadioGroup component that allows users to select a single option from a list.
|
|
8
|
+
* Built on top of Radix UI's RadioGroup primitive.
|
|
9
|
+
*
|
|
10
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-radio-group--docs
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <RadioGroup defaultValue="option-1">
|
|
15
|
+
* <RadioGroupItem value="option-1">Option 1</RadioGroupItem>
|
|
16
|
+
* <RadioGroupItem value="option-2">Option 2</RadioGroupItem>
|
|
17
|
+
* </RadioGroup>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
declare const RadioGroup: React.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
21
|
+
|
|
22
|
+
interface RHFRadioGroupOption {
|
|
23
|
+
label: string;
|
|
24
|
+
id: string;
|
|
25
|
+
}
|
|
26
|
+
interface RHFRadioGroupWithChildrenProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<React.ComponentProps<typeof RadioGroup>, "name"> {
|
|
27
|
+
/** The name of the field in the form */
|
|
28
|
+
name: TName;
|
|
29
|
+
/** Optional label for the field */
|
|
30
|
+
label?: string;
|
|
31
|
+
/** Optional description text below the field */
|
|
32
|
+
description?: string;
|
|
33
|
+
/** Optional warning text to display */
|
|
34
|
+
warningText?: string;
|
|
35
|
+
/** Whether the field is required */
|
|
36
|
+
required?: boolean;
|
|
37
|
+
/** Whether the field is disabled */
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/** Whether the field is read-only */
|
|
40
|
+
readOnly?: boolean;
|
|
41
|
+
/** Optional aria-label for accessibility */
|
|
42
|
+
"aria-label"?: string;
|
|
43
|
+
/** Optional aria-describedby for accessibility */
|
|
44
|
+
"aria-describedby"?: string;
|
|
45
|
+
/** Children must be RadioGroupItem components */
|
|
46
|
+
children: React.ReactNode;
|
|
47
|
+
}
|
|
48
|
+
interface RHFRadioGroupWithOptionsProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<React.ComponentProps<typeof RadioGroup>, "name"> {
|
|
49
|
+
/** The name of the field in the form */
|
|
50
|
+
name: TName;
|
|
51
|
+
/** Optional label for the field */
|
|
52
|
+
label?: string;
|
|
53
|
+
/** radio group options */
|
|
54
|
+
options: RHFRadioGroupOption[];
|
|
55
|
+
/** Optional description text below the field */
|
|
56
|
+
description?: string;
|
|
57
|
+
/** Optional warning text to display */
|
|
58
|
+
warningText?: string;
|
|
59
|
+
/** Whether the field is required */
|
|
60
|
+
required?: boolean;
|
|
61
|
+
/** Whether the field is disabled */
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
/** Whether the field is read-only */
|
|
64
|
+
readOnly?: boolean;
|
|
65
|
+
/** Optional aria-label for accessibility */
|
|
66
|
+
"aria-label"?: string;
|
|
67
|
+
/** Optional aria-describedby for accessibility */
|
|
68
|
+
"aria-describedby"?: string;
|
|
69
|
+
}
|
|
70
|
+
type RHFRadioGroupProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = RHFRadioGroupWithChildrenProps<TFieldValues, TName> | RHFRadioGroupWithOptionsProps<TFieldValues, TName>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A radio group component that integrates with React Hook Form.
|
|
74
|
+
* Provides form validation, error handling, and accessibility features.
|
|
75
|
+
*
|
|
76
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhfradiogroup--docs
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* // Using children
|
|
81
|
+
* <Form>
|
|
82
|
+
* <RHFRadioGroup name="preference" label="Select your preference">
|
|
83
|
+
* <RadioGroupItem value="option1" label="Option 1" />
|
|
84
|
+
* <RadioGroupItem value="option2" label="Option 2" />
|
|
85
|
+
* </RHFRadioGroup>
|
|
86
|
+
* </Form>
|
|
87
|
+
*
|
|
88
|
+
* // Using options prop
|
|
89
|
+
* <Form>
|
|
90
|
+
* <RHFRadioGroup
|
|
91
|
+
* name="preference"
|
|
92
|
+
* label="Select your preference"
|
|
93
|
+
* options={[
|
|
94
|
+
* { id: "option1", label: "Option 1" },
|
|
95
|
+
* { id: "option2", label: "Option 2" }
|
|
96
|
+
* ]}
|
|
97
|
+
* />
|
|
98
|
+
* </Form>
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function RHFRadioGroup<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, label, description, className, warningText, required, disabled, readOnly, "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, children, ...other }: RHFRadioGroupProps<TFieldValues, TName>): react_jsx_runtime.JSX.Element;
|
|
102
|
+
|
|
103
|
+
export { RHFRadioGroup };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var reactHookForm=require('react-hook-form'),r=require('react'),l=require('@radix-ui/react-radio-group'),lucideReact=require('lucide-react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),h=require('@radix-ui/react-label'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime'),reactSlot=require('@radix-ui/react-slot');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var r__namespace=/*#__PURE__*/_interopNamespace(r);var l__namespace=/*#__PURE__*/_interopNamespace(l);var h__namespace=/*#__PURE__*/_interopNamespace(h);function a(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var z=classVarianceAuthority.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),p=r__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(h__namespace.Root,{ref:o,className:a(z(),e),...t}));p.displayName=h__namespace.Root.displayName;var y=r__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(l__namespace.Root,{className:a("grid gap-3",e),...t,ref:o}));y.displayName=l__namespace.Root.displayName;var b=r__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(l__namespace.Item,{ref:o,className:a("aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:jsxRuntime.jsx(l__namespace.Indicator,{className:"flex items-center justify-center",children:jsxRuntime.jsx(lucideReact.Circle,{className:"h-3.5 w-3.5 fill-primary"})})}));b.displayName=l__namespace.Item.displayName;var x=r__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx("div",{ref:o,className:a("flex items-center gap-2",e),...t}));x.displayName="RadioItemContainer";var I=r__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(p,{ref:o,className:a("text-sm font-medium leading-none cursor-pointer peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...t}));I.displayName="RadioItemLabel";var E=r__namespace.createContext({}),G=({...e})=>jsxRuntime.jsx(E.Provider,{value:{name:e.name},children:jsxRuntime.jsx(reactHookForm.Controller,{...e})}),R=()=>{let e=r__namespace.useContext(E),t=r__namespace.useContext(D),{getFieldState:o,formState:i}=reactHookForm.useFormContext(),m=o(e.name,i);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:s}=t;return {id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...m}},D=r__namespace.createContext({}),C=r__namespace.forwardRef(({className:e,...t},o)=>{let i=r__namespace.useId();return jsxRuntime.jsx(D.Provider,{value:{id:i},children:jsxRuntime.jsx("div",{ref:o,className:a("space-y-2",e),...t})})});C.displayName="FormItem";var v=r__namespace.forwardRef(({className:e,...t},o)=>{let{error:i,formItemId:m}=R();return jsxRuntime.jsx(p,{ref:o,className:a(i&&"text-destructive",e),htmlFor:m,...t})});v.displayName="FormLabel";var L=r__namespace.forwardRef(({...e},t)=>{let{error:o,formItemId:i,formDescriptionId:m,formMessageId:s}=R();return jsxRuntime.jsx(reactSlot.Slot,{ref:t,id:i,"aria-describedby":o?`${m} ${s}`:`${m}`,"aria-invalid":!!o,...e})});L.displayName="FormControl";var V=r__namespace.forwardRef(({className:e,...t},o)=>{let{formDescriptionId:i}=R();return jsxRuntime.jsx("p",{ref:o,id:i,className:a("text-sm text-muted-foreground",e),...t})});V.displayName="FormDescription";var N=r__namespace.forwardRef(({className:e,children:t,...o},i)=>{let{error:m,formMessageId:s}=R(),F=m?String(m?.message??""):t;return F?jsxRuntime.jsx("p",{ref:i,id:s,className:a("text-sm font-medium text-destructive",e),...o,children:F}):null});N.displayName="FormMessage";function Te({name:e,label:t,description:o,className:i,warningText:m,required:s,disabled:F,readOnly:Y,"aria-label":S,"aria-describedby":W,children:O,...T}){let{control:$}=reactHookForm.useFormContext(),M="options"in T;return jsxRuntime.jsx(G,{name:e,control:$,render:({field:w,fieldState:{error:P}})=>jsxRuntime.jsxs(C,{className:"space-y-3",children:[t&&jsxRuntime.jsxs(v,{children:[t,s&&jsxRuntime.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),jsxRuntime.jsx(L,{children:jsxRuntime.jsxs(y,{onValueChange:w.onChange,defaultValue:w.value,disabled:F,"aria-label":S,"aria-describedby":W,"aria-invalid":!!P,"aria-required":s,...T,children:[M&&T.options.map(u=>jsxRuntime.jsxs(x,{children:[jsxRuntime.jsx(b,{value:u.id,id:u.id}),jsxRuntime.jsx(I,{htmlFor:u.id,children:u.label})]},u.id)),!M&&O]})}),o&&jsxRuntime.jsx(V,{children:o}),P&&jsxRuntime.jsx(N,{children:P.message}),!P&&m&&jsxRuntime.jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-500",role:"alert",children:m})]})})}exports.RHFRadioGroup=Te;//# sourceMappingURL=rhf-radio-group.js.map
|
|
2
|
+
//# sourceMappingURL=rhf-radio-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/cn.ts","../../src/components/atoms/label/label.tsx","../../src/components/atoms/radio-group/radio-group.tsx","../../src/components/rhf/form/form.tsx","../../src/components/rhf/rhf-radio-group/rhf-radio-group.tsx"],"names":["cn","inputs","twMerge","clsx","labelVariants","cva","Label","H","className","props","ref","jsx","h","RadioGroup","f","l","RadioGroupItem","Circle","RadioItemContainer","RadioItemLabel","FormFieldContext","r","FormField","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","formState","useFormContext","fieldState","id","FormItem","FormLabel","error","formItemId","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","children","body","RHFRadioGroup","name","label","description","warningText","required","disabled","readOnly","ariaLabel","ariaDescribedby","other","control","hasOptions","field","jsxs","option"],"mappings":"m1BAGO,SAASA,CAAAA,CAAAA,GAAMC,EAAsB,CAC1C,OAAOC,sBAAQC,SAAKF,CAAAA,CAAM,CAAC,CAC7B,CCCA,IAAMG,EAAgBC,0BACpB,CAAA,4FACF,EAaMC,CAAc,CAAAC,YAAA,CAAA,UAAA,CAClB,CAAC,CAAE,SAAA,CAAAC,EAAW,GAAGC,CAAM,EAAGC,CACxBC,GAAAA,cAAAA,CAAgBC,kBAAf,CAAoB,GAAA,CAAKF,EAAK,SAAWV,CAAAA,CAAAA,CAAGI,CAAc,EAAA,CAAGI,CAAS,CAAI,CAAA,GAAGC,EAAO,CAEzF,CAAA,CACAH,EAAM,WAA6B,CAAAM,YAAA,CAAA,IAAA,CAAK,YCLxC,IAAMC,CAAAA,CAAmBC,wBAGvB,CAAC,CAAE,UAAAN,CAAW,CAAA,GAAGC,CAAM,CAAA,CAAGC,IACnBC,cAAqB,CAAAI,YAAA,CAAA,IAAA,CAApB,CAAyB,SAAWf,CAAAA,CAAAA,CAAG,aAAcQ,CAAS,CAAA,CAAI,GAAGC,CAAO,CAAA,GAAA,CAAKC,EAAK,CAC/F,CAAA,CACDG,EAAW,WAAkC,CAAAE,YAAA,CAAA,IAAA,CAAK,YAWlD,IAAMC,CAAAA,CAAuBF,YAG3B,CAAA,UAAA,CAAA,CAAC,CAAE,SAAAN,CAAAA,CAAAA,CAAW,GAAGC,CAAM,CAAA,CAA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-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n","import * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/utils/index\"\n\nconst labelVariants = cva(\n \"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\"\n)\n\nexport interface LabelProps\n extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>,\n VariantProps<typeof labelVariants> {}\n\n/**\n * Label component for creating accessible labels.\n * Built on top of Radix UI's Label primitive.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-label--docs\n *\n */\nconst Label = React.forwardRef<React.ElementRef<typeof LabelPrimitive.Root>, LabelProps>(\n ({ className, ...props }, ref) => (\n <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />\n )\n)\nLabel.displayName = LabelPrimitive.Root.displayName\n\nexport { Label }\n","import * as React from \"react\"\nimport * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\"\nimport { Circle } from \"lucide-react\"\n\nimport { cn } from \"@/utils\"\nimport { Label } from \"@/components/atoms/label\"\n\n/**\n * RadioGroup component that allows users to select a single option from a list.\n * Built on top of Radix UI's RadioGroup primitive.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-radio-group--docs\n *\n * @example\n * ```tsx\n * <RadioGroup defaultValue=\"option-1\">\n * <RadioGroupItem value=\"option-1\">Option 1</RadioGroupItem>\n * <RadioGroupItem value=\"option-2\">Option 2</RadioGroupItem>\n * </RadioGroup>\n * ```\n */\nconst RadioGroup = React.forwardRef<\n React.ElementRef<typeof RadioGroupPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>\n>(({ className, ...props }, ref) => {\n return <RadioGroupPrimitive.Root className={cn(\"grid gap-3\", className)} {...props} ref={ref} />\n})\nRadioGroup.displayName = RadioGroupPrimitive.Root.displayName\n\n/**\n * RadioGroupItem component that represents a single option in a RadioGroup.\n * Built on top of Radix UI's RadioGroupItem primitive.\n *\n * @example\n * ```tsx\n * <RadioGroupItem value=\"option-1\">Option 1</RadioGroupItem>\n * ```\n */\nconst RadioGroupItem = React.forwardRef<\n React.ElementRef<typeof RadioGroupPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>\n>(({ className, ...props }, ref) => {\n return (\n <RadioGroupPrimitive.Item\n ref={ref}\n className={cn(\n \"aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\",\n className\n )}\n {...props}\n >\n <RadioGroupPrimitive.Indicator className=\"flex items-center justify-center\">\n <Circle className=\"h-3.5 w-3.5 fill-primary\" />\n </RadioGroupPrimitive.Indicator>\n </RadioGroupPrimitive.Item>\n )\n})\nRadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName\n\n/**\n * RadioItemContainer component that provides a container for radio group items with proper spacing and layout.\n *\n * @example\n * ```tsx\n * <RadioItemContainer>\n * <RadioGroupItem value=\"option-1\">Option 1</RadioGroupItem>\n * <RadioGroupItem value=\"option-2\">Option 2</RadioGroupItem>\n * </RadioItemContainer>\n * ```\n */\nconst RadioItemContainer = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n return <div ref={ref} className={cn(\"flex items-center gap-2\", className)} {...props} />\n }\n)\nRadioItemContainer.displayName = \"RadioItemContainer\"\n\n/**\n * RadioItemLabel component that provides a label for individual radio items.\n * Built on top of the Label component.\n *\n * @example\n * ```tsx\n * <RadioItemLabel>Select an option</RadioItemLabel>\n * ```\n */\nconst RadioItemLabel = React.forwardRef<\n React.ElementRef<typeof Label>,\n React.ComponentPropsWithoutRef<typeof Label>\n>(({ className, ...props }, ref) => {\n return (\n <Label\n ref={ref}\n className={cn(\n \"text-sm font-medium leading-none cursor-pointer peer-disabled:cursor-not-allowed peer-disabled:opacity-70\",\n className\n )}\n {...props}\n />\n )\n})\nRadioItemLabel.displayName = \"RadioItemLabel\"\n\nexport { RadioGroup, RadioGroupItem, RadioItemContainer, RadioItemLabel }\n","\"use client\"\n\nimport * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport {\n Controller,\n FormProvider,\n useFormContext,\n type ControllerProps,\n type FieldPath,\n type FieldValues\n} from \"react-hook-form\"\n\nimport { cn } from \"@/utils/cn\"\nimport { Label } from \"@/components/atoms/label\"\n\nconst Form = FormProvider\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue)\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const { getFieldState, formState } = useFormContext()\n\n const fieldState = getFieldState(fieldContext.name, formState)\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\")\n }\n\n const { id } = itemContext\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState\n }\n}\n\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue)\n\nconst FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n const id = React.useId()\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(\"space-y-2\", className)} {...props} />\n </FormItemContext.Provider>\n )\n }\n)\nFormItem.displayName = \"FormItem\"\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField()\n\n return (\n <Label\n ref={ref}\n className={cn(error && \"text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n )\n})\nFormLabel.displayName = \"FormLabel\"\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n aria-invalid={!!error}\n {...props}\n />\n )\n})\nFormControl.displayName = \"FormControl\"\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField()\n\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n )\n})\nFormDescription.displayName = \"FormDescription\"\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField()\n const body = error ? String(error?.message ?? \"\") : children\n\n if (!body) {\n return null\n }\n\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={cn(\"text-sm font-medium text-destructive\", className)}\n {...props}\n >\n {body}\n </p>\n )\n})\nFormMessage.displayName = \"FormMessage\"\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField\n}\n","import * as React from \"react\"\nimport { useFormContext, type FieldValues, type FieldPath } from \"react-hook-form\"\nimport {\n RadioGroup,\n RadioGroupItem,\n RadioItemLabel,\n RadioItemContainer\n} from \"@/components/atoms/radio-group\"\nimport {\n FormControl,\n FormItem,\n FormMessage,\n FormLabel,\n FormDescription,\n FormField\n} from \"@/components/rhf/form\"\nimport {\n RHFRadioGroupOption,\n type RHFRadioGroupProps,\n type RHFRadioGroupWithOptionsProps\n} from \"./rhf-radio-group.types\"\n\n// ----------------------------------------------------------------------\n\n/**\n * A radio group component that integrates with React Hook Form.\n * Provides form validation, error handling, and accessibility features.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhfradiogroup--docs\n *\n * @example\n * ```tsx\n * // Using children\n * <Form>\n * <RHFRadioGroup name=\"preference\" label=\"Select your preference\">\n * <RadioGroupItem value=\"option1\" label=\"Option 1\" />\n * <RadioGroupItem value=\"option2\" label=\"Option 2\" />\n * </RHFRadioGroup>\n * </Form>\n *\n * // Using options prop\n * <Form>\n * <RHFRadioGroup\n * name=\"preference\"\n * label=\"Select your preference\"\n * options={[\n * { id: \"option1\", label: \"Option 1\" },\n * { id: \"option2\", label: \"Option 2\" }\n * ]}\n * />\n * </Form>\n * ```\n */\nexport function RHFRadioGroup<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n name,\n label,\n description,\n className,\n warningText,\n required,\n disabled,\n readOnly,\n \"aria-label\": ariaLabel,\n \"aria-describedby\": ariaDescribedby,\n children,\n ...other\n}: RHFRadioGroupProps<TFieldValues, TName>) {\n const { control } = useFormContext<TFieldValues>()\n const hasOptions = \"options\" in other\n\n return (\n <FormField\n name={name}\n control={control}\n render={({ field, fieldState: { error } }) => (\n <FormItem className=\"space-y-3\">\n {label && (\n <FormLabel>\n {label}\n {required && <span className=\"text-destructive ml-1\">*</span>}\n </FormLabel>\n )}\n <FormControl>\n <RadioGroup\n onValueChange={field.onChange}\n defaultValue={field.value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedby}\n aria-invalid={!!error}\n aria-required={required}\n {...other}\n >\n {hasOptions &&\n (other as RHFRadioGroupWithOptionsProps<TFieldValues, TName>).options.map(\n (option: RHFRadioGroupOption) => (\n <RadioItemContainer key={option.id}>\n <RadioGroupItem value={option.id} id={option.id} />\n <RadioItemLabel htmlFor={option.id}>{option.label}</RadioItemLabel>\n </RadioItemContainer>\n )\n )}\n {!hasOptions && children}\n </RadioGroup>\n </FormControl>\n {description && <FormDescription>{description}</FormDescription>}\n {error && <FormMessage>{error.message}</FormMessage>}\n {!error && warningText && (\n <p className=\"text-sm text-yellow-600 dark:text-yellow-500\" role=\"alert\">\n {warningText}\n </p>\n )}\n </FormItem>\n )}\n />\n )\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {useFormContext,Controller}from'react-hook-form';import*as r from'react';import*as l from'@radix-ui/react-radio-group';import {Circle}from'lucide-react';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import*as h from'@radix-ui/react-label';import {cva}from'class-variance-authority';import {jsx,jsxs}from'react/jsx-runtime';import {Slot}from'@radix-ui/react-slot';function a(...e){return twMerge(clsx(e))}var z=cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),p=r.forwardRef(({className:e,...t},o)=>jsx(h.Root,{ref:o,className:a(z(),e),...t}));p.displayName=h.Root.displayName;var y=r.forwardRef(({className:e,...t},o)=>jsx(l.Root,{className:a("grid gap-3",e),...t,ref:o}));y.displayName=l.Root.displayName;var b=r.forwardRef(({className:e,...t},o)=>jsx(l.Item,{ref:o,className:a("aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:jsx(l.Indicator,{className:"flex items-center justify-center",children:jsx(Circle,{className:"h-3.5 w-3.5 fill-primary"})})}));b.displayName=l.Item.displayName;var x=r.forwardRef(({className:e,...t},o)=>jsx("div",{ref:o,className:a("flex items-center gap-2",e),...t}));x.displayName="RadioItemContainer";var I=r.forwardRef(({className:e,...t},o)=>jsx(p,{ref:o,className:a("text-sm font-medium leading-none cursor-pointer peer-disabled:cursor-not-allowed peer-disabled:opacity-70",e),...t}));I.displayName="RadioItemLabel";var E=r.createContext({}),G=({...e})=>jsx(E.Provider,{value:{name:e.name},children:jsx(Controller,{...e})}),R=()=>{let e=r.useContext(E),t=r.useContext(D),{getFieldState:o,formState:i}=useFormContext(),m=o(e.name,i);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:s}=t;return {id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...m}},D=r.createContext({}),C=r.forwardRef(({className:e,...t},o)=>{let i=r.useId();return jsx(D.Provider,{value:{id:i},children:jsx("div",{ref:o,className:a("space-y-2",e),...t})})});C.displayName="FormItem";var v=r.forwardRef(({className:e,...t},o)=>{let{error:i,formItemId:m}=R();return jsx(p,{ref:o,className:a(i&&"text-destructive",e),htmlFor:m,...t})});v.displayName="FormLabel";var L=r.forwardRef(({...e},t)=>{let{error:o,formItemId:i,formDescriptionId:m,formMessageId:s}=R();return jsx(Slot,{ref:t,id:i,"aria-describedby":o?`${m} ${s}`:`${m}`,"aria-invalid":!!o,...e})});L.displayName="FormControl";var V=r.forwardRef(({className:e,...t},o)=>{let{formDescriptionId:i}=R();return jsx("p",{ref:o,id:i,className:a("text-sm text-muted-foreground",e),...t})});V.displayName="FormDescription";var N=r.forwardRef(({className:e,children:t,...o},i)=>{let{error:m,formMessageId:s}=R(),F=m?String(m?.message??""):t;return F?jsx("p",{ref:i,id:s,className:a("text-sm font-medium text-destructive",e),...o,children:F}):null});N.displayName="FormMessage";function Te({name:e,label:t,description:o,className:i,warningText:m,required:s,disabled:F,readOnly:Y,"aria-label":S,"aria-describedby":W,children:O,...T}){let{control:$}=useFormContext(),M="options"in T;return jsx(G,{name:e,control:$,render:({field:w,fieldState:{error:P}})=>jsxs(C,{className:"space-y-3",children:[t&&jsxs(v,{children:[t,s&&jsx("span",{className:"text-destructive ml-1",children:"*"})]}),jsx(L,{children:jsxs(y,{onValueChange:w.onChange,defaultValue:w.value,disabled:F,"aria-label":S,"aria-describedby":W,"aria-invalid":!!P,"aria-required":s,...T,children:[M&&T.options.map(u=>jsxs(x,{children:[jsx(b,{value:u.id,id:u.id}),jsx(I,{htmlFor:u.id,children:u.label})]},u.id)),!M&&O]})}),o&&jsx(V,{children:o}),P&&jsx(N,{children:P.message}),!P&&m&&jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-500",role:"alert",children:m})]})})}export{Te as RHFRadioGroup};//# sourceMappingURL=rhf-radio-group.mjs.map
|
|
2
|
+
//# sourceMappingURL=rhf-radio-group.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/cn.ts","../../src/components/atoms/label/label.tsx","../../src/components/atoms/radio-group/radio-group.tsx","../../src/components/rhf/form/form.tsx","../../src/components/rhf/rhf-radio-group/rhf-radio-group.tsx"],"names":["cn","inputs","twMerge","clsx","labelVariants","cva","Label","H","className","props","ref","jsx","RadioGroup","f","RadioGroupItem","Circle","RadioItemContainer","RadioItemLabel","FormFieldContext","FormField","Controller","useFormField","fieldContext","itemContext","FormItemContext","getFieldState","formState","useFormContext","fieldState","id","FormItem","FormLabel","error","formItemId","FormControl","formDescriptionId","formMessageId","Slot","FormDescription","FormMessage","children","body","RHFRadioGroup","name","label","description","warningText","required","disabled","readOnly","ariaLabel","ariaDescribedby","other","control","hasOptions","field","jsxs","option"],"mappings":"iYAGO,SAASA,CAAAA,CAAAA,GAAMC,EAAsB,CAC1C,OAAOC,QAAQC,IAAKF,CAAAA,CAAM,CAAC,CAC7B,CCCA,IAAMG,EAAgBC,GACpB,CAAA,4FACF,EAaMC,CAAc,CAAAC,CAAA,CAAA,UAAA,CAClB,CAAC,CAAE,SAAA,CAAAC,EAAW,GAAGC,CAAM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,EACjD9C,GAACM,CAAAA,CAAAA,CAAA,CAAe,OAAA,CAASwC,EAAO,EAAK,CAAA,QAAA,CAAAA,EAAO,KAAM,CAAA,CAAA,CAAA,CAAA,CAF3BA,EAAO,EAGhC,CAEJ,EACD,CAACH,CAAAA,EAAcd,GAClB,CACF,CAAA,CAAA,CACCK,GAAelC,GAAC2B,CAAAA,CAAAA,CAAA,CAAiB,QAAAO,CAAAA,CAAAA,CAAY,EAC7Cb,CAASrB,EAAAA,GAAAA,CAAC4B,EAAA,CAAa,QAAA,CAAAP,EAAM,OAAQ,CAAA,CAAA,CACrC,CAACA,CAASc,EAAAA,CAAAA,EACTnC,IAAC,GAAE,CAAA,CAAA,SAAA,CAAU,+CAA+C,IAAK,CAAA,OAAA,CAC9D,SAAAmC,CACH,CAAA,CAAA,CAAA,CAEJ,EAEJ,CAEJ","file":"rhf-radio-group.mjs","sourcesContent":["import { type ClassValue, clsx } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n","import * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/utils/index\"\n\nconst labelVariants = cva(\n \"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\"\n)\n\nexport interface LabelProps\n extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>,\n VariantProps<typeof labelVariants> {}\n\n/**\n * Label component for creating accessible labels.\n * Built on top of Radix UI's Label primitive.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-label--docs\n *\n */\nconst Label = React.forwardRef<React.ElementRef<typeof LabelPrimitive.Root>, LabelProps>(\n ({ className, ...props }, ref) => (\n <LabelPrimitive.Root ref={ref} className={cn(labelVariants(), className)} {...props} />\n )\n)\nLabel.displayName = LabelPrimitive.Root.displayName\n\nexport { Label }\n","import * as React from \"react\"\nimport * as RadioGroupPrimitive from \"@radix-ui/react-radio-group\"\nimport { Circle } from \"lucide-react\"\n\nimport { cn } from \"@/utils\"\nimport { Label } from \"@/components/atoms/label\"\n\n/**\n * RadioGroup component that allows users to select a single option from a list.\n * Built on top of Radix UI's RadioGroup primitive.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/atoms-radio-group--docs\n *\n * @example\n * ```tsx\n * <RadioGroup defaultValue=\"option-1\">\n * <RadioGroupItem value=\"option-1\">Option 1</RadioGroupItem>\n * <RadioGroupItem value=\"option-2\">Option 2</RadioGroupItem>\n * </RadioGroup>\n * ```\n */\nconst RadioGroup = React.forwardRef<\n React.ElementRef<typeof RadioGroupPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>\n>(({ className, ...props }, ref) => {\n return <RadioGroupPrimitive.Root className={cn(\"grid gap-3\", className)} {...props} ref={ref} />\n})\nRadioGroup.displayName = RadioGroupPrimitive.Root.displayName\n\n/**\n * RadioGroupItem component that represents a single option in a RadioGroup.\n * Built on top of Radix UI's RadioGroupItem primitive.\n *\n * @example\n * ```tsx\n * <RadioGroupItem value=\"option-1\">Option 1</RadioGroupItem>\n * ```\n */\nconst RadioGroupItem = React.forwardRef<\n React.ElementRef<typeof RadioGroupPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>\n>(({ className, ...props }, ref) => {\n return (\n <RadioGroupPrimitive.Item\n ref={ref}\n className={cn(\n \"aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\",\n className\n )}\n {...props}\n >\n <RadioGroupPrimitive.Indicator className=\"flex items-center justify-center\">\n <Circle className=\"h-3.5 w-3.5 fill-primary\" />\n </RadioGroupPrimitive.Indicator>\n </RadioGroupPrimitive.Item>\n )\n})\nRadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName\n\n/**\n * RadioItemContainer component that provides a container for radio group items with proper spacing and layout.\n *\n * @example\n * ```tsx\n * <RadioItemContainer>\n * <RadioGroupItem value=\"option-1\">Option 1</RadioGroupItem>\n * <RadioGroupItem value=\"option-2\">Option 2</RadioGroupItem>\n * </RadioItemContainer>\n * ```\n */\nconst RadioItemContainer = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n return <div ref={ref} className={cn(\"flex items-center gap-2\", className)} {...props} />\n }\n)\nRadioItemContainer.displayName = \"RadioItemContainer\"\n\n/**\n * RadioItemLabel component that provides a label for individual radio items.\n * Built on top of the Label component.\n *\n * @example\n * ```tsx\n * <RadioItemLabel>Select an option</RadioItemLabel>\n * ```\n */\nconst RadioItemLabel = React.forwardRef<\n React.ElementRef<typeof Label>,\n React.ComponentPropsWithoutRef<typeof Label>\n>(({ className, ...props }, ref) => {\n return (\n <Label\n ref={ref}\n className={cn(\n \"text-sm font-medium leading-none cursor-pointer peer-disabled:cursor-not-allowed peer-disabled:opacity-70\",\n className\n )}\n {...props}\n />\n )\n})\nRadioItemLabel.displayName = \"RadioItemLabel\"\n\nexport { RadioGroup, RadioGroupItem, RadioItemContainer, RadioItemLabel }\n","\"use client\"\n\nimport * as React from \"react\"\nimport * as LabelPrimitive from \"@radix-ui/react-label\"\nimport { Slot } from \"@radix-ui/react-slot\"\nimport {\n Controller,\n FormProvider,\n useFormContext,\n type ControllerProps,\n type FieldPath,\n type FieldValues\n} from \"react-hook-form\"\n\nimport { cn } from \"@/utils/cn\"\nimport { Label } from \"@/components/atoms/label\"\n\nconst Form = FormProvider\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>({} as FormFieldContextValue)\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const { getFieldState, formState } = useFormContext()\n\n const fieldState = getFieldState(fieldContext.name, formState)\n\n if (!fieldContext) {\n throw new Error(\"useFormField should be used within <FormField>\")\n }\n\n const { id } = itemContext\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState\n }\n}\n\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue>({} as FormItemContextValue)\n\nconst FormItem = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(\n ({ className, ...props }, ref) => {\n const id = React.useId()\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(\"space-y-2\", className)} {...props} />\n </FormItemContext.Provider>\n )\n }\n)\nFormItem.displayName = \"FormItem\"\n\nconst FormLabel = React.forwardRef<\n React.ElementRef<typeof LabelPrimitive.Root>,\n React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>\n>(({ className, ...props }, ref) => {\n const { error, formItemId } = useFormField()\n\n return (\n <Label\n ref={ref}\n className={cn(error && \"text-destructive\", className)}\n htmlFor={formItemId}\n {...props}\n />\n )\n})\nFormLabel.displayName = \"FormLabel\"\n\nconst FormControl = React.forwardRef<\n React.ElementRef<typeof Slot>,\n React.ComponentPropsWithoutRef<typeof Slot>\n>(({ ...props }, ref) => {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n aria-invalid={!!error}\n {...props}\n />\n )\n})\nFormControl.displayName = \"FormControl\"\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField()\n\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n )\n})\nFormDescription.displayName = \"FormDescription\"\n\nconst FormMessage = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes<HTMLParagraphElement>\n>(({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField()\n const body = error ? String(error?.message ?? \"\") : children\n\n if (!body) {\n return null\n }\n\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={cn(\"text-sm font-medium text-destructive\", className)}\n {...props}\n >\n {body}\n </p>\n )\n})\nFormMessage.displayName = \"FormMessage\"\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField\n}\n","import * as React from \"react\"\nimport { useFormContext, type FieldValues, type FieldPath } from \"react-hook-form\"\nimport {\n RadioGroup,\n RadioGroupItem,\n RadioItemLabel,\n RadioItemContainer\n} from \"@/components/atoms/radio-group\"\nimport {\n FormControl,\n FormItem,\n FormMessage,\n FormLabel,\n FormDescription,\n FormField\n} from \"@/components/rhf/form\"\nimport {\n RHFRadioGroupOption,\n type RHFRadioGroupProps,\n type RHFRadioGroupWithOptionsProps\n} from \"./rhf-radio-group.types\"\n\n// ----------------------------------------------------------------------\n\n/**\n * A radio group component that integrates with React Hook Form.\n * Provides form validation, error handling, and accessibility features.\n *\n * @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhfradiogroup--docs\n *\n * @example\n * ```tsx\n * // Using children\n * <Form>\n * <RHFRadioGroup name=\"preference\" label=\"Select your preference\">\n * <RadioGroupItem value=\"option1\" label=\"Option 1\" />\n * <RadioGroupItem value=\"option2\" label=\"Option 2\" />\n * </RHFRadioGroup>\n * </Form>\n *\n * // Using options prop\n * <Form>\n * <RHFRadioGroup\n * name=\"preference\"\n * label=\"Select your preference\"\n * options={[\n * { id: \"option1\", label: \"Option 1\" },\n * { id: \"option2\", label: \"Option 2\" }\n * ]}\n * />\n * </Form>\n * ```\n */\nexport function RHFRadioGroup<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>({\n name,\n label,\n description,\n className,\n warningText,\n required,\n disabled,\n readOnly,\n \"aria-label\": ariaLabel,\n \"aria-describedby\": ariaDescribedby,\n children,\n ...other\n}: RHFRadioGroupProps<TFieldValues, TName>) {\n const { control } = useFormContext<TFieldValues>()\n const hasOptions = \"options\" in other\n\n return (\n <FormField\n name={name}\n control={control}\n render={({ field, fieldState: { error } }) => (\n <FormItem className=\"space-y-3\">\n {label && (\n <FormLabel>\n {label}\n {required && <span className=\"text-destructive ml-1\">*</span>}\n </FormLabel>\n )}\n <FormControl>\n <RadioGroup\n onValueChange={field.onChange}\n defaultValue={field.value}\n disabled={disabled}\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedby}\n aria-invalid={!!error}\n aria-required={required}\n {...other}\n >\n {hasOptions &&\n (other as RHFRadioGroupWithOptionsProps<TFieldValues, TName>).options.map(\n (option: RHFRadioGroupOption) => (\n <RadioItemContainer key={option.id}>\n <RadioGroupItem value={option.id} id={option.id} />\n <RadioItemLabel htmlFor={option.id}>{option.label}</RadioItemLabel>\n </RadioItemContainer>\n )\n )}\n {!hasOptions && children}\n </RadioGroup>\n </FormControl>\n {description && <FormDescription>{description}</FormDescription>}\n {error && <FormMessage>{error.message}</FormMessage>}\n {!error && warningText && (\n <p className=\"text-sm text-yellow-600 dark:text-yellow-500\" role=\"alert\">\n {warningText}\n </p>\n )}\n </FormItem>\n )}\n />\n )\n}\n"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { FieldValues, FieldPath } from 'react-hook-form';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
type SelectOption = {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
startIcon?: React.ReactNode;
|
|
9
|
+
endIcon?: React.ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
type SelectProps = {
|
|
14
|
+
/** Whether the select is searchable */
|
|
15
|
+
searchable?: boolean;
|
|
16
|
+
/** Whether the select should take up the full width of its container */
|
|
17
|
+
fullWidth?: boolean;
|
|
18
|
+
/** Currently selected value */
|
|
19
|
+
value: string;
|
|
20
|
+
/** Array of options to display in the select */
|
|
21
|
+
options: SelectOption[];
|
|
22
|
+
/** Callback fired when the value changes */
|
|
23
|
+
onChange: (value: string) => void;
|
|
24
|
+
/** Render a custom CommandList for the select, if not provided, the select will render a default CommandList with the options */
|
|
25
|
+
renderCommandList?: (options: SelectOption[]) => React.ReactNode;
|
|
26
|
+
/** Placeholder text to show when no value is selected */
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
/** Whether the select is disabled */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/** Whether the select is required */
|
|
31
|
+
required?: boolean;
|
|
32
|
+
/** Error message to display */
|
|
33
|
+
error?: string;
|
|
34
|
+
/** Additional class name for the select */
|
|
35
|
+
className?: string;
|
|
36
|
+
/** ID for the select element */
|
|
37
|
+
id?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type RHFSelectOption = SelectOption;
|
|
41
|
+
interface RHFSelectProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<SelectProps, "name" | "value" | "onChange"> {
|
|
42
|
+
/** The name of the field in the form */
|
|
43
|
+
name: TName;
|
|
44
|
+
/** Optional label for the field */
|
|
45
|
+
label?: string;
|
|
46
|
+
/** Optional description text below the field */
|
|
47
|
+
description?: string;
|
|
48
|
+
/** Optional warning text to display */
|
|
49
|
+
warningText?: string;
|
|
50
|
+
/** Whether the field is read-only */
|
|
51
|
+
readOnly?: boolean;
|
|
52
|
+
/** Optional aria-label for accessibility */
|
|
53
|
+
"aria-label"?: string;
|
|
54
|
+
/** Optional aria-describedby for accessibility */
|
|
55
|
+
"aria-describedby"?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A select component that integrates with React Hook Form.
|
|
60
|
+
* Provides form validation, error handling, and accessibility features.
|
|
61
|
+
*
|
|
62
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhfselect--docs
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* <Form>
|
|
67
|
+
* <RHFSelect
|
|
68
|
+
* name="country"
|
|
69
|
+
* label="Country"
|
|
70
|
+
* options={[
|
|
71
|
+
* { id: "us", label: "United States" },
|
|
72
|
+
* { id: "ca", label: "Canada" }
|
|
73
|
+
* ]}
|
|
74
|
+
* />
|
|
75
|
+
* </Form>
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
declare function RHFSelect<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, label, description, className, warningText, required, disabled, readOnly, placeholder, "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, options, ...other }: RHFSelectProps<TFieldValues, TName>): react_jsx_runtime.JSX.Element;
|
|
79
|
+
|
|
80
|
+
export { RHFSelect, type RHFSelectOption, type RHFSelectProps };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { FieldValues, FieldPath } from 'react-hook-form';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
type SelectOption = {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
startIcon?: React.ReactNode;
|
|
9
|
+
endIcon?: React.ReactNode;
|
|
10
|
+
className?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
type SelectProps = {
|
|
14
|
+
/** Whether the select is searchable */
|
|
15
|
+
searchable?: boolean;
|
|
16
|
+
/** Whether the select should take up the full width of its container */
|
|
17
|
+
fullWidth?: boolean;
|
|
18
|
+
/** Currently selected value */
|
|
19
|
+
value: string;
|
|
20
|
+
/** Array of options to display in the select */
|
|
21
|
+
options: SelectOption[];
|
|
22
|
+
/** Callback fired when the value changes */
|
|
23
|
+
onChange: (value: string) => void;
|
|
24
|
+
/** Render a custom CommandList for the select, if not provided, the select will render a default CommandList with the options */
|
|
25
|
+
renderCommandList?: (options: SelectOption[]) => React.ReactNode;
|
|
26
|
+
/** Placeholder text to show when no value is selected */
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
/** Whether the select is disabled */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/** Whether the select is required */
|
|
31
|
+
required?: boolean;
|
|
32
|
+
/** Error message to display */
|
|
33
|
+
error?: string;
|
|
34
|
+
/** Additional class name for the select */
|
|
35
|
+
className?: string;
|
|
36
|
+
/** ID for the select element */
|
|
37
|
+
id?: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
type RHFSelectOption = SelectOption;
|
|
41
|
+
interface RHFSelectProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<SelectProps, "name" | "value" | "onChange"> {
|
|
42
|
+
/** The name of the field in the form */
|
|
43
|
+
name: TName;
|
|
44
|
+
/** Optional label for the field */
|
|
45
|
+
label?: string;
|
|
46
|
+
/** Optional description text below the field */
|
|
47
|
+
description?: string;
|
|
48
|
+
/** Optional warning text to display */
|
|
49
|
+
warningText?: string;
|
|
50
|
+
/** Whether the field is read-only */
|
|
51
|
+
readOnly?: boolean;
|
|
52
|
+
/** Optional aria-label for accessibility */
|
|
53
|
+
"aria-label"?: string;
|
|
54
|
+
/** Optional aria-describedby for accessibility */
|
|
55
|
+
"aria-describedby"?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A select component that integrates with React Hook Form.
|
|
60
|
+
* Provides form validation, error handling, and accessibility features.
|
|
61
|
+
*
|
|
62
|
+
* @url https://sergii-melnykov.github.io/ui/?path=/docs/molecules-rhf-rhfselect--docs
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* <Form>
|
|
67
|
+
* <RHFSelect
|
|
68
|
+
* name="country"
|
|
69
|
+
* label="Country"
|
|
70
|
+
* options={[
|
|
71
|
+
* { id: "us", label: "United States" },
|
|
72
|
+
* { id: "ca", label: "Canada" }
|
|
73
|
+
* ]}
|
|
74
|
+
* />
|
|
75
|
+
* </Form>
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
declare function RHFSelect<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ name, label, description, className, warningText, required, disabled, readOnly, placeholder, "aria-label": ariaLabel, "aria-describedby": ariaDescribedby, options, ...other }: RHFSelectProps<TFieldValues, TName>): react_jsx_runtime.JSX.Element;
|
|
79
|
+
|
|
80
|
+
export { RHFSelect, type RHFSelectOption, type RHFSelectProps };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var reactHookForm=require('react-hook-form'),d=require('react'),lucideReact=require('lucide-react'),clsx=require('clsx'),tailwindMerge=require('tailwind-merge'),reactPopover=require('@radix-ui/react-popover'),reactSlot=require('@radix-ui/react-slot'),classVarianceAuthority=require('class-variance-authority'),jsxRuntime=require('react/jsx-runtime'),cmdk=require('cmdk'),A=require('@radix-ui/react-label');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var d__namespace=/*#__PURE__*/_interopNamespace(d);var A__namespace=/*#__PURE__*/_interopNamespace(A);function r(...e){return tailwindMerge.twMerge(clsx.clsx(e))}var K=classVarianceAuthority.cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),$=d__namespace.forwardRef(({className:e,variant:t,size:o,asChild:m=false,startIcon:n,endIcon:s,loading:l=false,disabled:P,children:c,type:F="button","aria-label":v,...f},y)=>{let C=m?reactSlot.Slot:"button",p=P||l,a=v||(typeof c=="string"?c:void 0),te=w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),!p&&f.onClick&&f.onClick(w));};return m?jsxRuntime.jsx(C,{className:r(K({variant:t,size:o,className:e})),ref:y,disabled:p,type:F,"aria-label":a,"aria-disabled":p,...f,children:c}):jsxRuntime.jsxs(C,{className:r(K({variant:t,size:o,className:e})),ref:y,disabled:p,type:F,"aria-label":a,"aria-disabled":p,onKeyDown:te,...f,children:[l&&jsxRuntime.jsx(lucideReact.Loader2,{className:"mr-2 h-4 w-4 animate-spin",role:"status","aria-label":"Loading","aria-hidden":"true"}),!l&&n&&jsxRuntime.jsx("span",{className:"mr-2","aria-hidden":"true",children:n}),c,!l&&s&&jsxRuntime.jsx("span",{className:"ml-2","aria-hidden":"true",children:s})]})});$.displayName="Button";var L=d__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(cmdk.Command,{ref:o,className:r("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));L.displayName=cmdk.Command.displayName;var V=d__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[jsxRuntime.jsx(lucideReact.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),jsxRuntime.jsx(cmdk.Command.Input,{ref:o,className:r("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));V.displayName=cmdk.Command.Input.displayName;var T=d__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(cmdk.Command.List,{ref:o,className:r("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));T.displayName=cmdk.Command.List.displayName;var k=d__namespace.forwardRef((e,t)=>jsxRuntime.jsx(cmdk.Command.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));k.displayName=cmdk.Command.Empty.displayName;var S=d__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(cmdk.Command.Group,{ref:o,className:r("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));S.displayName=cmdk.Command.Group.displayName;var W=d__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(cmdk.Command.Separator,{ref:o,className:r("-mx-1 h-px bg-border",e),...t}));W.displayName=cmdk.Command.Separator.displayName;var E=d__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(cmdk.Command.Item,{ref:o,className:r("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...t}));E.displayName=cmdk.Command.Item.displayName;var pe=classVarianceAuthority.cva("",{variants:{variant:{h1:"scroll-m-5 text-4xl font-extrabold tracking-tight lg:text-5xl",h2:"scroll-m-5 text-3xl font-semibold tracking-tight",h3:"scroll-m-5 text-2xl font-semibold tracking-tight",h4:"scroll-m-5 text-xl font-semibold tracking-tight",h5:"scroll-m-5 text-lg font-semibold tracking-tight",h6:"scroll-m-5 text-base font-semibold tracking-tight",p:"leading-7 [&:not(:first-child)]:mt-6",blockquote:"mt-6 border-l-2 border-slate-300 pl-6 italic",list:"my-6 ml-6 list-disc [&>li]:mt-2",lead:"text-xl text-muted-foreground",large:"text-lg font-semibold",small:"text-sm font-medium leading-none",muted:"text-sm text-muted-foreground"},align:{left:"text-left",center:"text-center",right:"text-right",justify:"text-justify"}},defaultVariants:{variant:"p",align:"left"}}),O=d__namespace.forwardRef(({className:e,variant:t,align:o,as:m="p",...n},s)=>jsxRuntime.jsx(m,{className:r(pe({variant:t,align:o,className:e})),ref:s,...n}));O.displayName="Typography";function X({options:e,value:t,onChange:o,placeholder:m="Select an option",disabled:n,required:s,error:l,className:P,fullWidth:c,searchable:F,id:v,renderCommandList:f}){let[y,C]=d__namespace.useState(false),p=e?.find(a=>a.id===t);return jsxRuntime.jsx("div",{className:r(c&&"w-full"),children:jsxRuntime.jsxs(reactPopover.Popover,{open:y,onOpenChange:C,children:[jsxRuntime.jsx(reactPopover.PopoverTrigger,{asChild:true,children:jsxRuntime.jsxs($,{variant:"outline",role:"combobox","aria-expanded":y,"aria-controls":v?`${v}-content`:void 0,"aria-required":s,"aria-invalid":!!l,disabled:n,className:r("w-[13rem] justify-between",!t&&"text-muted-foreground",c&&"w-full",l&&"border-destructive focus-visible:ring-destructive",P),children:[p?p.label:m,jsxRuntime.jsx(lucideReact.ChevronDown,{className:r("opacity-50",y&&"rotate-180")})]})}),jsxRuntime.jsx(reactPopover.PopoverContent,{className:r("w-[13rem] p-0 rounded-md border bg-popover text-popover-foreground shadow-md",c&&"w-full"),align:"start",children:jsxRuntime.jsxs(L,{children:[F&&jsxRuntime.jsx(V,{placeholder:"Search...",className:"h-9",disabled:n}),jsxRuntime.jsxs(T,{className:"max-h-[12rem] overflow-y-auto",children:[jsxRuntime.jsx(k,{children:"No items found."}),f?f(e):jsxRuntime.jsx(S,{children:e?.map(a=>jsxRuntime.jsxs(E,{value:a.label,onSelect:()=>{o(a.id),C(false);},disabled:a.disabled,className:r("flex items-center justify-between cursor-pointer my-1",t===a.id&&"bg-accent text-accent-foreground",a.disabled&&"opacity-50 cursor-not-allowed",a.className),children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-1",children:[a.startIcon&&a.startIcon,jsxRuntime.jsx(O,{variant:"small",children:a.label})]}),a.endIcon&&jsxRuntime.jsx("div",{className:"ml-2",children:a.endIcon})]},a.id))})]})]})})]})})}var be=classVarianceAuthority.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),M=d__namespace.forwardRef(({className:e,...t},o)=>jsxRuntime.jsx(A__namespace.Root,{ref:o,className:r(be(),e),...t}));M.displayName=A__namespace.Root.displayName;var Z=d__namespace.createContext({}),q=({...e})=>jsxRuntime.jsx(Z.Provider,{value:{name:e.name},children:jsxRuntime.jsx(reactHookForm.Controller,{...e})}),N=()=>{let e=d__namespace.useContext(Z),t=d__namespace.useContext(j),{getFieldState:o,formState:m}=reactHookForm.useFormContext(),n=o(e.name,m);if(!e)throw new Error("useFormField should be used within <FormField>");let{id:s}=t;return {id:s,name:e.name,formItemId:`${s}-form-item`,formDescriptionId:`${s}-form-item-description`,formMessageId:`${s}-form-item-message`,...n}},j=d__namespace.createContext({}),_=d__namespace.forwardRef(({className:e,...t},o)=>{let m=d__namespace.useId();return jsxRuntime.jsx(j.Provider,{value:{id:m},children:jsxRuntime.jsx("div",{ref:o,className:r("space-y-2",e),...t})})});_.displayName="FormItem";var D=d__namespace.forwardRef(({className:e,...t},o)=>{let{error:m,formItemId:n}=N();return jsxRuntime.jsx(M,{ref:o,className:r(m&&"text-destructive",e),htmlFor:n,...t})});D.displayName="FormLabel";var H=d__namespace.forwardRef(({...e},t)=>{let{error:o,formItemId:m,formDescriptionId:n,formMessageId:s}=N();return jsxRuntime.jsx(reactSlot.Slot,{ref:t,id:m,"aria-describedby":o?`${n} ${s}`:`${n}`,"aria-invalid":!!o,...e})});H.displayName="FormControl";var G=d__namespace.forwardRef(({className:e,...t},o)=>{let{formDescriptionId:m}=N();return jsxRuntime.jsx("p",{ref:o,id:m,className:r("text-sm text-muted-foreground",e),...t})});G.displayName="FormDescription";var B=d__namespace.forwardRef(({className:e,children:t,...o},m)=>{let{error:n,formMessageId:s}=N(),l=n?String(n?.message??""):t;return l?jsxRuntime.jsx("p",{ref:m,id:s,className:r("text-sm font-medium text-destructive",e),...o,children:l}):null});B.displayName="FormMessage";function vt({name:e,label:t,description:o,className:m,warningText:n,required:s,disabled:l,readOnly:P,placeholder:c,"aria-label":F,"aria-describedby":v,options:f,...y}){let{control:C}=reactHookForm.useFormContext();return jsxRuntime.jsx(q,{name:e,control:C,render:({field:p,fieldState:{error:a}})=>jsxRuntime.jsxs(_,{children:[t&&jsxRuntime.jsxs(D,{children:[t,s&&jsxRuntime.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),jsxRuntime.jsx(H,{children:jsxRuntime.jsx(X,{...p,options:f,value:p.value||"",onChange:p.onChange,className:r(a&&"border-destructive focus-visible:ring-destructive",m),disabled:l||P,required:s,placeholder:c,"aria-label":F,"aria-describedby":v,"aria-invalid":!!a,"aria-required":s,...y})}),o&&jsxRuntime.jsx(G,{children:o}),a&&jsxRuntime.jsx(B,{children:a.message}),!a&&n&&jsxRuntime.jsx("p",{className:"text-sm text-yellow-600 dark:text-yellow-500",role:"alert",children:n})]})})}exports.RHFSelect=vt;//# sourceMappingURL=rhf-select.js.map
|
|
2
|
+
//# sourceMappingURL=rhf-select.js.map
|