@customafk/lunas-ui 0.0.77 → 0.0.79
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/{add-new-CnZV8qWt.cjs → add-new-BaA0yy6U.cjs} +2 -2
- package/dist/{add-new-CnZV8qWt.cjs.map → add-new-BaA0yy6U.cjs.map} +1 -1
- package/dist/{add-new-CdyYFK4x.js → add-new-_5opEbrI.js} +2 -2
- package/dist/{add-new-CdyYFK4x.js.map → add-new-_5opEbrI.js.map} +1 -1
- package/dist/{alert-dialog-lXAg3Alc.js → alert-dialog-DcQKEgVC.js} +1 -1
- package/dist/{alert-dialog-lXAg3Alc.js.map → alert-dialog-DcQKEgVC.js.map} +1 -1
- package/dist/{alert-dialog-DIO7g0Aa.cjs → alert-dialog-brXudt77.cjs} +1 -1
- package/dist/{alert-dialog-DIO7g0Aa.cjs.map → alert-dialog-brXudt77.cjs.map} +1 -1
- package/dist/{avatar-kxLA5n-m.cjs → avatar-B4pklWJt.cjs} +1 -1
- package/dist/{avatar-kxLA5n-m.cjs.map → avatar-B4pklWJt.cjs.map} +1 -1
- package/dist/{avatar-BT0PH1Tk.js → avatar-iX5Jhj8E.js} +1 -1
- package/dist/{avatar-BT0PH1Tk.js.map → avatar-iX5Jhj8E.js.map} +1 -1
- package/dist/{badge-DG8ELRGF.cjs → badge-CsA-JCDX.cjs} +1 -1
- package/dist/{badge-DG8ELRGF.cjs.map → badge-CsA-JCDX.cjs.map} +1 -1
- package/dist/{badge-DH9VoXhk.js → badge-tjlLdDGl.js} +1 -1
- package/dist/{badge-DH9VoXhk.js.map → badge-tjlLdDGl.js.map} +1 -1
- package/dist/{button-Bpoqzxk-.d.cts → button-Bu22bfSc.d.ts} +5 -5
- package/dist/{button-BwKsSigg.d.ts → button-MK4kEvtG.d.cts} +6 -6
- package/dist/cards/simple-card.d.cts +2 -2
- package/dist/{command-BFIF8llT.cjs → command-BaW_SRkQ.cjs} +2 -2
- package/dist/{command-BFIF8llT.cjs.map → command-BaW_SRkQ.cjs.map} +1 -1
- package/dist/{command-Bdz8IRdV.js → command-CRNFM6Sb.js} +2 -2
- package/dist/{command-Bdz8IRdV.js.map → command-CRNFM6Sb.js.map} +1 -1
- package/dist/{command-BUnu6Cro.d.ts → command-DlFoBoLD.d.cts} +12 -12
- package/dist/{command-C-4VFIwT.d.cts → command-KDJ9A-WG.d.ts} +2 -2
- package/dist/data-display/country.cjs +1 -1
- package/dist/data-display/country.js +1 -1
- package/dist/data-display/data-list.cjs +1 -1
- package/dist/data-display/data-list.js +1 -1
- package/dist/data-display/date-tooltip.cjs +1 -1
- package/dist/data-display/date-tooltip.js +1 -1
- package/dist/data-display/date.cjs +1 -1
- package/dist/data-display/date.js +1 -1
- package/dist/data-display/empty.cjs +1 -1
- package/dist/data-display/empty.d.cts +2 -2
- package/dist/data-display/empty.d.ts +2 -2
- package/dist/data-display/empty.js +1 -1
- package/dist/data-display/name.cjs +1 -1
- package/dist/data-display/name.js +1 -1
- package/dist/data-display/phone-number.cjs +1 -1
- package/dist/data-display/phone-number.js +1 -1
- package/dist/data-display/role-badge.cjs +1 -1
- package/dist/data-display/role-badge.js +1 -1
- package/dist/data-display/statistic.cjs +1 -1
- package/dist/data-display/statistic.d.cts +2 -2
- package/dist/data-display/statistic.d.ts +2 -2
- package/dist/data-display/statistic.js +1 -1
- package/dist/data-display/user.cjs +1 -1
- package/dist/data-display/user.js +1 -1
- package/dist/{date-Cckz-1ou.cjs → date-2wue8L-1.cjs} +1 -1
- package/dist/{date-Cckz-1ou.cjs.map → date-2wue8L-1.cjs.map} +1 -1
- package/dist/{date-CAkONFNM.js → date-BuPl--Fc.js} +1 -1
- package/dist/{date-CAkONFNM.js.map → date-BuPl--Fc.js.map} +1 -1
- package/dist/{dialog-B0nEcw96.cjs → dialog-DGbWt3A4.cjs} +1 -1
- package/dist/{dialog-B0nEcw96.cjs.map → dialog-DGbWt3A4.cjs.map} +1 -1
- package/dist/{dialog-DDsbgE3Z.d.ts → dialog-DqP1cjOr.d.ts} +12 -12
- package/dist/{dialog-B4XWQE0p.d.cts → dialog-ONWCpHMt.d.cts} +12 -12
- package/dist/{dialog-CjX94zKb.js → dialog-SbX5GvMK.js} +1 -1
- package/dist/{dialog-CjX94zKb.js.map → dialog-SbX5GvMK.js.map} +1 -1
- package/dist/dialogs/confirm-dialog.cjs +1 -1
- package/dist/dialogs/confirm-dialog.js +1 -1
- package/dist/dialogs/detail-dialog/component/sidebar.cjs +1 -1
- package/dist/dialogs/detail-dialog/component/sidebar.d.cts +28 -28
- package/dist/dialogs/detail-dialog/component/sidebar.d.ts +4 -4
- package/dist/dialogs/detail-dialog/component/sidebar.js +1 -1
- package/dist/dialogs/detail-dialog/index.cjs +1 -1
- package/dist/dialogs/detail-dialog/index.cjs.map +1 -1
- package/dist/dialogs/detail-dialog/index.js +1 -1
- package/dist/dialogs/error-dialog.cjs +1 -1
- package/dist/dialogs/error-dialog.js +1 -1
- package/dist/dialogs/form-dialog.cjs +1 -1
- package/dist/dialogs/form-dialog.d.cts +2 -2
- package/dist/dialogs/form-dialog.d.ts +2 -2
- package/dist/dialogs/form-dialog.js +1 -1
- package/dist/dialogs/loading-dialog.cjs +1 -1
- package/dist/dialogs/loading-dialog.js +1 -1
- package/dist/{drawer-BWmBT8Xx.cjs → drawer-CaX-sUvZ.cjs} +1 -1
- package/dist/{drawer-BWmBT8Xx.cjs.map → drawer-CaX-sUvZ.cjs.map} +1 -1
- package/dist/{drawer-CWQ5bBHi.js → drawer-hi51Beoq.js} +1 -1
- package/dist/{drawer-CWQ5bBHi.js.map → drawer-hi51Beoq.js.map} +1 -1
- package/dist/{error-dialog-CUUXPd_g.js → error-dialog-BeYJOtSH.js} +2 -2
- package/dist/{error-dialog-CUUXPd_g.js.map → error-dialog-BeYJOtSH.js.map} +1 -1
- package/dist/{error-dialog-Br3cqI6T.cjs → error-dialog-DMbJhWyk.cjs} +2 -2
- package/dist/{error-dialog-Br3cqI6T.cjs.map → error-dialog-DMbJhWyk.cjs.map} +1 -1
- package/dist/{flex-B_qDiQBK.js → flex-D6XrXRQW.js} +1 -1
- package/dist/{flex-B_qDiQBK.js.map → flex-D6XrXRQW.js.map} +1 -1
- package/dist/{flex-3xY2da62.cjs → flex-DS4mxjtf.cjs} +1 -1
- package/dist/{flex-3xY2da62.cjs.map → flex-DS4mxjtf.cjs.map} +1 -1
- package/dist/{form-nFp50GQa.js → form-BT1TbgK6.js} +2 -2
- package/dist/{form-nFp50GQa.js.map → form-BT1TbgK6.js.map} +1 -1
- package/dist/{form-LlBR5CH6.cjs → form-DyH5iWq7.cjs} +2 -2
- package/dist/{form-LlBR5CH6.cjs.map → form-DyH5iWq7.cjs.map} +1 -1
- package/dist/{form-wrapper-C-4ssC7K.js → form-wrapper-CFcpJdfv.js} +2 -2
- package/dist/{form-wrapper-C-4ssC7K.js.map → form-wrapper-CFcpJdfv.js.map} +1 -1
- package/dist/{form-wrapper-C2nxYJsQ.cjs → form-wrapper-bC0IEtWT.cjs} +2 -2
- package/dist/{form-wrapper-C2nxYJsQ.cjs.map → form-wrapper-bC0IEtWT.cjs.map} +1 -1
- package/dist/forms/combobox-field.cjs +1 -1
- package/dist/forms/combobox-field.d.cts +2 -2
- package/dist/forms/combobox-field.d.ts +2 -2
- package/dist/forms/combobox-field.js +1 -1
- package/dist/forms/date-field.cjs +1 -1
- package/dist/forms/date-field.d.cts +2 -2
- package/dist/forms/date-field.d.ts +2 -2
- package/dist/forms/date-field.js +1 -1
- package/dist/forms/form-wrapper.cjs +1 -1
- package/dist/forms/form-wrapper.d.cts +2 -2
- package/dist/forms/form-wrapper.d.ts +2 -2
- package/dist/forms/form-wrapper.js +1 -1
- package/dist/forms/multi-select-field.cjs +1 -1
- package/dist/forms/multi-select-field.d.cts +2 -2
- package/dist/forms/multi-select-field.d.ts +2 -2
- package/dist/forms/multi-select-field.js +1 -1
- package/dist/forms/number-field.cjs +1 -1
- package/dist/forms/number-field.d.cts +2 -2
- package/dist/forms/number-field.d.ts +2 -2
- package/dist/forms/number-field.js +1 -1
- package/dist/forms/password-field.cjs +1 -1
- package/dist/forms/password-field.d.cts +2 -2
- package/dist/forms/password-field.d.ts +2 -2
- package/dist/forms/password-field.js +1 -1
- package/dist/forms/select-field.cjs +1 -1
- package/dist/forms/select-field.d.cts +2 -2
- package/dist/forms/select-field.d.ts +2 -2
- package/dist/forms/select-field.js +1 -1
- package/dist/forms/switch-field.cjs +1 -1
- package/dist/forms/switch-field.d.cts +2 -2
- package/dist/forms/switch-field.d.ts +2 -2
- package/dist/forms/switch-field.js +1 -1
- package/dist/forms/text-field.cjs +1 -1
- package/dist/forms/text-field.d.cts +2 -2
- package/dist/forms/text-field.d.ts +2 -2
- package/dist/forms/text-field.js +1 -1
- package/dist/forms/textarea-field.cjs +1 -1
- package/dist/forms/textarea-field.d.cts +2 -2
- package/dist/forms/textarea-field.d.ts +2 -2
- package/dist/forms/textarea-field.js +1 -1
- package/dist/{input-DXE-qRch.d.cts → input-C6NFFJxS.d.cts} +3 -3
- package/dist/{input-8EIWjE5j.d.ts → input-CG09_mqs.d.ts} +3 -3
- package/dist/{label-BR3QQSIp.cjs → label-CHNSlaoz.cjs} +1 -1
- package/dist/{label-BR3QQSIp.cjs.map → label-CHNSlaoz.cjs.map} +1 -1
- package/dist/{label-CRhvNQY4.js → label-CdrxlBJ8.js} +1 -1
- package/dist/{label-CRhvNQY4.js.map → label-CdrxlBJ8.js.map} +1 -1
- package/dist/layouts/app-layout/index.cjs +1 -1
- package/dist/layouts/app-layout/index.d.cts +28 -28
- package/dist/layouts/app-layout/index.d.ts +3 -3
- package/dist/layouts/app-layout/index.js +1 -1
- package/dist/layouts/flex.cjs +1 -1
- package/dist/layouts/flex.d.cts +2 -2
- package/dist/layouts/flex.d.ts +2 -2
- package/dist/layouts/flex.js +1 -1
- package/dist/layouts/service-layout/index.cjs +1 -1
- package/dist/layouts/service-layout/index.d.cts +15 -15
- package/dist/layouts/service-layout/index.d.ts +3 -3
- package/dist/layouts/service-layout/index.js +1 -1
- package/dist/layouts/service-layout/index.js.map +1 -1
- package/dist/{multi-select-zRSNabHi.cjs → multi-select-DIZCHmU4.cjs} +2 -2
- package/dist/{multi-select-zRSNabHi.cjs.map → multi-select-DIZCHmU4.cjs.map} +1 -1
- package/dist/{multi-select-7gJ0p2qk.js → multi-select-DzKtuSER.js} +2 -2
- package/dist/{multi-select-7gJ0p2qk.js.map → multi-select-DzKtuSER.js.map} +1 -1
- package/dist/{paragraph-eTkdWYsK.js → paragraph-B9fp9JaI.js} +1 -1
- package/dist/{paragraph-eTkdWYsK.js.map → paragraph-B9fp9JaI.js.map} +1 -1
- package/dist/{paragraph-BVNragDZ.cjs → paragraph-BLvW7xdo.cjs} +1 -1
- package/dist/{paragraph-BVNragDZ.cjs.map → paragraph-BLvW7xdo.cjs.map} +1 -1
- package/dist/{refresh-CWyM3e6G.js → refresh-BHjc0ETv.js} +2 -2
- package/dist/{refresh-CWyM3e6G.js.map → refresh-BHjc0ETv.js.map} +1 -1
- package/dist/{refresh-BMBMI6At.cjs → refresh-Bt9GEyuC.cjs} +2 -2
- package/dist/{refresh-BMBMI6At.cjs.map → refresh-Bt9GEyuC.cjs.map} +1 -1
- package/dist/{separator-E2_sfBcf.d.cts → separator-DIIArEUd.d.cts} +3 -3
- package/dist/{separator-DExlvlJ1.d.ts → separator-DUymk2P4.d.ts} +3 -3
- package/dist/{sidebar-V5_9Ws0A.cjs → sidebar-BF_5REY5.cjs} +2 -2
- package/dist/{sidebar-V5_9Ws0A.cjs.map → sidebar-BF_5REY5.cjs.map} +1 -1
- package/dist/{sidebar-Baw-T7Q1.js → sidebar-BgOz0zZh.js} +2 -2
- package/dist/{sidebar-Baw-T7Q1.js.map → sidebar-BgOz0zZh.js.map} +1 -1
- package/dist/table/index.cjs +1 -1
- package/dist/table/index.d.cts +2 -2
- package/dist/table/index.d.ts +2 -2
- package/dist/table/index.js +1 -1
- package/dist/{toggle-B4TinVZu.d.cts → toggle-2VFLb0ul.d.cts} +3 -3
- package/dist/{toggle-DPTA8XO2.d.ts → toggle-Ch4ddcGF.d.ts} +5 -5
- package/dist/{tooltip-CNdZZO_B.js → tooltip-BTrjCwd8.js} +1 -1
- package/dist/{tooltip-CNdZZO_B.js.map → tooltip-BTrjCwd8.js.map} +1 -1
- package/dist/{tooltip-BKTq7o5G.d.ts → tooltip-Cfp93PmG.d.ts} +6 -6
- package/dist/{tooltip-DCbmI7Af.cjs → tooltip-DXvcPsvM.cjs} +1 -1
- package/dist/{tooltip-DCbmI7Af.cjs.map → tooltip-DXvcPsvM.cjs.map} +1 -1
- package/dist/{tooltip-DLNDOfBF.d.cts → tooltip-DijjzZk1.d.cts} +6 -6
- package/dist/{types-DkOgOlMw.js → types-BiiGENwa.js} +1 -1
- package/dist/{types-DkOgOlMw.js.map → types-BiiGENwa.js.map} +1 -1
- package/dist/{types-Cs3x9-zN.cjs → types-D32qXHff.cjs} +1 -1
- package/dist/{types-Cs3x9-zN.cjs.map → types-D32qXHff.cjs.map} +1 -1
- package/dist/typography/paragraph.cjs +1 -1
- package/dist/typography/paragraph.d.cts +2 -2
- package/dist/typography/paragraph.d.ts +2 -2
- package/dist/typography/paragraph.js +1 -1
- package/dist/typography/title.d.cts +2 -2
- package/dist/typography/title.d.ts +2 -2
- package/dist/ui/alert-dialog.cjs +1 -1
- package/dist/ui/alert-dialog.d.cts +12 -12
- package/dist/ui/alert-dialog.d.ts +12 -12
- package/dist/ui/alert-dialog.js +1 -1
- package/dist/ui/alert.d.cts +6 -6
- package/dist/ui/alert.d.ts +4 -4
- package/dist/ui/aspect-ratio.d.cts +2 -2
- package/dist/ui/aspect-ratio.d.ts +2 -2
- package/dist/ui/avatar.cjs +1 -1
- package/dist/ui/avatar.d.cts +4 -4
- package/dist/ui/avatar.d.ts +4 -4
- package/dist/ui/avatar.js +1 -1
- package/dist/ui/badge.cjs +1 -1
- package/dist/ui/badge.d.cts +2 -2
- package/dist/ui/badge.d.ts +2 -2
- package/dist/ui/badge.js +1 -1
- package/dist/ui/breadcrumb.d.cts +8 -8
- package/dist/ui/breadcrumb.d.ts +8 -8
- package/dist/ui/button.d.cts +1 -1
- package/dist/ui/button.d.ts +1 -1
- package/dist/ui/buttons/add-new.cjs +1 -1
- package/dist/ui/buttons/add-new.js +1 -1
- package/dist/ui/buttons/refresh.cjs +1 -1
- package/dist/ui/buttons/refresh.js +1 -1
- package/dist/ui/calendar.d.cts +4 -4
- package/dist/ui/calendar.d.ts +4 -4
- package/dist/ui/card.d.cts +8 -8
- package/dist/ui/card.d.ts +8 -8
- package/dist/ui/carousel.d.cts +7 -7
- package/dist/ui/carousel.d.ts +7 -7
- package/dist/ui/collapsible.d.cts +4 -4
- package/dist/ui/collapsible.d.ts +4 -4
- package/dist/ui/command.cjs +1 -1
- package/dist/ui/command.d.cts +2 -2
- package/dist/ui/command.d.ts +2 -2
- package/dist/ui/command.js +1 -1
- package/dist/ui/context-menu.d.cts +16 -16
- package/dist/ui/context-menu.d.ts +16 -16
- package/dist/ui/dialog.cjs +1 -1
- package/dist/ui/dialog.d.cts +1 -1
- package/dist/ui/dialog.d.ts +1 -1
- package/dist/ui/dialog.js +1 -1
- package/dist/ui/dropdown-menu.d.cts +16 -16
- package/dist/ui/dropdown-menu.d.ts +16 -16
- package/dist/ui/file-uploader.d.cts +2 -2
- package/dist/ui/file-uploader.d.ts +2 -2
- package/dist/ui/form.cjs +1 -1
- package/dist/ui/form.d.cts +7 -7
- package/dist/ui/form.d.ts +7 -7
- package/dist/ui/form.js +1 -1
- package/dist/ui/hover-card.d.cts +4 -4
- package/dist/ui/hover-card.d.ts +4 -4
- package/dist/ui/input-otp.d.cts +5 -5
- package/dist/ui/input-otp.d.ts +5 -5
- package/dist/ui/input.d.cts +1 -1
- package/dist/ui/input.d.ts +1 -1
- package/dist/ui/inputs/search-input.d.cts +3 -3
- package/dist/ui/inputs/search-input.d.ts +3 -3
- package/dist/ui/label.cjs +1 -1
- package/dist/ui/label.d.cts +2 -2
- package/dist/ui/label.d.ts +2 -2
- package/dist/ui/label.js +1 -1
- package/dist/ui/menubar.d.cts +17 -17
- package/dist/ui/menubar.d.ts +17 -17
- package/dist/ui/multi-select.cjs +1 -1
- package/dist/ui/multi-select.d.cts +2 -2
- package/dist/ui/multi-select.d.ts +2 -2
- package/dist/ui/multi-select.js +1 -1
- package/dist/ui/navigation-menu.d.cts +9 -9
- package/dist/ui/navigation-menu.d.ts +9 -9
- package/dist/ui/pagination.d.cts +9 -9
- package/dist/ui/pagination.d.ts +9 -9
- package/dist/ui/popover.d.cts +5 -5
- package/dist/ui/popover.d.ts +5 -5
- package/dist/ui/progress.d.cts +2 -2
- package/dist/ui/progress.d.ts +2 -2
- package/dist/ui/radio-group.d.cts +3 -3
- package/dist/ui/radio-group.d.ts +3 -3
- package/dist/ui/resizable.d.cts +4 -4
- package/dist/ui/resizable.d.ts +4 -4
- package/dist/ui/scroll-area.d.cts +3 -3
- package/dist/ui/scroll-area.d.ts +3 -3
- package/dist/ui/select.d.cts +11 -11
- package/dist/ui/select.d.ts +11 -11
- package/dist/ui/separator.d.cts +1 -1
- package/dist/ui/separator.d.ts +1 -1
- package/dist/ui/sheet.d.cts +9 -9
- package/dist/ui/sheet.d.ts +9 -9
- package/dist/ui/sidebar.cjs +1 -1
- package/dist/ui/sidebar.d.cts +28 -28
- package/dist/ui/sidebar.d.ts +30 -30
- package/dist/ui/sidebar.js +1 -1
- package/dist/ui/skeleton.d.cts +2 -2
- package/dist/ui/skeleton.d.ts +2 -2
- package/dist/ui/slider.d.cts +2 -2
- package/dist/ui/slider.d.ts +2 -2
- package/dist/ui/sonner.d.cts +2 -2
- package/dist/ui/sonner.d.ts +2 -2
- package/dist/ui/switch.d.cts +2 -2
- package/dist/ui/switch.d.ts +2 -2
- package/dist/ui/table.d.cts +9 -9
- package/dist/ui/table.d.ts +9 -9
- package/dist/ui/tabs.d.cts +5 -5
- package/dist/ui/tabs.d.ts +5 -5
- package/dist/ui/textarea.d.cts +2 -2
- package/dist/ui/textarea.d.ts +2 -2
- package/dist/ui/toggle-group.d.cts +4 -4
- package/dist/ui/toggle-group.d.ts +4 -4
- package/dist/ui/toggle.d.cts +1 -1
- package/dist/ui/toggle.d.ts +1 -1
- package/dist/ui/tooltip.cjs +1 -1
- package/dist/ui/tooltip.d.cts +1 -1
- package/dist/ui/tooltip.d.ts +1 -1
- package/dist/ui/tooltip.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-
|
|
1
|
+
{"version":3,"file":"form-BT1TbgK6.js","names":["Label","SlotPrimitive"],"sources":["../packages/components/ui/form.tsx"],"sourcesContent":["'use client'\nimport { createContext, useContext, useId } from 'react'\nimport { Controller, type ControllerProps, type FieldPath, type FieldValues, FormProvider, useFormContext, useFormState } from 'react-hook-form'\nimport { cn } from '@customafk/react-toolkit/utils'\n\nimport { Label } from '@/components/ui/label'\n\nimport { Label as LabelPrimitive, Slot as SlotPrimitive } from 'radix-ui'\n\nconst Form = FormProvider\n\ntype FormFieldContextValue<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {\n name: TName\n}\n\nconst FormFieldContext = createContext<FormFieldContextValue>({} as FormFieldContextValue)\n\nconst FormField = <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({\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 = useContext(FormFieldContext)\n const itemContext = useContext(FormItemContext)\n const { getFieldState, control, resetField } = useFormContext()\n const formState = useFormState({ name: fieldContext.name })\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 control,\n resetField,\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 = createContext<FormItemContextValue>({} as FormItemContextValue)\n\nfunction FormItem({ className, ...props }: React.ComponentProps<'div'>) {\n const id = useId()\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div data-slot=\"form-item\" className={cn('grid gap-1', className)} {...props} />\n </FormItemContext.Provider>\n )\n}\n\nfunction FormLabel({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>) {\n const { formItemId } = useFormField()\n return <Label data-slot=\"form-label\" className={cn('text-xs', className)} htmlFor={formItemId} {...props} />\n}\n\nfunction FormControl({ ...props }: React.ComponentProps<typeof SlotPrimitive.Slot>) {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <SlotPrimitive.Slot\n data-slot=\"form-control\"\n id={formItemId}\n aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n aria-invalid={!!error}\n {...props}\n />\n )\n}\n\nfunction FormDescription({ className, ...props }: React.ComponentProps<'p'>) {\n const { formDescriptionId } = useFormField()\n\n return <p data-slot=\"form-description\" id={formDescriptionId} className={cn('text-text-positive-weak text-sm', className)} {...props} />\n}\n\nfunction FormMessage({ className, children, ...props }: React.ComponentProps<'p'>) {\n const { error, formMessageId } = useFormField()\n\n return (\n <span data-slot=\"form-message\" id={formMessageId} className={cn('text-danger text-xs', className)} {...props}>\n {error ? String(error?.message ?? '') : children}\n </span>\n )\n}\n\n// eslint-disable-next-line react-refresh/only-export-components\nexport { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField }\n"],"mappings":"yVASA,MAAM,EAAO,EAMP,EAAmB,EAAqC,IAExD,GAA8H,CAClI,GAAG,KAGD,EAAC,EAAiB,SAAA,CAAS,MAAO,CAAE,KAAM,EAAM,eAC9C,EAAC,EAAA,CAAW,GAAI,MAKhB,MAAqB,CACzB,IAAM,EAAe,EAAW,GAC1B,EAAc,EAAW,GACzB,CAAE,gBAAe,UAAS,cAAe,IACzC,EAAY,EAAa,CAAE,KAAM,EAAa,OAC9C,EAAa,EAAc,EAAa,KAAM,GAEpD,GAAI,CAAC,EACH,MAAU,MAAM,kDAGlB,GAAM,CAAE,MAAO,EAEf,MAAO,CACL,KACA,UACA,aACA,KAAM,EAAa,KACnB,WAAY,GAAG,EAAG,YAClB,kBAAmB,GAAG,EAAG,wBACzB,cAAe,GAAG,EAAG,oBACrB,GAAG,IAQD,EAAkB,EAAoC,IAE5D,SAAS,EAAS,CAAE,YAAW,GAAG,GAAsC,CACtE,IAAM,EAAK,IAEX,OACE,EAAC,EAAgB,SAAA,CAAS,MAAO,CAAE,eACjC,EAAC,MAAA,CAAI,YAAU,YAAY,UAAW,EAAG,aAAc,GAAY,GAAI,MAK7E,SAAS,EAAU,CAAE,YAAW,GAAG,GAA2D,CAC5F,GAAM,CAAE,cAAe,IACvB,OAAO,EAACA,EAAAA,CAAM,YAAU,aAAa,UAAW,EAAG,UAAW,GAAY,QAAS,EAAY,GAAI,IAGrG,SAAS,EAAY,CAAE,GAAG,GAA0D,CAClF,GAAM,CAAE,QAAO,aAAY,oBAAmB,iBAAkB,IAEhE,OACE,EAACC,EAAc,KAAA,CACb,YAAU,eACV,GAAI,EACJ,mBAAmB,EAAiC,GAAG,EAAkB,GAAG,IAAjD,GAAG,IAC9B,eAAc,CAAC,CAAC,EAChB,GAAI,IAKV,SAAS,EAAgB,CAAE,YAAW,GAAG,GAAoC,CAC3E,GAAM,CAAE,qBAAsB,IAE9B,OAAO,EAAC,IAAA,CAAE,YAAU,mBAAmB,GAAI,EAAmB,UAAW,EAAG,kCAAmC,GAAY,GAAI,IAGjI,SAAS,EAAY,CAAE,YAAW,WAAU,GAAG,GAAoC,CACjF,GAAM,CAAE,QAAO,iBAAkB,IAEjC,OACE,EAAC,OAAA,CAAK,YAAU,eAAe,GAAI,EAAe,UAAW,EAAG,sBAAuB,GAAY,GAAI,WACpG,EAAQ,OAAO,GAAO,SAAW,IAAM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`./chunk-CUT6urMc.cjs`),t=require(`./label-
|
|
2
|
-
//# sourceMappingURL=form-
|
|
1
|
+
const e=require(`./chunk-CUT6urMc.cjs`),t=require(`./label-CHNSlaoz.cjs`),n=e.__toESM(require(`@customafk/react-toolkit/utils`)),r=e.__toESM(require(`react`)),i=e.__toESM(require(`react/jsx-runtime`)),a=e.__toESM(require(`radix-ui`)),o=e.__toESM(require(`react-hook-form`)),s=o.FormProvider,c=(0,r.createContext)({}),l=({...e})=>(0,i.jsx)(c.Provider,{value:{name:e.name},children:(0,i.jsx)(o.Controller,{...e})}),u=()=>{let e=(0,r.useContext)(c),t=(0,r.useContext)(d),{getFieldState:n,control:i,resetField:a}=(0,o.useFormContext)(),s=(0,o.useFormState)({name:e.name}),l=n(e.name,s);if(!e)throw Error(`useFormField should be used within <FormField>`);let{id:u}=t;return{id:u,control:i,resetField:a,name:e.name,formItemId:`${u}-form-item`,formDescriptionId:`${u}-form-item-description`,formMessageId:`${u}-form-item-message`,...l}},d=(0,r.createContext)({});function f({className:e,...t}){let a=(0,r.useId)();return(0,i.jsx)(d.Provider,{value:{id:a},children:(0,i.jsx)(`div`,{"data-slot":`form-item`,className:(0,n.cn)(`grid gap-1`,e),...t})})}function p({className:e,...r}){let{formItemId:a}=u();return(0,i.jsx)(t.Label,{"data-slot":`form-label`,className:(0,n.cn)(`text-xs`,e),htmlFor:a,...r})}function m({...e}){let{error:t,formItemId:n,formDescriptionId:r,formMessageId:o}=u();return(0,i.jsx)(a.Slot.Slot,{"data-slot":`form-control`,id:n,"aria-describedby":t?`${r} ${o}`:`${r}`,"aria-invalid":!!t,...e})}function h({className:e,...t}){let{formDescriptionId:r}=u();return(0,i.jsx)(`p`,{"data-slot":`form-description`,id:r,className:(0,n.cn)(`text-text-positive-weak text-sm`,e),...t})}function g({className:e,children:t,...r}){let{error:a,formMessageId:o}=u();return(0,i.jsx)(`span`,{"data-slot":`form-message`,id:o,className:(0,n.cn)(`text-danger text-xs`,e),...r,children:a?String(a?.message??``):t})}Object.defineProperty(exports,`Form`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`FormControl`,{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,`FormDescription`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`FormField`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`FormItem`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`FormLabel`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`FormMessage`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`useFormField`,{enumerable:!0,get:function(){return u}});
|
|
2
|
+
//# sourceMappingURL=form-DyH5iWq7.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-
|
|
1
|
+
{"version":3,"file":"form-DyH5iWq7.cjs","names":["FormProvider","Controller","Label","SlotPrimitive"],"sources":["../packages/components/ui/form.tsx"],"sourcesContent":["'use client'\nimport { createContext, useContext, useId } from 'react'\nimport { Controller, type ControllerProps, type FieldPath, type FieldValues, FormProvider, useFormContext, useFormState } from 'react-hook-form'\nimport { cn } from '@customafk/react-toolkit/utils'\n\nimport { Label } from '@/components/ui/label'\n\nimport { Label as LabelPrimitive, Slot as SlotPrimitive } from 'radix-ui'\n\nconst Form = FormProvider\n\ntype FormFieldContextValue<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {\n name: TName\n}\n\nconst FormFieldContext = createContext<FormFieldContextValue>({} as FormFieldContextValue)\n\nconst FormField = <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({\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 = useContext(FormFieldContext)\n const itemContext = useContext(FormItemContext)\n const { getFieldState, control, resetField } = useFormContext()\n const formState = useFormState({ name: fieldContext.name })\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 control,\n resetField,\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 = createContext<FormItemContextValue>({} as FormItemContextValue)\n\nfunction FormItem({ className, ...props }: React.ComponentProps<'div'>) {\n const id = useId()\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div data-slot=\"form-item\" className={cn('grid gap-1', className)} {...props} />\n </FormItemContext.Provider>\n )\n}\n\nfunction FormLabel({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>) {\n const { formItemId } = useFormField()\n return <Label data-slot=\"form-label\" className={cn('text-xs', className)} htmlFor={formItemId} {...props} />\n}\n\nfunction FormControl({ ...props }: React.ComponentProps<typeof SlotPrimitive.Slot>) {\n const { error, formItemId, formDescriptionId, formMessageId } = useFormField()\n\n return (\n <SlotPrimitive.Slot\n data-slot=\"form-control\"\n id={formItemId}\n aria-describedby={!error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`}\n aria-invalid={!!error}\n {...props}\n />\n )\n}\n\nfunction FormDescription({ className, ...props }: React.ComponentProps<'p'>) {\n const { formDescriptionId } = useFormField()\n\n return <p data-slot=\"form-description\" id={formDescriptionId} className={cn('text-text-positive-weak text-sm', className)} {...props} />\n}\n\nfunction FormMessage({ className, children, ...props }: React.ComponentProps<'p'>) {\n const { error, formMessageId } = useFormField()\n\n return (\n <span data-slot=\"form-message\" id={formMessageId} className={cn('text-danger text-xs', className)} {...props}>\n {error ? String(error?.message ?? '') : children}\n </span>\n )\n}\n\n// eslint-disable-next-line react-refresh/only-export-components\nexport { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField }\n"],"mappings":"kRASM,EAAOA,EAAAA,aAMP,GAAA,EAAA,EAAA,eAAwD,IAExD,GAA8H,CAClI,GAAG,MAGD,EAAA,EAAA,KAAC,EAAiB,SAAA,CAAS,MAAO,CAAE,KAAM,EAAM,gBAC9C,EAAA,EAAA,KAACC,EAAAA,WAAAA,CAAW,GAAI,MAKhB,MAAqB,CACzB,IAAM,GAAA,EAAA,EAAA,YAA0B,GAC1B,GAAA,EAAA,EAAA,YAAyB,GACzB,CAAE,gBAAe,UAAS,eAAA,EAAA,EAAA,kBAC1B,GAAA,EAAA,EAAA,cAAyB,CAAE,KAAM,EAAa,OAC9C,EAAa,EAAc,EAAa,KAAM,GAEpD,GAAI,CAAC,EACH,MAAU,MAAM,kDAGlB,GAAM,CAAE,MAAO,EAEf,MAAO,CACL,KACA,UACA,aACA,KAAM,EAAa,KACnB,WAAY,GAAG,EAAG,YAClB,kBAAmB,GAAG,EAAG,wBACzB,cAAe,GAAG,EAAG,oBACrB,GAAG,IAQD,GAAA,EAAA,EAAA,eAAsD,IAE5D,SAAS,EAAS,CAAE,YAAW,GAAG,GAAsC,CACtE,IAAM,GAAA,EAAA,EAAA,SAEN,OACE,EAAA,EAAA,KAAC,EAAgB,SAAA,CAAS,MAAO,CAAE,gBACjC,EAAA,EAAA,KAAC,MAAA,CAAI,YAAU,YAAY,WAAA,EAAA,EAAA,IAAc,aAAc,GAAY,GAAI,MAK7E,SAAS,EAAU,CAAE,YAAW,GAAG,GAA2D,CAC5F,GAAM,CAAE,cAAe,IACvB,OAAO,EAAA,EAAA,KAACC,EAAAA,MAAAA,CAAM,YAAU,aAAa,WAAA,EAAA,EAAA,IAAc,UAAW,GAAY,QAAS,EAAY,GAAI,IAGrG,SAAS,EAAY,CAAE,GAAG,GAA0D,CAClF,GAAM,CAAE,QAAO,aAAY,oBAAmB,iBAAkB,IAEhE,OACE,EAAA,EAAA,KAACC,EAAAA,KAAc,KAAA,CACb,YAAU,eACV,GAAI,EACJ,mBAAmB,EAAiC,GAAG,EAAkB,GAAG,IAAjD,GAAG,IAC9B,eAAc,CAAC,CAAC,EAChB,GAAI,IAKV,SAAS,EAAgB,CAAE,YAAW,GAAG,GAAoC,CAC3E,GAAM,CAAE,qBAAsB,IAE9B,OAAO,EAAA,EAAA,KAAC,IAAA,CAAE,YAAU,mBAAmB,GAAI,EAAmB,WAAA,EAAA,EAAA,IAAc,kCAAmC,GAAY,GAAI,IAGjI,SAAS,EAAY,CAAE,YAAW,WAAU,GAAG,GAAoC,CACjF,GAAM,CAAE,QAAO,iBAAkB,IAEjC,OACE,EAAA,EAAA,KAAC,OAAA,CAAK,YAAU,eAAe,GAAI,EAAe,WAAA,EAAA,EAAA,IAAc,sBAAuB,GAAY,GAAI,WACpG,EAAQ,OAAO,GAAO,SAAW,IAAM"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ErrorDialog as e}from"./error-dialog-
|
|
2
|
-
//# sourceMappingURL=form-wrapper-
|
|
1
|
+
import{ErrorDialog as e}from"./error-dialog-BeYJOtSH.js";import{Form as t}from"./form-BT1TbgK6.js";import{AlertCircleIcon as n}from"lucide-react";import{useCallback as r,useEffect as i,useState as a}from"react";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";import{useForm as l}from"react-hook-form";import{ErrorMessage as u}from"@hookform/error-message";const d=({form:d,isResetAfterSubmit:f=!0,className:p,onSubmit:m,onError:h,onSubcribe:g,children:_})=>{let v=l({...d,criteriaMode:`all`}),{formState:y,reset:b,handleSubmit:x,subscribe:S}=v,{dirtyFields:C}=y,[w,T]=a(!1),E=r(e=>{m(e,y,C),f&&b()},[C,y,f,m,b]),D=r(e=>{let t=Object.keys(e);t.length!==0&&(h?.(e),T(!0))},[h]);return i(()=>{if(!g)return;let e=S({formState:{values:!0},callback:({values:e})=>{g(e)}});return()=>e()},[g,S]),c(t,{...v,children:[s(`form`,{className:p,onSubmit:x(E,D),children:_}),s(e,{open:w,title:`Lỗi nhập dữ liệu`,description:`An unexpected error has occurred. Please check the errors below and try again.`,onOpenChange:T,children:w&&s(o,{children:Object.keys(y.errors).length>0?c(`div`,{className:`flex max-w-100 flex-col gap-2 px-4`,children:[s(`p`,{className:`text-muted-foreground text-sm font-semibold`,children:`Cảnh báo: Vui lòng kiểm tra các lỗi sau:`}),s(`div`,{className:`flex flex-col space-y-1`,children:Object.entries(y.errors).map(([e])=>s(u,{errors:y.errors,name:e,render:({messages:e})=>s(o,{children:e?Object.entries(e).map(([e,t])=>c(`div`,{className:`text-accent-foreground flex items-start gap-x-1 truncate text-sm font-normal`,children:[s(n,{size:16,className:`text-destructive mt-0.5 min-w-4 flex-0`}),s(`p`,{className:`line-clamp-2 flex-1 text-wrap`,children:t})]},e)):null})},e))})]}):s(`p`,{className:`text-muted-foreground text-sm`,children:`No errors found.`})})})]})};export{d as FormWrapper};
|
|
2
|
+
//# sourceMappingURL=form-wrapper-CFcpJdfv.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-wrapper-
|
|
1
|
+
{"version":3,"file":"form-wrapper-CFcpJdfv.js","names":[],"sources":["../packages/components/forms/form-wrapper.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\nimport { type FieldValues, type FormState, type SubmitErrorHandler, type SubmitHandler, useForm, type UseFormProps } from 'react-hook-form'\n\nimport { AlertCircleIcon } from 'lucide-react'\n\nimport type { AnyEntity } from '@/types'\nimport { ErrorMessage } from '@hookform/error-message'\n\nimport { ErrorDialog } from '../dialogs/error-dialog'\nimport { Form } from '../ui/form'\n\ntype Props<TFieldValues extends FieldValues = FieldValues> = {\n form: UseFormProps<TFieldValues>\n isResetAfterSubmit?: boolean\n className?: string\n onSubmit: (data: TFieldValues, formState: FormState<FieldValues>, dirtyFields: FormState<FieldValues>['dirtyFields']) => void | Promise<void>\n onError?: SubmitErrorHandler<TFieldValues>\n onSubcribe?: (values: TFieldValues) => void\n}\n\nexport const FormWrapper = <TFieldValues extends FieldValues = FieldValues>({\n form: FormConfig,\n isResetAfterSubmit = true,\n className,\n onSubmit,\n onError,\n onSubcribe,\n children,\n}: React.PropsWithChildren<Props<TFieldValues>>) => {\n const form = useForm({\n ...FormConfig,\n criteriaMode: 'all',\n })\n\n const { formState, reset, handleSubmit, subscribe } = form\n const { dirtyFields } = formState\n\n const [errorOpen, setErrorOpen] = useState<boolean>(false)\n\n const handleFormSubmit = useCallback<SubmitHandler<TFieldValues>>(\n (data) => {\n onSubmit(data, formState, dirtyFields)\n if (isResetAfterSubmit) {\n reset()\n }\n },\n [dirtyFields, formState, isResetAfterSubmit, onSubmit, reset],\n )\n\n const handleFormError = useCallback<SubmitErrorHandler<TFieldValues>>(\n (errors) => {\n const errorKeys = Object.keys(errors)\n if (errorKeys.length === 0) return\n onError?.(errors)\n setErrorOpen(true)\n },\n [onError],\n )\n\n useEffect(() => {\n if (!onSubcribe) return\n const callback = subscribe({\n formState: { values: true },\n callback: ({ values }) => {\n onSubcribe(values)\n },\n })\n return () => callback()\n }, [onSubcribe, subscribe])\n\n return (\n <Form {...form}>\n <form className={className} onSubmit={handleSubmit(handleFormSubmit, handleFormError)}>\n {children}\n </form>\n <ErrorDialog\n open={errorOpen}\n title=\"Lỗi nhập dữ liệu\"\n description=\"An unexpected error has occurred. Please check the errors below and try again.\"\n onOpenChange={setErrorOpen}\n >\n {errorOpen && (\n <>\n {Object.keys(formState.errors).length > 0 ? (\n <div className=\"flex max-w-100 flex-col gap-2 px-4\">\n <p className=\"text-muted-foreground text-sm font-semibold\">Cảnh báo: Vui lòng kiểm tra các lỗi sau:</p>\n <div className=\"flex flex-col space-y-1\">\n {Object.entries(formState.errors).map(([key]) => (\n <ErrorMessage\n key={key}\n errors={formState.errors}\n name={key as AnyEntity}\n render={({ messages }) => {\n return (\n <>\n {messages\n ? Object.entries(messages).map(([type, message]) => {\n return (\n <div key={type} className=\"text-accent-foreground flex items-start gap-x-1 truncate text-sm font-normal\">\n <AlertCircleIcon size={16} className=\"text-destructive mt-0.5 min-w-4 flex-0\" />\n <p className=\"line-clamp-2 flex-1 text-wrap\">{message}</p>\n </div>\n )\n })\n : null}\n </>\n )\n }}\n />\n ))}\n </div>\n </div>\n ) : (\n <p className=\"text-muted-foreground text-sm\">No errors found.</p>\n )}\n </>\n )}\n </ErrorDialog>\n </Form>\n )\n}\n"],"mappings":"oXAoBA,MAAa,GAA+D,CAC1E,KAAM,EACN,qBAAqB,GACrB,YACA,WACA,UACA,aACA,cACkD,CAClD,IAAM,EAAO,EAAQ,CACnB,GAAG,EACH,aAAc,QAGV,CAAE,YAAW,QAAO,eAAc,aAAc,EAChD,CAAE,eAAgB,EAElB,CAAC,EAAW,GAAgB,EAAkB,IAE9C,EAAmB,EACtB,GAAS,CACR,EAAS,EAAM,EAAW,GACtB,GACF,KAGJ,CAAC,EAAa,EAAW,EAAoB,EAAU,IAGnD,EAAkB,EACrB,GAAW,CACV,IAAM,EAAY,OAAO,KAAK,GAC1B,EAAU,SAAW,IACzB,IAAU,GACV,EAAa,MAEf,CAAC,IAcH,OAXA,MAAgB,CACd,GAAI,CAAC,EAAY,OACjB,IAAM,EAAW,EAAU,CACzB,UAAW,CAAE,OAAQ,IACrB,UAAW,CAAE,YAAa,CACxB,EAAW,MAGf,UAAa,KACZ,CAAC,EAAY,IAGd,EAAC,EAAA,CAAK,GAAI,YACR,EAAC,OAAA,CAAgB,YAAW,SAAU,EAAa,EAAkB,GAClE,aAEH,EAAC,EAAA,CACC,KAAM,EACN,MAAM,mBACN,YAAY,iFACZ,aAAc,WAEb,GACC,EAAA,EAAA,CAAA,SACG,OAAO,KAAK,EAAU,QAAQ,OAAS,EACtC,EAAC,MAAA,CAAI,UAAU,+CACb,EAAC,IAAA,CAAE,UAAU,uDAA8C,6CAC3D,EAAC,MAAA,CAAI,UAAU,mCACZ,OAAO,QAAQ,EAAU,QAAQ,KAAK,CAAC,KACtC,EAAC,EAAA,CAEC,OAAQ,EAAU,OAClB,KAAM,EACN,QAAS,CAAE,cAEP,EAAA,EAAA,CAAA,SACG,EACG,OAAO,QAAQ,GAAU,KAAK,CAAC,EAAM,KAEjC,EAAC,MAAA,CAAe,UAAU,yFACxB,EAAC,EAAA,CAAgB,KAAM,GAAI,UAAU,2CACrC,EAAC,IAAA,CAAE,UAAU,yCAAiC,MAFtC,IAMd,QAfL,SAwBb,EAAC,IAAA,CAAE,UAAU,yCAAgC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`./chunk-CUT6urMc.cjs`),t=require(`./error-dialog-
|
|
2
|
-
//# sourceMappingURL=form-wrapper-
|
|
1
|
+
const e=require(`./chunk-CUT6urMc.cjs`),t=require(`./error-dialog-DMbJhWyk.cjs`),n=require(`./form-DyH5iWq7.cjs`),r=e.__toESM(require(`lucide-react`)),i=e.__toESM(require(`react`)),a=e.__toESM(require(`react/jsx-runtime`)),o=e.__toESM(require(`react-hook-form`)),s=e.__toESM(require(`@hookform/error-message`)),c=({form:e,isResetAfterSubmit:c=!0,className:l,onSubmit:u,onError:d,onSubcribe:f,children:p})=>{let m=(0,o.useForm)({...e,criteriaMode:`all`}),{formState:h,reset:g,handleSubmit:_,subscribe:v}=m,{dirtyFields:y}=h,[b,x]=(0,i.useState)(!1),S=(0,i.useCallback)(e=>{u(e,h,y),c&&g()},[y,h,c,u,g]),C=(0,i.useCallback)(e=>{let t=Object.keys(e);t.length!==0&&(d?.(e),x(!0))},[d]);return(0,i.useEffect)(()=>{if(!f)return;let e=v({formState:{values:!0},callback:({values:e})=>{f(e)}});return()=>e()},[f,v]),(0,a.jsxs)(n.Form,{...m,children:[(0,a.jsx)(`form`,{className:l,onSubmit:_(S,C),children:p}),(0,a.jsx)(t.ErrorDialog,{open:b,title:`Lỗi nhập dữ liệu`,description:`An unexpected error has occurred. Please check the errors below and try again.`,onOpenChange:x,children:b&&(0,a.jsx)(a.Fragment,{children:Object.keys(h.errors).length>0?(0,a.jsxs)(`div`,{className:`flex max-w-100 flex-col gap-2 px-4`,children:[(0,a.jsx)(`p`,{className:`text-muted-foreground text-sm font-semibold`,children:`Cảnh báo: Vui lòng kiểm tra các lỗi sau:`}),(0,a.jsx)(`div`,{className:`flex flex-col space-y-1`,children:Object.entries(h.errors).map(([e])=>(0,a.jsx)(s.ErrorMessage,{errors:h.errors,name:e,render:({messages:e})=>(0,a.jsx)(a.Fragment,{children:e?Object.entries(e).map(([e,t])=>(0,a.jsxs)(`div`,{className:`text-accent-foreground flex items-start gap-x-1 truncate text-sm font-normal`,children:[(0,a.jsx)(r.AlertCircleIcon,{size:16,className:`text-destructive mt-0.5 min-w-4 flex-0`}),(0,a.jsx)(`p`,{className:`line-clamp-2 flex-1 text-wrap`,children:t})]},e)):null})},e))})]}):(0,a.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No errors found.`})})})]})};Object.defineProperty(exports,`FormWrapper`,{enumerable:!0,get:function(){return c}});
|
|
2
|
+
//# sourceMappingURL=form-wrapper-bC0IEtWT.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-wrapper-
|
|
1
|
+
{"version":3,"file":"form-wrapper-bC0IEtWT.cjs","names":["Form","ErrorDialog","ErrorMessage","AlertCircleIcon"],"sources":["../packages/components/forms/form-wrapper.tsx"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react'\nimport { type FieldValues, type FormState, type SubmitErrorHandler, type SubmitHandler, useForm, type UseFormProps } from 'react-hook-form'\n\nimport { AlertCircleIcon } from 'lucide-react'\n\nimport type { AnyEntity } from '@/types'\nimport { ErrorMessage } from '@hookform/error-message'\n\nimport { ErrorDialog } from '../dialogs/error-dialog'\nimport { Form } from '../ui/form'\n\ntype Props<TFieldValues extends FieldValues = FieldValues> = {\n form: UseFormProps<TFieldValues>\n isResetAfterSubmit?: boolean\n className?: string\n onSubmit: (data: TFieldValues, formState: FormState<FieldValues>, dirtyFields: FormState<FieldValues>['dirtyFields']) => void | Promise<void>\n onError?: SubmitErrorHandler<TFieldValues>\n onSubcribe?: (values: TFieldValues) => void\n}\n\nexport const FormWrapper = <TFieldValues extends FieldValues = FieldValues>({\n form: FormConfig,\n isResetAfterSubmit = true,\n className,\n onSubmit,\n onError,\n onSubcribe,\n children,\n}: React.PropsWithChildren<Props<TFieldValues>>) => {\n const form = useForm({\n ...FormConfig,\n criteriaMode: 'all',\n })\n\n const { formState, reset, handleSubmit, subscribe } = form\n const { dirtyFields } = formState\n\n const [errorOpen, setErrorOpen] = useState<boolean>(false)\n\n const handleFormSubmit = useCallback<SubmitHandler<TFieldValues>>(\n (data) => {\n onSubmit(data, formState, dirtyFields)\n if (isResetAfterSubmit) {\n reset()\n }\n },\n [dirtyFields, formState, isResetAfterSubmit, onSubmit, reset],\n )\n\n const handleFormError = useCallback<SubmitErrorHandler<TFieldValues>>(\n (errors) => {\n const errorKeys = Object.keys(errors)\n if (errorKeys.length === 0) return\n onError?.(errors)\n setErrorOpen(true)\n },\n [onError],\n )\n\n useEffect(() => {\n if (!onSubcribe) return\n const callback = subscribe({\n formState: { values: true },\n callback: ({ values }) => {\n onSubcribe(values)\n },\n })\n return () => callback()\n }, [onSubcribe, subscribe])\n\n return (\n <Form {...form}>\n <form className={className} onSubmit={handleSubmit(handleFormSubmit, handleFormError)}>\n {children}\n </form>\n <ErrorDialog\n open={errorOpen}\n title=\"Lỗi nhập dữ liệu\"\n description=\"An unexpected error has occurred. Please check the errors below and try again.\"\n onOpenChange={setErrorOpen}\n >\n {errorOpen && (\n <>\n {Object.keys(formState.errors).length > 0 ? (\n <div className=\"flex max-w-100 flex-col gap-2 px-4\">\n <p className=\"text-muted-foreground text-sm font-semibold\">Cảnh báo: Vui lòng kiểm tra các lỗi sau:</p>\n <div className=\"flex flex-col space-y-1\">\n {Object.entries(formState.errors).map(([key]) => (\n <ErrorMessage\n key={key}\n errors={formState.errors}\n name={key as AnyEntity}\n render={({ messages }) => {\n return (\n <>\n {messages\n ? Object.entries(messages).map(([type, message]) => {\n return (\n <div key={type} className=\"text-accent-foreground flex items-start gap-x-1 truncate text-sm font-normal\">\n <AlertCircleIcon size={16} className=\"text-destructive mt-0.5 min-w-4 flex-0\" />\n <p className=\"line-clamp-2 flex-1 text-wrap\">{message}</p>\n </div>\n )\n })\n : null}\n </>\n )\n }}\n />\n ))}\n </div>\n </div>\n ) : (\n <p className=\"text-muted-foreground text-sm\">No errors found.</p>\n )}\n </>\n )}\n </ErrorDialog>\n </Form>\n )\n}\n"],"mappings":"uTAoBa,GAA+D,CAC1E,KAAM,EACN,qBAAqB,GACrB,YACA,WACA,UACA,aACA,cACkD,CAClD,IAAM,GAAA,EAAA,EAAA,SAAe,CACnB,GAAG,EACH,aAAc,QAGV,CAAE,YAAW,QAAO,eAAc,aAAc,EAChD,CAAE,eAAgB,EAElB,CAAC,EAAW,IAAA,EAAA,EAAA,UAAkC,IAE9C,GAAA,EAAA,EAAA,aACH,GAAS,CACR,EAAS,EAAM,EAAW,GACtB,GACF,KAGJ,CAAC,EAAa,EAAW,EAAoB,EAAU,IAGnD,GAAA,EAAA,EAAA,aACH,GAAW,CACV,IAAM,EAAY,OAAO,KAAK,GAC1B,EAAU,SAAW,IACzB,IAAU,GACV,EAAa,MAEf,CAAC,IAcH,OAXA,EAAA,EAAA,eAAgB,CACd,GAAI,CAAC,EAAY,OACjB,IAAM,EAAW,EAAU,CACzB,UAAW,CAAE,OAAQ,IACrB,UAAW,CAAE,YAAa,CACxB,EAAW,MAGf,UAAa,KACZ,CAAC,EAAY,KAGd,EAAA,EAAA,MAACA,EAAAA,KAAAA,CAAK,GAAI,aACR,EAAA,EAAA,KAAC,OAAA,CAAgB,YAAW,SAAU,EAAa,EAAkB,GAClE,cAEH,EAAA,EAAA,KAACC,EAAAA,YAAAA,CACC,KAAM,EACN,MAAM,mBACN,YAAY,iFACZ,aAAc,WAEb,IACC,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SACG,OAAO,KAAK,EAAU,QAAQ,OAAS,GACtC,EAAA,EAAA,MAAC,MAAA,CAAI,UAAU,gDACb,EAAA,EAAA,KAAC,IAAA,CAAE,UAAU,uDAA8C,8CAC3D,EAAA,EAAA,KAAC,MAAA,CAAI,UAAU,mCACZ,OAAO,QAAQ,EAAU,QAAQ,KAAK,CAAC,MACtC,EAAA,EAAA,KAACC,EAAAA,aAAAA,CAEC,OAAQ,EAAU,OAClB,KAAM,EACN,QAAS,CAAE,eAEP,EAAA,EAAA,KAAA,EAAA,SAAA,CAAA,SACG,EACG,OAAO,QAAQ,GAAU,KAAK,CAAC,EAAM,MAEjC,EAAA,EAAA,MAAC,MAAA,CAAe,UAAU,0FACxB,EAAA,EAAA,KAACC,EAAAA,gBAAAA,CAAgB,KAAM,GAAI,UAAU,4CACrC,EAAA,EAAA,KAAC,IAAA,CAAE,UAAU,yCAAiC,MAFtC,IAMd,QAfL,UAwBb,EAAA,EAAA,KAAC,IAAA,CAAE,UAAU,yCAAgC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../dist-D0uO1qIz.cjs`),require(`../button-variants-CCiseNSC.cjs`);const t=require(`../button-CuV2l4ge.cjs`);require(`../label-
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../dist-D0uO1qIz.cjs`),require(`../button-variants-CCiseNSC.cjs`);const t=require(`../button-CuV2l4ge.cjs`);require(`../label-CHNSlaoz.cjs`);const n=require(`../form-DyH5iWq7.cjs`);require(`../dialog-DGbWt3A4.cjs`);const r=require(`../command-BaW_SRkQ.cjs`),i=require(`../popover-DLbTz02b.cjs`),a=e.__toESM(require(`lucide-react`)),o=e.__toESM(require(`@customafk/react-toolkit/utils`)),s=e.__toESM(require(`react/jsx-runtime`)),c=({name:e,label:c=`Combobox`,placeholder:l=`Chọn một mục`,description:u,options:d,onAddNewItem:f})=>(0,s.jsx)(n.FormField,{name:e,render:({field:e})=>(0,s.jsxs)(n.FormItem,{className:`w-full`,children:[(0,s.jsx)(n.FormLabel,{children:c}),(0,s.jsxs)(i.Popover,{modal:!0,children:[(0,s.jsx)(i.PopoverTrigger,{asChild:!0,children:(0,s.jsx)(n.FormControl,{children:(0,s.jsxs)(t.Button,{type:`button`,variant:`outline`,role:`combobox`,color:`muted`,className:(0,o.cn)(`shadow-input flex justify-between rounded-md px-3`,`outline-border-weak font-normal`,`[&_div]:w-full`,`[&_div]:justify-between`,`hover:outline-border`,`data-[state=open]:text-text-positive-muted`,`data-[state=open]:outline-1`,`data-[state=open]:outline-primary-strong`,`data-[state=open]:ring-primary-weak`,`data-[state=open]:ring-4`,`focus:border-primary-strong`,`focus:ring-4`,`focus:ring-primary-weak`,`focus:outline-1`,`focus:outline-primary-strong`),children:[e.value?(0,s.jsx)(`span`,{className:`flex min-w-0 items-center gap-2`,children:d?.find(({value:t})=>t===e.value)?.label}):(0,s.jsx)(`span`,{className:`text-text-positive-muted`,children:l}),(0,s.jsx)(a.ChevronDownIcon,{size:16,className:`text-text-positive-weak shrink-0`,"aria-hidden":`true`})]})})}),(0,s.jsx)(i.PopoverContent,{className:`w-[var(--radix-popover-trigger-width)] p-0`,children:(0,s.jsxs)(r.Command,{className:`border-none`,children:[(0,s.jsx)(r.CommandInput,{placeholder:l??`Tìm kiếm`}),(0,s.jsxs)(r.CommandList,{children:[(0,s.jsx)(r.CommandGroup,{className:`max-h-40 overflow-y-auto`,children:d?.map(({value:t,label:n})=>(0,s.jsx)(r.CommandItem,{value:n,onSelect:()=>e.onChange(t),children:n},t))}),f&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.CommandSeparator,{}),(0,s.jsx)(r.CommandGroup,{children:(0,s.jsxs)(t.Button,{type:`button`,variant:`ghost`,className:`w-full justify-start font-normal`,children:[(0,s.jsx)(a.PlusIcon,{size:14,className:`-ms-2 opacity-60`,"aria-hidden":`true`}),`Thêm mới`]})})]})]}),(0,s.jsx)(r.CommandEmpty,{children:`Không có kết quả`})]})})]}),!!u&&(0,s.jsx)(n.FormDescription,{children:u})]})});exports.ComboboxField=c;
|
|
2
2
|
//# sourceMappingURL=combobox-field.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime50 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/combobox-field.d.ts
|
|
@@ -22,7 +22,7 @@ declare const ComboboxField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
22
22
|
description,
|
|
23
23
|
options,
|
|
24
24
|
onAddNewItem
|
|
25
|
-
}: Props<TFieldValues>) =>
|
|
25
|
+
}: Props<TFieldValues>) => react_jsx_runtime50.JSX.Element;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { ComboboxField };
|
|
28
28
|
//# sourceMappingURL=combobox-field.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/combobox-field.d.ts
|
|
@@ -22,7 +22,7 @@ declare const ComboboxField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
22
22
|
description,
|
|
23
23
|
options,
|
|
24
24
|
onAddNewItem
|
|
25
|
-
}: Props<TFieldValues>) =>
|
|
25
|
+
}: Props<TFieldValues>) => react_jsx_runtime2.JSX.Element;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { ComboboxField };
|
|
28
28
|
//# sourceMappingURL=combobox-field.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import"../dist-CkzytVha.js";import"../button-variants-Y1GTBayz.js";import{Button as e}from"../button-DhQJ9Ey8.js";import"../label-
|
|
1
|
+
"use client";import"../dist-CkzytVha.js";import"../button-variants-Y1GTBayz.js";import{Button as e}from"../button-DhQJ9Ey8.js";import"../label-CdrxlBJ8.js";import{FormControl as t,FormDescription as n,FormField as r,FormItem as i,FormLabel as a}from"../form-BT1TbgK6.js";import"../dialog-SbX5GvMK.js";import{Command as o,CommandEmpty as s,CommandGroup as c,CommandInput as l,CommandItem as u,CommandList as d,CommandSeparator as f}from"../command-CRNFM6Sb.js";import{Popover as p,PopoverContent as m,PopoverTrigger as h}from"../popover-DvXi2pyH.js";import{ChevronDownIcon as g,PlusIcon as _}from"lucide-react";import{cn as v}from"@customafk/react-toolkit/utils";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";const S=({name:S,label:C=`Combobox`,placeholder:w=`Chọn một mục`,description:T,options:E,onAddNewItem:D})=>b(r,{name:S,render:({field:r})=>x(i,{className:`w-full`,children:[b(a,{children:C}),x(p,{modal:!0,children:[b(h,{asChild:!0,children:b(t,{children:x(e,{type:`button`,variant:`outline`,role:`combobox`,color:`muted`,className:v(`shadow-input flex justify-between rounded-md px-3`,`outline-border-weak font-normal`,`[&_div]:w-full`,`[&_div]:justify-between`,`hover:outline-border`,`data-[state=open]:text-text-positive-muted`,`data-[state=open]:outline-1`,`data-[state=open]:outline-primary-strong`,`data-[state=open]:ring-primary-weak`,`data-[state=open]:ring-4`,`focus:border-primary-strong`,`focus:ring-4`,`focus:ring-primary-weak`,`focus:outline-1`,`focus:outline-primary-strong`),children:[r.value?b(`span`,{className:`flex min-w-0 items-center gap-2`,children:E?.find(({value:e})=>e===r.value)?.label}):b(`span`,{className:`text-text-positive-muted`,children:w}),b(g,{size:16,className:`text-text-positive-weak shrink-0`,"aria-hidden":`true`})]})})}),b(m,{className:`w-[var(--radix-popover-trigger-width)] p-0`,children:x(o,{className:`border-none`,children:[b(l,{placeholder:w??`Tìm kiếm`}),x(d,{children:[b(c,{className:`max-h-40 overflow-y-auto`,children:E?.map(({value:e,label:t})=>b(u,{value:t,onSelect:()=>r.onChange(e),children:t},e))}),D&&x(y,{children:[b(f,{}),b(c,{children:x(e,{type:`button`,variant:`ghost`,className:`w-full justify-start font-normal`,children:[b(_,{size:14,className:`-ms-2 opacity-60`,"aria-hidden":`true`}),`Thêm mới`]})})]})]}),b(s,{children:`Không có kết quả`})]})})]}),!!T&&b(n,{children:T})]})});export{S as ComboboxField};
|
|
2
2
|
//# sourceMappingURL=combobox-field.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../dist-D0uO1qIz.cjs`),require(`../button-variants-CCiseNSC.cjs`);const t=require(`../button-CuV2l4ge.cjs`);require(`../label-
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../dist-D0uO1qIz.cjs`),require(`../button-variants-CCiseNSC.cjs`);const t=require(`../button-CuV2l4ge.cjs`);require(`../label-CHNSlaoz.cjs`);const n=require(`../form-DyH5iWq7.cjs`),r=require(`../popover-DLbTz02b.cjs`),i=require(`../calendar-DGqBIV7n.cjs`),a=e.__toESM(require(`lucide-react`)),o=e.__toESM(require(`@customafk/react-toolkit/utils`)),s=e.__toESM(require(`react/jsx-runtime`)),c=e.__toESM(require(`@customafk/react-toolkit/date-fns`)),l=({name:e,label:l=`Date Field`,placeholder:u=`Select a date`,description:d=``,isShowErrorMsg:f=!1})=>(0,s.jsx)(n.FormField,{name:e,render:({field:e})=>(0,s.jsxs)(n.FormItem,{className:`w-full`,children:[(0,s.jsx)(n.FormLabel,{children:l}),(0,s.jsxs)(r.Popover,{modal:!0,children:[(0,s.jsx)(r.PopoverTrigger,{asChild:!0,children:(0,s.jsx)(n.FormControl,{children:(0,s.jsxs)(t.Button,{variant:`outline`,color:`muted`,className:(0,o.cn)(`w-full pl-3 text-left font-normal`,`outline-border-weak font-normal`,`hover:outline-border`,`data-[state=open]:text-text-positive-muted`,`data-[state=open]:outline-1`,`data-[state=open]:outline-primary-strong`,`data-[state=open]:ring-primary-weak`,`data-[state=open]:ring-4`,`focus:border-primary-strong`,`focus:ring-4`,`focus:ring-primary-weak`,`focus:outline-1`,`focus:outline-primary-strong`,!e.value&&`text-text-positive-muted`),children:[e.value?(0,c.format)(e.value,`PPP`):(0,s.jsxs)(`span`,{children:[` `,u||`Pick a date`]}),(0,s.jsx)(a.CalendarIcon,{className:`text-text-positive-weak ml-auto size-4`})]})})}),(0,s.jsx)(r.PopoverContent,{className:`w-auto p-0`,align:`start`,children:(0,s.jsx)(i.Calendar,{mode:`single`,selected:e.value,onSelect:t=>{e.onChange(t?.toISOString())},captionLayout:`dropdown`,disabled:e=>e<new Date(`2022-01-01`)})})]}),!!d&&(0,s.jsx)(n.FormDescription,{children:d}),f&&(0,s.jsx)(n.FormMessage,{})]})});exports.DateField=l;
|
|
2
2
|
//# sourceMappingURL=date-field.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime61 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/date-field.d.ts
|
|
@@ -16,7 +16,7 @@ declare const DateField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
16
16
|
placeholder,
|
|
17
17
|
description,
|
|
18
18
|
isShowErrorMsg
|
|
19
|
-
}: Props<TFieldValues>) =>
|
|
19
|
+
}: Props<TFieldValues>) => react_jsx_runtime61.JSX.Element;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { DateField };
|
|
22
22
|
//# sourceMappingURL=date-field.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime9 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/date-field.d.ts
|
|
@@ -16,7 +16,7 @@ declare const DateField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
16
16
|
placeholder,
|
|
17
17
|
description,
|
|
18
18
|
isShowErrorMsg
|
|
19
|
-
}: Props<TFieldValues>) =>
|
|
19
|
+
}: Props<TFieldValues>) => react_jsx_runtime9.JSX.Element;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { DateField };
|
|
22
22
|
//# sourceMappingURL=date-field.d.ts.map
|
package/dist/forms/date-field.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import"../dist-CkzytVha.js";import"../button-variants-Y1GTBayz.js";import{Button as e}from"../button-DhQJ9Ey8.js";import"../label-
|
|
1
|
+
"use client";import"../dist-CkzytVha.js";import"../button-variants-Y1GTBayz.js";import{Button as e}from"../button-DhQJ9Ey8.js";import"../label-CdrxlBJ8.js";import{FormControl as t,FormDescription as n,FormField as r,FormItem as i,FormLabel as a,FormMessage as o}from"../form-BT1TbgK6.js";import{Popover as s,PopoverContent as c,PopoverTrigger as l}from"../popover-DvXi2pyH.js";import{Calendar as u}from"../calendar-DdIUj5Dk.js";import{CalendarIcon as d}from"lucide-react";import{cn as f}from"@customafk/react-toolkit/utils";import{jsx as p,jsxs as m}from"react/jsx-runtime";import{format as h}from"@customafk/react-toolkit/date-fns";const g=({name:g,label:_=`Date Field`,placeholder:v=`Select a date`,description:y=``,isShowErrorMsg:b=!1})=>p(r,{name:g,render:({field:r})=>m(i,{className:`w-full`,children:[p(a,{children:_}),m(s,{modal:!0,children:[p(l,{asChild:!0,children:p(t,{children:m(e,{variant:`outline`,color:`muted`,className:f(`w-full pl-3 text-left font-normal`,`outline-border-weak font-normal`,`hover:outline-border`,`data-[state=open]:text-text-positive-muted`,`data-[state=open]:outline-1`,`data-[state=open]:outline-primary-strong`,`data-[state=open]:ring-primary-weak`,`data-[state=open]:ring-4`,`focus:border-primary-strong`,`focus:ring-4`,`focus:ring-primary-weak`,`focus:outline-1`,`focus:outline-primary-strong`,!r.value&&`text-text-positive-muted`),children:[r.value?h(r.value,`PPP`):m(`span`,{children:[` `,v||`Pick a date`]}),p(d,{className:`text-text-positive-weak ml-auto size-4`})]})})}),p(c,{className:`w-auto p-0`,align:`start`,children:p(u,{mode:`single`,selected:r.value,onSelect:e=>{r.onChange(e?.toISOString())},captionLayout:`dropdown`,disabled:e=>e<new Date(`2022-01-01`)})})]}),!!y&&p(n,{children:y}),b&&p(o,{})]})});export{g as DateField};
|
|
2
2
|
//# sourceMappingURL=date-field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../button-variants-CCiseNSC.cjs`),require(`../alert-dialog-
|
|
1
|
+
require(`../button-variants-CCiseNSC.cjs`),require(`../alert-dialog-brXudt77.cjs`),require(`../error-dialog-DMbJhWyk.cjs`),require(`../label-CHNSlaoz.cjs`),require(`../form-DyH5iWq7.cjs`);const e=require(`../form-wrapper-bC0IEtWT.cjs`);exports.FormWrapper=e.FormWrapper;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime98 from "react/jsx-runtime";
|
|
2
2
|
import { FieldValues, FormState, SubmitErrorHandler, UseFormProps } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/form-wrapper.d.ts
|
|
@@ -18,7 +18,7 @@ declare const FormWrapper: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
18
18
|
onError,
|
|
19
19
|
onSubcribe,
|
|
20
20
|
children
|
|
21
|
-
}: React.PropsWithChildren<Props<TFieldValues>>) =>
|
|
21
|
+
}: React.PropsWithChildren<Props<TFieldValues>>) => react_jsx_runtime98.JSX.Element;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { FormWrapper };
|
|
24
24
|
//# sourceMappingURL=form-wrapper.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime4 from "react/jsx-runtime";
|
|
2
2
|
import { FieldValues, FormState, SubmitErrorHandler, UseFormProps } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/form-wrapper.d.ts
|
|
@@ -18,7 +18,7 @@ declare const FormWrapper: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
18
18
|
onError,
|
|
19
19
|
onSubcribe,
|
|
20
20
|
children
|
|
21
|
-
}: React.PropsWithChildren<Props<TFieldValues>>) =>
|
|
21
|
+
}: React.PropsWithChildren<Props<TFieldValues>>) => react_jsx_runtime4.JSX.Element;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { FormWrapper };
|
|
24
24
|
//# sourceMappingURL=form-wrapper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../button-variants-Y1GTBayz.js";import"../alert-dialog-
|
|
1
|
+
import"../button-variants-Y1GTBayz.js";import"../alert-dialog-DcQKEgVC.js";import"../error-dialog-BeYJOtSH.js";import"../label-CdrxlBJ8.js";import"../form-BT1TbgK6.js";import{FormWrapper as e}from"../form-wrapper-CFcpJdfv.js";export{e as FormWrapper};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../dist-D0uO1qIz.cjs`),require(`../button-variants-CCiseNSC.cjs`),require(`../button-CuV2l4ge.cjs`),require(`../label-
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../dist-D0uO1qIz.cjs`),require(`../button-variants-CCiseNSC.cjs`),require(`../button-CuV2l4ge.cjs`),require(`../label-CHNSlaoz.cjs`);const t=require(`../form-DyH5iWq7.cjs`);require(`../dialog-DGbWt3A4.cjs`),require(`../command-BaW_SRkQ.cjs`);const n=require(`../multi-select-DIZCHmU4.cjs`),r=e.__toESM(require(`react/jsx-runtime`)),i=({name:e,label:i=`Multi Select Field`,isShowLabel:a=!0,isShowErrorMsg:o,placeholder:s=`Select options`,description:c=``,options:l=[],onAdd:u})=>(0,r.jsx)(t.FormField,{name:e,render:({field:{value:e,onChange:d}})=>{let f=l.filter(t=>e?.includes(t.value)),p=e=>{let t=e.map(e=>e.value);d(t)};return(0,r.jsxs)(t.FormItem,{className:`w-full gap-0`,children:[a&&(0,r.jsx)(t.FormLabel,{children:i}),(0,r.jsx)(t.FormControl,{children:(0,r.jsx)(n.MultipleSelector,{placeholder:s,emptyIndicator:`No options available`,value:f,options:l,onChange:p,onAddNewItem:u})}),!!c&&(0,r.jsx)(t.FormDescription,{children:c}),o&&(0,r.jsx)(t.FormMessage,{})]})}});exports.MultiSelectField=i;
|
|
2
2
|
//# sourceMappingURL=multi-select-field.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime97 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/multi-select-field.d.ts
|
|
@@ -24,7 +24,7 @@ declare const MultiSelectField: <TFieldValues extends FieldValues = FieldValues>
|
|
|
24
24
|
description,
|
|
25
25
|
options,
|
|
26
26
|
onAdd
|
|
27
|
-
}: Props<TFieldValues>) =>
|
|
27
|
+
}: Props<TFieldValues>) => react_jsx_runtime97.JSX.Element;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { MultiSelectField };
|
|
30
30
|
//# sourceMappingURL=multi-select-field.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime5 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/multi-select-field.d.ts
|
|
@@ -24,7 +24,7 @@ declare const MultiSelectField: <TFieldValues extends FieldValues = FieldValues>
|
|
|
24
24
|
description,
|
|
25
25
|
options,
|
|
26
26
|
onAdd
|
|
27
|
-
}: Props<TFieldValues>) =>
|
|
27
|
+
}: Props<TFieldValues>) => react_jsx_runtime5.JSX.Element;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { MultiSelectField };
|
|
30
30
|
//# sourceMappingURL=multi-select-field.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import"../dist-CkzytVha.js";import"../button-variants-Y1GTBayz.js";import"../button-DhQJ9Ey8.js";import"../label-
|
|
1
|
+
"use client";import"../dist-CkzytVha.js";import"../button-variants-Y1GTBayz.js";import"../button-DhQJ9Ey8.js";import"../label-CdrxlBJ8.js";import{FormControl as e,FormDescription as t,FormField as n,FormItem as r,FormLabel as i,FormMessage as a}from"../form-BT1TbgK6.js";import"../dialog-SbX5GvMK.js";import"../command-CRNFM6Sb.js";import{MultipleSelector as o}from"../multi-select-DzKtuSER.js";import{jsx as s,jsxs as c}from"react/jsx-runtime";const l=({name:l,label:u=`Multi Select Field`,isShowLabel:d=!0,isShowErrorMsg:f,placeholder:p=`Select options`,description:m=``,options:h=[],onAdd:g})=>s(n,{name:l,render:({field:{value:n,onChange:l}})=>{let _=h.filter(e=>n?.includes(e.value)),v=e=>{let t=e.map(e=>e.value);l(t)};return c(r,{className:`w-full gap-0`,children:[d&&s(i,{children:u}),s(e,{children:s(o,{placeholder:p,emptyIndicator:`No options available`,value:_,options:h,onChange:v,onAddNewItem:g})}),!!m&&s(t,{children:m}),f&&s(a,{})]})}});export{l as MultiSelectField};
|
|
2
2
|
//# sourceMappingURL=multi-select-field.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(`../chunk-CUT6urMc.cjs`);require(`../label-
|
|
1
|
+
const e=require(`../chunk-CUT6urMc.cjs`);require(`../label-CHNSlaoz.cjs`);const t=require(`../form-DyH5iWq7.cjs`),n=require(`../input-GHXBt6hz.cjs`),r=e.__toESM(require(`@customafk/react-toolkit/utils`)),i=e.__toESM(require(`react`)),a=e.__toESM(require(`react/jsx-runtime`)),o=e.__toESM(require(`react-hook-form`)),s=e=>e?/^-?\d*\.?\d*$/:/^\d*\.?\d*$/,c=e=>Number(e).toLocaleString(),l=({disabled:e=!1,readonly:t=!1,allowNegative:o=!1,numberAfterDecimalPoint:l=2,roundingRule:u=`none`,value:d=``,unitText:f,decimal:p,placeholder:m,precision:h,onChange:g,onValueChange:_,onBlur:v,...y})=>{let b=(0,i.useRef)(null),x=(0,i.useRef)(null),[S,C]=(0,i.useState)(d.toString()),w=p?.[1]??l,T=p&&p[0]-p[1],E=(0,i.useMemo)(()=>s(o),[o]),D=(0,i.useCallback)(e=>{if(!w&&e.includes(`.`))return!1;let t=e.split(`.`)[1];return!t||t.length<=w},[w]),O=(0,i.useCallback)(e=>{if(!p||e===`-`)return!0;let[t,n=``]=e.split(`.`);return n.length<=p[1]&&(t.startsWith(`-`)?t.length-1:t.length)<=T},[p,T]),k=(0,i.useCallback)((e,t)=>{if(u===`none`)return e;let n=Math.pow(10,t),r=e*n;switch(u){case`up`:return Math.ceil(r)/n;case`down`:return Math.floor(r)/n;case`nearest`:return r%1<.1?Math.floor(r)/n:r%1>=.59?Math.ceil(r)/n:(Math.floor(r)+.5)/n;default:return e}},[u]),A=(0,i.useCallback)(e=>!l&&e.includes(`.`)||e.split(`.`)[1]?.length>l,[l]),j=(0,i.useCallback)(e=>{if(e===`0`)return`0`;if(!Number(e))return``;let t=parseFloat(e),n=Math.min(w-1,h||0),r=k(t,n).toString(),[i,a=``]=r.split(`.`),o=c(i);return a?`${o}.${a}`:o},[k,w,h]),M=(0,i.useCallback)(e=>{if(!p||e===`-`)return!0;let[t,n=``]=e.split(`.`),r=t.startsWith(`-`)?t.length-1:t.length,i=p[0]-p[1];return n.length<=p[1]&&r<=i},[p]),N=(0,i.useCallback)(e=>{g?.(e);let{value:t}=e.target;if(!t){_?.(void 0),C(``);return}let n=t===`0`,r=t===`-`&&o;if(n||r){_?.(0),C(t);return}let i=E.test(t)&&O(t)&&(p||D(t));if(!i)return;let a=parseFloat(t)||0;_?.(a),C(t)},[o,p,D,O,g,_,E]),P=(0,i.useCallback)(()=>{t||C(e=>e.replace(/,/g,``))},[t]),F=(0,i.useCallback)(()=>{t||(v?.(),C(e=>j(e)))},[t,v,j]);return(0,i.useEffect)(()=>{let e=document.activeElement===x.current;if(!d||!E.test(d.toString())||!M(d.toString())||!p&&A(d.toString())){C(``);return}C(t=>t===`-`?`-`:t?e?d.toString():j(d.toString()):``)},[p,j,d,A,M,E]),(0,i.useEffect)(()=>{if(!b.current||!x.current||!f)return;let e=b.current.offsetWidth;x.current.style.setProperty(`padding-right`,`${(e+10)/16}rem`)},[e,f]),(0,a.jsxs)(`div`,{className:`relative`,children:[(0,a.jsx)(n.Input,{...y,ref:x,value:S||(t?`0`:``),placeholder:m,disabled:e,readOnly:t,className:(0,r.cn)(`font-number text-end`,t&&`bg-muted text-muted-foreground`),onChange:N,onFocus:P,onBlur:F}),f&&(0,a.jsx)(`span`,{ref:b,className:`text-muted-foreground pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 text-sm`,children:f})]})},u=({name:e,label:n=`Number Field`,placeholder:r=`0`,isShowErrorMsg:i=!1,isShowCount:s=!1,unitText:c=``,description:u=``,onValueChange:d})=>{let f=(0,o.useWatch)({name:e});return(0,a.jsx)(t.FormField,{name:e,render:({field:{onChange:e,...o}})=>(0,a.jsxs)(t.FormItem,{className:`w-full gap-0`,children:[(0,a.jsx)(t.FormLabel,{children:n}),(0,a.jsx)(t.FormControl,{children:(0,a.jsx)(l,{...o,placeholder:r,className:`w-full`,unitText:c,onValueChange:t=>{e(t),d?.(t)}})}),s&&(0,a.jsxs)(`div`,{className:`text-muted-foreground text-end text-xs`,children:[f?.length??0,` characters`]}),!!u&&(0,a.jsx)(t.FormDescription,{children:u}),i&&(0,a.jsx)(t.FormMessage,{})]})})};exports.NumberField=u;
|
|
2
2
|
//# sourceMappingURL=number-field.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime9 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/number-field.d.ts
|
|
@@ -22,7 +22,7 @@ declare const NumberField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
22
22
|
unitText,
|
|
23
23
|
description,
|
|
24
24
|
onValueChange
|
|
25
|
-
}: Props<TFieldValues>) =>
|
|
25
|
+
}: Props<TFieldValues>) => react_jsx_runtime9.JSX.Element;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { NumberField };
|
|
28
28
|
//# sourceMappingURL=number-field.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/number-field.d.ts
|
|
@@ -22,7 +22,7 @@ declare const NumberField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
22
22
|
unitText,
|
|
23
23
|
description,
|
|
24
24
|
onValueChange
|
|
25
|
-
}: Props<TFieldValues>) =>
|
|
25
|
+
}: Props<TFieldValues>) => react_jsx_runtime7.JSX.Element;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { NumberField };
|
|
28
28
|
//# sourceMappingURL=number-field.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../label-
|
|
1
|
+
import"../label-CdrxlBJ8.js";import{FormControl as e,FormDescription as t,FormField as n,FormItem as r,FormLabel as i,FormMessage as a}from"../form-BT1TbgK6.js";import{Input as o}from"../input-ZyZ1HKHN.js";import{cn as s}from"@customafk/react-toolkit/utils";import{useCallback as c,useEffect as l,useMemo as u,useRef as d,useState as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";import{useWatch as h}from"react-hook-form";const g=e=>e?/^-?\d*\.?\d*$/:/^\d*\.?\d*$/,_=e=>Number(e).toLocaleString(),v=({disabled:e=!1,readonly:t=!1,allowNegative:n=!1,numberAfterDecimalPoint:r=2,roundingRule:i=`none`,value:a=``,unitText:h,decimal:v,placeholder:y,precision:b,onChange:x,onValueChange:S,onBlur:C,...w})=>{let T=d(null),E=d(null),[D,O]=f(a.toString()),k=v?.[1]??r,A=v&&v[0]-v[1],j=u(()=>g(n),[n]),M=c(e=>{if(!k&&e.includes(`.`))return!1;let t=e.split(`.`)[1];return!t||t.length<=k},[k]),N=c(e=>{if(!v||e===`-`)return!0;let[t,n=``]=e.split(`.`);return n.length<=v[1]&&(t.startsWith(`-`)?t.length-1:t.length)<=A},[v,A]),P=c((e,t)=>{if(i===`none`)return e;let n=Math.pow(10,t),r=e*n;switch(i){case`up`:return Math.ceil(r)/n;case`down`:return Math.floor(r)/n;case`nearest`:return r%1<.1?Math.floor(r)/n:r%1>=.59?Math.ceil(r)/n:(Math.floor(r)+.5)/n;default:return e}},[i]),F=c(e=>!r&&e.includes(`.`)||e.split(`.`)[1]?.length>r,[r]),I=c(e=>{if(e===`0`)return`0`;if(!Number(e))return``;let t=parseFloat(e),n=Math.min(k-1,b||0),r=P(t,n).toString(),[i,a=``]=r.split(`.`),o=_(i);return a?`${o}.${a}`:o},[P,k,b]),L=c(e=>{if(!v||e===`-`)return!0;let[t,n=``]=e.split(`.`),r=t.startsWith(`-`)?t.length-1:t.length,i=v[0]-v[1];return n.length<=v[1]&&r<=i},[v]),R=c(e=>{x?.(e);let{value:t}=e.target;if(!t){S?.(void 0),O(``);return}let r=t===`0`,i=t===`-`&&n;if(r||i){S?.(0),O(t);return}let a=j.test(t)&&N(t)&&(v||M(t));if(!a)return;let o=parseFloat(t)||0;S?.(o),O(t)},[n,v,M,N,x,S,j]),z=c(()=>{t||O(e=>e.replace(/,/g,``))},[t]),B=c(()=>{t||(C?.(),O(e=>I(e)))},[t,C,I]);return l(()=>{let e=document.activeElement===E.current;if(!a||!j.test(a.toString())||!L(a.toString())||!v&&F(a.toString())){O(``);return}O(t=>t===`-`?`-`:t?e?a.toString():I(a.toString()):``)},[v,I,a,F,L,j]),l(()=>{if(!T.current||!E.current||!h)return;let e=T.current.offsetWidth;E.current.style.setProperty(`padding-right`,`${(e+10)/16}rem`)},[e,h]),m(`div`,{className:`relative`,children:[p(o,{...w,ref:E,value:D||(t?`0`:``),placeholder:y,disabled:e,readOnly:t,className:s(`font-number text-end`,t&&`bg-muted text-muted-foreground`),onChange:R,onFocus:z,onBlur:B}),h&&p(`span`,{ref:T,className:`text-muted-foreground pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 text-sm`,children:h})]})},y=({name:o,label:s=`Number Field`,placeholder:c=`0`,isShowErrorMsg:l=!1,isShowCount:u=!1,unitText:d=``,description:f=``,onValueChange:g})=>{let _=h({name:o});return p(n,{name:o,render:({field:{onChange:n,...o}})=>m(r,{className:`w-full gap-0`,children:[p(i,{children:s}),p(e,{children:p(v,{...o,placeholder:c,className:`w-full`,unitText:d,onValueChange:e=>{n(e),g?.(e)}})}),u&&m(`div`,{className:`text-muted-foreground text-end text-xs`,children:[_?.length??0,` characters`]}),!!f&&p(t,{children:f}),l&&p(a,{})]})})};export{y as NumberField};
|
|
2
2
|
//# sourceMappingURL=number-field.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../label-
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../label-CHNSlaoz.cjs`);const t=require(`../form-DyH5iWq7.cjs`),n=require(`../input-GHXBt6hz.cjs`),r=e.__toESM(require(`lucide-react`)),i=e.__toESM(require(`@customafk/react-toolkit/utils`)),a=e.__toESM(require(`react`)),o=e.__toESM(require(`react/jsx-runtime`)),s=({className:e,...t})=>{let s=(0,a.useId)(),[c,l]=(0,a.useState)(!1),u=(0,a.useCallback)(()=>l(e=>!e),[]);return(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(n.Input,{...t,id:s,placeholder:`Password`,type:c?`text`:`password`,className:(0,i.cn)(`pe-9`,e)}),(0,o.jsx)(`button`,{className:`text-muted-foreground/80 hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 absolute inset-y-0 end-0 flex h-full w-9 items-center justify-center rounded-e-md transition-[color,box-shadow] outline-none focus:z-10 focus-visible:ring-[3px] disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,type:`button`,onClick:u,"aria-label":c?`Hide password`:`Show password`,"aria-pressed":c,"aria-controls":`password`,children:c?(0,o.jsx)(r.EyeOffIcon,{size:16,"aria-hidden":`true`}):(0,o.jsx)(r.EyeIcon,{size:16,"aria-hidden":`true`})})]})},c=({name:e,label:n=`Text Field`,placeholder:r=`Enter text here`,isShowErrorMsg:i=!1,description:a,onValueChange:c})=>(0,o.jsx)(t.FormField,{name:e,render:({field:e})=>(0,o.jsxs)(t.FormItem,{className:`w-full`,children:[(0,o.jsx)(t.FormLabel,{children:n}),(0,o.jsx)(t.FormControl,{children:(0,o.jsx)(s,{placeholder:r,...e,onValueChange:c})}),!!a&&(0,o.jsx)(t.FormDescription,{children:a}),i&&(0,o.jsx)(t.FormMessage,{})]})});exports.PasswordField=c;
|
|
2
2
|
//# sourceMappingURL=password-field.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/password-field.d.ts
|
|
@@ -17,7 +17,7 @@ declare const PasswordField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
17
17
|
isShowErrorMsg,
|
|
18
18
|
description,
|
|
19
19
|
onValueChange
|
|
20
|
-
}: Props<TFieldValues>) =>
|
|
20
|
+
}: Props<TFieldValues>) => react_jsx_runtime2.JSX.Element;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { PasswordField };
|
|
23
23
|
//# sourceMappingURL=password-field.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/password-field.d.ts
|
|
@@ -17,7 +17,7 @@ declare const PasswordField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
17
17
|
isShowErrorMsg,
|
|
18
18
|
description,
|
|
19
19
|
onValueChange
|
|
20
|
-
}: Props<TFieldValues>) =>
|
|
20
|
+
}: Props<TFieldValues>) => react_jsx_runtime6.JSX.Element;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { PasswordField };
|
|
23
23
|
//# sourceMappingURL=password-field.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import"../label-
|
|
1
|
+
"use client";import"../label-CdrxlBJ8.js";import{FormControl as e,FormDescription as t,FormField as n,FormItem as r,FormLabel as i,FormMessage as a}from"../form-BT1TbgK6.js";import{Input as o}from"../input-ZyZ1HKHN.js";import{EyeIcon as s,EyeOffIcon as c}from"lucide-react";import{cn as l}from"@customafk/react-toolkit/utils";import{useCallback as u,useId as d,useState as f}from"react";import{jsx as p,jsxs as m}from"react/jsx-runtime";const h=({className:e,...t})=>{let n=d(),[r,i]=f(!1),a=u(()=>i(e=>!e),[]);return m(`div`,{className:`relative`,children:[p(o,{...t,id:n,placeholder:`Password`,type:r?`text`:`password`,className:l(`pe-9`,e)}),p(`button`,{className:`text-muted-foreground/80 hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 absolute inset-y-0 end-0 flex h-full w-9 items-center justify-center rounded-e-md transition-[color,box-shadow] outline-none focus:z-10 focus-visible:ring-[3px] disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,type:`button`,onClick:a,"aria-label":r?`Hide password`:`Show password`,"aria-pressed":r,"aria-controls":`password`,children:p(r?c:s,{size:16,"aria-hidden":`true`})})]})},g=({name:o,label:s=`Text Field`,placeholder:c=`Enter text here`,isShowErrorMsg:l=!1,description:u,onValueChange:d})=>p(n,{name:o,render:({field:n})=>m(r,{className:`w-full`,children:[p(i,{children:s}),p(e,{children:p(h,{placeholder:c,...n,onValueChange:d})}),!!u&&p(t,{children:u}),l&&p(a,{})]})});export{g as PasswordField};
|
|
2
2
|
//# sourceMappingURL=password-field.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../label-
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../label-CHNSlaoz.cjs`);const t=require(`../form-DyH5iWq7.cjs`),n=require(`../select-CvPIAeWb.cjs`),r=e.__toESM(require(`@customafk/react-toolkit/utils`)),i=e.__toESM(require(`react/jsx-runtime`)),a=({name:e,label:a=`Select Field`,placeholder:o=`Select an option`,disabledValues:s=[],options:c=[],isShowLabel:l=!0,isShowErrorMsg:u=!1,description:d=``,className:f=``})=>(0,i.jsx)(t.FormField,{name:e,render:({field:e})=>(0,i.jsxs)(t.FormItem,{className:(0,r.cn)(`w-full`,f),children:[l&&(0,i.jsx)(t.FormLabel,{children:a}),(0,i.jsxs)(n.Select,{defaultValue:e.value,onValueChange:e.onChange,children:[(0,i.jsx)(t.FormControl,{children:(0,i.jsx)(n.SelectTrigger,{className:`w-full`,children:(0,i.jsx)(n.SelectValue,{placeholder:o})})}),(0,i.jsx)(n.SelectContent,{children:c.map(e=>(0,i.jsx)(n.SelectItem,{disabled:s.includes(e.value),value:e.value,children:e.label},e.value))})]}),!!d&&(0,i.jsx)(t.FormDescription,{children:d}),u&&(0,i.jsx)(t.FormMessage,{})]})});exports.SelectField=a;
|
|
2
2
|
//# sourceMappingURL=select-field.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/select-field.d.ts
|
|
@@ -27,7 +27,7 @@ declare const SelectField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
27
27
|
isShowErrorMsg,
|
|
28
28
|
description,
|
|
29
29
|
className
|
|
30
|
-
}: Props<TFieldValues>) =>
|
|
30
|
+
}: Props<TFieldValues>) => react_jsx_runtime6.JSX.Element;
|
|
31
31
|
//#endregion
|
|
32
32
|
export { SelectField };
|
|
33
33
|
//# sourceMappingURL=select-field.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime8 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/select-field.d.ts
|
|
@@ -27,7 +27,7 @@ declare const SelectField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
27
27
|
isShowErrorMsg,
|
|
28
28
|
description,
|
|
29
29
|
className
|
|
30
|
-
}: Props<TFieldValues>) =>
|
|
30
|
+
}: Props<TFieldValues>) => react_jsx_runtime8.JSX.Element;
|
|
31
31
|
//#endregion
|
|
32
32
|
export { SelectField };
|
|
33
33
|
//# sourceMappingURL=select-field.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import"../label-
|
|
1
|
+
"use client";import"../label-CdrxlBJ8.js";import{FormControl as e,FormDescription as t,FormField as n,FormItem as r,FormLabel as i,FormMessage as a}from"../form-BT1TbgK6.js";import{Select as o,SelectContent as s,SelectItem as c,SelectTrigger as l,SelectValue as u}from"../select---jN6Yy0.js";import{cn as d}from"@customafk/react-toolkit/utils";import{jsx as f,jsxs as p}from"react/jsx-runtime";const m=({name:m,label:h=`Select Field`,placeholder:g=`Select an option`,disabledValues:_=[],options:v=[],isShowLabel:y=!0,isShowErrorMsg:b=!1,description:x=``,className:S=``})=>f(n,{name:m,render:({field:n})=>p(r,{className:d(`w-full`,S),children:[y&&f(i,{children:h}),p(o,{defaultValue:n.value,onValueChange:n.onChange,children:[f(e,{children:f(l,{className:`w-full`,children:f(u,{placeholder:g})})}),f(s,{children:v.map(e=>f(c,{disabled:_.includes(e.value),value:e.value,children:e.label},e.value))})]}),!!x&&f(t,{children:x}),b&&f(a,{})]})});export{m as SelectField};
|
|
2
2
|
//# sourceMappingURL=select-field.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../label-
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../label-CHNSlaoz.cjs`);const t=require(`../form-DyH5iWq7.cjs`),n=require(`../switch-BLfDkOOl.cjs`),r=e.__toESM(require(`@customafk/react-toolkit/utils`)),i=e.__toESM(require(`react/jsx-runtime`)),a=({name:e,label:a=`Switch Field`,description:o,isShowErrorMsg:s=!1})=>(0,i.jsx)(t.FormField,{name:e,render:({field:e})=>(0,i.jsxs)(`div`,{className:`spage-y-1`,children:[(0,i.jsxs)(t.FormItem,{className:(0,r.cn)(`border-border-weak flex flex-row items-center justify-between rounded-lg border p-3 shadow-xs`),children:[(0,i.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,i.jsx)(t.FormLabel,{className:`cursor-pointer text-sm`,children:a}),o&&(0,i.jsx)(t.FormDescription,{className:`text-xs`,children:o})]}),(0,i.jsx)(t.FormControl,{children:(0,i.jsx)(n.Switch,{checked:e.value,onCheckedChange:e.onChange})})]}),s&&(0,i.jsx)(t.FormMessage,{})]})});exports.SwitchField=a;
|
|
2
2
|
//# sourceMappingURL=switch-field.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/switch-field.d.ts
|
|
@@ -13,7 +13,7 @@ declare const SwitchField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
13
13
|
label,
|
|
14
14
|
description,
|
|
15
15
|
isShowErrorMsg
|
|
16
|
-
}: Props<TFieldValues>) =>
|
|
16
|
+
}: Props<TFieldValues>) => react_jsx_runtime3.JSX.Element;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { SwitchField };
|
|
19
19
|
//# sourceMappingURL=switch-field.d.cts.map
|