@customafk/lunas-ui 0.0.33 → 0.0.34
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-Cj8K1Czh.cjs → add-new-C1-CCkbQ.cjs} +2 -2
- package/dist/{add-new-Cj8K1Czh.cjs.map → add-new-C1-CCkbQ.cjs.map} +1 -1
- package/dist/add-new-CIkUJq58.js +2 -0
- package/dist/{add-new-CPZxuEkP.js.map → add-new-CIkUJq58.js.map} +1 -1
- package/dist/{alert-dialog-ACHwFDPf.js → alert-dialog-6qa0-AL-.js} +2 -2
- package/dist/{alert-dialog-ACHwFDPf.js.map → alert-dialog-6qa0-AL-.js.map} +1 -1
- package/dist/{alert-dialog-lQEYgR6M.cjs → alert-dialog-uupOOu4w.cjs} +2 -2
- package/dist/{alert-dialog-lQEYgR6M.cjs.map → alert-dialog-uupOOu4w.cjs.map} +1 -1
- package/dist/{badge-CDuVH1Mj.cjs → badge-C5OQVVdj.cjs} +1 -1
- package/dist/{badge-CDuVH1Mj.cjs.map → badge-C5OQVVdj.cjs.map} +1 -1
- package/dist/{badge-q5yF26Mk.js → badge-DP4D6fsq.js} +1 -1
- package/dist/{badge-q5yF26Mk.js.map → badge-DP4D6fsq.js.map} +1 -1
- package/dist/{button-BoUygRNE.d.ts → button-3uYacIew.d.cts} +5 -4
- package/dist/{button-DPxiXJtr.d.cts → button-Bu7Ti4Ru.d.ts} +6 -5
- package/dist/{button-B57i_k5U.cjs → button-Db_CKSZw.cjs} +2 -2
- package/dist/{button-B57i_k5U.cjs.map → button-Db_CKSZw.cjs.map} +1 -1
- package/dist/{button-BJxq6PAQ.js → button-Pscu7CVU.js} +2 -2
- package/dist/{button-BJxq6PAQ.js.map → button-Pscu7CVU.js.map} +1 -1
- package/dist/{calendar-CSDEJP-b.cjs → calendar-DfzVqVmv.cjs} +2 -2
- package/dist/{calendar-CSDEJP-b.cjs.map → calendar-DfzVqVmv.cjs.map} +1 -1
- package/dist/{calendar-BW8M2GW_.js → calendar-u4FqjUKm.js} +2 -2
- package/dist/{calendar-BW8M2GW_.js.map → calendar-u4FqjUKm.js.map} +1 -1
- package/dist/cards/simple-card.d.cts +2 -2
- package/dist/{command-BmHb5JLj.cjs → command-BqUZEUTy.cjs} +2 -2
- package/dist/{command-BmHb5JLj.cjs.map → command-BqUZEUTy.cjs.map} +1 -1
- package/dist/{command-BMTaaAVA.js → command-C3siWT3g.js} +2 -2
- package/dist/{command-BMTaaAVA.js.map → command-C3siWT3g.js.map} +1 -1
- package/dist/{command-BenMcy0a.d.cts → command-DuKVGg2h.d.cts} +12 -12
- package/dist/{command-iFY6IzYs.d.ts → command-eTZ_8zR_.d.ts} +12 -12
- 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/{date-BMq_DNsv.js → date-B1g1OMYc.js} +1 -1
- package/dist/{date-BMq_DNsv.js.map → date-B1g1OMYc.js.map} +1 -1
- package/dist/{date-nd8WkPlx.cjs → date-Cw6Jf7k6.cjs} +1 -1
- package/dist/{date-nd8WkPlx.cjs.map → date-Cw6Jf7k6.cjs.map} +1 -1
- package/dist/{dialog-CguMVyyd.cjs → dialog-C712sXiq.cjs} +2 -2
- package/dist/{dialog-CguMVyyd.cjs.map → dialog-C712sXiq.cjs.map} +1 -1
- package/dist/{dialog-YTzM43YA.js → dialog-DEgx84P1.js} +2 -2
- package/dist/{dialog-YTzM43YA.js.map → dialog-DEgx84P1.js.map} +1 -1
- package/dist/{dialog-KnfZCHrN.d.ts → dialog-DRWITPUY.d.ts} +12 -12
- package/dist/{dialog-DC9nwyvF.d.cts → dialog-oAOedasX.d.cts} +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.cjs +1 -1
- package/dist/dialogs/detail-dialog/component/sidebar.d.cts +30 -30
- 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.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.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/dropdown-menu-B8ugkLB5.cjs +2 -0
- package/dist/dropdown-menu-B8ugkLB5.cjs.map +1 -0
- package/dist/dropdown-menu-DiM3sKIv.js +2 -0
- package/dist/dropdown-menu-DiM3sKIv.js.map +1 -0
- package/dist/{error-dialog-AnOiRms-.js → error-dialog-Bbu3oJO-.js} +2 -2
- package/dist/{error-dialog-AnOiRms-.js.map → error-dialog-Bbu3oJO-.js.map} +1 -1
- package/dist/{error-dialog-BA46Lm8p.cjs → error-dialog-CmPmHWv-.cjs} +2 -2
- package/dist/{error-dialog-BA46Lm8p.cjs.map → error-dialog-CmPmHWv-.cjs.map} +1 -1
- package/dist/{flex-CNA_SId-.cjs → flex-B5MQmxX8.cjs} +1 -1
- package/dist/{flex-CNA_SId-.cjs.map → flex-B5MQmxX8.cjs.map} +1 -1
- package/dist/{flex-ILvQrYMJ.js → flex-CBAzUoXK.js} +1 -1
- package/dist/{flex-ILvQrYMJ.js.map → flex-CBAzUoXK.js.map} +1 -1
- package/dist/{form-CHs85hm6.cjs → form-D13wOyun.cjs} +2 -2
- package/dist/{form-CHs85hm6.cjs.map → form-D13wOyun.cjs.map} +1 -1
- package/dist/{form-tabDlutX.js → form-DZqGhxta.js} +2 -2
- package/dist/{form-tabDlutX.js.map → form-DZqGhxta.js.map} +1 -1
- package/dist/{form-wrapper-DBV6X6Db.js → form-wrapper-Brw2tcHJ.js} +2 -2
- package/dist/{form-wrapper-DBV6X6Db.js.map → form-wrapper-Brw2tcHJ.js.map} +1 -1
- package/dist/{form-wrapper-BqbIZ1z1.cjs → form-wrapper-DH49h1Pa.cjs} +2 -2
- package/dist/{form-wrapper-BqbIZ1z1.cjs.map → form-wrapper-DH49h1Pa.cjs.map} +1 -1
- package/dist/forms/combobox-field.cjs +1 -1
- package/dist/forms/combobox-field.cjs.map +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/combobox-field.js.map +1 -1
- package/dist/forms/date-field.cjs +1 -1
- 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.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.cjs +1 -1
- package/dist/forms/number-field.cjs.map +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/number-field.js.map +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.js +1 -1
- package/dist/{input-zQM2qGNB.d.cts → input-8RZx48bn.d.cts} +3 -4
- package/dist/input-C-60EZ1K.cjs +2 -0
- package/dist/input-C-60EZ1K.cjs.map +1 -0
- package/dist/{input-CHksbruy.d.ts → input-CNvAUyl3.d.ts} +3 -4
- package/dist/input-nsu0-DwM.js +2 -0
- package/dist/input-nsu0-DwM.js.map +1 -0
- package/dist/{label-B_2ZQn0X.cjs → label-CW94D639.cjs} +1 -1
- package/dist/{label-B_2ZQn0X.cjs.map → label-CW94D639.cjs.map} +1 -1
- package/dist/{label-D1XmKlc3.js → label-DuddAB1p.js} +1 -1
- package/dist/{label-D1XmKlc3.js.map → label-DuddAB1p.js.map} +1 -1
- package/dist/layouts/app-layout/index.cjs +1 -1
- package/dist/layouts/app-layout/index.d.cts +3 -3
- package/dist/layouts/app-layout/index.d.ts +26 -26
- 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 +4 -4
- package/dist/layouts/flex.js +1 -1
- package/dist/layouts/main/index.cjs +1 -1
- package/dist/layouts/main/index.cjs.map +1 -1
- package/dist/layouts/main/index.d.ts +4 -4
- package/dist/layouts/main/index.js +1 -1
- package/dist/{multi-select-CgMIwUze.cjs → multi-select-D1CyXEEU.cjs} +2 -2
- package/dist/{multi-select-CgMIwUze.cjs.map → multi-select-D1CyXEEU.cjs.map} +1 -1
- package/dist/{multi-select-2gDBlVHu.js → multi-select-DNLyV99t.js} +2 -2
- package/dist/{multi-select-2gDBlVHu.js.map → multi-select-DNLyV99t.js.map} +1 -1
- package/dist/{paragraph-B4cQhLhW.js → paragraph-C0KfolV0.js} +1 -1
- package/dist/{paragraph-B4cQhLhW.js.map → paragraph-C0KfolV0.js.map} +1 -1
- package/dist/{paragraph-DcRBcRhQ.cjs → paragraph-JXci2Ihg.cjs} +1 -1
- package/dist/{paragraph-DcRBcRhQ.cjs.map → paragraph-JXci2Ihg.cjs.map} +1 -1
- package/dist/{popover-DCcPvdz2.cjs → popover-ByzBl1kH.cjs} +1 -1
- package/dist/{popover-DCcPvdz2.cjs.map → popover-ByzBl1kH.cjs.map} +1 -1
- package/dist/{popover-CTFp7ZXi.js → popover-DyoAfuhi.js} +1 -1
- package/dist/{popover-CTFp7ZXi.js.map → popover-DyoAfuhi.js.map} +1 -1
- package/dist/refresh-B6cTks2r.js +2 -0
- package/dist/{refresh-BLScMELs.js.map → refresh-B6cTks2r.js.map} +1 -1
- package/dist/{refresh-jFf3KQ-2.cjs → refresh-T1bZVS2m.cjs} +2 -2
- package/dist/{refresh-jFf3KQ-2.cjs.map → refresh-T1bZVS2m.cjs.map} +1 -1
- package/dist/{search-input-DqcwkgsY.js → search-input-BTzO9gpv.js} +2 -2
- package/dist/{search-input-DqcwkgsY.js.map → search-input-BTzO9gpv.js.map} +1 -1
- package/dist/{search-input-yweS9EMM.cjs → search-input-CDvluPxl.cjs} +2 -2
- package/dist/{search-input-yweS9EMM.cjs.map → search-input-CDvluPxl.cjs.map} +1 -1
- package/dist/select-BQqcz6WZ.cjs +2 -0
- package/dist/select-BQqcz6WZ.cjs.map +1 -0
- package/dist/select-RKVYJMTd.js +2 -0
- package/dist/select-RKVYJMTd.js.map +1 -0
- package/dist/{separator-BWBuPnbr.d.ts → separator-D5g8c5qg.d.ts} +3 -3
- package/dist/{separator-CM1kQQxq.d.cts → separator-DIIArEUd.d.cts} +3 -3
- package/dist/{sheet-DqPtcv9H.js → sheet-7EAzHejw.js} +2 -2
- package/dist/{sheet-DqPtcv9H.js.map → sheet-7EAzHejw.js.map} +1 -1
- package/dist/{sheet-CX3PajAc.cjs → sheet-C1xD7y3c.cjs} +2 -2
- package/dist/{sheet-CX3PajAc.cjs.map → sheet-C1xD7y3c.cjs.map} +1 -1
- package/dist/{sidebar-N_QJqMBE.cjs → sidebar-BXAkGEG6.cjs} +2 -2
- package/dist/{sidebar-N_QJqMBE.cjs.map → sidebar-BXAkGEG6.cjs.map} +1 -1
- package/dist/{sidebar-CQbg0LEV.cjs → sidebar-BmjgdQ-H.cjs} +2 -2
- package/dist/{sidebar-CQbg0LEV.cjs.map → sidebar-BmjgdQ-H.cjs.map} +1 -1
- package/dist/{sidebar-Ex4hQbd6.js → sidebar-COss4MdI.js} +2 -2
- package/dist/{sidebar-Ex4hQbd6.js.map → sidebar-COss4MdI.js.map} +1 -1
- package/dist/{sidebar-gO9wT3iV.js → sidebar-D9c0zxDI.js} +2 -2
- package/dist/{sidebar-gO9wT3iV.js.map → sidebar-D9c0zxDI.js.map} +1 -1
- package/dist/{switch-965kHdW_.js → switch-B9LmV-PS.js} +1 -1
- package/dist/{switch-965kHdW_.js.map → switch-B9LmV-PS.js.map} +1 -1
- package/dist/{switch-C3igCoxt.cjs → switch-bfoTi9s3.cjs} +1 -1
- package/dist/{switch-C3igCoxt.cjs.map → switch-bfoTi9s3.cjs.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/textarea-B9T9ZzvL.js +2 -0
- package/dist/textarea-B9T9ZzvL.js.map +1 -0
- package/dist/textarea-DzxaJFbk.cjs +2 -0
- package/dist/textarea-DzxaJFbk.cjs.map +1 -0
- package/dist/{toggle-A6eGkFij.js → toggle-BNtw9z70.js} +2 -2
- package/dist/{toggle-A6eGkFij.js.map → toggle-BNtw9z70.js.map} +1 -1
- package/dist/{toggle-MKfmKthf.d.cts → toggle-Dfa885le.d.cts} +5 -5
- package/dist/{toggle-ZyB3GPu7.d.ts → toggle-Du_U7mc3.d.ts} +4 -4
- package/dist/{toggle-B7nXBZ9r.cjs → toggle-eio6M2Fc.cjs} +2 -2
- package/dist/{toggle-B7nXBZ9r.cjs.map → toggle-eio6M2Fc.cjs.map} +1 -1
- package/dist/{tooltip-DLnAwybV.cjs → tooltip-Ci6WUOcz.cjs} +1 -1
- package/dist/{tooltip-DLnAwybV.cjs.map → tooltip-Ci6WUOcz.cjs.map} +1 -1
- package/dist/{tooltip-DFsHixOs.d.ts → tooltip-DL5DG_s3.d.ts} +6 -6
- package/dist/{tooltip-B8KdfOeT.js → tooltip-DkB0gnp9.js} +1 -1
- package/dist/{tooltip-B8KdfOeT.js.map → tooltip-DkB0gnp9.js.map} +1 -1
- package/dist/{tooltip-CSLkr6mF.d.cts → tooltip-Dmw3-czf.d.cts} +6 -6
- package/dist/{types-DaIHddx7.js → types-BVNbk1ZN.js} +1 -1
- package/dist/{types-DaIHddx7.js.map → types-BVNbk1ZN.js.map} +1 -1
- package/dist/{types-CrbWxjnp.cjs → types-CnMfjcgO.cjs} +1 -1
- package/dist/{types-CrbWxjnp.cjs.map → types-CnMfjcgO.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 +4 -4
- 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.d.cts +4 -4
- package/dist/ui/avatar.d.ts +4 -4
- package/dist/ui/badge.cjs +1 -1
- package/dist/ui/badge.d.cts +4 -4
- package/dist/ui/badge.d.ts +4 -4
- package/dist/ui/badge.js +1 -1
- package/dist/ui/breadcrumb.cjs +1 -1
- package/dist/ui/breadcrumb.d.cts +8 -8
- package/dist/ui/breadcrumb.d.ts +8 -8
- package/dist/ui/breadcrumb.js +1 -1
- package/dist/ui/button.cjs +1 -1
- package/dist/ui/button.d.cts +1 -1
- package/dist/ui/button.d.ts +1 -1
- package/dist/ui/button.js +1 -1
- package/dist/ui/buttons/add-new.cjs +1 -1
- package/dist/ui/buttons/add-new.js +1 -1
- package/dist/ui/buttons/edit.cjs +1 -1
- package/dist/ui/buttons/edit.js +1 -1
- package/dist/ui/buttons/refresh.cjs +1 -1
- package/dist/ui/buttons/refresh.js +1 -1
- package/dist/ui/buttons/trash.cjs +1 -1
- package/dist/ui/buttons/trash.js +1 -1
- package/dist/ui/buttons/upload-image.cjs +1 -1
- package/dist/ui/buttons/upload-image.js +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.cjs +1 -1
- package/dist/ui/carousel.d.cts +7 -7
- package/dist/ui/carousel.d.ts +7 -7
- package/dist/ui/carousel.js +1 -1
- 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.cjs +1 -1
- package/dist/ui/context-menu.d.cts +16 -16
- package/dist/ui/context-menu.d.ts +16 -16
- package/dist/ui/context-menu.js +1 -1
- 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.cjs +1 -1
- package/dist/ui/dropdown-menu.d.cts +16 -16
- package/dist/ui/dropdown-menu.d.ts +16 -16
- package/dist/ui/dropdown-menu.js +1 -1
- package/dist/ui/file-uploader.cjs +1 -1
- package/dist/ui/file-uploader.d.cts +2 -2
- package/dist/ui/file-uploader.d.ts +2 -2
- package/dist/ui/file-uploader.js +1 -1
- 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.cjs +1 -1
- package/dist/ui/input.d.cts +1 -1
- package/dist/ui/input.d.ts +1 -1
- package/dist/ui/input.js +1 -1
- package/dist/ui/inputs/search-input.cjs +1 -1
- package/dist/ui/inputs/search-input.d.cts +3 -3
- package/dist/ui/inputs/search-input.d.ts +1 -1
- package/dist/ui/inputs/search-input.js +1 -1
- 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.cjs +1 -1
- package/dist/ui/menubar.d.cts +17 -17
- package/dist/ui/menubar.d.ts +17 -17
- package/dist/ui/menubar.js +1 -1
- 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.cjs +1 -1
- package/dist/ui/navigation-menu.d.cts +11 -11
- package/dist/ui/navigation-menu.js +1 -1
- package/dist/ui/pagination.cjs +1 -1
- package/dist/ui/pagination.d.cts +9 -9
- package/dist/ui/pagination.d.ts +9 -9
- package/dist/ui/pagination.js +1 -1
- 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.cjs +1 -1
- package/dist/ui/radio-group.d.cts +3 -3
- package/dist/ui/radio-group.d.ts +3 -3
- package/dist/ui/radio-group.js +1 -1
- 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.cjs +1 -1
- package/dist/ui/select.d.cts +11 -11
- package/dist/ui/select.d.ts +11 -11
- package/dist/ui/select.js +1 -1
- package/dist/ui/separator.d.cts +1 -1
- package/dist/ui/separator.d.ts +1 -1
- package/dist/ui/sheet.cjs +1 -1
- package/dist/ui/sheet.d.cts +9 -9
- package/dist/ui/sheet.d.ts +9 -9
- package/dist/ui/sheet.js +1 -1
- package/dist/ui/sidebar.cjs +1 -1
- package/dist/ui/sidebar.d.cts +30 -30
- package/dist/ui/sidebar.d.ts +28 -28
- 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.ts +2 -2
- package/dist/ui/switch.cjs +1 -1
- package/dist/ui/switch.d.cts +2 -2
- package/dist/ui/switch.d.ts +2 -2
- package/dist/ui/switch.js +1 -1
- 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.cjs +1 -1
- package/dist/ui/textarea.d.cts +2 -2
- package/dist/ui/textarea.d.ts +2 -2
- package/dist/ui/textarea.js +1 -1
- package/dist/ui/toggle-group.cjs +1 -1
- package/dist/ui/toggle-group.d.cts +4 -4
- package/dist/ui/toggle-group.d.ts +5 -5
- package/dist/ui/toggle-group.js +1 -1
- package/dist/ui/toggle.cjs +1 -1
- package/dist/ui/toggle.d.cts +1 -1
- package/dist/ui/toggle.d.ts +1 -1
- package/dist/ui/toggle.js +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 +1 -1
- package/dist/add-new-CPZxuEkP.js +0 -2
- package/dist/dropdown-menu-BnfaOPEM.cjs +0 -2
- package/dist/dropdown-menu-BnfaOPEM.cjs.map +0 -1
- package/dist/dropdown-menu-D5uG4HZA.js +0 -2
- package/dist/dropdown-menu-D5uG4HZA.js.map +0 -1
- package/dist/input--6vqz8UI.js +0 -2
- package/dist/input--6vqz8UI.js.map +0 -1
- package/dist/input-VZiryzkl.cjs +0 -2
- package/dist/input-VZiryzkl.cjs.map +0 -1
- package/dist/refresh-BLScMELs.js +0 -2
- package/dist/select-BHjk6yT3.cjs +0 -2
- package/dist/select-BHjk6yT3.cjs.map +0 -1
- package/dist/select-C6N3CXuY.js +0 -2
- package/dist/select-C6N3CXuY.js.map +0 -1
- package/dist/textarea-3XRFTUZ8.cjs +0 -2
- package/dist/textarea-3XRFTUZ8.cjs.map +0 -1
- package/dist/textarea-CQ6gAnm5.js +0 -2
- package/dist/textarea-CQ6gAnm5.js.map +0 -1
package/dist/forms/date-field.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{cn as e}from"../utils-D9AH0PUV.js";import{Button as t}from"../button-
|
|
1
|
+
"use client";import{cn as e}from"../utils-D9AH0PUV.js";import{Button as t}from"../button-Pscu7CVU.js";import"../label-DuddAB1p.js";import{FormControl as n,FormDescription as r,FormField as i,FormItem as a,FormLabel as o,FormMessage as s}from"../form-DZqGhxta.js";import{Popover as c,PopoverContent as l,PopoverTrigger as u}from"../popover-DyoAfuhi.js";import{Calendar as d}from"../calendar-u4FqjUKm.js";import{jsx as f,jsxs as p}from"react/jsx-runtime";import{CalendarIcon as m}from"lucide-react";import{format as h}from"date-fns";const g=({name:g,label:_=`Date Field`,placeholder:v=`Select a date`,description:y=``,isShowErrorMsg:b=!1})=>f(i,{name:g,render:({field:i})=>p(a,{className:`w-full`,children:[f(o,{children:_}),p(c,{modal:!0,children:[f(u,{asChild:!0,children:f(n,{children:p(t,{variant:`outline`,className:e(`w-full pl-3 text-left font-normal`,!i.value&&`text-muted-foreground`),children:[i.value?h(i.value,`PPP`):p(`span`,{children:[` `,v||`Pick a date`]}),f(m,{className:`ml-auto size-4 opacity-50`})]})})}),f(l,{className:`w-auto p-0`,align:`start`,children:f(d,{mode:`single`,selected:i.value,onSelect:e=>{i.onChange(e?.toISOString())},captionLayout:`dropdown`,disabled:e=>e<new Date(`2022-01-01`)})})]}),!!y&&f(r,{children:y}),b&&f(s,{})]})});export{g as DateField};
|
|
2
2
|
//# sourceMappingURL=date-field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../utils-BsjVK5EW.cjs`),require(`../button-
|
|
1
|
+
require(`../utils-BsjVK5EW.cjs`),require(`../button-Db_CKSZw.cjs`),require(`../label-CW94D639.cjs`),require(`../form-D13wOyun.cjs`),require(`../alert-dialog-uupOOu4w.cjs`),require(`../error-dialog-CmPmHWv-.cjs`);const e=require(`../form-wrapper-DH49h1Pa.cjs`);exports.FormWrapper=e.FormWrapper;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime4 from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { FieldValues, FormState, SubmitErrorHandler, UseFormProps } from "react-hook-form";
|
|
4
4
|
|
|
@@ -19,7 +19,7 @@ declare const FormWrapper: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
19
19
|
onError,
|
|
20
20
|
onSubcribe,
|
|
21
21
|
children
|
|
22
|
-
}: React.PropsWithChildren<Props<TFieldValues>>) =>
|
|
22
|
+
}: React.PropsWithChildren<Props<TFieldValues>>) => react_jsx_runtime4.JSX.Element;
|
|
23
23
|
//#endregion
|
|
24
24
|
export { FormWrapper };
|
|
25
25
|
//# sourceMappingURL=form-wrapper.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../utils-D9AH0PUV.js";import"../button-
|
|
1
|
+
import"../utils-D9AH0PUV.js";import"../button-Pscu7CVU.js";import"../label-DuddAB1p.js";import"../form-DZqGhxta.js";import"../alert-dialog-6qa0-AL-.js";import"../error-dialog-Bbu3oJO-.js";import{FormWrapper as e}from"../form-wrapper-Brw2tcHJ.js";export{e as FormWrapper};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../utils-BsjVK5EW.cjs`),require(`../button-
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../utils-BsjVK5EW.cjs`),require(`../button-Db_CKSZw.cjs`),require(`../dialog-C712sXiq.cjs`),require(`../command-BqUZEUTy.cjs`),require(`../label-CW94D639.cjs`);const t=require(`../form-D13wOyun.cjs`),n=require(`../multi-select-D1CyXEEU.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-select-field.cjs","names":["FormField","value","FormItem","FormLabel","FormControl","MultipleSelector","FormDescription","FormMessage"],"sources":["../../packages/components/forms/multi-select-field.tsx"],"sourcesContent":["'use client'\nimport type { FieldPath, FieldValues } from 'react-hook-form'\n\nimport { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'\nimport { type Option, MultipleSelector } from '../ui/multi-select'\n\ntype Props<TFieldValues extends FieldValues = FieldValues> = {\n name: FieldPath<TFieldValues>\n isShowLabel?: boolean\n isShowErrorMsg?: boolean\n label?: string\n description?: string\n placeholder?: string\n options?: { value: string; label: string }[]\n onAdd?: () => void\n}\nexport const MultiSelectField = <TFieldValues extends FieldValues = FieldValues>({\n name,\n label = 'Multi Select Field',\n isShowLabel = true,\n isShowErrorMsg,\n placeholder = 'Select options',\n description = '',\n options = [],\n onAdd,\n}: Props<TFieldValues>) => {\n return (\n <FormField\n name={name}\n render={({ field: { value, onChange } }) => {\n const val = options.filter((option) => value?.includes(option.value))\n const handleOnChange = (value: Option[]) => {\n const selectedValues = value.map((v) => v.value)\n onChange(selectedValues)\n }\n return (\n <FormItem className=\"w-full gap-0\">\n {isShowLabel && <FormLabel>{label}</FormLabel>}\n <FormControl>\n <MultipleSelector\n placeholder={placeholder}\n emptyIndicator=\"No options available\"\n value={val}\n options={options}\n onChange={handleOnChange}\n onAddNewItem={onAdd}\n />\n </FormControl>\n {!!description && <FormDescription>{description}</FormDescription>}\n {isShowErrorMsg && <FormMessage />}\n </FormItem>\n )\n }}\n />\n )\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"multi-select-field.cjs","names":["FormField","value","FormItem","FormLabel","FormControl","MultipleSelector","FormDescription","FormMessage"],"sources":["../../packages/components/forms/multi-select-field.tsx"],"sourcesContent":["'use client'\nimport type { FieldPath, FieldValues } from 'react-hook-form'\n\nimport { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'\nimport { type Option, MultipleSelector } from '../ui/multi-select'\n\ntype Props<TFieldValues extends FieldValues = FieldValues> = {\n name: FieldPath<TFieldValues>\n isShowLabel?: boolean\n isShowErrorMsg?: boolean\n label?: string\n description?: string\n placeholder?: string\n options?: { value: string; label: string }[]\n onAdd?: () => void\n}\nexport const MultiSelectField = <TFieldValues extends FieldValues = FieldValues>({\n name,\n label = 'Multi Select Field',\n isShowLabel = true,\n isShowErrorMsg,\n placeholder = 'Select options',\n description = '',\n options = [],\n onAdd,\n}: Props<TFieldValues>) => {\n return (\n <FormField\n name={name}\n render={({ field: { value, onChange } }) => {\n const val = options.filter((option) => value?.includes(option.value))\n const handleOnChange = (value: Option[]) => {\n const selectedValues = value.map((v) => v.value)\n onChange(selectedValues)\n }\n return (\n <FormItem className=\"w-full gap-0\">\n {isShowLabel && <FormLabel>{label}</FormLabel>}\n <FormControl>\n <MultipleSelector\n placeholder={placeholder}\n emptyIndicator=\"No options available\"\n value={val}\n options={options}\n onChange={handleOnChange}\n onAddNewItem={onAdd}\n />\n </FormControl>\n {!!description && <FormDescription>{description}</FormDescription>}\n {isShowErrorMsg && <FormMessage />}\n </FormItem>\n )\n }}\n />\n )\n}\n"],"mappings":"2VAgBa,GAAoE,CAC/E,OACA,QAAQ,qBACR,cAAc,GACd,iBACA,cAAc,iBACd,cAAc,GACd,UAAU,GACV,YAGE,EAAA,EAAA,KAACA,EAAAA,UAAAA,CACO,OACN,QAAS,CAAE,MAAO,CAAE,QAAO,eAAiB,CAC1C,IAAM,EAAM,EAAQ,OAAQ,GAAW,GAAO,SAAS,EAAO,QACxD,EAAkB,GAAoB,CAC1C,IAAM,EAAiBC,EAAM,IAAK,GAAM,EAAE,OAC1C,EAAS,IAEX,OACE,EAAA,EAAA,MAACC,EAAAA,SAAAA,CAAS,UAAU,yBACjB,IAAe,EAAA,EAAA,KAACC,EAAAA,UAAAA,CAAAA,SAAW,KAC5B,EAAA,EAAA,KAACC,EAAAA,YAAAA,CAAAA,UACC,EAAA,EAAA,KAACC,EAAAA,iBAAAA,CACc,cACb,eAAe,uBACf,MAAO,EACE,UACT,SAAU,EACV,aAAc,MAGjB,CAAC,CAAC,IAAe,EAAA,EAAA,KAACC,EAAAA,gBAAAA,CAAAA,SAAiB,IACnC,IAAkB,EAAA,EAAA,KAACC,EAAAA,YAAAA"}
|
|
@@ -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/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_runtime8.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_runtime1 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_runtime1.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"../utils-D9AH0PUV.js";import"../button-
|
|
1
|
+
"use client";import"../utils-D9AH0PUV.js";import"../button-Pscu7CVU.js";import"../dialog-DEgx84P1.js";import"../command-C3siWT3g.js";import"../label-DuddAB1p.js";import{FormControl as e,FormDescription as t,FormField as n,FormItem as r,FormLabel as i,FormMessage as a}from"../form-DZqGhxta.js";import{MultipleSelector as o}from"../multi-select-DNLyV99t.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`),t=require(`../utils-BsjVK5EW.cjs`);require(`../label-
|
|
1
|
+
const e=require(`../chunk-CUT6urMc.cjs`),t=require(`../utils-BsjVK5EW.cjs`);require(`../label-CW94D639.cjs`);const n=require(`../form-D13wOyun.cjs`),r=require(`../input-C-60EZ1K.cjs`),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:n=!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=i.default.useRef(null),x=i.default.useRef(null),[S,C]=i.default.useState(d.toString()),w=p?.[1]??l,T=p&&p[0]-p[1],E=i.default.useMemo(()=>s(o),[o]),D=i.default.useCallback(e=>{if(!w&&e.includes(`.`))return!1;let t=e.split(`.`)[1];return!t||t.length<=w},[w]),O=i.default.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=i.default.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=i.default.useCallback(e=>!l&&e.includes(`.`)||e.split(`.`)[1]?.length>l,[l]),j=i.default.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=i.default.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=i.default.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=i.default.useCallback(()=>{n||C(e=>e.replace(/,/g,``))},[n]),F=i.default.useCallback(()=>{n||(v?.(),C(e=>j(e)))},[n,v,j]);return i.default.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]),i.default.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)(r.Input,{...y,ref:x,value:S||(n?`0`:``),placeholder:m,disabled:e,readOnly:n,className:t.cn(`font-number text-end`,n&&`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:t=`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)(n.FormField,{name:e,render:({field:{onChange:e,...o}})=>(0,a.jsxs)(n.FormItem,{className:`w-full gap-0`,children:[(0,a.jsx)(n.FormLabel,{children:t}),(0,a.jsx)(n.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)(n.FormDescription,{children:u}),i&&(0,a.jsx)(n.FormMessage,{})]})})};exports.NumberField=u;
|
|
2
2
|
//# sourceMappingURL=number-field.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field.cjs","names":["NumberInput: React.FC<IProps>","React","value","precision","maxIntegerLength","Input","cn","FormField","FormItem","FormLabel","FormControl","FormDescription","FormMessage"],"sources":["../../packages/components/ui/inputs/number-input.tsx","../../packages/components/forms/number-field.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport { cn } from '@/lib/utils'\n\nimport { Input } from '../input'\n\nconst createValidationRegex = (allowNegative: boolean): RegExp => {\n return allowNegative ? /^-?\\d*\\.?\\d*$/ : /^\\d*\\.?\\d*$/\n}\n\nconst formatNumberWithCommas = (num: number | string): string => {\n return Number(num).toLocaleString()\n}\n\ninterface IProps extends React.HTMLAttributes<HTMLInputElement> {\n /**\n * Description: Value for the text field\n *\n * Default: ''\n *\n * Usage: Value for the text field\n */\n value?: string | number\n /**\n * Description: Disabled state of the text field\n *\n * Default: `false`\n *\n * Usage: Disabled state of the text field\n *\n * Note: If true, the text field will be disabled\n */\n disabled?: boolean\n /**\n * Description: Readonly state of the text field\n *\n * Default: `false`\n *\n * Usage: Readonly state of the text field\n */\n readonly?: boolean\n /**\n * Description: Allow negative value for the text field\n *\n * Default: `false`\n *\n * Usage: Allow negative value for the text field\n */\n allowNegative?: boolean\n /**\n * Description: Decimal point for the text field\n *\n * Default: `undefined`\n *\n * Usage: Ex: [12,3] => console.log(2323.23) // True\n *\n * Note: IF use this prop, `numberAfterDecimalPoint` will be ignored\n */\n decimal?: [number, number]\n /**\n * Description: Rounding rule for the text field\n *\n * Default: `nearest`\n *\n * Usage: Rounding rule for the text field\n */\n roundingRule?: 'up' | 'down' | 'nearest' | 'none'\n /**\n * Description: Number of digits after the decimal point\n *\n * Default: `2`\n *\n * Usage: Number of digits after the decimal point\n */\n numberAfterDecimalPoint?: number\n /**\n * Description: Placeholder for the text field\n *\n * Default: ''\n *\n * Usage: Placeholder for the text field\n */\n placeholder?: string\n /**\n * Description: Unit text for the text field\n *\n * Default: ''\n *\n * E.g. 'kg', 'm', 'USD'...\n */\n unitText?: string\n /**\n * Description: Invalid state of the text field\n *\n * Default: `false`\n *\n * Usage: Invalid state of the text field\n */\n invalid?: boolean\n /**\n * Description: Precision for the text field\n *\n * Default: `undefined`\n * E.g.\n * - 2.13 => 2.1 when precision is 1\n * - 2.134 => 2.13 when precision is 2\n */\n precision?: number\n /**\n * Description: Callback function for the value change\n * Usage: Callback function for the value change\n */\n onValueChange?: (value?: number) => void\n onBlur?: () => void\n}\n/**\n * ## Unit Text Field Component\n *\n * **Description**: This component is to display common text field with unit\n *\n * **Usage**: Text field with unit example: 1000 (kg), 100 (m), 1000 (USD)...\n */\nexport const NumberInput: React.FC<IProps> = ({\n disabled = false,\n readonly = false,\n allowNegative = false,\n numberAfterDecimalPoint = 2,\n roundingRule = 'none',\n value: initialValue = '',\n unitText,\n decimal,\n placeholder,\n precision,\n onChange,\n onValueChange,\n onBlur,\n ...props\n}) => {\n const _unitRef = React.useRef<HTMLSpanElement>(null)\n const _inputRef = React.useRef<HTMLInputElement>(null)\n\n const [value, setValue] = React.useState<string>(initialValue.toString())\n\n // Memoized values for validation and formatting\n const maxDecimalPlaces = decimal?.[1] ?? numberAfterDecimalPoint\n const maxIntegerLength = decimal && decimal[0] - decimal[1]\n const validationRegex = React.useMemo(() => createValidationRegex(allowNegative), [allowNegative])\n\n // Validation functions\n const isValidDecimalLength = React.useCallback(\n (value: string): boolean => {\n if (!maxDecimalPlaces && value.includes('.')) return false\n const decimalPart = value.split('.')[1]\n return !decimalPart || decimalPart.length <= maxDecimalPlaces\n },\n [maxDecimalPlaces],\n )\n const isValidFormat = React.useCallback(\n (value: string): boolean => {\n if (!decimal || value === '-') return true\n const [integerPart, decimalPart = ''] = value.split('.')\n\n return decimalPart.length <= decimal[1] && (integerPart.startsWith('-') ? integerPart.length - 1 : integerPart.length) <= maxIntegerLength!\n },\n [decimal, maxIntegerLength],\n )\n const customRoundedValue = React.useCallback(\n (value: number, precision: number) => {\n if (roundingRule === 'none') return value\n\n const factor = Math.pow(10, precision)\n const scaledValue = value * factor\n\n switch (roundingRule) {\n case 'up':\n return Math.ceil(scaledValue) / factor\n case 'down':\n return Math.floor(scaledValue) / factor\n case 'nearest': {\n if (scaledValue % 1 < 0.1) return Math.floor(scaledValue) / factor\n if (scaledValue % 1 >= 0.59) return Math.ceil(scaledValue) / factor\n return (Math.floor(scaledValue) + 0.5) / factor\n }\n default:\n return value\n }\n },\n [roundingRule],\n )\n const isDecimalPointGreaterThanLimit = React.useCallback(\n (value: string) => (!numberAfterDecimalPoint && value.includes('.')) || value.split('.')[1]?.length > numberAfterDecimalPoint,\n [numberAfterDecimalPoint],\n )\n const formattedValue = React.useCallback(\n (val: string) => {\n if (val === '0') return '0'\n if (!Number(val)) return ''\n\n const numValue = parseFloat(val)\n const effectivePrecision = Math.min(maxDecimalPlaces - 1, precision || 0)\n const roundedValue = customRoundedValue(numValue, effectivePrecision).toString()\n const [integerPart, decimalPart = ''] = roundedValue.split('.')\n const formattedInteger = formatNumberWithCommas(integerPart)\n return decimalPart ? `${formattedInteger}.${decimalPart}` : formattedInteger\n },\n [customRoundedValue, maxDecimalPlaces, precision],\n )\n // Validate decimal point is less than or equal to the limit\n const validateDecimalPoint = React.useCallback(\n (value: string) => {\n if (!decimal || value === '-') return true\n\n const [integerPart, decimalPart = ''] = value.split('.')\n const integerLength = integerPart.startsWith('-') ? integerPart.length - 1 : integerPart.length\n const maxIntegerLength = decimal[0] - decimal[1]\n\n return decimalPart.length <= decimal[1] && integerLength <= maxIntegerLength\n },\n [decimal],\n )\n const handleChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n // Don't prevent default behavior of input change\n onChange?.(e)\n\n // Custom event handler for value change\n const { value: inputValue } = e.target\n\n // Handle empty input\n if (!inputValue) {\n onValueChange?.(undefined)\n setValue('')\n return\n }\n\n // Handle zero and negative zero\n const isZero = inputValue === '0'\n const isNegativeZero = inputValue === '-' && allowNegative\n if (isZero || isNegativeZero) {\n onValueChange?.(0)\n setValue(inputValue)\n return\n }\n\n // Validate input format\n const isValid = validationRegex.test(inputValue) && isValidFormat(inputValue) && (decimal || isValidDecimalLength(inputValue))\n if (!isValid) return\n\n const numericValue = parseFloat(inputValue) || 0\n onValueChange?.(numericValue)\n setValue(inputValue)\n },\n [allowNegative, decimal, isValidDecimalLength, isValidFormat, onChange, onValueChange, validationRegex],\n )\n\n const handleFocus = React.useCallback(() => {\n if (readonly) return\n setValue((prev) => prev.replace(/,/g, '')) // Remove commas for easier editing\n }, [readonly])\n\n const handleBlur = React.useCallback(() => {\n if (readonly) return\n onBlur?.()\n setValue((prev) => formattedValue(prev))\n }, [readonly, onBlur, formattedValue])\n\n // Set initial value\n React.useEffect(() => {\n const isFocused = document.activeElement === _inputRef.current\n\n if (\n !initialValue ||\n !validationRegex.test(initialValue.toString()) ||\n !validateDecimalPoint(initialValue.toString()) ||\n (!decimal && isDecimalPointGreaterThanLimit(initialValue.toString()))\n ) {\n setValue('')\n return\n }\n\n setValue((prev) => {\n if (prev === '-') return '-'\n if (!prev) return ''\n return isFocused ? initialValue.toString() : formattedValue(initialValue.toString())\n })\n }, [decimal, formattedValue, initialValue, isDecimalPointGreaterThanLimit, validateDecimalPoint, validationRegex])\n\n // Set padding right for the input field\n React.useEffect(() => {\n if (!_unitRef.current || !_inputRef.current || !unitText) return\n const unitWidth = _unitRef.current.offsetWidth\n _inputRef.current.style.setProperty('padding-right', `${(unitWidth + 10) / 16}rem`)\n }, [disabled, unitText])\n\n return (\n <div className=\"relative\">\n <Input\n {...props}\n ref={_inputRef}\n value={value || (readonly ? '0' : '')}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readonly}\n className={cn('font-number text-end', readonly && 'bg-muted text-muted-foreground')}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n />\n {unitText && (\n <span ref={_unitRef} className=\"text-muted-foreground pointer-events-none absolute top-1/2 right-2 mt-px -translate-y-1/2 text-sm\">\n {unitText}\n </span>\n )}\n </div>\n )\n}\n","import { type FieldPath, type FieldValues, useWatch } from 'react-hook-form'\n\nimport { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'\nimport { NumberInput } from '../ui/inputs/number-input'\n\ntype Props<TFieldValues extends FieldValues = FieldValues> = {\n name: FieldPath<TFieldValues>\n label?: string\n description?: string\n placeholder?: string\n unitText?: string\n isShowClearButton?: boolean\n isShowErrorMsg?: boolean\n isShowCount?: boolean\n onValueChange?: (value?: number) => void\n}\nexport const NumberField = <TFieldValues extends FieldValues = FieldValues>({\n name,\n label = 'Number Field',\n placeholder = '0',\n isShowErrorMsg = false,\n isShowCount = false,\n unitText = '',\n description = '',\n onValueChange,\n}: Props<TFieldValues>) => {\n const valueWatch = useWatch({ name })\n\n return (\n <FormField\n name={name}\n render={({ field: { onChange, ...field } }) => (\n <FormItem className=\"w-full gap-0\">\n <FormLabel>{label}</FormLabel>\n <FormControl>\n <NumberInput\n {...field}\n placeholder={placeholder}\n className=\"w-full\"\n unitText={unitText}\n onValueChange={(value) => {\n onChange(value)\n onValueChange?.(value)\n }}\n />\n </FormControl>\n {isShowCount && <div className=\"text-muted-foreground text-end text-xs\">{valueWatch?.length ?? 0} characters</div>}\n {!!description && <FormDescription>{description}</FormDescription>}\n {isShowErrorMsg && <FormMessage />}\n </FormItem>\n )}\n />\n )\n}\n"],"mappings":"wSAOM,EAAyB,GACtB,EAAgB,gBAAkB,cAGrC,EAA0B,GACvB,OAAO,GAAK,iBA+GRA,GAAiC,CAC5C,WAAW,GACX,WAAW,GACX,gBAAgB,GAChB,0BAA0B,EAC1B,eAAe,OACf,MAAO,EAAe,GACtB,WACA,UACA,cACA,YACA,WACA,gBACA,SACA,GAAG,KACC,CACJ,IAAM,EAAWC,EAAAA,QAAM,OAAwB,MACzC,EAAYA,EAAAA,QAAM,OAAyB,MAE3C,CAAC,EAAO,GAAYA,EAAAA,QAAM,SAAiB,EAAa,YAGxD,EAAmB,IAAU,IAAM,EACnC,EAAmB,GAAW,EAAQ,GAAK,EAAQ,GACnD,EAAkBA,EAAAA,QAAM,YAAc,EAAsB,GAAgB,CA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,EAAA,KAACC,EAAAA,YAAAA"}
|
|
1
|
+
{"version":3,"file":"number-field.cjs","names":["NumberInput: React.FC<IProps>","React","value","precision","maxIntegerLength","Input","cn","FormField","FormItem","FormLabel","FormControl","FormDescription","FormMessage"],"sources":["../../packages/components/ui/inputs/number-input.tsx","../../packages/components/forms/number-field.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport { cn } from '@/lib/utils'\n\nimport { Input } from '../input'\n\nconst createValidationRegex = (allowNegative: boolean): RegExp => {\n return allowNegative ? /^-?\\d*\\.?\\d*$/ : /^\\d*\\.?\\d*$/\n}\n\nconst formatNumberWithCommas = (num: number | string): string => {\n return Number(num).toLocaleString()\n}\n\ninterface IProps extends React.HTMLAttributes<HTMLInputElement> {\n /**\n * Description: Value for the text field\n *\n * Default: ''\n *\n * Usage: Value for the text field\n */\n value?: string | number\n /**\n * Description: Disabled state of the text field\n *\n * Default: `false`\n *\n * Usage: Disabled state of the text field\n *\n * Note: If true, the text field will be disabled\n */\n disabled?: boolean\n /**\n * Description: Readonly state of the text field\n *\n * Default: `false`\n *\n * Usage: Readonly state of the text field\n */\n readonly?: boolean\n /**\n * Description: Allow negative value for the text field\n *\n * Default: `false`\n *\n * Usage: Allow negative value for the text field\n */\n allowNegative?: boolean\n /**\n * Description: Decimal point for the text field\n *\n * Default: `undefined`\n *\n * Usage: Ex: [12,3] => console.log(2323.23) // True\n *\n * Note: IF use this prop, `numberAfterDecimalPoint` will be ignored\n */\n decimal?: [number, number]\n /**\n * Description: Rounding rule for the text field\n *\n * Default: `nearest`\n *\n * Usage: Rounding rule for the text field\n */\n roundingRule?: 'up' | 'down' | 'nearest' | 'none'\n /**\n * Description: Number of digits after the decimal point\n *\n * Default: `2`\n *\n * Usage: Number of digits after the decimal point\n */\n numberAfterDecimalPoint?: number\n /**\n * Description: Placeholder for the text field\n *\n * Default: ''\n *\n * Usage: Placeholder for the text field\n */\n placeholder?: string\n /**\n * Description: Unit text for the text field\n *\n * Default: ''\n *\n * E.g. 'kg', 'm', 'USD'...\n */\n unitText?: string\n /**\n * Description: Invalid state of the text field\n *\n * Default: `false`\n *\n * Usage: Invalid state of the text field\n */\n invalid?: boolean\n /**\n * Description: Precision for the text field\n *\n * Default: `undefined`\n * E.g.\n * - 2.13 => 2.1 when precision is 1\n * - 2.134 => 2.13 when precision is 2\n */\n precision?: number\n /**\n * Description: Callback function for the value change\n * Usage: Callback function for the value change\n */\n onValueChange?: (value?: number) => void\n onBlur?: () => void\n}\n/**\n * ## Unit Text Field Component\n *\n * **Description**: This component is to display common text field with unit\n *\n * **Usage**: Text field with unit example: 1000 (kg), 100 (m), 1000 (USD)...\n */\nexport const NumberInput: React.FC<IProps> = ({\n disabled = false,\n readonly = false,\n allowNegative = false,\n numberAfterDecimalPoint = 2,\n roundingRule = 'none',\n value: initialValue = '',\n unitText,\n decimal,\n placeholder,\n precision,\n onChange,\n onValueChange,\n onBlur,\n ...props\n}) => {\n const _unitRef = React.useRef<HTMLSpanElement>(null)\n const _inputRef = React.useRef<HTMLInputElement>(null)\n\n const [value, setValue] = React.useState<string>(initialValue.toString())\n\n // Memoized values for validation and formatting\n const maxDecimalPlaces = decimal?.[1] ?? numberAfterDecimalPoint\n const maxIntegerLength = decimal && decimal[0] - decimal[1]\n const validationRegex = React.useMemo(() => createValidationRegex(allowNegative), [allowNegative])\n\n // Validation functions\n const isValidDecimalLength = React.useCallback(\n (value: string): boolean => {\n if (!maxDecimalPlaces && value.includes('.')) return false\n const decimalPart = value.split('.')[1]\n return !decimalPart || decimalPart.length <= maxDecimalPlaces\n },\n [maxDecimalPlaces],\n )\n const isValidFormat = React.useCallback(\n (value: string): boolean => {\n if (!decimal || value === '-') return true\n const [integerPart, decimalPart = ''] = value.split('.')\n\n return decimalPart.length <= decimal[1] && (integerPart.startsWith('-') ? integerPart.length - 1 : integerPart.length) <= maxIntegerLength!\n },\n [decimal, maxIntegerLength],\n )\n const customRoundedValue = React.useCallback(\n (value: number, precision: number) => {\n if (roundingRule === 'none') return value\n\n const factor = Math.pow(10, precision)\n const scaledValue = value * factor\n\n switch (roundingRule) {\n case 'up':\n return Math.ceil(scaledValue) / factor\n case 'down':\n return Math.floor(scaledValue) / factor\n case 'nearest': {\n if (scaledValue % 1 < 0.1) return Math.floor(scaledValue) / factor\n if (scaledValue % 1 >= 0.59) return Math.ceil(scaledValue) / factor\n return (Math.floor(scaledValue) + 0.5) / factor\n }\n default:\n return value\n }\n },\n [roundingRule],\n )\n const isDecimalPointGreaterThanLimit = React.useCallback(\n (value: string) => (!numberAfterDecimalPoint && value.includes('.')) || value.split('.')[1]?.length > numberAfterDecimalPoint,\n [numberAfterDecimalPoint],\n )\n const formattedValue = React.useCallback(\n (val: string) => {\n if (val === '0') return '0'\n if (!Number(val)) return ''\n\n const numValue = parseFloat(val)\n const effectivePrecision = Math.min(maxDecimalPlaces - 1, precision || 0)\n const roundedValue = customRoundedValue(numValue, effectivePrecision).toString()\n const [integerPart, decimalPart = ''] = roundedValue.split('.')\n const formattedInteger = formatNumberWithCommas(integerPart)\n return decimalPart ? `${formattedInteger}.${decimalPart}` : formattedInteger\n },\n [customRoundedValue, maxDecimalPlaces, precision],\n )\n // Validate decimal point is less than or equal to the limit\n const validateDecimalPoint = React.useCallback(\n (value: string) => {\n if (!decimal || value === '-') return true\n\n const [integerPart, decimalPart = ''] = value.split('.')\n const integerLength = integerPart.startsWith('-') ? integerPart.length - 1 : integerPart.length\n const maxIntegerLength = decimal[0] - decimal[1]\n\n return decimalPart.length <= decimal[1] && integerLength <= maxIntegerLength\n },\n [decimal],\n )\n const handleChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n // Don't prevent default behavior of input change\n onChange?.(e)\n\n // Custom event handler for value change\n const { value: inputValue } = e.target\n\n // Handle empty input\n if (!inputValue) {\n onValueChange?.(undefined)\n setValue('')\n return\n }\n\n // Handle zero and negative zero\n const isZero = inputValue === '0'\n const isNegativeZero = inputValue === '-' && allowNegative\n if (isZero || isNegativeZero) {\n onValueChange?.(0)\n setValue(inputValue)\n return\n }\n\n // Validate input format\n const isValid = validationRegex.test(inputValue) && isValidFormat(inputValue) && (decimal || isValidDecimalLength(inputValue))\n if (!isValid) return\n\n const numericValue = parseFloat(inputValue) || 0\n onValueChange?.(numericValue)\n setValue(inputValue)\n },\n [allowNegative, decimal, isValidDecimalLength, isValidFormat, onChange, onValueChange, validationRegex],\n )\n\n const handleFocus = React.useCallback(() => {\n if (readonly) return\n setValue((prev) => prev.replace(/,/g, '')) // Remove commas for easier editing\n }, [readonly])\n\n const handleBlur = React.useCallback(() => {\n if (readonly) return\n onBlur?.()\n setValue((prev) => formattedValue(prev))\n }, [readonly, onBlur, formattedValue])\n\n // Set initial value\n React.useEffect(() => {\n const isFocused = document.activeElement === _inputRef.current\n\n if (\n !initialValue ||\n !validationRegex.test(initialValue.toString()) ||\n !validateDecimalPoint(initialValue.toString()) ||\n (!decimal && isDecimalPointGreaterThanLimit(initialValue.toString()))\n ) {\n setValue('')\n return\n }\n\n setValue((prev) => {\n if (prev === '-') return '-'\n if (!prev) return ''\n return isFocused ? initialValue.toString() : formattedValue(initialValue.toString())\n })\n }, [decimal, formattedValue, initialValue, isDecimalPointGreaterThanLimit, validateDecimalPoint, validationRegex])\n\n // Set padding right for the input field\n React.useEffect(() => {\n if (!_unitRef.current || !_inputRef.current || !unitText) return\n const unitWidth = _unitRef.current.offsetWidth\n _inputRef.current.style.setProperty('padding-right', `${(unitWidth + 10) / 16}rem`)\n }, [disabled, unitText])\n\n return (\n <div className=\"relative\">\n <Input\n {...props}\n ref={_inputRef}\n value={value || (readonly ? '0' : '')}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readonly}\n className={cn('font-number text-end', readonly && 'bg-muted text-muted-foreground')}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n />\n {unitText && (\n <span ref={_unitRef} className=\"text-muted-foreground pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 text-sm\">\n {unitText}\n </span>\n )}\n </div>\n )\n}\n","import { type FieldPath, type FieldValues, useWatch } from 'react-hook-form'\n\nimport { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'\nimport { NumberInput } from '../ui/inputs/number-input'\n\ntype Props<TFieldValues extends FieldValues = FieldValues> = {\n name: FieldPath<TFieldValues>\n label?: string\n description?: string\n placeholder?: string\n unitText?: string\n isShowClearButton?: boolean\n isShowErrorMsg?: boolean\n isShowCount?: boolean\n onValueChange?: (value?: number) => void\n}\nexport const NumberField = <TFieldValues extends FieldValues = FieldValues>({\n name,\n label = 'Number Field',\n placeholder = '0',\n isShowErrorMsg = false,\n isShowCount = false,\n unitText = '',\n description = '',\n onValueChange,\n}: Props<TFieldValues>) => {\n const valueWatch = useWatch({ name })\n\n return (\n <FormField\n name={name}\n render={({ field: { onChange, ...field } }) => (\n <FormItem className=\"w-full gap-0\">\n <FormLabel>{label}</FormLabel>\n <FormControl>\n <NumberInput\n {...field}\n placeholder={placeholder}\n className=\"w-full\"\n unitText={unitText}\n onValueChange={(value) => {\n onChange(value)\n onValueChange?.(value)\n }}\n />\n </FormControl>\n {isShowCount && <div className=\"text-muted-foreground text-end text-xs\">{valueWatch?.length ?? 0} characters</div>}\n {!!description && <FormDescription>{description}</FormDescription>}\n {isShowErrorMsg && <FormMessage />}\n </FormItem>\n )}\n />\n )\n}\n"],"mappings":"wSAOM,EAAyB,GACtB,EAAgB,gBAAkB,cAGrC,EAA0B,GACvB,OAAO,GAAK,iBA+GRA,GAAiC,CAC5C,WAAW,GACX,WAAW,GACX,gBAAgB,GAChB,0BAA0B,EAC1B,eAAe,OACf,MAAO,EAAe,GACtB,WACA,UACA,cACA,YACA,WACA,gBACA,SACA,GAAG,KACC,CACJ,IAAM,EAAWC,EAAAA,QAAM,OAAwB,MACzC,EAAYA,EAAAA,QAAM,OAAyB,MAE3C,CAAC,EAAO,GAAYA,EAAAA,QAAM,SAAiB,EAAa,YAGxD,EAAmB,IAAU,IAAM,EACnC,EAAmB,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AAC,IAAe,EAAA,EAAA,KAACC,EAAAA,gBAAAA,CAAAA,SAAiB,IACnC,IAAkB,EAAA,EAAA,KAACC,EAAAA,YAAAA"}
|
|
@@ -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/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_runtime3.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_runtime2 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_runtime2.JSX.Element;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { NumberField };
|
|
28
28
|
//# sourceMappingURL=number-field.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{cn as e}from"../utils-D9AH0PUV.js";import"../label-
|
|
1
|
+
import{cn as e}from"../utils-D9AH0PUV.js";import"../label-DuddAB1p.js";import{FormControl as t,FormDescription as n,FormField as r,FormItem as i,FormLabel as a,FormMessage as o}from"../form-DZqGhxta.js";import{Input as s}from"../input-nsu0-DwM.js";import c from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";import{useWatch as d}from"react-hook-form";const f=e=>e?/^-?\d*\.?\d*$/:/^\d*\.?\d*$/,p=e=>Number(e).toLocaleString(),m=({disabled:t=!1,readonly:n=!1,allowNegative:r=!1,numberAfterDecimalPoint:i=2,roundingRule:a=`none`,value:o=``,unitText:d,decimal:m,placeholder:h,precision:g,onChange:_,onValueChange:v,onBlur:y,...b})=>{let x=c.useRef(null),S=c.useRef(null),[C,w]=c.useState(o.toString()),T=m?.[1]??i,E=m&&m[0]-m[1],D=c.useMemo(()=>f(r),[r]),O=c.useCallback(e=>{if(!T&&e.includes(`.`))return!1;let t=e.split(`.`)[1];return!t||t.length<=T},[T]),k=c.useCallback(e=>{if(!m||e===`-`)return!0;let[t,n=``]=e.split(`.`);return n.length<=m[1]&&(t.startsWith(`-`)?t.length-1:t.length)<=E},[m,E]),A=c.useCallback((e,t)=>{if(a===`none`)return e;let n=Math.pow(10,t),r=e*n;switch(a){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}},[a]),j=c.useCallback(e=>!i&&e.includes(`.`)||e.split(`.`)[1]?.length>i,[i]),M=c.useCallback(e=>{if(e===`0`)return`0`;if(!Number(e))return``;let t=parseFloat(e),n=Math.min(T-1,g||0),r=A(t,n).toString(),[i,a=``]=r.split(`.`),o=p(i);return a?`${o}.${a}`:o},[A,T,g]),N=c.useCallback(e=>{if(!m||e===`-`)return!0;let[t,n=``]=e.split(`.`),r=t.startsWith(`-`)?t.length-1:t.length,i=m[0]-m[1];return n.length<=m[1]&&r<=i},[m]),P=c.useCallback(e=>{_?.(e);let{value:t}=e.target;if(!t){v?.(void 0),w(``);return}let n=t===`0`,i=t===`-`&&r;if(n||i){v?.(0),w(t);return}let a=D.test(t)&&k(t)&&(m||O(t));if(!a)return;let o=parseFloat(t)||0;v?.(o),w(t)},[r,m,O,k,_,v,D]),F=c.useCallback(()=>{n||w(e=>e.replace(/,/g,``))},[n]),I=c.useCallback(()=>{n||(y?.(),w(e=>M(e)))},[n,y,M]);return c.useEffect(()=>{let e=document.activeElement===S.current;if(!o||!D.test(o.toString())||!N(o.toString())||!m&&j(o.toString())){w(``);return}w(t=>t===`-`?`-`:t?e?o.toString():M(o.toString()):``)},[m,M,o,j,N,D]),c.useEffect(()=>{if(!x.current||!S.current||!d)return;let e=x.current.offsetWidth;S.current.style.setProperty(`padding-right`,`${(e+10)/16}rem`)},[t,d]),u(`div`,{className:`relative`,children:[l(s,{...b,ref:S,value:C||(n?`0`:``),placeholder:h,disabled:t,readOnly:n,className:e(`font-number text-end`,n&&`bg-muted text-muted-foreground`),onChange:P,onFocus:F,onBlur:I}),d&&l(`span`,{ref:x,className:`text-muted-foreground pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 text-sm`,children:d})]})},h=({name:e,label:s=`Number Field`,placeholder:c=`0`,isShowErrorMsg:f=!1,isShowCount:p=!1,unitText:h=``,description:g=``,onValueChange:_})=>{let v=d({name:e});return l(r,{name:e,render:({field:{onChange:e,...r}})=>u(i,{className:`w-full gap-0`,children:[l(a,{children:s}),l(t,{children:l(m,{...r,placeholder:c,className:`w-full`,unitText:h,onValueChange:t=>{e(t),_?.(t)}})}),p&&u(`div`,{className:`text-muted-foreground text-end text-xs`,children:[v?.length??0,` characters`]}),!!g&&l(n,{children:g}),f&&l(o,{})]})})};export{h as NumberField};
|
|
2
2
|
//# sourceMappingURL=number-field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number-field.js","names":["NumberInput: React.FC<IProps>","value","precision","maxIntegerLength"],"sources":["../../packages/components/ui/inputs/number-input.tsx","../../packages/components/forms/number-field.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport { cn } from '@/lib/utils'\n\nimport { Input } from '../input'\n\nconst createValidationRegex = (allowNegative: boolean): RegExp => {\n return allowNegative ? /^-?\\d*\\.?\\d*$/ : /^\\d*\\.?\\d*$/\n}\n\nconst formatNumberWithCommas = (num: number | string): string => {\n return Number(num).toLocaleString()\n}\n\ninterface IProps extends React.HTMLAttributes<HTMLInputElement> {\n /**\n * Description: Value for the text field\n *\n * Default: ''\n *\n * Usage: Value for the text field\n */\n value?: string | number\n /**\n * Description: Disabled state of the text field\n *\n * Default: `false`\n *\n * Usage: Disabled state of the text field\n *\n * Note: If true, the text field will be disabled\n */\n disabled?: boolean\n /**\n * Description: Readonly state of the text field\n *\n * Default: `false`\n *\n * Usage: Readonly state of the text field\n */\n readonly?: boolean\n /**\n * Description: Allow negative value for the text field\n *\n * Default: `false`\n *\n * Usage: Allow negative value for the text field\n */\n allowNegative?: boolean\n /**\n * Description: Decimal point for the text field\n *\n * Default: `undefined`\n *\n * Usage: Ex: [12,3] => console.log(2323.23) // True\n *\n * Note: IF use this prop, `numberAfterDecimalPoint` will be ignored\n */\n decimal?: [number, number]\n /**\n * Description: Rounding rule for the text field\n *\n * Default: `nearest`\n *\n * Usage: Rounding rule for the text field\n */\n roundingRule?: 'up' | 'down' | 'nearest' | 'none'\n /**\n * Description: Number of digits after the decimal point\n *\n * Default: `2`\n *\n * Usage: Number of digits after the decimal point\n */\n numberAfterDecimalPoint?: number\n /**\n * Description: Placeholder for the text field\n *\n * Default: ''\n *\n * Usage: Placeholder for the text field\n */\n placeholder?: string\n /**\n * Description: Unit text for the text field\n *\n * Default: ''\n *\n * E.g. 'kg', 'm', 'USD'...\n */\n unitText?: string\n /**\n * Description: Invalid state of the text field\n *\n * Default: `false`\n *\n * Usage: Invalid state of the text field\n */\n invalid?: boolean\n /**\n * Description: Precision for the text field\n *\n * Default: `undefined`\n * E.g.\n * - 2.13 => 2.1 when precision is 1\n * - 2.134 => 2.13 when precision is 2\n */\n precision?: number\n /**\n * Description: Callback function for the value change\n * Usage: Callback function for the value change\n */\n onValueChange?: (value?: number) => void\n onBlur?: () => void\n}\n/**\n * ## Unit Text Field Component\n *\n * **Description**: This component is to display common text field with unit\n *\n * **Usage**: Text field with unit example: 1000 (kg), 100 (m), 1000 (USD)...\n */\nexport const NumberInput: React.FC<IProps> = ({\n disabled = false,\n readonly = false,\n allowNegative = false,\n numberAfterDecimalPoint = 2,\n roundingRule = 'none',\n value: initialValue = '',\n unitText,\n decimal,\n placeholder,\n precision,\n onChange,\n onValueChange,\n onBlur,\n ...props\n}) => {\n const _unitRef = React.useRef<HTMLSpanElement>(null)\n const _inputRef = React.useRef<HTMLInputElement>(null)\n\n const [value, setValue] = React.useState<string>(initialValue.toString())\n\n // Memoized values for validation and formatting\n const maxDecimalPlaces = decimal?.[1] ?? numberAfterDecimalPoint\n const maxIntegerLength = decimal && decimal[0] - decimal[1]\n const validationRegex = React.useMemo(() => createValidationRegex(allowNegative), [allowNegative])\n\n // Validation functions\n const isValidDecimalLength = React.useCallback(\n (value: string): boolean => {\n if (!maxDecimalPlaces && value.includes('.')) return false\n const decimalPart = value.split('.')[1]\n return !decimalPart || decimalPart.length <= maxDecimalPlaces\n },\n [maxDecimalPlaces],\n )\n const isValidFormat = React.useCallback(\n (value: string): boolean => {\n if (!decimal || value === '-') return true\n const [integerPart, decimalPart = ''] = value.split('.')\n\n return decimalPart.length <= decimal[1] && (integerPart.startsWith('-') ? integerPart.length - 1 : integerPart.length) <= maxIntegerLength!\n },\n [decimal, maxIntegerLength],\n )\n const customRoundedValue = React.useCallback(\n (value: number, precision: number) => {\n if (roundingRule === 'none') return value\n\n const factor = Math.pow(10, precision)\n const scaledValue = value * factor\n\n switch (roundingRule) {\n case 'up':\n return Math.ceil(scaledValue) / factor\n case 'down':\n return Math.floor(scaledValue) / factor\n case 'nearest': {\n if (scaledValue % 1 < 0.1) return Math.floor(scaledValue) / factor\n if (scaledValue % 1 >= 0.59) return Math.ceil(scaledValue) / factor\n return (Math.floor(scaledValue) + 0.5) / factor\n }\n default:\n return value\n }\n },\n [roundingRule],\n )\n const isDecimalPointGreaterThanLimit = React.useCallback(\n (value: string) => (!numberAfterDecimalPoint && value.includes('.')) || value.split('.')[1]?.length > numberAfterDecimalPoint,\n [numberAfterDecimalPoint],\n )\n const formattedValue = React.useCallback(\n (val: string) => {\n if (val === '0') return '0'\n if (!Number(val)) return ''\n\n const numValue = parseFloat(val)\n const effectivePrecision = Math.min(maxDecimalPlaces - 1, precision || 0)\n const roundedValue = customRoundedValue(numValue, effectivePrecision).toString()\n const [integerPart, decimalPart = ''] = roundedValue.split('.')\n const formattedInteger = formatNumberWithCommas(integerPart)\n return decimalPart ? `${formattedInteger}.${decimalPart}` : formattedInteger\n },\n [customRoundedValue, maxDecimalPlaces, precision],\n )\n // Validate decimal point is less than or equal to the limit\n const validateDecimalPoint = React.useCallback(\n (value: string) => {\n if (!decimal || value === '-') return true\n\n const [integerPart, decimalPart = ''] = value.split('.')\n const integerLength = integerPart.startsWith('-') ? integerPart.length - 1 : integerPart.length\n const maxIntegerLength = decimal[0] - decimal[1]\n\n return decimalPart.length <= decimal[1] && integerLength <= maxIntegerLength\n },\n [decimal],\n )\n const handleChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n // Don't prevent default behavior of input change\n onChange?.(e)\n\n // Custom event handler for value change\n const { value: inputValue } = e.target\n\n // Handle empty input\n if (!inputValue) {\n onValueChange?.(undefined)\n setValue('')\n return\n }\n\n // Handle zero and negative zero\n const isZero = inputValue === '0'\n const isNegativeZero = inputValue === '-' && allowNegative\n if (isZero || isNegativeZero) {\n onValueChange?.(0)\n setValue(inputValue)\n return\n }\n\n // Validate input format\n const isValid = validationRegex.test(inputValue) && isValidFormat(inputValue) && (decimal || isValidDecimalLength(inputValue))\n if (!isValid) return\n\n const numericValue = parseFloat(inputValue) || 0\n onValueChange?.(numericValue)\n setValue(inputValue)\n },\n [allowNegative, decimal, isValidDecimalLength, isValidFormat, onChange, onValueChange, validationRegex],\n )\n\n const handleFocus = React.useCallback(() => {\n if (readonly) return\n setValue((prev) => prev.replace(/,/g, '')) // Remove commas for easier editing\n }, [readonly])\n\n const handleBlur = React.useCallback(() => {\n if (readonly) return\n onBlur?.()\n setValue((prev) => formattedValue(prev))\n }, [readonly, onBlur, formattedValue])\n\n // Set initial value\n React.useEffect(() => {\n const isFocused = document.activeElement === _inputRef.current\n\n if (\n !initialValue ||\n !validationRegex.test(initialValue.toString()) ||\n !validateDecimalPoint(initialValue.toString()) ||\n (!decimal && isDecimalPointGreaterThanLimit(initialValue.toString()))\n ) {\n setValue('')\n return\n }\n\n setValue((prev) => {\n if (prev === '-') return '-'\n if (!prev) return ''\n return isFocused ? initialValue.toString() : formattedValue(initialValue.toString())\n })\n }, [decimal, formattedValue, initialValue, isDecimalPointGreaterThanLimit, validateDecimalPoint, validationRegex])\n\n // Set padding right for the input field\n React.useEffect(() => {\n if (!_unitRef.current || !_inputRef.current || !unitText) return\n const unitWidth = _unitRef.current.offsetWidth\n _inputRef.current.style.setProperty('padding-right', `${(unitWidth + 10) / 16}rem`)\n }, [disabled, unitText])\n\n return (\n <div className=\"relative\">\n <Input\n {...props}\n ref={_inputRef}\n value={value || (readonly ? '0' : '')}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readonly}\n className={cn('font-number text-end', readonly && 'bg-muted text-muted-foreground')}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n />\n {unitText && (\n <span ref={_unitRef} className=\"text-muted-foreground pointer-events-none absolute top-1/2 right-2 mt-px -translate-y-1/2 text-sm\">\n {unitText}\n </span>\n )}\n </div>\n )\n}\n","import { type FieldPath, type FieldValues, useWatch } from 'react-hook-form'\n\nimport { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'\nimport { NumberInput } from '../ui/inputs/number-input'\n\ntype Props<TFieldValues extends FieldValues = FieldValues> = {\n name: FieldPath<TFieldValues>\n label?: string\n description?: string\n placeholder?: string\n unitText?: string\n isShowClearButton?: boolean\n isShowErrorMsg?: boolean\n isShowCount?: boolean\n onValueChange?: (value?: number) => void\n}\nexport const NumberField = <TFieldValues extends FieldValues = FieldValues>({\n name,\n label = 'Number Field',\n placeholder = '0',\n isShowErrorMsg = false,\n isShowCount = false,\n unitText = '',\n description = '',\n onValueChange,\n}: Props<TFieldValues>) => {\n const valueWatch = useWatch({ name })\n\n return (\n <FormField\n name={name}\n render={({ field: { onChange, ...field } }) => (\n <FormItem className=\"w-full gap-0\">\n <FormLabel>{label}</FormLabel>\n <FormControl>\n <NumberInput\n {...field}\n placeholder={placeholder}\n className=\"w-full\"\n unitText={unitText}\n onValueChange={(value) => {\n onChange(value)\n onValueChange?.(value)\n }}\n />\n </FormControl>\n {isShowCount && <div className=\"text-muted-foreground text-end text-xs\">{valueWatch?.length ?? 0} characters</div>}\n {!!description && <FormDescription>{description}</FormDescription>}\n {isShowErrorMsg && <FormMessage />}\n </FormItem>\n )}\n />\n )\n}\n"],"mappings":"0WAOA,MAAM,EAAyB,GACtB,EAAgB,gBAAkB,cAGrC,EAA0B,GACvB,OAAO,GAAK,iBA+GRA,GAAiC,CAC5C,WAAW,GACX,WAAW,GACX,gBAAgB,GAChB,0BAA0B,EAC1B,eAAe,OACf,MAAO,EAAe,GACtB,WACA,UACA,cACA,YACA,WACA,gBACA,SACA,GAAG,KACC,CACJ,IAAM,EAAW,EAAM,OAAwB,MACzC,EAAY,EAAM,OAAyB,MAE3C,CAAC,EAAO,GAAY,EAAM,SAAiB,EAAa,YAGxD,EAAmB,IAAU,IAAM,EACnC,EAAmB,GAAW,EAAQ,GAAK,EAAQ,GACnD,EAAkB,EAAM,YAAc,EAAsB,GAAgB,CAAC,IAG7E,EAAuB,EAAM,YAChC,GAA2B,CAC1B,GAAI,CAAC,GAAoBC,EAAM,SAAS,KAAM,MAAO,GACrD,IAAM,EAAcA,EAAM,MAAM,KAAK,GACrC,MAAO,CAAC,GAAe,EAAY,QAAU,GAE/C,CAAC,IAEG,EAAgB,EAAM,YACzB,GAA2B,CAC1B,GAAI,CAAC,GAAWA,IAAU,IAAK,MAA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EACJ,IAAK,EACL,MAAO,IAAU,EAAW,IAAM,IACrB,cACH,WACV,SAAU,EACV,UAAW,EAAG,uBAAwB,GAAY,kCAClD,SAAU,EACV,QAAS,EACT,OAAQ,IAET,GACC,EAAC,OAAA,CAAK,IAAK,EAAU,UAAU,6GAC5B,QCvSE,GAA+D,CAC1E,OACA,QAAQ,eACR,cAAc,IACd,iBAAiB,GACjB,cAAc,GACd,WAAW,GACX,cAAc,GACd,mBACyB,CACzB,IAAM,EAAa,EAAS,CAAE,SAE9B,OACE,EAAC,EAAA,CACO,OACN,QAAS,CAAE,MAAO,CAAE,WAAU,GAAG,MAC/B,EAAC,EAAA,CAAS,UAAU,yBAClB,EAAC,EAAA,CAAA,SAAW,IACZ,EAAC,EAAA,CAAA,SACC,EAAC,EAAA,CACC,GAAI,EACS,cACb,UAAU,SACA,WACV,cAAgB,GAAU,CACxB,EAAS,GACT,IAAgB,QAIrB,GAAe,EAAC,MAAA,CAAI,UAAU,mDAA0C,GAAY,QAAU,EAAE,iBAChG,CAAC,CAAC,GAAe,EAAC,EAAA,CAAA,SAAiB,IACnC,GAAkB,EAAC,EAAA"}
|
|
1
|
+
{"version":3,"file":"number-field.js","names":["NumberInput: React.FC<IProps>","value","precision","maxIntegerLength"],"sources":["../../packages/components/ui/inputs/number-input.tsx","../../packages/components/forms/number-field.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nimport { cn } from '@/lib/utils'\n\nimport { Input } from '../input'\n\nconst createValidationRegex = (allowNegative: boolean): RegExp => {\n return allowNegative ? /^-?\\d*\\.?\\d*$/ : /^\\d*\\.?\\d*$/\n}\n\nconst formatNumberWithCommas = (num: number | string): string => {\n return Number(num).toLocaleString()\n}\n\ninterface IProps extends React.HTMLAttributes<HTMLInputElement> {\n /**\n * Description: Value for the text field\n *\n * Default: ''\n *\n * Usage: Value for the text field\n */\n value?: string | number\n /**\n * Description: Disabled state of the text field\n *\n * Default: `false`\n *\n * Usage: Disabled state of the text field\n *\n * Note: If true, the text field will be disabled\n */\n disabled?: boolean\n /**\n * Description: Readonly state of the text field\n *\n * Default: `false`\n *\n * Usage: Readonly state of the text field\n */\n readonly?: boolean\n /**\n * Description: Allow negative value for the text field\n *\n * Default: `false`\n *\n * Usage: Allow negative value for the text field\n */\n allowNegative?: boolean\n /**\n * Description: Decimal point for the text field\n *\n * Default: `undefined`\n *\n * Usage: Ex: [12,3] => console.log(2323.23) // True\n *\n * Note: IF use this prop, `numberAfterDecimalPoint` will be ignored\n */\n decimal?: [number, number]\n /**\n * Description: Rounding rule for the text field\n *\n * Default: `nearest`\n *\n * Usage: Rounding rule for the text field\n */\n roundingRule?: 'up' | 'down' | 'nearest' | 'none'\n /**\n * Description: Number of digits after the decimal point\n *\n * Default: `2`\n *\n * Usage: Number of digits after the decimal point\n */\n numberAfterDecimalPoint?: number\n /**\n * Description: Placeholder for the text field\n *\n * Default: ''\n *\n * Usage: Placeholder for the text field\n */\n placeholder?: string\n /**\n * Description: Unit text for the text field\n *\n * Default: ''\n *\n * E.g. 'kg', 'm', 'USD'...\n */\n unitText?: string\n /**\n * Description: Invalid state of the text field\n *\n * Default: `false`\n *\n * Usage: Invalid state of the text field\n */\n invalid?: boolean\n /**\n * Description: Precision for the text field\n *\n * Default: `undefined`\n * E.g.\n * - 2.13 => 2.1 when precision is 1\n * - 2.134 => 2.13 when precision is 2\n */\n precision?: number\n /**\n * Description: Callback function for the value change\n * Usage: Callback function for the value change\n */\n onValueChange?: (value?: number) => void\n onBlur?: () => void\n}\n/**\n * ## Unit Text Field Component\n *\n * **Description**: This component is to display common text field with unit\n *\n * **Usage**: Text field with unit example: 1000 (kg), 100 (m), 1000 (USD)...\n */\nexport const NumberInput: React.FC<IProps> = ({\n disabled = false,\n readonly = false,\n allowNegative = false,\n numberAfterDecimalPoint = 2,\n roundingRule = 'none',\n value: initialValue = '',\n unitText,\n decimal,\n placeholder,\n precision,\n onChange,\n onValueChange,\n onBlur,\n ...props\n}) => {\n const _unitRef = React.useRef<HTMLSpanElement>(null)\n const _inputRef = React.useRef<HTMLInputElement>(null)\n\n const [value, setValue] = React.useState<string>(initialValue.toString())\n\n // Memoized values for validation and formatting\n const maxDecimalPlaces = decimal?.[1] ?? numberAfterDecimalPoint\n const maxIntegerLength = decimal && decimal[0] - decimal[1]\n const validationRegex = React.useMemo(() => createValidationRegex(allowNegative), [allowNegative])\n\n // Validation functions\n const isValidDecimalLength = React.useCallback(\n (value: string): boolean => {\n if (!maxDecimalPlaces && value.includes('.')) return false\n const decimalPart = value.split('.')[1]\n return !decimalPart || decimalPart.length <= maxDecimalPlaces\n },\n [maxDecimalPlaces],\n )\n const isValidFormat = React.useCallback(\n (value: string): boolean => {\n if (!decimal || value === '-') return true\n const [integerPart, decimalPart = ''] = value.split('.')\n\n return decimalPart.length <= decimal[1] && (integerPart.startsWith('-') ? integerPart.length - 1 : integerPart.length) <= maxIntegerLength!\n },\n [decimal, maxIntegerLength],\n )\n const customRoundedValue = React.useCallback(\n (value: number, precision: number) => {\n if (roundingRule === 'none') return value\n\n const factor = Math.pow(10, precision)\n const scaledValue = value * factor\n\n switch (roundingRule) {\n case 'up':\n return Math.ceil(scaledValue) / factor\n case 'down':\n return Math.floor(scaledValue) / factor\n case 'nearest': {\n if (scaledValue % 1 < 0.1) return Math.floor(scaledValue) / factor\n if (scaledValue % 1 >= 0.59) return Math.ceil(scaledValue) / factor\n return (Math.floor(scaledValue) + 0.5) / factor\n }\n default:\n return value\n }\n },\n [roundingRule],\n )\n const isDecimalPointGreaterThanLimit = React.useCallback(\n (value: string) => (!numberAfterDecimalPoint && value.includes('.')) || value.split('.')[1]?.length > numberAfterDecimalPoint,\n [numberAfterDecimalPoint],\n )\n const formattedValue = React.useCallback(\n (val: string) => {\n if (val === '0') return '0'\n if (!Number(val)) return ''\n\n const numValue = parseFloat(val)\n const effectivePrecision = Math.min(maxDecimalPlaces - 1, precision || 0)\n const roundedValue = customRoundedValue(numValue, effectivePrecision).toString()\n const [integerPart, decimalPart = ''] = roundedValue.split('.')\n const formattedInteger = formatNumberWithCommas(integerPart)\n return decimalPart ? `${formattedInteger}.${decimalPart}` : formattedInteger\n },\n [customRoundedValue, maxDecimalPlaces, precision],\n )\n // Validate decimal point is less than or equal to the limit\n const validateDecimalPoint = React.useCallback(\n (value: string) => {\n if (!decimal || value === '-') return true\n\n const [integerPart, decimalPart = ''] = value.split('.')\n const integerLength = integerPart.startsWith('-') ? integerPart.length - 1 : integerPart.length\n const maxIntegerLength = decimal[0] - decimal[1]\n\n return decimalPart.length <= decimal[1] && integerLength <= maxIntegerLength\n },\n [decimal],\n )\n const handleChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n // Don't prevent default behavior of input change\n onChange?.(e)\n\n // Custom event handler for value change\n const { value: inputValue } = e.target\n\n // Handle empty input\n if (!inputValue) {\n onValueChange?.(undefined)\n setValue('')\n return\n }\n\n // Handle zero and negative zero\n const isZero = inputValue === '0'\n const isNegativeZero = inputValue === '-' && allowNegative\n if (isZero || isNegativeZero) {\n onValueChange?.(0)\n setValue(inputValue)\n return\n }\n\n // Validate input format\n const isValid = validationRegex.test(inputValue) && isValidFormat(inputValue) && (decimal || isValidDecimalLength(inputValue))\n if (!isValid) return\n\n const numericValue = parseFloat(inputValue) || 0\n onValueChange?.(numericValue)\n setValue(inputValue)\n },\n [allowNegative, decimal, isValidDecimalLength, isValidFormat, onChange, onValueChange, validationRegex],\n )\n\n const handleFocus = React.useCallback(() => {\n if (readonly) return\n setValue((prev) => prev.replace(/,/g, '')) // Remove commas for easier editing\n }, [readonly])\n\n const handleBlur = React.useCallback(() => {\n if (readonly) return\n onBlur?.()\n setValue((prev) => formattedValue(prev))\n }, [readonly, onBlur, formattedValue])\n\n // Set initial value\n React.useEffect(() => {\n const isFocused = document.activeElement === _inputRef.current\n\n if (\n !initialValue ||\n !validationRegex.test(initialValue.toString()) ||\n !validateDecimalPoint(initialValue.toString()) ||\n (!decimal && isDecimalPointGreaterThanLimit(initialValue.toString()))\n ) {\n setValue('')\n return\n }\n\n setValue((prev) => {\n if (prev === '-') return '-'\n if (!prev) return ''\n return isFocused ? initialValue.toString() : formattedValue(initialValue.toString())\n })\n }, [decimal, formattedValue, initialValue, isDecimalPointGreaterThanLimit, validateDecimalPoint, validationRegex])\n\n // Set padding right for the input field\n React.useEffect(() => {\n if (!_unitRef.current || !_inputRef.current || !unitText) return\n const unitWidth = _unitRef.current.offsetWidth\n _inputRef.current.style.setProperty('padding-right', `${(unitWidth + 10) / 16}rem`)\n }, [disabled, unitText])\n\n return (\n <div className=\"relative\">\n <Input\n {...props}\n ref={_inputRef}\n value={value || (readonly ? '0' : '')}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readonly}\n className={cn('font-number text-end', readonly && 'bg-muted text-muted-foreground')}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n />\n {unitText && (\n <span ref={_unitRef} className=\"text-muted-foreground pointer-events-none absolute top-1/2 right-2 -translate-y-1/2 text-sm\">\n {unitText}\n </span>\n )}\n </div>\n )\n}\n","import { type FieldPath, type FieldValues, useWatch } from 'react-hook-form'\n\nimport { FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from '../ui/form'\nimport { NumberInput } from '../ui/inputs/number-input'\n\ntype Props<TFieldValues extends FieldValues = FieldValues> = {\n name: FieldPath<TFieldValues>\n label?: string\n description?: string\n placeholder?: string\n unitText?: string\n isShowClearButton?: boolean\n isShowErrorMsg?: boolean\n isShowCount?: boolean\n onValueChange?: (value?: number) => void\n}\nexport const NumberField = <TFieldValues extends FieldValues = FieldValues>({\n name,\n label = 'Number Field',\n placeholder = '0',\n isShowErrorMsg = false,\n isShowCount = false,\n unitText = '',\n description = '',\n onValueChange,\n}: Props<TFieldValues>) => {\n const valueWatch = useWatch({ name })\n\n return (\n <FormField\n name={name}\n render={({ field: { onChange, ...field } }) => (\n <FormItem className=\"w-full gap-0\">\n <FormLabel>{label}</FormLabel>\n <FormControl>\n <NumberInput\n {...field}\n placeholder={placeholder}\n className=\"w-full\"\n unitText={unitText}\n onValueChange={(value) => {\n onChange(value)\n onValueChange?.(value)\n }}\n />\n </FormControl>\n {isShowCount && <div className=\"text-muted-foreground text-end text-xs\">{valueWatch?.length ?? 0} characters</div>}\n {!!description && <FormDescription>{description}</FormDescription>}\n {isShowErrorMsg && <FormMessage />}\n </FormItem>\n )}\n />\n )\n}\n"],"mappings":"0WAOA,MAAM,EAAyB,GACtB,EAAgB,gBAAkB,cAGrC,EAA0B,GACvB,OAAO,GAAK,iBA+GRA,GAAiC,CAC5C,WAAW,GACX,WAAW,GACX,gBAAgB,GAChB,0BAA0B,EAC1B,eAAe,OACf,MAAO,EAAe,GACtB,WACA,UACA,cACA,YACA,WACA,gBACA,SACA,GAAG,KACC,CACJ,IAAM,EAAW,EAAM,OAAwB,MACzC,EAAY,EAAM,OAAyB,MAE3C,CAAC,EAAO,GAAY,EAAM,SAAiB,EAAa,YAGxD,EAAmB,IAAU,IAAM,EACnC,EAAmB,GAAW,EAAQ,GAAK,EAAQ,GACnD,EAAkB,EAAM,YAAc,EAAsB,GAAgB,CAAC,IAG7E,EAAuB,EAAM,YAChC,GAA2B,CAC1B,GAAI,CAAC,GAAoBC,EAAM,SAAS,KAAM,MAAO,GACrD,IAAM,EAAcA,EAAM,MAAM,KAAK,GACrC,MAAO,CAAC,GAAe,EAAY,QAAU,GAE/C,CAAC,IAEG,EAAgB,EAAM,YACzB,GAA2B,CAC1B,GAAI,CAAC,GAAWA,IAAU,IAAK,MAAO,GACtC,GAAM,CAAC,EAAa,EAAc,IAAMA,EAAM,MAAM,KAEpD,OAAO,EAAY,QAAU,EAAQ,KAAO,EAAY,WAAW,KAAO,EAAY,OAAS,EAAI,EAAY,SAAW,GAE5H,CAAC,EAAS,IAEN,EAAqB,EAAM,aAC9B,EAAe,IAAsB,CACpC,GAAI,IAAiB,OAAQ,OAAOA,EAEpC,IAAM,EAAS,KAAK,IAAI,GAAIC,GACtB,EAAcD,EAAQ,EAE5B,OAAQ,EA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AAS,CAAE,SAE9B,OACE,EAAC,EAAA,CACO,OACN,QAAS,CAAE,MAAO,CAAE,WAAU,GAAG,MAC/B,EAAC,EAAA,CAAS,UAAU,yBAClB,EAAC,EAAA,CAAA,SAAW,IACZ,EAAC,EAAA,CAAA,SACC,EAAC,EAAA,CACC,GAAI,EACS,cACb,UAAU,SACA,WACV,cAAgB,GAAU,CACxB,EAAS,GACT,IAAgB,QAIrB,GAAe,EAAC,MAAA,CAAI,UAAU,mDAA0C,GAAY,QAAU,EAAE,iBAChG,CAAC,CAAC,GAAe,EAAC,EAAA,CAAA,SAAiB,IACnC,GAAkB,EAAC,EAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`),t=require(`../utils-BsjVK5EW.cjs`);require(`../label-
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`),t=require(`../utils-BsjVK5EW.cjs`);require(`../label-CW94D639.cjs`);const n=require(`../form-D13wOyun.cjs`),r=require(`../input-C-60EZ1K.cjs`),i=e.__toESM(require(`react`)),a=e.__toESM(require(`react/jsx-runtime`)),o=e.__toESM(require(`lucide-react`)),s=({className:e,...n})=>{let s=i.default.useId(),[c,l]=i.default.useState(!1),u=i.default.useCallback(()=>l(e=>!e),[]);return(0,a.jsxs)(`div`,{className:`relative`,children:[(0,a.jsx)(r.Input,{...n,id:s,placeholder:`Password`,type:c?`text`:`password`,className:t.cn(`pe-9`,e)}),(0,a.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,a.jsx)(o.EyeOffIcon,{size:16,"aria-hidden":`true`}):(0,a.jsx)(o.EyeIcon,{size:16,"aria-hidden":`true`})})]})},c=({name:e,label:t=`Text Field`,placeholder:r=`Enter text here`,isShowErrorMsg:i=!1,description:o,onValueChange:c})=>(0,a.jsx)(n.FormField,{name:e,render:({field:e})=>(0,a.jsxs)(n.FormItem,{className:`w-full`,children:[(0,a.jsx)(n.FormLabel,{children:t}),(0,a.jsx)(n.FormControl,{children:(0,a.jsx)(s,{placeholder:r,...e,onValueChange:c})}),!!o&&(0,a.jsx)(n.FormDescription,{children:o}),i&&(0,a.jsx)(n.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_runtime5 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_runtime5.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{cn as e}from"../utils-D9AH0PUV.js";import"../label-
|
|
1
|
+
"use client";import{cn as e}from"../utils-D9AH0PUV.js";import"../label-DuddAB1p.js";import{FormControl as t,FormDescription as n,FormField as r,FormItem as i,FormLabel as a,FormMessage as o}from"../form-DZqGhxta.js";import{Input as s}from"../input-nsu0-DwM.js";import c from"react";import{jsx as l,jsxs as u}from"react/jsx-runtime";import{EyeIcon as d,EyeOffIcon as f}from"lucide-react";const p=({className:t,...n})=>{let r=c.useId(),[i,a]=c.useState(!1),o=c.useCallback(()=>a(e=>!e),[]);return u(`div`,{className:`relative`,children:[l(s,{...n,id:r,placeholder:`Password`,type:i?`text`:`password`,className:e(`pe-9`,t)}),l(`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:o,"aria-label":i?`Hide password`:`Show password`,"aria-pressed":i,"aria-controls":`password`,children:l(i?f:d,{size:16,"aria-hidden":`true`})})]})},m=({name:e,label:s=`Text Field`,placeholder:c=`Enter text here`,isShowErrorMsg:d=!1,description:f,onValueChange:m})=>l(r,{name:e,render:({field:e})=>u(i,{className:`w-full`,children:[l(a,{children:s}),l(t,{children:l(p,{placeholder:c,...e,onValueChange:m})}),!!f&&l(n,{children:f}),d&&l(o,{})]})});export{m as PasswordField};
|
|
2
2
|
//# sourceMappingURL=password-field.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`),t=require(`../utils-BsjVK5EW.cjs`);require(`../label-
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`),t=require(`../utils-BsjVK5EW.cjs`);require(`../label-CW94D639.cjs`);const n=require(`../form-D13wOyun.cjs`),r=require(`../select-BQqcz6WZ.cjs`),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)(n.FormField,{name:e,render:({field:e})=>(0,i.jsxs)(n.FormItem,{className:t.cn(`w-full`,f),children:[l&&(0,i.jsx)(n.FormLabel,{children:a}),(0,i.jsxs)(r.Select,{defaultValue:e.value,onValueChange:e.onChange,children:[(0,i.jsx)(n.FormControl,{children:(0,i.jsx)(r.SelectTrigger,{className:`w-full`,children:(0,i.jsx)(r.SelectValue,{placeholder:o})})}),(0,i.jsx)(r.SelectContent,{children:c.map(e=>(0,i.jsx)(r.SelectItem,{disabled:s.includes(e.value),value:e.value,children:e.label},e.value))})]}),!!d&&(0,i.jsx)(n.FormDescription,{children:d}),u&&(0,i.jsx)(n.FormMessage,{})]})});exports.SelectField=a;
|
|
2
2
|
//# sourceMappingURL=select-field.cjs.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/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_runtime5.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_runtime7 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_runtime7.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{cn as e}from"../utils-D9AH0PUV.js";import"../label-
|
|
1
|
+
"use client";import{cn as e}from"../utils-D9AH0PUV.js";import"../label-DuddAB1p.js";import{FormControl as t,FormDescription as n,FormField as r,FormItem as i,FormLabel as a,FormMessage as o}from"../form-DZqGhxta.js";import{Select as s,SelectContent as c,SelectItem as l,SelectTrigger as u,SelectValue as d}from"../select-RKVYJMTd.js";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(r,{name:m,render:({field:r})=>p(i,{className:e(`w-full`,S),children:[y&&f(a,{children:h}),p(s,{defaultValue:r.value,onValueChange:r.onChange,children:[f(t,{children:f(u,{className:`w-full`,children:f(d,{placeholder:g})})}),f(c,{children:v.map(e=>f(l,{disabled:_.includes(e.value),value:e.value,children:e.label},e.value))})]}),!!x&&f(n,{children:x}),b&&f(o,{})]})});export{m as SelectField};
|
|
2
2
|
//# sourceMappingURL=select-field.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`),t=require(`../utils-BsjVK5EW.cjs`);require(`../label-
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`),t=require(`../utils-BsjVK5EW.cjs`);require(`../label-CW94D639.cjs`);const n=require(`../form-D13wOyun.cjs`),r=require(`../switch-bfoTi9s3.cjs`),i=e.__toESM(require(`react/jsx-runtime`)),a=({name:e,label:a=`Switch Field`,description:o,isShowErrorMsg:s=!1})=>(0,i.jsx)(n.FormField,{name:e,render:({field:e})=>(0,i.jsxs)(`div`,{className:`spage-y-1`,children:[(0,i.jsxs)(n.FormItem,{className:t.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)(n.FormLabel,{className:`cursor-pointer text-sm`,children:a}),o&&(0,i.jsx)(n.FormDescription,{className:`text-xs`,children:o})]}),(0,i.jsx)(n.FormControl,{children:(0,i.jsx)(r.Switch,{checked:e.value,onCheckedChange:e.onChange})})]}),s&&(0,i.jsx)(n.FormMessage,{})]})});exports.SwitchField=a;
|
|
2
2
|
//# sourceMappingURL=switch-field.cjs.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/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_runtime7.JSX.Element;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { SwitchField };
|
|
19
19
|
//# sourceMappingURL=switch-field.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime4 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_runtime4.JSX.Element;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { SwitchField };
|
|
19
19
|
//# sourceMappingURL=switch-field.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{cn as e}from"../utils-D9AH0PUV.js";import"../label-
|
|
1
|
+
"use client";import{cn as e}from"../utils-D9AH0PUV.js";import"../label-DuddAB1p.js";import{FormControl as t,FormDescription as n,FormField as r,FormItem as i,FormLabel as a,FormMessage as o}from"../form-DZqGhxta.js";import{Switch as s}from"../switch-B9LmV-PS.js";import{jsx as c,jsxs as l}from"react/jsx-runtime";const u=({name:u,label:d=`Switch Field`,description:f,isShowErrorMsg:p=!1})=>c(r,{name:u,render:({field:r})=>l(`div`,{className:`spage-y-1`,children:[l(i,{className:e(`border-border-weak flex flex-row items-center justify-between rounded-lg border p-3 shadow-xs`),children:[l(`div`,{className:`space-y-0.5`,children:[c(a,{className:`cursor-pointer text-sm`,children:d}),f&&c(n,{className:`text-xs`,children:f})]}),c(t,{children:c(s,{checked:r.value,onCheckedChange:r.onChange})})]}),p&&c(o,{})]})});export{u as SwitchField};
|
|
2
2
|
//# sourceMappingURL=switch-field.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`),t=require(`../utils-BsjVK5EW.cjs`)
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`),t=require(`../utils-BsjVK5EW.cjs`);require(`../label-CW94D639.cjs`);const n=require(`../form-D13wOyun.cjs`),r=require(`../input-C-60EZ1K.cjs`),i=require(`../flex-B5MQmxX8.cjs`),a=e.__toESM(require(`react`)),o=e.__toESM(require(`react/jsx-runtime`)),s=e.__toESM(require(`lucide-react`)),c=e.__toESM(require(`react-hook-form`)),l=({name:e,label:l=`Text Field`,placeholder:u=`Enter text here`,isShowLabel:d=!0,isShowClearButton:f=!1,isShowErrorMsg:p=!1,isShowCount:m=!1,description:h,className:g=``,onValueChange:_})=>{let{resetField:v}=n.useFormField(),y=(0,c.useWatch)({name:e}),b=a.default.useCallback(()=>{v(e)},[v,e]);return(0,o.jsx)(n.FormField,{name:e,render:({field:e})=>(0,o.jsxs)(n.FormItem,{className:t.cn(`w-full gap-0`,m||!!h&&`space-y-1`,g),children:[d&&(0,o.jsx)(n.FormLabel,{children:l}),(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(n.FormControl,{children:(0,o.jsx)(r.Input,{...e,placeholder:u,className:t.cn(`w-full`,f&&`pr-9`),onValueChange:_})}),f&&y&&(0,o.jsx)(`button`,{type:`button`,className:`text-muted-foreground/80 hover:text-accent-foreground focus-visible:ring-border absolute inset-y-0 end-0 flex h-full w-8 cursor-pointer items-center justify-center rounded-e-md transition-[color,box-shadow] outline-none focus:z-10 focus-visible:ring-2`,"aria-label":`Clear input`,onClick:b,children:(0,o.jsx)(s.XIcon,{size:14,"aria-hidden":`true`})})]}),(0,o.jsxs)(i.Flex,{width:`full`,padding:`none`,justify:`end`,children:[p&&(0,o.jsx)(n.FormMessage,{className:`grow`}),m&&(0,o.jsxs)(`div`,{className:`text-muted-foreground text-end text-xs`,children:[y?.length??0,` characters`]})]}),!!h&&(0,o.jsx)(n.FormDescription,{children:h})]})})};exports.TextField=l;
|
|
2
2
|
//# sourceMappingURL=text-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/text-field.d.ts
|
|
@@ -25,7 +25,7 @@ declare const TextField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
25
25
|
description,
|
|
26
26
|
className,
|
|
27
27
|
onValueChange
|
|
28
|
-
}: Props<TFieldValues>) =>
|
|
28
|
+
}: Props<TFieldValues>) => react_jsx_runtime9.JSX.Element;
|
|
29
29
|
//#endregion
|
|
30
30
|
export { TextField };
|
|
31
31
|
//# sourceMappingURL=text-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/text-field.d.ts
|
|
@@ -25,7 +25,7 @@ declare const TextField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
25
25
|
description,
|
|
26
26
|
className,
|
|
27
27
|
onValueChange
|
|
28
|
-
}: Props<TFieldValues>) =>
|
|
28
|
+
}: Props<TFieldValues>) => react_jsx_runtime9.JSX.Element;
|
|
29
29
|
//#endregion
|
|
30
30
|
export { TextField };
|
|
31
31
|
//# sourceMappingURL=text-field.d.ts.map
|
package/dist/forms/text-field.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import{cn as e}from"../utils-D9AH0PUV.js";import
|
|
1
|
+
"use client";import{cn as e}from"../utils-D9AH0PUV.js";import"../label-DuddAB1p.js";import{FormControl as t,FormDescription as n,FormField as r,FormItem as i,FormLabel as a,FormMessage as o,useFormField as s}from"../form-DZqGhxta.js";import{Input as c}from"../input-nsu0-DwM.js";import{Flex as l}from"../flex-CBAzUoXK.js";import u from"react";import{jsx as d,jsxs as f}from"react/jsx-runtime";import{XIcon as p}from"lucide-react";import{useWatch as m}from"react-hook-form";const h=({name:h,label:g=`Text Field`,placeholder:_=`Enter text here`,isShowLabel:v=!0,isShowClearButton:y=!1,isShowErrorMsg:b=!1,isShowCount:x=!1,description:S,className:C=``,onValueChange:w})=>{let{resetField:T}=s(),E=m({name:h}),D=u.useCallback(()=>{T(h)},[T,h]);return d(r,{name:h,render:({field:r})=>f(i,{className:e(`w-full gap-0`,x||!!S&&`space-y-1`,C),children:[v&&d(a,{children:g}),f(`div`,{className:`relative`,children:[d(t,{children:d(c,{...r,placeholder:_,className:e(`w-full`,y&&`pr-9`),onValueChange:w})}),y&&E&&d(`button`,{type:`button`,className:`text-muted-foreground/80 hover:text-accent-foreground focus-visible:ring-border absolute inset-y-0 end-0 flex h-full w-8 cursor-pointer items-center justify-center rounded-e-md transition-[color,box-shadow] outline-none focus:z-10 focus-visible:ring-2`,"aria-label":`Clear input`,onClick:D,children:d(p,{size:14,"aria-hidden":`true`})})]}),f(l,{width:`full`,padding:`none`,justify:`end`,children:[b&&d(o,{className:`grow`}),x&&f(`div`,{className:`text-muted-foreground text-end text-xs`,children:[E?.length??0,` characters`]})]}),!!S&&d(n,{children:S})]})})};export{h as TextField};
|
|
2
2
|
//# sourceMappingURL=text-field.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../utils-BsjVK5EW.cjs`),require(`../label-
|
|
1
|
+
"use client";const e=require(`../chunk-CUT6urMc.cjs`);require(`../utils-BsjVK5EW.cjs`),require(`../label-CW94D639.cjs`);const t=require(`../form-D13wOyun.cjs`),n=require(`../textarea-DzxaJFbk.cjs`),r=e.__toESM(require(`react/jsx-runtime`)),i=e.__toESM(require(`react-hook-form`)),a=({name:e,label:a=`Textarea Field`,placeholder:o=`Enter text here`,isShowErrorMsg:s=!1,isShowCount:c=!1,description:l,rows:u=3,onValueChange:d})=>{let f=(0,i.useWatch)({name:e});return(0,r.jsx)(t.FormField,{name:e,render:({field:e})=>(0,r.jsxs)(t.FormItem,{className:`w-full`,children:[(0,r.jsx)(t.FormLabel,{children:a}),(0,r.jsx)(t.FormControl,{children:(0,r.jsx)(n.Textarea,{...e,placeholder:o,className:`w-full`,rows:u,onValueChange:d})}),c&&(0,r.jsxs)(`div`,{className:`text-muted-foreground text-end text-xs`,children:[f?.length??0,` characters`]}),!!l&&(0,r.jsx)(t.FormDescription,{children:l}),s&&(0,r.jsx)(t.FormMessage,{})]})})};exports.TextareaField=a;
|
|
2
2
|
//# sourceMappingURL=textarea-field.cjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime11 from "react/jsx-runtime";
|
|
2
2
|
import { FieldPath, FieldValues } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
//#region packages/components/forms/textarea-field.d.ts
|
|
@@ -21,7 +21,7 @@ declare const TextareaField: <TFieldValues extends FieldValues = FieldValues>({
|
|
|
21
21
|
description,
|
|
22
22
|
rows,
|
|
23
23
|
onValueChange
|
|
24
|
-
}: Props<TFieldValues>) =>
|
|
24
|
+
}: Props<TFieldValues>) => react_jsx_runtime11.JSX.Element;
|
|
25
25
|
//#endregion
|
|
26
26
|
export { TextareaField };
|
|
27
27
|
//# sourceMappingURL=textarea-field.d.cts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";import"../utils-D9AH0PUV.js";import"../label-
|
|
1
|
+
"use client";import"../utils-D9AH0PUV.js";import"../label-DuddAB1p.js";import{FormControl as e,FormDescription as t,FormField as n,FormItem as r,FormLabel as i,FormMessage as a}from"../form-DZqGhxta.js";import{Textarea as o}from"../textarea-B9T9ZzvL.js";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{useWatch as l}from"react-hook-form";const u=({name:u,label:d=`Textarea Field`,placeholder:f=`Enter text here`,isShowErrorMsg:p=!1,isShowCount:m=!1,description:h,rows:g=3,onValueChange:_})=>{let v=l({name:u});return s(n,{name:u,render:({field:n})=>c(r,{className:`w-full`,children:[s(i,{children:d}),s(e,{children:s(o,{...n,placeholder:f,className:`w-full`,rows:g,onValueChange:_})}),m&&c(`div`,{className:`text-muted-foreground text-end text-xs`,children:[v?.length??0,` characters`]}),!!h&&s(t,{children:h}),p&&s(a,{})]})})};export{u as TextareaField};
|
|
2
2
|
//# sourceMappingURL=textarea-field.js.map
|