@mgdis/mg-components 5.0.0 → 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_24.cjs.entry.js → mg-badge_27.cjs.entry.js} +543 -64
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +8 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +39 -1
- 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-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 +2 -1
- 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-modal/mg-modal.css +2 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +52 -4
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +5 -14
- package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -5
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +3 -2
- package/dist/collection/utils/components.utils.js +10 -6
- package/dist/collection/variables.css +17 -2
- 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-button2.js +21 -2
- 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-modal.js +53 -5
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-popover.js +3 -2
- package/dist/components/mg-tooltip2.js +2 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mg-badge_24.entry.js → mg-badge_27.entry.js} +490 -14
- 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 +17 -2
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +6 -0
- 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-modal/mg-modal.d.ts +8 -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 +55 -6
- 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 -128
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +0 -20
- package/dist/esm/index-7efedd97.js +0 -238
- package/dist/esm/mg-modal.entry.js +0 -124
- package/dist/mg-components/p-5f89600c.js +0 -1
- package/dist/mg-components/p-b60a4c53.entry.js +0 -1
- package/dist/mg-components/p-df947fa5.entry.js +0 -1
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +0 -8
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["mg-
|
|
18
|
+
return index.bootstrapLazy([["mg-badge_27.cjs",[[1,"mg-panel",{"identifier":[1],"panelTitle":[1025,"panel-title"],"titlePattern":[1025,"title-pattern"],"titlePatternErrorMessage":[1025,"title-pattern-error-message"],"expanded":[1028],"expandToggleDisabled":[1028,"expand-toggle-disabled"],"titleEditable":[4,"title-editable"],"classList":[32],"isEditing":[32],"updatedPanelTitle":[32]}],[1,"mg-pagination",{"identifier":[1],"label":[1025],"totalPages":[2,"total-pages"],"currentPage":[1538,"current-page"]}],[1,"mg-input-textarea",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"maxlength":[2],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"pattern":[1],"patternErrorMessage":[1,"pattern-error-message"],"rows":[2],"tooltip":[1],"displayCharacterLeft":[4,"display-character-left"],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"resizable":[1],"classList":[32],"errorMessage":[32],"displayError":[64]}],[1,"mg-input-checkbox",{"value":[1040],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"inputVerticalList":[4,"input-vertical-list"],"required":[4],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"checkboxItems":[32],"displayError":[64]}],[1,"mg-input-date",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"required":[4],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"min":[1],"max":[1],"classList":[32],"errorMessage":[32],"displayError":[64]}],[1,"mg-input-numeric",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"tooltip":[1],"helpText":[1,"help-text"],"type":[1],"currency":[1],"max":[2],"min":[2],"integerLength":[2,"integer-length"],"decimalLength":[2,"decimal-length"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"hasFocus":[32],"displayError":[64]}],[1,"mg-input-password",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"displayError":[64]}],[1,"mg-input-radio",{"value":[1032],"items":[16],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"inputVerticalList":[4,"input-vertical-list"],"required":[4],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"options":[32],"displayError":[64]}],[1,"mg-input-toggle",{"value":[1032],"items":[16],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"isOnOff":[4,"is-on-off"],"isIcon":[4,"is-icon"],"readonly":[4],"disabled":[4],"tooltip":[1],"helpText":[1,"help-text"],"classList":[32],"options":[32],"checked":[32]}],[1,"mg-message",{"identifier":[1],"delay":[2],"variant":[1],"closeButton":[1028,"close-button"],"hide":[1028],"classList":[32],"hasActions":[32]}],[1,"mg-modal",{"identifier":[1],"modalTitle":[1,"modal-title"],"closeButton":[1028,"close-button"],"hide":[1028],"hasActions":[32],"hasContent":[32],"classList":[32]},[[8,"keydown","handleKeyDown"]]],[1,"mg-popover",{"identifier":[1],"placement":[1],"closeButton":[4,"close-button"],"display":[1028],"disabled":[1028]}],[1,"mg-tabs",{"identifier":[1],"label":[1],"size":[1],"items":[16],"activeTab":[1538,"active-tab"],"tabs":[32],"classList":[32]}],[1,"mg-details",{"toggleClosed":[1,"toggle-closed"],"toggleOpened":[1,"toggle-opened"],"hideSummary":[4,"hide-summary"],"expanded":[1028]}],[1,"mg-card"],[1,"mg-divider",{"size":[1]}],[1,"mg-form",{"identifier":[1],"name":[1],"readonly":[4],"disabled":[4],"valid":[1028],"invalid":[1028],"classList":[32],"displayError":[64]}],[1,"mg-illustrated-message",{"size":[1],"direction":[1]}],[1,"mg-tag",{"variant":[1],"outline":[4],"classList":[32]}],[1,"mg-input-text",{"value":[1537],"identifier":[1],"name":[1],"label":[1],"type":[1],"icon":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1],"maxlength":[2],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"pattern":[1],"patternErrorMessage":[1,"pattern-error-message"],"tooltip":[1],"displayCharacterLeft":[4,"display-character-left"],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"setFocus":[64],"displayError":[64]}],[1,"mg-input-select",{"value":[1032],"items":[16],"identifier":[1],"name":[1],"label":[1],"labelOnTop":[4,"label-on-top"],"labelHide":[4,"label-hide"],"placeholder":[1025],"placeholderHide":[4,"placeholder-hide"],"placeholderDisabled":[4,"placeholder-disabled"],"required":[4],"readonly":[4],"disabled":[4],"mgWidth":[8,"mg-width"],"tooltip":[1],"helpText":[1,"help-text"],"valid":[1028],"invalid":[1028],"classList":[32],"errorMessage":[32],"options":[32],"valueExist":[32],"readonlyValue":[32],"displayError":[64]}],[1,"mg-badge",{"value":[1032],"label":[1],"variant":[1],"outline":[4],"classList":[32]}],[2,"mg-character-left",{"identifier":[1],"characters":[1],"maxlength":[2]}],[1,"mg-button",{"variant":[1],"identifier":[1],"label":[1],"type":[1],"fullWidth":[1028,"full-width"],"form":[1025],"disabled":[1028],"isIcon":[4,"is-icon"],"disableOnClick":[4,"disable-on-click"],"loading":[32],"classList":[32]}],[6,"mg-input-title",{"identifier":[1],"required":[4],"isLegend":[4,"is-legend"],"tagName":[32]}],[1,"mg-tooltip",{"identifier":[1],"message":[1],"placement":[1],"display":[1028],"disabled":[1028]}],[1,"mg-icon",{"icon":[1],"size":[1],"variant":[1],"spin":[4],"classList":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
"entries": [
|
|
3
3
|
"./components/atoms/mg-badge/mg-badge.js",
|
|
4
4
|
"./components/atoms/mg-button/mg-button.js",
|
|
5
|
+
"./components/atoms/mg-card/mg-card.js",
|
|
5
6
|
"./components/atoms/mg-character-left/mg-character-left.js",
|
|
7
|
+
"./components/atoms/mg-divider/mg-divider.js",
|
|
6
8
|
"./components/atoms/mg-icon/mg-icon.js",
|
|
7
9
|
"./components/atoms/mg-input-title/mg-input-title.js",
|
|
8
10
|
"./components/atoms/mg-tag/mg-tag.js",
|
|
@@ -37,6 +37,7 @@ MgButton.args = {
|
|
|
37
37
|
disableOnClick: false,
|
|
38
38
|
isIcon: false,
|
|
39
39
|
type: undefined,
|
|
40
|
+
fullWidth: undefined,
|
|
40
41
|
};
|
|
41
42
|
export const IsIcon = Template.bind({});
|
|
42
43
|
IsIcon.args = Object.assign(Object.assign({}, MgButton.args), { isIcon: true, slot: h("mg-icon", { icon: Object.keys(icons)[0] }) });
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
background: hsla(var(--color-dark), 0.1);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
:host([full-width]) {
|
|
25
|
+
display: block;
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
.mg-button.mg-button--primary {
|
|
25
29
|
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%)));
|
|
26
30
|
color: hsl(var(--mg-button-primary-font-color));
|
|
@@ -140,6 +144,10 @@
|
|
|
140
144
|
background: none;
|
|
141
145
|
border: none;
|
|
142
146
|
}
|
|
147
|
+
.mg-button.mg-button--full-width {
|
|
148
|
+
display: flex;
|
|
149
|
+
justify-content: center;
|
|
150
|
+
}
|
|
143
151
|
.mg-button.mg-button--loading > mg-icon:first-of-type {
|
|
144
152
|
position: absolute;
|
|
145
153
|
left: 50%;
|
|
@@ -9,10 +9,15 @@ export class MgButton {
|
|
|
9
9
|
this.onClickElementFn = null;
|
|
10
10
|
this.classDisabled = 'mg-button--disabled';
|
|
11
11
|
this.classLoading = 'mg-button--loading';
|
|
12
|
+
this.classFullWidth = 'mg-button--full-width';
|
|
12
13
|
/**
|
|
13
14
|
* Define button variant
|
|
14
15
|
*/
|
|
15
16
|
this.variant = variants[0]; // Primary
|
|
17
|
+
/**
|
|
18
|
+
* Set button to full-width
|
|
19
|
+
*/
|
|
20
|
+
this.fullWidth = false;
|
|
16
21
|
/**
|
|
17
22
|
* Define if button is round.
|
|
18
23
|
* Used for icon button.
|
|
@@ -87,6 +92,17 @@ export class MgButton {
|
|
|
87
92
|
this.classList.add(`mg-button--${newValue}`);
|
|
88
93
|
}
|
|
89
94
|
}
|
|
95
|
+
validateFullWidth(newValue) {
|
|
96
|
+
if (newValue && this.isIcon) {
|
|
97
|
+
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
98
|
+
}
|
|
99
|
+
else if (newValue) {
|
|
100
|
+
this.classList.add(this.classFullWidth);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.classList.delete(this.classFullWidth);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
90
106
|
disabledHandler(isDisabled) {
|
|
91
107
|
// Remove loading when enable
|
|
92
108
|
// Will be set back onclick
|
|
@@ -119,6 +135,7 @@ export class MgButton {
|
|
|
119
135
|
*/
|
|
120
136
|
componentWillLoad() {
|
|
121
137
|
this.validateVariant(this.variant);
|
|
138
|
+
this.validateFullWidth(this.fullWidth);
|
|
122
139
|
if (this.isIcon) {
|
|
123
140
|
this.classList.add(`mg-button--icon`);
|
|
124
141
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
@@ -135,7 +152,7 @@ export class MgButton {
|
|
|
135
152
|
* @returns {HTMLElement} html element
|
|
136
153
|
*/
|
|
137
154
|
render() {
|
|
138
|
-
return (h(Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "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)))));
|
|
155
|
+
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)))));
|
|
139
156
|
}
|
|
140
157
|
static get is() { return "mg-button"; }
|
|
141
158
|
static get encapsulation() { return "shadow"; }
|
|
@@ -230,6 +247,24 @@ export class MgButton {
|
|
|
230
247
|
"attribute": "type",
|
|
231
248
|
"reflect": false
|
|
232
249
|
},
|
|
250
|
+
"fullWidth": {
|
|
251
|
+
"type": "boolean",
|
|
252
|
+
"mutable": true,
|
|
253
|
+
"complexType": {
|
|
254
|
+
"original": "boolean",
|
|
255
|
+
"resolved": "boolean",
|
|
256
|
+
"references": {}
|
|
257
|
+
},
|
|
258
|
+
"required": false,
|
|
259
|
+
"optional": false,
|
|
260
|
+
"docs": {
|
|
261
|
+
"tags": [],
|
|
262
|
+
"text": "Set button to full-width"
|
|
263
|
+
},
|
|
264
|
+
"attribute": "full-width",
|
|
265
|
+
"reflect": false,
|
|
266
|
+
"defaultValue": "false"
|
|
267
|
+
},
|
|
233
268
|
"form": {
|
|
234
269
|
"type": "string",
|
|
235
270
|
"mutable": true,
|
|
@@ -313,6 +348,9 @@ export class MgButton {
|
|
|
313
348
|
return [{
|
|
314
349
|
"propName": "variant",
|
|
315
350
|
"methodName": "validateVariant"
|
|
351
|
+
}, {
|
|
352
|
+
"propName": "fullWidth",
|
|
353
|
+
"methodName": "validateFullWidth"
|
|
316
354
|
}, {
|
|
317
355
|
"propName": "disabled",
|
|
318
356
|
"methodName": "disabledHandler"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
import { filterArgs } from '../../../../../.storybook/utils';
|
|
3
|
+
export default {
|
|
4
|
+
component: 'mg-card',
|
|
5
|
+
title: 'Atoms/mg-card',
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Template
|
|
9
|
+
*
|
|
10
|
+
* @param {any} args component arguments
|
|
11
|
+
* @returns {HTMLElement} HTMLElement
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
const Template = (args) => h("mg-card", Object.assign({}, filterArgs(args)), args.slot);
|
|
15
|
+
export const MgCard = Template.bind({});
|
|
16
|
+
MgCard.args = {
|
|
17
|
+
slot: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
|
|
18
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export class MgCard {
|
|
3
|
+
/*************
|
|
4
|
+
* Lifecycle *
|
|
5
|
+
*************/
|
|
6
|
+
/**
|
|
7
|
+
* Render
|
|
8
|
+
*
|
|
9
|
+
* @returns {HTMLElement} HTML Element
|
|
10
|
+
*/
|
|
11
|
+
render() {
|
|
12
|
+
return (h("div", { class: "mg-card" }, h("slot", null)));
|
|
13
|
+
}
|
|
14
|
+
static get is() { return "mg-card"; }
|
|
15
|
+
static get encapsulation() { return "shadow"; }
|
|
16
|
+
static get originalStyleUrls() {
|
|
17
|
+
return {
|
|
18
|
+
"$": ["mg-card.scss"]
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
static get styleUrls() {
|
|
22
|
+
return {
|
|
23
|
+
"$": ["mg-card.css"]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
import { filterArgs } from '../../../../../.storybook/utils';
|
|
3
|
+
export default {
|
|
4
|
+
component: 'mg-divider',
|
|
5
|
+
title: 'Atoms/mg-divider',
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Template
|
|
9
|
+
*
|
|
10
|
+
* @param {any} args component arguments
|
|
11
|
+
* @returns {HTMLElement} HTMLElement
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
const Template = (args) => h("mg-divider", Object.assign({}, filterArgs(args, { size: 'regular' })));
|
|
15
|
+
export const MgDivider = Template.bind({});
|
|
16
|
+
MgDivider.args = {
|
|
17
|
+
size: 'regular',
|
|
18
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export class MgDivider {
|
|
3
|
+
constructor() {
|
|
4
|
+
/**************
|
|
5
|
+
* Decorators *
|
|
6
|
+
**************/
|
|
7
|
+
/**
|
|
8
|
+
* Define component size
|
|
9
|
+
*/
|
|
10
|
+
this.size = 'regular';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Render
|
|
14
|
+
*
|
|
15
|
+
* @returns {HTMLElement} HTML Element
|
|
16
|
+
*/
|
|
17
|
+
render() {
|
|
18
|
+
return (h("div", { class: {
|
|
19
|
+
'mg-divider': true,
|
|
20
|
+
'mg-divider--full': this.size === 'full',
|
|
21
|
+
} }));
|
|
22
|
+
}
|
|
23
|
+
static get is() { return "mg-divider"; }
|
|
24
|
+
static get encapsulation() { return "shadow"; }
|
|
25
|
+
static get originalStyleUrls() {
|
|
26
|
+
return {
|
|
27
|
+
"$": ["mg-divider.scss"]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
static get styleUrls() {
|
|
31
|
+
return {
|
|
32
|
+
"$": ["mg-divider.css"]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
static get properties() {
|
|
36
|
+
return {
|
|
37
|
+
"size": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"mutable": false,
|
|
40
|
+
"complexType": {
|
|
41
|
+
"original": "'regular' | 'full'",
|
|
42
|
+
"resolved": "\"full\" | \"regular\"",
|
|
43
|
+
"references": {}
|
|
44
|
+
},
|
|
45
|
+
"required": false,
|
|
46
|
+
"optional": false,
|
|
47
|
+
"docs": {
|
|
48
|
+
"tags": [],
|
|
49
|
+
"text": "Define component size"
|
|
50
|
+
},
|
|
51
|
+
"attribute": "size",
|
|
52
|
+
"reflect": false,
|
|
53
|
+
"defaultValue": "'regular'"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
2
|
import { filterArgs } from '../../../../../.storybook/utils';
|
|
3
|
-
import { placements } from '../mg-tooltip.conf';
|
|
4
3
|
export default {
|
|
5
4
|
component: 'mg-tooltip',
|
|
6
5
|
title: 'Atoms/mg-tooltip',
|
|
@@ -9,11 +8,7 @@ export default {
|
|
|
9
8
|
},
|
|
10
9
|
argTypes: {
|
|
11
10
|
placement: {
|
|
12
|
-
options: placements,
|
|
13
11
|
control: { type: 'select' },
|
|
14
|
-
table: {
|
|
15
|
-
defaultValue: { summary: 'bottom' },
|
|
16
|
-
},
|
|
17
12
|
},
|
|
18
13
|
},
|
|
19
14
|
};
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* List of all possibles placements
|
|
3
|
-
*/
|
|
4
|
-
export const placements = [
|
|
5
|
-
'auto',
|
|
6
|
-
'auto-start',
|
|
7
|
-
'auto-end',
|
|
8
|
-
'top',
|
|
9
|
-
'top-start',
|
|
10
|
-
'top-end',
|
|
11
|
-
'bottom',
|
|
12
|
-
'bottom-start',
|
|
13
|
-
'bottom-end',
|
|
14
|
-
'right',
|
|
15
|
-
'right-start',
|
|
16
|
-
'right-end',
|
|
17
|
-
'left',
|
|
18
|
-
'left-start',
|
|
19
|
-
'left-end',
|
|
20
|
-
];
|
|
21
1
|
export var Guard;
|
|
22
2
|
(function (Guard) {
|
|
23
3
|
Guard["FOCUS"] = "focus";
|
|
@@ -136,6 +136,7 @@ export class MgTooltip {
|
|
|
136
136
|
// Create popperjs tooltip
|
|
137
137
|
this.popper = createPopper(tooltipedElement, this.tooltip, {
|
|
138
138
|
placement: this.placement,
|
|
139
|
+
strategy: 'fixed',
|
|
139
140
|
modifiers: [
|
|
140
141
|
{
|
|
141
142
|
name: 'offset',
|
|
@@ -241,7 +242,7 @@ export class MgTooltip {
|
|
|
241
242
|
"references": {
|
|
242
243
|
"Placement": {
|
|
243
244
|
"location": "import",
|
|
244
|
-
"path": "
|
|
245
|
+
"path": "@popperjs/core"
|
|
245
246
|
}
|
|
246
247
|
}
|
|
247
248
|
},
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A11Y
|
|
3
|
+
*/
|
|
4
|
+
.sr-only {
|
|
5
|
+
border: 0 !important;
|
|
6
|
+
clip: rect(1px, 1px, 1px, 1px) !important;
|
|
7
|
+
-webkit-clip-path: inset(50%) !important;
|
|
8
|
+
clip-path: inset(50%) !important;
|
|
9
|
+
height: 1px !important;
|
|
10
|
+
margin: -1px !important;
|
|
11
|
+
overflow: hidden !important;
|
|
12
|
+
padding: 0 !important;
|
|
13
|
+
position: absolute !important;
|
|
14
|
+
width: 1px !important;
|
|
15
|
+
white-space: nowrap !important;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
*:focus:not(:focus-visible) {
|
|
19
|
+
outline: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
1
22
|
.mg-details summary {
|
|
2
23
|
display: flex;
|
|
3
24
|
align-items: baseline;
|
|
@@ -7,6 +28,14 @@
|
|
|
7
28
|
.mg-details__toggle {
|
|
8
29
|
margin-left: 1.5rem;
|
|
9
30
|
flex-shrink: 0;
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
align-self: flex-start;
|
|
34
|
+
gap: 0.6rem;
|
|
35
|
+
min-height: calc(var(--font-size) * var(--line-height));
|
|
36
|
+
}
|
|
37
|
+
.mg-details__toggle mg-icon {
|
|
38
|
+
align-self: self-end;
|
|
10
39
|
}
|
|
11
40
|
|
|
12
41
|
.mg-details__details {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
2
|
export class MgDetails {
|
|
3
3
|
constructor() {
|
|
4
|
+
/**
|
|
5
|
+
* Hide summary element
|
|
6
|
+
*/
|
|
7
|
+
this.hideSummary = false;
|
|
4
8
|
/**
|
|
5
9
|
* Define if details are diplayed
|
|
6
10
|
*/
|
|
@@ -15,7 +19,7 @@ export class MgDetails {
|
|
|
15
19
|
};
|
|
16
20
|
}
|
|
17
21
|
validateTitles(newValue) {
|
|
18
|
-
if (newValue === undefined || newValue === '') {
|
|
22
|
+
if (newValue === undefined || newValue.trim() === '') {
|
|
19
23
|
throw new Error('<mg-details> prop "toggleClosed" and "toggleOpened" must be defined.');
|
|
20
24
|
}
|
|
21
25
|
}
|
|
@@ -40,7 +44,7 @@ export class MgDetails {
|
|
|
40
44
|
* @returns {HTMLElement} HTML Element
|
|
41
45
|
*/
|
|
42
46
|
render() {
|
|
43
|
-
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' }), "
|
|
47
|
+
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" }))));
|
|
44
48
|
}
|
|
45
49
|
static get is() { return "mg-details"; }
|
|
46
50
|
static get encapsulation() { return "shadow"; }
|
|
@@ -64,7 +68,7 @@ export class MgDetails {
|
|
|
64
68
|
"resolved": "string",
|
|
65
69
|
"references": {}
|
|
66
70
|
},
|
|
67
|
-
"required":
|
|
71
|
+
"required": true,
|
|
68
72
|
"optional": false,
|
|
69
73
|
"docs": {
|
|
70
74
|
"tags": [],
|
|
@@ -81,7 +85,7 @@ export class MgDetails {
|
|
|
81
85
|
"resolved": "string",
|
|
82
86
|
"references": {}
|
|
83
87
|
},
|
|
84
|
-
"required":
|
|
88
|
+
"required": true,
|
|
85
89
|
"optional": false,
|
|
86
90
|
"docs": {
|
|
87
91
|
"tags": [],
|
|
@@ -90,6 +94,24 @@ export class MgDetails {
|
|
|
90
94
|
"attribute": "toggle-opened",
|
|
91
95
|
"reflect": false
|
|
92
96
|
},
|
|
97
|
+
"hideSummary": {
|
|
98
|
+
"type": "boolean",
|
|
99
|
+
"mutable": false,
|
|
100
|
+
"complexType": {
|
|
101
|
+
"original": "boolean",
|
|
102
|
+
"resolved": "boolean",
|
|
103
|
+
"references": {}
|
|
104
|
+
},
|
|
105
|
+
"required": false,
|
|
106
|
+
"optional": false,
|
|
107
|
+
"docs": {
|
|
108
|
+
"tags": [],
|
|
109
|
+
"text": "Hide summary element"
|
|
110
|
+
},
|
|
111
|
+
"attribute": "hide-summary",
|
|
112
|
+
"reflect": false,
|
|
113
|
+
"defaultValue": "false"
|
|
114
|
+
},
|
|
93
115
|
"expanded": {
|
|
94
116
|
"type": "boolean",
|
|
95
117
|
"mutable": true,
|
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
right: 0;
|
|
8
8
|
bottom: 0;
|
|
9
9
|
left: 0;
|
|
10
|
-
z-index:
|
|
10
|
+
z-index: 2000;
|
|
11
11
|
padding: 2rem 0;
|
|
12
12
|
background-color: hsla(var(--color-light), 85%);
|
|
13
13
|
}
|
|
14
14
|
.mg-modal__dialog {
|
|
15
15
|
display: flex;
|
|
16
|
+
position: relative;
|
|
16
17
|
flex-direction: column;
|
|
17
18
|
align-self: center;
|
|
18
19
|
row-gap: 3rem;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
-
import { createID, ClassList } from '../../../utils/components.utils';
|
|
2
|
+
import { createID, ClassList, focusableElements } from '../../../utils/components.utils';
|
|
3
3
|
import { initLocales } from '../../../locales';
|
|
4
4
|
export class MgModal {
|
|
5
5
|
constructor() {
|
|
6
|
-
/************
|
|
7
|
-
* Internal *
|
|
8
|
-
************/
|
|
9
6
|
// Classes
|
|
10
7
|
this.classHide = 'mg-modal--hide';
|
|
11
8
|
// IDs
|
|
@@ -36,6 +33,37 @@ export class MgModal {
|
|
|
36
33
|
* Component classes
|
|
37
34
|
*/
|
|
38
35
|
this.classList = new ClassList(['mg-modal']);
|
|
36
|
+
this.setFocus = () => {
|
|
37
|
+
// Get all focusable elements
|
|
38
|
+
this.modalFocusableElements = Array.from(this.element.querySelectorAll(focusableElements)).reduce((acc, focusableElement) => {
|
|
39
|
+
acc.push(focusableElement.shadowRoot !== null ? focusableElement.shadowRoot.querySelector(focusableElements) || focusableElement : focusableElement);
|
|
40
|
+
return acc;
|
|
41
|
+
}, []);
|
|
42
|
+
// When close button is enabled it's the first focusable element.
|
|
43
|
+
if (this.closeButton) {
|
|
44
|
+
this.modalFocusableElements.unshift(this.element.shadowRoot.querySelector(`.mg-modal__close-button mg-button`));
|
|
45
|
+
}
|
|
46
|
+
// It at least one
|
|
47
|
+
if (this.modalFocusableElements.length >= 1) {
|
|
48
|
+
// Set focus on first element
|
|
49
|
+
this.modalFocusableElements[0].focus();
|
|
50
|
+
// Add event listener on last element
|
|
51
|
+
const lastFocusableElement = this.modalFocusableElements[this.modalFocusableElements.length - 1];
|
|
52
|
+
lastFocusableElement.addEventListener('keydown', event => {
|
|
53
|
+
if (event.key === 'Tab' && !event.shiftKey) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
this.modalFocusableElements[0].focus();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
// Add event listener on first element (case shift + tab)
|
|
59
|
+
this.modalFocusableElements[0].addEventListener('keydown', event => {
|
|
60
|
+
if (event.key === 'Tab' && event.shiftKey) {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
lastFocusableElement.focus();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
};
|
|
39
67
|
/*************
|
|
40
68
|
* Handlers *
|
|
41
69
|
*************/
|
|
@@ -100,6 +128,26 @@ export class MgModal {
|
|
|
100
128
|
this.validateModalTitle(this.modalTitle);
|
|
101
129
|
this.validateHide(this.hide);
|
|
102
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Add observer on component to set focus when displayed
|
|
133
|
+
*
|
|
134
|
+
* @returns {void}
|
|
135
|
+
*/
|
|
136
|
+
componentDidLoad() {
|
|
137
|
+
new MutationObserver(mutationList => {
|
|
138
|
+
/*
|
|
139
|
+
TODO find a way to cover this callback
|
|
140
|
+
*/
|
|
141
|
+
/* istanbul ignore next */
|
|
142
|
+
if (mutationList.some(mutation => mutation.attributeName === 'aria-hidden' && mutation.target.ariaHidden === null)) {
|
|
143
|
+
this.setFocus();
|
|
144
|
+
}
|
|
145
|
+
}).observe(this.element.shadowRoot.getElementById(this.identifier), { attributes: true });
|
|
146
|
+
// Set focus if display on load
|
|
147
|
+
if (!this.hide) {
|
|
148
|
+
this.setFocus();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
103
151
|
/**
|
|
104
152
|
* Render
|
|
105
153
|
*
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
.mg-panel {
|
|
2
2
|
background-color: hsl(var(--mg-panel-background));
|
|
3
3
|
border-radius: var(--mg-panel-border-radius);
|
|
4
|
-
box-shadow: var(--box-shadow);
|
|
4
|
+
box-shadow: var(--mg-panel-box-shadow);
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
.mg-panel__header {
|
|
8
7
|
display: flex;
|
|
9
8
|
flex-wrap: wrap;
|
|
@@ -11,22 +10,14 @@
|
|
|
11
10
|
padding: 0 1rem 0 0.3rem;
|
|
12
11
|
align-items: flex-start;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
.mg-panel__header-left,
|
|
16
|
-
.mg-panel__header-right {
|
|
13
|
+
.mg-panel__header-left, .mg-panel__header-right {
|
|
17
14
|
display: flex;
|
|
18
15
|
margin: 0.3rem 0;
|
|
19
16
|
}
|
|
20
|
-
|
|
21
|
-
.mg-panel__header-left--full {
|
|
22
|
-
flex: 1 1 auto;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
17
|
.mg-panel__header-right {
|
|
26
18
|
padding-left: 0.3rem;
|
|
27
19
|
flex: 1 auto;
|
|
28
20
|
}
|
|
29
|
-
|
|
30
21
|
.mg-panel__header-left mg-input-text {
|
|
31
22
|
flex-grow: 1;
|
|
32
23
|
margin-left: 0.3rem;
|
|
@@ -34,16 +25,16 @@
|
|
|
34
25
|
.mg-panel__header-left mg-button + mg-button:not([slot=append-input]) {
|
|
35
26
|
margin-left: 0.3rem;
|
|
36
27
|
}
|
|
37
|
-
|
|
28
|
+
.mg-panel__header-left.mg-panel__header-left--full {
|
|
29
|
+
flex: 1 1 auto;
|
|
30
|
+
}
|
|
38
31
|
.mg-panel__collapse-button-content {
|
|
39
32
|
--font-size: 1.4rem;
|
|
40
33
|
--mg-button-font-weight: 600;
|
|
41
34
|
}
|
|
42
|
-
|
|
43
35
|
.mg-panel__content {
|
|
44
36
|
padding: var(--mg-panel-content-padding);
|
|
45
37
|
}
|
|
46
|
-
|
|
47
38
|
.mg-panel ::slotted([slot=header-right]) {
|
|
48
39
|
display: flex;
|
|
49
40
|
flex-wrap: wrap;
|