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