@refinitiv-ui/elements 6.0.1 → 6.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 (149) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/lib/accordion/index.js +2 -2
  3. package/lib/autosuggest/helpers/renderer.d.ts +1 -1
  4. package/lib/autosuggest/helpers/utils.d.ts +1 -1
  5. package/lib/autosuggest/index.d.ts +2 -1
  6. package/lib/autosuggest/themes/halo/dark/index.js +1 -1
  7. package/lib/autosuggest/themes/halo/light/index.js +1 -1
  8. package/lib/button/index.js +2 -1
  9. package/lib/button/themes/halo/dark/index.js +1 -1
  10. package/lib/button/themes/halo/light/index.js +1 -1
  11. package/lib/button/themes/solar/charcoal/index.js +1 -1
  12. package/lib/button/themes/solar/pearl/index.js +1 -1
  13. package/lib/calendar/index.d.ts +1 -1
  14. package/lib/calendar/themes/halo/dark/index.js +1 -1
  15. package/lib/calendar/themes/halo/light/index.js +1 -1
  16. package/lib/calendar/themes/solar/charcoal/index.js +1 -1
  17. package/lib/calendar/themes/solar/pearl/index.js +1 -1
  18. package/lib/checkbox/index.d.ts +8 -15
  19. package/lib/checkbox/index.js +19 -41
  20. package/lib/checkbox/themes/halo/dark/index.js +1 -1
  21. package/lib/checkbox/themes/halo/light/index.js +1 -1
  22. package/lib/checkbox/themes/solar/charcoal/index.js +1 -1
  23. package/lib/checkbox/themes/solar/pearl/index.js +1 -1
  24. package/lib/clock/themes/halo/dark/index.js +1 -1
  25. package/lib/clock/themes/halo/light/index.js +1 -1
  26. package/lib/clock/themes/solar/charcoal/index.js +1 -1
  27. package/lib/clock/themes/solar/pearl/index.js +1 -1
  28. package/lib/combo-box/index.d.ts +4 -3
  29. package/lib/combo-box/index.js +7 -3
  30. package/lib/combo-box/themes/halo/dark/index.js +1 -1
  31. package/lib/combo-box/themes/halo/light/index.js +1 -1
  32. package/lib/combo-box/themes/solar/charcoal/index.js +1 -1
  33. package/lib/combo-box/themes/solar/pearl/index.js +1 -1
  34. package/lib/datetime-field/index.d.ts +1 -1
  35. package/lib/datetime-field/utils.d.ts +1 -1
  36. package/lib/datetime-picker/themes/halo/dark/index.js +1 -1
  37. package/lib/datetime-picker/themes/halo/light/index.js +1 -1
  38. package/lib/datetime-picker/themes/solar/charcoal/index.js +1 -1
  39. package/lib/datetime-picker/themes/solar/pearl/index.js +1 -1
  40. package/lib/email-field/themes/halo/dark/index.js +1 -1
  41. package/lib/email-field/themes/halo/light/index.js +1 -1
  42. package/lib/email-field/themes/solar/charcoal/index.js +1 -1
  43. package/lib/email-field/themes/solar/pearl/index.js +1 -1
  44. package/lib/heatmap/index.d.ts +2 -2
  45. package/lib/heatmap/themes/halo/light/index.js +1 -1
  46. package/lib/index.d.ts +1 -1
  47. package/lib/index.js +1 -1
  48. package/lib/item/helpers/types.d.ts +6 -6
  49. package/lib/item/index.d.ts +2 -2
  50. package/lib/item/index.js +0 -1
  51. package/lib/item/themes/halo/dark/index.js +1 -1
  52. package/lib/item/themes/halo/light/index.js +1 -1
  53. package/lib/list/elements/list-item.d.ts +30 -0
  54. package/lib/list/elements/list-item.js +19 -0
  55. package/lib/list/elements/list.d.ts +307 -0
  56. package/lib/list/elements/list.js +632 -0
  57. package/lib/list/helpers/renderer.d.ts +0 -1
  58. package/lib/list/helpers/renderer.js +1 -3
  59. package/lib/list/index.d.ts +3 -317
  60. package/lib/list/index.js +3 -641
  61. package/lib/list/themes/halo/dark/index.js +4 -1
  62. package/lib/list/themes/halo/light/index.js +5 -2
  63. package/lib/list/themes/solar/charcoal/index.js +4 -1
  64. package/lib/list/themes/solar/pearl/index.js +4 -1
  65. package/lib/multi-input/index.d.ts +1 -5
  66. package/lib/multi-input/index.js +17 -18
  67. package/lib/notification/themes/halo/dark/index.js +1 -1
  68. package/lib/notification/themes/halo/light/index.js +1 -1
  69. package/lib/notification/themes/solar/charcoal/index.js +1 -1
  70. package/lib/notification/themes/solar/pearl/index.js +1 -1
  71. package/lib/number-field/themes/halo/dark/index.js +1 -1
  72. package/lib/number-field/themes/halo/light/index.js +1 -1
  73. package/lib/number-field/themes/solar/charcoal/index.js +1 -1
  74. package/lib/number-field/themes/solar/pearl/index.js +1 -1
  75. package/lib/overlay/index.d.ts +2 -1
  76. package/lib/overlay-menu/helpers/constants.d.ts +6 -0
  77. package/lib/overlay-menu/helpers/constants.js +7 -0
  78. package/lib/overlay-menu/helpers/types.d.ts +0 -6
  79. package/lib/overlay-menu/helpers/types.js +1 -7
  80. package/lib/overlay-menu/index.d.ts +1 -1
  81. package/lib/overlay-menu/index.js +1 -1
  82. package/lib/password-field/themes/halo/dark/index.js +1 -1
  83. package/lib/password-field/themes/halo/light/index.js +1 -1
  84. package/lib/password-field/themes/solar/charcoal/index.js +1 -1
  85. package/lib/password-field/themes/solar/pearl/index.js +1 -1
  86. package/lib/pill/index.d.ts +11 -3
  87. package/lib/pill/index.js +25 -11
  88. package/lib/radio-button/index.d.ts +7 -11
  89. package/lib/radio-button/index.js +14 -25
  90. package/lib/radio-button/themes/halo/dark/index.js +1 -1
  91. package/lib/radio-button/themes/halo/light/index.js +1 -1
  92. package/lib/radio-button/themes/solar/charcoal/index.js +1 -1
  93. package/lib/radio-button/themes/solar/pearl/index.js +1 -1
  94. package/lib/search-field/themes/halo/dark/index.js +1 -1
  95. package/lib/search-field/themes/halo/light/index.js +1 -1
  96. package/lib/search-field/themes/solar/charcoal/index.js +1 -1
  97. package/lib/search-field/themes/solar/pearl/index.js +1 -1
  98. package/lib/select/index.d.ts +13 -1
  99. package/lib/select/index.js +25 -7
  100. package/lib/select/themes/halo/dark/index.js +1 -1
  101. package/lib/select/themes/halo/light/index.js +1 -1
  102. package/lib/select/themes/solar/charcoal/index.js +1 -1
  103. package/lib/select/themes/solar/pearl/index.js +1 -1
  104. package/lib/slider/themes/halo/dark/index.js +1 -1
  105. package/lib/slider/themes/halo/light/index.js +1 -1
  106. package/lib/slider/themes/solar/charcoal/index.js +1 -1
  107. package/lib/slider/themes/solar/pearl/index.js +1 -1
  108. package/lib/tab/themes/halo/dark/index.js +1 -1
  109. package/lib/tab/themes/halo/light/index.js +1 -1
  110. package/lib/tab/themes/solar/charcoal/index.js +1 -1
  111. package/lib/tab/themes/solar/pearl/index.js +1 -1
  112. package/lib/tab-bar/index.d.ts +6 -7
  113. package/lib/tab-bar/index.js +12 -10
  114. package/lib/tab-bar/themes/halo/dark/index.js +1 -0
  115. package/lib/tab-bar/themes/halo/light/index.js +1 -0
  116. package/lib/tab-bar/themes/solar/charcoal/index.js +1 -0
  117. package/lib/tab-bar/themes/solar/pearl/index.js +1 -0
  118. package/lib/text-field/index.js +2 -3
  119. package/lib/text-field/themes/halo/dark/index.js +1 -1
  120. package/lib/text-field/themes/halo/light/index.js +1 -1
  121. package/lib/text-field/themes/solar/charcoal/index.js +1 -1
  122. package/lib/text-field/themes/solar/pearl/index.js +1 -1
  123. package/lib/toggle/index.d.ts +7 -10
  124. package/lib/toggle/index.js +14 -24
  125. package/lib/toggle/themes/halo/dark/index.js +1 -1
  126. package/lib/toggle/themes/halo/light/index.js +1 -1
  127. package/lib/toggle/themes/solar/charcoal/index.js +1 -1
  128. package/lib/toggle/themes/solar/pearl/index.js +1 -1
  129. package/lib/tooltip/helpers/overflow-tooltip.d.ts +11 -4
  130. package/lib/tooltip/helpers/overflow-tooltip.js +34 -6
  131. package/lib/tooltip/index.d.ts +2 -2
  132. package/lib/tooltip/index.js +2 -2
  133. package/lib/tree/elements/tree-item.d.ts +4 -0
  134. package/lib/tree/elements/tree-item.js +4 -0
  135. package/lib/tree/elements/tree.d.ts +1 -0
  136. package/lib/tree/elements/tree.js +1 -0
  137. package/lib/tree/helpers/renderer.d.ts +0 -1
  138. package/lib/tree/helpers/renderer.js +0 -2
  139. package/lib/tree/index.d.ts +2 -1
  140. package/lib/tree/themes/halo/dark/index.js +2 -2
  141. package/lib/tree/themes/halo/light/index.js +3 -3
  142. package/lib/tree/themes/solar/charcoal/index.js +2 -2
  143. package/lib/tree/themes/solar/pearl/index.js +2 -2
  144. package/lib/tree-select/themes/halo/dark/index.js +1 -1
  145. package/lib/tree-select/themes/halo/light/index.js +1 -1
  146. package/lib/tree-select/themes/solar/charcoal/index.js +1 -1
  147. package/lib/tree-select/themes/solar/pearl/index.js +1 -1
  148. package/lib/version.js +1 -1
  149. package/package.json +17 -17
