@nova-design-system/nova-webcomponents 3.17.0 → 3.18.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 +21 -3
- 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-datagrid.cjs.entry.js +1 -1
- package/dist/cjs/nv-datagrid.cjs.entry.js.map +1 -1
- package/dist/cjs/nv-fieldtime.cjs.entry.js +556 -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 +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 +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-datagrid/nv-datagrid.css +4 -4
- 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 +331 -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 +1 -1
- 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 +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 +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 +21 -3
- 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 +3 -3
- package/dist/components/nv-datagrid.js.map +1 -1
- package/dist/components/nv-dialog.js +4 -4
- package/dist/components/nv-dialogfooter.js +1 -1
- package/dist/components/nv-fielddate.js +4 -4
- package/dist/components/nv-fielddaterange.js +4 -4
- package/dist/components/nv-fielddropdown.js +5 -5
- package/dist/components/nv-fielddropdownitem.js +1 -1
- package/dist/components/nv-fieldmultiselect.js +5 -5
- package/dist/components/nv-fieldnumber.js +1 -1
- package/dist/components/nv-fieldpassword.js +3 -3
- package/dist/components/nv-fieldselect.js +3 -3
- package/dist/components/nv-fieldslider.js +4 -4
- package/dist/components/nv-fieldtext.js +1 -1
- package/dist/components/nv-fieldtime.js +562 -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 +4 -4
- 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-31478080.js → p-015330b8.js} +2 -2
- package/dist/components/{p-31478080.js.map → p-015330b8.js.map} +1 -1
- package/dist/components/{p-7b5102c8.js → p-1bd396b1.js} +4 -4
- package/dist/components/{p-7b5102c8.js.map → p-1bd396b1.js.map} +1 -1
- package/dist/components/{p-9e7468e3.js → p-2574f8c2.js} +2 -2
- package/dist/components/{p-9e7468e3.js.map → p-2574f8c2.js.map} +1 -1
- package/dist/components/{p-f2bac2aa.js → p-4cd6f629.js} +2 -2
- package/dist/components/{p-f2bac2aa.js.map → p-4cd6f629.js.map} +1 -1
- package/dist/components/{p-2cc83e0c.js → p-5e315239.js} +2 -2
- package/dist/components/{p-2cc83e0c.js.map → p-5e315239.js.map} +1 -1
- package/dist/components/{p-7112612c.js → p-6ca3d847.js} +4 -4
- package/dist/components/{p-7112612c.js.map → p-6ca3d847.js.map} +1 -1
- package/dist/components/{p-98429fd7.js → p-c981bb48.js} +2 -2
- package/dist/components/{p-98429fd7.js.map → p-c981bb48.js.map} +1 -1
- package/dist/components/{p-0fd23531.js → p-d1b02966.js} +4 -4
- package/dist/components/{p-0fd23531.js.map → p-d1b02966.js.map} +1 -1
- package/dist/components/{p-6f2b257e.js → p-ea45f1ab.js} +3 -3
- package/dist/components/{p-6f2b257e.js.map → p-ea45f1ab.js.map} +1 -1
- package/dist/components/{p-63595ea1.js → p-ebfecbaa.js} +2 -2
- package/dist/components/{p-63595ea1.js.map → p-ebfecbaa.js.map} +1 -1
- package/dist/components/{p-47d499b4.js → p-ed43bcec.js} +3 -3
- package/dist/components/{p-47d499b4.js.map → p-ed43bcec.js.map} +1 -1
- package/dist/components/{p-378e3127.js → p-fabbaf47.js} +4 -4
- package/dist/components/{p-378e3127.js.map → p-fabbaf47.js.map} +1 -1
- package/dist/components/{p-df5d76a5.js → p-fca4d85b.js} +3 -3
- package/dist/components/{p-df5d76a5.js.map → p-fca4d85b.js.map} +1 -1
- package/dist/esm/index.js +21 -3
- 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-datagrid.entry.js +1 -1
- package/dist/esm/nv-datagrid.entry.js.map +1 -1
- package/dist/esm/nv-fieldtime.entry.js +557 -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 +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 +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-f30e0be6.entry.js → p-00d1e5e1.entry.js} +2 -2
- package/dist/native/{p-4eaf417d.entry.js → p-122c78c3.entry.js} +2 -2
- package/dist/native/{p-4eaf417d.entry.js.map → p-122c78c3.entry.js.map} +1 -1
- package/dist/native/{p-91fab6c2.entry.js → p-14d2f70a.entry.js} +2 -2
- package/dist/native/{p-d94bf052.entry.js → p-3464b86a.entry.js} +2 -2
- package/dist/native/{p-638967bf.entry.js → p-417fba7d.entry.js} +2 -2
- package/dist/native/{p-52d2c0ae.entry.js → p-4e6fb719.entry.js} +2 -2
- package/dist/native/{p-cb0293ec.entry.js → p-539666dd.entry.js} +2 -2
- package/dist/native/{p-2364aefa.entry.js → p-5c678bc7.entry.js} +2 -2
- package/dist/native/{p-bcf41cd0.entry.js → p-5e70f9ce.entry.js} +2 -2
- package/dist/native/{p-278613a3.entry.js → p-5f98d4cd.entry.js} +2 -2
- package/dist/native/p-8c053954.entry.js +2 -0
- package/dist/native/p-8c053954.entry.js.map +1 -0
- package/dist/native/{p-2dfd786f.entry.js → p-ad029453.entry.js} +2 -2
- package/dist/native/{p-9d7e099f.entry.js → p-ae43eee2.entry.js} +2 -2
- package/dist/native/{p-26513cbd.entry.js → p-b72b5e88.entry.js} +2 -2
- package/dist/native/{p-26513cbd.entry.js.map → p-b72b5e88.entry.js.map} +1 -1
- package/dist/native/{p-ce97ce24.entry.js → p-ca39f78d.entry.js} +2 -2
- package/dist/native/{p-647a0765.entry.js → p-da2060a5.entry.js} +2 -2
- package/dist/native/{p-14e622e1.entry.js → p-e5b7ce4e.entry.js} +2 -2
- 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 +20 -3
- package/dist/vscode-data.json +3 -3
- package/hydrate/index.js +571 -523
- package/hydrate/index.mjs +571 -523
- 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-a5c8eee9.js +0 -22
- package/dist/components/p-a5c8eee9.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-a5c8eee9.js +0 -2
- package/dist/native/p-a5c8eee9.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.map → p-00d1e5e1.entry.js.map} +0 -0
- /package/dist/native/{p-91fab6c2.entry.js.map → p-14d2f70a.entry.js.map} +0 -0
- /package/dist/native/{p-d94bf052.entry.js.map → p-3464b86a.entry.js.map} +0 -0
- /package/dist/native/{p-638967bf.entry.js.map → p-417fba7d.entry.js.map} +0 -0
- /package/dist/native/{p-52d2c0ae.entry.js.map → p-4e6fb719.entry.js.map} +0 -0
- /package/dist/native/{p-cb0293ec.entry.js.map → p-539666dd.entry.js.map} +0 -0
- /package/dist/native/{p-2364aefa.entry.js.map → p-5c678bc7.entry.js.map} +0 -0
- /package/dist/native/{p-bcf41cd0.entry.js.map → p-5e70f9ce.entry.js.map} +0 -0
- /package/dist/native/{p-278613a3.entry.js.map → p-5f98d4cd.entry.js.map} +0 -0
- /package/dist/native/{p-2dfd786f.entry.js.map → p-ad029453.entry.js.map} +0 -0
- /package/dist/native/{p-9d7e099f.entry.js.map → p-ae43eee2.entry.js.map} +0 -0
- /package/dist/native/{p-ce97ce24.entry.js.map → p-ca39f78d.entry.js.map} +0 -0
- /package/dist/native/{p-647a0765.entry.js.map → p-da2060a5.entry.js.map} +0 -0
- /package/dist/native/{p-14e622e1.entry.js.map → p-e5b7ce4e.entry.js.map} +0 -0
|
@@ -1,9 +1,243 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-dc2723f3.js';
|
|
2
|
-
import { a as startsWithIgnoreCase } from './string.utils-16aed4a7.js';
|
|
1
|
+
import { r as registerInstance, c as createEvent, f as forceUpdate, h, H as Host, g as getElement } from './index-dc2723f3.js';
|
|
3
2
|
import { g as TimeType } from './constants-69bafca2.js';
|
|
4
3
|
import { v as v4 } from './v4-a79185f4.js';
|
|
5
4
|
|
|
6
|
-
const nvFieldtimeCss = "nv-fieldslider .slider-container .track-container:has(.thumb:hover) .track-range{background:var(--components-slider-track-filled-hover)}nv-fieldslider .slider-container .track-container:has(.thumb:hover) .thumb{border-color:var(--components-slider-track-filled-hover)}nv-fieldslider .slider-container .track-container:has(.thumb:focus) .track-range{background:var(--components-slider-track-filled-focus)}nv-fieldslider .slider-container .track-container:has(.thumb:focus) .thumb{border-color:var(--components-slider-track-filled-focus)}nv-fieldslider[error] .slider-container .track-container .track .track-range{background:var(--components-slider-track-filled-error)}nv-fieldslider[error] .slider-container .track-container .track .thumb{border-color:var(--components-slider-track-filled-error)}nv-fieldslider[error] .slider-container .track-container .track .thumb:hover{border-color:var(--components-slider-track-filled-error);outline:calc(var(--focus-outline-stroke) * 1) solid var(--components-slider-track-filled-error);outline-offset:calc(var(--focus-outline-offset) * 1);background-color:var(--components-slider-handler-background-error)}nv-fieldslider[error] .slider-container .track-container .track .thumb:focus{border-color:var(--components-slider-track-filled-error);outline:calc(var(--focus-outline-stroke) * 1) solid var(--components-slider-track-filled-error);outline-offset:calc(var(--focus-outline-offset) * 1);background-color:var(--components-slider-track-filled-error)}nv-fieldslider[error] .slider-container .track-container:has(.thumb:hover) .track-range{background:var(--components-slider-track-filled-error)}nv-fieldslider[error] .slider-container .track-container:has(.thumb:hover) .thumb{border-color:var(--components-slider-track-filled-error)}nv-fieldtime{--nv-field-border-default:var(--components-form-field-border-default);--nv-field-border-hover:var(--components-form-field-border-hover);--nv-field-border-focus:var(--components-form-field-border-focus);--nv-field-border-disabled:var(--components-form-field-border-default);--nv-field-border-readonly:var(--components-form-field-border-default);--nv-field-focus-box-shadow:var(--color-focus-brand);--nv-field-background:var(--components-form-field-background-default);display:flex;flex-direction:column;align-items:flex-start;gap:var(--form-gap-y);box-sizing:border-box;max-width:480px}nv-fieldtime[readonly]:not([readonly=false]){--nv-field-border-default:var(--components-form-field-border-readonly);--nv-field-border-hover:var(--nv-field-border-default);--nv-field-border-focus:var(--components-form-field-border-focus);--nv-field-border-disabled:var(--nv-field-border-default);--nv-field-border-readonly:var(--nv-field-border-default);--nv-field-background:var(--components-form-field-background-readonly)}nv-fieldtime[error]:not([error=false]){--nv-field-border-default:var(--components-form-field-border-error);--nv-field-border-hover:var(--nv-field-border-default);--nv-field-border-focus:var(--nv-field-border-default);--nv-field-border-disabled:var(--nv-field-border-default);--nv-field-border-readonly:var(--nv-field-border-default);--nv-field-focus-box-shadow:var(--color-focus-destructive-in-field)}nv-fieldtime[success]:not([success=false]){--nv-field-border-default:var(--components-form-field-border-success);--nv-field-border-hover:var(--nv-field-border-default);--nv-field-border-focus:var(--nv-field-border-default);--nv-field-border-disabled:var(--nv-field-border-default);--nv-field-border-readonly:var(--nv-field-border-default);--nv-field-focus-box-shadow:var(--color-focus-success)}nv-fieldtime[required]:not([required=false]) label::after{content:\"*\";color:var(--components-form-text-required);font-weight:var(--font-weight-high-emphasis)}nv-fieldtime label{display:flex;align-items:center;gap:var(--form-label-gap);align-self:stretch;color:var(--components-form-text-label-default);font-family:var(--font-family-default), var(--font-family-fallback), sans-serif;font-size:var(--form-label-font-size);font-style:normal;font-weight:var(--font-weight-medium-emphasis);line-height:var(--form-label-line-height)}nv-fieldtime nv-popover{width:100%;display:block}nv-fieldtime nv-popover [data-scope=popover]{padding:var(--list-dropdown-padding);background-color:var(--components-list-dropdown-background);border:1px solid var(--components-list-dropdown-border);width:100%}nv-fieldtime .input-wrapper{display:flex;flex-wrap:wrap;gap:var(--form-gap-x);align-items:stretch;align-self:stretch;width:100%}nv-fieldtime .input-container{display:flex;flex-grow:1;justify-content:center;align-items:center;align-self:stretch;border-radius:var(--form-field-radius);border-width:1px;border-style:solid;border-color:var(--nv-field-border-default);opacity:var(--components-form-opacity-default, 1);background:var(--nv-field-background);transition:all 150ms ease-out;display:flex;justify-content:flex-start;align-items:center;position:relative;width:100%;min-height:40px;gap:0;padding-left:var(--form-field-padding-x)}nv-fieldtime .input-container:hover{border-color:var(--nv-field-border-hover)}nv-fieldtime .input-container:focus-within,nv-fieldtime .input-container:focus-within:hover,nv-fieldtime .input-container:focus,nv-fieldtime .input-container:focus:hover{border-color:var(--nv-field-border-focus);box-shadow:0px 0px 0px var(--focus-field-stroke) var(--nv-field-focus-box-shadow)}nv-fieldtime .input-container:has(input:read-only){opacity:0.5;background-color:var(--components-form-field-background-readonly);border-color:var(--nv-field-border-readonly)}nv-fieldtime .input-container:has(input:disabled){opacity:0.5;background-color:var(--components-form-field-background-disabled);border-color:var(--nv-field-border-disabled)}nv-fieldtime .input-container input.time-input{display:flex;align-items:center;flex:1 0 0;overflow:hidden;background-color:transparent;color:var(--components-form-field-content-text);padding:var(--form-field-padding-y) var(--form-field-padding-x);font-size:var(--form-field-font-size);font-style:normal;font-weight:var(--font-weight-medium-emphasis);line-height:var(--form-field-line-height);width:100%;width:100%;min-width:24px;flex:0 0 24px;text-align:center;padding:0;margin:0}nv-fieldtime .input-container input.time-input:focus{outline:none}nv-fieldtime .input-container input.time-input::placeholder{overflow:hidden;color:var(--components-form-field-content-placeholder);text-overflow:ellipsis;font-family:var(--font-family-default), var(--font-family-fallback), sans-serif;font-size:var(--form-field-font-size);font-style:normal;font-weight:var(--font-weight-low-emphasis);line-height:var(--form-field-line-height)}nv-fieldtime .input-container input.time-input[type=password]::-ms-clear,nv-fieldtime .input-container input.time-input[type=password]::-ms-reveal{display:none;width:0;height:0}nv-fieldtime .input-container input.time-input::-webkit-inner-spin-button,nv-fieldtime .input-container input.time-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}nv-fieldtime .input-container span{width:100%;text-align:center;min-width:24px;flex:0 0 24px;padding:0 4px;color:var(--components-form-field-content-text)}nv-fieldtime .input-container>nv-iconbutton{border:0px;border-radius:0px;margin-left:auto}nv-fieldtime .input-container>nv-iconbutton:focus-visible{border-radius:var(--button-md-border-radius);outline-offset:-3px}nv-fieldtime .input-container>nv-iconbutton:last-of-type{border-top-right-radius:var(--form-field-radius);border-bottom-right-radius:var(--form-field-radius)}nv-fieldtime .input-container nv-icon.validation{color:var(--nv-field-border-default);position:absolute;right:50px;top:50%;transform:translateY(-50%)}nv-fieldtime .input-container:focus,nv-fieldtime .input-container:focus-within{border-color:var(--color-focus-brand);box-shadow:0px 0px 0px var(--focus-field-stroke) var(--color-focus-brand)}nv-fieldtime .description{display:flex;align-items:center;align-self:stretch;gap:var(--spacing-1);color:var(--components-form-text-description-default);font-family:var(--font-family-default), var(--font-family-fallback), sans-serif;font-size:var(--form-description-font-size);font-style:normal;line-height:var(--form-description-line-height)}nv-fieldtime .error-description{display:flex;align-items:center;align-self:stretch;gap:var(--spacing-1);color:var(--components-form-text-description-default);font-family:var(--font-family-default), var(--font-family-fallback), sans-serif;font-size:var(--form-description-font-size);font-style:normal;line-height:var(--form-description-line-height);color:var(--components-form-text-description-error)}nv-fieldtime hr{border:none;border-top:1px solid var(--dropdown-divider-color, #ccc);margin:0.5rem 0}nv-fieldtime .time-dropdown{width:100%}nv-fieldtime .time-dropdown .time-columns{display:flex;justify-content:flex-start;align-items:center}nv-fieldtime .time-dropdown .time-columns .time-column{flex:1;text-align:center;max-height:200px;overflow-y:auto;scroll-behavior:smooth;scrollbar-gutter:stable both-edges;scrollbar-gutter:auto}nv-fieldtime .time-dropdown .time-columns .time-column::-webkit-scrollbar{width:6px;height:6px}nv-fieldtime .time-dropdown .time-columns .time-column::-webkit-scrollbar-track{background-color:var(--color-level-10-background);border-radius:9999px}nv-fieldtime .time-dropdown .time-columns .time-column::-webkit-scrollbar-thumb{background-color:var(--color-gray-200);border-radius:9999px}nv-fieldtime .time-dropdown .time-columns .time-column:last-child{border-right:none}nv-fieldtime .time-dropdown .time-columns .time-column .time-option{padding:var(--calendar-padding);text-align:center;cursor:pointer;transition:background-color 0.2s;border-radius:var(--list-dropdown-item-radius);color:var(--components-calendar-cell-text);font-size:var(--font-size-sm);display:flex;justify-content:center;align-items:center}nv-fieldtime .time-dropdown .time-columns .time-column .time-option:hover{background-color:var(--components-calendar-cell-background-hover);color:var(--components-calendar-cell-text-hover)}nv-fieldtime .time-dropdown .time-columns .time-column .time-option:focus,nv-fieldtime .time-dropdown .time-columns .time-column .time-option:focus-within{background-color:var(--components-calendar-cell-background-hover);color:var(--components-calendar-cell-text-hover)}nv-fieldtime .time-dropdown .time-columns .time-column .time-option.selected{background-color:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected)}nv-fieldtime .time-dropdown .time-columns .time-column .time-option.highlighted{background-color:var(--components-calendar-cell-background-hover);color:var(--components-menu-contextual-item-content-hover)}";
|
|
5
|
+
/**
|
|
6
|
+
* Format configurations for all supported time formats
|
|
7
|
+
*/
|
|
8
|
+
const FORMAT_CONFIGS = {
|
|
9
|
+
'HH': {
|
|
10
|
+
pattern: /^([0-1]?[0-9]|2[0-3])$/,
|
|
11
|
+
parts: [TimeType.Hours],
|
|
12
|
+
defaultValue: '00',
|
|
13
|
+
maxLength: 2,
|
|
14
|
+
},
|
|
15
|
+
'HH:mm': {
|
|
16
|
+
pattern: /^([0-1]?[0-9]|2[0-3]):([0-5]?[0-9])$/,
|
|
17
|
+
parts: [TimeType.Hours, TimeType.Minutes],
|
|
18
|
+
defaultValue: '00:00',
|
|
19
|
+
maxLength: 5,
|
|
20
|
+
},
|
|
21
|
+
'HH:mm:ss': {
|
|
22
|
+
pattern: /^([0-1]?[0-9]|2[0-3]):([0-5]?[0-9]):([0-5]?[0-9])$/,
|
|
23
|
+
parts: [TimeType.Hours, TimeType.Minutes, TimeType.Seconds],
|
|
24
|
+
defaultValue: '00:00:00',
|
|
25
|
+
maxLength: 8,
|
|
26
|
+
},
|
|
27
|
+
'hh': {
|
|
28
|
+
pattern: /^(0?[1-9]|1[0-2])$/,
|
|
29
|
+
parts: [TimeType.Hours],
|
|
30
|
+
defaultValue: '01',
|
|
31
|
+
maxLength: 2,
|
|
32
|
+
},
|
|
33
|
+
'hh:mm': {
|
|
34
|
+
pattern: /^(0?[1-9]|1[0-2]):([0-5]?[0-9])$/,
|
|
35
|
+
parts: [TimeType.Hours, TimeType.Minutes],
|
|
36
|
+
defaultValue: '01:00',
|
|
37
|
+
maxLength: 5,
|
|
38
|
+
},
|
|
39
|
+
'hh:mm:ss': {
|
|
40
|
+
pattern: /^(0?[1-9]|1[0-2]):([0-5]?[0-9]):([0-5]?[0-9])$/,
|
|
41
|
+
parts: [TimeType.Hours, TimeType.Minutes, TimeType.Seconds],
|
|
42
|
+
defaultValue: '01:00:00',
|
|
43
|
+
maxLength: 8,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Returns the visible time types for a given format
|
|
48
|
+
* @param {string} format - The time format string
|
|
49
|
+
* @returns {TimeType[]} Array of TimeType values that should be visible
|
|
50
|
+
*/
|
|
51
|
+
function getVisibleTimeTypes(format) {
|
|
52
|
+
const config = FORMAT_CONFIGS[format];
|
|
53
|
+
if (!config) {
|
|
54
|
+
// Fallback for unknown formats
|
|
55
|
+
return [TimeType.Hours, TimeType.Minutes, TimeType.Seconds];
|
|
56
|
+
}
|
|
57
|
+
return config.parts;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Validates if a given value string matches the expected format pattern
|
|
61
|
+
* @param {string} value - The time value string to validate
|
|
62
|
+
* @param {string} format - The expected time format
|
|
63
|
+
* @returns {boolean} True if the value matches the format, false otherwise
|
|
64
|
+
*/
|
|
65
|
+
function isValidFormatValue(value, format) {
|
|
66
|
+
if (!value || !format) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const config = FORMAT_CONFIGS[format];
|
|
70
|
+
if (!config) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return config.pattern.test(value);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Parses a time value string according to the specified format
|
|
77
|
+
* Handles both full and partial time strings with backward compatibility
|
|
78
|
+
* @param {string} value - The time value string to parse
|
|
79
|
+
* @param {string} format - The target time format
|
|
80
|
+
* @returns {TimeComponents} TimeComponents object with parsed hours, minutes, and seconds
|
|
81
|
+
*/
|
|
82
|
+
function parseValueByFormat(value, format) {
|
|
83
|
+
const config = FORMAT_CONFIGS[format];
|
|
84
|
+
const defaultComponents = {
|
|
85
|
+
hours: format.startsWith('hh') ? '01' : '00',
|
|
86
|
+
minutes: '00',
|
|
87
|
+
seconds: '00',
|
|
88
|
+
};
|
|
89
|
+
if (!value || !config) {
|
|
90
|
+
return defaultComponents;
|
|
91
|
+
}
|
|
92
|
+
// Clean the input value - remove non-numeric characters except colons
|
|
93
|
+
const cleanValue = value.replace(/[^0-9:]/g, '');
|
|
94
|
+
// Try to match the exact format first
|
|
95
|
+
const exactMatch = cleanValue.match(config.pattern);
|
|
96
|
+
if (exactMatch) {
|
|
97
|
+
return extractComponentsFromMatch(exactMatch, format);
|
|
98
|
+
}
|
|
99
|
+
// Handle backward compatibility - parse full format values when format is shorter
|
|
100
|
+
const fullFormatPattern = /^([0-1]?[0-9]|2[0-3]):([0-5]?[0-9]):([0-5]?[0-9])$/;
|
|
101
|
+
const fullMatch = cleanValue.match(fullFormatPattern);
|
|
102
|
+
if (fullMatch) {
|
|
103
|
+
const fullComponents = extractComponentsFromMatch(fullMatch, 'HH:mm:ss');
|
|
104
|
+
return extractRelevantComponents(fullComponents, format);
|
|
105
|
+
}
|
|
106
|
+
// Handle partial format values - try to parse what we can
|
|
107
|
+
const parts = cleanValue.split(':');
|
|
108
|
+
const result = Object.assign({}, defaultComponents);
|
|
109
|
+
if (parts.length >= 1 && parts[0]) {
|
|
110
|
+
const hours = parseInt(parts[0], 10);
|
|
111
|
+
if (!isNaN(hours)) {
|
|
112
|
+
if (format.startsWith('hh')) {
|
|
113
|
+
// 12-hour format validation
|
|
114
|
+
if (hours >= 1 && hours <= 12) {
|
|
115
|
+
result.hours = hours.toString().padStart(2, '0');
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
// Invalid hour for 12-hour format, keep default
|
|
119
|
+
result.hours = defaultComponents.hours;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
// 24-hour format validation
|
|
124
|
+
if (hours >= 0 && hours <= 23) {
|
|
125
|
+
result.hours = hours.toString().padStart(2, '0');
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Invalid hour for 24-hour format, keep default
|
|
129
|
+
result.hours = defaultComponents.hours;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (parts.length >= 2 &&
|
|
135
|
+
parts[1] &&
|
|
136
|
+
config.parts.includes(TimeType.Minutes)) {
|
|
137
|
+
const minutes = parseInt(parts[1], 10);
|
|
138
|
+
if (!isNaN(minutes) && minutes >= 0 && minutes <= 59) {
|
|
139
|
+
result.minutes = minutes.toString().padStart(2, '0');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (parts.length >= 3 &&
|
|
143
|
+
parts[2] &&
|
|
144
|
+
config.parts.includes(TimeType.Seconds)) {
|
|
145
|
+
const seconds = parseInt(parts[2], 10);
|
|
146
|
+
if (!isNaN(seconds) && seconds >= 0 && seconds <= 59) {
|
|
147
|
+
result.seconds = seconds.toString().padStart(2, '0');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Extracts time components from a regex match result
|
|
154
|
+
* @param {RegExpMatchArray} match - The regex match result
|
|
155
|
+
* @param {string} format - The format that was matched
|
|
156
|
+
* @returns {TimeComponents} TimeComponents object
|
|
157
|
+
*/
|
|
158
|
+
function extractComponentsFromMatch(match, format) {
|
|
159
|
+
const result = {
|
|
160
|
+
hours: format.startsWith('hh') ? '01' : '00',
|
|
161
|
+
minutes: '00',
|
|
162
|
+
seconds: '00',
|
|
163
|
+
};
|
|
164
|
+
if (match[1]) {
|
|
165
|
+
result.hours = parseInt(match[1], 10).toString().padStart(2, '0');
|
|
166
|
+
}
|
|
167
|
+
if (match[2]) {
|
|
168
|
+
result.minutes = parseInt(match[2], 10).toString().padStart(2, '0');
|
|
169
|
+
}
|
|
170
|
+
if (match[3]) {
|
|
171
|
+
result.seconds = parseInt(match[3], 10).toString().padStart(2, '0');
|
|
172
|
+
}
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Extracts only the relevant components based on the target format
|
|
177
|
+
* @param {TimeComponents} components - Full time components
|
|
178
|
+
* @param {string} format - Target format to extract components for
|
|
179
|
+
* @returns {TimeComponents} TimeComponents with only relevant parts
|
|
180
|
+
*/
|
|
181
|
+
function extractRelevantComponents(components, format) {
|
|
182
|
+
const config = FORMAT_CONFIGS[format];
|
|
183
|
+
const result = {
|
|
184
|
+
hours: format.startsWith('hh') ? '01' : '00',
|
|
185
|
+
minutes: '00',
|
|
186
|
+
seconds: '00',
|
|
187
|
+
};
|
|
188
|
+
if (config.parts.includes(TimeType.Hours)) {
|
|
189
|
+
// Validate hours for the target format
|
|
190
|
+
const hours = parseInt(components.hours, 10);
|
|
191
|
+
if (format.startsWith('hh')) {
|
|
192
|
+
// 12-hour format validation
|
|
193
|
+
if (hours >= 1 && hours <= 12) {
|
|
194
|
+
result.hours = components.hours;
|
|
195
|
+
}
|
|
196
|
+
// If invalid, keep the default '01'
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
// 24-hour format validation
|
|
200
|
+
if (hours >= 0 && hours <= 23) {
|
|
201
|
+
result.hours = components.hours;
|
|
202
|
+
}
|
|
203
|
+
// If invalid, keep the default '00'
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (config.parts.includes(TimeType.Minutes)) {
|
|
207
|
+
result.minutes = components.minutes;
|
|
208
|
+
}
|
|
209
|
+
if (config.parts.includes(TimeType.Seconds)) {
|
|
210
|
+
result.seconds = components.seconds;
|
|
211
|
+
}
|
|
212
|
+
return result;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Reconstructs a time string from components according to the specified format
|
|
216
|
+
* @param {TimeComponents} components - Time components to reconstruct
|
|
217
|
+
* @param {string} format - Target format for reconstruction
|
|
218
|
+
* @returns {string} Formatted time string
|
|
219
|
+
*/
|
|
220
|
+
function reconstructTimeByFormat(components, format) {
|
|
221
|
+
const config = FORMAT_CONFIGS[format];
|
|
222
|
+
if (!config) {
|
|
223
|
+
return `${components.hours}:${components.minutes}:${components.seconds}`;
|
|
224
|
+
}
|
|
225
|
+
switch (format) {
|
|
226
|
+
case 'HH':
|
|
227
|
+
case 'hh':
|
|
228
|
+
return components.hours;
|
|
229
|
+
case 'HH:mm':
|
|
230
|
+
case 'hh:mm':
|
|
231
|
+
return `${components.hours}:${components.minutes}`;
|
|
232
|
+
case 'HH:mm:ss':
|
|
233
|
+
case 'hh:mm:ss':
|
|
234
|
+
return `${components.hours}:${components.minutes}:${components.seconds}`;
|
|
235
|
+
default:
|
|
236
|
+
return `${components.hours}:${components.minutes}:${components.seconds}`;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const nvFieldtimeCss = "nv-fieldslider .slider-container .track-container:has(.thumb:hover) .track-range{background:var(--components-slider-track-filled-hover)}nv-fieldslider .slider-container .track-container:has(.thumb:hover) .thumb{border-color:var(--components-slider-track-filled-hover)}nv-fieldslider .slider-container .track-container:has(.thumb:focus) .track-range{background:var(--components-slider-track-filled-focus)}nv-fieldslider .slider-container .track-container:has(.thumb:focus) .thumb{border-color:var(--components-slider-track-filled-focus)}nv-fieldslider[error] .slider-container .track-container .track .track-range{background:var(--components-slider-track-filled-error)}nv-fieldslider[error] .slider-container .track-container .track .thumb{border-color:var(--components-slider-track-filled-error)}nv-fieldslider[error] .slider-container .track-container .track .thumb:hover{border-color:var(--components-slider-track-filled-error);outline:calc(var(--focus-outline-stroke) * 1) solid var(--components-slider-track-filled-error);outline-offset:calc(var(--focus-outline-offset) * 1);background-color:var(--components-slider-handler-background-error)}nv-fieldslider[error] .slider-container .track-container .track .thumb:focus{border-color:var(--components-slider-track-filled-error);outline:calc(var(--focus-outline-stroke) * 1) solid var(--components-slider-track-filled-error);outline-offset:calc(var(--focus-outline-offset) * 1);background-color:var(--components-slider-track-filled-error)}nv-fieldslider[error] .slider-container .track-container:has(.thumb:hover) .track-range{background:var(--components-slider-track-filled-error)}nv-fieldslider[error] .slider-container .track-container:has(.thumb:hover) .thumb{border-color:var(--components-slider-track-filled-error)}nv-fieldtime{--nv-field-border-default:var(--components-form-field-border-default);--nv-field-border-hover:var(--components-form-field-border-hover);--nv-field-border-focus:var(--components-form-field-border-focus);--nv-field-border-disabled:var(--components-form-field-border-default);--nv-field-border-readonly:var(--components-form-field-border-default);--nv-field-focus-box-shadow:var(--color-focus-brand);--nv-field-background:var(--components-form-field-background-default);display:flex;flex-direction:column;align-items:flex-start;gap:var(--form-gap-y);box-sizing:border-box;max-width:480px}nv-fieldtime[readonly]:not([readonly=false]){--nv-field-border-default:var(--components-form-field-border-readonly);--nv-field-border-hover:var(--nv-field-border-default);--nv-field-border-focus:var(--components-form-field-border-focus);--nv-field-border-disabled:var(--nv-field-border-default);--nv-field-border-readonly:var(--nv-field-border-default);--nv-field-background:var(--components-form-field-background-readonly)}nv-fieldtime[error]:not([error=false]){--nv-field-border-default:var(--components-form-field-border-error);--nv-field-border-hover:var(--nv-field-border-default);--nv-field-border-focus:var(--nv-field-border-default);--nv-field-border-disabled:var(--nv-field-border-default);--nv-field-border-readonly:var(--nv-field-border-default);--nv-field-focus-box-shadow:var(--color-focus-destructive-in-field)}nv-fieldtime[success]:not([success=false]){--nv-field-border-default:var(--components-form-field-border-success);--nv-field-border-hover:var(--nv-field-border-default);--nv-field-border-focus:var(--nv-field-border-default);--nv-field-border-disabled:var(--nv-field-border-default);--nv-field-border-readonly:var(--nv-field-border-default);--nv-field-focus-box-shadow:var(--color-focus-success)}nv-fieldtime[required]:not([required=false]) label::after{content:\"*\";color:var(--components-form-text-required);font-weight:var(--font-weight-high-emphasis)}nv-fieldtime label{display:flex;align-items:center;gap:var(--form-label-gap);align-self:stretch;color:var(--components-form-text-label-default);font-family:var(--font-family-default), var(--font-family-fallback), sans-serif;font-size:var(--form-label-font-size);font-style:normal;font-weight:var(--font-weight-medium-emphasis);line-height:var(--form-label-line-height)}nv-fieldtime nv-popover{width:100%;display:block;z-index:9999}nv-fieldtime nv-popover [data-scope=popover]{padding:var(--list-dropdown-padding);background-color:var(--components-list-dropdown-background);border:1px solid var(--components-list-dropdown-border);width:100%}nv-fieldtime .input-wrapper{display:flex;flex-wrap:wrap;gap:var(--form-gap-x);align-items:stretch;align-self:stretch;width:100%}nv-fieldtime .input-container{display:flex;flex-grow:1;justify-content:center;align-items:center;align-self:stretch;border-radius:var(--form-field-radius);border-width:1px;border-style:solid;border-color:var(--nv-field-border-default);opacity:var(--components-form-opacity-default, 1);background:var(--nv-field-background);transition:all 150ms ease-out;display:flex;justify-content:flex-start;align-items:center;position:relative;width:100%;min-height:40px;gap:0;padding-left:var(--form-field-padding-x)}nv-fieldtime .input-container:hover{border-color:var(--nv-field-border-hover)}nv-fieldtime .input-container:focus-within,nv-fieldtime .input-container:focus-within:hover,nv-fieldtime .input-container:focus,nv-fieldtime .input-container:focus:hover{border-color:var(--nv-field-border-focus);box-shadow:0px 0px 0px var(--focus-field-stroke) var(--nv-field-focus-box-shadow)}nv-fieldtime .input-container:has(input:read-only){opacity:0.5;background-color:var(--components-form-field-background-readonly);border-color:var(--nv-field-border-readonly)}nv-fieldtime .input-container:has(input:disabled){opacity:0.5;background-color:var(--components-form-field-background-disabled);border-color:var(--nv-field-border-disabled)}nv-fieldtime .input-container input.time-input{display:flex;align-items:center;flex:1 0 0;overflow:hidden;background-color:transparent;color:var(--components-form-field-content-text);padding:var(--form-field-padding-y) var(--form-field-padding-x);font-size:var(--form-field-font-size);font-style:normal;font-weight:var(--font-weight-medium-emphasis);line-height:var(--form-field-line-height);width:100%;width:100%;min-width:24px;flex:0 0 24px;text-align:center;padding:0;margin:0}nv-fieldtime .input-container input.time-input:focus{outline:none}nv-fieldtime .input-container input.time-input::placeholder{overflow:hidden;color:var(--components-form-field-content-placeholder);text-overflow:ellipsis;font-family:var(--font-family-default), var(--font-family-fallback), sans-serif;font-size:var(--form-field-font-size);font-style:normal;font-weight:var(--font-weight-low-emphasis);line-height:var(--form-field-line-height)}nv-fieldtime .input-container input.time-input[type=password]::-ms-clear,nv-fieldtime .input-container input.time-input[type=password]::-ms-reveal{display:none;width:0;height:0}nv-fieldtime .input-container input.time-input::-webkit-inner-spin-button,nv-fieldtime .input-container input.time-input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}nv-fieldtime .input-container span{width:100%;text-align:center;min-width:24px;flex:0 0 24px;padding:0 4px;color:var(--components-form-field-content-text)}nv-fieldtime .input-container>nv-iconbutton{border:0px;border-radius:0px;margin-left:auto}nv-fieldtime .input-container>nv-iconbutton:focus-visible{border-radius:var(--button-md-border-radius);outline-offset:-3px}nv-fieldtime .input-container>nv-iconbutton:last-of-type{border-top-right-radius:var(--form-field-radius);border-bottom-right-radius:var(--form-field-radius)}nv-fieldtime .input-container nv-icon.validation{color:var(--nv-field-border-default);position:absolute;right:50px;top:50%;transform:translateY(-50%)}nv-fieldtime .input-container:focus,nv-fieldtime .input-container:focus-within{border-color:var(--color-focus-brand);box-shadow:0px 0px 0px var(--focus-field-stroke) var(--color-focus-brand)}nv-fieldtime .description{display:flex;align-items:center;align-self:stretch;gap:var(--spacing-1);color:var(--components-form-text-description-default);font-family:var(--font-family-default), var(--font-family-fallback), sans-serif;font-size:var(--form-description-font-size);font-style:normal;line-height:var(--form-description-line-height)}nv-fieldtime .error-description{display:flex;align-items:center;align-self:stretch;gap:var(--spacing-1);color:var(--components-form-text-description-default);font-family:var(--font-family-default), var(--font-family-fallback), sans-serif;font-size:var(--form-description-font-size);font-style:normal;line-height:var(--form-description-line-height);color:var(--components-form-text-description-error)}nv-fieldtime hr{border:none;border-top:1px solid var(--dropdown-divider-color, #ccc);margin:0.5rem 0}nv-fieldtime .time-dropdown{width:100%}nv-fieldtime .time-dropdown .time-columns{display:flex;justify-content:flex-start;align-items:center}nv-fieldtime .time-dropdown .time-columns .time-column{flex:1;text-align:center;max-height:200px;overflow-y:auto;scroll-behavior:smooth;scrollbar-gutter:stable both-edges;scrollbar-gutter:auto}nv-fieldtime .time-dropdown .time-columns .time-column::-webkit-scrollbar{width:6px;height:6px}nv-fieldtime .time-dropdown .time-columns .time-column::-webkit-scrollbar-track{background-color:var(--color-level-10-background);border-radius:9999px}nv-fieldtime .time-dropdown .time-columns .time-column::-webkit-scrollbar-thumb{background-color:var(--color-gray-200);border-radius:9999px}nv-fieldtime .time-dropdown .time-columns .time-column:last-child{border-right:none}nv-fieldtime .time-dropdown .time-columns .time-column .time-option{padding:var(--calendar-padding);text-align:center;cursor:pointer;transition:background-color 0.2s;border-radius:var(--list-dropdown-item-radius);color:var(--components-calendar-cell-text);font-size:var(--font-size-sm);display:flex;justify-content:center;align-items:center}nv-fieldtime .time-dropdown .time-columns .time-column .time-option:hover{background-color:var(--components-calendar-cell-background-hover);color:var(--components-calendar-cell-text-hover)}nv-fieldtime .time-dropdown .time-columns .time-column .time-option:focus,nv-fieldtime .time-dropdown .time-columns .time-column .time-option:focus-within{background-color:var(--components-calendar-cell-background-hover);color:var(--components-calendar-cell-text-hover)}nv-fieldtime .time-dropdown .time-columns .time-column .time-option.selected{background-color:var(--components-calendar-cell-background-selected);color:var(--components-calendar-cell-text-selected)}nv-fieldtime .time-dropdown .time-columns .time-column .time-option.highlighted{background-color:var(--components-calendar-cell-background-hover);color:var(--components-menu-contextual-item-content-hover)}";
|
|
7
241
|
const NvFieldtimeStyle0 = nvFieldtimeCss;
|
|
8
242
|
|
|
9
243
|
const NvFieldtime = class {
|
|
@@ -63,6 +297,10 @@ const NvFieldtime = class {
|
|
|
63
297
|
* - hh: 12-hour format (01-12)
|
|
64
298
|
* - hh:mm: 12-hour format with minutes (01:00-12:59)
|
|
65
299
|
* - hh:mm:ss: 12-hour format with minutes and seconds (01:00:00-12:59:59)
|
|
300
|
+
*
|
|
301
|
+
* The component automatically shows only the relevant input fields based on the selected format.
|
|
302
|
+
* When the format changes dynamically, the component re-parses the current value and updates
|
|
303
|
+
* the visible fields accordingly.
|
|
66
304
|
*/
|
|
67
305
|
this.format = 'HH:mm:ss';
|
|
68
306
|
/**
|
|
@@ -91,7 +329,7 @@ const NvFieldtime = class {
|
|
|
91
329
|
this.open = event.detail;
|
|
92
330
|
}
|
|
93
331
|
handleKeyDown(event) {
|
|
94
|
-
var _a, _b
|
|
332
|
+
var _a, _b;
|
|
95
333
|
if (!this.open) {
|
|
96
334
|
if (event.key === 'ArrowDown') {
|
|
97
335
|
this.open = true;
|
|
@@ -126,20 +364,22 @@ const NvFieldtime = class {
|
|
|
126
364
|
else if (event.key === 'Enter' && currentIndex >= 0) {
|
|
127
365
|
event.preventDefault();
|
|
128
366
|
items[currentIndex].click();
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
(
|
|
136
|
-
(
|
|
367
|
+
// Navigate to the next visible field
|
|
368
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
369
|
+
const currentTypeIndex = visibleTypes.indexOf(this.typeFocused);
|
|
370
|
+
const nextTypeIndex = currentTypeIndex + 1;
|
|
371
|
+
if (nextTypeIndex < visibleTypes.length) {
|
|
372
|
+
const nextType = visibleTypes[nextTypeIndex];
|
|
373
|
+
(_a = this.inputElements[nextType]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
374
|
+
(_b = this.inputElements[nextType]) === null || _b === void 0 ? void 0 : _b.select();
|
|
137
375
|
}
|
|
138
376
|
}
|
|
139
377
|
else if (event.key === 'Escape') {
|
|
140
378
|
event.preventDefault();
|
|
141
|
-
|
|
142
|
-
|
|
379
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
380
|
+
const firstVisibleType = visibleTypes[0];
|
|
381
|
+
if (firstVisibleType && this.inputElements[firstVisibleType]) {
|
|
382
|
+
this.inputElements[firstVisibleType].blur();
|
|
143
383
|
}
|
|
144
384
|
}
|
|
145
385
|
}
|
|
@@ -147,6 +387,18 @@ const NvFieldtime = class {
|
|
|
147
387
|
/****************************************************************************/
|
|
148
388
|
//#region WATCHERS
|
|
149
389
|
handleValueChange(newValue) {
|
|
390
|
+
// Parse the new value and ensure it's in the correct format
|
|
391
|
+
if (newValue) {
|
|
392
|
+
const components = parseValueByFormat(newValue, this.format);
|
|
393
|
+
const formattedValue = reconstructTimeByFormat(components, this.format);
|
|
394
|
+
// Only emit if the formatted value is different from what we received
|
|
395
|
+
// This prevents infinite loops while ensuring format consistency
|
|
396
|
+
if (formattedValue !== newValue) {
|
|
397
|
+
this.value = formattedValue;
|
|
398
|
+
return; // The watcher will be called again with the formatted value
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
// Emit the value in the correct format
|
|
150
402
|
this.valueChanged.emit(newValue);
|
|
151
403
|
}
|
|
152
404
|
handleOpenChange(newOpen) {
|
|
@@ -161,12 +413,36 @@ const NvFieldtime = class {
|
|
|
161
413
|
this.updateColumnHighlight(secondsSelector, this.seconds);
|
|
162
414
|
}
|
|
163
415
|
}
|
|
416
|
+
handleFormatChange(newFormat, oldFormat) {
|
|
417
|
+
if (newFormat === oldFormat) {
|
|
418
|
+
return; // No change, nothing to do
|
|
419
|
+
}
|
|
420
|
+
// Re-parse the current value with the new format
|
|
421
|
+
const currentValue = this.value || this.reconstructTime();
|
|
422
|
+
// Parse the current value using the old format to get the time components
|
|
423
|
+
const components = parseValueByFormat(currentValue, oldFormat || 'HH:mm:ss');
|
|
424
|
+
// Update the component state with the parsed components
|
|
425
|
+
this.hours = components.hours;
|
|
426
|
+
this.minutes = components.minutes;
|
|
427
|
+
this.seconds = components.seconds;
|
|
428
|
+
// Reconstruct the time value in the new format
|
|
429
|
+
const newValue = reconstructTimeByFormat(components, newFormat);
|
|
430
|
+
// Update the value, which will trigger the value watcher and emit the event
|
|
431
|
+
this.value = newValue;
|
|
432
|
+
// Force a re-render to update the visible input fields
|
|
433
|
+
forceUpdate(this.el);
|
|
434
|
+
}
|
|
164
435
|
//#endregion WATCHERS
|
|
165
436
|
/****************************************************************************/
|
|
166
437
|
//#region METHODS
|
|
167
438
|
handleInputChange(e, type) {
|
|
168
439
|
const inputElement = e.target;
|
|
169
440
|
const inputValue = inputElement.value.replace(/[^0-9]/g, ''); // Only keep numeric input
|
|
441
|
+
// Check if this field is visible for the current format
|
|
442
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
443
|
+
if (!visibleTypes.includes(type)) {
|
|
444
|
+
return; // Don't process input for non-visible fields
|
|
445
|
+
}
|
|
170
446
|
// Update the time value based on the type
|
|
171
447
|
switch (type) {
|
|
172
448
|
case TimeType.Hours:
|
|
@@ -179,489 +455,230 @@ const NvFieldtime = class {
|
|
|
179
455
|
this.handleSecondsChange(inputValue, type);
|
|
180
456
|
break;
|
|
181
457
|
}
|
|
182
|
-
// Reconstruct time from inputs
|
|
183
|
-
const
|
|
184
|
-
|
|
458
|
+
// Reconstruct time from inputs in the correct format
|
|
459
|
+
const reconstructedValue = this.reconstructTime();
|
|
460
|
+
// Update the value, which will trigger the watcher and emit the event
|
|
461
|
+
this.value = reconstructedValue;
|
|
185
462
|
}
|
|
186
463
|
handleHoursChange(inputValue, type) {
|
|
187
|
-
var _a, _b
|
|
464
|
+
var _a, _b;
|
|
188
465
|
const isHHFormat = this.format.startsWith('HH');
|
|
189
466
|
const maxHours = isHHFormat ? 24 : 12;
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
467
|
+
// Handle empty input
|
|
468
|
+
if (inputValue.length === 0) {
|
|
469
|
+
this.hours = '00';
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
194
472
|
if (inputValue.length === 1) {
|
|
195
473
|
this.inputZeroAdded[type] = true;
|
|
196
474
|
const newInputValue = inputValue.padStart(2, '0');
|
|
197
|
-
|
|
198
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
199
|
-
this.hours = minHour;
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
this.hours = '00';
|
|
203
|
-
reputedToZero = true;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
208
|
-
this.hours = minHour;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
this.hours = newInputValue;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
475
|
+
this.hours = newInputValue;
|
|
214
476
|
}
|
|
215
477
|
else if (this.inputZeroAdded[type]) {
|
|
216
478
|
this.inputZeroAdded[type] = false;
|
|
217
479
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
218
480
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
481
|
+
// Only apply format validation (not min/max constraints)
|
|
219
482
|
if (parsedNewInputValue >= maxHours) {
|
|
220
|
-
|
|
221
|
-
this.hours = minHour;
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
this.hours = '00';
|
|
225
|
-
reputedToZero = true;
|
|
226
|
-
}
|
|
483
|
+
this.hours = '00';
|
|
227
484
|
}
|
|
228
485
|
else {
|
|
229
|
-
|
|
230
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
231
|
-
this.hours = minHour;
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
this.hours = '00';
|
|
235
|
-
reputedToZero = true;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
240
|
-
this.hours = minHour;
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
this.hours = newInputValue;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
486
|
+
this.hours = newInputValue;
|
|
246
487
|
}
|
|
247
488
|
}
|
|
248
489
|
else if (inputValue.length > 2) {
|
|
249
490
|
if (inputValue.startsWith('00')) {
|
|
250
491
|
this.inputZeroAdded[type] = true;
|
|
251
492
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
252
|
-
|
|
253
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
254
|
-
this.hours = minHour;
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
this.hours = '00';
|
|
258
|
-
reputedToZero = true;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
if (minHour && parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
263
|
-
this.hours = minHour;
|
|
264
|
-
}
|
|
265
|
-
else {
|
|
266
|
-
this.hours = newInputValue;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
493
|
+
this.hours = newInputValue;
|
|
269
494
|
}
|
|
270
495
|
else {
|
|
271
496
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
272
497
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
498
|
+
// Only apply format validation (not min/max constraints)
|
|
273
499
|
if (parsedNewInputValue >= maxHours) {
|
|
274
|
-
|
|
275
|
-
this.hours = minHour;
|
|
276
|
-
reputedToZero = true;
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
this.hours = '00';
|
|
280
|
-
reputedToZero = true;
|
|
281
|
-
}
|
|
500
|
+
this.hours = '00';
|
|
282
501
|
}
|
|
283
502
|
else {
|
|
284
|
-
|
|
285
|
-
if (minHour &&
|
|
286
|
-
parseInt(newInputValue, 10) < parseInt(minHour, 10)) {
|
|
287
|
-
this.hours = minHour;
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
this.hours = '00';
|
|
291
|
-
reputedToZero = true;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
else {
|
|
295
|
-
if (minHour && parsedNewInputValue < parseInt(minHour, 10)) {
|
|
296
|
-
this.hours = minHour;
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
this.hours = parsedNewInputValue.toString();
|
|
300
|
-
}
|
|
301
|
-
}
|
|
503
|
+
this.hours = parsedNewInputValue.toString();
|
|
302
504
|
}
|
|
303
505
|
}
|
|
304
506
|
}
|
|
305
507
|
else {
|
|
306
|
-
const
|
|
307
|
-
|
|
508
|
+
const parsedNewInputValue = parseInt(inputValue, 10) || 0;
|
|
509
|
+
// Only apply format validation (not min/max constraints)
|
|
308
510
|
if (parsedNewInputValue >= maxHours) {
|
|
309
|
-
|
|
310
|
-
this.hours = minHour;
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
this.hours = '00';
|
|
314
|
-
reputedToZero = true;
|
|
315
|
-
}
|
|
511
|
+
this.hours = '00';
|
|
316
512
|
}
|
|
317
513
|
else {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
reputedToZero = true;
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
if (minHour && parsedNewInputValue < parseInt(minHour, 10)) {
|
|
324
|
-
this.hours = minHour;
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
this.hours = parsedNewInputValue.toString();
|
|
328
|
-
}
|
|
329
|
-
}
|
|
514
|
+
// For direct input, remove unnecessary leading zeros (e.g., '01' becomes '1')
|
|
515
|
+
this.hours = parsedNewInputValue.toString();
|
|
330
516
|
}
|
|
331
517
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
518
|
+
// Auto-navigation to next field when input is complete
|
|
519
|
+
if (this.hours.length >= 1 && !this.inputZeroAdded[type]) {
|
|
520
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
521
|
+
const currentTypeIndex = visibleTypes.indexOf(TimeType.Hours);
|
|
522
|
+
const nextTypeIndex = currentTypeIndex + 1;
|
|
523
|
+
if (nextTypeIndex < visibleTypes.length) {
|
|
524
|
+
const nextType = visibleTypes[nextTypeIndex];
|
|
525
|
+
(_a = this.inputElements[nextType]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
526
|
+
(_b = this.inputElements[nextType]) === null || _b === void 0 ? void 0 : _b.select();
|
|
527
|
+
}
|
|
341
528
|
}
|
|
342
529
|
}
|
|
343
530
|
handleMinutesChange(inputValue, type) {
|
|
344
|
-
var _a, _b
|
|
531
|
+
var _a, _b;
|
|
345
532
|
const maxMinutes = 60;
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
533
|
+
// Handle empty input
|
|
534
|
+
if (inputValue.length === 0) {
|
|
535
|
+
this.minutes = '00';
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
349
538
|
if (inputValue.length === 1) {
|
|
350
539
|
this.inputZeroAdded[type] = true;
|
|
351
540
|
const newInputValue = inputValue.padStart(2, '0');
|
|
352
|
-
|
|
353
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
354
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
-
this.minutes = '00';
|
|
358
|
-
reputedToZero = true;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
363
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
this.minutes = newInputValue;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
541
|
+
this.minutes = newInputValue;
|
|
369
542
|
}
|
|
370
543
|
else if (this.inputZeroAdded[type]) {
|
|
371
544
|
this.inputZeroAdded[type] = false;
|
|
372
545
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
373
546
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
547
|
+
// Only apply format validation (not min/max constraints)
|
|
374
548
|
if (parsedNewInputValue >= maxMinutes) {
|
|
375
|
-
|
|
376
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
377
|
-
}
|
|
378
|
-
else {
|
|
379
|
-
this.minutes = '00';
|
|
380
|
-
reputedToZero = true;
|
|
381
|
-
}
|
|
549
|
+
this.minutes = '00';
|
|
382
550
|
}
|
|
383
551
|
else {
|
|
384
|
-
|
|
385
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
386
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
this.minutes = '00';
|
|
390
|
-
reputedToZero = true;
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
else {
|
|
394
|
-
if (minMinute && parsedNewInputValue < minMinute) {
|
|
395
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
this.minutes = newInputValue;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
552
|
+
this.minutes = newInputValue;
|
|
401
553
|
}
|
|
402
554
|
}
|
|
403
555
|
else if (inputValue.length > 2) {
|
|
404
556
|
if (inputValue.startsWith('00')) {
|
|
405
557
|
this.inputZeroAdded[type] = true;
|
|
406
558
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
407
|
-
|
|
408
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
409
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
410
|
-
}
|
|
411
|
-
else {
|
|
412
|
-
this.minutes = '00';
|
|
413
|
-
reputedToZero = true;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
else {
|
|
417
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
418
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
this.minutes = newInputValue;
|
|
422
|
-
}
|
|
423
|
-
}
|
|
559
|
+
this.minutes = newInputValue;
|
|
424
560
|
}
|
|
425
561
|
else {
|
|
426
562
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
427
563
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
564
|
+
// Only apply format validation (not min/max constraints)
|
|
428
565
|
if (parsedNewInputValue >= maxMinutes) {
|
|
429
|
-
|
|
430
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
431
|
-
}
|
|
432
|
-
else {
|
|
433
|
-
this.minutes = '00';
|
|
434
|
-
reputedToZero = true;
|
|
435
|
-
}
|
|
566
|
+
this.minutes = '00';
|
|
436
567
|
}
|
|
437
568
|
else {
|
|
438
|
-
|
|
439
|
-
if (minMinute && parseInt(newInputValue, 10) < minMinute) {
|
|
440
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
441
|
-
}
|
|
442
|
-
else {
|
|
443
|
-
this.minutes = '00';
|
|
444
|
-
reputedToZero = true;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
else {
|
|
448
|
-
if (minMinute && parsedNewInputValue < minMinute) {
|
|
449
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
450
|
-
}
|
|
451
|
-
else {
|
|
452
|
-
this.minutes = parsedNewInputValue.toString();
|
|
453
|
-
}
|
|
454
|
-
}
|
|
569
|
+
this.minutes = parsedNewInputValue.toString();
|
|
455
570
|
}
|
|
456
571
|
}
|
|
457
572
|
}
|
|
458
573
|
else {
|
|
459
|
-
const
|
|
460
|
-
|
|
574
|
+
const parsedNewInputValue = parseInt(inputValue, 10) || 0;
|
|
575
|
+
// Only apply format validation (not min/max constraints)
|
|
461
576
|
if (parsedNewInputValue >= maxMinutes) {
|
|
462
|
-
|
|
463
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
464
|
-
}
|
|
465
|
-
else {
|
|
466
|
-
this.minutes = '00';
|
|
467
|
-
reputedToZero = true;
|
|
468
|
-
}
|
|
577
|
+
this.minutes = '00';
|
|
469
578
|
}
|
|
470
579
|
else {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
474
|
-
}
|
|
475
|
-
else {
|
|
476
|
-
this.minutes = '00';
|
|
477
|
-
reputedToZero = true;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
else {
|
|
481
|
-
if (minMinute && parsedNewInputValue < minMinute) {
|
|
482
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
483
|
-
}
|
|
484
|
-
else {
|
|
485
|
-
this.minutes = parsedNewInputValue.toString();
|
|
486
|
-
}
|
|
487
|
-
}
|
|
580
|
+
// For direct input, remove unnecessary leading zeros (e.g., '01' becomes '1')
|
|
581
|
+
this.minutes = parsedNewInputValue.toString();
|
|
488
582
|
}
|
|
489
583
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
584
|
+
// Auto-navigation to next field when input is complete
|
|
585
|
+
if (this.minutes.length >= 1 && !this.inputZeroAdded[type]) {
|
|
586
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
587
|
+
const currentTypeIndex = visibleTypes.indexOf(TimeType.Minutes);
|
|
588
|
+
const nextTypeIndex = currentTypeIndex + 1;
|
|
589
|
+
if (nextTypeIndex < visibleTypes.length) {
|
|
590
|
+
const nextType = visibleTypes[nextTypeIndex];
|
|
591
|
+
(_a = this.inputElements[nextType]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
592
|
+
(_b = this.inputElements[nextType]) === null || _b === void 0 ? void 0 : _b.select();
|
|
593
|
+
}
|
|
499
594
|
}
|
|
500
595
|
}
|
|
501
596
|
handleSecondsChange(inputValue, type) {
|
|
502
|
-
var _a, _b, _c, _d;
|
|
503
597
|
const maxSeconds = 60;
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
598
|
+
// Handle empty input
|
|
599
|
+
if (inputValue.length === 0) {
|
|
600
|
+
this.seconds = '00';
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
507
603
|
if (inputValue.length === 1) {
|
|
508
604
|
this.inputZeroAdded[type] = true;
|
|
509
605
|
const newInputValue = inputValue.padStart(2, '0');
|
|
510
|
-
|
|
511
|
-
if (minSecond && parseInt(newInputValue, 10) < minSecond) {
|
|
512
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
this.seconds = '00';
|
|
516
|
-
reputedToZero = true;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
if (minSecond && parseInt(newInputValue, 10) < minSecond) {
|
|
521
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
522
|
-
}
|
|
523
|
-
else {
|
|
524
|
-
this.seconds = newInputValue;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
606
|
+
this.seconds = newInputValue;
|
|
527
607
|
}
|
|
528
608
|
else if (this.inputZeroAdded[type]) {
|
|
529
609
|
this.inputZeroAdded[type] = false;
|
|
530
610
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
531
611
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
612
|
+
// Only apply format validation (not min/max constraints)
|
|
532
613
|
if (parsedNewInputValue >= maxSeconds) {
|
|
533
|
-
|
|
534
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
535
|
-
}
|
|
536
|
-
else {
|
|
537
|
-
this.seconds = '00';
|
|
538
|
-
reputedToZero = true;
|
|
539
|
-
}
|
|
614
|
+
this.seconds = '00';
|
|
540
615
|
}
|
|
541
616
|
else {
|
|
542
|
-
|
|
543
|
-
if (minSecond && parseInt(newInputValue, 10) < minSecond) {
|
|
544
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
545
|
-
}
|
|
546
|
-
else {
|
|
547
|
-
this.seconds = '00';
|
|
548
|
-
reputedToZero = true;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
if (minSecond && parsedNewInputValue < minSecond) {
|
|
553
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
this.seconds = newInputValue;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
617
|
+
this.seconds = newInputValue;
|
|
559
618
|
}
|
|
560
619
|
}
|
|
561
620
|
else if (inputValue.length > 2) {
|
|
562
621
|
const newInputValue = inputValue.slice(1, 3).padStart(2, '0');
|
|
563
622
|
const parsedNewInputValue = parseInt(newInputValue, 10) || 0;
|
|
623
|
+
// Only apply format validation (not min/max constraints)
|
|
564
624
|
if (parsedNewInputValue >= maxSeconds) {
|
|
565
|
-
|
|
566
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
this.seconds = '00';
|
|
570
|
-
reputedToZero = true;
|
|
571
|
-
}
|
|
625
|
+
this.seconds = '00';
|
|
572
626
|
}
|
|
573
627
|
else {
|
|
574
|
-
|
|
575
|
-
if (minSecond && parseInt(newInputValue, 10) < minSecond) {
|
|
576
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
577
|
-
}
|
|
578
|
-
else {
|
|
579
|
-
this.seconds = '00';
|
|
580
|
-
reputedToZero = true;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
else {
|
|
584
|
-
if (minSecond && parsedNewInputValue < minSecond) {
|
|
585
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
586
|
-
}
|
|
587
|
-
else {
|
|
588
|
-
this.seconds = parsedNewInputValue.toString();
|
|
589
|
-
}
|
|
590
|
-
}
|
|
628
|
+
this.seconds = parsedNewInputValue.toString();
|
|
591
629
|
}
|
|
592
630
|
}
|
|
593
631
|
else {
|
|
594
|
-
const
|
|
595
|
-
|
|
632
|
+
const parsedNewInputValue = parseInt(inputValue, 10) || 0;
|
|
633
|
+
// Only apply format validation (not min/max constraints)
|
|
596
634
|
if (parsedNewInputValue >= maxSeconds) {
|
|
597
|
-
|
|
598
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
599
|
-
}
|
|
600
|
-
else {
|
|
601
|
-
this.seconds = '00';
|
|
602
|
-
reputedToZero = true;
|
|
603
|
-
}
|
|
635
|
+
this.seconds = '00';
|
|
604
636
|
}
|
|
605
637
|
else {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
609
|
-
}
|
|
610
|
-
else {
|
|
611
|
-
this.seconds = '00';
|
|
612
|
-
reputedToZero = true;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
else {
|
|
616
|
-
if (minSecond && parsedNewInputValue < minSecond) {
|
|
617
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
618
|
-
}
|
|
619
|
-
else {
|
|
620
|
-
this.seconds = parsedNewInputValue.toString();
|
|
621
|
-
}
|
|
622
|
-
}
|
|
638
|
+
// For direct input, remove unnecessary leading zeros (e.g., '01' becomes '1')
|
|
639
|
+
this.seconds = parsedNewInputValue.toString();
|
|
623
640
|
}
|
|
624
641
|
}
|
|
625
|
-
|
|
626
|
-
(_c = this.inputElements[TimeType.Seconds]) === null || _c === void 0 ? void 0 : _c.focus();
|
|
627
|
-
(_d = this.inputElements[TimeType.Seconds]) === null || _d === void 0 ? void 0 : _d.select();
|
|
628
|
-
}
|
|
642
|
+
// No auto-navigation for seconds field as it's typically the last field
|
|
629
643
|
}
|
|
630
|
-
// Parse a
|
|
644
|
+
// Parse a time string according to the current format
|
|
631
645
|
parseTime(timeString) {
|
|
632
646
|
if (!timeString) {
|
|
633
647
|
return;
|
|
634
648
|
}
|
|
635
|
-
|
|
636
|
-
const
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
const minSecond = this.parseSecond(this.min) || second;
|
|
642
|
-
this.hours = minHour.padStart(2, '0');
|
|
643
|
-
this.minutes = minMinute.toString().padStart(2, '0');
|
|
644
|
-
this.seconds = minSecond.toString().padStart(2, '0');
|
|
649
|
+
// Use format-aware parsing without constraint application
|
|
650
|
+
const components = parseValueByFormat(timeString, this.format);
|
|
651
|
+
// Set the parsed values without applying min/max constraints
|
|
652
|
+
this.hours = components.hours;
|
|
653
|
+
this.minutes = components.minutes;
|
|
654
|
+
this.seconds = components.seconds;
|
|
645
655
|
}
|
|
646
656
|
reconstructTime() {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
657
|
+
const components = {
|
|
658
|
+
hours: this.hours,
|
|
659
|
+
minutes: this.minutes,
|
|
660
|
+
seconds: this.seconds,
|
|
661
|
+
};
|
|
662
|
+
// Ensure the reconstructed time is in the correct format
|
|
663
|
+
const reconstructedTime = reconstructTimeByFormat(components, this.format);
|
|
664
|
+
// Validate that the reconstructed time matches the expected format
|
|
665
|
+
if (!isValidFormatValue(reconstructedTime, this.format)) {
|
|
666
|
+
// If invalid, return the default value for this format
|
|
667
|
+
const config = FORMAT_CONFIGS[this.format];
|
|
668
|
+
return config ? config.defaultValue : reconstructedTime;
|
|
658
669
|
}
|
|
670
|
+
return reconstructedTime;
|
|
659
671
|
}
|
|
660
672
|
handleFocus(type) {
|
|
661
673
|
var _a, _b, _c, _d;
|
|
662
674
|
if (this.readonly || this.disabled) {
|
|
663
675
|
return;
|
|
664
676
|
}
|
|
677
|
+
// Check if this field is visible for the current format
|
|
678
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
679
|
+
if (!visibleTypes.includes(type)) {
|
|
680
|
+
return; // Don't handle focus for non-visible fields
|
|
681
|
+
}
|
|
665
682
|
if (!this.open) {
|
|
666
683
|
this.open = true; // Force the popover to open
|
|
667
684
|
}
|
|
@@ -674,33 +691,23 @@ const NvFieldtime = class {
|
|
|
674
691
|
this.typeFocused = type;
|
|
675
692
|
}
|
|
676
693
|
HandleDropdownIconClick() {
|
|
677
|
-
var _a, _b
|
|
694
|
+
var _a, _b;
|
|
678
695
|
if (this.disabled || this.readonly) {
|
|
679
696
|
return; // Do not toggle if disabled or read-only
|
|
680
697
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
else if (this.open && this.inputElements[TimeType.Minutes]) {
|
|
685
|
-
this.open = false; // Close the popover if it is open
|
|
686
|
-
}
|
|
687
|
-
else if (this.open && this.inputElements[TimeType.Seconds]) {
|
|
698
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
699
|
+
const firstVisibleType = visibleTypes[0];
|
|
700
|
+
if (this.open) {
|
|
688
701
|
this.open = false; // Close the popover if it is open
|
|
689
702
|
}
|
|
690
|
-
else if (!this.open &&
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
(_c = this.inputElements[TimeType.Minutes]) === null || _c === void 0 ? void 0 : _c.focus(); // Focus will open the popover
|
|
696
|
-
(_d = this.inputElements[TimeType.Minutes]) === null || _d === void 0 ? void 0 : _d.select();
|
|
697
|
-
}
|
|
698
|
-
else if (!this.open && this.inputElements[TimeType.Seconds]) {
|
|
699
|
-
(_e = this.inputElements[TimeType.Seconds]) === null || _e === void 0 ? void 0 : _e.focus(); // Focus will open the popover
|
|
700
|
-
(_f = this.inputElements[TimeType.Seconds]) === null || _f === void 0 ? void 0 : _f.select();
|
|
703
|
+
else if (!this.open &&
|
|
704
|
+
firstVisibleType &&
|
|
705
|
+
this.inputElements[firstVisibleType]) {
|
|
706
|
+
(_a = this.inputElements[firstVisibleType]) === null || _a === void 0 ? void 0 : _a.focus(); // Focus will open the popover
|
|
707
|
+
(_b = this.inputElements[firstVisibleType]) === null || _b === void 0 ? void 0 : _b.select();
|
|
701
708
|
}
|
|
702
709
|
else {
|
|
703
|
-
console.warn('nv-fieldtime -> No input elements found to focus
|
|
710
|
+
console.warn('nv-fieldtime -> No visible input elements found to focus');
|
|
704
711
|
}
|
|
705
712
|
}
|
|
706
713
|
updateHighlightedItem(items, index) {
|
|
@@ -719,6 +726,8 @@ const NvFieldtime = class {
|
|
|
719
726
|
}
|
|
720
727
|
handleTimeOptionClick(event, type) {
|
|
721
728
|
const option = parseInt(event.target.textContent || '0', 10);
|
|
729
|
+
// Update the time component directly without constraint validation
|
|
730
|
+
// Dropdown options are already filtered by constraints during generation
|
|
722
731
|
if (type === TimeType.Hours) {
|
|
723
732
|
this.hours = option.toString().padStart(2, '0');
|
|
724
733
|
}
|
|
@@ -728,8 +737,9 @@ const NvFieldtime = class {
|
|
|
728
737
|
else if (type === TimeType.Seconds) {
|
|
729
738
|
this.seconds = option.toString().padStart(2, '0');
|
|
730
739
|
}
|
|
731
|
-
|
|
732
|
-
|
|
740
|
+
// Reconstruct time in the correct format and update value
|
|
741
|
+
const reconstructedTime = this.reconstructTime();
|
|
742
|
+
this.value = reconstructedTime;
|
|
733
743
|
}
|
|
734
744
|
handleInputBlur() {
|
|
735
745
|
// Use a delay to check if the focus is still within the popover
|
|
@@ -788,17 +798,29 @@ const NvFieldtime = class {
|
|
|
788
798
|
}
|
|
789
799
|
generateHourOptions(stepInSeconds) {
|
|
790
800
|
const hourStep = Math.max(1, Math.floor(stepInSeconds / 3600)); // Prevent step < 1
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
const
|
|
794
|
-
const
|
|
795
|
-
const
|
|
801
|
+
const is12HourFormat = this.format.startsWith('hh');
|
|
802
|
+
// Set proper hour ranges based on format
|
|
803
|
+
const defaultMaxHour = is12HourFormat ? 12 : 23;
|
|
804
|
+
const defaultMinHour = is12HourFormat ? 1 : 0;
|
|
805
|
+
const maxHour = this.parseHour(this.max, this.format);
|
|
806
|
+
const minHour = this.parseHour(this.min, this.format);
|
|
807
|
+
const maxHourValue = maxHour ? parseInt(maxHour, 10) : defaultMaxHour;
|
|
808
|
+
const minHourValue = minHour ? parseInt(minHour, 10) : defaultMinHour;
|
|
796
809
|
const values = [];
|
|
797
|
-
for (let i = minHourValue; i
|
|
798
|
-
|
|
810
|
+
for (let i = minHourValue; i <= maxHourValue; i += hourStep) {
|
|
811
|
+
const hourStr = i.toString().padStart(2, '0');
|
|
812
|
+
values.push(hourStr);
|
|
799
813
|
}
|
|
800
814
|
return values;
|
|
801
815
|
}
|
|
816
|
+
/**
|
|
817
|
+
* Parse hour value from min/max constraint strings for dropdown generation only.
|
|
818
|
+
* This method is used exclusively for filtering dropdown options and should not
|
|
819
|
+
* affect input values or validation.
|
|
820
|
+
* @param {string} value - The time string to parse (e.g., "14:30" or "02:30")
|
|
821
|
+
* @param {string} format - The time format string (e.g., "HH:mm" or "hh:mm")
|
|
822
|
+
* @returns {string} The parsed hour string or null if invalid
|
|
823
|
+
*/
|
|
802
824
|
parseHour(value, format) {
|
|
803
825
|
if (!value)
|
|
804
826
|
return null;
|
|
@@ -816,13 +838,21 @@ const NvFieldtime = class {
|
|
|
816
838
|
const minMinute = (_a = this.parseMinute(this.min)) !== null && _a !== void 0 ? _a : 0;
|
|
817
839
|
const maxMinute = (_b = this.parseMinute(this.max)) !== null && _b !== void 0 ? _b : 59;
|
|
818
840
|
if (minMinute === 0 && maxMinute === 0)
|
|
819
|
-
return ['00']; // Handle edge case for zero
|
|
841
|
+
return ['00']; // Handle edge case for zero minutes
|
|
820
842
|
const values = [];
|
|
821
843
|
for (let i = minMinute; i <= maxMinute; i += minuteStep) {
|
|
822
|
-
|
|
844
|
+
const minuteStr = i.toString().padStart(2, '0');
|
|
845
|
+
values.push(minuteStr);
|
|
823
846
|
}
|
|
824
847
|
return values;
|
|
825
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Parse minute value from min/max constraint strings for dropdown generation only.
|
|
851
|
+
* This method is used exclusively for filtering dropdown options and should not
|
|
852
|
+
* affect input values or validation.
|
|
853
|
+
* @param {string} value - The time string to parse (e.g., "14:30" or "02:30")
|
|
854
|
+
* @returns {number} The parsed minute number or null if invalid
|
|
855
|
+
*/
|
|
826
856
|
parseMinute(value) {
|
|
827
857
|
if (!value)
|
|
828
858
|
return null;
|
|
@@ -841,10 +871,18 @@ const NvFieldtime = class {
|
|
|
841
871
|
return ['00']; // Handle edge case for zero seconds
|
|
842
872
|
const values = [];
|
|
843
873
|
for (let i = minSecond; i <= maxSecond; i += secondStep) {
|
|
844
|
-
|
|
874
|
+
const secondStr = i.toString().padStart(2, '0');
|
|
875
|
+
values.push(secondStr);
|
|
845
876
|
}
|
|
846
877
|
return values;
|
|
847
878
|
}
|
|
879
|
+
/**
|
|
880
|
+
* Parse second value from min/max constraint strings for dropdown generation only.
|
|
881
|
+
* This method is used exclusively for filtering dropdown options and should not
|
|
882
|
+
* affect input values or validation.
|
|
883
|
+
* @param {string} value - The time string to parse (e.g., "14:30:45" or "02:30:45")
|
|
884
|
+
* @returns {number} The parsed second number or null if invalid
|
|
885
|
+
*/
|
|
848
886
|
parseSecond(value) {
|
|
849
887
|
if (!value)
|
|
850
888
|
return null;
|
|
@@ -861,10 +899,6 @@ const NvFieldtime = class {
|
|
|
861
899
|
const repetitions = Math.ceil(300 / totalOptions);
|
|
862
900
|
return Array(repetitions).fill(options).flat();
|
|
863
901
|
}
|
|
864
|
-
getCurrentTime() {
|
|
865
|
-
const currentTime = new Date();
|
|
866
|
-
return currentTime.toLocaleTimeString(); // Returns the time in the locale's format
|
|
867
|
-
}
|
|
868
902
|
updateColumnHighlight(selector, value) {
|
|
869
903
|
const items = Array.from(this.el.querySelectorAll(selector));
|
|
870
904
|
const index = items.findIndex(x => x.textContent === value);
|
|
@@ -882,8 +916,13 @@ const NvFieldtime = class {
|
|
|
882
916
|
}
|
|
883
917
|
if (!this.open) {
|
|
884
918
|
if (this.inputElements) {
|
|
885
|
-
|
|
886
|
-
|
|
919
|
+
// Focus on the first visible field based on format
|
|
920
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
921
|
+
const firstVisibleType = visibleTypes[0];
|
|
922
|
+
if (firstVisibleType && this.inputElements[firstVisibleType]) {
|
|
923
|
+
(_a = this.inputElements[firstVisibleType]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
924
|
+
(_b = this.inputElements[firstVisibleType]) === null || _b === void 0 ? void 0 : _b.select();
|
|
925
|
+
}
|
|
887
926
|
}
|
|
888
927
|
event.preventDefault();
|
|
889
928
|
}
|
|
@@ -893,17 +932,23 @@ const NvFieldtime = class {
|
|
|
893
932
|
//#region LIFECYCLE
|
|
894
933
|
componentWillLoad() {
|
|
895
934
|
document.addEventListener('click', this.handleClickOutside.bind(this));
|
|
896
|
-
//
|
|
935
|
+
// Initialize component state based on format and value
|
|
897
936
|
if (this.value) {
|
|
937
|
+
// Parse the provided value using format-aware parsing without constraint application
|
|
898
938
|
this.parseTime(this.value);
|
|
899
939
|
}
|
|
900
940
|
else {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
this.
|
|
906
|
-
this.
|
|
941
|
+
// Initialize with format-appropriate default values without any constraint application
|
|
942
|
+
// Use format-specific defaults: '01' for 12-hour formats, '00' for 24-hour formats
|
|
943
|
+
const defaultComponents = parseValueByFormat('', this.format);
|
|
944
|
+
// Set default values directly without any min/max constraint validation
|
|
945
|
+
this.hours = defaultComponents.hours;
|
|
946
|
+
this.minutes = defaultComponents.minutes;
|
|
947
|
+
this.seconds = defaultComponents.seconds;
|
|
948
|
+
// Set the initial value in the correct format without constraint validation
|
|
949
|
+
// This ensures the component has a proper initial state for the value watcher
|
|
950
|
+
const initialValue = reconstructTimeByFormat(defaultComponents, this.format);
|
|
951
|
+
this.value = initialValue;
|
|
907
952
|
}
|
|
908
953
|
}
|
|
909
954
|
connectedCallback() {
|
|
@@ -913,63 +958,94 @@ const NvFieldtime = class {
|
|
|
913
958
|
document.removeEventListener('click', this.handleClickOutside.bind(this));
|
|
914
959
|
}
|
|
915
960
|
componentDidLoad() {
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
second = secondAmPm;
|
|
928
|
-
}
|
|
929
|
-
// Parse hour as integer for calculations
|
|
930
|
-
let parsedHour = parseInt(hour, 10);
|
|
931
|
-
// Convert hour to 24-hour format based on AM/PM (if present)
|
|
932
|
-
if (amPm) {
|
|
933
|
-
if (amPm === 'PM' && parsedHour < 12) {
|
|
934
|
-
parsedHour += 12; // Convert PM to 24-hour
|
|
935
|
-
}
|
|
936
|
-
else if (amPm === 'AM' && parsedHour === 12) {
|
|
937
|
-
parsedHour = 0; // Midnight in 24-hour format
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
// Adjust for 12-hour format if necessary
|
|
941
|
-
if (this.format.startsWith('hh')) {
|
|
942
|
-
if (parsedHour === 0) {
|
|
943
|
-
hour = '12'; // Midnight in 12-hour format
|
|
944
|
-
}
|
|
945
|
-
else if (parsedHour > 12) {
|
|
946
|
-
hour = (parsedHour - 12).toString(); // Convert 24-hour to 12-hour
|
|
947
|
-
}
|
|
948
|
-
else {
|
|
949
|
-
hour = parsedHour.toString();
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
else {
|
|
953
|
-
hour = parsedHour.toString(); // Use 24-hour format directly
|
|
954
|
-
}
|
|
955
|
-
// Pad hour, minute, and second to ensure two digits
|
|
956
|
-
hour = hour.padStart(2, '0');
|
|
957
|
-
minute = minute.padStart(2, '0');
|
|
958
|
-
second = second.padStart(2, '0');
|
|
959
|
-
// Update highlighted items for hours
|
|
960
|
-
const hourSelector = `.time-column.time-column-hours div`;
|
|
961
|
-
this.updateColumnHighlight(hourSelector, hour);
|
|
962
|
-
// Update highlighted items for minutes
|
|
963
|
-
const minuteSelector = `.time-column.time-column-minutes div`;
|
|
964
|
-
this.updateColumnHighlight(minuteSelector, minute);
|
|
965
|
-
// Update highlighted items for seconds
|
|
966
|
-
const secondSelector = `.time-column.time-column-seconds div`;
|
|
967
|
-
this.updateColumnHighlight(secondSelector, second);
|
|
968
|
-
}
|
|
961
|
+
// Initialize dropdown highlighting based on current component state
|
|
962
|
+
// This ensures proper visual feedback without applying any constraints
|
|
963
|
+
// Update highlighted items for hours based on current state
|
|
964
|
+
const hourSelector = `.time-column.time-column-hours div`;
|
|
965
|
+
this.updateColumnHighlight(hourSelector, this.hours);
|
|
966
|
+
// Update highlighted items for minutes based on current state
|
|
967
|
+
const minuteSelector = `.time-column.time-column-minutes div`;
|
|
968
|
+
this.updateColumnHighlight(minuteSelector, this.minutes);
|
|
969
|
+
// Update highlighted items for seconds based on current state
|
|
970
|
+
const secondSelector = `.time-column.time-column-seconds div`;
|
|
971
|
+
this.updateColumnHighlight(secondSelector, this.seconds);
|
|
969
972
|
}
|
|
970
973
|
//#endregion LIFECYCLE
|
|
971
974
|
/****************************************************************************/
|
|
972
975
|
//#region RENDER
|
|
976
|
+
/**
|
|
977
|
+
* Renders input fields based on the current format
|
|
978
|
+
* Only shows fields that are relevant to the selected format
|
|
979
|
+
* @returns {HTMLElement[]} Array of HTML elements for time input fields
|
|
980
|
+
*/
|
|
981
|
+
renderTimeInputFields() {
|
|
982
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
983
|
+
const elements = [];
|
|
984
|
+
visibleTypes.forEach((type, index) => {
|
|
985
|
+
// Add separator colon before minutes and seconds (but not before the first field)
|
|
986
|
+
if (index > 0) {
|
|
987
|
+
elements.push(h("span", null, ":"));
|
|
988
|
+
}
|
|
989
|
+
// Add the input field for this time type
|
|
990
|
+
elements.push(this.renderTimeInputField(type));
|
|
991
|
+
});
|
|
992
|
+
return elements;
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Renders a single time input field for the specified type
|
|
996
|
+
* @param {TimeType} type - The time type to render input for
|
|
997
|
+
* @returns {HTMLInputElement} HTML input element for the specified time type
|
|
998
|
+
*/
|
|
999
|
+
renderTimeInputField(type) {
|
|
1000
|
+
const getValue = () => {
|
|
1001
|
+
switch (type) {
|
|
1002
|
+
case TimeType.Hours:
|
|
1003
|
+
return this.hours;
|
|
1004
|
+
case TimeType.Minutes:
|
|
1005
|
+
return this.minutes;
|
|
1006
|
+
case TimeType.Seconds:
|
|
1007
|
+
return this.seconds;
|
|
1008
|
+
default:
|
|
1009
|
+
return '00';
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
const getPlaceholder = () => {
|
|
1013
|
+
switch (type) {
|
|
1014
|
+
case TimeType.Hours:
|
|
1015
|
+
return this.format.includes('hh') ? 'hh' : 'HH';
|
|
1016
|
+
case TimeType.Minutes:
|
|
1017
|
+
return 'mm';
|
|
1018
|
+
case TimeType.Seconds:
|
|
1019
|
+
return 'ss';
|
|
1020
|
+
default:
|
|
1021
|
+
return '';
|
|
1022
|
+
}
|
|
1023
|
+
};
|
|
1024
|
+
const getId = () => {
|
|
1025
|
+
switch (type) {
|
|
1026
|
+
case TimeType.Hours:
|
|
1027
|
+
return this.inputId;
|
|
1028
|
+
case TimeType.Minutes:
|
|
1029
|
+
return `${this.inputId}-minutes`;
|
|
1030
|
+
case TimeType.Seconds:
|
|
1031
|
+
return `${this.inputId}-seconds`;
|
|
1032
|
+
default:
|
|
1033
|
+
return this.inputId;
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
// Remove min/max constraints from input elements to allow native stepper behavior
|
|
1037
|
+
// Constraints are only applied to dropdown options, not input steppers
|
|
1038
|
+
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() }));
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Renders dropdown columns based on the current format
|
|
1042
|
+
* Only shows columns that are relevant to the selected format
|
|
1043
|
+
* @returns {HTMLElement[]} Array of HTML elements for time dropdown columns
|
|
1044
|
+
*/
|
|
1045
|
+
renderTimeDropdownColumns() {
|
|
1046
|
+
const visibleTypes = getVisibleTimeTypes(this.format);
|
|
1047
|
+
return visibleTypes.map(type => this.RenderTimeOptionsColumn(type));
|
|
1048
|
+
}
|
|
973
1049
|
RenderTimeOptionsColumn(type) {
|
|
974
1050
|
return (h("div", { class: `time-column time-column-${type}`, onScroll: e => this.handleScroll(e, type) }, this.generateInfiniteTimeOptions(type).map((option, index) => (h("div", { class: {
|
|
975
1051
|
'time-option': true,
|
|
@@ -979,32 +1055,16 @@ const NvFieldtime = class {
|
|
|
979
1055
|
}, key: `${option}-${index}`, onClick: e => this.handleTimeOptionClick(e, type) }, option)))));
|
|
980
1056
|
}
|
|
981
1057
|
render() {
|
|
982
|
-
return (h(Host, { key: '
|
|
983
|
-
h("
|
|
984
|
-
|
|
985
|
-
: TimeType.Hours, id: this.inputId, readonly: this.readonly, disabled: this.disabled, required: this.required, onKeyDown: e => this.handleKeyDown(e), onBlur: () => this.handleInputBlur() }),
|
|
986
|
-
], this.format.includes('mm') && [
|
|
987
|
-
h("span", { key: '74f9604ffd54e0c0bbd88996e32fdcb08f2c3645' }, ":"),
|
|
988
|
-
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
|
|
989
|
-
? `${TimeType.Minutes}-${this.name}`
|
|
990
|
-
: TimeType.Minutes, id: `${this.inputId}-minutes`, readonly: this.readonly, disabled: this.disabled, required: this.required, onKeyDown: e => this.handleKeyDown(e), onBlur: () => this.handleInputBlur() }),
|
|
991
|
-
], this.format.includes('ss') && [
|
|
992
|
-
h("span", { key: '878bc9ce7557e9cf9471803a86956a9184d0ccb5' }, ":"),
|
|
993
|
-
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
|
|
994
|
-
? `${TimeType.Seconds}-${this.name}`
|
|
995
|
-
: TimeType.Seconds, id: `${this.inputId}-seconds`, readonly: this.readonly, disabled: this.disabled, required: this.required, onKeyDown: e => this.handleKeyDown(e), onBlur: () => this.handleInputBlur() }),
|
|
996
|
-
], 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') &&
|
|
997
|
-
this.RenderTimeOptionsColumn(TimeType.Hours), this.format.includes('mm') &&
|
|
998
|
-
this.RenderTimeOptionsColumn(TimeType.Minutes), this.format.includes('ss') &&
|
|
999
|
-
this.RenderTimeOptionsColumn(TimeType.Seconds)))), (this.description ||
|
|
1000
|
-
this.el.querySelector('[slot="description"]')) && (h("div", { key: '1076ded73b32ff9afbd0f02184febcc82f8d839e', class: "description" }, h("slot", { key: '479d09b299d0e380533a6cd689ce7f03aa92ea8e', name: "description" }, this.description))), (this.errorDescription ||
|
|
1001
|
-
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)))));
|
|
1058
|
+
return (h(Host, { key: '315b0a732c1ef8bee7aaa0141ce533ec265e35ab', onclick: (e) => this.handleHostClick(e), "aria-expanded": this.open ? 'true' : 'false' }, (this.label || this.el.querySelector('[slot="label"]')) && (h("label", { key: '100b75accd50c277e3ddd13c007e55dad8c6f8b7', htmlFor: this.inputId }, h("slot", { key: 'cec67688f98fc7976299a2f55ba8ba859e4ecacc', name: "label" }, this.label))), h("nv-popover", { key: 'feaaefb107251368db809babb02b8f8c7cb7baf0', ref: el => (this.popoverElement = el), triggerMode: "controlled", placement: "bottom-start", open: this.open }, h("div", { key: 'c539917597eebdd92bb2e832d1fd9d6afceb5c04', class: "input-wrapper", slot: "trigger" }, h("slot", { key: '5a869349e9fd7a422d596f5bd05402d5559a6f2b', name: "before-input" }), h("div", { key: '27dac6987b28d08bb54b9ffc70ddade28f527a9c', class: "input-container" }, h("slot", { key: '9df638bb3d58df138a360966925b04092f1d4b9a', name: "leading-input" }), this.renderTimeInputFields(), h("nv-iconbutton", { key: '8d6796d9fc57ef2a934bfe79621ff76def8e9507', 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: '15b593ce4e850d18a5f5f93120ae84e84054cffe', name: "alert-circle", class: "validation", size: "sm" })), this.success && (h("nv-icon", { key: '85e4a38c3ef64552fc7a47448471d4276ee5cc46', name: "circle-check", class: "validation", size: "sm" }))), h("slot", { key: '45cc1c26bc40425df62382a371ab658dd18aefa8', name: "after-input" })), h("div", { key: '23432dd354491420e42400d9eeb22bc23e36623e', class: "time-dropdown", slot: "content" }, h("div", { key: 'efb53556077c85ee94a8fe345a03d67a3e36cdc1', class: "time-columns" }, this.renderTimeDropdownColumns()))), (this.description ||
|
|
1059
|
+
this.el.querySelector('[slot="description"]')) && (h("div", { key: '735447b328a8264739d3185ce6c65d48a01ec801', class: "description" }, h("slot", { key: '86387e48804b2ac1842c64b4cf4f5ca9f34a6719', name: "description" }, this.description))), (this.errorDescription ||
|
|
1060
|
+
this.el.querySelector('[slot="error-description"]')) && (h("div", { key: 'b6cc406c6a872b5ebb83a35a84852e143781e12f', hidden: !this.error, class: "error-description" }, h("slot", { key: 'c9dc284e202b081a61346796d21e73c8647c7daa', name: "error-description" }, this.errorDescription)))));
|
|
1002
1061
|
}
|
|
1003
1062
|
static get formAssociated() { return true; }
|
|
1004
1063
|
get el() { return getElement(this); }
|
|
1005
1064
|
static get watchers() { return {
|
|
1006
1065
|
"value": ["handleValueChange"],
|
|
1007
|
-
"open": ["handleOpenChange"]
|
|
1066
|
+
"open": ["handleOpenChange"],
|
|
1067
|
+
"format": ["handleFormatChange"]
|
|
1008
1068
|
}; }
|
|
1009
1069
|
};
|
|
1010
1070
|
NvFieldtime.style = NvFieldtimeStyle0;
|