@refinitiv-ui/elements 7.0.0 → 7.0.2

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 (215) hide show
  1. package/CHANGELOG.md +195 -449
  2. package/LICENSE +2 -2
  3. package/README.md +12 -10
  4. package/cli.mjs +5 -3
  5. package/lib/accordion/index.d.ts +1 -1
  6. package/lib/accordion/index.js +4 -7
  7. package/lib/appstate-bar/index.d.ts +2 -2
  8. package/lib/appstate-bar/index.js +10 -4
  9. package/lib/autosuggest/index.d.ts +7 -7
  10. package/lib/autosuggest/index.js +80 -80
  11. package/lib/autosuggest/themes/solar/charcoal/index.js +1 -1
  12. package/lib/autosuggest/themes/solar/pearl/index.js +1 -1
  13. package/lib/button/index.js +7 -10
  14. package/lib/button-bar/index.d.ts +1 -1
  15. package/lib/button-bar/index.js +12 -12
  16. package/lib/calendar/index.d.ts +39 -39
  17. package/lib/calendar/index.js +156 -123
  18. package/lib/calendar/utils.js +1 -1
  19. package/lib/canvas/index.d.ts +1 -1
  20. package/lib/canvas/index.js +2 -4
  21. package/lib/card/helpers/types.d.ts +2 -2
  22. package/lib/card/index.d.ts +5 -5
  23. package/lib/card/index.js +34 -28
  24. package/lib/chart/elements/chart.d.ts +4 -4
  25. package/lib/chart/elements/chart.js +39 -33
  26. package/lib/chart/plugins/doughnut-center-label.d.ts +3 -3
  27. package/lib/chart/plugins/doughnut-center-label.js +13 -9
  28. package/lib/checkbox/index.d.ts +1 -1
  29. package/lib/checkbox/index.js +12 -13
  30. package/lib/clock/index.d.ts +55 -55
  31. package/lib/clock/index.js +84 -95
  32. package/lib/clock/themes/halo/dark/index.js +1 -1
  33. package/lib/clock/themes/halo/light/index.js +1 -1
  34. package/lib/clock/themes/solar/charcoal/index.js +1 -1
  35. package/lib/clock/themes/solar/pearl/index.js +1 -1
  36. package/lib/collapse/index.d.ts +1 -1
  37. package/lib/collapse/index.js +27 -18
  38. package/lib/collapse/themes/halo/dark/index.js +1 -1
  39. package/lib/collapse/themes/halo/light/index.js +1 -1
  40. package/lib/color-dialog/elements/color-palettes.d.ts +1 -1
  41. package/lib/color-dialog/elements/color-palettes.js +5 -6
  42. package/lib/color-dialog/elements/grayscale-palettes.d.ts +1 -1
  43. package/lib/color-dialog/elements/grayscale-palettes.js +9 -9
  44. package/lib/color-dialog/elements/palettes.js +5 -4
  45. package/lib/color-dialog/helpers/value-model.js +7 -9
  46. package/lib/color-dialog/index.d.ts +6 -6
  47. package/lib/color-dialog/index.js +53 -37
  48. package/lib/color-picker/index.d.ts +2 -2
  49. package/lib/color-picker/index.js +40 -34
  50. package/lib/combo-box/helpers/filter.d.ts +2 -2
  51. package/lib/combo-box/helpers/types.d.ts +1 -1
  52. package/lib/combo-box/index.d.ts +9 -9
  53. package/lib/combo-box/index.js +61 -55
  54. package/lib/configuration/elements/configuration.js +2 -2
  55. package/lib/counter/index.d.ts +4 -4
  56. package/lib/counter/index.js +9 -7
  57. package/lib/datetime-field/index.d.ts +4 -5
  58. package/lib/datetime-field/index.js +32 -23
  59. package/lib/datetime-field/utils.js +11 -1
  60. package/lib/datetime-picker/index.d.ts +75 -75
  61. package/lib/datetime-picker/index.js +150 -131
  62. package/lib/datetime-picker/locales.js +5 -5
  63. package/lib/datetime-picker/utils.js +9 -9
  64. package/lib/dialog/draggable-element.js +1 -2
  65. package/lib/dialog/index.d.ts +5 -5
  66. package/lib/dialog/index.js +51 -47
  67. package/lib/email-field/index.d.ts +1 -1
  68. package/lib/email-field/index.js +6 -6
  69. package/lib/events.d.ts +1 -1
  70. package/lib/flag/index.d.ts +1 -1
  71. package/lib/flag/index.js +6 -5
  72. package/lib/flag/utils/FlagLoader.js +1 -1
  73. package/lib/header/index.d.ts +1 -1
  74. package/lib/header/index.js +2 -2
  75. package/lib/header/themes/halo/dark/index.js +1 -1
  76. package/lib/header/themes/halo/light/index.js +1 -1
  77. package/lib/header/themes/solar/charcoal/index.js +1 -1
  78. package/lib/header/themes/solar/pearl/index.js +1 -1
  79. package/lib/heatmap/helpers/color.d.ts +1 -1
  80. package/lib/heatmap/helpers/color.js +11 -5
  81. package/lib/heatmap/helpers/track.js +3 -3
  82. package/lib/heatmap/index.d.ts +9 -9
  83. package/lib/heatmap/index.js +51 -42
  84. package/lib/icon/index.d.ts +2 -2
  85. package/lib/icon/index.js +8 -10
  86. package/lib/interactive-chart/helpers/types.d.ts +3 -3
  87. package/lib/interactive-chart/index.d.ts +29 -29
  88. package/lib/interactive-chart/index.js +69 -55
  89. package/lib/item/helpers/types.d.ts +1 -1
  90. package/lib/item/index.d.ts +3 -3
  91. package/lib/item/index.js +24 -20
  92. package/lib/jsx.d.ts +6 -4
  93. package/lib/label/index.d.ts +1 -1
  94. package/lib/label/index.js +10 -7
  95. package/lib/layout/index.d.ts +7 -7
  96. package/lib/layout/index.js +7 -7
  97. package/lib/led-gauge/index.d.ts +1 -1
  98. package/lib/led-gauge/index.js +10 -10
  99. package/lib/list/elements/list.d.ts +3 -3
  100. package/lib/list/elements/list.js +10 -12
  101. package/lib/list/helpers/renderer.js +2 -2
  102. package/lib/list/helpers/types.d.ts +1 -1
  103. package/lib/list/index.d.ts +1 -1
  104. package/lib/list/renderer.d.ts +7 -7
  105. package/lib/loader/index.js +7 -8
  106. package/lib/multi-input/index.d.ts +6 -6
  107. package/lib/multi-input/index.js +39 -45
  108. package/lib/notification/elements/notification-tray.d.ts +2 -2
  109. package/lib/notification/elements/notification-tray.js +3 -3
  110. package/lib/notification/elements/notification.d.ts +2 -2
  111. package/lib/notification/elements/notification.js +14 -13
  112. package/lib/notification/helpers/status.js +1 -1
  113. package/lib/notification/themes/halo/dark/index.js +1 -1
  114. package/lib/notification/themes/halo/light/index.js +1 -1
  115. package/lib/notification/themes/solar/charcoal/index.js +1 -1
  116. package/lib/notification/themes/solar/pearl/index.js +1 -1
  117. package/lib/number-field/index.d.ts +5 -6
  118. package/lib/number-field/index.js +37 -47
  119. package/lib/overlay/elements/overlay-viewport.d.ts +1 -1
  120. package/lib/overlay/elements/overlay.d.ts +2 -2
  121. package/lib/overlay/elements/overlay.js +152 -96
  122. package/lib/overlay/helpers/types.d.ts +1 -1
  123. package/lib/overlay/managers/backdrop-manager.d.ts +1 -1
  124. package/lib/overlay/managers/backdrop-manager.js +2 -2
  125. package/lib/overlay/managers/close-manager.js +2 -1
  126. package/lib/overlay/managers/focus-manager.js +23 -13
  127. package/lib/overlay/managers/interaction-lock-manager.d.ts +4 -4
  128. package/lib/overlay/managers/interaction-lock-manager.js +33 -25
  129. package/lib/overlay/managers/viewport-manager.d.ts +2 -2
  130. package/lib/overlay/managers/viewport-manager.js +3 -2
  131. package/lib/overlay/managers/zindex-manager.js +4 -2
  132. package/lib/overlay-menu/helpers/types.d.ts +2 -2
  133. package/lib/overlay-menu/index.d.ts +1 -1
  134. package/lib/overlay-menu/index.js +44 -33
  135. package/lib/overlay-menu/managers/menu-manager.d.ts +10 -10
  136. package/lib/overlay-menu/managers/menu-manager.js +14 -13
  137. package/lib/pagination/index.d.ts +4 -4
  138. package/lib/pagination/index.js +39 -14
  139. package/lib/panel/index.js +1 -1
  140. package/lib/password-field/index.d.ts +2 -2
  141. package/lib/password-field/index.js +3 -3
  142. package/lib/pill/index.d.ts +1 -1
  143. package/lib/pill/index.js +22 -19
  144. package/lib/progress-bar/index.d.ts +1 -1
  145. package/lib/progress-bar/index.js +38 -37
  146. package/lib/radio-button/index.d.ts +2 -2
  147. package/lib/radio-button/index.js +17 -12
  148. package/lib/radio-button/radio-button-registry.js +8 -5
  149. package/lib/rating/index.d.ts +1 -1
  150. package/lib/rating/index.js +2 -5
  151. package/lib/rating/utils.d.ts +6 -6
  152. package/lib/rating/utils.js +6 -6
  153. package/lib/search-field/index.d.ts +2 -2
  154. package/lib/search-field/index.js +4 -4
  155. package/lib/select/index.d.ts +34 -34
  156. package/lib/select/index.js +68 -81
  157. package/lib/sidebar-layout/index.d.ts +2 -2
  158. package/lib/sidebar-layout/index.js +7 -9
  159. package/lib/slider/index.d.ts +2 -2
  160. package/lib/slider/index.js +57 -45
  161. package/lib/slider/utils.d.ts +10 -10
  162. package/lib/slider/utils.js +10 -10
  163. package/lib/sparkline/index.d.ts +1 -1
  164. package/lib/sparkline/index.js +7 -8
  165. package/lib/swing-gauge/helpers.js +2 -2
  166. package/lib/swing-gauge/index.d.ts +19 -19
  167. package/lib/swing-gauge/index.js +91 -81
  168. package/lib/tab/index.d.ts +1 -1
  169. package/lib/tab/index.js +16 -27
  170. package/lib/tab/themes/halo/dark/index.js +1 -1
  171. package/lib/tab/themes/halo/light/index.js +1 -1
  172. package/lib/tab/themes/solar/charcoal/index.js +1 -1
  173. package/lib/tab/themes/solar/pearl/index.js +1 -1
  174. package/lib/tab-bar/helpers/animate.js +1 -1
  175. package/lib/tab-bar/index.d.ts +1 -1
  176. package/lib/tab-bar/index.js +34 -18
  177. package/lib/tab-bar/themes/halo/dark/index.js +1 -1
  178. package/lib/tab-bar/themes/halo/light/index.js +1 -1
  179. package/lib/text-field/index.d.ts +1 -1
  180. package/lib/text-field/index.js +34 -31
  181. package/lib/time-picker/index.d.ts +6 -6
  182. package/lib/time-picker/index.js +103 -89
  183. package/lib/toggle/index.d.ts +1 -1
  184. package/lib/toggle/index.js +4 -3
  185. package/lib/toggle/themes/halo/dark/index.js +1 -1
  186. package/lib/toggle/themes/halo/light/index.js +1 -1
  187. package/lib/toggle/themes/solar/charcoal/index.js +1 -1
  188. package/lib/toggle/themes/solar/pearl/index.js +1 -1
  189. package/lib/tooltip/elements/title-tooltip.js +2 -2
  190. package/lib/tooltip/index.d.ts +27 -27
  191. package/lib/tooltip/index.js +42 -38
  192. package/lib/tooltip/managers/tooltip-manager.d.ts +1 -1
  193. package/lib/tornado-chart/elements/tornado-chart.d.ts +1 -1
  194. package/lib/tornado-chart/elements/tornado-chart.js +2 -2
  195. package/lib/tornado-chart/elements/tornado-item.d.ts +2 -2
  196. package/lib/tornado-chart/elements/tornado-item.js +12 -10
  197. package/lib/tree/elements/tree-item.d.ts +3 -3
  198. package/lib/tree/elements/tree-item.js +21 -19
  199. package/lib/tree/elements/tree.d.ts +1 -1
  200. package/lib/tree/elements/tree.js +12 -11
  201. package/lib/tree/helpers/renderer.js +4 -3
  202. package/lib/tree/index.d.ts +1 -1
  203. package/lib/tree/managers/tree-manager.d.ts +1 -1
  204. package/lib/tree/managers/tree-manager.js +17 -18
  205. package/lib/tree/themes/solar/charcoal/index.js +1 -1
  206. package/lib/tree/themes/solar/pearl/index.js +1 -1
  207. package/lib/tree-select/index.d.ts +9 -9
  208. package/lib/tree-select/index.js +91 -82
  209. package/lib/tree-select/themes/halo/dark/index.js +1 -1
  210. package/lib/tree-select/themes/halo/light/index.js +1 -1
  211. package/lib/tree-select/themes/solar/charcoal/index.js +1 -1
  212. package/lib/tree-select/themes/solar/pearl/index.js +1 -1
  213. package/lib/version.js +1 -1
  214. package/package.json +17 -17
  215. package/tsconfig.tsbuildinfo +1 -1