package/lib/list/index.js CHANGED
@@ -1,641 +1,3 @@
1
- import { __decorate } from "tslib";
2
- import { ControlElement, css, html, WarningNotice } from '@refinitiv-ui/core';
3
- import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
4
- import { property } from '@refinitiv-ui/core/decorators/property.js';
5
- import { VERSION } from '../version.js';
6
- import { CollectionComposer } from '@refinitiv-ui/utils/collection.js';
7
- import { getItemId } from './helpers/item-id.js';
8
- import { ListRenderer } from './helpers/renderer.js';
9
- import '../item/index.js';
10
- export { ListRenderer };
11
- /**
12
- * Key direction
13
- */
14
- var Direction;
15
- (function (Direction) {
16
- Direction[Direction["UP"] = -1] = "UP";
17
- Direction[Direction["DOWN"] = 1] = "DOWN";
18
- })(Direction || (Direction = {}));
19
- const valueFormatWarning = new WarningNotice('The specified \'values\' format does not conform to the required format.');
20
- /**
21
- * Provides listing and immutable selection
22
- * @fires value-changed - Dispatched when value changes
23
- */
24
- let List = class List extends ControlElement {
25
- constructor() {
26
- super(...arguments);
27
- this.defaultRole = 'listbox';
28
- /**
29
- * Used to timestamp renders.
30
- * This enables diff checking against item updates,
31
- * rendering only items which have updated since the last render cycle.
32
- */
33
- this.renderTimestamp = new Map();
34
- /**
35
- * Requests an update after a composer modification.
36
- * @returns Update promise.
37
- */
38
- this.modificationUpdate = () => {
39
- this.requestUpdate();
40
- };
41
- /**
42
- * Item map; used to link element nodes to data items.
43
- */
44
- this.itemMap = new Map();
45
- /**
46
- * Element map; used to link data items to element nodes.
47
- */
48
- this.elementMap = new Map();
49
- /**
50
- * Composer used to query and modify item state.
51
- */
52
- this.composer = new CollectionComposer([]);
53
- /**
54
- * Element focus delegation.
55
- * Set to `false` and relies on native focusing.
56
- */
57
- this.delegatesFocus = false;
58
- /**
59
- * Renderer used to render list item elements
60
- * @type {ListRenderer}
61
- */
62
- this.renderer = new ListRenderer(this);
63
- /**
64
- * Disable selections
65
- */
66
- this.stateless = false;
67
- /**
68
- * Allow multiple selections
69
- */
70
- this.multiple = false;
71
- this._data = null;
72
- }
73
- /**
74
- * Element version number
75
- * @returns version number
76
- */
77
- static get version() {
78
- return VERSION;
79
- }
80
- /**
81
- * The data object, used to render the list.
82
- * @type {ListData}
83
- * @default null
84
- */
85
- get data() {
86
- return this._data;
87
- }
88
- set data(value) {
89
- const oldValue = this._data;
90
- if (oldValue === value) {
91
- return;
92
- }
93
- if (value instanceof CollectionComposer) {
94
- this.composer = value;
95
- }
96
- else if (Array.isArray(value)) {
97
- this.composer = new CollectionComposer(value);
98
- }
99
- else {
100
- this.composer = new CollectionComposer([]);
101
- }
102
- this.composer.on('modification', // Listen for modifications
103
- this.modificationUpdate // Update the template
104
- );
105
- this.clearMaps();
106
- this._data = value;
107
- this.requestUpdate('data', oldValue);
108
- }
109
- /**
110
- * Returns the first selected item value.
111
- * Use `values` when multiple selection mode is enabled.
112
- * @default -
113
- */
114
- get value() {
115
- return this.values[0] || '';
116
- }
117
- set value(value) {
118
- const oldValue = this.value;
119
- if (value !== oldValue || this.values.length > 1) {
120
- this.clearSelection();
121
- const item = this.queryItemsByPropertyValue('value', value)[0];
122
- if (item) {
123
- this.composer.setItemPropertyValue(item, 'selected', true);
124
- }
125
- this.requestUpdate('value', oldValue);
126
- }
127
- }
128
- /**
129
- * Returns a values collection of the currently
130
- * selected item values
131
- * @type {string[]}
132
- * @default []
133
- * @readonly
134
- */
135
- get values() {
136
- return this.queryItemsByPropertyValue('selected', true)
137
- .map((item) => this.composer.getItemPropertyValue(item, 'value'));
138
- }
139
- set values(values) {
140
- if (!Array.isArray(values)) {
141
- valueFormatWarning.show();
142
- this.values = [];
143
- }
144
- else {
145
- // Clone value arrays
146
- const newValue = values.slice();
147
- const oldValue = this.values.slice();
148
- // Create comparison strings to check for differences
149
- const newComparison = newValue.sort().toString();
150
- const oldComparison = oldValue.sort().toString();
151
- // Should we update the selection state?
152
- if (newComparison !== oldComparison) {
153
- this.clearSelection();
154
- values.some((value) => {
155
- const matches = this.queryItemsByPropertyValue('value', value);
156
- matches.forEach((match) => this.composer.setItemPropertyValue(match, 'selected', true));
157
- return !this.multiple; // Only set the fist value if multiple is not enabled
158
- });
159
- this.requestUpdate('values', oldValue);
160
- }
161
- }
162
- }
163
- /**
164
- * Selects an item in the list
165
- * @param item Data Item or Item Element
166
- * @returns If a selection has been made or not
167
- */
168
- selectItem(item) {
169
- if (!this.stateless) {
170
- if (item instanceof HTMLElement) {
171
- item = this.itemFromElement(item);
172
- }
173
- if (item && this.multiple) {
174
- const value = this.composer.getItemPropertyValue(item, 'selected');
175
- this.composer.setItemPropertyValue(item, 'selected', !value);
176
- return true;
177
- }
178
- if (item && this.composer.getItemPropertyValue(item, 'selected') !== true) {
179
- this.clearSelection();
180
- this.composer.setItemPropertyValue(item, 'selected', true);
181
- return true;
182
- }
183
- }
184
- return false;
185
- }
186
- /**
187
- * Navigate up through the list items
188
- * @returns {void}
189
- */
190
- up() {
191
- this.highlightItem(this.getNextHighlightItem(Direction.UP), true);
192
- }
193
- /**
194
- * Navigate down through the list items
195
- * @returns {void}
196
- */
197
- down() {
198
- this.highlightItem(this.getNextHighlightItem(Direction.DOWN), true);
199
- }
200
- /**
201
- * Navigate to first focusable item of the list
202
- * @returns {void}
203
- */
204
- first() {
205
- const firstItem = this.itemMap.get(this.tabbableItems[0]);
206
- this.highlightItem(firstItem, true);
207
- }
208
- /**
209
- * Navigate to first focusable item of the list
210
- * @returns {void}
211
- */
212
- last() {
213
- const lastItem = this.itemMap.get(this.tabbableItems[this.tabbableItems.length - 1]);
214
- this.highlightItem(lastItem, true);
215
- }
216
- /**
217
- * Proxy for querying the composer
218
- * @param engine composer querying engine
219
- * @returns Collection of queried items
220
- */
221
- queryItems(engine) {
222
- return this.composer.queryItems(engine);
223
- }
224
- /**
225
- * Proxy for querying the composer by property and value
226
- * @param property Property name
227
- * @param value Property value
228
- * @returns Collection of queried items
229
- */
230
- queryItemsByPropertyValue(property, value) {
231
- return this.composer.queryItemsByPropertyValue(property, value);
232
- }
233
- /**
234
- * Gets the associated element for the data item provided,
235
- * if there is one available.
236
- * @param item Item to map element to
237
- * @returns Associated element
238
- */
239
- elementFromItem(item) {
240
- return this.elementMap.get(item);
241
- }
242
- /**
243
- * Gets the associated data item for the provided element,
244
- * if there is one available.
245
- * @param element Element to map item to
246
- * @returns Associated date item
247
- */
248
- itemFromElement(element) {
249
- return this.itemMap.get(element);
250
- }
251
- /**
252
- * Tries to find the next focusable element.
253
- * @param direction Direction to search
254
- * @param element Starting element
255
- * @returns Next logical element to focus
256
- */
257
- getNextFocusableItem(direction, element = this.activeElement) {
258
- if (!element) {
259
- return;
260
- }
261
- const children = this.tabbableItems;
262
- if (children.length > 1) {
263
- let index = children.indexOf(element) + direction;
264
- index = index < 0 ? children.length - 1 : index === children.length ? 0 : index;
265
- return children[index];
266
- }
267
- }
268
- /**
269
- * Tries to find the next highlight item
270
- * @param direction Direction to search
271
- * @returns A data item, if found.
272
- */
273
- getNextHighlightItem(direction) {
274
- const highlightItem = this.queryItemsByPropertyValue('highlighted', true)[0];
275
- const nextElement = this.getNextFocusableItem(direction) || this.getNextFocusableItem(direction, this.elementFromItem(highlightItem));
276
- const backupElement = this.tabbableItems[0];
277
- return nextElement ? this.itemFromElement(nextElement) : backupElement ? this.itemFromElement(backupElement) : undefined;
278
- }
279
- /**
280
- * Clears any highlighted item
281
- * @returns {void}
282
- */
283
- clearHighlighted() {
284
- this.queryItemsByPropertyValue('highlighted', true)
285
- .forEach(item => this.composer.setItemPropertyValue(item, 'highlighted', false));
286
- }
287
- /**
288
- * Highlights a single item.
289
- * Used for navigation.
290
- * @param item Item to highlight
291
- * @param scrollToItem Scroll the item into view?
292
- * @returns {void}
293
- */
294
- highlightItem(item, scrollToItem = false) {
295
- if (item) {
296
- this.clearHighlighted();
297
- this.composer.setItemPropertyValue(item, 'highlighted', true);
298
- const id = getItemId(this.renderer.key, item.value);
299
- this.tabIndex >= 0 && id && this.setAttribute('aria-activedescendant', id);
300
- scrollToItem && this.scrollToItem(item);
301
- }
302
- }
303
- /**
304
- * Gets the available tabbable elements
305
- */
306
- get tabbableItems() {
307
- return Array.from(this.children).filter((el) => {
308
- if (el instanceof HTMLElement) {
309
- const role = el.getAttribute('role');
310
- const isEnabled = !el.hasAttribute('disabled');
311
- const isOption = role ? ['option', 'treeitem'].includes(role) : false;
312
- return isOption && isEnabled;
313
- }
314
- return false;
315
- });
316
- }
317
- /**
318
- * Returns the current focused element
319
- */
320
- get activeElement() {
321
- const el = this.getRootNode().activeElement;
322
- const itemEl = this.findItemElementFromTarget(el);
323
- if (itemEl && this.tabbableItems.includes(itemEl)) {
324
- return itemEl;
325
- }
326
- return null;
327
- }
328
- /**
329
- * Returns the current focused element
330
- */
331
- get highlightElement() {
332
- const item = this.queryItemsByPropertyValue('highlighted', true)[0];
333
- return item ? this.elementFromItem(item) || null : null;
334
- }
335
- /**
336
- * Tries to select the current highlighted element
337
- * @returns {void}
338
- */
339
- triggerActiveItem() {
340
- const el = this.activeElement || this.highlightElement;
341
- const item = el && this.itemFromElement(el);
342
- item && this.selectItem(item) && this.fireSelectionUpdate();
343
- }
344
- /**
345
- * Scroll to list item element
346
- * @param item Data item to scroll to
347
- * @returns {void}
348
- */
349
- scrollToItem(item) {
350
- const element = this.elementFromItem(item);
351
- if (element) {
352
- const min = this.scrollTop;
353
- const max = this.scrollTop + this.clientHeight - element.offsetHeight;
354
- const pos = element.offsetTop;
355
- pos > max ? this.scrollTop = element.offsetTop - this.clientHeight + element.offsetHeight
356
- : pos < min ? this.scrollTop = element.offsetTop : 0;
357
- }
358
- }
359
- /**
360
- * Handles key input
361
- * @param event Key down event object
362
- * @returns {void}
363
- */
364
- onKeyDown(event) {
365
- switch (event.key) {
366
- case ' ':
367
- case 'Spacebar':
368
- case 'Enter':
369
- this.triggerActiveItem();
370
- break;
371
- case 'Up':
372
- case 'ArrowUp':
373
- this.up();
374
- break;
375
- case 'Down':
376
- case 'ArrowDown':
377
- this.down();
378
- break;
379
- case 'Home':
380
- this.first();
381
- break;
382
- case 'End':
383
- this.last();
384
- break;
385
- default:
386
- return;
387
- }
388
- event.preventDefault();
389
- }
390
- /**
391
- * Handle list on tap
392
- * Typically it will select an item
393
- * @param event Event to handle
394
- * @returns {void}
395
- */
396
- onTap(event) {
397
- const el = this.findItemElementFromTarget(event.target);
398
- const item = el && this.itemFromElement(el);
399
- if (item) {
400
- this.clearHighlighted();
401
- if (this.selectItem(item)) {
402
- this.highlightItem(item);
403
- this.fireSelectionUpdate();
404
- }
405
- }
406
- }
407
- /**
408
- * Handles mouse move
409
- * Typically it will highlight an item
410
- * @param event Event to handle
411
- * @returns {void}
412
- */
413
- onMouse(event) {
414
- const el = this.findItemElementFromTarget(event.target);
415
- const item = el ? this.itemFromElement(el) : null;
416
- if (item && el !== this.highlightElement) {
417
- if (this.activeElement) {
418
- // prevent shifting focus to other items
419
- // on mouse move and just fallback to host
420
- this.activeElement.focus({ preventScroll: true });
421
- }
422
- this.highlightItem(item);
423
- }
424
- }
425
- /**
426
- * Handles item focus in
427
- * Typically it will highlight the item
428
- * @param event Event to handle
429
- * @returns {void}
430
- */
431
- onFocus(event) {
432
- const el = this.findItemElementFromTarget(event.target);
433
- const item = el && this.itemFromElement(el);
434
- if (item) {
435
- this.highlightItem(item);
436
- }
437
- }
438
- /**
439
- * Handles item focus out
440
- * Typically it will remove highlighting
441
- * @returns {void}
442
- */
443
- onBlur() {
444
- this.clearHighlighted();
445
- this.removeAttribute('aria-activedescendant');
446
- }
447
- /**
448
- * Tries to find a known item element,
449
- * from an event target
450
- * @param target Event target
451
- * @returns Found element, if available
452
- */
453
- findItemElementFromTarget(target) {
454
- let el = target;
455
- while (el) {
456
- if (this.itemMap.has(el)) {
457
- break; // known rendered item
458
- }
459
- el = el.parentElement;
460
- }
461
- return el;
462
- }
463
- /**
464
- * Clears the current selected items
465
- * @returns {void}
466
- */
467
- clearSelection() {
468
- this.queryItemsByPropertyValue('selected', true)
469
- .forEach((item) => this.composer.setItemPropertyValue(item, 'selected', false));
470
- this.requestUpdate();
471
- }
472
- /**
473
- * Queries and returns all renderable items.
474
- * @returns Collection of renderable items
475
- */
476
- get renderItems() {
477
- return this.queryItems((item, composer) => {
478
- return composer.getItemPropertyValue(item, 'hidden') !== true;
479
- });
480
- }
481
- /**
482
- * Proxy for creating list item elements.
483
- * Allows for a mapping to be created between
484
- * Data Item and Item Element.
485
- * @param item Data item context
486
- * @param recyclableElements Child elements available for reuse
487
- * @returns List item element
488
- */
489
- createListItem(item, recyclableElements) {
490
- const cachedElement = this.elementFromItem(item);
491
- const previousTimestamp = this.renderTimestamp.get(item) || NaN;
492
- if (cachedElement && previousTimestamp > this.composer.getItemTimestamp(item)) {
493
- return cachedElement; // don't re-render if the item hasn't changed
494
- }
495
- if (!cachedElement && recyclableElements.length) {
496
- // Remove any old ties with the reusable element.
497
- const recycledElement = recyclableElements.pop();
498
- const previousItem = this.itemFromElement(recycledElement);
499
- this.itemMap.delete(recycledElement);
500
- previousItem && this.elementMap.delete(previousItem);
501
- this.elementMap.set(item, recycledElement);
502
- }
503
- const freshElement = this.renderer(item, this.composer, this.elementFromItem(item));
504
- if (cachedElement && cachedElement !== freshElement) {
505
- // Renderer returned a new element, so remove the old link.
506
- this.itemMap.delete(cachedElement);
507
- }
508
- this.itemMap.set(freshElement, item); // Link element to item
509
- this.elementMap.set(item, freshElement); // Link item to element
510
- this.renderTimestamp.set(item, performance.now());
511
- return freshElement;
512
- }
513
- /**
514
- * Clears all item-element and timestamp maps
515
- * @returns {void}
516
- */
517
- clearMaps() {
518
- this.itemMap.clear();
519
- this.elementMap.clear();
520
- this.renderTimestamp.clear();
521
- }
522
- /**
523
- * Fire value changed event
524
- * @returns {void}
525
- */
526
- fireSelectionUpdate() {
527
- /**
528
- * @event List#value-changed
529
- */
530
- this.notifyPropertyChange('value', this.value);
531
- }
532
- /**
533
- * Calculates what elements can be recycled safely
534
- * @param renderItems Current items to render
535
- * @returns Collection of elements to be recycled
536
- */
537
- calculateRecyclableElements(renderItems) {
538
- const result = [];
539
- for (const element of this.children) {
540
- const item = this.itemFromElement(element);
541
- if (item && !renderItems.includes(item)) {
542
- result.push(element);
543
- }
544
- }
545
- return result;
546
- }
547
- /**
548
- * Renders updates to light DOM
549
- * @returns {void}
550
- */
551
- renderLightDOM() {
552
- const renderItems = this.renderItems;
553
- const currentChildren = Array.from(this.children);
554
- const recyclableElements = this.calculateRecyclableElements(renderItems);
555
- const renderChildren = renderItems.map((item) => this.createListItem(item, recyclableElements));
556
- const deletions = currentChildren.filter(element => !renderChildren.includes(element));
557
- deletions.forEach(element => this.removeChild(element));
558
- renderChildren.forEach((element, index) => {
559
- if (this.children.length === index) {
560
- this.appendChild(element);
561
- }
562
- else if (element !== this.children[index]) {
563
- this.insertBefore(element, this.children[index]);
564
- }
565
- });
566
- }
567
- /**
568
- * Invoked when the element is first updated. Implement to perform one time work on the element after update.
569
- * @param changeProperties changed properties
570
- * @returns {void}
571
- */
572
- firstUpdated(changeProperties) {
573
- super.firstUpdated(changeProperties);
574
- this.addEventListener('keydown', this.onKeyDown);
575
- this.addEventListener('tap', this.onTap);
576
- this.addEventListener('mousemove', this.onMouse);
577
- this.addEventListener('mouseleave', this.clearHighlighted);
578
- this.addEventListener('focusin', this.onFocus);
579
- this.addEventListener('focusout', this.onBlur);
580
- }
581
- /**
582
- * Invoked before update() to compute values needed during the update.
583
- * @param changeProperties changed properties
584
- * @returns {void}
585
- */
586
- willUpdate(changeProperties) {
587
- if (changeProperties.has('multiple')) {
588
- this.renderTimestamp.clear(); // force render of all items
589
- this.setAttribute('aria-multiselectable', this.multiple ? 'true' : 'false');
590
- }
591
- }
592
- /**
593
- * A `CSSResultGroup` that will be used
594
- * to style the host, slotted children
595
- * and the internal template of the element.
596
- * @return CSS template
597
- */
598
- static get styles() {
599
- return css `
600
- :host {
601
- display: block;
602
- max-height: 600px;
603
- overflow-y: auto;
604
- position: relative; /* required for scrollToItem */
605
- }
606
- `;
607
- }
608
- /**
609
- * A `TemplateResult` that will be used
610
- * to render the updated internal template.
611
- * @return Render template
612
- */
613
- render() {
614
- this.renderLightDOM();
615
- return html `<slot></slot>`;
616
- }
617
- };
618
- __decorate([
619
- property({ type: Function, attribute: false })
620
- ], List.prototype, "renderer", void 0);
621
- __decorate([
622
- property({ type: Boolean })
623
- ], List.prototype, "stateless", void 0);
624
- __decorate([
625
- property({ type: Boolean })
626
- ], List.prototype, "multiple", void 0);
627
- __decorate([
628
- property({ attribute: false })
629
- ], List.prototype, "data", null);
630
- __decorate([
631
- property({ type: String })
632
- ], List.prototype, "value", null);
633
- __decorate([
634
- property({ type: Array, attribute: false })
635
- ], List.prototype, "values", null);
636
- List = __decorate([
637
- customElement('ef-list', {
638
- alias: 'coral-list'
639
- })
640
- ], List);
641
- export { List };
1
+ export * from './elements/list.js';
2
+ export * from './elements/list-item.js';
3
+ export { ListRenderer } from './helpers/renderer.js';
@@ -1,3 +1,6 @@
1
- import '@refinitiv-ui/elements/item/themes/halo/dark';
1
+ import '@refinitiv-ui/elements/icon/themes/halo/dark';
2
+ import '@refinitiv-ui/elements/checkbox/themes/halo/dark';
3
+
4
+ elf.customStyles.define('ef-list-item', ':host{outline:0;cursor:pointer;padding:0 8px;min-height:24px;box-sizing:border-box;touch-action:manipulation}@media all and (-ms-high-contrast:none),(-ms-high-contrast:active){:host(:after){content:\'\';min-height:inherit;font-size:0}}:host([selected]){color:#fff}:host([readonly]){cursor:default}:host([focused]),:host([highlighted]){background-color:#1429bd}:host([focused]:not([selected])),:host([highlighted]:not([selected])){color:#fff}:host [part=center],:host [part=sub-label]{text-overflow:ellipsis;overflow:hidden;white-space:nowrap}:host([disabled]){color:rgba(204,204,204,.5)}:host([type=divider]),:host([type=header]){pointer-events:none;min-height:auto}:host([type=divider]) [part=sub-label],:host([type=header]) [part=sub-label]{display:none}:host([type=header]){color:#999;background-color:transparent;font-size:83%;font-weight:600;border:none;height:24px;align-items:flex-end;margin:0;min-height:0;text-transform:uppercase}:host([type=divider]){border:none;padding:0;margin:0;height:5px;background:linear-gradient(#404040,#404040) 0 center/calc(100% - (0px * 2)) 1px no-repeat}:host [part=checkbox],:host [part=icon],:host [part=left] ::slotted(*){margin:0 .5em 0 0}:host [part=right] ::slotted(*){margin-left:.5em}:host [part=sub-label]{font-size:80%}');
2
5
 
