@customafk/lunas-ui 0.0.25 → 0.0.27
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/{alert-dialog-D-oR0YW3.cjs → alert-dialog-26JyobJb.cjs} +1 -1
- package/dist/{alert-dialog-D-oR0YW3.cjs.map → alert-dialog-26JyobJb.cjs.map} +1 -1
- package/dist/{alert-dialog-CNHyP_A9.js → alert-dialog-Dv0cgymS.js} +1 -1
- package/dist/{alert-dialog-CNHyP_A9.js.map → alert-dialog-Dv0cgymS.js.map} +1 -1
- package/dist/{button-BmBtMriU.d.ts → button-CPBLm_02.d.ts} +5 -5
- package/dist/{button-tCnJHt8O.d.cts → button-ghXW1WTr.d.cts} +5 -5
- package/dist/{calendar-CbuOOMpK.js → calendar-B66UT_fu.js} +1 -1
- package/dist/{calendar-CbuOOMpK.js.map → calendar-B66UT_fu.js.map} +1 -1
- package/dist/{calendar-B8IKzrdN.cjs → calendar-DXegnGRJ.cjs} +1 -1
- package/dist/{calendar-B8IKzrdN.cjs.map → calendar-DXegnGRJ.cjs.map} +1 -1
- package/dist/{command-Dr2XmKV6.d.cts → command-CE_Qcgo7.d.ts} +12 -12
- package/dist/{command-Dvq-HZwH.d.ts → command-CiEjoEnP.d.cts} +12 -12
- package/dist/{command-TFZwJmux.js → command-Dbkg10QA.js} +2 -2
- package/dist/{command-TFZwJmux.js.map → command-Dbkg10QA.js.map} +1 -1
- package/dist/{command-CoB5R5FI.cjs → command-IL3ogESu.cjs} +2 -2
- package/dist/{command-CoB5R5FI.cjs.map → command-IL3ogESu.cjs.map} +1 -1
- package/dist/data-display/empty.d.cts +2 -2
- package/dist/data-display/statistic.d.cts +2 -2
- package/dist/data-display/statistic.d.ts +2 -2
- package/dist/{dialog-CSDDiHKO.js → dialog-BEdMA5Lp.js} +1 -1
- package/dist/{dialog-CSDDiHKO.js.map → dialog-BEdMA5Lp.js.map} +1 -1
- package/dist/{dialog-C-DYoapJ.d.ts → dialog-Bw_T5aco.d.cts} +12 -12
- package/dist/{dialog-_Cgij9NP.cjs → dialog-C4oHnJNN.cjs} +1 -1
- package/dist/{dialog-_Cgij9NP.cjs.map → dialog-C4oHnJNN.cjs.map} +1 -1
- package/dist/{dialog-CA0E_tNX.d.cts → dialog-CoH1pTBH.d.ts} +12 -12
- package/dist/dialogs/confirm-dialog.cjs +1 -1
- package/dist/dialogs/confirm-dialog.js +1 -1
- package/dist/dialogs/detail-dialog/component/sidebar.d.cts +4 -4
- package/dist/dialogs/detail-dialog/component/sidebar.d.ts +28 -28
- package/dist/dialogs/detail-dialog/index.cjs +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/{error-dialog-D5R5le-W.cjs → error-dialog-C0PDn-pj.cjs} +2 -2
- package/dist/{error-dialog-D5R5le-W.cjs.map → error-dialog-C0PDn-pj.cjs.map} +1 -1
- package/dist/{error-dialog-Q99thrSD.js → error-dialog-CCdQ8zbQ.js} +2 -2
- package/dist/{error-dialog-Q99thrSD.js.map → error-dialog-CCdQ8zbQ.js.map} +1 -1
- package/dist/{form-wrapper-CY-stRaQ.cjs → form-wrapper-Cd8c5MIL.cjs} +2 -2
- package/dist/{form-wrapper-CY-stRaQ.cjs.map → form-wrapper-Cd8c5MIL.cjs.map} +1 -1
- package/dist/{form-wrapper-C2xlvWx0.js → form-wrapper-DntbFqN1.js} +2 -2
- package/dist/{form-wrapper-C2xlvWx0.js.map → form-wrapper-DntbFqN1.js.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.cjs.map +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.d.cts +2 -2
- package/dist/forms/number-field.d.ts +2 -2
- package/dist/forms/password-field.d.cts +2 -2
- package/dist/forms/password-field.d.ts +2 -2
- package/dist/forms/select-field.d.cts +2 -2
- package/dist/forms/select-field.d.ts +2 -2
- package/dist/forms/switch-field.d.cts +2 -2
- package/dist/forms/switch-field.d.ts +2 -2
- package/dist/forms/text-field.d.cts +2 -2
- package/dist/forms/text-field.d.ts +2 -2
- package/dist/forms/textarea-field.d.cts +2 -2
- package/dist/forms/textarea-field.d.ts +2 -2
- package/dist/{input-CjNcnHb_.d.ts → input-CUDclgoU.d.ts} +3 -3
- package/dist/{input-BsXm0_Iq.d.cts → input-y_n-XGys.d.cts} +3 -3
- package/dist/layouts/app-layout/index.d.cts +5 -5
- package/dist/layouts/app-layout/index.d.ts +3 -3
- package/dist/layouts/flex.d.cts +4 -4
- package/dist/layouts/flex.d.ts +4 -4
- package/dist/layouts/main/index.d.cts +4 -4
- package/dist/layouts/main/index.d.ts +4 -4
- package/dist/{multi-select-Cjvm4tK5.cjs → multi-select-3yxD9gbY.cjs} +2 -2
- package/dist/{multi-select-Cjvm4tK5.cjs.map → multi-select-3yxD9gbY.cjs.map} +1 -1
- package/dist/{multi-select-D0bZVOnm.js → multi-select-Cb07NlA7.js} +2 -2
- package/dist/{multi-select-D0bZVOnm.js.map → multi-select-Cb07NlA7.js.map} +1 -1
- package/dist/{popover-CTFp7ZXi.js → popover-CqAD7HNo.js} +1 -1
- package/dist/{popover-CTFp7ZXi.js.map → popover-CqAD7HNo.js.map} +1 -1
- package/dist/{popover-DCcPvdz2.cjs → popover-Dd0acCEk.cjs} +1 -1
- package/dist/{popover-DCcPvdz2.cjs.map → popover-Dd0acCEk.cjs.map} +1 -1
- package/dist/{separator-5FdzRGaJ.d.ts → separator-BLYi41aC.d.ts} +3 -3
- package/dist/{separator-DpxrpK_H.d.cts → separator-ClGBPiYE.d.cts} +3 -3
- package/dist/table/index.d.cts +2 -2
- package/dist/table/index.d.ts +2 -2
- package/dist/{toggle-Cx9H5u3p.d.cts → toggle-BWQWsKMA.d.ts} +4 -4
- package/dist/{toggle-DH9IssyE.d.ts → toggle-DnGvFJh8.d.cts} +4 -4
- package/dist/{tooltip-Djh_dcy5.d.ts → tooltip-Bk8VwHdM.d.ts} +6 -6
- package/dist/{tooltip-BAtWdJyX.d.cts → tooltip-cisSpCHG.d.cts} +6 -6
- package/dist/typography/paragraph.d.cts +2 -2
- package/dist/typography/paragraph.d.ts +2 -2
- 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 +6 -6
- package/dist/ui/aspect-ratio.d.cts +2 -2
- package/dist/ui/aspect-ratio.d.ts +2 -2
- package/dist/ui/avatar.d.cts +4 -4
- package/dist/ui/avatar.d.ts +4 -4
- package/dist/ui/badge.d.cts +2 -2
- package/dist/ui/badge.d.ts +4 -4
- 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/calendar.cjs +1 -1
- package/dist/ui/calendar.d.cts +4 -4
- package/dist/ui/calendar.d.ts +4 -4
- package/dist/ui/calendar.js +1 -1
- 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.d.cts +7 -7
- package/dist/ui/form.d.ts +7 -7
- 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 +1 -1
- package/dist/ui/inputs/search-input.d.ts +3 -3
- package/dist/ui/label.d.cts +2 -2
- package/dist/ui/label.d.ts +2 -2
- 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 +11 -11
- 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.cjs +1 -1
- package/dist/ui/popover.d.cts +5 -5
- package/dist/ui/popover.d.ts +5 -5
- package/dist/ui/popover.js +1 -1
- 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.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.d.cts +30 -30
- package/dist/ui/sidebar.d.ts +30 -30
- 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.d.cts +1 -1
- package/dist/ui/tooltip.d.ts +1 -1
- package/package.json +2 -2
- package/styles/base.css +29 -0
- package/styles/loader.css +113 -0
- package/styles/theme.css +104 -0
- package/styles/typography.css +6 -0
- package/packages/components/cards/simple-card.tsx +0 -23
- package/packages/components/data-display/country.tsx +0 -53
- package/packages/components/data-display/data-list.tsx +0 -29
- package/packages/components/data-display/date-tooltip.tsx +0 -23
- package/packages/components/data-display/date.tsx +0 -157
- package/packages/components/data-display/empty.tsx +0 -13
- package/packages/components/data-display/name.tsx +0 -23
- package/packages/components/data-display/phone-number.tsx +0 -14
- package/packages/components/data-display/role-badge.tsx +0 -29
- package/packages/components/data-display/statistic.tsx +0 -139
- package/packages/components/dialogs/confirm-dialog.tsx +0 -44
- package/packages/components/dialogs/detail-dialog/component/header.tsx +0 -10
- package/packages/components/dialogs/detail-dialog/component/main.tsx +0 -35
- package/packages/components/dialogs/detail-dialog/component/sidebar.tsx +0 -618
- package/packages/components/dialogs/detail-dialog/component/wrapper.tsx +0 -15
- package/packages/components/dialogs/detail-dialog/index.tsx +0 -91
- package/packages/components/dialogs/error-dialog.tsx +0 -34
- package/packages/components/dialogs/form-dialog.tsx +0 -74
- package/packages/components/dialogs/loading-dialog.tsx +0 -20
- package/packages/components/forms/combobox-field.tsx +0 -104
- package/packages/components/forms/date-field.tsx +0 -62
- package/packages/components/forms/form-wrapper.tsx +0 -120
- package/packages/components/forms/multi-select-field.tsx +0 -56
- package/packages/components/forms/number-field.tsx +0 -54
- package/packages/components/forms/password-field.tsx +0 -38
- package/packages/components/forms/select-field.tsx +0 -58
- package/packages/components/forms/switch-field.tsx +0 -40
- package/packages/components/forms/text-field.tsx +0 -73
- package/packages/components/forms/textarea-field.tsx +0 -45
- package/packages/components/index.tsx +0 -0
- package/packages/components/layouts/app-layout/index.tsx +0 -74
- package/packages/components/layouts/app-layout/sidebar.tsx +0 -663
- package/packages/components/layouts/flex.tsx +0 -99
- package/packages/components/layouts/main/content.tsx +0 -11
- package/packages/components/layouts/main/header.tsx +0 -41
- package/packages/components/layouts/main/index.tsx +0 -3
- package/packages/components/layouts/main/wrapper.tsx +0 -5
- package/packages/components/table/data-table-pagination.tsx +0 -70
- package/packages/components/table/data-table.tsx +0 -241
- package/packages/components/table/index.tsx +0 -107
- package/packages/components/typography/paragraph.tsx +0 -29
- package/packages/components/typography/title.tsx +0 -31
- package/packages/components/ui/alert-dialog.tsx +0 -99
- package/packages/components/ui/alert.tsx +0 -44
- package/packages/components/ui/aspect-ratio.tsx +0 -11
- package/packages/components/ui/avatar.tsx +0 -25
- package/packages/components/ui/badge.tsx +0 -57
- package/packages/components/ui/breadcrumb.tsx +0 -74
- package/packages/components/ui/button.tsx +0 -205
- package/packages/components/ui/buttons/add-new.tsx +0 -19
- package/packages/components/ui/buttons/edit.tsx +0 -14
- package/packages/components/ui/buttons/refresh.tsx +0 -19
- package/packages/components/ui/buttons/trash.tsx +0 -14
- package/packages/components/ui/buttons/upload-image.tsx +0 -25
- package/packages/components/ui/calendar.tsx +0 -141
- package/packages/components/ui/card.tsx +0 -44
- package/packages/components/ui/carousel.tsx +0 -187
- package/packages/components/ui/checkbox.tsx +0 -34
- package/packages/components/ui/collapsible.tsx +0 -17
- package/packages/components/ui/command.tsx +0 -138
- package/packages/components/ui/context-menu.tsx +0 -196
- package/packages/components/ui/dialog.tsx +0 -119
- package/packages/components/ui/dropdown-menu.tsx +0 -249
- package/packages/components/ui/file-uploader.tsx +0 -314
- package/packages/components/ui/form.tsx +0 -104
- package/packages/components/ui/hover-card.tsx +0 -32
- package/packages/components/ui/input-otp.tsx +0 -67
- package/packages/components/ui/input.tsx +0 -59
- package/packages/components/ui/inputs/number-input.tsx +0 -317
- package/packages/components/ui/inputs/password-input.tsx +0 -29
- package/packages/components/ui/inputs/search-input.tsx +0 -24
- package/packages/components/ui/label.tsx +0 -26
- package/packages/components/ui/menubar.tsx +0 -212
- package/packages/components/ui/multi-select.tsx +0 -626
- package/packages/components/ui/navigation-menu.tsx +0 -124
- package/packages/components/ui/pagination.tsx +0 -70
- package/packages/components/ui/popover.tsx +0 -49
- package/packages/components/ui/progress.tsx +0 -19
- package/packages/components/ui/radio-group.tsx +0 -36
- package/packages/components/ui/resizable.tsx +0 -47
- package/packages/components/ui/scroll-area.tsx +0 -35
- package/packages/components/ui/select.tsx +0 -199
- package/packages/components/ui/separator.tsx +0 -25
- package/packages/components/ui/sheet.tsx +0 -119
- package/packages/components/ui/sidebar.tsx +0 -675
- package/packages/components/ui/skeleton.tsx +0 -8
- package/packages/components/ui/slider.tsx +0 -45
- package/packages/components/ui/sonner.tsx +0 -40
- package/packages/components/ui/switch.tsx +0 -46
- package/packages/components/ui/table.tsx +0 -66
- package/packages/components/ui/tabs.tsx +0 -53
- package/packages/components/ui/textarea.tsx +0 -46
- package/packages/components/ui/toggle-group.tsx +0 -63
- package/packages/components/ui/toggle.tsx +0 -34
- package/packages/components/ui/tooltip.tsx +0 -53
- package/packages/constants.tsx +0 -45
- package/packages/hooks/use-callback-ref.ts +0 -22
- package/packages/hooks/use-controllable-state.ts +0 -58
- package/packages/hooks/use-mobile.ts +0 -19
- package/packages/index.css +0 -133
- package/packages/lib/utils.ts +0 -24
- package/packages/stories/1.Guideline.mdx +0 -3
- package/packages/stories/2.Colors.mdx +0 -145
- package/packages/stories/3.Pypography.mdx +0 -51
- package/packages/stories/cards/simple-card.stories.tsx +0 -24
- package/packages/stories/data-display/data-list.stories.tsx +0 -22
- package/packages/stories/data-display/empty.stories.tsx +0 -13
- package/packages/stories/data-display/form-dialog.stories.tsx +0 -27
- package/packages/stories/data-display/name.stories.tsx +0 -25
- package/packages/stories/data-display/phone-number.stories.tsx +0 -17
- package/packages/stories/data-display/statistic.stories.tsx +0 -41
- package/packages/stories/dialogs/confirm-dialog.stories.tsx +0 -26
- package/packages/stories/dialogs/detail-dialog.stories.tsx +0 -34
- package/packages/stories/dialogs/error-dialog.stories.tsx +0 -27
- package/packages/stories/dialogs/loading-dialog.stories.tsx +0 -16
- package/packages/stories/forms/combobox-field.stories.tsx +0 -38
- package/packages/stories/forms/form-wrapper.stories.tsx +0 -59
- package/packages/stories/forms/multi-select-field.stories.tsx +0 -42
- package/packages/stories/forms/number-field.stories.tsx +0 -35
- package/packages/stories/forms/select-field.stories.tsx +0 -39
- package/packages/stories/forms/switch-field.stories.tsx +0 -36
- package/packages/stories/forms/text-field.stories.tsx +0 -41
- package/packages/stories/forms/textarea-field.stories.tsx +0 -34
- package/packages/stories/layouts/app-layout.stories.tsx +0 -49
- package/packages/stories/typography/paragraph.stories.tsx +0 -45
- package/packages/stories/typography/title.stories.tsx +0 -39
- package/packages/stories/ui/alert-dialog.stories.tsx +0 -49
- package/packages/stories/ui/alert.stories.tsx +0 -63
- package/packages/stories/ui/aspect-ratio.stories.tsx +0 -22
- package/packages/stories/ui/badge.stories.tsx +0 -170
- package/packages/stories/ui/breadcrumb.stories.tsx +0 -172
- package/packages/stories/ui/button.stories.tsx +0 -181
- package/packages/stories/ui/card.stories.tsx +0 -58
- package/packages/stories/ui/checkbox.stories.tsx +0 -48
- package/packages/stories/ui/command.stories.tsx +0 -58
- package/packages/stories/ui/dialog.stories.tsx +0 -55
- package/packages/stories/ui/dropdown-menu.stories.tsx +0 -89
- package/packages/stories/ui/file-uploader.stories.tsx +0 -18
- package/packages/stories/ui/input.stories.tsx +0 -38
- package/packages/stories/ui/label.stories.tsx +0 -17
- package/packages/stories/ui/multi-select.stories.tsx +0 -29
- package/packages/stories/ui/popover.stories.tsx +0 -52
- package/packages/stories/ui/progress.stories.tsx +0 -17
- package/packages/stories/ui/radio-group.stories.tsx +0 -31
- package/packages/stories/ui/select.stories.tsx +0 -31
- package/packages/stories/ui/separator.stories.tsx +0 -31
- package/packages/stories/ui/sheet.stories.tsx +0 -50
- package/packages/stories/ui/skeleton.stories.tsx +0 -27
- package/packages/stories/ui/switch.stories.tsx +0 -21
- package/packages/stories/ui/table.stories.tsx +0 -82
- package/packages/stories/ui/tabs.stories.tsx +0 -70
- package/packages/stories/ui/textarea.stories.tsx +0 -15
- package/packages/stories/ui/toaster.stories.tsx +0 -87
- package/packages/types.ts +0 -50
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { CatIcon } from 'lucide-react'
|
|
2
|
-
|
|
3
|
-
import { Flex } from '@/components/layouts/flex'
|
|
4
|
-
import { Dialog } from '@/components/ui/dialog'
|
|
5
|
-
|
|
6
|
-
import { DetailDialogHeader } from './component/header'
|
|
7
|
-
import { DetailDialogMain, DetailDialogMainHeader } from './component/main'
|
|
8
|
-
import {
|
|
9
|
-
Sidebar,
|
|
10
|
-
SidebarContent,
|
|
11
|
-
SidebarFooter,
|
|
12
|
-
SidebarGroup,
|
|
13
|
-
SidebarHeader,
|
|
14
|
-
SidebarMenu,
|
|
15
|
-
SidebarMenuButton,
|
|
16
|
-
SidebarMenuItem,
|
|
17
|
-
SidebarProvider,
|
|
18
|
-
} from './component/sidebar'
|
|
19
|
-
import { DetailDialogWrapper } from './component/wrapper'
|
|
20
|
-
|
|
21
|
-
const DetailDialogSidebar: React.FC<React.PropsWithChildren<{ title?: string; sidebarFooter?: React.ReactNode }>> = ({ title, sidebarFooter, children }) => {
|
|
22
|
-
return (
|
|
23
|
-
<Sidebar collapsible="icon" className="border-border-weak hidden border-r md:flex">
|
|
24
|
-
<SidebarHeader>
|
|
25
|
-
<SidebarMenu>
|
|
26
|
-
<SidebarMenuItem>
|
|
27
|
-
<SidebarMenuButton size="lg" tabIndex={-1}>
|
|
28
|
-
<div className="bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg">
|
|
29
|
-
<CatIcon size={16} />
|
|
30
|
-
</div>
|
|
31
|
-
<div className="grid flex-1 text-left text-sm leading-tight">
|
|
32
|
-
<span className="truncate font-medium">{title || 'Detail Dialog'}</span>
|
|
33
|
-
<span className="truncate text-xs">Lunas Enterprise</span>
|
|
34
|
-
</div>
|
|
35
|
-
</SidebarMenuButton>
|
|
36
|
-
</SidebarMenuItem>
|
|
37
|
-
</SidebarMenu>
|
|
38
|
-
</SidebarHeader>
|
|
39
|
-
<SidebarContent>
|
|
40
|
-
<SidebarGroup>{children}</SidebarGroup>
|
|
41
|
-
</SidebarContent>
|
|
42
|
-
{sidebarFooter && <SidebarFooter>{sidebarFooter}</SidebarFooter>}
|
|
43
|
-
</Sidebar>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
type Props = {
|
|
48
|
-
open?: boolean
|
|
49
|
-
isLoading?: boolean
|
|
50
|
-
sidebarTitle?: string
|
|
51
|
-
sidebar?: React.ReactNode
|
|
52
|
-
sidebarFooter?: React.ReactNode
|
|
53
|
-
title: string
|
|
54
|
-
createdAt: string | Date | number
|
|
55
|
-
onOpenChange?: (open: boolean) => void | Promise<void>
|
|
56
|
-
}
|
|
57
|
-
export const DetailDialog: React.FC<React.PropsWithChildren<Props>> = ({
|
|
58
|
-
open,
|
|
59
|
-
isLoading = false,
|
|
60
|
-
sidebarTitle,
|
|
61
|
-
sidebar,
|
|
62
|
-
sidebarFooter,
|
|
63
|
-
title,
|
|
64
|
-
createdAt,
|
|
65
|
-
onOpenChange,
|
|
66
|
-
children,
|
|
67
|
-
}) => {
|
|
68
|
-
return (
|
|
69
|
-
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
70
|
-
<DetailDialogWrapper>
|
|
71
|
-
<DetailDialogHeader />
|
|
72
|
-
|
|
73
|
-
<SidebarProvider className="h-full min-h-[85svh] items-start">
|
|
74
|
-
<DetailDialogSidebar title={sidebarTitle} sidebarFooter={sidebarFooter}>
|
|
75
|
-
{sidebar}
|
|
76
|
-
</DetailDialogSidebar>
|
|
77
|
-
<DetailDialogMain>
|
|
78
|
-
<DetailDialogMainHeader title={title} createdAt={createdAt} />
|
|
79
|
-
{isLoading ? (
|
|
80
|
-
<Flex justify="center" className="bg-muted-muted/20 size-full">
|
|
81
|
-
<div className="loader" />
|
|
82
|
-
</Flex>
|
|
83
|
-
) : (
|
|
84
|
-
<section className="bg-muted-muted/20 relative flex-1 overflow-y-auto inset-shadow-sm">{children}</section>
|
|
85
|
-
)}
|
|
86
|
-
</DetailDialogMain>
|
|
87
|
-
</SidebarProvider>
|
|
88
|
-
</DetailDialogWrapper>
|
|
89
|
-
</Dialog>
|
|
90
|
-
)
|
|
91
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { AlertTriangleIcon } from 'lucide-react'
|
|
3
|
-
|
|
4
|
-
import { AlertDialog, AlertDialogAction, AlertDialogContent, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from '../ui/alert-dialog'
|
|
5
|
-
|
|
6
|
-
type Props = {
|
|
7
|
-
open?: boolean
|
|
8
|
-
title?: string
|
|
9
|
-
description?: string
|
|
10
|
-
onOpenChange?: (open: boolean) => void
|
|
11
|
-
}
|
|
12
|
-
export const ErrorDialog: React.FC<React.PropsWithChildren<Props>> = ({ open, title, children, onOpenChange }) => {
|
|
13
|
-
const handleClose = React.useCallback(() => {
|
|
14
|
-
onOpenChange?.(false)
|
|
15
|
-
}, [onOpenChange])
|
|
16
|
-
return (
|
|
17
|
-
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
|
18
|
-
<AlertDialogContent className="gap-8 p-4 sm:max-w-md">
|
|
19
|
-
<AlertDialogHeader>
|
|
20
|
-
<div className="text-destructive flex flex-col items-center">
|
|
21
|
-
<AlertTriangleIcon size={42} />
|
|
22
|
-
<AlertDialogTitle className="text-xl font-medium">{title || 'An error occurred'}</AlertDialogTitle>
|
|
23
|
-
</div>
|
|
24
|
-
</AlertDialogHeader>
|
|
25
|
-
{children}
|
|
26
|
-
<AlertDialogFooter>
|
|
27
|
-
<AlertDialogAction className="w-28" onClick={handleClose}>
|
|
28
|
-
Đóng
|
|
29
|
-
</AlertDialogAction>
|
|
30
|
-
</AlertDialogFooter>
|
|
31
|
-
</AlertDialogContent>
|
|
32
|
-
</AlertDialog>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { FieldValues, FormState, SubmitErrorHandler, UseFormProps } from 'react-hook-form'
|
|
2
|
-
|
|
3
|
-
import { cn } from '@/lib/utils'
|
|
4
|
-
|
|
5
|
-
import { FormWrapper } from '../forms/form-wrapper'
|
|
6
|
-
import { Button } from '../ui/button'
|
|
7
|
-
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '../ui/dialog'
|
|
8
|
-
|
|
9
|
-
type Props<TFieldValues extends FieldValues = FieldValues> = {
|
|
10
|
-
form: UseFormProps<TFieldValues>
|
|
11
|
-
|
|
12
|
-
open: boolean
|
|
13
|
-
isSubmitting?: boolean
|
|
14
|
-
isResetAfterSubmit?: boolean
|
|
15
|
-
disableSubmit?: boolean
|
|
16
|
-
title?: string
|
|
17
|
-
description?: string
|
|
18
|
-
className?: string
|
|
19
|
-
|
|
20
|
-
onOpenChange: (open: boolean) => void
|
|
21
|
-
onSubmit: (data: TFieldValues, formState: FormState<FieldValues>, dirtyFields: FormState<FieldValues>['dirtyFields']) => void | Promise<void>
|
|
22
|
-
onError?: SubmitErrorHandler<TFieldValues>
|
|
23
|
-
onReset?: () => void
|
|
24
|
-
}
|
|
25
|
-
export const FormDialog = <TFieldValues extends FieldValues = FieldValues>({
|
|
26
|
-
form,
|
|
27
|
-
open,
|
|
28
|
-
isSubmitting = false,
|
|
29
|
-
isResetAfterSubmit = true,
|
|
30
|
-
disableSubmit = false,
|
|
31
|
-
title,
|
|
32
|
-
description,
|
|
33
|
-
className,
|
|
34
|
-
|
|
35
|
-
onOpenChange,
|
|
36
|
-
onSubmit,
|
|
37
|
-
onError,
|
|
38
|
-
onReset,
|
|
39
|
-
children,
|
|
40
|
-
}: React.PropsWithChildren<Props<TFieldValues>>) => {
|
|
41
|
-
return (
|
|
42
|
-
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
43
|
-
<DialogContent
|
|
44
|
-
className={cn('flex flex-col gap-0 border-none p-0', className)}
|
|
45
|
-
onInteractOutside={(e) => {
|
|
46
|
-
e.preventDefault()
|
|
47
|
-
e.stopPropagation()
|
|
48
|
-
}}
|
|
49
|
-
>
|
|
50
|
-
<DialogHeader className="flex-0 gap-2 border-b px-6 pt-6 pb-4">
|
|
51
|
-
<DialogTitle>{title || 'Form Dialog'}</DialogTitle>
|
|
52
|
-
<DialogDescription>{description || 'This is a form dialog where you can add your form elements.'}</DialogDescription>
|
|
53
|
-
</DialogHeader>
|
|
54
|
-
<FormWrapper
|
|
55
|
-
form={form}
|
|
56
|
-
isResetAfterSubmit={isResetAfterSubmit}
|
|
57
|
-
className="flex flex-1 flex-col overflow-y-auto pt-4"
|
|
58
|
-
onSubmit={onSubmit}
|
|
59
|
-
onError={onError}
|
|
60
|
-
>
|
|
61
|
-
<main className="flex-1 overflow-y-auto px-6">{children}</main>
|
|
62
|
-
<DialogFooter className="border-t px-6 pt-4 pb-6">
|
|
63
|
-
<Button tabIndex={-1} type="button" variant="outline" color="muted" className="w-30 rounded-full" onClick={onReset}>
|
|
64
|
-
Reset
|
|
65
|
-
</Button>
|
|
66
|
-
<Button autoFocus tabIndex={0} type="submit" isLoading={isSubmitting} disabled={disableSubmit} className="w-30 rounded-full">
|
|
67
|
-
Xác nhận
|
|
68
|
-
</Button>
|
|
69
|
-
</DialogFooter>
|
|
70
|
-
</FormWrapper>
|
|
71
|
-
</DialogContent>
|
|
72
|
-
</Dialog>
|
|
73
|
-
)
|
|
74
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
|
|
3
|
-
import { Dialog, DialogContent, DialogTitle } from '../ui/dialog'
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
open?: boolean
|
|
7
|
-
onOpenChange?: (open: boolean) => void
|
|
8
|
-
}
|
|
9
|
-
export const LoadingDialog: React.FC<Props> = ({ open, onOpenChange }) => {
|
|
10
|
-
return (
|
|
11
|
-
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
12
|
-
<DialogContent showCloseButton={false} className="pointer-events-none border-none bg-transparent shadow-none outline-0 [&>div]:bg-transparent">
|
|
13
|
-
<DialogTitle />
|
|
14
|
-
<div className="flex items-center justify-center">
|
|
15
|
-
<div className="loader opacity-60" />
|
|
16
|
-
</div>
|
|
17
|
-
</DialogContent>
|
|
18
|
-
</Dialog>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import type { FieldPath, FieldValues } from 'react-hook-form'
|
|
4
|
-
import { ChevronDownIcon, PlusIcon } from 'lucide-react'
|
|
5
|
-
|
|
6
|
-
import { Button } from '@/components/ui/button'
|
|
7
|
-
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from '@/components/ui/command'
|
|
8
|
-
import { FormControl, FormDescription, FormField, FormItem, FormLabel } from '@/components/ui/form'
|
|
9
|
-
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
|
10
|
-
import { cn } from '@/lib/utils'
|
|
11
|
-
|
|
12
|
-
type Props<TFieldValues extends FieldValues = FieldValues> = {
|
|
13
|
-
name: FieldPath<TFieldValues>
|
|
14
|
-
label?: string
|
|
15
|
-
placeholder?: string
|
|
16
|
-
options?: { value: string | number; label: string }[]
|
|
17
|
-
isShowErrorMsg?: boolean
|
|
18
|
-
modal?: boolean
|
|
19
|
-
description?: string
|
|
20
|
-
onAddNewItem?: () => void
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const ComboboxField = <TFieldValues extends FieldValues = FieldValues>({
|
|
24
|
-
name,
|
|
25
|
-
label = 'Combobox',
|
|
26
|
-
placeholder = 'Chọn một mục',
|
|
27
|
-
description,
|
|
28
|
-
options,
|
|
29
|
-
onAddNewItem,
|
|
30
|
-
}: Props<TFieldValues>) => {
|
|
31
|
-
return (
|
|
32
|
-
<FormField
|
|
33
|
-
name={name}
|
|
34
|
-
render={({ field }) => {
|
|
35
|
-
return (
|
|
36
|
-
<FormItem className="w-full">
|
|
37
|
-
<FormLabel>{label}</FormLabel>
|
|
38
|
-
<Popover modal={true}>
|
|
39
|
-
<PopoverTrigger asChild>
|
|
40
|
-
<FormControl>
|
|
41
|
-
<Button
|
|
42
|
-
type="button"
|
|
43
|
-
variant="outline"
|
|
44
|
-
role="combobox"
|
|
45
|
-
color="muted"
|
|
46
|
-
className={cn(
|
|
47
|
-
'flex justify-between rounded-md px-3',
|
|
48
|
-
'outline-border-weak font-normal',
|
|
49
|
-
'[&_div]:justify-between',
|
|
50
|
-
'data-[state=open]:border-primary-strong',
|
|
51
|
-
'data-[state=open]:outline-1',
|
|
52
|
-
'data-[state=open]:outline-primary-strong',
|
|
53
|
-
'data-[state=open]:ring-primary-weak',
|
|
54
|
-
'data-[state=open]:ring-4',
|
|
55
|
-
'focus:border-primary-strong',
|
|
56
|
-
'focus:ring-4',
|
|
57
|
-
'focus:ring-primary-weak',
|
|
58
|
-
'focus:outline-1',
|
|
59
|
-
'focus:outline-primary-strong',
|
|
60
|
-
)}
|
|
61
|
-
>
|
|
62
|
-
{field.value ? (
|
|
63
|
-
<span className="flex min-w-0 items-center gap-2">{options?.find(({ value }) => value === field.value)?.label}</span>
|
|
64
|
-
) : (
|
|
65
|
-
<span className="text-text-positive-muted">{placeholder}</span>
|
|
66
|
-
)}
|
|
67
|
-
<ChevronDownIcon size={16} className="text-text-positive-weak shrink-0" aria-hidden="true" />
|
|
68
|
-
</Button>
|
|
69
|
-
</FormControl>
|
|
70
|
-
</PopoverTrigger>
|
|
71
|
-
<PopoverContent className="border-input w-full max-w-[var(--radix-popover-trigger-width)] p-0">
|
|
72
|
-
<Command>
|
|
73
|
-
<CommandInput placeholder={placeholder ?? 'Tìm kiếm'} />
|
|
74
|
-
<CommandList>
|
|
75
|
-
<CommandGroup className="max-h-40 overflow-y-auto">
|
|
76
|
-
{options?.map(({ value, label }) => (
|
|
77
|
-
<CommandItem key={value} value={label} onSelect={() => field.onChange(value)}>
|
|
78
|
-
{label}
|
|
79
|
-
</CommandItem>
|
|
80
|
-
))}
|
|
81
|
-
</CommandGroup>
|
|
82
|
-
{onAddNewItem && (
|
|
83
|
-
<React.Fragment>
|
|
84
|
-
<CommandSeparator />
|
|
85
|
-
<CommandGroup>
|
|
86
|
-
<Button type="button" variant="ghost" className="w-full justify-start font-normal">
|
|
87
|
-
<PlusIcon size={14} className="-ms-2 opacity-60" aria-hidden="true" />
|
|
88
|
-
Thêm mới
|
|
89
|
-
</Button>
|
|
90
|
-
</CommandGroup>
|
|
91
|
-
</React.Fragment>
|
|
92
|
-
)}
|
|
93
|
-
</CommandList>
|
|
94
|
-
<CommandEmpty>Không có kết quả</CommandEmpty>
|
|
95
|
-
</Command>
|
|
96
|
-
</PopoverContent>
|
|
97
|
-
</Popover>
|
|
98
|
-
{!!description && <FormDescription>{description}</FormDescription>}
|
|
99
|
-
</FormItem>
|
|
100
|
-
)
|
|
101
|
-
}}
|
|
102
|
-
/>
|
|
103
|
-
)
|
|
104
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import type { FieldPath, FieldValues } from 'react-hook-form'
|
|
3
|
-
import { format } from 'date-fns'
|
|
4
|
-
import { CalendarIcon } from 'lucide-react'
|
|
5
|
-
|
|
6
|
-
import { cn } from '@/lib/utils'
|
|
7
|
-
|
|
8
|
-
import { Button } from '../ui/button'
|
|
9
|
-
import { Calendar } from '../ui/calendar'
|
|
10
|
-
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'
|
|
11
|
-
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
|
|
12
|
-
|
|
13
|
-
type Props<TFieldValues extends FieldValues = FieldValues> = {
|
|
14
|
-
name: FieldPath<TFieldValues>
|
|
15
|
-
label?: string
|
|
16
|
-
placeholder?: string
|
|
17
|
-
description?: string
|
|
18
|
-
isShowErrorMsg?: boolean
|
|
19
|
-
modal?: boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const DateField = <TFieldValues extends FieldValues = FieldValues>({
|
|
23
|
-
name,
|
|
24
|
-
label = 'Date Field',
|
|
25
|
-
placeholder = 'Select a date',
|
|
26
|
-
description = '',
|
|
27
|
-
isShowErrorMsg = false,
|
|
28
|
-
}: Props<TFieldValues>) => {
|
|
29
|
-
return (
|
|
30
|
-
<FormField
|
|
31
|
-
name={name}
|
|
32
|
-
render={({ field }) => (
|
|
33
|
-
<FormItem className="w-full">
|
|
34
|
-
<FormLabel>{label}</FormLabel>
|
|
35
|
-
<Popover modal>
|
|
36
|
-
<PopoverTrigger asChild>
|
|
37
|
-
<FormControl>
|
|
38
|
-
<Button variant="outline" className={cn('w-full pl-3 text-left font-normal', !field.value && 'text-muted-foreground')}>
|
|
39
|
-
{field.value ? format(field.value, 'PPP') : <span> {placeholder || 'Pick a date'}</span>}
|
|
40
|
-
<CalendarIcon className="ml-auto size-4 opacity-50" />
|
|
41
|
-
</Button>
|
|
42
|
-
</FormControl>
|
|
43
|
-
</PopoverTrigger>
|
|
44
|
-
<PopoverContent className="w-auto p-0" align="start">
|
|
45
|
-
<Calendar
|
|
46
|
-
mode="single"
|
|
47
|
-
selected={field.value}
|
|
48
|
-
onSelect={(date) => {
|
|
49
|
-
field.onChange(date?.toISOString())
|
|
50
|
-
}}
|
|
51
|
-
captionLayout="dropdown"
|
|
52
|
-
disabled={(date) => date < new Date('2022-01-01')}
|
|
53
|
-
/>
|
|
54
|
-
</PopoverContent>
|
|
55
|
-
</Popover>
|
|
56
|
-
{!!description && <FormDescription>{description}</FormDescription>}
|
|
57
|
-
{isShowErrorMsg && <FormMessage />}
|
|
58
|
-
</FormItem>
|
|
59
|
-
)}
|
|
60
|
-
/>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { type FieldValues, type FormState, type SubmitErrorHandler, type SubmitHandler, useForm, type UseFormProps } from 'react-hook-form'
|
|
3
|
-
import { AlertCircleIcon } from 'lucide-react'
|
|
4
|
-
|
|
5
|
-
import type { AnyEntity } from '@/types'
|
|
6
|
-
import { ErrorMessage } from '@hookform/error-message'
|
|
7
|
-
|
|
8
|
-
import { ErrorDialog } from '../dialogs/error-dialog'
|
|
9
|
-
import { Form } from '../ui/form'
|
|
10
|
-
|
|
11
|
-
type Props<TFieldValues extends FieldValues = FieldValues> = {
|
|
12
|
-
form: UseFormProps<TFieldValues>
|
|
13
|
-
isResetAfterSubmit?: boolean
|
|
14
|
-
className?: string
|
|
15
|
-
onSubmit: (data: TFieldValues, formState: FormState<FieldValues>, dirtyFields: FormState<FieldValues>['dirtyFields']) => void | Promise<void>
|
|
16
|
-
onError?: SubmitErrorHandler<TFieldValues>
|
|
17
|
-
onSubcribe?: (values: TFieldValues) => void
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const FormWrapper = <TFieldValues extends FieldValues = FieldValues>({
|
|
21
|
-
form: FormConfig,
|
|
22
|
-
isResetAfterSubmit = true,
|
|
23
|
-
className,
|
|
24
|
-
onSubmit,
|
|
25
|
-
onError,
|
|
26
|
-
onSubcribe,
|
|
27
|
-
children,
|
|
28
|
-
}: React.PropsWithChildren<Props<TFieldValues>>) => {
|
|
29
|
-
const form = useForm({
|
|
30
|
-
...FormConfig,
|
|
31
|
-
criteriaMode: 'all',
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
const { formState, reset, handleSubmit, subscribe } = form
|
|
35
|
-
const { dirtyFields } = formState
|
|
36
|
-
|
|
37
|
-
const [errorOpen, setErrorOpen] = React.useState<boolean>(false)
|
|
38
|
-
|
|
39
|
-
const handleFormSubmit = React.useCallback<SubmitHandler<TFieldValues>>(
|
|
40
|
-
(data) => {
|
|
41
|
-
onSubmit(data, formState, dirtyFields)
|
|
42
|
-
if (isResetAfterSubmit) {
|
|
43
|
-
reset()
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
[dirtyFields, formState, isResetAfterSubmit, onSubmit, reset],
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
const handleFormError = React.useCallback<SubmitErrorHandler<TFieldValues>>(
|
|
50
|
-
(errors) => {
|
|
51
|
-
const errorKeys = Object.keys(errors)
|
|
52
|
-
if (errorKeys.length === 0) return
|
|
53
|
-
onError?.(errors)
|
|
54
|
-
setErrorOpen(true)
|
|
55
|
-
},
|
|
56
|
-
[onError],
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
React.useEffect(() => {
|
|
60
|
-
if (!onSubcribe) return
|
|
61
|
-
const callback = subscribe({
|
|
62
|
-
formState: { values: true },
|
|
63
|
-
callback: ({ values }) => {
|
|
64
|
-
onSubcribe(values)
|
|
65
|
-
},
|
|
66
|
-
})
|
|
67
|
-
return () => callback()
|
|
68
|
-
}, [onSubcribe, subscribe])
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<Form {...form}>
|
|
72
|
-
<form className={className} onSubmit={handleSubmit(handleFormSubmit, handleFormError)}>
|
|
73
|
-
{children}
|
|
74
|
-
</form>
|
|
75
|
-
<ErrorDialog
|
|
76
|
-
open={errorOpen}
|
|
77
|
-
title="Lỗi nhập dữ liệu"
|
|
78
|
-
description="An unexpected error has occurred. Please check the errors below and try again."
|
|
79
|
-
onOpenChange={setErrorOpen}
|
|
80
|
-
>
|
|
81
|
-
{errorOpen && (
|
|
82
|
-
<>
|
|
83
|
-
{Object.keys(formState.errors).length > 0 ? (
|
|
84
|
-
<div className="flex max-w-100 flex-col gap-2 px-4">
|
|
85
|
-
<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>
|
|
86
|
-
<div className="flex flex-col space-y-1">
|
|
87
|
-
{Object.entries(formState.errors).map(([key]) => (
|
|
88
|
-
<ErrorMessage
|
|
89
|
-
key={key}
|
|
90
|
-
errors={formState.errors}
|
|
91
|
-
name={key as AnyEntity}
|
|
92
|
-
render={({ messages }) => {
|
|
93
|
-
return (
|
|
94
|
-
<>
|
|
95
|
-
{messages
|
|
96
|
-
? Object.entries(messages).map(([type, message]) => {
|
|
97
|
-
return (
|
|
98
|
-
<div key={type} className="text-accent-foreground flex items-start gap-x-1 truncate text-sm font-normal">
|
|
99
|
-
<AlertCircleIcon size={16} className="text-destructive mt-0.5 min-w-4 flex-0" />
|
|
100
|
-
<p className="line-clamp-2 flex-1 text-wrap">{message}</p>
|
|
101
|
-
</div>
|
|
102
|
-
)
|
|
103
|
-
})
|
|
104
|
-
: null}
|
|
105
|
-
</>
|
|
106
|
-
)
|
|
107
|
-
}}
|
|
108
|
-
/>
|
|
109
|
-
))}
|
|
110
|
-
</div>
|
|
111
|
-
</div>
|
|
112
|
-
) : (
|
|
113
|
-
<p className="text-muted-foreground text-sm">No errors found.</p>
|
|
114
|
-
)}
|
|
115
|
-
</>
|
|
116
|
-
)}
|
|
117
|
-
</ErrorDialog>
|
|
118
|
-
</Form>
|
|
119
|
-
)
|
|
120
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import type { FieldPath, FieldValues } from 'react-hook-form'
|
|
3
|
-
|
|
4
|
-
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'
|
|
5
|
-
import { type Option, MultipleSelector } from '../ui/multi-select'
|
|
6
|
-
|
|
7
|
-
type Props<TFieldValues extends FieldValues = FieldValues> = {
|
|
8
|
-
name: FieldPath<TFieldValues>
|
|
9
|
-
isShowLabel?: boolean
|
|
10
|
-
isShowErrorMsg?: boolean
|
|
11
|
-
label?: string
|
|
12
|
-
description?: string
|
|
13
|
-
placeholder?: string
|
|
14
|
-
options?: { value: string; label: string }[]
|
|
15
|
-
onAdd?: () => void
|
|
16
|
-
}
|
|
17
|
-
export const MultiSelectField = <TFieldValues extends FieldValues = FieldValues>({
|
|
18
|
-
name,
|
|
19
|
-
label = 'Multi Select Field',
|
|
20
|
-
isShowLabel = true,
|
|
21
|
-
isShowErrorMsg,
|
|
22
|
-
placeholder = 'Select options',
|
|
23
|
-
description = '',
|
|
24
|
-
options = [],
|
|
25
|
-
onAdd,
|
|
26
|
-
}: Props<TFieldValues>) => {
|
|
27
|
-
return (
|
|
28
|
-
<FormField
|
|
29
|
-
name={name}
|
|
30
|
-
render={({ field: { value, onChange } }) => {
|
|
31
|
-
const val = options.filter((option) => value?.includes(option.value))
|
|
32
|
-
const handleOnChange = (value: Option[]) => {
|
|
33
|
-
const selectedValues = value.map((v) => v.value)
|
|
34
|
-
onChange(selectedValues)
|
|
35
|
-
}
|
|
36
|
-
return (
|
|
37
|
-
<FormItem className="w-full gap-0">
|
|
38
|
-
{isShowLabel && <FormLabel>{label}</FormLabel>}
|
|
39
|
-
<FormControl>
|
|
40
|
-
<MultipleSelector
|
|
41
|
-
placeholder={placeholder}
|
|
42
|
-
emptyIndicator="No options available"
|
|
43
|
-
value={val}
|
|
44
|
-
options={options}
|
|
45
|
-
onChange={handleOnChange}
|
|
46
|
-
onAddNewItem={onAdd}
|
|
47
|
-
/>
|
|
48
|
-
</FormControl>
|
|
49
|
-
{!!description && <FormDescription>{description}</FormDescription>}
|
|
50
|
-
{isShowErrorMsg && <FormMessage />}
|
|
51
|
-
</FormItem>
|
|
52
|
-
)
|
|
53
|
-
}}
|
|
54
|
-
/>
|
|
55
|
-
)
|
|
56
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { type FieldPath, type FieldValues, useWatch } from 'react-hook-form'
|
|
2
|
-
|
|
3
|
-
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'
|
|
4
|
-
import { NumberInput } from '../ui/inputs/number-input'
|
|
5
|
-
|
|
6
|
-
type Props<TFieldValues extends FieldValues = FieldValues> = {
|
|
7
|
-
name: FieldPath<TFieldValues>
|
|
8
|
-
label?: string
|
|
9
|
-
description?: string
|
|
10
|
-
placeholder?: string
|
|
11
|
-
unitText?: string
|
|
12
|
-
isShowClearButton?: boolean
|
|
13
|
-
isShowErrorMsg?: boolean
|
|
14
|
-
isShowCount?: boolean
|
|
15
|
-
onValueChange?: (value?: number) => void
|
|
16
|
-
}
|
|
17
|
-
export const NumberField = <TFieldValues extends FieldValues = FieldValues>({
|
|
18
|
-
name,
|
|
19
|
-
label = 'Number Field',
|
|
20
|
-
placeholder = '0',
|
|
21
|
-
isShowErrorMsg = false,
|
|
22
|
-
isShowCount = false,
|
|
23
|
-
unitText = '',
|
|
24
|
-
description = '',
|
|
25
|
-
onValueChange,
|
|
26
|
-
}: Props<TFieldValues>) => {
|
|
27
|
-
const valueWatch = useWatch({ name })
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<FormField
|
|
31
|
-
name={name}
|
|
32
|
-
render={({ field: { onChange, ...field } }) => (
|
|
33
|
-
<FormItem className="w-full gap-0">
|
|
34
|
-
<FormLabel>{label}</FormLabel>
|
|
35
|
-
<FormControl>
|
|
36
|
-
<NumberInput
|
|
37
|
-
{...field}
|
|
38
|
-
placeholder={placeholder}
|
|
39
|
-
className="w-full"
|
|
40
|
-
unitText={unitText}
|
|
41
|
-
onValueChange={(value) => {
|
|
42
|
-
onChange(value)
|
|
43
|
-
onValueChange?.(value)
|
|
44
|
-
}}
|
|
45
|
-
/>
|
|
46
|
-
</FormControl>
|
|
47
|
-
{isShowCount && <div className="text-muted-foreground text-end text-xs">{valueWatch?.length ?? 0} characters</div>}
|
|
48
|
-
{!!description && <FormDescription>{description}</FormDescription>}
|
|
49
|
-
{isShowErrorMsg && <FormMessage />}
|
|
50
|
-
</FormItem>
|
|
51
|
-
)}
|
|
52
|
-
/>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import type { FieldPath, FieldValues } from 'react-hook-form'
|
|
3
|
-
|
|
4
|
-
import { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'
|
|
5
|
-
import { PasswordInput } from '../ui/inputs/password-input'
|
|
6
|
-
|
|
7
|
-
type Props<TFieldValues extends FieldValues = FieldValues> = {
|
|
8
|
-
name: FieldPath<TFieldValues>
|
|
9
|
-
label?: string
|
|
10
|
-
description?: string
|
|
11
|
-
placeholder?: string
|
|
12
|
-
isShowErrorMsg?: boolean
|
|
13
|
-
onValueChange?: (value: string) => void
|
|
14
|
-
}
|
|
15
|
-
export const PasswordField = <TFieldValues extends FieldValues = FieldValues>({
|
|
16
|
-
name,
|
|
17
|
-
label = 'Text Field',
|
|
18
|
-
placeholder = 'Enter text here',
|
|
19
|
-
isShowErrorMsg = false,
|
|
20
|
-
description,
|
|
21
|
-
onValueChange,
|
|
22
|
-
}: Props<TFieldValues>) => {
|
|
23
|
-
return (
|
|
24
|
-
<FormField
|
|
25
|
-
name={name}
|
|
26
|
-
render={({ field }) => (
|
|
27
|
-
<FormItem className="w-full">
|
|
28
|
-
<FormLabel>{label}</FormLabel>
|
|
29
|
-
<FormControl>
|
|
30
|
-
<PasswordInput placeholder={placeholder} {...field} onValueChange={onValueChange} />
|
|
31
|
-
</FormControl>
|
|
32
|
-
{!!description && <FormDescription>{description}</FormDescription>}
|
|
33
|
-
{isShowErrorMsg && <FormMessage />}
|
|
34
|
-
</FormItem>
|
|
35
|
-
)}
|
|
36
|
-
/>
|
|
37
|
-
)
|
|
38
|
-
}
|