@refinitiv-ui/elements 6.14.1 → 6.14.3

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 CHANGED
@@ -3,6 +3,16 @@
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
+ ## [6.14.3](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@6.14.2...@refinitiv-ui/elements@6.14.3) (2023-11-13)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **time-picker:** remove pre-populate value ([#1011](https://github.com/Refinitiv/refinitiv-ui/issues/1011)) ([8562ef5](https://github.com/Refinitiv/refinitiv-ui/commit/8562ef52f02a4f6826c1e0f0d827d897892bffa9))
11
+
12
+ ## [6.14.2](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@6.14.1...@refinitiv-ui/elements@6.14.2) (2023-11-06)
13
+
14
+ **Note:** Version bump only for package @refinitiv-ui/elements
15
+
6
16
  ## [6.14.1](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@6.14.0...@refinitiv-ui/elements@6.14.1) (2023-10-31)
7
17
 
8
18
  ### Bug Fixes
@@ -1,3 +1,4 @@
1
+ import escapeStringRegexp from 'escape-string-regexp';
1
2
  /**
2
3
  * Default filter used by combo box
3
4
  * @param el ComboBox instance to filter
@@ -14,7 +15,7 @@ export const defaultFilter = (el) => {
14
15
  const getRegularExpressionOfQuery = () => {
15
16
  if (el.query !== query || !queryRegExp) {
16
17
  query = el.query || '';
17
- queryRegExp = new RegExp(query.replace(/(\W)/g, '\\$1'), 'i');
18
+ queryRegExp = new RegExp(escapeStringRegexp(query), 'i');
18
19
  }
19
20
  return queryRegExp;
20
21
  };
@@ -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}
@@ -9,7 +9,7 @@ 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
11
  import { isIE } from '@refinitiv-ui/utils/browser.js';
12
- 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';
12
+ 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';
13
13
  import '../number-field/index.js';
14
14
  import { VERSION } from '../version.js';
15
15
  var Segment;
@@ -24,6 +24,20 @@ const MAX_MINUTES = 59;
24
24
  const MAX_SECONDS = 59;
25
25
  const HOURS_IN_DAY = 24;
26
26
  const HOURS_OF_NOON = 12;
27
+ const SegmentMap = {
28
+ [Segment.HOURS]: {
29
+ milliseconds: MILLISECONDS_IN_HOUR,
30
+ cycle: HOURS_IN_DAY
31
+ },
32
+ [Segment.MINUTES]: {
33
+ milliseconds: MILLISECONDS_IN_MINUTE,
34
+ cycle: MINUTES_IN_HOUR
35
+ },
36
+ [Segment.SECONDS]: {
37
+ milliseconds: MILLISECONDS_IN_SECOND,
38
+ cycle: SECONDS_IN_MINUTE
39
+ }
40
+ };
27
41
  const Placeholder = {
28
42
  HOURS: '--',
29
43
  MINUTES: '--',
@@ -195,7 +209,7 @@ let TimePicker = TimePicker_1 = class TimePicker extends ControlElement {
195
209
  }
196
210
  }
197
211
  get value() {
198
- if (this.hours === null || this.minutes === null || (this.isShowSeconds && this.seconds === null)) {
212
+ if (!this.isCompleteValue) {
199
213
  return '';
200
214
  }
201
215
  return this.currentTimeString;
@@ -231,6 +245,12 @@ let TimePicker = TimePicker_1 = class TimePicker extends ControlElement {
231
245
  get isShowSeconds() {
232
246
  return this.showSeconds || this.valueWithSeconds;
233
247
  }
248
+ /**
249
+ * True if time value is complete, that is having all the required time segment
250
+ */
251
+ get isCompleteValue() {
252
+ return !(this.hours === null || this.minutes === null || (this.isShowSeconds && this.seconds === null));
253
+ }
234
254
  /**
235
255
  * Get hours taking into account AM/PM placeholder
236
256
  */
@@ -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
- let offset = 0;
588
- switch (segment) {
589
- case Segment.HOURS:
590
- offset = this.hours === null ? 0 : amount * MILLISECONDS_IN_HOUR;
591
- break;
592
- case Segment.MINUTES:
593
- offset = this.minutes === null ? 0 : amount * MILLISECONDS_IN_MINUTE;
594
- break;
595
- case Segment.SECONDS:
596
- offset = this.seconds === null ? 0 : amount * MILLISECONDS_IN_SECOND;
597
- break;
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
@@ -1,3 +1,4 @@
1
+ import escapeStringRegexp from 'escape-string-regexp';
1
2
  /**
2
3
  * Default filter used by tree
3
4
  * @param el Tree instance to filter
@@ -14,7 +15,7 @@ export const defaultFilter = (el) => {
14
15
  const getRegularExpressionOfQuery = () => {
15
16
  if (el.query !== query || !queryRegExp) {
16
17
  query = el.query || '';
17
- queryRegExp = new RegExp(query.replace(/(\W)/g, '\\$1'), 'i');
18
+ queryRegExp = new RegExp(escapeStringRegexp(query), 'i');
18
19
  }
19
20
  return queryRegExp;
20
21
  };
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = '6.14.1';
1
+ export const VERSION = '6.14.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@refinitiv-ui/elements",
3
- "version": "6.14.1",
3
+ "version": "6.14.3",
4
4
  "description": "Element Framework Elements",
5
5
  "author": "LSEG",
6
6
  "license": "Apache-2.0",
@@ -345,6 +345,7 @@
345
345
  "chart.js": "~2.9.4",
346
346
  "d3-interpolate": "^3.0.1",
347
347
  "date-fns": "^2.22.1",
348
+ "escape-string-regexp": "^5.0.0",
348
349
  "lightweight-charts": "^3.8.0",
349
350
  "tslib": "^2.3.1"
350
351
  },
@@ -369,5 +370,5 @@
369
370
  "publishConfig": {
370
371
  "access": "public"
371
372
  },
372
- "gitHead": "524ac82024897ca86027b58ed33e6f0a36ee3281"
373
+ "gitHead": "ac513ef23b94d77c49fb6f4187c9d861f8db8103"
373
374
  }