@refinitiv-ui/elements 7.4.0 → 7.6.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +1 -1
  3. package/README.md +5 -5
  4. package/lib/calendar/constants.d.ts +1 -1
  5. package/lib/calendar/constants.js +7 -6
  6. package/lib/calendar/custom-elements.json +4 -0
  7. package/lib/calendar/custom-elements.md +5 -4
  8. package/lib/calendar/index.d.ts +13 -3
  9. package/lib/calendar/index.js +52 -29
  10. package/lib/calendar/types.d.ts +21 -2
  11. package/lib/calendar/utils.d.ts +9 -1
  12. package/lib/calendar/utils.js +24 -1
  13. package/lib/combo-box/index.js +2 -0
  14. package/lib/datetime-field/custom-elements.json +0 -5
  15. package/lib/datetime-field/custom-elements.md +4 -5
  16. package/lib/datetime-field/index.d.ts +0 -22
  17. package/lib/datetime-field/index.js +2 -38
  18. package/lib/email-field/custom-elements.json +12 -0
  19. package/lib/email-field/custom-elements.md +7 -0
  20. package/lib/email-field/index.d.ts +10 -7
  21. package/lib/email-field/index.js +14 -13
  22. package/lib/interactive-chart/index.js +1 -0
  23. package/lib/number-field/custom-elements.json +4 -7
  24. package/lib/number-field/custom-elements.md +2 -3
  25. package/lib/number-field/index.d.ts +6 -11
  26. package/lib/number-field/index.js +19 -33
  27. package/lib/password-field/custom-elements.json +12 -0
  28. package/lib/password-field/custom-elements.md +7 -0
  29. package/lib/password-field/index.d.ts +10 -0
  30. package/lib/password-field/index.js +14 -0
  31. package/lib/search-field/custom-elements.json +12 -0
  32. package/lib/search-field/custom-elements.md +7 -0
  33. package/lib/search-field/index.d.ts +10 -0
  34. package/lib/search-field/index.js +14 -0
  35. package/lib/slider/custom-elements.json +1 -1
  36. package/lib/slider/custom-elements.md +1 -1
  37. package/lib/slider/index.d.ts +6 -1
  38. package/lib/slider/index.js +14 -2
  39. package/lib/text-field/custom-elements.json +12 -0
  40. package/lib/text-field/custom-elements.md +7 -0
  41. package/lib/text-field/index.d.ts +17 -12
  42. package/lib/text-field/index.js +29 -31
  43. package/lib/tree/elements/tree.js +4 -4
  44. package/lib/tree/managers/tree-manager.d.ts +8 -0
  45. package/lib/tree/managers/tree-manager.js +19 -1
  46. package/lib/tree-select/index.d.ts +12 -3
  47. package/lib/tree-select/index.js +55 -20
  48. package/lib/version.js +1 -1
  49. package/package.json +17 -17
