@refinitiv-ui/elements 6.0.0-next.2 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +3 -15
  3. package/lib/autosuggest/custom-elements.json +5 -15
  4. package/lib/autosuggest/custom-elements.md +14 -14
  5. package/lib/autosuggest/helpers/renderer.d.ts +8 -0
  6. package/lib/autosuggest/helpers/renderer.js +35 -0
  7. package/lib/autosuggest/helpers/types.d.ts +101 -1
  8. package/lib/autosuggest/helpers/utils.d.ts +1 -8
  9. package/lib/autosuggest/helpers/utils.js +0 -27
  10. package/lib/autosuggest/index.d.ts +33 -32
  11. package/lib/autosuggest/index.js +246 -202
  12. package/lib/autosuggest/themes/halo/dark/index.js +1 -1
  13. package/lib/autosuggest/themes/halo/light/index.js +1 -1
  14. package/lib/autosuggest/themes/solar/charcoal/index.js +1 -1
  15. package/lib/autosuggest/themes/solar/pearl/index.js +1 -1
  16. package/lib/button/themes/halo/dark/index.js +1 -1
  17. package/lib/button/themes/halo/light/index.js +1 -1
  18. package/lib/calendar/themes/halo/dark/index.js +1 -1
  19. package/lib/calendar/themes/halo/light/index.js +1 -1
  20. package/lib/calendar/themes/solar/charcoal/index.js +1 -1
  21. package/lib/calendar/themes/solar/pearl/index.js +1 -1
  22. package/lib/card/themes/halo/dark/index.js +1 -1
  23. package/lib/card/themes/halo/light/index.js +1 -1
  24. package/lib/chart/plugins/doughnut-center-label.js +1 -1
  25. package/lib/chart/themes/halo/dark/index.js +1 -1
  26. package/lib/chart/themes/halo/light/index.js +1 -1
  27. package/lib/clock/custom-elements.json +10 -10
  28. package/lib/clock/custom-elements.md +1 -1
  29. package/lib/clock/index.d.ts +44 -16
  30. package/lib/clock/index.js +178 -61
  31. package/lib/clock/themes/halo/dark/index.js +1 -1
  32. package/lib/clock/themes/halo/light/index.js +1 -1
  33. package/lib/clock/themes/solar/charcoal/index.js +1 -1
  34. package/lib/clock/themes/solar/pearl/index.js +1 -1
  35. package/lib/collapse/themes/halo/dark/index.js +1 -1
  36. package/lib/collapse/themes/halo/light/index.js +1 -1
  37. package/lib/combo-box/custom-elements.json +0 -22
  38. package/lib/combo-box/custom-elements.md +0 -7
  39. package/lib/combo-box/themes/halo/dark/index.js +1 -1
  40. package/lib/combo-box/themes/halo/light/index.js +1 -1
  41. package/lib/counter/themes/halo/dark/index.js +1 -1
  42. package/lib/counter/themes/halo/light/index.js +1 -1
  43. package/lib/datetime-field/custom-elements.json +0 -75
  44. package/lib/datetime-field/custom-elements.md +27 -36
  45. package/lib/datetime-picker/themes/halo/dark/index.js +1 -1
  46. package/lib/datetime-picker/themes/halo/light/index.js +1 -1
  47. package/lib/dialog/themes/halo/dark/index.js +1 -1
  48. package/lib/dialog/themes/halo/light/index.js +1 -1
  49. package/lib/flag/utils/FlagLoader.d.ts +2 -32
  50. package/lib/flag/utils/FlagLoader.js +2 -69
  51. package/lib/heatmap/themes/halo/dark/index.js +1 -1
  52. package/lib/heatmap/themes/halo/light/index.js +1 -1
  53. package/lib/icon/utils/IconLoader.d.ts +2 -37
  54. package/lib/icon/utils/IconLoader.js +2 -76
  55. package/lib/interactive-chart/themes/halo/dark/index.js +1 -1
  56. package/lib/interactive-chart/themes/halo/light/index.js +1 -1
  57. package/lib/item/themes/halo/dark/index.js +1 -1
  58. package/lib/item/themes/halo/light/index.js +1 -1
  59. package/lib/list/themes/halo/dark/index.js +1 -1
  60. package/lib/list/themes/halo/light/index.js +1 -1
  61. package/lib/multi-input/themes/halo/dark/index.js +1 -1
  62. package/lib/multi-input/themes/halo/light/index.js +1 -1
  63. package/lib/number-field/custom-elements.json +0 -48
  64. package/lib/number-field/custom-elements.md +20 -26
  65. package/lib/number-field/themes/halo/dark/index.js +1 -1
  66. package/lib/number-field/themes/halo/light/index.js +1 -1
  67. package/lib/overlay/themes/halo/dark/index.js +1 -1
  68. package/lib/overlay/themes/halo/light/index.js +1 -1
  69. package/lib/overlay-menu/themes/halo/dark/index.js +1 -1
  70. package/lib/overlay-menu/themes/halo/light/index.js +1 -1
  71. package/lib/password-field/custom-elements.json +0 -7
  72. package/lib/password-field/custom-elements.md +0 -6
  73. package/lib/pill/themes/halo/dark/index.js +1 -1
  74. package/lib/pill/themes/halo/light/index.js +1 -1
  75. package/lib/rating/custom-elements.json +4 -4
  76. package/lib/rating/custom-elements.md +2 -2
  77. package/lib/rating/index.d.ts +84 -32
  78. package/lib/rating/index.js +209 -80
  79. package/lib/rating/themes/halo/dark/index.js +1 -1
  80. package/lib/rating/themes/halo/light/index.js +1 -1
  81. package/lib/rating/themes/solar/charcoal/index.js +1 -1
  82. package/lib/rating/themes/solar/pearl/index.js +1 -1
  83. package/lib/rating/utils.d.ts +9 -0
  84. package/lib/rating/utils.js +11 -0
  85. package/lib/search-field/custom-elements.json +0 -7
  86. package/lib/search-field/custom-elements.md +0 -6
  87. package/lib/select/themes/halo/dark/index.js +1 -1
  88. package/lib/select/themes/halo/light/index.js +1 -1
  89. package/lib/sidebar-layout/themes/halo/dark/index.js +1 -1
  90. package/lib/sidebar-layout/themes/halo/light/index.js +1 -1
  91. package/lib/slider/constants.d.ts +5 -1
  92. package/lib/slider/constants.js +6 -1
  93. package/lib/slider/index.d.ts +112 -49
  94. package/lib/slider/index.js +331 -182
  95. package/lib/slider/themes/halo/dark/index.js +1 -1
  96. package/lib/slider/themes/halo/light/index.js +1 -1
  97. package/lib/slider/themes/solar/charcoal/index.js +1 -1
  98. package/lib/slider/themes/solar/pearl/index.js +1 -1
  99. package/lib/slider/utils.d.ts +1 -9
  100. package/lib/slider/utils.js +1 -18
  101. package/lib/sparkline/themes/halo/dark/index.js +1 -1
  102. package/lib/sparkline/themes/halo/light/index.js +1 -1
  103. package/lib/tab/themes/halo/dark/index.js +1 -1
  104. package/lib/tab/themes/halo/light/index.js +1 -1
  105. package/lib/tab-bar/themes/halo/dark/index.js +1 -1
  106. package/lib/tab-bar/themes/halo/light/index.js +1 -1
  107. package/lib/text-field/custom-elements.json +0 -22
  108. package/lib/text-field/custom-elements.md +0 -7
  109. package/lib/toggle/themes/halo/dark/index.js +1 -1
  110. package/lib/toggle/themes/halo/light/index.js +1 -1
  111. package/lib/tree/elements/tree-item.js +1 -2
  112. package/lib/tree/elements/tree.d.ts +6 -0
  113. package/lib/tree/elements/tree.js +11 -1
  114. package/lib/tree/themes/halo/dark/index.js +2 -2
  115. package/lib/tree/themes/halo/light/index.js +2 -2
  116. package/lib/tree-select/index.js +15 -5
  117. package/lib/tree-select/themes/halo/dark/index.js +1 -1
  118. package/lib/tree-select/themes/halo/light/index.js +1 -1
  119. package/lib/version.js +1 -1
  120. package/package.json +19 -18
  121. package/lib/clock/utils/timestamps.d.ts +0 -6
  122. package/lib/clock/utils/timestamps.js +0 -6
