@mgdis/mg-components 6.6.1 → 6.8.0
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.
- package/README.md +1 -1
- package/dist/cjs/index-1a5a1081.js +2 -2
- package/dist/cjs/{index-019dd5c0.js → index-234e834a.js} +75 -39
- package/dist/cjs/index-234e834a.js.map +1 -0
- package/dist/cjs/{index.es-903492c5.js → index.es-b90f74d4.js} +2 -2
- package/dist/cjs/index.es-b90f74d4.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{mg-action-more_36.cjs.entry.js → mg-action-more_37.cjs.entry.js} +522 -98
- package/dist/cjs/mg-action-more_37.cjs.entry.js.map +1 -0
- package/dist/cjs/mg-alert.cjs.entry.js +2 -2
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +2 -2
- package/dist/cjs/mg-loader.cjs.entry.js +3 -3
- package/dist/cjs/mg-loader.cjs.entry.js.map +1 -1
- package/dist/cjs/mg-progress.cjs.entry.js +1 -1
- package/dist/collection/assets/icons/index.js +1 -1
- package/dist/collection/assets/icons/index.js.map +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +10 -10
- package/dist/collection/components/atoms/mg-button/mg-button.js.map +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +22 -7
- package/dist/collection/components/atoms/mg-icon/mg-icon.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +46 -19
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +57 -28
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js +7 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.conf.js.map +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +44 -13
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js.map +1 -1
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js.map +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +41 -5
- package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
- package/dist/collection/components/molecules/mg-table/mg-table.conf.js +13 -0
- package/dist/collection/components/molecules/mg-table/mg-table.conf.js.map +1 -0
- package/dist/collection/components/molecules/mg-table/mg-table.js +364 -0
- package/dist/collection/components/molecules/mg-table/mg-table.js.map +1 -0
- package/dist/collection/locales/en/messages.json +33 -16
- package/dist/collection/locales/fr/messages.json +36 -19
- package/dist/collection/utils/floating-ui.utils.js +2 -0
- package/dist/collection/utils/floating-ui.utils.js.map +1 -1
- package/dist/components/floating-ui.utils.js +5 -3
- package/dist/components/floating-ui.utils.js.map +1 -1
- package/dist/components/index.es.js +1 -1
- package/dist/components/index.es.js.map +1 -1
- package/dist/components/index2.js +73 -37
- package/dist/components/index2.js.map +1 -1
- package/dist/components/mg-button2.js +10 -10
- package/dist/components/mg-button2.js.map +1 -1
- package/dist/components/mg-icon2.js +22 -7
- package/dist/components/mg-icon2.js.map +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +2 -2
- package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
- package/dist/components/mg-input-date.js +47 -19
- package/dist/components/mg-input-date.js.map +1 -1
- package/dist/components/mg-input-numeric.js +58 -29
- package/dist/components/mg-input-numeric.js.map +1 -1
- package/dist/components/mg-input-text2.js +50 -14
- package/dist/components/mg-input-text2.js.map +1 -1
- package/dist/components/mg-loader.js +1 -1
- package/dist/components/mg-loader.js.map +1 -1
- package/dist/components/mg-popover2.js +41 -5
- package/dist/components/mg-popover2.js.map +1 -1
- package/dist/components/mg-table.d.ts +11 -0
- package/dist/components/mg-table.js +320 -0
- package/dist/components/mg-table.js.map +1 -0
- package/dist/components/mg-tooltip2.js +1 -1
- package/dist/esm/index-5059254f.js +2 -2
- package/dist/esm/{index-6b7bdd63.js → index-544778a7.js} +75 -39
- package/dist/esm/index-544778a7.js.map +1 -0
- package/dist/esm/{index.es-b80b758c.js → index.es-517b1bf2.js} +2 -2
- package/dist/esm/index.es-517b1bf2.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mg-action-more_36.entry.js → mg-action-more_37.entry.js} +522 -99
- package/dist/esm/mg-action-more_37.entry.js.map +1 -0
- package/dist/esm/mg-alert.entry.js +2 -2
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-input-rich-text-editor.entry.js +2 -2
- package/dist/esm/mg-loader.entry.js +3 -3
- package/dist/esm/mg-loader.entry.js.map +1 -1
- package/dist/esm/mg-progress.entry.js +1 -1
- package/dist/mg-components/locales/en/messages.json +33 -16
- package/dist/mg-components/locales/fr/messages.json +36 -19
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/mg-components.esm.js.map +1 -1
- package/dist/mg-components/{p-3c6710be.js → p-12a1edee.js} +2 -2
- package/dist/mg-components/p-12a1edee.js.map +1 -0
- package/dist/mg-components/p-9bc53279.js +2 -0
- package/dist/mg-components/{p-4049bd40.js.map → p-9bc53279.js.map} +1 -1
- package/dist/mg-components/{p-c4f37d1f.entry.js → p-ad98f3d8.entry.js} +2 -2
- package/dist/mg-components/p-ad98f3d8.entry.js.map +1 -0
- package/dist/mg-components/{p-0ae49cc4.entry.js → p-c10433db.entry.js} +2 -2
- package/dist/mg-components/{p-17f0b7eb.entry.js → p-c67e4934.entry.js} +2 -2
- package/dist/mg-components/p-f72efb64.entry.js +2 -0
- package/dist/mg-components/p-f72efb64.entry.js.map +1 -0
- package/dist/mg-components/{p-361cc090.entry.js → p-fd4a7980.entry.js} +2 -2
- package/dist/types/assets/icons/index.d.ts +4 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +1 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +6 -5
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.conf.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +8 -2
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +14 -0
- package/dist/types/components/molecules/mg-table/mg-table.conf.d.ts +19 -0
- package/dist/types/components/molecules/mg-table/mg-table.d.ts +58 -0
- package/dist/types/components.d.ts +39 -0
- package/dist/types/utils/floating-ui.utils.d.ts +1 -0
- package/ide/intellij/web-types.json +79 -15
- package/ide/vscode/html-custom-data.json +112 -4
- package/package.json +26 -24
- package/dist/cjs/index-019dd5c0.js.map +0 -1
- package/dist/cjs/index.es-903492c5.js.map +0 -1
- package/dist/cjs/mg-action-more_36.cjs.entry.js.map +0 -1
- package/dist/esm/index-6b7bdd63.js.map +0 -1
- package/dist/esm/index.es-b80b758c.js.map +0 -1
- package/dist/esm/mg-action-more_36.entry.js.map +0 -1
- package/dist/mg-components/p-3c6710be.js.map +0 -1
- package/dist/mg-components/p-4049bd40.js +0 -2
- package/dist/mg-components/p-8dbb78aa.entry.js +0 -2
- package/dist/mg-components/p-8dbb78aa.entry.js.map +0 -1
- package/dist/mg-components/p-c4f37d1f.entry.js.map +0 -1
- /package/dist/mg-components/{p-0ae49cc4.entry.js.map → p-c10433db.entry.js.map} +0 -0
- /package/dist/mg-components/{p-17f0b7eb.entry.js.map → p-c67e4934.entry.js.map} +0 -0
- /package/dist/mg-components/{p-361cc090.entry.js.map → p-fd4a7980.entry.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
2
|
import { G as Ge, X as Xe, V as Ve, Y as Ye } from './index.es.js';
|
|
3
|
-
import { a as autoUpdate,
|
|
3
|
+
import { i as isFloatingUIPlacement, s as sides, a as autoUpdate, b as alignments, c as computePosition, o as offset, f as flip, d as shift, l as limitShift, e as arrow } from './floating-ui.utils.js';
|
|
4
4
|
import { d as defineCustomElement$4 } from './mg-button2.js';
|
|
5
5
|
import { d as defineCustomElement$3 } from './mg-card2.js';
|
|
6
6
|
import { d as defineCustomElement$2 } from './mg-icon2.js';
|
|
@@ -50,12 +50,24 @@ const MgPopover = /*@__PURE__*/ proxyCustomElement(class MgPopover extends HTMLE
|
|
|
50
50
|
this.display = false;
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Update aria-expanded attribute on interactive element
|
|
55
|
+
* @param expanded - expanded state
|
|
56
|
+
*/
|
|
57
|
+
this.updateAriaExpanded = (expanded) => {
|
|
58
|
+
const interactiveElement = this.element.querySelector(':not([slot])');
|
|
59
|
+
if (interactiveElement !== null) {
|
|
60
|
+
interactiveElement.setAttribute('aria-expanded', String(expanded));
|
|
61
|
+
}
|
|
62
|
+
};
|
|
53
63
|
/**
|
|
54
64
|
* Show popover
|
|
55
65
|
*/
|
|
56
66
|
this.show = () => {
|
|
57
67
|
// Make the popover visible
|
|
58
68
|
this.mgPopover.dataset.show = '';
|
|
69
|
+
// Update aria-expanded
|
|
70
|
+
this.updateAriaExpanded(true);
|
|
59
71
|
// hide when click outside
|
|
60
72
|
// setTimeout is used to prevent event to trigger after creation
|
|
61
73
|
setTimeout(() => {
|
|
@@ -68,6 +80,8 @@ const MgPopover = /*@__PURE__*/ proxyCustomElement(class MgPopover extends HTMLE
|
|
|
68
80
|
this.hide = () => {
|
|
69
81
|
// Hide the popover
|
|
70
82
|
this.mgPopover.removeAttribute('data-show');
|
|
83
|
+
// Update aria-expanded
|
|
84
|
+
this.updateAriaExpanded(false);
|
|
71
85
|
// Remove event listener
|
|
72
86
|
this.manageClickOutsideListeners('removeEventListener');
|
|
73
87
|
};
|
|
@@ -122,12 +136,34 @@ const MgPopover = /*@__PURE__*/ proxyCustomElement(class MgPopover extends HTMLE
|
|
|
122
136
|
mgPopoverContent.setAttribute('id', this.identifier);
|
|
123
137
|
}
|
|
124
138
|
};
|
|
139
|
+
/**
|
|
140
|
+
* Get alternative placements ordered by proximity to initial placement
|
|
141
|
+
* First check fallbackPlacement attribute, then generate alternatives:
|
|
142
|
+
* 1. Same side with different alignments (start, center, end)
|
|
143
|
+
* 2. Other sides in order
|
|
144
|
+
* @param placement - initial placement
|
|
145
|
+
* @returns array of alternative placements
|
|
146
|
+
*/
|
|
147
|
+
this.getClosestPlacements = (placement) => {
|
|
148
|
+
// First check if fallbackPlacement attribute is defined
|
|
149
|
+
const fallbackPlacements = (this.element.dataset.fallbackPlacement || '')
|
|
150
|
+
.split(',')
|
|
151
|
+
.map(t => t.trim())
|
|
152
|
+
.filter(isFloatingUIPlacement);
|
|
153
|
+
if (fallbackPlacements.length > 0)
|
|
154
|
+
return Array.from(new Set([...fallbackPlacements, ...sides]).values()).filter(isFloatingUIPlacement);
|
|
155
|
+
// Extract side from placement (e.g. "top" from "top-start")
|
|
156
|
+
const [side] = placement.split('-');
|
|
157
|
+
// Generate placements for same side with different alignments
|
|
158
|
+
const currentSidePlacements = alignments.map(alignment => (alignment !== null ? `${side}-${alignment}` : side));
|
|
159
|
+
// Return unique placements: current side variants first, then other sides
|
|
160
|
+
return Array.from(new Set([...currentSidePlacements, ...sides.filter(otherSide => otherSide !== side)])).filter(isFloatingUIPlacement);
|
|
161
|
+
};
|
|
125
162
|
/**
|
|
126
163
|
* Set up Floating UI positioning and arrow behavior
|
|
127
164
|
* @param interactiveElement - Element that triggers the popover
|
|
128
165
|
*/
|
|
129
166
|
this.setFloatingUI = (interactiveElement) => {
|
|
130
|
-
const fallbackPlacements = (this.element.dataset.fallbackPlacement || '').split(',').map(t => t.trim());
|
|
131
167
|
this.floatingUICleanup = autoUpdate(interactiveElement, this.mgPopover, () => {
|
|
132
168
|
computePosition(interactiveElement, this.mgPopover, {
|
|
133
169
|
placement: this.placement,
|
|
@@ -135,7 +171,7 @@ const MgPopover = /*@__PURE__*/ proxyCustomElement(class MgPopover extends HTMLE
|
|
|
135
171
|
middleware: [
|
|
136
172
|
offset(0),
|
|
137
173
|
flip({
|
|
138
|
-
fallbackPlacements:
|
|
174
|
+
fallbackPlacements: this.getClosestPlacements(this.placement),
|
|
139
175
|
}),
|
|
140
176
|
shift({
|
|
141
177
|
limiter: limitShift(),
|
|
@@ -164,7 +200,7 @@ const MgPopover = /*@__PURE__*/ proxyCustomElement(class MgPopover extends HTMLE
|
|
|
164
200
|
// Unlike the floating element, which has both coordinates defined at all times, the arrow only has one defined.
|
|
165
201
|
// Due to this, either x or y will be undefined, depending on the side of placement.
|
|
166
202
|
// The above code uses `isNaN` to check for null and undefined simultaneously.
|
|
167
|
-
// Don
|
|
203
|
+
// Don't remove `isNaN`, because either value can be falsy (0), causing a bug!
|
|
168
204
|
const numberToPx = (number) => (!isNaN(number) ? `${number}px` : '');
|
|
169
205
|
if (arrowElement !== null)
|
|
170
206
|
Object.assign(arrowElement.style, {
|
|
@@ -286,7 +322,7 @@ const MgPopover = /*@__PURE__*/ proxyCustomElement(class MgPopover extends HTMLE
|
|
|
286
322
|
* @returns HTML Element
|
|
287
323
|
*/
|
|
288
324
|
render() {
|
|
289
|
-
return (h(Host, { key: '
|
|
325
|
+
return (h(Host, { key: '085dde7110b2c100db1876d31f7db23e7c1fda5e' }, h("slot", { key: 'dcc6587d5a88784109f1421925992112ef77490d' }), h("slot", { key: '0d1831d325762c99a503a5e461b428a5cb7bdc2c', name: "content" })));
|
|
290
326
|
}
|
|
291
327
|
get element() { return this; }
|
|
292
328
|
static get watchers() { return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"mg-popover2.js","mappings":";;;;;;;;AAAA,MAAM,YAAY,GAAG,muCAAmuC,CAAC;AACzvC,wBAAe,YAAY;;MCad,SAAS;IALtB;;;;;;;;;;QA4BU,eAAU,GAAWA,EAAQ,CAAC,YAAY,CAAC,CAAC;;;;QAa3B,cAAS,GAAyB,QAAQ,CAAC;;;;QAS5D,cAAS,GAAG,KAAK,CAAC;;;;QAUlB,gBAAW,GAAG,KAAK,CAAC;;;;QASH,YAAO,GAAG,KAAK,CAAC;;;;QAcjC,aAAQ,GAAG,KAAK,CAAC;;;;;QAgBjB,iBAAY,GAAG,CAAC,KAA2C;YACjE,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,2BAA2B,IAAI,CAAC,UAAU,IAAI,CAAC,KAAK,IAAI,EAAE;gBAC1J,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;aACtB;SACF,CAAC;;;;QAKM,SAAI,GAAG;;YAEb,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC;;;YAGjC,UAAU,CAAC;gBACT,IAAI,CAAC,2BAA2B,CAAC,kBAAkB,CAAC,CAAC;aACtD,CAAC,CAAC;SACJ,CAAC;;;;QAKM,SAAI,GAAG;;YAEb,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;;YAE5C,IAAI,CAAC,2BAA2B,CAAC,qBAAqB,CAAC,CAAC;SACzD,CAAC;;;;;QAMM,gCAA2B,GAAG,CAAC,MAAkD;;;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,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAA2C;YACjF,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;YAC7D,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,YAAY,CAAC,qBAAqB,CAAC,KAAK,MAAM,EAAE;gBACrG,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;aACtB;SACF,CAAC,CAAC;;QAGH,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC;YACxC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;gBACrB,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;gBAC3B,kBAAkB,CAAC,KAAK,EAAE,CAAC;aAC5B;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAClC;;;;IAKD,oBAAoB;;QAElB,IAAI,CAAC,iBAAiB,EAAE,CAAC;KAC1B;;;;;IAMD,MAAM;QACJ,QACE,EAAC,IAAI,uDACH,8DAAa,EACb,6DAAM,IAAI,EAAC,SAAS,GAAQ,CACvB,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["createID","isValideID","toString","getWindows"],"sources":["../styles/dist/components/mg-popover.css?tag=mg-popover&encapsulation=shadow","src/components/molecules/mg-popover/mg-popover.tsx"],"sourcesContent":["/*!\n * @prop --mg-c-popover-color-background: Defines the background color of the popover. Default value: `--mg-b-color-light`.\n * @prop --mg-c-popover-color-text: Defines the font color of the popover. Default value: `--mg-b-color-font-dark`.\n * @prop --mg-c-popover-title-font-size: Defines the font size of the popover title. Default value: `--mg-b-font-size-h5`.\n * @prop --mg-c-popover-padding-vertical: Defines the vertical padding of the popover. Default value: `unset`, fallback to `--mg-b-size-16`.\n * @prop --mg-c-popover-padding-horizontal: Defines the horizontal padding of the popover. Default value: `unset`, fallback to `--mg-b-size-16`.\n * @prop --mg-c-popover-max-width: Defines the max-width of the popover. Default value: `--mg-b-size-floating-element-max-width`.\n * @prop --mg-c-popover-min-width: Defines the min-width of the popover. Default value: `unset`.\n */:host{--mg-c-card-spacing: var(--mg-c-popover-padding-vertical, var(--mg-b-size-16)) var(--mg-c-popover-padding-horizontal, var(--mg-b-size-16));--mg-c-card-border: none;--mg-c-card-border-radius: var(--mg-b-size-radius);--mg-c-card-color-background: var(--mg-c-popover-color-background);position:relative;display:contents}:host::slotted(*){display:inline-block}/*# sourceMappingURL=mg-popover.css.map */\n","import { Component, Element, Host, h, Prop, Watch, EventEmitter, Event } from '@stencil/core';\nimport { createID, getWindows, isValideID, toString } from '@mgdis/stencil-helpers';\nimport { computePosition, autoUpdate, flip, shift, limitShift, offset, arrow, type Placement } from '@floating-ui/dom';\nimport { isFloatingUIPlacement, type PopoverPlacementType, sides } from './mg-popover.conf';\n\n/**\n * @slot - Element that will display the popover\n * @slot content - popover content\n */\n@Component({\n tag: 'mg-popover',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-popover.css',\n shadow: true,\n})\nexport class MgPopover {\n /************\n * Internal *\n ************/\n\n private mgPopover: HTMLElement;\n private mgPopoverContent: HTMLMgPopoverContentElement;\n private windows: Window[];\n private floatingUICleanup: ReturnType<typeof autoUpdate>;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgPopoverElement;\n\n /**\n * Sets an `id` attribute.\n * Needed by the input for accessibility `aria-decribedby`.\n */\n @Prop() identifier: string = createID('mg-popover');\n @Watch('identifier')\n validateIdentifier(newValue: MgPopover['identifier']): void {\n if (!isValideID(newValue)) {\n throw new Error(`<mg-popover> prop \"identifier\" value is invalid. Passed value: ${toString(newValue)}.`);\n }\n // use renderPopoverContent to update popover-content id\n this.renderPopoverContent();\n }\n\n /**\n * Popover placement\n */\n @Prop({ mutable: true }) placement: PopoverPlacementType = 'bottom';\n @Watch('placement')\n watchPlacement(newValue): void {\n if (!isFloatingUIPlacement(newValue)) this.placement = 'bottom';\n }\n\n /**\n * Hide popover arrow\n */\n @Prop() arrowHide = false;\n @Watch('arrowHide')\n validateArrowHide(newValue: MgPopover['arrowHide']): void {\n if (newValue) this.mgPopoverContent.dataset.arrowHide = '';\n else delete this.mgPopoverContent.dataset.arrowHide;\n }\n\n /**\n * Define if popover has a cross button\n */\n @Prop() closeButton = false;\n @Watch('closeButton')\n validateCloseButton(newValue: MgPopover['closeButton']): void {\n this.mgPopoverContent.closeButton = newValue;\n }\n\n /**\n * Display popover\n */\n @Prop({ mutable: true }) display = false;\n @Watch('display')\n handleDisplay(newValue: boolean): void {\n if (newValue) {\n this.show();\n } else {\n this.hide();\n }\n this.displayChange.emit(newValue);\n }\n\n /**\n * Disable popover\n */\n @Prop() disabled = false;\n\n /**\n * Emited event when display value change\n */\n @Event({ eventName: 'display-change' }) displayChange: EventEmitter<HTMLMgPopoverElement['display']>;\n\n /**\n * Emmited event when popover is closed\n */\n @Event({ eventName: 'component-close' }) componentClose: EventEmitter<void>;\n\n /**\n * Check if clicked outside of component\n * @param event - mouse event\n */\n private clickOutside = (event: MouseEvent & { target: HTMLElement }): void => {\n if (!this.disabled && event.target.closest('mg-popover') !== this.element && event.target.closest(`[data-mg-popover-guard=\"${this.identifier}\"]`) === null) {\n this.display = false;\n }\n };\n\n /**\n * Show popover\n */\n private show = (): void => {\n // Make the popover visible\n this.mgPopover.dataset.show = '';\n // hide when click outside\n // setTimeout is used to prevent event to trigger after creation\n setTimeout(() => {\n this.manageClickOutsideListeners('addEventListener');\n });\n };\n\n /**\n * Hide popover\n */\n private hide = (): void => {\n // Hide the popover\n this.mgPopover.removeAttribute('data-show');\n // Remove event listener\n this.manageClickOutsideListeners('removeEventListener');\n };\n\n /**\n * Manage all clickOustside listeners\n * @param action - top process on elements listeners\n */\n private manageClickOutsideListeners = (action: 'removeEventListener' | 'addEventListener'): void => {\n // clickOutside listeners need to bind windows\n // AND as shawdowDom content is not include on windows listeners `event.target` we need to include popover guard content DOM if it's a web-component\n // by doing this we can get and parse all needeed document DOM elements in clickOutside callback event.details.\n // This result in the givern junction :\n // Windows > document > [data-mg-popover-guard] + [data-mg-popover-guard] > shadowRoot = Windows > document > [data-mg-popover-guard] > shadowRoot\n const guardChildren = Array.from(document.querySelector(`[data-mg-popover-guard=\"${this.identifier}\"]`)?.shadowRoot?.children || new Set());\n [...guardChildren, ...this.windows].forEach((element: Window | HTMLElement) => {\n if (element !== null) {\n element[action]('click', this.clickOutside, false);\n }\n });\n };\n\n /**\n * Handle content hide event\n */\n private handleHideContent = (): void => {\n this.display = false;\n this.componentClose.emit();\n };\n\n /**\n * Render popover content element\n */\n private renderPopoverContent = (): void => {\n const mgPopoverContent = this.element.querySelector('mg-popover-content');\n if (mgPopoverContent === null) {\n this.mgPopoverContent = document.createElement('mg-popover-content');\n this.mgPopoverContent.setAttribute('slot', 'content');\n this.mgPopoverContent.setAttribute('id', this.identifier);\n this.mgPopoverContent.addEventListener('hide-content', this.handleHideContent);\n\n const arrow = document.createElement('div');\n arrow.setAttribute('slot', 'arrow');\n arrow.dataset.floatingArrow = '';\n this.mgPopoverContent.appendChild(arrow);\n\n // insert elements in DOM\n ['[slot=\"title\"]', '[slot=\"content\"]:not(mg-popover-content)'].forEach(slotType => {\n Array.from(this.element.querySelectorAll(slotType)).forEach(slot => {\n this.mgPopoverContent.appendChild(slot);\n });\n });\n this.element.appendChild(this.mgPopoverContent);\n } else {\n mgPopoverContent.setAttribute('id', this.identifier);\n }\n };\n\n /**\n * Set up Floating UI positioning and arrow behavior\n * @param interactiveElement - Element that triggers the popover\n */\n private setFloatingUI = (interactiveElement: HTMLElement): void => {\n const fallbackPlacements = (this.element.dataset.fallbackPlacement || '').split(',').map(t => t.trim());\n\n this.floatingUICleanup = autoUpdate(interactiveElement, this.mgPopover, () => {\n computePosition(interactiveElement, this.mgPopover, {\n placement: this.placement as Placement,\n strategy: 'fixed',\n middleware: [\n offset(0),\n flip({\n fallbackPlacements: Array.from(new Set([...fallbackPlacements, ...sides]).values()).filter(isFloatingUIPlacement), // simulate \"auto\" placement with default fallback values\n }),\n shift({\n limiter: limitShift(),\n }),\n arrow({\n element: this.mgPopover.querySelector('[data-floating-arrow]'),\n }),\n ],\n }).then(({ x, y, placement, middlewareData }) => {\n Object.assign(this.mgPopover.style, {\n position: 'fixed',\n top: '0',\n left: '0',\n transform: `translate(${Math.round(x)}px, ${Math.round(y)}px)`,\n });\n\n // Update arrow style\n const staticSide = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n }[placement.split('-')[0]];\n\n const arrowElement: HTMLElement = this.mgPopover.querySelector('[data-floating-arrow]');\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n // https://floating-ui.com/docs/arrow\n // Unlike the floating element, which has both coordinates defined at all times, the arrow only has one defined.\n // Due to this, either x or y will be undefined, depending on the side of placement.\n // The above code uses `isNaN` to check for null and undefined simultaneously.\n // Don’t remove `isNaN`, because either value can be falsy (0), causing a bug!\n const numberToPx = (number: number): string => (!isNaN(number) ? `${number}px` : '');\n\n if (arrowElement !== null)\n Object.assign(arrowElement.style, {\n position: 'absolute',\n left: numberToPx(arrowX),\n top: numberToPx(arrowY),\n [staticSide]: '1px',\n });\n\n this.mgPopover.setAttribute('data-placement', placement);\n });\n });\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * update popper position after props change on component did update hook to benefit from render ended\n */\n componentDidUpdate(): void {\n this.floatingUICleanup();\n }\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Get windows to attach events\n this.windows = getWindows(window);\n // render mg-popover-content slot\n this.renderPopoverContent();\n this.validateCloseButton(this.closeButton);\n this.validateIdentifier(this.identifier);\n this.validateArrowHide(this.arrowHide);\n this.watchPlacement(this.placement);\n }\n\n /**\n * Check if component props are well configured on init\n */\n componentDidLoad(): void {\n // Get popover content\n this.mgPopover = this.element.querySelector(`#${this.identifier}`);\n\n // Get interactive element (first element without slot attribute)\n const interactiveElement: HTMLElement = this.element.querySelector(':not([slot])');\n\n // Add aria attributes\n interactiveElement.setAttribute('aria-controls', this.identifier);\n interactiveElement.setAttribute('aria-expanded', `${this.display}`);\n\n // Initial styles configuration\n Object.assign(this.mgPopover.style, {\n position: 'fixed',\n });\n\n // Create Floating UI instance\n this.setFloatingUI(interactiveElement);\n\n // Add resize observer\n [interactiveElement, this.mgPopoverContent].forEach(element => {\n new ResizeObserver(() => {\n this.floatingUICleanup();\n this.setFloatingUI(interactiveElement);\n }).observe(element);\n });\n\n // Add events to toggle display\n interactiveElement.addEventListener('click', () => {\n if (!this.disabled) this.display = !this.display;\n });\n\n this.element.addEventListener('click', (event: MouseEvent & { target: HTMLElement }): void => {\n const target = event.target.closest('[popovertargetaction]');\n if (this.display === true && target !== null && target.getAttribute('popovertargetaction') === 'hide') {\n this.display = false;\n }\n });\n\n // Add events to hide popover\n this.element.addEventListener('keydown', e => {\n if (!this.disabled && e.code === 'Escape') {\n this.display = false;\n this.componentClose.emit();\n interactiveElement.focus();\n }\n });\n\n this.handleDisplay(this.display);\n }\n\n /**\n * Cleanup when component is disconnected\n */\n disconnectedCallback(): void {\n // Cleanup Floating UI instance\n this.floatingUICleanup();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host>\n <slot></slot>\n <slot name=\"content\"></slot>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"mg-popover2.js","mappings":";;;;;;;;AAAA,MAAM,YAAY,GAAG,muCAAmuC,CAAC;AACzvC,wBAAe,YAAY;;MCad,SAAS;IALtB;;;;;;;;;;QA4BU,eAAU,GAAWA,EAAQ,CAAC,YAAY,CAAC,CAAC;;;;QAa3B,cAAS,GAAyB,QAAQ,CAAC;;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C;QAEH,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAClC;;;;IAKD,oBAAoB;;QAElB,IAAI,CAAC,iBAAiB,EAAE,CAAC;KAC1B;;;;;IAMD,MAAM;QACJ,QACE,EAAC,IAAI,uDACH,8DAAa,EACb,6DAAM,IAAI,EAAC,SAAS,GAAQ,CACvB,EACP;KACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["createID","isValideID","toString","getWindows"],"sources":["../styles/dist/components/mg-popover.css?tag=mg-popover&encapsulation=shadow","src/components/molecules/mg-popover/mg-popover.tsx"],"sourcesContent":["/*!\n * @prop --mg-c-popover-color-background: Defines the background color of the popover. Default value: `--mg-b-color-light`.\n * @prop --mg-c-popover-color-text: Defines the font color of the popover. Default value: `--mg-b-color-font-dark`.\n * @prop --mg-c-popover-title-font-size: Defines the font size of the popover title. Default value: `--mg-b-font-size-h5`.\n * @prop --mg-c-popover-padding-vertical: Defines the vertical padding of the popover. Default value: `unset`, fallback to `--mg-b-size-16`.\n * @prop --mg-c-popover-padding-horizontal: Defines the horizontal padding of the popover. Default value: `unset`, fallback to `--mg-b-size-16`.\n * @prop --mg-c-popover-max-width: Defines the max-width of the popover. Default value: `--mg-b-size-floating-element-max-width`.\n * @prop --mg-c-popover-min-width: Defines the min-width of the popover. Default value: `unset`.\n */:host{--mg-c-card-spacing: var(--mg-c-popover-padding-vertical, var(--mg-b-size-16)) var(--mg-c-popover-padding-horizontal, var(--mg-b-size-16));--mg-c-card-border: none;--mg-c-card-border-radius: var(--mg-b-size-radius);--mg-c-card-color-background: var(--mg-c-popover-color-background);position:relative;display:contents}:host::slotted(*){display:inline-block}/*# sourceMappingURL=mg-popover.css.map */\n","import { Component, Element, Host, h, Prop, Watch, EventEmitter, Event } from '@stencil/core';\nimport { createID, getWindows, isValideID, toString } from '@mgdis/stencil-helpers';\nimport { computePosition, autoUpdate, flip, shift, limitShift, offset, arrow, type Placement } from '@floating-ui/dom';\nimport { isFloatingUIPlacement, type PopoverPlacementType, sides, alignments } from './mg-popover.conf';\n\n/**\n * @slot - Element that will display the popover\n * @slot content - popover content\n */\n@Component({\n tag: 'mg-popover',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-popover.css',\n shadow: true,\n})\nexport class MgPopover {\n /************\n * Internal *\n ************/\n\n private mgPopover: HTMLElement;\n private mgPopoverContent: HTMLMgPopoverContentElement;\n private windows: Window[];\n private floatingUICleanup: ReturnType<typeof autoUpdate>;\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgPopoverElement;\n\n /**\n * Sets an `id` attribute.\n * Needed by the input for accessibility `aria-decribedby`.\n */\n @Prop() identifier: string = createID('mg-popover');\n @Watch('identifier')\n validateIdentifier(newValue: MgPopover['identifier']): void {\n if (!isValideID(newValue)) {\n throw new Error(`<mg-popover> prop \"identifier\" value is invalid. Passed value: ${toString(newValue)}.`);\n }\n // use renderPopoverContent to update popover-content id\n this.renderPopoverContent();\n }\n\n /**\n * Popover placement\n */\n @Prop({ mutable: true }) placement: PopoverPlacementType = 'bottom';\n @Watch('placement')\n watchPlacement(newValue): void {\n if (!isFloatingUIPlacement(newValue)) this.placement = 'bottom';\n }\n\n /**\n * Hide popover arrow\n */\n @Prop() arrowHide = false;\n @Watch('arrowHide')\n validateArrowHide(newValue: MgPopover['arrowHide']): void {\n if (newValue) this.mgPopoverContent.dataset.arrowHide = '';\n else delete this.mgPopoverContent.dataset.arrowHide;\n }\n\n /**\n * Define if popover has a cross button\n */\n @Prop() closeButton = false;\n @Watch('closeButton')\n validateCloseButton(newValue: MgPopover['closeButton']): void {\n this.mgPopoverContent.closeButton = newValue;\n }\n\n /**\n * Display popover\n */\n @Prop({ mutable: true }) display = false;\n @Watch('display')\n handleDisplay(newValue: boolean): void {\n if (newValue) {\n this.show();\n } else {\n this.hide();\n }\n this.displayChange.emit(newValue);\n }\n\n /**\n * Disable popover\n */\n @Prop() disabled = false;\n\n /**\n * Emited event when display value change\n */\n @Event({ eventName: 'display-change' }) displayChange: EventEmitter<HTMLMgPopoverElement['display']>;\n\n /**\n * Emmited event when popover is closed\n */\n @Event({ eventName: 'component-close' }) componentClose: EventEmitter<void>;\n\n /**\n * Check if clicked outside of component\n * @param event - mouse event\n */\n private clickOutside = (event: MouseEvent & { target: HTMLElement }): void => {\n if (!this.disabled && event.target.closest('mg-popover') !== this.element && event.target.closest(`[data-mg-popover-guard=\"${this.identifier}\"]`) === null) {\n this.display = false;\n }\n };\n\n /**\n * Update aria-expanded attribute on interactive element\n * @param expanded - expanded state\n */\n private updateAriaExpanded = (expanded: boolean): void => {\n const interactiveElement = this.element.querySelector(':not([slot])');\n if (interactiveElement !== null) {\n interactiveElement.setAttribute('aria-expanded', String(expanded));\n }\n };\n\n /**\n * Show popover\n */\n private show = (): void => {\n // Make the popover visible\n this.mgPopover.dataset.show = '';\n // Update aria-expanded\n this.updateAriaExpanded(true);\n // hide when click outside\n // setTimeout is used to prevent event to trigger after creation\n setTimeout(() => {\n this.manageClickOutsideListeners('addEventListener');\n });\n };\n\n /**\n * Hide popover\n */\n private hide = (): void => {\n // Hide the popover\n this.mgPopover.removeAttribute('data-show');\n // Update aria-expanded\n this.updateAriaExpanded(false);\n // Remove event listener\n this.manageClickOutsideListeners('removeEventListener');\n };\n\n /**\n * Manage all clickOustside listeners\n * @param action - top process on elements listeners\n */\n private manageClickOutsideListeners = (action: 'removeEventListener' | 'addEventListener'): void => {\n // clickOutside listeners need to bind windows\n // AND as shawdowDom content is not include on windows listeners `event.target` we need to include popover guard content DOM if it's a web-component\n // by doing this we can get and parse all needeed document DOM elements in clickOutside callback event.details.\n // This result in the givern junction :\n // Windows > document > [data-mg-popover-guard] + [data-mg-popover-guard] > shadowRoot = Windows > document > [data-mg-popover-guard] > shadowRoot\n const guardChildren = Array.from(document.querySelector(`[data-mg-popover-guard=\"${this.identifier}\"]`)?.shadowRoot?.children || new Set());\n [...guardChildren, ...this.windows].forEach((element: Window | HTMLElement) => {\n if (element !== null) {\n element[action]('click', this.clickOutside, false);\n }\n });\n };\n\n /**\n * Handle content hide event\n */\n private handleHideContent = (): void => {\n this.display = false;\n this.componentClose.emit();\n };\n\n /**\n * Render popover content element\n */\n private renderPopoverContent = (): void => {\n const mgPopoverContent = this.element.querySelector('mg-popover-content');\n if (mgPopoverContent === null) {\n this.mgPopoverContent = document.createElement('mg-popover-content');\n this.mgPopoverContent.setAttribute('slot', 'content');\n this.mgPopoverContent.setAttribute('id', this.identifier);\n this.mgPopoverContent.addEventListener('hide-content', this.handleHideContent);\n\n const arrow = document.createElement('div');\n arrow.setAttribute('slot', 'arrow');\n arrow.dataset.floatingArrow = '';\n this.mgPopoverContent.appendChild(arrow);\n\n // insert elements in DOM\n ['[slot=\"title\"]', '[slot=\"content\"]:not(mg-popover-content)'].forEach(slotType => {\n Array.from(this.element.querySelectorAll(slotType)).forEach(slot => {\n this.mgPopoverContent.appendChild(slot);\n });\n });\n this.element.appendChild(this.mgPopoverContent);\n } else {\n mgPopoverContent.setAttribute('id', this.identifier);\n }\n };\n\n /**\n * Get alternative placements ordered by proximity to initial placement\n * First check fallbackPlacement attribute, then generate alternatives:\n * 1. Same side with different alignments (start, center, end)\n * 2. Other sides in order\n * @param placement - initial placement\n * @returns array of alternative placements\n */\n private getClosestPlacements = (placement: PopoverPlacementType): Placement[] => {\n // First check if fallbackPlacement attribute is defined\n const fallbackPlacements = (this.element.dataset.fallbackPlacement || '')\n .split(',')\n .map(t => t.trim())\n .filter(isFloatingUIPlacement);\n if (fallbackPlacements.length > 0) return Array.from(new Set([...fallbackPlacements, ...sides]).values()).filter(isFloatingUIPlacement);\n\n // Extract side from placement (e.g. \"top\" from \"top-start\")\n const [side] = placement.split('-');\n\n // Generate placements for same side with different alignments\n const currentSidePlacements = alignments.map(alignment => (alignment !== null ? `${side}-${alignment}` : side));\n\n // Return unique placements: current side variants first, then other sides\n return Array.from(new Set([...currentSidePlacements, ...sides.filter(otherSide => otherSide !== side)])).filter(isFloatingUIPlacement);\n };\n\n /**\n * Set up Floating UI positioning and arrow behavior\n * @param interactiveElement - Element that triggers the popover\n */\n private setFloatingUI = (interactiveElement: HTMLElement): void => {\n this.floatingUICleanup = autoUpdate(interactiveElement, this.mgPopover, () => {\n computePosition(interactiveElement, this.mgPopover, {\n placement: this.placement as Placement,\n strategy: 'fixed',\n middleware: [\n offset(0),\n flip({\n fallbackPlacements: this.getClosestPlacements(this.placement),\n }),\n shift({\n limiter: limitShift(),\n }),\n arrow({\n element: this.mgPopover.querySelector('[data-floating-arrow]'),\n }),\n ],\n }).then(({ x, y, placement, middlewareData }) => {\n Object.assign(this.mgPopover.style, {\n position: 'fixed',\n top: '0',\n left: '0',\n transform: `translate(${Math.round(x)}px, ${Math.round(y)}px)`,\n });\n\n // Update arrow style\n const staticSide = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n }[placement.split('-')[0]];\n\n const arrowElement: HTMLElement = this.mgPopover.querySelector('[data-floating-arrow]');\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n // https://floating-ui.com/docs/arrow\n // Unlike the floating element, which has both coordinates defined at all times, the arrow only has one defined.\n // Due to this, either x or y will be undefined, depending on the side of placement.\n // The above code uses `isNaN` to check for null and undefined simultaneously.\n // Don't remove `isNaN`, because either value can be falsy (0), causing a bug!\n const numberToPx = (number: number): string => (!isNaN(number) ? `${number}px` : '');\n\n if (arrowElement !== null)\n Object.assign(arrowElement.style, {\n position: 'absolute',\n left: numberToPx(arrowX),\n top: numberToPx(arrowY),\n [staticSide]: '1px',\n });\n\n this.mgPopover.setAttribute('data-placement', placement);\n });\n });\n };\n\n /*************\n * Lifecycle *\n *************/\n\n /**\n * update popper position after props change on component did update hook to benefit from render ended\n */\n componentDidUpdate(): void {\n this.floatingUICleanup();\n }\n\n /**\n * Check if component props are well configured on init\n */\n componentWillLoad(): void {\n // Get windows to attach events\n this.windows = getWindows(window);\n // render mg-popover-content slot\n this.renderPopoverContent();\n this.validateCloseButton(this.closeButton);\n this.validateIdentifier(this.identifier);\n this.validateArrowHide(this.arrowHide);\n this.watchPlacement(this.placement);\n }\n\n /**\n * Check if component props are well configured on init\n */\n componentDidLoad(): void {\n // Get popover content\n this.mgPopover = this.element.querySelector(`#${this.identifier}`);\n\n // Get interactive element (first element without slot attribute)\n const interactiveElement: HTMLElement = this.element.querySelector(':not([slot])');\n\n // Add aria attributes\n interactiveElement.setAttribute('aria-controls', this.identifier);\n interactiveElement.setAttribute('aria-expanded', `${this.display}`);\n\n // Initial styles configuration\n Object.assign(this.mgPopover.style, {\n position: 'fixed',\n });\n\n // Create Floating UI instance\n this.setFloatingUI(interactiveElement);\n\n // Add resize observer\n [interactiveElement, this.mgPopoverContent].forEach(element => {\n new ResizeObserver(() => {\n this.floatingUICleanup();\n this.setFloatingUI(interactiveElement);\n }).observe(element);\n });\n\n // Add events to toggle display\n interactiveElement.addEventListener('click', () => {\n if (!this.disabled) this.display = !this.display;\n });\n\n this.element.addEventListener('click', (event: MouseEvent & { target: HTMLElement }): void => {\n const target = event.target.closest('[popovertargetaction]');\n if (this.display === true && target !== null && target.getAttribute('popovertargetaction') === 'hide') {\n this.display = false;\n }\n });\n\n // Add events to hide popover\n this.element.addEventListener('keydown', e => {\n if (!this.disabled && e.code === 'Escape') {\n this.display = false;\n this.componentClose.emit();\n interactiveElement.focus();\n }\n });\n\n this.handleDisplay(this.display);\n }\n\n /**\n * Cleanup when component is disconnected\n */\n disconnectedCallback(): void {\n // Cleanup Floating UI instance\n this.floatingUICleanup();\n }\n\n /**\n * Render\n * @returns HTML Element\n */\n render(): HTMLElement {\n return (\n <Host>\n <slot></slot>\n <slot name=\"content\"></slot>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface MgTable extends Components.MgTable, HTMLElement {}
|
|
4
|
+
export const MgTable: {
|
|
5
|
+
prototype: MgTable;
|
|
6
|
+
new (): MgTable;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement } from '@stencil/core/internal/client';
|
|
2
|
+
import { Z as Ze, V as Ve, m as me, G as Ge } from './index.es.js';
|
|
3
|
+
import { i as initLocales } from './index2.js';
|
|
4
|
+
import { d as defineCustomElement$2 } from './mg-icon2.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sizes
|
|
8
|
+
*/
|
|
9
|
+
// Define possible sizes
|
|
10
|
+
const sizes = ['small', 'medium', 'large', 'xlarge'];
|
|
11
|
+
/**
|
|
12
|
+
* Columns
|
|
13
|
+
*/
|
|
14
|
+
// Define possible text alignments
|
|
15
|
+
const textAlignments = ['left', 'center', 'right'];
|
|
16
|
+
// Define possible data types
|
|
17
|
+
const dataTypes = ['string', 'numeric', 'date'];
|
|
18
|
+
|
|
19
|
+
const mgTableCss = ".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}}@font-face{font-family:\"Open Sans\";src:url(\"fonts/OpenSans-Regular.ttf\") format(\"truetype\")}@font-face{font-family:\"Open Sans\";font-weight:600;src:url(\"fonts/OpenSans-SemiBold.ttf\") format(\"truetype\")}@font-face{font-family:\"Open Sans\";font-weight:700;src:url(\"fonts/OpenSans-Bold.ttf\") format(\"truetype\")}p{margin:0}p+p{margin-top:var(--mg-b-size-8)}h1,.mg-u-h1{font-family:var(--mg-b-font-family-heading);font-weight:bold}h2,.mg-u-h2{font-family:var(--mg-b-font-family-heading);font-weight:bold}h3,.mg-u-h3{font-family:var(--mg-b-font-family-heading);font-weight:bold}h4,.mg-u-h4{font-family:var(--mg-b-font-family-heading);font-weight:bold}h5,.mg-u-h5{font-family:var(--mg-b-font-family-heading);font-weight:bold}h6,.mg-u-h6{font-family:var(--mg-b-font-family-heading);font-weight:bold}h1,.mg-u-h1{font-size:var(--mg-b-font-size-h1)}h2,.mg-u-h2{font-size:var(--mg-b-font-size-h2)}h3,.mg-u-h3{font-size:var(--mg-b-font-size-h3)}h4,.mg-u-h4{font-size:var(--mg-b-font-size-h4)}h5,.mg-u-h5{font-size:var(--mg-b-font-size-h5)}h6,.mg-u-h6{font-size:var(--mg-b-font-size-h6)}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}small{font-size:var(--mg-b-small-font-size)}.mg-u-text-left{text-align:left !important}.mg-u-text-center{text-align:center !important}.mg-u-text-right{text-align:right !important}.mg-c-table{--mg-c-table-cell-spacing:var(--mg-b-size-8) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-40);--mg-c-table-header-cell-height:calc(var(--mg-b-size-min-height) + 2 * var(--mg-b-size-8));overflow:hidden;border:none;border-radius:var(--mg-b-size-8);background:var(--mg-b-color-light);border-collapse:separate;border-spacing:0;color:var(--mg-b-color-dark)}.mg-c-table td,.mg-c-table th{height:var(--mg-c-table-cell-height);box-sizing:border-box;padding:var(--mg-c-table-cell-spacing);text-align:start}.mg-c-table thead td,.mg-c-table th{font-weight:600}.mg-c-table thead{height:var(--mg-c-table-header-cell-height);background-color:var(--mg-b-color-app);color:var(--mg-b-color-light)}.mg-c-table :not(thead) tr:nth-child(even){background:color-mix(in srgb, var(--mg-b-color-app), transparent 80%)}.mg-c-table.mg-c-table--size-small{--mg-c-table-cell-spacing:var(--mg-b-size-4) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-32);--mg-c-table-header-cell-height:var(--mg-b-size-32)}.mg-c-table.mg-c-table--size-large{--mg-c-table-cell-height:var(--mg-c-table-header-cell-height)}.mg-c-table.mg-c-table--size-xlarge{--mg-c-table-cell-spacing:var(--mg-b-size-12) var(--mg-b-size-16);--mg-c-table-cell-height:var(--mg-b-size-64);--mg-c-table-header-cell-height:var(--mg-b-size-64)}.mg-c-table.mg-c-table--full-width{width:100%}.mg-c-table-wrapper{overflow:auto}.mg-c-table thead td,.mg-c-table thead th{position:relative}.mg-c-table thead td .mg-c-table__sort-button,.mg-c-table thead th .mg-c-table__sort-button{padding:0;border:none;margin:0;background:none;color:inherit;font-size:inherit;font-weight:600}.mg-c-table thead td .mg-c-table__sort-button::after,.mg-c-table thead th .mg-c-table__sort-button::after{position:absolute;content:\"\";inset:0}.mg-c-table thead td .mg-c-table__sort-button:hover,.mg-c-table thead th .mg-c-table__sort-button:hover{cursor:pointer}.mg-c-table thead td .mg-c-table__sort-button mg-icon,.mg-c-table thead th .mg-c-table__sort-button mg-icon{margin-left:var(--mg-b-size-4)}.mg-c-table thead td:has(.mg-c-table__sort-button):hover,.mg-c-table thead td[aria-sort=descending],.mg-c-table thead td[aria-sort=ascending],.mg-c-table thead th:has(.mg-c-table__sort-button):hover,.mg-c-table thead th[aria-sort=descending],.mg-c-table thead th[aria-sort=ascending]{background-color:color-mix(in srgb, var(--mg-b-color-app), black 10%)}";
|
|
20
|
+
const MgTableStyle0 = mgTableCss;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Check if value is a valid align object
|
|
24
|
+
* @param newValue - New value
|
|
25
|
+
* @returns True if value is a valid align object
|
|
26
|
+
*/
|
|
27
|
+
const isValidColumnsObject = (newValue) =>
|
|
28
|
+
// ensure newValue is an object
|
|
29
|
+
typeof newValue === 'object' &&
|
|
30
|
+
!Array.isArray(newValue) &&
|
|
31
|
+
// Ensure every property is well formatted
|
|
32
|
+
Object.entries(newValue).every(([key, value]) =>
|
|
33
|
+
// ensure key is a number
|
|
34
|
+
!isNaN(parseInt(key)) &&
|
|
35
|
+
// ensure value is an object
|
|
36
|
+
typeof value === 'object' &&
|
|
37
|
+
!Array.isArray(value) &&
|
|
38
|
+
// ensure value has at least one of the following properties
|
|
39
|
+
((value.align !== undefined && textAlignments.includes(value.align)) ||
|
|
40
|
+
(value.sortable !== undefined && typeof value.sortable === 'boolean') ||
|
|
41
|
+
(value.datatype !== undefined && dataTypes.includes(value.datatype))) &&
|
|
42
|
+
// ensure no extra properties are present
|
|
43
|
+
Object.keys(value).every(key => ['align', 'sortable', 'datatype'].includes(key)));
|
|
44
|
+
/**
|
|
45
|
+
* Compare values
|
|
46
|
+
* @param firstValue - First value
|
|
47
|
+
* @param secondValue - Second value
|
|
48
|
+
* @param descending - Define descending order
|
|
49
|
+
* @param datatype - Data type
|
|
50
|
+
* @returns Comparison result
|
|
51
|
+
* @example
|
|
52
|
+
* compareValues('a', 'b', false, 'string'); // -1
|
|
53
|
+
*/
|
|
54
|
+
const compareValues = (firstValue, secondValue, descending, datatype) => {
|
|
55
|
+
if (descending) {
|
|
56
|
+
const temp = firstValue;
|
|
57
|
+
firstValue = secondValue;
|
|
58
|
+
secondValue = temp;
|
|
59
|
+
}
|
|
60
|
+
if (datatype === 'date') {
|
|
61
|
+
return new Date(firstValue).getTime() - new Date(secondValue).getTime();
|
|
62
|
+
}
|
|
63
|
+
return firstValue.localeCompare(secondValue, undefined, { numeric: datatype === 'numeric' });
|
|
64
|
+
};
|
|
65
|
+
const MgTable$1 = /*@__PURE__*/ proxyCustomElement(class MgTable extends HTMLElement {
|
|
66
|
+
constructor() {
|
|
67
|
+
super();
|
|
68
|
+
this.__registerHost();
|
|
69
|
+
this.__attachShadow();
|
|
70
|
+
// Classes
|
|
71
|
+
this.componentClass = 'mg-c-table';
|
|
72
|
+
this.componentWrapperClass = 'mg-c-table-wrapper';
|
|
73
|
+
this.classFullWidth = 'mg-c-table--full-width';
|
|
74
|
+
// Alignment stylesheet
|
|
75
|
+
this.alignmentStylesheet = new CSSStyleSheet();
|
|
76
|
+
/**
|
|
77
|
+
* Define table size
|
|
78
|
+
*/
|
|
79
|
+
this.size = 'medium';
|
|
80
|
+
/**
|
|
81
|
+
* Define if table fits its parent element
|
|
82
|
+
*/
|
|
83
|
+
this.fullWidth = false;
|
|
84
|
+
/**
|
|
85
|
+
* Class collection
|
|
86
|
+
*/
|
|
87
|
+
this.classCollection = new Ze([this.componentClass]);
|
|
88
|
+
}
|
|
89
|
+
watchSize(newValue, oldValue) {
|
|
90
|
+
if (!sizes.includes(newValue)) {
|
|
91
|
+
throw new Error(`<mg-table> prop "size" must be one of: ${sizes.join(', ')}. Passed value: ${Ve(newValue)}.`);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
if (oldValue !== undefined) {
|
|
95
|
+
this.classCollection.delete(`mg-c-table--size-${oldValue}`);
|
|
96
|
+
}
|
|
97
|
+
this.classCollection.add(`mg-c-table--size-${newValue}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
watchFullWidth(newValue) {
|
|
101
|
+
if (newValue) {
|
|
102
|
+
this.classCollection.add(this.classFullWidth);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this.classCollection.delete(this.classFullWidth);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
watchColumns(newValue) {
|
|
109
|
+
if (newValue !== undefined && !isValidColumnsObject(newValue)) {
|
|
110
|
+
throw new Error(`<mg-table> prop "columns" must be a ColumnsType object. Passed value: ${Ve(newValue)}.`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Render Table
|
|
115
|
+
* @param table - Table element
|
|
116
|
+
*/
|
|
117
|
+
renderTable(table) {
|
|
118
|
+
let isSortable = false;
|
|
119
|
+
// Remove table classes
|
|
120
|
+
table.className = '';
|
|
121
|
+
// Add table classes
|
|
122
|
+
table.classList.add(...this.classCollection.classes);
|
|
123
|
+
// Set columns based on columns prop
|
|
124
|
+
if (this.columns !== undefined) {
|
|
125
|
+
// Store original rows
|
|
126
|
+
const rowsDefault = Array.from(table.querySelectorAll('tbody tr'));
|
|
127
|
+
// Apply columns settings
|
|
128
|
+
Object.entries(this.columns).forEach(([key, value]) => {
|
|
129
|
+
// Add alignment to stylesheet
|
|
130
|
+
if (value.align !== undefined) {
|
|
131
|
+
this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:${value.align}}}`);
|
|
132
|
+
}
|
|
133
|
+
// if align is not defined and datatype is number, align right
|
|
134
|
+
else if (value.datatype === 'numeric') {
|
|
135
|
+
this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:right}}`);
|
|
136
|
+
}
|
|
137
|
+
// Define if column is sortable
|
|
138
|
+
if (value.sortable) {
|
|
139
|
+
isSortable = true;
|
|
140
|
+
// Add sortable class to table header
|
|
141
|
+
const sortableHeader = table.querySelector(`thead td:nth-child(${key}),thead th:nth-child(${key})`);
|
|
142
|
+
// Create button
|
|
143
|
+
const button = document.createElement('button');
|
|
144
|
+
button.classList.add('mg-c-table__sort-button');
|
|
145
|
+
// Append button to header
|
|
146
|
+
const sortableHeaderContent = sortableHeader.innerHTML;
|
|
147
|
+
sortableHeader.innerHTML = '';
|
|
148
|
+
button.innerHTML = sortableHeaderContent;
|
|
149
|
+
// Set icon
|
|
150
|
+
const icon = document.createElement('mg-icon');
|
|
151
|
+
icon.setAttribute('icon', 'arrows-up-down');
|
|
152
|
+
// Append icon to button
|
|
153
|
+
button.append(icon);
|
|
154
|
+
sortableHeader.append(button);
|
|
155
|
+
// Add event listener
|
|
156
|
+
button.addEventListener('click', () => {
|
|
157
|
+
// Reset aria pressed
|
|
158
|
+
table.querySelectorAll(`thead td:not(:nth-child(${key})) [aria-pressed],thead th:not(:nth-child(${key})) [aria-pressed]`).forEach(ariaPressed => {
|
|
159
|
+
ariaPressed.removeAttribute('aria-pressed');
|
|
160
|
+
ariaPressed.querySelector('mg-icon').setAttribute('icon', 'arrows-up-down');
|
|
161
|
+
});
|
|
162
|
+
// Reset aria sort
|
|
163
|
+
table.querySelectorAll(`thead td:not(:nth-child(${key}))[aria-sort],thead th:not(:nth-child(${key}))[aria-sort]`).forEach(ariaSort => {
|
|
164
|
+
ariaSort.removeAttribute('aria-sort');
|
|
165
|
+
});
|
|
166
|
+
// Set aria pressed
|
|
167
|
+
button.setAttribute('aria-pressed', 'true');
|
|
168
|
+
// Manage sort order
|
|
169
|
+
// Get sort order
|
|
170
|
+
let sortOrder = sortableHeader.getAttribute('aria-sort');
|
|
171
|
+
// First click sort asc
|
|
172
|
+
if ([null, 'none'].includes(sortOrder)) {
|
|
173
|
+
sortableHeader.setAttribute('aria-sort', 'ascending');
|
|
174
|
+
}
|
|
175
|
+
// Second click sort desc
|
|
176
|
+
else if (sortOrder === 'ascending') {
|
|
177
|
+
sortableHeader.setAttribute('aria-sort', 'descending');
|
|
178
|
+
}
|
|
179
|
+
// Third click remove sort
|
|
180
|
+
else {
|
|
181
|
+
sortableHeader.setAttribute('aria-sort', 'none');
|
|
182
|
+
}
|
|
183
|
+
// Update sort order
|
|
184
|
+
sortOrder = sortableHeader.getAttribute('aria-sort');
|
|
185
|
+
// Update button icon
|
|
186
|
+
const icon = button.querySelector('mg-icon');
|
|
187
|
+
let iconType = 'arrows-up-down';
|
|
188
|
+
if (sortOrder === 'ascending') {
|
|
189
|
+
iconType = 'arrow-up';
|
|
190
|
+
}
|
|
191
|
+
else if (sortOrder === 'descending') {
|
|
192
|
+
iconType = 'arrow-down';
|
|
193
|
+
}
|
|
194
|
+
icon.setAttribute('icon', iconType);
|
|
195
|
+
// If sort order is none, return to original order
|
|
196
|
+
if (sortOrder === 'none') {
|
|
197
|
+
// Append rows to table
|
|
198
|
+
rowsDefault.forEach(row => table.querySelector('tbody').append(row));
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
// Set a copy of rows
|
|
202
|
+
const rows = Array.from(table.querySelectorAll('tbody tr'));
|
|
203
|
+
// Sort rows
|
|
204
|
+
rows.sort((a, b) => {
|
|
205
|
+
var _a, _b;
|
|
206
|
+
// Get cells
|
|
207
|
+
const cellA = a.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);
|
|
208
|
+
const cellB = b.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);
|
|
209
|
+
// Get cell values
|
|
210
|
+
const cellValueA = (_a = cellA.dataset.sort) !== null && _a !== void 0 ? _a : cellA.textContent;
|
|
211
|
+
const cellValueB = (_b = cellB.dataset.sort) !== null && _b !== void 0 ? _b : cellB.textContent;
|
|
212
|
+
// Sort cells based on sort order
|
|
213
|
+
return compareValues(cellValueA, cellValueB, sortOrder === 'descending', value.datatype);
|
|
214
|
+
});
|
|
215
|
+
// Append rows to table
|
|
216
|
+
rows.forEach(row => table.querySelector('tbody').append(row));
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
// Add alignment to columns
|
|
222
|
+
this.element.shadowRoot.adoptedStyleSheets = [...this.element.shadowRoot.adoptedStyleSheets, this.alignmentStylesheet];
|
|
223
|
+
// Create div wrapper for responsive behavior
|
|
224
|
+
const divWrapper = document.createElement('div');
|
|
225
|
+
divWrapper.setAttribute('class', this.componentWrapperClass);
|
|
226
|
+
divWrapper.setAttribute('tabindex', '0');
|
|
227
|
+
divWrapper.setAttribute('role', 'region');
|
|
228
|
+
// Get table title
|
|
229
|
+
let captionTable = table.querySelector('caption');
|
|
230
|
+
// If table is sortable we must add a caption
|
|
231
|
+
if (captionTable === null && isSortable) {
|
|
232
|
+
captionTable = document.createElement('caption');
|
|
233
|
+
table.prepend(captionTable);
|
|
234
|
+
}
|
|
235
|
+
if (captionTable !== null) {
|
|
236
|
+
// Ensure caption is not visible (otherwhise the table does not have rounded corners)
|
|
237
|
+
captionTable.className = 'mg-u-visually-hidden';
|
|
238
|
+
// Link caption to div
|
|
239
|
+
if (!me(captionTable.id)) {
|
|
240
|
+
captionTable.setAttribute('id', Ge(`${this.componentClass}-caption`));
|
|
241
|
+
}
|
|
242
|
+
divWrapper.setAttribute('aria-labelledby', captionTable.id);
|
|
243
|
+
// Add sortable caption if neeeded
|
|
244
|
+
if (isSortable) {
|
|
245
|
+
captionTable.innerHTML = `${captionTable.innerHTML} ${this.messages.table.sortableCaption}`.trim();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
divWrapper.append(table);
|
|
249
|
+
// Remove existing table from shadow root
|
|
250
|
+
const existingTable = this.element.shadowRoot.querySelector(`.${this.componentWrapperClass}`);
|
|
251
|
+
if (existingTable !== null) {
|
|
252
|
+
existingTable.remove();
|
|
253
|
+
}
|
|
254
|
+
// Append table
|
|
255
|
+
this.element.shadowRoot.append(divWrapper);
|
|
256
|
+
}
|
|
257
|
+
/*************
|
|
258
|
+
* Lifecycle *
|
|
259
|
+
*************/
|
|
260
|
+
componentWillLoad() {
|
|
261
|
+
this.messages = initLocales(this.element).messages;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Set variables and validate props
|
|
265
|
+
*/
|
|
266
|
+
componentDidLoad() {
|
|
267
|
+
this.watchSize(this.size);
|
|
268
|
+
this.watchFullWidth(this.fullWidth);
|
|
269
|
+
this.watchColumns(this.columns);
|
|
270
|
+
this.renderTable(this.element.querySelector('table'));
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Update table
|
|
274
|
+
*/
|
|
275
|
+
componentWillUpdate() {
|
|
276
|
+
this.renderTable(this.element.shadowRoot.querySelector('table'));
|
|
277
|
+
}
|
|
278
|
+
get element() { return this; }
|
|
279
|
+
static get watchers() { return {
|
|
280
|
+
"size": ["watchSize"],
|
|
281
|
+
"fullWidth": ["watchFullWidth"],
|
|
282
|
+
"columns": ["watchColumns"]
|
|
283
|
+
}; }
|
|
284
|
+
static get style() { return MgTableStyle0; }
|
|
285
|
+
}, [1, "mg-table", {
|
|
286
|
+
"size": [1],
|
|
287
|
+
"fullWidth": [4, "full-width"],
|
|
288
|
+
"columns": [16],
|
|
289
|
+
"classCollection": [32]
|
|
290
|
+
}, undefined, {
|
|
291
|
+
"size": ["watchSize"],
|
|
292
|
+
"fullWidth": ["watchFullWidth"],
|
|
293
|
+
"columns": ["watchColumns"]
|
|
294
|
+
}]);
|
|
295
|
+
function defineCustomElement$1() {
|
|
296
|
+
if (typeof customElements === "undefined") {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const components = ["mg-table", "mg-icon"];
|
|
300
|
+
components.forEach(tagName => { switch (tagName) {
|
|
301
|
+
case "mg-table":
|
|
302
|
+
if (!customElements.get(tagName)) {
|
|
303
|
+
customElements.define(tagName, MgTable$1);
|
|
304
|
+
}
|
|
305
|
+
break;
|
|
306
|
+
case "mg-icon":
|
|
307
|
+
if (!customElements.get(tagName)) {
|
|
308
|
+
defineCustomElement$2();
|
|
309
|
+
}
|
|
310
|
+
break;
|
|
311
|
+
} });
|
|
312
|
+
}
|
|
313
|
+
defineCustomElement$1();
|
|
314
|
+
|
|
315
|
+
const MgTable = MgTable$1;
|
|
316
|
+
const defineCustomElement = defineCustomElement$1;
|
|
317
|
+
|
|
318
|
+
export { MgTable, defineCustomElement };
|
|
319
|
+
|
|
320
|
+
//# sourceMappingURL=mg-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"file":"mg-table.js","mappings":";;;;;AACA;;;AAGA;AACO,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAGrE;;;AAGA;AACO,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAU,CAAC;AACnE;AACO,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAU;;ACd/D,MAAM,UAAU,GAAG,gmIAAgmI,CAAC;AACpnI,sBAAe,UAAU;;ACIzB;;;;;AAKA,MAAM,oBAAoB,GAAG,CAAC,QAAqB;AACjD;AACA,OAAO,QAAQ,KAA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I,UAAU,EAAE;gBACd,YAAY,CAAC,SAAS,GAAG,GAAG,YAAY,CAAC,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,IAAI,EAAE,CAAC;aACpG;SACF;QACD,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;;QAGzB,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;QAC9F,IAAI,aAAa,KAAK,IAAI,EAAE;YAC1B,aAAa,CAAC,MAAM,EAAE,CAAC;SACxB;;QAED,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;KAC5C;;;;IAMD,iBAAiB;QACf,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC;KACpD;;;;IAKD,gBAAgB;QACd,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;KACvD;;;;IAKD,mBAAmB;QACjB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;KAClE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["MgTable","ClassList","toString","isValidString","createID"],"sources":["src/components/molecules/mg-table/mg-table.conf.ts","../styles/dist/components/mg-table.css?tag=mg-table&encapsulation=shadow","src/components/molecules/mg-table/mg-table.tsx"],"sourcesContent":["import type { Size } from '../../../types';\n/**\n * Sizes\n */\n// Define possible sizes\nexport const sizes = ['small', 'medium', 'large', 'xlarge'] as const;\n// Define Table size type and ensure it is a valid size\nexport type TableSizeType = Size & (typeof sizes)[number];\n/**\n * Columns\n */\n// Define possible text alignments\nexport const textAlignments = ['left', 'center', 'right'] as const;\n// Define possible data types\nexport const dataTypes = ['string', 'numeric', 'date'] as const;\n// Define possible data types\nexport type datatypesType = (typeof dataTypes)[number];\n// Define columns type\nexport type ColumnsType = {\n [key: number]: { align?: (typeof textAlignments)[number]; sortable?: boolean; datatype?: datatypesType };\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}}@font-face{font-family:\"Open Sans\";src:url(\"fonts/OpenSans-Regular.ttf\") format(\"truetype\")}@font-face{font-family:\"Open Sans\";font-weight:600;src:url(\"fonts/OpenSans-SemiBold.ttf\") format(\"truetype\")}@font-face{font-family:\"Open Sans\";font-weight:700;src:url(\"fonts/OpenSans-Bold.ttf\") format(\"truetype\")}p{margin:0}p+p{margin-top:var(--mg-b-size-8)}h1,.mg-u-h1{font-family:var(--mg-b-font-family-heading);font-weight:bold}h2,.mg-u-h2{font-family:var(--mg-b-font-family-heading);font-weight:bold}h3,.mg-u-h3{font-family:var(--mg-b-font-family-heading);font-weight:bold}h4,.mg-u-h4{font-family:var(--mg-b-font-family-heading);font-weight:bold}h5,.mg-u-h5{font-family:var(--mg-b-font-family-heading);font-weight:bold}h6,.mg-u-h6{font-family:var(--mg-b-font-family-heading);font-weight:bold}h1,.mg-u-h1{font-size:var(--mg-b-font-size-h1)}h2,.mg-u-h2{font-size:var(--mg-b-font-size-h2)}h3,.mg-u-h3{font-size:var(--mg-b-font-size-h3)}h4,.mg-u-h4{font-size:var(--mg-b-font-size-h4)}h5,.mg-u-h5{font-size:var(--mg-b-font-size-h5)}h6,.mg-u-h6{font-size:var(--mg-b-font-size-h6)}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}small{font-size:var(--mg-b-small-font-size)}.mg-u-text-left{text-align:left !important}.mg-u-text-center{text-align:center !important}.mg-u-text-right{text-align:right !important}.mg-c-table{--mg-c-table-cell-spacing: var(--mg-b-size-8) var(--mg-b-size-16);--mg-c-table-cell-height: var(--mg-b-size-40);--mg-c-table-header-cell-height: calc(var(--mg-b-size-min-height) + 2 * var(--mg-b-size-8));overflow:hidden;border:none;border-radius:var(--mg-b-size-8);background:var(--mg-b-color-light);border-collapse:separate;border-spacing:0;color:var(--mg-b-color-dark)}.mg-c-table td,.mg-c-table th{height:var(--mg-c-table-cell-height);box-sizing:border-box;padding:var(--mg-c-table-cell-spacing);text-align:start}.mg-c-table thead td,.mg-c-table th{font-weight:600}.mg-c-table thead{height:var(--mg-c-table-header-cell-height);background-color:var(--mg-b-color-app);color:var(--mg-b-color-light)}.mg-c-table :not(thead) tr:nth-child(even){background:color-mix(in srgb, var(--mg-b-color-app), transparent 80%)}.mg-c-table.mg-c-table--size-small{--mg-c-table-cell-spacing: var(--mg-b-size-4) var(--mg-b-size-16);--mg-c-table-cell-height: var(--mg-b-size-32);--mg-c-table-header-cell-height: var(--mg-b-size-32)}.mg-c-table.mg-c-table--size-large{--mg-c-table-cell-height: var(--mg-c-table-header-cell-height)}.mg-c-table.mg-c-table--size-xlarge{--mg-c-table-cell-spacing: var(--mg-b-size-12) var(--mg-b-size-16);--mg-c-table-cell-height: var(--mg-b-size-64);--mg-c-table-header-cell-height: var(--mg-b-size-64)}.mg-c-table.mg-c-table--full-width{width:100%}.mg-c-table-wrapper{overflow:auto}.mg-c-table thead td,.mg-c-table thead th{position:relative}.mg-c-table thead td .mg-c-table__sort-button,.mg-c-table thead th .mg-c-table__sort-button{padding:0;border:none;margin:0;background:none;color:inherit;font-size:inherit;font-weight:600}.mg-c-table thead td .mg-c-table__sort-button::after,.mg-c-table thead th .mg-c-table__sort-button::after{position:absolute;content:\"\";inset:0}.mg-c-table thead td .mg-c-table__sort-button:hover,.mg-c-table thead th .mg-c-table__sort-button:hover{cursor:pointer}.mg-c-table thead td .mg-c-table__sort-button mg-icon,.mg-c-table thead th .mg-c-table__sort-button mg-icon{margin-left:var(--mg-b-size-4)}.mg-c-table thead td:has(.mg-c-table__sort-button):hover,.mg-c-table thead td[aria-sort=descending],.mg-c-table thead td[aria-sort=ascending],.mg-c-table thead th:has(.mg-c-table__sort-button):hover,.mg-c-table thead th[aria-sort=descending],.mg-c-table thead th[aria-sort=ascending]{background-color:color-mix(in srgb, var(--mg-b-color-app), black 10%)}/*# sourceMappingURL=mg-table.css.map */\n","import { Component, Element, State, Prop, Watch } from '@stencil/core';\nimport { ClassList, toString, createID, isValidString } from '@mgdis/stencil-helpers';\nimport { type TableSizeType, type ColumnsType, type datatypesType, textAlignments, dataTypes, sizes } from './mg-table.conf';\nimport { initLocales } from '../../../locales';\n\n/**\n * Check if value is a valid align object\n * @param newValue - New value\n * @returns True if value is a valid align object\n */\nconst isValidColumnsObject = (newValue: ColumnsType): boolean =>\n // ensure newValue is an object\n typeof newValue === 'object' &&\n !Array.isArray(newValue) &&\n // Ensure every property is well formatted\n Object.entries(newValue).every(\n ([key, value]) =>\n // ensure key is a number\n !isNaN(parseInt(key)) &&\n // ensure value is an object\n typeof value === 'object' &&\n !Array.isArray(value) &&\n // ensure value has at least one of the following properties\n ((value.align !== undefined && textAlignments.includes(value.align)) ||\n (value.sortable !== undefined && typeof value.sortable === 'boolean') ||\n (value.datatype !== undefined && dataTypes.includes(value.datatype))) &&\n // ensure no extra properties are present\n Object.keys(value).every(key => ['align', 'sortable', 'datatype'].includes(key)),\n );\n\n/**\n * Compare values\n * @param firstValue - First value\n * @param secondValue - Second value\n * @param descending - Define descending order\n * @param datatype - Data type\n * @returns Comparison result\n * @example\n * compareValues('a', 'b', false, 'string'); // -1\n */\nconst compareValues = (firstValue: string, secondValue: string, descending: boolean, datatype: datatypesType): number => {\n if (descending) {\n const temp = firstValue;\n firstValue = secondValue;\n secondValue = temp;\n }\n if (datatype === 'date') {\n return new Date(firstValue).getTime() - new Date(secondValue).getTime();\n }\n return firstValue.localeCompare(secondValue, undefined, { numeric: datatype === 'numeric' });\n};\n\n/**\n * @slot - Table content\n */\n@Component({\n tag: 'mg-table',\n styleUrl: '../../../../node_modules/@mgdis/styles/dist/components/mg-table.css',\n shadow: true,\n})\nexport class MgTable {\n /************\n * Internal *\n ************/\n\n private messages;\n\n // Classes\n private readonly componentClass = 'mg-c-table';\n private readonly componentWrapperClass = 'mg-c-table-wrapper';\n private readonly classFullWidth = 'mg-c-table--full-width';\n\n // Alignment stylesheet\n private alignmentStylesheet = new CSSStyleSheet();\n\n /**************\n * Decorators *\n **************/\n\n /**\n * Get component DOM element\n */\n @Element() element: HTMLMgTableElement;\n\n /**\n * Define table size\n */\n @Prop() size: TableSizeType = 'medium';\n @Watch('size')\n watchSize(newValue: MgTable['size'], oldValue?: MgTable['size']): void {\n if (!sizes.includes(newValue)) {\n throw new Error(`<mg-table> prop \"size\" must be one of: ${sizes.join(', ')}. Passed value: ${toString(newValue)}.`);\n } else {\n if (oldValue !== undefined) {\n this.classCollection.delete(`mg-c-table--size-${oldValue}`);\n }\n this.classCollection.add(`mg-c-table--size-${newValue}`);\n }\n }\n\n /**\n * Define if table fits its parent element\n */\n @Prop() fullWidth = false;\n @Watch('fullWidth')\n watchFullWidth(newValue: MgTable['fullWidth']): void {\n if (newValue) {\n this.classCollection.add(this.classFullWidth);\n } else {\n this.classCollection.delete(this.classFullWidth);\n }\n }\n\n /**\n * Define column properties\n */\n @Prop() columns: ColumnsType;\n @Watch('columns')\n watchColumns(newValue: ColumnsType): void {\n if (newValue !== undefined && !isValidColumnsObject(newValue)) {\n throw new Error(`<mg-table> prop \"columns\" must be a ColumnsType object. Passed value: ${toString(newValue)}.`);\n }\n }\n\n /**\n * Class collection\n */\n @State() classCollection: ClassList = new ClassList([this.componentClass]);\n\n /**\n * Render Table\n * @param table - Table element\n */\n private renderTable(table: HTMLTableElement): void {\n let isSortable = false;\n // Remove table classes\n table.className = '';\n // Add table classes\n table.classList.add(...this.classCollection.classes);\n\n // Set columns based on columns prop\n if (this.columns !== undefined) {\n // Store original rows\n const rowsDefault = Array.from(table.querySelectorAll('tbody tr'));\n\n // Apply columns settings\n Object.entries(this.columns).forEach(([key, value]) => {\n // Add alignment to stylesheet\n if (value.align !== undefined) {\n this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:${value.align}}}`);\n }\n // if align is not defined and datatype is number, align right\n else if (value.datatype === 'numeric') {\n this.alignmentStylesheet.insertRule(`.${this.componentClass}{th:nth-child(${key}),td:nth-child(${key}){text-align:right}}`);\n }\n\n // Define if column is sortable\n if (value.sortable) {\n isSortable = true;\n // Add sortable class to table header\n const sortableHeader = table.querySelector(`thead td:nth-child(${key}),thead th:nth-child(${key})`);\n\n // Create button\n const button = document.createElement('button');\n button.classList.add('mg-c-table__sort-button');\n\n // Append button to header\n const sortableHeaderContent = sortableHeader.innerHTML;\n sortableHeader.innerHTML = '';\n button.innerHTML = sortableHeaderContent;\n\n // Set icon\n const icon = document.createElement('mg-icon');\n icon.setAttribute('icon', 'arrows-up-down');\n\n // Append icon to button\n button.append(icon);\n sortableHeader.append(button);\n\n // Add event listener\n button.addEventListener('click', (): void => {\n // Reset aria pressed\n table.querySelectorAll(`thead td:not(:nth-child(${key})) [aria-pressed],thead th:not(:nth-child(${key})) [aria-pressed]`).forEach(ariaPressed => {\n ariaPressed.removeAttribute('aria-pressed');\n ariaPressed.querySelector('mg-icon').setAttribute('icon', 'arrows-up-down');\n });\n // Reset aria sort\n table.querySelectorAll(`thead td:not(:nth-child(${key}))[aria-sort],thead th:not(:nth-child(${key}))[aria-sort]`).forEach(ariaSort => {\n ariaSort.removeAttribute('aria-sort');\n });\n\n // Set aria pressed\n button.setAttribute('aria-pressed', 'true');\n\n // Manage sort order\n // Get sort order\n let sortOrder = sortableHeader.getAttribute('aria-sort');\n\n // First click sort asc\n if ([null, 'none'].includes(sortOrder)) {\n sortableHeader.setAttribute('aria-sort', 'ascending');\n }\n // Second click sort desc\n else if (sortOrder === 'ascending') {\n sortableHeader.setAttribute('aria-sort', 'descending');\n }\n // Third click remove sort\n else {\n sortableHeader.setAttribute('aria-sort', 'none');\n }\n\n // Update sort order\n sortOrder = sortableHeader.getAttribute('aria-sort');\n\n // Update button icon\n const icon = button.querySelector('mg-icon');\n let iconType = 'arrows-up-down';\n if (sortOrder === 'ascending') {\n iconType = 'arrow-up';\n } else if (sortOrder === 'descending') {\n iconType = 'arrow-down';\n }\n icon.setAttribute('icon', iconType);\n\n // If sort order is none, return to original order\n if (sortOrder === 'none') {\n // Append rows to table\n rowsDefault.forEach(row => table.querySelector('tbody').append(row));\n return;\n }\n\n // Set a copy of rows\n const rows = Array.from(table.querySelectorAll('tbody tr'));\n\n // Sort rows\n rows.sort((a, b) => {\n // Get cells\n const cellA: HTMLTableCellElement = a.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);\n const cellB: HTMLTableCellElement = b.querySelector(`td:nth-child(${key}),th:nth-child(${key})`);\n\n // Get cell values\n const cellValueA = cellA.dataset.sort ?? cellA.textContent;\n const cellValueB = cellB.dataset.sort ?? cellB.textContent;\n\n // Sort cells based on sort order\n return compareValues(cellValueA, cellValueB, sortOrder === 'descending', value.datatype);\n });\n\n // Append rows to table\n rows.forEach(row => table.querySelector('tbody').append(row));\n });\n }\n });\n }\n\n // Add alignment to columns\n this.element.shadowRoot.adoptedStyleSheets = [...this.element.shadowRoot.adoptedStyleSheets, this.alignmentStylesheet];\n\n // Create div wrapper for responsive behavior\n const divWrapper = document.createElement('div');\n divWrapper.setAttribute('class', this.componentWrapperClass);\n divWrapper.setAttribute('tabindex', '0');\n divWrapper.setAttribute('role', 'region');\n\n // Get table title\n let captionTable = table.querySelector('caption');\n\n // If table is sortable we must add a caption\n if (captionTable === null && isSortable) {\n captionTable = document.createElement('caption');\n table.prepend(captionTable);\n }\n\n if (captionTable !== null) {\n // Ensure caption is not visible (otherwhise the table does not have rounded corners)\n captionTable.className = 'mg-u-visually-hidden';\n\n // Link caption to div\n if (!isValidString(captionTable.id)) {\n captionTable.setAttribute('id', createID(`${this.componentClass}-caption`));\n }\n divWrapper.setAttribute('aria-labelledby', captionTable.id);\n\n // Add sortable caption if neeeded\n if (isSortable) {\n captionTable.innerHTML = `${captionTable.innerHTML} ${this.messages.table.sortableCaption}`.trim();\n }\n }\n divWrapper.append(table);\n\n // Remove existing table from shadow root\n const existingTable = this.element.shadowRoot.querySelector(`.${this.componentWrapperClass}`);\n if (existingTable !== null) {\n existingTable.remove();\n }\n // Append table\n this.element.shadowRoot.append(divWrapper);\n }\n\n /*************\n * Lifecycle *\n *************/\n\n componentWillLoad(): void {\n this.messages = initLocales(this.element).messages;\n }\n\n /**\n * Set variables and validate props\n */\n componentDidLoad(): void {\n this.watchSize(this.size);\n this.watchFullWidth(this.fullWidth);\n this.watchColumns(this.columns);\n this.renderTable(this.element.querySelector('table'));\n }\n\n /**\n * Update table\n */\n componentWillUpdate(): void {\n this.renderTable(this.element.shadowRoot.querySelector('table'));\n }\n}\n"],"version":3}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
2
|
import { G as Ge, s as st, X as Xe, V as Ve, m as me, Y as Ye, Q as Qe } from './index.es.js';
|
|
3
|
-
import { a as autoUpdate, c as computePosition, o as offset, f as flip,
|
|
3
|
+
import { a as autoUpdate, c as computePosition, o as offset, f as flip, d as shift, l as limitShift, e as arrow, i as isFloatingUIPlacement } from './floating-ui.utils.js';
|
|
4
4
|
import { d as defineCustomElement$1 } from './mg-tooltip-content2.js';
|
|
5
5
|
|
|
6
6
|
const Guard = {
|
|
@@ -57,10 +57,10 @@ var loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
57
57
|
}
|
|
58
58
|
switch(bundleId) {
|
|
59
59
|
|
|
60
|
-
case 'mg-action-
|
|
60
|
+
case 'mg-action-more_37':
|
|
61
61
|
return import(
|
|
62
62
|
/* webpackMode: "lazy" */
|
|
63
|
-
'./mg-action-
|
|
63
|
+
'./mg-action-more_37.entry.js').then(processMod, consoleError);
|
|
64
64
|
case 'mg-alert':
|
|
65
65
|
return import(
|
|
66
66
|
/* webpackMode: "lazy" */
|