@@ -1,20 +1,20 @@
1
1
  import { __decorate } from "tslib";
2
- import { ControlElement, html, css, WarningNotice, nothing } from '@refinitiv-ui/core';
2
+ import inputFormat from 'date-fns/esm/format/index.js';
3
+ import isValid from 'date-fns/esm/isValid/index.js';
4
+ import inputParse from 'date-fns/esm/parse/index.js';
5
+ import { ControlElement, WarningNotice, css, html, nothing } from '@refinitiv-ui/core';
3
6
  import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
4
7
  import { property } from '@refinitiv-ui/core/decorators/property.js';
5
8
  import { query } from '@refinitiv-ui/core/decorators/query.js';
6
- import { VERSION } from '../version.js';
9
+ import { TranslatePropertyKey, getLocale, translate } from '@refinitiv-ui/translate';
10
+ import { DateFormat, DateTimeFormat, addMonths, format, isAfter, isBefore, isValidDate, isValidDateTime, parse, subMonths } from '@refinitiv-ui/utils/date.js';
7
11
  import '../calendar/index.js';
8
12
  import '../icon/index.js';
9
13
  import '../overlay/index.js';
10
14
  import '../text-field/index.js';
11
15
  import '../time-picker/index.js';
12
- import { translate, getLocale, TranslatePropertyKey } from '@refinitiv-ui/translate';
16
+ import { VERSION } from '../version.js';
13
17
  import { getDateFNSLocale } from './locales.js';
