@vaadin/time-picker 24.6.0-alpha4 → 24.6.0-alpha6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/time-picker",
3
- "version": "24.6.0-alpha4",
3
+ "version": "24.6.0-alpha6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -35,19 +35,21 @@
35
35
  "polymer"
36
36
  ],
37
37
  "dependencies": {
38
+ "@open-wc/dedupe-mixin": "^1.3.0",
38
39
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/combo-box": "24.6.0-alpha4",
40
- "@vaadin/component-base": "24.6.0-alpha4",
41
- "@vaadin/field-base": "24.6.0-alpha4",
42
- "@vaadin/input-container": "24.6.0-alpha4",
43
- "@vaadin/item": "24.6.0-alpha4",
44
- "@vaadin/overlay": "24.6.0-alpha4",
45
- "@vaadin/vaadin-lumo-styles": "24.6.0-alpha4",
46
- "@vaadin/vaadin-material-styles": "24.6.0-alpha4",
47
- "@vaadin/vaadin-themable-mixin": "24.6.0-alpha4"
40
+ "@vaadin/combo-box": "24.6.0-alpha6",
41
+ "@vaadin/component-base": "24.6.0-alpha6",
42
+ "@vaadin/field-base": "24.6.0-alpha6",
43
+ "@vaadin/input-container": "24.6.0-alpha6",
44
+ "@vaadin/item": "24.6.0-alpha6",
45
+ "@vaadin/overlay": "24.6.0-alpha6",
46
+ "@vaadin/vaadin-lumo-styles": "24.6.0-alpha6",
47
+ "@vaadin/vaadin-material-styles": "24.6.0-alpha6",
48
+ "@vaadin/vaadin-themable-mixin": "24.6.0-alpha6",
49
+ "lit": "^3.0.0"
48
50
  },
49
51
  "devDependencies": {
50
- "@vaadin/chai-plugins": "24.6.0-alpha4",
52
+ "@vaadin/chai-plugins": "24.6.0-alpha6",
51
53
  "@vaadin/testing-helpers": "^1.0.0",
52
54
  "sinon": "^18.0.0"
53
55
  },
@@ -55,5 +57,5 @@
55
57
  "web-types.json",
56
58
  "web-types.lit.json"
57
59
  ],
58
- "gitHead": "78967d4f3bb46f58f43c2cc621802554acb2efaf"
60
+ "gitHead": "53f2f0c6cb9324a832ee7c0a052db927e151e167"
59
61
  }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2018 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import './vaadin-lit-time-picker-item.js';