package/CHANGELOG.md CHANGED
@@ -3,6 +3,29 @@
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.6.0](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@7.5.0...@refinitiv-ui/elements@7.6.0) (2023-09-25)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **interactive-chart:** invalid legend render when add new seriesList ([#954](https://github.com/Refinitiv/refinitiv-ui/issues/954)) ([f8706b6](https://github.com/Refinitiv/refinitiv-ui/commit/f8706b6da7ad5c49b6abbadce853c339bd5a77b8))
11
+ - **tree-select:** show invalid values when click on cancel button on selected view ([#964](https://github.com/Refinitiv/refinitiv-ui/issues/964)) ([49302bc](https://github.com/Refinitiv/refinitiv-ui/commit/49302bc1af0edec984e77083cdcdb31ba068c0c8))
12
+
13
+ ### Features
14
+
15
+ - **calendar:** introduce before-cell-render event ([#926](https://github.com/Refinitiv/refinitiv-ui/issues/926)) ([ff2164f](https://github.com/Refinitiv/refinitiv-ui/commit/ff2164f5794d874064f167c363a476fe7a3836e1))
16
+
17
+ # [7.5.0](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@7.4.0...@refinitiv-ui/elements@7.5.0) (2023-09-18)
18
+
19
+ ### Bug Fixes
20
+
21
+ - **slider:** incorrect updating `to` value ([#938](https://github.com/Refinitiv/refinitiv-ui/issues/938)) ([8479abc](https://github.com/Refinitiv/refinitiv-ui/commit/8479abc828571e06379b5f389058f60d5ba8443b))
22
+ - **slider:** number field not revalidate when error state changes ([#942](https://github.com/Refinitiv/refinitiv-ui/issues/942)) ([5fc64a6](https://github.com/Refinitiv/refinitiv-ui/commit/5fc64a6ac21cdbbf820ae97de04ec19443755e50))
23
+
24
+ ### Features
25
+
26
+ - **fields:** improve validation consistency for field elements ([#937](https://github.com/Refinitiv/refinitiv-ui/issues/937)) ([d58051c](https://github.com/Refinitiv/refinitiv-ui/commit/d58051c0b4d3508ac55d223299fd8bf267458ddf))
27
+ - **utils:** add `selectedAt` property to `DataItem` interface ([4d69419](https://github.com/Refinitiv/refinitiv-ui/commit/4d69419107d8ed8dd554cb7cf0ecadd327d02f18))
28
+
6
29
  # [7.4.0](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@7.3.2...@refinitiv-ui/elements@7.4.0) (2023-09-11)
7
30
 
8
31
  ### Features
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright © 2023, Refinitiv.
1
+ Copyright © 2023, LSEG
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Element Framework
2
2
 
3
- Element Framework (EF) is a collection of elements that includes theming capability within the Refinitiv Workspace's design system. The elements are a set of web components which is a standard web technology and can be utilized across all browsers.
3
+ Element Framework (EF) is a collection of elements that includes theming capability within the LSEG Workspace's design system. The elements are a set of web components which is a standard web technology and can be utilized across all browsers.
4
4
 
5
5
  ## Usage
6
6
 
@@ -10,17 +10,17 @@ EF elements are published under single package.
10
10
  npm install @refinitiv-ui/elements
11
11
  ```
12
12
 
13
- The elements are required theme to instantiate itself in the app. Refinitiv Workspace's design system is called Halo theme and you can install it from npm command.
13
+ The elements are required theme to instantiate itself in the app. LSEG Workspace's design system is called Halo theme and you can install it from npm command.
14
14
 
15
15
  ```sh
16
16
  npm install @refinitiv-ui/halo-theme
17
17
  ```
18
18
 
19
- Finally, import both elements that you want to use and its themes into your application and it is ready to go. To follow Refinitiv Workspace's design system, it is required styles of some native elements e.g. typography.
19
+ Finally, import both elements that you want to use and its themes into your application and it is ready to go. To follow LSEG Workspace's design system, it is required styles of some native elements e.g. typography.
20
20
 
21
21
  <br>
22
22
 
23
- > The font "Proxima Nova Fin" shall only be used within Refinitiv products or services. The copyright owner must approve any use of such font outside of Refinitiv products or services, which may be subject to a fee. Please see https://www.fontspring.com/lic/fontspring/webfont#license_text
23
+ > The font "Proxima Nova Fin" shall only be used within LSEG products or services. The copyright owner must approve any use of such font outside of LSEG products or services, which may be subject to a fee. Please see https://www.fontspring.com/lic/fontspring/webfont#license_text
24
24
 
25
25
  <br>
26
26
 
@@ -57,4 +57,4 @@ See list of elements, demo and more tutorial by visiting [EF Documentation](http
57
57
 
58
58
  # License
59
59
 
60
- Apache License 2.0. However, Halo theme shall only be used within Refinitiv products or services due to license of the font "Proxima Nova Fin".
60
+ Apache License 2.0. However, Halo theme shall only be used within LSEG products or services due to license of the font "Proxima Nova Fin".
@@ -1,4 +1,4 @@
1
- export declare enum RenderView {
1
+ export declare enum CalendarRenderView {
2
2
  DAY = "day",
3
3
  MONTH = "month",
4
4
  YEAR = "year"
@@ -1,10 +1,11 @@
1
1
  import { uuid } from '@refinitiv-ui/utils/uuid.js';
2
- export var RenderView;
3
- (function (RenderView) {
4
- RenderView["DAY"] = "day";
5
- RenderView["MONTH"] = "month";
6
- RenderView["YEAR"] = "year";
7
- })(RenderView || (RenderView = {}));
2
+ // public API
3
+ export var CalendarRenderView;
4
+ (function (CalendarRenderView) {
5
+ CalendarRenderView["DAY"] = "day";
6
+ CalendarRenderView["MONTH"] = "month";
7
+ CalendarRenderView["YEAR"] = "year";
8
+ })(CalendarRenderView || (CalendarRenderView = {}));
8
9
  export const FIRST_DAY_OF_WEEK = 0; // 0 for Sunday
9
10
  export const YEARS_PER_YEAR_VIEW = 16; /* must be a square number */
10
11
  export const DAY_VIEW = {
@@ -181,6 +181,10 @@
181
181
  }
182
182
  ],
183
183
  "events": [
184
+ {
185
+ "name": "before-cell-render",
186
+ "description": "Fired before calendar renders each cell along with `cell` model."
187
+ },
184
188
  {
185
189
  "name": "value-changed",
186
190
  "description": "Fired when the user commits a date change. The event is not triggered if `value` is changed programmatically."
@@ -23,10 +23,11 @@ Standard calendar element
23
23
 
24
24
  ## Events
25
25
 
26
- | Event | Description |
27
- |-----------------|--------------------------------------------------|
28
- | `value-changed` | Fired when the user commits a date change. The event is not triggered if `value` is changed programmatically. |
29
- | `view-changed` | Fired when the user changes a view of calendar e.g. changed to next month page. The event is not triggered if `view` property is changed programmatically. |
26
+ | Event | Description |
27
+ |----------------------|--------------------------------------------------|
28
+ | `before-cell-render` | Fired before calendar renders each cell along with `cell` model. |
29
+ | `value-changed` | Fired when the user commits a date change. The event is not triggered if `value` is changed programmatically. |
30
+ | `view-changed` | Fired when the user changes a view of calendar e.g. changed to next month page. The event is not triggered if `view` property is changed programmatically. |
30
31
 
31
32
  ## Slots
32
33
 
@@ -3,12 +3,16 @@ import { CSSResultGroup, ControlElement, MultiValue, PropertyValues, TemplateRes
3
3
  import '@refinitiv-ui/phrasebook/locale/en/calendar.js';
4
4
  import { TranslateDirective, TranslatePromise } from '@refinitiv-ui/translate';
5
5
  import '../button/index.js';
6
+ import { CalendarRenderView } from './constants.js';
6
7
  import './locales.js';
7
- import type { CalendarFilter } from './types';
8
- export { CalendarFilter };
8
+ import type { BeforeCellRenderEvent, CalendarFilter } from './types';
9
+ export { CalendarRenderView };
10
+ export type { CalendarCell } from './types';
11
+ export type { CalendarFilter, BeforeCellRenderEvent };
9
12
  /**
10
13
  * Standard calendar element
11
14
  *
15
+ * @fires before-cell-render - Fired before calendar renders each cell along with `cell` model.
12
16
  * @fires value-changed - Fired when the user commits a date change. The event is not triggered if `value` is changed programmatically.
13
17
  * @fires view-changed - Fired when the user changes a view of calendar e.g. changed to next month page. The event is not triggered if `view` property is changed programmatically.
14
18
  *
@@ -381,9 +385,15 @@ export declare class Calendar extends ControlElement implements MultiValue {
381
385
  * @returns key Translate label key
382
386
  */
383
387
  private getCellLabelKey;
388
+ /**
389
+ * fire 'before-cell-render' event
390
+ * @param cell Cell
391
+ * @returns {void}
392
+ */
393
+ private dispatchBeforeCellRender;
384
394
  /**
385
395
  * Render cell template. Cell can be a day, month or year
386
- * @param cell Cell object
396
+ * @param cell Cell
387
397
  * @returns template result
388
398
  */
389
399
  private renderCell;
@@ -12,12 +12,14 @@ import { DateFormat, addMonths, format, isAfter, isBefore, isSameDay, isSameMont
12
12
  import { down, first, last, left, right, up } from '@refinitiv-ui/utils/navigation.js';
13
13
  import '../button/index.js';
14
14
  import { VERSION } from '../version.js';
15
- import { CalendarLocaleScope, DAY_VIEW, FIRST_DAY_OF_WEEK, MONTH_VIEW, RenderView, YEARS_PER_YEAR_VIEW, YEAR_VIEW } from './constants.js';
15
+ import { CalendarLocaleScope, CalendarRenderView, DAY_VIEW, FIRST_DAY_OF_WEEK, MONTH_VIEW, YEARS_PER_YEAR_VIEW, YEAR_VIEW } from './constants.js';
16
16
  import './locales.js';
17
- import { ViewFormatTranslateParams, monthInfo, monthsNames, weekdaysNames } from './utils.js';
17
+ import { ViewFormatTranslateParams, monthInfo, monthsNames, toCalendarCell, weekdaysNames } from './utils.js';
18
+ export { CalendarRenderView };
18
19
  /**
19
20
  * Standard calendar element
20
21
  *
22
+ * @fires before-cell-render - Fired before calendar renders each cell along with `cell` model.
21
23
  * @fires value-changed - Fired when the user commits a date change. The event is not triggered if `value` is changed programmatically.
22
24
  * @fires view-changed - Fired when the user changes a view of calendar e.g. changed to next month page. The event is not triggered if `view` property is changed programmatically.
23
25
  *
@@ -72,7 +74,7 @@ let Calendar = class Calendar extends ControlElement {
72
74
  /**
73
75
  * Used for internal navigation between render views
74
76
  */
75
- this._renderView = RenderView.DAY;
77
+ this._renderView = CalendarRenderView.DAY;
76
78
  /**
77
79
  * Used for keyboard navigation when trying
78
80
  * to restore focus on re-render and control navigation
@@ -578,7 +580,8 @@ let Calendar = class Calendar extends ControlElement {
578
580
  */
579
581
  onRenderViewTap(event) {
580
582
  if (!event.defaultPrevented) {
581
- this.renderView = this.renderView === RenderView.DAY ? RenderView.YEAR : RenderView.DAY;
583
+ this.renderView =
584
+ this.renderView === CalendarRenderView.DAY ? CalendarRenderView.YEAR : CalendarRenderView.DAY;
582
585
  }
583
586
  }
584
587
  /**
@@ -592,8 +595,8 @@ let Calendar = class Calendar extends ControlElement {
592
595
  }
593
596
  switch (event.key) {
594
597
  case 'Escape':
595
- if (this.renderView === RenderView.YEAR || this.renderView === RenderView.MONTH) {
596
- this.renderView = RenderView.DAY;
598
+ if (this.renderView === CalendarRenderView.YEAR || this.renderView === CalendarRenderView.MONTH) {
599
+ this.renderView = CalendarRenderView.DAY;
597
600
  break;
598
601
  }
599
602
  return;
@@ -656,20 +659,20 @@ let Calendar = class Calendar extends ControlElement {
656
659
  this.activeCellIndex = cell.index;
657
660
  const cellSegment = toDateSegment(cell.value);
658
661
  const viewSegment = toDateSegment(this.view);
659
- if (this.renderView === RenderView.YEAR) {
662
+ if (this.renderView === CalendarRenderView.YEAR) {
660
663
  /* YEAR -> MONTH */
661
664
  viewSegment.year = cellSegment.year;
662
665
  if (this.notifyViewChange(viewSegment)) {
663
- this.renderView = RenderView.MONTH;
666
+ this.renderView = CalendarRenderView.MONTH;
664
667
  }
665
668
  return;
666
669
  }
667
- if (this.renderView === RenderView.MONTH) {
670
+ if (this.renderView === CalendarRenderView.MONTH) {
668
671
  /* MONTH -> DAY */
669
672
  viewSegment.year = cellSegment.year;
670
673
  viewSegment.month = cellSegment.month;
671
674
  if (this.notifyViewChange(viewSegment)) {
672
- this.renderView = RenderView.DAY;
675
+ this.renderView = CalendarRenderView.DAY;
673
676
  }
674
677
  return;
675
678
  }
@@ -753,13 +756,13 @@ let Calendar = class Calendar extends ControlElement {
753
756
  toNextView() {
754
757
  let viewSegment = toDateSegment(this.view);
755
758
  switch (this.renderView) {
756
- case RenderView.DAY:
759
+ case CalendarRenderView.DAY:
757
760
  viewSegment = toDateSegment(addMonths(this.view, 1));
758
761
  break;
759
- case RenderView.MONTH:
762
+ case CalendarRenderView.MONTH:
760
763
  viewSegment.year += 1;
761
764
  break;
762
- case RenderView.YEAR:
765
+ case CalendarRenderView.YEAR:
763
766
  viewSegment.year += YEARS_PER_YEAR_VIEW;
764
767
  break;
765
768
  // no default
@@ -773,13 +776,13 @@ let Calendar = class Calendar extends ControlElement {
773
776
  toPreviousView() {
774
777
  let viewSegment = toDateSegment(this.view);
775
778
  switch (this.renderView) {
776
- case RenderView.DAY:
779
+ case CalendarRenderView.DAY:
777
780
  viewSegment = toDateSegment(subMonths(this.view, 1));
778
781
  break;
779
- case RenderView.MONTH:
782
+ case CalendarRenderView.MONTH:
780
783
  viewSegment.year -= 1;
781
784
  break;
782
- case RenderView.YEAR:
785
+ case CalendarRenderView.YEAR:
783
786
  viewSegment.year -= YEARS_PER_YEAR_VIEW;
784
787
  break;
785
788
  // no default
@@ -874,9 +877,9 @@ let Calendar = class Calendar extends ControlElement {
874
877
  get formattedViewRender() {
875
878
  const segment = toDateSegment(this.view);
876
879
  switch (this.renderView) {
877
- case RenderView.MONTH:
880
+ case CalendarRenderView.MONTH:
878
881
  return this.viewFormattedDate(segment);
879
- case RenderView.YEAR:
882
+ case CalendarRenderView.YEAR:
880
883
  const month = segment.month;
881
884
  const day = segment.day;
882
885
  const fromYear = Math.floor(segment.year / YEARS_PER_YEAR_VIEW) * YEARS_PER_YEAR_VIEW;
@@ -884,7 +887,7 @@ let Calendar = class Calendar extends ControlElement {
884
887
  const fromView = this.viewFormattedDate({ year: fromYear, month, day });
885
888
  const toView = this.viewFormattedDate({ year: toYear, month, day });
886
889
  return html `${fromView} - ${toView}`;
887
- case RenderView.DAY:
890
+ case CalendarRenderView.DAY:
888
891
  default:
889
892
  return this.viewFormattedDate(segment, true);
890
893
  }
@@ -938,7 +941,7 @@ let Calendar = class Calendar extends ControlElement {
938
941
  * Get year view template
939
942
  */
940
943
  get yearView() {
941
- const view = RenderView.YEAR;
944
+ const view = CalendarRenderView.YEAR;
942
945
  const currentYear = toDateSegment(this.view).year;
943
946
  const startIdx = Math.floor(currentYear / YEARS_PER_YEAR_VIEW) * YEARS_PER_YEAR_VIEW;
944
947
  const years = [];
@@ -973,7 +976,7 @@ let Calendar = class Calendar extends ControlElement {
973
976
  * Get month view template
974
977
  */
975
978
  get monthView() {
976
- const view = RenderView.MONTH;
979
+ const view = CalendarRenderView.MONTH;
977
980
  const currentYear = toDateSegment(this.view).year;
978
981
  const columnCount = MONTH_VIEW.columnCount;
979
982
  const monthCount = 12;
@@ -1018,7 +1021,7 @@ let Calendar = class Calendar extends ControlElement {
1018
1021
  * Get day view template
1019
1022
  */
1020
1023
  get dayView() {
1021
- const view = RenderView.DAY;
1024
+ const view = CalendarRenderView.DAY;
1022
1025
  const firstDayOfWeek = this.firstDayOfWeek;
1023
1026
  const padding = (7 + utcParse(this.view).getUTCDay() - firstDayOfWeek) % 7;
1024
1027
  const viewMonth = monthInfo(this.view);
@@ -1111,13 +1114,13 @@ let Calendar = class Calendar extends ControlElement {
1111
1114
  get viewRender() {
1112
1115
  let renderView;
1113
1116
  switch (this.renderView) {
1114
- case RenderView.MONTH:
1117
+ case CalendarRenderView.MONTH:
1115
1118
  renderView = this.monthView;
1116
1119
  break;
1117
- case RenderView.YEAR:
1120
+ case CalendarRenderView.YEAR:
1118
1121
  renderView = this.yearView;
1119
1122
  break;
1120
- case RenderView.DAY:
1123
+ case CalendarRenderView.DAY:
1121
1124
  default:
1122
1125
  renderView = this.dayView;
1123
1126
  }
@@ -1140,12 +1143,32 @@ let Calendar = class Calendar extends ControlElement {
1140
1143
  }
1141
1144
  return 'CELL_LABEL';
1142
1145
  }
1146
+ /**
1147
+ * fire 'before-cell-render' event
1148
+ * @param cell Cell
1149
+ * @returns {void}
1150
+ */
1151
+ dispatchBeforeCellRender(cell) {
1152
+ const calendarCell = toCalendarCell(cell);
1153
+ const event = new CustomEvent('before-cell-render', {
1154
+ cancelable: false,
1155
+ composed: true,
1156
+ detail: {
1157
+ cell: calendarCell
1158
+ }
1159
+ });
1160
+ this.dispatchEvent(event);
1161
+ }
1143
1162
  /**
1144
1163
  * Render cell template. Cell can be a day, month or year
1145
- * @param cell Cell object
1164
+ * @param cell Cell
1146
1165
  * @returns template result
1147
1166
  */
1148
1167
  renderCell(cell) {
1168
+ // there is no slot for cells with falsy value
1169
+ if (cell.value) {
1170
+ this.dispatchBeforeCellRender(cell);
1171
+ }
1149
1172
  const isSelection = cell.value !== undefined;
1150
1173
  const isSelectable = isSelection && !cell.disabled;
1151
1174
  const isSelected = cell.selected ? 'true' : 'false';
@@ -1201,12 +1224,12 @@ let Calendar = class Calendar extends ControlElement {
1201
1224
  let nextBtnAriaLabel = this.t('NEXT_MONTH');
1202
1225
  let viewBtnAriaLabel = this.t('YEAR_SELECTOR');
1203
1226
  switch (this.renderView) {
1204
- case RenderView.YEAR:
1227
+ case CalendarRenderView.YEAR:
1205
1228
  prevBtnAriaLabel = this.t('PREVIOUS_DECADE');
1206
1229
  nextBtnAriaLabel = this.t('NEXT_DECADE');
1207
1230
  viewBtnAriaLabel = this.t('DATE_SELECTOR');
1208
1231
  break;
1209
- case RenderView.MONTH:
1232
+ case CalendarRenderView.MONTH:
1210
1233
  prevBtnAriaLabel = this.t('PREVIOUS_YEAR');
1211
1234
  nextBtnAriaLabel = this.t('NEXT_YEAR');
1212
1235
  viewBtnAriaLabel = this.t('DATE_SELECTOR');
@@ -1226,7 +1249,7 @@ let Calendar = class Calendar extends ControlElement {
1226
1249
  aria-description="${viewBtnAriaLabel}"
1227
1250
  part="btn-view"
1228
1251
  textpos="before"
1229
- .icon="${this.renderView === RenderView.DAY ? 'down' : 'up'}"
1252
+ .icon="${this.renderView === CalendarRenderView.DAY ? 'down' : 'up'}"
1230
1253
  @tap="${this.onRenderViewTap}"
1231
1254
  >${this.formattedViewRender}</ef-button
1232
1255
  >
@@ -1,5 +1,5 @@
1
1
  import { CellIndex } from '@refinitiv-ui/utils/navigation.js';
2
- import { RenderView } from './constants.js';
2
+ import { CalendarRenderView } from './constants.js';
3
3
  export interface CellSelectionModel {
4
4
  selected?: boolean;
5
5
  range?: boolean;
@@ -9,7 +9,7 @@ export interface CellSelectionModel {
9
9
  lastDate?: boolean;
10
10
  }
11
11
  export interface Cell extends CellSelectionModel {
12
- view: RenderView;
12
+ view: CalendarRenderView;
13
13
  text?: string;
14
14
  active?: boolean;
15
15
  value?: string;
@@ -30,3 +30,22 @@ export type WeekdayName = {
30
30
  narrow: string;
31
31
  long: string;
32
32
  };
33
+ export type CalendarCell = {
34
+ active: boolean;
35
+ disabled: boolean;
36
+ firstDate: boolean;
37
+ idle: boolean;
38
+ index: CellIndex;
39
+ lastDate: boolean;
40
+ now: boolean;
41
+ range: boolean;
42
+ rangeFrom: boolean;
43
+ rangeTo: boolean;
44
+ selected: boolean;
45
+ text: string;
46
+ value: string;
47
+ view: CalendarRenderView;
48
+ };
49
+ export type BeforeCellRenderEvent = CustomEvent<{
50
+ cell: CalendarCell;
51
+ }>;
@@ -1,4 +1,5 @@
1
1
  import { TranslateParams } from '@refinitiv-ui/i18n';
2
+ import { CalendarCell, Cell } from './types.js';
2
3
  export type MonthInfo = {
3
4
  days: number;
4
5
  month: number;
@@ -28,4 +29,11 @@ declare const monthsNames: (locale: string, width?: Intl.DateTimeFormatOptions['
28
29
  * Used to format views
29
30
  */
30
31
  declare const ViewFormatTranslateParams: TranslateParams;
31
- export { monthInfo, weekdaysNames, monthsNames, ViewFormatTranslateParams };
32
+ /**
33
+ * convert internal Cell to CalendarCell
34
+ * avoid introducing breaking changes to the API
35
+ * @param cell Cell
36
+ * @returns CalendarCell
37
+ */
38
+ declare const toCalendarCell: (cell: Cell) => CalendarCell;
39
+ export { monthInfo, weekdaysNames, monthsNames, toCalendarCell, ViewFormatTranslateParams };
@@ -99,4 +99,27 @@ const ViewFormatTranslateParams = {
99
99
  },
100
100
  formats: DateMessageFormats
101
101
  };
102
- export { monthInfo, weekdaysNames, monthsNames, ViewFormatTranslateParams };
102
+ /**
103
+ * convert internal Cell to CalendarCell
104
+ * avoid introducing breaking changes to the API
105
+ * @param cell Cell
106
+ * @returns CalendarCell
107
+ */
108
+ const toCalendarCell = (cell) => {
109
+ return {
110
+ ...cell,
111
+ active: cell.active || false,
112
+ disabled: cell.disabled || false,
113
+ firstDate: cell.firstDate || false,
114
+ idle: cell.idle || false,
115
+ lastDate: cell.lastDate || false,
116
+ now: cell.now || false,
117
+ range: cell.range || false,
118
+ rangeFrom: cell.rangeFrom || false,
119
+ rangeTo: cell.rangeTo || false,
120
+ selected: cell.selected || false,
121
+ text: cell.text ?? '',
122
+ value: cell.value ?? ''
123
+ };
124
+ };
125
+ export { monthInfo, weekdaysNames, monthsNames, toCalendarCell, ViewFormatTranslateParams };
@@ -288,9 +288,11 @@ let ComboBox = class ComboBox extends FormFieldElement {
288
288
  * @returns {void}
289
289
  */
290
290
  updateComposerValues(newValues) {
291
+ const selectedAt = Date.now();
291
292
  this.queryItems((item, composer) => {
292
293
  if (newValues.includes(composer.getItemPropertyValue(item, 'value'))) {
293
294
  composer.setItemPropertyValue(item, 'selected', true);
295
+ composer.setItemPropertyValue(item, 'selectedAt', selectedAt + newValues.indexOf(item.value ?? '')); // Sequential selection
294
296
  return true;
295
297
  }
296
298
  composer.setItemPropertyValue(item, 'selected', false);
@@ -258,11 +258,6 @@
258
258
  "name": "checkValidity",
259
259
  "description": "Returns true if an input element contains valid data.",
260
260
  "params": []
261
- },
262
- {
263
- "name": "reportValidity",
264
- "description": "Validate input. Mark as error if input is invalid",
265
- "params": []
266
261
  }
267
262
  ]
268
263
  }
@@ -37,11 +37,10 @@ A form control element for datetime input.
37
37
 
38
38
  ## Methods
39
39
 
40
- | Method | Type | Description |
41
- |------------------|----------------------------------|--------------------------------------------------|
42
- | `checkValidity` | `(): boolean` | Returns true if an input element contains valid data. |
43
- | `reportValidity` | `(): boolean` | Validate input. Mark as error if input is invalid |
44
- | `willUpdate` | `(changedProperties: any): void` | Updates the element<br /><br />**changedProperties**: Properties that has changed |
40
+ | Method | Type | Description |
41
+ |-----------------|----------------------------------|--------------------------------------------------|
42
+ | `checkValidity` | `(): boolean` | Returns true if an input element contains valid data. |
43
+ | `willUpdate` | `(changedProperties: any): void` | Updates the element<br /><br />**changedProperties**: Properties that has changed |
45
44
 
46
45
  ## Events
47
46
 
@@ -186,18 +186,6 @@ export declare class DatetimeField extends TextField {
186
186
  * @returns {void}
187
187
  */
188
188
  protected syncInputValue(changedProperties?: PropertyValues): void;
189
- /**
190
- * Check if input should be re-validated
191
- * @param changedProperties Properties that has changed
192
- * @returns True if input should be re-validated
193
- */
194
- protected shouldValidateInput(changedProperties: PropertyValues): boolean;
195
- /**
196
- * Validate input according `pattern`, `minLength` and `maxLength` properties
197
- * change state of `error` property according pattern validation
198
- * @returns {void}
199
- */
200
- protected validateInput(): void;
201
189
  /**
202
190
  * Override validation method for value
203
191
  * @param value value
@@ -244,21 +232,11 @@ export declare class DatetimeField extends TextField {
244
232
  * @returns {void}
245
233
  */
246
234
  protected setValueAndNotify(value: string): void;
247
- /**
248
- * Reset error state on input
249
- * @returns {void}
250
- */
251
- protected resetError(): void;
252
235
  /**
253
236
  * Returns true if an input element contains valid data.
254
237
  * @returns true if input is valid
255
238
  */
256
239
  checkValidity(): boolean;
257
- /**
258
- * Validate input. Mark as error if input is invalid
259
- * @returns false if there is an error
260
- */
261
- reportValidity(): boolean;
262
240
  /**
263
241
  * Select part
264
242
  * @param parts The list of parts
@@ -294,23 +294,6 @@ let DatetimeField = class DatetimeField extends TextField {
294
294
  this.inputValue = inputValue; // setting the value resets selection
295
295
  }
296
296
  }
297
- /**
298
- * Check if input should be re-validated
299
- * @param changedProperties Properties that has changed
300
- * @returns True if input should be re-validated
301
- */
302
- shouldValidateInput(changedProperties) {
303
- // TODO: this needs refactoring with all other fields to support common validation patterns
304
- return changedProperties.has(FocusedPropertyKey) && !this.focused;
305
- }
306
- /**
307
- * Validate input according `pattern`, `minLength` and `maxLength` properties
308
- * change state of `error` property according pattern validation
309
- * @returns {void}
310
- */
311
- validateInput() {
312
- this.reportValidity();
313
- }
314
297
  /**
315
298
  * Override validation method for value
316
299
  * @param value value
@@ -399,15 +382,6 @@ let DatetimeField = class DatetimeField extends TextField {
399
382
  this.notifyPropertyChange('value', value);
400
383
  }
401
384
  }
402
- /**
403
- * Reset error state on input
404
- * @returns {void}
405
- */
406
- resetError() {
407
- if (this.error && this.checkValidity()) {
408
- this.reportValidity();
409
- }
410
- }
411
385
  /**
412
386
  * Returns true if an input element contains valid data.
413
387
  * @returns true if input is valid
@@ -433,15 +407,6 @@ let DatetimeField = class DatetimeField extends TextField {
433
407
  }
434
408
  return true;
435
409
  }
436
- /**
437
- * Validate input. Mark as error if input is invalid
438
- * @returns false if there is an error
439
- */
440
- reportValidity() {
441
- const hasError = !this.checkValidity();
442
- this.notifyErrorChange(hasError);
443
- return !hasError;
444
- }
445
410
  /**
446
411
  * Select part
447
412
  * @param parts The list of parts
@@ -527,7 +492,7 @@ let DatetimeField = class DatetimeField extends TextField {
527
492
  this.setValueAndNotify(newValue);
528
493
  this.syncInputValue();
529
494
  this.selectPart(this.formatToParts(newValue), selectedPartIndex);
530
- this.resetError();
495
+ this.reportValidity();
531
496
  event.preventDefault();
532
497
  }
533
498
  break;
@@ -547,8 +512,7 @@ let DatetimeField = class DatetimeField extends TextField {
547
512
  */
548
513
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
549
514
  onPossibleValueChange(event) {
550
- // Nobody likes to see a red border
551
- this.resetError();
515
+ this.reportValidity();
552
516
  this.selectPartFrame.cancel(); // ensure no pending selection
553
517
  this.partLabel = '';
554
518
  const inputValue = this.inputElement?.value || '';
@@ -180,6 +180,18 @@
180
180
  "name": "icon-click",
181
181
  "description": "Fired when the user taps on icon added into control's slot."
182
182
  }
183
+ ],
184
+ "methods": [
185
+ {
186
+ "name": "checkValidity",
187
+ "description": "Returns `true` if the element input is valid; otherwise, returns `false`.",
188
+ "params": []
189
+ },
190
+ {
191
+ "name": "reportValidity",
192
+ "description": "Validate the element input and mark it as error if its input is invalid.",
193
+ "params": []
194
+ }
183
195
  ]
184
196
  }
185
197
  ]