ivt 0.7.4 → 0.7.5
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/accordion/index.mjs +13 -13
- package/dist/accordion-table/index.mjs +25 -25
- package/dist/alert/index.mjs +3 -3
- package/dist/alert-dialog/index.mjs +15 -15
- package/dist/auto-complete-multi-select/index.mjs +31 -31
- package/dist/avatar/index.mjs +5 -5
- package/dist/badge/index.mjs +3 -3
- package/dist/base/index.d.ts +31 -9
- package/dist/base/index.mjs +79 -79
- package/dist/base/index.mjs.map +1 -1
- package/dist/breadcrumb/index.mjs +5 -5
- package/dist/button/index.d.ts +1 -1
- package/dist/button/index.mjs +3 -3
- package/dist/button-group/index.d.ts +3 -2
- package/dist/button-group/index.mjs +3 -3
- package/dist/calendar/index.mjs +9 -9
- package/dist/card/index.mjs +3 -3
- package/dist/carousel/index.mjs +4 -4
- package/dist/chart/index.mjs +4 -4
- package/dist/checkbox/index.mjs +12 -12
- package/dist/chunks/{AutoComplete-qFuwmV53.mjs → AutoComplete-BpwnFm_u.mjs} +23 -12
- package/dist/chunks/AutoComplete-BpwnFm_u.mjs.map +1 -0
- package/dist/chunks/{CalendarRange-Ce7PiNfq.mjs → CalendarRange-BGP7p-ma.mjs} +8 -8
- package/dist/chunks/{CalendarRange-Ce7PiNfq.mjs.map → CalendarRange-BGP7p-ma.mjs.map} +1 -1
- package/dist/chunks/{ComboboxField-DaRpRraW.mjs → ComboboxField-CzJlHHXv.mjs} +9 -9
- package/dist/chunks/{ComboboxField-DaRpRraW.mjs.map → ComboboxField-CzJlHHXv.mjs.map} +1 -1
- package/dist/chunks/{Container-DwaAaEiC.mjs → Container-77E_UFi2.mjs} +2 -2
- package/dist/chunks/{Container-DwaAaEiC.mjs.map → Container-77E_UFi2.mjs.map} +1 -1
- package/dist/chunks/{DeleteConfirmationModal-BwTbbBAw.mjs → DeleteConfirmationModal-DQK05Srx.mjs} +4 -4
- package/dist/chunks/{DeleteConfirmationModal-BwTbbBAw.mjs.map → DeleteConfirmationModal-DQK05Srx.mjs.map} +1 -1
- package/dist/chunks/{ListItem-zxS4CZdq.mjs → ListItem-B0_5JcsU.mjs} +4 -4
- package/dist/chunks/{ListItem-zxS4CZdq.mjs.map → ListItem-B0_5JcsU.mjs.map} +1 -1
- package/dist/chunks/{TooltipIndicator-CwGGAeRz.mjs → TooltipIndicator-Db1poSJI.mjs} +4 -4
- package/dist/chunks/{TooltipIndicator-CwGGAeRz.mjs.map → TooltipIndicator-Db1poSJI.mjs.map} +1 -1
- package/dist/chunks/{_commonjsHelpers-B2Be7UYW.mjs → _commonjsHelpers-DkfSKqYE.mjs} +1 -1
- package/dist/chunks/_commonjsHelpers-DkfSKqYE.mjs.map +1 -0
- package/dist/chunks/{accordion-D4JVALAO.mjs → accordion-DSn7k_RQ.mjs} +9 -9
- package/dist/chunks/{accordion-D4JVALAO.mjs.map → accordion-DSn7k_RQ.mjs.map} +1 -1
- package/dist/chunks/{alert-D-E6nsVK.mjs → alert-aP6n7wtq.mjs} +2 -2
- package/dist/chunks/{alert-D-E6nsVK.mjs.map → alert-aP6n7wtq.mjs.map} +1 -1
- package/dist/chunks/{badge-C6mkl9yr.mjs → badge-CsUuqHNu.mjs} +2 -2
- package/dist/chunks/{badge-C6mkl9yr.mjs.map → badge-CsUuqHNu.mjs.map} +1 -1
- package/dist/chunks/{bundle-mjs-B1dpl-bk.mjs → bundle-mjs-BRbxNcQb.mjs} +1 -1
- package/dist/chunks/{bundle-mjs-B1dpl-bk.mjs.map → bundle-mjs-BRbxNcQb.mjs.map} +1 -1
- package/dist/chunks/{button-DsgJkgEz.mjs → button-BW9I4XWU.mjs} +2 -2
- package/dist/chunks/{button-DsgJkgEz.mjs.map → button-BW9I4XWU.mjs.map} +1 -1
- package/dist/chunks/button-C8IZYeQz.d.ts +16 -0
- package/dist/chunks/{calendar-Co99lCn4.mjs → calendar-C549VT55.mjs} +531 -531
- package/dist/chunks/{calendar-Co99lCn4.mjs.map → calendar-C549VT55.mjs.map} +1 -1
- package/dist/chunks/{calendar-days-BF4GDmMr.mjs → calendar-days-BSzlDBsi.mjs} +2 -2
- package/dist/chunks/{calendar-days-BF4GDmMr.mjs.map → calendar-days-BSzlDBsi.mjs.map} +1 -1
- package/dist/chunks/{card-Cuo7NL8y.mjs → card-Dqm2EuWU.mjs} +2 -2
- package/dist/chunks/{card-Cuo7NL8y.mjs.map → card-Dqm2EuWU.mjs.map} +1 -1
- package/dist/chunks/{check-CzKqQLNR.mjs → check-CKdwsuVA.mjs} +2 -2
- package/dist/chunks/{check-CzKqQLNR.mjs.map → check-CKdwsuVA.mjs.map} +1 -1
- package/dist/chunks/{checkbox-C7RUdsIS.mjs → checkbox-CvaPsjy3.mjs} +9 -9
- package/dist/chunks/{checkbox-C7RUdsIS.mjs.map → checkbox-CvaPsjy3.mjs.map} +1 -1
- package/dist/chunks/{chevron-down-CZjN_vyX.mjs → chevron-down-o7NUBnJ4.mjs} +2 -2
- package/dist/chunks/{chevron-down-CZjN_vyX.mjs.map → chevron-down-o7NUBnJ4.mjs.map} +1 -1
- package/dist/chunks/{chevron-left-BpfBwM4S.mjs → chevron-left-BZ8X7kLy.mjs} +2 -2
- package/dist/chunks/{chevron-left-BpfBwM4S.mjs.map → chevron-left-BZ8X7kLy.mjs.map} +1 -1
- package/dist/chunks/{chevron-right-uq-O8rwC.mjs → chevron-right-jAScR3zY.mjs} +2 -2
- package/dist/chunks/{chevron-right-uq-O8rwC.mjs.map → chevron-right-jAScR3zY.mjs.map} +1 -1
- package/dist/chunks/{chevrons-up-down-DKM8h8j_.mjs → chevrons-up-down-BSIPdamI.mjs} +2 -2
- package/dist/chunks/{chevrons-up-down-DKM8h8j_.mjs.map → chevrons-up-down-BSIPdamI.mjs.map} +1 -1
- package/dist/chunks/{command-CAS791lb.mjs → command-B29vdoVO.mjs} +8 -8
- package/dist/chunks/{command-CAS791lb.mjs.map → command-B29vdoVO.mjs.map} +1 -1
- package/dist/chunks/{createLucideIcon-xkRZC0aJ.mjs → createLucideIcon-CkP7424r.mjs} +1 -1
- package/dist/chunks/{createLucideIcon-xkRZC0aJ.mjs.map → createLucideIcon-CkP7424r.mjs.map} +1 -1
- package/dist/chunks/{date-DYEUxjwi.mjs → date-Y_hKMQVr.mjs} +2 -2
- package/dist/chunks/{date-DYEUxjwi.mjs.map → date-Y_hKMQVr.mjs.map} +1 -1
- package/dist/chunks/{dialog-Dt_M700u.mjs → dialog-BhaHMQnG.mjs} +4 -4
- package/dist/chunks/{dialog-Dt_M700u.mjs.map → dialog-BhaHMQnG.mjs.map} +1 -1
- package/dist/chunks/{ellipsis-BcRZkfZw.mjs → ellipsis-DHAz8TrI.mjs} +2 -2
- package/dist/chunks/{ellipsis-BcRZkfZw.mjs.map → ellipsis-DHAz8TrI.mjs.map} +1 -1
- package/dist/chunks/{form-CJnoOgoH.mjs → form-BAxhKbgh.mjs} +3 -3
- package/dist/chunks/{form-CJnoOgoH.mjs.map → form-BAxhKbgh.mjs.map} +1 -1
- package/dist/chunks/{format-BSPAt__h.mjs → format-CR4Q6BSq.mjs} +1 -1
- package/dist/chunks/{format-BSPAt__h.mjs.map → format-CR4Q6BSq.mjs.map} +1 -1
- package/dist/chunks/{format-numbers-BpGX211b.mjs → format-numbers-CWj9Vf7x.mjs} +1 -1
- package/dist/chunks/{format-numbers-BpGX211b.mjs.map → format-numbers-CWj9Vf7x.mjs.map} +1 -1
- package/dist/chunks/{hover-card-DKMcpBnt.mjs → hover-card-DVmQc78n.mjs} +9 -9
- package/dist/chunks/{hover-card-DKMcpBnt.mjs.map → hover-card-DVmQc78n.mjs.map} +1 -1
- package/dist/chunks/{index-DjoMuta5.mjs → index-4pJ77hyF.mjs} +1 -1
- package/dist/chunks/{index-DjoMuta5.mjs.map → index-4pJ77hyF.mjs.map} +1 -1
- package/dist/chunks/{index-9921_a2g.mjs → index-BN17NQCv.mjs} +1 -1
- package/dist/chunks/{index-9921_a2g.mjs.map → index-BN17NQCv.mjs.map} +1 -1
- package/dist/chunks/{index-7wUPkpwA.mjs → index-Bt1elORc.mjs} +9 -9
- package/dist/chunks/{index-7wUPkpwA.mjs.map → index-Bt1elORc.mjs.map} +1 -1
- package/dist/chunks/{index-CsC-dafu.mjs → index-CByz7d8q.mjs} +3 -3
- package/dist/chunks/{index-CsC-dafu.mjs.map → index-CByz7d8q.mjs.map} +1 -1
- package/dist/chunks/{index-CvWc6WZ4.mjs → index-CS2Lzoed.mjs} +7 -7
- package/dist/chunks/{index-CvWc6WZ4.mjs.map → index-CS2Lzoed.mjs.map} +1 -1
- package/dist/chunks/{index-Cm5-jAR7.mjs → index-CVjOpozG.mjs} +1 -1
- package/dist/chunks/{index-Cm5-jAR7.mjs.map → index-CVjOpozG.mjs.map} +1 -1
- package/dist/chunks/{index-BtdTgi0_.mjs → index-Cs9A0tpU.mjs} +1 -1
- package/dist/chunks/{index-BtdTgi0_.mjs.map → index-Cs9A0tpU.mjs.map} +1 -1
- package/dist/chunks/{index-0DBJW078.mjs → index-Ct610FOk.mjs} +2 -2
- package/dist/chunks/{index-0DBJW078.mjs.map → index-Ct610FOk.mjs.map} +1 -1
- package/dist/chunks/{index-DSBOi0JP.mjs → index-CvVBB5ll.mjs} +4 -4
- package/dist/chunks/{index-DSBOi0JP.mjs.map → index-CvVBB5ll.mjs.map} +1 -1
- package/dist/chunks/{index-B8pOe-bI.mjs → index-D1CSAowX.mjs} +13 -13
- package/dist/chunks/{index-B8pOe-bI.mjs.map → index-D1CSAowX.mjs.map} +1 -1
- package/dist/chunks/{index-BpZD69GD.mjs → index-D2DYiX9D.mjs} +2 -2
- package/dist/chunks/{index-BpZD69GD.mjs.map → index-D2DYiX9D.mjs.map} +1 -1
- package/dist/chunks/{index-SJQIKyxi.mjs → index-D8mA4n7w.mjs} +1 -1
- package/dist/chunks/{index-SJQIKyxi.mjs.map → index-D8mA4n7w.mjs.map} +1 -1
- package/dist/chunks/{index-CuEeN4AG.mjs → index-DCDDoDjL.mjs} +6 -6
- package/dist/chunks/{index-CuEeN4AG.mjs.map → index-DCDDoDjL.mjs.map} +1 -1
- package/dist/chunks/{index-G8uUqzC7.mjs → index-DLqxy-dg.mjs} +1 -1
- package/dist/chunks/{index-G8uUqzC7.mjs.map → index-DLqxy-dg.mjs.map} +1 -1
- package/dist/chunks/{index-DaifcY5X.mjs → index-DNMhNzeD.mjs} +7 -7
- package/dist/chunks/{index-DaifcY5X.mjs.map → index-DNMhNzeD.mjs.map} +1 -1
- package/dist/chunks/{index-zv8c0UAU.mjs → index-DQD35Ges.mjs} +3 -3
- package/dist/chunks/{index-zv8c0UAU.mjs.map → index-DQD35Ges.mjs.map} +1 -1
- package/dist/chunks/{index-B49Rv10M.mjs → index-D_Q4NGnO.mjs} +1 -1
- package/dist/chunks/{index-B49Rv10M.mjs.map → index-D_Q4NGnO.mjs.map} +1 -1
- package/dist/chunks/{index-fcmnzZn6.mjs → index-D_e6adwb.mjs} +5 -5
- package/dist/chunks/{index-fcmnzZn6.mjs.map → index-D_e6adwb.mjs.map} +1 -1
- package/dist/chunks/{index-DWtzT31F.mjs → index-DhI6OG_H.mjs} +2 -2
- package/dist/chunks/{index-DWtzT31F.mjs.map → index-DhI6OG_H.mjs.map} +1 -1
- package/dist/chunks/{index-Dn87UbZu.mjs → index-Dp_0m03a.mjs} +2 -2
- package/dist/chunks/{index-Dn87UbZu.mjs.map → index-Dp_0m03a.mjs.map} +1 -1
- package/dist/chunks/{index-B8zlei3I.mjs → index-oX_tk439.mjs} +1 -1
- package/dist/chunks/{index-B8zlei3I.mjs.map → index-oX_tk439.mjs.map} +1 -1
- package/dist/chunks/{index.module-B_Z75X1e.mjs → index.module-Df4mRjmZ.mjs} +1 -1
- package/dist/chunks/{index.module-B_Z75X1e.mjs.map → index.module-Df4mRjmZ.mjs.map} +1 -1
- package/dist/chunks/{input-NILUGijL.mjs → input-YpoAHnXb.mjs} +2 -2
- package/dist/chunks/{input-NILUGijL.mjs.map → input-YpoAHnXb.mjs.map} +1 -1
- package/dist/chunks/{input-otp-b-7MmY2H.mjs → input-otp-BKqdZwNx.mjs} +3 -3
- package/dist/chunks/{input-otp-b-7MmY2H.mjs.map → input-otp-BKqdZwNx.mjs.map} +1 -1
- package/dist/chunks/{label-81mjh4Q4.mjs → label-D5s6d0et.mjs} +2 -2
- package/dist/chunks/{label-81mjh4Q4.mjs.map → label-D5s6d0et.mjs.map} +1 -1
- package/dist/chunks/{loader-circle-sGBNpyP3.mjs → loader-circle-C7StEOZI.mjs} +2 -2
- package/dist/chunks/{loader-circle-sGBNpyP3.mjs.map → loader-circle-C7StEOZI.mjs.map} +1 -1
- package/dist/chunks/{menubar-Dz5biTZv.mjs → menubar-ySifmjAG.mjs} +11 -11
- package/dist/chunks/{menubar-Dz5biTZv.mjs.map → menubar-ySifmjAG.mjs.map} +1 -1
- package/dist/chunks/{multi-select-DeW-tL6j.mjs → multi-select-BsnRMfg7.mjs} +13 -13
- package/dist/chunks/{multi-select-DeW-tL6j.mjs.map → multi-select-BsnRMfg7.mjs.map} +1 -1
- package/dist/chunks/{pagination-0W2Kek6Z.mjs → pagination-CV6N_Qu_.mjs} +6 -6
- package/dist/chunks/{pagination-0W2Kek6Z.mjs.map → pagination-CV6N_Qu_.mjs.map} +1 -1
- package/dist/chunks/{popover-ChoMUAP9.mjs → popover-D3JC54Y3.mjs} +11 -11
- package/dist/chunks/{popover-ChoMUAP9.mjs.map → popover-D3JC54Y3.mjs.map} +1 -1
- package/dist/chunks/{progress-zrBdDKEV.mjs → progress-D_Enl4tV.mjs} +2 -2
- package/dist/chunks/{progress-zrBdDKEV.mjs.map → progress-D_Enl4tV.mjs.map} +1 -1
- package/dist/chunks/{radio-group-r3ejuIom.mjs → radio-group-yF1QEewC.mjs} +11 -11
- package/dist/chunks/{radio-group-r3ejuIom.mjs.map → radio-group-yF1QEewC.mjs.map} +1 -1
- package/dist/chunks/{react-number-format.es-rRpdCutF.mjs → react-number-format.es-C3uDZhRo.mjs} +1 -1
- package/dist/chunks/{react-number-format.es-rRpdCutF.mjs.map → react-number-format.es-C3uDZhRo.mjs.map} +1 -1
- package/dist/chunks/{scroll-area-DjtXX0pm.mjs → scroll-area-CdGRe--S.mjs} +9 -9
- package/dist/chunks/{scroll-area-DjtXX0pm.mjs.map → scroll-area-CdGRe--S.mjs.map} +1 -1
- package/dist/chunks/{select-CICQavYx.mjs → select-B8JYuJE5.mjs} +5 -5
- package/dist/chunks/{select-CICQavYx.mjs.map → select-B8JYuJE5.mjs.map} +1 -1
- package/dist/chunks/{separator-CL28DVoA.mjs → separator-sWF5eZgM.mjs} +2 -2
- package/dist/chunks/{separator-CL28DVoA.mjs.map → separator-sWF5eZgM.mjs.map} +1 -1
- package/dist/chunks/{sheet-BIN5Bwkz.mjs → sheet-D-4XWzUo.mjs} +4 -4
- package/dist/chunks/{sheet-BIN5Bwkz.mjs.map → sheet-D-4XWzUo.mjs.map} +1 -1
- package/dist/chunks/{skeleton-DEo09dsp.mjs → skeleton-CQlSHSfr.mjs} +2 -2
- package/dist/chunks/{skeleton-DEo09dsp.mjs.map → skeleton-CQlSHSfr.mjs.map} +1 -1
- package/dist/chunks/{slider-C_afdOBq.mjs → slider-CaliGouI.mjs} +9 -9
- package/dist/chunks/{slider-C_afdOBq.mjs.map → slider-CaliGouI.mjs.map} +1 -1
- package/dist/chunks/{sortable-Hz2p-hG_.mjs → sortable-BoTUMXD0.mjs} +3 -3
- package/dist/chunks/{sortable-Hz2p-hG_.mjs.map → sortable-BoTUMXD0.mjs.map} +1 -1
- package/dist/chunks/{styles-DQr_CtBg.mjs → styles-C5sFcbz4.mjs} +1 -1
- package/dist/chunks/{styles-DQr_CtBg.mjs.map → styles-C5sFcbz4.mjs.map} +1 -1
- package/dist/chunks/{switch-CoxjUYji.mjs → switch-szutUcvb.mjs} +7 -7
- package/dist/chunks/{switch-CoxjUYji.mjs.map → switch-szutUcvb.mjs.map} +1 -1
- package/dist/chunks/{table-CaTzvnGO.mjs → table-wwce3IsC.mjs} +2 -2
- package/dist/chunks/{table-CaTzvnGO.mjs.map → table-wwce3IsC.mjs.map} +1 -1
- package/dist/chunks/{tabs-DbcqE74l.mjs → tabs-BDPMoWeJ.mjs} +9 -9
- package/dist/chunks/{tabs-DbcqE74l.mjs.map → tabs-BDPMoWeJ.mjs.map} +1 -1
- package/dist/chunks/{textarea-C99bTFre.mjs → textarea-DYBOxg35.mjs} +2 -2
- package/dist/chunks/{textarea-C99bTFre.mjs.map → textarea-DYBOxg35.mjs.map} +1 -1
- package/dist/chunks/toast-S15TT7Q2.mjs +702 -0
- package/dist/chunks/toast-S15TT7Q2.mjs.map +1 -0
- package/dist/chunks/{toggle-x7-6JYvP.mjs → toggle-GXtKRhvr.mjs} +4 -4
- package/dist/chunks/{toggle-x7-6JYvP.mjs.map → toggle-GXtKRhvr.mjs.map} +1 -1
- package/dist/chunks/{tooltip-aCFcTWvT.mjs → tooltip-z43eMlPO.mjs} +11 -11
- package/dist/chunks/{tooltip-aCFcTWvT.mjs.map → tooltip-z43eMlPO.mjs.map} +1 -1
- package/dist/chunks/{trash-2-BRTBRPsE.mjs → trash-2-CZE_1bXY.mjs} +2 -2
- package/dist/chunks/{trash-2-BRTBRPsE.mjs.map → trash-2-CZE_1bXY.mjs.map} +1 -1
- package/dist/chunks/{triangle-alert-DEr_0gbo.mjs → triangle-alert-BeczCtiG.mjs} +2 -2
- package/dist/chunks/{triangle-alert-DEr_0gbo.mjs.map → triangle-alert-BeczCtiG.mjs.map} +1 -1
- package/dist/chunks/{tslib.es6-9fTryOSE.mjs → tslib.es6-B20VGjW7.mjs} +1 -1
- package/dist/chunks/{tslib.es6-9fTryOSE.mjs.map → tslib.es6-B20VGjW7.mjs.map} +1 -1
- package/dist/chunks/use-toast-C3gJQZ0s.mjs +137 -0
- package/dist/chunks/use-toast-C3gJQZ0s.mjs.map +1 -0
- package/dist/chunks/{utils-M7D-rn0u.mjs → utils-uOfHPBdi.mjs} +2 -2
- package/dist/chunks/{utils-M7D-rn0u.mjs.map → utils-uOfHPBdi.mjs.map} +1 -1
- package/dist/chunks/{wand-sparkles-cr6EaHA_.mjs → wand-sparkles-COk3z6HL.mjs} +2 -2
- package/dist/chunks/{wand-sparkles-cr6EaHA_.mjs.map → wand-sparkles-COk3z6HL.mjs.map} +1 -1
- package/dist/chunks/{x-Heb3hHKJ.mjs → x-D5HL_X5m.mjs} +2 -2
- package/dist/chunks/{x-Heb3hHKJ.mjs.map → x-D5HL_X5m.mjs.map} +1 -1
- package/dist/collapsible/index.mjs +7 -7
- package/dist/combobox/index.mjs +24 -24
- package/dist/command/index.d.ts +7 -7
- package/dist/command/index.mjs +18 -18
- package/dist/context-menu/index.mjs +21 -21
- package/dist/dash/index.mjs +24 -24
- package/dist/data-table/index.mjs +33 -33
- package/dist/date-picker/index.d.ts +22 -7
- package/dist/date-picker/index.mjs +25 -25
- package/dist/dialog/index.mjs +17 -17
- package/dist/drawer/index.mjs +14 -14
- package/dist/dropdown-menu/index.mjs +21 -21
- package/dist/dropzone/index.mjs +19 -131
- package/dist/dropzone/index.mjs.map +1 -1
- package/dist/editable-table/index.mjs +18 -18
- package/dist/empty/index.mjs +2 -2
- package/dist/field/index.d.ts +3 -2
- package/dist/field/index.mjs +4 -4
- package/dist/form/index.mjs +4 -4
- package/dist/form-fields/index.mjs +26 -26
- package/dist/form-layout/index.d.ts +1 -0
- package/dist/form-layout/index.mjs +55 -54
- package/dist/form-layout/index.mjs.map +1 -1
- package/dist/hover-card/index.mjs +13 -13
- package/dist/icon/index.mjs +1 -1
- package/dist/input/index.mjs +3 -3
- package/dist/input-group/index.d.ts +1 -1
- package/dist/input-group/index.mjs +5 -5
- package/dist/input-otp/index.mjs +4 -4
- package/dist/item/index.d.ts +4 -2
- package/dist/item/index.mjs +3 -3
- package/dist/kbd/index.mjs +2 -2
- package/dist/label/index.mjs +3 -3
- package/dist/layout/index.mjs +21 -21
- package/dist/menubar/index.mjs +22 -22
- package/dist/multi-input-list/index.mjs +28 -28
- package/dist/multi-select/index.mjs +31 -31
- package/dist/navigation-menu/index.mjs +15 -15
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/index.mjs +8 -8
- package/dist/popover/index.mjs +16 -16
- package/dist/progress/index.mjs +3 -3
- package/dist/radio-group/index.mjs +16 -16
- package/dist/resizable/index.mjs +3 -3
- package/dist/scroll-area/index.mjs +10 -10
- package/dist/select/index.mjs +6 -6
- package/dist/separator/index.mjs +3 -3
- package/dist/shared/index.d.ts +13 -3
- package/dist/shared/index.mjs +6 -6
- package/dist/shared/index.mjs.map +1 -1
- package/dist/sheet/index.d.ts +7 -7
- package/dist/sheet/index.mjs +17 -17
- package/dist/sidebar/index.d.ts +17 -4
- package/dist/sidebar/index.mjs +25 -25
- package/dist/skeleton/index.mjs +3 -3
- package/dist/skeleton-component/index.mjs +4 -4
- package/dist/slider/index.mjs +11 -11
- package/dist/sortable/index.d.ts +12 -3
- package/dist/sortable/index.mjs +4 -4
- package/dist/spinner/index.mjs +4 -4
- package/dist/switch/index.mjs +9 -9
- package/dist/table/index.mjs +3 -3
- package/dist/table-filter/index.d.ts +8 -3
- package/dist/table-filter/index.mjs +52 -52
- package/dist/tabs/index.mjs +12 -12
- package/dist/textarea/index.mjs +3 -3
- package/dist/toast/index.mjs +19 -703
- package/dist/toast/index.mjs.map +1 -1
- package/dist/toaster/index.d.ts +5 -0
- package/dist/toaster/index.mjs +34 -0
- package/dist/toaster/index.mjs.map +1 -0
- package/dist/toggle/index.mjs +6 -6
- package/dist/toggle-group/index.mjs +11 -11
- package/dist/tooltip/index.mjs +15 -15
- package/package.json +5 -2
- package/dist/chunks/AutoComplete-qFuwmV53.mjs.map +0 -1
- package/dist/chunks/_commonjsHelpers-B2Be7UYW.mjs.map +0 -1
- package/dist/icon.svg +0 -7
- package/dist/index.cjs.js +0 -1
- package/dist/index.es.js +0 -1
- package/dist/ivt.css +0 -1
- package/dist/ivt.png +0 -0
|
@@ -1,232 +1,572 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { createContext, useContext, useCallback, useRef, useLayoutEffect, useState, useEffect, useMemo } from 'react';
|
|
3
|
-
import { c as cn } from './utils-
|
|
4
|
-
import { t as toDate, c as constructFrom, j as addDays, y as normalizeDates, z as startOfDay, g as getDefaultOptions, l as enUS$1, f as format, A as differenceInCalendarDays, i as getISOWeek, h as getWeek, B as isDate, e as startOfISOWeek, s as startOfWeek, C as startOfYear } from './format-
|
|
5
|
-
import { C as ChevronLeft } from './chevron-left-
|
|
6
|
-
import { C as ChevronRight } from './chevron-right-
|
|
7
|
-
import { C as ChevronDown } from './chevron-down-
|
|
8
|
-
import { b as buttonVariants, B as Button$1 } from './button-
|
|
3
|
+
import { c as cn } from './utils-uOfHPBdi.mjs';
|
|
4
|
+
import { t as toDate, c as constructFrom, j as addDays, y as normalizeDates, z as startOfDay, g as getDefaultOptions, l as enUS$1, f as format, A as differenceInCalendarDays, i as getISOWeek, h as getWeek, B as isDate, e as startOfISOWeek, s as startOfWeek, C as startOfYear } from './format-CR4Q6BSq.mjs';
|
|
5
|
+
import { C as ChevronLeft } from './chevron-left-BZ8X7kLy.mjs';
|
|
6
|
+
import { C as ChevronRight } from './chevron-right-jAScR3zY.mjs';
|
|
7
|
+
import { C as ChevronDown } from './chevron-down-o7NUBnJ4.mjs';
|
|
8
|
+
import { b as buttonVariants, B as Button$1 } from './button-BW9I4XWU.mjs';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Time zone name format.
|
|
12
12
|
*/ /**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @summary Add the specified number of months to the given date.
|
|
13
|
+
* The function returns the time zone name for the given date in the specified
|
|
14
|
+
* time zone.
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* It uses the `Intl.DateTimeFormat` API and by default outputs the time zone
|
|
17
|
+
* name in a long format, e.g. "Pacific Standard Time" or
|
|
18
|
+
* "Singapore Standard Time".
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
20
|
+
* It is possible to specify the format as the third argument using one of the following options
|
|
22
21
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* - "short": e.g. "EDT" or "GMT+8".
|
|
23
|
+
* - "long": e.g. "Eastern Daylight Time".
|
|
24
|
+
* - "shortGeneric": e.g. "ET" or "Singapore Time".
|
|
25
|
+
* - "longGeneric": e.g. "Eastern Time" or "Singapore Standard Time".
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* These options correspond to TR35 tokens `z..zzz`, `zzzz`, `v`, and `vvvv` respectively: https://www.unicode.org/reports/tr35/tr35-dates.html#dfst-zone
|
|
28
28
|
*
|
|
29
|
-
* @
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* //=> Sun Feb 01 2015 00:00:00
|
|
29
|
+
* @param timeZone - Time zone name (IANA or UTC offset)
|
|
30
|
+
* @param date - Date object to get the time zone name for
|
|
31
|
+
* @param format - Optional format of the time zone name. Defaults to "long". Can be "short", "long", "shortGeneric", or "longGeneric".
|
|
33
32
|
*
|
|
34
|
-
*
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const dayOfMonth = _date.getDate();
|
|
45
|
-
// The JS Date object supports date math by accepting out-of-bounds values for
|
|
46
|
-
// month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and
|
|
47
|
-
// new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we
|
|
48
|
-
// want except that dates will wrap around the end of a month, meaning that
|
|
49
|
-
// new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
|
|
50
|
-
// we'll default to the end of the desired month by adding 1 to the desired
|
|
51
|
-
// month and using a date of 0 to back up one day to the end of the desired
|
|
52
|
-
// month.
|
|
53
|
-
const endOfDesiredMonth = constructFrom(date, _date.getTime());
|
|
54
|
-
endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
|
|
55
|
-
const daysInMonth = endOfDesiredMonth.getDate();
|
|
56
|
-
if (dayOfMonth >= daysInMonth) {
|
|
57
|
-
// If we're already at the end of the month, then this is the correct date
|
|
58
|
-
// and we're done.
|
|
59
|
-
return endOfDesiredMonth;
|
|
60
|
-
} else {
|
|
61
|
-
// Otherwise, we now know that setting the original day-of-month value won't
|
|
62
|
-
// cause an overflow, so set the desired day-of-month. Note that we can't
|
|
63
|
-
// just set the date of `endOfDesiredMonth` because that object may have had
|
|
64
|
-
// its time changed in the unusual case where where a DST transition was on
|
|
65
|
-
// the last day of the month and its local time was in the hour skipped or
|
|
66
|
-
// repeated next to a DST transition. So we use `date` instead which is
|
|
67
|
-
// guaranteed to still have the original time.
|
|
68
|
-
_date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);
|
|
69
|
-
return _date;
|
|
70
|
-
}
|
|
33
|
+
* @returns Time zone name (e.g. "Singapore Standard Time")
|
|
34
|
+
*/ function tzName(timeZone, date, format = "long") {
|
|
35
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
36
|
+
// Enforces engine to render the time. Without the option JavaScriptCore omits it.
|
|
37
|
+
hour: "numeric",
|
|
38
|
+
timeZone: timeZone,
|
|
39
|
+
timeZoneName: format
|
|
40
|
+
}).format(date).split(/\s/g) // Format.JS uses non-breaking spaces
|
|
41
|
+
.slice(2) // Skip the hour and AM/PM parts
|
|
42
|
+
.join(" ");
|
|
71
43
|
}
|
|
72
44
|
|
|
45
|
+
const offsetFormatCache = {};
|
|
46
|
+
const offsetCache = {};
|
|
73
47
|
/**
|
|
74
|
-
* The
|
|
75
|
-
|
|
76
|
-
* @name addWeeks
|
|
77
|
-
* @category Week Helpers
|
|
78
|
-
* @summary Add the specified number of weeks to the given date.
|
|
79
|
-
*
|
|
80
|
-
* @description
|
|
81
|
-
* Add the specified number of weeks to the given date.
|
|
82
|
-
*
|
|
83
|
-
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
84
|
-
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
48
|
+
* The function extracts UTC offset in minutes from the given date in specified
|
|
49
|
+
* time zone.
|
|
85
50
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
51
|
+
* Unlike `Date.prototype.getTimezoneOffset`, this function returns the value
|
|
52
|
+
* mirrored to the sign of the offset in the time zone. For Asia/Singapore
|
|
53
|
+
* (UTC+8), `tzOffset` returns 480, while `getTimezoneOffset` returns -480.
|
|
89
54
|
*
|
|
90
|
-
* @
|
|
55
|
+
* @param timeZone - Time zone name (IANA or UTC offset)
|
|
56
|
+
* @param date - Date to check the offset for
|
|
91
57
|
*
|
|
92
|
-
* @
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
58
|
+
* @returns UTC offset in minutes
|
|
59
|
+
*/ function tzOffset(timeZone, date) {
|
|
60
|
+
try {
|
|
61
|
+
var _offsetFormatCache, _timeZone;
|
|
62
|
+
const format = (_offsetFormatCache = offsetFormatCache)[_timeZone = timeZone] || (_offsetFormatCache[_timeZone] = new Intl.DateTimeFormat("en-US", {
|
|
63
|
+
timeZone,
|
|
64
|
+
timeZoneName: "longOffset"
|
|
65
|
+
}).format);
|
|
66
|
+
const offsetStr = format(date).split("GMT")[1];
|
|
67
|
+
if (offsetStr in offsetCache) return offsetCache[offsetStr];
|
|
68
|
+
return calcOffset(offsetStr, offsetStr.split(":"));
|
|
69
|
+
} catch {
|
|
70
|
+
// Fallback to manual parsing if the runtime doesn't support ±HH:MM/±HHMM/±HH
|
|
71
|
+
// See: https://github.com/nodejs/node/issues/53419
|
|
72
|
+
if (timeZone in offsetCache) return offsetCache[timeZone];
|
|
73
|
+
const captures = timeZone?.match(offsetRe);
|
|
74
|
+
if (captures) return calcOffset(timeZone, captures.slice(1));
|
|
75
|
+
return NaN;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const offsetRe = /([+-]\d\d):?(\d\d)?/;
|
|
79
|
+
function calcOffset(cacheStr, values) {
|
|
80
|
+
const hours = +(values[0] || 0);
|
|
81
|
+
const minutes = +(values[1] || 0);
|
|
82
|
+
// Convert seconds to minutes by dividing by 60 to keep the function return in minutes.
|
|
83
|
+
const seconds = +(values[2] || 0) / 60;
|
|
84
|
+
return offsetCache[cacheStr] = hours * 60 + minutes > 0 ? hours * 60 + minutes + seconds : hours * 60 - minutes - seconds;
|
|
98
85
|
}
|
|
99
86
|
|
|
87
|
+
class TZDateMini extends Date {
|
|
88
|
+
static tz(tz, ...args) {
|
|
89
|
+
return args.length ? new TZDateMini(...args, tz) : new TZDateMini(Date.now(), tz);
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region time zone
|
|
93
|
+
withTimeZone(timeZone) {
|
|
94
|
+
return new TZDateMini(+this, timeZone);
|
|
95
|
+
}
|
|
96
|
+
getTimezoneOffset() {
|
|
97
|
+
const offset = -tzOffset(this.timeZone, this);
|
|
98
|
+
// Remove the seconds offset
|
|
99
|
+
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
100
|
+
return offset > 0 ? Math.floor(offset) : Math.ceil(offset);
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region time
|
|
104
|
+
setTime(time) {
|
|
105
|
+
Date.prototype.setTime.apply(this, arguments);
|
|
106
|
+
syncToInternal(this);
|
|
107
|
+
return +this;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region date-fns integration
|
|
111
|
+
[Symbol.for("constructDateFrom")](date) {
|
|
112
|
+
return new TZDateMini(+new Date(date), this.timeZone);
|
|
113
|
+
}
|
|
114
|
+
//#region static
|
|
115
|
+
constructor(...args){
|
|
116
|
+
super();
|
|
117
|
+
if (args.length > 1 && typeof args[args.length - 1] === "string") {
|
|
118
|
+
this.timeZone = args.pop();
|
|
119
|
+
}
|
|
120
|
+
this.internal = new Date();
|
|
121
|
+
if (isNaN(tzOffset(this.timeZone, this))) {
|
|
122
|
+
this.setTime(NaN);
|
|
123
|
+
} else {
|
|
124
|
+
if (!args.length) {
|
|
125
|
+
this.setTime(Date.now());
|
|
126
|
+
} else if (typeof args[0] === "number" && (args.length === 1 || args.length === 2 && typeof args[1] !== "number")) {
|
|
127
|
+
this.setTime(args[0]);
|
|
128
|
+
} else if (typeof args[0] === "string") {
|
|
129
|
+
this.setTime(+new Date(args[0]));
|
|
130
|
+
} else if (args[0] instanceof Date) {
|
|
131
|
+
this.setTime(+args[0]);
|
|
132
|
+
} else {
|
|
133
|
+
this.setTime(+new Date(...args));
|
|
134
|
+
adjustToSystemTZ(this);
|
|
135
|
+
syncToInternal(this);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Assign getters and setters
|
|
141
|
+
const re = /^(get|set)(?!UTC)/;
|
|
142
|
+
Object.getOwnPropertyNames(Date.prototype).forEach((method)=>{
|
|
143
|
+
if (!re.test(method)) return;
|
|
144
|
+
const utcMethod = method.replace(re, "$1UTC");
|
|
145
|
+
// Filter out methods without UTC counterparts
|
|
146
|
+
if (!TZDateMini.prototype[utcMethod]) return;
|
|
147
|
+
if (method.startsWith("get")) {
|
|
148
|
+
// Delegate to internal date's UTC method
|
|
149
|
+
TZDateMini.prototype[method] = function() {
|
|
150
|
+
return this.internal[utcMethod]();
|
|
151
|
+
};
|
|
152
|
+
} else {
|
|
153
|
+
// Assign regular setter
|
|
154
|
+
TZDateMini.prototype[method] = function() {
|
|
155
|
+
Date.prototype[utcMethod].apply(this.internal, arguments);
|
|
156
|
+
syncFromInternal(this);
|
|
157
|
+
return +this;
|
|
158
|
+
};
|
|
159
|
+
// Assign UTC setter
|
|
160
|
+
TZDateMini.prototype[utcMethod] = function() {
|
|
161
|
+
Date.prototype[utcMethod].apply(this, arguments);
|
|
162
|
+
syncToInternal(this);
|
|
163
|
+
return +this;
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
});
|
|
100
167
|
/**
|
|
101
|
-
*
|
|
102
|
-
*/ /**
|
|
103
|
-
* @name addYears
|
|
104
|
-
* @category Year Helpers
|
|
105
|
-
* @summary Add the specified number of years to the given date.
|
|
106
|
-
*
|
|
107
|
-
* @description
|
|
108
|
-
* Add the specified number of years to the given date.
|
|
109
|
-
*
|
|
110
|
-
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
111
|
-
* @typeParam ResultDate - The result `Date` type.
|
|
112
|
-
*
|
|
113
|
-
* @param date - The date to be changed
|
|
114
|
-
* @param amount - The amount of years to be added.
|
|
115
|
-
* @param options - The options
|
|
116
|
-
*
|
|
117
|
-
* @returns The new date with the years added
|
|
168
|
+
* Function syncs time to internal date, applying the time zone offset.
|
|
118
169
|
*
|
|
119
|
-
* @
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*/ function addYears(date, amount, options) {
|
|
124
|
-
return addMonths(date, amount * 12, options);
|
|
170
|
+
* @param {Date} date - Date to sync
|
|
171
|
+
*/ function syncToInternal(date) {
|
|
172
|
+
date.internal.setTime(+date);
|
|
173
|
+
date.internal.setUTCSeconds(date.internal.getUTCSeconds() - Math.round(-tzOffset(date.timeZone, date) * 60));
|
|
125
174
|
}
|
|
126
|
-
|
|
127
175
|
/**
|
|
128
|
-
*
|
|
129
|
-
|
|
130
|
-
* @name max
|
|
131
|
-
* @category Common Helpers
|
|
132
|
-
* @summary Return the latest of the given dates.
|
|
133
|
-
*
|
|
134
|
-
* @description
|
|
135
|
-
* Return the latest of the given dates.
|
|
176
|
+
* Function syncs the internal date UTC values to the date. It allows to get
|
|
177
|
+
* accurate timestamp value.
|
|
136
178
|
*
|
|
137
|
-
* @
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
* @example
|
|
145
|
-
* // Which of these dates is the latest?
|
|
146
|
-
* const result = max([
|
|
147
|
-
* new Date(1989, 6, 10),
|
|
148
|
-
* new Date(1987, 1, 11),
|
|
149
|
-
* new Date(1995, 6, 2),
|
|
150
|
-
* new Date(1990, 0, 1)
|
|
151
|
-
* ])
|
|
152
|
-
* //=> Sun Jul 02 1995 00:00:00
|
|
153
|
-
*/ function max(dates, options) {
|
|
154
|
-
let result;
|
|
155
|
-
let context = options?.in;
|
|
156
|
-
dates.forEach((date)=>{
|
|
157
|
-
// Use the first date object as the context function
|
|
158
|
-
if (!context && typeof date === "object") context = constructFrom.bind(null, date);
|
|
159
|
-
const date_ = toDate(date, context);
|
|
160
|
-
if (!result || result < date_ || isNaN(+date_)) result = date_;
|
|
161
|
-
});
|
|
162
|
-
return constructFrom(context, result || NaN);
|
|
179
|
+
* @param {Date} date - The date to sync
|
|
180
|
+
*/ function syncFromInternal(date) {
|
|
181
|
+
// First we transpose the internal values
|
|
182
|
+
Date.prototype.setFullYear.call(date, date.internal.getUTCFullYear(), date.internal.getUTCMonth(), date.internal.getUTCDate());
|
|
183
|
+
Date.prototype.setHours.call(date, date.internal.getUTCHours(), date.internal.getUTCMinutes(), date.internal.getUTCSeconds(), date.internal.getUTCMilliseconds());
|
|
184
|
+
// Now we have to adjust the date to the system time zone
|
|
185
|
+
adjustToSystemTZ(date);
|
|
163
186
|
}
|
|
164
|
-
|
|
165
187
|
/**
|
|
166
|
-
*
|
|
167
|
-
|
|
168
|
-
* @name min
|
|
169
|
-
* @category Common Helpers
|
|
170
|
-
* @summary Returns the earliest of the given dates.
|
|
171
|
-
*
|
|
172
|
-
* @description
|
|
173
|
-
* Returns the earliest of the given dates.
|
|
174
|
-
*
|
|
175
|
-
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
176
|
-
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
177
|
-
*
|
|
178
|
-
* @param dates - The dates to compare
|
|
179
|
-
*
|
|
180
|
-
* @returns The earliest of the dates
|
|
188
|
+
* Function adjusts the date to the system time zone. It uses the time zone
|
|
189
|
+
* differences to calculate the offset and adjust the date.
|
|
181
190
|
*
|
|
182
|
-
* @
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
191
|
+
* @param {Date} date - Date to adjust
|
|
192
|
+
*/ function adjustToSystemTZ(date) {
|
|
193
|
+
// Save the time zone offset before all the adjustments
|
|
194
|
+
const baseOffset = tzOffset(date.timeZone, date);
|
|
195
|
+
// Remove the seconds offset
|
|
196
|
+
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
197
|
+
const offset = baseOffset > 0 ? Math.floor(baseOffset) : Math.ceil(baseOffset);
|
|
198
|
+
//#region System DST adjustment
|
|
199
|
+
// The biggest problem with using the system time zone is that when we create
|
|
200
|
+
// a date from internal values stored in UTC, the system time zone might end
|
|
201
|
+
// up on the DST hour:
|
|
202
|
+
//
|
|
203
|
+
// $ TZ=America/New_York node
|
|
204
|
+
// > new Date(2020, 2, 8, 1).toString()
|
|
205
|
+
// 'Sun Mar 08 2020 01:00:00 GMT-0500 (Eastern Standard Time)'
|
|
206
|
+
// > new Date(2020, 2, 8, 2).toString()
|
|
207
|
+
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
208
|
+
// > new Date(2020, 2, 8, 3).toString()
|
|
209
|
+
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
210
|
+
// > new Date(2020, 2, 8, 4).toString()
|
|
211
|
+
// 'Sun Mar 08 2020 04:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
212
|
+
//
|
|
213
|
+
// Here we get the same hour for both 2 and 3, because the system time zone
|
|
214
|
+
// has DST beginning at 8 March 2020, 2 a.m. and jumps to 3 a.m. So we have
|
|
215
|
+
// to adjust the internal date to reflect that.
|
|
216
|
+
//
|
|
217
|
+
// However we want to adjust only if that's the DST hour the change happenes,
|
|
218
|
+
// not the hour where DST moves to.
|
|
219
|
+
// We calculate the previous hour to see if the time zone offset has changed
|
|
220
|
+
// and we have landed on the DST hour.
|
|
221
|
+
const prevHour = new Date(+date);
|
|
222
|
+
// We use UTC methods here as we don't want to land on the same hour again
|
|
223
|
+
// in case of DST.
|
|
224
|
+
prevHour.setUTCHours(prevHour.getUTCHours() - 1);
|
|
225
|
+
// Calculate if we are on the system DST hour.
|
|
226
|
+
const systemOffset = -new Date(+date).getTimezoneOffset();
|
|
227
|
+
const prevHourSystemOffset = -new Date(+prevHour).getTimezoneOffset();
|
|
228
|
+
const systemDSTChange = systemOffset - prevHourSystemOffset;
|
|
229
|
+
// Detect the DST shift. System DST change will occur both on
|
|
230
|
+
const dstShift = Date.prototype.getHours.apply(date) !== date.internal.getUTCHours();
|
|
231
|
+
// Move the internal date when we are on the system DST hour.
|
|
232
|
+
if (systemDSTChange && dstShift) date.internal.setUTCMinutes(date.internal.getUTCMinutes() + systemDSTChange);
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region System diff adjustment
|
|
235
|
+
// Now we need to adjust the date, since we just applied internal values.
|
|
236
|
+
// We need to calculate the difference between the system and date time zones
|
|
237
|
+
// and apply it to the date.
|
|
238
|
+
const offsetDiff = systemOffset - offset;
|
|
239
|
+
if (offsetDiff) Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetDiff);
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region Seconds System diff adjustment
|
|
242
|
+
const systemDate = new Date(+date);
|
|
243
|
+
// Set the UTC seconds to 0 to isolate the timezone offset in seconds.
|
|
244
|
+
systemDate.setUTCSeconds(0);
|
|
245
|
+
// For negative systemOffset, invert the seconds.
|
|
246
|
+
const systemSecondsOffset = systemOffset > 0 ? systemDate.getSeconds() : (systemDate.getSeconds() - 60) % 60;
|
|
247
|
+
// Calculate the seconds offset based on the timezone offset.
|
|
248
|
+
const secondsOffset = Math.round(-(tzOffset(date.timeZone, date) * 60)) % 60;
|
|
249
|
+
if (secondsOffset || systemSecondsOffset) {
|
|
250
|
+
date.internal.setUTCSeconds(date.internal.getUTCSeconds() + secondsOffset);
|
|
251
|
+
Date.prototype.setUTCSeconds.call(date, Date.prototype.getUTCSeconds.call(date) + secondsOffset + systemSecondsOffset);
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region Post-adjustment DST fix
|
|
255
|
+
const postBaseOffset = tzOffset(date.timeZone, date);
|
|
256
|
+
// Remove the seconds offset
|
|
257
|
+
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
258
|
+
const postOffset = postBaseOffset > 0 ? Math.floor(postBaseOffset) : Math.ceil(postBaseOffset);
|
|
259
|
+
const postSystemOffset = -new Date(+date).getTimezoneOffset();
|
|
260
|
+
const postOffsetDiff = postSystemOffset - postOffset;
|
|
261
|
+
const offsetChanged = postOffset !== offset;
|
|
262
|
+
const postDiff = postOffsetDiff - offsetDiff;
|
|
263
|
+
if (offsetChanged && postDiff) {
|
|
264
|
+
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + postDiff);
|
|
265
|
+
// Now we need to check if got offset change during the post-adjustment.
|
|
266
|
+
// If so, we also need both dates to reflect that.
|
|
267
|
+
const newBaseOffset = tzOffset(date.timeZone, date);
|
|
268
|
+
// Remove the seconds offset
|
|
269
|
+
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
270
|
+
const newOffset = newBaseOffset > 0 ? Math.floor(newBaseOffset) : Math.ceil(newBaseOffset);
|
|
271
|
+
const offsetChange = postOffset - newOffset;
|
|
272
|
+
if (offsetChange) {
|
|
273
|
+
date.internal.setUTCMinutes(date.internal.getUTCMinutes() + offsetChange);
|
|
274
|
+
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetChange);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
class TZDate extends TZDateMini {
|
|
281
|
+
//#region static
|
|
282
|
+
static tz(tz, ...args) {
|
|
283
|
+
return args.length ? new TZDate(...args, tz) : new TZDate(Date.now(), tz);
|
|
284
|
+
}
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region representation
|
|
287
|
+
toISOString() {
|
|
288
|
+
const [sign, hours, minutes] = this.tzComponents();
|
|
289
|
+
const tz = `${sign}${hours}:${minutes}`;
|
|
290
|
+
return this.internal.toISOString().slice(0, -1) + tz;
|
|
291
|
+
}
|
|
292
|
+
toString() {
|
|
293
|
+
// "Tue Aug 13 2024 07:50:19 GMT+0800 (Singapore Standard Time)";
|
|
294
|
+
return `${this.toDateString()} ${this.toTimeString()}`;
|
|
295
|
+
}
|
|
296
|
+
toDateString() {
|
|
297
|
+
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
|
298
|
+
const [day, date, month, year] = this.internal.toUTCString().split(" ");
|
|
299
|
+
// "Tue Aug 13 2024"
|
|
300
|
+
return `${day?.slice(0, -1)} ${month} ${date} ${year}`;
|
|
301
|
+
}
|
|
302
|
+
toTimeString() {
|
|
303
|
+
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
|
304
|
+
const time = this.internal.toUTCString().split(" ")[4];
|
|
305
|
+
const [sign, hours, minutes] = this.tzComponents();
|
|
306
|
+
// "07:42:23 GMT+0800 (Singapore Standard Time)"
|
|
307
|
+
return `${time} GMT${sign}${hours}${minutes} (${tzName(this.timeZone, this)})`;
|
|
308
|
+
}
|
|
309
|
+
toLocaleString(locales, options) {
|
|
310
|
+
return Date.prototype.toLocaleString.call(this, locales, {
|
|
311
|
+
...options,
|
|
312
|
+
timeZone: options?.timeZone || this.timeZone
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
toLocaleDateString(locales, options) {
|
|
316
|
+
return Date.prototype.toLocaleDateString.call(this, locales, {
|
|
317
|
+
...options,
|
|
318
|
+
timeZone: options?.timeZone || this.timeZone
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
toLocaleTimeString(locales, options) {
|
|
322
|
+
return Date.prototype.toLocaleTimeString.call(this, locales, {
|
|
323
|
+
...options,
|
|
324
|
+
timeZone: options?.timeZone || this.timeZone
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region private
|
|
329
|
+
tzComponents() {
|
|
330
|
+
const offset = this.getTimezoneOffset();
|
|
331
|
+
const sign = offset > 0 ? "-" : "+";
|
|
332
|
+
const hours = String(Math.floor(Math.abs(offset) / 60)).padStart(2, "0");
|
|
333
|
+
const minutes = String(Math.abs(offset) % 60).padStart(2, "0");
|
|
334
|
+
return [
|
|
335
|
+
sign,
|
|
336
|
+
hours,
|
|
337
|
+
minutes
|
|
338
|
+
];
|
|
339
|
+
}
|
|
340
|
+
//#endregion
|
|
341
|
+
withTimeZone(timeZone) {
|
|
342
|
+
return new TZDate(+this, timeZone);
|
|
343
|
+
}
|
|
344
|
+
//#region date-fns integration
|
|
345
|
+
[Symbol.for("constructDateFrom")](date) {
|
|
346
|
+
return new TZDate(+new Date(date), this.timeZone);
|
|
347
|
+
}
|
|
201
348
|
}
|
|
202
349
|
|
|
203
350
|
/**
|
|
204
|
-
* The {@link
|
|
351
|
+
* The {@link addMonths} function options.
|
|
205
352
|
*/ /**
|
|
206
|
-
* @name
|
|
207
|
-
* @category
|
|
208
|
-
* @summary
|
|
353
|
+
* @name addMonths
|
|
354
|
+
* @category Month Helpers
|
|
355
|
+
* @summary Add the specified number of months to the given date.
|
|
209
356
|
*
|
|
210
357
|
* @description
|
|
211
|
-
*
|
|
358
|
+
* Add the specified number of months to the given date.
|
|
212
359
|
*
|
|
213
|
-
* @
|
|
214
|
-
* @
|
|
215
|
-
* @param options - An object with options
|
|
360
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
361
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
216
362
|
*
|
|
217
|
-
* @
|
|
363
|
+
* @param date - The date to be changed
|
|
364
|
+
* @param amount - The amount of months to be added.
|
|
365
|
+
* @param options - The options object
|
|
218
366
|
*
|
|
219
|
-
* @
|
|
220
|
-
* // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?
|
|
221
|
-
* const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))
|
|
222
|
-
* //=> true
|
|
367
|
+
* @returns The new date with the months added
|
|
223
368
|
*
|
|
224
369
|
* @example
|
|
225
|
-
* //
|
|
226
|
-
* const result =
|
|
227
|
-
* //=>
|
|
370
|
+
* // Add 5 months to 1 September 2014:
|
|
371
|
+
* const result = addMonths(new Date(2014, 8, 1), 5)
|
|
372
|
+
* //=> Sun Feb 01 2015 00:00:00
|
|
228
373
|
*
|
|
229
|
-
*
|
|
374
|
+
* // Add one month to 30 January 2023:
|
|
375
|
+
* const result = addMonths(new Date(2023, 0, 30), 1)
|
|
376
|
+
* //=> Tue Feb 28 2023 00:00:00
|
|
377
|
+
*/ function addMonths(date, amount, options) {
|
|
378
|
+
const _date = toDate(date, options?.in);
|
|
379
|
+
if (isNaN(amount)) return constructFrom(date, NaN);
|
|
380
|
+
if (!amount) {
|
|
381
|
+
// If 0 months, no-op to avoid changing times in the hour before end of DST
|
|
382
|
+
return _date;
|
|
383
|
+
}
|
|
384
|
+
const dayOfMonth = _date.getDate();
|
|
385
|
+
// The JS Date object supports date math by accepting out-of-bounds values for
|
|
386
|
+
// month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and
|
|
387
|
+
// new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we
|
|
388
|
+
// want except that dates will wrap around the end of a month, meaning that
|
|
389
|
+
// new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
|
|
390
|
+
// we'll default to the end of the desired month by adding 1 to the desired
|
|
391
|
+
// month and using a date of 0 to back up one day to the end of the desired
|
|
392
|
+
// month.
|
|
393
|
+
const endOfDesiredMonth = constructFrom(date, _date.getTime());
|
|
394
|
+
endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
|
|
395
|
+
const daysInMonth = endOfDesiredMonth.getDate();
|
|
396
|
+
if (dayOfMonth >= daysInMonth) {
|
|
397
|
+
// If we're already at the end of the month, then this is the correct date
|
|
398
|
+
// and we're done.
|
|
399
|
+
return endOfDesiredMonth;
|
|
400
|
+
} else {
|
|
401
|
+
// Otherwise, we now know that setting the original day-of-month value won't
|
|
402
|
+
// cause an overflow, so set the desired day-of-month. Note that we can't
|
|
403
|
+
// just set the date of `endOfDesiredMonth` because that object may have had
|
|
404
|
+
// its time changed in the unusual case where where a DST transition was on
|
|
405
|
+
// the last day of the month and its local time was in the hour skipped or
|
|
406
|
+
// repeated next to a DST transition. So we use `date` instead which is
|
|
407
|
+
// guaranteed to still have the original time.
|
|
408
|
+
_date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);
|
|
409
|
+
return _date;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* The {@link addWeeks} function options.
|
|
415
|
+
*/ /**
|
|
416
|
+
* @name addWeeks
|
|
417
|
+
* @category Week Helpers
|
|
418
|
+
* @summary Add the specified number of weeks to the given date.
|
|
419
|
+
*
|
|
420
|
+
* @description
|
|
421
|
+
* Add the specified number of weeks to the given date.
|
|
422
|
+
*
|
|
423
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
424
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
425
|
+
*
|
|
426
|
+
* @param date - The date to be changed
|
|
427
|
+
* @param amount - The amount of weeks to be added.
|
|
428
|
+
* @param options - An object with options
|
|
429
|
+
*
|
|
430
|
+
* @returns The new date with the weeks added
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* // Add 4 weeks to 1 September 2014:
|
|
434
|
+
* const result = addWeeks(new Date(2014, 8, 1), 4)
|
|
435
|
+
* //=> Mon Sep 29 2014 00:00:00
|
|
436
|
+
*/ function addWeeks(date, amount, options) {
|
|
437
|
+
return addDays(date, amount * 7, options);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* The {@link addYears} function options.
|
|
442
|
+
*/ /**
|
|
443
|
+
* @name addYears
|
|
444
|
+
* @category Year Helpers
|
|
445
|
+
* @summary Add the specified number of years to the given date.
|
|
446
|
+
*
|
|
447
|
+
* @description
|
|
448
|
+
* Add the specified number of years to the given date.
|
|
449
|
+
*
|
|
450
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
451
|
+
* @typeParam ResultDate - The result `Date` type.
|
|
452
|
+
*
|
|
453
|
+
* @param date - The date to be changed
|
|
454
|
+
* @param amount - The amount of years to be added.
|
|
455
|
+
* @param options - The options
|
|
456
|
+
*
|
|
457
|
+
* @returns The new date with the years added
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* // Add 5 years to 1 September 2014:
|
|
461
|
+
* const result = addYears(new Date(2014, 8, 1), 5)
|
|
462
|
+
* //=> Sun Sep 01 2019 00:00:00
|
|
463
|
+
*/ function addYears(date, amount, options) {
|
|
464
|
+
return addMonths(date, amount * 12, options);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* The {@link max} function options.
|
|
469
|
+
*/ /**
|
|
470
|
+
* @name max
|
|
471
|
+
* @category Common Helpers
|
|
472
|
+
* @summary Return the latest of the given dates.
|
|
473
|
+
*
|
|
474
|
+
* @description
|
|
475
|
+
* Return the latest of the given dates.
|
|
476
|
+
*
|
|
477
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
478
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
479
|
+
*
|
|
480
|
+
* @param dates - The dates to compare
|
|
481
|
+
*
|
|
482
|
+
* @returns The latest of the dates
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* // Which of these dates is the latest?
|
|
486
|
+
* const result = max([
|
|
487
|
+
* new Date(1989, 6, 10),
|
|
488
|
+
* new Date(1987, 1, 11),
|
|
489
|
+
* new Date(1995, 6, 2),
|
|
490
|
+
* new Date(1990, 0, 1)
|
|
491
|
+
* ])
|
|
492
|
+
* //=> Sun Jul 02 1995 00:00:00
|
|
493
|
+
*/ function max(dates, options) {
|
|
494
|
+
let result;
|
|
495
|
+
let context = options?.in;
|
|
496
|
+
dates.forEach((date)=>{
|
|
497
|
+
// Use the first date object as the context function
|
|
498
|
+
if (!context && typeof date === "object") context = constructFrom.bind(null, date);
|
|
499
|
+
const date_ = toDate(date, context);
|
|
500
|
+
if (!result || result < date_ || isNaN(+date_)) result = date_;
|
|
501
|
+
});
|
|
502
|
+
return constructFrom(context, result || NaN);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* The {@link min} function options.
|
|
507
|
+
*/ /**
|
|
508
|
+
* @name min
|
|
509
|
+
* @category Common Helpers
|
|
510
|
+
* @summary Returns the earliest of the given dates.
|
|
511
|
+
*
|
|
512
|
+
* @description
|
|
513
|
+
* Returns the earliest of the given dates.
|
|
514
|
+
*
|
|
515
|
+
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
|
|
516
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
517
|
+
*
|
|
518
|
+
* @param dates - The dates to compare
|
|
519
|
+
*
|
|
520
|
+
* @returns The earliest of the dates
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* // Which of these dates is the earliest?
|
|
524
|
+
* const result = min([
|
|
525
|
+
* new Date(1989, 6, 10),
|
|
526
|
+
* new Date(1987, 1, 11),
|
|
527
|
+
* new Date(1995, 6, 2),
|
|
528
|
+
* new Date(1990, 0, 1)
|
|
529
|
+
* ])
|
|
530
|
+
* //=> Wed Feb 11 1987 00:00:00
|
|
531
|
+
*/ function min(dates, options) {
|
|
532
|
+
let result;
|
|
533
|
+
let context = options?.in;
|
|
534
|
+
dates.forEach((date)=>{
|
|
535
|
+
// Use the first date object as the context function
|
|
536
|
+
if (!context && typeof date === "object") context = constructFrom.bind(null, date);
|
|
537
|
+
const date_ = toDate(date, context);
|
|
538
|
+
if (!result || result > date_ || isNaN(+date_)) result = date_;
|
|
539
|
+
});
|
|
540
|
+
return constructFrom(context, result || NaN);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* The {@link isSameDay} function options.
|
|
545
|
+
*/ /**
|
|
546
|
+
* @name isSameDay
|
|
547
|
+
* @category Day Helpers
|
|
548
|
+
* @summary Are the given dates in the same day (and year and month)?
|
|
549
|
+
*
|
|
550
|
+
* @description
|
|
551
|
+
* Are the given dates in the same day (and year and month)?
|
|
552
|
+
*
|
|
553
|
+
* @param laterDate - The first date to check
|
|
554
|
+
* @param earlierDate - The second date to check
|
|
555
|
+
* @param options - An object with options
|
|
556
|
+
*
|
|
557
|
+
* @returns The dates are in the same day (and year and month)
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?
|
|
561
|
+
* const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))
|
|
562
|
+
* //=> true
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* // Are 4 September and 4 October in the same day?
|
|
566
|
+
* const result = isSameDay(new Date(2014, 8, 4), new Date(2014, 9, 4))
|
|
567
|
+
* //=> false
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
230
570
|
* // Are 4 September, 2014 and 4 September, 2015 in the same day?
|
|
231
571
|
* const result = isSameDay(new Date(2014, 8, 4), new Date(2015, 8, 4))
|
|
232
572
|
* //=> false
|
|
@@ -778,346 +1118,6 @@ function normalizeInterval(context, interval) {
|
|
|
778
1118
|
return date_;
|
|
779
1119
|
}
|
|
780
1120
|
|
|
781
|
-
/**
|
|
782
|
-
* Time zone name format.
|
|
783
|
-
*/ /**
|
|
784
|
-
* The function returns the time zone name for the given date in the specified
|
|
785
|
-
* time zone.
|
|
786
|
-
*
|
|
787
|
-
* It uses the `Intl.DateTimeFormat` API and by default outputs the time zone
|
|
788
|
-
* name in a long format, e.g. "Pacific Standard Time" or
|
|
789
|
-
* "Singapore Standard Time".
|
|
790
|
-
*
|
|
791
|
-
* It is possible to specify the format as the third argument using one of the following options
|
|
792
|
-
*
|
|
793
|
-
* - "short": e.g. "EDT" or "GMT+8".
|
|
794
|
-
* - "long": e.g. "Eastern Daylight Time".
|
|
795
|
-
* - "shortGeneric": e.g. "ET" or "Singapore Time".
|
|
796
|
-
* - "longGeneric": e.g. "Eastern Time" or "Singapore Standard Time".
|
|
797
|
-
*
|
|
798
|
-
* These options correspond to TR35 tokens `z..zzz`, `zzzz`, `v`, and `vvvv` respectively: https://www.unicode.org/reports/tr35/tr35-dates.html#dfst-zone
|
|
799
|
-
*
|
|
800
|
-
* @param timeZone - Time zone name (IANA or UTC offset)
|
|
801
|
-
* @param date - Date object to get the time zone name for
|
|
802
|
-
* @param format - Optional format of the time zone name. Defaults to "long". Can be "short", "long", "shortGeneric", or "longGeneric".
|
|
803
|
-
*
|
|
804
|
-
* @returns Time zone name (e.g. "Singapore Standard Time")
|
|
805
|
-
*/ function tzName(timeZone, date, format = "long") {
|
|
806
|
-
return new Intl.DateTimeFormat("en-US", {
|
|
807
|
-
// Enforces engine to render the time. Without the option JavaScriptCore omits it.
|
|
808
|
-
hour: "numeric",
|
|
809
|
-
timeZone: timeZone,
|
|
810
|
-
timeZoneName: format
|
|
811
|
-
}).format(date).split(/\s/g) // Format.JS uses non-breaking spaces
|
|
812
|
-
.slice(2) // Skip the hour and AM/PM parts
|
|
813
|
-
.join(" ");
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
const offsetFormatCache = {};
|
|
817
|
-
const offsetCache = {};
|
|
818
|
-
/**
|
|
819
|
-
* The function extracts UTC offset in minutes from the given date in specified
|
|
820
|
-
* time zone.
|
|
821
|
-
*
|
|
822
|
-
* Unlike `Date.prototype.getTimezoneOffset`, this function returns the value
|
|
823
|
-
* mirrored to the sign of the offset in the time zone. For Asia/Singapore
|
|
824
|
-
* (UTC+8), `tzOffset` returns 480, while `getTimezoneOffset` returns -480.
|
|
825
|
-
*
|
|
826
|
-
* @param timeZone - Time zone name (IANA or UTC offset)
|
|
827
|
-
* @param date - Date to check the offset for
|
|
828
|
-
*
|
|
829
|
-
* @returns UTC offset in minutes
|
|
830
|
-
*/ function tzOffset(timeZone, date) {
|
|
831
|
-
try {
|
|
832
|
-
var _offsetFormatCache, _timeZone;
|
|
833
|
-
const format = (_offsetFormatCache = offsetFormatCache)[_timeZone = timeZone] || (_offsetFormatCache[_timeZone] = new Intl.DateTimeFormat("en-US", {
|
|
834
|
-
timeZone,
|
|
835
|
-
timeZoneName: "longOffset"
|
|
836
|
-
}).format);
|
|
837
|
-
const offsetStr = format(date).split("GMT")[1];
|
|
838
|
-
if (offsetStr in offsetCache) return offsetCache[offsetStr];
|
|
839
|
-
return calcOffset(offsetStr, offsetStr.split(":"));
|
|
840
|
-
} catch {
|
|
841
|
-
// Fallback to manual parsing if the runtime doesn't support ±HH:MM/±HHMM/±HH
|
|
842
|
-
// See: https://github.com/nodejs/node/issues/53419
|
|
843
|
-
if (timeZone in offsetCache) return offsetCache[timeZone];
|
|
844
|
-
const captures = timeZone?.match(offsetRe);
|
|
845
|
-
if (captures) return calcOffset(timeZone, captures.slice(1));
|
|
846
|
-
return NaN;
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
const offsetRe = /([+-]\d\d):?(\d\d)?/;
|
|
850
|
-
function calcOffset(cacheStr, values) {
|
|
851
|
-
const hours = +(values[0] || 0);
|
|
852
|
-
const minutes = +(values[1] || 0);
|
|
853
|
-
// Convert seconds to minutes by dividing by 60 to keep the function return in minutes.
|
|
854
|
-
const seconds = +(values[2] || 0) / 60;
|
|
855
|
-
return offsetCache[cacheStr] = hours * 60 + minutes > 0 ? hours * 60 + minutes + seconds : hours * 60 - minutes - seconds;
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
class TZDateMini extends Date {
|
|
859
|
-
static tz(tz, ...args) {
|
|
860
|
-
return args.length ? new TZDateMini(...args, tz) : new TZDateMini(Date.now(), tz);
|
|
861
|
-
}
|
|
862
|
-
//#endregion
|
|
863
|
-
//#region time zone
|
|
864
|
-
withTimeZone(timeZone) {
|
|
865
|
-
return new TZDateMini(+this, timeZone);
|
|
866
|
-
}
|
|
867
|
-
getTimezoneOffset() {
|
|
868
|
-
const offset = -tzOffset(this.timeZone, this);
|
|
869
|
-
// Remove the seconds offset
|
|
870
|
-
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
871
|
-
return offset > 0 ? Math.floor(offset) : Math.ceil(offset);
|
|
872
|
-
}
|
|
873
|
-
//#endregion
|
|
874
|
-
//#region time
|
|
875
|
-
setTime(time) {
|
|
876
|
-
Date.prototype.setTime.apply(this, arguments);
|
|
877
|
-
syncToInternal(this);
|
|
878
|
-
return +this;
|
|
879
|
-
}
|
|
880
|
-
//#endregion
|
|
881
|
-
//#region date-fns integration
|
|
882
|
-
[Symbol.for("constructDateFrom")](date) {
|
|
883
|
-
return new TZDateMini(+new Date(date), this.timeZone);
|
|
884
|
-
}
|
|
885
|
-
//#region static
|
|
886
|
-
constructor(...args){
|
|
887
|
-
super();
|
|
888
|
-
if (args.length > 1 && typeof args[args.length - 1] === "string") {
|
|
889
|
-
this.timeZone = args.pop();
|
|
890
|
-
}
|
|
891
|
-
this.internal = new Date();
|
|
892
|
-
if (isNaN(tzOffset(this.timeZone, this))) {
|
|
893
|
-
this.setTime(NaN);
|
|
894
|
-
} else {
|
|
895
|
-
if (!args.length) {
|
|
896
|
-
this.setTime(Date.now());
|
|
897
|
-
} else if (typeof args[0] === "number" && (args.length === 1 || args.length === 2 && typeof args[1] !== "number")) {
|
|
898
|
-
this.setTime(args[0]);
|
|
899
|
-
} else if (typeof args[0] === "string") {
|
|
900
|
-
this.setTime(+new Date(args[0]));
|
|
901
|
-
} else if (args[0] instanceof Date) {
|
|
902
|
-
this.setTime(+args[0]);
|
|
903
|
-
} else {
|
|
904
|
-
this.setTime(+new Date(...args));
|
|
905
|
-
adjustToSystemTZ(this);
|
|
906
|
-
syncToInternal(this);
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
// Assign getters and setters
|
|
912
|
-
const re = /^(get|set)(?!UTC)/;
|
|
913
|
-
Object.getOwnPropertyNames(Date.prototype).forEach((method)=>{
|
|
914
|
-
if (!re.test(method)) return;
|
|
915
|
-
const utcMethod = method.replace(re, "$1UTC");
|
|
916
|
-
// Filter out methods without UTC counterparts
|
|
917
|
-
if (!TZDateMini.prototype[utcMethod]) return;
|
|
918
|
-
if (method.startsWith("get")) {
|
|
919
|
-
// Delegate to internal date's UTC method
|
|
920
|
-
TZDateMini.prototype[method] = function() {
|
|
921
|
-
return this.internal[utcMethod]();
|
|
922
|
-
};
|
|
923
|
-
} else {
|
|
924
|
-
// Assign regular setter
|
|
925
|
-
TZDateMini.prototype[method] = function() {
|
|
926
|
-
Date.prototype[utcMethod].apply(this.internal, arguments);
|
|
927
|
-
syncFromInternal(this);
|
|
928
|
-
return +this;
|
|
929
|
-
};
|
|
930
|
-
// Assign UTC setter
|
|
931
|
-
TZDateMini.prototype[utcMethod] = function() {
|
|
932
|
-
Date.prototype[utcMethod].apply(this, arguments);
|
|
933
|
-
syncToInternal(this);
|
|
934
|
-
return +this;
|
|
935
|
-
};
|
|
936
|
-
}
|
|
937
|
-
});
|
|
938
|
-
/**
|
|
939
|
-
* Function syncs time to internal date, applying the time zone offset.
|
|
940
|
-
*
|
|
941
|
-
* @param {Date} date - Date to sync
|
|
942
|
-
*/ function syncToInternal(date) {
|
|
943
|
-
date.internal.setTime(+date);
|
|
944
|
-
date.internal.setUTCSeconds(date.internal.getUTCSeconds() - Math.round(-tzOffset(date.timeZone, date) * 60));
|
|
945
|
-
}
|
|
946
|
-
/**
|
|
947
|
-
* Function syncs the internal date UTC values to the date. It allows to get
|
|
948
|
-
* accurate timestamp value.
|
|
949
|
-
*
|
|
950
|
-
* @param {Date} date - The date to sync
|
|
951
|
-
*/ function syncFromInternal(date) {
|
|
952
|
-
// First we transpose the internal values
|
|
953
|
-
Date.prototype.setFullYear.call(date, date.internal.getUTCFullYear(), date.internal.getUTCMonth(), date.internal.getUTCDate());
|
|
954
|
-
Date.prototype.setHours.call(date, date.internal.getUTCHours(), date.internal.getUTCMinutes(), date.internal.getUTCSeconds(), date.internal.getUTCMilliseconds());
|
|
955
|
-
// Now we have to adjust the date to the system time zone
|
|
956
|
-
adjustToSystemTZ(date);
|
|
957
|
-
}
|
|
958
|
-
/**
|
|
959
|
-
* Function adjusts the date to the system time zone. It uses the time zone
|
|
960
|
-
* differences to calculate the offset and adjust the date.
|
|
961
|
-
*
|
|
962
|
-
* @param {Date} date - Date to adjust
|
|
963
|
-
*/ function adjustToSystemTZ(date) {
|
|
964
|
-
// Save the time zone offset before all the adjustments
|
|
965
|
-
const baseOffset = tzOffset(date.timeZone, date);
|
|
966
|
-
// Remove the seconds offset
|
|
967
|
-
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
968
|
-
const offset = baseOffset > 0 ? Math.floor(baseOffset) : Math.ceil(baseOffset);
|
|
969
|
-
//#region System DST adjustment
|
|
970
|
-
// The biggest problem with using the system time zone is that when we create
|
|
971
|
-
// a date from internal values stored in UTC, the system time zone might end
|
|
972
|
-
// up on the DST hour:
|
|
973
|
-
//
|
|
974
|
-
// $ TZ=America/New_York node
|
|
975
|
-
// > new Date(2020, 2, 8, 1).toString()
|
|
976
|
-
// 'Sun Mar 08 2020 01:00:00 GMT-0500 (Eastern Standard Time)'
|
|
977
|
-
// > new Date(2020, 2, 8, 2).toString()
|
|
978
|
-
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
979
|
-
// > new Date(2020, 2, 8, 3).toString()
|
|
980
|
-
// 'Sun Mar 08 2020 03:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
981
|
-
// > new Date(2020, 2, 8, 4).toString()
|
|
982
|
-
// 'Sun Mar 08 2020 04:00:00 GMT-0400 (Eastern Daylight Time)'
|
|
983
|
-
//
|
|
984
|
-
// Here we get the same hour for both 2 and 3, because the system time zone
|
|
985
|
-
// has DST beginning at 8 March 2020, 2 a.m. and jumps to 3 a.m. So we have
|
|
986
|
-
// to adjust the internal date to reflect that.
|
|
987
|
-
//
|
|
988
|
-
// However we want to adjust only if that's the DST hour the change happenes,
|
|
989
|
-
// not the hour where DST moves to.
|
|
990
|
-
// We calculate the previous hour to see if the time zone offset has changed
|
|
991
|
-
// and we have landed on the DST hour.
|
|
992
|
-
const prevHour = new Date(+date);
|
|
993
|
-
// We use UTC methods here as we don't want to land on the same hour again
|
|
994
|
-
// in case of DST.
|
|
995
|
-
prevHour.setUTCHours(prevHour.getUTCHours() - 1);
|
|
996
|
-
// Calculate if we are on the system DST hour.
|
|
997
|
-
const systemOffset = -new Date(+date).getTimezoneOffset();
|
|
998
|
-
const prevHourSystemOffset = -new Date(+prevHour).getTimezoneOffset();
|
|
999
|
-
const systemDSTChange = systemOffset - prevHourSystemOffset;
|
|
1000
|
-
// Detect the DST shift. System DST change will occur both on
|
|
1001
|
-
const dstShift = Date.prototype.getHours.apply(date) !== date.internal.getUTCHours();
|
|
1002
|
-
// Move the internal date when we are on the system DST hour.
|
|
1003
|
-
if (systemDSTChange && dstShift) date.internal.setUTCMinutes(date.internal.getUTCMinutes() + systemDSTChange);
|
|
1004
|
-
//#endregion
|
|
1005
|
-
//#region System diff adjustment
|
|
1006
|
-
// Now we need to adjust the date, since we just applied internal values.
|
|
1007
|
-
// We need to calculate the difference between the system and date time zones
|
|
1008
|
-
// and apply it to the date.
|
|
1009
|
-
const offsetDiff = systemOffset - offset;
|
|
1010
|
-
if (offsetDiff) Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetDiff);
|
|
1011
|
-
//#endregion
|
|
1012
|
-
//#region Seconds System diff adjustment
|
|
1013
|
-
const systemDate = new Date(+date);
|
|
1014
|
-
// Set the UTC seconds to 0 to isolate the timezone offset in seconds.
|
|
1015
|
-
systemDate.setUTCSeconds(0);
|
|
1016
|
-
// For negative systemOffset, invert the seconds.
|
|
1017
|
-
const systemSecondsOffset = systemOffset > 0 ? systemDate.getSeconds() : (systemDate.getSeconds() - 60) % 60;
|
|
1018
|
-
// Calculate the seconds offset based on the timezone offset.
|
|
1019
|
-
const secondsOffset = Math.round(-(tzOffset(date.timeZone, date) * 60)) % 60;
|
|
1020
|
-
if (secondsOffset || systemSecondsOffset) {
|
|
1021
|
-
date.internal.setUTCSeconds(date.internal.getUTCSeconds() + secondsOffset);
|
|
1022
|
-
Date.prototype.setUTCSeconds.call(date, Date.prototype.getUTCSeconds.call(date) + secondsOffset + systemSecondsOffset);
|
|
1023
|
-
}
|
|
1024
|
-
//#endregion
|
|
1025
|
-
//#region Post-adjustment DST fix
|
|
1026
|
-
const postBaseOffset = tzOffset(date.timeZone, date);
|
|
1027
|
-
// Remove the seconds offset
|
|
1028
|
-
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
1029
|
-
const postOffset = postBaseOffset > 0 ? Math.floor(postBaseOffset) : Math.ceil(postBaseOffset);
|
|
1030
|
-
const postSystemOffset = -new Date(+date).getTimezoneOffset();
|
|
1031
|
-
const postOffsetDiff = postSystemOffset - postOffset;
|
|
1032
|
-
const offsetChanged = postOffset !== offset;
|
|
1033
|
-
const postDiff = postOffsetDiff - offsetDiff;
|
|
1034
|
-
if (offsetChanged && postDiff) {
|
|
1035
|
-
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + postDiff);
|
|
1036
|
-
// Now we need to check if got offset change during the post-adjustment.
|
|
1037
|
-
// If so, we also need both dates to reflect that.
|
|
1038
|
-
const newBaseOffset = tzOffset(date.timeZone, date);
|
|
1039
|
-
// Remove the seconds offset
|
|
1040
|
-
// use Math.floor for negative GMT timezones and Math.ceil for positive GMT timezones.
|
|
1041
|
-
const newOffset = newBaseOffset > 0 ? Math.floor(newBaseOffset) : Math.ceil(newBaseOffset);
|
|
1042
|
-
const offsetChange = postOffset - newOffset;
|
|
1043
|
-
if (offsetChange) {
|
|
1044
|
-
date.internal.setUTCMinutes(date.internal.getUTCMinutes() + offsetChange);
|
|
1045
|
-
Date.prototype.setUTCMinutes.call(date, Date.prototype.getUTCMinutes.call(date) + offsetChange);
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
//#endregion
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
class TZDate extends TZDateMini {
|
|
1052
|
-
//#region static
|
|
1053
|
-
static tz(tz, ...args) {
|
|
1054
|
-
return args.length ? new TZDate(...args, tz) : new TZDate(Date.now(), tz);
|
|
1055
|
-
}
|
|
1056
|
-
//#endregion
|
|
1057
|
-
//#region representation
|
|
1058
|
-
toISOString() {
|
|
1059
|
-
const [sign, hours, minutes] = this.tzComponents();
|
|
1060
|
-
const tz = `${sign}${hours}:${minutes}`;
|
|
1061
|
-
return this.internal.toISOString().slice(0, -1) + tz;
|
|
1062
|
-
}
|
|
1063
|
-
toString() {
|
|
1064
|
-
// "Tue Aug 13 2024 07:50:19 GMT+0800 (Singapore Standard Time)";
|
|
1065
|
-
return `${this.toDateString()} ${this.toTimeString()}`;
|
|
1066
|
-
}
|
|
1067
|
-
toDateString() {
|
|
1068
|
-
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
|
1069
|
-
const [day, date, month, year] = this.internal.toUTCString().split(" ");
|
|
1070
|
-
// "Tue Aug 13 2024"
|
|
1071
|
-
return `${day?.slice(0, -1)} ${month} ${date} ${year}`;
|
|
1072
|
-
}
|
|
1073
|
-
toTimeString() {
|
|
1074
|
-
// toUTCString returns RFC 7231 ("Mon, 12 Aug 2024 23:36:08 GMT")
|
|
1075
|
-
const time = this.internal.toUTCString().split(" ")[4];
|
|
1076
|
-
const [sign, hours, minutes] = this.tzComponents();
|
|
1077
|
-
// "07:42:23 GMT+0800 (Singapore Standard Time)"
|
|
1078
|
-
return `${time} GMT${sign}${hours}${minutes} (${tzName(this.timeZone, this)})`;
|
|
1079
|
-
}
|
|
1080
|
-
toLocaleString(locales, options) {
|
|
1081
|
-
return Date.prototype.toLocaleString.call(this, locales, {
|
|
1082
|
-
...options,
|
|
1083
|
-
timeZone: options?.timeZone || this.timeZone
|
|
1084
|
-
});
|
|
1085
|
-
}
|
|
1086
|
-
toLocaleDateString(locales, options) {
|
|
1087
|
-
return Date.prototype.toLocaleDateString.call(this, locales, {
|
|
1088
|
-
...options,
|
|
1089
|
-
timeZone: options?.timeZone || this.timeZone
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
toLocaleTimeString(locales, options) {
|
|
1093
|
-
return Date.prototype.toLocaleTimeString.call(this, locales, {
|
|
1094
|
-
...options,
|
|
1095
|
-
timeZone: options?.timeZone || this.timeZone
|
|
1096
|
-
});
|
|
1097
|
-
}
|
|
1098
|
-
//#endregion
|
|
1099
|
-
//#region private
|
|
1100
|
-
tzComponents() {
|
|
1101
|
-
const offset = this.getTimezoneOffset();
|
|
1102
|
-
const sign = offset > 0 ? "-" : "+";
|
|
1103
|
-
const hours = String(Math.floor(Math.abs(offset) / 60)).padStart(2, "0");
|
|
1104
|
-
const minutes = String(Math.abs(offset) % 60).padStart(2, "0");
|
|
1105
|
-
return [
|
|
1106
|
-
sign,
|
|
1107
|
-
hours,
|
|
1108
|
-
minutes
|
|
1109
|
-
];
|
|
1110
|
-
}
|
|
1111
|
-
//#endregion
|
|
1112
|
-
withTimeZone(timeZone) {
|
|
1113
|
-
return new TZDate(+this, timeZone);
|
|
1114
|
-
}
|
|
1115
|
-
//#region date-fns integration
|
|
1116
|
-
[Symbol.for("constructDateFrom")](date) {
|
|
1117
|
-
return new TZDate(+new Date(date), this.timeZone);
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
|
|
1121
1121
|
const FIVE_WEEKS = 5;
|
|
1122
1122
|
const FOUR_WEEKS = 4;
|
|
1123
1123
|
/**
|
|
@@ -5019,4 +5019,4 @@ function CalendarDayButton({ className, day, modifiers, ...props }) {
|
|
|
5019
5019
|
}
|
|
5020
5020
|
|
|
5021
5021
|
export { Calendar as C, CalendarDayButton as a, addMonths as b };
|
|
5022
|
-
//# sourceMappingURL=calendar-
|
|
5022
|
+
//# sourceMappingURL=calendar-C549VT55.mjs.map
|