@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
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
|
|
8
8
|
import { BadgeType } from "./components/atoms/mg-badge/mg-badge.conf";
|
|
9
|
-
import { ButtonType } from "./components/atoms/mg-button/mg-button.conf";
|
|
9
|
+
import { ButtonType, VariantType } from "./components/atoms/mg-button/mg-button.conf";
|
|
10
10
|
import { CheckboxValue } from "./components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf";
|
|
11
11
|
import { Width } from "./components/molecules/inputs/MgInput.conf";
|
|
12
12
|
import { RadioOption } from "./components/molecules/inputs/mg-input-radio/mg-input-radio.conf";
|
|
@@ -35,10 +35,6 @@ export namespace Components {
|
|
|
35
35
|
"variant": string;
|
|
36
36
|
}
|
|
37
37
|
interface MgButton {
|
|
38
|
-
/**
|
|
39
|
-
* Prop to set aria-controls on button element
|
|
40
|
-
*/
|
|
41
|
-
"controls": string;
|
|
42
38
|
/**
|
|
43
39
|
* Option to set input disable on click, in order to prevent multi-click. Parent component have to remove the attribute 'disabled' when the process ends.
|
|
44
40
|
*/
|
|
@@ -47,18 +43,10 @@ export namespace Components {
|
|
|
47
43
|
* Disable button
|
|
48
44
|
*/
|
|
49
45
|
"disabled": boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Prop to set aria-expanded on button element
|
|
52
|
-
*/
|
|
53
|
-
"expanded": boolean;
|
|
54
46
|
/**
|
|
55
47
|
* Define form id to attach button with. If this attribute is not set, the <button> is associated with its ancestor <form> element.
|
|
56
48
|
*/
|
|
57
49
|
"form": string;
|
|
58
|
-
/**
|
|
59
|
-
* Option to set aria-haspopup The aria-haspopup state informs assistive technology users that there is a popup and the type of popup it is, but provides no interactivity.
|
|
60
|
-
*/
|
|
61
|
-
"haspopup": boolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
|
62
50
|
/**
|
|
63
51
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
64
52
|
*/
|
|
@@ -72,13 +60,13 @@ export namespace Components {
|
|
|
72
60
|
*/
|
|
73
61
|
"label": string;
|
|
74
62
|
/**
|
|
75
|
-
* Define button type
|
|
63
|
+
* Define button type
|
|
76
64
|
*/
|
|
77
65
|
"type": ButtonType;
|
|
78
66
|
/**
|
|
79
67
|
* Define button variant
|
|
80
68
|
*/
|
|
81
|
-
"variant":
|
|
69
|
+
"variant": VariantType;
|
|
82
70
|
}
|
|
83
71
|
interface MgCharacterLeft {
|
|
84
72
|
/**
|
|
@@ -158,6 +146,10 @@ export namespace Components {
|
|
|
158
146
|
"variant": string;
|
|
159
147
|
}
|
|
160
148
|
interface MgIllustratedMessage {
|
|
149
|
+
/**
|
|
150
|
+
* Define component orientation
|
|
151
|
+
*/
|
|
152
|
+
"direction": 'vertical' | 'horizontal';
|
|
161
153
|
/**
|
|
162
154
|
* Define illustration size
|
|
163
155
|
*/
|
|
@@ -1285,10 +1277,6 @@ declare namespace LocalJSX {
|
|
|
1285
1277
|
"variant"?: string;
|
|
1286
1278
|
}
|
|
1287
1279
|
interface MgButton {
|
|
1288
|
-
/**
|
|
1289
|
-
* Prop to set aria-controls on button element
|
|
1290
|
-
*/
|
|
1291
|
-
"controls"?: string;
|
|
1292
1280
|
/**
|
|
1293
1281
|
* Option to set input disable on click, in order to prevent multi-click. Parent component have to remove the attribute 'disabled' when the process ends.
|
|
1294
1282
|
*/
|
|
@@ -1297,18 +1285,10 @@ declare namespace LocalJSX {
|
|
|
1297
1285
|
* Disable button
|
|
1298
1286
|
*/
|
|
1299
1287
|
"disabled"?: boolean;
|
|
1300
|
-
/**
|
|
1301
|
-
* Prop to set aria-expanded on button element
|
|
1302
|
-
*/
|
|
1303
|
-
"expanded"?: boolean;
|
|
1304
1288
|
/**
|
|
1305
1289
|
* Define form id to attach button with. If this attribute is not set, the <button> is associated with its ancestor <form> element.
|
|
1306
1290
|
*/
|
|
1307
1291
|
"form"?: string;
|
|
1308
|
-
/**
|
|
1309
|
-
* Option to set aria-haspopup The aria-haspopup state informs assistive technology users that there is a popup and the type of popup it is, but provides no interactivity.
|
|
1310
|
-
*/
|
|
1311
|
-
"haspopup"?: boolean | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
|
1312
1292
|
/**
|
|
1313
1293
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
1314
1294
|
*/
|
|
@@ -1322,13 +1302,13 @@ declare namespace LocalJSX {
|
|
|
1322
1302
|
*/
|
|
1323
1303
|
"label"?: string;
|
|
1324
1304
|
/**
|
|
1325
|
-
* Define button type
|
|
1305
|
+
* Define button type
|
|
1326
1306
|
*/
|
|
1327
1307
|
"type"?: ButtonType;
|
|
1328
1308
|
/**
|
|
1329
1309
|
* Define button variant
|
|
1330
1310
|
*/
|
|
1331
|
-
"variant"?:
|
|
1311
|
+
"variant"?: VariantType;
|
|
1332
1312
|
}
|
|
1333
1313
|
interface MgCharacterLeft {
|
|
1334
1314
|
/**
|
|
@@ -1415,6 +1395,10 @@ declare namespace LocalJSX {
|
|
|
1415
1395
|
"variant"?: string;
|
|
1416
1396
|
}
|
|
1417
1397
|
interface MgIllustratedMessage {
|
|
1398
|
+
/**
|
|
1399
|
+
* Define component orientation
|
|
1400
|
+
*/
|
|
1401
|
+
"direction"?: 'vertical' | 'horizontal';
|
|
1418
1402
|
/**
|
|
1419
1403
|
* Define illustration size
|
|
1420
1404
|
*/
|
|
@@ -221,7 +221,8 @@ export declare type ErrorHandler = (err: any, element?: HTMLElement) => void;
|
|
|
221
221
|
*/
|
|
222
222
|
export declare const setMode: (handler: ResolutionHandler) => void;
|
|
223
223
|
/**
|
|
224
|
-
* getMode
|
|
224
|
+
* `getMode()` is used for libraries which provide multiple "modes" for styles.
|
|
225
|
+
* @param ref a reference to the node to get styles for
|
|
225
226
|
*/
|
|
226
227
|
export declare function getMode<T = string | undefined>(ref: any): T;
|
|
227
228
|
export declare function setPlatformHelpers(helpers: {
|
|
@@ -234,6 +235,8 @@ export declare function setPlatformHelpers(helpers: {
|
|
|
234
235
|
/**
|
|
235
236
|
* Get the base path to where the assets can be found. Use `setAssetPath(path)`
|
|
236
237
|
* if the path needs to be customized.
|
|
238
|
+
* @param path the path to use in calculating the asset path. this value will be
|
|
239
|
+
* used in conjunction with the base asset path
|
|
237
240
|
*/
|
|
238
241
|
export declare function getAssetPath(path: string): string;
|
|
239
242
|
/**
|
|
@@ -246,18 +249,22 @@ export declare function getAssetPath(path: string): string;
|
|
|
246
249
|
* `setAssetPath(document.currentScript.src)`, or using a bundler's replace plugin to
|
|
247
250
|
* dynamically set the path at build time, such as `setAssetPath(process.env.ASSET_PATH)`.
|
|
248
251
|
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
249
|
-
*
|
|
252
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
250
253
|
* will have to ensure the static assets are copied to its build directory.
|
|
254
|
+
* @param path the asset path to set
|
|
251
255
|
*/
|
|
252
256
|
export declare function setAssetPath(path: string): string;
|
|
253
257
|
/**
|
|
254
|
-
*
|
|
258
|
+
* Retrieve a Stencil element for a given reference
|
|
259
|
+
* @param ref the ref to get the Stencil element for
|
|
255
260
|
*/
|
|
256
261
|
export declare function getElement(ref: any): HTMLStencilElement;
|
|
257
262
|
/**
|
|
258
263
|
* Schedules a new render of the given instance or element even if no state changed.
|
|
259
264
|
*
|
|
260
|
-
* Notice `forceUpdate()` is not
|
|
265
|
+
* Notice `forceUpdate()` is not synchronous and might perform the DOM render in the next frame.
|
|
266
|
+
*
|
|
267
|
+
* @param ref the node/element to force the re-render of
|
|
261
268
|
*/
|
|
262
269
|
export declare function forceUpdate(ref: any): void;
|
|
263
270
|
/**
|
|
@@ -272,6 +279,8 @@ export interface HTMLStencilElement extends HTMLElement {
|
|
|
272
279
|
* in the best moment to perform DOM mutation without causing layout thrashing.
|
|
273
280
|
*
|
|
274
281
|
* For further information: https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing
|
|
282
|
+
*
|
|
283
|
+
* @param task the DOM-write to schedule
|
|
275
284
|
*/
|
|
276
285
|
export declare function writeTask(task: RafCallback): void;
|
|
277
286
|
/**
|
|
@@ -279,6 +288,8 @@ export declare function writeTask(task: RafCallback): void;
|
|
|
279
288
|
* in the best moment to perform DOM reads without causing layout thrashing.
|
|
280
289
|
*
|
|
281
290
|
* For further information: https://developers.google.com/web/fundamentals/performance/rendering/avoid-large-complex-layouts-and-layout-thrashing
|
|
291
|
+
*
|
|
292
|
+
* @param task the DOM-read to schedule
|
|
282
293
|
*/
|
|
283
294
|
export declare function readTask(task: RafCallback): void;
|
|
284
295
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mgdis/mg-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "MG Components",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@typescript-eslint/parser": "^4.33.0",
|
|
65
65
|
"babel-loader": "^8.2.2",
|
|
66
66
|
"babel-plugin-jsx-pragmatic": "^1.0.2",
|
|
67
|
-
"chromatic": "^6.
|
|
67
|
+
"chromatic": "^6.10.1",
|
|
68
68
|
"css-loader": "^5.2.7",
|
|
69
69
|
"eslint": "^7.32.0",
|
|
70
70
|
"eslint-plugin-jsdoc": "^38.0.6",
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const index = require('./index-64cee0c8.js');
|
|
6
|
-
const index$1 = require('./index-179621c8.js');
|
|
7
|
-
const popper = require('./popper-71bf3058.js');
|
|
8
|
-
|
|
9
|
-
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}";
|
|
10
|
-
|
|
11
|
-
const MgPopover = class {
|
|
12
|
-
constructor(hostRef) {
|
|
13
|
-
index.registerInstance(this, hostRef);
|
|
14
|
-
this.displayChange = index.createEvent(this, "display-change", 7);
|
|
15
|
-
this.closeButtonId = '';
|
|
16
|
-
/**
|
|
17
|
-
* Sets an `id` attribute.
|
|
18
|
-
* Needed by the input for accessibility `aria-decribedby`.
|
|
19
|
-
*/
|
|
20
|
-
this.identifier = index$1.createID('mg-popover');
|
|
21
|
-
/**
|
|
22
|
-
* Popover placement
|
|
23
|
-
*/
|
|
24
|
-
this.placement = 'bottom';
|
|
25
|
-
/**
|
|
26
|
-
* Define if popover has a cross button
|
|
27
|
-
*/
|
|
28
|
-
this.closeButton = false;
|
|
29
|
-
/**
|
|
30
|
-
* Display popover
|
|
31
|
-
*/
|
|
32
|
-
this.display = false;
|
|
33
|
-
/**
|
|
34
|
-
* Disable popover
|
|
35
|
-
*/
|
|
36
|
-
this.disabled = false;
|
|
37
|
-
/**
|
|
38
|
-
* Check if clicked outside of component
|
|
39
|
-
*
|
|
40
|
-
* @param {MouseEvent} event mouse event
|
|
41
|
-
* @returns {void}
|
|
42
|
-
*/
|
|
43
|
-
this.clickOutside = (event) => {
|
|
44
|
-
var _a;
|
|
45
|
-
if (!this.disabled && ((_a = event.target.closest(`#${this.identifier}`)) === null || _a === void 0 ? void 0 : _a.parentElement.nodeName) !== 'MG-POPOVER') {
|
|
46
|
-
this.display = false;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Show popover
|
|
51
|
-
*
|
|
52
|
-
* @returns {void}
|
|
53
|
-
*/
|
|
54
|
-
this.show = () => {
|
|
55
|
-
// Make the popover visible
|
|
56
|
-
this.popover.setAttribute('data-show', '');
|
|
57
|
-
// Enable the event listeners
|
|
58
|
-
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
59
|
-
// Update its position
|
|
60
|
-
this.popper.update();
|
|
61
|
-
// hide when click outside
|
|
62
|
-
// setTimeout is used to prevent event to trigger after creation
|
|
63
|
-
setTimeout(() => {
|
|
64
|
-
document.addEventListener('click', this.clickOutside, false);
|
|
65
|
-
}, 0);
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Hide popover
|
|
69
|
-
*
|
|
70
|
-
* @returns {void}
|
|
71
|
-
*/
|
|
72
|
-
this.hide = () => {
|
|
73
|
-
// Hide the popover
|
|
74
|
-
this.popover.removeAttribute('data-show');
|
|
75
|
-
// Disable the event listeners
|
|
76
|
-
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
|
|
77
|
-
// Remove event listener
|
|
78
|
-
document.removeEventListener('click', this.clickOutside, false);
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Handle action for close button
|
|
82
|
-
*
|
|
83
|
-
* @returns {void}
|
|
84
|
-
*/
|
|
85
|
-
this.handleCloseButton = () => {
|
|
86
|
-
this.display = false;
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
handleDisplay(newValue) {
|
|
90
|
-
if (newValue) {
|
|
91
|
-
this.show();
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
this.hide();
|
|
95
|
-
}
|
|
96
|
-
this.displayChange.emit(newValue);
|
|
97
|
-
}
|
|
98
|
-
/*************
|
|
99
|
-
* Lifecycle *
|
|
100
|
-
*************/
|
|
101
|
-
/**
|
|
102
|
-
* Check if component props are well configured on init
|
|
103
|
-
*
|
|
104
|
-
* @returns {void} timeout
|
|
105
|
-
*/
|
|
106
|
-
componentWillLoad() {
|
|
107
|
-
// Get locales
|
|
108
|
-
this.messages = index$1.initLocales(this.element).messages;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Check if component props are well configured on init
|
|
112
|
-
*
|
|
113
|
-
* @returns {void}
|
|
114
|
-
*/
|
|
115
|
-
componentDidLoad() {
|
|
116
|
-
const headingTags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
117
|
-
const slotedTitleElement = this.element.querySelector('[slot="title"]');
|
|
118
|
-
if (slotedTitleElement && !index$1.isTagName(slotedTitleElement, headingTags)) {
|
|
119
|
-
throw new Error(`<mg-popover> Slotted title must be a heading: ${headingTags.join(', ')}`);
|
|
120
|
-
}
|
|
121
|
-
// Set close button id
|
|
122
|
-
if (this.closeButton) {
|
|
123
|
-
this.closeButtonId = `${this.identifier}-close-button`;
|
|
124
|
-
}
|
|
125
|
-
// Get popover content
|
|
126
|
-
this.popover = this.element.querySelector(`#${this.identifier}`);
|
|
127
|
-
//Get interactive element
|
|
128
|
-
const interactiveElement = this.element.firstElementChild;
|
|
129
|
-
// Add aria attributes
|
|
130
|
-
interactiveElement.setAttribute('aria-controls', this.identifier);
|
|
131
|
-
interactiveElement.setAttribute('aria-expanded', `${this.display}`);
|
|
132
|
-
// Create popperjs popover
|
|
133
|
-
this.popper = popper.createPopper(interactiveElement, this.popover, {
|
|
134
|
-
placement: this.placement,
|
|
135
|
-
modifiers: [
|
|
136
|
-
{
|
|
137
|
-
name: 'offset',
|
|
138
|
-
options: {
|
|
139
|
-
offset: [0, 10],
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
});
|
|
144
|
-
// Add events to toggle display
|
|
145
|
-
interactiveElement.addEventListener('click', () => {
|
|
146
|
-
if (!this.disabled)
|
|
147
|
-
this.display = !this.display;
|
|
148
|
-
});
|
|
149
|
-
// Add events to hide popover
|
|
150
|
-
this.element.addEventListener('keydown', e => {
|
|
151
|
-
if (!this.disabled && e.code === 'Escape')
|
|
152
|
-
this.display = false;
|
|
153
|
-
});
|
|
154
|
-
this.handleDisplay(this.display);
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Render
|
|
158
|
-
*
|
|
159
|
-
* @returns {HTMLElement} HTML Element
|
|
160
|
-
*/
|
|
161
|
-
render() {
|
|
162
|
-
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { id: this.identifier, class: "mg-popover" }, !this.disabled && this.closeButton && (index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, index.h("mg-icon", { icon: "cross" }))), index.h("div", { class: "mg-popover__title" }, index.h("slot", { name: "title" })), index.h("slot", { name: "content" }), index.h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
163
|
-
}
|
|
164
|
-
get element() { return index.getElement(this); }
|
|
165
|
-
static get watchers() { return {
|
|
166
|
-
"display": ["handleDisplay"]
|
|
167
|
-
}; }
|
|
168
|
-
};
|
|
169
|
-
MgPopover.style = mgPopoverCss;
|
|
170
|
-
|
|
171
|
-
exports.mg_popover = MgPopover;
|