7
+ import './vaadin-lit-time-picker-overlay.js';
8
+ import './vaadin-lit-time-picker-scroller.js';
9
+ import { css, html, LitElement } from 'lit';
10
+ import { ifDefined } from 'lit/directives/if-defined.js';
11
+ import { ComboBoxMixin } from '@vaadin/combo-box/src/vaadin-combo-box-mixin.js';
12
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
13
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
14
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
15
+
16
+ /**
17
+ * An element used internally by `<vaadin-time-picker>`. Not intended to be used separately.
18
+ *
19
+ * @customElement
20
+ * @extends HTMLElement
21
+ * @mixes ComboBoxMixin
22
+ * @mixes ThemableMixin
23
+ * @private
24
+ */
25
+ class TimePickerComboBox extends ComboBoxMixin(ThemableMixin(PolylitMixin(LitElement))) {
26
+ static get is() {
27
+ return 'vaadin-time-picker-combo-box';
28
+ }
29
+
30
+ static get styles() {
31
+ return css`
32
+ :host([opened]) {
33
+ pointer-events: auto;
34
+ }
35
+ `;
36
+ }
37
+
38
+ static get properties() {
39
+ return {
40
+ positionTarget: {
41
+ type: Object,
42
+ },
43
+ };
44
+ }
45
+
46
+ /**
47
+ * Tag name prefix used by scroller and items.
48
+ * @protected
49
+ * @return {string}
50
+ */
51
+ get _tagNamePrefix() {
52
+ return 'vaadin-time-picker';
53
+ }
54
+
55
+ /**
56
+ * Reference to the clear button element.
57
+ * @protected
58
+ * @return {!HTMLElement}
59
+ */
60
+ get clearElement() {
61
+ return this.querySelector('[part="clear-button"]');
62
+ }
63
+
64
+ /**
65
+ * @override
66
+ * @protected
67
+ */
68
+ get _inputElementValue() {
69
+ return super._inputElementValue;
70
+ }
71
+
72
+ /**
73
+ * The setter is overridden to ensure the `_hasInputValue` property
74
+ * doesn't wrongly indicate true after the input element's value
75
+ * is reverted or cleared programmatically.
76
+ *
77
+ * @override
78
+ * @protected
79
+ */
80
+ set _inputElementValue(value) {
81
+ super._inputElementValue = value;
82
+ this._hasInputValue = value && value.length > 0;
83
+ }
84
+
85
+ /** @protected */
86
+ render() {
87
+ return html`
88
+ <slot></slot>
89
+
90
+ <vaadin-time-picker-overlay
91
+ id="overlay"
92
+ .opened="${this._overlayOpened}"
93
+ ?loading="${this.loading}"
94
+ theme="${ifDefined(this._theme)}"
95
+ .positionTarget="${this.positionTarget}"
96
+ .restoreFocusNode="${this.inputElement}"
97
+ no-vertical-overlap
98
+ ></vaadin-time-picker-overlay>
99
+ `;
100
+ }
101
+ /** @protected */
102
+ ready() {
103
+ super.ready();
104
+
105
+ this.allowCustomValue = true;
106
+ this._toggleElement = this.querySelector('.toggle-button');
107
+
108
+ // See https://github.com/vaadin/vaadin-time-picker/issues/145
109
+ this.setAttribute('dir', 'ltr');
110
+ }
111
+ }
112
+
113
+ defineCustomElement(TimePickerComboBox);
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2018 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css, html, LitElement } from 'lit';
7
+ import { ComboBoxItemMixin } from '@vaadin/combo-box/src/vaadin-combo-box-item-mixin.js';
8
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
9
+ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
10
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
11
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
12
+
13
+ /**
14
+ * LitElement based version of `<vaadin-time-picker-item>` web component.
15
+ *
16
+ * ## Disclaimer
17
+ *
18
+ * This component is an experiment and not yet a part of Vaadin platform.
19
+ * There is no ETA regarding specific Vaadin version where it'll land.
20
+ * Feel free to try this code in your apps as per Apache 2.0 license.
21
+ */
22
+ export class TimePickerItem extends ComboBoxItemMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
23
+ static get is() {
24
+ return 'vaadin-time-picker-item';
25
+ }
26
+
27
+ static get styles() {
28
+ return css`
29
+ :host {
30
+ display: block;
31
+ }
32
+
33
+ :host([hidden]) {
34
+ display: none !important;
35
+ }
36
+ `;
37
+ }
38
+
39
+ /** @protected */
40
+ render() {
41
+ return html`
42
+ <span part="checkmark" aria-hidden="true"></span>
43
+ <div part="content">
44
+ <slot></slot>
45
+ </div>
46
+ `;
47
+ }
48
+ }
49
+
50
+ defineCustomElement(TimePickerItem);
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2018 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css, html, LitElement } from 'lit';
7
+ import { ComboBoxOverlayMixin } from '@vaadin/combo-box/src/vaadin-combo-box-overlay-mixin.js';
8
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
9
+ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
10
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
11
+ import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
12
+ import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
13
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
+
15
+ const timePickerOverlayStyles = css`
16
+ #overlay {
17
+ width: var(--vaadin-time-picker-overlay-width, var(--_vaadin-time-picker-overlay-default-width, auto));
18
+ }
19
+
20
+ [part='content'] {
21
+ display: flex;
22
+ flex-direction: column;
23
+ height: 100%;
24
+ }
25
+ `;
26
+
27
+ /**
28
+ * An element used internally by `<vaadin-time-picker>`. Not intended to be used separately.
29
+ *
30
+ * @extends HTMLElement
31
+ * @mixes ComboBoxOverlayMixin
32
+ * @mixes DirMixin
33
+ * @mixes OverlayMixin
34
+ * @mixes ThemableMixin
35
+ * @private
36
+ */
37
+ export class TimePickerOverlay extends ComboBoxOverlayMixin(
38
+ OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement)))),
39
+ ) {
40
+ static get is() {
41
+ return 'vaadin-time-picker-overlay';
42
+ }
43
+
44
+ static get styles() {
45
+ return [overlayStyles, timePickerOverlayStyles];
46
+ }
47
+
48
+ static get properties() {
49
+ return {
50
+ /**
51
+ * When true, the overlay is visible and attached to body.
52
+ * This property config is overridden to set `sync: true`.
53
+ */
54
+ opened: {
55
+ type: Boolean,
56
+ notify: true,
57
+ observer: '_openedChanged',
58
+ reflectToAttribute: true,
59
+ sync: true,
60
+ },
61
+ };
62
+ }
63
+
64
+ /** @protected */
65
+ render() {
66
+ return html`
67
+ <div id="backdrop" part="backdrop" hidden></div>
68
+ <div part="overlay" id="overlay">
69
+ <div part="loader"></div>
70
+ <div part="content" id="content"><slot></slot></div>
71
+ </div>
72
+ `;
73
+ }
74
+ }
75
+
76
+ defineCustomElement(TimePickerOverlay);
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2015 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css, html, LitElement } from 'lit';
7
+ import { ComboBoxScrollerMixin } from '@vaadin/combo-box/src/vaadin-combo-box-scroller-mixin.js';
8
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
9
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
+
11
+ /**
12
+ * An element used internally by `<vaadin-time-picker>`. Not intended to be used separately.
13
+ *
14
+ * @extends HTMLElement
15
+ * @mixes ComboBoxScrollerMixin
16
+ * @private
17
+ */
18
+ export class TimePickerScroller extends ComboBoxScrollerMixin(PolylitMixin(LitElement)) {
19
+ static get is() {
20
+ return 'vaadin-time-picker-scroller';
21
+ }
22
+
23
+ static get styles() {
24
+ return css`
25
+ :host {
26
+ display: block;
27
+ min-height: 1px;
28
+ overflow: auto;
29
+
30
+ /* Fixes item background from getting on top of scrollbars on Safari */
31
+ transform: translate3d(0, 0, 0);
32
+
33
+ /* Enable momentum scrolling on iOS */
34
+ -webkit-overflow-scrolling: touch;
35
+
36
+ /* Fixes scrollbar disappearing when 'Show scroll bars: Always' enabled in Safari */
37
+ box-shadow: 0 0 0 white;
38
+ }
39
+
40
+ #selector {
41
+ border-width: var(--_vaadin-time-picker-items-container-border-width);
42
+ border-style: var(--_vaadin-time-picker-items-container-border-style);
43
+ border-color: var(--_vaadin-time-picker-items-container-border-color, transparent);
44
+ position: relative;
45
+ }
46
+ `;
47
+ }
48
+
49
+ /** @protected */
50
+ render() {
51
+ return html`
52
+ <div id="selector">
53
+ <slot></slot>
54
+ </div>
55
+ `;
56
+ }
57
+ }
58
+
59
+ defineCustomElement(TimePickerScroller);
@@ -0,0 +1,161 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2018 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import '@vaadin/input-container/src/vaadin-lit-input-container.js';
7
+ import './vaadin-lit-time-picker-combo-box.js';
8
+ import { css, html, LitElement } from 'lit';
9
+ import { ifDefined } from 'lit/directives/if-defined.js';
10
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
11
+ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
12
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
13
+ import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
14
+ import { InputController } from '@vaadin/field-base/src/input-controller.js';
15
+ import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
16
+ import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
17
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
18
+ import { TimePickerMixin } from './vaadin-time-picker-mixin.js';
19
+
20
+ /**
21
+ * LitElement based version of `<vaadin-time-picker>` web component.
22
+ *
23
+ * ## Disclaimer
24
+ *
25
+ * This component is an experiment and not yet a part of Vaadin platform.
26
+ * There is no ETA regarding specific Vaadin version where it'll land.
27
+ * Feel free to try this code in your apps as per Apache 2.0 license.
28
+ */
29
+ class TimePicker extends TimePickerMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement)))) {
30
+ static get is() {
31
+ return 'vaadin-time-picker';
32
+ }
33
+
34
+ static get styles() {
35
+ return [
36
+ inputFieldShared,
37
+ css`
38
+ /* See https://github.com/vaadin/vaadin-time-picker/issues/145 */
39
+ :host([dir='rtl']) [part='input-field'] {
40
+ direction: ltr;
41
+ }
42
+
43
+ :host([dir='rtl']) [part='input-field'] ::slotted(input)::placeholder {
44
+ direction: rtl;
45
+ text-align: left;
46
+ }
47
+
48
+ [part~='toggle-button'] {
49
+ cursor: pointer;
50
+ }
51
+ `,
52
+ ];
53
+ }
54
+
55
+ static get properties() {
56
+ return {
57
+ /** @private */
58
+ _inputContainer: {
59
+ type: Object,
60
+ },
61
+ };
62
+ }
63
+
64
+ /** @protected */
65
+ render() {
66
+ return html`
67
+ <div class="vaadin-time-picker-container">
68
+ <div part="label">
69
+ <slot name="label"></slot>
70
+ <span part="required-indicator" aria-hidden="true" @click="${this.focus}"></span>
71
+ </div>
72
+
73
+ <vaadin-time-picker-combo-box
74
+ id="comboBox"
75
+ .filteredItems="${this.__dropdownItems}"
76
+ .value="${this._comboBoxValue}"
77
+ .opened="${this.opened}"
78
+ .disabled="${this.disabled}"
79
+ .readonly="${this.readonly}"
80
+ .clearButtonVisible="${this.clearButtonVisible}"
81
+ .autoOpenDisabled="${this.autoOpenDisabled}"
82
+ .overlayClass="${this.overlayClass}"
83
+ .positionTarget="${this._inputContainer}"
84
+ theme="${ifDefined(this._theme)}"
85
+ @value-changed="${this.__onComboBoxValueChanged}"
86
+ @opened-changed="${this.__onComboBoxOpenedChanged}"
87
+ @change="${this.__onComboBoxChange}"
88
+ @has-input-value-changed="${this.__onComboBoxHasInputValueChanged}"
89
+ >
90
+ <vaadin-input-container
91
+ part="input-field"
92
+ .readonly="${this.readonly}"
93
+ .disabled="${this.disabled}"
94
+ .invalid="${this.invalid}"
95
+ theme="${ifDefined(this._theme)}"
96
+ >
97
+ <slot name="prefix" slot="prefix"></slot>
98
+ <slot name="input"></slot>
99
+ <div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
100
+ <div id="toggleButton" class="toggle-button" part="toggle-button" slot="suffix" aria-hidden="true"></div>
101
+ </vaadin-input-container>
102
+ </vaadin-time-picker-combo-box>
103
+
104
+ <div part="helper-text">
105
+ <slot name="helper"></slot>
106
+ </div>
107
+
108
+ <div part="error-message">
109
+ <slot name="error-message"></slot>
110
+ </div>
111
+ </div>
112
+
113
+ <slot name="tooltip"></slot>
114
+ `;
115
+ }
116
+
117
+ /** @protected */
118
+ firstUpdated() {
119
+ super.firstUpdated();
120
+
121
+ this.addController(
122
+ new InputController(
123
+ this,
124
+ (input) => {
125
+ this._setInputElement(input);
126
+ this._setFocusElement(input);
127
+ this.stateTarget = input;
128
+ this.ariaTarget = input;
129
+ },
130
+ {
131
+ // The "search" word is a trick to prevent Safari from enabling AutoFill,
132
+ // which is causing click issues:
133
+ // https://github.com/vaadin/web-components/issues/6817#issuecomment-2268229567
134
+ uniqueIdPrefix: 'search-input',
135
+ },
136
+ ),
137
+ );
138
+ this.addController(new LabelledInputController(this.inputElement, this._labelController));
139
+ this._inputContainer = this.shadowRoot.querySelector('[part~="input-field"]');
140
+
141
+ this._tooltipController = new TooltipController(this);
142
+ this._tooltipController.setShouldShow((timePicker) => !timePicker.opened);
143
+ this._tooltipController.setPosition('top');
144
+ this._tooltipController.setAriaTarget(this.inputElement);
145
+ this.addController(this._tooltipController);
146
+ }
147
+
148
+ /** @private */
149
+ __onComboBoxOpenedChanged(event) {
150
+ this.opened = event.detail.value;
151
+ }
152
+
153
+ /** @private */
154
+ __onComboBoxValueChanged(event) {
155
+ this._comboBoxValue = event.detail.value;
156
+ }
157
+ }
158
+
159
+ defineCustomElement(TimePicker);
160
+
161
+ export { TimePicker };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2018 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ export interface TimePickerTime {
8
+ hours: number | string;
9
+ minutes: number | string;
10
+ seconds?: number | string;
11
+ milliseconds?: number | string;
12
+ }
13
+
14
+ /**
15
+ * A function to format given `Object` as time string.
16
+ * Object is in the format `{ hours: ..., minutes: ..., seconds: ..., milliseconds: ... }`
17
+ */
18
+ export function formatISOTime(time: TimePickerTime | undefined): string;
19
+
20
+ /**
21
+ * A function to parse the given string to an `Object` in the format
22
+ * `{ hours: ..., minutes: ..., seconds: ..., milliseconds: ... }`.
23
+ */
24
+ export function parseISOTime(timeString: string): TimePickerTime | undefined;
25
+
26
+ /**
27
+ * A function to validate the time object based on the given step.
28
+ */
29
+ export function validateTime(
30
+ timeObject: TimePickerTime | undefined,
31
+ step: number | null | undefined,
32
+ ): TimePickerTime | undefined;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2018 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ /**
8
+ * A function to format given `Object` as time string.
9
+ * Object is in the format `{ hours: ..., minutes: ..., seconds: ..., milliseconds: ... }`
10
+ * @param {object} time
11
+ * @return {string}
12
+ */
13
+ export function formatISOTime(time) {
14
+ if (!time) {
15
+ return '';
16
+ }
17
+
18
+ const pad = (num = 0, fmt = '00') => (fmt + num).substr((fmt + num).length - fmt.length);
19
+ // Always display hour and minute
20
+ let timeString = `${pad(time.hours)}:${pad(time.minutes)}`;
21
+ // Adding second and millisecond depends on resolution
22
+ if (time.seconds !== undefined) {
23
+ timeString += `:${pad(time.seconds)}`;
24
+ }
25
+ if (time.milliseconds !== undefined) {
26
+ timeString += `.${pad(time.milliseconds, '000')}`;
27
+ }
28
+ return timeString;
29
+ }
30
+
31
+ const MATCH_HOURS = '(\\d|[0-1]\\d|2[0-3])';
32
+ const MATCH_MINUTES = '(\\d|[0-5]\\d)';
33
+ const MATCH_SECONDS = MATCH_MINUTES;
34
+ const MATCH_MILLISECONDS = '(\\d{1,3})';
35
+ const re = new RegExp(`^${MATCH_HOURS}(?::${MATCH_MINUTES}(?::${MATCH_SECONDS}(?:\\.${MATCH_MILLISECONDS})?)?)?$`, 'u');
36
+
37
+ /**
38
+ * A function to parse the given string to an `Object` in the format
39
+ * `{ hours: ..., minutes: ..., seconds: ..., milliseconds: ... }`.
40
+ *
41
+ * @param {string} timeString
42
+ * @return {object | undefined}
43
+ */
44
+ export function parseISOTime(timeString) {
45
+ // Parsing with RegExp to ensure correct format
46
+ const parts = re.exec(timeString);
47
+ if (parts) {
48
+ // Allows setting the milliseconds with hundreds and tens precision
49
+ if (parts[4]) {
50
+ while (parts[4].length < 3) {
51
+ parts[4] += '0';
52
+ }
53
+ }
54
+ return { hours: parts[1], minutes: parts[2], seconds: parts[3], milliseconds: parts[4] };
55
+ }
56
+ }
57
+
58
+ function getStepSegment(stepValue) {
59
+ const step = stepValue == null ? 60 : parseFloat(stepValue);
60
+ if (step % 3600 === 0) {
61
+ // Accept hours
62
+ return 1;
63
+ } else if (step % 60 === 0 || !step) {
64
+ // Accept minutes
65
+ return 2;
66
+ } else if (step % 1 === 0) {
67
+ // Accept seconds
68
+ return 3;
69
+ } else if (step < 1) {
70
+ // Accept milliseconds
71
+ return 4;
72
+ }
73
+ }
74
+
75
+ /**
76
+ * A function to validate the time object based on the given step.
77
+ *
78
+ * @param {object} timeObject
79
+ * @param {number} step
80
+ * @return {object | undefined}
81
+ */
82
+ export function validateTime(timeObject, step) {
83
+ if (timeObject) {
84
+ const stepSegment = getStepSegment(step);
85
+ timeObject.hours = parseInt(timeObject.hours);
86
+ timeObject.minutes = parseInt(timeObject.minutes || 0);
87
+ timeObject.seconds = stepSegment < 3 ? undefined : parseInt(timeObject.seconds || 0);
88
+ timeObject.milliseconds = stepSegment < 4 ? undefined : parseInt(timeObject.milliseconds || 0);
89
+ }
90
+ return timeObject;
91
+ }