@mgdis/mg-components 5.27.0 → 5.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/dist/cjs/{index-1d560837.js → index-00072168.js} +46 -46
  2. package/dist/cjs/index-00072168.js.map +1 -0
  3. package/dist/cjs/{index-7072369e.js → index-7e27c7ae.js} +34 -10
  4. package/dist/cjs/index-7e27c7ae.js.map +1 -0
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/{mg-action-more_35.cjs.entry.js → mg-action-more_36.cjs.entry.js} +513 -179
  7. package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -0
  8. package/dist/cjs/mg-components.cjs.js +3 -3
  9. package/dist/cjs/mg-components.cjs.js.map +1 -1
  10. package/dist/cjs/mg-loader.cjs.entry.js +4 -4
  11. package/dist/collection/collection-manifest.json +2 -2
  12. package/dist/collection/components/atoms/mg-button/mg-button.js +4 -1
  13. package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
  14. package/dist/collection/components/atoms/mg-card/mg-card.js +4 -1
  15. package/dist/collection/components/atoms/mg-card/mg-card.js.map +1 -1
  16. package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +1 -1
  17. package/dist/collection/components/atoms/mg-divider/mg-divider.js +1 -1
  18. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +4 -1
  19. package/dist/collection/components/atoms/mg-input-title/mg-input-title.js.map +1 -1
  20. package/dist/collection/components/atoms/mg-tag/mg-tag.js +4 -1
  21. package/dist/collection/components/atoms/mg-tag/mg-tag.js.map +1 -1
  22. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js +4 -1
  23. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.js.map +1 -1
  24. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +1 -0
  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 +13 -3
  27. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
  28. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +7 -1
  29. package/dist/collection/components/molecules/inputs/mg-input/mg-input.js.map +1 -1
  30. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +2 -2
  31. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
  32. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +1 -1
  33. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +1 -0
  34. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js.map +1 -1
  35. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +42 -11
  36. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
  37. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +6 -3
  38. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
  39. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +2 -2
  40. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js.map +1 -1
  41. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +1 -1
  42. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +2 -2
  43. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js.map +1 -1
  44. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +12 -3
  45. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
  46. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +2 -2
  47. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js.map +1 -1
  48. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +5 -1
  49. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js.map +1 -1
  50. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +24 -22
  51. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
  52. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +34 -3
  53. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
  54. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +3 -3
  55. package/dist/collection/components/molecules/mg-action-more/mg-action-more.js.map +1 -1
  56. package/dist/collection/components/molecules/mg-details/mg-details.js +5 -1
  57. package/dist/collection/components/molecules/mg-details/mg-details.js.map +1 -1
  58. package/dist/collection/components/molecules/mg-form/mg-form.js +5 -1
  59. package/dist/collection/components/molecules/mg-form/mg-form.js.map +1 -1
  60. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +8 -3
  61. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js.map +1 -1
  62. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +10 -4
  63. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +1 -1
  64. package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
  65. package/dist/collection/components/molecules/mg-message/mg-message.js +5 -1
  66. package/dist/collection/components/molecules/mg-message/mg-message.js.map +1 -1
  67. package/dist/collection/components/molecules/mg-modal/mg-modal.js +6 -2
  68. package/dist/collection/components/molecules/mg-modal/mg-modal.js.map +1 -1
  69. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +3 -3
  70. package/dist/collection/components/molecules/mg-pagination/mg-pagination.js.map +1 -1
  71. package/dist/collection/components/molecules/mg-panel/mg-panel.js +5 -1
  72. package/dist/collection/components/molecules/mg-panel/mg-panel.js.map +1 -1
  73. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +4 -1
  74. package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js.map +1 -1
  75. package/dist/collection/components/molecules/mg-popover/mg-popover.js +5 -1
  76. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  77. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
  78. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +4 -1
  79. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js.map +1 -1
  80. package/dist/components/index.es.js +42 -42
  81. package/dist/components/index.es.js.map +1 -1
  82. package/dist/components/index2.js +2 -2
  83. package/dist/components/mg-action-more.js +20 -16
  84. package/dist/components/mg-action-more.js.map +1 -1
  85. package/dist/components/mg-badge2.js +3 -3
  86. package/dist/components/mg-button2.js +5 -5
  87. package/dist/components/mg-button2.js.map +1 -1
  88. package/dist/components/mg-card2.js +3 -3
  89. package/dist/components/mg-card2.js.map +1 -1
  90. package/dist/components/mg-character-left2.js +1 -1
  91. package/dist/components/mg-details.js +3 -3
  92. package/dist/components/mg-details.js.map +1 -1
  93. package/dist/components/mg-divider.js +1 -1
  94. package/dist/components/mg-form.js +4 -4
  95. package/dist/components/mg-form.js.map +1 -1
  96. package/dist/components/mg-icon2.js +2 -2
  97. package/dist/components/mg-illustrated-message.js +5 -5
  98. package/dist/components/mg-illustrated-message.js.map +1 -1
  99. package/dist/components/mg-input-checkbox-paginated2.js +2 -2
  100. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
  101. package/dist/components/mg-input-checkbox.js +5 -5
  102. package/dist/components/mg-input-date.js +49 -18
  103. package/dist/components/mg-input-date.js.map +1 -1
  104. package/dist/components/mg-input-numeric.js +7 -7
  105. package/dist/components/mg-input-numeric.js.map +1 -1
  106. package/dist/components/mg-input-password.js +5 -5
  107. package/dist/components/mg-input-password.js.map +1 -1
  108. package/dist/components/mg-input-radio.js +5 -5
  109. package/dist/components/mg-input-select2.js +8 -8
  110. package/dist/components/mg-input-select2.js.map +1 -1
  111. package/dist/components/mg-input-text2.js +15 -9
  112. package/dist/components/mg-input-text2.js.map +1 -1
  113. package/dist/components/mg-input-textarea.js +8 -8
  114. package/dist/components/mg-input-textarea.js.map +1 -1
  115. package/dist/components/mg-input-title2.js +3 -3
  116. package/dist/components/mg-input-title2.js.map +1 -1
  117. package/dist/components/mg-input-toggle.js +5 -5
  118. package/dist/components/mg-input-toggle.js.map +1 -1
  119. package/dist/components/mg-input2.js +4 -4
  120. package/dist/components/mg-input2.js.map +1 -1
  121. package/dist/components/mg-item-more.js +1 -339
  122. package/dist/components/mg-item-more.js.map +1 -1
  123. package/dist/components/mg-item-more2.js +592 -0
  124. package/dist/components/mg-item-more2.js.map +1 -0
  125. package/dist/components/mg-loader.js +3 -3
  126. package/dist/components/mg-menu-item2.js +30 -8
  127. package/dist/components/mg-menu-item2.js.map +1 -1
  128. package/dist/components/mg-menu.js +1 -1
  129. package/dist/components/mg-message.js +4 -4
  130. package/dist/components/mg-message.js.map +1 -1
  131. package/dist/components/mg-modal.js +8 -8
  132. package/dist/components/mg-modal.js.map +1 -1
  133. package/dist/components/mg-pagination2.js +5 -5
  134. package/dist/components/mg-pagination2.js.map +1 -1
  135. package/dist/components/mg-panel.js +5 -5
  136. package/dist/components/mg-panel.js.map +1 -1
  137. package/dist/components/mg-popover-content2.js +4 -4
  138. package/dist/components/mg-popover-content2.js.map +1 -1
  139. package/dist/components/mg-popover2.js +4 -4
  140. package/dist/components/mg-popover2.js.map +1 -1
  141. package/dist/components/mg-skip-links.js +3 -3
  142. package/dist/components/mg-tabs.js +7 -7
  143. package/dist/components/mg-tabs.js.map +1 -1
  144. package/dist/components/mg-tag.js +4 -4
  145. package/dist/components/mg-tag.js.map +1 -1
  146. package/dist/components/mg-tooltip-content2.js +1 -1
  147. package/dist/components/mg-tooltip-content2.js.map +1 -1
  148. package/dist/components/mg-tooltip2.js +16 -9
  149. package/dist/components/mg-tooltip2.js.map +1 -1
  150. package/dist/esm/{index-445fc2a0.js → index-8d5d1bfd.js} +44 -44
  151. package/dist/esm/index-8d5d1bfd.js.map +1 -0
  152. package/dist/esm/{index-629a42c7.js → index-e479d5ae.js} +34 -10
  153. package/dist/esm/index-e479d5ae.js.map +1 -0
  154. package/dist/esm/loader.js +3 -3
  155. package/dist/esm/{mg-action-more_35.entry.js → mg-action-more_36.entry.js} +501 -168
  156. package/dist/esm/mg-action-more_36.entry.js.map +1 -0
  157. package/dist/esm/mg-components.js +4 -4
  158. package/dist/esm/mg-components.js.map +1 -1
  159. package/dist/esm/mg-loader.entry.js +4 -4
  160. package/dist/mg-components/mg-components.esm.js +1 -1
  161. package/dist/mg-components/mg-components.esm.js.map +1 -1
  162. package/dist/mg-components/p-7315d4a6.js +3 -0
  163. package/dist/mg-components/p-7315d4a6.js.map +1 -0
  164. package/dist/mg-components/p-8800813b.js +2 -0
  165. package/dist/mg-components/p-8800813b.js.map +1 -0
  166. package/dist/mg-components/{p-fe347f48.entry.js → p-99e2f42a.entry.js} +2 -2
  167. package/dist/mg-components/p-f9ac8927.entry.js +2 -0
  168. package/dist/mg-components/p-f9ac8927.entry.js.map +1 -0
  169. package/dist/types/components/atoms/mg-button/mg-button.d.ts +3 -0
  170. package/dist/types/components/atoms/mg-card/mg-card.d.ts +3 -0
  171. package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +3 -0
  172. package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +3 -0
  173. package/dist/types/components/atoms/mg-tooltip/mg-tooltip-content/mg-tooltip-content.d.ts +3 -0
  174. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +2 -1
  175. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +4 -0
  176. package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +6 -0
  177. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +2 -1
  178. package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +11 -0
  179. package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +3 -0
  180. package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +3 -0
  181. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -0
  182. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +3 -0
  183. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +15 -0
  184. package/dist/types/components/molecules/mg-popover/mg-popover-content/mg-popover-content.d.ts +3 -0
  185. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +4 -0
  186. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +3 -0
  187. package/dist/types/components.d.ts +5 -0
  188. package/ide/intellij/web-types.json +20 -81
  189. package/ide/vscode/html-custom-data.json +14 -74
  190. package/package.json +25 -25
  191. package/dist/cjs/index-1d560837.js.map +0 -1
  192. package/dist/cjs/index-7072369e.js.map +0 -1
  193. package/dist/cjs/mg-action-more_35.cjs.entry.js.map +0 -1
  194. package/dist/cjs/mg-item-more.cjs.entry.js +0 -273
  195. package/dist/cjs/mg-item-more.cjs.entry.js.map +0 -1
  196. package/dist/cjs/mg-menu.conf-c291eee6.js +0 -18
  197. package/dist/cjs/mg-menu.conf-c291eee6.js.map +0 -1
  198. package/dist/components/mg-menu.conf.js +0 -16
  199. package/dist/components/mg-menu.conf.js.map +0 -1
  200. package/dist/components/mg-menu2.js +0 -202
  201. package/dist/components/mg-menu2.js.map +0 -1
  202. package/dist/esm/index-445fc2a0.js.map +0 -1
  203. package/dist/esm/index-629a42c7.js.map +0 -1
  204. package/dist/esm/mg-action-more_35.entry.js.map +0 -1
  205. package/dist/esm/mg-item-more.entry.js +0 -269
  206. package/dist/esm/mg-item-more.entry.js.map +0 -1
  207. package/dist/esm/mg-menu.conf-9609bcb2.js +0 -16
  208. package/dist/esm/mg-menu.conf-9609bcb2.js.map +0 -1
  209. package/dist/mg-components/p-3ebe6845.js +0 -2
  210. package/dist/mg-components/p-3ebe6845.js.map +0 -1
  211. package/dist/mg-components/p-6735e4b2.entry.js +0 -2
  212. package/dist/mg-components/p-6735e4b2.entry.js.map +0 -1
  213. package/dist/mg-components/p-9dfaa41f.js +0 -3
  214. package/dist/mg-components/p-9dfaa41f.js.map +0 -1
  215. package/dist/mg-components/p-b3e0f7b3.entry.js +0 -2
  216. package/dist/mg-components/p-b3e0f7b3.entry.js.map +0 -1
  217. package/dist/mg-components/p-fe935e54.js +0 -2
  218. package/dist/mg-components/p-fe935e54.js.map +0 -1
  219. /package/dist/mg-components/{p-fe347f48.entry.js.map → p-99e2f42a.entry.js.map} +0 -0
