@mgdis/mg-components 6.9.0 → 6.10.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 (215) hide show
  1. package/dist/cjs/events.utils-D5SAtkpQ.js +28 -0
  2. package/dist/cjs/events.utils-D5SAtkpQ.js.map +1 -0
  3. package/dist/cjs/index-CATFkm3O.js +4 -0
  4. package/dist/cjs/{index-CTU2m-sy.js → index-CL_COdxv.js} +20 -6
  5. package/dist/cjs/{index-CTU2m-sy.js.map → index-CL_COdxv.js.map} +1 -1
  6. package/dist/cjs/index.es-DaPqByCe.js +250 -0
  7. package/dist/cjs/index.es-DaPqByCe.js.map +1 -0
  8. package/dist/cjs/loader.cjs.js +1 -1
  9. package/dist/cjs/mg-action-more_37.cjs.entry.js +1929 -1913
  10. package/dist/cjs/mg-action-more_37.cjs.entry.js.map +1 -1
  11. package/dist/cjs/mg-alert.cjs.entry.js +7 -7
  12. package/dist/cjs/mg-components.cjs.js +1 -1
  13. package/dist/cjs/mg-input-combobox.cjs.entry.js +774 -0
  14. package/dist/cjs/mg-input-combobox.cjs.entry.js.map +1 -0
  15. package/dist/cjs/mg-input-combobox.entry.cjs.js.map +1 -0
  16. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +16 -14
  17. package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js.map +1 -1
  18. package/dist/cjs/mg-input-rich-text-editor.entry.cjs.js.map +1 -1
  19. package/dist/cjs/mg-loader.cjs.entry.js +5 -5
  20. package/dist/cjs/mg-progress.cjs.entry.js +11 -11
  21. package/dist/collection/collection-manifest.json +1 -0
  22. package/dist/collection/components/atoms/mg-button/mg-button.js +3 -2
  23. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  24. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +0 -1
  25. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js.map +1 -1
  26. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +38 -68
  27. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
  28. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.js +2 -0
  29. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.js.map +1 -0
  30. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +1443 -0
  31. package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js.map +1 -0
  32. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +1 -1
  33. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +2 -2
  34. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
  35. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
  36. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
  37. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/editor/editor.scss +1 -0
  38. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +3 -3
  39. package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js.map +1 -1
  40. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +1 -1
  41. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +1 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
  43. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
  44. package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +2 -2
  45. package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js.map +1 -1
  46. package/dist/collection/components/molecules/menus/mg-menu-item/mg-menu-item.js +3 -3
  47. package/dist/collection/components/molecules/menus/mg-menu-item/mg-menu-item.js.map +1 -1
  48. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +2 -2
  49. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
  50. package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
  51. package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
  52. package/dist/collection/components/molecules/mg-form/mg-form.js +1 -1
  53. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
  54. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  55. package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
  56. package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
  57. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +3 -3
  58. package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
  59. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
  60. package/dist/collection/components/molecules/mg-popover/mg-popover.js +53 -129
  61. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  62. package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
  63. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  64. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +6 -5
  65. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
  66. package/dist/collection/locales/en/messages.json +8 -1
  67. package/dist/collection/locales/fr/messages.json +8 -1
  68. package/dist/collection/utils/behaviors.utils.js +3 -3
  69. package/dist/collection/utils/behaviors.utils.js.map +1 -1
  70. package/dist/collection/utils/events.utils.js +22 -0
  71. package/dist/collection/utils/events.utils.js.map +1 -0
  72. package/dist/components/events.utils.js +26 -0
  73. package/dist/components/events.utils.js.map +1 -0
  74. package/dist/components/index.es.js +129 -36
  75. package/dist/components/index.es.js.map +1 -1
  76. package/dist/components/index2.js +18 -4
  77. package/dist/components/index2.js.map +1 -1
  78. package/dist/components/mg-action-more.js +8 -8
  79. package/dist/components/mg-action-more.js.map +1 -1
  80. package/dist/components/mg-alert.js +6 -6
  81. package/dist/components/mg-badge2.js +6 -6
  82. package/dist/components/mg-button2.js +9 -8
  83. package/dist/components/mg-button2.js.map +1 -1
  84. package/dist/components/mg-character-left2.js +4 -4
  85. package/dist/components/mg-details.js +4 -4
  86. package/dist/components/mg-details.js.map +1 -1
  87. package/dist/components/mg-form.js +8 -8
  88. package/dist/components/mg-icon2.js +6 -6
  89. package/dist/components/mg-illustrated-message.js +6 -6
  90. package/dist/components/mg-input-checkbox.js +9 -9
  91. package/dist/components/mg-input-combobox.d.ts +11 -0
  92. package/dist/components/mg-input-combobox.js +897 -0
  93. package/dist/components/mg-input-combobox.js.map +1 -0
  94. package/dist/components/mg-input-date.js +18 -18
  95. package/dist/components/mg-input-date.js.map +1 -1
  96. package/dist/components/mg-input-numeric.js +16 -16
  97. package/dist/components/mg-input-numeric.js.map +1 -1
  98. package/dist/components/mg-input-password.js +5 -5
  99. package/dist/components/mg-input-password.js.map +1 -1
  100. package/dist/components/mg-input-radio.js +8 -8
  101. package/dist/components/mg-input-rich-text-editor.js +15 -13
  102. package/dist/components/mg-input-rich-text-editor.js.map +1 -1
  103. package/dist/components/mg-input-select2.js +9 -9
  104. package/dist/components/mg-input-select2.js.map +1 -1
  105. package/dist/components/mg-input-text2.js +11 -11
  106. package/dist/components/mg-input-text2.js.map +1 -1
  107. package/dist/components/mg-input-textarea.js +9 -9
  108. package/dist/components/mg-input-textarea.js.map +1 -1
  109. package/dist/components/mg-input-title2.js +4 -4
  110. package/dist/components/mg-input-toggle.js +7 -7
  111. package/dist/components/mg-input2.js +8 -8
  112. package/dist/components/mg-item-more2.js +12 -12
  113. package/dist/components/mg-item-more2.js.map +1 -1
  114. package/dist/components/mg-loader.js +1 -70
  115. package/dist/components/mg-loader.js.map +1 -1
  116. package/dist/components/mg-loader2.js +75 -0
  117. package/dist/components/mg-loader2.js.map +1 -0
  118. package/dist/components/mg-menu-item2.js +13 -13
  119. package/dist/components/mg-menu-item2.js.map +1 -1
  120. package/dist/components/mg-message2.js +6 -6
  121. package/dist/components/mg-modal.js +10 -10
  122. package/dist/components/mg-pagination2.js +9 -9
  123. package/dist/components/mg-panel.js +10 -10
  124. package/dist/components/mg-popover-content2.js +5 -5
  125. package/dist/components/mg-popover-content2.js.map +1 -1
  126. package/dist/components/mg-popover2.js +54 -128
  127. package/dist/components/mg-popover2.js.map +1 -1
  128. package/dist/components/mg-progress.js +11 -11
  129. package/dist/components/mg-skip-links.js +3 -3
  130. package/dist/components/mg-table.js +6 -6
  131. package/dist/components/mg-tabs.js +18 -17
  132. package/dist/components/mg-tabs.js.map +1 -1
  133. package/dist/components/mg-tag.js +4 -4
  134. package/dist/components/mg-tooltip-content2.js +1 -1
  135. package/dist/components/mg-tooltip-content2.js.map +1 -1
  136. package/dist/components/mg-tooltip2.js +42 -71
  137. package/dist/components/mg-tooltip2.js.map +1 -1
  138. package/dist/components/popper.js +1793 -0
  139. package/dist/components/popper.js.map +1 -0
  140. package/dist/esm/events.utils-yMGqY8YG.js +26 -0
  141. package/dist/esm/events.utils-yMGqY8YG.js.map +1 -0
  142. package/dist/esm/index-CAuxALt5.js +4 -0
  143. package/dist/esm/{index-SQlkEaXW.js → index-DALWFL9i.js} +20 -6
  144. package/dist/esm/{index-SQlkEaXW.js.map → index-DALWFL9i.js.map} +1 -1
  145. package/dist/esm/index.es-hNwGkhG6.js +223 -0
  146. package/dist/esm/index.es-hNwGkhG6.js.map +1 -0
  147. package/dist/esm/loader.js +1 -1
  148. package/dist/esm/mg-action-more_37.entry.js +1930 -1914
  149. package/dist/esm/mg-action-more_37.entry.js.map +1 -1
  150. package/dist/esm/mg-alert.entry.js +7 -7
  151. package/dist/esm/mg-components.js +1 -1
  152. package/dist/esm/mg-input-combobox.entry.js +772 -0
  153. package/dist/esm/mg-input-combobox.entry.js.map +1 -0
  154. package/dist/esm/mg-input-rich-text-editor.entry.js +17 -15
  155. package/dist/esm/mg-input-rich-text-editor.entry.js.map +1 -1
  156. package/dist/esm/{mg-input.conf-BtkqaBXm.js → mg-input.conf-CNgv8hc5.js} +3 -3
  157. package/dist/esm/{mg-input.conf-BtkqaBXm.js.map → mg-input.conf-CNgv8hc5.js.map} +1 -1
  158. package/dist/esm/mg-loader.entry.js +5 -5
  159. package/dist/esm/mg-progress.entry.js +11 -11
  160. package/dist/mg-components/locales/en/messages.json +8 -1
  161. package/dist/mg-components/locales/fr/messages.json +8 -1
  162. package/dist/mg-components/mg-components.esm.js +1 -1
  163. package/dist/mg-components/mg-input-combobox.entry.esm.js.map +1 -0
  164. package/dist/mg-components/mg-input-rich-text-editor.entry.esm.js.map +1 -1
  165. package/dist/mg-components/p-352cfc01.entry.js +2 -0
  166. package/dist/mg-components/{p-680948e3.entry.js.map → p-352cfc01.entry.js.map} +1 -1
  167. package/dist/mg-components/p-68f7de47.entry.js +2 -0
  168. package/dist/mg-components/p-68f7de47.entry.js.map +1 -0
  169. package/dist/mg-components/p-CNgv8hc5.js +2 -0
  170. package/dist/mg-components/{p-BtkqaBXm.js.map → p-CNgv8hc5.js.map} +1 -1
  171. package/dist/mg-components/p-Cg3R_y_o.js +2 -0
  172. package/dist/mg-components/{p-CqGbLOnN.js.map → p-Cg3R_y_o.js.map} +1 -1
  173. package/dist/mg-components/p-a52a168c.entry.js +2 -0
  174. package/dist/mg-components/{p-9acc6504.entry.js.map → p-a52a168c.entry.js.map} +1 -1
  175. package/dist/mg-components/{p-583b3769.entry.js → p-bf5de898.entry.js} +2 -2
  176. package/dist/mg-components/p-dcefa0b0.entry.js +2 -0
  177. package/dist/mg-components/p-dcefa0b0.entry.js.map +1 -0
  178. package/dist/mg-components/{p-650d6986.entry.js → p-e33557f9.entry.js} +3 -3
  179. package/dist/mg-components/p-e33557f9.entry.js.map +1 -0
  180. package/dist/mg-components/p-hNwGkhG6.js +2 -0
  181. package/dist/mg-components/p-hNwGkhG6.js.map +1 -0
  182. package/dist/mg-components/p-yMGqY8YG.js +2 -0
  183. package/dist/mg-components/p-yMGqY8YG.js.map +1 -0
  184. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +0 -6
  185. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +6 -7
  186. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.d.ts +24 -0
  187. package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +340 -0
  188. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +9 -27
  189. package/dist/types/components.d.ts +253 -10
  190. package/dist/types/utils/events.utils.d.ts +4 -0
  191. package/ide/intellij/web-types.json +400 -1
  192. package/ide/vscode/html-custom-data.json +332 -0
  193. package/package.json +15 -15
  194. package/dist/cjs/index.es-jXqiN1uw.js +0 -152
  195. package/dist/cjs/index.es-jXqiN1uw.js.map +0 -1
  196. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +0 -2
  197. package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js.map +0 -1
  198. package/dist/collection/utils/floating-ui.utils.js +0 -30
  199. package/dist/collection/utils/floating-ui.utils.js.map +0 -1
  200. package/dist/components/floating-ui.utils.js +0 -1677
  201. package/dist/components/floating-ui.utils.js.map +0 -1
  202. package/dist/esm/index.es-DDBtzymI.js +0 -130
  203. package/dist/esm/index.es-DDBtzymI.js.map +0 -1
  204. package/dist/mg-components/p-650d6986.entry.js.map +0 -1
  205. package/dist/mg-components/p-680948e3.entry.js +0 -2
  206. package/dist/mg-components/p-9acc6504.entry.js +0 -2
  207. package/dist/mg-components/p-BtkqaBXm.js +0 -2
  208. package/dist/mg-components/p-CqGbLOnN.js +0 -2
  209. package/dist/mg-components/p-DDBtzymI.js +0 -2
  210. package/dist/mg-components/p-DDBtzymI.js.map +0 -1
  211. package/dist/mg-components/p-c0fb6f62.entry.js +0 -2
  212. package/dist/mg-components/p-c0fb6f62.entry.js.map +0 -1
  213. package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +0 -6
  214. package/dist/types/utils/floating-ui.utils.d.ts +0 -20
  215. /package/dist/mg-components/{p-583b3769.entry.js.map → p-bf5de898.entry.js.map} +0 -0
