@refinitiv-ui/elements 7.9.0 → 7.9.1
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/CHANGELOG.md +6 -0
- package/lib/time-picker/index.d.ts +5 -0
- package/lib/time-picker/index.js +34 -28
- package/lib/version.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [7.9.1](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@7.9.0...@refinitiv-ui/elements@7.9.1) (2023-11-13)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **time-picker:** remove pre-populate value ([#995](https://github.com/Refinitiv/refinitiv-ui/issues/995)) ([afe008c](https://github.com/Refinitiv/refinitiv-ui/commit/afe008c1059031d28f6a6c6cff79caf8f301acaa))
|
|
11
|
+
|
|
6
12
|
# [7.9.0](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@7.8.0...@refinitiv-ui/elements@7.9.0) (2023-11-06)
|
|
7
13
|
|
|
8
14
|
### Features
|
|
@@ -143,6 +143,10 @@ export declare class TimePicker extends ControlElement {
|
|
|
143
143
|
* Seconds are automatically shown when `hh:mm:ss` time format is provided as a value.
|
|
144
144
|
*/
|
|
145
145
|
private get isShowSeconds();
|
|
146
|
+
/**
|
|
147
|
+
* True if time value is complete, that is having all the required time segment
|
|
148
|
+
*/
|
|
149
|
+
private get isCompleteValue();
|
|
146
150
|
/**
|
|
147
151
|
* Get hours taking into account AM/PM placeholder
|
|
148
152
|
*/
|
|
@@ -295,6 +299,7 @@ export declare class TimePicker extends ControlElement {
|
|
|
295
299
|
/**
|
|
296
300
|
* Changes a time segment value by a specified amount.
|
|
297
301
|
* Also updates parent values when rolling through cycles.
|
|
302
|
+
* Incomplete value will update only segment without pre-populate value.
|
|
298
303
|
* @param amount Amount to change by
|
|
299
304
|
* @param segment Segment id
|
|
300
305
|
* @returns {void}
|
package/lib/time-picker/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { state } from '@refinitiv-ui/core/decorators/state.js';
|
|
|
8
8
|
import { guard } from '@refinitiv-ui/core/directives/guard.js';
|
|
9
9
|
import '@refinitiv-ui/phrasebook/locale/en/time-picker.js';
|
|
10
10
|
import { translate } from '@refinitiv-ui/translate';
|
|
11
|
-
import { MILLISECONDS_IN_HOUR, MILLISECONDS_IN_MINUTE, MILLISECONDS_IN_SECOND, TimeFormat, addOffset, format, getFormat, isAM, isPM, isValidTime, padNumber, parse, toTimeSegment } from '@refinitiv-ui/utils/date.js';
|
|
11
|
+
import { MILLISECONDS_IN_HOUR, MILLISECONDS_IN_MINUTE, MILLISECONDS_IN_SECOND, MINUTES_IN_HOUR, SECONDS_IN_MINUTE, TimeFormat, addOffset, format, getFormat, isAM, isPM, isValidTime, padNumber, parse, toTimeSegment } from '@refinitiv-ui/utils/date.js';
|
|
12
12
|
import '../number-field/index.js';
|
|
13
13
|
import { VERSION } from '../version.js';
|
|
14
14
|
var Segment;
|
|
@@ -23,6 +23,20 @@ const MAX_MINUTES = 59;
|
|
|
23
23
|
const MAX_SECONDS = 59;
|
|
24
24
|
const HOURS_IN_DAY = 24;
|
|
25
25
|
const HOURS_OF_NOON = 12;
|
|
26
|
+
const SegmentMap = {
|
|
27
|
+
[Segment.HOURS]: {
|
|
28
|
+
milliseconds: MILLISECONDS_IN_HOUR,
|
|
29
|
+
cycle: HOURS_IN_DAY
|
|
30
|
+
},
|
|
31
|
+
[Segment.MINUTES]: {
|
|
32
|
+
milliseconds: MILLISECONDS_IN_MINUTE,
|
|
33
|
+
cycle: MINUTES_IN_HOUR
|
|
34
|
+
},
|
|
35
|
+
[Segment.SECONDS]: {
|
|
36
|
+
milliseconds: MILLISECONDS_IN_SECOND,
|
|
37
|
+
cycle: SECONDS_IN_MINUTE
|
|
38
|
+
}
|
|
39
|
+
};
|
|
26
40
|
const Placeholder = {
|
|
27
41
|
HOURS: '--',
|
|
28
42
|
MINUTES: '--',
|
|
@@ -194,7 +208,7 @@ let TimePicker = TimePicker_1 = class TimePicker extends ControlElement {
|
|
|
194
208
|
}
|
|
195
209
|
}
|
|
196
210
|
get value() {
|
|
197
|
-
if (this.
|
|
211
|
+
if (!this.isCompleteValue) {
|
|
198
212
|
return '';
|
|
199
213
|
}
|
|
200
214
|
return this.currentTimeString;
|
|
@@ -230,6 +244,12 @@ let TimePicker = TimePicker_1 = class TimePicker extends ControlElement {
|
|
|
230
244
|
get isShowSeconds() {
|
|
231
245
|
return this.showSeconds || this.valueWithSeconds;
|
|
232
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* True if time value is complete, that is having all the required time segment
|
|
249
|
+
*/
|
|
250
|
+
get isCompleteValue() {
|
|
251
|
+
return !(this.hours === null || this.minutes === null || (this.isShowSeconds && this.seconds === null));
|
|
252
|
+
}
|
|
233
253
|
/**
|
|
234
254
|
* Get hours taking into account AM/PM placeholder
|
|
235
255
|
*/
|
|
@@ -358,17 +378,6 @@ let TimePicker = TimePicker_1 = class TimePicker extends ControlElement {
|
|
|
358
378
|
break;
|
|
359
379
|
// no default
|
|
360
380
|
}
|
|
361
|
-
// Pre-populate empty segments
|
|
362
|
-
if (value !== null) {
|
|
363
|
-
if (segment === Segment.HOURS && this.minutes === null) {
|
|
364
|
-
this.minutes = 0;
|
|
365
|
-
}
|
|
366
|
-
if (this.isShowSeconds &&
|
|
367
|
-
this.seconds === null &&
|
|
368
|
-
(segment === Segment.HOURS || segment === Segment.MINUTES)) {
|
|
369
|
-
this.seconds = 0;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
381
|
// verify value again, as time segment validation
|
|
373
382
|
// might fail in setter and previous value returned
|
|
374
383
|
if (oldValue !== this.value) {
|
|
@@ -579,27 +588,24 @@ let TimePicker = TimePicker_1 = class TimePicker extends ControlElement {
|
|
|
579
588
|
/**
|
|
580
589
|
* Changes a time segment value by a specified amount.
|
|
581
590
|
* Also updates parent values when rolling through cycles.
|
|
591
|
+
* Incomplete value will update only segment without pre-populate value.
|
|
582
592
|
* @param amount Amount to change by
|
|
583
593
|
* @param segment Segment id
|
|
584
594
|
* @returns {void}
|
|
585
595
|
*/
|
|
586
596
|
changeValueBy(amount, segment) {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
// no default
|
|
597
|
+
const segmentValue = this[segment];
|
|
598
|
+
const { milliseconds, cycle } = SegmentMap[segment];
|
|
599
|
+
if (this.isCompleteValue) {
|
|
600
|
+
const offset = segmentValue === null ? 0 : amount * milliseconds;
|
|
601
|
+
const value = addOffset(this.currentTimeString, offset);
|
|
602
|
+
this.setValueAndNotify(value);
|
|
603
|
+
this.selectedSegment = segment;
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
// a segment cycle is added to support wrapping of amount with negative value
|
|
607
|
+
this[segment] = segmentValue === null ? 0 : (segmentValue + amount + cycle) % cycle;
|
|
599
608
|
}
|
|
600
|
-
const value = addOffset(this.currentTimeString, offset);
|
|
601
|
-
this.setValueAndNotify(value);
|
|
602
|
-
this.selectedSegment = segment;
|
|
603
609
|
}
|
|
604
610
|
/**
|
|
605
611
|
* Gets the hours segment of the provided value
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '7.9.
|
|
1
|
+
export const VERSION = '7.9.1';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refinitiv-ui/elements",
|
|
3
|
-
"version": "7.9.
|
|
3
|
+
"version": "7.9.1",
|
|
4
4
|
"description": "Element Framework Elements",
|
|
5
5
|
"author": "LSEG",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -373,5 +373,5 @@
|
|
|
373
373
|
"publishConfig": {
|
|
374
374
|
"access": "public"
|
|
375
375
|
},
|
|
376
|
-
"gitHead": "
|
|
376
|
+
"gitHead": "78ca6b3e5c4b3347663dc2abc713fa150c9ee638"
|
|
377
377
|
}
|