@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,774 @@
1
+ 'use strict';
2
+
3
+ var index = require('./index-CATFkm3O.js');
4
+ var index_es = require('./index.es-DaPqByCe.js');
5
+ var mgInput_conf = require('./mg-input.conf-WTsvDfpC.js');
6
+ var index$1 = require('./index-CL_COdxv.js');
7
+ var events_utils = require('./events.utils-D5SAtkpQ.js');
8
+
9
+ const mgInputComboboxCss = ".mg-c-input__box{height:var(--mg-b-size-min-height);box-sizing:border-box;padding:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2) var(--mg-b-size-8);border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-c-input-color-border);border-radius:var(--mg-c-input-border-radius);background-color:var(--mg-b-color-light);color:var(--mg-b-color-dark);font-family:inherit;font-size:var(--mg-b-font-size);text-align:var(--mg-c-input-text-align, left)}.mg-c-input__box::placeholder{color:var(--mg-c-input-placeholder-color-text);font-style:italic}.mg-c-input__box:focus{box-shadow:0 0 var(--mg-b-size-4) var(--mg-c-input-color-box-shadow-focus)}.mg-c-input__box:disabled{opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input.mg-c-input--has-error .mg-c-input__box{border-color:var(--mg-b-color-danger)}.mg-c-input.mg-c-input--is-input-group-append{--mg-c-button-border-radius-top-left:0;--mg-c-button-border-radius-bottom-left:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box{margin-right:calc(-1*var(--mg-b-size-border));border-bottom-right-radius:0;border-top-right-radius:0}.mg-c-input.mg-c-input--is-input-group-append .mg-c-input__box:focus-visible{outline-offset:-0.2rem;outline-style:solid;outline-width:.2rem}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-c-button-border-radius-top-right:0;--mg-c-button-border-radius-bottom-right:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-c-button-border-right-width:0}.mg-c-input.mg-c-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-c-button-border-radius-top-right:var(--mg-c-input-border-radius);--mg-c-button-border-radius-bottom-right:var(--mg-c-input-border-radius)}.mg-c-input.mg-c-input--is-append-input-slot-content:not(.mg-c-input--readonly) ::slotted([slot=append-input]){align-self:start;padding-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input.mg-c-input--has-icon .mg-c-input__with-character-left>mg-icon:first-of-type,.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container>mg-icon:first-of-type{position:absolute;top:50%;left:var(--mg-b-size-8);color:var(--mg-c-input-color-icon);transform:translateY(-50%)}.mg-c-input.mg-c-input--has-icon .mg-c-input__with-character-left .mg-c-input__box,.mg-c-input.mg-c-input--has-icon .mg-c-input__input-group-container .mg-c-input__box{padding-left:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2)}.mg-c-input__input-container{width:100%;flex:1 auto}.mg-c-input.mg-c-input--width-full .mg-c-input__box{width:100%}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left,.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left{width:max-content}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:has(textarea),.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:has(textarea){flex-grow:inherit}.mg-c-input.mg-c-input--width-2 .mg-c-input__box{width:var(--mg-b-size-48)}.mg-c-input.mg-c-input--width-2 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-48) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-4 .mg-c-input__box{width:var(--mg-b-size-72)}.mg-c-input.mg-c-input--width-4 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(var(--mg-b-size-72) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-16 .mg-c-input__box{width:calc(26*var(--mg-b-size-8))}.mg-c-input.mg-c-input--width-16 .mg-c-input__with-character-left:not(:has(textarea)) .mg-c-input__box{width:calc(calc(26 * var(--mg-b-size-8)) + var(--mg-c-character-left-message-length)*(.35ch + .3rem))}.mg-c-input.mg-c-input--width-full:not(.mg-c-input--label-on-top){justify-content:stretch}.mg-c-input.mg-c-input--is-input-group-append ::slotted([slot=append-input]),.mg-c-input.mg-c-input--is-append-input-slot-content ::slotted([slot=append-input]){width:auto}:host(.mg-c-input.mg-c-input--width-full) ::slotted(*:not(mg-input-title)){width:100%;max-width:100%}.mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);word-break:break-word}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}.mg-c-input.mg-c-input--combobox mg-popover{--mg-c-popover-padding-vertical:0;--mg-c-popover-padding-horizontal:0}.mg-c-input.mg-c-input--combobox .mg-c-input__input-group-container{position:relative}.mg-c-input.mg-c-input--combobox .mg-c-input__box{cursor:pointer}.mg-c-input.mg-c-input--combobox .mg-c-input__popover-container{display:flex;min-width:var(--mg-c-input-list-width);max-height:calc(50*var(--mg-b-size-8) - var(--mg-b-size-32));flex-direction:column;gap:var(--mg-b-size-4);overflow-y:scroll}.mg-c-input.mg-c-input--combobox .mg-c-input__popover-info{padding:var(--mg-b-size-8);margin:0;text-align:center}.mg-c-input.mg-c-input--combobox .mg-c-input__load-more{padding:0 var(--mg-b-size-8) var(--mg-b-size-4)}.mg-c-input.mg-c-input--combobox .mg-c-input__reset{padding-right:var(--mg-b-size-min-height)}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list{padding:0;margin:0;cursor:pointer;list-style:none}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item{display:flex;padding:var(--mg-b-size-8)}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item:hover,.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item.mg-c-input__input-list-item--focus-visible{background-color:var(--mg-b-color-neutral-20)}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item.mg-c-input__input-list-item--selected{font-weight:700}.mg-c-input.mg-c-input--combobox .mg-c-input__input-list-item.mg-c-input__input-list-item--selected mg-icon{margin-left:auto}.mg-c-input.mg-c-input--combobox.mg-c-input--width-2 .mg-c-input__box{width:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2 + var(--mg-b-size-24) + var(--mg-b-size-min-height)*2 + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-4 .mg-c-input__box{width:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2 + var(--mg-b-size-48) + var(--mg-b-size-min-height)*2 + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-16 .mg-c-input__box{width:calc(var(--mg-b-size-16) + var(--mg-b-size-8)*2 + calc(23 * var(--mg-b-size-8)) + var(--mg-b-size-min-height)*2 + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-full mg-popover{--mg-c-popover-max-width:var(--mg-c-input-list-width, var(--mg-c-popover-max-width))}.mg-c-input.mg-c-input--combobox.mg-c-input--width-full .mg-c-input__input-group-container{display:flex;width:100%}.mg-c-input.mg-c-input--combobox.mg-c-input--width-full .mg-c-input__box{flex:1}.mg-c-input.mg-c-input--combobox.mg-c-input--input-append .mg-c-input__box{padding-right:calc(var(--mg-b-size-min-height)*var(--mg-c-input-append-x) + var(--mg-b-size-4))}.mg-c-input.mg-c-input--combobox.mg-c-input--input-append .mg-c-input__box-append{position:absolute;top:0;right:0}";
10
+
11
+ /**
12
+ * Check if object is an item
13
+ * @param item - object to check
14
+ * @returns True if object is an item
15
+ */
16
+ const isItem = (item) => item && typeof item === 'object' && typeof item.title === 'string' && item.value !== undefined;
17
+ /**
18
+ * Check if objects are items
19
+ * @param items - items to check
20
+ * @returns True if objects are items
21
+ */
22
+ const isItems = (items) => Array.isArray(items) && items.every(isItem);
23
+ /**
24
+ * Check if object is valid combobox fetchmappings
25
+ * @param value - to validate
26
+ * @returns truthy if mapping is valid
27
+ */
28
+ const isFetchmappings = (value) => {
29
+ const isValidRoot = index_es.ne(value) && Object.hasOwn(value, 'request') && Object.hasOwn(value, 'response');
30
+ if (isValidRoot) {
31
+ const { request, response } = value;
32
+ if ([request, response].some(property => !index_es.ne(property)))
33
+ return false;
34
+ const isValidRequest = typeof request.filter === 'string';
35
+ const isValidResponse = typeof response === 'object' &&
36
+ typeof response.total === 'string' &&
37
+ typeof response.items === 'string' &&
38
+ typeof response.next === 'string' &&
39
+ typeof response.itemTitle === 'string' &&
40
+ typeof response.itemValue === 'string';
41
+ return isValidRequest && isValidResponse;
42
+ }
43
+ else {
44
+ return isValidRoot;
45
+ }
46
+ };
47
+ /**
48
+ * Map new URL from old url
49
+ * @param newValue - new URL value
50
+ * @param oldValue - previous URL value
51
+ * @returns updated url
52
+ */
53
+ const mapUrl = (newValue, oldValue) => {
54
+ if (!Boolean(newValue))
55
+ return;
56
+ else if (URL.canParse(newValue)) {
57
+ return newValue;
58
+ }
59
+ // build new URL
60
+ const params = newValue.includes('?') && newValue.split('?').pop();
61
+ if (Boolean(params)) {
62
+ const { origin, pathname } = new URL(oldValue);
63
+ return `${origin}${pathname}?${params}`;
64
+ }
65
+ else {
66
+ return newValue;
67
+ }
68
+ };
69
+ const MgInputCombobox = class {
70
+ constructor(hostRef) {
71
+ index.registerInstance(this, hostRef);
72
+ this.valueChange = index.createEvent(this, "value-change");
73
+ this.filterChange = index.createEvent(this, "filter-change");
74
+ this.loadMore = index.createEvent(this, "load-more");
75
+ this.inputValid = index.createEvent(this, "input-valid");
76
+ /************
77
+ * Internal *
78
+ ************/
79
+ // Classes
80
+ this.classFocus = 'mg-u-is-focused';
81
+ // hasDisplayedError (triggered by blur event)
82
+ this.hasDisplayedError = false;
83
+ /**
84
+ * Input name
85
+ * If not set the value equals the identifier
86
+ */
87
+ this.name = this.identifier;
88
+ /**
89
+ * Define if label is displayed on top
90
+ */
91
+ this.labelOnTop = false;
92
+ /**
93
+ * Define if label is visible
94
+ */
95
+ this.labelHide = false;
96
+ /**
97
+ * Define if input is required
98
+ */
99
+ this.required = false;
100
+ /**
101
+ * Define if input is readonly
102
+ */
103
+ this.readonly = false;
104
+ /**
105
+ * Define if input is disabled
106
+ */
107
+ this.disabled = false;
108
+ /**
109
+ * Define input width
110
+ */
111
+ this.mgWidth = 'full';
112
+ /**
113
+ * Define tooltip position
114
+ */
115
+ this.tooltipPosition = 'input';
116
+ /**
117
+ * Formated items for display
118
+ */
119
+ this.options = new index_es.er([]);
120
+ /**
121
+ * Option filter
122
+ */
123
+ this.filter = '';
124
+ /**
125
+ * Component classes
126
+ */
127
+ this.classCollection = new index_es.Ht(['mg-c-input--combobox', 'mg-c-input--has-icon', 'mg-c-input--input-append']);
128
+ /**
129
+ * Popover display state
130
+ */
131
+ this.popoverDisplay = false;
132
+ /**
133
+ * Handle `click` event on option
134
+ * @param event - option element click event
135
+ */
136
+ this.handleOptionClick = (event) => {
137
+ this.setValue(this.options.items.find(option => option.value === event.target.id));
138
+ this.popoverDisplay = false;
139
+ };
140
+ /**
141
+ * Handle `click` event on reset button
142
+ * @param event - click event
143
+ */
144
+ this.handleResetButton = (event) => {
145
+ event.stopPropagation();
146
+ this.reset().then(() => {
147
+ this.input.focus();
148
+ });
149
+ };
150
+ /**
151
+ * Handle `display-change` event on mg-popover
152
+ */
153
+ this.handlePopoverDisplay = (event) => {
154
+ this.popoverDisplay = event.detail;
155
+ };
156
+ /**
157
+ * Handle input event
158
+ */
159
+ this.handleFilterInput = () => {
160
+ this.checkValidity();
161
+ if (this.hasDisplayedError)
162
+ this.setErrorMessage();
163
+ if (!this.popoverDisplay)
164
+ this.popoverDisplay = true;
165
+ this.filter = this.input.value;
166
+ };
167
+ /**
168
+ * Handle `blur` event
169
+ */
170
+ this.handleFilterBlur = () => {
171
+ // skip process if popover is displayed
172
+ if (this.popoverDisplay)
173
+ return;
174
+ // Display Error
175
+ this.handlerInProgress = 'blur';
176
+ this.displayError().finally(() => {
177
+ // reset guard
178
+ this.handlerInProgress = undefined;
179
+ });
180
+ };
181
+ /**
182
+ * Handle `focus` event
183
+ */
184
+ this.handleFilterFocus = () => {
185
+ // ensure visual focus is always clear on focus when component isn't in loading state
186
+ if (!this.isLoading) {
187
+ this.option = null;
188
+ }
189
+ };
190
+ /**
191
+ * Handle load-more <mg-button> `click`
192
+ */
193
+ this.handleLoadMoreButton = () => {
194
+ this.loadingWrapper({ name: 'load-more', cursor: index_es.Vt.NEXT }).then(() => {
195
+ this.input.focus();
196
+ });
197
+ };
198
+ /**
199
+ * Handle `keypress` event
200
+ * @param event - keyboard event
201
+ */
202
+ this.handleFilterKeydown = (event) => {
203
+ if (this.disabled || event.ctrlKey || event.shiftKey)
204
+ return;
205
+ let guard = false;
206
+ // override keys actions
207
+ switch (event.key) {
208
+ case events_utils.Keys.TAB:
209
+ case events_utils.Keys.ENTER:
210
+ guard = event.key === events_utils.Keys.ENTER;
211
+ const option = this.option || this.options.items.find(this.isCurrentOption);
212
+ // Sets the value to the content of the focused option in the listbox.
213
+ if (this.popoverDisplay)
214
+ this.setValue(this.page.total > 0 ? option : null);
215
+ // Closes the popover.
216
+ this.popoverDisplay = false;
217
+ break;
218
+ case events_utils.Keys.DOWN:
219
+ case events_utils.Keys.ARROWDOWN:
220
+ case events_utils.Keys.UP:
221
+ case events_utils.Keys.ARROWUP:
222
+ guard = true;
223
+ if (this.isLoading || !(this.page.total > 0)) {
224
+ this.popoverDisplay = true;
225
+ break;
226
+ }
227
+ if (Boolean(event.altKey) && [events_utils.Keys.DOWN, events_utils.Keys.ARROWDOWN].includes(event.key)) {
228
+ // Opens the popover without moving focus or changing selection.
229
+ this.popoverDisplay = true;
230
+ break;
231
+ }
232
+ // define cursor
233
+ let cursor;
234
+ const isNavigationStart = this.popoverDisplay && isItem(this.option);
235
+ if ([events_utils.Keys.DOWN, events_utils.Keys.ARROWDOWN].includes(event.key)) {
236
+ // If the filter is not empty and the popover is displayed, moves visual focus to the first suggested value.
237
+ // If the filter is empty and the popover is not displayed, opens the popover and moves visual focus to the first option.
238
+ // Moves visual focus to the next option.
239
+ // If visual focus is on the last option, moves visual focus to the first option.
240
+ cursor = isNavigationStart ? index_es.Vt.NEXT : index_es.Vt.FIRST;
241
+ }
242
+ else if ([events_utils.Keys.UP, events_utils.Keys.ARROWUP].includes(event.key)) {
243
+ // If the filter is not empty and the popover is displayed, moves visual focus to the last suggested value.
244
+ // If the filter is empty, first opens the popover if it is not already displayed and then moves visual focus to the last option.
245
+ // Moves visual focus to the previous option.
246
+ // If visual focus is on the first option, moves visual focus to the last option.
247
+ cursor = isNavigationStart ? index_es.Vt.PREVIOUS : index_es.Vt.LAST;
248
+ }
249
+ // update scroll and visual focused option in wrapper
250
+ this.loadingWrapper({ name: 'scroll', cursor });
251
+ // open popover
252
+ this.popoverDisplay = true;
253
+ break;
254
+ case events_utils.Keys.LEFT:
255
+ case events_utils.Keys.ARROWLEFT:
256
+ case events_utils.Keys.HOME:
257
+ case events_utils.Keys.RIGHT:
258
+ case events_utils.Keys.ARROWRIGHT:
259
+ case events_utils.Keys.END:
260
+ // skip process if visual focus is not in popover
261
+ if (!isItem(this.option))
262
+ break;
263
+ guard = true;
264
+ // Remove visual focus from popover options
265
+ this.option = null;
266
+ let index;
267
+ if (events_utils.Keys.HOME === event.key) {
268
+ // Moves visual focus to the textbox and places the editing cursor at the beginning of the field.
269
+ index = 0;
270
+ }
271
+ else if (events_utils.Keys.END === event.key) {
272
+ // Moves visual focus to the textbox and places the editing cursor at the end of the field.
273
+ index = this.filter.length;
274
+ }
275
+ if (typeof index === 'number') {
276
+ this.input.setSelectionRange(index, index);
277
+ }
278
+ break;
279
+ case events_utils.Keys.ESC:
280
+ case events_utils.Keys.ESCAPE:
281
+ guard = true;
282
+ if (this.popoverDisplay) {
283
+ // If the popover is displayed, closes it.
284
+ this.popoverDisplay = false;
285
+ }
286
+ else {
287
+ // If the popover is not displayed, clears the filter.
288
+ this.setValue(null);
289
+ this.filter = '';
290
+ // Sets visual focus on the textbox.
291
+ this.option = null;
292
+ }
293
+ break;
294
+ default:
295
+ // Remove visual focus from popover options
296
+ this.option = null;
297
+ break;
298
+ }
299
+ if (guard) {
300
+ event.stopPropagation();
301
+ event.preventDefault();
302
+ }
303
+ };
304
+ /**
305
+ * Scroll to next option from cursor
306
+ * @param index - targeted option index to scroll into
307
+ */
308
+ this.scrollToIndex = (index) => {
309
+ var _a;
310
+ (_a = this.element.shadowRoot.querySelector(`li:nth-of-type(${(index || 0) + this.page.baseIndex})`)) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
311
+ };
312
+ /**
313
+ * Is option the current value
314
+ * @param option - option to match with
315
+ * @returns true if option is the current value
316
+ */
317
+ this.isCurrentOption = (option) => (isItem(this.value) ? this.value.value : this.value) === option.value;
318
+ /**
319
+ * get value prop title
320
+ * @returns value title
321
+ */
322
+ this.getValueTitle = () => {
323
+ if (this.value && isItem(this.value))
324
+ return this.value.title;
325
+ else if (typeof this.value === 'string')
326
+ return this.value;
327
+ else
328
+ return '';
329
+ };
330
+ /**
331
+ * Check if input is valid
332
+ */
333
+ this.checkValidity = () => {
334
+ this.setValidity(this.readonly || this.disabled || this.input.checkValidity());
335
+ };
336
+ /**
337
+ * Set input error message
338
+ * @param errorMessage - errorMessage override
339
+ */
340
+ this.setErrorMessage = (errorMessage) => {
341
+ // Set error message
342
+ this.errorMessage = undefined;
343
+ // Does have a custom error message
344
+ if (!this.valid && errorMessage !== undefined) {
345
+ this.errorMessage = errorMessage;
346
+ }
347
+ // required
348
+ else if (!this.valid && this.input.validity.valueMissing) {
349
+ this.errorMessage = this.messages.errors.required;
350
+ }
351
+ };
352
+ /**
353
+ * Get filtered options from `filter` input value
354
+ * @returns filtered options
355
+ */
356
+ this.optionsFilter = (option) => (this.filter === '' ? true : option.title.toLocaleLowerCase().includes(this.filter.toLocaleLowerCase()));
357
+ /**
358
+ * Loading wrapper with a given action
359
+ * @param action - wrapped loading action
360
+ * @returns promisified action
361
+ */
362
+ this.loadingWrapper = (action) => {
363
+ let promise;
364
+ let index;
365
+ // cache initial loading action if not defined
366
+ if (!Boolean(this.loadingAction)) {
367
+ this.loadingAction = action.name;
368
+ }
369
+ // update index
370
+ if (Boolean(this.option) && this.loadingAction !== 'load-more') {
371
+ index = this.page.items.findIndex(option => option.value.toString() === this.option.value.toString());
372
+ }
373
+ else if (this.loadingAction === 'load-more') {
374
+ index = this.page.items.length - this.page.baseIndex;
375
+ }
376
+ // when action require a loadMore we fetch the API else we report action to next tick
377
+ // Set "load more" if action match OR if next item not available in the current page
378
+ if (action.name === 'load-more') {
379
+ // wait for new element render and update scroll position
380
+ // set component loading
381
+ this.isLoading = true;
382
+ promise = this.goToNextPage;
383
+ }
384
+ else if (action.cursor === index_es.Vt.NEXT &&
385
+ this.page.items.length <= this.page.total &&
386
+ index + this.page.baseIndex === this.page.items.length &&
387
+ index + this.page.baseIndex < this.page.total) {
388
+ // trigger load-more from button to benefit from `disabled-on-click`
389
+ this.loadMoreElement.click();
390
+ return;
391
+ }
392
+ else if (action.name === 'scroll') {
393
+ promise = index_es.Qt;
394
+ }
395
+ else {
396
+ promise = this.updatePage;
397
+ }
398
+ return promise()
399
+ .then(() => {
400
+ // parse full items list from options
401
+ const options = this.options.items.filter(this.optionsFilter);
402
+ // update visual focus
403
+ if (action.name !== 'load-data') {
404
+ index = this.page.getIndexFromCursor(action.cursor, this.loadingAction === 'load-more' && index >= 0 ? options[index] : this.option);
405
+ }
406
+ this.option = options[index];
407
+ // update scroll position
408
+ this.scrollToIndex(index);
409
+ })
410
+ .finally(() => {
411
+ // reset loading after next render
412
+ requestAnimationFrame(() => {
413
+ this.isLoading = false;
414
+ this.loadingAction = undefined;
415
+ });
416
+ });
417
+ };
418
+ /**
419
+ * Go to next page
420
+ * @returns promise
421
+ */
422
+ this.goToNextPage = () => {
423
+ this.loadMore.emit();
424
+ if (Boolean(this.fetchurl)) {
425
+ return this.getOptions(typeof this.page.next === 'string' ? this.page.next : undefined).then(nextPage => {
426
+ if (!Boolean(nextPage))
427
+ return;
428
+ // merge items from current page and next page
429
+ const items = [...this.page.items, ...nextPage.items];
430
+ // create new options pagination withe merged items
431
+ this.options = new index_es.er(items, { total: nextPage.total, next: nextPage.next, top: items.length });
432
+ });
433
+ }
434
+ else {
435
+ return index_es.Qt(() => {
436
+ if (typeof this.page.next === 'function') {
437
+ const nextPage = this.page.next();
438
+ this.page = new index_es.Ge(Object.assign(Object.assign({}, nextPage), { items: [...this.page.items, ...nextPage.items] }));
439
+ }
440
+ });
441
+ }
442
+ };
443
+ /**
444
+ * Go to next page
445
+ * @returns promise
446
+ */
447
+ this.updatePage = async () => {
448
+ if (Boolean(this.fetchurl)) {
449
+ return this.getOptions().then(page => {
450
+ if (!Boolean(page))
451
+ return;
452
+ // reset current options pagination from API response
453
+ this.options = new index_es.er(page.items, { total: page.total, next: page.next, top: page.top });
454
+ });
455
+ }
456
+ else {
457
+ this.page = this.options.getPage(0, this.optionsFilter);
458
+ }
459
+ };
460
+ /**
461
+ * Fetch request
462
+ * @param url - to fetch
463
+ * @returns new page from url
464
+ */
465
+ this.getOptions = async (url = this.fetchurl) => {
466
+ // add text filter
467
+ const updateUrl = (typeof url === 'string' ? url : url.toString()).replaceAll(this.fetchmappings.request.filter, encodeURIComponent(this.filter));
468
+ try {
469
+ const response = await fetch(updateUrl, this.fetchoptions).then(response => response.json());
470
+ if (!response)
471
+ return null;
472
+ const items = index_es.Be(response, this.fetchmappings.response.items).map((item) => ({
473
+ title: index_es.Be(item, this.fetchmappings.response.itemTitle),
474
+ value: index_es.Be(item, this.fetchmappings.response.itemValue),
475
+ }));
476
+ const total = Number(index_es.Be(response, this.fetchmappings.response.total, 0));
477
+ const next = mapUrl(index_es.Be(response, this.fetchmappings.response.next), this.fetchurl.toString());
478
+ return { items, total, next, top: items.length };
479
+ }
480
+ catch (_a) { }
481
+ };
482
+ }
483
+ watchValue(newValue) {
484
+ this.filter = this.getValueTitle();
485
+ this.valueChange.emit(newValue);
486
+ }
487
+ watchItems(newValue) {
488
+ if (Boolean(this.fetchurl) && !Boolean(newValue)) {
489
+ // skip newValue check
490
+ return;
491
+ }
492
+ else if (Boolean(this.fetchurl) && Boolean(newValue)) {
493
+ throw new Error(`<mg-input-combobox> prop "items" values cannot be use with "fetchurl" prop defined. Passed value: ${index_es.Xt(newValue)}.`);
494
+ }
495
+ // Empty options
496
+ else if (Array.isArray(newValue) && newValue.length === 0) {
497
+ this.options = new index_es.er([]);
498
+ }
499
+ // String array
500
+ else if (index_es.qt(newValue)) {
501
+ this.options = new index_es.er(newValue.map(item => ({ title: item, value: item })), { total: newValue.length });
502
+ }
503
+ // Object array
504
+ else if (isItems(newValue)) {
505
+ this.options = new index_es.er(newValue, { total: newValue.length });
506
+ }
507
+ else {
508
+ throw new Error(`<mg-input-combobox> prop "items" values must be the same type, string or Option. Passed value: ${index_es.Xt(newValue)}.`);
509
+ }
510
+ }
511
+ watchIdentifier(newValue) {
512
+ if (Boolean(newValue)) {
513
+ this.popoverId = `${newValue}-popover`;
514
+ this.element.dataset.mgPopoverGuard = this.popoverId;
515
+ }
516
+ }
517
+ watchReadonly(newValue) {
518
+ if (newValue)
519
+ this.classCollection.add(mgInput_conf.classReadonly);
520
+ else
521
+ this.classCollection.delete(mgInput_conf.classReadonly);
522
+ }
523
+ watchValidityChange(newValue, _oldValue, prop) {
524
+ if (this.input === undefined)
525
+ return;
526
+ this.input[prop] = newValue;
527
+ this.checkValidity();
528
+ if (this.hasDisplayedError) {
529
+ this.setErrorMessage();
530
+ this.hasDisplayedError = false;
531
+ }
532
+ }
533
+ watchDisabled(newValue) {
534
+ if (newValue) {
535
+ this.classCollection.add(mgInput_conf.classDisabled);
536
+ }
537
+ else {
538
+ this.classCollection.delete(mgInput_conf.classDisabled);
539
+ }
540
+ }
541
+ watchMgWidth(newValue) {
542
+ // reset width class
543
+ mgInput_conf.widths.forEach(width => {
544
+ this.classCollection.delete(`mg-c-input--width-${width}`);
545
+ });
546
+ // apply new width
547
+ if (newValue !== undefined)
548
+ this.classCollection.add(`mg-c-input--width-${this.mgWidth}`);
549
+ this.classCollection = new index_es.Ht(this.classCollection.classes);
550
+ }
551
+ watchFetchUrl(newValue) {
552
+ if (newValue && !URL.canParse(newValue)) {
553
+ throw new Error(`<mg-input-combobox> prop "fetchurl" value must be URL or string. Passed value: ${index_es.Xt(newValue)}.`);
554
+ }
555
+ }
556
+ watchFetchOptions(newValue) {
557
+ if (this.fetchurl && newValue && !index_es.ne(newValue)) {
558
+ throw new Error(`<mg-input-combobox> prop "fetchoptions" value must be a valid RequestInit. Passed value: ${index_es.Xt(newValue)}.`);
559
+ }
560
+ else {
561
+ new Request(this.fetchurl, newValue);
562
+ }
563
+ }
564
+ watchFetchMappings(newValue) {
565
+ if (Boolean(this.fetchurl) && !Boolean(newValue)) {
566
+ throw new Error(`<mg-input-combobox> prop "fetchmappings" is required with "fetchurl" prop.`);
567
+ }
568
+ else if (Boolean(newValue) && !isFetchmappings(newValue)) {
569
+ throw new Error(`<mg-input-combobox> prop "fetchmappings" value must be { request: RequestMappingType, response: ResponseMappingType }. Passed value: ${index_es.Xt(newValue)}.`);
570
+ }
571
+ }
572
+ watchOptions(newValue) {
573
+ this.page = newValue.getPage(0, Boolean(this.filter) ? this.optionsFilter : undefined);
574
+ }
575
+ watchFilter(newValue) {
576
+ this.loadingWrapper({ name: 'load-data' });
577
+ this.filterChange.emit(newValue);
578
+ }
579
+ watchPopoverDisplay(newValue) {
580
+ if (newValue) {
581
+ this.classCollection.add(this.classFocus);
582
+ this.input.focus();
583
+ this.scrollToIndex(0);
584
+ }
585
+ else {
586
+ // remove visual focus
587
+ this.option = null;
588
+ // reset filter with value
589
+ this.filter = this.getValueTitle();
590
+ this.classCollection.delete(this.classFocus);
591
+ this.handlerInProgress = 'blur';
592
+ this.displayError().finally(() => {
593
+ // reset guard
594
+ this.handlerInProgress = undefined;
595
+ });
596
+ }
597
+ }
598
+ /**
599
+ * Public method to play input focus
600
+ */
601
+ async setFocus() {
602
+ this.input.focus();
603
+ }
604
+ /**
605
+ * Display input error if it exists.
606
+ */
607
+ displayError() {
608
+ // Use `Promise` as requested for stencil method
609
+ // Use `requestAnimationFrame` to ensure:
610
+ // - DOM is fully updated before validation
611
+ // - Async operations are completed
612
+ // - No timing issues with Stencil's render cycle
613
+ // - Keep everything in sync both inside and outside the component
614
+ return new Promise(resolve => {
615
+ requestAnimationFrame(() => {
616
+ this.checkValidity();
617
+ this.setErrorMessage();
618
+ this.hasDisplayedError = this.invalid;
619
+ resolve();
620
+ });
621
+ });
622
+ }
623
+ /**
624
+ * Set an error and display a custom error message.
625
+ * This method can be used to set the component's error state from its concombobox by passing a boolean value to the `valid` parameter.
626
+ * It must be paired with an error message to display for the given concombobox.
627
+ * When used to set validity to `false`, you should use this method again to reset the validity to `true`.
628
+ * @param valid - value indicating the validity
629
+ * @param errorMessage - the error message to display
630
+ */
631
+ async setError(valid, errorMessage) {
632
+ if (typeof valid !== 'boolean') {
633
+ throw new Error('<mg-input-combobox> method "setError()" param "valid" must be a boolean.');
634
+ }
635
+ else if (!index_es.qe(errorMessage)) {
636
+ throw new Error('<mg-input-combobox> method "setError()" param "errorMessage" must be a string.');
637
+ }
638
+ else {
639
+ this.setValidity(valid);
640
+ this.setErrorMessage(valid ? undefined : errorMessage);
641
+ this.hasDisplayedError = this.invalid;
642
+ }
643
+ }
644
+ /**
645
+ * Reset value, validity and error state
646
+ */
647
+ async reset() {
648
+ if (this.readonly)
649
+ return;
650
+ this.setValue(null);
651
+ this.option = null;
652
+ this.filter = '';
653
+ this.checkValidity();
654
+ this.errorMessage = undefined;
655
+ this.hasDisplayedError = false;
656
+ }
657
+ /**
658
+ * Set value prop
659
+ * @param newValue - slected option item
660
+ */
661
+ setValue(newValue) {
662
+ if (!isItem(newValue)) {
663
+ this.value = '';
664
+ }
665
+ else {
666
+ this.value = index_es.qt(this.items || this.options.items) ? newValue.title : Object.assign({}, newValue);
667
+ }
668
+ }
669
+ /**
670
+ * Method to set validity values
671
+ * @param newValue - valid new value
672
+ */
673
+ setValidity(newValue) {
674
+ const oldValidValue = this.valid;
675
+ this.valid = newValue;
676
+ this.invalid = !this.valid;
677
+ // We need to send valid event even if it is the same value
678
+ if (this.handlerInProgress === undefined || (this.handlerInProgress === 'blur' && this.valid !== oldValidValue))
679
+ this.inputValid.emit(this.valid);
680
+ }
681
+ /*************
682
+ * Lifecycle *
683
+ *************/
684
+ /**
685
+ * Check if component props are well configured on init
686
+ * @returns timeout
687
+ */
688
+ componentWillLoad() {
689
+ // Get locales
690
+ this.messages = index$1.initLocales(this.element).messages;
691
+ // Validate
692
+ this.watchIdentifier(this.identifier);
693
+ this.watchItems(this.items);
694
+ if (Boolean(this.fetchurl)) {
695
+ this.watchFetchUrl(this.fetchurl);
696
+ this.watchFetchOptions(this.fetchoptions);
697
+ this.watchFetchMappings(this.fetchmappings);
698
+ this.loadingWrapper({ name: 'load-data' });
699
+ }
700
+ this.watchValue(this.value);
701
+ this.watchOptions(this.options);
702
+ this.watchMgWidth(this.mgWidth);
703
+ this.watchReadonly(this.readonly);
704
+ this.watchDisabled(this.disabled);
705
+ // Check validity when component is ready
706
+ // return a promise to process action only in the FIRST render().
707
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
708
+ return setTimeout(() => {
709
+ this.checkValidity();
710
+ }, 0);
711
+ }
712
+ /**
713
+ * Render
714
+ * @returns HTML Element
715
+ */
716
+ render() {
717
+ var _a, _b, _c, _d, _e, _f;
718
+ const listId = `${this.identifier}-list`;
719
+ const readonlyValue = this.getValueTitle();
720
+ const withResetButton = this.value && !this.disabled;
721
+ let popoverContent;
722
+ if (((_a = this.page) === null || _a === void 0 ? void 0 : _a.items.length) > 0)
723
+ popoverContent = 'list';
724
+ else if (((_b = this.page) === null || _b === void 0 ? void 0 : _b.items.length) === 0 && Boolean(this.filter))
725
+ popoverContent = 'notfound';
726
+ else if (((_c = this.page) === null || _c === void 0 ? void 0 : _c.items.length) === 0)
727
+ popoverContent = 'notavailable';
728
+ return (index.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 && index.h("b", { class: "mg-c-input__readonly-value" }, readonlyValue)) : (index.h("mg-popover", { identifier: this.popoverId, placement: "bottom-start", display: this.popoverDisplay, "arrow-hide": true, style: {
729
+ '--mg-c-input-list-width': Boolean((_d = this.input) === null || _d === void 0 ? void 0 : _d.offsetWidth) ? `${this.input.offsetWidth}px` : undefined,
730
+ '--mg-c-input-append-x': withResetButton ? '2' : '1',
731
+ }, "data-fallback-placement": "bottom-end", "onDisplay-change": this.handlePopoverDisplay }, index.h("div", { class: "mg-c-input__input-group-container" }, index.h("mg-icon", { icon: "magnifying-glass" }), index.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) => {
732
+ if (el !== null)
733
+ this.input = el;
734
+ } }), withResetButton && (index.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 }, index.h("mg-icon", { icon: "cross" }))), index.h("mg-button", { class: "mg-c-input__box-append", variant: "flat", "is-icon": true, label: this.itemsLabel, tabindex: "-1", disabled: this.disabled }, index.h("mg-icon", { icon: `chevron-${this.popoverDisplay ? 'up' : 'down'}` }))), index.h("div", { slot: "content", class: "mg-c-input__popover-container" }, popoverContent === 'list' && [
735
+ // eslint-disable-next-line jsx-a11y/role-supports-aria-props
736
+ index.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 => {
737
+ return (
738
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events
739
+ index.h("li", { role: "option", class: {
740
+ 'mg-c-input__input-list-item': true,
741
+ 'mg-c-input__input-list-item--focus-visible': this.option === option,
742
+ 'mg-c-input__input-list-item--selected': this.isCurrentOption(option),
743
+ }, key: option.title, id: option.value.toString(), "aria-selected": this.isCurrentOption(option).toString(), onClick: this.handleOptionClick }, option.title, this.isCurrentOption(option) && index.h("mg-icon", { icon: "check" })));
744
+ })),
745
+ this.isLoading && index.h("mg-loader", { key: "loader", message: this.messages.input.combobox.search, class: { 'mg-u-visually-hidden': Boolean(this.page.next) } }),
746
+ this.page.next && (index.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) => {
747
+ if (el !== null)
748
+ this.loadMoreElement = el;
749
+ } }, index.h("mg-icon", { icon: "chevron-down" }), this.messages.input.combobox.loadMore)),
750
+ ], popoverContent === 'notfound' && (index.h("p", { id: popoverContent, class: "mg-c-input__popover-info" }, this.messages.input.combobox.notFound)), popoverContent === 'notavailable' && (index.h("p", { id: popoverContent, class: "mg-c-input__popover-info" }, this.messages.input.combobox.notAvailable)))))));
751
+ }
752
+ get element() { return index.getElement(this); }
753
+ static get watchers() { return {
754
+ "value": ["watchValue"],
755
+ "items": ["watchItems"],
756
+ "identifier": ["watchIdentifier"],
757
+ "readonly": ["watchReadonly", "watchValidityChange"],
758
+ "required": ["watchValidityChange"],
759
+ "disabled": ["watchValidityChange", "watchDisabled"],
760
+ "mgWidth": ["watchMgWidth"],
761
+ "fetchurl": ["watchFetchUrl"],
762
+ "fetchoptions": ["watchFetchOptions"],
763
+ "fetchmappings": ["watchFetchMappings"],
764
+ "options": ["watchOptions"],
765
+ "filter": ["watchFilter"],
766
+ "popoverDisplay": ["watchPopoverDisplay"]
767
+ }; }
768
+ };
769
+ MgInputCombobox.style = mgInputComboboxCss;
770
+
771
+ exports.mg_input_combobox = MgInputCombobox;
772
+ //# sourceMappingURL=mg-input-combobox.entry.cjs.js.map
773
+
774
+ //# sourceMappingURL=mg-input-combobox.cjs.entry.js.map