@@ -1,273 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-7072369e.js');
6
- const index$1 = require('./index-1d560837.js');
7
- const mgMenu_conf = require('./mg-menu.conf-c291eee6.js');
8
-
9
- /**
10
- * MgItemMore type guard
11
- * @param element - element to control type
12
- * @returns truthy if element is mg-item-more
13
- */
14
- const isMgItemMore = (element) => element.nodeName === 'MG-ITEM-MORE';
15
- var OverflowBehaviorElements;
16
- (function (OverflowBehaviorElements) {
17
- OverflowBehaviorElements["BASE_INDEX"] = "data-overflow-base-index";
18
- OverflowBehaviorElements["PROXY_INDEX"] = "data-overflow-proxy-index";
19
- })(OverflowBehaviorElements || (OverflowBehaviorElements = {}));
20
- class OverflowBehavior {
21
- constructor(element, render) {
22
- this.element = element;
23
- this.render = render;
24
- /**********
25
- * Public *
26
- **********/
27
- /**
28
- * Disconnect ResizeObserver
29
- */
30
- this.disconnect = () => {
31
- this._resizeObserver.disconnect();
32
- };
33
- /************
34
- * Internal *
35
- ************/
36
- /**
37
- * run overflow behavior
38
- * @param width - width of the container. Optional.
39
- */
40
- this.run = (width) => {
41
- if (this._moreElement === undefined) {
42
- // set moreElement
43
- this._moreElement = this.render();
44
- // set children
45
- this._baseChildren = this.getInteractiveItems(this.element);
46
- if (isMgItemMore(this._moreElement)) {
47
- this._proxyChildren = this.getInteractiveItems(this._moreElement.shadowRoot.querySelector('mg-menu'));
48
- }
49
- // update children
50
- this._baseChildren.forEach((child, index) => {
51
- child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);
52
- // set moreElement children
53
- this._proxyChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);
54
- });
55
- }
56
- if (width !== undefined)
57
- this.updateDisplayedItems(width);
58
- };
59
- /**
60
- * Get interactive children filtred by authorized nodeName ['MG-MENU-ITEM', 'MG-BUTTON']
61
- * @param element - element to parse
62
- * @returns children
63
- */
64
- this.getInteractiveItems = (element) => { var _a; return (((_a = element.children) === null || _a === void 0 ? void 0 : _a.length) > 0 ? Array.from(element.children) : []).filter(element => ['MG-MENU-ITEM', 'MG-BUTTON'].includes(element.nodeName)); };
65
- /**
66
- * Update displayed items in container from a given available space
67
- * @param availableWidth - available width in container to display child items
68
- */
69
- this.updateDisplayedItems = (availableWidth) => {
70
- this.restoreItems();
71
- const acc = { accWidth: 0, previousItem: null };
72
- [...this._baseChildren, this._moreElement].forEach((child) => {
73
- acc.accWidth += child.offsetWidth;
74
- const hasPreviuosItem = acc.previousItem !== null;
75
- const isPreviousItemHidden = hasPreviuosItem && acc.previousItem.getAttribute('hidden') !== null;
76
- // if previous item is hidden AND is NOT more element we hidde current
77
- // OR if item has an overflow we hidde current
78
- // OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item
79
- // ELSE current is a display item
80
- this.toggleItem(child, (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden));
81
- // update previous item with current item
82
- acc.previousItem = child;
83
- });
84
- };
85
- /**
86
- * Utility method to know if item overflow partialy or totaly in the container
87
- * @param cumulateWidth - previous sibling elements cumulate width + item width
88
- * @param item - item HTML element
89
- * @param availableWidth - container available width
90
- * @returns truthy if element is overflow
91
- */
92
- this.isOverflowElement = (cumulateWidth, item, availableWidth) => {
93
- if (item.previousElementSibling === null || this.isMoreElement(item))
94
- return false;
95
- else if (!this.isMoreElement(item.nextElementSibling))
96
- return cumulateWidth + this._moreElement.offsetWidth > availableWidth;
97
- else
98
- return cumulateWidth > availableWidth;
99
- };
100
- /**
101
- * Utility method to know if a given element is the 'MORE' element
102
- * @param element - element to match with 'MORE' element
103
- * @returns truthy if element is the 'MORE' element
104
- */
105
- this.isMoreElement = (element) => element.nodeName === 'MG-ITEM-MORE';
106
- /**
107
- * Toggle display item element
108
- * @param item - item to control
109
- * @param isHidden - is item hidden
110
- */
111
- this.toggleItem = (item, isHidden) => {
112
- const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));
113
- if (this.isMoreElement(item))
114
- this.toggleElement(this._moreElement, isHidden);
115
- else if (mgActionMenuindex >= 0) {
116
- this.toggleElement(item, isHidden);
117
- this.toggleElement(this._proxyChildren[mgActionMenuindex], !isHidden);
118
- }
119
- };
120
- /**
121
- * Toggle element's hidde attribute
122
- * @param element - element to toggle
123
- * @param isHidden - element is hidden
124
- */
125
- this.toggleElement = (element, isHidden) => {
126
- if (isHidden)
127
- element.setAttribute('hidden', '');
128
- else
129
- element.removeAttribute('hidden');
130
- };
131
- /**
132
- * Remove hidden attributes on all items
133
- */
134
- this.restoreItems = () => {
135
- [...this._baseChildren, this._moreElement].forEach(item => item.removeAttribute('hidden'));
136
- };
137
- if (this._resizeObserver === undefined) {
138
- // add resize observer
139
- this._resizeObserver = new ResizeObserver(entries => {
140
- entries.forEach(entry => {
141
- this.run(entry.contentRect.width);
142
- });
143
- });
144
- this._resizeObserver.observe(this.element);
145
- }
146
- this.run();
147
- }
148
- }
149
-
150
- const mgItemMoreCss = ".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}}:host:not([hidden]){display:flex}";
151
- const MgItemMoreStyle0 = mgItemMoreCss;
152
-
153
- const MgItemMore = class {
154
- constructor(hostRef) {
155
- index.registerInstance(this, hostRef);
156
- /************
157
- * Internal *
158
- ************/
159
- this.name = 'mg-item-more';
160
- this.canRenderMgMenuItemOverflowElement = true;
161
- /***********
162
- * Methods *
163
- ***********/
164
- /**
165
- * render mg-item-more overflow element
166
- * @returns mg-item-more element
167
- */
168
- this.renderMgMenuItemOverflowElement = () => {
169
- // create menu items proxy element from item clones
170
- this.parentMenuItems.forEach((child) => {
171
- this.moreElementMenuItem.querySelector('mg-menu').appendChild(child.cloneNode(true));
172
- });
173
- const allMenuItem = Array.from(this.parentMenu.querySelectorAll('mg-menu-item:not([data-overflow-more])'));
174
- Array.from(this.moreElementMenuItem.querySelectorAll('mg-menu-item:not([data-overflow-more])')).forEach((proxy, index) => {
175
- // manage click on proxy to mirror it on initial element
176
- proxy.addEventListener('click', () => {
177
- // be carefull to use element.click() method instead of dispatchEvent to ensure bubbles outside shadowDom
178
- const navElement = allMenuItem[index].shadowRoot.querySelector('a, button');
179
- if (navElement instanceof HTMLButtonElement || navElement instanceof HTMLAnchorElement)
180
- navElement.click();
181
- });
182
- // add id suffix to prevent duplicate key. default html id is: '';
183
- if (index$1.Be(proxy.id))
184
- proxy.id = `${proxy.id}-proxy`;
185
- // manage status change miror in proxy
186
- allMenuItem[index].addEventListener('status-change', (event) => {
187
- proxy.setAttribute('status', event.detail);
188
- });
189
- });
190
- return this.element;
191
- };
192
- this.icon = { icon: 'ellipsis-vertical' };
193
- this.slotlabel = { display: false };
194
- this.size = undefined;
195
- this.parentMenu = undefined;
196
- }
197
- validateIcon(newValue) {
198
- if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.icon !== 'string'))
199
- throw new Error(`<${this.name}> prop "icon" must match MgItemMore['icon'] type.`);
200
- }
201
- validateSlotLabel(newValue) {
202
- if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.display !== 'boolean'))
203
- throw new Error(`<${this.name}> prop "slotlabel" must match MgItemMore['slotlabel'] type.`);
204
- else if (typeof newValue.label !== 'string')
205
- this.slotlabel.label = this.messages.menuLabel;
206
- }
207
- validateSize(newValue) {
208
- if (newValue && typeof newValue !== 'string')
209
- throw new Error(`<${this.name}> prop "size" must match MgItemMore['size'] type.`);
210
- }
211
- /*************
212
- * Lifecycle *
213
- *************/
214
- /**
215
- * Set variables and validate props
216
- */
217
- componentWillLoad() {
218
- // init variables
219
- this.messages = index$1.initLocales(this.element).messages.itemMore;
220
- // validate props
221
- this.validateIcon(this.icon);
222
- this.validateSlotLabel(this.slotlabel);
223
- this.validateSize(this.size);
224
- }
225
- /**
226
- * Ensure parent DOM is fully rendered with timeout method before parse elements
227
- * @returns timeout
228
- */
229
- componentDidLoad() {
230
- // ensure parent menu is fully rendered
231
- return setTimeout(() => {
232
- this.parentMenu = this.element.closest('mg-menu');
233
- });
234
- }
235
- /**
236
- * Set OverflowBehavior when parentMenu state is upate AND defined
237
- */
238
- componentDidUpdate() {
239
- if (this.parentMenu && this.canRenderMgMenuItemOverflowElement) {
240
- this.parentMenuItems = Array.from(this.parentMenu.children).filter(item => item.nodeName === 'MG-MENU-ITEM');
241
- this.overflowBehavior = new OverflowBehavior(this.parentMenu, this.renderMgMenuItemOverflowElement);
242
- this.canRenderMgMenuItemOverflowElement = false;
243
- }
244
- }
245
- /**
246
- * Disconnect overflow ResizeObserver
247
- */
248
- disconnectedCallback() {
249
- var _a;
250
- (_a = this.overflowBehavior) === null || _a === void 0 ? void 0 : _a.disconnect();
251
- }
252
- /**
253
- * Render
254
- * @returns HTML Element
255
- */
256
- render() {
257
- return (index.h(index.Host, { key: 'd19aa0bb690ee7ed301954913d3e056d1050dc04', role: "listitem" }, this.parentMenu && (index.h("mg-menu-item", { "data-overflow-more": true, "data-size": this.parentMenu.size, ref: el => {
258
- if (el)
259
- this.moreElementMenuItem = el;
260
- } }, index.h("mg-icon", { icon: this.icon.icon, slot: "image" }), index.h("span", { class: { 'mg-u-visually-hidden': !this.slotlabel.display }, slot: "label" }, this.slotlabel.label), index.h("mg-menu", { direction: mgMenu_conf.Direction.VERTICAL, label: this.messages.menuLabel, size: this.size })))));
261
- }
262
- get element() { return index.getElement(this); }
263
- static get watchers() { return {
264
- "icon": ["validateIcon"],
265
- "slotlabel": ["validateSlotLabel"],
266
- "size": ["validateSize"]
267
- }; }
268
- };
269
- MgItemMore.style = MgItemMoreStyle0;
270
-
271
- exports.mg_item_more = MgItemMore;
272
-
273
- //# sourceMappingURL=mg-item-more.cjs.entry.js.map
@@ -1 +0,0 @@
1
- {"file":"mg-item-more.entry.cjs.js","mappings":";;;;;;;;AAAA;;;;;AAKA,MAAM,YAAY,GAAG,CAAC,OAAoB,KAAuC,OAAO,CAAC,QAAQ,KAAK,cAAc,CAAC;AAErH,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IAClC,mEAAuC,CAAA;IACvC,qEAAyC,CAAA;AAC3C,CAAC,EAHW,wBAAwB,KAAxB,wBAAwB,QAGnC;MAEY,gBAAgB;IAO3B,YACU,OAAgB,EAChB,MAAyB;QADzB,YAAO,GAAP,OAAO,CAAS;QAChB,WAAM,GAAN,MAAM,CAAmB;;;;;;;QAqB5B,eAAU,GAAG;YAClB,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;SACnC,CAAC;;;;;;;;QAUM,QAAG,GAAG,CAAC,KAAc;YAC3B,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;;gBAEnC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;;gBAGlC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAC5D,IAAI,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;oBACnC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,YA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gB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,+BAA+B,CAAC,CAAC;YACpG,IAAI,CAAC,kCAAkC,GAAG,KAAK,CAAC;SACjD;KACF;;;;IAKD,oBAAoB;;QAClB,MAAA,IAAI,CAAC,gBAAgB,0CAAE,UAAU,EAAE,CAAC;KACrC;;;;;IAMD,MAAM;QACJ,QACEC,QAACC,UAAI,qDAAC,IAAI,EAAC,UAAU,IAClB,IAAI,CAAC,UAAU,KACdD,mEAEa,IAAI,CAAC,UAAU,CAAC,IAAI,EAC/B,GAAG,EAAE,EAAE;gBACL,IAAI,EAAE;oBAAE,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;aACvC,IAEDA,qBAAS,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAC,OAAO,GAAW,EACtDA,kBAAM,KAAK,EAAE,EAAE,sBAAsB,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,IAAI,EAAC,OAAO,IAC3E,IAAI,CAAC,SAAS,CAAC,KAAK,CAChB,EACPA,qBAAS,SAAS,EAAEE,qBAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,GAAY,CACtF,CAChB,CACI,EACP;KACH;;;;;;;;;;;;","names":["isValidString","initLocales","h","Host","Direction"],"sources":["src/utils/behaviors.utils.ts","../styles/dist/components/mg-item-more.css?tag=mg-item-more&encapsulation=shadow","src/components/molecules/mg-item-more/mg-item-more.tsx"],"sourcesContent":["/**\n * MgItemMore type guard\n * @param element - element to control type\n * @returns truthy if element is mg-item-more\n */\nconst isMgItemMore = (element: HTMLElement): element is HTMLMgItemMoreElement => element.nodeName === 'MG-ITEM-MORE';\n\nexport enum OverflowBehaviorElements {\n BASE_INDEX = 'data-overflow-base-index',\n PROXY_INDEX = 'data-overflow-proxy-index',\n}\n\nexport class OverflowBehavior {\n // variables\n private _resizeObserver: ResizeObserver;\n private _moreElement: HTMLElement;\n private _baseChildren: Element[];\n private _proxyChildren: Element[];\n\n constructor(\n private element: Element,\n private render: () => HTMLElement,\n ) {\n if (this._resizeObserver === undefined) {\n // add resize observer\n this._resizeObserver = new ResizeObserver(entries => {\n entries.forEach(entry => {\n this.run(entry.contentRect.width);\n });\n });\n this._resizeObserver.observe(this.element);\n }\n this.run();\n }\n\n /**********\n * Public *\n **********/\n\n /**\n * Disconnect ResizeObserver\n */\n public disconnect = (): void => {\n this._resizeObserver.disconnect();\n };\n\n /************\n * Internal *\n ************/\n\n /**\n * run overflow behavior\n * @param width - width of the container. Optional.\n */\n private run = (width?: number): void => {\n if (this._moreElement === undefined) {\n // set moreElement\n this._moreElement = this.render();\n\n // set children\n this._baseChildren = this.getInteractiveItems(this.element);\n if (isMgItemMore(this._moreElement)) {\n this._proxyChildren = this.getInteractiveItems(this._moreElement.shadowRoot.querySelector('mg-menu'));\n }\n\n // update children\n this._baseChildren.forEach((child, index) => {\n child.setAttribute(OverflowBehaviorElements.BASE_INDEX, `${index}`);\n // set moreElement children\n this._proxyChildren[index].setAttribute(OverflowBehaviorElements.PROXY_INDEX, `${index}`);\n });\n }\n\n if (width !== undefined) this.updateDisplayedItems(width);\n };\n\n /**\n * Get interactive children filtred by authorized nodeName ['MG-MENU-ITEM', 'MG-BUTTON']\n * @param element - element to parse\n * @returns children\n */\n private getInteractiveItems = (element: Element) =>\n (element.children?.length > 0 ? Array.from(element.children) : []).filter(element => ['MG-MENU-ITEM', 'MG-BUTTON'].includes(element.nodeName));\n\n /**\n * Update displayed items in container from a given available space\n * @param availableWidth - available width in container to display child items\n */\n private updateDisplayedItems = (availableWidth: number): void => {\n this.restoreItems();\n const acc = { accWidth: 0, previousItem: null };\n [...this._baseChildren, this._moreElement].forEach((child: HTMLMgMenuItemElement | HTMLMgItemMoreElement) => {\n acc.accWidth += child.offsetWidth;\n const hasPreviuosItem = acc.previousItem !== null;\n const isPreviousItemHidden = hasPreviuosItem && acc.previousItem.getAttribute('hidden') !== null;\n // if previous item is hidden AND is NOT more element we hidde current\n // OR if item has an overflow we hidde current\n // OR if current item is more element AND have NOT previous hidden items, current more element item is an hidden item\n // ELSE current is a display item\n this.toggleItem(\n child,\n (isPreviousItemHidden && !this.isMoreElement(child)) || this.isOverflowElement(acc.accWidth, child, availableWidth) || (this.isMoreElement(child) && !isPreviousItemHidden),\n );\n\n // update previous item with current item\n acc.previousItem = child;\n });\n };\n\n /**\n * Utility method to know if item overflow partialy or totaly in the container\n * @param cumulateWidth - previous sibling elements cumulate width + item width\n * @param item - item HTML element\n * @param availableWidth - container available width\n * @returns truthy if element is overflow\n */\n private isOverflowElement = (cumulateWidth: number, item: HTMLElement, availableWidth: number): boolean => {\n if (item.previousElementSibling === null || this.isMoreElement(item)) return false;\n else if (!this.isMoreElement(item.nextElementSibling)) return cumulateWidth + this._moreElement.offsetWidth > availableWidth;\n else return cumulateWidth > availableWidth;\n };\n\n /**\n * Utility method to know if a given element is the 'MORE' element\n * @param element - element to match with 'MORE' element\n * @returns truthy if element is the 'MORE' element\n */\n private isMoreElement = (element: Element): boolean => element.nodeName === 'MG-ITEM-MORE';\n\n /**\n * Toggle display item element\n * @param item - item to control\n * @param isHidden - is item hidden\n */\n private toggleItem = (item: HTMLElement, isHidden: boolean): void => {\n const mgActionMenuindex = Number(item.getAttribute(OverflowBehaviorElements.BASE_INDEX));\n if (this.isMoreElement(item)) this.toggleElement(this._moreElement, isHidden);\n else if (mgActionMenuindex >= 0) {\n this.toggleElement(item, isHidden);\n this.toggleElement(this._proxyChildren[mgActionMenuindex], !isHidden);\n }\n };\n\n /**\n * Toggle element's hidde attribute\n * @param element - element to toggle\n * @param isHidden - element is hidden\n */\n private toggleElement = (element: Element, isHidden: boolean): void => {\n if (isHidden) element.setAttribute('hidden', '');\n else element.removeAttribute('hidden');\n };\n\n /**\n * Remove hidden attributes on all items\n */\n private restoreItems = (): void => {\n [...this._baseChildren, this._moreElement].forEach(item => item.removeAttribute('hidden'));\n };\n}\n",".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}}:host:not([hidden]){display:flex}/*# sourceMappingURL=mg-item-more.css.map */\n","import { Component, h, Prop, Element, Host, Watch, State } from '@stencil/core';\nimport { isValidString } from '@mgdis/stencil-helpers';\nimport { Direction } from '../menu/mg-menu/mg-menu.conf';\nimport { OverflowBehavior } from '../../../utils/behaviors.utils';\nimport { initLocales } from '../../../locales';\nimport type { IconType, SizeType, SlotLabelType } from './mg-item-more.conf';\nimport type { MessageType } from '../../../locales/index.conf';\n\n@Component({\n tag: 'mg-item-more',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-item-more.css',\n shadow: true,\n})\nexport class MgItemMore {\n /************\n * Internal *\n ************/\n private readonly name = 'mg-item-more';\n private messages: MessageType;\n private parentMenuItems: HTMLMgMenuItemElement[];\n private moreElementMenuItem: HTMLMgMenuItemElement;\n private overflowBehavior: OverflowBehavior;\n private canRenderMgMenuItemOverflowElement = true;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgItemMoreElement;\n\n /**\n * Define icon\n */\n @Prop() icon?: IconType = { icon: 'ellipsis-vertical' };\n @Watch('icon')\n validateIcon(newValue: MgItemMore['icon']): void {\n if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.icon !== 'string'))\n throw new Error(`<${this.name}> prop \"icon\" must match MgItemMore['icon'] type.`);\n }\n\n /**\n * Define slot label element\n */\n @Prop() slotlabel?: SlotLabelType = { display: false };\n @Watch('slotlabel')\n validateSlotLabel(newValue: MgItemMore['slotlabel']): void {\n if (typeof newValue !== 'object' || (typeof newValue === 'object' && typeof newValue.display !== 'boolean'))\n throw new Error(`<${this.name}> prop \"slotlabel\" must match MgItemMore['slotlabel'] type.`);\n else if (typeof newValue.label !== 'string') this.slotlabel.label = this.messages.menuLabel;\n }\n\n /**\n * Define component child menu size.\n */\n @Prop() size?: SizeType;\n @Watch('size')\n validateSize(newValue: MgItemMore['size']): void {\n if (newValue && typeof newValue !== 'string') throw new Error(`<${this.name}> prop \"size\" must match MgItemMore['size'] type.`);\n }\n\n /**\n * Define component parent menu.\n */\n @State() parentMenu: HTMLMgMenuElement;\n\n /***********\n * Methods *\n ***********/\n\n /**\n * render mg-item-more overflow element\n * @returns mg-item-more element\n */\n private renderMgMenuItemOverflowElement = (): HTMLMgItemMoreElement => {\n // create menu items proxy element from item clones\n this.parentMenuItems.forEach((child: HTMLMgMenuItemElement) => {\n this.moreElementMenuItem.querySelector('mg-menu').appendChild(child.cloneNode(true));\n });\n\n const allMenuItem = Array.from(this.parentMenu.querySelectorAll('mg-menu-item:not([data-overflow-more])'));\n\n Array.from(this.moreElementMenuItem.querySelectorAll('mg-menu-item:not([data-overflow-more])')).forEach((proxy, index) => {\n // manage click on proxy to mirror it on initial element\n proxy.addEventListener('click', () => {\n // be carefull to use element.click() method instead of dispatchEvent to ensure bubbles outside shadowDom\n const navElement = allMenuItem[index].shadowRoot.querySelector('a, button');\n if (navElement instanceof HTMLButtonElement || navElement instanceof HTMLAnchorElement) navElement.click();\n });\n\n // add id suffix to prevent duplicate key. default html id is: '';\n if (isValidString(proxy.id)) proxy.id = `${proxy.id}-proxy`;\n\n // manage status change miror in proxy\n allMenuItem[index].addEventListener('status-change', (event: CustomEvent) => {\n proxy.setAttribute('status', event.detail);\n });\n });\n\n return this.element;\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Set variables and validate props\n */\n componentWillLoad(): void {\n // init variables\n this.messages = initLocales(this.element).messages.itemMore as MessageType;\n\n // validate props\n this.validateIcon(this.icon);\n this.validateSlotLabel(this.slotlabel);\n this.validateSize(this.size);\n }\n\n /**\n * Ensure parent DOM is fully rendered with timeout method before parse elements\n * @returns timeout\n */\n componentDidLoad(): ReturnType<typeof setTimeout> {\n // ensure parent menu is fully rendered\n return setTimeout(() => {\n this.parentMenu = this.element.closest('mg-menu');\n });\n }\n\n /**\n * Set OverflowBehavior when parentMenu state is upate AND defined\n */\n componentDidUpdate(): void {\n if (this.parentMenu && this.canRenderMgMenuItemOverflowElement) {\n this.parentMenuItems = Array.from(this.parentMenu.children).filter(item => item.nodeName === 'MG-MENU-ITEM') as HTMLMgMenuItemElement[];\n this.overflowBehavior = new OverflowBehavior(this.parentMenu, this.renderMgMenuItemOverflowElement);\n this.canRenderMgMenuItemOverflowElement = false;\n }\n }\n\n /**\n * Disconnect overflow ResizeObserver\n */\n disconnectedCallback(): void {\n this.overflowBehavior?.disconnect();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"listitem\">\n {this.parentMenu && (\n <mg-menu-item\n data-overflow-more\n data-size={this.parentMenu.size}\n ref={el => {\n if (el) this.moreElementMenuItem = el;\n }}\n >\n <mg-icon icon={this.icon.icon} slot=\"image\"></mg-icon>\n <span class={{ 'mg-u-visually-hidden': !this.slotlabel.display }} slot=\"label\">\n {this.slotlabel.label}\n </span>\n <mg-menu direction={Direction.VERTICAL} label={this.messages.menuLabel} size={this.size}></mg-menu>\n </mg-menu-item>\n )}\n </Host>\n );\n }\n}\n"],"version":3}
@@ -1,18 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Menu direction type
5
- */
6
- exports.Direction = void 0;
7
- (function (Direction) {
8
- Direction["VERTICAL"] = "vertical";
9
- Direction["HORIZONTAL"] = "horizontal";
10
- })(exports.Direction || (exports.Direction = {}));
11
- /**
12
- * List of all possibles sizes
13
- */
14
- const sizes = ['regular', 'medium', 'large'];
15
-
16
- exports.sizes = sizes;
17
-
18
- //# sourceMappingURL=mg-menu.conf-c291eee6.js.map
@@ -1 +0,0 @@
1
- {"file":"mg-menu.conf-c291eee6.js","mappings":";;AAEA;;;AAGYA;AAAZ,WAAY,SAAS;IACnB,kCAAqB,CAAA;IACrB,sCAAyB,CAAA;AAC3B,CAAC,EAHWA,iBAAS,KAATA,iBAAS,QAGpB;AAOD;;;MAGa,KAAK,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO;;;;","names":["Direction"],"sources":["src/components/molecules/menu/mg-menu/mg-menu.conf.ts"],"sourcesContent":["import { MgItemMore } from '../../mg-item-more/mg-item-more';\n\n/**\n * Menu direction type\n */\nexport enum Direction {\n VERTICAL = 'vertical',\n HORIZONTAL = 'horizontal',\n}\n\n/**\n * ItemMore prop type\n */\nexport type ItemMoreType = Pick<MgItemMore, 'icon' | 'slotlabel' | 'size'>;\n\n/**\n * List of all possibles sizes\n */\nexport const sizes = ['regular', 'medium', 'large'] as const;\n\n/**\n * item Size from sizes\n */\nexport type MenuSizeType = (typeof sizes)[number];\n"],"version":3}
@@ -1,16 +0,0 @@
1
- /**
2
- * Menu direction type
3
- */
4
- var Direction;
5
- (function (Direction) {
6
- Direction["VERTICAL"] = "vertical";
7
- Direction["HORIZONTAL"] = "horizontal";
8
- })(Direction || (Direction = {}));
9
- /**
10
- * List of all possibles sizes
11
- */
12
- const sizes = ['regular', 'medium', 'large'];
13
-
14
- export { Direction as D, sizes as s };
15
-
16
- //# sourceMappingURL=mg-menu.conf.js.map
@@ -1 +0,0 @@
1
- {"file":"mg-menu.conf.js","mappings":"AAEA;;;IAGY;AAAZ,WAAY,SAAS;IACnB,kCAAqB,CAAA;IACrB,sCAAyB,CAAA;AAC3B,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAOD;;;MAGa,KAAK,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO;;;;","names":[],"sources":["src/components/molecules/menu/mg-menu/mg-menu.conf.ts"],"sourcesContent":["import { MgItemMore } from '../../mg-item-more/mg-item-more';\n\n/**\n * Menu direction type\n */\nexport enum Direction {\n VERTICAL = 'vertical',\n HORIZONTAL = 'horizontal',\n}\n\n/**\n * ItemMore prop type\n */\nexport type ItemMoreType = Pick<MgItemMore, 'icon' | 'slotlabel' | 'size'>;\n\n/**\n * List of all possibles sizes\n */\nexport const sizes = ['regular', 'medium', 'large'] as const;\n\n/**\n * item Size from sizes\n */\nexport type MenuSizeType = (typeof sizes)[number];\n"],"version":3}
@@ -1,202 +0,0 @@
1
- import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
- import { D as Direction, s as sizes } from './mg-menu.conf.js';
3
-
4
- const mgMenuCss = ".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}}:host{display:flex;background-color:hsl(var(--mg-menu-background-color-hsl, var(--color-light)))}:host([direction=vertical]){height:100%;flex-direction:column;overflow-y:auto}";
5
- const MgMenuStyle0 = mgMenuCss;
6
-
7
- const MgMenu = /*@__PURE__*/ proxyCustomElement(class MgMenu extends HTMLElement {
8
- constructor() {
9
- super();
10
- this.__registerHost();
11
- this.__attachShadow();
12
- /************
13
- * Internal *
14
- ************/
15
- this.name = 'mg-menu';
16
- this.menuItems = [];
17
- this.focusedMenuItem = 0;
18
- /*************
19
- * Methods *
20
- *************/
21
- /**
22
- * Close matching menu-item
23
- * @param item - menu-item to close
24
- * @param condition - addionnal condition
25
- */
26
- this.closeMenuItem = (item, condition) => {
27
- if (!this.isChildMenu && condition) {
28
- item.expanded = false;
29
- }
30
- };
31
- /**
32
- * get mg-item-more element
33
- * @returns mg-item-more element
34
- */
35
- this.getItemMore = () => this.element.querySelector('mg-item-more');
36
- /**
37
- * get mg-item-more child mg-menu-item element
38
- * @returns mg-menu-item element
39
- */
40
- this.getItemMoreMenuItem = () => { var _a, _b; return (_b = (_a = this.getItemMore()) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('mg-menu-item'); };
41
- /**
42
- * Set item listend
43
- * @param item - mg-menu-item element
44
- * @param index - number
45
- */
46
- this.setItemListener = (item, index) => {
47
- ['click', 'focus'].forEach(trigger => {
48
- (item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, () => {
49
- this.focusedMenuItem = index;
50
- // reset expanded on previous active menu item
51
- (this.getItemMoreMenuItem() ? [...this.menuItems, this.getItemMoreMenuItem()] : this.menuItems).forEach((item, index) => {
52
- this.closeMenuItem(item, index !== this.focusedMenuItem);
53
- });
54
- });
55
- });
56
- };
57
- /**
58
- * Store menu-items on component init and add listeners
59
- */
60
- this.initMenuItemsListeners = () => {
61
- // add listeners on menu item and edit index
62
- this.menuItems.forEach((item, index) => {
63
- this.setItemListener(item, index);
64
- });
65
- };
66
- /**
67
- * Handle item-loaded event on mg-item-more element
68
- */
69
- this.handleItemLoaded = () => {
70
- this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);
71
- };
72
- /**
73
- * render mg-item-more
74
- */
75
- this.renderMgItemMore = () => {
76
- // /!\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement
77
- // by doing this we prevent stencil to generate a circular dependencies graph at build time with mg-item-more component.
78
- const item = 'mg-item-more';
79
- const mgItemMore = document.createElement(item);
80
- Object.assign(mgItemMore, this.itemmore);
81
- mgItemMore.addEventListener('item-loaded', this.handleItemLoaded);
82
- this.element.appendChild(mgItemMore);
83
- };
84
- this.label = undefined;
85
- this.direction = Direction.HORIZONTAL;
86
- this.itemmore = undefined;
87
- this.size = 'regular';
88
- this.isChildMenu = undefined;
89
- }
90
- validateLabel(newValue) {
91
- if (newValue === undefined) {
92
- throw new Error(`<${this.name}> prop "label" is required.`);
93
- }
94
- }
95
- validateDirection(newValue) {
96
- if (![Direction.VERTICAL, Direction.HORIZONTAL].includes(newValue)) {
97
- throw new Error(`<${this.name}> prop "direction" must be one of: ${Direction.HORIZONTAL}, ${Direction.VERTICAL}.`);
98
- }
99
- }
100
- validateItemMore(newValue) {
101
- if (newValue !== undefined && this.direction !== Direction.HORIZONTAL) {
102
- throw new Error(`<${this.name}> prop "itemmore" must be paired with direction ${Direction.HORIZONTAL}.`);
103
- }
104
- }
105
- validateSize(newValue) {
106
- if (!sizes.includes(newValue)) {
107
- throw new Error(`<${this.name}> prop "size" must be one of: ${sizes.join(', ')}.`);
108
- }
109
- }
110
- /*************
111
- * Lifecycle *
112
- *************/
113
- /**
114
- * Validate props
115
- */
116
- componentWillLoad() {
117
- this.validateDirection(this.direction);
118
- this.validateLabel(this.label);
119
- this.validateItemMore(this.itemmore);
120
- this.validateSize(this.size);
121
- }
122
- /**
123
- * Check if component slots configuration
124
- * @returns timeout
125
- */
126
- componentDidLoad() {
127
- // update props and states after componentDidLoad hook
128
- // return a promise to process action only in the FIRST render().
129
- // https://stenciljs.com/docs/component-lifecycle#componentwillload
130
- return setTimeout(() => {
131
- // store all menu-items
132
- this.menuItems = Array.from(this.element.children).filter(child => child.nodeName === 'MG-MENU-ITEM');
133
- this.isChildMenu = this.element.closest('mg-menu-item') !== null;
134
- // add mg-item-more to manage OverflowBehavior
135
- if (this.direction === Direction.HORIZONTAL && !this.isChildMenu)
136
- this.renderMgItemMore();
137
- // use mutation observer to improve reactivity
138
- new MutationObserver(entries => {
139
- const mgItemMore = this.getItemMore();
140
- // prevent infinit loop by exclude mg-item-more deletion entry
141
- if (entries.some(entry => entry.type === 'childList' && Array.from(entry.removedNodes).some(node => node.nodeName === 'MG-ITEM-MORE')))
142
- return;
143
- else if (mgItemMore !== null) {
144
- // render a new mg-item-more
145
- mgItemMore.remove();
146
- mgItemMore.removeEventListener('item-loaded', this.handleItemLoaded);
147
- this.renderMgItemMore();
148
- }
149
- }).observe(this.element, { childList: true, characterData: true, subtree: true });
150
- }, 0);
151
- }
152
- /**
153
- * Add listeners to items
154
- */
155
- componentDidRender() {
156
- this.initMenuItemsListeners();
157
- }
158
- /**
159
- * Render
160
- * @returns HTML Element
161
- */
162
- render() {
163
- return (h(Host, { key: '086439eeee2cbd3ee887bf047f04271de3e909b1', role: "list", "aria-label": this.label }, h("slot", { key: '332f520ff53aa203bfa299afce5251aa108e7e55' })));
164
- }
165
- get element() { return this; }
166
- static get watchers() { return {
167
- "label": ["validateLabel"],
168
- "direction": ["validateDirection"],
169
- "itemmore": ["validateItemMore"],
170
- "size": ["validateSize"]
171
- }; }
172
- static get style() { return MgMenuStyle0; }
173
- }, [1, "mg-menu", {
174
- "label": [1],
175
- "direction": [513],
176
- "itemmore": [16],
177
- "size": [1],
178
- "isChildMenu": [32]
179
- }, undefined, {
180
- "label": ["validateLabel"],
181
- "direction": ["validateDirection"],
182
- "itemmore": ["validateItemMore"],
183
- "size": ["validateSize"]
184
- }]);
185
- function defineCustomElement() {
186
- if (typeof customElements === "undefined") {
187
- return;
188
- }
189
- const components = ["mg-menu"];
190
- components.forEach(tagName => { switch (tagName) {
191
- case "mg-menu":
192
- if (!customElements.get(tagName)) {
193
- customElements.define(tagName, MgMenu);
194
- }
195
- break;
196
- } });
197
- }
198
- defineCustomElement();
199
-
200
- export { MgMenu as M, defineCustomElement as d };
201
-
202
- //# sourceMappingURL=mg-menu2.js.map
@@ -1 +0,0 @@
1
- {"file":"mg-menu2.js","mappings":";;;AAAA,MAAM,SAAS,GAAG,qmBAAqmB,CAAC;AACxnB,qBAAe,SAAS;;MCQX,MAAM;;;;;;;;QAKA,SAAI,GAAG,SAAS,CAAC;QAC1B,cAAS,GAA4B,EAAE,CAAC;QACxC,oBAAe,GAAG,CAAC,CAAC;;;;;;;;;QAuEpB,kBAAa,GAAG,CAAC,IAA2B,EAAE,SAAkB;YACtE,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,SAAS,EAAE;gBAClC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;aACvB;SACF,CAAC;;;;;QAMM,gBA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AC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;SACnF,EAAE,CAAC,CAAC,CAAC;KACP;;;;IAKD,kBAAkB;QAChB,IAAI,CAAC,sBAAsB,EAAE,CAAC;KAC/B;;;;;IAMD,MAAM;QACJ,QACE,EAAC,IAAI,qDAAC,IAAI,EAAC,MAAM,gBAAa,IAAI,CAAC,KAAK,IACtC,8DAAa,CACR,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["../styles/dist/components/mg-menu.css?tag=mg-menu&encapsulation=shadow","src/components/molecules/menu/mg-menu/mg-menu.tsx"],"sourcesContent":[".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}}:host{display:flex;background-color:hsl(var(--mg-menu-background-color-hsl, var(--color-light)))}:host([direction=vertical]){height:100%;flex-direction:column;overflow-y:auto}/*# sourceMappingURL=mg-menu.css.map */\n","import { Component, h, Prop, State, Element, Watch, Host } from '@stencil/core';\nimport { Direction, sizes } from './mg-menu.conf';\nimport type { MenuSizeType, ItemMoreType } from './mg-menu.conf';\n\n@Component({\n tag: 'mg-menu',\n styleUrl: '../../../../../node_modules/@mgdis/styles/dist/components/mg-menu.css',\n shadow: true,\n})\nexport class MgMenu {\n /************\n * Internal *\n ************/\n\n private readonly name = 'mg-menu';\n private menuItems: HTMLMgMenuItemElement[] = [];\n private focusedMenuItem = 0;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgMenuElement;\n\n /**\n * Menu label. Include short menu description.\n * Required for accessibility\n */\n @Prop() label!: string;\n @Watch('label')\n validateLabel(newValue: MgMenu['label']): void {\n if (newValue === undefined) {\n throw new Error(`<${this.name}> prop \"label\" is required.`);\n }\n }\n\n /**\n * Component display direction.\n */\n @Prop({ reflect: true }) direction: Direction = Direction.HORIZONTAL;\n @Watch('direction')\n validateDirection(newValue: MgMenu['direction']): void {\n if (![Direction.VERTICAL, Direction.HORIZONTAL].includes(newValue)) {\n throw new Error(`<${this.name}> prop \"direction\" must be one of: ${Direction.HORIZONTAL}, ${Direction.VERTICAL}.`);\n }\n }\n\n /**\n * Customize \"mg-item-more\" element\n * Used with direction: 'vertical' to manage overflow\n */\n @Prop() itemmore?: ItemMoreType;\n @Watch('itemmore')\n validateItemMore(newValue: MgMenu['itemmore']): void {\n if (newValue !== undefined && this.direction !== Direction.HORIZONTAL) {\n throw new Error(`<${this.name}> prop \"itemmore\" must be paired with direction ${Direction.HORIZONTAL}.`);\n }\n }\n\n /**\n * Define mg-menu size\n */\n @Prop() size: MenuSizeType = 'regular';\n @Watch('size')\n validateSize(newValue: MgMenu['size']): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<${this.name}> prop \"size\" must be one of: ${sizes.join(', ')}.`);\n }\n }\n\n /**\n * is this menu a child menu. Used for conditional render.\n */\n @State() isChildMenu: boolean;\n\n /*************\n * Methods *\n *************/\n\n /**\n * Close matching menu-item\n * @param item - menu-item to close\n * @param condition - addionnal condition\n */\n private closeMenuItem = (item: HTMLMgMenuItemElement, condition: boolean): void => {\n if (!this.isChildMenu && condition) {\n item.expanded = false;\n }\n };\n\n /**\n * get mg-item-more element\n * @returns mg-item-more element\n */\n private getItemMore = (): HTMLMgItemMoreElement => this.element.querySelector('mg-item-more');\n\n /**\n * get mg-item-more child mg-menu-item element\n * @returns mg-menu-item element\n */\n private getItemMoreMenuItem = (): HTMLMgMenuItemElement => this.getItemMore()?.shadowRoot?.querySelector('mg-menu-item');\n\n /**\n * Set item listend\n * @param item - mg-menu-item element\n * @param index - number\n */\n private setItemListener = (item: HTMLMgMenuItemElement, index: MgMenu['focusedMenuItem']): void => {\n ['click', 'focus'].forEach(trigger => {\n (item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, () => {\n this.focusedMenuItem = index;\n // reset expanded on previous active menu item\n (this.getItemMoreMenuItem() ? [...this.menuItems, this.getItemMoreMenuItem()] : this.menuItems).forEach((item, index) => {\n this.closeMenuItem(item, index !== this.focusedMenuItem);\n });\n });\n });\n };\n\n /**\n * Store menu-items on component init and add listeners\n */\n private initMenuItemsListeners = (): void => {\n // add listeners on menu item and edit index\n this.menuItems.forEach((item, index) => {\n this.setItemListener(item, index);\n });\n };\n\n /**\n * Handle item-loaded event on mg-item-more element\n */\n private handleItemLoaded = (): void => {\n this.setItemListener(this.getItemMoreMenuItem(), this.menuItems.length);\n };\n\n /**\n * render mg-item-more\n */\n private renderMgItemMore = (): void => {\n // /!\\ externalise item tag name to get a string type and bypass type checking when value is used in next createElement\n // by doing this we prevent stencil to generate a circular dependencies graph at build time with mg-item-more component.\n const item = 'mg-item-more';\n const mgItemMore = document.createElement(item);\n Object.assign(mgItemMore, this.itemmore);\n mgItemMore.addEventListener('item-loaded', this.handleItemLoaded);\n this.element.appendChild(mgItemMore);\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * Validate props\n */\n componentWillLoad(): void {\n this.validateDirection(this.direction);\n this.validateLabel(this.label);\n this.validateItemMore(this.itemmore);\n this.validateSize(this.size);\n }\n\n /**\n * Check if component slots configuration\n * @returns timeout\n */\n componentDidLoad(): ReturnType<typeof setTimeout> {\n // update props and states after componentDidLoad hook\n // return a promise to process action only in the FIRST render().\n // https://stenciljs.com/docs/component-lifecycle#componentwillload\n return setTimeout(() => {\n // store all menu-items\n this.menuItems = Array.from(this.element.children).filter(child => child.nodeName === 'MG-MENU-ITEM') as HTMLMgMenuItemElement[];\n this.isChildMenu = this.element.closest('mg-menu-item') !== null;\n\n // add mg-item-more to manage OverflowBehavior\n if (this.direction === Direction.HORIZONTAL && !this.isChildMenu) this.renderMgItemMore();\n\n // use mutation observer to improve reactivity\n new MutationObserver(entries => {\n const mgItemMore = this.getItemMore();\n // prevent infinit loop by exclude mg-item-more deletion entry\n if (entries.some(entry => entry.type === 'childList' && Array.from(entry.removedNodes).some(node => node.nodeName === 'MG-ITEM-MORE'))) return;\n else if (mgItemMore !== null) {\n // render a new mg-item-more\n mgItemMore.remove();\n mgItemMore.removeEventListener('item-loaded', this.handleItemLoaded);\n this.renderMgItemMore();\n }\n }).observe(this.element, { childList: true, characterData: true, subtree: true });\n }, 0);\n }\n\n /**\n * Add listeners to items\n */\n componentDidRender(): void {\n this.initMenuItemsListeners();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host role=\"list\" aria-label={this.label}>\n <slot></slot>\n </Host>\n );\n }\n}\n"],"version":3}