package/CHANGELOG.md CHANGED
@@ -3,6 +3,43 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [6.0.1](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@6.0.0...@refinitiv-ui/elements@6.0.1) (2022-06-20)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **chart:** render selected segment after tooltip has rendered so it won't cut off the tooltip ([#359](https://github.com/Refinitiv/refinitiv-ui/issues/359)) ([62e37d5](https://github.com/Refinitiv/refinitiv-ui/commit/62e37d50618f5ec4750d189e150ae8a076d8eca4))
12
+ * **datetime-picker:** change warning and error border style to make it consistent with textfield ([#356](https://github.com/Refinitiv/refinitiv-ui/issues/356)) ([51638bd](https://github.com/Refinitiv/refinitiv-ui/commit/51638bd4d5e9306deb538725726fb085d55fd425))
13
+ * incorrect TypeScript type delcaration path ([#370](https://github.com/Refinitiv/refinitiv-ui/issues/370)) ([4b40823](https://github.com/Refinitiv/refinitiv-ui/commit/4b4082316233ce5b6e4b6e8dd38e10ddedd532f7))
14
+ * **tree-select:** show unselected item on selection filter ([#358](https://github.com/Refinitiv/refinitiv-ui/issues/358)) ([ea88b3c](https://github.com/Refinitiv/refinitiv-ui/commit/ea88b3c1389ef7887af890206bdd29695ce49787))
15
+ * **tree:** incorrect padding size of tree item when use multiple mode ([#362](https://github.com/Refinitiv/refinitiv-ui/issues/362)) ([1f5d6aa](https://github.com/Refinitiv/refinitiv-ui/commit/1f5d6aa71fd9e155202203e18134934fa93c920c))
16
+ * **tree:** tree query selection issues ([#364](https://github.com/Refinitiv/refinitiv-ui/issues/364)) ([cf1c072](https://github.com/Refinitiv/refinitiv-ui/commit/cf1c07234be0ec0984cb109a9fed9cf58db22c44))
17
+
18
+
19
+
20
+
21
+
22
+ # [6.0.0](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@6.0.0-next.3...@refinitiv-ui/elements@6.0.0) (2022-06-07)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **clock:** a11y, tick, show-seconds should not pronounce all the time ([#339](https://github.com/Refinitiv/refinitiv-ui/issues/339)) ([b4e51ac](https://github.com/Refinitiv/refinitiv-ui/commit/b4e51ac1a4b181d99ff37cc30980fd4fc55dd426))
28
+ * **clock:** sync interactiveChange code with rating ([#346](https://github.com/Refinitiv/refinitiv-ui/issues/346)) ([6837206](https://github.com/Refinitiv/refinitiv-ui/commit/6837206d9a32a4d05a18fef262e4277e8630c568))
29
+ * **utils:** improve svg security ([#342](https://github.com/Refinitiv/refinitiv-ui/issues/342)) ([ef53c5c](https://github.com/Refinitiv/refinitiv-ui/commit/ef53c5c8918548a0c2aa67a1934ba0823698a9e8))
30
+
31
+
32
+ ### Features
33
+
34
+ * **clock:** improve clock accessibility ([#308](https://github.com/Refinitiv/refinitiv-ui/issues/308)) ([c0a9bb0](https://github.com/Refinitiv/refinitiv-ui/commit/c0a9bb04c212b6aa4dbce495bec4faebd9080eaf)), closes [#311](https://github.com/Refinitiv/refinitiv-ui/issues/311)
35
+ * **rating:** add accessibility support ([2a1b7e4](https://github.com/Refinitiv/refinitiv-ui/commit/2a1b7e47199de3c1cca73b0a86150da07612c347))
36
+ * **slider:** add arrow key navigation support and aria attributes ([#299](https://github.com/Refinitiv/refinitiv-ui/issues/299)) ([056a45b](https://github.com/Refinitiv/refinitiv-ui/commit/056a45b56911ed0f7634ea1b4abe38c6392144d4)), closes [#332](https://github.com/Refinitiv/refinitiv-ui/issues/332) [#341](https://github.com/Refinitiv/refinitiv-ui/issues/341)
37
+ * **slider:** add localised label for slider thumb ([#351](https://github.com/Refinitiv/refinitiv-ui/issues/351)) ([ba9cc8d](https://github.com/Refinitiv/refinitiv-ui/commit/ba9cc8d563444dba35a082a3898dc4e8f9235074))
38
+
39
+
40
+
41
+
42
+
6
43
  ## [5.12.2](https://github.com/Refinitiv/refinitiv-ui/compare/@refinitiv-ui/elements@5.12.1...@refinitiv-ui/elements@5.12.2) (2022-02-17)
7
44
 
8
45
  **Note:** Version bump only for package @refinitiv-ui/elements
package/README.md CHANGED
@@ -25,12 +25,11 @@ Finally, import both elements that you want to use and its themes into your appl
25
25
  <br>
26
26
 
27
27
  ```javascript
28
- // import native styles for typography, css variables, etc.
29
- import '@refinitiv-ui/halo-theme/dark/imports/native-elements';
30
-
31
28
  // import element and its Halo dark theme
32
29
  import '@refinitiv-ui/elements/button';
33
30
  import '@refinitiv-ui/elements/panel';
31
+ // import native styles for typography, css variables, etc.
32
+ import '@refinitiv-ui/halo-theme/dark/imports/native-elements';
34
33
  import '@refinitiv-ui/elements/button/themes/halo/dark';
35
34
  import '@refinitiv-ui/elements/panel/themes/halo/dark';
36
35
  ```
@@ -51,20 +50,9 @@ Now, you can use the elements in your app.
51
50
  </ef-panel>
52
51
  ```
53
52
 
54
- ## Command Overview
55
-
56
- | Command | Target | Description | Example |
57
- | --- |:--- | --- | --- |
58
- | npm start | `<element>` | Build and serve an element. | npm start button |
59
- | npm run test | `<element>` &#124; `all` | Run unit tests. | npm run test button |
60
- | npm run test:watch | `<element>` | Run test server. | npm run test:watch button |
61
- | npm run test:snapshots | `<element>` &#124; `all` | Update and prune snapshots. | npm run test:watch button |
62
- | npm run lint | `<element>` &#124; `all` | Run linting tools. | npm run lint button |
63
- | npm run lint:fix | `<element>` &#124; `all` | Fix linting errors. | npm run lint:fix button |
64
-
65
53
  # Documentation
66
54
 
67
- See list of elements, demo and more tutorial by visiting [EF Documentation](https://cdn.ppe.refinitiv.com/public/apps/elf-docs/book/en/index.html).
55
+ See list of elements, demo and more tutorial by visiting [EF Documentation](https://ui.refinitiv.com/).
68
56
 
69
57
  # License
70
58
  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".
@@ -7,8 +7,7 @@
7
7
  "attributes": [
8
8
  {
9
9
  "name": "attach",
10
- "description": "An HTML Element or CSS selector",
11
- "type": "AutosuggestTargetElement | string | null"
10
+ "description": "An HTML Element or CSS selector"
12
11
  },
13
12
  {
14
13
  "name": "request-on-focus",
@@ -59,16 +58,10 @@
59
58
  "type": "100",
60
59
  "default": "100"
61
60
  },
62
- {
63
- "name": "defaultMoreSearchText (readonly)",
64
- "type": "\"More results for {0}\"",
65
- "default": "\"More results for {0}\""
66
- },
67
61
  {
68
62
  "name": "attach",
69
63
  "attribute": "attach",
70
- "description": "An HTML Element or CSS selector",
71
- "type": "AutosuggestTargetElement | string | null"
64
+ "description": "An HTML Element or CSS selector"
72
65
  },
73
66
  {
74
67
  "name": "requestOnFocus",
@@ -100,8 +93,7 @@
100
93
  },
101
94
  {
102
95
  "name": "query",
103
- "description": "An object that represents a query from attach target",
104
- "type": "AutosuggestQuery | null"
96
+ "description": "An object that represents a query from attach target"
105
97
  },
106
98
  {
107
99
  "name": "debounceRate",
@@ -113,19 +105,17 @@
113
105
  {
114
106
  "name": "renderer",
115
107
  "description": "A renderer applied to suggestion.\nBy default a render maps data to item attributes",
116
- "type": "AutosuggestRenderer",
117
- "default": "\"itemRenderer\""
108
+ "default": "\"renderer\""
118
109
  },
119
110
  {
120
111
  "name": "highlightable",
121
112
  "description": "A function that is applied to every suggestion during the render process\nto say whether the item can be highlighted and selected. Only items that return true are considered.\nBy default the function checks for `item` `highlightable` property.",
122
- "type": "AutosuggestHighlightable",
123
113
  "default": "\"itemHighlightable\""
124
114
  },
125
115
  {
126
116
  "name": "suggestions",
127
117
  "description": "A list of suggestion items",
128
- "type": "AutosuggestItem[]",
118
+ "type": "object",
129
119
  "default": "[]"
130
120
  },
131
121
  {
@@ -8,20 +8,20 @@ custom rendering, pagination, asynchronous data request, etc.
8
8
 
9
9
  ## Properties
10
10
 
11
- | Property | Attribute | Type | Default | Description |
12
- |------------------|--------------------|----------------------------------------------|------------------------|--------------------------------------------------|
13
- | `attach` | `attach` | `AutosuggestTargetElement \| string \| null` | null | An HTML Element or CSS selector |
14
- | `debounceRate` | `debounce-rate` | `number` | "100" | Debounce rate in ms of the filter as a number.<br />Used to throttle the filter rate so as not to trigger unneeded filtering |
15
- | `highlightable` | | `AutosuggestHighlightable` | "itemHighlightable" | A function that is applied to every suggestion during the render process<br />to say whether the item can be highlighted and selected. Only items that return true are considered.<br />By default the function checks for `item` `highlightable` property. |
16
- | `htmlRenderer` | `html-renderer` | `boolean` | false | If set to true, the render function is not called. Instead the wrapper element<br />should populate and destroy suggestion elements. Rendering items manually<br />may have performance benefits in frameworks that use virtual DOM (such as `Vue`, `React`, `hyperHTML` and others) |
17
- | `loading` | `loading` | `boolean` | false | If set to true show loading mask |
18
- | `moreResults` | `more-results` | `boolean` | false | If set to true display 'Has more results' item |
19
- | `moreSearchText` | `more-search-text` | `string` | "More results for {0}" | Custom text for More Search |
20
- | `opened` | `opened` | `boolean` | false | Auto suggest popup's open state |
21
- | `query` | | `AutosuggestQuery \| null` | null | An object that represents a query from attach target |
22
- | `renderer` | | `AutosuggestRenderer` | "itemRenderer" | A renderer applied to suggestion.<br />By default a render maps data to item attributes |
23
- | `requestOnFocus` | `request-on-focus` | `boolean` | false | Request suggestions when attach target is focused |
24
- | `suggestions` | | `AutosuggestItem[]` | [] | A list of suggestion items |
11
+ | Property | Attribute | Type | Default | Description |
12
+ |------------------|--------------------|-----------|------------------------|--------------------------------------------------|
13
+ | `attach` | `attach` | | null | An HTML Element or CSS selector |
14
+ | `debounceRate` | `debounce-rate` | `number` | "100" | Debounce rate in ms of the filter as a number.<br />Used to throttle the filter rate so as not to trigger unneeded filtering |
15
+ | `highlightable` | | | "itemHighlightable" | A function that is applied to every suggestion during the render process<br />to say whether the item can be highlighted and selected. Only items that return true are considered.<br />By default the function checks for `item` `highlightable` property. |
16
+ | `htmlRenderer` | `html-renderer` | `boolean` | false | If set to true, the render function is not called. Instead the wrapper element<br />should populate and destroy suggestion elements. Rendering items manually<br />may have performance benefits in frameworks that use virtual DOM (such as `Vue`, `React`, `hyperHTML` and others) |
17
+ | `loading` | `loading` | `boolean` | false | If set to true show loading mask |
18
+ | `moreResults` | `more-results` | `boolean` | false | If set to true display 'Has more results' item |
19
+ | `moreSearchText` | `more-search-text` | `string` | "More results for {0}" | Custom text for More Search |
20
+ | `opened` | `opened` | `boolean` | false | Auto suggest popup's open state |
21
+ | `query` | | | null | An object that represents a query from attach target |
22
+ | `renderer` | | | "renderer" | A renderer applied to suggestion.<br />By default a render maps data to item attributes |
23
+ | `requestOnFocus` | `request-on-focus` | `boolean` | false | Request suggestions when attach target is focused |
24
+ | `suggestions` | | `object` | [] | A list of suggestion items |
25
25
 
26
26
  ## Methods
27
27
 
@@ -0,0 +1,8 @@
1
+ import { AutosuggestRenderer } from './types';
2
+ /**
3
+ * Build item element from data object
4
+ * @param suggestion Suggestion data
5
+ * @param query A query data (usually string, but could be any entity )
6
+ * @returns item
7
+ */
8
+ export declare const renderer: AutosuggestRenderer;
@@ -0,0 +1,35 @@
1
+ import { uuid } from '@refinitiv-ui/utils/uuid.js';
2
+ import { updateElementContent } from './utils.js';
3
+ /**
4
+ * Build item element from data object
5
+ * @param suggestion Suggestion data
6
+ * @param query A query data (usually string, but could be any entity )
7
+ * @returns item
8
+ */
9
+ export const renderer = (suggestion, query) => {
10
+ if (typeof suggestion !== 'object') {
11
+ const value = suggestion || '';
12
+ suggestion = {
13
+ label: value,
14
+ value
15
+ };
16
+ }
17
+ const { type, label, title, icon, disabled, value, id } = suggestion;
18
+ const el = document.createElement('ef-item');
19
+ const isTextType = !type || type === 'text';
20
+ const elId = id || (isTextType ? uuid() : '');
21
+ if (elId) {
22
+ el.id = elId;
23
+ }
24
+ el.tabIndex = -1;
25
+ el.setAttribute('role', isTextType ? 'option' : 'presentation');
26
+ el.type = type || null;
27
+ el.disabled = !!disabled;
28
+ el.icon = icon || null;
29
+ el.value = value || label || '';
30
+ if (title) {
31
+ el.title = title;
32
+ }
33
+ updateElementContent(el, query || '', label || '', el.value);
34
+ return el;
35
+ };
@@ -3,7 +3,7 @@ export declare type AutosuggestSelectItemEvent = CustomEvent<{
3
3
  query: string;
4
4
  suggestion: Suggestion;
5
5
  }>;
6
- export declare type AutosuggestHighlightItem = {
6
+ export declare type AutosuggestHighlightItem = HTMLElement & {
7
7
  highlighted: boolean;
8
8
  };
9
9
  export declare type AutosuggestHighlightItemEvent = CustomEvent<{
@@ -41,6 +41,10 @@ export interface Suggestion {
41
41
  * Sort data item into the group.
42
42
  */
43
43
  group?: string;
44
+ /**
45
+ * Suggestion unique id.
46
+ */
47
+ id?: string;
44
48
  }
45
49
  export declare type AutosuggestItem = Suggestion | string | unknown;
46
50
  export interface AutosuggestQuery {
@@ -52,3 +56,99 @@ export declare type AutosuggestTargetElement = HTMLElement & {
52
56
  export declare type AutosuggestMethodType = 'click' | 'enter' | 'clear' | 'reset' | 'navigation';
53
57
  export declare type AutosuggestRenderer = (suggestion: AutosuggestItem, query: AutosuggestQuery | null) => HTMLElement;
54
58
  export declare type AutosuggestHighlightable = (suggestion: AutosuggestItem, target: HTMLElement) => boolean;
59
+ /**
60
+ * @event item-highlight
61
+ * Fired when an item gets highlighted or highlight is removed
62
+ */
63
+ export declare type ItemHighlightEvent = CustomEvent<{
64
+ /**
65
+ * New highlight target
66
+ */
67
+ target: AutosuggestTargetElement | null;
68
+ /**
69
+ * New suggestion
70
+ */
71
+ suggestion: AutosuggestItem | null;
72
+ /**
73
+ * Old highlight target
74
+ */
75
+ oldTarget: AutosuggestTargetElement | null;
76
+ /**
77
+ * Old suggestion
78
+ */
79
+ oldSuggestion: AutosuggestItem | null;
80
+ }>;
81
+ /**
82
+ * @event add-attach-target-events
83
+ * Fired when attach has been set.
84
+ * Add attach target listeners
85
+ */
86
+ export declare type AddAttachTargetEventsEvent = CustomEvent;
87
+ /**
88
+ * @event remove-attach-target-events
89
+ * Fired when attach has been removed.
90
+ * Remove attach target listeners
91
+ */
92
+ export declare type RemoveAttachTargetEventsEvent = CustomEvent;
93
+ /**
94
+ * @event item-select
95
+ * Fired when an item gets selected
96
+ */
97
+ export declare type ItemSelectEvent = CustomEvent<{
98
+ /**
99
+ * Select method
100
+ */
101
+ method: AutosuggestMethodType;
102
+ /**
103
+ * Selection target
104
+ */
105
+ target: AutosuggestTargetElement;
106
+ /**
107
+ * Selected suggestion
108
+ */
109
+ suggestion: AutosuggestItem | null;
110
+ /**
111
+ * Saved query object
112
+ */
113
+ query: AutosuggestQuery | null;
114
+ }>;
115
+ /**
116
+ * @event suggestions-fetch-requested
117
+ * Fired when auto suggest requests the data
118
+ */
119
+ export declare type SuggestionsFetchRequestedEvent = CustomEvent<{
120
+ /**
121
+ * Input query
122
+ */
123
+ query: AutosuggestQuery | null;
124
+ /**
125
+ * The reason to fetch data
126
+ */
127
+ reason: AutosuggestReason;
128
+ }>;
129
+ /**
130
+ * @event suggestions-clear-requested
131
+ * Fired when auto suggest requests to clear the data.
132
+ * If used in reactive application, prevent default and set suggestions to []
133
+ */
134
+ export declare type SuggestionsClearRequestedEvent = CustomEvent;
135
+ /**
136
+ * @event suggestions-query
137
+ * Fired when input value has changed and the query must be set.
138
+ */
139
+ export declare type SuggestionsQueryEvent = CustomEvent<{
140
+ /**
141
+ * The reason to request query
142
+ */
143
+ reason: AutosuggestReason;
144
+ }>;
145
+ /**
146
+ * @event suggestions-changed
147
+ * Fired when suggestions changed
148
+ */
149
+ export declare type SuggestionsChangedEvent = CustomEvent<{
150
+ /**
151
+ * Suggestion Items
152
+ */
153
+ value: AutosuggestItem[];
154
+ }>;
@@ -1,5 +1,5 @@
1
1
  import type { Item } from '../../item';
2
- import type { AutosuggestHighlightable, AutosuggestRenderer } from './types';
2
+ import { AutosuggestHighlightable } from './types';
3
3
  /**
4
4
  * Check whether item can be highlighted
5
5
  * @param suggestion Suggestion object
@@ -30,10 +30,3 @@ export declare const queryWordSelect: (text: string, query?: string, pattern?: s
30
30
  * @return {void}
31
31
  */
32
32
  export declare const updateElementContent: (el: Item, query: string, label: string, value: string | number) => void;
33
- /**
34
- * Build item element from data object
35
- * @param suggestion Suggestion data
36
- * @param query A query data (usually string, but could be any entity )
37
- * @returns item
38
- */
39
- export declare const itemRenderer: AutosuggestRenderer;
@@ -46,30 +46,3 @@ export const updateElementContent = (el, query, label, value) => {
46
46
  el.label = `${value}`;
47
47
  }
48
48
  };
49
- /**
50
- * Build item element from data object
51
- * @param suggestion Suggestion data
52
- * @param query A query data (usually string, but could be any entity )
53
- * @returns item
54
- */
55
- export const itemRenderer = (suggestion, query) => {
56
- const el = document.createElement('ef-item');
57
- if (typeof suggestion === 'object') {
58
- const { type, label, title, icon, disabled, value } = suggestion;
59
- el.type = type || null;
60
- el.disabled = !!disabled;
61
- el.icon = icon || null;
62
- el.value = value || label || '';
63
- if (title) {
64
- el.title = title;
65
- }
66
- updateElementContent(el, query || '', label || '', el.value);
67
- }
68
- else {
69
- const value = suggestion || '';
70
- el.label = value;
71
- el.value = value;
72
- updateElementContent(el, query || '', value, value);
73
- }
74
- return el;
75
- };
@@ -1,11 +1,16 @@
1
1
  import { JSXInterface } from '../jsx';
2
2
  import { CSSResultGroup, ElementSize, PropertyValues, TemplateResult } from '@refinitiv-ui/core';
3
+ import { TranslateDirective } from '@refinitiv-ui/translate';
3
4
  import type { AutosuggestTargetElement, AutosuggestHighlightable, AutosuggestMethodType, AutosuggestQuery, AutosuggestRenderer, AutosuggestReason, AutosuggestItem, AutosuggestSelectItemEvent, AutosuggestHighlightItemEvent } from './helpers/types';
5
+ import { escapeRegExp, itemHighlightable, queryWordSelect } from './helpers/utils.js';
6
+ import { renderer } from './helpers/renderer.js';
4
7
  import { Overlay } from '../overlay/index.js';
5
8
  import '../loader/index.js';
6
9
  import '../item/index.js';
7
- export type { AutosuggestTargetElement, AutosuggestHighlightable, AutosuggestMethodType, AutosuggestQuery, AutosuggestRenderer, AutosuggestReason, AutosuggestItem } from './helpers/types';
8
- export { queryWordSelect, itemRenderer, escapeRegExp, itemHighlightable, updateElementContent } from './helpers/utils.js';
10
+ import '@refinitiv-ui/phrasebook/locale/en/autosuggest.js';
11
+ export type { AutosuggestTargetElement, AutosuggestHighlightable, AutosuggestMethodType, AutosuggestQuery, AutosuggestRenderer, AutosuggestReason, AutosuggestItem, ItemHighlightEvent, AddAttachTargetEventsEvent, RemoveAttachTargetEventsEvent, ItemSelectEvent, SuggestionsFetchRequestedEvent, SuggestionsClearRequestedEvent, SuggestionsQueryEvent, SuggestionsChangedEvent } from './helpers/types';
12
+ export { updateElementContent } from './helpers/utils.js';
13
+ export { itemHighlightable, escapeRegExp, queryWordSelect, renderer, renderer as itemRenderer };
9
14
  /**
10
15
  * Shows suggestions based on users' query.
11
16
  * It can be used by attaching to text form control
@@ -34,6 +39,7 @@ export declare class Autosuggest extends Overlay {
34
39
  * @returns version number
35
40
  */
36
41
  static get version(): string;
42
+ protected readonly defaultRole: string | null;
37
43
  /**
38
44
  * A `CSSResultGroup` that will be used
39
45
  * to style the host, slotted children
@@ -70,10 +76,8 @@ export declare class Autosuggest extends Overlay {
70
76
  */
71
77
  static ItemHighlightable(suggestion: AutosuggestItem, target: HTMLElement): boolean;
72
78
  static readonly defaultDebounceRate = 100;
73
- static readonly defaultMoreSearchText = "More results for {0}";
74
79
  /**
75
80
  * An HTML Element or CSS selector
76
- * @type {AutosuggestTargetElement | string | null}
77
81
  */
78
82
  attach: AutosuggestTargetElement | string | null;
79
83
  /**
@@ -95,7 +99,6 @@ export declare class Autosuggest extends Overlay {
95
99
  loading: boolean;
96
100
  /**
97
101
  * An object that represents a query from attach target
98
- * @type {AutosuggestQuery | null}
99
102
  */
100
103
  query: AutosuggestQuery | null;
101
104
  /**
@@ -107,19 +110,16 @@ export declare class Autosuggest extends Overlay {
107
110
  /**
108
111
  * A renderer applied to suggestion.
109
112
  * By default a render maps data to item attributes
110
- * @type {AutosuggestRenderer}
111
113
  */
112
114
  renderer: AutosuggestRenderer;
113
115
  /**
114
116
  * A function that is applied to every suggestion during the render process
115
117
  * to say whether the item can be highlighted and selected. Only items that return true are considered.
116
118
  * By default the function checks for `item` `highlightable` property.
117
- * @type {AutosuggestHighlightable}
118
119
  */
119
120
  highlightable: AutosuggestHighlightable;
120
121
  /**
121
122
  * A list of suggestion items
122
- * @type {AutosuggestItem[]}
123
123
  */
124
124
  suggestions: AutosuggestItem[];
125
125
  /**
@@ -128,11 +128,15 @@ export declare class Autosuggest extends Overlay {
128
128
  * may have performance benefits in frameworks that use virtual DOM (such as `Vue`, `React`, `hyperHTML` and others)
129
129
  */
130
130
  htmlRenderer: boolean;
131
+ /**
132
+ * Autosuggest internal translation strings
133
+ */
134
+ protected t: TranslateDirective;
131
135
  protected moreResultsItem?: HTMLElement | null;
132
- private contentSlot?;
133
- private contentElement?;
134
- private headerElement?;
135
- private footerElement?;
136
+ private contentSlotRef;
137
+ private contentElementRef;
138
+ private headerElementRef;
139
+ private footerElementRef;
136
140
  private suggestionMap;
137
141
  protected highlightedItem: HTMLElement | null;
138
142
  protected attachTarget: AutosuggestTargetElement | null;
@@ -180,20 +184,6 @@ export declare class Autosuggest extends Overlay {
180
184
  * @returns {void}
181
185
  */
182
186
  resizedCallback(size: ElementSize): void;
183
- /**
184
- * @returns template of loader if currently query loading
185
- */
186
- protected get loaderTemplate(): TemplateResult | null;
187
- /**
188
- * @returns template of moreResults
189
- */
190
- protected get moreResultsTemplate(): TemplateResult | null;
191
- /**
192
- * A `TemplateResult` that will be used
193
- * to render the updated internal template.
194
- * @return Render template
195
- */
196
- protected render(): TemplateResult;
197
187
  /**
198
188
  * Called once after the component is first rendered
199
189
  * @param changedProperties map of changed properties with old values
@@ -277,14 +267,12 @@ export declare class Autosuggest extends Overlay {
277
267
  * @returns {void}
278
268
  */
279
269
  protected highlightItem(target?: HTMLElement | null, silent?: boolean): void;
270
+ private xmlSerializer;
280
271
  /**
281
272
  * Calculate more search text inner html
282
- * @param moreResults True if has more results
283
- * @param moreSearchText More search text template
284
- * @param query A query
285
273
  * @returns innerHTML
286
274
  */
287
- protected highlightText(moreResults: boolean, moreSearchText: string, query: AutosuggestQuery | null): TemplateResult | null;
275
+ protected get moreResultsTextTemplate(): TemplateResult | null;
288
276
  /**
289
277
  * Call this method to request suggestions
290
278
  * @private
@@ -391,7 +379,7 @@ export declare class Autosuggest extends Overlay {
391
379
  */
392
380
  private debounceRateChange;
393
381
  /**
394
- * fire event and reinit listeners if attach was changed
382
+ * fire event and re-init listeners if attach was changed
395
383
  * @returns {void}
396
384
  */
397
385
  private attachChangeFrameCallback;
@@ -496,7 +484,6 @@ export declare class Autosuggest extends Overlay {
496
484
  * @returns {void}
497
485
  */
498
486
  private notifySuggestions;
499
- private removeChildNode;
500
487
  private generateSuggestionsFragment;
501
488
  /**
502
489
  * Set the width
@@ -509,6 +496,20 @@ export declare class Autosuggest extends Overlay {
509
496
  * @returns {void}
510
497
  */
511
498
  private onItemMousedown;
499
+ /**
500
+ * @returns template of loader if currently query loading
501
+ */
502
+ protected get loaderTemplate(): TemplateResult | null;
503
+ /**
504
+ * @returns template of moreResults
505
+ */
506
+ protected get moreResultsTemplate(): TemplateResult | null;
507
+ /**
508
+ * A `TemplateResult` that will be used
509
+ * to render the updated internal template.
510
+ * @return Render template
511
+ */
512
+ protected render(): TemplateResult;
512
513
  /**
513
514
  * IE11 only: Restrict maximum height of content element
514
515
  * @param [maxHeight] Maximum height of content element