@nova-design-system/nova-webcomponents 3.18.0-beta.0 → 3.19.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/index.cjs.js +33 -2
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/native.cjs.js +1 -1
- package/dist/cjs/nv-badge_2.cjs.entry.js +1 -1
- package/dist/cjs/nv-fielddate.cjs.entry.js +10 -6
- package/dist/cjs/nv-fielddate.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fielddaterange.cjs.entry.js +11 -7
- package/dist/cjs/nv-fielddaterange.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fielddropdown.cjs.entry.js +193 -209
- package/dist/cjs/nv-fielddropdown.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fielddropdownitem.cjs.entry.js +7 -4
- package/dist/cjs/nv-fielddropdownitem.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldmultiselect.cjs.entry.js +4 -0
- package/dist/cjs/nv-fieldmultiselect.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldnumber.cjs.entry.js +3 -3
- package/dist/cjs/nv-fieldpassword.cjs.entry.js +3 -3
- package/dist/cjs/nv-fieldradio.cjs.entry.js +3 -3
- package/dist/cjs/nv-fieldselect.cjs.entry.js +5 -5
- package/dist/cjs/nv-fieldslider.cjs.entry.js +3 -3
- package/dist/cjs/nv-fieldtext.cjs.entry.js +3 -3
- package/dist/cjs/nv-fieldtextarea.cjs.entry.js +3 -3
- package/dist/cjs/nv-fieldtime.cjs.entry.js +557 -496
- package/dist/cjs/nv-fieldtime.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-icon.cjs.entry.js +2 -2
- package/dist/cjs/nv-icon.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-iconbutton_2.cjs.entry.js +2 -2
- package/dist/cjs/nv-menu.cjs.entry.js +2 -2
- package/dist/cjs/nv-menu.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-menuitem.cjs.entry.js +1 -1
- package/dist/cjs/nv-notification.cjs.entry.js +1 -1
- package/dist/cjs/nv-notificationcontainer.cjs.entry.js +1 -1
- package/dist/cjs/nv-popover.cjs.entry.js +2 -2
- package/dist/cjs/nv-popover.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-row.cjs.entry.js +1 -1
- package/dist/cjs/nv-split.cjs.entry.js +1 -1
- package/dist/cjs/nv-stack.cjs.entry.js +1 -1
- package/dist/cjs/nv-table.cjs.entry.js +1 -1
- package/dist/cjs/nv-toggle.cjs.entry.js +2 -2
- package/dist/cjs/nv-togglebutton.cjs.entry.js +1 -1
- package/dist/cjs/nv-togglebuttongroup.cjs.entry.js +1 -1
- package/dist/cjs/nv-tooltip.cjs.entry.js +1 -1
- package/dist/collection/components/nv-fielddate/nv-fielddate.js +10 -6
- package/dist/collection/components/nv-fielddate/nv-fielddate.js.map +1 -1
- package/dist/collection/components/nv-fielddaterange/nv-fielddaterange.js +10 -6
- package/dist/collection/components/nv-fielddaterange/nv-fielddaterange.js.map +1 -1
- package/dist/collection/components/nv-fielddaterange/styles/nv-fielddaterange.css +2 -0
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.docs.js +31 -13
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.docs.js.map +1 -1
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.js +310 -245
- package/dist/collection/components/nv-fielddropdown/nv-fielddropdown.js.map +1 -1
- package/dist/collection/components/nv-fielddropdownitem/nv-fielddropdownitem.js +29 -6
- package/dist/collection/components/nv-fielddropdownitem/nv-fielddropdownitem.js.map +1 -1
- package/dist/collection/components/nv-fielddropdownitemcheck/nv-fielddropdownitemcheck.js +1 -1
- package/dist/collection/components/nv-fieldmultiselect/nv-fieldmultiselect.js +4 -0
- package/dist/collection/components/nv-fieldmultiselect/nv-fieldmultiselect.js.map +1 -1
- package/dist/collection/components/nv-fieldnumber/nv-fieldnumber.js +3 -3
- package/dist/collection/components/nv-fieldpassword/nv-fieldpassword.js +3 -3
- package/dist/collection/components/nv-fieldradio/nv-fieldradio.js +3 -3
- package/dist/collection/components/nv-fieldselect/nv-fieldselect.js +5 -5
- package/dist/collection/components/nv-fieldslider/nv-fieldslider.js +3 -3
- package/dist/collection/components/nv-fieldtext/nv-fieldtext.js +3 -3
- package/dist/collection/components/nv-fieldtextarea/nv-fieldtextarea.js +3 -3
- package/dist/collection/components/nv-fieldtime/nv-fieldtime.docs.js +6 -0
- package/dist/collection/components/nv-fieldtime/nv-fieldtime.docs.js.map +1 -1
- package/dist/collection/components/nv-fieldtime/nv-fieldtime.js +332 -497
- package/dist/collection/components/nv-fieldtime/nv-fieldtime.js.map +1 -1
- package/dist/collection/components/nv-fieldtime/styles/nv-fieldtime.css +1 -0
- package/dist/collection/components/nv-fieldtime/utils/format-utils.js +236 -0
- package/dist/collection/components/nv-fieldtime/utils/format-utils.js.map +1 -0
- package/dist/collection/components/nv-icon/nv-icon.js +1 -1
- package/dist/collection/components/nv-icon/nv-icons.js +13 -0
- 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 -3
- 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-notification/nv-notification.js +1 -1
- package/dist/collection/components/nv-notificationcontainer/nv-notificationcontainer.js +1 -1
- package/dist/collection/components/nv-popover/nv-popover.js +2 -2
- package/dist/collection/components/nv-popover/nv-popover.js.map +1 -1
- package/dist/collection/components/nv-row/nv-row.js +1 -1
- package/dist/collection/components/nv-split/nv-split.js +1 -1
- package/dist/collection/components/nv-stack/nv-stack.js +1 -1
- package/dist/collection/components/nv-table/nv-table.js +1 -1
- package/dist/collection/components/nv-toggle/nv-toggle.js +2 -2
- package/dist/collection/components/nv-togglebutton/nv-togglebutton.js +1 -1
- package/dist/collection/components/nv-togglebuttongroup/nv-togglebuttongroup.js +1 -1
- package/dist/collection/components/nv-tooltip/nv-tooltip.js +1 -1
- package/dist/components/index.js +33 -2
- package/dist/components/index.js.map +1 -1
- package/dist/components/nv-accordion-item.js +1 -1
- package/dist/components/nv-accordion.js +4 -4
- package/dist/components/nv-alert.js +1 -1
- package/dist/components/nv-avatar.js +1 -1
- package/dist/components/nv-badge.js +1 -1
- package/dist/components/nv-breadcrumb.js +2 -2
- package/dist/components/nv-button.js +1 -1
- package/dist/components/nv-datagrid.js +2 -2
- package/dist/components/nv-dialog.js +4 -4
- package/dist/components/nv-dialogfooter.js +1 -1
- package/dist/components/nv-fielddate.js +14 -10
- package/dist/components/nv-fielddate.js.map +1 -1
- package/dist/components/nv-fielddaterange.js +15 -11
- package/dist/components/nv-fielddaterange.js.map +1 -1
- package/dist/components/nv-fielddropdown.js +207 -220
- 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 +10 -6
- package/dist/components/nv-fieldmultiselect.js.map +1 -1
- package/dist/components/nv-fieldnumber.js +1 -1
- package/dist/components/nv-fieldpassword.js +6 -6
- package/dist/components/nv-fieldradio.js +3 -3
- package/dist/components/nv-fieldselect.js +8 -8
- package/dist/components/nv-fieldslider.js +7 -7
- package/dist/components/nv-fieldtext.js +1 -1
- package/dist/components/nv-fieldtextarea.js +3 -3
- package/dist/components/nv-fieldtime.js +563 -501
- 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 +5 -5
- package/dist/components/nv-menu.js.map +1 -1
- package/dist/components/nv-menuitem.js +1 -1
- package/dist/components/nv-notification.js +2 -2
- package/dist/components/nv-notificationcontainer.js +1 -1
- package/dist/components/nv-popover.js +1 -1
- package/dist/components/nv-row.js +1 -1
- package/dist/components/nv-split.js +1 -1
- package/dist/components/nv-stack.js +1 -1
- package/dist/components/nv-table.js +1 -1
- package/dist/components/nv-toggle.js +2 -2
- package/dist/components/nv-togglebutton.js +1 -1
- package/dist/components/nv-togglebuttongroup.js +1 -1
- package/dist/components/nv-tooltip.js +1 -1
- package/dist/components/{p-811c9225.js → p-18f50d91.js} +2 -2
- package/dist/components/{p-811c9225.js.map → p-18f50d91.js.map} +1 -1
- package/dist/components/{p-98429fd7.js → p-222136c2.js} +2 -2
- package/dist/components/{p-98429fd7.js.map → p-222136c2.js.map} +1 -1
- package/dist/components/{p-ec31af69.js → p-2ac6f42d.js} +3 -3
- package/dist/components/{p-ec31af69.js.map → p-2ac6f42d.js.map} +1 -1
- package/dist/components/{p-47a33f6b.js → p-334e19d3.js} +4 -4
- package/dist/components/{p-47a33f6b.js.map → p-334e19d3.js.map} +1 -1
- package/dist/components/{p-766a3f49.js → p-45a3cf85.js} +11 -7
- package/dist/components/p-45a3cf85.js.map +1 -0
- package/dist/components/{p-63595ea1.js → p-4799b6c3.js} +3 -3
- package/dist/components/p-4799b6c3.js.map +1 -0
- package/dist/components/{p-6e67bfc0.js → p-49205084.js} +5 -5
- package/dist/components/{p-6e67bfc0.js.map → p-49205084.js.map} +1 -1
- package/dist/components/{p-7684ad27.js → p-5a5db065.js} +4 -4
- package/dist/components/{p-7684ad27.js.map → p-5a5db065.js.map} +1 -1
- package/dist/components/{p-e43a36c4.js → p-60083982.js} +4 -4
- package/dist/components/{p-e43a36c4.js.map → p-60083982.js.map} +1 -1
- package/dist/components/{p-6f2b257e.js → p-81d915ef.js} +3 -3
- package/dist/components/{p-6f2b257e.js.map → p-81d915ef.js.map} +1 -1
- package/dist/components/p-946a047c.js +88 -0
- package/dist/components/p-946a047c.js.map +1 -0
- package/dist/components/{p-715e5235.js → p-a6c29711.js} +2 -2
- package/dist/components/{p-715e5235.js.map → p-a6c29711.js.map} +1 -1
- package/dist/components/{p-147cefeb.js → p-e0eb748c.js} +7 -7
- package/dist/components/{p-147cefeb.js.map → p-e0eb748c.js.map} +1 -1
- package/dist/components/{p-9e7468e3.js → p-e1b2eba2.js} +2 -2
- package/dist/components/{p-9e7468e3.js.map → p-e1b2eba2.js.map} +1 -1
- package/dist/esm/index.js +33 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/native.js +1 -1
- package/dist/esm/nv-badge_2.entry.js +1 -1
- package/dist/esm/nv-fielddate.entry.js +10 -6
- package/dist/esm/nv-fielddate.entry.js.map +1 -1
- package/dist/esm/nv-fielddaterange.entry.js +11 -7
- package/dist/esm/nv-fielddaterange.entry.js.map +1 -1
- package/dist/esm/nv-fielddropdown.entry.js +193 -209
- package/dist/esm/nv-fielddropdown.entry.js.map +1 -1
- package/dist/esm/nv-fielddropdownitem.entry.js +7 -4
- package/dist/esm/nv-fielddropdownitem.entry.js.map +1 -1
- package/dist/esm/nv-fieldmultiselect.entry.js +4 -0
- package/dist/esm/nv-fieldmultiselect.entry.js.map +1 -1
- package/dist/esm/nv-fieldnumber.entry.js +3 -3
- package/dist/esm/nv-fieldpassword.entry.js +3 -3
- package/dist/esm/nv-fieldradio.entry.js +3 -3
- package/dist/esm/nv-fieldselect.entry.js +5 -5
- package/dist/esm/nv-fieldslider.entry.js +3 -3
- package/dist/esm/nv-fieldtext.entry.js +3 -3
- package/dist/esm/nv-fieldtextarea.entry.js +3 -3
- package/dist/esm/nv-fieldtime.entry.js +558 -497
- package/dist/esm/nv-fieldtime.entry.js.map +1 -1
- package/dist/esm/nv-icon.entry.js +2 -2
- package/dist/esm/nv-icon.entry.js.map +1 -1
- package/dist/esm/nv-iconbutton_2.entry.js +2 -2
- package/dist/esm/nv-menu.entry.js +2 -2
- package/dist/esm/nv-menu.entry.js.map +1 -1
- package/dist/esm/nv-menuitem.entry.js +1 -1
- package/dist/esm/nv-notification.entry.js +1 -1
- package/dist/esm/nv-notificationcontainer.entry.js +1 -1
- package/dist/esm/nv-popover.entry.js +2 -2
- package/dist/esm/nv-popover.entry.js.map +1 -1
- package/dist/esm/nv-row.entry.js +1 -1
- package/dist/esm/nv-split.entry.js +1 -1
- package/dist/esm/nv-stack.entry.js +1 -1
- package/dist/esm/nv-table.entry.js +1 -1
- package/dist/esm/nv-toggle.entry.js +2 -2
- package/dist/esm/nv-togglebutton.entry.js +1 -1
- package/dist/esm/nv-togglebuttongroup.entry.js +1 -1
- package/dist/esm/nv-tooltip.entry.js +1 -1
- package/dist/native/index.esm.js +1 -1
- package/dist/native/index.esm.js.map +1 -1
- package/dist/native/native.esm.js +1 -1
- package/dist/native/native.esm.js.map +1 -1
- package/dist/native/{p-acada158.entry.js → p-0177409b.entry.js} +2 -2
- package/dist/native/{p-91fab6c2.entry.js → p-075d231e.entry.js} +2 -2
- package/dist/native/{p-d878e90a.entry.js → p-144d0f8a.entry.js} +2 -2
- package/dist/native/p-144d0f8a.entry.js.map +1 -0
- package/dist/native/{p-b4c15f25.entry.js → p-17666092.entry.js} +2 -2
- package/dist/native/{p-107e80c6.entry.js → p-218135b1.entry.js} +2 -2
- package/dist/native/p-218135b1.entry.js.map +1 -0
- package/dist/native/p-2a7f80f4.entry.js +2 -0
- package/dist/native/p-2a7f80f4.entry.js.map +1 -0
- package/dist/native/{p-14e622e1.entry.js → p-445221dc.entry.js} +2 -2
- package/dist/native/{p-52d2c0ae.entry.js → p-44a78545.entry.js} +2 -2
- package/dist/native/p-57420a2f.entry.js +2 -0
- package/dist/native/{p-2364aefa.entry.js → p-587d94f3.entry.js} +2 -2
- package/dist/native/{p-95184ea2.entry.js → p-6a418ec4.entry.js} +2 -2
- package/dist/native/{p-5039ceb8.entry.js → p-859bf9ad.entry.js} +2 -2
- package/dist/native/{p-5039ceb8.entry.js.map → p-859bf9ad.entry.js.map} +1 -1
- package/dist/native/{p-9d7e099f.entry.js → p-9950e075.entry.js} +2 -2
- package/dist/native/{p-2dfd786f.entry.js → p-9c432751.entry.js} +2 -2
- package/dist/native/p-a026654f.entry.js +2 -0
- package/dist/native/p-a026654f.entry.js.map +1 -0
- package/dist/native/{p-638967bf.entry.js → p-a2f58133.entry.js} +2 -2
- package/dist/native/{p-d94bf052.entry.js → p-b02c896a.entry.js} +2 -2
- package/dist/native/{p-9613087c.entry.js → p-b4382c94.entry.js} +2 -2
- package/dist/native/{p-835abdb9.entry.js → p-b626ef47.entry.js} +2 -2
- package/dist/native/{p-23ee0384.entry.js → p-c0de4bb0.entry.js} +2 -2
- package/dist/native/{p-278613a3.entry.js → p-c9fea0df.entry.js} +2 -2
- package/dist/native/{p-278613a3.entry.js.map → p-c9fea0df.entry.js.map} +1 -1
- package/dist/native/{p-ce97ce24.entry.js → p-d62869ff.entry.js} +2 -2
- package/dist/native/p-d63689da.entry.js +2 -0
- package/dist/native/p-d63689da.entry.js.map +1 -0
- package/dist/native/p-d8f3cf92.entry.js +2 -0
- package/dist/native/p-d8f3cf92.entry.js.map +1 -0
- package/dist/native/{p-cb0293ec.entry.js → p-dfb6b65e.entry.js} +2 -2
- package/dist/native/{p-230af58a.entry.js → p-e6f24210.entry.js} +2 -2
- package/dist/native/p-e6f24210.entry.js.map +1 -0
- package/dist/native/{p-647a0765.entry.js → p-eb74feb7.entry.js} +2 -2
- package/dist/native/{p-6d427897.entry.js → p-fa3e588e.entry.js} +2 -2
- package/dist/native/{p-112d096c.entry.js → p-fffbd3c1.entry.js} +2 -2
- package/dist/types/components/nv-fielddropdown/nv-fielddropdown.d.ts +54 -35
- package/dist/types/components/nv-fielddropdownitem/nv-fielddropdownitem.d.ts +7 -0
- package/dist/types/components/nv-fieldtime/nv-fieldtime.d.ts +50 -2
- package/dist/types/components/nv-fieldtime/utils/format-utils.d.ts +63 -0
- package/dist/types/components/nv-icon/nv-icons.d.ts +1 -1
- package/dist/types/components.d.ts +79 -16
- package/dist/vscode-data.json +52 -5
- package/hydrate/index.js +843 -791
- package/hydrate/index.mjs +843 -791
- package/package.json +1 -1
- package/dist/cjs/string.utils-9c581350.js +0 -25
- package/dist/cjs/string.utils-9c581350.js.map +0 -1
- package/dist/components/p-63595ea1.js.map +0 -1
- package/dist/components/p-766a3f49.js.map +0 -1
- package/dist/components/p-a5c8eee9.js +0 -22
- package/dist/components/p-a5c8eee9.js.map +0 -1
- package/dist/components/p-be6e2884.js +0 -88
- package/dist/components/p-be6e2884.js.map +0 -1
- package/dist/esm/string.utils-16aed4a7.js +0 -22
- package/dist/esm/string.utils-16aed4a7.js.map +0 -1
- package/dist/native/p-107e80c6.entry.js.map +0 -1
- package/dist/native/p-230af58a.entry.js.map +0 -1
- package/dist/native/p-74572fce.entry.js +0 -2
- package/dist/native/p-74572fce.entry.js.map +0 -1
- package/dist/native/p-a5c8eee9.js +0 -2
- package/dist/native/p-a5c8eee9.js.map +0 -1
- package/dist/native/p-bcf41cd0.entry.js +0 -2
- package/dist/native/p-d7f444fb.entry.js +0 -2
- package/dist/native/p-d7f444fb.entry.js.map +0 -1
- package/dist/native/p-d878e90a.entry.js.map +0 -1
- package/dist/native/p-ddc41f1f.entry.js +0 -2
- package/dist/native/p-ddc41f1f.entry.js.map +0 -1
- package/dist/native/p-f30e0be6.entry.js +0 -2
- package/dist/native/p-f30e0be6.entry.js.map +0 -1
- /package/dist/native/{p-acada158.entry.js.map → p-0177409b.entry.js.map} +0 -0
- /package/dist/native/{p-91fab6c2.entry.js.map → p-075d231e.entry.js.map} +0 -0
- /package/dist/native/{p-b4c15f25.entry.js.map → p-17666092.entry.js.map} +0 -0
- /package/dist/native/{p-14e622e1.entry.js.map → p-445221dc.entry.js.map} +0 -0
- /package/dist/native/{p-52d2c0ae.entry.js.map → p-44a78545.entry.js.map} +0 -0
- /package/dist/native/{p-bcf41cd0.entry.js.map → p-57420a2f.entry.js.map} +0 -0
- /package/dist/native/{p-2364aefa.entry.js.map → p-587d94f3.entry.js.map} +0 -0
- /package/dist/native/{p-95184ea2.entry.js.map → p-6a418ec4.entry.js.map} +0 -0
- /package/dist/native/{p-9d7e099f.entry.js.map → p-9950e075.entry.js.map} +0 -0
- /package/dist/native/{p-2dfd786f.entry.js.map → p-9c432751.entry.js.map} +0 -0
- /package/dist/native/{p-638967bf.entry.js.map → p-a2f58133.entry.js.map} +0 -0
- /package/dist/native/{p-d94bf052.entry.js.map → p-b02c896a.entry.js.map} +0 -0
- /package/dist/native/{p-9613087c.entry.js.map → p-b4382c94.entry.js.map} +0 -0
- /package/dist/native/{p-835abdb9.entry.js.map → p-b626ef47.entry.js.map} +0 -0
- /package/dist/native/{p-23ee0384.entry.js.map → p-c0de4bb0.entry.js.map} +0 -0
- /package/dist/native/{p-ce97ce24.entry.js.map → p-d62869ff.entry.js.map} +0 -0
- /package/dist/native/{p-cb0293ec.entry.js.map → p-dfb6b65e.entry.js.map} +0 -0
- /package/dist/native/{p-647a0765.entry.js.map → p-eb74feb7.entry.js.map} +0 -0
- /package/dist/native/{p-6d427897.entry.js.map → p-fa3e588e.entry.js.map} +0 -0
- /package/dist/native/{p-112d096c.entry.js.map → p-fffbd3c1.entry.js.map} +0 -0
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/* eslint-disable react/jsx-no-bind */
|
|
2
|
-
import { Host, h, } from "@stencil/core";
|
|
2
|
+
import { Host, h, forceUpdate, } from "@stencil/core";
|
|
3
3
|
import { v4 as uuidv4 } from "uuid";
|
|
4
|
-
import { startsWithIgnoreCase } from "../../utils/string.utils";
|
|
5
4
|
import { TimeType } from "../../utils/constants";
|
|
5
|
+
import { parseValueByFormat, reconstructTimeByFormat, isValidFormatValue, FORMAT_CONFIGS, getVisibleTimeTypes, } from "./utils/format-utils";
|
|
6
6
|
/**
|
|
7
|
+
* A format-aware time input component that displays only relevant input fields based on the specified format.
|
|
8
|
+
* The component ensures consistency between the format property and both input validation and value emission.
|
|
9
|
+
*
|
|
7
10
|
* @slot label - Content to be placed as the label, will override the label prop.
|
|
8
11
|
* @slot before-input - Content to be placed before the input text, outside the input container.
|
|
9
12
|
* @slot after-input - Content to be placed after the input text, outside the input container.
|
|
@@ -66,6 +69,10 @@ export class NvFieldtime {
|
|
|
66
69
|
* - hh: 12-hour format (01-12)
|
|
67
70
|
* - hh:mm: 12-hour format with minutes (01:00-12:59)
|
|
68
71
|
* - hh:mm:ss: 12-hour format with minutes and seconds (01:00:00-12:59:59)
|
|
72
|
+
*
|
|
73
|
+
* The component automatically shows only the relevant input fields based on the selected format.
|
|
74
|
+
* When the format changes dynamically, the component re-parses the current value and updates
|
|
75
|
+
* the visible fields accordingly.
|
|
69
76
|
*/
|
|
70
77
|
this.format = 'HH:mm:ss';
|
|
71
78
|
/**
|
|
@@ -94,7 +101,7 @@ export class NvFieldtime {
|
|
|
94
101
|
this.open = event.detail;
|
|
95
102
|
}
|
|
96
103
|
handleKeyDown(event) {
|
|
97
|
-
var _a, _b
|
|
104
|
+
var _a, _b;
|
|
98
105
|
if (!this.open) {
|
|
99
106
|
if (event.key === 'ArrowDown') {
|
|
100
107
|
this.open = true;
|
|
@@ -129,27 +136,42 @@ export class NvFieldtime {
|
|
|
129
136
|
else if (event.key === 'Enter' && currentIndex >= 0) {
|
|
130
137
|
event.preventDefault();
|
|
131
138
|
items[currentIndex].click();
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
(
|
|
139
|
-
(
|
|
139
|
+
// Navigate to the next visible field
|
|
140
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
141
|
+
const currentTypeIndex = visibleTypes.indexOf(this.typeFocused);
|
|
142
|
+
const nextTypeIndex = currentTypeIndex + 1;
|
|
143
|
+
if (nextTypeIndex < visibleTypes.length) {
|
|
144
|
+
const nextType = visibleTypes[nextTypeIndex];
|
|
145
|
+
(_a = this.inputElements[nextType]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
146
|
+
(_b = this.inputElements[nextType]) === null || _b === void 0 ? void 0 : _b.select();
|
|
140
147
|
}
|
|
141
148
|
}
|
|
142
149
|
else if (event.key === 'Escape') {
|
|
143
150
|
event.preventDefault();
|
|
144
|
-
|
|
145
|
-
|
|
151
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
152
|
+
const firstVisibleType = visibleTypes[0];
|
|
153
|
+
if (firstVisibleType && this.inputElements[firstVisibleType]) {
|
|
154
|
+
this.inputElements[firstVisibleType].blur();
|
|
146
155
|
}
|
|
156
|
+
this.open = false;
|
|
147
157
|
}
|
|
148
158
|
}
|
|
149
159
|
//#endregion LISTENERS
|
|
150
160
|
/****************************************************************************/
|
|
151
161
|
//#region WATCHERS
|
|
152
162
|
handleValueChange(newValue) {
|
|
163
|
+
// Parse the new value and ensure it's in the correct format
|
|
164
|
+
if (newValue) {
|
|
165
|
+
const components = parseValueByFormat(newValue, this.format);
|
|
166
|
+
const formattedValue = reconstructTimeByFormat(components, this.format);
|
|
167
|
+
// Only emit if the formatted value is different from what we received
|
|
168
|
+
// This prevents infinite loops while ensuring format consistency
|
|
169
|
+
if (formattedValue !== newValue) {
|
|
170
|
+
this.value = formattedValue;
|
|
171
|
+
return; // The watcher will be called again with the formatted value
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Emit the value in the correct format
|
|
153
175
|
this.valueChanged.emit(newValue);
|
|
154
176
|
}
|
|
155
177
|
handleOpenChange(newOpen) {
|
|
@@ -164,12 +186,36 @@ export class NvFieldtime {
|
|
|
164
186
|
this.updateColumnHighlight(secondsSelector, this.seconds);
|
|
165
187
|
}
|
|
166
188
|
}
|
|
189
|
+
handleFormatChange(newFormat, oldFormat) {
|
|
190
|
+
if (newFormat === oldFormat) {
|
|
191
|
+
return; // No change, nothing to do
|
|
192
|
+
}
|
|
193
|
+
// Re-parse the current value with the new format
|
|
194
|
+
const currentValue = this.value || this.reconstructTime();
|
|
195
|
+
// Parse the current value using the old format to get the time components
|
|
196
|
+
const components = parseValueByFormat(currentValue, oldFormat || 'HH:mm:ss');
|
|
197
|
+
// Update the component state with the parsed components
|
|
198
|
+
this.hours = components.hours;
|
|
199
|
+
this.minutes = components.minutes;
|
|
200
|
+
this.seconds = components.seconds;
|
|
201
|
+
// Reconstruct the time value in the new format
|
|
202
|
+
const newValue = reconstructTimeByFormat(components, newFormat);
|
|
203
|
+
// Update the value, which will trigger the value watcher and emit the event
|
|
204
|
+
this.value = newValue;
|
|
205
|
+
// Force a re-render to update the visible input fields
|
|
206
|
+
forceUpdate(this.el);
|
|
207
|
+
}
|
|
167
208
|
//#endregion WATCHERS
|
|
168
209
|
/****************************************************************************/
|
|
169
210
|
//#region METHODS
|
|
170
211
|
handleInputChange(e, type) {
|
|
171
212
|
const inputElement = e.target;
|
|
172
213
|
const inputValue = inputElement.value.replace(/[^0-9]/g, ''); // Only keep numeric input
|
|
214
|
+
// Check if this field is visible for the current format
|
|
215
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
216
|
+
if (!visibleTypes.includes(type)) {
|
|
217
|
+
return; // Don't process input for non-visible fields
|
|
218
|
+
}
|
|
173
219
|
// Update the time value based on the type
|
|
174
220
|
switch (type) {
|
|
175
221
|
case TimeType.Hours:
|
|
@@ -182,489 +228,230 @@ export class NvFieldtime {
|
|
|
182
228
|
this.handleSecondsChange(inputValue, type);
|
|
183
229
|
break;
|
|
184
230
|
}
|
|
185
|
-
// Reconstruct time from inputs
|
|
186
|
-
const
|
|
187
|
-
|
|
231
|
+
// Reconstruct time from inputs in the correct format
|
|
232
|
+
const reconstructedValue = this.reconstructTime();
|
|
233
|
+
// Update the value, which will trigger the watcher and emit the event
|
|
234
|
+
this.value = reconstructedValue;
|
|
188
235
|
}
|
|
189
236
|
handleHoursChange(inputValue, type) {
|
|
190
|
-
var _a, _b
|
|
237
|
+
var _a, _b;
|
|
191
238
|
const isHHFormat = this.format.startsWith('HH');
|
|
192
239
|
const maxHours = isHHFormat ? 24 : 12;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
240
|
+
// Handle empty input
|
|
241
|
+
if (inputValue.length === 0) {
|
|
242
|
+
this.hours = '00';
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
197
245
|
if (inputValue.length === 1) {
|
|
198
246
|
this.inputZeroAdded[type] = true;
|
|
199
247
|
const newInputValue = inputValue.padStart(2, '0');
|
|
200
|
-
|
|
201
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
202
|
-
this.hours = minHour;
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
this.hours = '00';
|
|
206
|
-
reputedToZero = true;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
211
|
-
this.hours = minHour;
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
this.hours = newInputValue;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
248
|
+
this.hours = newInputValue;
|
|
217
249
|
}
|
|
218
250
|
else if (this.inputZeroAdded[type]) {
|
|
219
251
|
this.inputZeroAdded[type] = false;
|
|
220
252
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
221
253
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
254
|
+
// Only apply format validation (not min/max constraints)
|
|
222
255
|
if (parsedNewInputValue >= maxHours) {
|
|
223
|
-
|
|
224
|
-
this.hours = minHour;
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
this.hours = '00';
|
|
228
|
-
reputedToZero = true;
|
|
229
|
-
}
|
|
256
|
+
this.hours = '00';
|
|
230
257
|
}
|
|
231
258
|
else {
|
|
232
|
-
|
|
233
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
234
|
-
this.hours = minHour;
|
|
235
|
-
}
|
|
236
|
-
else {
|
|
237
|
-
this.hours = '00';
|
|
238
|
-
reputedToZero = true;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
243
|
-
this.hours = minHour;
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
this.hours = newInputValue;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
259
|
+
this.hours = newInputValue;
|
|
249
260
|
}
|
|
250
261
|
}
|
|
251
262
|
else if (inputValue.length > 2) {
|
|
252
263
|
if (inputValue.startsWith('00')) {
|
|
253
264
|
this.inputZeroAdded[type] = true;
|
|
254
265
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
255
|
-
|
|
256
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
257
|
-
this.hours = minHour;
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
this.hours = '00';
|
|
261
|
-
reputedToZero = true;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
266
|
-
this.hours = minHour;
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
this.hours = newInputValue;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
266
|
+
this.hours = newInputValue;
|
|
272
267
|
}
|
|
273
268
|
else {
|
|
274
269
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
275
270
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
271
|
+
// Only apply format validation (not min/max constraints)
|
|
276
272
|
if (parsedNewInputValue >= maxHours) {
|
|
277
|
-
|
|
278
|
-
this.hours = minHour;
|
|
279
|
-
reputedToZero = true;
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
this.hours = '00';
|
|
283
|
-
reputedToZero = true;
|
|
284
|
-
}
|
|
273
|
+
this.hours = '00';
|
|
285
274
|
}
|
|
286
275
|
else {
|
|
287
|
-
|
|
288
|
-
if (minHour &&
|
|
289
|
-
parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
290
|
-
this.hours = minHour;
|
|
291
|
-
}
|
|
292
|
-
else {
|
|
293
|
-
this.hours = '00';
|
|
294
|
-
reputedToZero = true;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
if (minHour && parsedNewInputValue < parseInt(minHour, 10)) {
|
|
299
|
-
this.hours = minHour;
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
this.hours = parsedNewInputValue.toString();
|
|
303
|
-
}
|
|
304
|
-
}
|
|
276
|
+
this.hours = parsedNewInputValue.toString();
|
|
305
277
|
}
|
|
306
278
|
}
|
|
307
279
|
}
|
|
308
280
|
else {
|
|
309
|
-
const
|
|
310
|
-
|
|
281
|
+
const parsedNewInputValue = parseInt(inputValue, 10) || 0;
|
|
282
|
+
// Only apply format validation (not min/max constraints)
|
|
311
283
|
if (parsedNewInputValue >= maxHours) {
|
|
312
|
-
|
|
313
|
-
this.hours = minHour;
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
this.hours = '00';
|
|
317
|
-
reputedToZero = true;
|
|
318
|
-
}
|
|
284
|
+
this.hours = '00';
|
|
319
285
|
}
|
|
320
286
|
else {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
reputedToZero = true;
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
if (minHour && parsedNewInputValue < parseInt(minHour, 10)) {
|
|
327
|
-
this.hours = minHour;
|
|
328
|
-
}
|
|
329
|
-
else {
|
|
330
|
-
this.hours = parsedNewInputValue.toString();
|
|
331
|
-
}
|
|
332
|
-
}
|
|
287
|
+
// For direct input, remove unnecessary leading zeros (e.g., '01' becomes '1')
|
|
288
|
+
this.hours = parsedNewInputValue.toString();
|
|
333
289
|
}
|
|
334
290
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
291
|
+
// Auto-navigation to next field when input is complete
|
|
292
|
+
if (this.hours.length >= 1 && !this.inputZeroAdded[type]) {
|
|
293
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
294
|
+
const currentTypeIndex = visibleTypes.indexOf(TimeType.Hours);
|
|
295
|
+
const nextTypeIndex = currentTypeIndex + 1;
|
|
296
|
+
if (nextTypeIndex < visibleTypes.length) {
|
|
297
|
+
const nextType = visibleTypes[nextTypeIndex];
|
|
298
|
+
(_a = this.inputElements[nextType]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
299
|
+
(_b = this.inputElements[nextType]) === null || _b === void 0 ? void 0 : _b.select();
|
|
300
|
+
}
|
|
344
301
|
}
|
|
345
302
|
}
|
|
346
303
|
handleMinutesChange(inputValue, type) {
|
|
347
|
-
var _a, _b
|
|
304
|
+
var _a, _b;
|
|
348
305
|
const maxMinutes = 60;
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
306
|
+
// Handle empty input
|
|
307
|
+
if (inputValue.length === 0) {
|
|
308
|
+
this.minutes = '00';
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
352
311
|
if (inputValue.length === 1) {
|
|
353
312
|
this.inputZeroAdded[type] = true;
|
|
354
313
|
const newInputValue = inputValue.padStart(2, '0');
|
|
355
|
-
|
|
356
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
357
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
this.minutes = '00';
|
|
361
|
-
reputedToZero = true;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
else {
|
|
365
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
366
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
this.minutes = newInputValue;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
314
|
+
this.minutes = newInputValue;
|
|
372
315
|
}
|
|
373
316
|
else if (this.inputZeroAdded[type]) {
|
|
374
317
|
this.inputZeroAdded[type] = false;
|
|
375
318
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
376
319
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
320
|
+
// Only apply format validation (not min/max constraints)
|
|
377
321
|
if (parsedNewInputValue >= maxMinutes) {
|
|
378
|
-
|
|
379
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
380
|
-
}
|
|
381
|
-
else {
|
|
382
|
-
this.minutes = '00';
|
|
383
|
-
reputedToZero = true;
|
|
384
|
-
}
|
|
322
|
+
this.minutes = '00';
|
|
385
323
|
}
|
|
386
324
|
else {
|
|
387
|
-
|
|
388
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
389
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
390
|
-
}
|
|
391
|
-
else {
|
|
392
|
-
this.minutes = '00';
|
|
393
|
-
reputedToZero = true;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
else {
|
|
397
|
-
if (minMinute && parsedNewInputValue < minMinute) {
|
|
398
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
this.minutes = newInputValue;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
325
|
+
this.minutes = newInputValue;
|
|
404
326
|
}
|
|
405
327
|
}
|
|
406
328
|
else if (inputValue.length > 2) {
|
|
407
329
|
if (inputValue.startsWith('00')) {
|
|
408
330
|
this.inputZeroAdded[type] = true;
|
|
409
331
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
410
|
-
|
|
411
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
412
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
this.minutes = '00';
|
|
416
|
-
reputedToZero = true;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
421
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
422
|
-
}
|
|
423
|
-
else {
|
|
424
|
-
this.minutes = newInputValue;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
332
|
+
this.minutes = newInputValue;
|
|
427
333
|
}
|
|
428
334
|
else {
|
|
429
335
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
430
336
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
337
|
+
// Only apply format validation (not min/max constraints)
|
|
431
338
|
if (parsedNewInputValue >= maxMinutes) {
|
|
432
|
-
|
|
433
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
this.minutes = '00';
|
|
437
|
-
reputedToZero = true;
|
|
438
|
-
}
|
|
339
|
+
this.minutes = '00';
|
|
439
340
|
}
|
|
440
341
|
else {
|
|
441
|
-
|
|
442
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
443
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
444
|
-
}
|
|
445
|
-
else {
|
|
446
|
-
this.minutes = '00';
|
|
447
|
-
reputedToZero = true;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
else {
|
|
451
|
-
if (minMinute && parsedNewInputValue < minMinute) {
|
|
452
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
453
|
-
}
|
|
454
|
-
else {
|
|
455
|
-
this.minutes = parsedNewInputValue.toString();
|
|
456
|
-
}
|
|
457
|
-
}
|
|
342
|
+
this.minutes = parsedNewInputValue.toString();
|
|
458
343
|
}
|
|
459
344
|
}
|
|
460
345
|
}
|
|
461
346
|
else {
|
|
462
|
-
const
|
|
463
|
-
|
|
347
|
+
const parsedNewInputValue = parseInt(inputValue, 10) || 0;
|
|
348
|
+
// Only apply format validation (not min/max constraints)
|
|
464
349
|
if (parsedNewInputValue >= maxMinutes) {
|
|
465
|
-
|
|
466
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
this.minutes = '00';
|
|
470
|
-
reputedToZero = true;
|
|
471
|
-
}
|
|
350
|
+
this.minutes = '00';
|
|
472
351
|
}
|
|
473
352
|
else {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
477
|
-
}
|
|
478
|
-
else {
|
|
479
|
-
this.minutes = '00';
|
|
480
|
-
reputedToZero = true;
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
if (minMinute && parsedNewInputValue < minMinute) {
|
|
485
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
486
|
-
}
|
|
487
|
-
else {
|
|
488
|
-
this.minutes = parsedNewInputValue.toString();
|
|
489
|
-
}
|
|
490
|
-
}
|
|
353
|
+
// For direct input, remove unnecessary leading zeros (e.g., '01' becomes '1')
|
|
354
|
+
this.minutes = parsedNewInputValue.toString();
|
|
491
355
|
}
|
|
492
356
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
357
|
+
// Auto-navigation to next field when input is complete
|
|
358
|
+
if (this.minutes.length >= 1 && !this.inputZeroAdded[type]) {
|
|
359
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
360
|
+
const currentTypeIndex = visibleTypes.indexOf(TimeType.Minutes);
|
|
361
|
+
const nextTypeIndex = currentTypeIndex + 1;
|
|
362
|
+
if (nextTypeIndex < visibleTypes.length) {
|
|
363
|
+
const nextType = visibleTypes[nextTypeIndex];
|
|
364
|
+
(_a = this.inputElements[nextType]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
365
|
+
(_b = this.inputElements[nextType]) === null || _b === void 0 ? void 0 : _b.select();
|
|
366
|
+
}
|
|
502
367
|
}
|
|
503
368
|
}
|
|
504
369
|
handleSecondsChange(inputValue, type) {
|
|
505
|
-
var _a, _b, _c, _d;
|
|
506
370
|
const maxSeconds = 60;
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
371
|
+
// Handle empty input
|
|
372
|
+
if (inputValue.length === 0) {
|
|
373
|
+
this.seconds = '00';
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
510
376
|
if (inputValue.length === 1) {
|
|
511
377
|
this.inputZeroAdded[type] = true;
|
|
512
378
|
const newInputValue = inputValue.padStart(2, '0');
|
|
513
|
-
|
|
514
|
-
if (minSecond && parseInt(newInputValue, 10) < minSecond) {
|
|
515
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
516
|
-
}
|
|
517
|
-
else {
|
|
518
|
-
this.seconds = '00';
|
|
519
|
-
reputedToZero = true;
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
else {
|
|
523
|
-
if (minSecond && parseInt(newInputValue, 10) < minSecond) {
|
|
524
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
525
|
-
}
|
|
526
|
-
else {
|
|
527
|
-
this.seconds = newInputValue;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
379
|
+
this.seconds = newInputValue;
|
|
530
380
|
}
|
|
531
381
|
else if (this.inputZeroAdded[type]) {
|
|
532
382
|
this.inputZeroAdded[type] = false;
|
|
533
383
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
534
384
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
385
|
+
// Only apply format validation (not min/max constraints)
|
|
535
386
|
if (parsedNewInputValue >= maxSeconds) {
|
|
536
|
-
|
|
537
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
538
|
-
}
|
|
539
|
-
else {
|
|
540
|
-
this.seconds = '00';
|
|
541
|
-
reputedToZero = true;
|
|
542
|
-
}
|
|
387
|
+
this.seconds = '00';
|
|
543
388
|
}
|
|
544
389
|
else {
|
|
545
|
-
|
|
546
|
-
if (minSecond && parseInt(newInputValue, 10) < minSecond) {
|
|
547
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
548
|
-
}
|
|
549
|
-
else {
|
|
550
|
-
this.seconds = '00';
|
|
551
|
-
reputedToZero = true;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
else {
|
|
555
|
-
if (minSecond && parsedNewInputValue < minSecond) {
|
|
556
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
557
|
-
}
|
|
558
|
-
else {
|
|
559
|
-
this.seconds = newInputValue;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
390
|
+
this.seconds = newInputValue;
|
|
562
391
|
}
|
|
563
392
|
}
|
|
564
393
|
else if (inputValue.length > 2) {
|
|
565
394
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
566
395
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
396
|
+
// Only apply format validation (not min/max constraints)
|
|
567
397
|
if (parsedNewInputValue >= maxSeconds) {
|
|
568
|
-
|
|
569
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
570
|
-
}
|
|
571
|
-
else {
|
|
572
|
-
this.seconds = '00';
|
|
573
|
-
reputedToZero = true;
|
|
574
|
-
}
|
|
398
|
+
this.seconds = '00';
|
|
575
399
|
}
|
|
576
400
|
else {
|
|
577
|
-
|
|
578
|
-
if (minSecond && parseInt(newInputValue, 10) < minSecond) {
|
|
579
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
582
|
-
this.seconds = '00';
|
|
583
|
-
reputedToZero = true;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
else {
|
|
587
|
-
if (minSecond && parsedNewInputValue < minSecond) {
|
|
588
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
589
|
-
}
|
|
590
|
-
else {
|
|
591
|
-
this.seconds = parsedNewInputValue.toString();
|
|
592
|
-
}
|
|
593
|
-
}
|
|
401
|
+
this.seconds = parsedNewInputValue.toString();
|
|
594
402
|
}
|
|
595
403
|
}
|
|
596
404
|
else {
|
|
597
|
-
const
|
|
598
|
-
|
|
405
|
+
const parsedNewInputValue = parseInt(inputValue, 10) || 0;
|
|
406
|
+
// Only apply format validation (not min/max constraints)
|
|
599
407
|
if (parsedNewInputValue >= maxSeconds) {
|
|
600
|
-
|
|
601
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
602
|
-
}
|
|
603
|
-
else {
|
|
604
|
-
this.seconds = '00';
|
|
605
|
-
reputedToZero = true;
|
|
606
|
-
}
|
|
408
|
+
this.seconds = '00';
|
|
607
409
|
}
|
|
608
410
|
else {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
612
|
-
}
|
|
613
|
-
else {
|
|
614
|
-
this.seconds = '00';
|
|
615
|
-
reputedToZero = true;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
else {
|
|
619
|
-
if (minSecond && parsedNewInputValue < minSecond) {
|
|
620
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
621
|
-
}
|
|
622
|
-
else {
|
|
623
|
-
this.seconds = parsedNewInputValue.toString();
|
|
624
|
-
}
|
|
625
|
-
}
|
|
411
|
+
// For direct input, remove unnecessary leading zeros (e.g., '01' becomes '1')
|
|
412
|
+
this.seconds = parsedNewInputValue.toString();
|
|
626
413
|
}
|
|
627
414
|
}
|
|
628
|
-
|
|
629
|
-
(_c = this.inputElements[TimeType.Seconds]) === null || _c === void 0 ? void 0 : _c.focus();
|
|
630
|
-
(_d = this.inputElements[TimeType.Seconds]) === null || _d === void 0 ? void 0 : _d.select();
|
|
631
|
-
}
|
|
415
|
+
// No auto-navigation for seconds field as it's typically the last field
|
|
632
416
|
}
|
|
633
|
-
// Parse a
|
|
417
|
+
// Parse a time string according to the current format
|
|
634
418
|
parseTime(timeString) {
|
|
635
419
|
if (!timeString) {
|
|
636
420
|
return;
|
|
637
421
|
}
|
|
638
|
-
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
const minSecond = this.parseSecond(this.min) || second;
|
|
645
|
-
this.hours = minHour.padStart(2, '0');
|
|
646
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
647
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
422
|
+
// Use format-aware parsing without constraint application
|
|
423
|
+
const components = parseValueByFormat(timeString, this.format);
|
|
424
|
+
// Set the parsed values without applying min/max constraints
|
|
425
|
+
this.hours = components.hours;
|
|
426
|
+
this.minutes = components.minutes;
|
|
427
|
+
this.seconds = components.seconds;
|
|
648
428
|
}
|
|
649
429
|
reconstructTime() {
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
430
|
+
const components = {
|
|
431
|
+
hours: this.hours,
|
|
432
|
+
minutes: this.minutes,
|
|
433
|
+
seconds: this.seconds,
|
|
434
|
+
};
|
|
435
|
+
// Ensure the reconstructed time is in the correct format
|
|
436
|
+
const reconstructedTime = reconstructTimeByFormat(components, this.format);
|
|
437
|
+
// Validate that the reconstructed time matches the expected format
|
|
438
|
+
if (!isValidFormatValue(reconstructedTime, this.format)) {
|
|
439
|
+
// If invalid, return the default value for this format
|
|
440
|
+
const config = FORMAT_CONFIGS[this.format];
|
|
441
|
+
return config ? config.defaultValue : reconstructedTime;
|
|
661
442
|
}
|
|
443
|
+
return reconstructedTime;
|
|
662
444
|
}
|
|
663
445
|
handleFocus(type) {
|
|
664
446
|
var _a, _b, _c, _d;
|
|
665
447
|
if (this.readonly || this.disabled) {
|
|
666
448
|
return;
|
|
667
449
|
}
|
|
450
|
+
// Check if this field is visible for the current format
|
|
451
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
452
|
+
if (!visibleTypes.includes(type)) {
|
|
453
|
+
return; // Don't handle focus for non-visible fields
|
|
454
|
+
}
|
|
668
455
|
if (!this.open) {
|
|
669
456
|
this.open = true; // Force the popover to open
|
|
670
457
|
}
|
|
@@ -677,33 +464,23 @@ export class NvFieldtime {
|
|
|
677
464
|
this.typeFocused = type;
|
|
678
465
|
}
|
|
679
466
|
HandleDropdownIconClick() {
|
|
680
|
-
var _a, _b
|
|
467
|
+
var _a, _b;
|
|
681
468
|
if (this.disabled || this.readonly) {
|
|
682
469
|
return; // Do not toggle if disabled or read-only
|
|
683
470
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
else if (this.open && this.inputElements[TimeType.Minutes]) {
|
|
688
|
-
this.open = false; // Close the popover if it is open
|
|
689
|
-
}
|
|
690
|
-
else if (this.open && this.inputElements[TimeType.Seconds]) {
|
|
471
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
472
|
+
const firstVisibleType = visibleTypes[0];
|
|
473
|
+
if (this.open) {
|
|
691
474
|
this.open = false; // Close the popover if it is open
|
|
692
475
|
}
|
|
693
|
-
else if (!this.open &&
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
(_c = this.inputElements[TimeType.Minutes]) === null || _c === void 0 ? void 0 : _c.focus(); // Focus will open the popover
|
|
699
|
-
(_d = this.inputElements[TimeType.Minutes]) === null || _d === void 0 ? void 0 : _d.select();
|
|
700
|
-
}
|
|
701
|
-
else if (!this.open && this.inputElements[TimeType.Seconds]) {
|
|
702
|
-
(_e = this.inputElements[TimeType.Seconds]) === null || _e === void 0 ? void 0 : _e.focus(); // Focus will open the popover
|
|
703
|
-
(_f = this.inputElements[TimeType.Seconds]) === null || _f === void 0 ? void 0 : _f.select();
|
|
476
|
+
else if (!this.open &&
|
|
477
|
+
firstVisibleType &&
|
|
478
|
+
this.inputElements[firstVisibleType]) {
|
|
479
|
+
(_a = this.inputElements[firstVisibleType]) === null || _a === void 0 ? void 0 : _a.focus(); // Focus will open the popover
|
|
480
|
+
(_b = this.inputElements[firstVisibleType]) === null || _b === void 0 ? void 0 : _b.select();
|
|
704
481
|
}
|
|
705
482
|
else {
|
|
706
|
-
console.warn('nv-fieldtime -> No input elements found to focus
|
|
483
|
+
console.warn('nv-fieldtime -> No visible input elements found to focus');
|
|
707
484
|
}
|
|
708
485
|
}
|
|
709
486
|
updateHighlightedItem(items, index) {
|
|
@@ -722,6 +499,8 @@ export class NvFieldtime {
|
|
|
722
499
|
}
|
|
723
500
|
handleTimeOptionClick(event, type) {
|
|
724
501
|
const option = parseInt(event.target.textContent || '0', 10);
|
|
502
|
+
// Update the time component directly without constraint validation
|
|
503
|
+
// Dropdown options are already filtered by constraints during generation
|
|
725
504
|
if (type === TimeType.Hours) {
|
|
726
505
|
this.hours = option.toString().padStart(2, '0');
|
|
727
506
|
}
|
|
@@ -731,8 +510,9 @@ export class NvFieldtime {
|
|
|
731
510
|
else if (type === TimeType.Seconds) {
|
|
732
511
|
this.seconds = option.toString().padStart(2, '0');
|
|
733
512
|
}
|
|
734
|
-
|
|
735
|
-
|
|
513
|
+
// Reconstruct time in the correct format and update value
|
|
514
|
+
const reconstructedTime = this.reconstructTime();
|
|
515
|
+
this.value = reconstructedTime;
|
|
736
516
|
}
|
|
737
517
|
handleInputBlur() {
|
|
738
518
|
// Use a delay to check if the focus is still within the popover
|
|
@@ -791,17 +571,29 @@ export class NvFieldtime {
|
|
|
791
571
|
}
|
|
792
572
|
generateHourOptions(stepInSeconds) {
|
|
793
573
|
const hourStep = Math.max(1, Math.floor(stepInSeconds / 3600)); // Prevent step < 1
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
const
|
|
797
|
-
const
|
|
798
|
-
const
|
|
574
|
+
const is12HourFormat = this.format.startsWith('hh');
|
|
575
|
+
// Set proper hour ranges based on format
|
|
576
|
+
const defaultMaxHour = is12HourFormat ? 12 : 23;
|
|
577
|
+
const defaultMinHour = is12HourFormat ? 1 : 0;
|
|
578
|
+
const maxHour = this.parseHour(this.max, this.format);
|
|
579
|
+
const minHour = this.parseHour(this.min, this.format);
|
|
580
|
+
const maxHourValue = maxHour ? parseInt(maxHour, 10) : defaultMaxHour;
|
|
581
|
+
const minHourValue = minHour ? parseInt(minHour, 10) : defaultMinHour;
|
|
799
582
|
const values = [];
|
|
800
|
-
for (let i = minHourValue; i
|
|
801
|
-
|
|
583
|
+
for (let i = minHourValue; i <= maxHourValue; i += hourStep) {
|
|
584
|
+
const hourStr = i.toString().padStart(2, '0');
|
|
585
|
+
values.push(hourStr);
|
|
802
586
|
}
|
|
803
587
|
return values;
|
|
804
588
|
}
|
|
589
|
+
/**
|
|
590
|
+
* Parse hour value from min/max constraint strings for dropdown generation only.
|
|
591
|
+
* This method is used exclusively for filtering dropdown options and should not
|
|
592
|
+
* affect input values or validation.
|
|
593
|
+
* @param {string} value - The time string to parse (e.g., "14:30" or "02:30")
|
|
594
|
+
* @param {string} format - The time format string (e.g., "HH:mm" or "hh:mm")
|
|
595
|
+
* @returns {string} The parsed hour string or null if invalid
|
|
596
|
+
*/
|
|
805
597
|
parseHour(value, format) {
|
|
806
598
|
if (!value)
|
|
807
599
|
return null;
|
|
@@ -819,13 +611,21 @@ export class NvFieldtime {
|
|
|
819
611
|
const minMinute = (_a = this.parseMinute(this.min)) !== null && _a !== void 0 ? _a : 0;
|
|
820
612
|
const maxMinute = (_b = this.parseMinute(this.max)) !== null && _b !== void 0 ? _b : 59;
|
|
821
613
|
if (minMinute === 0 && maxMinute === 0)
|
|
822
|
-
return ['00']; // Handle edge case for zero
|
|
614
|
+
return ['00']; // Handle edge case for zero minutes
|
|
823
615
|
const values = [];
|
|
824
616
|
for (let i = minMinute; i <= maxMinute; i += minuteStep) {
|
|
825
|
-
|
|
617
|
+
const minuteStr = i.toString().padStart(2, '0');
|
|
618
|
+
values.push(minuteStr);
|
|
826
619
|
}
|
|
827
620
|
return values;
|
|
828
621
|
}
|
|
622
|
+
/**
|
|
623
|
+
* Parse minute value from min/max constraint strings for dropdown generation only.
|
|
624
|
+
* This method is used exclusively for filtering dropdown options and should not
|
|
625
|
+
* affect input values or validation.
|
|
626
|
+
* @param {string} value - The time string to parse (e.g., "14:30" or "02:30")
|
|
627
|
+
* @returns {number} The parsed minute number or null if invalid
|
|
628
|
+
*/
|
|
829
629
|
parseMinute(value) {
|
|
830
630
|
if (!value)
|
|
831
631
|
return null;
|
|
@@ -844,10 +644,18 @@ export class NvFieldtime {
|
|
|
844
644
|
return ['00']; // Handle edge case for zero seconds
|
|
845
645
|
const values = [];
|
|
846
646
|
for (let i = minSecond; i <= maxSecond; i += secondStep) {
|
|
847
|
-
|
|
647
|
+
const secondStr = i.toString().padStart(2, '0');
|
|
648
|
+
values.push(secondStr);
|
|
848
649
|
}
|
|
849
650
|
return values;
|
|
850
651
|
}
|
|
652
|
+
/**
|
|
653
|
+
* Parse second value from min/max constraint strings for dropdown generation only.
|
|
654
|
+
* This method is used exclusively for filtering dropdown options and should not
|
|
655
|
+
* affect input values or validation.
|
|
656
|
+
* @param {string} value - The time string to parse (e.g., "14:30:45" or "02:30:45")
|
|
657
|
+
* @returns {number} The parsed second number or null if invalid
|
|
658
|
+
*/
|
|
851
659
|
parseSecond(value) {
|
|
852
660
|
if (!value)
|
|
853
661
|
return null;
|
|
@@ -864,10 +672,6 @@ export class NvFieldtime {
|
|
|
864
672
|
const repetitions = Math.ceil(300 / totalOptions);
|
|
865
673
|
return Array(repetitions).fill(options).flat();
|
|
866
674
|
}
|
|
867
|
-
getCurrentTime() {
|
|
868
|
-
const currentTime = new Date();
|
|
869
|
-
return currentTime.toLocaleTimeString(); // Returns the time in the locale's format
|
|
870
|
-
}
|
|
871
675
|
updateColumnHighlight(selector, value) {
|
|
872
676
|
const items = Array.from(this.el.querySelectorAll(selector));
|
|
873
677
|
const index = items.findIndex(x => x.textContent === value);
|
|
@@ -885,8 +689,13 @@ export class NvFieldtime {
|
|
|
885
689
|
}
|
|
886
690
|
if (!this.open) {
|
|
887
691
|
if (this.inputElements) {
|
|
888
|
-
|
|
889
|
-
|
|
692
|
+
// Focus on the first visible field based on format
|
|
693
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
694
|
+
const firstVisibleType = visibleTypes[0];
|
|
695
|
+
if (firstVisibleType && this.inputElements[firstVisibleType]) {
|
|
696
|
+
(_a = this.inputElements[firstVisibleType]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
697
|
+
(_b = this.inputElements[firstVisibleType]) === null || _b === void 0 ? void 0 : _b.select();
|
|
698
|
+
}
|
|
890
699
|
}
|
|
891
700
|
event.preventDefault();
|
|
892
701
|
}
|
|
@@ -896,17 +705,23 @@ export class NvFieldtime {
|
|
|
896
705
|
//#region LIFECYCLE
|
|
897
706
|
componentWillLoad() {
|
|
898
707
|
document.addEventListener('click', this.handleClickOutside.bind(this));
|
|
899
|
-
//
|
|
708
|
+
// Initialize component state based on format and value
|
|
900
709
|
if (this.value) {
|
|
710
|
+
// Parse the provided value using format-aware parsing without constraint application
|
|
901
711
|
this.parseTime(this.value);
|
|
902
712
|
}
|
|
903
713
|
else {
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
const
|
|
907
|
-
|
|
908
|
-
this.
|
|
909
|
-
this.
|
|
714
|
+
// Initialize with format-appropriate default values without any constraint application
|
|
715
|
+
// Use format-specific defaults: '01' for 12-hour formats, '00' for 24-hour formats
|
|
716
|
+
const defaultComponents = parseValueByFormat('', this.format);
|
|
717
|
+
// Set default values directly without any min/max constraint validation
|
|
718
|
+
this.hours = defaultComponents.hours;
|
|
719
|
+
this.minutes = defaultComponents.minutes;
|
|
720
|
+
this.seconds = defaultComponents.seconds;
|
|
721
|
+
// Set the initial value in the correct format without constraint validation
|
|
722
|
+
// This ensures the component has a proper initial state for the value watcher
|
|
723
|
+
const initialValue = reconstructTimeByFormat(defaultComponents, this.format);
|
|
724
|
+
this.value = initialValue;
|
|
910
725
|
}
|
|
911
726
|
}
|
|
912
727
|
connectedCallback() {
|
|
@@ -916,63 +731,94 @@ export class NvFieldtime {
|
|
|
916
731
|
document.removeEventListener('click', this.handleClickOutside.bind(this));
|
|
917
732
|
}
|
|
918
733
|
componentDidLoad() {
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
734
|
+
// Initialize dropdown highlighting based on current component state
|
|
735
|
+
// This ensures proper visual feedback without applying any constraints
|
|
736
|
+
// Update highlighted items for hours based on current state
|
|
737
|
+
const hourSelector = `.time-column.time-column-hours div`;
|
|
738
|
+
this.updateColumnHighlight(hourSelector, this.hours);
|
|
739
|
+
// Update highlighted items for minutes based on current state
|
|
740
|
+
const minuteSelector = `.time-column.time-column-minutes div`;
|
|
741
|
+
this.updateColumnHighlight(minuteSelector, this.minutes);
|
|
742
|
+
// Update highlighted items for seconds based on current state
|
|
743
|
+
const secondSelector = `.time-column.time-column-seconds div`;
|
|
744
|
+
this.updateColumnHighlight(secondSelector, this.seconds);
|
|
745
|
+
}
|
|
746
|
+
//#endregion LIFECYCLE
|
|
747
|
+
/****************************************************************************/
|
|
748
|
+
//#region RENDER
|
|
749
|
+
/**
|
|
750
|
+
* Renders input fields based on the current format
|
|
751
|
+
* Only shows fields that are relevant to the selected format
|
|
752
|
+
* @returns {HTMLElement[]} Array of HTML elements for time input fields
|
|
753
|
+
*/
|
|
754
|
+
renderTimeInputFields() {
|
|
755
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
756
|
+
const elements = [];
|
|
757
|
+
visibleTypes.forEach((type, index) => {
|
|
758
|
+
// Add separator colon before minutes and seconds (but not before the first field)
|
|
759
|
+
if (index > 0) {
|
|
760
|
+
elements.push(h("span", null, ":"));
|
|
931
761
|
}
|
|
932
|
-
//
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
762
|
+
// Add the input field for this time type
|
|
763
|
+
elements.push(this.renderTimeInputField(type));
|
|
764
|
+
});
|
|
765
|
+
return elements;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Renders a single time input field for the specified type
|
|
769
|
+
* @param {TimeType} type - The time type to render input for
|
|
770
|
+
* @returns {HTMLInputElement} HTML input element for the specified time type
|
|
771
|
+
*/
|
|
772
|
+
renderTimeInputField(type) {
|
|
773
|
+
const getValue = () => {
|
|
774
|
+
switch (type) {
|
|
775
|
+
case TimeType.Hours:
|
|
776
|
+
return this.hours;
|
|
777
|
+
case TimeType.Minutes:
|
|
778
|
+
return this.minutes;
|
|
779
|
+
case TimeType.Seconds:
|
|
780
|
+
return this.seconds;
|
|
781
|
+
default:
|
|
782
|
+
return '00';
|
|
942
783
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
784
|
+
};
|
|
785
|
+
const getPlaceholder = () => {
|
|
786
|
+
switch (type) {
|
|
787
|
+
case TimeType.Hours:
|
|
788
|
+
return this.format.includes('hh') ? 'hh' : 'HH';
|
|
789
|
+
case TimeType.Minutes:
|
|
790
|
+
return 'mm';
|
|
791
|
+
case TimeType.Seconds:
|
|
792
|
+
return 'ss';
|
|
793
|
+
default:
|
|
794
|
+
return '';
|
|
954
795
|
}
|
|
955
|
-
|
|
956
|
-
|
|
796
|
+
};
|
|
797
|
+
const getId = () => {
|
|
798
|
+
switch (type) {
|
|
799
|
+
case TimeType.Hours:
|
|
800
|
+
return this.inputId;
|
|
801
|
+
case TimeType.Minutes:
|
|
802
|
+
return `${this.inputId}-minutes`;
|
|
803
|
+
case TimeType.Seconds:
|
|
804
|
+
return `${this.inputId}-seconds`;
|
|
805
|
+
default:
|
|
806
|
+
return this.inputId;
|
|
957
807
|
}
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
}
|
|
808
|
+
};
|
|
809
|
+
// Remove min/max constraints from input elements to allow native stepper behavior
|
|
810
|
+
// Constraints are only applied to dropdown options, not input steppers
|
|
811
|
+
return (h("input", { ref: el => (this.inputElements[type] = el), type: "number", autofocus: this.autofocus && type === getVisibleTimeTypes(this.format)[0], class: "time-input", pattern: "[0-9]*", maxlength: "3", value: getValue(), onInput: e => this.handleInputChange(e, type), placeholder: getPlaceholder(), inputMode: "numeric", onFocus: () => this.handleFocus(type), name: this.name ? `${type}-${this.name}` : type, id: getId(), readonly: this.readonly, disabled: this.disabled, required: this.required, onKeyDown: e => this.handleKeyDown(e), onBlur: () => this.handleInputBlur() }));
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Renders dropdown columns based on the current format
|
|
815
|
+
* Only shows columns that are relevant to the selected format
|
|
816
|
+
* @returns {HTMLElement[]} Array of HTML elements for time dropdown columns
|
|
817
|
+
*/
|
|
818
|
+
renderTimeDropdownColumns() {
|
|
819
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
820
|
+
return visibleTypes.map(type => this.RenderTimeOptionsColumn(type));
|
|
972
821
|
}
|
|
973
|
-
//#endregion LIFECYCLE
|
|
974
|
-
/****************************************************************************/
|
|
975
|
-
//#region RENDER
|
|
976
822
|
RenderTimeOptionsColumn(type) {
|
|
977
823
|
return (h("div", { class: `time-column time-column-${type}`, onScroll: e => this.handleScroll(e, type) }, this.generateInfiniteTimeOptions(type).map((option, index) => (h("div", { class: {
|
|
978
824
|
'time-option': true,
|
|
@@ -982,26 +828,9 @@ export class NvFieldtime {
|
|
|
982
828
|
}, key: `${option}-${index}`, onClick: e => this.handleTimeOptionClick(e, type) }, option)))));
|
|
983
829
|
}
|
|
984
830
|
render() {
|
|
985
|
-
return (h(Host, { key: '
|
|
986
|
-
h("
|
|
987
|
-
|
|
988
|
-
: TimeType.Hours, id: this.inputId, readonly: this.readonly, disabled: this.disabled, required: this.required, onKeyDown: e => this.handleKeyDown(e), onBlur: () => this.handleInputBlur() }),
|
|
989
|
-
], this.format.includes('mm') && [
|
|
990
|
-
h("span", { key: '74f9604ffd54e0c0bbd88996e32fdcb08f2c3645' }, ":"),
|
|
991
|
-
h("input", { key: '52f9b637bba804cac6fadff06e8b077bb2f5748a', ref: el => (this.inputElements[TimeType.Minutes] = el), type: "number", autofocus: this.autofocus, class: "time-input", pattern: "[0-9]*", maxlength: "3", value: this.minutes, onInput: e => this.handleInputChange(e, TimeType.Minutes), placeholder: "mm", inputMode: "numeric", onFocus: () => this.handleFocus(TimeType.Minutes), name: this.name
|
|
992
|
-
? `${TimeType.Minutes}-${this.name}`
|
|
993
|
-
: TimeType.Minutes, id: `${this.inputId}-minutes`, readonly: this.readonly, disabled: this.disabled, required: this.required, onKeyDown: e => this.handleKeyDown(e), onBlur: () => this.handleInputBlur() }),
|
|
994
|
-
], this.format.includes('ss') && [
|
|
995
|
-
h("span", { key: '878bc9ce7557e9cf9471803a86956a9184d0ccb5' }, ":"),
|
|
996
|
-
h("input", { key: 'b074d4d3ef80f66e7dbe051b6bc53f151661f409', ref: el => (this.inputElements[TimeType.Seconds] = el), type: "number", autofocus: this.autofocus, class: "time-input", pattern: "[0-9]*", maxlength: "3", value: this.seconds, onInput: e => this.handleInputChange(e, TimeType.Seconds), placeholder: "ss", inputMode: "numeric", onFocus: () => this.handleFocus(TimeType.Seconds), name: this.name
|
|
997
|
-
? `${TimeType.Seconds}-${this.name}`
|
|
998
|
-
: TimeType.Seconds, id: `${this.inputId}-seconds`, readonly: this.readonly, disabled: this.disabled, required: this.required, onKeyDown: e => this.handleKeyDown(e), onBlur: () => this.handleInputBlur() }),
|
|
999
|
-
], h("nv-iconbutton", { key: '3f5d78116ee60d1874a4629d9cf36a06d52b7df4', name: 'clock', size: "md", emphasis: "lower", "aria-label": this.open ? 'Hide time picker' : 'Show time picker', onClick: () => this.HandleDropdownIconClick() }), this.error && (h("nv-icon", { key: '4b2356cf95131af213a4e98feede16fc8c4963db', name: "alert-circle", class: "validation", size: "sm" })), this.success && (h("nv-icon", { key: 'f9b0e61037049a36ac900d1af9ecc71b211ebd88', name: "circle-check", class: "validation", size: "sm" }))), h("slot", { key: '6177abde559c57f2b0586368ead1a61d7b543838', name: "after-input" })), h("div", { key: 'f6d5205a5011411550179f9337143163cb547fb1', class: "time-dropdown", slot: "content" }, h("div", { key: '9f0b3e1423bef197b269c5b11ce744cabc2bd6c4', class: "time-columns" }, startsWithIgnoreCase(this.format, 'HH') &&
|
|
1000
|
-
this.RenderTimeOptionsColumn(TimeType.Hours), this.format.includes('mm') &&
|
|
1001
|
-
this.RenderTimeOptionsColumn(TimeType.Minutes), this.format.includes('ss') &&
|
|
1002
|
-
this.RenderTimeOptionsColumn(TimeType.Seconds)))), (this.description ||
|
|
1003
|
-
this.el.querySelector('[slot="description"]')) && (h("div", { key: '1076ded73b32ff9afbd0f02184febcc82f8d839e', class: "description" }, h("slot", { key: '479d09b299d0e380533a6cd689ce7f03aa92ea8e', name: "description" }, this.description))), (this.errorDescription ||
|
|
1004
|
-
this.el.querySelector('[slot="error-description"]')) && (h("div", { key: '5615246dbd797c300be357be37d3b9d0aee56e31', hidden: !this.error, class: "error-description" }, h("slot", { key: '6568ea3f9e0bdf85dd280c645956f8e0bb592e35', name: "error-description" }, this.errorDescription)))));
|
|
831
|
+
return (h(Host, { key: 'f66fe2a29f23a0bc967821a0c9bca4347b622286', onclick: (e) => this.handleHostClick(e), "aria-expanded": this.open ? 'true' : 'false' }, (this.label || this.el.querySelector('[slot="label"]')) && (h("label", { key: 'f01ce1b034b1b547cbdde5814db9357ee1913e04', htmlFor: this.inputId }, h("slot", { key: 'd81dcb20883b93280db6e76e0299f679f1f9ed84', name: "label" }, this.label))), h("nv-popover", { key: '8c9e83002edcfba89ca4ca282fc82db714ed2f43', ref: el => (this.popoverElement = el), triggerMode: "controlled", placement: "bottom-start", open: this.open }, h("div", { key: '3a5b26e4be67f277ead2a9fe2f04e5d12a4bd596', class: "input-wrapper", slot: "trigger" }, h("slot", { key: '2ea5f8269c6f0892c53a002a298ca3ceed8f8a00', name: "before-input" }), h("div", { key: 'ab97bbbf183118d7b510f82c800b4a3fa1fefda3', class: "input-container" }, h("slot", { key: 'a80d2f68b24d4226c18bf0df18ebf13ac6e0873e', name: "leading-input" }), this.renderTimeInputFields(), h("nv-iconbutton", { key: '1f7aacf1ab073c0c6ef10b50e948a7ecbca4dd75', name: 'clock', size: "md", emphasis: "lower", "aria-label": this.open ? 'Hide time picker' : 'Show time picker', onClick: () => this.HandleDropdownIconClick() }), this.error && (h("nv-icon", { key: '8f414a3b3daae6f0625b3c62b920621bf8698db3', name: "alert-circle", class: "validation", size: "sm" })), this.success && (h("nv-icon", { key: '13b5671664466b6bb50f2561b5cffb96517a1068', name: "circle-check", class: "validation", size: "sm" }))), h("slot", { key: 'b5d6085a9864ef84d4113062a0b1cb8a807ab241', name: "after-input" })), h("div", { key: '2950c5fac3a0f219e5db2e3a7e9f605d86e50aa2', class: "time-dropdown", slot: "content" }, h("div", { key: 'c5b7ff3818a05e1f6d7ca76657f57b85bb595345', class: "time-columns" }, this.renderTimeDropdownColumns()))), (this.description ||
|
|
832
|
+
this.el.querySelector('[slot="description"]')) && (h("div", { key: 'c8cb90fad74721a9b5eb0ab50980f3fd7c587e62', class: "description" }, h("slot", { key: '641d1a6a9dbf580267664831d5b371a601afb039', name: "description" }, this.description))), (this.errorDescription ||
|
|
833
|
+
this.el.querySelector('[slot="error-description"]')) && (h("div", { key: '5721b81d7a16b626bfa7c3af20897f33b7c37080', hidden: !this.error, class: "error-description" }, h("slot", { key: '84cef1043666ab6dd86f70d4ba0054d7f33ca589', name: "error-description" }, this.errorDescription)))));
|
|
1005
834
|
}
|
|
1006
835
|
static get is() { return "nv-fieldtime"; }
|
|
1007
836
|
static get formAssociated() { return true; }
|
|
@@ -1231,7 +1060,7 @@ export class NvFieldtime {
|
|
|
1231
1060
|
"optional": false,
|
|
1232
1061
|
"docs": {
|
|
1233
1062
|
"tags": [],
|
|
1234
|
-
"text": "Specifies the time format to be used.\nAvailable formats:\n- HH: 24-hour format (00-23)\n- HH:mm: 24-hour format with minutes (00:00-23:59)\n- HH:mm:ss: 24-hour format with minutes and seconds (00:00:00-23:59:59)\n- hh: 12-hour format (01-12)\n- hh:mm: 12-hour format with minutes (01:00-12:59)\n- hh:mm:ss: 12-hour format with minutes and seconds (01:00:00-12:59:59)"
|
|
1063
|
+
"text": "Specifies the time format to be used.\nAvailable formats:\n- HH: 24-hour format (00-23)\n- HH:mm: 24-hour format with minutes (00:00-23:59)\n- HH:mm:ss: 24-hour format with minutes and seconds (00:00:00-23:59:59)\n- hh: 12-hour format (01-12)\n- hh:mm: 12-hour format with minutes (01:00-12:59)\n- hh:mm:ss: 12-hour format with minutes and seconds (01:00:00-12:59:59)\n\nThe component automatically shows only the relevant input fields based on the selected format.\nWhen the format changes dynamically, the component re-parses the current value and updates\nthe visible fields accordingly."
|
|
1235
1064
|
},
|
|
1236
1065
|
"getter": false,
|
|
1237
1066
|
"setter": false,
|
|
@@ -1373,8 +1202,11 @@ export class NvFieldtime {
|
|
|
1373
1202
|
"cancelable": true,
|
|
1374
1203
|
"composed": true,
|
|
1375
1204
|
"docs": {
|
|
1376
|
-
"tags": [
|
|
1377
|
-
|
|
1205
|
+
"tags": [{
|
|
1206
|
+
"name": "bind",
|
|
1207
|
+
"text": "value"
|
|
1208
|
+
}],
|
|
1209
|
+
"text": "Emit an event when the time value changes.\nThe event detail contains the new time value in the format specified by the format property."
|
|
1378
1210
|
},
|
|
1379
1211
|
"complexType": {
|
|
1380
1212
|
"original": "string",
|
|
@@ -1391,6 +1223,9 @@ export class NvFieldtime {
|
|
|
1391
1223
|
}, {
|
|
1392
1224
|
"propName": "open",
|
|
1393
1225
|
"methodName": "handleOpenChange"
|
|
1226
|
+
}, {
|
|
1227
|
+
"propName": "format",
|
|
1228
|
+
"methodName": "handleFormatChange"
|
|
1394
1229
|
}];
|
|
1395
1230
|
}
|
|
1396
1231
|
static get listeners() {
|