3
6
  elf.customStyles.define('ef-list', ':host{--item-indent:8px;--item-height:24px;color:#ccc;background-color:transparent;touch-action:manipulation;scrollbar-face-color:#595959;scrollbar-shadow-color:#595959;scrollbar-highlight-color:#595959;scrollbar-arrow-color:#595959;scrollbar-track-color:#1a1a1a;scrollbar-3dlight-color:#1a1a1a;scrollbar-darkshadow-color:#1a1a1a;scrollbar-color:#595959 #1a1a1a;scrollbar-width:thin}:host(:focus){outline:0}:host([focused=visible]){outline:#334bff solid 1px}:host([readonly]) [part=list-item]{cursor:default}::-webkit-scrollbar-corner{background:0 0}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-thumb{background:#595959;border-radius:0;border:1px solid transparent}::-webkit-scrollbar-thumb:hover{background:#1429bd}::-webkit-scrollbar-thumb:active{background:#0f1e8a}::-webkit-scrollbar-track{background:#1a1a1a}::-webkit-scrollbar-thumb:horizontal{background-size:auto 6px;background-repeat:repeat-x;background-image:linear-gradient(to bottom,#595959,#595959);background-color:transparent;background-position:center}::-webkit-scrollbar-thumb:horizontal:hover{background-image:linear-gradient(to bottom,#1429bd,#1429bd);background-color:transparent;background-position:center}::-webkit-scrollbar-thumb:horizontal:active{background-image:linear-gradient(to bottom,#0f1e8a,#0f1e8a);background-color:transparent;background-position:center}::-webkit-scrollbar-thumb:vertical{background-size:6px auto;background-repeat:repeat-y;background-image:linear-gradient(to right,#595959,#595959);background-color:transparent;background-position:center}::-webkit-scrollbar-thumb:vertical:hover{background-image:linear-gradient(to right,#1429bd,#1429bd);background-color:transparent;background-position:center}::-webkit-scrollbar-thumb:vertical:active{background-image:linear-gradient(to right,#0f1e8a,#0f1e8a);background-color:transparent;background-position:center}::-webkit-scrollbar-track:horizontal{border-top:1px solid #0d0d0d;border-bottom:1px solid #0d0d0d}::-webkit-scrollbar-track:vertical{border-left:1px solid #0d0d0d;border-right:1px solid #0d0d0d}::-webkit-scrollbar-button{background:0 0/1px 2px no-repeat #1a1a1a;height:16px;width:16px;display:none;border:1px solid #0d0d0d}::-webkit-scrollbar-button:end:decrement,::-webkit-scrollbar-button:start:increment{display:none}::-webkit-scrollbar-button:hover{background-color:#1429bd;border:1px solid #1429bd}::-webkit-scrollbar-button:active{background-color:#0f1e8a;border:1px solid #0d0d0d}::-webkit-scrollbar-button:horizontal{background-size:2px 1px}::-webkit-scrollbar-button:vertical:start:decrement{border-bottom-color:#0d0d0d;background-image:linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc);background-position:10.55px 8px,9.55px 7px,8.55px 6px,7.55px 5px,6.55px 4px,5.55px 5px,4.55px 6px,3.55px 7px,2.55px 8px}::-webkit-scrollbar-button:vertical:start:decrement:hover{background-image:linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff);background-position:10.55px 8px,9.55px 7px,8.55px 6px,7.55px 5px,6.55px 4px,5.55px 5px,4.55px 6px,3.55px 7px,2.55px 8px;border-bottom-color:#1429bd}::-webkit-scrollbar-button:vertical:start:decrement:active{background-image:linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff);background-position:10.55px 8px,9.55px 7px,8.55px 6px,7.55px 5px,6.55px 4px,5.55px 5px,4.55px 6px,3.55px 7px,2.55px 8px;border-bottom-color:#0d0d0d}::-webkit-scrollbar-button:vertical:end:increment{border-top-color:#0d0d0d;background-image:linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc);background-position:10.55px 4px,9.55px 5px,8.55px 6px,7.55px 7px,6.55px 8px,5.55px 7px,4.55px 6px,3.55px 5px,2.55px 4px}::-webkit-scrollbar-button:vertical:end:increment:hover{background-image:linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff);background-position:10.55px 4px,9.55px 5px,8.55px 6px,7.55px 7px,6.55px 8px,5.55px 7px,4.55px 6px,3.55px 5px,2.55px 4px;border-top-color:#1429bd}::-webkit-scrollbar-button:vertical:end:increment:active{background-image:linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff);background-position:10.55px 4px,9.55px 5px,8.55px 6px,7.55px 7px,6.55px 8px,5.55px 7px,4.55px 6px,3.55px 5px,2.55px 4px;border-top-color:#0d0d0d}::-webkit-scrollbar-button:horizontal:start:decrement{border-right-color:#0d0d0d;background-image:linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc);background-position:7.5px 10.55px,6.5px 9.55px,5.5px 8.55px,4.5px 7.55px,3.5px 6.55px,4.5px 5.55px,5.5px 4.55px,6.5px 3.55px,7.5px 2.55px}::-webkit-scrollbar-button:horizontal:start:decrement:hover{background-image:linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff);background-position:7.5px 10.55px,6.5px 9.55px,5.5px 8.55px,4.5px 7.55px,3.5px 6.55px,4.5px 5.55px,5.5px 4.55px,6.5px 3.55px,7.5px 2.55px;border-right-color:#1429bd}::-webkit-scrollbar-button:horizontal:start:decrement:active{background-image:linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff);background-position:7.5px 10.55px,6.5px 9.55px,5.5px 8.55px,4.5px 7.55px,3.5px 6.55px,4.5px 5.55px,5.5px 4.55px,6.5px 3.55px,7.5px 2.55px;border-right-color:#0d0d0d}::-webkit-scrollbar-button:horizontal:end:increment{border-left-color:#0d0d0d;background-image:linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc),linear-gradient(#ccc,#ccc);background-position:5px 10.55px,6px 9.55px,7px 8.55px,8px 7.55px,9px 6.55px,8px 5.55px,7px 4.55px,6px 3.55px,5px 2.55px}::-webkit-scrollbar-button:horizontal:end:increment:hover{background-image:linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff);background-position:5px 10.55px,6px 9.55px,7px 8.55px,8px 7.55px,9px 6.55px,8px 5.55px,7px 4.55px,6px 3.55px,5px 2.55px;border-left-color:#1429bd}::-webkit-scrollbar-button:horizontal:end:increment:active{background-image:linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff),linear-gradient(#fff,#fff);background-position:5px 10.55px,6px 9.55px,7px 8.55px,8px 7.55px,9px 6.55px,8px 5.55px,7px 4.55px,6px 3.55px,5px 2.55px;border-left-color:#0d0d0d}');