@customafk/lunas-ui 0.0.7 → 0.0.9
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-BaABbnol.js → add-new-BaTjxsdU.js} +1 -1
- package/dist/{add-new-BaABbnol.js.map → add-new-BaTjxsdU.js.map} +1 -1
- package/dist/{add-new-DUoS_-n2.cjs → add-new-aIL8RwI8.cjs} +2 -2
- package/dist/{add-new-DUoS_-n2.cjs.map → add-new-aIL8RwI8.cjs.map} +1 -1
- package/dist/alert-dialog-0KwdjY-6.js.map +1 -1
- package/dist/{alert-dialog-D5ZqgIiC.cjs → alert-dialog-BQv-ZvW9.cjs} +2 -2
- package/dist/{alert-dialog-D5ZqgIiC.cjs.map → alert-dialog-BQv-ZvW9.cjs.map} +1 -1
- package/dist/badge-D_qEoSL8.js.map +1 -1
- package/dist/{badge-CRXT2dH_.cjs → badge-DfSj5nwV.cjs} +2 -2
- package/dist/{badge-CRXT2dH_.cjs.map → badge-DfSj5nwV.cjs.map} +1 -1
- package/dist/button-Bku3bKv9.js.map +1 -1
- package/dist/button-Blg2XhHo.d.ts +23 -0
- package/dist/{button-Dzv_nos1.cjs → button-CycE0WzB.cjs} +2 -2
- package/dist/{button-Dzv_nos1.cjs.map → button-CycE0WzB.cjs.map} +1 -1
- package/dist/button-DThtZ8g0.d.cts +23 -0
- package/dist/calendar-5D53vIAn.js +2 -0
- package/dist/calendar-5D53vIAn.js.map +1 -0
- package/dist/calendar-CPFb8F_s.cjs +2 -0
- package/dist/calendar-CPFb8F_s.cjs.map +1 -0
- package/dist/{card-Dta5eW8u.cjs → card-D7C05tvk.cjs} +2 -2
- package/dist/{card-Dta5eW8u.cjs.map → card-D7C05tvk.cjs.map} +1 -1
- package/dist/card-D8cxRC5y.js.map +1 -1
- package/dist/cards/simple-card.cjs +1 -1
- package/dist/cards/simple-card.cjs.map +1 -1
- package/dist/cards/simple-card.d.cts +2 -1
- package/dist/cards/simple-card.d.ts +2 -1
- package/dist/cards/simple-card.js.map +1 -1
- package/dist/chunk-hhQzssFb.cjs +1 -0
- package/dist/command-ByvjNMyq.d.cts +53 -0
- package/dist/{command-CsntVmEz.cjs → command-D8k85t1c.cjs} +2 -2
- package/dist/{command-CsntVmEz.cjs.map → command-D8k85t1c.cjs.map} +1 -1
- package/dist/command-DXhsKiMq.d.ts +53 -0
- package/dist/{command-_L9bD9a-.js → command-DieInaEN.js} +1 -1
- package/dist/{command-_L9bD9a-.js.map → command-DieInaEN.js.map} +1 -1
- package/dist/data-display/country.cjs +1 -1
- package/dist/data-display/country.cjs.map +1 -1
- package/dist/data-display/country.d.ts +1 -1
- package/dist/data-display/country.js.map +1 -1
- package/dist/data-display/data-list.cjs +1 -1
- package/dist/data-display/data-list.cjs.map +1 -1
- package/dist/data-display/data-list.js.map +1 -1
- package/dist/data-display/date.cjs +1 -1
- package/dist/data-display/empty.cjs +1 -1
- package/dist/data-display/empty.d.cts +3 -1
- package/dist/data-display/empty.d.ts +3 -1
- package/dist/data-display/name.cjs +1 -1
- package/dist/data-display/name.cjs.map +1 -1
- package/dist/data-display/name.js.map +1 -1
- package/dist/data-display/phone-number.cjs +1 -1
- package/dist/data-display/phone-number.cjs.map +1 -1
- package/dist/data-display/phone-number.js.map +1 -1
- package/dist/data-display/role-badge.cjs +1 -1
- package/dist/data-display/role-badge.cjs.map +1 -1
- package/dist/data-display/role-badge.d.ts +1 -1
- package/dist/data-display/role-badge.js.map +1 -1
- package/dist/data-display/statistic.cjs +1 -1
- package/dist/data-display/statistic.cjs.map +1 -1
- package/dist/data-display/statistic.d.cts +25 -1
- package/dist/data-display/statistic.d.ts +25 -1
- package/dist/data-display/statistic.js +1 -1
- package/dist/data-display/statistic.js.map +1 -1
- package/dist/date-BMq_DNsv.js.map +1 -1
- package/dist/{date-nd8WkPlx.cjs → date-ByLOGsKl.cjs} +2 -2
- package/dist/{date-nd8WkPlx.cjs.map → date-ByLOGsKl.cjs.map} +1 -1
- package/dist/{dialog-MLCAvDJH.d.ts → dialog-B3V9xxdD.d.cts} +12 -11
- package/dist/dialog-C4hf-Puw.js.map +1 -1
- package/dist/{dialog-W-DmDMEE.cjs → dialog-Cn8cFeu-.cjs} +2 -2
- package/dist/{dialog-W-DmDMEE.cjs.map → dialog-Cn8cFeu-.cjs.map} +1 -1
- package/dist/{dialog-D3VF5qxy.d.cts → dialog-Dlozd6qY.d.ts} +12 -11
- package/dist/dialogs/confirm-dialog.cjs +1 -1
- package/dist/dialogs/confirm-dialog.cjs.map +1 -1
- package/dist/dialogs/confirm-dialog.js.map +1 -1
- package/dist/dialogs/detail-dialog/index.cjs +1 -1
- package/dist/dialogs/detail-dialog/index.cjs.map +1 -1
- package/dist/dialogs/detail-dialog/index.js +1 -1
- package/dist/dialogs/detail-dialog/index.js.map +1 -1
- package/dist/dialogs/error-dialog.cjs +1 -1
- package/dist/dialogs/form-dialog.cjs +1 -1
- package/dist/dialogs/form-dialog.cjs.map +1 -1
- package/dist/dialogs/form-dialog.d.cts +2 -1
- package/dist/dialogs/form-dialog.d.ts +2 -1
- package/dist/dialogs/form-dialog.js.map +1 -1
- package/dist/dialogs/loading-dialog.cjs +1 -1
- package/dist/dialogs/loading-dialog.cjs.map +1 -1
- package/dist/dialogs/loading-dialog.js.map +1 -1
- package/dist/{dropdown-menu-Bv18S56o.cjs → dropdown-menu-D2Kh77uw.cjs} +2 -2
- package/dist/{dropdown-menu-Bv18S56o.cjs.map → dropdown-menu-D2Kh77uw.cjs.map} +1 -1
- package/dist/{dropdown-menu-jCQwh2rG.js → dropdown-menu-DTFOCPH_.js} +1 -1
- package/dist/{dropdown-menu-jCQwh2rG.js.map → dropdown-menu-DTFOCPH_.js.map} +1 -1
- package/dist/{error-dialog-DpQgL5Hy.cjs → error-dialog-DO0Bb-pi.cjs} +2 -2
- package/dist/{error-dialog-DpQgL5Hy.cjs.map → error-dialog-DO0Bb-pi.cjs.map} +1 -1
- package/dist/error-dialog-D_4WL-Hj.js.map +1 -1
- package/dist/flex-ILvQrYMJ.js.map +1 -1
- package/dist/{flex-CNA_SId-.cjs → flex-yTyoLpgH.cjs} +2 -2
- package/dist/{flex-CNA_SId-.cjs.map → flex-yTyoLpgH.cjs.map} +1 -1
- package/dist/form-CA4hhSV5.js.map +1 -1
- package/dist/{form-CYZkgobJ.cjs → form-C_PCHrpx.cjs} +2 -2
- package/dist/{form-CYZkgobJ.cjs.map → form-C_PCHrpx.cjs.map} +1 -1
- package/dist/form-wrapper-D-2Uz518.js.map +1 -1
- package/dist/{form-wrapper-BYbwt1zC.cjs → form-wrapper-FYiHHas7.cjs} +2 -2
- package/dist/{form-wrapper-BYbwt1zC.cjs.map → form-wrapper-FYiHHas7.cjs.map} +1 -1
- package/dist/forms/combobox-field.cjs +42 -0
- package/dist/forms/combobox-field.cjs.map +1 -0
- package/dist/forms/combobox-field.d.cts +28 -0
- package/dist/forms/combobox-field.d.ts +28 -0
- package/dist/forms/combobox-field.js +42 -0
- package/dist/forms/combobox-field.js.map +1 -0
- package/dist/forms/date-field.cjs +2 -0
- package/dist/forms/date-field.cjs.map +1 -0
- package/dist/forms/date-field.d.cts +22 -0
- package/dist/forms/date-field.d.ts +22 -0
- package/dist/forms/date-field.js +2 -0
- package/dist/forms/date-field.js.map +1 -0
- package/dist/forms/form-wrapper.cjs +1 -1
- package/dist/forms/form-wrapper.d.cts +2 -1
- package/dist/forms/form-wrapper.d.ts +2 -1
- package/dist/forms/multi-select-field.cjs +2 -0
- package/dist/forms/multi-select-field.cjs.map +1 -0
- package/dist/forms/multi-select-field.d.cts +30 -0
- package/dist/forms/multi-select-field.d.ts +30 -0
- package/dist/forms/multi-select-field.js +2 -0
- package/dist/forms/multi-select-field.js.map +1 -0
- package/dist/forms/number-field.cjs +2 -0
- package/dist/forms/number-field.cjs.map +1 -0
- package/dist/forms/number-field.d.cts +28 -0
- package/dist/forms/number-field.d.ts +28 -0
- package/dist/forms/number-field.js +2 -0
- package/dist/forms/number-field.js.map +1 -0
- package/dist/forms/password-field.cjs +2 -0
- package/dist/forms/password-field.cjs.map +1 -0
- package/dist/forms/password-field.d.cts +23 -0
- package/dist/forms/password-field.d.ts +23 -0
- package/dist/forms/password-field.js +2 -0
- package/dist/forms/password-field.js.map +1 -0
- package/dist/forms/select-field.cjs +2 -0
- package/dist/forms/select-field.cjs.map +1 -0
- package/dist/forms/select-field.d.cts +33 -0
- package/dist/forms/select-field.d.ts +33 -0
- package/dist/forms/select-field.js +2 -0
- package/dist/forms/select-field.js.map +1 -0
- package/dist/forms/switch-field.cjs +2 -0
- package/dist/forms/switch-field.cjs.map +1 -0
- package/dist/forms/switch-field.d.cts +19 -0
- package/dist/forms/switch-field.d.ts +19 -0
- package/dist/forms/switch-field.js +2 -0
- package/dist/forms/switch-field.js.map +1 -0
- package/dist/forms/text-field.cjs +2 -0
- package/dist/forms/text-field.cjs.map +1 -0
- package/dist/forms/text-field.d.cts +31 -0
- package/dist/forms/text-field.d.ts +31 -0
- package/dist/forms/text-field.js +2 -0
- package/dist/forms/text-field.js.map +1 -0
- package/dist/forms/textarea-field.cjs +2 -0
- package/dist/forms/textarea-field.cjs.map +1 -0
- package/dist/forms/textarea-field.d.cts +27 -0
- package/dist/forms/textarea-field.d.ts +27 -0
- package/dist/forms/textarea-field.js +2 -0
- package/dist/forms/textarea-field.js.map +1 -0
- package/dist/{input-DXEBB91E.cjs → input-C8Sebaue.cjs} +2 -2
- package/dist/{input-DXEBB91E.cjs.map → input-C8Sebaue.cjs.map} +1 -1
- package/dist/{input-D0Phuz25.d.cts → input-DlRU8OGl.d.cts} +3 -2
- package/dist/{input-FzKbxUq2.js → input-Dmaq3fzf.js} +1 -1
- package/dist/{input-FzKbxUq2.js.map → input-Dmaq3fzf.js.map} +1 -1
- package/dist/{input-tHIKXxVS.d.ts → input-yduNlg8y.d.ts} +3 -2
- package/dist/label-Cxbctr6x.js.map +1 -1
- package/dist/{label-CunjD1rx.cjs → label-i858Jr98.cjs} +2 -2
- package/dist/{label-CunjD1rx.cjs.map → label-i858Jr98.cjs.map} +1 -1
- package/dist/layouts/flex.cjs +1 -1
- package/dist/layouts/flex.d.cts +13 -2
- package/dist/layouts/flex.d.ts +13 -2
- package/dist/layouts/main/index.cjs +1 -1
- package/dist/layouts/main/index.cjs.map +1 -1
- package/dist/layouts/main/index.d.cts +14 -4
- package/dist/layouts/main/index.d.ts +14 -4
- package/dist/layouts/main/index.js +1 -1
- package/dist/layouts/main/index.js.map +1 -1
- package/dist/multi-select-Bbv0Z0TP.js +2 -0
- package/dist/multi-select-Bbv0Z0TP.js.map +1 -0
- package/dist/multi-select-EqlnkO5V.cjs +2 -0
- package/dist/multi-select-EqlnkO5V.cjs.map +1 -0
- package/dist/paragraph-Bey03JkA.js.map +1 -1
- package/dist/{paragraph-ZxI8zxuf.cjs → paragraph-DWQ0PZt_.cjs} +2 -2
- package/dist/{paragraph-ZxI8zxuf.cjs.map → paragraph-DWQ0PZt_.cjs.map} +1 -1
- package/dist/popover-B8j86VQv.js +2 -0
- package/dist/popover-B8j86VQv.js.map +1 -0
- package/dist/popover-CAokgoc_.cjs +2 -0
- package/dist/popover-CAokgoc_.cjs.map +1 -0
- package/dist/{progress-BnnOfAZN.cjs → progress-CHh9eRZi.cjs} +2 -2
- package/dist/{progress-BnnOfAZN.cjs.map → progress-CHh9eRZi.cjs.map} +1 -1
- package/dist/{progress-CBccqUUJ.js → progress-CeXKNvJc.js} +1 -1
- package/dist/{progress-CBccqUUJ.js.map → progress-CeXKNvJc.js.map} +1 -1
- package/dist/{refresh-BHt_h3N_.js → refresh-B__T7OFC.js} +1 -1
- package/dist/{refresh-BHt_h3N_.js.map → refresh-B__T7OFC.js.map} +1 -1
- package/dist/{refresh-DrolZxuC.cjs → refresh-BuL5nDf9.cjs} +2 -2
- package/dist/{refresh-DrolZxuC.cjs.map → refresh-BuL5nDf9.cjs.map} +1 -1
- package/dist/{scroll-area-Bdb_LSFF.js → scroll-area-C0KQbcG0.js} +1 -1
- package/dist/{scroll-area-Bdb_LSFF.js.map → scroll-area-C0KQbcG0.js.map} +1 -1
- package/dist/{scroll-area-DWWpaz5j.cjs → scroll-area-fNeFxa8L.cjs} +2 -2
- package/dist/{scroll-area-DWWpaz5j.cjs.map → scroll-area-fNeFxa8L.cjs.map} +1 -1
- package/dist/{search-input-L2sq0eB0.js → search-input-BGmx8sXy.js} +2 -2
- package/dist/{search-input-L2sq0eB0.js.map → search-input-BGmx8sXy.js.map} +1 -1
- package/dist/{search-input-Bf4-FeWu.cjs → search-input-CWCcWgmA.cjs} +2 -2
- package/dist/{search-input-Bf4-FeWu.cjs.map → search-input-CWCcWgmA.cjs.map} +1 -1
- package/dist/{select-CWUsisI0.js → select-4IO3vAjO.js} +1 -1
- package/dist/{select-CWUsisI0.js.map → select-4IO3vAjO.js.map} +1 -1
- package/dist/{select-ZSyt5zCe.cjs → select-UsiicIRo.cjs} +2 -2
- package/dist/{select-ZSyt5zCe.cjs.map → select-UsiicIRo.cjs.map} +1 -1
- package/dist/{separator-2cwfp8qT.d.ts → separator-C4XPc_2Y.d.cts} +3 -2
- package/dist/{separator-DTB3sDNG.cjs → separator-D4iTmsID.cjs} +2 -2
- package/dist/{separator-DTB3sDNG.cjs.map → separator-D4iTmsID.cjs.map} +1 -1
- package/dist/{separator-BpsL0PlX.js → separator-DMdqEz29.js} +1 -1
- package/dist/{separator-BpsL0PlX.js.map → separator-DMdqEz29.js.map} +1 -1
- package/dist/{separator-COXs-I-Q.d.cts → separator-o7tKOtGF.d.ts} +3 -2
- package/dist/{sheet-C8r2QGpq.js → sheet-2JqHfdYi.js} +1 -1
- package/dist/{sheet-C8r2QGpq.js.map → sheet-2JqHfdYi.js.map} +1 -1
- package/dist/{sheet-CCwbAaA6.cjs → sheet-Dr-a3-o2.cjs} +2 -2
- package/dist/{sheet-CCwbAaA6.cjs.map → sheet-Dr-a3-o2.cjs.map} +1 -1
- package/dist/{sidebar-C166f_9B.js → sidebar-COBzB7S8.js} +2 -2
- package/dist/{sidebar-C166f_9B.js.map → sidebar-COBzB7S8.js.map} +1 -1
- package/dist/{sidebar-BLPMNltJ.cjs → sidebar-gXuaHBie.cjs} +2 -2
- package/dist/{sidebar-BLPMNltJ.cjs.map → sidebar-gXuaHBie.cjs.map} +1 -1
- package/dist/{skeleton-m3giaF4T.cjs → skeleton-BTQm_mtV.cjs} +2 -2
- package/dist/{skeleton-m3giaF4T.cjs.map → skeleton-BTQm_mtV.cjs.map} +1 -1
- package/dist/{skeleton-DYmX0k94.js → skeleton-D1_Brnl9.js} +1 -1
- package/dist/{skeleton-DYmX0k94.js.map → skeleton-D1_Brnl9.js.map} +1 -1
- package/dist/switch-BlK-TC1h.js +2 -0
- package/dist/switch-BlK-TC1h.js.map +1 -0
- package/dist/switch-CoP3UwNk.cjs +2 -0
- package/dist/switch-CoP3UwNk.cjs.map +1 -0
- package/dist/table/index.cjs +1 -1
- package/dist/table/index.cjs.map +1 -1
- package/dist/table/index.d.cts +2 -1
- package/dist/table/index.d.ts +2 -1
- package/dist/table/index.js +1 -1
- package/dist/table/index.js.map +1 -1
- package/dist/{table-BSeev7T0.cjs → table-CFqnfTKO.cjs} +2 -2
- package/dist/{table-BSeev7T0.cjs.map → table-CFqnfTKO.cjs.map} +1 -1
- package/dist/{table-BvA64mE8.js → table-DrnU8YJP.js} +1 -1
- package/dist/{table-BvA64mE8.js.map → table-DrnU8YJP.js.map} +1 -1
- package/dist/textarea-Dz6npuI4.cjs +2 -0
- package/dist/textarea-Dz6npuI4.cjs.map +1 -0
- package/dist/textarea-dM1DYNfF.js +2 -0
- package/dist/textarea-dM1DYNfF.js.map +1 -0
- package/dist/{title-DTkABsIG.js → title-CA6PvqiD.js} +1 -1
- package/dist/{title-DTkABsIG.js.map → title-CA6PvqiD.js.map} +1 -1
- package/dist/{title-xsPZpQpb.cjs → title-CIQdEGOd.cjs} +2 -2
- package/dist/{title-xsPZpQpb.cjs.map → title-CIQdEGOd.cjs.map} +1 -1
- package/dist/toggle-BCSHdzP0.d.cts +20 -0
- package/dist/{toggle-D_MDMruK.js → toggle-CHJ2edke.js} +1 -1
- package/dist/{toggle-D_MDMruK.js.map → toggle-CHJ2edke.js.map} +1 -1
- package/dist/{toggle-CfL3GVe2.cjs → toggle-CzMYdDvC.cjs} +2 -2
- package/dist/{toggle-CfL3GVe2.cjs.map → toggle-CzMYdDvC.cjs.map} +1 -1
- package/dist/toggle-D42pqCTD.d.ts +20 -0
- package/dist/tooltip-DZ2Shzgg.d.ts +24 -0
- package/dist/tooltip-Dn8AOhc4.d.cts +24 -0
- package/dist/tooltip-Dzyf5smh.js.map +1 -1
- package/dist/{tooltip-Beb-_EPp.cjs → tooltip-MgToVOzy.cjs} +2 -2
- package/dist/{tooltip-Beb-_EPp.cjs.map → tooltip-MgToVOzy.cjs.map} +1 -1
- package/dist/{types-DLrIc2fL.d.ts → types-CmcNT14g.d.ts} +1 -1
- package/dist/types-CrbWxjnp.cjs.map +1 -1
- package/dist/types-DaIHddx7.js.map +1 -1
- package/dist/typography/paragraph.cjs +1 -1
- package/dist/typography/paragraph.d.cts +2 -1
- package/dist/typography/paragraph.d.ts +2 -1
- package/dist/typography/title.cjs +1 -1
- package/dist/typography/title.d.cts +3 -1
- package/dist/typography/title.d.ts +3 -1
- package/dist/typography/title.js +1 -1
- package/dist/ui/alert-dialog.cjs +1 -1
- package/dist/ui/alert-dialog.d.cts +12 -11
- package/dist/ui/alert-dialog.d.ts +12 -11
- package/dist/ui/alert.cjs +1 -1
- package/dist/ui/alert.cjs.map +1 -1
- package/dist/ui/alert.d.cts +8 -4
- package/dist/ui/alert.d.ts +8 -4
- package/dist/ui/alert.js.map +1 -1
- package/dist/ui/aspect-ratio.cjs +1 -1
- package/dist/ui/aspect-ratio.cjs.map +1 -1
- package/dist/ui/aspect-ratio.d.cts +2 -1
- package/dist/ui/aspect-ratio.d.ts +2 -1
- package/dist/ui/aspect-ratio.js.map +1 -1
- package/dist/ui/avatar.cjs +1 -1
- package/dist/ui/avatar.cjs.map +1 -1
- package/dist/ui/avatar.d.cts +4 -3
- package/dist/ui/avatar.d.ts +4 -3
- package/dist/ui/avatar.js.map +1 -1
- package/dist/ui/badge.cjs +1 -1
- package/dist/ui/badge.d.cts +8 -2
- package/dist/ui/badge.d.ts +8 -2
- package/dist/ui/breadcrumb.cjs +1 -1
- package/dist/ui/breadcrumb.cjs.map +1 -1
- package/dist/ui/breadcrumb.d.cts +8 -7
- package/dist/ui/breadcrumb.d.ts +8 -7
- package/dist/ui/breadcrumb.js.map +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/buttons/add-new.cjs +1 -1
- package/dist/ui/buttons/add-new.js +1 -1
- package/dist/ui/buttons/refresh.cjs +1 -1
- package/dist/ui/buttons/refresh.js +1 -1
- package/dist/ui/calendar.cjs +1 -2
- package/dist/ui/calendar.d.cts +4 -3
- package/dist/ui/calendar.d.ts +4 -3
- package/dist/ui/calendar.js +1 -2
- package/dist/ui/card.cjs +1 -1
- package/dist/ui/card.d.cts +8 -7
- package/dist/ui/card.d.ts +8 -7
- package/dist/ui/carousel.cjs +1 -1
- package/dist/ui/carousel.cjs.map +1 -1
- package/dist/ui/carousel.d.cts +7 -6
- package/dist/ui/carousel.d.ts +7 -6
- package/dist/ui/carousel.js.map +1 -1
- package/dist/ui/collapsible.cjs +1 -1
- package/dist/ui/collapsible.cjs.map +1 -1
- package/dist/ui/collapsible.d.cts +4 -3
- package/dist/ui/collapsible.d.ts +4 -3
- package/dist/ui/collapsible.js.map +1 -1
- package/dist/ui/command.cjs +1 -1
- package/dist/ui/command.d.cts +3 -52
- package/dist/ui/command.d.ts +3 -52
- package/dist/ui/command.js +1 -1
- package/dist/ui/context-menu.cjs +1 -1
- package/dist/ui/context-menu.cjs.map +1 -1
- package/dist/ui/context-menu.d.cts +16 -15
- package/dist/ui/context-menu.d.ts +16 -15
- package/dist/ui/context-menu.js.map +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/dropdown-menu.cjs +1 -1
- package/dist/ui/dropdown-menu.d.cts +16 -15
- package/dist/ui/dropdown-menu.d.ts +16 -15
- package/dist/ui/dropdown-menu.js +1 -1
- package/dist/ui/file-uploader.cjs +1 -1
- package/dist/ui/file-uploader.cjs.map +1 -1
- package/dist/ui/file-uploader.d.cts +2 -1
- package/dist/ui/file-uploader.d.ts +2 -1
- package/dist/ui/file-uploader.js +1 -1
- package/dist/ui/file-uploader.js.map +1 -1
- package/dist/ui/form.cjs +1 -1
- package/dist/ui/form.d.cts +23 -8
- package/dist/ui/form.d.ts +23 -8
- package/dist/ui/hover-card.cjs +1 -1
- package/dist/ui/hover-card.cjs.map +1 -1
- package/dist/ui/hover-card.d.cts +4 -3
- package/dist/ui/hover-card.d.ts +4 -3
- package/dist/ui/hover-card.js.map +1 -1
- package/dist/ui/input-otp.cjs +1 -1
- package/dist/ui/input-otp.cjs.map +1 -1
- package/dist/ui/input-otp.d.cts +5 -4
- package/dist/ui/input-otp.d.ts +5 -4
- package/dist/ui/input-otp.js.map +1 -1
- 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 -2
- package/dist/ui/inputs/search-input.d.ts +3 -2
- package/dist/ui/inputs/search-input.js +1 -1
- package/dist/ui/label.cjs +1 -1
- package/dist/ui/label.d.cts +2 -1
- package/dist/ui/label.d.ts +2 -1
- package/dist/ui/menubar.cjs +1 -1
- package/dist/ui/menubar.cjs.map +1 -1
- package/dist/ui/menubar.d.cts +17 -16
- package/dist/ui/menubar.d.ts +17 -16
- package/dist/ui/menubar.js.map +1 -1
- package/dist/ui/multi-select.cjs +1 -2
- package/dist/ui/multi-select.d.cts +61 -1
- package/dist/ui/multi-select.d.ts +61 -1
- package/dist/ui/multi-select.js +1 -2
- package/dist/ui/navigation-menu.cjs +1 -1
- package/dist/ui/navigation-menu.cjs.map +1 -1
- package/dist/ui/navigation-menu.d.cts +11 -9
- package/dist/ui/navigation-menu.d.ts +11 -9
- package/dist/ui/navigation-menu.js.map +1 -1
- package/dist/ui/pagination.cjs +1 -1
- package/dist/ui/pagination.cjs.map +1 -1
- package/dist/ui/pagination.d.cts +9 -8
- package/dist/ui/pagination.d.ts +9 -8
- package/dist/ui/pagination.js.map +1 -1
- package/dist/ui/popover.cjs +1 -2
- package/dist/ui/popover.d.cts +5 -4
- package/dist/ui/popover.d.ts +5 -4
- package/dist/ui/popover.js +1 -2
- package/dist/ui/progress.cjs +1 -1
- package/dist/ui/progress.d.cts +2 -1
- package/dist/ui/progress.d.ts +2 -1
- package/dist/ui/progress.js +1 -1
- package/dist/ui/radio-group.cjs +1 -1
- package/dist/ui/radio-group.cjs.map +1 -1
- package/dist/ui/radio-group.d.cts +3 -2
- package/dist/ui/radio-group.d.ts +3 -2
- package/dist/ui/radio-group.js.map +1 -1
- package/dist/ui/resizable.cjs +1 -1
- package/dist/ui/resizable.cjs.map +1 -1
- package/dist/ui/resizable.d.cts +4 -3
- package/dist/ui/resizable.d.ts +4 -3
- package/dist/ui/resizable.js.map +1 -1
- package/dist/ui/scroll-area.cjs +1 -1
- package/dist/ui/scroll-area.d.cts +3 -2
- package/dist/ui/scroll-area.d.ts +3 -2
- package/dist/ui/scroll-area.js +1 -1
- package/dist/ui/select.cjs +1 -1
- package/dist/ui/select.d.cts +11 -10
- package/dist/ui/select.d.ts +11 -10
- package/dist/ui/select.js +1 -1
- package/dist/ui/separator.cjs +1 -1
- package/dist/ui/separator.d.cts +1 -1
- package/dist/ui/separator.d.ts +1 -1
- package/dist/ui/separator.js +1 -1
- package/dist/ui/sheet.cjs +1 -1
- package/dist/ui/sheet.d.cts +9 -8
- package/dist/ui/sheet.d.ts +9 -8
- package/dist/ui/sheet.js +1 -1
- package/dist/ui/sidebar.cjs +1 -1
- package/dist/ui/sidebar.d.cts +43 -29
- package/dist/ui/sidebar.d.ts +43 -29
- package/dist/ui/sidebar.js +1 -1
- package/dist/ui/skeleton.cjs +1 -1
- package/dist/ui/skeleton.d.cts +2 -1
- package/dist/ui/skeleton.d.ts +2 -1
- package/dist/ui/skeleton.js +1 -1
- package/dist/ui/slider.cjs +1 -1
- package/dist/ui/slider.cjs.map +1 -1
- package/dist/ui/slider.d.cts +2 -1
- package/dist/ui/slider.d.ts +2 -1
- package/dist/ui/slider.js.map +1 -1
- package/dist/ui/sonner.cjs +1 -1
- package/dist/ui/sonner.cjs.map +1 -1
- package/dist/ui/sonner.d.cts +3 -1
- package/dist/ui/sonner.d.ts +3 -1
- package/dist/ui/sonner.js.map +1 -1
- package/dist/ui/switch.cjs +1 -2
- package/dist/ui/switch.d.cts +2 -1
- package/dist/ui/switch.d.ts +2 -1
- package/dist/ui/switch.js +1 -2
- package/dist/ui/table.cjs +1 -1
- package/dist/ui/table.d.cts +9 -8
- package/dist/ui/table.d.ts +9 -8
- package/dist/ui/table.js +1 -1
- package/dist/ui/tabs.cjs +1 -1
- package/dist/ui/tabs.cjs.map +1 -1
- package/dist/ui/tabs.d.cts +5 -4
- package/dist/ui/tabs.d.ts +5 -4
- package/dist/ui/tabs.js.map +1 -1
- package/dist/ui/textarea.cjs +1 -2
- package/dist/ui/textarea.d.cts +2 -1
- package/dist/ui/textarea.d.ts +2 -1
- package/dist/ui/textarea.js +1 -2
- package/dist/ui/toggle-group.cjs +1 -1
- package/dist/ui/toggle-group.cjs.map +1 -1
- package/dist/ui/toggle-group.d.cts +4 -3
- package/dist/ui/toggle-group.d.ts +4 -3
- package/dist/ui/toggle-group.js +1 -1
- package/dist/ui/toggle-group.js.map +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/utils-D9AH0PUV.js +1 -1
- package/dist/utils-D9AH0PUV.js.map +1 -1
- package/dist/utils-DaJ1XZgX.cjs +2 -0
- package/dist/{utils-BsjVK5EW.cjs.map → utils-DaJ1XZgX.cjs.map} +1 -1
- package/package.json +51 -4
- package/packages/components/cards/simple-card.tsx +37 -0
- package/packages/components/data-display/country.tsx +59 -0
- package/packages/components/data-display/data-list.tsx +38 -0
- package/packages/components/data-display/date.tsx +215 -0
- package/packages/components/data-display/empty.tsx +25 -0
- package/packages/components/data-display/name.tsx +25 -0
- package/packages/components/data-display/phone-number.tsx +22 -0
- package/packages/components/data-display/role-badge.tsx +33 -0
- package/packages/components/data-display/statistic.tsx +141 -0
- package/packages/components/dialogs/confirm-dialog.tsx +51 -0
- package/packages/components/dialogs/detail-dialog/component/header.tsx +14 -0
- package/packages/components/dialogs/detail-dialog/component/main.tsx +39 -0
- package/packages/components/dialogs/detail-dialog/component/sidebar.tsx +747 -0
- package/packages/components/dialogs/detail-dialog/component/wrapper.tsx +17 -0
- package/packages/components/dialogs/detail-dialog/index.tsx +100 -0
- package/packages/components/dialogs/error-dialog.tsx +48 -0
- package/packages/components/dialogs/form-dialog.tsx +106 -0
- package/packages/components/dialogs/loading-dialog.tsx +23 -0
- package/packages/components/forms/combobox-field.tsx +113 -0
- package/packages/components/forms/date-field.tsx +65 -0
- package/packages/components/forms/form-wrapper.tsx +146 -0
- package/packages/components/forms/multi-select-field.tsx +56 -0
- package/packages/components/forms/number-field.tsx +56 -0
- package/packages/components/forms/password-field.tsx +38 -0
- package/packages/components/forms/select-field.tsx +58 -0
- package/packages/components/forms/switch-field.tsx +42 -0
- package/packages/components/forms/text-field.tsx +80 -0
- package/packages/components/forms/textarea-field.tsx +53 -0
- package/packages/components/index.tsx +0 -0
- package/packages/components/layouts/flex.tsx +110 -0
- package/packages/components/layouts/main/content.tsx +11 -0
- package/packages/components/layouts/main/header.tsx +53 -0
- package/packages/components/layouts/main/index.tsx +3 -0
- package/packages/components/layouts/main/wrapper.tsx +5 -0
- package/packages/components/table/data-table-pagination.tsx +99 -0
- package/packages/components/table/data-table.tsx +328 -0
- package/packages/components/table/index.tsx +126 -0
- package/packages/components/typography/paragraph.tsx +32 -0
- package/packages/components/typography/title.tsx +36 -0
- package/packages/components/ui/alert-dialog.tsx +173 -0
- package/packages/components/ui/alert.tsx +71 -0
- package/packages/components/ui/aspect-ratio.tsx +20 -0
- package/packages/components/ui/avatar.tsx +52 -0
- package/packages/components/ui/badge.tsx +63 -0
- package/packages/components/ui/breadcrumb.tsx +110 -0
- package/packages/components/ui/button.tsx +88 -0
- package/packages/components/ui/buttons/add-new.tsx +26 -0
- package/packages/components/ui/buttons/refresh.tsx +30 -0
- package/packages/components/ui/calendar.tsx +209 -0
- package/packages/components/ui/card.tsx +95 -0
- package/packages/components/ui/carousel.tsx +241 -0
- package/packages/components/ui/checkbox.tsx +44 -0
- package/packages/components/ui/collapsible.tsx +33 -0
- package/packages/components/ui/command.tsx +217 -0
- package/packages/components/ui/context-menu.tsx +258 -0
- package/packages/components/ui/dialog.tsx +174 -0
- package/packages/components/ui/dropdown-menu.tsx +318 -0
- package/packages/components/ui/file-uploader.tsx +372 -0
- package/packages/components/ui/form.tsx +168 -0
- package/packages/components/ui/hover-card.tsx +43 -0
- package/packages/components/ui/input-otp.tsx +76 -0
- package/packages/components/ui/input.tsx +59 -0
- package/packages/components/ui/inputs/number-input.tsx +325 -0
- package/packages/components/ui/inputs/password-input.tsx +35 -0
- package/packages/components/ui/inputs/search-input.tsx +24 -0
- package/packages/components/ui/label.tsx +29 -0
- package/packages/components/ui/menubar.tsx +275 -0
- package/packages/components/ui/multi-select.tsx +693 -0
- package/packages/components/ui/navigation-menu.tsx +170 -0
- package/packages/components/ui/pagination.tsx +128 -0
- package/packages/components/ui/popover.tsx +64 -0
- package/packages/components/ui/progress.tsx +30 -0
- package/packages/components/ui/radio-group.tsx +53 -0
- package/packages/components/ui/resizable.tsx +55 -0
- package/packages/components/ui/scroll-area.tsx +51 -0
- package/packages/components/ui/select.tsx +246 -0
- package/packages/components/ui/separator.tsx +27 -0
- package/packages/components/ui/sheet.tsx +155 -0
- package/packages/components/ui/sidebar.tsx +751 -0
- package/packages/components/ui/skeleton.tsx +15 -0
- package/packages/components/ui/slider.tsx +62 -0
- package/packages/components/ui/sonner.tsx +43 -0
- package/packages/components/ui/switch.tsx +52 -0
- package/packages/components/ui/table.tsx +118 -0
- package/packages/components/ui/tabs.tsx +85 -0
- package/packages/components/ui/textarea.tsx +47 -0
- package/packages/components/ui/toggle-group.tsx +72 -0
- package/packages/components/ui/toggle.tsx +47 -0
- package/packages/components/ui/tooltip.tsx +71 -0
- package/packages/constants.tsx +79 -0
- package/packages/hooks/use-callback-ref.ts +27 -0
- package/packages/hooks/use-controllable-state.ts +67 -0
- package/packages/hooks/use-mobile.ts +21 -0
- package/packages/index.css +392 -0
- package/packages/lib/utils.ts +28 -0
- package/packages/types.ts +50 -0
- package/dist/button-D_E_bNRb.d.ts +0 -18
- package/dist/button-YHI7I64h.d.cts +0 -18
- package/dist/chunk-CUT6urMc.cjs +0 -1
- package/dist/toggle-BVkMTVAz.d.ts +0 -15
- package/dist/toggle-CW-ZnYMy.d.cts +0 -15
- package/dist/tooltip-Cjuu_Ld4.d.ts +0 -23
- package/dist/tooltip-Dk4HsZVR.d.cts +0 -23
- package/dist/ui/calendar.cjs.map +0 -1
- package/dist/ui/calendar.js.map +0 -1
- package/dist/ui/multi-select.cjs.map +0 -1
- package/dist/ui/multi-select.js.map +0 -1
- package/dist/ui/popover.cjs.map +0 -1
- package/dist/ui/popover.js.map +0 -1
- package/dist/ui/switch.cjs.map +0 -1
- package/dist/ui/switch.js.map +0 -1
- package/dist/ui/textarea.cjs.map +0 -1
- package/dist/ui/textarea.js.map +0 -1
- package/dist/utils-BsjVK5EW.cjs +0 -2
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Command as CommandPrimitive, useCommandState } from "cmdk";
|
|
4
|
+
import { PlusIcon, X } from "lucide-react";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Command,
|
|
8
|
+
CommandGroup,
|
|
9
|
+
CommandItem,
|
|
10
|
+
CommandList,
|
|
11
|
+
CommandSeparator,
|
|
12
|
+
} from "@/components/ui/command";
|
|
13
|
+
import { cn } from "@/lib/utils";
|
|
14
|
+
|
|
15
|
+
import { Button } from "./button";
|
|
16
|
+
|
|
17
|
+
export interface Option {
|
|
18
|
+
value: string;
|
|
19
|
+
label: string;
|
|
20
|
+
disable?: boolean;
|
|
21
|
+
/** fixed option that can‘t be removed. */
|
|
22
|
+
fixed?: boolean;
|
|
23
|
+
/** Group the options by providing key. */
|
|
24
|
+
[key: string]: string | boolean | undefined;
|
|
25
|
+
}
|
|
26
|
+
interface GroupOption {
|
|
27
|
+
[key: string]: Option[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface MultipleSelectorProps {
|
|
31
|
+
value?: Option[];
|
|
32
|
+
defaultOptions?: Option[];
|
|
33
|
+
/** manually controlled options */
|
|
34
|
+
options?: Option[];
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
/** Loading component. */
|
|
37
|
+
loadingIndicator?: React.ReactNode;
|
|
38
|
+
/** Empty component. */
|
|
39
|
+
emptyIndicator?: React.ReactNode;
|
|
40
|
+
/** Debounce time for async search. Only work with `onSearch`. */
|
|
41
|
+
delay?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Only work with `onSearch` prop. Trigger search when `onFocus`.
|
|
44
|
+
* For example, when user click on the input, it will trigger the search to get initial options.
|
|
45
|
+
**/
|
|
46
|
+
triggerSearchOnFocus?: boolean;
|
|
47
|
+
/** async search */
|
|
48
|
+
onSearch?: (value: string) => Promise<Option[]>;
|
|
49
|
+
/**
|
|
50
|
+
* sync search. This search will not showing loadingIndicator.
|
|
51
|
+
* The rest props are the same as async search.
|
|
52
|
+
* i.e.: creatable, groupBy, delay.
|
|
53
|
+
**/
|
|
54
|
+
onSearchSync?: (value: string) => Option[];
|
|
55
|
+
onChange?: (options: Option[]) => void;
|
|
56
|
+
/** Limit the maximum number of selected options. */
|
|
57
|
+
maxSelected?: number;
|
|
58
|
+
/** When the number of selected options exceeds the limit, the onMaxSelected will be called. */
|
|
59
|
+
onMaxSelected?: (maxLimit: number) => void;
|
|
60
|
+
/** Hide the placeholder when there are options selected. */
|
|
61
|
+
hidePlaceholderWhenSelected?: boolean;
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
/** Group the options base on provided key. */
|
|
64
|
+
groupBy?: string;
|
|
65
|
+
className?: string;
|
|
66
|
+
badgeClassName?: string;
|
|
67
|
+
/**
|
|
68
|
+
* First item selected is a default behavior by cmdk. That is why the default is true.
|
|
69
|
+
* This is a workaround solution by add a dummy item.
|
|
70
|
+
*
|
|
71
|
+
* @reference: https://github.com/pacocoursey/cmdk/issues/171
|
|
72
|
+
*/
|
|
73
|
+
selectFirstItem?: boolean;
|
|
74
|
+
/** Allow user to create option when there is no option matched. */
|
|
75
|
+
creatable?: boolean;
|
|
76
|
+
/** Props of `Command` */
|
|
77
|
+
commandProps?: React.ComponentPropsWithoutRef<typeof Command>;
|
|
78
|
+
/** Props of `CommandInput` */
|
|
79
|
+
inputProps?: Omit<
|
|
80
|
+
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>,
|
|
81
|
+
"value" | "placeholder" | "disabled"
|
|
82
|
+
>;
|
|
83
|
+
/** hide the clear all button. */
|
|
84
|
+
hideClearAllButton?: boolean;
|
|
85
|
+
|
|
86
|
+
/** Add new item event for select with search */
|
|
87
|
+
onAddNewItem?: () => void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface MultipleSelectorRef {
|
|
91
|
+
selectedValue: Option[];
|
|
92
|
+
input: HTMLInputElement;
|
|
93
|
+
focus: () => void;
|
|
94
|
+
reset: () => void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
98
|
+
export function useDebounce<T>(value: T, delay?: number): T {
|
|
99
|
+
const [debouncedValue, setDebouncedValue] = React.useState<T>(value);
|
|
100
|
+
|
|
101
|
+
React.useEffect(() => {
|
|
102
|
+
const timer = setTimeout(() => setDebouncedValue(value), delay || 500);
|
|
103
|
+
|
|
104
|
+
return () => {
|
|
105
|
+
clearTimeout(timer);
|
|
106
|
+
};
|
|
107
|
+
}, [value, delay]);
|
|
108
|
+
|
|
109
|
+
return debouncedValue;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function transToGroupOption(options: Option[], groupBy?: string) {
|
|
113
|
+
if (options.length === 0) {
|
|
114
|
+
return {};
|
|
115
|
+
}
|
|
116
|
+
if (!groupBy) {
|
|
117
|
+
return {
|
|
118
|
+
"": options,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const groupOption: GroupOption = {};
|
|
123
|
+
options.forEach((option) => {
|
|
124
|
+
const key = (option[groupBy] as string) || "";
|
|
125
|
+
if (!groupOption[key]) {
|
|
126
|
+
groupOption[key] = [];
|
|
127
|
+
}
|
|
128
|
+
groupOption[key].push(option);
|
|
129
|
+
});
|
|
130
|
+
return groupOption;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function removePickedOption(groupOption: GroupOption, picked: Option[]) {
|
|
134
|
+
const cloneOption = JSON.parse(JSON.stringify(groupOption)) as GroupOption;
|
|
135
|
+
|
|
136
|
+
for (const [key, value] of Object.entries(cloneOption)) {
|
|
137
|
+
cloneOption[key] = value.filter(
|
|
138
|
+
(val) => !picked.find((p) => p.value === val.value),
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
return cloneOption;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function isOptionsExist(groupOption: GroupOption, targetOption: Option[]) {
|
|
145
|
+
for (const [, value] of Object.entries(groupOption)) {
|
|
146
|
+
if (
|
|
147
|
+
value.some((option) => targetOption.find((p) => p.value === option.value))
|
|
148
|
+
) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The `CommandEmpty` of shadcn/ui will cause the cmdk empty not rendering correctly.
|
|
157
|
+
* So we create one and copy the `Empty` implementation from `cmdk`.
|
|
158
|
+
*
|
|
159
|
+
* @reference: https://github.com/hsuanyi-chou/shadcn-ui-expansions/issues/34#issuecomment-1949561607
|
|
160
|
+
**/
|
|
161
|
+
const CommandEmpty = React.forwardRef<
|
|
162
|
+
HTMLDivElement,
|
|
163
|
+
React.ComponentProps<typeof CommandPrimitive.Empty>
|
|
164
|
+
>(({ className, ...props }, forwardedRef) => {
|
|
165
|
+
const render = useCommandState((state) => state.filtered.count === 0);
|
|
166
|
+
|
|
167
|
+
if (!render) return null;
|
|
168
|
+
|
|
169
|
+
return (
|
|
170
|
+
<div
|
|
171
|
+
ref={forwardedRef}
|
|
172
|
+
className={cn("px-2 py-4 text-center text-sm", className)}
|
|
173
|
+
cmdk-empty=""
|
|
174
|
+
role="presentation"
|
|
175
|
+
{...props}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
CommandEmpty.displayName = "CommandEmpty";
|
|
181
|
+
|
|
182
|
+
const MultipleSelector = React.forwardRef<
|
|
183
|
+
MultipleSelectorRef,
|
|
184
|
+
MultipleSelectorProps
|
|
185
|
+
>(
|
|
186
|
+
(
|
|
187
|
+
{
|
|
188
|
+
value,
|
|
189
|
+
onChange,
|
|
190
|
+
placeholder,
|
|
191
|
+
defaultOptions: arrayDefaultOptions = [],
|
|
192
|
+
options: arrayOptions,
|
|
193
|
+
delay,
|
|
194
|
+
onSearch,
|
|
195
|
+
onSearchSync,
|
|
196
|
+
loadingIndicator: LoadingIndicator,
|
|
197
|
+
emptyIndicator,
|
|
198
|
+
maxSelected = Number.MAX_SAFE_INTEGER,
|
|
199
|
+
onMaxSelected,
|
|
200
|
+
hidePlaceholderWhenSelected,
|
|
201
|
+
disabled,
|
|
202
|
+
groupBy,
|
|
203
|
+
className,
|
|
204
|
+
badgeClassName,
|
|
205
|
+
selectFirstItem = true,
|
|
206
|
+
creatable = false,
|
|
207
|
+
triggerSearchOnFocus = false,
|
|
208
|
+
commandProps,
|
|
209
|
+
inputProps,
|
|
210
|
+
hideClearAllButton = false,
|
|
211
|
+
onAddNewItem,
|
|
212
|
+
}: MultipleSelectorProps,
|
|
213
|
+
ref: React.Ref<MultipleSelectorRef>,
|
|
214
|
+
) => {
|
|
215
|
+
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
216
|
+
const dropdownRef = React.useRef<HTMLDivElement>(null); // Added this
|
|
217
|
+
|
|
218
|
+
const [open, setOpen] = React.useState(false);
|
|
219
|
+
const [onScrollbar, setOnScrollbar] = React.useState(false);
|
|
220
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
221
|
+
|
|
222
|
+
const [selected, setSelected] = React.useState<Option[]>(value || []);
|
|
223
|
+
const [options, setOptions] = React.useState<GroupOption>(
|
|
224
|
+
transToGroupOption(arrayDefaultOptions, groupBy),
|
|
225
|
+
);
|
|
226
|
+
const [inputValue, setInputValue] = React.useState("");
|
|
227
|
+
|
|
228
|
+
const debouncedSearchTerm = useDebounce(inputValue, delay || 500);
|
|
229
|
+
|
|
230
|
+
React.useImperativeHandle(
|
|
231
|
+
ref,
|
|
232
|
+
() => ({
|
|
233
|
+
selectedValue: [...selected],
|
|
234
|
+
input: inputRef.current as HTMLInputElement,
|
|
235
|
+
focus: () => inputRef?.current?.focus(),
|
|
236
|
+
reset: () => setSelected([]),
|
|
237
|
+
}),
|
|
238
|
+
[selected],
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
const handleClickOutside = React.useCallback(
|
|
242
|
+
(event: MouseEvent | TouchEvent) => {
|
|
243
|
+
if (
|
|
244
|
+
dropdownRef.current &&
|
|
245
|
+
!dropdownRef.current.contains(event.target as Node) &&
|
|
246
|
+
inputRef.current &&
|
|
247
|
+
!inputRef.current.contains(event.target as Node)
|
|
248
|
+
) {
|
|
249
|
+
setOpen(false);
|
|
250
|
+
inputRef.current.blur();
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
[],
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
const handleUnselect = React.useCallback(
|
|
257
|
+
(option: Option) => {
|
|
258
|
+
const newOptions = selected.filter((s) => s.value !== option.value);
|
|
259
|
+
setSelected(newOptions);
|
|
260
|
+
onChange?.(newOptions);
|
|
261
|
+
},
|
|
262
|
+
[onChange, selected],
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
const handleKeyDown = React.useCallback(
|
|
266
|
+
(e: React.KeyboardEvent<HTMLDivElement>) => {
|
|
267
|
+
const input = inputRef.current;
|
|
268
|
+
if (!input) return;
|
|
269
|
+
|
|
270
|
+
if (e.key === "Delete" || e.key === "Backspace") {
|
|
271
|
+
if (input.value === "" && selected.length > 0) {
|
|
272
|
+
const lastSelectOption = selected[selected.length - 1];
|
|
273
|
+
// If last item is fixed, we should not remove it.
|
|
274
|
+
if (!lastSelectOption.fixed) {
|
|
275
|
+
handleUnselect(selected[selected.length - 1]);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// This is not a default behavior of the <input /> field
|
|
281
|
+
if (e.key === "Escape") {
|
|
282
|
+
input.blur();
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
[handleUnselect, selected],
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
React.useEffect(() => {
|
|
289
|
+
if (open) {
|
|
290
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
291
|
+
document.addEventListener("touchend", handleClickOutside);
|
|
292
|
+
} else {
|
|
293
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
294
|
+
document.removeEventListener("touchend", handleClickOutside);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
return () => {
|
|
298
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
299
|
+
document.removeEventListener("touchend", handleClickOutside);
|
|
300
|
+
};
|
|
301
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
302
|
+
}, [open]);
|
|
303
|
+
|
|
304
|
+
React.useEffect(() => {
|
|
305
|
+
if (value) {
|
|
306
|
+
setSelected(value);
|
|
307
|
+
}
|
|
308
|
+
}, [value]);
|
|
309
|
+
|
|
310
|
+
React.useEffect(() => {
|
|
311
|
+
/** If `onSearch` is provided, do not trigger options updated. */
|
|
312
|
+
if (!arrayOptions || onSearch) {
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const newOption = transToGroupOption(arrayOptions || [], groupBy);
|
|
316
|
+
if (JSON.stringify(newOption) !== JSON.stringify(options)) {
|
|
317
|
+
setOptions(newOption);
|
|
318
|
+
}
|
|
319
|
+
}, [arrayDefaultOptions, arrayOptions, groupBy, onSearch, options]);
|
|
320
|
+
|
|
321
|
+
React.useEffect(() => {
|
|
322
|
+
/** sync search */
|
|
323
|
+
|
|
324
|
+
const doSearchSync = () => {
|
|
325
|
+
const res = onSearchSync?.(debouncedSearchTerm);
|
|
326
|
+
setOptions(transToGroupOption(res || [], groupBy));
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const exec = async () => {
|
|
330
|
+
if (!onSearchSync || !open) return;
|
|
331
|
+
|
|
332
|
+
if (triggerSearchOnFocus) {
|
|
333
|
+
doSearchSync();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (debouncedSearchTerm) {
|
|
337
|
+
doSearchSync();
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
void exec();
|
|
342
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
343
|
+
}, [debouncedSearchTerm, groupBy, open, triggerSearchOnFocus]);
|
|
344
|
+
|
|
345
|
+
React.useEffect(() => {
|
|
346
|
+
/** async search */
|
|
347
|
+
|
|
348
|
+
const doSearch = async () => {
|
|
349
|
+
setIsLoading(true);
|
|
350
|
+
const res = await onSearch?.(debouncedSearchTerm);
|
|
351
|
+
setOptions(transToGroupOption(res || [], groupBy));
|
|
352
|
+
setIsLoading(false);
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
const exec = async () => {
|
|
356
|
+
if (!onSearch || !open) return;
|
|
357
|
+
|
|
358
|
+
if (triggerSearchOnFocus) {
|
|
359
|
+
await doSearch();
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (debouncedSearchTerm) {
|
|
363
|
+
await doSearch();
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
void exec();
|
|
368
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
369
|
+
}, [debouncedSearchTerm, groupBy, open, triggerSearchOnFocus]);
|
|
370
|
+
|
|
371
|
+
const CreatableItem = () => {
|
|
372
|
+
if (!creatable) return undefined;
|
|
373
|
+
if (
|
|
374
|
+
isOptionsExist(options, [{ value: inputValue, label: inputValue }]) ||
|
|
375
|
+
selected.find((s) => s.value === inputValue)
|
|
376
|
+
) {
|
|
377
|
+
return undefined;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const Item = (
|
|
381
|
+
<CommandItem
|
|
382
|
+
value={inputValue}
|
|
383
|
+
className="cursor-pointer"
|
|
384
|
+
onMouseDown={(e) => {
|
|
385
|
+
e.preventDefault();
|
|
386
|
+
e.stopPropagation();
|
|
387
|
+
}}
|
|
388
|
+
onSelect={(value: string) => {
|
|
389
|
+
if (selected.length >= maxSelected) {
|
|
390
|
+
onMaxSelected?.(selected.length);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
setInputValue("");
|
|
394
|
+
const newOptions = [...selected, { value, label: value }];
|
|
395
|
+
setSelected(newOptions);
|
|
396
|
+
onChange?.(newOptions);
|
|
397
|
+
}}
|
|
398
|
+
>
|
|
399
|
+
{`Create "${inputValue}"`}
|
|
400
|
+
</CommandItem>
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
// For normal creatable
|
|
404
|
+
if (!onSearch && inputValue.length > 0) {
|
|
405
|
+
return Item;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// For async search creatable. avoid showing creatable item before loading at first.
|
|
409
|
+
if (onSearch && debouncedSearchTerm.length > 0 && !isLoading) {
|
|
410
|
+
return Item;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return undefined;
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
const EmptyItem = React.useCallback(() => {
|
|
417
|
+
if (!emptyIndicator) return undefined;
|
|
418
|
+
|
|
419
|
+
// For async search that showing emptyIndicator
|
|
420
|
+
if (onSearch && !creatable && Object.keys(options).length === 0) {
|
|
421
|
+
return (
|
|
422
|
+
<CommandItem value="-" disabled>
|
|
423
|
+
{emptyIndicator}
|
|
424
|
+
</CommandItem>
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return <CommandEmpty>{emptyIndicator}</CommandEmpty>;
|
|
429
|
+
}, [creatable, emptyIndicator, onSearch, options]);
|
|
430
|
+
|
|
431
|
+
const selectables = React.useMemo<GroupOption>(
|
|
432
|
+
() => removePickedOption(options, selected),
|
|
433
|
+
[options, selected],
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
/** Avoid Creatable Selector freezing or lagging when paste a long string. */
|
|
437
|
+
const commandFilter = React.useCallback(() => {
|
|
438
|
+
if (commandProps?.filter) {
|
|
439
|
+
return commandProps.filter;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (creatable) {
|
|
443
|
+
return (value: string, search: string) => {
|
|
444
|
+
return value.toLowerCase().includes(search.toLowerCase()) ? 1 : -1;
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
// Using default filter in `cmdk`. We don‘t have to provide it.
|
|
448
|
+
return undefined;
|
|
449
|
+
}, [creatable, commandProps?.filter]);
|
|
450
|
+
|
|
451
|
+
return (
|
|
452
|
+
<Command
|
|
453
|
+
ref={dropdownRef}
|
|
454
|
+
{...commandProps}
|
|
455
|
+
onKeyDown={(e) => {
|
|
456
|
+
handleKeyDown(e);
|
|
457
|
+
commandProps?.onKeyDown?.(e);
|
|
458
|
+
}}
|
|
459
|
+
className={cn(
|
|
460
|
+
"h-auto overflow-visible bg-transparent",
|
|
461
|
+
commandProps?.className,
|
|
462
|
+
)}
|
|
463
|
+
shouldFilter={
|
|
464
|
+
commandProps?.shouldFilter !== undefined
|
|
465
|
+
? commandProps.shouldFilter
|
|
466
|
+
: !onSearch
|
|
467
|
+
} // When onSearch is provided, we don‘t want to filter the options. You can still override it.
|
|
468
|
+
filter={commandFilter()}
|
|
469
|
+
>
|
|
470
|
+
<div
|
|
471
|
+
className={cn(
|
|
472
|
+
"border-input focus-within:border-primary focus-within:ring-ring relative rounded-md border text-sm transition-shadow focus-within:ring-4 focus-within:outline-hidden",
|
|
473
|
+
"has-disabled:bg-muted",
|
|
474
|
+
"has-disabled:text-muted-foreground",
|
|
475
|
+
{
|
|
476
|
+
"p-1": selected.length !== 0,
|
|
477
|
+
"cursor-text": !disabled && selected.length !== 0,
|
|
478
|
+
},
|
|
479
|
+
!hideClearAllButton && "pe-9",
|
|
480
|
+
className,
|
|
481
|
+
)}
|
|
482
|
+
onClick={() => {
|
|
483
|
+
if (disabled) return;
|
|
484
|
+
inputRef?.current?.focus();
|
|
485
|
+
}}
|
|
486
|
+
>
|
|
487
|
+
<div className="flex flex-wrap gap-1">
|
|
488
|
+
{selected.map((option) => {
|
|
489
|
+
return (
|
|
490
|
+
<div
|
|
491
|
+
key={option.value}
|
|
492
|
+
className={cn(
|
|
493
|
+
"animate-fadeIn bg-background text-secondary-foreground hover:bg-background relative inline-flex h-7 cursor-default items-center rounded-md border border-solid ps-2 pe-7 pl-2 text-xs font-medium transition-all disabled:cursor-not-allowed disabled:opacity-50 data-fixed:pe-2",
|
|
494
|
+
badgeClassName,
|
|
495
|
+
)}
|
|
496
|
+
data-fixed={option.fixed}
|
|
497
|
+
data-disabled={disabled || undefined}
|
|
498
|
+
>
|
|
499
|
+
{option.label}
|
|
500
|
+
<button
|
|
501
|
+
type="button"
|
|
502
|
+
disabled={disabled || option.fixed}
|
|
503
|
+
className={cn(
|
|
504
|
+
"text-muted-foreground/80 absolute -inset-y-px -end-px flex size-7 items-center justify-center rounded-e-lg border border-transparent p-0 outline-0 transition-colors",
|
|
505
|
+
"hover:text-foreground",
|
|
506
|
+
"focus-visible:outline",
|
|
507
|
+
"focus-visible:outline-2",
|
|
508
|
+
"focus-visible:outline-ring/70",
|
|
509
|
+
"disabled:hover:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
510
|
+
)}
|
|
511
|
+
onKeyDown={(e) => {
|
|
512
|
+
if (e.key === "Enter") {
|
|
513
|
+
handleUnselect(option);
|
|
514
|
+
}
|
|
515
|
+
}}
|
|
516
|
+
onMouseDown={(e) => {
|
|
517
|
+
e.preventDefault();
|
|
518
|
+
e.stopPropagation();
|
|
519
|
+
}}
|
|
520
|
+
onClick={() => handleUnselect(option)}
|
|
521
|
+
aria-label="Remove"
|
|
522
|
+
>
|
|
523
|
+
<X size={14} strokeWidth={2} aria-hidden="true" />
|
|
524
|
+
</button>
|
|
525
|
+
</div>
|
|
526
|
+
);
|
|
527
|
+
})}
|
|
528
|
+
{/* Avoid having the "Search" Icon */}
|
|
529
|
+
<CommandPrimitive.Input
|
|
530
|
+
{...inputProps}
|
|
531
|
+
ref={inputRef}
|
|
532
|
+
value={inputValue}
|
|
533
|
+
disabled={disabled}
|
|
534
|
+
onValueChange={(value) => {
|
|
535
|
+
setInputValue(value);
|
|
536
|
+
inputProps?.onValueChange?.(value);
|
|
537
|
+
}}
|
|
538
|
+
onBlur={(event) => {
|
|
539
|
+
if (!onScrollbar) {
|
|
540
|
+
setOpen(false);
|
|
541
|
+
}
|
|
542
|
+
inputProps?.onBlur?.(event);
|
|
543
|
+
}}
|
|
544
|
+
onFocus={(event) => {
|
|
545
|
+
setOpen(true);
|
|
546
|
+
if (triggerSearchOnFocus) {
|
|
547
|
+
onSearch?.(debouncedSearchTerm);
|
|
548
|
+
}
|
|
549
|
+
inputProps?.onFocus?.(event);
|
|
550
|
+
}}
|
|
551
|
+
placeholder={
|
|
552
|
+
hidePlaceholderWhenSelected && selected.length !== 0
|
|
553
|
+
? ""
|
|
554
|
+
: placeholder
|
|
555
|
+
}
|
|
556
|
+
className={cn(
|
|
557
|
+
"placeholder:text-muted-foreground flex-1 bg-transparent outline-hidden",
|
|
558
|
+
"disabled:placeholder:text-transparent",
|
|
559
|
+
{
|
|
560
|
+
"w-full": hidePlaceholderWhenSelected,
|
|
561
|
+
"px-3 py-2": selected.length === 0,
|
|
562
|
+
"ml-1": selected.length !== 0,
|
|
563
|
+
},
|
|
564
|
+
inputProps?.className,
|
|
565
|
+
)}
|
|
566
|
+
/>
|
|
567
|
+
<button
|
|
568
|
+
type="button"
|
|
569
|
+
onClick={() => {
|
|
570
|
+
setSelected(selected.filter((s) => s.fixed));
|
|
571
|
+
onChange?.(selected.filter((s) => s.fixed));
|
|
572
|
+
}}
|
|
573
|
+
className={cn(
|
|
574
|
+
"text-muted-foreground/80",
|
|
575
|
+
"absolute end-0 top-0 flex size-9 items-center justify-center rounded-lg border border-transparent transition-colors",
|
|
576
|
+
"focus-visible:outline-2",
|
|
577
|
+
"hover:text-foreground",
|
|
578
|
+
"focus-visible:outline-ring/70",
|
|
579
|
+
(hideClearAllButton ||
|
|
580
|
+
disabled ||
|
|
581
|
+
selected.length < 1 ||
|
|
582
|
+
selected.filter(({ fixed }) => fixed).length ===
|
|
583
|
+
selected.length) &&
|
|
584
|
+
"hidden",
|
|
585
|
+
)}
|
|
586
|
+
aria-label="Clear all"
|
|
587
|
+
>
|
|
588
|
+
<X size={16} strokeWidth={2} aria-hidden="true" />
|
|
589
|
+
</button>
|
|
590
|
+
</div>
|
|
591
|
+
</div>
|
|
592
|
+
<div className="relative">
|
|
593
|
+
<div
|
|
594
|
+
className={cn(
|
|
595
|
+
"border-input absolute top-2 z-10 w-full overflow-hidden rounded-lg border shadow-sm",
|
|
596
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
|
597
|
+
!open && "hidden",
|
|
598
|
+
)}
|
|
599
|
+
data-state={open ? "open" : "closed"}
|
|
600
|
+
>
|
|
601
|
+
{open && (
|
|
602
|
+
<CommandList
|
|
603
|
+
className="bg-popover text-popover-foreground shadow-lg outline-hidden"
|
|
604
|
+
onMouseLeave={() => {
|
|
605
|
+
setOnScrollbar(false);
|
|
606
|
+
}}
|
|
607
|
+
onMouseEnter={() => {
|
|
608
|
+
setOnScrollbar(true);
|
|
609
|
+
}}
|
|
610
|
+
onMouseUp={() => {
|
|
611
|
+
inputRef?.current?.focus();
|
|
612
|
+
}}
|
|
613
|
+
>
|
|
614
|
+
{onAddNewItem && (
|
|
615
|
+
<>
|
|
616
|
+
<CommandSeparator />
|
|
617
|
+
<CommandGroup>
|
|
618
|
+
<Button
|
|
619
|
+
type="button"
|
|
620
|
+
variant="ghost"
|
|
621
|
+
className="w-full font-normal [&_div]:justify-start"
|
|
622
|
+
onClick={onAddNewItem}
|
|
623
|
+
>
|
|
624
|
+
<PlusIcon
|
|
625
|
+
size={14}
|
|
626
|
+
className="-ms-2 opacity-60"
|
|
627
|
+
aria-hidden="true"
|
|
628
|
+
/>
|
|
629
|
+
Thêm mới
|
|
630
|
+
</Button>
|
|
631
|
+
</CommandGroup>
|
|
632
|
+
</>
|
|
633
|
+
)}
|
|
634
|
+
{isLoading ? (
|
|
635
|
+
LoadingIndicator
|
|
636
|
+
) : (
|
|
637
|
+
<React.Fragment>
|
|
638
|
+
{EmptyItem()}
|
|
639
|
+
{CreatableItem()}
|
|
640
|
+
{!selectFirstItem && (
|
|
641
|
+
<CommandItem value="-" className="hidden" />
|
|
642
|
+
)}
|
|
643
|
+
{Object.entries(selectables).map(([key, dropdowns]) => (
|
|
644
|
+
<CommandGroup
|
|
645
|
+
key={key}
|
|
646
|
+
heading={key}
|
|
647
|
+
className="h-full overflow-auto"
|
|
648
|
+
>
|
|
649
|
+
{dropdowns.map((option) => {
|
|
650
|
+
return (
|
|
651
|
+
<CommandItem
|
|
652
|
+
key={option.value}
|
|
653
|
+
value={option.value}
|
|
654
|
+
disabled={option.disable}
|
|
655
|
+
onMouseDown={(e) => {
|
|
656
|
+
e.preventDefault();
|
|
657
|
+
e.stopPropagation();
|
|
658
|
+
}}
|
|
659
|
+
onSelect={() => {
|
|
660
|
+
if (selected.length >= maxSelected) {
|
|
661
|
+
onMaxSelected?.(selected.length);
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
setInputValue("");
|
|
665
|
+
const newOptions = [...selected, option];
|
|
666
|
+
setSelected(newOptions);
|
|
667
|
+
onChange?.(newOptions);
|
|
668
|
+
}}
|
|
669
|
+
className={cn(
|
|
670
|
+
"cursor-pointer",
|
|
671
|
+
option.disable &&
|
|
672
|
+
"cursor-not-allowed opacity-50",
|
|
673
|
+
)}
|
|
674
|
+
>
|
|
675
|
+
{option.label}
|
|
676
|
+
</CommandItem>
|
|
677
|
+
);
|
|
678
|
+
})}
|
|
679
|
+
</CommandGroup>
|
|
680
|
+
))}
|
|
681
|
+
</React.Fragment>
|
|
682
|
+
)}
|
|
683
|
+
</CommandList>
|
|
684
|
+
)}
|
|
685
|
+
</div>
|
|
686
|
+
</div>
|
|
687
|
+
</Command>
|
|
688
|
+
);
|
|
689
|
+
},
|
|
690
|
+
);
|
|
691
|
+
|
|
692
|
+
MultipleSelector.displayName = "MultipleSelector";
|
|
693
|
+
export default MultipleSelector;
|