14
- import inputFormat from 'date-fns/esm/format/index.js';
15
- import inputParse from 'date-fns/esm/parse/index.js';
16
- import isValid from 'date-fns/esm/isValid/index.js';
17
- import { addMonths, subMonths, isAfter, isBefore, isValidDate, isValidDateTime, DateFormat, DateTimeFormat, parse, format } from '@refinitiv-ui/utils/date.js';
18
18
  import { DateTimeSegment, formatToView, getCurrentTime } from './utils.js';
19
19
  const POPUP_POSITION = ['bottom-start', 'top-start', 'bottom-end', 'top-end', 'bottom-middle', 'top-middle'];
20
20
  const INPUT_FORMAT = {
@@ -56,21 +56,21 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
56
56
  this._max = '';
57
57
  this.maxDate = '';
58
58
  /**
59
- * Only enable weekdays
60
- */
59
+ * Only enable weekdays
60
+ */
61
61
  this.weekdaysOnly = false;
62
62
  /**
63
- * Only enable weekends
64
- */
63
+ * Only enable weekends
64
+ */
65
65
  this.weekendsOnly = false;
66
66
  /**
67
- * Custom filter, used for enabling/disabling certain dates
68
- * @type {DatetimePickerFilter | null}
69
- */
67
+ * Custom filter, used for enabling/disabling certain dates
68
+ * @type {DatetimePickerFilter | null}
69
+ */
70
70
  this.filter = null;
71
71
  /**
72
- * Set to switch to range select mode
73
- */
72
+ * Set to switch to range select mode
73
+ */
74
74
  this.range = false;
75
75
  this._values = []; /* list of values as passed by the user */
76
76
  this._segments = []; /* filtered and processed list of values */
@@ -85,8 +85,8 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
85
85
  this.showSeconds = false;
86
86
  this._placeholder = '';
87
87
  /**
88
- * Toggles the opened state of the list
89
- */
88
+ * Toggles the opened state of the list
89
+ */
90
90
  this.opened = false;
91
91
  /**
92
92
  * Set state to error
@@ -97,27 +97,27 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
97
97
  */
98
98
  this.warning = false;
99
99
  /**
100
- * Only open picker panel when calendar icon is clicked.
101
- * Clicking on the input will no longer open the picker.
102
- */
100
+ * Only open picker panel when calendar icon is clicked.
101
+ * Clicking on the input will no longer open the picker.
102
+ */
103
103
  this.inputTriggerDisabled = false;
104
104
  /**
105
- * Disable input part of the picker
106
- */
105
+ * Disable input part of the picker
106
+ */
107
107
  this.inputDisabled = false;
108
108
  /**
109
- * Disable the popup
110
- */
109
+ * Disable the popup
110
+ */
111
111
  this.popupDisabled = false;
112
112
  this._format = '';
113
113
  /**
114
- * Toggle to display the time picker
115
- */
114
+ * Toggle to display the time picker
115
+ */
116
116
  this.timepicker = false;
117
117
  /**
118
- * Display two calendar pickers.
119
- * @type {"" | "consecutive" | "split"}
120
- */
118
+ * Display two calendar pickers.
119
+ * @type {"" | "consecutive" | "split"}
120
+ */
121
121
  this.duplex = null;
122
122
  this._views = [];
123
123
  this._interimSegments = [];
@@ -143,44 +143,45 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
143
143
  outline: none;
144
144
  cursor: text;
145
145
  }
