@mgdis/mg-components 4.2.0 → 5.0.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/{index-64cee0c8.js → index-94497267.js} +220 -202
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{mg-badge_23.cjs.entry.js → mg-badge_24.cjs.entry.js} +2028 -26
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-modal.cjs.entry.js +6 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +0 -2
- package/dist/collection/components/atoms/mg-button/mg-button.css +106 -68
- package/dist/collection/components/atoms/mg-button/mg-button.js +51 -64
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +3 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
- 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 -2
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +4 -0
- 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 +8 -7
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +5 -7
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +7 -8
- package/dist/collection/variables.css +6 -0
- package/dist/components/mg-button2.js +44 -13
- 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-numeric.js +1 -1
- package/dist/components/mg-modal.js +5 -1
- package/dist/components/mg-pagination.js +4 -3
- package/dist/components/mg-panel.js +2 -2
- package/dist/components/mg-popover.js +9 -9
- package/dist/components/mg-tooltip2.js +5 -4
- package/dist/components/popper.js +60 -49
- package/dist/esm/{index-120f47fd.js → index-aad0184c.js} +220 -202
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{mg-badge_23.entry.js → mg-badge_24.entry.js} +2027 -26
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-modal.entry.js +6 -2
- package/dist/esm/polyfills/css-shim.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-3899d5d2.js +2 -0
- package/dist/mg-components/p-b60a4c53.entry.js +1 -0
- package/dist/mg-components/p-df947fa5.entry.js +1 -0
- package/dist/mg-components/variables.css +6 -0
- 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 +19 -17
- 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 +1 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +1 -0
- package/dist/types/components.d.ts +13 -29
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/package.json +2 -2
- package/dist/cjs/mg-popover.cjs.entry.js +0 -171
- package/dist/cjs/popper-71bf3058.js +0 -1790
- package/dist/collection/variables.scss +0 -212
- package/dist/esm/mg-popover.entry.js +0 -167
- package/dist/esm/popper-93ecb064.js +0 -1788
- package/dist/mg-components/p-21991be8.entry.js +0 -1
- package/dist/mg-components/p-36a64f8c.entry.js +0 -1
- package/dist/mg-components/p-4c66f794.js +0 -1
- package/dist/mg-components/p-7bc32a2f.js +0 -2
- package/dist/mg-components/p-b380a0df.entry.js +0 -1
- package/dist/mg-components/variables.scss +0 -212
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
/*
|
|
3
|
-
Fonts
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
--font-size: 1.3rem;
|
|
7
|
-
--line-height: 1.4;
|
|
8
|
-
|
|
9
|
-
/* Open Sans is used for the body (mostly all texts) */
|
|
10
|
-
--font-family: 'Open Sans', sans-serif;
|
|
11
|
-
|
|
12
|
-
/* Headings (h1 to h6) font can be customized */
|
|
13
|
-
--font-family-heading: var(--font-family);
|
|
14
|
-
|
|
15
|
-
/* Font colors */
|
|
16
|
-
--color-font-light: var(--color-light);
|
|
17
|
-
--color-font-dark: var(--color-dark);
|
|
18
|
-
/*
|
|
19
|
-
Colors
|
|
20
|
-
https://jira.mgdis.fr/browse/PDA9-690
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/* Neutral */
|
|
24
|
-
/* #fefefe; */
|
|
25
|
-
/* rgb(254, 254, 254); */
|
|
26
|
-
--color-neutral-h: 0;
|
|
27
|
-
--color-neutral-s: 0%;
|
|
28
|
-
--color-neutral-l: 99.6%;
|
|
29
|
-
--color-neutral: var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l);
|
|
30
|
-
|
|
31
|
-
/* Warning */
|
|
32
|
-
/* #ffc33e */
|
|
33
|
-
/* rgb(255, 195, 62); */
|
|
34
|
-
--color-warning-h: 41;
|
|
35
|
-
--color-warning-s: 100%;
|
|
36
|
-
--color-warning-l: 62.2%;
|
|
37
|
-
--color-warning: var(--color-warning-h), var(--color-warning-s), var(--color-warning-l);
|
|
38
|
-
|
|
39
|
-
/* Success */
|
|
40
|
-
/* #32d59c */
|
|
41
|
-
/* rgb(50, 213, 156); */
|
|
42
|
-
--color-success-h: 159;
|
|
43
|
-
--color-success-s: 66%;
|
|
44
|
-
--color-success-l: 51.6%;
|
|
45
|
-
--color-success: var(--color-success-h), var(--color-success-s), var(--color-success-l);
|
|
46
|
-
|
|
47
|
-
/* Info */
|
|
48
|
-
/* #005e9c; */
|
|
49
|
-
/* rgb(0, 94, 156); */
|
|
50
|
-
--color-info-h: 204;
|
|
51
|
-
--color-info-s: 100%;
|
|
52
|
-
--color-info-l: 30.6%;
|
|
53
|
-
--color-info: var(--color-info-h), var(--color-info-s), var(--color-info-l);
|
|
54
|
-
|
|
55
|
-
/* Danger */
|
|
56
|
-
/* #db1f29; */
|
|
57
|
-
/* rgb(219, 31, 41); */
|
|
58
|
-
--color-danger-h: 357;
|
|
59
|
-
--color-danger-s: 75%;
|
|
60
|
-
--color-danger-l: 49%;
|
|
61
|
-
--color-danger: var(--color-danger-h), var(--color-danger-s), var(--color-danger-l);
|
|
62
|
-
|
|
63
|
-
/* Dark */
|
|
64
|
-
/* #15282e; */
|
|
65
|
-
/* rgb(21, 40, 46); */
|
|
66
|
-
--color-dark-h: 194;
|
|
67
|
-
--color-dark-s: 37.3%;
|
|
68
|
-
--color-dark-l: 13.1%;
|
|
69
|
-
--color-dark: var(--color-dark-h), var(--color-dark-s), var(--color-dark-l);
|
|
70
|
-
|
|
71
|
-
/* Light */
|
|
72
|
-
/* white; (#ffffff) */
|
|
73
|
-
/* rgb(255, 255, 255); */
|
|
74
|
-
--color-light-h: 0;
|
|
75
|
-
--color-light-s: 0%;
|
|
76
|
-
--color-light-l: 100%;
|
|
77
|
-
--color-light: var(--color-light-h), var(--color-light-s), var(--color-light-l);
|
|
78
|
-
|
|
79
|
-
/* Primary */
|
|
80
|
-
--color-primary-h: hsl(var(--color-dark-h));
|
|
81
|
-
--color-primary-s: hsl(var(--color-dark-s));
|
|
82
|
-
--color-primary-l: hsl(var(--color-dark-l));
|
|
83
|
-
--color-primary: hsl(var(--color-dark));
|
|
84
|
-
|
|
85
|
-
/* Secondary */
|
|
86
|
-
--color-secondary-h: hsl(var(--color-neutral-h));
|
|
87
|
-
--color-secondary-s: hsl(var(--color-neutral-s));
|
|
88
|
-
--color-secondary-l: hsl(var(--color-neutral-l));
|
|
89
|
-
--color-secondary: hsl(var(--color-neutral));
|
|
90
|
-
|
|
91
|
-
/* Shadow */
|
|
92
|
-
--box-shadow: 0 0.3rem 0.8rem 0 rgba(0, 0, 0, 0.1);
|
|
93
|
-
|
|
94
|
-
/*
|
|
95
|
-
Global
|
|
96
|
-
*/
|
|
97
|
-
--default-size: 3.5rem;
|
|
98
|
-
|
|
99
|
-
/*
|
|
100
|
-
<mg-icon>
|
|
101
|
-
*/
|
|
102
|
-
--mg-icon-small-size: 1.2rem;
|
|
103
|
-
--mg-icon-regular-size: 1.6rem;
|
|
104
|
-
--mg-icon-large-size: 2.4rem;
|
|
105
|
-
--mg-icon-extra-large-size: 3.6rem;
|
|
106
|
-
|
|
107
|
-
/*
|
|
108
|
-
<mg-button>
|
|
109
|
-
*/
|
|
110
|
-
|
|
111
|
-
--mg-button-border-radius: 0.3rem;
|
|
112
|
-
--mg-button-icon-border-radius: var(--default-size);
|
|
113
|
-
--mg-button-disabled-opacity: 0.6;
|
|
114
|
-
--mg-button-gradient: 1; /* Can only be 1 or 0 to enable disable gradient */
|
|
115
|
-
--mg-button-border-variation: 1; /* Can only be 1 or 0 to enable disable border variation */
|
|
116
|
-
|
|
117
|
-
/* Primary */
|
|
118
|
-
--mg-button-primary-color-h: var(--color-dark-h);
|
|
119
|
-
--mg-button-primary-color-s: var(--color-dark-s);
|
|
120
|
-
--mg-button-primary-color-l: var(--color-dark-l);
|
|
121
|
-
--mg-button-primary-font-color: var(--color-neutral);
|
|
122
|
-
|
|
123
|
-
/* Secondary */
|
|
124
|
-
--mg-button-secondary-color-h: var(--color-neutral-h);
|
|
125
|
-
--mg-button-secondary-color-s: var(--color-neutral-s);
|
|
126
|
-
--mg-button-secondary-color-l: var(--color-neutral-l);
|
|
127
|
-
--mg-button-secondary-font-color: var(--color-dark);
|
|
128
|
-
|
|
129
|
-
/*
|
|
130
|
-
<mg-tag>
|
|
131
|
-
*/
|
|
132
|
-
--mg-tag-height: 2.3rem;
|
|
133
|
-
--mg-tag-border-radius: 0.5rem;
|
|
134
|
-
--mg-tag-font-size: 1.2rem;
|
|
135
|
-
|
|
136
|
-
/*
|
|
137
|
-
<mg-badge>
|
|
138
|
-
*/
|
|
139
|
-
--mg-badge-size: 1.6rem;
|
|
140
|
-
--mg-badge-font-size: 1.1rem;
|
|
141
|
-
|
|
142
|
-
/*
|
|
143
|
-
<mg-tooltip>
|
|
144
|
-
*/
|
|
145
|
-
--mg-tooltip-border-radius: 0.5rem;
|
|
146
|
-
--mg-tooltip-background-color: var(--color-dark);
|
|
147
|
-
--mg-tooltip-font-color: var(--color-font-light);
|
|
148
|
-
|
|
149
|
-
/*
|
|
150
|
-
<mg-popover>
|
|
151
|
-
*/
|
|
152
|
-
--mg-popover-background-color: var(--color-light);
|
|
153
|
-
--mg-popover-font-color: var(--color-font-dark);
|
|
154
|
-
--mg-popover-title-font-size: 1.4rem;
|
|
155
|
-
|
|
156
|
-
/*
|
|
157
|
-
<mg-message>
|
|
158
|
-
*/
|
|
159
|
-
--mg-message-border-radius: 0.3rem;
|
|
160
|
-
|
|
161
|
-
/*
|
|
162
|
-
<mg-modal>
|
|
163
|
-
*/
|
|
164
|
-
--mg-modal-border-radius: 0.5rem;
|
|
165
|
-
--mg-modal-title-font-size: 1.8rem;
|
|
166
|
-
--mg-modal-content-font-size: 1.2rem;
|
|
167
|
-
|
|
168
|
-
/*
|
|
169
|
-
<mg-panel>
|
|
170
|
-
*/
|
|
171
|
-
|
|
172
|
-
--mg-panel-border-radius: 0.5rem;
|
|
173
|
-
--mg-panel-background: var(--color-info-h) var(--color-info-s) calc(var(--color-info-l) + 68%);
|
|
174
|
-
--mg-panel-content-padding: 1.5rem;
|
|
175
|
-
|
|
176
|
-
/*
|
|
177
|
-
Layout
|
|
178
|
-
*/
|
|
179
|
-
--mg-grid-spacing: 1rem;
|
|
180
|
-
|
|
181
|
-
/*
|
|
182
|
-
Forms
|
|
183
|
-
*/
|
|
184
|
-
|
|
185
|
-
/*
|
|
186
|
-
<mg-input-...>
|
|
187
|
-
*/
|
|
188
|
-
--mg-inputs-border-width: 0.1rem;
|
|
189
|
-
--mg-inputs-border-radius: 0.3rem;
|
|
190
|
-
--mg-inputs-color: #b5c2c9;
|
|
191
|
-
--mg-inputs-spacer: 1rem;
|
|
192
|
-
|
|
193
|
-
/* Error message background */
|
|
194
|
-
--mg-inputs-error-bg-color: var(--color-danger-h), calc(var(--color-danger-s) + 5%), calc(var(--color-danger-l) + 49%);
|
|
195
|
-
|
|
196
|
-
/* Input focus shadow */
|
|
197
|
-
/* #b5c2c9 */
|
|
198
|
-
/* rgb(0, 221, 255); */
|
|
199
|
-
/* hsl(188, 100%, 50%); */
|
|
200
|
-
--mg-inputs-color-shadow-focus-hsl: 188, 100%, 50%;
|
|
201
|
-
|
|
202
|
-
/*
|
|
203
|
-
<mg-input-toggle>
|
|
204
|
-
*/
|
|
205
|
-
--mg-input-toggle-border-radius-ratio: 2;
|
|
206
|
-
|
|
207
|
-
/*
|
|
208
|
-
<mg-input-checkbox>
|
|
209
|
-
<mg-input-radio>
|
|
210
|
-
*/
|
|
211
|
-
--mg-input-check-size: 1.3rem;
|
|
212
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-120f47fd.js';
|
|
2
|
-
import { c as createID, i as initLocales, a as isTagName } from './index-7efedd97.js';
|
|
3
|
-
import { c as createPopper } from './popper-93ecb064.js';
|
|
4
|
-
|
|
5
|
-
const mgPopoverCss = "mg-popover.sc-mg-popover{display:contents}mg-popover.sc-mg-popover-s>*{display:inline-block}.mg-popover.sc-mg-popover{display:none;padding:1.5rem;z-index:9999;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].sc-mg-popover{display:block}.mg-popover.sc-mg-popover mg-button.sc-mg-popover{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.sc-mg-popover .mg-popover__arrow.sc-mg-popover,.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover::before{position:absolute;width:2rem;height:2rem;z-index:-1;background:inherit}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover{visibility:hidden}.mg-popover.sc-mg-popover .mg-popover__arrow.sc-mg-popover::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-popover[data-popper-placement^=top].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{bottom:-6px}.mg-popover[data-popper-placement^=bottom].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{top:-6px}.mg-popover[data-popper-placement^=left].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{right:-6px}.mg-popover[data-popper-placement^=right].sc-mg-popover>.mg-popover__arrow.sc-mg-popover{left:-6px}.mg-popover__title.sc-mg-popover-s>[slot=title],.mg-popover__title .sc-mg-popover-s>[slot=title]{margin:0 0 1rem;font-size:var(--mg-popover-title-font-size);font-weight:600}";
|
|
6
|
-
|
|
7
|
-
const MgPopover = class {
|
|
8
|
-
constructor(hostRef) {
|
|
9
|
-
registerInstance(this, hostRef);
|
|
10
|
-
this.displayChange = createEvent(this, "display-change", 7);
|
|
11
|
-
this.closeButtonId = '';
|
|
12
|
-
/**
|
|
13
|
-
* Sets an `id` attribute.
|
|
14
|
-
* Needed by the input for accessibility `aria-decribedby`.
|
|
15
|
-
*/
|
|
16
|
-
this.identifier = createID('mg-popover');
|
|
17
|
-
/**
|
|
18
|
-
* Popover placement
|
|
19
|
-
*/
|
|
20
|
-
this.placement = 'bottom';
|
|
21
|
-
/**
|
|
22
|
-
* Define if popover has a cross button
|
|
23
|
-
*/
|
|
24
|
-
this.closeButton = false;
|
|
25
|
-
/**
|
|
26
|
-
* Display popover
|
|
27
|
-
*/
|
|
28
|
-
this.display = false;
|
|
29
|
-
/**
|
|
30
|
-
* Disable popover
|
|
31
|
-
*/
|
|
32
|
-
this.disabled = false;
|
|
33
|
-
/**
|
|
34
|
-
* Check if clicked outside of component
|
|
35
|
-
*
|
|
36
|
-
* @param {MouseEvent} event mouse event
|
|
37
|
-
* @returns {void}
|
|
38
|
-
*/
|
|
39
|
-
this.clickOutside = (event) => {
|
|
40
|
-
var _a;
|
|
41
|
-
if (!this.disabled && ((_a = event.target.closest(`#${this.identifier}`)) === null || _a === void 0 ? void 0 : _a.parentElement.nodeName) !== 'MG-POPOVER') {
|
|
42
|
-
this.display = false;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Show popover
|
|
47
|
-
*
|
|
48
|
-
* @returns {void}
|
|
49
|
-
*/
|
|
50
|
-
this.show = () => {
|
|
51
|
-
// Make the popover visible
|
|
52
|
-
this.popover.setAttribute('data-show', '');
|
|
53
|
-
// Enable the event listeners
|
|
54
|
-
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
55
|
-
// Update its position
|
|
56
|
-
this.popper.update();
|
|
57
|
-
// hide when click outside
|
|
58
|
-
// setTimeout is used to prevent event to trigger after creation
|
|
59
|
-
setTimeout(() => {
|
|
60
|
-
document.addEventListener('click', this.clickOutside, false);
|
|
61
|
-
}, 0);
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Hide popover
|
|
65
|
-
*
|
|
66
|
-
* @returns {void}
|
|
67
|
-
*/
|
|
68
|
-
this.hide = () => {
|
|
69
|
-
// Hide the popover
|
|
70
|
-
this.popover.removeAttribute('data-show');
|
|
71
|
-
// Disable the event listeners
|
|
72
|
-
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
|
|
73
|
-
// Remove event listener
|
|
74
|
-
document.removeEventListener('click', this.clickOutside, false);
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Handle action for close button
|
|
78
|
-
*
|
|
79
|
-
* @returns {void}
|
|
80
|
-
*/
|
|
81
|
-
this.handleCloseButton = () => {
|
|
82
|
-
this.display = false;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
handleDisplay(newValue) {
|
|
86
|
-
if (newValue) {
|
|
87
|
-
this.show();
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
this.hide();
|
|
91
|
-
}
|
|
92
|
-
this.displayChange.emit(newValue);
|
|
93
|
-
}
|
|
94
|
-
/*************
|
|
95
|
-
* Lifecycle *
|
|
96
|
-
*************/
|
|
97
|
-
/**
|
|
98
|
-
* Check if component props are well configured on init
|
|
99
|
-
*
|
|
100
|
-
* @returns {void} timeout
|
|
101
|
-
*/
|
|
102
|
-
componentWillLoad() {
|
|
103
|
-
// Get locales
|
|
104
|
-
this.messages = initLocales(this.element).messages;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Check if component props are well configured on init
|
|
108
|
-
*
|
|
109
|
-
* @returns {void}
|
|
110
|
-
*/
|
|
111
|
-
componentDidLoad() {
|
|
112
|
-
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
113
|
-
const slotedTitleElement = this.element.querySelector('[slot="title"]');
|
|
114
|
-
if (slotedTitleElement && !isTagName(slotedTitleElement, headingTags)) {
|
|
115
|
-
throw new Error(`<mg-popover> Slotted title must be a heading: ${headingTags.join(', ')}`);
|
|
116
|
-
}
|
|
117
|
-
// Set close button id
|
|
118
|
-
if (this.closeButton) {
|
|
119
|
-
this.closeButtonId = `${this.identifier}-close-button`;
|
|
120
|
-
}
|
|
121
|
-
// Get popover content
|
|
122
|
-
this.popover = this.element.querySelector(`#${this.identifier}`);
|
|
123
|
-
//Get interactive element
|
|
124
|
-
const interactiveElement = this.element.firstElementChild;
|
|
125
|
-
// Add aria attributes
|
|
126
|
-
interactiveElement.setAttribute('aria-controls', this.identifier);
|
|
127
|
-
interactiveElement.setAttribute('aria-expanded', `${this.display}`);
|
|
128
|
-
// Create popperjs popover
|
|
129
|
-
this.popper = createPopper(interactiveElement, this.popover, {
|
|
130
|
-
placement: this.placement,
|
|
131
|
-
modifiers: [
|
|
132
|
-
{
|
|
133
|
-
name: 'offset',
|
|
134
|
-
options: {
|
|
135
|
-
offset: [0, 10],
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
});
|
|
140
|
-
// Add events to toggle display
|
|
141
|
-
interactiveElement.addEventListener('click', () => {
|
|
142
|
-
if (!this.disabled)
|
|
143
|
-
this.display = !this.display;
|
|
144
|
-
});
|
|
145
|
-
// Add events to hide popover
|
|
146
|
-
this.element.addEventListener('keydown', e => {
|
|
147
|
-
if (!this.disabled && e.code === 'Escape')
|
|
148
|
-
this.display = false;
|
|
149
|
-
});
|
|
150
|
-
this.handleDisplay(this.display);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Render
|
|
154
|
-
*
|
|
155
|
-
* @returns {HTMLElement} HTML Element
|
|
156
|
-
*/
|
|
157
|
-
render() {
|
|
158
|
-
return (h(Host, null, h("slot", null), h("div", { id: this.identifier, class: "mg-popover" }, !this.disabled && 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 }))));
|
|
159
|
-
}
|
|
160
|
-
get element() { return getElement(this); }
|
|
161
|
-
static get watchers() { return {
|
|
162
|
-
"display": ["handleDisplay"]
|
|
163
|
-
}; }
|
|
164
|
-
};
|
|
165
|
-
MgPopover.style = mgPopoverCss;
|
|
166
|
-
|
|
167
|
-
export { MgPopover as mg_popover };
|