@@ -0,0 +1,1443 @@
1
+ import { h } from "@stencil/core";
2
+ import { allItemsAreString, ClassList, getObjectValueFromKey, isValidString, nextTick, Page, Paginate, Cursor, toString, isObject } from "@mgdis/stencil-helpers";
3
+ import { widths, classReadonly, classDisabled } from "../mg-input/mg-input.conf";
4
+ import { initLocales } from "../../../../locales";
5
+ import { Keys } from "../../../../utils/events.utils";
6
+ /**
7
+ * Check if object is an item
8
+ * @param item - object to check
9
+ * @returns True if object is an item
10
+ */
11
+ const isItem = (item) => item && typeof item === 'object' && typeof item.title === 'string' && item.value !== undefined;
12
+ /**
13
+ * Check if objects are items
14
+ * @param items - items to check
15
+ * @returns True if objects are items
16
+ */
17
+ const isItems = (items) => Array.isArray(items) && items.every(isItem);
18
+ /**
19
+ * Check if object is valid combobox fetchmappings
20
+ * @param value - to validate
21
+ * @returns truthy if mapping is valid
22
+ */
23
+ const isFetchmappings = (value) => {
24
+ const isValidRoot = isObject(value) && Object.hasOwn(value, 'request') && Object.hasOwn(value, 'response');
25
+ if (isValidRoot) {
26
+ const { request, response } = value;
27
+ if ([request, response].some(property => !isObject(property)))
28
+ return false;
29
+ const isValidRequest = typeof request.filter === 'string';
30
+ const isValidResponse = typeof response === 'object' &&
31
+ typeof response.total === 'string' &&
32
+ typeof response.items === 'string' &&
33
+ typeof response.next === 'string' &&
34
+ typeof response.itemTitle === 'string' &&
35
+ typeof response.itemValue === 'string';
36
+ return isValidRequest && isValidResponse;
37
+ }
38
+ else {
39
+ return isValidRoot;
40
+ }
41
+ };
42
+ /**
43
+ * Map new URL from old url
44
+ * @param newValue - new URL value
45
+ * @param oldValue - previous URL value
46
+ * @returns updated url
47
+ */
48
+ const mapUrl = (newValue, oldValue) => {
49
+ if (!Boolean(newValue))
50
+ return;
51
+ else if (URL.canParse(newValue)) {
52
+ return newValue;
53
+ }
54
+ // build new URL
55
+ const params = newValue.includes('?') && newValue.split('?').pop();
56
+ if (Boolean(params)) {
57
+ const { origin, pathname } = new URL(oldValue);
58
+ return `${origin}${pathname}?${params}`;
59
+ }
60
+ else {
61
+ return newValue;
62
+ }
63
+ };
64
+ export class MgInputCombobox {
65
+ constructor() {
66
+ /************
67
+ * Internal *
68
+ ************/
69
+ // Classes
70
+ this.classFocus = 'mg-u-is-focused';
71
+ // hasDisplayedError (triggered by blur event)
72
+ this.hasDisplayedError = false;
73
+ /**
74
+ * Input name
75
+ * If not set the value equals the identifier
76
+ */
77
+ this.name = this.identifier;
78
+ /**
79
+ * Define if label is displayed on top
80
+ */
81
+ this.labelOnTop = false;
82
+ /**
83
+ * Define if label is visible
84
+ */
85
+ this.labelHide = false;
86
+ /**
87
+ * Define if input is required
88
+ */
89
+ this.required = false;
90
+ /**
91
+ * Define if input is readonly
92
+ */
93
+ this.readonly = false;
94
+ /**
95
+ * Define if input is disabled
96
+ */
97
+ this.disabled = false;
98
+ /**
99
+ * Define input width
100
+ */
101
+ this.mgWidth = 'full';
102
+ /**
103
+ * Define tooltip position
104
+ */
105
+ this.tooltipPosition = 'input';
106
+ /**
107
+ * Formated items for display
108
+ */
109
+ this.options = new Paginate([]);
110
+ /**
111
+ * Option filter
112
+ */
113
+ this.filter = '';
114
+ /**
115
+ * Component classes
116
+ */
117
+ this.classCollection = new ClassList(['mg-c-input--combobox', 'mg-c-input--has-icon', 'mg-c-input--input-append']);
118
+ /**
119
+ * Popover display state
120
+ */
121
+ this.popoverDisplay = false;
122
+ /**
123
+ * Handle `click` event on option
124
+ * @param event - option element click event
125
+ */
126
+ this.handleOptionClick = (event) => {
127
+ this.setValue(this.options.items.find(option => option.value === event.target.id));
128
+ this.popoverDisplay = false;
129
+ };
130
+ /**
131
+ * Handle `click` event on reset button
132
+ * @param event - click event
133
+ */
134
+ this.handleResetButton = (event) => {
135
+ event.stopPropagation();
136
+ this.reset().then(() => {
137
+ this.input.focus();
138
+ });
139
+ };
140
+ /**
141
+ * Handle `display-change` event on mg-popover
142
+ */
143
+ this.handlePopoverDisplay = (event) => {
144
+ this.popoverDisplay = event.detail;
145
+ };
146
+ /**
147
+ * Handle input event
148
+ */
149
+ this.handleFilterInput = () => {
150
+ this.checkValidity();
151
+ if (this.hasDisplayedError)
152
+ this.setErrorMessage();
153
+ if (!this.popoverDisplay)
154
+ this.popoverDisplay = true;
155
+ this.filter = this.input.value;
156
+ };
157
+ /**
158
+ * Handle `blur` event
159
+ */
160
+ this.handleFilterBlur = () => {
161
+ // skip process if popover is displayed
162
+ if (this.popoverDisplay)
163
+ return;
164
+ // Display Error
165
+ this.handlerInProgress = 'blur';
166
+ this.displayError().finally(() => {
167
+ // reset guard
168
+ this.handlerInProgress = undefined;
169
+ });
170
+ };
171
+ /**
172
+ * Handle `focus` event
173
+ */
174
+ this.handleFilterFocus = () => {
175
+ // ensure visual focus is always clear on focus when component isn't in loading state
176
+ if (!this.isLoading) {
177
+ this.option = null;
178
+ }
179
+ };
180
+ /**
181
+ * Handle load-more <mg-button> `click`
182
+ */
183
+ this.handleLoadMoreButton = () => {
184
+ this.loadingWrapper({ name: 'load-more', cursor: Cursor.NEXT }).then(() => {
185
+ this.input.focus();
186
+ });
187
+ };
188
+ /**
189
+ * Handle `keypress` event
190
+ * @param event - keyboard event
191
+ */
192
+ this.handleFilterKeydown = (event) => {
193
+ if (this.disabled || event.ctrlKey || event.shiftKey)
194
+ return;
195
+ let guard = false;
196
+ // override keys actions
197
+ switch (event.key) {
198
+ case Keys.TAB:
199
+ case Keys.ENTER:
200
+ guard = event.key === Keys.ENTER;
201
+ const option = this.option || this.options.items.find(this.isCurrentOption);
202
+ // Sets the value to the content of the focused option in the listbox.
203
+ if (this.popoverDisplay)
204
+ this.setValue(this.page.total > 0 ? option : null);
205
+ // Closes the popover.
206
+ this.popoverDisplay = false;
207
+ break;
208
+ case Keys.DOWN:
209
+ case Keys.ARROWDOWN:
210
+ case Keys.UP:
211
+ case Keys.ARROWUP:
212
+ guard = true;
213
+ if (this.isLoading || !(this.page.total > 0)) {
214
+ this.popoverDisplay = true;
215
+ break;
216
+ }
217
+ if (Boolean(event.altKey) && [Keys.DOWN, Keys.ARROWDOWN].includes(event.key)) {
218
+ // Opens the popover without moving focus or changing selection.
219
+ this.popoverDisplay = true;
220
+ break;
221
+ }
222
+ // define cursor
223
+ let cursor;
224
+ const isNavigationStart = this.popoverDisplay && isItem(this.option);
225
+ if ([Keys.DOWN, Keys.ARROWDOWN].includes(event.key)) {
226
+ // If the filter is not empty and the popover is displayed, moves visual focus to the first suggested value.
227
+ // If the filter is empty and the popover is not displayed, opens the popover and moves visual focus to the first option.
228
+ // Moves visual focus to the next option.
229
+ // If visual focus is on the last option, moves visual focus to the first option.
230
+ cursor = isNavigationStart ? Cursor.NEXT : Cursor.FIRST;
231
+ }
232
+ else if ([Keys.UP, Keys.ARROWUP].includes(event.key)) {
233
+ // If the filter is not empty and the popover is displayed, moves visual focus to the last suggested value.
234
+ // If the filter is empty, first opens the popover if it is not already displayed and then moves visual focus to the last option.
235
+ // Moves visual focus to the previous option.
236
+ // If visual focus is on the first option, moves visual focus to the last option.
237
+ cursor = isNavigationStart ? Cursor.PREVIOUS : Cursor.LAST;
238
+ }
239
+ // update scroll and visual focused option in wrapper
240
+ this.loadingWrapper({ name: 'scroll', cursor });
241
+ // open popover
242
+ this.popoverDisplay = true;
243
+ break;
244
+ case Keys.LEFT:
245
+ case Keys.ARROWLEFT:
246
+ case Keys.HOME:
247
+ case Keys.RIGHT:
248
+ case Keys.ARROWRIGHT:
249
+ case Keys.END:
250
+ // skip process if visual focus is not in popover
251
+ if (!isItem(this.option))
252
+ break;
253
+ guard = true;
254
+ // Remove visual focus from popover options
255
+ this.option = null;
256
+ let index;
257
+ if (Keys.HOME === event.key) {
258
+ // Moves visual focus to the textbox and places the editing cursor at the beginning of the field.
259
+ index = 0;
260
+ }
261
+ else if (Keys.END === event.key) {
262
+ // Moves visual focus to the textbox and places the editing cursor at the end of the field.
263
+ index = this.filter.length;
264
+ }
265
+ if (typeof index === 'number') {
266
+ this.input.setSelectionRange(index, index);
267
+ }
268
+ break;
269
+ case Keys.ESC:
270
+ case Keys.ESCAPE:
271
+ guard = true;
272
+ if (this.popoverDisplay) {
273
+ // If the popover is displayed, closes it.
274
+ this.popoverDisplay = false;
275
+ }
276
+ else {
277
+ // If the popover is not displayed, clears the filter.
278
+ this.setValue(null);
279
+ this.filter = '';
280
+ // Sets visual focus on the textbox.
281
+ this.option = null;
282
+ }
283
+ break;
284
+ default:
285
+ // Remove visual focus from popover options
286
+ this.option = null;
287
+ break;
288
+ }
289
+ if (guard) {
290
+ event.stopPropagation();
291
+ event.preventDefault();
292
+ }
293
+ };
294
+ /**
295
+ * Scroll to next option from cursor
296
+ * @param index - targeted option index to scroll into
297
+ */
298
+ this.scrollToIndex = (index) => {
299
+ var _a;
300
+ (_a = this.element.shadowRoot.querySelector(`li:nth-of-type(${(index || 0) + this.page.baseIndex})`)) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
301
+ };
302
+ /**
303
+ * Is option the current value
304
+ * @param option - option to match with
305
+ * @returns true if option is the current value
306
+ */
307
+ this.isCurrentOption = (option) => (isItem(this.value) ? this.value.value : this.value) === option.value;
308
+ /**
309
+ * get value prop title
310
+ * @returns value title
311
+ */
312
+ this.getValueTitle = () => {
313
+ if (this.value && isItem(this.value))
314
+ return this.value.title;
315
+ else if (typeof this.value === 'string')
316
+ return this.value;
317
+ else
318
+ return '';
319
+ };
320
+ /**
321
+ * Check if input is valid
322
+ */
323
+ this.checkValidity = () => {
324
+ this.setValidity(this.readonly || this.disabled || this.input.checkValidity());
325
+ };
326
+ /**
327
+ * Set input error message
328
+ * @param errorMessage - errorMessage override
329
+ */
330
+ this.setErrorMessage = (errorMessage) => {
331
+ // Set error message
332
+ this.errorMessage = undefined;
333
+ // Does have a custom error message
334
+ if (!this.valid && errorMessage !== undefined) {
335
+ this.errorMessage = errorMessage;
336
+ }
337
+ // required
338
+ else if (!this.valid && this.input.validity.valueMissing) {
339
+ this.errorMessage = this.messages.errors.required;
340
+ }
341
+ };
342
+ /**
343
+ * Get filtered options from `filter` input value
344
+ * @returns filtered options
345
+ */
346
+ this.optionsFilter = (option) => (this.filter === '' ? true : option.title.toLocaleLowerCase().includes(this.filter.toLocaleLowerCase()));
347
+ /**
348
+ * Loading wrapper with a given action
349
+ * @param action - wrapped loading action
350
+ * @returns promisified action
351
+ */
352
+ this.loadingWrapper = (action) => {
353
+ let promise;
354
+ let index;
355
+ // cache initial loading action if not defined
356
+ if (!Boolean(this.loadingAction)) {
357
+ this.loadingAction = action.name;
358
+ }
359
+ // update index
360
+ if (Boolean(this.option) && this.loadingAction !== 'load-more') {
361
+ index = this.page.items.findIndex(option => option.value.toString() === this.option.value.toString());
362
+ }
363
+ else if (this.loadingAction === 'load-more') {
364
+ index = this.page.items.length - this.page.baseIndex;
365
+ }
366
+ // when action require a loadMore we fetch the API else we report action to next tick
367
+ // Set "load more" if action match OR if next item not available in the current page
368
+ if (action.name === 'load-more') {
369
+ // wait for new element render and update scroll position
370
+ // set component loading
371
+ this.isLoading = true;
372
+ promise = this.goToNextPage;
373
+ }
374
+ else if (action.cursor === Cursor.NEXT &&
375
+ this.page.items.length <= this.page.total &&
376
+ index + this.page.baseIndex === this.page.items.length &&
377
+ index + this.page.baseIndex < this.page.total) {
378
+ // trigger load-more from button to benefit from `disabled-on-click`
379
+ this.loadMoreElement.click();
380
+ return;
381
+ }
382
+ else if (action.name === 'scroll') {
383
+ promise = nextTick;
384
+ }
385
+ else {
386
+ promise = this.updatePage;
387
+ }
388
+ return promise()
389
+ .then(() => {
390
+ // parse full items list from options
391
+ const options = this.options.items.filter(this.optionsFilter);
392
+ // update visual focus
393
+ if (action.name !== 'load-data') {
394
+ index = this.page.getIndexFromCursor(action.cursor, this.loadingAction === 'load-more' && index >= 0 ? options[index] : this.option);
395
+ }
396
+ this.option = options[index];
397
+ // update scroll position
398
+ this.scrollToIndex(index);
399
+ })
400
+ .finally(() => {
401
+ // reset loading after next render
402
+ requestAnimationFrame(() => {
403
+ this.isLoading = false;
404
+ this.loadingAction = undefined;
405
+ });
406
+ });
407
+ };
408
+ /**
409
+ * Go to next page
410
+ * @returns promise
411
+ */
412
+ this.goToNextPage = () => {
413
+ this.loadMore.emit();
414
+ if (Boolean(this.fetchurl)) {
415
+ return this.getOptions(typeof this.page.next === 'string' ? this.page.next : undefined).then(nextPage => {
416
+ if (!Boolean(nextPage))
417
+ return;
418
+ // merge items from current page and next page
419
+ const items = [...this.page.items, ...nextPage.items];
420
+ // create new options pagination withe merged items
421
+ this.options = new Paginate(items, { total: nextPage.total, next: nextPage.next, top: items.length });
422
+ });
423
+ }
424
+ else {
425
+ return nextTick(() => {
426
+ if (typeof this.page.next === 'function') {
427
+ const nextPage = this.page.next();
428
+ this.page = new Page(Object.assign(Object.assign({}, nextPage), { items: [...this.page.items, ...nextPage.items] }));
429
+ }
430
+ });
431
+ }
432
+ };
433
+ /**
434
+ * Go to next page
435
+ * @returns promise
436
+ */
437
+ this.updatePage = async () => {
438
+ if (Boolean(this.fetchurl)) {
439
+ return this.getOptions().then(page => {
440
+ if (!Boolean(page))
441
+ return;
442
+ // reset current options pagination from API response
443
+ this.options = new Paginate(page.items, { total: page.total, next: page.next, top: page.top });
444
+ });
445
+ }
446
+ else {
447
+ this.page = this.options.getPage(0, this.optionsFilter);
448
+ }
449
+ };
450
+ /**
451
+ * Fetch request
452
+ * @param url - to fetch
453
+ * @returns new page from url
454
+ */
455
+ this.getOptions = async (url = this.fetchurl) => {
456
+ // add text filter
457
+ const updateUrl = (typeof url === 'string' ? url : url.toString()).replaceAll(this.fetchmappings.request.filter, encodeURIComponent(this.filter));
458
+ try {
459
+ const response = await fetch(updateUrl, this.fetchoptions).then(response => response.json());
460
+ if (!response)
461
+ return null;
462
+ const items = getObjectValueFromKey(response, this.fetchmappings.response.items).map((item) => ({
463
+ title: getObjectValueFromKey(item, this.fetchmappings.response.itemTitle),
464
+ value: getObjectValueFromKey(item, this.fetchmappings.response.itemValue),
465
+ }));
466
+ const total = Number(getObjectValueFromKey(response, this.fetchmappings.response.total, 0));
467
+ const next = mapUrl(getObjectValueFromKey(response, this.fetchmappings.response.next), this.fetchurl.toString());
468
+ return { items, total, next, top: items.length };
469
+ }
470
+ catch (_a) { }
471
+ };
472
+ }
473
+ watchValue(newValue) {
474
+ this.filter = this.getValueTitle();
475
+ this.valueChange.emit(newValue);
476
+ }
477
+ watchItems(newValue) {
478
+ if (Boolean(this.fetchurl) && !Boolean(newValue)) {
479
+ // skip newValue check
480
+ return;
481
+ }
482
+ else if (Boolean(this.fetchurl) && Boolean(newValue)) {
483
+ throw new Error(`<mg-input-combobox> prop "items" values cannot be use with "fetchurl" prop defined. Passed value: ${toString(newValue)}.`);
484
+ }
485
+ // Empty options
486
+ else if (Array.isArray(newValue) && newValue.length === 0) {
487
+ this.options = new Paginate([]);
488
+ }
489
+ // String array
490
+ else if (allItemsAreString(newValue)) {
491
+ this.options = new Paginate(newValue.map(item => ({ title: item, value: item })), { total: newValue.length });
492
+ }
493
+ // Object array
494
+ else if (isItems(newValue)) {
495
+ this.options = new Paginate(newValue, { total: newValue.length });
496
+ }
497
+ else {
498
+ throw new Error(`<mg-input-combobox> prop "items" values must be the same type, string or Option. Passed value: ${toString(newValue)}.`);
499
+ }
500
+ }
501
+ watchIdentifier(newValue) {
502
+ if (Boolean(newValue)) {
503
+ this.popoverId = `${newValue}-popover`;
504
+ this.element.dataset.mgPopoverGuard = this.popoverId;
505
+ }
506
+ }
507
+ watchReadonly(newValue) {
508
+ if (newValue)
509
+ this.classCollection.add(classReadonly);
510
+ else
511
+ this.classCollection.delete(classReadonly);
512
+ }
513
+ watchValidityChange(newValue, _oldValue, prop) {
514
+ if (this.input === undefined)
515
+ return;
516
+ this.input[prop] = newValue;
517
+ this.checkValidity();
518
+ if (this.hasDisplayedError) {
519
+ this.setErrorMessage();
520
+ this.hasDisplayedError = false;
521
+ }
522
+ }
523
+ watchDisabled(newValue) {
524
+ if (newValue) {
525
+ this.classCollection.add(classDisabled);
526
+ }
527
+ else {
528
+ this.classCollection.delete(classDisabled);
529
+ }
530
+ }
531
+ watchMgWidth(newValue) {
532
+ // reset width class
533
+ widths.forEach(width => {
534
+ this.classCollection.delete(`mg-c-input--width-${width}`);
535
+ });
536
+ // apply new width
537
+ if (newValue !== undefined)
538
+ this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
539
+ this.classCollection = new ClassList(this.classCollection.classes);
540
+ }
541
+ watchFetchUrl(newValue) {
542
+ if (newValue && !URL.canParse(newValue)) {
543
+ throw new Error(`<mg-input-combobox> prop "fetchurl" value must be URL or string. Passed value: ${toString(newValue)}.`);
544
+ }
545
+ }
546
+ watchFetchOptions(newValue) {
547
+ if (this.fetchurl && newValue && !isObject(newValue)) {
548
+ throw new Error(`<mg-input-combobox> prop "fetchoptions" value must be a valid RequestInit. Passed value: ${toString(newValue)}.`);
549
+ }
550
+ else {
551
+ new Request(this.fetchurl, newValue);
552
+ }
553
+ }
554
+ watchFetchMappings(newValue) {
555
+ if (Boolean(this.fetchurl) && !Boolean(newValue)) {
556
+ throw new Error(`<mg-input-combobox> prop "fetchmappings" is required with "fetchurl" prop.`);
557
+ }
558
+ else if (Boolean(newValue) && !isFetchmappings(newValue)) {
559
+ throw new Error(`<mg-input-combobox> prop "fetchmappings" value must be { request: RequestMappingType, response: ResponseMappingType }. Passed value: ${toString(newValue)}.`);
560
+ }
561
+ }
562
+ watchOptions(newValue) {
563
+ this.page = newValue.getPage(0, Boolean(this.filter) ? this.optionsFilter : undefined);
564
+ }
565
+ watchFilter(newValue) {
566
+ this.loadingWrapper({ name: 'load-data' });
567
+ this.filterChange.emit(newValue);
568
+ }
569
+ watchPopoverDisplay(newValue) {
570
+ if (newValue) {
571
+ this.classCollection.add(this.classFocus);
572
+ this.input.focus();
573
+ this.scrollToIndex(0);
574
+ }
575
+ else {
576
+ // remove visual focus
577
+ this.option = null;
578
+ // reset filter with value
579
+ this.filter = this.getValueTitle();
580
+ this.classCollection.delete(this.classFocus);
581
+ this.handlerInProgress = 'blur';
582
+ this.displayError().finally(() => {
583
+ // reset guard
584
+ this.handlerInProgress = undefined;
585
+ });
586
+ }
587
+ }
588
+ /**
589
+ * Public method to play input focus
590
+ */
591
+ async setFocus() {
592
+ this.input.focus();
593
+ }
594
+ /**
595
+ * Display input error if it exists.
596
+ */
597
+ displayError() {
598
+ // Use `Promise` as requested for stencil method
599
+ // Use `requestAnimationFrame` to ensure:
600
+ // - DOM is fully updated before validation
601
+ // - Async operations are completed
602
+ // - No timing issues with Stencil's render cycle
603
+ // - Keep everything in sync both inside and outside the component
604
+ return new Promise(resolve => {
605
+ requestAnimationFrame(() => {
606
+ this.checkValidity();
607
+ this.setErrorMessage();
608
+ this.hasDisplayedError = this.invalid;
609
+ resolve();
610
+ });
611
+ });
612
+ }
613
+ /**
614
+ * Set an error and display a custom error message.
615
+ * This method can be used to set the component's error state from its concombobox by passing a boolean value to the `valid` parameter.
616
+ * It must be paired with an error message to display for the given concombobox.
617
+ * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
618
+ * @param valid - value indicating the validity
619
+ * @param errorMessage - the error message to display
620
+ */
621
+ async setError(valid, errorMessage) {
622
+ if (typeof valid !== 'boolean') {
623
+ throw new Error('<mg-input-combobox> method "setError()" param "valid" must be a boolean.');
624
+ }
625
+ else if (!isValidString(errorMessage)) {
626
+ throw new Error('<mg-input-combobox> method "setError()" param "errorMessage" must be a string.');
627
+ }
628
+ else {
629
+ this.setValidity(valid);
630
+ this.setErrorMessage(valid ? undefined : errorMessage);
631
+ this.hasDisplayedError = this.invalid;
632
+ }
633
+ }
634
+ /**
635
+ * Reset value, validity and error state
636
+ */
637
+ async reset() {
638
+ if (this.readonly)
639
+ return;
640
+ this.setValue(null);
641
+ this.option = null;
642
+ this.filter = '';
643
+ this.checkValidity();
644
+ this.errorMessage = undefined;
645
+ this.hasDisplayedError = false;
646
+ }
647
+ /**
648
+ * Set value prop
649
+ * @param newValue - slected option item
650
+ */
651
+ setValue(newValue) {
652
+ if (!isItem(newValue)) {
653
+ this.value = '';
654
+ }
655
+ else {
656
+ this.value = allItemsAreString(this.items || this.options.items) ? newValue.title : Object.assign({}, newValue);
657
+ }
658
+ }
659
+ /**
660
+ * Method to set validity values
661
+ * @param newValue - valid new value
662
+ */
663
+ setValidity(newValue) {
664
+ const oldValidValue = this.valid;
665
+ this.valid = newValue;
666
+ this.invalid = !this.valid;
667
+ // We need to send valid event even if it is the same value
668
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
669
+ this.inputValid.emit(this.valid);
670
+ }
671
+ /*************
672
+ * Lifecycle *
673
+ *************/
674
+ /**
675
+ * Check if component props are well configured on init
676
+ * @returns timeout
677
+ */
678
+ componentWillLoad() {
679
+ // Get locales
680
+ this.messages = initLocales(this.element).messages;
681
+ // Validate
682
+ this.watchIdentifier(this.identifier);
683
+ this.watchItems(this.items);
684
+ if (Boolean(this.fetchurl)) {
685
+ this.watchFetchUrl(this.fetchurl);
686
+ this.watchFetchOptions(this.fetchoptions);
687
+ this.watchFetchMappings(this.fetchmappings);
688
+ this.loadingWrapper({ name: 'load-data' });
689
+ }
690
+ this.watchValue(this.value);
691
+ this.watchOptions(this.options);
692
+ this.watchMgWidth(this.mgWidth);
693
+ this.watchReadonly(this.readonly);
694
+ this.watchDisabled(this.disabled);
695
+ // Check validity when component is ready
696
+ // return a promise to process action only in the FIRST render().
697
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
698
+ return setTimeout(() => {
699
+ this.checkValidity();
700
+ }, 0);
701
+ }
702
+ /**
703
+ * Render
704
+ * @returns HTML Element
705
+ */
706
+ render() {
707
+ var _a, _b, _c, _d, _e, _f;
708
+ const listId = `${this.identifier}-list`;
709
+ const readonlyValue = this.getValueTitle();
710
+ const withResetButton = this.value && !this.disabled;
711
+ let popoverContent;
712
+ if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0)
713
+ popoverContent = 'list';
714
+ else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && Boolean(this.filter))
715
+ popoverContent = 'notfound';
716
+ else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0)
717
+ popoverContent = 'notavailable';
718
+ return (h("mg-input", { key: 'b8c4c6d18bb1d16ff0a8494ddb698cb4e0198e43', label: this.label, identifier: this.identifier, class: this.classCollection.classes.join(' '), ariaDescribedbyIDs: popoverContent && popoverContent !== 'list' ? [popoverContent] : [], labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, tooltip: this.tooltip, tooltipPosition: this.readonly && this.value === undefined ? 'label' : this.tooltipPosition, helpText: this.helpText, errorMessage: this.errorMessage }, this.readonly ? (readonlyValue && h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (h("mg-popover", { identifier: this.popoverId, placement: "bottom-start", display: this.popoverDisplay, "arrow-hide": true, style: {
719
+ '--mg-c-input-list-width': Boolean((_d = this.input) === null || _d === void 0 ? void 0 : _d.offsetWidth) ? `${this.input.offsetWidth}px` : undefined,
720
+ '--mg-c-input-append-x': withResetButton ? '2' : '1',
721
+ }, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, h("div", { class: "mg-c-input__input-group-container" }, h("mg-icon", { icon: "magnifying-glass" }), h("input", { type: "text", role: "combobox", class: "mg-c-input__box mg-c-input__box--width", value: this.filter, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, autocomplete: "off", "aria-autocomplete": "list", "aria-expanded": this.popoverDisplay.toString(), "aria-controls": listId, "aria-invalid": (this.invalid === true).toString(), "aria-activedescendant": Boolean((_e = this.option) === null || _e === void 0 ? void 0 : _e.value) ? this.option.value : typeof this.value === 'string' ? this.value : (_f = this.value) === null || _f === void 0 ? void 0 : _f.value, onInput: this.handleFilterInput, onBlur: this.handleFilterBlur, onFocus: this.handleFilterFocus, onKeyDown: this.handleFilterKeydown, ref: (el) => {
722
+ if (el !== null)
723
+ this.input = el;
724
+ } }), withResetButton && (h("mg-button", { class: "mg-c-input__box-append mg-c-input__reset", variant: "flat", "is-icon": true, label: this.messages.general.reset, "aria-controls": this.identifier, tabindex: "-1", onClick: this.handleResetButton }, h("mg-icon", { icon: "cross" }))), h("mg-button", { class: "mg-c-input__box-append", variant: "flat", "is-icon": true, label: this.itemsLabel, tabindex: "-1", disabled: this.disabled }, h("mg-icon", { icon: `chevron-${this.popoverDisplay ? 'up' : 'down'}` }))), h("div", { slot: "content", class: "mg-c-input__popover-container" }, popoverContent === 'list' && [
725
+ // eslint-disable-next-line jsx-a11y/role-supports-aria-props
726
+ h("ul", { key: "list", class: "mg-c-input__input-list", role: "listbox", id: listId, "aria-label": this.itemsLabel, "aria-setsize": this.page.total }, this.page.items.map(option => {
727
+ return (
728
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events
729
+ h("li", { role: "option", class: {
730
+ 'mg-c-input__input-list-item': true,
731
+ 'mg-c-input__input-list-item--focus-visible': this.option === option,
732
+ 'mg-c-input__input-list-item--selected': this.isCurrentOption(option),
733
+ }, key: option.title, id: option.value.toString(), "aria-selected": this.isCurrentOption(option).toString(), onClick: this.handleOptionClick }, option.title, this.isCurrentOption(option) && h("mg-icon", { icon: "check" })));
734
+ })),
735
+ this.isLoading && h("mg-loader", { key: "loader", message: this.messages.input.combobox.search, class: { 'mg-u-visually-hidden': Boolean(this.page.next) } }),
736
+ this.page.next && (h("mg-button", { key: "load-more", variant: "flat", class: "mg-c-input__load-more", tabIndex: -1, disabled: this.isLoading, "full-width": true, "disable-on-click": true, onClick: this.handleLoadMoreButton, "aria-controls": listId, ref: (el) => {
737
+ if (el !== null)
738
+ this.loadMoreElement = el;
739
+ } }, h("mg-icon", { icon: "chevron-down" }), this.messages.input.combobox.loadMore)),
740
+ ], popoverContent === 'notfound' && (h("p", { id: popoverContent, class: "mg-c-input__popover-info" }, this.messages.input.combobox.notFound)), popoverContent === 'notavailable' && (h("p", { id: popoverContent, class: "mg-c-input__popover-info" }, this.messages.input.combobox.notAvailable)))))));
741
+ }
742
+ static get is() { return "mg-input-combobox"; }
743
+ static get encapsulation() { return "shadow"; }
744
+ static get originalStyleUrls() {
745
+ return {
746
+ "$": ["../../../../../node_modules/@mgdis/styles/dist/components/mg-input-combobox.css"]
747
+ };
748
+ }
749
+ static get styleUrls() {
750
+ return {
751
+ "$": ["../../../../../node_modules/@mgdis/styles/dist/components/mg-input-combobox.css"]
752
+ };
753
+ }
754
+ static get properties() {
755
+ return {
756
+ "value": {
757
+ "type": "string",
758
+ "mutable": true,
759
+ "complexType": {
760
+ "original": "string | Option",
761
+ "resolved": "string | { title: string; value: unknown; }",
762
+ "references": {
763
+ "Option": {
764
+ "location": "import",
765
+ "path": "../../../../types",
766
+ "id": "src/types/index.ts::Option"
767
+ }
768
+ }
769
+ },
770
+ "required": false,
771
+ "optional": false,
772
+ "docs": {
773
+ "tags": [],
774
+ "text": "Define component value"
775
+ },
776
+ "getter": false,
777
+ "setter": false,
778
+ "attribute": "value",
779
+ "reflect": true
780
+ },
781
+ "items": {
782
+ "type": "unknown",
783
+ "mutable": false,
784
+ "complexType": {
785
+ "original": "(string | Option)[]",
786
+ "resolved": "(string | Option)[]",
787
+ "references": {
788
+ "Option": {
789
+ "location": "import",
790
+ "path": "../../../../types",
791
+ "id": "src/types/index.ts::Option"
792
+ }
793
+ }
794
+ },
795
+ "required": false,
796
+ "optional": false,
797
+ "docs": {
798
+ "tags": [],
799
+ "text": "Define components items"
800
+ },
801
+ "getter": false,
802
+ "setter": false
803
+ },
804
+ "itemsLabel": {
805
+ "type": "string",
806
+ "mutable": false,
807
+ "complexType": {
808
+ "original": "string",
809
+ "resolved": "string",
810
+ "references": {}
811
+ },
812
+ "required": true,
813
+ "optional": false,
814
+ "docs": {
815
+ "tags": [{
816
+ "name": "example",
817
+ "text": "```\nCountries\n```"
818
+ }],
819
+ "text": "Define items label\nInclude short description. Required for accessibility."
820
+ },
821
+ "getter": false,
822
+ "setter": false,
823
+ "attribute": "items-label",
824
+ "reflect": false
825
+ },
826
+ "identifier": {
827
+ "type": "string",
828
+ "mutable": false,
829
+ "complexType": {
830
+ "original": "string",
831
+ "resolved": "string",
832
+ "references": {}
833
+ },
834
+ "required": true,
835
+ "optional": false,
836
+ "docs": {
837
+ "tags": [],
838
+ "text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)"
839
+ },
840
+ "getter": false,
841
+ "setter": false,
842
+ "attribute": "identifier",
843
+ "reflect": false
844
+ },
845
+ "name": {
846
+ "type": "string",
847
+ "mutable": false,
848
+ "complexType": {
849
+ "original": "string",
850
+ "resolved": "string",
851
+ "references": {}
852
+ },
853
+ "required": false,
854
+ "optional": false,
855
+ "docs": {
856
+ "tags": [],
857
+ "text": "Input name\nIf not set the value equals the identifier"
858
+ },
859
+ "getter": false,
860
+ "setter": false,
861
+ "attribute": "name",
862
+ "reflect": false,
863
+ "defaultValue": "this.identifier"
864
+ },
865
+ "label": {
866
+ "type": "string",
867
+ "mutable": false,
868
+ "complexType": {
869
+ "original": "string",
870
+ "resolved": "string",
871
+ "references": {}
872
+ },
873
+ "required": true,
874
+ "optional": false,
875
+ "docs": {
876
+ "tags": [],
877
+ "text": "Input label"
878
+ },
879
+ "getter": false,
880
+ "setter": false,
881
+ "attribute": "label",
882
+ "reflect": false
883
+ },
884
+ "labelOnTop": {
885
+ "type": "boolean",
886
+ "mutable": false,
887
+ "complexType": {
888
+ "original": "boolean",
889
+ "resolved": "boolean",
890
+ "references": {}
891
+ },
892
+ "required": false,
893
+ "optional": false,
894
+ "docs": {
895
+ "tags": [],
896
+ "text": "Define if label is displayed on top"
897
+ },
898
+ "getter": false,
899
+ "setter": false,
900
+ "attribute": "label-on-top",
901
+ "reflect": false,
902
+ "defaultValue": "false"
903
+ },
904
+ "labelHide": {
905
+ "type": "boolean",
906
+ "mutable": false,
907
+ "complexType": {
908
+ "original": "boolean",
909
+ "resolved": "boolean",
910
+ "references": {}
911
+ },
912
+ "required": false,
913
+ "optional": false,
914
+ "docs": {
915
+ "tags": [],
916
+ "text": "Define if label is visible"
917
+ },
918
+ "getter": false,
919
+ "setter": false,
920
+ "attribute": "label-hide",
921
+ "reflect": false,
922
+ "defaultValue": "false"
923
+ },
924
+ "placeholder": {
925
+ "type": "string",
926
+ "mutable": false,
927
+ "complexType": {
928
+ "original": "string",
929
+ "resolved": "string",
930
+ "references": {}
931
+ },
932
+ "required": false,
933
+ "optional": true,
934
+ "docs": {
935
+ "tags": [],
936
+ "text": "Define input placeholder.\nIt should be a word or short phrase that demonstrates the expected type of data, not a replacement for labels or help combobox."
937
+ },
938
+ "getter": false,
939
+ "setter": false,
940
+ "attribute": "placeholder",
941
+ "reflect": false
942
+ },
943
+ "required": {
944
+ "type": "boolean",
945
+ "mutable": false,
946
+ "complexType": {
947
+ "original": "boolean",
948
+ "resolved": "boolean",
949
+ "references": {}
950
+ },
951
+ "required": false,
952
+ "optional": false,
953
+ "docs": {
954
+ "tags": [],
955
+ "text": "Define if input is required"
956
+ },
957
+ "getter": false,
958
+ "setter": false,
959
+ "attribute": "required",
960
+ "reflect": false,
961
+ "defaultValue": "false"
962
+ },
963
+ "readonly": {
964
+ "type": "boolean",
965
+ "mutable": false,
966
+ "complexType": {
967
+ "original": "boolean",
968
+ "resolved": "boolean",
969
+ "references": {}
970
+ },
971
+ "required": false,
972
+ "optional": false,
973
+ "docs": {
974
+ "tags": [],
975
+ "text": "Define if input is readonly"
976
+ },
977
+ "getter": false,
978
+ "setter": false,
979
+ "attribute": "readonly",
980
+ "reflect": false,
981
+ "defaultValue": "false"
982
+ },
983
+ "disabled": {
984
+ "type": "boolean",
985
+ "mutable": false,
986
+ "complexType": {
987
+ "original": "boolean",
988
+ "resolved": "boolean",
989
+ "references": {}
990
+ },
991
+ "required": false,
992
+ "optional": false,
993
+ "docs": {
994
+ "tags": [],
995
+ "text": "Define if input is disabled"
996
+ },
997
+ "getter": false,
998
+ "setter": false,
999
+ "attribute": "disabled",
1000
+ "reflect": false,
1001
+ "defaultValue": "false"
1002
+ },
1003
+ "mgWidth": {
1004
+ "type": "any",
1005
+ "mutable": false,
1006
+ "complexType": {
1007
+ "original": "Width",
1008
+ "resolved": "\"full\" | 16 | 2 | 4",
1009
+ "references": {
1010
+ "Width": {
1011
+ "location": "import",
1012
+ "path": "../mg-input/mg-input.conf",
1013
+ "id": "src/components/molecules/inputs/mg-input/mg-input.conf.ts::Width"
1014
+ }
1015
+ }
1016
+ },
1017
+ "required": false,
1018
+ "optional": false,
1019
+ "docs": {
1020
+ "tags": [],
1021
+ "text": "Define input width"
1022
+ },
1023
+ "getter": false,
1024
+ "setter": false,
1025
+ "attribute": "mg-width",
1026
+ "reflect": false,
1027
+ "defaultValue": "'full'"
1028
+ },
1029
+ "tooltip": {
1030
+ "type": "string",
1031
+ "mutable": false,
1032
+ "complexType": {
1033
+ "original": "string",
1034
+ "resolved": "string",
1035
+ "references": {}
1036
+ },
1037
+ "required": false,
1038
+ "optional": true,
1039
+ "docs": {
1040
+ "tags": [],
1041
+ "text": "Add a tooltip message next to the input"
1042
+ },
1043
+ "getter": false,
1044
+ "setter": false,
1045
+ "attribute": "tooltip",
1046
+ "reflect": false
1047
+ },
1048
+ "tooltipPosition": {
1049
+ "type": "string",
1050
+ "mutable": false,
1051
+ "complexType": {
1052
+ "original": "TooltipPosition",
1053
+ "resolved": "\"input\" | \"label\"",
1054
+ "references": {
1055
+ "TooltipPosition": {
1056
+ "location": "import",
1057
+ "path": "../mg-input/mg-input.conf",
1058
+ "id": "src/components/molecules/inputs/mg-input/mg-input.conf.ts::TooltipPosition"
1059
+ }
1060
+ }
1061
+ },
1062
+ "required": false,
1063
+ "optional": false,
1064
+ "docs": {
1065
+ "tags": [],
1066
+ "text": "Define tooltip position"
1067
+ },
1068
+ "getter": false,
1069
+ "setter": false,
1070
+ "attribute": "tooltip-position",
1071
+ "reflect": false,
1072
+ "defaultValue": "'input'"
1073
+ },
1074
+ "helpText": {
1075
+ "type": "string",
1076
+ "mutable": false,
1077
+ "complexType": {
1078
+ "original": "string",
1079
+ "resolved": "string",
1080
+ "references": {}
1081
+ },
1082
+ "required": false,
1083
+ "optional": true,
1084
+ "docs": {
1085
+ "tags": [],
1086
+ "text": "Add a help text under the input, usually expected data format and example"
1087
+ },
1088
+ "getter": false,
1089
+ "setter": false,
1090
+ "attribute": "help-text",
1091
+ "reflect": false
1092
+ },
1093
+ "fetchurl": {
1094
+ "type": "string",
1095
+ "mutable": false,
1096
+ "complexType": {
1097
+ "original": "string | URL",
1098
+ "resolved": "URL | string",
1099
+ "references": {
1100
+ "URL": {
1101
+ "location": "global",
1102
+ "id": "global::URL"
1103
+ }
1104
+ }
1105
+ },
1106
+ "required": false,
1107
+ "optional": true,
1108
+ "docs": {
1109
+ "tags": [{
1110
+ "name": "example",
1111
+ "text": "```\n{\n url: \"http://myapi.com?$select='href,name'&my-custom-param='my-custom-value'\", // url to fetch\n}\n```"
1112
+ }],
1113
+ "text": "Define API url to fetch"
1114
+ },
1115
+ "getter": false,
1116
+ "setter": false,
1117
+ "attribute": "fetchurl",
1118
+ "reflect": false
1119
+ },
1120
+ "fetchoptions": {
1121
+ "type": "unknown",
1122
+ "mutable": false,
1123
+ "complexType": {
1124
+ "original": "RequestInit",
1125
+ "resolved": "RequestInit",
1126
+ "references": {
1127
+ "RequestInit": {
1128
+ "location": "global",
1129
+ "id": "global::RequestInit"
1130
+ }
1131
+ }
1132
+ },
1133
+ "required": false,
1134
+ "optional": true,
1135
+ "docs": {
1136
+ "tags": [{
1137
+ "name": "see",
1138
+ "text": "{@link https://developer.mozilla.org/en-US/docs/Web/API/RequestInit}"
1139
+ }, {
1140
+ "name": "example",
1141
+ "text": "JSON headers:\n```json\n{\n\"headers\": {\n\"authorization\": \"my-token\"\n}\n}\n```"
1142
+ }],
1143
+ "text": "Define fetch options object\nRequire `fetchurl` prop to be defined otherwith it will be ignored if defined"
1144
+ },
1145
+ "getter": false,
1146
+ "setter": false
1147
+ },
1148
+ "fetchmappings": {
1149
+ "type": "unknown",
1150
+ "mutable": false,
1151
+ "complexType": {
1152
+ "original": "{ request: RequestMappingType; response: ResponseMappingType }",
1153
+ "resolved": "{ request: RequestMappingType; response: ResponseMappingType; }",
1154
+ "references": {
1155
+ "RequestMappingType": {
1156
+ "location": "import",
1157
+ "path": "./mg-input-combobox.conf",
1158
+ "id": "src/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.ts::RequestMappingType"
1159
+ },
1160
+ "ResponseMappingType": {
1161
+ "location": "import",
1162
+ "path": "./mg-input-combobox.conf",
1163
+ "id": "src/components/molecules/inputs/mg-input-combobox/mg-input-combobox.conf.ts::ResponseMappingType"
1164
+ }
1165
+ }
1166
+ },
1167
+ "required": false,
1168
+ "optional": true,
1169
+ "docs": {
1170
+ "tags": [{
1171
+ "name": "example",
1172
+ "text": "```\n{\n request: {\n filter: 'name', // `filter` key\n },\n response: {\n total: 'body.data.total', // response object mapping to get `total` value\n items: 'body.data.results' // response object mapping to get `items` value\n next: 'body.next' // response object mapping to get `next` items\n itemTitle: 'name', // item property to map on item['title']\n itemValue: 'href', // item property to map on item['value']\n }\n}\n```"
1173
+ }],
1174
+ "text": "Define fetch request mappings.\nRequired with `fetchurl`"
1175
+ },
1176
+ "getter": false,
1177
+ "setter": false
1178
+ },
1179
+ "valid": {
1180
+ "type": "boolean",
1181
+ "mutable": true,
1182
+ "complexType": {
1183
+ "original": "boolean",
1184
+ "resolved": "boolean",
1185
+ "references": {}
1186
+ },
1187
+ "required": false,
1188
+ "optional": false,
1189
+ "docs": {
1190
+ "tags": [],
1191
+ "text": "Define input valid state"
1192
+ },
1193
+ "getter": false,
1194
+ "setter": false,
1195
+ "attribute": "valid",
1196
+ "reflect": false
1197
+ },
1198
+ "invalid": {
1199
+ "type": "boolean",
1200
+ "mutable": true,
1201
+ "complexType": {
1202
+ "original": "boolean",
1203
+ "resolved": "boolean",
1204
+ "references": {}
1205
+ },
1206
+ "required": false,
1207
+ "optional": false,
1208
+ "docs": {
1209
+ "tags": [],
1210
+ "text": "Define input invalid state"
1211
+ },
1212
+ "getter": false,
1213
+ "setter": false,
1214
+ "attribute": "invalid",
1215
+ "reflect": false
1216
+ }
1217
+ };
1218
+ }
1219
+ static get states() {
1220
+ return {
1221
+ "isLoading": {},
1222
+ "options": {},
1223
+ "option": {},
1224
+ "filter": {},
1225
+ "classCollection": {},
1226
+ "errorMessage": {},
1227
+ "popoverDisplay": {}
1228
+ };
1229
+ }
1230
+ static get events() {
1231
+ return [{
1232
+ "method": "valueChange",
1233
+ "name": "value-change",
1234
+ "bubbles": true,
1235
+ "cancelable": true,
1236
+ "composed": true,
1237
+ "docs": {
1238
+ "tags": [],
1239
+ "text": "Emited event when value change"
1240
+ },
1241
+ "complexType": {
1242
+ "original": "HTMLMgInputComboboxElement['value']",
1243
+ "resolved": "string | { title: string; value: unknown; }",
1244
+ "references": {
1245
+ "HTMLMgInputComboboxElement": {
1246
+ "location": "global",
1247
+ "id": "global::HTMLMgInputComboboxElement"
1248
+ }
1249
+ }
1250
+ }
1251
+ }, {
1252
+ "method": "filterChange",
1253
+ "name": "filter-change",
1254
+ "bubbles": true,
1255
+ "cancelable": true,
1256
+ "composed": true,
1257
+ "docs": {
1258
+ "tags": [],
1259
+ "text": "Emited event when filter change"
1260
+ },
1261
+ "complexType": {
1262
+ "original": "string",
1263
+ "resolved": "string",
1264
+ "references": {}
1265
+ }
1266
+ }, {
1267
+ "method": "loadMore",
1268
+ "name": "load-more",
1269
+ "bubbles": true,
1270
+ "cancelable": true,
1271
+ "composed": true,
1272
+ "docs": {
1273
+ "tags": [],
1274
+ "text": "Emited event when `load-more` is called"
1275
+ },
1276
+ "complexType": {
1277
+ "original": "void",
1278
+ "resolved": "void",
1279
+ "references": {}
1280
+ }
1281
+ }, {
1282
+ "method": "inputValid",
1283
+ "name": "input-valid",
1284
+ "bubbles": true,
1285
+ "cancelable": true,
1286
+ "composed": true,
1287
+ "docs": {
1288
+ "tags": [],
1289
+ "text": "Emited event when checking validity"
1290
+ },
1291
+ "complexType": {
1292
+ "original": "HTMLMgInputComboboxElement['valid']",
1293
+ "resolved": "boolean",
1294
+ "references": {
1295
+ "HTMLMgInputComboboxElement": {
1296
+ "location": "global",
1297
+ "id": "global::HTMLMgInputComboboxElement"
1298
+ }
1299
+ }
1300
+ }
1301
+ }];
1302
+ }
1303
+ static get methods() {
1304
+ return {
1305
+ "setFocus": {
1306
+ "complexType": {
1307
+ "signature": "() => Promise<void>",
1308
+ "parameters": [],
1309
+ "references": {
1310
+ "Promise": {
1311
+ "location": "global",
1312
+ "id": "global::Promise"
1313
+ }
1314
+ },
1315
+ "return": "Promise<void>"
1316
+ },
1317
+ "docs": {
1318
+ "text": "Public method to play input focus",
1319
+ "tags": []
1320
+ }
1321
+ },
1322
+ "displayError": {
1323
+ "complexType": {
1324
+ "signature": "() => Promise<void>",
1325
+ "parameters": [],
1326
+ "references": {
1327
+ "Promise": {
1328
+ "location": "global",
1329
+ "id": "global::Promise"
1330
+ }
1331
+ },
1332
+ "return": "Promise<void>"
1333
+ },
1334
+ "docs": {
1335
+ "text": "Display input error if it exists.",
1336
+ "tags": []
1337
+ }
1338
+ },
1339
+ "setError": {
1340
+ "complexType": {
1341
+ "signature": "(valid: MgInputCombobox[\"valid\"], errorMessage: string) => Promise<void>",
1342
+ "parameters": [{
1343
+ "name": "valid",
1344
+ "type": "boolean",
1345
+ "docs": "- value indicating the validity"
1346
+ }, {
1347
+ "name": "errorMessage",
1348
+ "type": "string",
1349
+ "docs": "- the error message to display"
1350
+ }],
1351
+ "references": {
1352
+ "Promise": {
1353
+ "location": "global",
1354
+ "id": "global::Promise"
1355
+ },
1356
+ "MgInputCombobox": {
1357
+ "location": "global",
1358
+ "id": "global::MgInputCombobox"
1359
+ }
1360
+ },
1361
+ "return": "Promise<void>"
1362
+ },
1363
+ "docs": {
1364
+ "text": "Set an error and display a custom error message.\nThis method can be used to set the component's error state from its concombobox by passing a boolean value to the `valid` parameter.\nIt must be paired with an error message to display for the given concombobox.\nWhen used to set validity to `false`, you should use this method again to reset the validity to `true`.",
1365
+ "tags": [{
1366
+ "name": "param",
1367
+ "text": "valid - value indicating the validity"
1368
+ }, {
1369
+ "name": "param",
1370
+ "text": "errorMessage - the error message to display"
1371
+ }]
1372
+ }
1373
+ },
1374
+ "reset": {
1375
+ "complexType": {
1376
+ "signature": "() => Promise<void>",
1377
+ "parameters": [],
1378
+ "references": {
1379
+ "Promise": {
1380
+ "location": "global",
1381
+ "id": "global::Promise"
1382
+ }
1383
+ },
1384
+ "return": "Promise<void>"
1385
+ },
1386
+ "docs": {
1387
+ "text": "Reset value, validity and error state",
1388
+ "tags": []
1389
+ }
1390
+ }
1391
+ };
1392
+ }
1393
+ static get elementRef() { return "element"; }
1394
+ static get watchers() {
1395
+ return [{
1396
+ "propName": "value",
1397
+ "methodName": "watchValue"
1398
+ }, {
1399
+ "propName": "items",
1400
+ "methodName": "watchItems"
1401
+ }, {
1402
+ "propName": "identifier",
1403
+ "methodName": "watchIdentifier"
1404
+ }, {
1405
+ "propName": "readonly",
1406
+ "methodName": "watchReadonly"
1407
+ }, {
1408
+ "propName": "required",
1409
+ "methodName": "watchValidityChange"
1410
+ }, {
1411
+ "propName": "readonly",
1412
+ "methodName": "watchValidityChange"
1413
+ }, {
1414
+ "propName": "disabled",
1415
+ "methodName": "watchValidityChange"
1416
+ }, {
1417
+ "propName": "disabled",
1418
+ "methodName": "watchDisabled"
1419
+ }, {
1420
+ "propName": "mgWidth",
1421
+ "methodName": "watchMgWidth"
1422
+ }, {
1423
+ "propName": "fetchurl",
1424
+ "methodName": "watchFetchUrl"
1425
+ }, {
1426
+ "propName": "fetchoptions",
1427
+ "methodName": "watchFetchOptions"
1428
+ }, {
1429
+ "propName": "fetchmappings",
1430
+ "methodName": "watchFetchMappings"
1431
+ }, {
1432
+ "propName": "options",
1433
+ "methodName": "watchOptions"
1434
+ }, {
1435
+ "propName": "filter",
1436
+ "methodName": "watchFilter"
1437
+ }, {
1438
+ "propName": "popoverDisplay",
1439
+ "methodName": "watchPopoverDisplay"
1440
+ }];
1441
+ }
1442
+ }
1443
+ //# sourceMappingURL=mg-input-combobox.js.map