146
- [part=input-wrapper] {
146
+ [part='input-wrapper'] {
147
147
  display: flex;
148
148
  flex: 1;
149
149
  }
150
- [part=body] {
150
+ [part='body'] {
151
151
  display: flex;
152
152
  }
153
- [part=timepicker-wrapper] {
153
+ [part='timepicker-wrapper'] {
154
154
  display: flex;
155
155
  justify-content: space-between;
156
156
  }
157
- [part=timepicker-wrapper]:before,
158
- [part=timepicker-wrapper]:after {
157
+ [part='timepicker-wrapper']:before,
158
+ [part='timepicker-wrapper']:after {
159
159
  content: '';
160
160
  }
161
- [part=input] {
161
+ [part='input'] {
162
162
  flex: 1;
163
163
  width: auto;
164
164
  height: auto;
165
165
  padding: 0;
166
166
  margin: 0;
167
167
  }
168
- [part=calendar-wrapper] {
168
+ [part='calendar-wrapper'] {
169
169
  display: inline-flex;
170
170
  }
171
- [part=icon] {
171
+ [part='icon'] {
172
172
  cursor: pointer;
173
173
  }
174
- :host([popup-disabled]) [part=icon], :host([readonly]) [part=icon] {
174
+ :host([popup-disabled]) [part='icon'],
175
+ :host([readonly]) [part='icon'] {
175
176
  pointer-events: none;
176
177
  }
177
178
  `;
178
179
  }
179
180
  /**
180
- * Set minimum date
181
- * @param min date
182
- * @default -
183
- */
181
+ * Set minimum date
182
+ * @param min date
183
+ * @default -
184
+ */
184
185
  set min(min) {
185
186
  if (!this.isValidValue(min)) {
186
187
  this.warnInvalidValue(min);
@@ -197,10 +198,10 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
197
198
  return this._min;
198
199
  }
199
200
  /**
200
- * Set maximum date
201
- * @param max date
202
- * @default -
203
- */
201
+ * Set maximum date
202
+ * @param max date
203
+ * @default -
204
+ */
204
205
  set max(max) {
205
206
  if (!this.isValidValue(max)) {
206
207
  this.warnInvalidValue(max);
@@ -217,26 +218,26 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
217
218
  return this._max;
218
219
  }
219
220
  /**
220
- * Set to switch to multiple select mode
221
- * @ignore
222
- * @param multiple Multiple
223
- */
221
+ * Set to switch to multiple select mode
222
+ * @ignore
223
+ * @param multiple Multiple
224
+ */
224
225
  /* c8 ignore start */
225
226
  set multiple(multiple) {
226
227
  new WarningNotice('multiple is not currently supported').show();
227
228
  }
228
229
  /* c8 ignore stop */
229
230
  /**
230
- * @ignore
231
- */
231
+ * @ignore
232
+ */
232
233
  get multiple() {
233
234
  return false;
234
235
  }
235
236
  /**
236
- * Current date time value
237
- * @param value Calendar value
238
- * @default -
239
- */
237
+ * Current date time value
238
+ * @param value Calendar value
239
+ * @default -
240
+ */
240
241
  set value(value) {
241
242
  this.values = value ? [value] : [];
242
243
  }
@@ -244,11 +245,11 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
244
245
  return this.values[0] || '';
245
246
  }
246
247
  /**
247
- * Set multiple selected values
248
- * @param values Values to set
249
- * @type {string[]}
250
- * @default []
251
- */
248
+ * Set multiple selected values
249
+ * @param values Values to set
250
+ * @type {string[]}
251
+ * @default []
252
+ */
252
253
  set values(values) {
253
254
  const oldValues = this._values;
254
255
  if (String(oldValues) !== String(values)) {
@@ -258,13 +259,13 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
258
259
  }
259
260
  }
260
261
  get values() {
261
- return this._segments.map(segment => segment.value);
262
+ return this._segments.map((segment) => segment.value);
262
263
  }
263
264
  /**
264
- * Placeholder to display when no value is set
265
- * @param placeholder Placeholder
266
- * @default -
267
- */
265
+ * Placeholder to display when no value is set
266
+ * @param placeholder Placeholder
267
+ * @default -
268
+ */
268
269
  set placeholder(placeholder) {
269
270
  const oldPlaceholder = this._placeholder;
270
271
  if (oldPlaceholder !== placeholder) {
@@ -276,11 +277,11 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
276
277
  return this._placeholder || this.format;
277
278
  }
278
279
  /**
279
- * Set the datetime format
280
- * Based on dane-fns datetime formats
281
- * @param format Date format
282
- * @default -
283
- */
280
+ * Set the datetime format
281
+ * Based on dane-fns datetime formats
282
+ * @param format Date format
283
+ * @default -
284
+ */
284
285
  set format(format) {
285
286
  const oldFormat = this._format;
286
287
  if (oldFormat !== format) {
@@ -289,18 +290,23 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
289
290
  }
290
291
  }
291
292
  get format() {
292
- return this._format || (this.timepicker
293
- ? (this.showSeconds
294
- ? (this.amPm ? INPUT_FORMAT.DATETIME_SECONDS_AM_PM : INPUT_FORMAT.DATETIME_SECONDS)
295
- : (this.amPm ? INPUT_FORMAT.DATETIME_AM_PM : INPUT_FORMAT.DATETIME))
296
- : INPUT_FORMAT.DATE);
293
+ return (this._format ||
294
+ (this.timepicker
295
+ ? this.showSeconds
296
+ ? this.amPm
297
+ ? INPUT_FORMAT.DATETIME_SECONDS_AM_PM
298
+ : INPUT_FORMAT.DATETIME_SECONDS
299
+ : this.amPm
300
+ ? INPUT_FORMAT.DATETIME_AM_PM
301
+ : INPUT_FORMAT.DATETIME
302
+ : INPUT_FORMAT.DATE));
297
303
  }
298
304
  /**
299
- * Set the current calendar view.
300
- * Accepted format: 'yyyy-MM'
301
- * @param view view date
302
- * @default -
303
- */
305
+ * Set the current calendar view.
306
+ * Accepted format: 'yyyy-MM'
307
+ * @param view view date
308
+ * @default -
309
+ */
304
310
  set view(view) {
305
311
  this.views = view ? [view] : [];
306
312
  }
@@ -308,12 +314,12 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
308
314
  return this.views[0] || '';
309
315
  }
310
316
  /**
311
- * Set the current calendar views for duplex mode
312
- * Accepted format: 'yyyy-MM'
313
- * @param views view dates
314
- * @type {string[]}
315
- * @default []
316
- */
317
+ * Set the current calendar views for duplex mode
318
+ * Accepted format: 'yyyy-MM'
319
+ * @param views view dates
320
+ * @type {string[]}
321
+ * @default []
322
+ */
317
323
  set views(views) {
318
324
  const oldViews = this._views;
319
325
  views = this.filterAndWarnInvalidViews(views);
@@ -333,7 +339,11 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
333
339
  }
334
340
  const to = this.values[1];
335
341
  // default duplex mode
336
- if (this.isDuplexConsecutive() || !from || !to || formatToView(from) === formatToView(to) || isBefore(to, from)) {
342
+ if (this.isDuplexConsecutive() ||
343
+ !from ||
344
+ !to ||
345
+ formatToView(from) === formatToView(to) ||
346
+ isBefore(to, from)) {
337
347
  return this.composeViews(formatToView(from || to || now), !from && to ? 1 : 0, []);
338
348
  }
339
349
  // duplex split if as from and to
@@ -393,15 +403,15 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
393
403
  }
394
404
  // Need to check for the attribute to cover the case when
395
405
  // timepicker and value attributes are set
396
- return (this.timepicker || this.hasAttribute('timepicker'))
406
+ return this.timepicker || this.hasAttribute('timepicker')
397
407
  ? isValidDateTime(value)
398
408
  : isValidDate(value, DateFormat.yyyyMMdd);
399
409
  }
400
410
  /**
401
- * Used to show a warning when the value does not pass the validation
402
- * @param value that is invalid
403
- * @returns {void}
404
- */
411
+ * Used to show a warning when the value does not pass the validation
412
+ * @param value that is invalid
413
+ * @returns {void}
414
+ */
405
415
  warnInvalidValue(value) {
406
416
  new WarningNotice(`The specified value "${value}" does not conform to the required format. The format is ${this.timepicker ? '"yyyy-MM-ddThh:mm" followed by optional ":ss" or ":ss.SSS"' : '"yyyy-MM-dd"'}.`).show();
407
417
  }
@@ -419,7 +429,7 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
419
429
  * @returns {void}
420
430
  */
421
431
  valuesToSegments() {
422
- const newSegments = this.filterAndWarnInvalidValues(this._values).map(value => DateTimeSegment.fromString(value));
432
+ const newSegments = this.filterAndWarnInvalidValues(this._values).map((value) => DateTimeSegment.fromString(value));
423
433
  this._segments = newSegments;
424
434
  this.interimSegments = newSegments;
425
435
  }
@@ -430,10 +440,10 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
430
440
  */
431
441
  shouldValidateValue(changedProperties) {
432
442
  // do not validate default value
433
- if (changedProperties.has('_values') && changedProperties.get('_values') !== undefined
434
- || changedProperties.has('min') && changedProperties.get('min') !== undefined
435
- || changedProperties.has('max') && changedProperties.get('max') !== undefined
436
- || changedProperties.has('showSeconds') && changedProperties.get('showSeconds') !== undefined) {
443
+ if ((changedProperties.has('_values') && changedProperties.get('_values') !== undefined) ||
444
+ (changedProperties.has('min') && changedProperties.get('min') !== undefined) ||
445
+ (changedProperties.has('max') && changedProperties.get('max') !== undefined) ||
446
+ (changedProperties.has('showSeconds') && changedProperties.get('showSeconds') !== undefined)) {
437
447
  return true;
438
448
  }
439
449
  return false;
@@ -445,7 +455,7 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
445
455
  * @returns Filtered collection of values
446
456
  */
447
457
  filterAndWarnInvalidValues(values) {
448
- return values.map(value => {
458
+ return values.map((value) => {
449
459
  if (this.isValidValue(value)) {
450
460
  return value;
451
461
  }
@@ -514,7 +524,7 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
514
524
  }
515
525
  // input values cannot be populated off interim segments as require a valid date
516
526
  // date-fns formats to local if there is time info
517
- this.inputValues = this._segments.map(segment => this.formatSegment(segment));
527
+ this.inputValues = this._segments.map((segment) => this.formatSegment(segment));
518
528
  }
519
529
  /**
520
530
  * Format date segment according to format and locale
@@ -522,9 +532,11 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
522
532
  * @returns formatted string
523
533
  */
524
534
  formatSegment(segment) {
525
- return segment.value ? inputFormat(segment.getTime(), this.format, {
526
- locale: getDateFNSLocale(getLocale(this))
527
- }) : '';
535
+ return segment.value
536
+ ? inputFormat(segment.getTime(), this.format, {
537
+ locale: getDateFNSLocale(getLocale(this))
538
+ })
539
+ : '';
528
540
  }
529
541
  /**
530
542
  * Construct view collection
@@ -539,22 +551,26 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
539
551
  return [view];
540
552
  }
541
553
  if (this.isDuplexConsecutive()) {
542
- if (index === 0) { /* from */
554
+ if (index === 0) {
555
+ /* from */
543
556
  return [view, formatToView(addMonths(view, 1))];
544
557
  }
545
- else { /* to */
558
+ else {
559
+ /* to */
546
560
  return [formatToView(subMonths(view, 1)), view];
547
561
  }
548
562
  }
549
563
  // duplex split
550
- if (index === 0) { /* from. to must be after or the same */
564
+ if (index === 0) {
565
+ /* from. to must be after or the same */
551
566
  let after = views[1] || addMonths(view, 1);
552
567
  if (isBefore(after, view)) {
553
568
  after = view;
554
569
  }
555
570
  return [view, formatToView(after)];
556
571
  }
557
- if (index === 1) { /* to. from must be before or the same */
572
+ if (index === 1) {
573
+ /* to. from must be before or the same */
558
574
  let before = views[0] || subMonths(view, 1);
559
575
  if (isAfter(before, view)) {
560
576
  before = view;
@@ -569,11 +585,11 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
569
585
  * @param segments Segments
570
586
  */
571
587
  set interimSegments(segments) {
572
- const interimSegments = segments.map(segment => DateTimeSegment.fromDateTimeSegment(segment));
588
+ const interimSegments = segments.map((segment) => DateTimeSegment.fromDateTimeSegment(segment));
573
589
  this._interimSegments = interimSegments;
574
590
  // cannot populate calendar if from is after to, it looks broken
575
- this.calendarValues = this.isFromBeforeTo() ? interimSegments.map(segment => segment.dateSegment) : [];
576
- this.timepickerValues = interimSegments.map(segment => segment.timeSegment);
591
+ this.calendarValues = this.isFromBeforeTo() ? interimSegments.map((segment) => segment.dateSegment) : [];
592
+ this.timepickerValues = interimSegments.map((segment) => segment.timeSegment);
577
593
  }
578
594
  /**
579
595
  * Get interim segments. These are free to modify
@@ -594,9 +610,10 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
594
610
  if (oldSegments.toString() === newSegments.toString()) {
595
611
  return false;
596
612
  }
597
- const newValues = newSegments.map(segment => segment.value);
613
+ const newValues = newSegments.map((segment) => segment.value);
598
614
  // validate
599
- for (let i = 0; i < newValues.length; i += 1) { /* need this step in case timepicker is not populated */
615
+ for (let i = 0; i < newValues.length; i += 1) {
616
+ /* need this step in case timepicker is not populated */
600
617
  if (!this.isValidValue(newValues[i])) {
601
618
  return false;
602
619
  }
@@ -802,7 +819,11 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
802
819
  locale: getDateFNSLocale(getLocale(this))
803
820
  });
804
821
  if (isValid(date)) {
805
- dateString = inputFormat(date, this.timepicker ? this.showSeconds ? DateTimeFormat.yyyMMddTHHmmss : DateTimeFormat.yyyMMddTHHmm : DateFormat.yyyyMMdd);
822
+ dateString = inputFormat(date, this.timepicker
823
+ ? this.showSeconds
824
+ ? DateTimeFormat.yyyMMddTHHmmss
825
+ : DateTimeFormat.yyyMMddTHHmm
826
+ : DateFormat.yyyyMMdd);
806
827
  this.resetViews(); /* user input should be treated similar to manually switching the views */
807
828
  }
808
829
  }
@@ -893,7 +914,8 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
893
914
  * @returns {void}
894
915
  */
895
916
  setOpened(opened) {
896
- if (opened && !this.canOpenPopup) { /* never allow to open popup if cannot do so */
917
+ if (opened && !this.canOpenPopup) {
918
+ /* never allow to open popup if cannot do so */
897
919
  return;
898
920
  }
899
921
  if (this.opened !== opened && this.notifyPropertyChange('opened', opened, true)) {
@@ -920,7 +942,8 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
920
942
  .showSeconds=${this.showSeconds}
921
943
  .amPm=${this.amPm}
922
944
  .value=${value}
923
- @value-changed=${this.onTimePickerValueChanged}></ef-time-picker>`;
945
+ @value-changed=${this.onTimePickerValueChanged}
946
+ ></ef-time-picker>`;
924
947
  }
925
948
  /**
926
949
  * Get calendar template
@@ -946,7 +969,8 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
946
969
  .view=${view}
947
970
  @keydown=${this.onCalendarKeyDown}
948
971
  @view-changed=${this.onCalendarViewChanged}
949
- @value-changed=${this.onCalendarValueChanged}></ef-calendar>`;
972
+ @value-changed=${this.onCalendarValueChanged}
973
+ ></ef-calendar>`;
950
974
  }
951
975
  /**
952
976
  * Get calendar templates
@@ -988,18 +1012,15 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
988
1012
  @focus=${this.onInputFocus}
989
1013
  @blur=${this.onInputBlur}
990
1014
  @keydown=${this.onInputKeyDown}
991
- @value-changed=${this.onInputValueChanged}></ef-text-field>
1015
+ @value-changed=${this.onInputValueChanged}
1016
+ ></ef-text-field>
992
1017
  `;
993
1018
  }
994
1019
  /**
995
1020
  * Template for rendering an icon
996
1021
  */
997
1022
  get iconTemplate() {
998
- return html `
999
- <ef-icon
1000
- part="icon"
1001
- icon="calendar"></ef-icon>
1002
- `;
1023
+ return html ` <ef-icon part="icon" icon="calendar"></ef-icon> `;
1003
1024
  }
1004
1025
  /**
1005
1026
  * Template for inputs
@@ -1016,8 +1037,8 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
1016
1037
  `;
1017
1038
  }
1018
1039
  /**
1019
- * Popup panel template
1020
- */
1040
+ * Popup panel template
1041
+ */
1021
1042
  get popupTemplate() {
1022
1043
  if (this.lazyRendered) {
1023
1044
  return html `<ef-overlay
@@ -1039,7 +1060,9 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
1039
1060
  <div part="calendar-wrapper">
1040
1061
  ${this.calendarsTemplate}
1041
1062
  </div>
1042
- ${this.timepicker ? html `<div part="timepicker-wrapper">${this.timepickersTemplate}</div>` : undefined}
1063
+ ${this.timepicker
1064
+ ? html `<div part="timepicker-wrapper">${this.timepickersTemplate}</div>`
1065
+ : undefined}
1043
1066
  </div>
1044
1067
  <div><slot name="right"></div>
1045
1068
  </div>
@@ -1053,11 +1076,7 @@ let DatetimePicker = class DatetimePicker extends ControlElement {
1053
1076
  * @return Render template
1054
1077
  */
1055
1078
  render() {
1056
- return html `
1057
- ${this.inputTemplates}
1058
- ${this.iconTemplate}
1059
- ${this.popupTemplate}
1060
- `;
1079
+ return html ` ${this.inputTemplates} ${this.iconTemplate} ${this.popupTemplate} `;
1061
1080
  }
1062
1081
  };
1063
1082
  __decorate([
@@ -1,8 +1,6 @@
1
- import { Phrasebook } from '@refinitiv-ui/phrasebook';
2
- import { resolveLocale, DEFAULT_LOCALE } from '@refinitiv-ui/i18n';
1
+ import de from 'date-fns/esm/locale/de/index.js';
3
2
  import enGB from 'date-fns/esm/locale/en-GB/index.js';
4
3
  import enUS from 'date-fns/esm/locale/en-US/index.js';
5
- import de from 'date-fns/esm/locale/de/index.js';
6
4
  import es from 'date-fns/esm/locale/es/index.js';
7
5
  import fr from 'date-fns/esm/locale/fr/index.js';
8
6
  import it from 'date-fns/esm/locale/it/index.js';
@@ -12,6 +10,8 @@ import pl from 'date-fns/esm/locale/pl/index.js';
12
10
  import ru from 'date-fns/esm/locale/ru/index.js';
13
11
  import th from 'date-fns/esm/locale/th/index.js';
14
12
  import zhCN from 'date-fns/esm/locale/zh-CN/index.js';
13
+ import { DEFAULT_LOCALE, resolveLocale } from '@refinitiv-ui/i18n';
14
+ import { Phrasebook } from '@refinitiv-ui/phrasebook';
15
15
  // This file is a transition between using date-fns and Intl object to format dates
16
16
  // As of now, use Phraseboook to just resolve languages and locales
17
17
  // and match against the date-fns locales.
@@ -32,7 +32,7 @@ Phrasebook.define('ru', scope, globals);
32
32
  Phrasebook.define('th', scope, globals);
33
33
  Phrasebook.define('zh', scope, globals);
34
34
  const locales = {
35
- 'en': enUS,
35
+ en: enUS,
36
36
  'en-GB': enGB,
37
37
  de,
38
38
  es,
@@ -43,7 +43,7 @@ const locales = {
43
43
  pl,
44
44
  ru,
45
45
  th,
46
- 'zh': zhCN
46
+ zh: zhCN
47
47
  };
48
48
  /**
49
49
  * Get date-fns locale or default locale
@@ -1,4 +1,4 @@
1
- import { format, DateFormat, parse, TimeFormat, toTimeSegment } from '@refinitiv-ui/utils/date.js';
1
+ import { DateFormat, TimeFormat, format, parse, toTimeSegment } from '@refinitiv-ui/utils/date.js';
2
2
  /**
3
3
  * A helper class to split date time string into date and time segments
4
4
  */
@@ -53,18 +53,18 @@ DateTimeSegment.fromDateTimeSegment = (segment) => {
53
53
  return new DateTimeSegment(segment.dateSegment, segment.timeSegment);
54
54
  };
55
55
  /**
56
- * Check if passed Date object is valid
57
- * @param date Date to check
58
- * @returns is valid
59
- */
56
+ * Check if passed Date object is valid
57
+ * @param date Date to check
58
+ * @returns is valid
59
+ */
60
60
  const isValid = (date) => {
61
61
  return !isNaN(date.getTime());
62
62
  };
63
63
  /**
64
- * Convert date to Date object
65
- * @param date Date to convert
66
- * @returns Date object
67
- */
64
+ * Convert date to Date object
65
+ * @param date Date to convert
66
+ * @returns Date object
67
+ */
68
68
  const toDate = (date) => {
69
69
  if (typeof date === 'string') {
70
70
  return parse(date);
@@ -128,8 +128,7 @@ class DraggableManager {
128
128
  setHandleListeners(draggableElement) {
129
129
  const element = this.draggableElements.get(draggableElement);
130
130
  if (element) {
131
- element.handle
132
- .addEventListener('mousedown', element.mouseDownListener);
131
+ element.handle.addEventListener('mousedown', element.mouseDownListener);
133
132
  }
134
133
  }
135
134
  /**
@@ -1,12 +1,12 @@
1
1
  import { JSXInterface } from '../jsx';
2
- import { CSSResultGroup, TemplateResult, PropertyValues } from '@refinitiv-ui/core';
2
+ import { CSSResultGroup, PropertyValues, TemplateResult } from '@refinitiv-ui/core';
3
+ import '@refinitiv-ui/phrasebook/locale/en/dialog.js';
3
4
  import { Translate } from '@refinitiv-ui/translate';
4
- import { Overlay } from '../overlay/index.js';
5
+ import '../button/index.js';
6
+ import '../header/index.js';
5
7
  import '../icon/index.js';
8
+ import { Overlay } from '../overlay/index.js';
6
9
  import '../panel/index.js';
7
- import '../header/index.js';
8
- import '../button/index.js';
9
- import '@refinitiv-ui/phrasebook/locale/en/dialog.js';
10
10
  /**
11
11
  * Popup window, designed to contain and show any HTML content.
12
12
  * It provides modal and dragging functionality,