@mgdis/mg-components 4.2.1 → 5.1.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/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{mg-badge_23.cjs.entry.js → mg-badge_27.cjs.entry.js} +2590 -121
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -3
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +1 -2
- package/dist/collection/components/atoms/mg-button/mg-button.css +113 -67
- package/dist/collection/components/atoms/mg-button/mg-button.js +89 -64
- package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +18 -0
- package/dist/collection/components/atoms/mg-card/mg-card.css +7 -0
- package/dist/collection/components/atoms/mg-card/mg-card.js +26 -0
- package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +18 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.css +9 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +57 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +3 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +1 -3
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -5
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +0 -20
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +6 -7
- package/dist/collection/components/molecules/inputs/MgInput.js +1 -3
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +1 -0
- package/dist/collection/components/molecules/mg-details/mg-details.css +29 -0
- package/dist/collection/components/molecules/mg-details/mg-details.js +26 -4
- package/dist/collection/components/molecules/mg-form/mg-form.js +2 -3
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +2 -1
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.css +15 -7
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +27 -2
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +1 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +2 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +53 -7
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +4 -3
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +1 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +12 -20
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +2 -4
- package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -5
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +3 -3
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +10 -10
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -3
- package/dist/collection/utils/components.utils.js +10 -6
- package/dist/collection/variables.css +22 -1
- package/dist/components/MgInput.js +1 -3
- package/dist/components/components.utils.js +11 -7
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/mg-badge2.js +1 -3
- package/dist/components/mg-button2.js +63 -13
- package/dist/components/mg-card.d.ts +11 -0
- package/dist/components/mg-card.js +42 -0
- package/dist/components/mg-details.js +8 -3
- package/dist/components/mg-divider.d.ts +11 -0
- package/dist/components/mg-divider.js +51 -0
- package/dist/components/mg-form.js +2 -3
- package/dist/components/mg-icon2.js +3 -0
- package/dist/components/mg-illustrated-message.js +12 -4
- package/dist/components/mg-input-title2.js +1 -3
- package/dist/components/mg-modal.js +54 -8
- package/dist/components/mg-pagination.js +4 -3
- package/dist/components/mg-panel.js +3 -5
- package/dist/components/mg-popover.js +11 -10
- package/dist/components/mg-tabs.js +1 -3
- package/dist/components/mg-tooltip2.js +7 -10
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mg-badge_23.entry.js → mg-badge_27.entry.js} +2538 -73
- package/dist/esm/mg-components.js +1 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-e131701a.entry.js +1 -0
- package/dist/mg-components/variables.css +22 -1
- package/dist/types/components/atoms/mg-button/doc/mg-button.stories.d.ts +2 -2
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +5 -1
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +25 -17
- package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +11 -0
- package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +15 -0
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +0 -8
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +1 -1
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
- package/dist/types/components/molecules/mg-illustrated-message/mg-illustrated-message.d.ts +4 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +8 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +1 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +1 -1
- package/dist/types/components.d.ts +64 -31
- package/dist/types/utils/components.utils.d.ts +7 -3
- package/package.json +4 -3
- package/dist/cjs/index-179621c8.js +0 -244
- package/dist/cjs/mg-modal.cjs.entry.js +0 -130
- package/dist/cjs/mg-popover.cjs.entry.js +0 -171
- package/dist/cjs/popper-11d5f714.js +0 -1801
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +0 -20
- package/dist/collection/variables.scss +0 -212
- package/dist/esm/index-7efedd97.js +0 -238
- package/dist/esm/mg-modal.entry.js +0 -126
- package/dist/esm/mg-popover.entry.js +0 -167
- package/dist/esm/popper-f860750c.js +0 -1799
- package/dist/mg-components/p-25452f60.entry.js +0 -1
- package/dist/mg-components/p-5f89600c.js +0 -1
- package/dist/mg-components/p-a20fc541.entry.js +0 -1
- package/dist/mg-components/p-e08bc19a.entry.js +0 -1
- package/dist/mg-components/p-ec26fc38.js +0 -1
- package/dist/mg-components/variables.scss +0 -212
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +0 -8
|
@@ -1,12 +1,99 @@
|
|
|
1
|
-
import { r as registerInstance, h,
|
|
2
|
-
import { C as ClassList, i as initLocales, c as createID, a as isTagName, b as allItemsAreString } from './index-7efedd97.js';
|
|
3
|
-
import { c as createPopper } from './popper-f860750c.js';
|
|
1
|
+
import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-aad0184c.js';
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* List of all possibles variants
|
|
7
5
|
*/
|
|
8
6
|
const variants$4 = ['info', 'primary', 'secondary', 'success', 'warning', 'danger'];
|
|
9
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Create random ID
|
|
10
|
+
*
|
|
11
|
+
* @param {string} prefix add prefix to created ID
|
|
12
|
+
* @param {number} length ID length
|
|
13
|
+
* @returns {string} ID
|
|
14
|
+
*/
|
|
15
|
+
const createID = (prefix = '', length = 10) => {
|
|
16
|
+
let ID = '';
|
|
17
|
+
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
18
|
+
const charsLength = chars.length;
|
|
19
|
+
for (let i = 0; i < length; i++) {
|
|
20
|
+
ID += chars.charAt(Math.floor(Math.random() * charsLength));
|
|
21
|
+
}
|
|
22
|
+
return (prefix !== '' ? `${prefix}-` : '') + ID;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Class to manage component classlist
|
|
26
|
+
* Set() are not working when imported in project
|
|
27
|
+
*/
|
|
28
|
+
class ClassList {
|
|
29
|
+
constructor(classlist = []) {
|
|
30
|
+
/**
|
|
31
|
+
* Add class
|
|
32
|
+
*
|
|
33
|
+
* @param {string} className class name to add
|
|
34
|
+
* @returns {void}
|
|
35
|
+
*/
|
|
36
|
+
this.add = (className) => {
|
|
37
|
+
if (!this.has(className)) {
|
|
38
|
+
this.classes.push(className);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Delete class
|
|
43
|
+
*
|
|
44
|
+
* @param {string} className class name to delete
|
|
45
|
+
* @returns {void}
|
|
46
|
+
*/
|
|
47
|
+
this.delete = (className) => {
|
|
48
|
+
const index = this.classes.indexOf(className);
|
|
49
|
+
if (index > -1) {
|
|
50
|
+
this.classes.splice(index, 1);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Check if class exist in list
|
|
55
|
+
*
|
|
56
|
+
* @param {string} className class name to check
|
|
57
|
+
* @returns {boolean} class name is in the list
|
|
58
|
+
*/
|
|
59
|
+
this.has = (className) => {
|
|
60
|
+
return this.classes.includes(className);
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Join classes seperated by spaces
|
|
64
|
+
*
|
|
65
|
+
* @returns {string} joined values
|
|
66
|
+
*/
|
|
67
|
+
this.join = () => {
|
|
68
|
+
return this.classes.join(' ');
|
|
69
|
+
};
|
|
70
|
+
this.classes = classlist;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check if all items are string
|
|
75
|
+
*
|
|
76
|
+
* @param {string[]} items items to check
|
|
77
|
+
* @returns {boolean} all items are string
|
|
78
|
+
*/
|
|
79
|
+
const allItemsAreString = (items) => {
|
|
80
|
+
return items && items.every(item => typeof item === 'string');
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Check if element is a heading
|
|
84
|
+
*
|
|
85
|
+
* @param {Element} element slotted element
|
|
86
|
+
* @param {string[]} tagNames allowed tag names list
|
|
87
|
+
* @returns {boolean} element is a heading
|
|
88
|
+
*/
|
|
89
|
+
const isTagName = (element, tagNames) => {
|
|
90
|
+
return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Focusable elements query selector
|
|
94
|
+
*/
|
|
95
|
+
const focusableElements = 'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]), [identifier]';
|
|
96
|
+
|
|
10
97
|
const mgBadgeCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-badge{padding:0 0.4rem;height:var(--mg-badge-size);min-width:var(--mg-badge-size);box-sizing:border-box;border:0.1rem solid;border-radius:calc(var(--mg-badge-size) / 2);font-size:var(--mg-badge-font-size);font-weight:600;text-align:center;line-height:var(--mg-badge-size)}.mg-badge.mg-badge--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-badge.mg-badge--primary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-badge.mg-badge--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-badge.mg-badge--success.mg-badge--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-badge.mg-badge--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-badge.mg-badge--warning.mg-badge--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-badge.mg-badge--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-badge.mg-badge--danger.mg-badge--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-badge.mg-badge--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-badge.mg-badge--info.mg-badge--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-badge,mg-badge{display:inline-flex;align-items:center;justify-content:center}";
|
|
11
98
|
|
|
12
99
|
const MgBadge = class {
|
|
@@ -33,9 +120,7 @@ const MgBadge = class {
|
|
|
33
120
|
}
|
|
34
121
|
validateLabel(newValue) {
|
|
35
122
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
36
|
-
|
|
37
|
-
// throw new Error('<mg-badge> prop "label" is required.');
|
|
38
|
-
console.error('<mg-badge> prop "label" is required.');
|
|
123
|
+
throw new Error('<mg-badge> prop "label" is required.');
|
|
39
124
|
}
|
|
40
125
|
}
|
|
41
126
|
validateVariant(newValue, oldValue) {
|
|
@@ -88,7 +173,7 @@ MgBadge.style = mgBadgeCss;
|
|
|
88
173
|
*/
|
|
89
174
|
const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success'];
|
|
90
175
|
|
|
91
|
-
const mgButtonCss = "
|
|
176
|
+
const mgButtonCss = ":host{display:inline-block;vertical-align:middle;max-width:100%}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-button:not(.mg-button--disabled){outline-color:-webkit-focus-ring-color;outline-style:auto;outline-width:0.2rem}:host(:hover) .mg-button--flat:not(.mg-button--disabled),:host(:focus) .mg-button--flat:not(.mg-button--disabled),:host(:active) .mg-button--flat:not(.mg-button--disabled){background:hsla(var(--color-dark), 0.1)}:host([full-width]){display:block}.mg-button.mg-button--primary{border-color:hsl(var(--mg-button-primary-border-color, var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-primary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--primary:not(.mg-button--disabled),:host(:focus) .mg-button--primary:not(.mg-button--disabled),:host(:active) .mg-button--primary:not(.mg-button--disabled){background:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l))}.mg-button.mg-button--secondary{border-color:hsl(var(--mg-button-secondary-border-color, var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-secondary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--secondary:not(.mg-button--disabled),:host(:focus) .mg-button--secondary:not(.mg-button--disabled),:host(:active) .mg-button--secondary:not(.mg-button--disabled){background:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l))}.mg-button.mg-button--danger{border-color:hsl(var(--mg-button-danger-border-color, var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger:not(.mg-button--disabled),:host(:focus) .mg-button--danger:not(.mg-button--disabled),:host(:active) .mg-button--danger:not(.mg-button--disabled){background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-button.mg-button--danger-alt{border-color:hsl(var(--mg-button-danger-alt-border-color, var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-danger));background:linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger-alt:not(.mg-button--disabled),:host(:focus) .mg-button--danger-alt:not(.mg-button--disabled),:host(:active) .mg-button--danger-alt:not(.mg-button--disabled){background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))}.mg-button.mg-button--info{border-color:hsl(var(--mg-button-info-border-color, var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--info:not(.mg-button--disabled),:host(:focus) .mg-button--info:not(.mg-button--disabled),:host(:active) .mg-button--info:not(.mg-button--disabled){background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-button.mg-button--success{border-color:hsl(var(--mg-button-success-border-color, var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-dark));background:linear-gradient(to bottom, hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l)), hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--success:not(.mg-button--disabled),:host(:focus) .mg-button--success:not(.mg-button--disabled),:host(:active) .mg-button--success:not(.mg-button--disabled){background:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))}.mg-button{position:relative;display:inline-flex;align-items:center;column-gap:0.6rem;padding:calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;min-height:var(--default-size);box-sizing:border-box;border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-border-radius));cursor:pointer;background-image:none;border-top-width:var(--mg-button-border-top-width, 0.1rem);border-right-width:var(--mg-button-border-right-width, 0.1rem);border-bottom-width:var(--mg-button-border-bottom-width, 0.1rem);border-left-width:var(--mg-button-border-left-width, 0.1rem);border-style:solid;text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);touch-action:manipulation}.mg-button.mg-button--disabled{opacity:var(--mg-button-disabled-opacity);cursor:default}.mg-button.mg-button--icon{padding:0;justify-content:center;width:var(--default-size);height:var(--default-size);border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-icon-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-icon-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-icon-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-icon-border-radius));font-size:var(--font-size);line-height:var(--font-size)}.mg-button.mg-button--flat{background:none;border:none}.mg-button.mg-button--full-width{display:flex;justify-content:center}.mg-button.mg-button--loading>mg-icon:first-of-type{position:absolute;left:50%;top:50%;transform:translate(-50%, -50%)}.mg-button.mg-button--loading .mg-button__content{opacity:0}.mg-button mg-icon:only-child,.mg-button ::slotted(mg-icon){display:inline-flex;flex-shrink:0;line-height:1;margin:auto 0}.mg-button slot,.mg-button ::slotted(*:not(mg-icon)){text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);display:flex;align-items:center;column-gap:0.6rem}";
|
|
92
177
|
|
|
93
178
|
const MgButton = class {
|
|
94
179
|
constructor(hostRef) {
|
|
@@ -97,10 +182,17 @@ const MgButton = class {
|
|
|
97
182
|
* Internal *
|
|
98
183
|
************/
|
|
99
184
|
this.onClickElementFn = null;
|
|
185
|
+
this.classDisabled = 'mg-button--disabled';
|
|
186
|
+
this.classLoading = 'mg-button--loading';
|
|
187
|
+
this.classFullWidth = 'mg-button--full-width';
|
|
100
188
|
/**
|
|
101
189
|
* Define button variant
|
|
102
190
|
*/
|
|
103
191
|
this.variant = variants$3[0]; // Primary
|
|
192
|
+
/**
|
|
193
|
+
* Set button to full-width
|
|
194
|
+
*/
|
|
195
|
+
this.fullWidth = false;
|
|
104
196
|
/**
|
|
105
197
|
* Define if button is round.
|
|
106
198
|
* Used for icon button.
|
|
@@ -131,11 +223,38 @@ const MgButton = class {
|
|
|
131
223
|
if (this.disabled)
|
|
132
224
|
event.stopPropagation();
|
|
133
225
|
// Used to prevent multi-click.
|
|
134
|
-
if (this.disableOnClick
|
|
226
|
+
else if (this.disableOnClick) {
|
|
135
227
|
this.loading = true;
|
|
136
228
|
this.disabled = true;
|
|
137
229
|
}
|
|
138
230
|
};
|
|
231
|
+
/**
|
|
232
|
+
* Handle onKeyDown event
|
|
233
|
+
*
|
|
234
|
+
* @param {KeyboardEvent} event keyboard event
|
|
235
|
+
* @returns {void}
|
|
236
|
+
*/
|
|
237
|
+
this.handleKeydown = (event) => {
|
|
238
|
+
if (!this.disabled && event.key === ' ') {
|
|
239
|
+
event.preventDefault();
|
|
240
|
+
}
|
|
241
|
+
else if (!this.disabled && ['Enter', 'NumpadEnter', 'Space'].includes(event.key)) {
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
this.element.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Handle onKeyUp event
|
|
248
|
+
*
|
|
249
|
+
* @param {KeyboardEvent} event keyboard event
|
|
250
|
+
* @returns {void}
|
|
251
|
+
*/
|
|
252
|
+
this.handleKeyup = (event) => {
|
|
253
|
+
if (!this.disabled && event.key === ' ') {
|
|
254
|
+
event.preventDefault();
|
|
255
|
+
this.element.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
256
|
+
}
|
|
257
|
+
};
|
|
139
258
|
}
|
|
140
259
|
validateVariant(newValue, oldValue) {
|
|
141
260
|
if (!variants$3.includes(newValue)) {
|
|
@@ -148,6 +267,17 @@ const MgButton = class {
|
|
|
148
267
|
this.classList.add(`mg-button--${newValue}`);
|
|
149
268
|
}
|
|
150
269
|
}
|
|
270
|
+
validateFullWidth(newValue) {
|
|
271
|
+
if (newValue && this.isIcon) {
|
|
272
|
+
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
273
|
+
}
|
|
274
|
+
else if (newValue) {
|
|
275
|
+
this.classList.add(this.classFullWidth);
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
this.classList.delete(this.classFullWidth);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
151
281
|
disabledHandler(isDisabled) {
|
|
152
282
|
// Remove loading when enable
|
|
153
283
|
// Will be set back onclick
|
|
@@ -156,14 +286,21 @@ const MgButton = class {
|
|
|
156
286
|
}
|
|
157
287
|
// Manage if onclick
|
|
158
288
|
this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
|
|
289
|
+
// apply style
|
|
290
|
+
if (isDisabled) {
|
|
291
|
+
this.classList.add(this.classDisabled);
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
this.classList.delete(this.classDisabled);
|
|
295
|
+
}
|
|
159
296
|
}
|
|
160
297
|
loadingHandler(newValue) {
|
|
161
298
|
// we add loading style if it newvalue is true else we remove it
|
|
162
299
|
if (newValue) {
|
|
163
|
-
this.classList.add(
|
|
300
|
+
this.classList.add(this.classLoading);
|
|
164
301
|
}
|
|
165
302
|
else {
|
|
166
|
-
this.classList.delete(
|
|
303
|
+
this.classList.delete(this.classLoading);
|
|
167
304
|
}
|
|
168
305
|
}
|
|
169
306
|
/**
|
|
@@ -173,6 +310,7 @@ const MgButton = class {
|
|
|
173
310
|
*/
|
|
174
311
|
componentWillLoad() {
|
|
175
312
|
this.validateVariant(this.variant);
|
|
313
|
+
this.validateFullWidth(this.fullWidth);
|
|
176
314
|
if (this.isIcon) {
|
|
177
315
|
this.classList.add(`mg-button--icon`);
|
|
178
316
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
@@ -189,20 +327,190 @@ const MgButton = class {
|
|
|
189
327
|
* @returns {HTMLElement} html element
|
|
190
328
|
*/
|
|
191
329
|
render() {
|
|
192
|
-
return (h("button",
|
|
193
|
-
// has stencil does not support form attribute on button, we set the attribute from the ref
|
|
194
|
-
// https://github.com/ionic-team/stencil/issues/2703#issuecomment-1050943715
|
|
195
|
-
ref: btn => this.form && btn.setAttribute('form', this.form) }, this.loading && h("mg-icon", { icon: "loader", spin: true }), h("div", { class: "mg-button__content" }, h("slot", null))));
|
|
330
|
+
return (h(Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyUp: this.handleKeyup, onKeyDown: this.handleKeydown }, h("div", { class: this.classList.join(), id: this.identifier }, this.loading && h("mg-icon", { icon: "loader", spin: true }), h("div", { class: "mg-button__content" }, h("slot", null)))));
|
|
196
331
|
}
|
|
197
332
|
get element() { return getElement(this); }
|
|
198
333
|
static get watchers() { return {
|
|
199
334
|
"variant": ["validateVariant"],
|
|
335
|
+
"fullWidth": ["validateFullWidth"],
|
|
200
336
|
"disabled": ["disabledHandler"],
|
|
201
337
|
"loading": ["loadingHandler"]
|
|
202
338
|
}; }
|
|
203
339
|
};
|
|
204
340
|
MgButton.style = mgButtonCss;
|
|
205
341
|
|
|
342
|
+
const mgCardCss = ".mg-card{padding:var(--mg-card-padding);border-radius:var(--mg-card-border-radius);background:var(--mg-card-background);border:var(--mg-card-border);box-shadow:var(--mg-card-box-shadow)}";
|
|
343
|
+
|
|
344
|
+
const MgCard = class {
|
|
345
|
+
constructor(hostRef) {
|
|
346
|
+
registerInstance(this, hostRef);
|
|
347
|
+
}
|
|
348
|
+
/*************
|
|
349
|
+
* Lifecycle *
|
|
350
|
+
*************/
|
|
351
|
+
/**
|
|
352
|
+
* Render
|
|
353
|
+
*
|
|
354
|
+
* @returns {HTMLElement} HTML Element
|
|
355
|
+
*/
|
|
356
|
+
render() {
|
|
357
|
+
return (h("div", { class: "mg-card" }, h("slot", null)));
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
MgCard.style = mgCardCss;
|
|
361
|
+
|
|
362
|
+
const errors$1 = {
|
|
363
|
+
required: "This field is required.",
|
|
364
|
+
date: {
|
|
365
|
+
badInput: "The date format must be <span aria-hidden=\"true\">mm/dd/yyyy</span><span class=\"sr-only\">m m / d d / y y y y</span> and the date must be greater than {min}",
|
|
366
|
+
min: "The date cannot be earlier than {min}",
|
|
367
|
+
max: "The date cannot be later than {max}",
|
|
368
|
+
minMax: "The date must be between {min} and {max}"
|
|
369
|
+
},
|
|
370
|
+
numeric: {
|
|
371
|
+
min: "The value cannot be less than {min}",
|
|
372
|
+
max: "The value cannot be greater than {max}",
|
|
373
|
+
minMax: "The value must be between {min} et {max}"
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
const nbCharLeft$1 = "{counter} characters left.";
|
|
377
|
+
const input$1 = {
|
|
378
|
+
select: {
|
|
379
|
+
placeholder: "Select a value"
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
const form$1 = {
|
|
383
|
+
required: "Fields with a <strong class=\"is-asterisk\">*</strong> are required",
|
|
384
|
+
allRequired: "All fields are required"
|
|
385
|
+
};
|
|
386
|
+
const message$1 = {
|
|
387
|
+
closeButton: "Close message"
|
|
388
|
+
};
|
|
389
|
+
const modal$1 = {
|
|
390
|
+
closeButton: "Close modal"
|
|
391
|
+
};
|
|
392
|
+
const pagination$1 = {
|
|
393
|
+
label: "Pagination",
|
|
394
|
+
page: "page",
|
|
395
|
+
pages: "pages",
|
|
396
|
+
nextPage: "Next page",
|
|
397
|
+
previousPage: "Previous page",
|
|
398
|
+
selectPage: "Select the page to display."
|
|
399
|
+
};
|
|
400
|
+
const panel$1 = {
|
|
401
|
+
editLabel: "Edit section title."
|
|
402
|
+
};
|
|
403
|
+
const general$1 = {
|
|
404
|
+
confirm: "Confirm",
|
|
405
|
+
cancel: "Cancel",
|
|
406
|
+
close: "Close",
|
|
407
|
+
next: "next",
|
|
408
|
+
previous: "previous"
|
|
409
|
+
};
|
|
410
|
+
const en = {
|
|
411
|
+
errors: errors$1,
|
|
412
|
+
nbCharLeft: nbCharLeft$1,
|
|
413
|
+
input: input$1,
|
|
414
|
+
form: form$1,
|
|
415
|
+
message: message$1,
|
|
416
|
+
modal: modal$1,
|
|
417
|
+
pagination: pagination$1,
|
|
418
|
+
panel: panel$1,
|
|
419
|
+
general: general$1
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const errors = {
|
|
423
|
+
required: "Ce champ est obligatoire.",
|
|
424
|
+
date: {
|
|
425
|
+
badInput: "Le format de la date doit être du type <span aria-hidden=\"true\">jj/mm/aaaa</span><span class=\"sr-only\">j j / m m / a a a a</span> et la date supérieure au {min}",
|
|
426
|
+
min: "La date ne peut pas être antérieure au {min}",
|
|
427
|
+
max: "La date ne peut pas être postérieure au {max}",
|
|
428
|
+
minMax: "La date doit être comprise entre le {min} et le {max}"
|
|
429
|
+
},
|
|
430
|
+
numeric: {
|
|
431
|
+
min: "La valeur ne peut pas être inférieure à {min}",
|
|
432
|
+
max: "La valeur ne peut pas être supérieure à {max}",
|
|
433
|
+
minMax: "La valeur doit être comprise entre {min} et {max}"
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
const nbCharLeft = "{counter} caractères disponibles.";
|
|
437
|
+
const input = {
|
|
438
|
+
select: {
|
|
439
|
+
placeholder: "Sélectionnez une valeur"
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
const form = {
|
|
443
|
+
required: "Les champs marqués d'un <strong class=\"is-asterisk\">*</strong> sont obligatoires",
|
|
444
|
+
allRequired: "Tous les champs sont obligatoires"
|
|
445
|
+
};
|
|
446
|
+
const message = {
|
|
447
|
+
closeButton: "Fermer le message"
|
|
448
|
+
};
|
|
449
|
+
const modal = {
|
|
450
|
+
closeButton: "Fermer la modale"
|
|
451
|
+
};
|
|
452
|
+
const pagination = {
|
|
453
|
+
label: "Pagination",
|
|
454
|
+
page: "page",
|
|
455
|
+
pages: "pages",
|
|
456
|
+
nextPage: "Page suivante",
|
|
457
|
+
previousPage: "Page précédente",
|
|
458
|
+
selectPage: "Sélectionner la page à afficher."
|
|
459
|
+
};
|
|
460
|
+
const panel = {
|
|
461
|
+
editLabel: "Modifier le titre de la section."
|
|
462
|
+
};
|
|
463
|
+
const general = {
|
|
464
|
+
confirm: "Valider",
|
|
465
|
+
cancel: "Annuler",
|
|
466
|
+
close: "Fermer",
|
|
467
|
+
next: "suivant",
|
|
468
|
+
previous: "précédent"
|
|
469
|
+
};
|
|
470
|
+
const fr = {
|
|
471
|
+
errors: errors,
|
|
472
|
+
nbCharLeft: nbCharLeft,
|
|
473
|
+
input: input,
|
|
474
|
+
form: form,
|
|
475
|
+
message: message,
|
|
476
|
+
modal: modal,
|
|
477
|
+
pagination: pagination,
|
|
478
|
+
panel: panel,
|
|
479
|
+
general: general
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
const defaultLocale = 'en';
|
|
483
|
+
const messages = { en, fr };
|
|
484
|
+
/**
|
|
485
|
+
* Get locale
|
|
486
|
+
*
|
|
487
|
+
* @param {HTMLElement} element element that needs to know the locale to use
|
|
488
|
+
* @returns {string} locale
|
|
489
|
+
*/
|
|
490
|
+
const getLocale = (element) => {
|
|
491
|
+
var _a;
|
|
492
|
+
return ((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang) || navigator.language || defaultLocale;
|
|
493
|
+
};
|
|
494
|
+
/**
|
|
495
|
+
* Get Intl object
|
|
496
|
+
* We load the defined locale but for now we only support the first subtag for messages
|
|
497
|
+
*
|
|
498
|
+
* @param {HTMLElement} element element we need to get the language
|
|
499
|
+
* @returns {{ locale: string; messages: unknown }} messages object
|
|
500
|
+
*/
|
|
501
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
502
|
+
const initLocales = (element) => {
|
|
503
|
+
// Get local
|
|
504
|
+
const locale = getLocale(element);
|
|
505
|
+
// Only keep first subtag
|
|
506
|
+
const localeSubtag = locale.split('-').shift();
|
|
507
|
+
// Return
|
|
508
|
+
return {
|
|
509
|
+
locale,
|
|
510
|
+
messages: messages[localeSubtag] || messages[defaultLocale],
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
|
|
206
514
|
const mgCharacterLeftCss = "mg-character-left.sc-mg-character-left{display:block}";
|
|
207
515
|
|
|
208
516
|
const MgCharacterLeft = class {
|
|
@@ -245,12 +553,16 @@ const MgCharacterLeft = class {
|
|
|
245
553
|
};
|
|
246
554
|
MgCharacterLeft.style = mgCharacterLeftCss;
|
|
247
555
|
|
|
248
|
-
const mgDetailsCss = ".mg-details summary{display:flex;align-items:baseline;cursor:pointer}.mg-details__toggle{margin-left:1.5rem;flex-shrink:0}.mg-details__details{margin-top:1.5rem}";
|
|
556
|
+
const mgDetailsCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-details summary{display:flex;align-items:baseline;cursor:pointer}.mg-details__toggle{margin-left:1.5rem;flex-shrink:0;display:flex;align-items:center;align-self:flex-start;gap:0.6rem;min-height:calc(var(--font-size) * var(--line-height))}.mg-details__toggle mg-icon{align-self:self-end}.mg-details__details{margin-top:1.5rem}";
|
|
249
557
|
|
|
250
558
|
const MgDetails = class {
|
|
251
559
|
constructor(hostRef) {
|
|
252
560
|
registerInstance(this, hostRef);
|
|
253
561
|
this.expandedChange = createEvent(this, "expanded-change", 7);
|
|
562
|
+
/**
|
|
563
|
+
* Hide summary element
|
|
564
|
+
*/
|
|
565
|
+
this.hideSummary = false;
|
|
254
566
|
/**
|
|
255
567
|
* Define if details are diplayed
|
|
256
568
|
*/
|
|
@@ -265,7 +577,7 @@ const MgDetails = class {
|
|
|
265
577
|
};
|
|
266
578
|
}
|
|
267
579
|
validateTitles(newValue) {
|
|
268
|
-
if (newValue === undefined || newValue === '') {
|
|
580
|
+
if (newValue === undefined || newValue.trim() === '') {
|
|
269
581
|
throw new Error('<mg-details> prop "toggleClosed" and "toggleOpened" must be defined.');
|
|
270
582
|
}
|
|
271
583
|
}
|
|
@@ -290,7 +602,7 @@ const MgDetails = class {
|
|
|
290
602
|
* @returns {HTMLElement} HTML Element
|
|
291
603
|
*/
|
|
292
604
|
render() {
|
|
293
|
-
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), "
|
|
605
|
+
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), h("div", { class: "mg-details__details" }, h("slot", { name: "details" }))));
|
|
294
606
|
}
|
|
295
607
|
static get watchers() { return {
|
|
296
608
|
"toggleClosed": ["validateTitles"],
|
|
@@ -300,6 +612,33 @@ const MgDetails = class {
|
|
|
300
612
|
};
|
|
301
613
|
MgDetails.style = mgDetailsCss;
|
|
302
614
|
|
|
615
|
+
const mgDividerCss = ".mg-divider{margin:var(--mg-divider-vertical-spacing) auto;width:12rem;height:var(--mg-divider-thickness);background-color:var(--mg-divider-background-color)}.mg-divider.mg-divider--full{width:100%}";
|
|
616
|
+
|
|
617
|
+
const MgDivider = class {
|
|
618
|
+
constructor(hostRef) {
|
|
619
|
+
registerInstance(this, hostRef);
|
|
620
|
+
/**************
|
|
621
|
+
* Decorators *
|
|
622
|
+
**************/
|
|
623
|
+
/**
|
|
624
|
+
* Define component size
|
|
625
|
+
*/
|
|
626
|
+
this.size = 'regular';
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Render
|
|
630
|
+
*
|
|
631
|
+
* @returns {HTMLElement} HTML Element
|
|
632
|
+
*/
|
|
633
|
+
render() {
|
|
634
|
+
return (h("div", { class: {
|
|
635
|
+
'mg-divider': true,
|
|
636
|
+
'mg-divider--full': this.size === 'full',
|
|
637
|
+
} }));
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
MgDivider.style = mgDividerCss;
|
|
641
|
+
|
|
303
642
|
const mgFormCss = ".is-asterisk{color:hsl(var(--color-danger))}.mg-form,.mg-form-group{--mg-inputs-title-width:var(--mg-form-inputs-title-width, 15rem);--mg-inputs-margin-bottom:1.5rem;--mg-inputs-title-horizontal-space:3rem;--mg-inputs-shrink:0}.mg-form.mg-form--all-required,.mg-form-group.mg-form--all-required{--mg-input-title-display:none}.mg-form>p,.mg-form-group>p{font-size:1.2rem}";
|
|
304
643
|
|
|
305
644
|
const MgForm = class {
|
|
@@ -424,9 +763,8 @@ const MgForm = class {
|
|
|
424
763
|
*/
|
|
425
764
|
componentDidLoad() {
|
|
426
765
|
this.mgButtons.forEach(mgButton => {
|
|
427
|
-
// submit buttons should trigger form submition
|
|
428
|
-
|
|
429
|
-
if (['submit', null].includes(button.getAttribute('type'))) {
|
|
766
|
+
// submit buttons should trigger form submition;
|
|
767
|
+
if (['submit', null].includes(mgButton.getAttribute('type'))) {
|
|
430
768
|
mgButton.addEventListener('click', () => {
|
|
431
769
|
this.form.dispatchEvent(new CustomEvent('submit', { bubbles: true }));
|
|
432
770
|
});
|
|
@@ -496,6 +834,8 @@ const icons = {
|
|
|
496
834
|
'dashboard': () => h("path", { fill: "currentColor", d: "M1.67 8.7H7.3V1.67H1.67v7.04Zm0 5.63H7.3v-4.22H1.67v4.22Zm7.04 0h5.63V7.3H8.71v7.04Zm0-12.67v4.23h5.63V1.67H8.71Z" }),
|
|
497
835
|
'dashboard-outline': () => (h("path", { fill: "currentColor", d: "M13.33 2.67v2.22H9.7V2.67h3.63m-7.04 0V7.7H2.67V2.67H6.3m7.04 5.63v5.04H9.71V8.3h3.63M6.3 11.11v2.22H2.67v-2.22H6.3m8.03-9.44H8.7v4.22h5.63V1.67Zm-7.04 0H1.67v7.04H7.3V1.67Zm7.04 5.63H8.7v7.04h5.63V7.3Zm-7.04 2.81H1.67v4.22H7.3v-4.22Z" })),
|
|
498
836
|
'download': () => (h("path", { fill: "currentColor", d: "M6.4 2v4.1c0 .2-.1.3-.3.3H4c-.2 0-.3.1-.3.3 0 .1 0 .2.1.2l4 4c.1.1.3.1.4 0l4-4c.1-.1.1-.3 0-.4-.1-.1-.1-.1-.2-.1H9.9c-.2 0-.3-.1-.3-.3V2c0-.2-.1-.3-.3-.3H6.7c-.1 0-.3.1-.3.3zm7.9 11v1c0 .2-.1.3-.3.3H2c-.2 0-.3-.1-.3-.3v-1c0-.2.1-.3.3-.3h12c.2 0 .3.1.3.3z" })),
|
|
837
|
+
'ellipsis': () => (h("path", { fill: "currentColor", d: "M2.5 6.17A1.83 1.83 0 1 0 4.33 8c0-1.01-.82-1.83-1.83-1.83Zm11 0A1.83 1.83 0 1 0 15.33 8c0-1.01-.82-1.83-1.83-1.83Zm-5.5 0A1.83 1.83 0 1 0 9.83 8c0-1.01-.82-1.83-1.83-1.83Z" })),
|
|
838
|
+
'ellipsis-vertical': () => (h("path", { fill: "currentColor", d: "M6.17 13.5A1.83 1.83 0 1 0 8 11.67c-1.01 0-1.83.82-1.83 1.83Zm0-11A1.83 1.83 0 1 0 8 .67c-1.01 0-1.83.82-1.83 1.83Zm0 5.5A1.83 1.83 0 1 0 8 6.17c-1.01 0-1.83.82-1.83 1.83Z" })),
|
|
499
839
|
'euro': () => (h("path", { fill: "currentColor", d: "M13 13.14a.4.4 0 0 0-.47-.31A7.79 7.79 0 0 1 11 13a4.31 4.31 0 0 1-4-2.79h3.8a.41.41 0 0 0 .39-.31l.19-.9a.39.39 0 0 0-.3-.47H6.51a7.07 7.07 0 0 1 0-1.38h4.89a.4.4 0 0 0 .39-.31l.22-1a.4.4 0 0 0-.3-.47H7a4.2 4.2 0 0 1 3.92-2.45 6.57 6.57 0 0 1 1.26.14.41.41 0 0 0 .47-.29l.4-1.45a.4.4 0 0 0-.28-.48A9.43 9.43 0 0 0 11 .67a7.12 7.12 0 0 0-6.83 4.7h-1.1a.4.4 0 0 0-.4.39v1a.4.4 0 0 0 .4.39h.72a9.08 9.08 0 0 0 0 1.38h-.72a.39.39 0 0 0-.4.39v.93a.4.4 0 0 0 .4.39h1A7 7 0 0 0 11 15.3a8.7 8.7 0 0 0 2-.25.39.39 0 0 0 .3-.46l-.3-1.45Z" })),
|
|
500
840
|
'euro-circle': () => (h("path", { fill: "currentColor", d: "M8 .67C3.95.67.67 3.95.67 8S3.95 15.33 8 15.33s7.33-3.28 7.33-7.33S12.05.67 8 .67Zm2.27 11.4c-.38.09-.76.14-1.15.14a4.038 4.038 0 0 1-3.99-2.92h-.58c-.13 0-.23-.1-.23-.22v-.54c0-.12.11-.22.23-.22h.41a5.34 5.34 0 0 1 0-.8h-.41c-.13 0-.23-.1-.23-.22v-.58c0-.13.11-.22.23-.22h.63c.6-1.65 2.18-2.74 3.94-2.71.34 0 .68.03 1.02.1.12.03.19.16.16.28l-.23.84c-.03.12-.15.19-.27.17-.24-.05-.48-.08-.73-.08A2.42 2.42 0 0 0 6.81 6.5h2.71c.12.03.2.15.17.27l-.13.58c-.02.1-.12.18-.22.18H6.52c-.03.26-.03.53 0 .8h2.63c.12.03.2.15.17.27l-.11.52c-.03.1-.12.18-.22.18H6.8c.36.96 1.28 1.6 2.31 1.61.3 0 .59-.04.88-.1.12-.02.24.05.27.18l.17.84c.02.12-.05.24-.17.27v-.03Z" })),
|
|
501
841
|
'exclamation-circle': () => (h("path", { fill: "currentColor", d: "M8 15.33c4.05 0 7.33-3.28 7.33-7.33S12.05.67 8 .67.67 3.95.67 8 3.95 15.33 8 15.33Zm.95-3.3c0 .15-.12.27-.28.27h-1.4c-.15 0-.28-.12-.28-.27v-1.31c0-.15.12-.28.28-.28h1.4c.15 0 .28.12.28.28v1.31ZM7 3.96c0-.14.11-.25.25-.25H8.7c.14 0 .25.11.25.25v4.8c0 .14-.11.25-.25.25H7.25c-.14 0-.25-.11-.25-.25V3.95Z" })),
|
|
@@ -595,6 +935,7 @@ const icons = {
|
|
|
595
935
|
'user-group': () => (h("path", { fill: "currentColor", d: "M13.15 4.12c-.81-.01-1.47.65-1.48 1.46 0 .82.65 1.47 1.46 1.48s1.47-.65 1.48-1.46-.65-1.47-1.46-1.48Zm-10.04.01a1.47 1.47 0 0 0-1.58 1.59c.06.71.62 1.28 1.34 1.34.81.07 1.52-.53 1.59-1.34.06-.81-.54-1.52-1.35-1.59Zm7.36.39c-.22-.84-.87-1.51-1.71-1.75-1.36-.41-2.8.36-3.22 1.72-.18.61-.13 1.27.14 1.85.41.9 1.33 1.48 2.32 1.45 1.41.01 2.56-1.14 2.57-2.55 0-.24-.03-.49-.1-.72Zm-.71 4h-.19c-.99.49-2.14.49-3.13 0h-.19c-1.46 0-2.64 1.18-2.64 2.64v2.69c1.23.93 2.74 1.47 4.39 1.47s3.17-.55 4.4-1.48v-2.68c0-1.46-1.18-2.64-2.64-2.64Zm5.52.25a7.282 7.282 0 0 1-1.65 3.91c-.08.1-.16.19-.25.28-.08.09-.17.18-.25.27v-.55h.03v-.72s.01-.07 0-.1v-.66c.01-1.25-.66-2.4-1.76-3 .27-.26.63-.41 1-.41h1.51c.63.01 1.17.41 1.37.98ZM2.86 11.16v1.52h.01v.55l-.28-.31c-.08-.08-.15-.16-.22-.24A7.238 7.238 0 0 1 .74 8.86c.16-.62.72-1.07 1.4-1.07h1.47c.37-.01.73.12 1.01.37-1.1.6-1.77 1.75-1.76 3Z" })),
|
|
596
936
|
'user-plus': () => (h("path", { fill: "currentColor", d: "M14,3.33H12.65V2a.36.36,0,0,0-.35-.33h-.65A.36.36,0,0,0,11.3,2V3.33H10a.34.34,0,0,0-.33.34v.66a.34.34,0,0,0,.33.34H11.3V6a.37.37,0,0,0,.35.33h.65A.37.37,0,0,0,12.65,6V4.67H14a.34.34,0,0,0,.32-.34V3.67A.34.34,0,0,0,14,3.33ZM9.28,9.77h-.2a5.19,5.19,0,0,1-3.91,0H5A3,3,0,0,0,1.7,12.46h0v.72A1.27,1.27,0,0,0,3,14.33h8.25a1.26,1.26,0,0,0,1.36-1.14v-.68A3,3,0,0,0,9.37,9.76H9.28ZM7.13,3.7A2.64,2.64,0,1,1,4.5,6.34h0A2.64,2.64,0,0,1,7.13,3.7Z" })),
|
|
597
937
|
'user-question-outline': () => (h("path", { fill: "currentColor", d: "M5.23 11.14c.86-.66 1.01-1.9.35-2.75s-1.9-1.01-2.75-.35a1.96 1.96 0 0 0 0 3.1c-.72.42-1.16 1.2-1.16 2.03v.8c0 .2.17.37.37.37h3.98c.2 0 .37-.17.37-.37v-.8c0-.83-.44-1.61-1.16-2.03ZM2.81 9.59c0-.67.55-1.22 1.22-1.22s1.22.55 1.22 1.22-.55 1.22-1.22 1.22-1.22-.55-1.22-1.22Zm2.83 4H2.41v-.42c0-.89.72-1.62 1.62-1.62s1.62.72 1.62 1.62v.42h-.01Zm7.13-11.93H8c-.86 0-1.56.7-1.56 1.56v7.16c0 .21.17.37.37.37.08 0 .16-.03.22-.07l1.49-1.12h4.25c.86 0 1.56-.7 1.56-1.56V3.22c0-.86-.7-1.56-1.56-1.56Zm.82 6.33c0 .45-.37.82-.82.82H8.4a.41.41 0 0 0-.22.07l-1 .75V3.22c0-.45.37-.82.82-.82h4.77c.45 0 .82.37.82.82v4.77Zm-2.8-.42c0 .23-.18.41-.41.41s-.41-.18-.41-.41.18-.41.41-.41c.23 0 .41.18.41.41Zm-.41-4.34c-.83 0-1.5.67-1.5 1.5 0 .23.18.41.41.41s.41-.18.41-.41c0-.38.31-.68.69-.68.38 0 .68.31.68.69 0 .38-.31.68-.68.68-.23 0-.41.18-.41.41v.44c0 .23.18.41.41.41s.41-.18.41-.41v-.09c.8-.23 1.26-1.06 1.04-1.85-.18-.65-.77-1.09-1.44-1.09Z" })),
|
|
938
|
+
'user-shield-outline': () => (h("path", { fill: "currentColor", d: "M8 8.92c-1.5 0-2.72-1.22-2.72-2.72S6.5 3.48 8 3.48s2.72 1.22 2.72 2.72S9.5 8.92 8 8.92Zm0-4.64a1.92 1.92 0 1 0 .001 3.841A1.92 1.92 0 0 0 8 4.28Zm4.97-1.84L8.56.78C8.2.65 7.81.65 7.45.78L3.03 2.43C2.41 2.66 2 3.26 2 3.92V8c0 3.82 4.23 6.47 5.52 7.2.15.08.31.13.48.13s.33-.04.48-.13C9.78 14.48 14 11.82 14 8V3.92c0-.66-.41-1.25-1.03-1.48ZM8.08 14.5c-.05.03-.12.03-.17 0-.49-.28-2.12-1.24-3.4-2.68.62-.82 1.94-1.39 3.47-1.39s2.84.61 3.49 1.4c-1.29 1.43-2.9 2.39-3.39 2.67ZM13.19 8c0 1.2-.51 2.28-1.22 3.22-.83-.91-2.34-1.59-4-1.59s-3.16.64-3.98 1.58c-.7-.93-1.2-2.01-1.2-3.2V3.93c0-.33.21-.62.51-.74l4.43-1.66c.09-.03.18-.05.27-.05s.19.02.27.05l4.42 1.66c.3.11.51.41.51.73V8Z" })),
|
|
598
939
|
'users': () => (h("path", { fill: "currentColor", d: "M12,8.76h-.2a5.24,5.24,0,0,1-3.93,0H7.61a3.05,3.05,0,0,0-3.3,2.75v.69a1.28,1.28,0,0,0,1.38,1.14H14a1.27,1.27,0,0,0,1.37-1.14v-.69A3.07,3.07,0,0,0,12,8.75Zm-6.4-.32A2,2,0,0,0,4.31,8H2.48A1.69,1.69,0,0,0,.65,9.53v.76a.85.85,0,0,0,.91.76H3.45A3.58,3.58,0,0,1,5.61,8.44ZM9.81,2.66A2.65,2.65,0,1,1,7.16,5.31h0A2.65,2.65,0,0,1,9.81,2.66ZM3.31,4.18A1.51,1.51,0,1,1,1.8,5.69,1.51,1.51,0,0,1,3.31,4.18Z" })),
|
|
599
940
|
'wallet': () => (h("path", { fill: "currentColor", d: "M13.88 5H3a.43.43 0 0 1-.46-.38.43.43 0 0 1 .46-.43h11a.43.43 0 0 0 .46-.38A1.28 1.28 0 0 0 13 2.67H2.5A1.7 1.7 0 0 0 .67 4.19v7.62a1.7 1.7 0 0 0 1.83 1.52h11.38a1.32 1.32 0 0 0 1.45-1.14V6.1A1.33 1.33 0 0 0 13.88 5Zm-1.21 5.29a1.1 1.1 0 1 1 1.1-1.1 1.1 1.1 0 0 1-1.1 1.05Z" })),
|
|
600
941
|
};
|
|
@@ -700,7 +1041,7 @@ const MgIcon = class {
|
|
|
700
1041
|
};
|
|
701
1042
|
MgIcon.style = mgIconCss;
|
|
702
1043
|
|
|
703
|
-
const mgIllustratedMessageCss = ".mg-illustrated-message{margin:auto;padding:
|
|
1044
|
+
const mgIllustratedMessageCss = ".mg-illustrated-message{display:flex;flex-direction:column;justify-content:center;gap:3em 7rem;margin:auto;padding:var(--mg-illustrated-message-padding-vertical) 1.5rem;max-width:47.5rem;box-sizing:border-box;text-align:center}.mg-illustrated-message.mg-illustrated-message--horizontal{flex-direction:row;flex-wrap:wrap;align-items:center;max-width:unset}.mg-illustrated-message.mg-illustrated-message--horizontal .mg-illustrated-message__slots,.mg-illustrated-message.mg-illustrated-message--horizontal .mg-illustrated-message__illustration{max-width:47.5rem}.mg-illustrated-message__illustration{max-height:33.5rem}.mg-illustrated-message__illustration ::slotted([slot=illustration]){width:auto;height:auto;max-width:100%;max-height:33.5rem}.mg-illustrated-message__illustration.mg-illustrated-message__illustration--small{max-height:6rem}.mg-illustrated-message__illustration.mg-illustrated-message__illustration--small ::slotted([slot=illustration]){max-height:6rem}.mg-illustrated-message__title ::slotted([slot=title]){margin:0;font-size:2rem !important;font-family:var(--font-family) !important;font-weight:400}.mg-illustrated-message__details ::slotted([slot=details]){margin:2rem 0 0}";
|
|
704
1045
|
|
|
705
1046
|
const MgIllustratedMessage = class {
|
|
706
1047
|
constructor(hostRef) {
|
|
@@ -709,6 +1050,10 @@ const MgIllustratedMessage = class {
|
|
|
709
1050
|
* Define illustration size
|
|
710
1051
|
*/
|
|
711
1052
|
this.size = 'regular';
|
|
1053
|
+
/**
|
|
1054
|
+
* Define component orientation
|
|
1055
|
+
*/
|
|
1056
|
+
this.direction = 'vertical';
|
|
712
1057
|
}
|
|
713
1058
|
/*************
|
|
714
1059
|
* Lifecycle *
|
|
@@ -734,10 +1079,13 @@ const MgIllustratedMessage = class {
|
|
|
734
1079
|
* @returns {HTMLElement} HTML Element
|
|
735
1080
|
*/
|
|
736
1081
|
render() {
|
|
737
|
-
return (h("div", { class:
|
|
1082
|
+
return (h("div", { class: {
|
|
1083
|
+
'mg-illustrated-message': true,
|
|
1084
|
+
'mg-illustrated-message--horizontal': this.direction === 'horizontal',
|
|
1085
|
+
} }, h("div", { class: {
|
|
738
1086
|
'mg-illustrated-message__illustration': true,
|
|
739
1087
|
'mg-illustrated-message__illustration--small': this.size === 'small',
|
|
740
|
-
} }, h("slot", { name: "illustration" })), h("div", { class: "mg-illustrated-message__title" }, h("slot", { name: "title" })), h("div", { class: "mg-illustrated-message__details" }, h("slot", { name: "details" }))));
|
|
1088
|
+
} }, h("slot", { name: "illustration" })), h("div", { class: "mg-illustrated-message__slots" }, h("div", { class: "mg-illustrated-message__title" }, h("slot", { name: "title" })), h("div", { class: "mg-illustrated-message__details" }, h("slot", { name: "details" })))));
|
|
741
1089
|
}
|
|
742
1090
|
get element() { return getElement(this); }
|
|
743
1091
|
};
|
|
@@ -794,9 +1142,7 @@ const MgInput = (props, children, utils) => {
|
|
|
794
1142
|
* Check required properties
|
|
795
1143
|
*/
|
|
796
1144
|
if (typeof props.identifier !== 'string' || props.identifier.trim() === '') {
|
|
797
|
-
|
|
798
|
-
// throw new Error('<mg-input> prop "identifier" is required.');
|
|
799
|
-
console.error('<mg-input> prop "identifier" is required.');
|
|
1145
|
+
throw new Error('<mg-input> prop "identifier" is required.');
|
|
800
1146
|
}
|
|
801
1147
|
if (typeof props.label !== 'string' || props.label.trim() === '') {
|
|
802
1148
|
throw new Error('<mg-input> prop "label" is required.');
|
|
@@ -2512,9 +2858,7 @@ const MgInputTitle = class {
|
|
|
2512
2858
|
}
|
|
2513
2859
|
validateIdentifier(newValue) {
|
|
2514
2860
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
2515
|
-
|
|
2516
|
-
// throw new Error('<mg-input-title> prop "identifier" is required.');
|
|
2517
|
-
console.error('<mg-input-title> prop "identifier" is required.');
|
|
2861
|
+
throw new Error('<mg-input-title> prop "identifier" is required.');
|
|
2518
2862
|
}
|
|
2519
2863
|
}
|
|
2520
2864
|
/*************
|
|
@@ -2899,6 +3243,174 @@ const MgMessage = class {
|
|
|
2899
3243
|
};
|
|
2900
3244
|
MgMessage.style = mgMessageCss;
|
|
2901
3245
|
|
|
3246
|
+
const mgModalCss = ".mg-modal{display:flex;justify-content:center;align-items:center;position:fixed;top:0;right:0;bottom:0;left:0;z-index:2000;padding:2rem 0;background-color:hsla(var(--color-light), 85%)}.mg-modal__dialog{display:flex;position:relative;flex-direction:column;align-self:center;row-gap:3rem;padding:1.5rem 2.5rem;width:60rem;height:fit-content;max-width:100%;max-height:100%;box-sizing:border-box;background-color:hsl(var(--color-light));box-shadow:var(--box-shadow);border-radius:var(--mg-modal-border-radius)}.mg-modal__header{margin-bottom:0.5rem}.mg-modal__title{margin:0;font-family:var(--font-family-heading);font-size:var(--mg-modal-title-font-size);font-weight:600}.mg-modal__close-button{float:right;height:var(--mg-modal-title-font-size);margin-top:calc((var(--default-size) - var(--mg-modal-title-font-size) * var(--line-height)) / 2 * -1);margin-right:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2 * -1)}.mg-modal__content{overflow-y:auto}.mg-modal__content::slotted(*){font-size:var(--mg-modal-content-font-size)}.mg-modal.mg-modal--hide{display:none}";
|
|
3247
|
+
|
|
3248
|
+
const MgModal = class {
|
|
3249
|
+
constructor(hostRef) {
|
|
3250
|
+
registerInstance(this, hostRef);
|
|
3251
|
+
this.componentShow = createEvent(this, "component-show", 7);
|
|
3252
|
+
this.componentHide = createEvent(this, "component-hide", 7);
|
|
3253
|
+
// Classes
|
|
3254
|
+
this.classHide = 'mg-modal--hide';
|
|
3255
|
+
// IDs
|
|
3256
|
+
this.closeButtonId = '';
|
|
3257
|
+
this.titleId = '';
|
|
3258
|
+
/**
|
|
3259
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
3260
|
+
* If not set, it will be created.
|
|
3261
|
+
*/
|
|
3262
|
+
this.identifier = createID('mg-modal');
|
|
3263
|
+
/**
|
|
3264
|
+
* Define if modal has a cross button
|
|
3265
|
+
*/
|
|
3266
|
+
this.closeButton = false;
|
|
3267
|
+
/**
|
|
3268
|
+
* Define if modal is hidden
|
|
3269
|
+
*/
|
|
3270
|
+
this.hide = false;
|
|
3271
|
+
/**
|
|
3272
|
+
* Define if component is using actions slot
|
|
3273
|
+
*/
|
|
3274
|
+
this.hasActions = false;
|
|
3275
|
+
/**
|
|
3276
|
+
* Define if component is using content slot
|
|
3277
|
+
*/
|
|
3278
|
+
this.hasContent = false;
|
|
3279
|
+
/**
|
|
3280
|
+
* Component classes
|
|
3281
|
+
*/
|
|
3282
|
+
this.classList = new ClassList(['mg-modal']);
|
|
3283
|
+
this.setFocus = () => {
|
|
3284
|
+
// Get all focusable elements
|
|
3285
|
+
this.modalFocusableElements = Array.from(this.element.querySelectorAll(focusableElements)).reduce((acc, focusableElement) => {
|
|
3286
|
+
acc.push(focusableElement.shadowRoot !== null ? focusableElement.shadowRoot.querySelector(focusableElements) || focusableElement : focusableElement);
|
|
3287
|
+
return acc;
|
|
3288
|
+
}, []);
|
|
3289
|
+
// When close button is enabled it's the first focusable element.
|
|
3290
|
+
if (this.closeButton) {
|
|
3291
|
+
this.modalFocusableElements.unshift(this.element.shadowRoot.querySelector(`.mg-modal__close-button mg-button`));
|
|
3292
|
+
}
|
|
3293
|
+
// It at least one
|
|
3294
|
+
if (this.modalFocusableElements.length >= 1) {
|
|
3295
|
+
// Set focus on first element
|
|
3296
|
+
this.modalFocusableElements[0].focus();
|
|
3297
|
+
// Add event listener on last element
|
|
3298
|
+
const lastFocusableElement = this.modalFocusableElements[this.modalFocusableElements.length - 1];
|
|
3299
|
+
lastFocusableElement.addEventListener('keydown', event => {
|
|
3300
|
+
if (event.key === 'Tab' && !event.shiftKey) {
|
|
3301
|
+
event.preventDefault();
|
|
3302
|
+
this.modalFocusableElements[0].focus();
|
|
3303
|
+
}
|
|
3304
|
+
});
|
|
3305
|
+
// Add event listener on first element (case shift + tab)
|
|
3306
|
+
this.modalFocusableElements[0].addEventListener('keydown', event => {
|
|
3307
|
+
if (event.key === 'Tab' && event.shiftKey) {
|
|
3308
|
+
event.preventDefault();
|
|
3309
|
+
lastFocusableElement.focus();
|
|
3310
|
+
}
|
|
3311
|
+
});
|
|
3312
|
+
}
|
|
3313
|
+
};
|
|
3314
|
+
/*************
|
|
3315
|
+
* Handlers *
|
|
3316
|
+
*************/
|
|
3317
|
+
/**
|
|
3318
|
+
* Handle close button
|
|
3319
|
+
*
|
|
3320
|
+
* @returns {void}
|
|
3321
|
+
*/
|
|
3322
|
+
this.handleClose = () => {
|
|
3323
|
+
this.hide = true;
|
|
3324
|
+
};
|
|
3325
|
+
}
|
|
3326
|
+
validateModalTitle(newValue) {
|
|
3327
|
+
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
3328
|
+
throw new Error('<mg-modal> prop "modalTitle" is required.');
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
validateHide(newValue) {
|
|
3332
|
+
if (newValue) {
|
|
3333
|
+
this.componentHide.emit();
|
|
3334
|
+
this.classList.add(this.classHide);
|
|
3335
|
+
document.body.style.overflow = this.bodyOverflow;
|
|
3336
|
+
}
|
|
3337
|
+
else {
|
|
3338
|
+
this.componentShow.emit();
|
|
3339
|
+
this.classList.delete(this.classHide);
|
|
3340
|
+
document.body.style.overflow = 'hidden';
|
|
3341
|
+
}
|
|
3342
|
+
}
|
|
3343
|
+
/**
|
|
3344
|
+
* Handle 'escape' key down
|
|
3345
|
+
*
|
|
3346
|
+
* @param {KeyboardEvent} event keydown event
|
|
3347
|
+
* @returns {void}
|
|
3348
|
+
*/
|
|
3349
|
+
handleKeyDown(event) {
|
|
3350
|
+
// we can use 'Escape button" when this not a blocking modal, induced by closeButton value.
|
|
3351
|
+
if (this.closeButton && event.key === 'Escape') {
|
|
3352
|
+
this.hide = true;
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
/*************
|
|
3356
|
+
* Lifecycle *
|
|
3357
|
+
*************/
|
|
3358
|
+
/**
|
|
3359
|
+
* Check if component props are well configured on init
|
|
3360
|
+
*
|
|
3361
|
+
* @returns {void}
|
|
3362
|
+
*/
|
|
3363
|
+
componentWillLoad() {
|
|
3364
|
+
// Store body overflow
|
|
3365
|
+
this.bodyOverflow = document.body.style.overflow;
|
|
3366
|
+
// Get locales
|
|
3367
|
+
this.messages = initLocales(this.element).messages;
|
|
3368
|
+
// Validate
|
|
3369
|
+
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
3370
|
+
this.hasContent = this.element.querySelector('[slot="content"]') !== null;
|
|
3371
|
+
if (this.closeButton) {
|
|
3372
|
+
this.closeButtonId = `${this.identifier}-close-button`;
|
|
3373
|
+
}
|
|
3374
|
+
this.titleId = `${this.identifier}-title`;
|
|
3375
|
+
this.validateModalTitle(this.modalTitle);
|
|
3376
|
+
this.validateHide(this.hide);
|
|
3377
|
+
}
|
|
3378
|
+
/**
|
|
3379
|
+
* Add observer on component to set focus when displayed
|
|
3380
|
+
*
|
|
3381
|
+
* @returns {void}
|
|
3382
|
+
*/
|
|
3383
|
+
componentDidLoad() {
|
|
3384
|
+
new MutationObserver(mutationList => {
|
|
3385
|
+
/*
|
|
3386
|
+
TODO find a way to cover this callback
|
|
3387
|
+
*/
|
|
3388
|
+
/* istanbul ignore next */
|
|
3389
|
+
if (mutationList.some(mutation => mutation.attributeName === 'aria-hidden' && mutation.target.ariaHidden === null)) {
|
|
3390
|
+
this.setFocus();
|
|
3391
|
+
}
|
|
3392
|
+
}).observe(this.element.shadowRoot.getElementById(this.identifier), { attributes: true });
|
|
3393
|
+
// Set focus if display on load
|
|
3394
|
+
if (!this.hide) {
|
|
3395
|
+
this.setFocus();
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
/**
|
|
3399
|
+
* Render
|
|
3400
|
+
*
|
|
3401
|
+
* @returns {HTMLElement} HTML Element
|
|
3402
|
+
*/
|
|
3403
|
+
render() {
|
|
3404
|
+
return (h("section", { role: "dialog", id: this.identifier, class: this.classList.join(), tabindex: "-1", "aria-labelledby": this.titleId, "aria-modal": "true", "aria-hidden": this.hide }, h("article", { class: "mg-modal__dialog" }, h("header", { class: "mg-modal__header" }, this.closeButton && (h("span", { class: "mg-modal__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" })))), h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)), this.hasContent && (h("article", { class: "mg-modal__content" }, h("slot", { name: "content" }))), this.hasActions && (h("footer", { class: "mg-modal__footer" }, h("slot", { name: "actions" }))))));
|
|
3405
|
+
}
|
|
3406
|
+
get element() { return getElement(this); }
|
|
3407
|
+
static get watchers() { return {
|
|
3408
|
+
"modalTitle": ["validateModalTitle"],
|
|
3409
|
+
"hide": ["validateHide"]
|
|
3410
|
+
}; }
|
|
3411
|
+
};
|
|
3412
|
+
MgModal.style = mgModalCss;
|
|
3413
|
+
|
|
2902
3414
|
var NavigationAction;
|
|
2903
3415
|
(function (NavigationAction) {
|
|
2904
3416
|
NavigationAction["NEXT"] = "next";
|
|
@@ -2971,10 +3483,11 @@ const MgPagination = class {
|
|
|
2971
3483
|
* Go to 'previous/next' page button handler
|
|
2972
3484
|
*
|
|
2973
3485
|
* @param {string} action navigation action
|
|
3486
|
+
* @param {boolean} disabled button disable state
|
|
2974
3487
|
* @returns {void}
|
|
2975
3488
|
*/
|
|
2976
|
-
this.handleGoToPage = (action) => {
|
|
2977
|
-
this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
3489
|
+
this.handleGoToPage = (action, disabled) => {
|
|
3490
|
+
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
2978
3491
|
};
|
|
2979
3492
|
}
|
|
2980
3493
|
validateTotalPages(newValue) {
|
|
@@ -3018,7 +3531,7 @@ const MgPagination = class {
|
|
|
3018
3531
|
render() {
|
|
3019
3532
|
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, label: this.messages.pagination[`${action}Page`],
|
|
3020
3533
|
// eslint-disable-next-line react/jsx-no-bind
|
|
3021
|
-
onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" }, action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }), this.messages.general[action], action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
|
|
3534
|
+
onClick: () => this.handleGoToPage(action, disabled), disabled: disabled, variant: "flat" }, action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }), this.messages.general[action], action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
|
|
3022
3535
|
return (h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination" }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), h("span", { class: "sr-only" }, this.messages.pagination.page, " ", this.currentPage), h("span", null, "/ ", this.totalPages, " ", this.totalPages > 1 ? this.messages.pagination.pages : this.messages.pagination.page), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
|
|
3023
3536
|
}
|
|
3024
3537
|
get element() { return getElement(this); }
|
|
@@ -3029,7 +3542,7 @@ const MgPagination = class {
|
|
|
3029
3542
|
};
|
|
3030
3543
|
MgPagination.style = mgPaginationCss;
|
|
3031
3544
|
|
|
3032
|
-
const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);box-shadow:var(--box-shadow)}.mg-panel__header{display:flex;flex-wrap:wrap;justify-content:space-between;padding:0 1rem 0 0.3rem;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:flex;margin:0.3rem 0}.mg-panel__header-left
|
|
3545
|
+
const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);box-shadow:var(--mg-panel-box-shadow)}.mg-panel__header{display:flex;flex-wrap:wrap;justify-content:space-between;padding:0 1rem 0 0.3rem;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:flex;margin:0.3rem 0}.mg-panel__header-right{padding-left:0.3rem;flex:1 auto}.mg-panel__header-left mg-input-text{flex-grow:1;margin-left:0.3rem}.mg-panel__header-left mg-button+mg-button:not([slot=append-input]){margin-left:0.3rem}.mg-panel__header-left.mg-panel__header-left--full{flex:1 1 auto}.mg-panel__collapse-button-content{--font-size:1.4rem;--mg-button-font-weight:600}.mg-panel__content{padding:var(--mg-panel-content-padding)}.mg-panel ::slotted([slot=header-right]){display:flex;flex-wrap:wrap;gap:1rem;margin-left:auto}";
|
|
3033
3546
|
|
|
3034
3547
|
const MgPanel = class {
|
|
3035
3548
|
constructor(hostRef) {
|
|
@@ -3126,7 +3639,7 @@ const MgPanel = class {
|
|
|
3126
3639
|
* @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
|
|
3127
3640
|
*/
|
|
3128
3641
|
this.headerLeft = () => {
|
|
3129
|
-
const collapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", identifier: `${this.identifier}-collapse-button`, expanded: this.expanded, controls: `${this.identifier}-content`, disabled: this.expandToggleDisabled }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle));
|
|
3642
|
+
const collapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", identifier: `${this.identifier}-collapse-button`, "aria-expanded": this.expanded !== undefined && this.expanded.toString(), "aria-controls": `${this.identifier}-content`, disabled: this.expandToggleDisabled }, h("span", { class: "mg-panel__collapse-button-content" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle)));
|
|
3130
3643
|
if (this.titleEditable && !this.isEditing) {
|
|
3131
3644
|
return [
|
|
3132
3645
|
collapseButton(),
|
|
@@ -3144,9 +3657,7 @@ const MgPanel = class {
|
|
|
3144
3657
|
}
|
|
3145
3658
|
validatePanelTitle(newValue) {
|
|
3146
3659
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
3147
|
-
|
|
3148
|
-
// throw new Error('<mg-panel> prop "panelTitle" is required.');
|
|
3149
|
-
console.error('<mg-panel> prop "panelTitle" is required.');
|
|
3660
|
+
throw new Error('<mg-panel> prop "panelTitle" is required.');
|
|
3150
3661
|
}
|
|
3151
3662
|
this.titleChange.emit(newValue);
|
|
3152
3663
|
}
|
|
@@ -3204,31 +3715,1991 @@ const MgPanel = class {
|
|
|
3204
3715
|
};
|
|
3205
3716
|
MgPanel.style = mgPanelCss;
|
|
3206
3717
|
|
|
3207
|
-
var
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3718
|
+
var top = 'top';
|
|
3719
|
+
var bottom = 'bottom';
|
|
3720
|
+
var right = 'right';
|
|
3721
|
+
var left = 'left';
|
|
3722
|
+
var auto = 'auto';
|
|
3723
|
+
var basePlacements = [top, bottom, right, left];
|
|
3724
|
+
var start = 'start';
|
|
3725
|
+
var end = 'end';
|
|
3726
|
+
var clippingParents = 'clippingParents';
|
|
3727
|
+
var viewport = 'viewport';
|
|
3728
|
+
var popper = 'popper';
|
|
3729
|
+
var reference = 'reference';
|
|
3730
|
+
var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) {
|
|
3731
|
+
return acc.concat([placement + "-" + start, placement + "-" + end]);
|
|
3732
|
+
}, []);
|
|
3733
|
+
var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) {
|
|
3734
|
+
return acc.concat([placement, placement + "-" + start, placement + "-" + end]);
|
|
3735
|
+
}, []); // modifiers that need to read the DOM
|
|
3218
3736
|
|
|
3219
|
-
|
|
3737
|
+
var beforeRead = 'beforeRead';
|
|
3738
|
+
var read = 'read';
|
|
3739
|
+
var afterRead = 'afterRead'; // pure-logic modifiers
|
|
3220
3740
|
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3741
|
+
var beforeMain = 'beforeMain';
|
|
3742
|
+
var main = 'main';
|
|
3743
|
+
var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
|
|
3744
|
+
|
|
3745
|
+
var beforeWrite = 'beforeWrite';
|
|
3746
|
+
var write = 'write';
|
|
3747
|
+
var afterWrite = 'afterWrite';
|
|
3748
|
+
var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
|
|
3749
|
+
|
|
3750
|
+
function getNodeName(element) {
|
|
3751
|
+
return element ? (element.nodeName || '').toLowerCase() : null;
|
|
3752
|
+
}
|
|
3753
|
+
|
|
3754
|
+
function getWindow(node) {
|
|
3755
|
+
if (node == null) {
|
|
3756
|
+
return window;
|
|
3757
|
+
}
|
|
3758
|
+
|
|
3759
|
+
if (node.toString() !== '[object Window]') {
|
|
3760
|
+
var ownerDocument = node.ownerDocument;
|
|
3761
|
+
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
3762
|
+
}
|
|
3763
|
+
|
|
3764
|
+
return node;
|
|
3765
|
+
}
|
|
3766
|
+
|
|
3767
|
+
function isElement(node) {
|
|
3768
|
+
var OwnElement = getWindow(node).Element;
|
|
3769
|
+
return node instanceof OwnElement || node instanceof Element;
|
|
3770
|
+
}
|
|
3771
|
+
|
|
3772
|
+
function isHTMLElement(node) {
|
|
3773
|
+
var OwnElement = getWindow(node).HTMLElement;
|
|
3774
|
+
return node instanceof OwnElement || node instanceof HTMLElement;
|
|
3775
|
+
}
|
|
3776
|
+
|
|
3777
|
+
function isShadowRoot(node) {
|
|
3778
|
+
// IE 11 has no ShadowRoot
|
|
3779
|
+
if (typeof ShadowRoot === 'undefined') {
|
|
3780
|
+
return false;
|
|
3781
|
+
}
|
|
3782
|
+
|
|
3783
|
+
var OwnElement = getWindow(node).ShadowRoot;
|
|
3784
|
+
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
3785
|
+
}
|
|
3786
|
+
|
|
3787
|
+
// and applies them to the HTMLElements such as popper and arrow
|
|
3788
|
+
|
|
3789
|
+
function applyStyles(_ref) {
|
|
3790
|
+
var state = _ref.state;
|
|
3791
|
+
Object.keys(state.elements).forEach(function (name) {
|
|
3792
|
+
var style = state.styles[name] || {};
|
|
3793
|
+
var attributes = state.attributes[name] || {};
|
|
3794
|
+
var element = state.elements[name]; // arrow is optional + virtual elements
|
|
3795
|
+
|
|
3796
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
3797
|
+
return;
|
|
3798
|
+
} // Flow doesn't support to extend this property, but it's the most
|
|
3799
|
+
// effective way to apply styles to an HTMLElement
|
|
3800
|
+
// $FlowFixMe[cannot-write]
|
|
3801
|
+
|
|
3802
|
+
|
|
3803
|
+
Object.assign(element.style, style);
|
|
3804
|
+
Object.keys(attributes).forEach(function (name) {
|
|
3805
|
+
var value = attributes[name];
|
|
3806
|
+
|
|
3807
|
+
if (value === false) {
|
|
3808
|
+
element.removeAttribute(name);
|
|
3809
|
+
} else {
|
|
3810
|
+
element.setAttribute(name, value === true ? '' : value);
|
|
3811
|
+
}
|
|
3812
|
+
});
|
|
3813
|
+
});
|
|
3814
|
+
}
|
|
3815
|
+
|
|
3816
|
+
function effect$2(_ref2) {
|
|
3817
|
+
var state = _ref2.state;
|
|
3818
|
+
var initialStyles = {
|
|
3819
|
+
popper: {
|
|
3820
|
+
position: state.options.strategy,
|
|
3821
|
+
left: '0',
|
|
3822
|
+
top: '0',
|
|
3823
|
+
margin: '0'
|
|
3824
|
+
},
|
|
3825
|
+
arrow: {
|
|
3826
|
+
position: 'absolute'
|
|
3827
|
+
},
|
|
3828
|
+
reference: {}
|
|
3829
|
+
};
|
|
3830
|
+
Object.assign(state.elements.popper.style, initialStyles.popper);
|
|
3831
|
+
state.styles = initialStyles;
|
|
3832
|
+
|
|
3833
|
+
if (state.elements.arrow) {
|
|
3834
|
+
Object.assign(state.elements.arrow.style, initialStyles.arrow);
|
|
3835
|
+
}
|
|
3836
|
+
|
|
3837
|
+
return function () {
|
|
3838
|
+
Object.keys(state.elements).forEach(function (name) {
|
|
3839
|
+
var element = state.elements[name];
|
|
3840
|
+
var attributes = state.attributes[name] || {};
|
|
3841
|
+
var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
|
|
3842
|
+
|
|
3843
|
+
var style = styleProperties.reduce(function (style, property) {
|
|
3844
|
+
style[property] = '';
|
|
3845
|
+
return style;
|
|
3846
|
+
}, {}); // arrow is optional + virtual elements
|
|
3847
|
+
|
|
3848
|
+
if (!isHTMLElement(element) || !getNodeName(element)) {
|
|
3849
|
+
return;
|
|
3850
|
+
}
|
|
3851
|
+
|
|
3852
|
+
Object.assign(element.style, style);
|
|
3853
|
+
Object.keys(attributes).forEach(function (attribute) {
|
|
3854
|
+
element.removeAttribute(attribute);
|
|
3855
|
+
});
|
|
3856
|
+
});
|
|
3857
|
+
};
|
|
3858
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
3859
|
+
|
|
3860
|
+
|
|
3861
|
+
const applyStyles$1 = {
|
|
3862
|
+
name: 'applyStyles',
|
|
3863
|
+
enabled: true,
|
|
3864
|
+
phase: 'write',
|
|
3865
|
+
fn: applyStyles,
|
|
3866
|
+
effect: effect$2,
|
|
3867
|
+
requires: ['computeStyles']
|
|
3868
|
+
};
|
|
3869
|
+
|
|
3870
|
+
function getBasePlacement(placement) {
|
|
3871
|
+
return placement.split('-')[0];
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3874
|
+
var max = Math.max;
|
|
3875
|
+
var min = Math.min;
|
|
3876
|
+
var round = Math.round;
|
|
3877
|
+
|
|
3878
|
+
function getUAString() {
|
|
3879
|
+
var uaData = navigator.userAgentData;
|
|
3880
|
+
|
|
3881
|
+
if (uaData != null && uaData.brands) {
|
|
3882
|
+
return uaData.brands.map(function (item) {
|
|
3883
|
+
return item.brand + "/" + item.version;
|
|
3884
|
+
}).join(' ');
|
|
3885
|
+
}
|
|
3886
|
+
|
|
3887
|
+
return navigator.userAgent;
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
function isLayoutViewport() {
|
|
3891
|
+
return !/^((?!chrome|android).)*safari/i.test(getUAString());
|
|
3892
|
+
}
|
|
3893
|
+
|
|
3894
|
+
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
3895
|
+
if (includeScale === void 0) {
|
|
3896
|
+
includeScale = false;
|
|
3897
|
+
}
|
|
3898
|
+
|
|
3899
|
+
if (isFixedStrategy === void 0) {
|
|
3900
|
+
isFixedStrategy = false;
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
var clientRect = element.getBoundingClientRect();
|
|
3904
|
+
var scaleX = 1;
|
|
3905
|
+
var scaleY = 1;
|
|
3906
|
+
|
|
3907
|
+
if (includeScale && isHTMLElement(element)) {
|
|
3908
|
+
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
3909
|
+
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
3910
|
+
}
|
|
3911
|
+
|
|
3912
|
+
var _ref = isElement(element) ? getWindow(element) : window,
|
|
3913
|
+
visualViewport = _ref.visualViewport;
|
|
3914
|
+
|
|
3915
|
+
var addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
3916
|
+
var x = (clientRect.left + (addVisualOffsets && visualViewport ? visualViewport.offsetLeft : 0)) / scaleX;
|
|
3917
|
+
var y = (clientRect.top + (addVisualOffsets && visualViewport ? visualViewport.offsetTop : 0)) / scaleY;
|
|
3918
|
+
var width = clientRect.width / scaleX;
|
|
3919
|
+
var height = clientRect.height / scaleY;
|
|
3920
|
+
return {
|
|
3921
|
+
width: width,
|
|
3922
|
+
height: height,
|
|
3923
|
+
top: y,
|
|
3924
|
+
right: x + width,
|
|
3925
|
+
bottom: y + height,
|
|
3926
|
+
left: x,
|
|
3927
|
+
x: x,
|
|
3928
|
+
y: y
|
|
3929
|
+
};
|
|
3930
|
+
}
|
|
3931
|
+
|
|
3932
|
+
// means it doesn't take into account transforms.
|
|
3933
|
+
|
|
3934
|
+
function getLayoutRect(element) {
|
|
3935
|
+
var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
|
|
3936
|
+
// Fixes https://github.com/popperjs/popper-core/issues/1223
|
|
3937
|
+
|
|
3938
|
+
var width = element.offsetWidth;
|
|
3939
|
+
var height = element.offsetHeight;
|
|
3940
|
+
|
|
3941
|
+
if (Math.abs(clientRect.width - width) <= 1) {
|
|
3942
|
+
width = clientRect.width;
|
|
3943
|
+
}
|
|
3944
|
+
|
|
3945
|
+
if (Math.abs(clientRect.height - height) <= 1) {
|
|
3946
|
+
height = clientRect.height;
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3949
|
+
return {
|
|
3950
|
+
x: element.offsetLeft,
|
|
3951
|
+
y: element.offsetTop,
|
|
3952
|
+
width: width,
|
|
3953
|
+
height: height
|
|
3954
|
+
};
|
|
3955
|
+
}
|
|
3956
|
+
|
|
3957
|
+
function contains(parent, child) {
|
|
3958
|
+
var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
|
|
3959
|
+
|
|
3960
|
+
if (parent.contains(child)) {
|
|
3961
|
+
return true;
|
|
3962
|
+
} // then fallback to custom implementation with Shadow DOM support
|
|
3963
|
+
else if (rootNode && isShadowRoot(rootNode)) {
|
|
3964
|
+
var next = child;
|
|
3965
|
+
|
|
3966
|
+
do {
|
|
3967
|
+
if (next && parent.isSameNode(next)) {
|
|
3968
|
+
return true;
|
|
3969
|
+
} // $FlowFixMe[prop-missing]: need a better way to handle this...
|
|
3970
|
+
|
|
3971
|
+
|
|
3972
|
+
next = next.parentNode || next.host;
|
|
3973
|
+
} while (next);
|
|
3974
|
+
} // Give up, the result is false
|
|
3975
|
+
|
|
3976
|
+
|
|
3977
|
+
return false;
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
function getComputedStyle(element) {
|
|
3981
|
+
return getWindow(element).getComputedStyle(element);
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3984
|
+
function isTableElement(element) {
|
|
3985
|
+
return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
|
|
3986
|
+
}
|
|
3987
|
+
|
|
3988
|
+
function getDocumentElement(element) {
|
|
3989
|
+
// $FlowFixMe[incompatible-return]: assume body is always available
|
|
3990
|
+
return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
|
|
3991
|
+
element.document) || window.document).documentElement;
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
function getParentNode(element) {
|
|
3995
|
+
if (getNodeName(element) === 'html') {
|
|
3996
|
+
return element;
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
|
|
4000
|
+
// $FlowFixMe[incompatible-return]
|
|
4001
|
+
// $FlowFixMe[prop-missing]
|
|
4002
|
+
element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
|
|
4003
|
+
element.parentNode || ( // DOM Element detected
|
|
4004
|
+
isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
|
|
4005
|
+
// $FlowFixMe[incompatible-call]: HTMLElement is a Node
|
|
4006
|
+
getDocumentElement(element) // fallback
|
|
4007
|
+
|
|
4008
|
+
);
|
|
4009
|
+
}
|
|
4010
|
+
|
|
4011
|
+
function getTrueOffsetParent(element) {
|
|
4012
|
+
if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
|
|
4013
|
+
getComputedStyle(element).position === 'fixed') {
|
|
4014
|
+
return null;
|
|
4015
|
+
}
|
|
4016
|
+
|
|
4017
|
+
return element.offsetParent;
|
|
4018
|
+
} // `.offsetParent` reports `null` for fixed elements, while absolute elements
|
|
4019
|
+
// return the containing block
|
|
4020
|
+
|
|
4021
|
+
|
|
4022
|
+
function getContainingBlock(element) {
|
|
4023
|
+
var isFirefox = /firefox/i.test(getUAString());
|
|
4024
|
+
var isIE = /Trident/i.test(getUAString());
|
|
4025
|
+
|
|
4026
|
+
if (isIE && isHTMLElement(element)) {
|
|
4027
|
+
// In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
|
|
4028
|
+
var elementCss = getComputedStyle(element);
|
|
4029
|
+
|
|
4030
|
+
if (elementCss.position === 'fixed') {
|
|
4031
|
+
return null;
|
|
4032
|
+
}
|
|
4033
|
+
}
|
|
4034
|
+
|
|
4035
|
+
var currentNode = getParentNode(element);
|
|
4036
|
+
|
|
4037
|
+
if (isShadowRoot(currentNode)) {
|
|
4038
|
+
currentNode = currentNode.host;
|
|
4039
|
+
}
|
|
4040
|
+
|
|
4041
|
+
while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
|
|
4042
|
+
var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
|
|
4043
|
+
// create a containing block.
|
|
4044
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
|
|
4045
|
+
|
|
4046
|
+
if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
|
|
4047
|
+
return currentNode;
|
|
4048
|
+
} else {
|
|
4049
|
+
currentNode = currentNode.parentNode;
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
|
|
4053
|
+
return null;
|
|
4054
|
+
} // Gets the closest ancestor positioned element. Handles some edge cases,
|
|
4055
|
+
// such as table ancestors and cross browser bugs.
|
|
4056
|
+
|
|
4057
|
+
|
|
4058
|
+
function getOffsetParent(element) {
|
|
4059
|
+
var window = getWindow(element);
|
|
4060
|
+
var offsetParent = getTrueOffsetParent(element);
|
|
4061
|
+
|
|
4062
|
+
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
|
|
4063
|
+
offsetParent = getTrueOffsetParent(offsetParent);
|
|
4064
|
+
}
|
|
4065
|
+
|
|
4066
|
+
if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
|
|
4067
|
+
return window;
|
|
4068
|
+
}
|
|
4069
|
+
|
|
4070
|
+
return offsetParent || getContainingBlock(element) || window;
|
|
4071
|
+
}
|
|
4072
|
+
|
|
4073
|
+
function getMainAxisFromPlacement(placement) {
|
|
4074
|
+
return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
|
|
4075
|
+
}
|
|
4076
|
+
|
|
4077
|
+
function within(min$1, value, max$1) {
|
|
4078
|
+
return max(min$1, min(value, max$1));
|
|
4079
|
+
}
|
|
4080
|
+
function withinMaxClamp(min, value, max) {
|
|
4081
|
+
var v = within(min, value, max);
|
|
4082
|
+
return v > max ? max : v;
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
function getFreshSideObject() {
|
|
4086
|
+
return {
|
|
4087
|
+
top: 0,
|
|
4088
|
+
right: 0,
|
|
4089
|
+
bottom: 0,
|
|
4090
|
+
left: 0
|
|
4091
|
+
};
|
|
4092
|
+
}
|
|
4093
|
+
|
|
4094
|
+
function mergePaddingObject(paddingObject) {
|
|
4095
|
+
return Object.assign({}, getFreshSideObject(), paddingObject);
|
|
4096
|
+
}
|
|
4097
|
+
|
|
4098
|
+
function expandToHashMap(value, keys) {
|
|
4099
|
+
return keys.reduce(function (hashMap, key) {
|
|
4100
|
+
hashMap[key] = value;
|
|
4101
|
+
return hashMap;
|
|
4102
|
+
}, {});
|
|
4103
|
+
}
|
|
4104
|
+
|
|
4105
|
+
var toPaddingObject = function toPaddingObject(padding, state) {
|
|
4106
|
+
padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
|
|
4107
|
+
placement: state.placement
|
|
4108
|
+
})) : padding;
|
|
4109
|
+
return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
|
4110
|
+
};
|
|
4111
|
+
|
|
4112
|
+
function arrow(_ref) {
|
|
4113
|
+
var _state$modifiersData$;
|
|
4114
|
+
|
|
4115
|
+
var state = _ref.state,
|
|
4116
|
+
name = _ref.name,
|
|
4117
|
+
options = _ref.options;
|
|
4118
|
+
var arrowElement = state.elements.arrow;
|
|
4119
|
+
var popperOffsets = state.modifiersData.popperOffsets;
|
|
4120
|
+
var basePlacement = getBasePlacement(state.placement);
|
|
4121
|
+
var axis = getMainAxisFromPlacement(basePlacement);
|
|
4122
|
+
var isVertical = [left, right].indexOf(basePlacement) >= 0;
|
|
4123
|
+
var len = isVertical ? 'height' : 'width';
|
|
4124
|
+
|
|
4125
|
+
if (!arrowElement || !popperOffsets) {
|
|
4126
|
+
return;
|
|
4127
|
+
}
|
|
4128
|
+
|
|
4129
|
+
var paddingObject = toPaddingObject(options.padding, state);
|
|
4130
|
+
var arrowRect = getLayoutRect(arrowElement);
|
|
4131
|
+
var minProp = axis === 'y' ? top : left;
|
|
4132
|
+
var maxProp = axis === 'y' ? bottom : right;
|
|
4133
|
+
var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len];
|
|
4134
|
+
var startDiff = popperOffsets[axis] - state.rects.reference[axis];
|
|
4135
|
+
var arrowOffsetParent = getOffsetParent(arrowElement);
|
|
4136
|
+
var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|
4137
|
+
var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is
|
|
4138
|
+
// outside of the popper bounds
|
|
4139
|
+
|
|
4140
|
+
var min = paddingObject[minProp];
|
|
4141
|
+
var max = clientSize - arrowRect[len] - paddingObject[maxProp];
|
|
4142
|
+
var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference;
|
|
4143
|
+
var offset = within(min, center, max); // Prevents breaking syntax highlighting...
|
|
4144
|
+
|
|
4145
|
+
var axisProp = axis;
|
|
4146
|
+
state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$);
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
function effect$1(_ref2) {
|
|
4150
|
+
var state = _ref2.state,
|
|
4151
|
+
options = _ref2.options;
|
|
4152
|
+
var _options$element = options.element,
|
|
4153
|
+
arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
|
|
4154
|
+
|
|
4155
|
+
if (arrowElement == null) {
|
|
4156
|
+
return;
|
|
4157
|
+
} // CSS selector
|
|
4158
|
+
|
|
4159
|
+
|
|
4160
|
+
if (typeof arrowElement === 'string') {
|
|
4161
|
+
arrowElement = state.elements.popper.querySelector(arrowElement);
|
|
4162
|
+
|
|
4163
|
+
if (!arrowElement) {
|
|
4164
|
+
return;
|
|
4165
|
+
}
|
|
4166
|
+
}
|
|
4167
|
+
|
|
4168
|
+
if (!contains(state.elements.popper, arrowElement)) {
|
|
4169
|
+
|
|
4170
|
+
return;
|
|
4171
|
+
}
|
|
4172
|
+
|
|
4173
|
+
state.elements.arrow = arrowElement;
|
|
4174
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
4175
|
+
|
|
4176
|
+
|
|
4177
|
+
const arrow$1 = {
|
|
4178
|
+
name: 'arrow',
|
|
4179
|
+
enabled: true,
|
|
4180
|
+
phase: 'main',
|
|
4181
|
+
fn: arrow,
|
|
4182
|
+
effect: effect$1,
|
|
4183
|
+
requires: ['popperOffsets'],
|
|
4184
|
+
requiresIfExists: ['preventOverflow']
|
|
4185
|
+
};
|
|
4186
|
+
|
|
4187
|
+
function getVariation(placement) {
|
|
4188
|
+
return placement.split('-')[1];
|
|
4189
|
+
}
|
|
4190
|
+
|
|
4191
|
+
var unsetSides = {
|
|
4192
|
+
top: 'auto',
|
|
4193
|
+
right: 'auto',
|
|
4194
|
+
bottom: 'auto',
|
|
4195
|
+
left: 'auto'
|
|
4196
|
+
}; // Round the offsets to the nearest suitable subpixel based on the DPR.
|
|
4197
|
+
// Zooming can change the DPR, but it seems to report a value that will
|
|
4198
|
+
// cleanly divide the values into the appropriate subpixels.
|
|
4199
|
+
|
|
4200
|
+
function roundOffsetsByDPR(_ref) {
|
|
4201
|
+
var x = _ref.x,
|
|
4202
|
+
y = _ref.y;
|
|
4203
|
+
var win = window;
|
|
4204
|
+
var dpr = win.devicePixelRatio || 1;
|
|
4205
|
+
return {
|
|
4206
|
+
x: round(x * dpr) / dpr || 0,
|
|
4207
|
+
y: round(y * dpr) / dpr || 0
|
|
4208
|
+
};
|
|
4209
|
+
}
|
|
4210
|
+
|
|
4211
|
+
function mapToStyles(_ref2) {
|
|
4212
|
+
var _Object$assign2;
|
|
4213
|
+
|
|
4214
|
+
var popper = _ref2.popper,
|
|
4215
|
+
popperRect = _ref2.popperRect,
|
|
4216
|
+
placement = _ref2.placement,
|
|
4217
|
+
variation = _ref2.variation,
|
|
4218
|
+
offsets = _ref2.offsets,
|
|
4219
|
+
position = _ref2.position,
|
|
4220
|
+
gpuAcceleration = _ref2.gpuAcceleration,
|
|
4221
|
+
adaptive = _ref2.adaptive,
|
|
4222
|
+
roundOffsets = _ref2.roundOffsets,
|
|
4223
|
+
isFixed = _ref2.isFixed;
|
|
4224
|
+
var _offsets$x = offsets.x,
|
|
4225
|
+
x = _offsets$x === void 0 ? 0 : _offsets$x,
|
|
4226
|
+
_offsets$y = offsets.y,
|
|
4227
|
+
y = _offsets$y === void 0 ? 0 : _offsets$y;
|
|
4228
|
+
|
|
4229
|
+
var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
|
|
4230
|
+
x: x,
|
|
4231
|
+
y: y
|
|
4232
|
+
}) : {
|
|
4233
|
+
x: x,
|
|
4234
|
+
y: y
|
|
4235
|
+
};
|
|
4236
|
+
|
|
4237
|
+
x = _ref3.x;
|
|
4238
|
+
y = _ref3.y;
|
|
4239
|
+
var hasX = offsets.hasOwnProperty('x');
|
|
4240
|
+
var hasY = offsets.hasOwnProperty('y');
|
|
4241
|
+
var sideX = left;
|
|
4242
|
+
var sideY = top;
|
|
4243
|
+
var win = window;
|
|
4244
|
+
|
|
4245
|
+
if (adaptive) {
|
|
4246
|
+
var offsetParent = getOffsetParent(popper);
|
|
4247
|
+
var heightProp = 'clientHeight';
|
|
4248
|
+
var widthProp = 'clientWidth';
|
|
4249
|
+
|
|
4250
|
+
if (offsetParent === getWindow(popper)) {
|
|
4251
|
+
offsetParent = getDocumentElement(popper);
|
|
4252
|
+
|
|
4253
|
+
if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
|
|
4254
|
+
heightProp = 'scrollHeight';
|
|
4255
|
+
widthProp = 'scrollWidth';
|
|
4256
|
+
}
|
|
4257
|
+
} // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
|
|
4258
|
+
|
|
4259
|
+
|
|
4260
|
+
offsetParent = offsetParent;
|
|
4261
|
+
|
|
4262
|
+
if (placement === top || (placement === left || placement === right) && variation === end) {
|
|
4263
|
+
sideY = bottom;
|
|
4264
|
+
var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
|
|
4265
|
+
offsetParent[heightProp];
|
|
4266
|
+
y -= offsetY - popperRect.height;
|
|
4267
|
+
y *= gpuAcceleration ? 1 : -1;
|
|
4268
|
+
}
|
|
4269
|
+
|
|
4270
|
+
if (placement === left || (placement === top || placement === bottom) && variation === end) {
|
|
4271
|
+
sideX = right;
|
|
4272
|
+
var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
|
|
4273
|
+
offsetParent[widthProp];
|
|
4274
|
+
x -= offsetX - popperRect.width;
|
|
4275
|
+
x *= gpuAcceleration ? 1 : -1;
|
|
4276
|
+
}
|
|
4277
|
+
}
|
|
4278
|
+
|
|
4279
|
+
var commonStyles = Object.assign({
|
|
4280
|
+
position: position
|
|
4281
|
+
}, adaptive && unsetSides);
|
|
4282
|
+
|
|
4283
|
+
var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
|
|
4284
|
+
x: x,
|
|
4285
|
+
y: y
|
|
4286
|
+
}) : {
|
|
4287
|
+
x: x,
|
|
4288
|
+
y: y
|
|
4289
|
+
};
|
|
4290
|
+
|
|
4291
|
+
x = _ref4.x;
|
|
4292
|
+
y = _ref4.y;
|
|
4293
|
+
|
|
4294
|
+
if (gpuAcceleration) {
|
|
4295
|
+
var _Object$assign;
|
|
4296
|
+
|
|
4297
|
+
return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
|
|
4298
|
+
}
|
|
4299
|
+
|
|
4300
|
+
return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
|
|
4301
|
+
}
|
|
4302
|
+
|
|
4303
|
+
function computeStyles(_ref5) {
|
|
4304
|
+
var state = _ref5.state,
|
|
4305
|
+
options = _ref5.options;
|
|
4306
|
+
var _options$gpuAccelerat = options.gpuAcceleration,
|
|
4307
|
+
gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
|
|
4308
|
+
_options$adaptive = options.adaptive,
|
|
4309
|
+
adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
|
|
4310
|
+
_options$roundOffsets = options.roundOffsets,
|
|
4311
|
+
roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
|
|
4312
|
+
|
|
4313
|
+
var commonStyles = {
|
|
4314
|
+
placement: getBasePlacement(state.placement),
|
|
4315
|
+
variation: getVariation(state.placement),
|
|
4316
|
+
popper: state.elements.popper,
|
|
4317
|
+
popperRect: state.rects.popper,
|
|
4318
|
+
gpuAcceleration: gpuAcceleration,
|
|
4319
|
+
isFixed: state.options.strategy === 'fixed'
|
|
4320
|
+
};
|
|
4321
|
+
|
|
4322
|
+
if (state.modifiersData.popperOffsets != null) {
|
|
4323
|
+
state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
|
|
4324
|
+
offsets: state.modifiersData.popperOffsets,
|
|
4325
|
+
position: state.options.strategy,
|
|
4326
|
+
adaptive: adaptive,
|
|
4327
|
+
roundOffsets: roundOffsets
|
|
4328
|
+
})));
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4331
|
+
if (state.modifiersData.arrow != null) {
|
|
4332
|
+
state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
|
|
4333
|
+
offsets: state.modifiersData.arrow,
|
|
4334
|
+
position: 'absolute',
|
|
4335
|
+
adaptive: false,
|
|
4336
|
+
roundOffsets: roundOffsets
|
|
4337
|
+
})));
|
|
4338
|
+
}
|
|
4339
|
+
|
|
4340
|
+
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
|
4341
|
+
'data-popper-placement': state.placement
|
|
4342
|
+
});
|
|
4343
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
4344
|
+
|
|
4345
|
+
|
|
4346
|
+
const computeStyles$1 = {
|
|
4347
|
+
name: 'computeStyles',
|
|
4348
|
+
enabled: true,
|
|
4349
|
+
phase: 'beforeWrite',
|
|
4350
|
+
fn: computeStyles,
|
|
4351
|
+
data: {}
|
|
4352
|
+
};
|
|
4353
|
+
|
|
4354
|
+
var passive = {
|
|
4355
|
+
passive: true
|
|
4356
|
+
};
|
|
4357
|
+
|
|
4358
|
+
function effect(_ref) {
|
|
4359
|
+
var state = _ref.state,
|
|
4360
|
+
instance = _ref.instance,
|
|
4361
|
+
options = _ref.options;
|
|
4362
|
+
var _options$scroll = options.scroll,
|
|
4363
|
+
scroll = _options$scroll === void 0 ? true : _options$scroll,
|
|
4364
|
+
_options$resize = options.resize,
|
|
4365
|
+
resize = _options$resize === void 0 ? true : _options$resize;
|
|
4366
|
+
var window = getWindow(state.elements.popper);
|
|
4367
|
+
var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
|
|
4368
|
+
|
|
4369
|
+
if (scroll) {
|
|
4370
|
+
scrollParents.forEach(function (scrollParent) {
|
|
4371
|
+
scrollParent.addEventListener('scroll', instance.update, passive);
|
|
4372
|
+
});
|
|
4373
|
+
}
|
|
4374
|
+
|
|
4375
|
+
if (resize) {
|
|
4376
|
+
window.addEventListener('resize', instance.update, passive);
|
|
4377
|
+
}
|
|
4378
|
+
|
|
4379
|
+
return function () {
|
|
4380
|
+
if (scroll) {
|
|
4381
|
+
scrollParents.forEach(function (scrollParent) {
|
|
4382
|
+
scrollParent.removeEventListener('scroll', instance.update, passive);
|
|
4383
|
+
});
|
|
4384
|
+
}
|
|
4385
|
+
|
|
4386
|
+
if (resize) {
|
|
4387
|
+
window.removeEventListener('resize', instance.update, passive);
|
|
4388
|
+
}
|
|
4389
|
+
};
|
|
4390
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
4391
|
+
|
|
4392
|
+
|
|
4393
|
+
const eventListeners = {
|
|
4394
|
+
name: 'eventListeners',
|
|
4395
|
+
enabled: true,
|
|
4396
|
+
phase: 'write',
|
|
4397
|
+
fn: function fn() {},
|
|
4398
|
+
effect: effect,
|
|
4399
|
+
data: {}
|
|
4400
|
+
};
|
|
4401
|
+
|
|
4402
|
+
var hash$1 = {
|
|
4403
|
+
left: 'right',
|
|
4404
|
+
right: 'left',
|
|
4405
|
+
bottom: 'top',
|
|
4406
|
+
top: 'bottom'
|
|
4407
|
+
};
|
|
4408
|
+
function getOppositePlacement(placement) {
|
|
4409
|
+
return placement.replace(/left|right|bottom|top/g, function (matched) {
|
|
4410
|
+
return hash$1[matched];
|
|
4411
|
+
});
|
|
4412
|
+
}
|
|
4413
|
+
|
|
4414
|
+
var hash = {
|
|
4415
|
+
start: 'end',
|
|
4416
|
+
end: 'start'
|
|
4417
|
+
};
|
|
4418
|
+
function getOppositeVariationPlacement(placement) {
|
|
4419
|
+
return placement.replace(/start|end/g, function (matched) {
|
|
4420
|
+
return hash[matched];
|
|
4421
|
+
});
|
|
4422
|
+
}
|
|
4423
|
+
|
|
4424
|
+
function getWindowScroll(node) {
|
|
4425
|
+
var win = getWindow(node);
|
|
4426
|
+
var scrollLeft = win.pageXOffset;
|
|
4427
|
+
var scrollTop = win.pageYOffset;
|
|
4428
|
+
return {
|
|
4429
|
+
scrollLeft: scrollLeft,
|
|
4430
|
+
scrollTop: scrollTop
|
|
4431
|
+
};
|
|
4432
|
+
}
|
|
4433
|
+
|
|
4434
|
+
function getWindowScrollBarX(element) {
|
|
4435
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
4436
|
+
// incorrect for RTL.
|
|
4437
|
+
// Popper 1 is broken in this case and never had a bug report so let's assume
|
|
4438
|
+
// it's not an issue. I don't think anyone ever specifies width on <html>
|
|
4439
|
+
// anyway.
|
|
4440
|
+
// Browsers where the left scrollbar doesn't cause an issue report `0` for
|
|
4441
|
+
// this (e.g. Edge 2019, IE11, Safari)
|
|
4442
|
+
return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
|
|
4443
|
+
}
|
|
4444
|
+
|
|
4445
|
+
function getViewportRect(element, strategy) {
|
|
4446
|
+
var win = getWindow(element);
|
|
4447
|
+
var html = getDocumentElement(element);
|
|
4448
|
+
var visualViewport = win.visualViewport;
|
|
4449
|
+
var width = html.clientWidth;
|
|
4450
|
+
var height = html.clientHeight;
|
|
4451
|
+
var x = 0;
|
|
4452
|
+
var y = 0;
|
|
4453
|
+
|
|
4454
|
+
if (visualViewport) {
|
|
4455
|
+
width = visualViewport.width;
|
|
4456
|
+
height = visualViewport.height;
|
|
4457
|
+
var layoutViewport = isLayoutViewport();
|
|
4458
|
+
|
|
4459
|
+
if (layoutViewport || !layoutViewport && strategy === 'fixed') {
|
|
4460
|
+
x = visualViewport.offsetLeft;
|
|
4461
|
+
y = visualViewport.offsetTop;
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
|
|
4465
|
+
return {
|
|
4466
|
+
width: width,
|
|
4467
|
+
height: height,
|
|
4468
|
+
x: x + getWindowScrollBarX(element),
|
|
4469
|
+
y: y
|
|
4470
|
+
};
|
|
4471
|
+
}
|
|
4472
|
+
|
|
4473
|
+
// of the `<html>` and `<body>` rect bounds if horizontally scrollable
|
|
4474
|
+
|
|
4475
|
+
function getDocumentRect(element) {
|
|
4476
|
+
var _element$ownerDocumen;
|
|
4477
|
+
|
|
4478
|
+
var html = getDocumentElement(element);
|
|
4479
|
+
var winScroll = getWindowScroll(element);
|
|
4480
|
+
var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|
4481
|
+
var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
4482
|
+
var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
4483
|
+
var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
|
|
4484
|
+
var y = -winScroll.scrollTop;
|
|
4485
|
+
|
|
4486
|
+
if (getComputedStyle(body || html).direction === 'rtl') {
|
|
4487
|
+
x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
4488
|
+
}
|
|
4489
|
+
|
|
4490
|
+
return {
|
|
4491
|
+
width: width,
|
|
4492
|
+
height: height,
|
|
4493
|
+
x: x,
|
|
4494
|
+
y: y
|
|
4495
|
+
};
|
|
4496
|
+
}
|
|
4497
|
+
|
|
4498
|
+
function isScrollParent(element) {
|
|
4499
|
+
// Firefox wants us to check `-x` and `-y` variations as well
|
|
4500
|
+
var _getComputedStyle = getComputedStyle(element),
|
|
4501
|
+
overflow = _getComputedStyle.overflow,
|
|
4502
|
+
overflowX = _getComputedStyle.overflowX,
|
|
4503
|
+
overflowY = _getComputedStyle.overflowY;
|
|
4504
|
+
|
|
4505
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
4506
|
+
}
|
|
4507
|
+
|
|
4508
|
+
function getScrollParent(node) {
|
|
4509
|
+
if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
|
|
4510
|
+
// $FlowFixMe[incompatible-return]: assume body is always available
|
|
4511
|
+
return node.ownerDocument.body;
|
|
4512
|
+
}
|
|
4513
|
+
|
|
4514
|
+
if (isHTMLElement(node) && isScrollParent(node)) {
|
|
4515
|
+
return node;
|
|
4516
|
+
}
|
|
4517
|
+
|
|
4518
|
+
return getScrollParent(getParentNode(node));
|
|
4519
|
+
}
|
|
4520
|
+
|
|
4521
|
+
/*
|
|
4522
|
+
given a DOM element, return the list of all scroll parents, up the list of ancesors
|
|
4523
|
+
until we get to the top window object. This list is what we attach scroll listeners
|
|
4524
|
+
to, because if any of these parent elements scroll, we'll need to re-calculate the
|
|
4525
|
+
reference element's position.
|
|
4526
|
+
*/
|
|
4527
|
+
|
|
4528
|
+
function listScrollParents(element, list) {
|
|
4529
|
+
var _element$ownerDocumen;
|
|
4530
|
+
|
|
4531
|
+
if (list === void 0) {
|
|
4532
|
+
list = [];
|
|
4533
|
+
}
|
|
4534
|
+
|
|
4535
|
+
var scrollParent = getScrollParent(element);
|
|
4536
|
+
var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
|
|
4537
|
+
var win = getWindow(scrollParent);
|
|
4538
|
+
var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
|
|
4539
|
+
var updatedList = list.concat(target);
|
|
4540
|
+
return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
|
|
4541
|
+
updatedList.concat(listScrollParents(getParentNode(target)));
|
|
4542
|
+
}
|
|
4543
|
+
|
|
4544
|
+
function rectToClientRect(rect) {
|
|
4545
|
+
return Object.assign({}, rect, {
|
|
4546
|
+
left: rect.x,
|
|
4547
|
+
top: rect.y,
|
|
4548
|
+
right: rect.x + rect.width,
|
|
4549
|
+
bottom: rect.y + rect.height
|
|
4550
|
+
});
|
|
4551
|
+
}
|
|
4552
|
+
|
|
4553
|
+
function getInnerBoundingClientRect(element, strategy) {
|
|
4554
|
+
var rect = getBoundingClientRect(element, false, strategy === 'fixed');
|
|
4555
|
+
rect.top = rect.top + element.clientTop;
|
|
4556
|
+
rect.left = rect.left + element.clientLeft;
|
|
4557
|
+
rect.bottom = rect.top + element.clientHeight;
|
|
4558
|
+
rect.right = rect.left + element.clientWidth;
|
|
4559
|
+
rect.width = element.clientWidth;
|
|
4560
|
+
rect.height = element.clientHeight;
|
|
4561
|
+
rect.x = rect.left;
|
|
4562
|
+
rect.y = rect.top;
|
|
4563
|
+
return rect;
|
|
4564
|
+
}
|
|
4565
|
+
|
|
4566
|
+
function getClientRectFromMixedType(element, clippingParent, strategy) {
|
|
4567
|
+
return clippingParent === viewport ? rectToClientRect(getViewportRect(element, strategy)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent, strategy) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
4568
|
+
} // A "clipping parent" is an overflowable container with the characteristic of
|
|
4569
|
+
// clipping (or hiding) overflowing elements with a position different from
|
|
4570
|
+
// `initial`
|
|
4571
|
+
|
|
4572
|
+
|
|
4573
|
+
function getClippingParents(element) {
|
|
4574
|
+
var clippingParents = listScrollParents(getParentNode(element));
|
|
4575
|
+
var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
|
|
4576
|
+
var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
|
|
4577
|
+
|
|
4578
|
+
if (!isElement(clipperElement)) {
|
|
4579
|
+
return [];
|
|
4580
|
+
} // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
|
|
4581
|
+
|
|
4582
|
+
|
|
4583
|
+
return clippingParents.filter(function (clippingParent) {
|
|
4584
|
+
return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
|
|
4585
|
+
});
|
|
4586
|
+
} // Gets the maximum area that the element is visible in due to any number of
|
|
4587
|
+
// clipping parents
|
|
4588
|
+
|
|
4589
|
+
|
|
4590
|
+
function getClippingRect(element, boundary, rootBoundary, strategy) {
|
|
4591
|
+
var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
|
|
4592
|
+
var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
|
|
4593
|
+
var firstClippingParent = clippingParents[0];
|
|
4594
|
+
var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
|
|
4595
|
+
var rect = getClientRectFromMixedType(element, clippingParent, strategy);
|
|
4596
|
+
accRect.top = max(rect.top, accRect.top);
|
|
4597
|
+
accRect.right = min(rect.right, accRect.right);
|
|
4598
|
+
accRect.bottom = min(rect.bottom, accRect.bottom);
|
|
4599
|
+
accRect.left = max(rect.left, accRect.left);
|
|
4600
|
+
return accRect;
|
|
4601
|
+
}, getClientRectFromMixedType(element, firstClippingParent, strategy));
|
|
4602
|
+
clippingRect.width = clippingRect.right - clippingRect.left;
|
|
4603
|
+
clippingRect.height = clippingRect.bottom - clippingRect.top;
|
|
4604
|
+
clippingRect.x = clippingRect.left;
|
|
4605
|
+
clippingRect.y = clippingRect.top;
|
|
4606
|
+
return clippingRect;
|
|
4607
|
+
}
|
|
4608
|
+
|
|
4609
|
+
function computeOffsets(_ref) {
|
|
4610
|
+
var reference = _ref.reference,
|
|
4611
|
+
element = _ref.element,
|
|
4612
|
+
placement = _ref.placement;
|
|
4613
|
+
var basePlacement = placement ? getBasePlacement(placement) : null;
|
|
4614
|
+
var variation = placement ? getVariation(placement) : null;
|
|
4615
|
+
var commonX = reference.x + reference.width / 2 - element.width / 2;
|
|
4616
|
+
var commonY = reference.y + reference.height / 2 - element.height / 2;
|
|
4617
|
+
var offsets;
|
|
4618
|
+
|
|
4619
|
+
switch (basePlacement) {
|
|
4620
|
+
case top:
|
|
4621
|
+
offsets = {
|
|
4622
|
+
x: commonX,
|
|
4623
|
+
y: reference.y - element.height
|
|
4624
|
+
};
|
|
4625
|
+
break;
|
|
4626
|
+
|
|
4627
|
+
case bottom:
|
|
4628
|
+
offsets = {
|
|
4629
|
+
x: commonX,
|
|
4630
|
+
y: reference.y + reference.height
|
|
4631
|
+
};
|
|
4632
|
+
break;
|
|
4633
|
+
|
|
4634
|
+
case right:
|
|
4635
|
+
offsets = {
|
|
4636
|
+
x: reference.x + reference.width,
|
|
4637
|
+
y: commonY
|
|
4638
|
+
};
|
|
4639
|
+
break;
|
|
4640
|
+
|
|
4641
|
+
case left:
|
|
4642
|
+
offsets = {
|
|
4643
|
+
x: reference.x - element.width,
|
|
4644
|
+
y: commonY
|
|
4645
|
+
};
|
|
4646
|
+
break;
|
|
4647
|
+
|
|
4648
|
+
default:
|
|
4649
|
+
offsets = {
|
|
4650
|
+
x: reference.x,
|
|
4651
|
+
y: reference.y
|
|
4652
|
+
};
|
|
4653
|
+
}
|
|
4654
|
+
|
|
4655
|
+
var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
|
|
4656
|
+
|
|
4657
|
+
if (mainAxis != null) {
|
|
4658
|
+
var len = mainAxis === 'y' ? 'height' : 'width';
|
|
4659
|
+
|
|
4660
|
+
switch (variation) {
|
|
4661
|
+
case start:
|
|
4662
|
+
offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
|
|
4663
|
+
break;
|
|
4664
|
+
|
|
4665
|
+
case end:
|
|
4666
|
+
offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
|
|
4667
|
+
break;
|
|
4668
|
+
}
|
|
4669
|
+
}
|
|
4670
|
+
|
|
4671
|
+
return offsets;
|
|
4672
|
+
}
|
|
4673
|
+
|
|
4674
|
+
function detectOverflow(state, options) {
|
|
4675
|
+
if (options === void 0) {
|
|
4676
|
+
options = {};
|
|
4677
|
+
}
|
|
4678
|
+
|
|
4679
|
+
var _options = options,
|
|
4680
|
+
_options$placement = _options.placement,
|
|
4681
|
+
placement = _options$placement === void 0 ? state.placement : _options$placement,
|
|
4682
|
+
_options$strategy = _options.strategy,
|
|
4683
|
+
strategy = _options$strategy === void 0 ? state.strategy : _options$strategy,
|
|
4684
|
+
_options$boundary = _options.boundary,
|
|
4685
|
+
boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
|
|
4686
|
+
_options$rootBoundary = _options.rootBoundary,
|
|
4687
|
+
rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
|
|
4688
|
+
_options$elementConte = _options.elementContext,
|
|
4689
|
+
elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
|
|
4690
|
+
_options$altBoundary = _options.altBoundary,
|
|
4691
|
+
altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
|
|
4692
|
+
_options$padding = _options.padding,
|
|
4693
|
+
padding = _options$padding === void 0 ? 0 : _options$padding;
|
|
4694
|
+
var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
|
|
4695
|
+
var altContext = elementContext === popper ? reference : popper;
|
|
4696
|
+
var popperRect = state.rects.popper;
|
|
4697
|
+
var element = state.elements[altBoundary ? altContext : elementContext];
|
|
4698
|
+
var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary, strategy);
|
|
4699
|
+
var referenceClientRect = getBoundingClientRect(state.elements.reference);
|
|
4700
|
+
var popperOffsets = computeOffsets({
|
|
4701
|
+
reference: referenceClientRect,
|
|
4702
|
+
element: popperRect,
|
|
4703
|
+
strategy: 'absolute',
|
|
4704
|
+
placement: placement
|
|
4705
|
+
});
|
|
4706
|
+
var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
|
|
4707
|
+
var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
|
|
4708
|
+
// 0 or negative = within the clipping rect
|
|
4709
|
+
|
|
4710
|
+
var overflowOffsets = {
|
|
4711
|
+
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
4712
|
+
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
4713
|
+
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
4714
|
+
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
4715
|
+
};
|
|
4716
|
+
var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
|
|
4717
|
+
|
|
4718
|
+
if (elementContext === popper && offsetData) {
|
|
4719
|
+
var offset = offsetData[placement];
|
|
4720
|
+
Object.keys(overflowOffsets).forEach(function (key) {
|
|
4721
|
+
var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
|
|
4722
|
+
var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
|
|
4723
|
+
overflowOffsets[key] += offset[axis] * multiply;
|
|
4724
|
+
});
|
|
4725
|
+
}
|
|
4726
|
+
|
|
4727
|
+
return overflowOffsets;
|
|
4728
|
+
}
|
|
4729
|
+
|
|
4730
|
+
function computeAutoPlacement(state, options) {
|
|
4731
|
+
if (options === void 0) {
|
|
4732
|
+
options = {};
|
|
4733
|
+
}
|
|
4734
|
+
|
|
4735
|
+
var _options = options,
|
|
4736
|
+
placement = _options.placement,
|
|
4737
|
+
boundary = _options.boundary,
|
|
4738
|
+
rootBoundary = _options.rootBoundary,
|
|
4739
|
+
padding = _options.padding,
|
|
4740
|
+
flipVariations = _options.flipVariations,
|
|
4741
|
+
_options$allowedAutoP = _options.allowedAutoPlacements,
|
|
4742
|
+
allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP;
|
|
4743
|
+
var variation = getVariation(placement);
|
|
4744
|
+
var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
|
|
4745
|
+
return getVariation(placement) === variation;
|
|
4746
|
+
}) : basePlacements;
|
|
4747
|
+
var allowedPlacements = placements$1.filter(function (placement) {
|
|
4748
|
+
return allowedAutoPlacements.indexOf(placement) >= 0;
|
|
4749
|
+
});
|
|
4750
|
+
|
|
4751
|
+
if (allowedPlacements.length === 0) {
|
|
4752
|
+
allowedPlacements = placements$1;
|
|
4753
|
+
} // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
|
|
4754
|
+
|
|
4755
|
+
|
|
4756
|
+
var overflows = allowedPlacements.reduce(function (acc, placement) {
|
|
4757
|
+
acc[placement] = detectOverflow(state, {
|
|
4758
|
+
placement: placement,
|
|
4759
|
+
boundary: boundary,
|
|
4760
|
+
rootBoundary: rootBoundary,
|
|
4761
|
+
padding: padding
|
|
4762
|
+
})[getBasePlacement(placement)];
|
|
4763
|
+
return acc;
|
|
4764
|
+
}, {});
|
|
4765
|
+
return Object.keys(overflows).sort(function (a, b) {
|
|
4766
|
+
return overflows[a] - overflows[b];
|
|
4767
|
+
});
|
|
4768
|
+
}
|
|
4769
|
+
|
|
4770
|
+
function getExpandedFallbackPlacements(placement) {
|
|
4771
|
+
if (getBasePlacement(placement) === auto) {
|
|
4772
|
+
return [];
|
|
4773
|
+
}
|
|
4774
|
+
|
|
4775
|
+
var oppositePlacement = getOppositePlacement(placement);
|
|
4776
|
+
return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)];
|
|
4777
|
+
}
|
|
4778
|
+
|
|
4779
|
+
function flip(_ref) {
|
|
4780
|
+
var state = _ref.state,
|
|
4781
|
+
options = _ref.options,
|
|
4782
|
+
name = _ref.name;
|
|
4783
|
+
|
|
4784
|
+
if (state.modifiersData[name]._skip) {
|
|
4785
|
+
return;
|
|
4786
|
+
}
|
|
4787
|
+
|
|
4788
|
+
var _options$mainAxis = options.mainAxis,
|
|
4789
|
+
checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
|
4790
|
+
_options$altAxis = options.altAxis,
|
|
4791
|
+
checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis,
|
|
4792
|
+
specifiedFallbackPlacements = options.fallbackPlacements,
|
|
4793
|
+
padding = options.padding,
|
|
4794
|
+
boundary = options.boundary,
|
|
4795
|
+
rootBoundary = options.rootBoundary,
|
|
4796
|
+
altBoundary = options.altBoundary,
|
|
4797
|
+
_options$flipVariatio = options.flipVariations,
|
|
4798
|
+
flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio,
|
|
4799
|
+
allowedAutoPlacements = options.allowedAutoPlacements;
|
|
4800
|
+
var preferredPlacement = state.options.placement;
|
|
4801
|
+
var basePlacement = getBasePlacement(preferredPlacement);
|
|
4802
|
+
var isBasePlacement = basePlacement === preferredPlacement;
|
|
4803
|
+
var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement));
|
|
4804
|
+
var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) {
|
|
4805
|
+
return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, {
|
|
4806
|
+
placement: placement,
|
|
4807
|
+
boundary: boundary,
|
|
4808
|
+
rootBoundary: rootBoundary,
|
|
4809
|
+
padding: padding,
|
|
4810
|
+
flipVariations: flipVariations,
|
|
4811
|
+
allowedAutoPlacements: allowedAutoPlacements
|
|
4812
|
+
}) : placement);
|
|
4813
|
+
}, []);
|
|
4814
|
+
var referenceRect = state.rects.reference;
|
|
4815
|
+
var popperRect = state.rects.popper;
|
|
4816
|
+
var checksMap = new Map();
|
|
4817
|
+
var makeFallbackChecks = true;
|
|
4818
|
+
var firstFittingPlacement = placements[0];
|
|
4819
|
+
|
|
4820
|
+
for (var i = 0; i < placements.length; i++) {
|
|
4821
|
+
var placement = placements[i];
|
|
4822
|
+
|
|
4823
|
+
var _basePlacement = getBasePlacement(placement);
|
|
4824
|
+
|
|
4825
|
+
var isStartVariation = getVariation(placement) === start;
|
|
4826
|
+
var isVertical = [top, bottom].indexOf(_basePlacement) >= 0;
|
|
4827
|
+
var len = isVertical ? 'width' : 'height';
|
|
4828
|
+
var overflow = detectOverflow(state, {
|
|
4829
|
+
placement: placement,
|
|
4830
|
+
boundary: boundary,
|
|
4831
|
+
rootBoundary: rootBoundary,
|
|
4832
|
+
altBoundary: altBoundary,
|
|
4833
|
+
padding: padding
|
|
4834
|
+
});
|
|
4835
|
+
var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top;
|
|
4836
|
+
|
|
4837
|
+
if (referenceRect[len] > popperRect[len]) {
|
|
4838
|
+
mainVariationSide = getOppositePlacement(mainVariationSide);
|
|
4839
|
+
}
|
|
4840
|
+
|
|
4841
|
+
var altVariationSide = getOppositePlacement(mainVariationSide);
|
|
4842
|
+
var checks = [];
|
|
4843
|
+
|
|
4844
|
+
if (checkMainAxis) {
|
|
4845
|
+
checks.push(overflow[_basePlacement] <= 0);
|
|
4846
|
+
}
|
|
4847
|
+
|
|
4848
|
+
if (checkAltAxis) {
|
|
4849
|
+
checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0);
|
|
4850
|
+
}
|
|
4851
|
+
|
|
4852
|
+
if (checks.every(function (check) {
|
|
4853
|
+
return check;
|
|
4854
|
+
})) {
|
|
4855
|
+
firstFittingPlacement = placement;
|
|
4856
|
+
makeFallbackChecks = false;
|
|
4857
|
+
break;
|
|
4858
|
+
}
|
|
4859
|
+
|
|
4860
|
+
checksMap.set(placement, checks);
|
|
4861
|
+
}
|
|
4862
|
+
|
|
4863
|
+
if (makeFallbackChecks) {
|
|
4864
|
+
// `2` may be desired in some cases – research later
|
|
4865
|
+
var numberOfChecks = flipVariations ? 3 : 1;
|
|
4866
|
+
|
|
4867
|
+
var _loop = function _loop(_i) {
|
|
4868
|
+
var fittingPlacement = placements.find(function (placement) {
|
|
4869
|
+
var checks = checksMap.get(placement);
|
|
4870
|
+
|
|
4871
|
+
if (checks) {
|
|
4872
|
+
return checks.slice(0, _i).every(function (check) {
|
|
4873
|
+
return check;
|
|
4874
|
+
});
|
|
4875
|
+
}
|
|
4876
|
+
});
|
|
4877
|
+
|
|
4878
|
+
if (fittingPlacement) {
|
|
4879
|
+
firstFittingPlacement = fittingPlacement;
|
|
4880
|
+
return "break";
|
|
4881
|
+
}
|
|
4882
|
+
};
|
|
4883
|
+
|
|
4884
|
+
for (var _i = numberOfChecks; _i > 0; _i--) {
|
|
4885
|
+
var _ret = _loop(_i);
|
|
4886
|
+
|
|
4887
|
+
if (_ret === "break") break;
|
|
4888
|
+
}
|
|
4889
|
+
}
|
|
4890
|
+
|
|
4891
|
+
if (state.placement !== firstFittingPlacement) {
|
|
4892
|
+
state.modifiersData[name]._skip = true;
|
|
4893
|
+
state.placement = firstFittingPlacement;
|
|
4894
|
+
state.reset = true;
|
|
4895
|
+
}
|
|
4896
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
4897
|
+
|
|
4898
|
+
|
|
4899
|
+
const flip$1 = {
|
|
4900
|
+
name: 'flip',
|
|
4901
|
+
enabled: true,
|
|
4902
|
+
phase: 'main',
|
|
4903
|
+
fn: flip,
|
|
4904
|
+
requiresIfExists: ['offset'],
|
|
4905
|
+
data: {
|
|
4906
|
+
_skip: false
|
|
4907
|
+
}
|
|
4908
|
+
};
|
|
4909
|
+
|
|
4910
|
+
function getSideOffsets(overflow, rect, preventedOffsets) {
|
|
4911
|
+
if (preventedOffsets === void 0) {
|
|
4912
|
+
preventedOffsets = {
|
|
4913
|
+
x: 0,
|
|
4914
|
+
y: 0
|
|
4915
|
+
};
|
|
4916
|
+
}
|
|
4917
|
+
|
|
4918
|
+
return {
|
|
4919
|
+
top: overflow.top - rect.height - preventedOffsets.y,
|
|
4920
|
+
right: overflow.right - rect.width + preventedOffsets.x,
|
|
4921
|
+
bottom: overflow.bottom - rect.height + preventedOffsets.y,
|
|
4922
|
+
left: overflow.left - rect.width - preventedOffsets.x
|
|
4923
|
+
};
|
|
4924
|
+
}
|
|
4925
|
+
|
|
4926
|
+
function isAnySideFullyClipped(overflow) {
|
|
4927
|
+
return [top, right, bottom, left].some(function (side) {
|
|
4928
|
+
return overflow[side] >= 0;
|
|
4929
|
+
});
|
|
4930
|
+
}
|
|
4931
|
+
|
|
4932
|
+
function hide(_ref) {
|
|
4933
|
+
var state = _ref.state,
|
|
4934
|
+
name = _ref.name;
|
|
4935
|
+
var referenceRect = state.rects.reference;
|
|
4936
|
+
var popperRect = state.rects.popper;
|
|
4937
|
+
var preventedOffsets = state.modifiersData.preventOverflow;
|
|
4938
|
+
var referenceOverflow = detectOverflow(state, {
|
|
4939
|
+
elementContext: 'reference'
|
|
4940
|
+
});
|
|
4941
|
+
var popperAltOverflow = detectOverflow(state, {
|
|
4942
|
+
altBoundary: true
|
|
4943
|
+
});
|
|
4944
|
+
var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect);
|
|
4945
|
+
var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets);
|
|
4946
|
+
var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets);
|
|
4947
|
+
var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets);
|
|
4948
|
+
state.modifiersData[name] = {
|
|
4949
|
+
referenceClippingOffsets: referenceClippingOffsets,
|
|
4950
|
+
popperEscapeOffsets: popperEscapeOffsets,
|
|
4951
|
+
isReferenceHidden: isReferenceHidden,
|
|
4952
|
+
hasPopperEscaped: hasPopperEscaped
|
|
4953
|
+
};
|
|
4954
|
+
state.attributes.popper = Object.assign({}, state.attributes.popper, {
|
|
4955
|
+
'data-popper-reference-hidden': isReferenceHidden,
|
|
4956
|
+
'data-popper-escaped': hasPopperEscaped
|
|
4957
|
+
});
|
|
4958
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
4959
|
+
|
|
4960
|
+
|
|
4961
|
+
const hide$1 = {
|
|
4962
|
+
name: 'hide',
|
|
4963
|
+
enabled: true,
|
|
4964
|
+
phase: 'main',
|
|
4965
|
+
requiresIfExists: ['preventOverflow'],
|
|
4966
|
+
fn: hide
|
|
4967
|
+
};
|
|
4968
|
+
|
|
4969
|
+
function distanceAndSkiddingToXY(placement, rects, offset) {
|
|
4970
|
+
var basePlacement = getBasePlacement(placement);
|
|
4971
|
+
var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
|
|
4972
|
+
|
|
4973
|
+
var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
|
|
4974
|
+
placement: placement
|
|
4975
|
+
})) : offset,
|
|
4976
|
+
skidding = _ref[0],
|
|
4977
|
+
distance = _ref[1];
|
|
4978
|
+
|
|
4979
|
+
skidding = skidding || 0;
|
|
4980
|
+
distance = (distance || 0) * invertDistance;
|
|
4981
|
+
return [left, right].indexOf(basePlacement) >= 0 ? {
|
|
4982
|
+
x: distance,
|
|
4983
|
+
y: skidding
|
|
4984
|
+
} : {
|
|
4985
|
+
x: skidding,
|
|
4986
|
+
y: distance
|
|
4987
|
+
};
|
|
4988
|
+
}
|
|
4989
|
+
|
|
4990
|
+
function offset(_ref2) {
|
|
4991
|
+
var state = _ref2.state,
|
|
4992
|
+
options = _ref2.options,
|
|
4993
|
+
name = _ref2.name;
|
|
4994
|
+
var _options$offset = options.offset,
|
|
4995
|
+
offset = _options$offset === void 0 ? [0, 0] : _options$offset;
|
|
4996
|
+
var data = placements.reduce(function (acc, placement) {
|
|
4997
|
+
acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset);
|
|
4998
|
+
return acc;
|
|
4999
|
+
}, {});
|
|
5000
|
+
var _data$state$placement = data[state.placement],
|
|
5001
|
+
x = _data$state$placement.x,
|
|
5002
|
+
y = _data$state$placement.y;
|
|
5003
|
+
|
|
5004
|
+
if (state.modifiersData.popperOffsets != null) {
|
|
5005
|
+
state.modifiersData.popperOffsets.x += x;
|
|
5006
|
+
state.modifiersData.popperOffsets.y += y;
|
|
5007
|
+
}
|
|
5008
|
+
|
|
5009
|
+
state.modifiersData[name] = data;
|
|
5010
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
5011
|
+
|
|
5012
|
+
|
|
5013
|
+
const offset$1 = {
|
|
5014
|
+
name: 'offset',
|
|
5015
|
+
enabled: true,
|
|
5016
|
+
phase: 'main',
|
|
5017
|
+
requires: ['popperOffsets'],
|
|
5018
|
+
fn: offset
|
|
5019
|
+
};
|
|
5020
|
+
|
|
5021
|
+
function popperOffsets(_ref) {
|
|
5022
|
+
var state = _ref.state,
|
|
5023
|
+
name = _ref.name;
|
|
5024
|
+
// Offsets are the actual position the popper needs to have to be
|
|
5025
|
+
// properly positioned near its reference element
|
|
5026
|
+
// This is the most basic placement, and will be adjusted by
|
|
5027
|
+
// the modifiers in the next step
|
|
5028
|
+
state.modifiersData[name] = computeOffsets({
|
|
5029
|
+
reference: state.rects.reference,
|
|
5030
|
+
element: state.rects.popper,
|
|
5031
|
+
strategy: 'absolute',
|
|
5032
|
+
placement: state.placement
|
|
5033
|
+
});
|
|
5034
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
5035
|
+
|
|
5036
|
+
|
|
5037
|
+
const popperOffsets$1 = {
|
|
5038
|
+
name: 'popperOffsets',
|
|
5039
|
+
enabled: true,
|
|
5040
|
+
phase: 'read',
|
|
5041
|
+
fn: popperOffsets,
|
|
5042
|
+
data: {}
|
|
5043
|
+
};
|
|
5044
|
+
|
|
5045
|
+
function getAltAxis(axis) {
|
|
5046
|
+
return axis === 'x' ? 'y' : 'x';
|
|
5047
|
+
}
|
|
5048
|
+
|
|
5049
|
+
function preventOverflow(_ref) {
|
|
5050
|
+
var state = _ref.state,
|
|
5051
|
+
options = _ref.options,
|
|
5052
|
+
name = _ref.name;
|
|
5053
|
+
var _options$mainAxis = options.mainAxis,
|
|
5054
|
+
checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis,
|
|
5055
|
+
_options$altAxis = options.altAxis,
|
|
5056
|
+
checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis,
|
|
5057
|
+
boundary = options.boundary,
|
|
5058
|
+
rootBoundary = options.rootBoundary,
|
|
5059
|
+
altBoundary = options.altBoundary,
|
|
5060
|
+
padding = options.padding,
|
|
5061
|
+
_options$tether = options.tether,
|
|
5062
|
+
tether = _options$tether === void 0 ? true : _options$tether,
|
|
5063
|
+
_options$tetherOffset = options.tetherOffset,
|
|
5064
|
+
tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset;
|
|
5065
|
+
var overflow = detectOverflow(state, {
|
|
5066
|
+
boundary: boundary,
|
|
5067
|
+
rootBoundary: rootBoundary,
|
|
5068
|
+
padding: padding,
|
|
5069
|
+
altBoundary: altBoundary
|
|
5070
|
+
});
|
|
5071
|
+
var basePlacement = getBasePlacement(state.placement);
|
|
5072
|
+
var variation = getVariation(state.placement);
|
|
5073
|
+
var isBasePlacement = !variation;
|
|
5074
|
+
var mainAxis = getMainAxisFromPlacement(basePlacement);
|
|
5075
|
+
var altAxis = getAltAxis(mainAxis);
|
|
5076
|
+
var popperOffsets = state.modifiersData.popperOffsets;
|
|
5077
|
+
var referenceRect = state.rects.reference;
|
|
5078
|
+
var popperRect = state.rects.popper;
|
|
5079
|
+
var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
|
|
5080
|
+
placement: state.placement
|
|
5081
|
+
})) : tetherOffset;
|
|
5082
|
+
var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
|
|
5083
|
+
mainAxis: tetherOffsetValue,
|
|
5084
|
+
altAxis: tetherOffsetValue
|
|
5085
|
+
} : Object.assign({
|
|
5086
|
+
mainAxis: 0,
|
|
5087
|
+
altAxis: 0
|
|
5088
|
+
}, tetherOffsetValue);
|
|
5089
|
+
var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
|
|
5090
|
+
var data = {
|
|
5091
|
+
x: 0,
|
|
5092
|
+
y: 0
|
|
5093
|
+
};
|
|
5094
|
+
|
|
5095
|
+
if (!popperOffsets) {
|
|
5096
|
+
return;
|
|
5097
|
+
}
|
|
5098
|
+
|
|
5099
|
+
if (checkMainAxis) {
|
|
5100
|
+
var _offsetModifierState$;
|
|
5101
|
+
|
|
5102
|
+
var mainSide = mainAxis === 'y' ? top : left;
|
|
5103
|
+
var altSide = mainAxis === 'y' ? bottom : right;
|
|
5104
|
+
var len = mainAxis === 'y' ? 'height' : 'width';
|
|
5105
|
+
var offset = popperOffsets[mainAxis];
|
|
5106
|
+
var min$1 = offset + overflow[mainSide];
|
|
5107
|
+
var max$1 = offset - overflow[altSide];
|
|
5108
|
+
var additive = tether ? -popperRect[len] / 2 : 0;
|
|
5109
|
+
var minLen = variation === start ? referenceRect[len] : popperRect[len];
|
|
5110
|
+
var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
|
|
5111
|
+
// outside the reference bounds
|
|
5112
|
+
|
|
5113
|
+
var arrowElement = state.elements.arrow;
|
|
5114
|
+
var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : {
|
|
5115
|
+
width: 0,
|
|
5116
|
+
height: 0
|
|
5117
|
+
};
|
|
5118
|
+
var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject();
|
|
5119
|
+
var arrowPaddingMin = arrowPaddingObject[mainSide];
|
|
5120
|
+
var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want
|
|
5121
|
+
// to include its full size in the calculation. If the reference is small
|
|
5122
|
+
// and near the edge of a boundary, the popper can overflow even if the
|
|
5123
|
+
// reference is not overflowing as well (e.g. virtual elements with no
|
|
5124
|
+
// width or height)
|
|
5125
|
+
|
|
5126
|
+
var arrowLen = within(0, referenceRect[len], arrowRect[len]);
|
|
5127
|
+
var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
|
|
5128
|
+
var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
|
|
5129
|
+
var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
|
|
5130
|
+
var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
|
|
5131
|
+
var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
|
|
5132
|
+
var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
|
|
5133
|
+
var tetherMax = offset + maxOffset - offsetModifierValue;
|
|
5134
|
+
var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
|
|
5135
|
+
popperOffsets[mainAxis] = preventedOffset;
|
|
5136
|
+
data[mainAxis] = preventedOffset - offset;
|
|
5137
|
+
}
|
|
5138
|
+
|
|
5139
|
+
if (checkAltAxis) {
|
|
5140
|
+
var _offsetModifierState$2;
|
|
5141
|
+
|
|
5142
|
+
var _mainSide = mainAxis === 'x' ? top : left;
|
|
5143
|
+
|
|
5144
|
+
var _altSide = mainAxis === 'x' ? bottom : right;
|
|
5145
|
+
|
|
5146
|
+
var _offset = popperOffsets[altAxis];
|
|
5147
|
+
|
|
5148
|
+
var _len = altAxis === 'y' ? 'height' : 'width';
|
|
5149
|
+
|
|
5150
|
+
var _min = _offset + overflow[_mainSide];
|
|
5151
|
+
|
|
5152
|
+
var _max = _offset - overflow[_altSide];
|
|
5153
|
+
|
|
5154
|
+
var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
|
|
5155
|
+
|
|
5156
|
+
var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
|
|
5157
|
+
|
|
5158
|
+
var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
|
|
5159
|
+
|
|
5160
|
+
var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
|
|
5161
|
+
|
|
5162
|
+
var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
|
|
5163
|
+
|
|
5164
|
+
popperOffsets[altAxis] = _preventedOffset;
|
|
5165
|
+
data[altAxis] = _preventedOffset - _offset;
|
|
5166
|
+
}
|
|
5167
|
+
|
|
5168
|
+
state.modifiersData[name] = data;
|
|
5169
|
+
} // eslint-disable-next-line import/no-unused-modules
|
|
5170
|
+
|
|
5171
|
+
|
|
5172
|
+
const preventOverflow$1 = {
|
|
5173
|
+
name: 'preventOverflow',
|
|
5174
|
+
enabled: true,
|
|
5175
|
+
phase: 'main',
|
|
5176
|
+
fn: preventOverflow,
|
|
5177
|
+
requiresIfExists: ['offset']
|
|
5178
|
+
};
|
|
5179
|
+
|
|
5180
|
+
function getHTMLElementScroll(element) {
|
|
5181
|
+
return {
|
|
5182
|
+
scrollLeft: element.scrollLeft,
|
|
5183
|
+
scrollTop: element.scrollTop
|
|
5184
|
+
};
|
|
5185
|
+
}
|
|
5186
|
+
|
|
5187
|
+
function getNodeScroll(node) {
|
|
5188
|
+
if (node === getWindow(node) || !isHTMLElement(node)) {
|
|
5189
|
+
return getWindowScroll(node);
|
|
5190
|
+
} else {
|
|
5191
|
+
return getHTMLElementScroll(node);
|
|
5192
|
+
}
|
|
5193
|
+
}
|
|
5194
|
+
|
|
5195
|
+
function isElementScaled(element) {
|
|
5196
|
+
var rect = element.getBoundingClientRect();
|
|
5197
|
+
var scaleX = round(rect.width) / element.offsetWidth || 1;
|
|
5198
|
+
var scaleY = round(rect.height) / element.offsetHeight || 1;
|
|
5199
|
+
return scaleX !== 1 || scaleY !== 1;
|
|
5200
|
+
} // Returns the composite rect of an element relative to its offsetParent.
|
|
5201
|
+
// Composite means it takes into account transforms as well as layout.
|
|
5202
|
+
|
|
5203
|
+
|
|
5204
|
+
function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
|
|
5205
|
+
if (isFixed === void 0) {
|
|
5206
|
+
isFixed = false;
|
|
5207
|
+
}
|
|
5208
|
+
|
|
5209
|
+
var isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
5210
|
+
var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
|
|
5211
|
+
var documentElement = getDocumentElement(offsetParent);
|
|
5212
|
+
var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled, isFixed);
|
|
5213
|
+
var scroll = {
|
|
5214
|
+
scrollLeft: 0,
|
|
5215
|
+
scrollTop: 0
|
|
5216
|
+
};
|
|
5217
|
+
var offsets = {
|
|
5218
|
+
x: 0,
|
|
5219
|
+
y: 0
|
|
5220
|
+
};
|
|
5221
|
+
|
|
5222
|
+
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
5223
|
+
if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
|
|
5224
|
+
isScrollParent(documentElement)) {
|
|
5225
|
+
scroll = getNodeScroll(offsetParent);
|
|
5226
|
+
}
|
|
5227
|
+
|
|
5228
|
+
if (isHTMLElement(offsetParent)) {
|
|
5229
|
+
offsets = getBoundingClientRect(offsetParent, true);
|
|
5230
|
+
offsets.x += offsetParent.clientLeft;
|
|
5231
|
+
offsets.y += offsetParent.clientTop;
|
|
5232
|
+
} else if (documentElement) {
|
|
5233
|
+
offsets.x = getWindowScrollBarX(documentElement);
|
|
5234
|
+
}
|
|
5235
|
+
}
|
|
5236
|
+
|
|
5237
|
+
return {
|
|
5238
|
+
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
5239
|
+
y: rect.top + scroll.scrollTop - offsets.y,
|
|
5240
|
+
width: rect.width,
|
|
5241
|
+
height: rect.height
|
|
5242
|
+
};
|
|
5243
|
+
}
|
|
5244
|
+
|
|
5245
|
+
function order(modifiers) {
|
|
5246
|
+
var map = new Map();
|
|
5247
|
+
var visited = new Set();
|
|
5248
|
+
var result = [];
|
|
5249
|
+
modifiers.forEach(function (modifier) {
|
|
5250
|
+
map.set(modifier.name, modifier);
|
|
5251
|
+
}); // On visiting object, check for its dependencies and visit them recursively
|
|
5252
|
+
|
|
5253
|
+
function sort(modifier) {
|
|
5254
|
+
visited.add(modifier.name);
|
|
5255
|
+
var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
|
|
5256
|
+
requires.forEach(function (dep) {
|
|
5257
|
+
if (!visited.has(dep)) {
|
|
5258
|
+
var depModifier = map.get(dep);
|
|
5259
|
+
|
|
5260
|
+
if (depModifier) {
|
|
5261
|
+
sort(depModifier);
|
|
5262
|
+
}
|
|
5263
|
+
}
|
|
5264
|
+
});
|
|
5265
|
+
result.push(modifier);
|
|
5266
|
+
}
|
|
5267
|
+
|
|
5268
|
+
modifiers.forEach(function (modifier) {
|
|
5269
|
+
if (!visited.has(modifier.name)) {
|
|
5270
|
+
// check for visited object
|
|
5271
|
+
sort(modifier);
|
|
5272
|
+
}
|
|
5273
|
+
});
|
|
5274
|
+
return result;
|
|
5275
|
+
}
|
|
5276
|
+
|
|
5277
|
+
function orderModifiers(modifiers) {
|
|
5278
|
+
// order based on dependencies
|
|
5279
|
+
var orderedModifiers = order(modifiers); // order based on phase
|
|
5280
|
+
|
|
5281
|
+
return modifierPhases.reduce(function (acc, phase) {
|
|
5282
|
+
return acc.concat(orderedModifiers.filter(function (modifier) {
|
|
5283
|
+
return modifier.phase === phase;
|
|
5284
|
+
}));
|
|
5285
|
+
}, []);
|
|
5286
|
+
}
|
|
5287
|
+
|
|
5288
|
+
function debounce(fn) {
|
|
5289
|
+
var pending;
|
|
5290
|
+
return function () {
|
|
5291
|
+
if (!pending) {
|
|
5292
|
+
pending = new Promise(function (resolve) {
|
|
5293
|
+
Promise.resolve().then(function () {
|
|
5294
|
+
pending = undefined;
|
|
5295
|
+
resolve(fn());
|
|
5296
|
+
});
|
|
5297
|
+
});
|
|
5298
|
+
}
|
|
5299
|
+
|
|
5300
|
+
return pending;
|
|
5301
|
+
};
|
|
5302
|
+
}
|
|
5303
|
+
|
|
5304
|
+
function mergeByName(modifiers) {
|
|
5305
|
+
var merged = modifiers.reduce(function (merged, current) {
|
|
5306
|
+
var existing = merged[current.name];
|
|
5307
|
+
merged[current.name] = existing ? Object.assign({}, existing, current, {
|
|
5308
|
+
options: Object.assign({}, existing.options, current.options),
|
|
5309
|
+
data: Object.assign({}, existing.data, current.data)
|
|
5310
|
+
}) : current;
|
|
5311
|
+
return merged;
|
|
5312
|
+
}, {}); // IE11 does not support Object.values
|
|
5313
|
+
|
|
5314
|
+
return Object.keys(merged).map(function (key) {
|
|
5315
|
+
return merged[key];
|
|
5316
|
+
});
|
|
5317
|
+
}
|
|
5318
|
+
|
|
5319
|
+
var DEFAULT_OPTIONS = {
|
|
5320
|
+
placement: 'bottom',
|
|
5321
|
+
modifiers: [],
|
|
5322
|
+
strategy: 'absolute'
|
|
5323
|
+
};
|
|
5324
|
+
|
|
5325
|
+
function areValidElements() {
|
|
5326
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
5327
|
+
args[_key] = arguments[_key];
|
|
5328
|
+
}
|
|
5329
|
+
|
|
5330
|
+
return !args.some(function (element) {
|
|
5331
|
+
return !(element && typeof element.getBoundingClientRect === 'function');
|
|
5332
|
+
});
|
|
5333
|
+
}
|
|
5334
|
+
|
|
5335
|
+
function popperGenerator(generatorOptions) {
|
|
5336
|
+
if (generatorOptions === void 0) {
|
|
5337
|
+
generatorOptions = {};
|
|
5338
|
+
}
|
|
5339
|
+
|
|
5340
|
+
var _generatorOptions = generatorOptions,
|
|
5341
|
+
_generatorOptions$def = _generatorOptions.defaultModifiers,
|
|
5342
|
+
defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
|
|
5343
|
+
_generatorOptions$def2 = _generatorOptions.defaultOptions,
|
|
5344
|
+
defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
|
|
5345
|
+
return function createPopper(reference, popper, options) {
|
|
5346
|
+
if (options === void 0) {
|
|
5347
|
+
options = defaultOptions;
|
|
5348
|
+
}
|
|
5349
|
+
|
|
5350
|
+
var state = {
|
|
5351
|
+
placement: 'bottom',
|
|
5352
|
+
orderedModifiers: [],
|
|
5353
|
+
options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
|
|
5354
|
+
modifiersData: {},
|
|
5355
|
+
elements: {
|
|
5356
|
+
reference: reference,
|
|
5357
|
+
popper: popper
|
|
5358
|
+
},
|
|
5359
|
+
attributes: {},
|
|
5360
|
+
styles: {}
|
|
5361
|
+
};
|
|
5362
|
+
var effectCleanupFns = [];
|
|
5363
|
+
var isDestroyed = false;
|
|
5364
|
+
var instance = {
|
|
5365
|
+
state: state,
|
|
5366
|
+
setOptions: function setOptions(setOptionsAction) {
|
|
5367
|
+
var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
|
|
5368
|
+
cleanupModifierEffects();
|
|
5369
|
+
state.options = Object.assign({}, defaultOptions, state.options, options);
|
|
5370
|
+
state.scrollParents = {
|
|
5371
|
+
reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
|
|
5372
|
+
popper: listScrollParents(popper)
|
|
5373
|
+
}; // Orders the modifiers based on their dependencies and `phase`
|
|
5374
|
+
// properties
|
|
5375
|
+
|
|
5376
|
+
var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
|
|
5377
|
+
|
|
5378
|
+
state.orderedModifiers = orderedModifiers.filter(function (m) {
|
|
5379
|
+
return m.enabled;
|
|
5380
|
+
}); // Validate the provided modifiers so that the consumer will get warned
|
|
5381
|
+
|
|
5382
|
+
runModifierEffects();
|
|
5383
|
+
return instance.update();
|
|
5384
|
+
},
|
|
5385
|
+
// Sync update – it will always be executed, even if not necessary. This
|
|
5386
|
+
// is useful for low frequency updates where sync behavior simplifies the
|
|
5387
|
+
// logic.
|
|
5388
|
+
// For high frequency updates (e.g. `resize` and `scroll` events), always
|
|
5389
|
+
// prefer the async Popper#update method
|
|
5390
|
+
forceUpdate: function forceUpdate() {
|
|
5391
|
+
if (isDestroyed) {
|
|
5392
|
+
return;
|
|
5393
|
+
}
|
|
5394
|
+
|
|
5395
|
+
var _state$elements = state.elements,
|
|
5396
|
+
reference = _state$elements.reference,
|
|
5397
|
+
popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
|
|
5398
|
+
// anymore
|
|
5399
|
+
|
|
5400
|
+
if (!areValidElements(reference, popper)) {
|
|
5401
|
+
|
|
5402
|
+
return;
|
|
5403
|
+
} // Store the reference and popper rects to be read by modifiers
|
|
5404
|
+
|
|
5405
|
+
|
|
5406
|
+
state.rects = {
|
|
5407
|
+
reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
|
|
5408
|
+
popper: getLayoutRect(popper)
|
|
5409
|
+
}; // Modifiers have the ability to reset the current update cycle. The
|
|
5410
|
+
// most common use case for this is the `flip` modifier changing the
|
|
5411
|
+
// placement, which then needs to re-run all the modifiers, because the
|
|
5412
|
+
// logic was previously ran for the previous placement and is therefore
|
|
5413
|
+
// stale/incorrect
|
|
5414
|
+
|
|
5415
|
+
state.reset = false;
|
|
5416
|
+
state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
|
|
5417
|
+
// is filled with the initial data specified by the modifier. This means
|
|
5418
|
+
// it doesn't persist and is fresh on each update.
|
|
5419
|
+
// To ensure persistent data, use `${name}#persistent`
|
|
5420
|
+
|
|
5421
|
+
state.orderedModifiers.forEach(function (modifier) {
|
|
5422
|
+
return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
|
|
5423
|
+
});
|
|
5424
|
+
|
|
5425
|
+
for (var index = 0; index < state.orderedModifiers.length; index++) {
|
|
5426
|
+
|
|
5427
|
+
if (state.reset === true) {
|
|
5428
|
+
state.reset = false;
|
|
5429
|
+
index = -1;
|
|
5430
|
+
continue;
|
|
5431
|
+
}
|
|
5432
|
+
|
|
5433
|
+
var _state$orderedModifie = state.orderedModifiers[index],
|
|
5434
|
+
fn = _state$orderedModifie.fn,
|
|
5435
|
+
_state$orderedModifie2 = _state$orderedModifie.options,
|
|
5436
|
+
_options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
|
|
5437
|
+
name = _state$orderedModifie.name;
|
|
5438
|
+
|
|
5439
|
+
if (typeof fn === 'function') {
|
|
5440
|
+
state = fn({
|
|
5441
|
+
state: state,
|
|
5442
|
+
options: _options,
|
|
5443
|
+
name: name,
|
|
5444
|
+
instance: instance
|
|
5445
|
+
}) || state;
|
|
5446
|
+
}
|
|
5447
|
+
}
|
|
5448
|
+
},
|
|
5449
|
+
// Async and optimistically optimized update – it will not be executed if
|
|
5450
|
+
// not necessary (debounced to run at most once-per-tick)
|
|
5451
|
+
update: debounce(function () {
|
|
5452
|
+
return new Promise(function (resolve) {
|
|
5453
|
+
instance.forceUpdate();
|
|
5454
|
+
resolve(state);
|
|
5455
|
+
});
|
|
5456
|
+
}),
|
|
5457
|
+
destroy: function destroy() {
|
|
5458
|
+
cleanupModifierEffects();
|
|
5459
|
+
isDestroyed = true;
|
|
5460
|
+
}
|
|
5461
|
+
};
|
|
5462
|
+
|
|
5463
|
+
if (!areValidElements(reference, popper)) {
|
|
5464
|
+
|
|
5465
|
+
return instance;
|
|
5466
|
+
}
|
|
5467
|
+
|
|
5468
|
+
instance.setOptions(options).then(function (state) {
|
|
5469
|
+
if (!isDestroyed && options.onFirstUpdate) {
|
|
5470
|
+
options.onFirstUpdate(state);
|
|
5471
|
+
}
|
|
5472
|
+
}); // Modifiers have the ability to execute arbitrary code before the first
|
|
5473
|
+
// update cycle runs. They will be executed in the same order as the update
|
|
5474
|
+
// cycle. This is useful when a modifier adds some persistent data that
|
|
5475
|
+
// other modifiers need to use, but the modifier is run after the dependent
|
|
5476
|
+
// one.
|
|
5477
|
+
|
|
5478
|
+
function runModifierEffects() {
|
|
5479
|
+
state.orderedModifiers.forEach(function (_ref3) {
|
|
5480
|
+
var name = _ref3.name,
|
|
5481
|
+
_ref3$options = _ref3.options,
|
|
5482
|
+
options = _ref3$options === void 0 ? {} : _ref3$options,
|
|
5483
|
+
effect = _ref3.effect;
|
|
5484
|
+
|
|
5485
|
+
if (typeof effect === 'function') {
|
|
5486
|
+
var cleanupFn = effect({
|
|
5487
|
+
state: state,
|
|
5488
|
+
name: name,
|
|
5489
|
+
instance: instance,
|
|
5490
|
+
options: options
|
|
5491
|
+
});
|
|
5492
|
+
|
|
5493
|
+
var noopFn = function noopFn() {};
|
|
5494
|
+
|
|
5495
|
+
effectCleanupFns.push(cleanupFn || noopFn);
|
|
5496
|
+
}
|
|
5497
|
+
});
|
|
5498
|
+
}
|
|
5499
|
+
|
|
5500
|
+
function cleanupModifierEffects() {
|
|
5501
|
+
effectCleanupFns.forEach(function (fn) {
|
|
5502
|
+
return fn();
|
|
5503
|
+
});
|
|
5504
|
+
effectCleanupFns = [];
|
|
5505
|
+
}
|
|
5506
|
+
|
|
5507
|
+
return instance;
|
|
5508
|
+
};
|
|
5509
|
+
}
|
|
5510
|
+
|
|
5511
|
+
var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1];
|
|
5512
|
+
var createPopper = /*#__PURE__*/popperGenerator({
|
|
5513
|
+
defaultModifiers: defaultModifiers
|
|
5514
|
+
}); // eslint-disable-next-line import/no-unused-modules
|
|
5515
|
+
|
|
5516
|
+
const mgPopoverCss = "mg-popover{display:contents}mg-popover::slotted(*){display:inline-block}.mg-popover{display:none;padding:1.5rem;z-index:1000;border-radius:0.5rem;background-color:hsl(var(--mg-popover-background-color));box-shadow:var(--box-shadow);color:hsl(var(--mg-popover-font-color))}.mg-popover[data-show]{display:block}.mg-popover mg-button{float:right;margin-right:calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);margin-top:calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);margin-left:3rem}.mg-popover__arrow,.mg-popover__arrow::before{position:absolute;width:2rem;height:2rem;z-index:-1;background:inherit}.mg-popover__arrow{visibility:hidden}.mg-popover__arrow::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-popover[data-popper-placement^=top]>.mg-popover__arrow{bottom:-6px}.mg-popover[data-popper-placement^=bottom]>.mg-popover__arrow{top:-6px}.mg-popover[data-popper-placement^=left]>.mg-popover__arrow{right:-6px}.mg-popover[data-popper-placement^=right]>.mg-popover__arrow{left:-6px}.mg-popover__title ::slotted([slot=title]){margin:0 0 1rem !important;font-size:var(--mg-popover-title-font-size) !important;font-weight:600}";
|
|
5517
|
+
|
|
5518
|
+
const MgPopover = class {
|
|
5519
|
+
constructor(hostRef) {
|
|
5520
|
+
registerInstance(this, hostRef);
|
|
5521
|
+
this.displayChange = createEvent(this, "display-change", 7);
|
|
5522
|
+
this.closeButtonId = '';
|
|
5523
|
+
/**
|
|
5524
|
+
* Sets an `id` attribute.
|
|
5525
|
+
* Needed by the input for accessibility `aria-decribedby`.
|
|
5526
|
+
*/
|
|
5527
|
+
this.identifier = createID('mg-popover');
|
|
5528
|
+
/**
|
|
5529
|
+
* Popover placement
|
|
5530
|
+
*/
|
|
5531
|
+
this.placement = 'bottom';
|
|
5532
|
+
/**
|
|
5533
|
+
* Define if popover has a cross button
|
|
5534
|
+
*/
|
|
5535
|
+
this.closeButton = false;
|
|
5536
|
+
/**
|
|
5537
|
+
* Display popover
|
|
5538
|
+
*/
|
|
5539
|
+
this.display = false;
|
|
5540
|
+
/**
|
|
5541
|
+
* Disable popover
|
|
5542
|
+
*/
|
|
5543
|
+
this.disabled = false;
|
|
5544
|
+
/**
|
|
5545
|
+
* Check if clicked outside of component
|
|
5546
|
+
*
|
|
5547
|
+
* @param {MouseEvent} event mouse event
|
|
5548
|
+
* @returns {void}
|
|
5549
|
+
*/
|
|
5550
|
+
this.clickOutside = (event) => {
|
|
5551
|
+
if (!this.disabled && event.target.closest(`mg-popover`) !== this.element) {
|
|
5552
|
+
this.display = false;
|
|
5553
|
+
}
|
|
5554
|
+
};
|
|
5555
|
+
/**
|
|
5556
|
+
* Show popover
|
|
5557
|
+
*
|
|
5558
|
+
* @returns {void}
|
|
5559
|
+
*/
|
|
5560
|
+
this.show = () => {
|
|
5561
|
+
// Make the popover visible
|
|
5562
|
+
this.popover.setAttribute('data-show', '');
|
|
5563
|
+
// Enable the event listeners
|
|
5564
|
+
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
5565
|
+
// Update its position
|
|
5566
|
+
this.popper.update();
|
|
5567
|
+
// hide when click outside
|
|
5568
|
+
// setTimeout is used to prevent event to trigger after creation
|
|
5569
|
+
setTimeout(() => {
|
|
5570
|
+
document.addEventListener('click', this.clickOutside, false);
|
|
5571
|
+
}, 0);
|
|
5572
|
+
};
|
|
5573
|
+
/**
|
|
5574
|
+
* Hide popover
|
|
5575
|
+
*
|
|
5576
|
+
* @returns {void}
|
|
5577
|
+
*/
|
|
5578
|
+
this.hide = () => {
|
|
5579
|
+
// Hide the popover
|
|
5580
|
+
this.popover.removeAttribute('data-show');
|
|
5581
|
+
// Disable the event listeners
|
|
5582
|
+
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
|
|
5583
|
+
// Remove event listener
|
|
5584
|
+
document.removeEventListener('click', this.clickOutside, false);
|
|
5585
|
+
};
|
|
5586
|
+
/**
|
|
5587
|
+
* Handle action for close button
|
|
5588
|
+
*
|
|
5589
|
+
* @returns {void}
|
|
5590
|
+
*/
|
|
5591
|
+
this.handleCloseButton = () => {
|
|
5592
|
+
this.display = false;
|
|
5593
|
+
};
|
|
5594
|
+
}
|
|
5595
|
+
handleDisplay(newValue) {
|
|
5596
|
+
if (newValue) {
|
|
5597
|
+
this.show();
|
|
5598
|
+
}
|
|
5599
|
+
else {
|
|
5600
|
+
this.hide();
|
|
5601
|
+
}
|
|
5602
|
+
this.displayChange.emit(newValue);
|
|
5603
|
+
}
|
|
5604
|
+
/*************
|
|
5605
|
+
* Lifecycle *
|
|
5606
|
+
*************/
|
|
5607
|
+
/**
|
|
5608
|
+
* Check if component props are well configured on init
|
|
5609
|
+
*
|
|
5610
|
+
* @returns {void} timeout
|
|
5611
|
+
*/
|
|
5612
|
+
componentWillLoad() {
|
|
5613
|
+
// Get locales
|
|
5614
|
+
this.messages = initLocales(this.element).messages;
|
|
5615
|
+
}
|
|
5616
|
+
/**
|
|
5617
|
+
* Check if component props are well configured on init
|
|
5618
|
+
*
|
|
5619
|
+
* @returns {void}
|
|
5620
|
+
*/
|
|
5621
|
+
componentDidLoad() {
|
|
5622
|
+
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
5623
|
+
const slottedTitleElement = this.element.querySelector('[slot="title"]');
|
|
5624
|
+
if (slottedTitleElement && !isTagName(slottedTitleElement, headingTags)) {
|
|
5625
|
+
throw new Error(`<mg-popover> Slotted title must be a heading: ${headingTags.join(', ')}`);
|
|
5626
|
+
}
|
|
5627
|
+
// Set close button id
|
|
5628
|
+
if (this.closeButton) {
|
|
5629
|
+
this.closeButtonId = `${this.identifier}-close-button`;
|
|
5630
|
+
}
|
|
5631
|
+
// Get popover content
|
|
5632
|
+
this.popover = this.element.shadowRoot.querySelector(`#${this.identifier}`);
|
|
5633
|
+
//Get interactive element (first element without slot attribute)
|
|
5634
|
+
const interactiveElement = this.element.querySelector(':not([slot])');
|
|
5635
|
+
// Add aria attributes
|
|
5636
|
+
interactiveElement.setAttribute('aria-controls', this.identifier);
|
|
5637
|
+
interactiveElement.setAttribute('aria-expanded', `${this.display}`);
|
|
5638
|
+
// Create popperjs popover
|
|
5639
|
+
this.popper = createPopper(interactiveElement, this.popover, {
|
|
5640
|
+
placement: this.placement,
|
|
5641
|
+
strategy: 'fixed',
|
|
5642
|
+
modifiers: [
|
|
5643
|
+
{
|
|
5644
|
+
name: 'offset',
|
|
5645
|
+
options: {
|
|
5646
|
+
offset: [0, 10],
|
|
5647
|
+
},
|
|
5648
|
+
},
|
|
5649
|
+
],
|
|
5650
|
+
});
|
|
5651
|
+
// Add events to toggle display
|
|
5652
|
+
interactiveElement.addEventListener('click', () => {
|
|
5653
|
+
if (!this.disabled)
|
|
5654
|
+
this.display = !this.display;
|
|
5655
|
+
});
|
|
5656
|
+
// Add events to hide popover
|
|
5657
|
+
this.element.addEventListener('keydown', e => {
|
|
5658
|
+
if (!this.disabled && e.code === 'Escape')
|
|
5659
|
+
this.display = false;
|
|
5660
|
+
});
|
|
5661
|
+
this.handleDisplay(this.display);
|
|
5662
|
+
}
|
|
5663
|
+
/**
|
|
5664
|
+
* Render
|
|
5665
|
+
*
|
|
5666
|
+
* @returns {HTMLElement} HTML Element
|
|
5667
|
+
*/
|
|
5668
|
+
render() {
|
|
5669
|
+
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: "mg-popover" }, this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, h("mg-icon", { icon: "cross" }))), h("div", { class: "mg-popover__title" }, h("slot", { name: "title" })), h("slot", { name: "content" }), h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
5670
|
+
}
|
|
5671
|
+
get element() { return getElement(this); }
|
|
5672
|
+
static get watchers() { return {
|
|
5673
|
+
"display": ["handleDisplay"]
|
|
5674
|
+
}; }
|
|
5675
|
+
};
|
|
5676
|
+
MgPopover.style = mgPopoverCss;
|
|
5677
|
+
|
|
5678
|
+
var Status;
|
|
5679
|
+
(function (Status) {
|
|
5680
|
+
Status["VISIBLE"] = "visible";
|
|
5681
|
+
Status["HIDDEN"] = "hidden";
|
|
5682
|
+
Status["DISABLED"] = "disabled";
|
|
5683
|
+
Status["ACTIVE"] = "active";
|
|
5684
|
+
})(Status || (Status = {}));
|
|
5685
|
+
/**
|
|
5686
|
+
* List of all possibles sizes
|
|
5687
|
+
*/
|
|
5688
|
+
const sizes = ['regular', 'large'];
|
|
5689
|
+
|
|
5690
|
+
const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button{padding:calc(1rem + 0.3rem) calc(1rem * 1.3) 1rem}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button{padding:calc(1.8rem + 0.3rem) calc(1.8rem * 1.3) 1.8rem}.mg-tabs__header{display:flex;flex-direction:row;flex-wrap:wrap}.mg-tabs__navigation-button{display:flex;align-items:center;column-gap:0.5rem;background:none;border:none;border-bottom:0.3rem solid transparent;font-family:var(--font-family);color:hsl(var(--color-dark));line-height:var(--line-height);cursor:pointer}.mg-tabs__navigation-button:disabled,.mg-tabs__navigation-button--disabled{cursor:default;opacity:30%}.mg-tabs__navigation-button:hover:not(:disabled),.mg-tabs__navigation-button:focus:not(:disabled){background-color:hsla(var(--color-info-h), var(--color-info-s), var(--color-info-l), 10%)}.mg-tabs__navigation-button.mg-tabs__navigation-button--active{color:hsl(var(--color-info));border-bottom-color:hsl(var(--color-info));font-weight:700}.mg-tabs__navigation-button.mg-tabs__navigation-button--hidden{display:none}.mg-tabs__content-container:focus-visible{outline:none}";
|
|
5691
|
+
|
|
5692
|
+
/**
|
|
5693
|
+
* type TabItem validation function
|
|
5694
|
+
*
|
|
5695
|
+
* @param {TabItem} tab tab item
|
|
5696
|
+
* @returns {boolean} tab item type is valid
|
|
5697
|
+
*/
|
|
5698
|
+
const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
|
|
5699
|
+
const MgTabs = class {
|
|
5700
|
+
constructor(hostRef) {
|
|
5701
|
+
registerInstance(this, hostRef);
|
|
5702
|
+
this.activeTabChange = createEvent(this, "active-tab-change", 7);
|
|
3232
5703
|
/************
|
|
3233
5704
|
* Internal *
|
|
3234
5705
|
************/
|
|
@@ -3350,9 +5821,7 @@ const MgTabs = class {
|
|
|
3350
5821
|
}
|
|
3351
5822
|
validateLabel(newValue) {
|
|
3352
5823
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
3353
|
-
|
|
3354
|
-
// throw new Error('<mg-tabs> prop "label" is required.');
|
|
3355
|
-
console.error('<mg-tabs> prop "label" is required.');
|
|
5824
|
+
throw new Error('<mg-tabs> prop "label" is required.');
|
|
3356
5825
|
}
|
|
3357
5826
|
}
|
|
3358
5827
|
validateSize(newValue) {
|
|
@@ -3492,9 +5961,6 @@ const MgTag = class {
|
|
|
3492
5961
|
};
|
|
3493
5962
|
MgTag.style = mgTagCss;
|
|
3494
5963
|
|
|
3495
|
-
/**
|
|
3496
|
-
* List of all possibles placements
|
|
3497
|
-
*/
|
|
3498
5964
|
var Guard;
|
|
3499
5965
|
(function (Guard) {
|
|
3500
5966
|
Guard["FOCUS"] = "focus";
|
|
@@ -3502,7 +5968,7 @@ var Guard;
|
|
|
3502
5968
|
Guard["HOVER_TOOLTIPED_ELEMENT"] = "hoverTooltipedGuard";
|
|
3503
5969
|
})(Guard || (Guard = {}));
|
|
3504
5970
|
|
|
3505
|
-
const mgTooltipCss = "
|
|
5971
|
+
const mgTooltipCss = ":host{display:inline-block}.mg-tooltip{display:none;padding:0.5rem 0.8rem;z-index:1000;border-radius:var(--mg-tooltip-border-radius);background-color:hsl(var(--mg-tooltip-background-color));color:hsl(var(--mg-tooltip-font-color));text-align:start}.mg-tooltip[data-show]{display:block}.mg-tooltip .mg-tooltip__arrow,.mg-tooltip .mg-tooltip__arrow::before{position:absolute;width:0.8rem;height:0.8rem;z-index:9999;background:inherit}.mg-tooltip .mg-tooltip__arrow{visibility:hidden}.mg-tooltip .mg-tooltip__arrow::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-tooltip[data-popper-placement^=top]>.mg-tooltip__arrow{bottom:-4px}.mg-tooltip[data-popper-placement^=bottom]>.mg-tooltip__arrow{top:-4px}.mg-tooltip[data-popper-placement^=left]>.mg-tooltip__arrow{right:-4px}.mg-tooltip[data-popper-placement^=right]>.mg-tooltip__arrow{left:-4px}";
|
|
3506
5972
|
|
|
3507
5973
|
const MgTooltip = class {
|
|
3508
5974
|
constructor(hostRef) {
|
|
@@ -3593,9 +6059,7 @@ const MgTooltip = class {
|
|
|
3593
6059
|
}
|
|
3594
6060
|
validateMessage(newValue) {
|
|
3595
6061
|
if (typeof newValue !== 'string' || newValue.trim() === '') {
|
|
3596
|
-
|
|
3597
|
-
// throw new Error('<mg-tooltip> prop "message" is required.');
|
|
3598
|
-
console.error('<mg-tooltip> prop "message" is required.');
|
|
6062
|
+
throw new Error('<mg-tooltip> prop "message" is required.');
|
|
3599
6063
|
}
|
|
3600
6064
|
}
|
|
3601
6065
|
handleDisplay(newValue) {
|
|
@@ -3619,12 +6083,12 @@ const MgTooltip = class {
|
|
|
3619
6083
|
componentDidLoad() {
|
|
3620
6084
|
var _a;
|
|
3621
6085
|
// Get tooltip element
|
|
3622
|
-
this.tooltip = this.element.querySelector(`#${this.identifier}`);
|
|
6086
|
+
this.tooltip = this.element.shadowRoot.querySelector(`#${this.identifier}`);
|
|
3623
6087
|
// get slotted element
|
|
3624
6088
|
const slotElement = this.element.firstElementChild;
|
|
3625
6089
|
// Get interactive element
|
|
3626
6090
|
const interactiveElements = ['a', 'button', 'input', 'textarea', 'select']; //! Might needs updates
|
|
3627
|
-
const interactiveElement = this.element.querySelector(interactiveElements.join(',')) || ((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
|
|
6091
|
+
const interactiveElement = this.element.shadowRoot.querySelector(interactiveElements.join(',')) || ((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
|
|
3628
6092
|
// define selected element to become tooltip selector
|
|
3629
6093
|
const tooltipedElement = interactiveElement || slotElement;
|
|
3630
6094
|
// Add tabindex to slotted element if we can't find any interactive element
|
|
@@ -3641,6 +6105,7 @@ const MgTooltip = class {
|
|
|
3641
6105
|
// Create popperjs tooltip
|
|
3642
6106
|
this.popper = createPopper(tooltipedElement, this.tooltip, {
|
|
3643
6107
|
placement: this.placement,
|
|
6108
|
+
strategy: 'fixed',
|
|
3644
6109
|
modifiers: [
|
|
3645
6110
|
{
|
|
3646
6111
|
name: 'offset',
|
|
@@ -3696,4 +6161,4 @@ const MgTooltip = class {
|
|
|
3696
6161
|
};
|
|
3697
6162
|
MgTooltip.style = mgTooltipCss;
|
|
3698
6163
|
|
|
3699
|
-
export { MgBadge as mg_badge, MgButton as mg_button, MgCharacterLeft as mg_character_left, MgDetails as mg_details, MgForm as mg_form, MgIcon as mg_icon, MgIllustratedMessage as mg_illustrated_message, MgInputCheckbox as mg_input_checkbox, MgInputDate as mg_input_date, MgInputNumeric as mg_input_numeric, MgInputPassword as mg_input_password, MgInputRadio as mg_input_radio, MgInputSelect as mg_input_select, MgInputText as mg_input_text, MgInputTextarea as mg_input_textarea, MgInputTitle as mg_input_title, MgInputToggle as mg_input_toggle, MgMessage as mg_message, MgPagination as mg_pagination, MgPanel as mg_panel, MgTabs as mg_tabs, MgTag as mg_tag, MgTooltip as mg_tooltip };
|
|
6164
|
+
export { MgBadge as mg_badge, MgButton as mg_button, MgCard as mg_card, MgCharacterLeft as mg_character_left, MgDetails as mg_details, MgDivider as mg_divider, MgForm as mg_form, MgIcon as mg_icon, MgIllustratedMessage as mg_illustrated_message, MgInputCheckbox as mg_input_checkbox, MgInputDate as mg_input_date, MgInputNumeric as mg_input_numeric, MgInputPassword as mg_input_password, MgInputRadio as mg_input_radio, MgInputSelect as mg_input_select, MgInputText as mg_input_text, MgInputTextarea as mg_input_textarea, MgInputTitle as mg_input_title, MgInputToggle as mg_input_toggle, MgMessage as mg_message, MgModal as mg_modal, MgPagination as mg_pagination, MgPanel as mg_panel, MgPopover as mg_popover, MgTabs as mg_tabs, MgTag as mg_tag, MgTooltip as mg_tooltip };
|