@nova-design-system/nova-webcomponents 3.0.0 → 3.2.0
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/cjs/{constants-bcd6b2e2.js → constants-8fb8ccc0.js} +14 -1
- package/dist/cjs/constants-8fb8ccc0.js.map +1 -0
- package/dist/cjs/{index-9bda5507.js → index-108ddff0.js} +22 -6
- package/dist/cjs/index-108ddff0.js.map +1 -0
- package/dist/cjs/index.cjs.js +5 -471
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/native.cjs.js +2 -2
- package/dist/cjs/nv-alert.cjs.entry.js +6 -6
- package/dist/cjs/nv-alert.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-avatar.cjs.entry.js +2 -2
- package/dist/cjs/nv-badge_2.cjs.entry.js +18 -9
- package/dist/cjs/nv-badge_2.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-breadcrumb.cjs.entry.js +1 -1
- package/dist/cjs/nv-breadcrumbs.cjs.entry.js +1 -1
- package/dist/cjs/nv-button.cjs.entry.js +2 -2
- package/dist/cjs/nv-calendar.cjs.entry.js +821 -843
- package/dist/cjs/nv-calendar.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-col.cjs.entry.js +1 -1
- package/dist/cjs/nv-datagrid.cjs.entry.js +423 -94
- package/dist/cjs/nv-datagrid.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-datagridcolumn.cjs.entry.js +2 -2
- package/dist/cjs/nv-datagridcolumn.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-dialog.cjs.entry.js +19 -13
- package/dist/cjs/nv-dialog.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-dialogfooter_2.cjs.entry.js +2 -2
- package/dist/cjs/nv-fieldcheckbox.cjs.entry.js +1 -1
- package/dist/cjs/nv-fielddate.cjs.entry.js +9 -18
- package/dist/cjs/nv-fielddate.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fielddaterange.cjs.entry.js +85 -32
- package/dist/cjs/nv-fielddaterange.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fielddropdown.cjs.entry.js +88 -57
- package/dist/cjs/nv-fielddropdown.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fielddropdownitem.cjs.entry.js +2 -2
- package/dist/cjs/nv-fieldmultiselect.cjs.entry.js +122 -104
- package/dist/cjs/nv-fieldmultiselect.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldnumber.cjs.entry.js +9 -5
- package/dist/cjs/nv-fieldnumber.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldpassword.cjs.entry.js +9 -5
- package/dist/cjs/nv-fieldpassword.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldradio.cjs.entry.js +4 -4
- package/dist/cjs/nv-fieldselect.cjs.entry.js +11 -7
- package/dist/cjs/nv-fieldselect.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldslider.cjs.entry.js +663 -0
- package/dist/cjs/nv-fieldslider.cjs.entry.js.map +1 -0
- package/dist/cjs/nv-fieldtext.cjs.entry.js +9 -5
- package/dist/cjs/nv-fieldtext.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldtextarea.cjs.entry.js +9 -5
- package/dist/cjs/nv-fieldtextarea.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldtime.cjs.entry.js +16 -13
- package/dist/cjs/nv-fieldtime.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-icon.cjs.entry.js +4 -4
- package/dist/cjs/nv-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-iconbutton_2.cjs.entry.js +3 -3
- package/dist/cjs/nv-menu.cjs.entry.js +4 -2
- package/dist/cjs/nv-menu.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-menuitem.cjs.entry.js +2 -2
- package/dist/cjs/nv-popover.cjs.entry.js +2 -2
- package/dist/cjs/nv-row.cjs.entry.js +2 -2
- package/dist/cjs/nv-stack.cjs.entry.js +2 -2
- package/dist/cjs/nv-table.cjs.entry.js +3 -3
- package/dist/cjs/nv-table.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-tablecolumn.cjs.entry.js +1 -1
- package/dist/cjs/nv-toggle.cjs.entry.js +3 -3
- package/dist/cjs/nv-tooltip.cjs.entry.js +3 -3
- package/dist/cjs/nv-tooltip.cjs.entry.js.map +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/nv-alert/nv-alert.css +3 -0
- package/dist/collection/components/nv-alert/nv-alert.js +6 -11
- package/dist/collection/components/nv-alert/nv-alert.js.map +1 -1
- package/dist/collection/components/nv-badge/nv-badge.css +181 -1
- package/dist/collection/components/nv-badge/nv-badge.docs.js +20 -1
- package/dist/collection/components/nv-badge/nv-badge.docs.js.map +1 -1
- package/dist/collection/components/nv-badge/nv-badge.js +39 -15
- package/dist/collection/components/nv-badge/nv-badge.js.map +1 -1
- package/dist/collection/components/nv-breadcrumbs/nv-breadcrumbs.docs.js +0 -1
- package/dist/collection/components/nv-breadcrumbs/nv-breadcrumbs.docs.js.map +1 -1
- package/dist/collection/components/nv-calendar/nv-calendar.css +25 -2
- package/dist/collection/components/nv-calendar/nv-calendar.docs.js +33 -38
- package/dist/collection/components/nv-calendar/nv-calendar.docs.js.map +1 -1
- package/dist/collection/components/nv-calendar/nv-calendar.js +659 -897
- package/dist/collection/components/nv-calendar/nv-calendar.js.map +1 -1
- package/dist/collection/components/nv-calendar/nv-calendar.utils.js +202 -0
- package/dist/collection/components/nv-calendar/nv-calendar.utils.js.map +1 -0
- package/dist/collection/components/nv-calendar/test/nv-calendar.utils.test.js +667 -0
- package/dist/collection/components/nv-calendar/test/nv-calendar.utils.test.js.map +1 -0
- package/dist/collection/components/nv-datagrid/nv-datagrid.css +98 -0
- package/dist/collection/components/nv-datagrid/nv-datagrid.docs.js +232 -51
- package/dist/collection/components/nv-datagrid/nv-datagrid.docs.js.map +1 -1
- package/dist/collection/components/nv-datagrid/nv-datagrid.js +437 -160
- package/dist/collection/components/nv-datagrid/nv-datagrid.js.map +1 -1
- package/dist/collection/components/nv-datagridcolumn/nv-datagridcolumn.js +20 -1
- package/dist/collection/components/nv-datagridcolumn/nv-datagridcolumn.js.map +1 -1
- package/dist/collection/components/nv-dialog/nv-dialog.css +29 -5
- package/dist/collection/components/nv-dialog/nv-dialog.docs.js +0 -1
- package/dist/collection/components/nv-dialog/nv-dialog.docs.js.map +1 -1
- package/dist/collection/components/nv-dialog/nv-dialog.js +16 -10
- package/dist/collection/components/nv-dialog/nv-dialog.js.map +1 -1
- package/dist/collection/components/nv-fielddate/nv-fielddate.docs.js +16 -8
- package/dist/collection/components/nv-fielddate/nv-fielddate.docs.js.map +1 -1
- package/dist/collection/components/nv-fielddate/nv-fielddate.js +48 -39
- package/dist/collection/components/nv-fielddate/nv-fielddate.js.map +1 -1
- package/dist/collection/components/nv-fielddate/styles/nv-fielddate.css +14 -1
- package/dist/collection/components/nv-fielddaterange/nv-fielddaterange.docs.js +12 -15
- package/dist/collection/components/nv-fielddaterange/nv-fielddaterange.docs.js.map +1 -1
- package/dist/collection/components/nv-fielddaterange/nv-fielddaterange.js +147 -68
- package/dist/collection/components/nv-fielddaterange/nv-fielddaterange.js.map +1 -1
- package/dist/collection/components/nv-fielddaterange/styles/nv-fielddaterange.css +20 -12
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.docs.js +16 -0
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.docs.js.map +1 -1
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.js +197 -103
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.js.map +1 -1
- package/dist/collection/components/nv-fielddropdown/styles/nv-fielddropdown.css +36 -1
- package/dist/collection/components/nv-fielddropdownitem/nv-fielddropdownitem.js +1 -1
- package/dist/collection/components/nv-fielddropdownitemcheck/nv-fielddropdownitemcheck.js +1 -1
- package/dist/collection/components/nv-fieldmultiselect/nv-fieldmultiselect.docs.js +8 -1
- package/dist/collection/components/nv-fieldmultiselect/nv-fieldmultiselect.docs.js.map +1 -1
- package/dist/collection/components/nv-fieldmultiselect/nv-fieldmultiselect.js +228 -190
- package/dist/collection/components/nv-fieldmultiselect/nv-fieldmultiselect.js.map +1 -1
- package/dist/collection/components/nv-fieldmultiselect/{nv-fieldmultiselect.css → styles/nv-fieldmultiselect.css} +36 -1
- package/dist/collection/components/nv-fieldnumber/nv-fieldnumber.css +12 -1
- package/dist/collection/components/nv-fieldnumber/nv-fieldnumber.docs.js +8 -0
- package/dist/collection/components/nv-fieldnumber/nv-fieldnumber.docs.js.map +1 -1
- package/dist/collection/components/nv-fieldnumber/nv-fieldnumber.js +27 -3
- package/dist/collection/components/nv-fieldnumber/nv-fieldnumber.js.map +1 -1
- package/dist/collection/components/nv-fieldpassword/nv-fieldpassword.css +12 -1
- package/dist/collection/components/nv-fieldpassword/nv-fieldpassword.docs.js +8 -0
- package/dist/collection/components/nv-fieldpassword/nv-fieldpassword.docs.js.map +1 -1
- package/dist/collection/components/nv-fieldpassword/nv-fieldpassword.js +27 -3
- package/dist/collection/components/nv-fieldpassword/nv-fieldpassword.js.map +1 -1
- package/dist/collection/components/nv-fieldradio/nv-fieldradio.js +3 -3
- package/dist/collection/components/nv-fieldselect/nv-fieldselect.css +12 -1
- package/dist/collection/components/nv-fieldselect/nv-fieldselect.docs.js +8 -0
- package/dist/collection/components/nv-fieldselect/nv-fieldselect.docs.js.map +1 -1
- package/dist/collection/components/nv-fieldselect/nv-fieldselect.js +29 -5
- package/dist/collection/components/nv-fieldselect/nv-fieldselect.js.map +1 -1
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.docs.js +264 -0
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.docs.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.js +1035 -0
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.utils.js +77 -0
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.utils.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/partials/field-input.js +33 -0
- package/dist/collection/components/nv-fieldslider/partials/field-input.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/partials/range-thumb.js +34 -0
- package/dist/collection/components/nv-fieldslider/partials/range-thumb.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/partials/single-thumb.js +18 -0
- package/dist/collection/components/nv-fieldslider/partials/single-thumb.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/partials/tick-marks.js +18 -0
- package/dist/collection/components/nv-fieldslider/partials/tick-marks.js.map +1 -0
- package/dist/collection/components/nv-fieldslider/styles/nv-fieldslider.css +267 -0
- package/dist/collection/components/nv-fieldslider/test/nv-fieldslider.utils.test.js +159 -0
- package/dist/collection/components/nv-fieldslider/test/nv-fieldslider.utils.test.js.map +1 -0
- package/dist/collection/components/nv-fieldtext/nv-fieldtext.css +20 -1
- package/dist/collection/components/nv-fieldtext/nv-fieldtext.docs.js +17 -1
- package/dist/collection/components/nv-fieldtext/nv-fieldtext.docs.js.map +1 -1
- package/dist/collection/components/nv-fieldtext/nv-fieldtext.js +28 -3
- package/dist/collection/components/nv-fieldtext/nv-fieldtext.js.map +1 -1
- package/dist/collection/components/nv-fieldtextarea/nv-fieldtextarea.css +30 -1
- package/dist/collection/components/nv-fieldtextarea/nv-fieldtextarea.docs.js +8 -0
- package/dist/collection/components/nv-fieldtextarea/nv-fieldtextarea.docs.js.map +1 -1
- package/dist/collection/components/nv-fieldtextarea/nv-fieldtextarea.js +27 -3
- package/dist/collection/components/nv-fieldtextarea/nv-fieldtextarea.js.map +1 -1
- package/dist/collection/components/nv-fieldtime/nv-fieldtime.js +13 -10
- package/dist/collection/components/nv-fieldtime/nv-fieldtime.js.map +1 -1
- package/dist/collection/components/nv-fieldtime/styles/nv-fieldtime.css +26 -3
- package/dist/collection/components/nv-icon/nv-icon.js +1 -1
- package/dist/collection/components/nv-icon/nv-icons.js +4 -470
- package/dist/collection/components/nv-icon/nv-icons.js.map +1 -1
- package/dist/collection/components/nv-iconbutton/nv-iconbutton.js +1 -1
- package/dist/collection/components/nv-loader/nv-loader.js +1 -1
- package/dist/collection/components/nv-menu/nv-menu.js +3 -1
- package/dist/collection/components/nv-menu/nv-menu.js.map +1 -1
- package/dist/collection/components/nv-menuitem/nv-menuitem.js +2 -2
- package/dist/collection/components/nv-popover/nv-popover.js +1 -1
- package/dist/collection/components/nv-row/nv-row.js +1 -1
- package/dist/collection/components/nv-stack/nv-stack.js +1 -1
- package/dist/collection/components/nv-table/nv-table.js +8 -11
- package/dist/collection/components/nv-table/nv-table.js.map +1 -1
- package/dist/collection/components/nv-toggle/nv-toggle.js +2 -2
- package/dist/collection/components/nv-tooltip/nv-tooltip.css +1 -0
- package/dist/collection/components/nv-tooltip/nv-tooltip.js +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/interfaces/Column.js.map +1 -1
- package/dist/collection/templates/navigation.docs.js +0 -1
- package/dist/collection/templates/navigation.docs.js.map +1 -1
- package/dist/collection/utils/constants.js +11 -0
- package/dist/collection/utils/constants.js.map +1 -1
- package/dist/components/index.js +6 -472
- package/dist/components/index.js.map +1 -1
- package/dist/components/nv-alert.js +7 -7
- package/dist/components/nv-alert.js.map +1 -1
- package/dist/components/nv-avatar.js +3 -3
- package/dist/components/nv-badge.js +1 -1
- package/dist/components/nv-breadcrumb.js +3 -3
- package/dist/components/nv-breadcrumbs.js +1 -1
- package/dist/components/nv-button.js +1 -1
- package/dist/components/nv-calendar.js +1 -1
- package/dist/components/nv-col.js +1 -1
- package/dist/components/nv-datagrid.js +447 -102
- package/dist/components/nv-datagrid.js.map +1 -1
- package/dist/components/nv-datagridcolumn.js +4 -3
- package/dist/components/nv-datagridcolumn.js.map +1 -1
- package/dist/components/nv-dialog.js +24 -18
- package/dist/components/nv-dialog.js.map +1 -1
- package/dist/components/nv-dialogfooter.js +1 -1
- package/dist/components/nv-dialogheader.js +1 -1
- package/dist/components/nv-fieldcheckbox.js +1 -1
- package/dist/components/nv-fielddate.js +19 -27
- package/dist/components/nv-fielddate.js.map +1 -1
- package/dist/components/nv-fielddaterange.js +99 -44
- package/dist/components/nv-fielddaterange.js.map +1 -1
- package/dist/components/nv-fielddropdown.js +103 -69
- package/dist/components/nv-fielddropdown.js.map +1 -1
- package/dist/components/nv-fielddropdownitem.js +1 -1
- package/dist/components/nv-fielddropdownitemcheck.js +1 -1
- package/dist/components/nv-fieldmultiselect.js +139 -120
- package/dist/components/nv-fieldmultiselect.js.map +1 -1
- package/dist/components/nv-fieldnumber.js +14 -9
- package/dist/components/nv-fieldnumber.js.map +1 -1
- package/dist/components/nv-fieldpassword.js +13 -8
- package/dist/components/nv-fieldpassword.js.map +1 -1
- package/dist/components/nv-fieldradio.js +4 -4
- package/dist/components/nv-fieldselect.js +15 -10
- package/dist/components/nv-fieldselect.js.map +1 -1
- package/dist/components/nv-fieldslider.d.ts +11 -0
- package/dist/components/nv-fieldslider.js +726 -0
- package/dist/components/nv-fieldslider.js.map +1 -0
- package/dist/components/nv-fieldtext.js +1 -158
- package/dist/components/nv-fieldtext.js.map +1 -1
- package/dist/components/nv-fieldtextarea.js +11 -6
- package/dist/components/nv-fieldtextarea.js.map +1 -1
- package/dist/components/nv-fieldtime.js +20 -17
- package/dist/components/nv-fieldtime.js.map +1 -1
- package/dist/components/nv-icon.js +1 -1
- package/dist/components/nv-iconbutton.js +1 -1
- package/dist/components/nv-loader.js +1 -1
- package/dist/components/nv-menu.js +7 -5
- package/dist/components/nv-menu.js.map +1 -1
- package/dist/components/nv-menuitem.js +1 -1
- package/dist/components/nv-popover.js +1 -1
- package/dist/components/nv-row.js +2 -2
- package/dist/components/nv-stack.js +2 -2
- package/dist/components/nv-table.js +3 -3
- package/dist/components/nv-table.js.map +1 -1
- package/dist/components/nv-tablecolumn.js +1 -1
- package/dist/components/nv-toggle.js +3 -3
- package/dist/components/nv-tooltip.js +1 -1
- package/dist/components/{p-dc3faba3.js → p-04cb3a6f.js} +5 -5
- package/dist/components/{p-dc3faba3.js.map → p-04cb3a6f.js.map} +1 -1
- package/dist/components/p-07a89754.js +187 -0
- package/dist/components/p-07a89754.js.map +1 -0
- package/dist/components/{p-b7b78e64.js → p-0ab80d95.js} +3 -3
- package/dist/components/{p-b7b78e64.js.map → p-0ab80d95.js.map} +1 -1
- package/dist/components/{p-8348db09.js → p-1f505531.js} +15 -2
- package/dist/components/p-1f505531.js.map +1 -0
- package/dist/components/{p-02752770.js → p-33e231f4.js} +2 -2
- package/dist/components/{p-02752770.js.map → p-33e231f4.js.map} +1 -1
- package/dist/components/p-4656efae.js +1111 -0
- package/dist/components/p-4656efae.js.map +1 -0
- package/dist/components/{p-2012b8ba.js → p-581e67cc.js} +4 -4
- package/dist/components/{p-2012b8ba.js.map → p-581e67cc.js.map} +1 -1
- package/dist/components/{p-1c45c0f2.js → p-679e0fa9.js} +16 -4
- package/dist/components/p-679e0fa9.js.map +1 -0
- package/dist/components/p-76a30bf1.js +88 -0
- package/dist/components/p-76a30bf1.js.map +1 -0
- package/dist/components/{p-150daf68.js → p-83c8873a.js} +3 -3
- package/dist/components/{p-150daf68.js.map → p-83c8873a.js.map} +1 -1
- package/dist/components/{p-c14f6b8e.js → p-c0a91091.js} +5 -5
- package/dist/components/p-c0a91091.js.map +1 -0
- package/dist/components/{p-6c364a23.js → p-cbdc2c8b.js} +6 -6
- package/dist/components/{p-6c364a23.js.map → p-cbdc2c8b.js.map} +1 -1
- package/dist/components/{p-2d9ba7d3.js → p-cbe9521f.js} +4 -4
- package/dist/components/{p-2d9ba7d3.js.map → p-cbe9521f.js.map} +1 -1
- package/dist/components/{p-a30b55fc.js → p-d19b41d2.js} +2 -2
- package/dist/components/{p-a30b55fc.js.map → p-d19b41d2.js.map} +1 -1
- package/dist/components/{p-4d3ec142.js → p-d63f1cbe.js} +4 -4
- package/dist/components/{p-4d3ec142.js.map → p-d63f1cbe.js.map} +1 -1
- package/dist/components/{p-e00cbb8a.js → p-dd2273a3.js} +2 -2
- package/dist/components/{p-e00cbb8a.js.map → p-dd2273a3.js.map} +1 -1
- package/dist/components/p-f0a5e7e4.js +167 -0
- package/dist/components/p-f0a5e7e4.js.map +1 -0
- package/dist/components/{p-f4d86795.js → p-f1859ddc.js} +4 -4
- package/dist/components/{p-f4d86795.js.map → p-f1859ddc.js.map} +1 -1
- package/dist/esm/{constants-98e2dcc2.js → constants-b97e736d.js} +15 -2
- package/dist/esm/constants-b97e736d.js.map +1 -0
- package/dist/esm/{index-1fb7a9a6.js → index-8f0e5f19.js} +22 -6
- package/dist/esm/index-8f0e5f19.js.map +1 -0
- package/dist/esm/index.js +5 -471
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/native.js +3 -3
- package/dist/esm/nv-alert.entry.js +6 -6
- package/dist/esm/nv-alert.entry.js.map +1 -1
- package/dist/esm/nv-avatar.entry.js +2 -2
- package/dist/esm/nv-badge_2.entry.js +18 -9
- package/dist/esm/nv-badge_2.entry.js.map +1 -1
- package/dist/esm/nv-breadcrumb.entry.js +1 -1
- package/dist/esm/nv-breadcrumbs.entry.js +1 -1
- package/dist/esm/nv-button.entry.js +2 -2
- package/dist/esm/nv-calendar.entry.js +821 -843
- package/dist/esm/nv-calendar.entry.js.map +1 -1
- package/dist/esm/nv-col.entry.js +1 -1
- package/dist/esm/nv-datagrid.entry.js +423 -94
- package/dist/esm/nv-datagrid.entry.js.map +1 -1
- package/dist/esm/nv-datagridcolumn.entry.js +2 -2
- package/dist/esm/nv-datagridcolumn.entry.js.map +1 -1
- package/dist/esm/nv-dialog.entry.js +19 -13
- package/dist/esm/nv-dialog.entry.js.map +1 -1
- package/dist/esm/nv-dialogfooter_2.entry.js +2 -2
- package/dist/esm/nv-fieldcheckbox.entry.js +1 -1
- package/dist/esm/nv-fielddate.entry.js +9 -18
- package/dist/esm/nv-fielddate.entry.js.map +1 -1
- package/dist/esm/nv-fielddaterange.entry.js +85 -32
- package/dist/esm/nv-fielddaterange.entry.js.map +1 -1
- package/dist/esm/nv-fielddropdown.entry.js +88 -57
- package/dist/esm/nv-fielddropdown.entry.js.map +1 -1
- package/dist/esm/nv-fielddropdownitem.entry.js +2 -2
- package/dist/esm/nv-fieldmultiselect.entry.js +122 -104
- package/dist/esm/nv-fieldmultiselect.entry.js.map +1 -1
- package/dist/esm/nv-fieldnumber.entry.js +9 -5
- package/dist/esm/nv-fieldnumber.entry.js.map +1 -1
- package/dist/esm/nv-fieldpassword.entry.js +9 -5
- package/dist/esm/nv-fieldpassword.entry.js.map +1 -1
- package/dist/esm/nv-fieldradio.entry.js +4 -4
- package/dist/esm/nv-fieldselect.entry.js +11 -7
- package/dist/esm/nv-fieldselect.entry.js.map +1 -1
- package/dist/esm/nv-fieldslider.entry.js +659 -0
- package/dist/esm/nv-fieldslider.entry.js.map +1 -0
- package/dist/esm/nv-fieldtext.entry.js +9 -5
- package/dist/esm/nv-fieldtext.entry.js.map +1 -1
- package/dist/esm/nv-fieldtextarea.entry.js +9 -5
- package/dist/esm/nv-fieldtextarea.entry.js.map +1 -1
- package/dist/esm/nv-fieldtime.entry.js +16 -13
- package/dist/esm/nv-fieldtime.entry.js.map +1 -1
- package/dist/esm/nv-icon.entry.js +4 -4
- package/dist/esm/nv-icon.entry.js.map +1 -1
- package/dist/esm/nv-iconbutton_2.entry.js +3 -3
- package/dist/esm/nv-menu.entry.js +4 -2
- package/dist/esm/nv-menu.entry.js.map +1 -1
- package/dist/esm/nv-menuitem.entry.js +2 -2
- package/dist/esm/nv-popover.entry.js +2 -2
- package/dist/esm/nv-row.entry.js +2 -2
- package/dist/esm/nv-stack.entry.js +2 -2
- package/dist/esm/nv-table.entry.js +3 -3
- package/dist/esm/nv-table.entry.js.map +1 -1
- package/dist/esm/nv-tablecolumn.entry.js +1 -1
- package/dist/esm/nv-toggle.entry.js +3 -3
- package/dist/esm/nv-tooltip.entry.js +3 -3
- package/dist/esm/nv-tooltip.entry.js.map +1 -1
- package/dist/native/index.esm.js +1 -1
- package/dist/native/index.esm.js.map +1 -1
- package/dist/native/native.css +1 -1
- package/dist/native/native.esm.js +1 -1
- package/dist/native/native.esm.js.map +1 -1
- package/dist/native/{p-6b348684.entry.js → p-0323daf6.entry.js} +2 -2
- package/dist/native/{p-d5cbf5c8.entry.js → p-05d95d4d.entry.js} +2 -2
- package/dist/native/{p-fb5bddba.entry.js → p-0ec1e2e3.entry.js} +2 -2
- package/dist/native/{p-c7b201cd.entry.js → p-16a4cdf3.entry.js} +2 -2
- package/dist/native/p-19fb0fd0.entry.js +2 -0
- package/dist/native/p-19fb0fd0.entry.js.map +1 -0
- package/dist/native/p-1e3d3374.entry.js +2 -0
- package/dist/native/{p-9135fdf5.entry.js.map → p-1e3d3374.entry.js.map} +1 -1
- package/dist/native/p-21e7132f.entry.js +2 -0
- package/dist/native/p-21e7132f.entry.js.map +1 -0
- package/dist/native/p-221b8f72.entry.js +2 -0
- package/dist/native/p-221b8f72.entry.js.map +1 -0
- package/dist/native/p-2805f9f2.entry.js +2 -0
- package/dist/native/p-2805f9f2.entry.js.map +1 -0
- package/dist/native/p-3f2b6a22.entry.js +2 -0
- package/dist/native/p-3f2b6a22.entry.js.map +1 -0
- package/dist/native/{p-0245863d.entry.js → p-407fc32d.entry.js} +2 -2
- package/dist/native/{p-63e6aed3.entry.js → p-4c0d81b0.entry.js} +2 -2
- package/dist/native/p-4c0d81b0.entry.js.map +1 -0
- package/dist/native/{p-39bb95ff.entry.js → p-519b4819.entry.js} +2 -2
- package/dist/native/{p-fa77a591.entry.js → p-5382eab2.entry.js} +2 -2
- package/dist/native/p-5ba3fc3c.entry.js +2 -0
- package/dist/native/p-5ba3fc3c.entry.js.map +1 -0
- package/dist/native/{p-bad11367.entry.js → p-60b204ac.entry.js} +2 -2
- package/dist/native/p-60b204ac.entry.js.map +1 -0
- package/dist/native/p-7092a675.entry.js +2 -0
- package/dist/native/p-711a7778.js +3 -0
- package/dist/native/p-711a7778.js.map +1 -0
- package/dist/native/p-759c9ce4.entry.js +2 -0
- package/dist/native/p-759c9ce4.entry.js.map +1 -0
- package/dist/native/{p-d7a76400.entry.js → p-7c676f2c.entry.js} +2 -2
- package/dist/native/p-7c6edd1c.entry.js +2 -0
- package/dist/native/p-7c6edd1c.entry.js.map +1 -0
- package/dist/native/p-987c79d8.entry.js +2 -0
- package/dist/native/p-987c79d8.entry.js.map +1 -0
- package/dist/native/{p-f85aca27.entry.js → p-9fba8663.entry.js} +2 -2
- package/dist/native/{p-b094296d.entry.js → p-a2c0f1a7.entry.js} +2 -2
- package/dist/native/p-aa86af25.entry.js +2 -0
- package/dist/native/p-aa86af25.entry.js.map +1 -0
- package/dist/native/p-adc96c3a.entry.js +2 -0
- package/dist/native/p-adc96c3a.entry.js.map +1 -0
- package/dist/native/p-b0fc08e7.entry.js +2 -0
- package/dist/native/p-b0fc08e7.entry.js.map +1 -0
- package/dist/native/{p-6ff228da.entry.js → p-c930adb7.entry.js} +2 -2
- package/dist/native/{p-701b5557.entry.js → p-cfe0a6c6.entry.js} +2 -2
- package/dist/native/p-d07ab618.entry.js +2 -0
- package/dist/native/p-dac0089b.entry.js +2 -0
- package/dist/native/p-dac0089b.entry.js.map +1 -0
- package/dist/native/p-de2c07a6.entry.js +13 -0
- package/dist/native/p-de2c07a6.entry.js.map +1 -0
- package/dist/native/p-ed488498.entry.js +7 -0
- package/dist/native/p-ed488498.entry.js.map +1 -0
- package/dist/native/p-ef76178b.entry.js +2 -0
- package/dist/native/p-ef76178b.entry.js.map +1 -0
- package/dist/native/{p-e5de64d5.entry.js → p-f0ddf60b.entry.js} +2 -2
- package/dist/native/p-f39803d9.entry.js +2 -0
- package/dist/native/p-f39803d9.entry.js.map +1 -0
- package/dist/native/{p-59768ee5.js → p-f85c08f1.js} +2 -2
- package/dist/native/p-f85c08f1.js.map +1 -0
- package/dist/native/p-fb897f7d.entry.js +2 -0
- package/dist/native/p-fb897f7d.entry.js.map +1 -0
- package/dist/native/{p-244f56ac.entry.js → p-fc3bea07.entry.js} +2 -2
- package/dist/types/components/nv-alert/nv-alert.d.ts +1 -1
- package/dist/types/components/nv-badge/nv-badge.d.ts +11 -3
- package/dist/types/components/nv-calendar/nv-calendar.d.ts +70 -112
- package/dist/types/components/nv-calendar/nv-calendar.utils.d.ts +60 -0
- package/dist/types/components/nv-calendar/test/nv-calendar.utils.test.d.ts +1 -0
- package/dist/types/components/nv-datagrid/nv-datagrid.d.ts +47 -26
- package/dist/types/components/nv-datagridcolumn/nv-datagridcolumn.d.ts +4 -0
- package/dist/types/components/nv-dialog/nv-dialog.d.ts +4 -0
- package/dist/types/components/nv-fielddate/nv-fielddate.d.ts +6 -7
- package/dist/types/components/nv-fielddaterange/nv-fielddaterange.d.ts +23 -12
- package/dist/types/components/nv-fielddropdown/nv-fielddropdown.d.ts +51 -26
- package/dist/types/components/nv-fieldmultiselect/nv-fieldmultiselect.d.ts +65 -55
- package/dist/types/components/nv-fieldnumber/nv-fieldnumber.d.ts +4 -0
- package/dist/types/components/nv-fieldpassword/nv-fieldpassword.d.ts +4 -0
- package/dist/types/components/nv-fieldselect/nv-fieldselect.d.ts +4 -0
- package/dist/types/components/nv-fieldslider/nv-fieldslider.d.ts +230 -0
- package/dist/types/components/nv-fieldslider/nv-fieldslider.docs.d.ts +4 -0
- package/dist/types/components/nv-fieldslider/nv-fieldslider.utils.d.ts +46 -0
- package/dist/types/components/nv-fieldslider/partials/field-input.d.ts +45 -0
- package/dist/types/components/nv-fieldslider/partials/range-thumb.d.ts +37 -0
- package/dist/types/components/nv-fieldslider/partials/single-thumb.d.ts +35 -0
- package/dist/types/components/nv-fieldslider/partials/tick-marks.d.ts +28 -0
- package/dist/types/components/nv-fieldslider/test/nv-fieldslider.utils.test.d.ts +1 -0
- package/dist/types/components/nv-fieldtext/nv-fieldtext.d.ts +5 -0
- package/dist/types/components/nv-fieldtextarea/nv-fieldtextarea.d.ts +4 -0
- package/dist/types/components/nv-icon/nv-icons.d.ts +1 -1
- package/dist/types/components/nv-table/nv-table.d.ts +13 -2
- package/dist/types/components.d.ts +656 -154
- package/dist/types/index.d.ts +0 -2
- package/dist/types/interfaces/Column.d.ts +5 -1
- package/dist/types/utils/constants.d.ts +9 -0
- package/dist/vscode-data.json +292 -1546
- package/hydrate/index.js +2715 -1533
- package/hydrate/index.mjs +2715 -1533
- package/package.json +6 -2
- package/dist/cjs/constants-bcd6b2e2.js.map +0 -1
- package/dist/cjs/index-9bda5507.js.map +0 -1
- package/dist/collection/interfaces/actionEvent.js +0 -2
- package/dist/collection/interfaces/actionEvent.js.map +0 -1
- package/dist/collection/interfaces/calendarShortcut.js +0 -2
- package/dist/collection/interfaces/calendarShortcut.js.map +0 -1
- package/dist/collection/interfaces/dateRange.js +0 -2
- package/dist/collection/interfaces/dateRange.js.map +0 -1
- package/dist/components/p-1c45c0f2.js.map +0 -1
- package/dist/components/p-373926aa.js +0 -177
- package/dist/components/p-373926aa.js.map +0 -1
- package/dist/components/p-591730e7.js +0 -88
- package/dist/components/p-591730e7.js.map +0 -1
- package/dist/components/p-8348db09.js.map +0 -1
- package/dist/components/p-c14f6b8e.js.map +0 -1
- package/dist/components/p-f331117c.js +0 -1133
- package/dist/components/p-f331117c.js.map +0 -1
- package/dist/esm/constants-98e2dcc2.js.map +0 -1
- package/dist/esm/index-1fb7a9a6.js.map +0 -1
- package/dist/native/p-0ee428d5.entry.js +0 -2
- package/dist/native/p-0ee428d5.entry.js.map +0 -1
- package/dist/native/p-2691e02d.entry.js +0 -2
- package/dist/native/p-37f0210e.entry.js +0 -2
- package/dist/native/p-37f0210e.entry.js.map +0 -1
- package/dist/native/p-4a440970.entry.js +0 -2
- package/dist/native/p-4a440970.entry.js.map +0 -1
- package/dist/native/p-4ae26462.entry.js +0 -7
- package/dist/native/p-4ae26462.entry.js.map +0 -1
- package/dist/native/p-4d9c4618.entry.js +0 -2
- package/dist/native/p-4d9c4618.entry.js.map +0 -1
- package/dist/native/p-4dc1d036.entry.js +0 -2
- package/dist/native/p-59768ee5.js.map +0 -1
- package/dist/native/p-59e0bd2b.entry.js +0 -2
- package/dist/native/p-59e0bd2b.entry.js.map +0 -1
- package/dist/native/p-5c00f092.entry.js +0 -2
- package/dist/native/p-5c00f092.entry.js.map +0 -1
- package/dist/native/p-63e6aed3.entry.js.map +0 -1
- package/dist/native/p-7f5eb2ac.entry.js +0 -2
- package/dist/native/p-7f5eb2ac.entry.js.map +0 -1
- package/dist/native/p-84a73e2a.entry.js +0 -2
- package/dist/native/p-84a73e2a.entry.js.map +0 -1
- package/dist/native/p-9135fdf5.entry.js +0 -2
- package/dist/native/p-93dc2f47.entry.js +0 -2
- package/dist/native/p-93dc2f47.entry.js.map +0 -1
- package/dist/native/p-9a267f16.entry.js +0 -13
- package/dist/native/p-9a267f16.entry.js.map +0 -1
- package/dist/native/p-9d6431c7.entry.js +0 -2
- package/dist/native/p-9d6431c7.entry.js.map +0 -1
- package/dist/native/p-ab002252.js +0 -3
- package/dist/native/p-ab002252.js.map +0 -1
- package/dist/native/p-b2ce83ad.entry.js +0 -2
- package/dist/native/p-b2ce83ad.entry.js.map +0 -1
- package/dist/native/p-bad11367.entry.js.map +0 -1
- package/dist/native/p-e1a4f776.entry.js +0 -2
- package/dist/native/p-e1a4f776.entry.js.map +0 -1
- package/dist/native/p-e49bbd02.entry.js +0 -2
- package/dist/native/p-e49bbd02.entry.js.map +0 -1
- package/dist/native/p-eee01062.entry.js +0 -2
- package/dist/native/p-eee01062.entry.js.map +0 -1
- package/dist/native/p-f6bdc270.entry.js +0 -2
- package/dist/native/p-f6bdc270.entry.js.map +0 -1
- package/dist/types/interfaces/actionEvent.d.ts +0 -13
- package/dist/types/interfaces/calendarShortcut.d.ts +0 -17
- package/dist/types/interfaces/dateRange.d.ts +0 -13
- /package/dist/native/{p-6b348684.entry.js.map → p-0323daf6.entry.js.map} +0 -0
- /package/dist/native/{p-d5cbf5c8.entry.js.map → p-05d95d4d.entry.js.map} +0 -0
- /package/dist/native/{p-fb5bddba.entry.js.map → p-0ec1e2e3.entry.js.map} +0 -0
- /package/dist/native/{p-c7b201cd.entry.js.map → p-16a4cdf3.entry.js.map} +0 -0
- /package/dist/native/{p-0245863d.entry.js.map → p-407fc32d.entry.js.map} +0 -0
- /package/dist/native/{p-39bb95ff.entry.js.map → p-519b4819.entry.js.map} +0 -0
- /package/dist/native/{p-fa77a591.entry.js.map → p-5382eab2.entry.js.map} +0 -0
- /package/dist/native/{p-2691e02d.entry.js.map → p-7092a675.entry.js.map} +0 -0
- /package/dist/native/{p-d7a76400.entry.js.map → p-7c676f2c.entry.js.map} +0 -0
- /package/dist/native/{p-f85aca27.entry.js.map → p-9fba8663.entry.js.map} +0 -0
- /package/dist/native/{p-b094296d.entry.js.map → p-a2c0f1a7.entry.js.map} +0 -0
- /package/dist/native/{p-6ff228da.entry.js.map → p-c930adb7.entry.js.map} +0 -0
- /package/dist/native/{p-701b5557.entry.js.map → p-cfe0a6c6.entry.js.map} +0 -0
- /package/dist/native/{p-4dc1d036.entry.js.map → p-d07ab618.entry.js.map} +0 -0
- /package/dist/native/{p-e5de64d5.entry.js.map → p-f0ddf60b.entry.js.map} +0 -0
- /package/dist/native/{p-244f56ac.entry.js.map → p-fc3bea07.entry.js.map} +0 -0
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-108ddff0.js');
|
|
6
|
+
const constants = require('./constants-8fb8ccc0.js');
|
|
6
7
|
const _commonjsHelpers = require('./_commonjsHelpers-b3309d7b.js');
|
|
7
|
-
const constants = require('./constants-bcd6b2e2.js');
|
|
8
8
|
|
|
9
9
|
var dayjs_min = {exports: {}};
|
|
10
10
|
|
|
@@ -38,13 +38,207 @@ var weekOfYear$1 = {exports: {}};
|
|
|
38
38
|
|
|
39
39
|
const weekOfYear = weekOfYear$1.exports;
|
|
40
40
|
|
|
41
|
-
const nvCalendarCss = "nv-calendar{display:block}.datepicker-root{display:flex;justify-content:center;align-items:flex-start;width:auto}.datepicker-container{font-family:system-ui, sans-serif;display:flex;flex-direction:column;align-items:stretch;background:var(--components-calendar-background);border-radius:var(--calendar-radius);padding:var(--calendar-padding);box-shadow:0px var(--shadow-y-axis-md-1) var(--shadow-blur-md-1) var(--shadow-spread-md, 0) var(--shadow-color-opacity-0), 0px var(--shadow-y-axis-md-2) var(--shadow-blur-md-2) var(--shadow-spread-md, 0) var(--shadow-color-opacity-2);border:1px solid var(--components-calendar-border);width:auto;max-width:100%}.datepicker-container-single{max-width:300px}.datepicker-container-single .datepicker-wrapper:has(.shortcuts-placement-left),.datepicker-container-single .datepicker-wrapper:has(.shortcuts-placement-right){max-width:410px !important}.datepicker-container-single:has(.shortcuts-placement-left),.datepicker-container-single:has(.shortcuts-placement-right){max-width:410px !important}.datepicker-wrapper{display:flex;justify-content:center;align-items:flex-start;gap:var(--calendar-gap-x);width:auto;overflow-x:hidden}.datepicker-wrapper.single{justify-content:center}.calendar-container{display:flex;flex-direction:column;align-items:center;padding:var(--calendar-padding);width:auto;position:relative}.calendar-separator{width:1px;background:var(--components-calendar-border);height:auto;min-height:100%;margin:0 10px}.header{display:flex;justify-content:start;align-items:center;margin-bottom:var(--calendar-header-margin-bottom);width:100%}.header nv-iconbutton{width:var(--calendar-header-button-size);height:var(--calendar-header-button-size)}.nav-buttons{display:flex;gap:var(--spacing-0);margin-left:auto}.nav-left{order:-1}.date-controls{display:flex;gap:var(--spacing-1);align-items:center;min-height:34px;justify-content:center}.datepicker-container-single .date-controls{justify-content:flex-start}.datepicker-container:not(.datepicker-container-single) .date-controls{justify-content:start;flex-grow:1}.date-controls .month-select,.date-controls .year-input{background:transparent !important}.calendar-wrapper:nth-child(n+2) .datepicker-container{margin-left:42px}.calendar-grid{display:grid;grid-template-columns:auto 1fr;column-gap:var(--calendar-weeks-calendar-gap-x);position:relative}.calendar-grid.slide-left{animation:slideLeft 0.3s ease-out}.calendar-grid.slide-right{animation:slideRight 0.3s ease-out}.week-numbers{display:grid;grid-template-rows:var(--calendar-cell-size) repeat(6, var(--calendar-cell-size));background:var(--components-calendar-weeks-background);color:var(--components-calendar-weeks-text);border-radius:var(--calendar-weeks-radius);width:var(--calendar-weeks-size);row-gap:var(--calendar-grid-gap-y)}.week-numbers .clickable{cursor:pointer}.week-numbers .clickable:hover{background-color:var(--components-calendar-weeks-background-hover);color:var(--components-calendar-weeks-text-hover);border-radius:var(--calendar-radius)}.week-header,.week-number{display:grid;place-items:center;font-size:var(--calendar-cell-font-size)}.week-header{font-weight:700;color:var(--components-calendar-weeks-text)}.week-number{color:var(--components-calendar-cell-text)}.days-container{display:grid;grid-template-rows:auto 1fr;row-gap:var(--calendar-grid-gap-y)}.days-header{display:grid;grid-template-columns:repeat(7, var(--calendar-cell-size));height:var(--calendar-cell-size)}.day-header{display:grid;place-items:center;font-size:var(--calendar-cell-font-size);color:var(--components-calendar-cell-text)}.days-grid{display:grid;grid-template-columns:repeat(7, var(--calendar-cell-size));grid-template-rows:repeat(6, var(--calendar-cell-size));animation:fadeIn 0.2s ease-in;row-gap:var(--calendar-grid-gap-y);z-index:0}.day{display:grid;place-items:center;width:var(--calendar-cell-size);height:var(--calendar-cell-size);font-size:var(--calendar-cell-font-size);border-radius:var(--calendar-cell-radius);cursor:pointer;border:none;background:transparent;transition:all 0.2s ease;text-align:center;animation:scaleIn 0.2s ease-out}.day:hover:not(.disabled,.empty,.selected){background:var(--components-calendar-cell-background-hover);color:var(--components-calendar-cell-text-hover)}.day.selected,.day.selected:hover .day.is-today.selected,.day.is-today.selected:hover{background:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected) !important}.day.disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.day.outside-month{color:var(--components-calendar-cell-text);opacity:var(--opacity-disabled)}.day.outside-month.selected{opacity:1 !important;color:var(--components-calendar-cell-text-selected)}.day.outside-month.in-range{opacity:1 !important;background-color:var(--components-calendar-cell-background-in-range);color:var(--components-calendar-cell-text-in-range)}.day.in-range{background:var(--components-calendar-cell-background-in-range);color:var(--components-calendar-cell-text-in-range);border-radius:0;position:relative}.day.range-start,.day.range-start:focus,.day.range-start:hover,.day.range-end,.day.range-end:focus,.day.range-end:hover{background-color:var(--components-calendar-cell-background-selected) !important;color:var(--components-calendar-cell-text-selected) !important}.day.range-start,.day.range-end,.day.range-start.is-today,.day.range-end.is-today{background:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected);position:relative;border-radius:var(--radius-rounded-full)}.day.range-start:hover,.day.range-end:hover,.day.range-start.is-today:hover,.day.range-end.is-today:hover{color:var(--components-calendar-cell-text-today)}.day.range-start:before,.day.range-end:before,.day.range-start.is-today:before,.day.range-end.is-today:before{content:\"\";position:absolute;bottom:0;left:0;right:0;top:0;z-index:-1;background-color:var(--components-calendar-cell-background-in-range);border-radius:var(--radius-rounded-full);width:auto;height:auto}.day.range-start:has(~.range-end):before,.day.range-start:has(+.in-range):before{border-top-right-radius:0;border-bottom-right-radius:0}.day.range-end:before{border-top-left-radius:0 !important;border-bottom-left-radius:0 !important}.day.outside-month.range-start,.day.outside-month.range-end{background:var(--components-calendar-cell-background-selected) !important;color:var(--components-calendar-cell-text-selected);opacity:1 !important}.day.is-today{font-weight:700;position:relative;color:var(--components-calendar-cell-text-today)}.day.is-today.range-start,.day.is-today.range-end{color:var(--components-calendar-cell-text-selected)}.day.is-today.range-start:hover,.day.is-today.range-end:hover{color:var(--components-calendar-cell-text-today)}.day.is-today::after{content:\"\";position:absolute;bottom:var(--spacing-1);left:50%;transform:translateX(-50%);width:var(--calendar-cell-dot-size);height:var(--calendar-cell-dot-size);background-color:currentColor;border-radius:50%}.day.is-today.selected::after{color:var(--components-calendar-cell-text-selected)}.day.is-today.selected::after::after{background-color:var(--components-calendar-cell-dot-selected)}.calendar-footer{display:flex;gap:var(--spacing-1);justify-content:flex-start;width:100%;flex-wrap:wrap}.footer-placement-left{justify-content:flex-start}.footer-placement-right{justify-content:flex-end}.footer-placement-center{justify-content:center}.datepicker-controls{display:flex;flex-direction:column;border-top:1px solid var(--components-calendar-border);padding:var(--calendar-controls-padding-top) var(--calendar-padding) var(--calendar-padding);gap:var(--calendar-grid-gap-y);margin-top:var(--calendar-controls-margin-top)}.datepicker-actions{display:flex;justify-content:flex-end;gap:var(--spacing-1);width:100%}.datepicker-actions slot-fb{display:contents !important}.calendar-footer+.datepicker-actions{margin-top:0}.shortcuts-placement-left,.shortcuts-placement-right{display:flex;flex-direction:column;gap:var(--spacing-1);margin-top:var(--spacing-4)}.shortcuts-placement-left{align-items:flex-end}.shortcuts-placement-right{align-items:flex-start}@keyframes slideLeft{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:translateX(0)}}@keyframes slideRight{from{opacity:0;transform:translateX(-20px)}to{opacity:1;transform:translateX(0)}}@keyframes fadeIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes scaleIn{from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:scale(1)}}";
|
|
42
|
-
const NvCalendarStyle0 = nvCalendarCss;
|
|
43
|
-
|
|
44
|
-
// Extend dayjs with plugins
|
|
45
41
|
dayjs.extend(customParseFormat);
|
|
46
42
|
dayjs.extend(utc);
|
|
47
43
|
dayjs.extend(weekOfYear);
|
|
44
|
+
/**
|
|
45
|
+
* Formats a date to a string according to the format
|
|
46
|
+
* @param {Date} date - Date to format
|
|
47
|
+
* @returns {string} Formatted date
|
|
48
|
+
* @param {Object} options - Additional options
|
|
49
|
+
* @param {string} options.dateFormat - Date format (ex: 'YYYY-MM-DD', 'DD-MM-YYYY', etc.)
|
|
50
|
+
*/
|
|
51
|
+
function formatDate(date, options) {
|
|
52
|
+
if (!date)
|
|
53
|
+
return '';
|
|
54
|
+
const isUTCMode = options.dateFormat.includes('Z');
|
|
55
|
+
const isISO8601Format = options.dateFormat === 'YYYY-MM-DD[T]HH:mm:ss[Z]';
|
|
56
|
+
// Special case for ISO 8601
|
|
57
|
+
if (isISO8601Format) {
|
|
58
|
+
// For the ISO 8601 format, use directly toISOString() which is standard
|
|
59
|
+
return date.toISOString();
|
|
60
|
+
}
|
|
61
|
+
// If the format is "Ticks", convert the time to C# ticks
|
|
62
|
+
if (options.dateFormat === 'Ticks') {
|
|
63
|
+
const ticks = date.getTime() * 10000 + 621355968000000000;
|
|
64
|
+
return ticks.toString();
|
|
65
|
+
}
|
|
66
|
+
// If the format is "X" (Unix Seconds)
|
|
67
|
+
if (options.dateFormat === 'X') {
|
|
68
|
+
return dayjs(date).unix().toString();
|
|
69
|
+
}
|
|
70
|
+
// If the format is "x" (Unix Milliseconds)
|
|
71
|
+
if (options.dateFormat === 'x') {
|
|
72
|
+
return date.getTime().toString();
|
|
73
|
+
}
|
|
74
|
+
// Otherwise, format according to the mode (UTC or local)
|
|
75
|
+
return isUTCMode
|
|
76
|
+
? dayjs(date).utc().format(options.dateFormat)
|
|
77
|
+
: dayjs(date).format(options.dateFormat);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Checks if two dates are identical
|
|
81
|
+
* @param {Date | null} date - First date
|
|
82
|
+
* @param {Date | null} compareDate - Second date
|
|
83
|
+
* @param {Object} options - Additional options
|
|
84
|
+
* @param {boolean} options.isUTCMode - Whether the dates are in UTC mode
|
|
85
|
+
* @returns {boolean} true if the dates are identical
|
|
86
|
+
*/
|
|
87
|
+
function isSameDate(date, compareDate, options) {
|
|
88
|
+
if (!date || !compareDate)
|
|
89
|
+
return false;
|
|
90
|
+
if (options.isUTCMode) {
|
|
91
|
+
return (date.getUTCFullYear() === compareDate.getUTCFullYear() &&
|
|
92
|
+
date.getUTCMonth() === compareDate.getUTCMonth() &&
|
|
93
|
+
date.getUTCDate() === compareDate.getUTCDate());
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return (date.getFullYear() === compareDate.getFullYear() &&
|
|
97
|
+
date.getMonth() === compareDate.getMonth() &&
|
|
98
|
+
date.getDate() === compareDate.getDate());
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Checks if a date is identical or before another date
|
|
103
|
+
* @param {Date} date - Date to check
|
|
104
|
+
* @param {Date} compareDate - Reference date
|
|
105
|
+
* @param {Object} options - Additional options
|
|
106
|
+
* @param {boolean} options.isUTCMode - Whether the dates are in UTC mode
|
|
107
|
+
* @returns {boolean} true if `date` <= `compareDate`
|
|
108
|
+
*/
|
|
109
|
+
function isSameOrBefore(date, compareDate, options) {
|
|
110
|
+
if (!date || !compareDate)
|
|
111
|
+
return false;
|
|
112
|
+
if (options.isUTCMode) {
|
|
113
|
+
return (date.getUTCFullYear() < compareDate.getUTCFullYear() ||
|
|
114
|
+
(date.getUTCFullYear() === compareDate.getUTCFullYear() &&
|
|
115
|
+
date.getUTCMonth() < compareDate.getUTCMonth()) ||
|
|
116
|
+
(date.getUTCFullYear() === compareDate.getUTCFullYear() &&
|
|
117
|
+
date.getUTCMonth() === compareDate.getUTCMonth() &&
|
|
118
|
+
date.getUTCDate() <= compareDate.getUTCDate()));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return (date.getFullYear() < compareDate.getFullYear() ||
|
|
122
|
+
(date.getFullYear() === compareDate.getFullYear() &&
|
|
123
|
+
date.getMonth() < compareDate.getMonth()) ||
|
|
124
|
+
(date.getFullYear() === compareDate.getFullYear() &&
|
|
125
|
+
date.getMonth() === compareDate.getMonth() &&
|
|
126
|
+
date.getDate() <= compareDate.getDate()));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Checks if a date is identical or after another date
|
|
131
|
+
* @param {Date} date - Date to check
|
|
132
|
+
* @param {Date} compareDate - Reference date
|
|
133
|
+
* @param {Object} options - Additional options
|
|
134
|
+
* @param {boolean} options.isUTCMode - Whether the dates are in UTC mode
|
|
135
|
+
* @returns {boolean} true if `date` >= `compareDate`
|
|
136
|
+
*/
|
|
137
|
+
function isSameOrAfter(date, compareDate, options) {
|
|
138
|
+
if (!date || !compareDate)
|
|
139
|
+
return false;
|
|
140
|
+
if (options.isUTCMode) {
|
|
141
|
+
return (date.getUTCFullYear() > compareDate.getUTCFullYear() ||
|
|
142
|
+
(date.getUTCFullYear() === compareDate.getUTCFullYear() &&
|
|
143
|
+
date.getUTCMonth() > compareDate.getUTCMonth()) ||
|
|
144
|
+
(date.getUTCFullYear() === compareDate.getUTCFullYear() &&
|
|
145
|
+
date.getUTCMonth() === compareDate.getUTCMonth() &&
|
|
146
|
+
date.getUTCDate() >= compareDate.getUTCDate()));
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
return (date.getFullYear() > compareDate.getFullYear() ||
|
|
150
|
+
(date.getFullYear() === compareDate.getFullYear() &&
|
|
151
|
+
date.getMonth() > compareDate.getMonth()) ||
|
|
152
|
+
(date.getFullYear() === compareDate.getFullYear() &&
|
|
153
|
+
date.getMonth() === compareDate.getMonth() &&
|
|
154
|
+
date.getDate() >= compareDate.getDate()));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Calculates the ISO week number
|
|
159
|
+
* @param {Date} date - Date to calculate
|
|
160
|
+
* @returns {number} Week number
|
|
161
|
+
*/
|
|
162
|
+
function getWeekNumber(date) {
|
|
163
|
+
const startOfYear = new Date(date.getFullYear(), 0, 1);
|
|
164
|
+
const pastDaysOfYear = (date.getTime() - startOfYear.getTime()) / 86400000;
|
|
165
|
+
return Math.ceil((pastDaysOfYear + startOfYear.getDay() + 1) / 7);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Convert a date string/Date to a Date without timezone offset
|
|
169
|
+
* @param {string | Date} dateInput - Date under string or Date object form
|
|
170
|
+
* @param {string} dateFormat - Date format (ex: 'YYYY-MM-DD', 'DD-MM-YYYY', etc.)
|
|
171
|
+
* @returns {Date} Date in Date form without timezone offset
|
|
172
|
+
*/
|
|
173
|
+
function parseDate(dateInput, dateFormat) {
|
|
174
|
+
if (dateInput instanceof Date)
|
|
175
|
+
return dateInput;
|
|
176
|
+
const isUTCMode = dateFormat.includes('Z');
|
|
177
|
+
// Attempt to automatically detect ISO 8601 format (generated by toISOString())
|
|
178
|
+
// The regex checks the standard ISO format: YYYY-MM-DDTHH:mm:ss.sssZ
|
|
179
|
+
if (typeof dateInput === 'string' &&
|
|
180
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/.test(dateInput)) {
|
|
181
|
+
try {
|
|
182
|
+
const parsedDate = new Date(dateInput);
|
|
183
|
+
if (!isNaN(parsedDate.getTime())) {
|
|
184
|
+
return parsedDate;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
// If it fails, continue with other methods
|
|
189
|
+
console.error('Error parsing ISO date:', error);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Handling Unix Seconds ("X") formats
|
|
193
|
+
if (dateFormat === 'X') {
|
|
194
|
+
const unixSeconds = Number(dateInput);
|
|
195
|
+
if (isNaN(unixSeconds))
|
|
196
|
+
return null;
|
|
197
|
+
return isUTCMode
|
|
198
|
+
? dayjs.unix(unixSeconds).utc().toDate()
|
|
199
|
+
: dayjs.unix(unixSeconds).toDate();
|
|
200
|
+
}
|
|
201
|
+
// Handling Unix Milliseconds ("x") formats
|
|
202
|
+
if (dateFormat === 'x') {
|
|
203
|
+
const unixMilliseconds = Number(dateInput);
|
|
204
|
+
if (isNaN(unixMilliseconds))
|
|
205
|
+
return null;
|
|
206
|
+
return isUTCMode
|
|
207
|
+
? dayjs(unixMilliseconds).utc().toDate()
|
|
208
|
+
: dayjs(unixMilliseconds).toDate();
|
|
209
|
+
}
|
|
210
|
+
// Handling C# Ticks format
|
|
211
|
+
if (dateFormat === 'Ticks') {
|
|
212
|
+
const ticks = Number(dateInput);
|
|
213
|
+
if (isNaN(ticks))
|
|
214
|
+
return null;
|
|
215
|
+
// Conversion of .NET ticks to milliseconds since Unix epoch
|
|
216
|
+
const unixMilliseconds = (ticks - 621355968000000000) / 10000;
|
|
217
|
+
return isUTCMode
|
|
218
|
+
? dayjs(unixMilliseconds).utc().toDate()
|
|
219
|
+
: dayjs(unixMilliseconds).toDate();
|
|
220
|
+
}
|
|
221
|
+
// For all other formats, use customParseFormat in strict mode
|
|
222
|
+
let parsed;
|
|
223
|
+
if (isUTCMode) {
|
|
224
|
+
parsed = dayjs.utc(dateInput, dateFormat, true);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
parsed = dayjs(dateInput, dateFormat, true);
|
|
228
|
+
}
|
|
229
|
+
if (!parsed.isValid()) {
|
|
230
|
+
console.error(`Parsing error:`, {
|
|
231
|
+
dateInput,
|
|
232
|
+
dateFormat: dateFormat,
|
|
233
|
+
});
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
return parsed.toDate();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const nvCalendarCss = "nv-calendar{display:block}.datepicker-root{display:flex;justify-content:center;align-items:flex-start;width:auto}.datepicker-container{font-family:system-ui, sans-serif;display:flex;flex-direction:column;align-items:stretch;background:var(--components-calendar-background);border-radius:var(--calendar-radius);padding:var(--calendar-padding);box-shadow:0px var(--shadow-y-axis-md-1) var(--shadow-blur-md-1) var(--shadow-spread-md, 0) var(--shadow-color-opacity-0), 0px var(--shadow-y-axis-md-2) var(--shadow-blur-md-2) var(--shadow-spread-md, 0) var(--shadow-color-opacity-2);border:1px solid var(--components-calendar-border);width:auto;max-width:100%}.datepicker-container-single{max-width:300px}.datepicker-container-single .datepicker-wrapper:has(.shortcuts-placement-left),.datepicker-container-single .datepicker-wrapper:has(.shortcuts-placement-right){max-width:410px !important}.datepicker-container-single:has(.shortcuts-placement-left),.datepicker-container-single:has(.shortcuts-placement-right){max-width:410px !important}.datepicker-wrapper{display:flex;justify-content:center;align-items:flex-start;gap:var(--calendar-gap-x);width:auto;overflow-x:hidden}.datepicker-wrapper::-webkit-scrollbar{width:6px;height:6px}.datepicker-wrapper::-webkit-scrollbar-track{background-color:var(--color-level-10-background);border-radius:9999px}.datepicker-wrapper::-webkit-scrollbar-thumb{background-color:var(--color-gray-200);border-radius:9999px}.datepicker-wrapper.single{justify-content:center}.calendar-container{display:flex;flex-direction:column;align-items:center;padding:var(--calendar-padding);width:auto;position:relative}.calendar-separator{width:1px;background:var(--components-calendar-border);height:auto;min-height:100%;margin:0 10px}.header{display:flex;justify-content:start;align-items:center;margin-bottom:var(--calendar-header-margin-bottom);width:100%}.header nv-iconbutton{width:var(--calendar-header-button-size);height:var(--calendar-header-button-size)}.nav-buttons{display:flex;gap:var(--spacing-0);margin-left:auto}.nav-left{order:-1}.date-controls{display:flex;gap:var(--spacing-1);align-items:center;min-height:34px;justify-content:center}.datepicker-container-single .date-controls{justify-content:flex-start}.datepicker-container:not(.datepicker-container-single) .date-controls{justify-content:start;flex-grow:1}.date-controls .month-select,.date-controls .year-input{background:transparent !important}.calendar-wrapper:nth-child(n+2) .datepicker-container{margin-left:42px}.calendar-grid{display:grid;grid-template-columns:auto 1fr;column-gap:var(--calendar-weeks-calendar-gap-x);position:relative}.calendar-grid.slide-left{animation:slideLeft 0.3s ease-out}.calendar-grid.slide-right{animation:slideRight 0.3s ease-out}.week-numbers{display:grid;grid-template-rows:var(--calendar-cell-size) repeat(6, var(--calendar-cell-size));background:var(--components-calendar-weeks-background);color:var(--components-calendar-weeks-text);border-radius:var(--calendar-weeks-radius);width:var(--calendar-weeks-size);row-gap:var(--calendar-grid-gap-y)}.week-numbers .clickable{cursor:pointer}.week-numbers .clickable:hover{background-color:var(--components-calendar-weeks-background-hover);color:var(--components-calendar-weeks-text-hover);border-radius:var(--calendar-radius)}.week-header,.week-number{display:grid;place-items:center;font-size:var(--calendar-cell-font-size)}.week-header{font-weight:700;color:var(--components-calendar-weeks-text)}.week-number{color:var(--components-calendar-cell-text)}.days-container{display:grid;grid-template-rows:auto 1fr;row-gap:var(--calendar-grid-gap-y)}.days-header{display:grid;grid-template-columns:repeat(7, var(--calendar-cell-size));height:var(--calendar-cell-size)}.day-header{display:grid;place-items:center;font-size:var(--calendar-cell-font-size);color:var(--components-calendar-cell-text)}.days-grid{display:grid;grid-template-columns:repeat(7, var(--calendar-cell-size));grid-template-rows:repeat(6, var(--calendar-cell-size));animation:fadeIn 0.2s ease-in;row-gap:var(--calendar-grid-gap-y);z-index:0}.day{display:grid;place-items:center;width:var(--calendar-cell-size);height:var(--calendar-cell-size);font-size:var(--calendar-cell-font-size);border-radius:var(--calendar-cell-radius);cursor:pointer;border:none;background:transparent;transition:all 0.2s ease;text-align:center;animation:scaleIn 0.2s ease-out}.day:hover:not(.disabled,.empty,.selected){background:var(--components-calendar-cell-background-hover);color:var(--components-calendar-cell-text-hover)}.day.selected,.day.selected:hover .day.is-today.selected,.day.is-today.selected:hover{background:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected) !important}.day.disabled{opacity:var(--opacity-disabled);cursor:not-allowed}.day.outside-month{color:var(--components-calendar-cell-text);opacity:var(--opacity-disabled)}.day.outside-month.selected{opacity:1 !important;color:var(--components-calendar-cell-text-selected)}.day.outside-month.in-range{opacity:0.5 !important;background-color:var(--components-calendar-cell-background-in-range);color:var(--components-calendar-cell-text-in-range)}.day.outside-month.in-range:hover{opacity:0.7 !important;background-color:var(--components-calendar-cell-background-in-range)}.day.in-range{background:var(--components-calendar-cell-background-in-range);color:var(--components-calendar-cell-text-in-range);border-radius:0;position:relative}.day.range-start,.day.range-start:focus,.day.range-start:hover,.day.range-end,.day.range-end:focus,.day.range-end:hover{background-color:var(--components-calendar-cell-background-selected) !important;color:var(--components-calendar-cell-text-selected) !important}.day.range-start,.day.range-end,.day.range-start.is-today,.day.range-end.is-today{background:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected);position:relative;border-radius:var(--radius-rounded-full)}.day.range-start:hover,.day.range-end:hover,.day.range-start.is-today:hover,.day.range-end.is-today:hover{color:var(--components-calendar-cell-text-today)}.day.range-start:before,.day.range-end:before,.day.range-start.is-today:before,.day.range-end.is-today:before{content:\"\";position:absolute;bottom:0;left:0;right:0;top:0;z-index:-1;background-color:var(--components-calendar-cell-background-in-range);border-radius:var(--radius-rounded-full);width:auto;height:auto}.day.range-start:has(~.range-end):before,.day.range-start:has(+.in-range):before{border-top-right-radius:0;border-bottom-right-radius:0}.day.range-end:before{border-top-left-radius:0 !important;border-bottom-left-radius:0 !important}.day.outside-month.range-start,.day.outside-month.range-end{opacity:1 !important;background:var(--components-calendar-cell-background-selected) !important;color:var(--components-calendar-cell-text-selected)}.day.is-today{font-weight:700;position:relative;color:var(--components-calendar-cell-text-today)}.day.is-today.range-start,.day.is-today.range-end{color:var(--components-calendar-cell-text-selected)}.day.is-today.range-start:hover,.day.is-today.range-end:hover{color:var(--components-calendar-cell-text-today)}.day.is-today::after{content:\"\";position:absolute;bottom:var(--spacing-1);left:50%;transform:translateX(-50%);width:var(--calendar-cell-dot-size);height:var(--calendar-cell-dot-size);background-color:currentColor;border-radius:50%}.day.is-today.selected::after{color:var(--components-calendar-cell-text-selected)}.day.is-today.selected::after::after{background-color:var(--components-calendar-cell-dot-selected)}.calendar-footer{display:flex;gap:var(--spacing-1);justify-content:flex-start;width:100%;flex-wrap:wrap}.footer-placement-left{justify-content:flex-start}.footer-placement-right{justify-content:flex-end}.footer-placement-center{justify-content:center}.datepicker-controls{display:flex;flex-direction:column;border-top:1px solid var(--components-calendar-border);padding:var(--calendar-controls-padding-top) var(--calendar-padding) var(--calendar-padding);gap:var(--calendar-grid-gap-y);margin-top:var(--calendar-controls-margin-top)}.datepicker-actions{display:flex;justify-content:flex-end;gap:var(--spacing-1);width:100%}.datepicker-actions slot-fb{display:contents !important}.calendar-footer+.datepicker-actions{margin-top:0}.shortcuts-placement-left,.shortcuts-placement-right{display:flex;flex-direction:column;gap:var(--spacing-1);margin-top:var(--spacing-4)}.shortcuts-placement-left{align-items:flex-end}.shortcuts-placement-right{align-items:flex-start}@keyframes slideLeft{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:translateX(0)}}@keyframes slideRight{from{opacity:0;transform:translateX(-20px)}to{opacity:1;transform:translateX(0)}}@keyframes fadeIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}@keyframes scaleIn{from{opacity:0;transform:scale(0.9)}to{opacity:1;transform:scale(1)}}";
|
|
240
|
+
const NvCalendarStyle0 = nvCalendarCss;
|
|
241
|
+
|
|
48
242
|
const NvCalendar = class {
|
|
49
243
|
constructor(hostRef) {
|
|
50
244
|
index.registerInstance(this, hostRef);
|
|
@@ -63,33 +257,12 @@ const NvCalendar = class {
|
|
|
63
257
|
*/
|
|
64
258
|
this.numberOfCalendars = 1;
|
|
65
259
|
/**
|
|
66
|
-
*
|
|
67
|
-
* ex: "2025-03-15"
|
|
68
|
-
*/
|
|
69
|
-
this.singleValue = '';
|
|
70
|
-
/**
|
|
71
|
-
* Selected date range
|
|
72
|
-
* format: { start: ISO string, end: ISO string }
|
|
73
|
-
* ex: { start: "2025-03-15", end: "2025-03-20" }
|
|
74
|
-
*/
|
|
75
|
-
this.rangeValue = '';
|
|
76
|
-
/**
|
|
77
|
-
* Minimum date for selection (ISO string format, ex: "2025-01-01")
|
|
78
|
-
*/
|
|
79
|
-
this.min = '';
|
|
80
|
-
/**
|
|
81
|
-
* Maximum date for selection (ISO string format, ex: "2025-12-31")
|
|
82
|
-
*/
|
|
83
|
-
this.max = '';
|
|
84
|
-
/** Disabled dates (ISO string array)
|
|
85
|
-
* @default '[]'
|
|
86
|
-
*/
|
|
87
|
-
this.disabledDates = '';
|
|
88
|
-
/** Locale for date formatting
|
|
260
|
+
* Locale for date formatting
|
|
89
261
|
* @default 'en-BE'
|
|
90
262
|
*/
|
|
91
263
|
this.locale = 'en-BE';
|
|
92
|
-
/**
|
|
264
|
+
/**
|
|
265
|
+
* Date format (ex: 'YYYY-MM-DD', 'DD-MM-YYYY', etc.)
|
|
93
266
|
* @default 'YYYY-MM-DD'
|
|
94
267
|
* @note If the date format is in UTC mode, the date will be displayed in UTC time.
|
|
95
268
|
* @note If the date format is not in UTC mode, the date will be displayed in the local time.
|
|
@@ -107,40 +280,454 @@ const NvCalendar = class {
|
|
|
107
280
|
this.selectionType = 'single';
|
|
108
281
|
/**
|
|
109
282
|
* Show action buttons
|
|
110
|
-
* @default false
|
|
111
283
|
*/
|
|
112
284
|
this.showActions = false;
|
|
113
|
-
/**
|
|
114
|
-
* Custom actions to display in the footer
|
|
115
|
-
* JSON array of objects with the following properties:
|
|
116
|
-
* - label: string
|
|
117
|
-
* - onClick: function
|
|
118
|
-
* @default '[]'
|
|
119
|
-
*/
|
|
120
|
-
this.shortcuts = '[]';
|
|
121
285
|
/** Cache for parsed disabled dates */
|
|
122
286
|
this.parsedDisabledDates = [];
|
|
123
|
-
|
|
287
|
+
//#endregion PROPERTIES
|
|
288
|
+
/****************************************************************************/
|
|
289
|
+
//#region STATE
|
|
290
|
+
this.currentDate = null;
|
|
124
291
|
this.selectedDate = null;
|
|
125
|
-
/** Start date */
|
|
126
292
|
this.startDate = null;
|
|
127
|
-
/** End date */
|
|
128
293
|
this.endDate = null;
|
|
129
294
|
/** List of formatted months for the selector */
|
|
130
295
|
this.months = [];
|
|
296
|
+
/**
|
|
297
|
+
* Change the displayed month
|
|
298
|
+
* @param {number} offset - Month offset (-1 for previous, 1 for next)
|
|
299
|
+
*/
|
|
300
|
+
this.changeMonth = (offset) => {
|
|
301
|
+
const newDate = new Date(this.currentDate);
|
|
302
|
+
// Ensure we only move by one month at a time
|
|
303
|
+
newDate.setUTCMonth(newDate.getUTCMonth() + offset);
|
|
304
|
+
// Add the appropriate animation class
|
|
305
|
+
const containers = this.el.querySelectorAll('.calendar-grid');
|
|
306
|
+
containers.forEach(container => {
|
|
307
|
+
// Remove existing animation classes
|
|
308
|
+
container.classList.remove('slide-left', 'slide-right');
|
|
309
|
+
// Add the new animation class
|
|
310
|
+
const animationClass = offset > 0 ? 'slide-left' : 'slide-right';
|
|
311
|
+
container.classList.add(animationClass);
|
|
312
|
+
// Remove the class after the animation
|
|
313
|
+
setTimeout(() => {
|
|
314
|
+
container.classList.remove(animationClass);
|
|
315
|
+
}, 300); // 300ms corresponds to $slide-duration in the SCSS
|
|
316
|
+
});
|
|
317
|
+
this.currentDate = newDate;
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Handles date selection based on the mode
|
|
321
|
+
* @param {Date} date - Selected date
|
|
322
|
+
*/
|
|
323
|
+
this.handleDateSelection = (date) => {
|
|
324
|
+
if (this.isDateDisabled(date)) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (this.selectionType === 'single') {
|
|
328
|
+
this.handleSingleSelection(date);
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
this.handleRangeSelection(date);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Handles single date selection
|
|
336
|
+
* @param {Date} date - Selected date
|
|
337
|
+
*/
|
|
338
|
+
this.handleSingleSelection = (date) => {
|
|
339
|
+
if (!date)
|
|
340
|
+
return;
|
|
341
|
+
const formattedDate = formatDate(date, { dateFormat: this.dateFormat });
|
|
342
|
+
this.selectedDate = date;
|
|
343
|
+
this.singleDateChange.emit(formattedDate);
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* Handles range date selection
|
|
347
|
+
* @param {Date} date - Selected date
|
|
348
|
+
*/
|
|
349
|
+
this.handleRangeSelection = (date) => {
|
|
350
|
+
if (!this.startDate || (this.startDate && this.endDate)) {
|
|
351
|
+
this.startDate = date;
|
|
352
|
+
this.endDate = null;
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
this.endDate = date;
|
|
356
|
+
if (this.startDate > this.endDate) {
|
|
357
|
+
[this.startDate, this.endDate] = [this.endDate, this.startDate];
|
|
358
|
+
}
|
|
359
|
+
this.rangeDateChange.emit({
|
|
360
|
+
start: formatDate(this.startDate, { dateFormat: this.dateFormat }),
|
|
361
|
+
end: formatDate(this.endDate, { dateFormat: this.dateFormat }),
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
/**
|
|
366
|
+
* Checks if a date is disabled.
|
|
367
|
+
* Disabled if:
|
|
368
|
+
* - The date is before min (if defined)
|
|
369
|
+
* - The date is after max (if defined)
|
|
370
|
+
* - The date is in the disabledDates array
|
|
371
|
+
* @param {Date} date - Date to check
|
|
372
|
+
* @returns {boolean} true if the date is disabled
|
|
373
|
+
*/
|
|
374
|
+
this.isDateDisabled = (date) => {
|
|
375
|
+
if (!date)
|
|
376
|
+
return true;
|
|
377
|
+
// Minimum bound check
|
|
378
|
+
if (this.min) {
|
|
379
|
+
const minDate = parseDate(this.min, this.dateFormat);
|
|
380
|
+
if (minDate && date < minDate) {
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
// Maximum bound check
|
|
385
|
+
if (this.max) {
|
|
386
|
+
const maxDate = parseDate(this.max, this.dateFormat);
|
|
387
|
+
if (maxDate && date > maxDate) {
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
// Check disabled dates
|
|
392
|
+
return this.parsedDisabledDates.some(disabledDate => isSameDate(date, disabledDate, { isUTCMode: this.isUTCMode }));
|
|
393
|
+
};
|
|
394
|
+
/**
|
|
395
|
+
* Checks if a date is in the selected range
|
|
396
|
+
* @param {Date} date - Date to check
|
|
397
|
+
* @returns {boolean} true if the date is in the range
|
|
398
|
+
*/
|
|
399
|
+
this.isDateInRange = (date) => {
|
|
400
|
+
if (!date || !this.startDate || !this.endDate)
|
|
401
|
+
return false;
|
|
402
|
+
const checkDate = parseDate(date, this.dateFormat);
|
|
403
|
+
const startDate = parseDate(this.startDate, this.dateFormat);
|
|
404
|
+
const endDate = parseDate(this.endDate, this.dateFormat);
|
|
405
|
+
// Verify if startDate and endDate are valid
|
|
406
|
+
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
// Verify that startDate is before endDate (additional security)
|
|
410
|
+
if (startDate > endDate)
|
|
411
|
+
return false;
|
|
412
|
+
// Comparison based only on the date (year, month, day)
|
|
413
|
+
return (isSameOrAfter(checkDate, startDate, { isUTCMode: this.isUTCMode }) &&
|
|
414
|
+
isSameOrBefore(checkDate, endDate, { isUTCMode: this.isUTCMode }));
|
|
415
|
+
};
|
|
416
|
+
/**
|
|
417
|
+
* Retrieves the localized day names
|
|
418
|
+
* @returns {string[]} Array of short day names
|
|
419
|
+
*/
|
|
420
|
+
this.getDayNames = () => {
|
|
421
|
+
// If we have custom day names for this locale
|
|
422
|
+
if (constants.CUSTOM_DAY_NAMES[this.locale]) {
|
|
423
|
+
const days = [...constants.CUSTOM_DAY_NAMES[this.locale]];
|
|
424
|
+
// Reorganize the days based on the first day of the week
|
|
425
|
+
const firstDays = days.slice(0, this.firstDayOfWeek);
|
|
426
|
+
const remainingDays = days.slice(this.firstDayOfWeek);
|
|
427
|
+
return [...remainingDays, ...firstDays];
|
|
428
|
+
}
|
|
429
|
+
// Otherwise, use the default behavior
|
|
430
|
+
const formatter = new Intl.DateTimeFormat(this.locale, {
|
|
431
|
+
weekday: 'short',
|
|
432
|
+
});
|
|
433
|
+
const days = [...Array(7)].map((_, i) => formatter.format(new Date(2023, 0, i + 1)).toUpperCase());
|
|
434
|
+
// Reorganize the days based on the first day of the week
|
|
435
|
+
const firstDays = days.slice(0, this.firstDayOfWeek);
|
|
436
|
+
const remainingDays = days.slice(this.firstDayOfWeek);
|
|
437
|
+
return [...remainingDays, ...firstDays];
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* Generates the days of the current month
|
|
441
|
+
* @param {number} offset - Month offset (0 by default)
|
|
442
|
+
* @param {number} totalCalendars - Number of calendars to display (1 by default)
|
|
443
|
+
* @returns {Array<{ dayOfMonth: number | null, date: Date | null, isSelected: boolean, isDisabled: boolean }>} Array of formatted days
|
|
444
|
+
*/
|
|
445
|
+
this.getDaysInMonth = (offset = 0, totalCalendars = 1) => {
|
|
446
|
+
const year = this.currentDate.getUTCFullYear();
|
|
447
|
+
const month = this.currentDate.getUTCMonth() + offset;
|
|
448
|
+
const firstDay = new Date(Date.UTC(year, month, 1));
|
|
449
|
+
const lastDay = new Date(Date.UTC(year, month + 1, 0));
|
|
450
|
+
const days = [];
|
|
451
|
+
// Correct calculation of offset for previous month days
|
|
452
|
+
// Use getUTCDay to stay consistent with UTC timezone
|
|
453
|
+
const dayOfWeekIndex = firstDay.getUTCDay(); // 0 = Sunday, 1 = Monday, etc.
|
|
454
|
+
// Adjust based on firstDayOfWeek (if week starts on Monday, offset is different)
|
|
455
|
+
const offsetDays = (dayOfWeekIndex - this.firstDayOfWeek + 7) % 7;
|
|
456
|
+
// Add the days of the previous month for the first calendar
|
|
457
|
+
if (offset === 0 && offsetDays > 0) {
|
|
458
|
+
const prevMonthLastDay = new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
459
|
+
for (let i = offsetDays; i > 0; i--) {
|
|
460
|
+
const date = new Date(Date.UTC(year, month - 1, prevMonthLastDay - i + 1));
|
|
461
|
+
days.push({
|
|
462
|
+
dayOfMonth: date.getUTCDate(),
|
|
463
|
+
date,
|
|
464
|
+
isCurrentMonth: false,
|
|
465
|
+
isDisabled: this.isDateDisabled(date),
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
// Add the days of the current month
|
|
470
|
+
for (let i = 1; i <= lastDay.getUTCDate(); i++) {
|
|
471
|
+
const date = new Date(Date.UTC(year, month, i));
|
|
472
|
+
days.push({
|
|
473
|
+
dayOfMonth: i,
|
|
474
|
+
date,
|
|
475
|
+
isCurrentMonth: true,
|
|
476
|
+
isDisabled: this.isDateDisabled(date),
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
// Add the days of the next month only for the last calendar
|
|
480
|
+
if (offset === totalCalendars - 1) {
|
|
481
|
+
const nextMonthDaysNeeded = 7 - (days.length % 7 || 7);
|
|
482
|
+
for (let i = 1; i <= nextMonthDaysNeeded; i++) {
|
|
483
|
+
const date = new Date(Date.UTC(year, month + 1, i));
|
|
484
|
+
days.push({
|
|
485
|
+
dayOfMonth: i,
|
|
486
|
+
date,
|
|
487
|
+
isCurrentMonth: false,
|
|
488
|
+
isDisabled: this.isDateDisabled(date),
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return days;
|
|
493
|
+
};
|
|
494
|
+
/** Initializes the list of formatted months according to the locale */
|
|
495
|
+
this.initializeMonths = () => {
|
|
496
|
+
// If we have custom month names for this locale
|
|
497
|
+
if (constants.CUSTOM_MONTH_NAMES[this.locale]) {
|
|
498
|
+
this.months = constants.CUSTOM_MONTH_NAMES[this.locale].map((label, value) => ({
|
|
499
|
+
value,
|
|
500
|
+
label,
|
|
501
|
+
}));
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
// Otherwise, use the default behavior
|
|
505
|
+
const formatter = new Intl.DateTimeFormat(this.locale, { month: 'short' });
|
|
506
|
+
this.months = Array.from({ length: 12 }, (_, i) => ({
|
|
507
|
+
value: i,
|
|
508
|
+
label: formatter.format(new Date(2000, i, 1)).toUpperCase(),
|
|
509
|
+
}));
|
|
510
|
+
};
|
|
511
|
+
/**
|
|
512
|
+
* Retrieves the localized abbreviation for "week"
|
|
513
|
+
* @returns {string} Localized abbreviation for "week"
|
|
514
|
+
*/
|
|
515
|
+
this.getLocalizedWeekText = () => {
|
|
516
|
+
return constants.WEEK_ABBREVIATIONS[this.locale] || 'W';
|
|
517
|
+
};
|
|
518
|
+
/**
|
|
519
|
+
* Handles month change in the selector
|
|
520
|
+
* @param {Event} event - Month change event
|
|
521
|
+
* @param {number} calendarOffset - Calendar offset (0 by default)
|
|
522
|
+
*/
|
|
523
|
+
this.handleMonthChange = (event, calendarOffset = 0) => {
|
|
524
|
+
const select = event.target;
|
|
525
|
+
const selectedMonth = parseInt(select.value, 10);
|
|
526
|
+
const currentMonth = this.currentDate.getUTCMonth();
|
|
527
|
+
// Calculate the difference considering the calendar offset
|
|
528
|
+
const monthDiff = selectedMonth - ((currentMonth + calendarOffset) % 12);
|
|
529
|
+
const newDate = new Date(this.currentDate);
|
|
530
|
+
newDate.setUTCMonth(newDate.getUTCMonth() + monthDiff);
|
|
531
|
+
this.currentDate = newDate;
|
|
532
|
+
};
|
|
533
|
+
/**
|
|
534
|
+
* Handles year change in the numeric entry
|
|
535
|
+
* @param {Event} event - Year change event
|
|
536
|
+
* @param {number} calendarOffset - Calendar offset (0 by default)
|
|
537
|
+
*/
|
|
538
|
+
this.handleYearChange = (event, calendarOffset = 0) => {
|
|
539
|
+
const input = event.target;
|
|
540
|
+
const year = parseInt(input.value, 10);
|
|
541
|
+
if (!isNaN(year) && year >= 1900 && year <= 2100) {
|
|
542
|
+
const newDate = new Date(this.currentDate);
|
|
543
|
+
newDate.setUTCFullYear(year);
|
|
544
|
+
newDate.setUTCMonth(newDate.getUTCMonth() + calendarOffset);
|
|
545
|
+
this.currentDate = newDate;
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
/**
|
|
549
|
+
* Handles week selection
|
|
550
|
+
* @param {Date[]} weekDays - Selected week days
|
|
551
|
+
* @param {number} calendarIndex - Calendar index from which the selection is made
|
|
552
|
+
*/
|
|
553
|
+
this.handleWeekSelection = (weekDays, calendarIndex) => {
|
|
554
|
+
if (this.selectionType !== 'range')
|
|
555
|
+
return;
|
|
556
|
+
const allDays = this.getDaysInMonth(calendarIndex, this.numberOfCalendars);
|
|
557
|
+
const weekStart = weekDays[0];
|
|
558
|
+
const weekEnd = weekDays[weekDays.length - 1];
|
|
559
|
+
if (!weekStart || !weekEnd)
|
|
560
|
+
return;
|
|
561
|
+
const selectedWeekDays = allDays.filter(day => day.date && day.date >= weekStart && day.date <= weekEnd);
|
|
562
|
+
const validDays = selectedWeekDays.filter(day => !this.isDateDisabled(day.date));
|
|
563
|
+
if (validDays.length > 0) {
|
|
564
|
+
this.startDate = validDays[0].date;
|
|
565
|
+
this.endDate = validDays[validDays.length - 1].date;
|
|
566
|
+
this.rangeDateChange.emit({
|
|
567
|
+
start: formatDate(this.startDate, { dateFormat: this.dateFormat }),
|
|
568
|
+
end: formatDate(this.endDate, { dateFormat: this.dateFormat }),
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
/**
|
|
573
|
+
* Checks if a date corresponds to today
|
|
574
|
+
* @param {Date} date - Date to check
|
|
575
|
+
* @returns {boolean} true if the date is today
|
|
576
|
+
*/
|
|
577
|
+
this.isToday = (date) => {
|
|
578
|
+
const today = new Date();
|
|
579
|
+
return (date.getDate() === today.getDate() &&
|
|
580
|
+
date.getMonth() === today.getMonth() &&
|
|
581
|
+
date.getFullYear() === today.getFullYear());
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* Parse and cache the disabled dates
|
|
585
|
+
* @description Parse and cache the disabled dates
|
|
586
|
+
*/
|
|
587
|
+
this.parseDisabledDates = () => {
|
|
588
|
+
if (!this.disabledDates) {
|
|
589
|
+
this.parsedDisabledDates = [];
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
try {
|
|
593
|
+
this.parsedDisabledDates = this.disabledDates
|
|
594
|
+
.map(date => parseDate(date, this.dateFormat))
|
|
595
|
+
.filter(date => date !== null);
|
|
596
|
+
}
|
|
597
|
+
catch (error) {
|
|
598
|
+
console.error('Error parsing disabled dates:', error);
|
|
599
|
+
this.parsedDisabledDates = [];
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
603
|
+
* Applies a shortcut selection
|
|
604
|
+
* @param {Object} shortcut - Shortcut to apply
|
|
605
|
+
* @param {string | Date} shortcut.singleValue - Selected date value
|
|
606
|
+
* @param {Object} shortcut.rangeValue - Start and end date values
|
|
607
|
+
* @param {string | Date} shortcut.rangeValue.start - Start date value
|
|
608
|
+
* @param {string | Date} shortcut.rangeValue.end - End date value
|
|
609
|
+
* @param {string} shortcut.label - Label
|
|
610
|
+
*/
|
|
611
|
+
this.applyShortcut = (shortcut) => {
|
|
612
|
+
this.selectedDate = null;
|
|
613
|
+
this.startDate = null;
|
|
614
|
+
this.endDate = null;
|
|
615
|
+
if (shortcut.singleValue) {
|
|
616
|
+
const newDate = parseDate(shortcut.singleValue, this.dateFormat);
|
|
617
|
+
this.selectedDate = newDate;
|
|
618
|
+
this.singleDateChange.emit(formatDate(newDate, { dateFormat: this.dateFormat }));
|
|
619
|
+
this.singleValue = formatDate(newDate, { dateFormat: this.dateFormat });
|
|
620
|
+
if (!this.showActions) {
|
|
621
|
+
const event = new CustomEvent('closePopover', {
|
|
622
|
+
bubbles: true,
|
|
623
|
+
composed: true,
|
|
624
|
+
});
|
|
625
|
+
this.el.dispatchEvent(event);
|
|
626
|
+
}
|
|
627
|
+
this.forceCalendarUpdate(newDate);
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
const start = parseDate(shortcut.rangeValue.start, this.dateFormat);
|
|
631
|
+
const end = parseDate(shortcut.rangeValue.end, this.dateFormat);
|
|
632
|
+
this.startDate = start;
|
|
633
|
+
this.endDate = end;
|
|
634
|
+
this.rangeDateChange.emit({
|
|
635
|
+
start: formatDate(start, { dateFormat: this.dateFormat }),
|
|
636
|
+
end: formatDate(end, { dateFormat: this.dateFormat }),
|
|
637
|
+
});
|
|
638
|
+
this.rangeValue = {
|
|
639
|
+
start: formatDate(start, { dateFormat: this.dateFormat }),
|
|
640
|
+
end: formatDate(end, { dateFormat: this.dateFormat }),
|
|
641
|
+
};
|
|
642
|
+
if (!this.showActions) {
|
|
643
|
+
const event = new CustomEvent('closePopover', {
|
|
644
|
+
bubbles: true,
|
|
645
|
+
composed: true,
|
|
646
|
+
});
|
|
647
|
+
this.el.dispatchEvent(event);
|
|
648
|
+
}
|
|
649
|
+
this.currentDate = start;
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
* Method to force the complete calendar update
|
|
654
|
+
* @param {Date} newDate - Date to force
|
|
655
|
+
*/
|
|
656
|
+
this.forceCalendarUpdate = newDate => {
|
|
657
|
+
this.currentDate = new Date(newDate);
|
|
658
|
+
};
|
|
659
|
+
/**
|
|
660
|
+
* Handles month change with an offset
|
|
661
|
+
* @param {number} direction - Direction (-1 for previous, 1 for next)
|
|
662
|
+
* @returns {Function} Change month handler
|
|
663
|
+
*/
|
|
664
|
+
this.getChangeMonthHandler = (direction) => {
|
|
665
|
+
return () => this.changeMonth(direction);
|
|
666
|
+
};
|
|
667
|
+
/**
|
|
668
|
+
* Handles month change from an event (ex: dropdown)
|
|
669
|
+
* @param {number} offset - Month offset (0 by default)
|
|
670
|
+
* @returns {Function} Change month handler
|
|
671
|
+
*/
|
|
672
|
+
this.getHandleMonthChange = (offset) => {
|
|
673
|
+
return (event) => this.handleMonthChange(event, offset);
|
|
674
|
+
};
|
|
675
|
+
/**
|
|
676
|
+
* Handles year change from an event (ex: dropdown)
|
|
677
|
+
* @param {number} offset - Year offset (0 by default)
|
|
678
|
+
* @returns {Function} Change year handler
|
|
679
|
+
*/
|
|
680
|
+
this.getHandleYearChange = (offset) => {
|
|
681
|
+
return (event) => this.handleYearChange(event, offset);
|
|
682
|
+
};
|
|
683
|
+
/**
|
|
684
|
+
* Handles day click
|
|
685
|
+
* @param {Date} date - Date to handle
|
|
686
|
+
* @param {boolean} isDisabled - Whether the date is disabled
|
|
687
|
+
* @returns {Function} Day click handler
|
|
688
|
+
*/
|
|
689
|
+
this.getDayClickHandler = (date, isDisabled) => {
|
|
690
|
+
return isDisabled ? undefined : () => this.handleDateSelection(date);
|
|
691
|
+
};
|
|
692
|
+
/**
|
|
693
|
+
* Handles shortcut selection
|
|
694
|
+
* @param {Object} shortcut - Shortcut to handle
|
|
695
|
+
* @param {string | Date} shortcut.singleValue - Selected date value
|
|
696
|
+
* @param {Object} shortcut.rangeValue - Start and end date values
|
|
697
|
+
* @param {string | Date} shortcut.rangeValue.start - Start date value
|
|
698
|
+
* @param {string | Date} shortcut.rangeValue.end - End date value
|
|
699
|
+
* @param {string} shortcut.label - Label
|
|
700
|
+
* @returns {Function} Shortcut selection handler
|
|
701
|
+
*/
|
|
702
|
+
this.getShortcutHandler = (shortcut) => {
|
|
703
|
+
return () => this.applyShortcut(shortcut);
|
|
704
|
+
};
|
|
705
|
+
/**
|
|
706
|
+
* Handles week selection
|
|
707
|
+
* @param {Date[]} dates - Dates to handle
|
|
708
|
+
* @param {number} index - Calendar index
|
|
709
|
+
* @returns {Function} Week selection handler
|
|
710
|
+
*/
|
|
711
|
+
this.getWeekSelectionHandler = (dates, index) => {
|
|
712
|
+
return () => {
|
|
713
|
+
if (this.selectionType === 'range') {
|
|
714
|
+
this.handleWeekSelection(dates, index);
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
};
|
|
131
718
|
/**
|
|
132
719
|
* Resets the current selection
|
|
133
720
|
*/
|
|
134
721
|
this.resetSelection = () => {
|
|
135
722
|
if (this.selectionType === 'single') {
|
|
136
723
|
this.selectedDate = null;
|
|
137
|
-
this.singleValue =
|
|
724
|
+
this.singleValue = null;
|
|
138
725
|
this.singleDateChange.emit('');
|
|
139
726
|
}
|
|
140
727
|
else {
|
|
141
728
|
this.startDate = null;
|
|
142
729
|
this.endDate = null;
|
|
143
|
-
this.rangeValue =
|
|
730
|
+
this.rangeValue = null;
|
|
144
731
|
this.rangeDateChange.emit({ start: '', end: '' });
|
|
145
732
|
}
|
|
146
733
|
};
|
|
@@ -149,7 +736,9 @@ const NvCalendar = class {
|
|
|
149
736
|
*/
|
|
150
737
|
this.confirmSelection = () => {
|
|
151
738
|
if (this.selectionType === 'single' && this.selectedDate) {
|
|
152
|
-
const dateStr =
|
|
739
|
+
const dateStr = formatDate(this.selectedDate, {
|
|
740
|
+
dateFormat: this.dateFormat,
|
|
741
|
+
});
|
|
153
742
|
this.singleDateChange.emit(dateStr);
|
|
154
743
|
this.singleValue = dateStr;
|
|
155
744
|
const event = new CustomEvent('closePopover', {
|
|
@@ -162,13 +751,13 @@ const NvCalendar = class {
|
|
|
162
751
|
this.startDate &&
|
|
163
752
|
this.endDate) {
|
|
164
753
|
this.rangeDateChange.emit({
|
|
165
|
-
start:
|
|
166
|
-
end:
|
|
167
|
-
});
|
|
168
|
-
this.rangeValue = JSON.stringify({
|
|
169
|
-
start: this.formatDate(this.startDate),
|
|
170
|
-
end: this.formatDate(this.endDate),
|
|
754
|
+
start: formatDate(this.startDate, { dateFormat: this.dateFormat }),
|
|
755
|
+
end: formatDate(this.endDate, { dateFormat: this.dateFormat }),
|
|
171
756
|
});
|
|
757
|
+
this.rangeValue = {
|
|
758
|
+
start: formatDate(this.startDate, { dateFormat: this.dateFormat }),
|
|
759
|
+
end: formatDate(this.endDate, { dateFormat: this.dateFormat }),
|
|
760
|
+
};
|
|
172
761
|
const event = new CustomEvent('closePopover', {
|
|
173
762
|
bubbles: true,
|
|
174
763
|
composed: true,
|
|
@@ -176,353 +765,114 @@ const NvCalendar = class {
|
|
|
176
765
|
this.el.dispatchEvent(event);
|
|
177
766
|
}
|
|
178
767
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
//#endregion LIFECYCLE
|
|
224
|
-
/****************************************************************************/
|
|
225
|
-
//#region METHODS
|
|
226
|
-
/**
|
|
227
|
-
* Change the displayed month
|
|
228
|
-
* @param {number} offset - Month offset (-1 for previous, 1 for next)
|
|
229
|
-
*/
|
|
230
|
-
changeMonth(offset) {
|
|
231
|
-
const newDate = new Date(this.currentDate);
|
|
232
|
-
// Ensure we only move by one month at a time
|
|
233
|
-
newDate.setUTCMonth(newDate.getUTCMonth() + offset);
|
|
234
|
-
// Add the appropriate animation class
|
|
235
|
-
const containers = this.el.querySelectorAll('.calendar-grid');
|
|
236
|
-
containers.forEach(container => {
|
|
237
|
-
// Remove existing animation classes
|
|
238
|
-
container.classList.remove('slide-left', 'slide-right');
|
|
239
|
-
// Add the new animation class
|
|
240
|
-
const animationClass = offset > 0 ? 'slide-left' : 'slide-right';
|
|
241
|
-
container.classList.add(animationClass);
|
|
242
|
-
// Remove the class after the animation
|
|
243
|
-
setTimeout(() => {
|
|
244
|
-
container.classList.remove(animationClass);
|
|
245
|
-
}, 300); // 300ms corresponds to $slide-duration in the SCSS
|
|
246
|
-
});
|
|
247
|
-
this.currentDate = newDate;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Handles date selection based on the mode
|
|
251
|
-
* @param {Date} date - Selected date
|
|
252
|
-
*/
|
|
253
|
-
handleDateSelection(date) {
|
|
254
|
-
if (this.isDateDisabled(date)) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
if (this.selectionType === 'single') {
|
|
258
|
-
this.handleSingleSelection(date);
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
this.handleRangeSelection(date);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Handles single date selection
|
|
266
|
-
* @param {Date} date - Selected date
|
|
267
|
-
*/
|
|
268
|
-
handleSingleSelection(date) {
|
|
269
|
-
if (!date)
|
|
270
|
-
return;
|
|
271
|
-
const formattedDate = this.formatDate(date);
|
|
272
|
-
this.selectedDate = date;
|
|
273
|
-
this.singleDateChange.emit(formattedDate);
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Handles range date selection
|
|
277
|
-
* @param {Date} date - Selected date
|
|
278
|
-
*/
|
|
279
|
-
handleRangeSelection(date) {
|
|
280
|
-
if (!this.startDate || (this.startDate && this.endDate)) {
|
|
281
|
-
this.startDate = date;
|
|
282
|
-
this.endDate = null;
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
this.endDate = date;
|
|
286
|
-
if (this.startDate > this.endDate) {
|
|
287
|
-
[this.startDate, this.endDate] = [this.endDate, this.startDate];
|
|
288
|
-
}
|
|
289
|
-
this.rangeDateChange.emit({
|
|
290
|
-
start: this.formatDate(this.startDate),
|
|
291
|
-
end: this.formatDate(this.endDate),
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* Calculates the ISO week number
|
|
297
|
-
* @param {Date} date - Date to calculate
|
|
298
|
-
* @returns {number} Week number
|
|
299
|
-
*/
|
|
300
|
-
getWeekNumber(date) {
|
|
301
|
-
const startOfYear = new Date(date.getFullYear(), 0, 1);
|
|
302
|
-
const pastDaysOfYear = (date.getTime() - startOfYear.getTime()) / 86400000;
|
|
303
|
-
return Math.ceil((pastDaysOfYear + startOfYear.getDay() + 1) / 7);
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Checks if a date is disabled.
|
|
307
|
-
* Disabled if:
|
|
308
|
-
* - The date is before min (if defined)
|
|
309
|
-
* - The date is after max (if defined)
|
|
310
|
-
* - The date is in the disabledDates array
|
|
311
|
-
* @param {Date} date - Date to check
|
|
312
|
-
* @returns {boolean} true if the date is disabled
|
|
313
|
-
*/
|
|
314
|
-
isDateDisabled(date) {
|
|
315
|
-
if (!date)
|
|
316
|
-
return true;
|
|
317
|
-
// Minimum bound check
|
|
318
|
-
if (this.min) {
|
|
319
|
-
const minDate = this.parseDate(this.min);
|
|
320
|
-
if (minDate && date < minDate) {
|
|
321
|
-
return true;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
// Maximum bound check
|
|
325
|
-
if (this.max) {
|
|
326
|
-
const maxDate = this.parseDate(this.max);
|
|
327
|
-
if (maxDate && date > maxDate) {
|
|
328
|
-
return true;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
// Check disabled dates
|
|
332
|
-
return this.parsedDisabledDates.some(disabledDate => this.isSameDate(date, disabledDate));
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Checks if a date is in the selected range
|
|
336
|
-
* @param {Date} date - Date to check
|
|
337
|
-
* @returns {boolean} true if the date is in the range
|
|
338
|
-
*/
|
|
339
|
-
isDateInRange(date) {
|
|
340
|
-
if (!date || !this.startDate || !this.endDate)
|
|
341
|
-
return false;
|
|
342
|
-
const checkDate = this.parseDate(date);
|
|
343
|
-
const startDate = this.parseDate(this.startDate);
|
|
344
|
-
const endDate = this.parseDate(this.endDate);
|
|
345
|
-
// Verify if startDate and endDate are valid
|
|
346
|
-
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
// Verify that startDate is before endDate (additional security)
|
|
350
|
-
if (startDate > endDate)
|
|
351
|
-
return false;
|
|
352
|
-
// Comparison based only on the date (year, month, day)
|
|
353
|
-
return (this.isSameOrAfter(checkDate, startDate) &&
|
|
354
|
-
this.isSameOrBefore(checkDate, endDate));
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Retrieves the localized day names
|
|
358
|
-
* @returns {string[]} Array of short day names
|
|
359
|
-
*/
|
|
360
|
-
getDayNames() {
|
|
361
|
-
// If we have custom day names for this locale
|
|
362
|
-
if (constants.CUSTOM_DAY_NAMES[this.locale]) {
|
|
363
|
-
const days = [...constants.CUSTOM_DAY_NAMES[this.locale]];
|
|
364
|
-
// Reorganize the days based on the first day of the week
|
|
365
|
-
const firstDays = days.slice(0, this.firstDayOfWeek);
|
|
366
|
-
const remainingDays = days.slice(this.firstDayOfWeek);
|
|
367
|
-
return [...remainingDays, ...firstDays];
|
|
368
|
-
}
|
|
369
|
-
// Otherwise, use the default behavior
|
|
370
|
-
const formatter = new Intl.DateTimeFormat(this.locale, {
|
|
371
|
-
weekday: 'short',
|
|
372
|
-
});
|
|
373
|
-
const days = [...Array(7)].map((_, i) => formatter.format(new Date(2023, 0, i + 1)).toUpperCase());
|
|
374
|
-
// Reorganize the days based on the first day of the week
|
|
375
|
-
const firstDays = days.slice(0, this.firstDayOfWeek);
|
|
376
|
-
const remainingDays = days.slice(this.firstDayOfWeek);
|
|
377
|
-
return [...remainingDays, ...firstDays];
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Generates the days of the current month
|
|
381
|
-
* @param {number} offset - Month offset (0 by default)
|
|
382
|
-
* @param {number} totalCalendars - Number of calendars to display (1 by default)
|
|
383
|
-
* @returns {Array<{ dayOfMonth: number | null, date: Date | null, isSelected: boolean, isDisabled: boolean }>} Array of formatted days
|
|
384
|
-
*/
|
|
385
|
-
getDaysInMonth(offset = 0, totalCalendars = 1) {
|
|
386
|
-
const year = this.currentDate.getUTCFullYear();
|
|
387
|
-
const month = this.currentDate.getUTCMonth() + offset;
|
|
388
|
-
const firstDay = new Date(Date.UTC(year, month, 1));
|
|
389
|
-
const lastDay = new Date(Date.UTC(year, month + 1, 0));
|
|
390
|
-
const days = [];
|
|
391
|
-
// Correct calculation of offset for previous month days
|
|
392
|
-
// Use getUTCDay to stay consistent with UTC timezone
|
|
393
|
-
const dayOfWeekIndex = firstDay.getUTCDay(); // 0 = Sunday, 1 = Monday, etc.
|
|
394
|
-
// Adjust based on firstDayOfWeek (if week starts on Monday, offset is different)
|
|
395
|
-
const offsetDays = (dayOfWeekIndex - this.firstDayOfWeek + 7) % 7;
|
|
396
|
-
// Add the days of the previous month for the first calendar
|
|
397
|
-
if (offset === 0 && offsetDays > 0) {
|
|
398
|
-
const prevMonthLastDay = new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
399
|
-
for (let i = offsetDays; i > 0; i--) {
|
|
400
|
-
const date = new Date(Date.UTC(year, month - 1, prevMonthLastDay - i + 1));
|
|
401
|
-
days.push({
|
|
402
|
-
dayOfMonth: date.getUTCDate(),
|
|
403
|
-
date,
|
|
404
|
-
isCurrentMonth: false,
|
|
405
|
-
isDisabled: this.isDateDisabled(date),
|
|
768
|
+
//#endregion METHODS
|
|
769
|
+
/****************************************************************************/
|
|
770
|
+
//#region RENDER
|
|
771
|
+
/**
|
|
772
|
+
* Renders the header
|
|
773
|
+
* @param {number} offset - Month offset
|
|
774
|
+
* @param {number} index - Calendar index
|
|
775
|
+
* @returns {JSX.Element} Header
|
|
776
|
+
* @description Renders the header of the calendar
|
|
777
|
+
*/
|
|
778
|
+
this.renderHeader = (offset, index$1) => {
|
|
779
|
+
return (index.h("div", { class: "header" }, this.numberOfCalendars > 1 && index$1 === 0 && (index.h("nv-iconbutton", { class: "nav-left", emphasis: "lower", name: "chevron-left", onClick: this.getChangeMonthHandler(-1) })), index.h("div", { class: "date-controls" }, index.h("select", { class: "month-select mr-4", onChange: this.getHandleMonthChange(offset) }, this.months.map(month => (index.h("option", { key: month.value, value: month.value, selected: month.value === (this.currentDate.getUTCMonth() + offset) % 12 }, month.label)))), index.h("input", { type: "number", class: "year-input", min: "1950", max: "2100", value: this.currentDate.getUTCFullYear() +
|
|
780
|
+
Math.floor((this.currentDate.getUTCMonth() + offset) / 12), onChange: this.getHandleYearChange(offset) })), this.numberOfCalendars === 1 && (index.h("div", { class: "nav-buttons" }, index.h("nv-iconbutton", { emphasis: "lower", name: "chevron-left", onClick: this.getChangeMonthHandler(-1) }), index.h("nv-iconbutton", { emphasis: "lower", name: "chevron-right", onClick: this.getChangeMonthHandler(1) }))), this.numberOfCalendars > 1 && index$1 === this.numberOfCalendars - 1 && (index.h("nv-iconbutton", { emphasis: "lower", name: "chevron-right", onClick: this.getChangeMonthHandler(1), class: "nav-right" }))));
|
|
781
|
+
};
|
|
782
|
+
/**
|
|
783
|
+
* Renders the week numbers
|
|
784
|
+
* @param {Array<{date: Date}>} weeks - Weeks to render
|
|
785
|
+
* @param {number} index - Calendar index
|
|
786
|
+
* @returns {JSX.Element} Week numbers
|
|
787
|
+
* @description Renders the week numbers of the calendar
|
|
788
|
+
*/
|
|
789
|
+
this.renderWeekNumbers = (
|
|
790
|
+
/** Weeks to render */
|
|
791
|
+
weeks,
|
|
792
|
+
/** Calendar index */
|
|
793
|
+
index$1) => {
|
|
794
|
+
return (index.h("div", { class: "week-numbers" }, index.h("div", { class: "week-header" }, this.getLocalizedWeekText()), weeks.map((week, weekIndex) => {
|
|
795
|
+
var _a;
|
|
796
|
+
const dates = week.map(d => d.date);
|
|
797
|
+
return (index.h("div", { class: `week-number ${this.selectionType === 'range' ? 'clickable' : ''}`, onClick: this.getWeekSelectionHandler(dates, index$1), key: `week-${weekIndex}` }, getWeekNumber(((_a = week.find(d => d.date)) === null || _a === void 0 ? void 0 : _a.date) || new Date())));
|
|
798
|
+
})));
|
|
799
|
+
};
|
|
800
|
+
this.renderDaysGrid = (
|
|
801
|
+
/** Days to render */
|
|
802
|
+
days) => {
|
|
803
|
+
return (index.h("div", { class: "days-grid" }, days.map(day => {
|
|
804
|
+
const date = day.date;
|
|
805
|
+
if (!date)
|
|
806
|
+
return null;
|
|
807
|
+
const isSelected = this.selectionType === 'single' &&
|
|
808
|
+
isSameDate(date, this.selectedDate, { isUTCMode: this.isUTCMode });
|
|
809
|
+
const isInRange = this.isDateInRange(date);
|
|
810
|
+
const isStart = isSameDate(date, this.startDate, {
|
|
811
|
+
isUTCMode: this.isUTCMode,
|
|
406
812
|
});
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
// Add the days of the current month
|
|
410
|
-
for (let i = 1; i <= lastDay.getUTCDate(); i++) {
|
|
411
|
-
const date = new Date(Date.UTC(year, month, i));
|
|
412
|
-
days.push({
|
|
413
|
-
dayOfMonth: i,
|
|
414
|
-
date,
|
|
415
|
-
isCurrentMonth: true,
|
|
416
|
-
isDisabled: this.isDateDisabled(date),
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
// Add the days of the next month only for the last calendar
|
|
420
|
-
if (offset === totalCalendars - 1) {
|
|
421
|
-
const nextMonthDaysNeeded = 7 - (days.length % 7 || 7);
|
|
422
|
-
for (let i = 1; i <= nextMonthDaysNeeded; i++) {
|
|
423
|
-
const date = new Date(Date.UTC(year, month + 1, i));
|
|
424
|
-
days.push({
|
|
425
|
-
dayOfMonth: i,
|
|
426
|
-
date,
|
|
427
|
-
isCurrentMonth: false,
|
|
428
|
-
isDisabled: this.isDateDisabled(date),
|
|
813
|
+
const isEnd = isSameDate(date, this.endDate, {
|
|
814
|
+
isUTCMode: this.isUTCMode,
|
|
429
815
|
});
|
|
816
|
+
const isToday = this.isToday(date);
|
|
817
|
+
const isOutsideMonth = !day.isCurrentMonth;
|
|
818
|
+
const dayClasses = [
|
|
819
|
+
'day',
|
|
820
|
+
isSelected ? 'selected' : '',
|
|
821
|
+
isStart ? 'range-start' : '',
|
|
822
|
+
isEnd ? 'range-end' : '',
|
|
823
|
+
isInRange ? 'in-range' : '',
|
|
824
|
+
day.isDisabled ? 'disabled' : '',
|
|
825
|
+
isOutsideMonth ? 'outside-month' : '',
|
|
826
|
+
isToday ? 'is-today' : '',
|
|
827
|
+
];
|
|
828
|
+
return (index.h("div", { class: dayClasses.filter(Boolean).join(' '), onClick: this.getDayClickHandler(date, day.isDisabled), "aria-disabled": day.isDisabled, key: `day-${date.toISOString()}` }, day.dayOfMonth));
|
|
829
|
+
})));
|
|
830
|
+
};
|
|
831
|
+
/**
|
|
832
|
+
* Renders the calendar
|
|
833
|
+
* @param {number} index - Calendar index
|
|
834
|
+
* @param {number} offset - Month offset
|
|
835
|
+
* @returns {JSX.Element} Calendar
|
|
836
|
+
* @description Renders the calendar of the calendar
|
|
837
|
+
*/
|
|
838
|
+
this.renderCalendar = (
|
|
839
|
+
/** Calendar index */
|
|
840
|
+
index$1,
|
|
841
|
+
/** Month offset */
|
|
842
|
+
offset) => {
|
|
843
|
+
const days = this.getDaysInMonth(offset, this.numberOfCalendars);
|
|
844
|
+
const weeks = [];
|
|
845
|
+
for (let i = 0; i < days.length; i += 7) {
|
|
846
|
+
weeks.push(days.slice(i, i + 7));
|
|
430
847
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
* @returns {string} Localized abbreviation for "week"
|
|
454
|
-
*/
|
|
455
|
-
getLocalizedWeekText() {
|
|
456
|
-
return constants.WEEK_ABBREVIATIONS[this.locale] || 'W';
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Handles month change in the selector
|
|
460
|
-
* @param {Event} event - Month change event
|
|
461
|
-
* @param {number} calendarOffset - Calendar offset (0 by default)
|
|
462
|
-
*/
|
|
463
|
-
handleMonthChange(event, calendarOffset = 0) {
|
|
464
|
-
const select = event.target;
|
|
465
|
-
const selectedMonth = parseInt(select.value, 10);
|
|
466
|
-
const currentMonth = this.currentDate.getUTCMonth();
|
|
467
|
-
// Calculate the difference considering the calendar offset
|
|
468
|
-
const monthDiff = selectedMonth - ((currentMonth + calendarOffset) % 12);
|
|
469
|
-
const newDate = new Date(this.currentDate);
|
|
470
|
-
newDate.setUTCMonth(newDate.getUTCMonth() + monthDiff);
|
|
471
|
-
this.currentDate = newDate;
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Handles year change in the numeric entry
|
|
475
|
-
* @param {Event} event - Year change event
|
|
476
|
-
* @param {number} calendarOffset - Calendar offset (0 by default)
|
|
477
|
-
*/
|
|
478
|
-
handleYearChange(event, calendarOffset = 0) {
|
|
479
|
-
const input = event.target;
|
|
480
|
-
const year = parseInt(input.value, 10);
|
|
481
|
-
if (!isNaN(year) && year >= 1900 && year <= 2100) {
|
|
482
|
-
const newDate = new Date(this.currentDate);
|
|
483
|
-
newDate.setUTCFullYear(year);
|
|
484
|
-
newDate.setUTCMonth(newDate.getUTCMonth() + calendarOffset);
|
|
485
|
-
this.currentDate = newDate;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Handles week selection
|
|
490
|
-
* @param {Date[]} weekDays - Selected week days
|
|
491
|
-
* @param {number} calendarIndex - Calendar index from which the selection is made
|
|
492
|
-
*/
|
|
493
|
-
handleWeekSelection(weekDays, calendarIndex) {
|
|
494
|
-
if (this.selectionType !== 'range')
|
|
495
|
-
return;
|
|
496
|
-
const allDays = this.getDaysInMonth(calendarIndex, this.numberOfCalendars);
|
|
497
|
-
const weekStart = weekDays[0];
|
|
498
|
-
const weekEnd = weekDays[weekDays.length - 1];
|
|
499
|
-
if (!weekStart || !weekEnd)
|
|
500
|
-
return;
|
|
501
|
-
const selectedWeekDays = allDays.filter(day => day.date && day.date >= weekStart && day.date <= weekEnd);
|
|
502
|
-
const validDays = selectedWeekDays.filter(day => !this.isDateDisabled(day.date));
|
|
503
|
-
if (validDays.length > 0) {
|
|
504
|
-
this.startDate = validDays[0].date;
|
|
505
|
-
this.endDate = validDays[validDays.length - 1].date;
|
|
506
|
-
this.rangeDateChange.emit({
|
|
507
|
-
start: this.formatDate(this.startDate),
|
|
508
|
-
end: this.formatDate(this.endDate),
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* Checks if a date corresponds to today
|
|
514
|
-
* @param {Date} date - Date to check
|
|
515
|
-
* @returns {boolean} true if the date is today
|
|
516
|
-
*/
|
|
517
|
-
isToday(date) {
|
|
518
|
-
const today = new Date();
|
|
519
|
-
return (date.getDate() === today.getDate() &&
|
|
520
|
-
date.getMonth() === today.getMonth() &&
|
|
521
|
-
date.getFullYear() === today.getFullYear());
|
|
848
|
+
return (index.h("div", { class: "calendar-wrapper" }, index.h("div", { class: "calendar-container", key: `calendar-${index$1}` }, this.renderHeader(offset, index$1), index.h("div", { class: "calendar-grid" }, this.showWeekNumbers && this.renderWeekNumbers(weeks, index$1), index.h("div", { class: "days-container" }, index.h("div", { class: "days-header" }, this.getDayNames().map(day => (index.h("div", { class: "day-header" }, day)))), this.renderDaysGrid(days)))), index$1 < this.numberOfCalendars - 1 && (index.h("div", { class: "calendar-separator" }))));
|
|
849
|
+
};
|
|
850
|
+
/**
|
|
851
|
+
* Renders the shortcuts
|
|
852
|
+
* @returns {JSX.Element} Shortcuts
|
|
853
|
+
* @description Renders the shortcuts of the calendar
|
|
854
|
+
*/
|
|
855
|
+
this.renderShortcuts = () => {
|
|
856
|
+
if (!this.hasShortcuts) {
|
|
857
|
+
return null;
|
|
858
|
+
}
|
|
859
|
+
return (index.h("div", { class: `shortcuts-container shortcuts-placement-${this.shortcutsPlacement}` }, this.shortcuts.map(shortcut => (index.h("nv-button", { emphasis: "lower", size: "xs", "aria-label": shortcut.label, onClick: this.getShortcutHandler(shortcut) }, shortcut.label)))));
|
|
860
|
+
};
|
|
861
|
+
/**
|
|
862
|
+
* Renders the actions
|
|
863
|
+
* @returns {JSX.Element} Actions
|
|
864
|
+
* @description Renders the actions of the calendar
|
|
865
|
+
* @slot actions - Child content of the component.
|
|
866
|
+
*/
|
|
867
|
+
this.renderActions = () => {
|
|
868
|
+
return (index.h("div", { class: "datepicker-actions" }, index.h("slot", { name: "actions" }, index.h("nv-button", { emphasis: "low", size: "xs", onClick: this.resetSelection }, "Cancel"), index.h("nv-button", { size: "xs", onClick: this.confirmSelection }, "OK"))));
|
|
869
|
+
};
|
|
522
870
|
}
|
|
871
|
+
//#endregion EVENTS
|
|
872
|
+
/****************************************************************************/
|
|
873
|
+
//#region WATCHERS
|
|
523
874
|
/**
|
|
524
875
|
* Watches the changes of the number of calendars
|
|
525
|
-
* @watch numberOfCalendars
|
|
526
876
|
* @param {number} newValue - New number of calendars
|
|
527
877
|
*/
|
|
528
878
|
validateNumberOfCalendars(newValue) {
|
|
@@ -533,29 +883,29 @@ const NvCalendar = class {
|
|
|
533
883
|
}
|
|
534
884
|
/**
|
|
535
885
|
* Watches the changes of the selected date range
|
|
536
|
-
* @watch rangeValue
|
|
537
886
|
* @param {Object} newValue - New rangeValue value
|
|
538
887
|
* @param {string} newValue.start - Start date
|
|
539
888
|
* @param {string} newValue.end - End date
|
|
540
889
|
*/
|
|
541
890
|
onRangeValueChange(newValue) {
|
|
542
|
-
if (newValue) {
|
|
891
|
+
if (newValue && newValue.start && newValue.end) {
|
|
543
892
|
try {
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
893
|
+
const { startDate, endDate } = this.validateDateRange(newValue.start, newValue.end);
|
|
894
|
+
this.startDate = startDate;
|
|
895
|
+
this.endDate = endDate;
|
|
896
|
+
// Do not navigate to the start date if data-prevent-navigation attribute is present
|
|
897
|
+
const preventNavigation = this.el.getAttribute('data-prevent-navigation') === 'true';
|
|
898
|
+
if (!preventNavigation) {
|
|
899
|
+
this.currentDate = startDate;
|
|
549
900
|
}
|
|
550
901
|
}
|
|
551
902
|
catch (error) {
|
|
552
|
-
console.error('Invalid
|
|
903
|
+
console.error('Invalid rangeValue:', error);
|
|
553
904
|
}
|
|
554
905
|
}
|
|
555
906
|
}
|
|
556
907
|
/**
|
|
557
908
|
* Watches the changes of the disabled dates
|
|
558
|
-
* @watch disabledDates
|
|
559
909
|
* @description Watches the changes of the disabled dates
|
|
560
910
|
*/
|
|
561
911
|
handleDisabledDatesChange() {
|
|
@@ -563,381 +913,65 @@ const NvCalendar = class {
|
|
|
563
913
|
}
|
|
564
914
|
/**
|
|
565
915
|
* Watches the changes of the single value
|
|
566
|
-
* @watch singleValue
|
|
567
916
|
* @param {string} newValue - New single value
|
|
568
917
|
* @param {string} oldValue - Old single value
|
|
569
918
|
*/
|
|
570
919
|
onSingleValueChange(newValue, oldValue) {
|
|
571
920
|
if (this.selectionType === 'single' && newValue !== oldValue && newValue) {
|
|
572
|
-
const parsedDate =
|
|
921
|
+
const parsedDate = parseDate(newValue, this.dateFormat);
|
|
573
922
|
if (parsedDate) {
|
|
574
923
|
this.selectedDate = parsedDate;
|
|
575
|
-
|
|
924
|
+
// Do not navigate to the selected date if data-prevent-navigation attribute is present
|
|
925
|
+
const preventNavigation = this.el.getAttribute('data-prevent-navigation') === 'true';
|
|
926
|
+
if (!preventNavigation) {
|
|
927
|
+
this.currentDate = parsedDate;
|
|
928
|
+
}
|
|
576
929
|
}
|
|
577
930
|
}
|
|
578
931
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
if (typeof dateInput === 'string' &&
|
|
590
|
-
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/.test(dateInput)) {
|
|
932
|
+
//#endregion WATCHERS
|
|
933
|
+
/****************************************************************************/
|
|
934
|
+
//#region LIFECYCLE
|
|
935
|
+
componentWillLoad() {
|
|
936
|
+
this.parseDisabledDates();
|
|
937
|
+
if (this.selectionType === 'single' && this.singleValue) {
|
|
938
|
+
this.selectedDate = parseDate(this.singleValue, this.dateFormat);
|
|
939
|
+
this.currentDate = this.selectedDate;
|
|
940
|
+
}
|
|
941
|
+
else if (this.selectionType === 'range' && this.rangeValue) {
|
|
591
942
|
try {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
943
|
+
if (this.rangeValue.start && this.rangeValue.end) {
|
|
944
|
+
const { startDate, endDate, swapped } = this.validateDateRange(this.rangeValue.start, this.rangeValue.end);
|
|
945
|
+
this.startDate = startDate;
|
|
946
|
+
this.endDate = endDate;
|
|
947
|
+
this.currentDate = startDate;
|
|
948
|
+
if (swapped) {
|
|
949
|
+
// If dates were swapped, update the rangeValue property
|
|
950
|
+
this.rangeValue = {
|
|
951
|
+
start: formatDate(startDate, { dateFormat: this.dateFormat }),
|
|
952
|
+
end: formatDate(endDate, { dateFormat: this.dateFormat }),
|
|
953
|
+
};
|
|
954
|
+
}
|
|
595
955
|
}
|
|
596
956
|
}
|
|
597
957
|
catch (error) {
|
|
598
|
-
|
|
599
|
-
console.error('Error parsing ISO date:', error);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
// Handling Unix Seconds ("X") formats
|
|
603
|
-
if (this.dateFormat === 'X') {
|
|
604
|
-
const unixSeconds = Number(dateInput);
|
|
605
|
-
if (isNaN(unixSeconds))
|
|
606
|
-
return null;
|
|
607
|
-
return this.isUTCMode
|
|
608
|
-
? dayjs.unix(unixSeconds).utc().toDate()
|
|
609
|
-
: dayjs.unix(unixSeconds).toDate();
|
|
610
|
-
}
|
|
611
|
-
// Handling Unix Milliseconds ("x") formats
|
|
612
|
-
if (this.dateFormat === 'x') {
|
|
613
|
-
const unixMilliseconds = Number(dateInput);
|
|
614
|
-
if (isNaN(unixMilliseconds))
|
|
615
|
-
return null;
|
|
616
|
-
return this.isUTCMode
|
|
617
|
-
? dayjs(unixMilliseconds).utc().toDate()
|
|
618
|
-
: dayjs(unixMilliseconds).toDate();
|
|
619
|
-
}
|
|
620
|
-
// Handling C# Ticks format
|
|
621
|
-
if (this.dateFormat === 'Ticks') {
|
|
622
|
-
const ticks = Number(dateInput);
|
|
623
|
-
if (isNaN(ticks))
|
|
624
|
-
return null;
|
|
625
|
-
// Conversion of .NET ticks to milliseconds since Unix epoch
|
|
626
|
-
const unixMilliseconds = (ticks - 621355968000000000) / 10000;
|
|
627
|
-
return this.isUTCMode
|
|
628
|
-
? dayjs(unixMilliseconds).utc().toDate()
|
|
629
|
-
: dayjs(unixMilliseconds).toDate();
|
|
630
|
-
}
|
|
631
|
-
// For all other formats, use customParseFormat in strict mode
|
|
632
|
-
let parsed;
|
|
633
|
-
if (this.isUTCMode) {
|
|
634
|
-
parsed = dayjs.utc(dateInput, this.dateFormat, true);
|
|
635
|
-
}
|
|
636
|
-
else {
|
|
637
|
-
parsed = dayjs(dateInput, this.dateFormat, true);
|
|
638
|
-
}
|
|
639
|
-
if (!parsed.isValid()) {
|
|
640
|
-
console.error(`Parsing error:`, {
|
|
641
|
-
dateInput,
|
|
642
|
-
dateFormat: this.dateFormat,
|
|
643
|
-
});
|
|
644
|
-
return null;
|
|
645
|
-
}
|
|
646
|
-
return parsed.toDate();
|
|
647
|
-
}
|
|
648
|
-
/**
|
|
649
|
-
* Checks if the date format is in UTC mode
|
|
650
|
-
* @returns {boolean} true if the date format is in UTC mode
|
|
651
|
-
*/
|
|
652
|
-
get isUTCMode() {
|
|
653
|
-
return this.dateFormat.includes('Z');
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Checks if the date format is ISO 8601
|
|
657
|
-
* @returns {boolean} true if the format is ISO 8601
|
|
658
|
-
*/
|
|
659
|
-
get isISO8601Format() {
|
|
660
|
-
return this.dateFormat === 'YYYY-MM-DD[T]HH:mm:ss[Z]';
|
|
661
|
-
}
|
|
662
|
-
/**
|
|
663
|
-
* Formats a date to a string according to the format
|
|
664
|
-
* @param {Date} date - Date to format
|
|
665
|
-
* @returns {string} Formatted date
|
|
666
|
-
*/
|
|
667
|
-
formatDate(date) {
|
|
668
|
-
if (!date)
|
|
669
|
-
return '';
|
|
670
|
-
// Special case for ISO 8601
|
|
671
|
-
if (this.isISO8601Format) {
|
|
672
|
-
// For the ISO 8601 format, use directly toISOString() which is standard
|
|
673
|
-
return date.toISOString();
|
|
674
|
-
}
|
|
675
|
-
// If the format is "Ticks", convert the time to C# ticks
|
|
676
|
-
if (this.dateFormat === 'Ticks') {
|
|
677
|
-
const ticks = date.getTime() * 10000 + 621355968000000000;
|
|
678
|
-
return ticks.toString();
|
|
679
|
-
}
|
|
680
|
-
// If the format is "X" (Unix Seconds)
|
|
681
|
-
if (this.dateFormat === 'X') {
|
|
682
|
-
return dayjs(date).unix().toString();
|
|
683
|
-
}
|
|
684
|
-
// If the format is "x" (Unix Milliseconds)
|
|
685
|
-
if (this.dateFormat === 'x') {
|
|
686
|
-
return date.getTime().toString();
|
|
687
|
-
}
|
|
688
|
-
// Otherwise, format according to the mode (UTC or local)
|
|
689
|
-
return this.isUTCMode
|
|
690
|
-
? dayjs(date).utc().format(this.dateFormat)
|
|
691
|
-
: dayjs(date).format(this.dateFormat);
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Parse and cache the disabled dates
|
|
695
|
-
* @description Parse and cache the disabled dates
|
|
696
|
-
*/
|
|
697
|
-
parseDisabledDates() {
|
|
698
|
-
if (!this.disabledDates) {
|
|
699
|
-
this.parsedDisabledDates = [];
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
try {
|
|
703
|
-
const disabledDatesArray = JSON.parse(this.disabledDates);
|
|
704
|
-
this.parsedDisabledDates = disabledDatesArray
|
|
705
|
-
.map(date => this.parseDate(date))
|
|
706
|
-
.filter(date => date !== null);
|
|
707
|
-
}
|
|
708
|
-
catch (error) {
|
|
709
|
-
console.error('Error parsing disabled dates:', error);
|
|
710
|
-
this.parsedDisabledDates = [];
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
/**
|
|
714
|
-
* Checks if two dates are identical
|
|
715
|
-
* @param {Date | null} date1 - First date
|
|
716
|
-
* @param {Date | null} date2 - Second date
|
|
717
|
-
* @returns {boolean} true if the dates are identical
|
|
718
|
-
*/
|
|
719
|
-
isSameDate(date1, date2) {
|
|
720
|
-
if (!date1 || !date2)
|
|
721
|
-
return false;
|
|
722
|
-
if (this.isUTCMode) {
|
|
723
|
-
return (date1.getUTCFullYear() === date2.getUTCFullYear() &&
|
|
724
|
-
date1.getUTCMonth() === date2.getUTCMonth() &&
|
|
725
|
-
date1.getUTCDate() === date2.getUTCDate());
|
|
726
|
-
}
|
|
727
|
-
else {
|
|
728
|
-
return (date1.getFullYear() === date2.getFullYear() &&
|
|
729
|
-
date1.getMonth() === date2.getMonth() &&
|
|
730
|
-
date1.getDate() === date2.getDate());
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
/**
|
|
734
|
-
* Checks if a date is identical or after another date
|
|
735
|
-
* @param {Date} date - Date to check
|
|
736
|
-
* @param {Date} compareDate - Reference date
|
|
737
|
-
* @returns {boolean} true if `date` >= `compareDate`
|
|
738
|
-
*/
|
|
739
|
-
isSameOrAfter(date, compareDate) {
|
|
740
|
-
if (this.isUTCMode) {
|
|
741
|
-
return (date.getUTCFullYear() > compareDate.getUTCFullYear() ||
|
|
742
|
-
(date.getUTCFullYear() === compareDate.getUTCFullYear() &&
|
|
743
|
-
date.getUTCMonth() > compareDate.getUTCMonth()) ||
|
|
744
|
-
(date.getUTCFullYear() === compareDate.getUTCFullYear() &&
|
|
745
|
-
date.getUTCMonth() === compareDate.getUTCMonth() &&
|
|
746
|
-
date.getUTCDate() >= compareDate.getUTCDate()));
|
|
747
|
-
}
|
|
748
|
-
else {
|
|
749
|
-
return (date.getFullYear() > compareDate.getFullYear() ||
|
|
750
|
-
(date.getFullYear() === compareDate.getFullYear() &&
|
|
751
|
-
date.getMonth() > compareDate.getMonth()) ||
|
|
752
|
-
(date.getFullYear() === compareDate.getFullYear() &&
|
|
753
|
-
date.getMonth() === compareDate.getMonth() &&
|
|
754
|
-
date.getDate() >= compareDate.getDate()));
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
/**
|
|
758
|
-
* Checks if a date is identical or before another date
|
|
759
|
-
* @param {Date} date - Date to check
|
|
760
|
-
* @param {Date} compareDate - Reference date
|
|
761
|
-
* @returns {boolean} true if `date` <= `compareDate`
|
|
762
|
-
*/
|
|
763
|
-
isSameOrBefore(date, compareDate) {
|
|
764
|
-
if (this.isUTCMode) {
|
|
765
|
-
return (date.getUTCFullYear() < compareDate.getUTCFullYear() ||
|
|
766
|
-
(date.getUTCFullYear() === compareDate.getUTCFullYear() &&
|
|
767
|
-
date.getUTCMonth() < compareDate.getUTCMonth()) ||
|
|
768
|
-
(date.getUTCFullYear() === compareDate.getUTCFullYear() &&
|
|
769
|
-
date.getUTCMonth() === compareDate.getUTCMonth() &&
|
|
770
|
-
date.getUTCDate() <= compareDate.getUTCDate()));
|
|
771
|
-
}
|
|
772
|
-
else {
|
|
773
|
-
return (date.getFullYear() < compareDate.getFullYear() ||
|
|
774
|
-
(date.getFullYear() === compareDate.getFullYear() &&
|
|
775
|
-
date.getMonth() < compareDate.getMonth()) ||
|
|
776
|
-
(date.getFullYear() === compareDate.getFullYear() &&
|
|
777
|
-
date.getMonth() === compareDate.getMonth() &&
|
|
778
|
-
date.getDate() <= compareDate.getDate()));
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
/**
|
|
782
|
-
* Applies a shortcut selection
|
|
783
|
-
* @param {Object} shortcut - Shortcut to apply
|
|
784
|
-
* @param {string | Date} shortcut.singleValue - Selected date value
|
|
785
|
-
* @param {Object} shortcut.rangeValue - Start and end date values
|
|
786
|
-
* @param {string | Date} shortcut.rangeValue.start - Start date value
|
|
787
|
-
* @param {string | Date} shortcut.rangeValue.end - End date value
|
|
788
|
-
* @param {string} shortcut.label - Label
|
|
789
|
-
*/
|
|
790
|
-
applyShortcut(shortcut) {
|
|
791
|
-
this.selectedDate = null;
|
|
792
|
-
this.startDate = null;
|
|
793
|
-
this.endDate = null;
|
|
794
|
-
if (shortcut.singleValue) {
|
|
795
|
-
const newDate = this.parseDate(shortcut.singleValue);
|
|
796
|
-
this.selectedDate = newDate;
|
|
797
|
-
this.singleDateChange.emit(this.formatDate(newDate));
|
|
798
|
-
this.singleValue = this.formatDate(newDate);
|
|
799
|
-
if (!this.showActions) {
|
|
800
|
-
const event = new CustomEvent('closePopover', {
|
|
801
|
-
bubbles: true,
|
|
802
|
-
composed: true,
|
|
803
|
-
});
|
|
804
|
-
this.el.dispatchEvent(event);
|
|
958
|
+
console.error('Invalid rangeValue:', error);
|
|
805
959
|
}
|
|
806
|
-
this.forceCalendarUpdate(newDate);
|
|
807
960
|
}
|
|
808
961
|
else {
|
|
809
|
-
|
|
810
|
-
const end = this.parseDate(shortcut.rangeValue.end);
|
|
811
|
-
this.startDate = start;
|
|
812
|
-
this.endDate = end;
|
|
813
|
-
this.rangeDateChange.emit({
|
|
814
|
-
start: this.formatDate(start),
|
|
815
|
-
end: this.formatDate(end),
|
|
816
|
-
});
|
|
817
|
-
this.rangeValue = JSON.stringify({
|
|
818
|
-
start: this.formatDate(start),
|
|
819
|
-
end: this.formatDate(end),
|
|
820
|
-
});
|
|
821
|
-
if (!this.showActions) {
|
|
822
|
-
const event = new CustomEvent('closePopover', {
|
|
823
|
-
bubbles: true,
|
|
824
|
-
composed: true,
|
|
825
|
-
});
|
|
826
|
-
this.el.dispatchEvent(event);
|
|
827
|
-
}
|
|
828
|
-
this.forceCalendarUpdate(end);
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
/**
|
|
832
|
-
* Method to force the complete calendar update (and fix the persistent hover problem)
|
|
833
|
-
* @param {Date} newDate - Date to force
|
|
834
|
-
*/
|
|
835
|
-
forceCalendarUpdate(newDate) {
|
|
836
|
-
this.currentDate = new Date(newDate);
|
|
837
|
-
this.currentDate = new Date(this.currentDate); // Force a re-render
|
|
838
|
-
// Reset visually the hover/touch effect
|
|
839
|
-
requestAnimationFrame(() => {
|
|
840
|
-
const days = document.querySelectorAll('.day');
|
|
841
|
-
days.forEach(el => {
|
|
842
|
-
el.classList.remove('hover', 'active', 'touched');
|
|
843
|
-
el.style.pointerEvents = 'none';
|
|
844
|
-
});
|
|
845
|
-
// Add specific touch handling (for mobile)
|
|
846
|
-
document.body.addEventListener('touchstart', this.clearTouchState, {
|
|
847
|
-
passive: true,
|
|
848
|
-
});
|
|
849
|
-
// Reset the touch state after 50ms
|
|
850
|
-
setTimeout(() => {
|
|
851
|
-
days.forEach(el => {
|
|
852
|
-
el.style.pointerEvents = '';
|
|
853
|
-
});
|
|
854
|
-
}, 50);
|
|
855
|
-
});
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* Function to reset the touch effect (Mobile fix)
|
|
859
|
-
*/
|
|
860
|
-
clearTouchState() {
|
|
861
|
-
document.querySelectorAll('.day').forEach(el => {
|
|
862
|
-
el.classList.remove('touched');
|
|
863
|
-
});
|
|
864
|
-
// Remove the listener after the first interaction
|
|
865
|
-
document.body.removeEventListener('touchstart', this.clearTouchState);
|
|
866
|
-
}
|
|
867
|
-
/**
|
|
868
|
-
* Handles month change with an offset
|
|
869
|
-
* @param {number} direction - Direction (-1 for previous, 1 for next)
|
|
870
|
-
* @returns {Function} Change month handler
|
|
871
|
-
*/
|
|
872
|
-
getChangeMonthHandler(direction) {
|
|
873
|
-
return () => this.changeMonth(direction);
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* Handles month change from an event (ex: dropdown)
|
|
877
|
-
* @param {number} offset - Month offset (0 by default)
|
|
878
|
-
* @returns {Function} Change month handler
|
|
879
|
-
*/
|
|
880
|
-
getHandleMonthChange(offset) {
|
|
881
|
-
return (event) => this.handleMonthChange(event, offset);
|
|
882
|
-
}
|
|
883
|
-
/**
|
|
884
|
-
* Handles year change from an event (ex: dropdown)
|
|
885
|
-
* @param {number} offset - Year offset (0 by default)
|
|
886
|
-
* @returns {Function} Change year handler
|
|
887
|
-
*/
|
|
888
|
-
getHandleYearChange(offset) {
|
|
889
|
-
return (event) => this.handleYearChange(event, offset);
|
|
890
|
-
}
|
|
891
|
-
/**
|
|
892
|
-
* Handles day click
|
|
893
|
-
* @param {Date} date - Date to handle
|
|
894
|
-
* @param {boolean} isDisabled - Whether the date is disabled
|
|
895
|
-
* @returns {Function} Day click handler
|
|
896
|
-
*/
|
|
897
|
-
getDayClickHandler(date, isDisabled) {
|
|
898
|
-
return isDisabled ? undefined : () => this.handleDateSelection(date);
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* Handles shortcut selection
|
|
902
|
-
* @param {Object} shortcut - Shortcut to handle
|
|
903
|
-
* @param {string | Date} shortcut.singleValue - Selected date value
|
|
904
|
-
* @param {Object} shortcut.rangeValue - Start and end date values
|
|
905
|
-
* @param {string | Date} shortcut.rangeValue.start - Start date value
|
|
906
|
-
* @param {string | Date} shortcut.rangeValue.end - End date value
|
|
907
|
-
* @param {string} shortcut.label - Label
|
|
908
|
-
* @returns {Function} Shortcut selection handler
|
|
909
|
-
*/
|
|
910
|
-
getShortcutHandler(shortcut) {
|
|
911
|
-
return () => this.applyShortcut(shortcut);
|
|
912
|
-
}
|
|
913
|
-
/**
|
|
914
|
-
* Handles week selection
|
|
915
|
-
* @param {Date[]} dates - Dates to handle
|
|
916
|
-
* @param {number} index - Calendar index
|
|
917
|
-
* @returns {Function} Week selection handler
|
|
918
|
-
*/
|
|
919
|
-
getWeekSelectionHandler(dates, index) {
|
|
920
|
-
return () => {
|
|
921
|
-
if (this.selectionType === 'range') {
|
|
922
|
-
this.handleWeekSelection(dates, index);
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
parsedShortcuts() {
|
|
927
|
-
try {
|
|
928
|
-
return this.shortcuts ? JSON.parse(this.shortcuts) : [];
|
|
929
|
-
}
|
|
930
|
-
catch (error) {
|
|
931
|
-
console.error('Invalid JSON for shortcuts:', error);
|
|
932
|
-
return [];
|
|
962
|
+
this.currentDate = new Date();
|
|
933
963
|
}
|
|
964
|
+
this.initializeMonths();
|
|
934
965
|
}
|
|
966
|
+
//#endregion LIFECYCLE
|
|
967
|
+
/****************************************************************************/
|
|
968
|
+
//#region METHODS
|
|
935
969
|
/**
|
|
936
970
|
* Checks if shortcuts are visible
|
|
937
971
|
* @returns {boolean} true if shortcuts are visible
|
|
938
972
|
*/
|
|
939
973
|
get hasShortcuts() {
|
|
940
|
-
return (this.shortcutsPlacement
|
|
974
|
+
return Boolean(this.shortcutsPlacement && this.shortcuts);
|
|
941
975
|
}
|
|
942
976
|
/**
|
|
943
977
|
* Checks if actions are visible
|
|
@@ -946,103 +980,46 @@ const NvCalendar = class {
|
|
|
946
980
|
get hasActions() {
|
|
947
981
|
return this.showActions;
|
|
948
982
|
}
|
|
949
|
-
//#endregion METHODS
|
|
950
|
-
/****************************************************************************/
|
|
951
|
-
//#region RENDER
|
|
952
|
-
/**
|
|
953
|
-
* Renders the header
|
|
954
|
-
* @param {number} offset - Month offset
|
|
955
|
-
* @param {number} index - Calendar index
|
|
956
|
-
* @returns {JSX.Element} Header
|
|
957
|
-
* @description Renders the header of the calendar
|
|
958
|
-
*/
|
|
959
|
-
renderHeader(offset, index$1) {
|
|
960
|
-
return (index.h("div", { class: "header" }, this.numberOfCalendars > 1 && index$1 === 0 && (index.h("nv-iconbutton", { class: "nav-left", emphasis: "lower", name: "chevron-left", onClick: this.getChangeMonthHandler(-1) })), index.h("div", { class: "date-controls" }, index.h("select", { class: "month-select mr-4", onChange: this.getHandleMonthChange(offset) }, this.months.map(month => (index.h("option", { key: month.value, value: month.value, selected: month.value === (this.currentDate.getUTCMonth() + offset) % 12 }, month.label)))), index.h("input", { type: "number", class: "year-input", min: "1950", max: "2100", value: this.currentDate.getUTCFullYear() +
|
|
961
|
-
Math.floor((this.currentDate.getUTCMonth() + offset) / 12), onChange: this.getHandleYearChange(offset) })), this.numberOfCalendars === 1 && (index.h("div", { class: "nav-buttons" }, index.h("nv-iconbutton", { emphasis: "lower", name: "chevron-left", onClick: this.getChangeMonthHandler(-1) }), index.h("nv-iconbutton", { emphasis: "lower", name: "chevron-right", onClick: this.getChangeMonthHandler(1) }))), this.numberOfCalendars > 1 && index$1 === this.numberOfCalendars - 1 && (index.h("nv-iconbutton", { emphasis: "lower", name: "chevron-right", onClick: this.getChangeMonthHandler(1), class: "nav-right" }))));
|
|
962
|
-
}
|
|
963
983
|
/**
|
|
964
|
-
*
|
|
965
|
-
* @
|
|
966
|
-
* @param {number} index - Calendar index
|
|
967
|
-
* @returns {JSX.Element} Week numbers
|
|
968
|
-
* @description Renders the week numbers of the calendar
|
|
984
|
+
* Checks if the date format is in UTC mode
|
|
985
|
+
* @returns {boolean} true if the date format is in UTC mode
|
|
969
986
|
*/
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
weeks,
|
|
973
|
-
/** Calendar index */
|
|
974
|
-
index$1) {
|
|
975
|
-
return (index.h("div", { class: "week-numbers" }, index.h("div", { class: "week-header" }, this.getLocalizedWeekText()), weeks.map((week, weekIndex) => {
|
|
976
|
-
var _a;
|
|
977
|
-
const dates = week.map(d => d.date);
|
|
978
|
-
return (index.h("div", { class: `week-number ${this.selectionType === 'range' ? 'clickable' : ''}`, onClick: this.getWeekSelectionHandler(dates, index$1), key: `week-${weekIndex}` }, this.getWeekNumber(((_a = week.find(d => d.date)) === null || _a === void 0 ? void 0 : _a.date) || new Date())));
|
|
979
|
-
})));
|
|
980
|
-
}
|
|
981
|
-
renderDaysGrid(
|
|
982
|
-
/** Days to render */
|
|
983
|
-
days) {
|
|
984
|
-
return (index.h("div", { class: "days-grid" }, days.map(day => {
|
|
985
|
-
const date = day.date;
|
|
986
|
-
if (!date)
|
|
987
|
-
return null;
|
|
988
|
-
const isSelected = this.selectionType === 'single' &&
|
|
989
|
-
this.isSameDate(date, this.selectedDate);
|
|
990
|
-
const isInRange = this.isDateInRange(date);
|
|
991
|
-
const isStart = this.isSameDate(date, this.startDate);
|
|
992
|
-
const isEnd = this.isSameDate(date, this.endDate);
|
|
993
|
-
const isToday = this.isToday(date);
|
|
994
|
-
const isOutsideMonth = !day.isCurrentMonth;
|
|
995
|
-
const dayClasses = [
|
|
996
|
-
'day',
|
|
997
|
-
isSelected ? 'selected' : '',
|
|
998
|
-
isStart ? 'range-start' : '',
|
|
999
|
-
isEnd ? 'range-end' : '',
|
|
1000
|
-
isInRange ? 'in-range' : '',
|
|
1001
|
-
day.isDisabled ? 'disabled' : '',
|
|
1002
|
-
isOutsideMonth ? 'outside-month' : '',
|
|
1003
|
-
isToday ? 'is-today' : '',
|
|
1004
|
-
];
|
|
1005
|
-
return (index.h("div", { class: dayClasses.filter(Boolean).join(' '), onClick: this.getDayClickHandler(date, day.isDisabled), "aria-disabled": day.isDisabled, key: `day-${date.toISOString()}` }, day.dayOfMonth));
|
|
1006
|
-
})));
|
|
987
|
+
get isUTCMode() {
|
|
988
|
+
return this.dateFormat.includes('Z');
|
|
1007
989
|
}
|
|
1008
990
|
/**
|
|
1009
|
-
*
|
|
1010
|
-
* @param {
|
|
1011
|
-
* @param {
|
|
1012
|
-
* @returns {
|
|
1013
|
-
* @description Renders the calendar of the calendar
|
|
991
|
+
* Validates and processes a date range, warning if start is after end
|
|
992
|
+
* @param {string} startDateStr - Start date in ISO string format
|
|
993
|
+
* @param {string} endDateStr - End date in ISO string format
|
|
994
|
+
* @returns {object} Object containing the validated start and end dates
|
|
1014
995
|
*/
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
996
|
+
validateDateRange(startDateStr, endDateStr) {
|
|
997
|
+
try {
|
|
998
|
+
const startDate = parseDate(startDateStr, this.dateFormat);
|
|
999
|
+
const endDate = parseDate(endDateStr, this.dateFormat);
|
|
1000
|
+
if (startDate && endDate && startDate > endDate) {
|
|
1001
|
+
console.warn(`Warning: startDate (${formatDate(startDate, {
|
|
1002
|
+
dateFormat: this.dateFormat,
|
|
1003
|
+
})}) is after endDate (${formatDate(endDate, {
|
|
1004
|
+
dateFormat: this.dateFormat,
|
|
1005
|
+
})})`);
|
|
1006
|
+
// Return dates in correct order, with swapped flag
|
|
1007
|
+
return {
|
|
1008
|
+
startDate: endDate,
|
|
1009
|
+
endDate: startDate,
|
|
1010
|
+
swapped: true,
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
return {
|
|
1014
|
+
startDate,
|
|
1015
|
+
endDate,
|
|
1016
|
+
swapped: false,
|
|
1017
|
+
};
|
|
1024
1018
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
* Renders the shortcuts
|
|
1029
|
-
* @returns {JSX.Element} Shortcuts
|
|
1030
|
-
* @description Renders the shortcuts of the calendar
|
|
1031
|
-
*/
|
|
1032
|
-
renderShortcuts() {
|
|
1033
|
-
if (!this.parsedShortcuts().length) {
|
|
1034
|
-
return null;
|
|
1019
|
+
catch (error) {
|
|
1020
|
+
console.error('Invalid date range:', error);
|
|
1021
|
+
throw error; // Re-throw to let the caller handle it
|
|
1035
1022
|
}
|
|
1036
|
-
return (index.h("div", { class: `shortcuts-container shortcuts-placement-${this.shortcutsPlacement}` }, this.parsedShortcuts().map(shortcut => (index.h("nv-button", { emphasis: "lower", size: "xs", "aria-label": shortcut.label, onClick: this.getShortcutHandler(shortcut) }, shortcut.label)))));
|
|
1037
|
-
}
|
|
1038
|
-
/**
|
|
1039
|
-
* Renders the actions
|
|
1040
|
-
* @returns {JSX.Element} Actions
|
|
1041
|
-
* @description Renders the actions of the calendar
|
|
1042
|
-
* @slot actions - Child content of the component.
|
|
1043
|
-
*/
|
|
1044
|
-
renderActions() {
|
|
1045
|
-
return (index.h("div", { class: "datepicker-actions" }, index.h("slot", { name: "actions" }, index.h("nv-button", { emphasis: "low", size: "xs", onClick: this.resetSelection }, "Cancel"), index.h("nv-button", { size: "xs", onClick: this.confirmSelection }, "OK"))));
|
|
1046
1023
|
}
|
|
1047
1024
|
/**
|
|
1048
1025
|
* Renders the datepicker
|
|
@@ -1051,7 +1028,8 @@ const NvCalendar = class {
|
|
|
1051
1028
|
* @slot default - Child content of the component.
|
|
1052
1029
|
*/
|
|
1053
1030
|
render() {
|
|
1054
|
-
return (index.h(index.Host, { key: '
|
|
1031
|
+
return (index.h(index.Host, { key: '9804c486acf32e12f2d88f932a54ca6260365887' }, index.h("div", { key: '8503f585401191b904f2de248ed0c24b1fed1505', class: "datepicker-root" }, index.h("div", { key: '9da71618bd2031b44f5a3fd889d40b2580fcca58', class: `datepicker-container ${this.numberOfCalendars === 1 ? 'datepicker-container-single' : ''}` }, index.h("div", { key: 'fbf71a34b520ca48f1440d8caeec442773b1e57a', class: `datepicker-wrapper ${this.numberOfCalendars === 1 ? 'single' : ''}` }, this.shortcutsPlacement === 'left' && this.renderShortcuts(), Array.from({ length: this.numberOfCalendars }, (_, index) => this.renderCalendar(index, index)), this.shortcutsPlacement === 'right' && this.renderShortcuts()), ((this.hasShortcuts && this.shortcutsPlacement === 'bottom') ||
|
|
1032
|
+
this.hasActions) && (index.h("div", { key: '4431e3f1221e9d47807d58af380dcaa91bf05c48', class: "datepicker-controls" }, this.shortcutsPlacement === 'bottom' && this.renderShortcuts(), this.hasActions && this.renderActions())))), index.h("slot", { key: '30386356bda72f4f12a28351084ab498ec95f5b9' })));
|
|
1055
1033
|
}
|
|
1056
1034
|
get el() { return index.getElement(this); }
|
|
1057
1035
|
static get watchers() { return {
|