@mgdis/mg-components 3.1.0 → 4.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-85a4a0b6.js → index-88560a66.js} +123 -48
- package/dist/cjs/index-a39c5567.js +233 -0
- package/dist/cjs/loader.cjs.js +3 -17
- package/dist/cjs/mg-badge_21.cjs.entry.js +3538 -0
- package/dist/cjs/mg-components.cjs.js +3 -7
- package/dist/cjs/mg-modal.cjs.entry.js +117 -0
- package/dist/cjs/mg-popover.cjs.entry.js +170 -0
- package/dist/cjs/popper-71bf3058.js +1790 -0
- package/dist/collection/collection-manifest.json +4 -1
- package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.js} +4 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -2
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +26 -10
- package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +7 -2
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.css +46 -49
- package/dist/collection/components/atoms/mg-button/mg-button.js +78 -4
- package/dist/collection/components/atoms/mg-character-left/{mg-character-left.stories.js → doc/mg-character-left.stories.js} +8 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +20 -46
- package/dist/collection/components/atoms/mg-icon/{mg-icon.stories.js → doc/mg-icon.stories.js} +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +104 -9
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +9 -7
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +33 -7
- package/dist/collection/components/atoms/mg-input-title/{mg-input-title.stories.js → doc/mg-input-title.stories.js} +0 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +4 -4
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +14 -3
- package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +4 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +28 -6
- package/dist/collection/components/atoms/mg-tooltip/{mg-tooltip.stories.js → doc/mg-tooltip.stories.js} +14 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +20 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +16 -2
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
- package/dist/collection/components/molecules/inputs/MgInput.js +25 -29
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +25 -11
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +102 -52
- package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +37 -9
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +136 -66
- package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +15 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +38 -10
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +180 -80
- package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +16 -2
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +37 -9
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +108 -47
- package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +25 -11
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +113 -42
- package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +22 -2
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +39 -10
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +145 -71
- package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +17 -8
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +69 -19
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +184 -83
- package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +16 -5
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +69 -13
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +163 -70
- package/dist/collection/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.js → doc/mg-input-toggle.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +22 -10
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +68 -33
- package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +58 -0
- package/dist/collection/components/molecules/mg-form/mg-form.css +19 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +271 -0
- package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +6 -2
- package/dist/collection/components/molecules/mg-message/mg-message.css +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +26 -11
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +51 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +52 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +240 -0
- package/dist/collection/components/molecules/mg-pagination/{mg-pagination.stories.js → doc/mg-pagination.stories.js} +1 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +47 -28
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +39 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +53 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +356 -0
- package/dist/collection/components/molecules/mg-popover/{mg-popover.stories.js → doc/mg-popover.stories.js} +10 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +20 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +37 -12
- package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +20 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +11 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +17 -3
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +139 -26
- package/dist/collection/locales/index.js +33 -4
- package/dist/collection/stories/helpers.stories.js +33 -0
- package/dist/collection/utils/components.utils.js +16 -9
- package/dist/collection/utils/locale.utils.js +13 -7
- package/dist/collection/utils/test.utils.js +27 -15
- package/dist/collection/variables.css +39 -5
- package/dist/collection/variables.scss +39 -5
- package/dist/components/MgInput.js +26 -37
- package/dist/components/components.utils.js +16 -9
- package/dist/components/index.d.ts +24 -6
- package/dist/components/index.js +23 -0
- package/dist/components/index2.js +116 -17
- package/dist/components/locale.utils.js +13 -8
- package/dist/components/mg-badge2.js +25 -9
- package/dist/components/mg-button2.js +29 -5
- package/dist/components/mg-character-left2.js +14 -26
- package/dist/components/mg-form.d.ts +11 -0
- package/dist/components/mg-form.js +148 -0
- package/dist/components/mg-icon2.js +138 -17
- package/dist/components/mg-input-checkbox.js +66 -53
- package/dist/components/mg-input-date.js +100 -69
- package/dist/components/mg-input-numeric.js +125 -81
- package/dist/components/mg-input-password.js +69 -48
- package/dist/components/mg-input-radio.js +74 -46
- package/dist/components/mg-input-select2.js +103 -71
- package/dist/components/mg-input-text.js +1 -237
- package/dist/components/mg-input-text2.js +300 -0
- package/dist/components/mg-input-textarea.js +100 -46
- package/dist/components/mg-input-title2.js +13 -4
- package/dist/components/mg-input-toggle.js +39 -31
- package/dist/components/mg-message.js +25 -10
- package/dist/components/mg-modal.d.ts +11 -0
- package/dist/components/mg-modal.js +153 -0
- package/dist/components/mg-pagination.js +45 -31
- package/dist/components/mg-panel.d.ts +11 -0
- package/dist/components/mg-panel.js +244 -0
- package/dist/components/mg-popover.js +31 -11
- package/dist/components/mg-tabs.js +113 -23
- package/dist/components/mg-tag.js +27 -5
- package/dist/components/mg-tooltip2.js +10 -1
- package/dist/components/popper.js +6 -2
- package/dist/esm/{index-e3e84606.js → index-bca81100.js} +124 -46
- package/dist/esm/index-e51ae032.js +228 -0
- package/dist/esm/loader.js +3 -17
- package/dist/esm/mg-badge_21.entry.js +3514 -0
- package/dist/esm/mg-components.js +3 -7
- package/dist/esm/mg-modal.entry.js +113 -0
- package/dist/esm/mg-popover.entry.js +166 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/popper-93ecb064.js +1788 -0
- package/dist/index.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-003a1344.entry.js +1 -0
- package/dist/mg-components/p-462d648a.entry.js +1 -0
- package/dist/mg-components/p-4c66f794.js +1 -0
- package/dist/mg-components/p-5126ab10.entry.js +1 -0
- package/dist/mg-components/p-780bd52d.js +1 -0
- package/dist/mg-components/p-b14a3443.js +2 -0
- package/dist/mg-components/variables.css +39 -5
- package/dist/mg-components/variables.scss +39 -5
- package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +16 -5
- package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +23 -3
- package/dist/types/components/atoms/mg-character-left/{mg-character-left.stories.d.ts → doc/mg-character-left.stories.d.ts} +9 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +16 -13
- package/dist/types/components/atoms/mg-icon/{mg-icon.stories.d.ts → doc/mg-icon.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +14 -4
- package/dist/types/components/atoms/mg-input-title/{mg-input-title.stories.d.ts → doc/mg-input-title.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +11 -1
- package/dist/types/components/atoms/mg-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +18 -4
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +29 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +13 -3
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +6 -4
- package/dist/types/components/molecules/inputs/MgInput.d.ts +7 -8
- package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +36 -13
- package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +46 -15
- package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +11 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +61 -16
- package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +22 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +35 -11
- package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +42 -9
- package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +34 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +37 -9
- package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +13 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +52 -16
- package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +45 -17
- package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +29 -12
- package/dist/types/components/molecules/{mg-popover/mg-popover.stories.d.ts → mg-form/doc/mg-form.stories.d.ts} +3 -4
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +83 -0
- package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +10 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +13 -4
- package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +13 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +85 -0
- package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +5 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +31 -7
- package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +11 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +139 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +25 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +8 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +27 -4
- package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +20 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +11 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +70 -6
- package/dist/types/components.d.ts +528 -211
- package/dist/types/locales/index.d.ts +108 -38
- package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
- package/dist/types/utils/components.utils.d.ts +16 -9
- package/dist/types/utils/locale.utils.d.ts +13 -6
- package/dist/types/utils/test.utils.d.ts +13 -1
- package/loader/index.js +1 -1
- package/package.json +45 -14
- package/readme.md +9 -35
- package/dist/cjs/css-shim-a22512c4.js +0 -6
- package/dist/cjs/mg-badge_20.cjs.entry.js +0 -4661
- package/dist/cjs/shadow-css-8940f82d.js +0 -390
- package/dist/collection/stories/buttons.stories.js +0 -43
- package/dist/collection/stories/messages.stories.js +0 -44
- package/dist/collection/stories/tags.stories.js +0 -13
- package/dist/esm/css-shim-7c240feb.js +0 -4
- package/dist/esm/mg-badge_20.entry.js +0 -4638
- package/dist/esm/shadow-css-5d2d01ce.js +0 -388
- package/dist/esm-es5/css-shim-7c240feb.js +0 -1
- package/dist/esm-es5/index-e3e84606.js +0 -1
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +0 -1
- package/dist/esm-es5/mg-badge_20.entry.js +0 -2
- package/dist/esm-es5/mg-components.js +0 -1
- package/dist/esm-es5/shadow-css-5d2d01ce.js +0 -12
- package/dist/mg-components/mg-components.js +0 -132
- package/dist/mg-components/p-1cd24462.system.js +0 -1
- package/dist/mg-components/p-2e2f6b27.system.entry.js +0 -2
- package/dist/mg-components/p-366a224e.js +0 -1
- package/dist/mg-components/p-422c429b.system.js +0 -1
- package/dist/mg-components/p-50ea2036.system.js +0 -1
- package/dist/mg-components/p-62fa3797.js +0 -1
- package/dist/mg-components/p-71d57b8b.system.js +0 -13
- package/dist/mg-components/p-9a215712.system.js +0 -1
- package/dist/mg-components/p-cbf0464b.entry.js +0 -1
- package/dist/mg-components/p-f6455ab3.js +0 -12
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +0 -9
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +0 -14
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +0 -7
- package/dist/types/stories/messages.stories.d.ts +0 -13
- package/dist/types/stories/tags.stories.d.ts +0 -5
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
.mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button {
|
|
2
|
+
padding: calc(1rem + 0.3rem) calc(1rem * 1.3) 1rem;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button {
|
|
6
|
+
padding: calc(1.8rem + 0.3rem) calc(1.8rem * 1.3) 1.8rem;
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
.mg-tabs__header {
|
|
2
10
|
display: flex;
|
|
3
11
|
flex-direction: row;
|
|
@@ -8,7 +16,6 @@
|
|
|
8
16
|
display: flex;
|
|
9
17
|
align-items: center;
|
|
10
18
|
column-gap: 0.5rem;
|
|
11
|
-
padding: 1.8rem 2.4rem 1.5rem;
|
|
12
19
|
background: none;
|
|
13
20
|
border: none;
|
|
14
21
|
border-bottom: 0.3rem solid transparent;
|
|
@@ -16,7 +23,11 @@
|
|
|
16
23
|
line-height: var(--line-height);
|
|
17
24
|
cursor: pointer;
|
|
18
25
|
}
|
|
19
|
-
.mg-tabs__navigation-button:
|
|
26
|
+
.mg-tabs__navigation-button:disabled, .mg-tabs__navigation-button--disabled {
|
|
27
|
+
cursor: default;
|
|
28
|
+
opacity: 30%;
|
|
29
|
+
}
|
|
30
|
+
.mg-tabs__navigation-button:hover:not(:disabled), .mg-tabs__navigation-button:focus:not(:disabled) {
|
|
20
31
|
background-color: hsla(var(--color-info-h), var(--color-info-s), var(--color-info-l), 10%);
|
|
21
32
|
}
|
|
22
33
|
.mg-tabs__navigation-button.mg-tabs__navigation-button--active {
|
|
@@ -24,7 +35,10 @@
|
|
|
24
35
|
border-bottom-color: hsl(var(--color-info));
|
|
25
36
|
font-weight: 700;
|
|
26
37
|
}
|
|
38
|
+
.mg-tabs__navigation-button.mg-tabs__navigation-button--hidden {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
27
41
|
|
|
28
42
|
.mg-tabs__content-container:focus-visible {
|
|
29
|
-
outline
|
|
43
|
+
outline: none;
|
|
30
44
|
}
|
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
import { Component, h, Host, Prop, State, Element, Watch } from '@stencil/core';
|
|
1
|
+
import { Component, Event, h, Host, Prop, State, Element, Watch } from '@stencil/core';
|
|
2
2
|
import { createID, ClassList, allItemsAreString } from '../../../utils/components.utils';
|
|
3
|
+
import { sizes, Status } from './mg-tabs.conf';
|
|
3
4
|
/**
|
|
4
5
|
* type TabItem validation function
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
6
|
+
*
|
|
7
|
+
* @param {TabItem} tab tab item
|
|
8
|
+
* @returns {boolean} tab item type is valid
|
|
7
9
|
*/
|
|
8
10
|
const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
|
|
9
11
|
export class MgTabs {
|
|
10
12
|
constructor() {
|
|
13
|
+
/************
|
|
14
|
+
* Internal *
|
|
15
|
+
************/
|
|
16
|
+
this.tabPanel = 'panel';
|
|
17
|
+
this.startIndex = 1;
|
|
18
|
+
this.buttonTabBaseClass = 'mg-tabs__navigation-button';
|
|
11
19
|
/**
|
|
12
20
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
13
21
|
* If not set, it will be created.
|
|
14
22
|
*/
|
|
15
23
|
this.identifier = createID('mg-tabs');
|
|
24
|
+
/**
|
|
25
|
+
* Define tabs size
|
|
26
|
+
*/
|
|
27
|
+
this.size = 'regular';
|
|
16
28
|
/**
|
|
17
29
|
* Active tab number
|
|
18
30
|
* default: first is 1
|
|
@@ -26,33 +38,81 @@ export class MgTabs {
|
|
|
26
38
|
* Component classes
|
|
27
39
|
*/
|
|
28
40
|
this.classList = new ClassList(['mg-tabs']);
|
|
41
|
+
/**
|
|
42
|
+
* Method to set active tab
|
|
43
|
+
*
|
|
44
|
+
* @param {number} tabKey item tab key to set to ACTIVE status
|
|
45
|
+
* @returns {void}
|
|
46
|
+
*/
|
|
47
|
+
this.setActiveTab = (tabKey) => {
|
|
48
|
+
// reset active tabs
|
|
49
|
+
this.tabs.forEach(tab => {
|
|
50
|
+
if (this.tabHasGivenStatus(tab, Status.ACTIVE))
|
|
51
|
+
tab.status = Status.VISIBLE;
|
|
52
|
+
});
|
|
53
|
+
// set active tab from given tab key
|
|
54
|
+
this.tabs[tabKey - this.startIndex].status = Status.ACTIVE;
|
|
55
|
+
// emit change active tab key event
|
|
56
|
+
this.activeTabChange.emit(tabKey);
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Method to know if given tab has the given status
|
|
60
|
+
*
|
|
61
|
+
* @param {TabItem} tab item tab key to set to ACTIVE status
|
|
62
|
+
* @param {Status} status status to valide
|
|
63
|
+
* @returns {boolean} status comparaison
|
|
64
|
+
*/
|
|
65
|
+
this.tabHasGivenStatus = (tab, status) => tab.status === status;
|
|
66
|
+
/**
|
|
67
|
+
* Method to get element id from index
|
|
68
|
+
*
|
|
69
|
+
* @param {string} element to get id
|
|
70
|
+
* @param {number} index to generate id
|
|
71
|
+
* @returns {string} generated element id
|
|
72
|
+
*/
|
|
73
|
+
this.getElementId = (element, index) => `${element}-${this.getTabIndex(index)}`;
|
|
74
|
+
/**
|
|
75
|
+
* Method to get tab index
|
|
76
|
+
*
|
|
77
|
+
* @param {number} index to get
|
|
78
|
+
* @returns {number} index
|
|
79
|
+
*/
|
|
80
|
+
this.getTabIndex = (index) => index + this.startIndex;
|
|
29
81
|
/**
|
|
30
82
|
* Handle click events on tabs
|
|
31
|
-
*
|
|
83
|
+
*
|
|
84
|
+
* @param {MouseEvent} event mouse event
|
|
32
85
|
*/
|
|
33
86
|
this.handleClick = (event) => {
|
|
34
87
|
const tabId = event.currentTarget.getAttribute('data-index');
|
|
35
88
|
this.activeTab = Number(tabId);
|
|
36
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* get navigation button class from given status
|
|
92
|
+
*
|
|
93
|
+
* @param {Status} status button tab status
|
|
94
|
+
* @param {boolean} isSelector set if we need a CSS selector with the dot '.' at the begin. default value = false.
|
|
95
|
+
* @returns {string} button class/selector variant
|
|
96
|
+
*/
|
|
97
|
+
this.getNavigationButtonClass = (status, isSelector = false) => `${isSelector ? '.' : ''}${this.buttonTabBaseClass}--${status}`;
|
|
37
98
|
/**
|
|
38
99
|
* Handle keyboard event on tabs
|
|
39
|
-
*
|
|
100
|
+
*
|
|
101
|
+
* @param {MouseEvent} event mouse event
|
|
102
|
+
* @returns {void}
|
|
40
103
|
*/
|
|
41
104
|
this.handleKeydown = (event) => {
|
|
42
|
-
let selectedTab;
|
|
43
105
|
let tabId = Number(event.target.getAttribute('data-index'));
|
|
44
106
|
const parent = event.target.parentElement;
|
|
45
107
|
// change selected id from key code
|
|
46
|
-
|
|
47
|
-
if (['ArrowRight', 'Right'].includes(event.key)) {
|
|
108
|
+
if (event.key === 'ArrowRight') {
|
|
48
109
|
tabId++;
|
|
49
|
-
// /* IE FIX */ delete 'Left'
|
|
50
110
|
}
|
|
51
|
-
else if (
|
|
111
|
+
else if (event.key === 'ArrowLeft') {
|
|
52
112
|
tabId--;
|
|
53
113
|
}
|
|
54
|
-
// get selected tab
|
|
55
|
-
selectedTab = parent.querySelector(`[data-index="${tabId}"]`);
|
|
114
|
+
// get selected tab if NOT hidden, disabled
|
|
115
|
+
const selectedTab = parent.querySelector(`[data-index="${tabId}"]:not(${[this.getNavigationButtonClass(Status.HIDDEN, true), this.getNavigationButtonClass(Status.DISABLED, true)].join()})`);
|
|
56
116
|
// apply selected tab if exist
|
|
57
117
|
if (selectedTab !== null) {
|
|
58
118
|
selectedTab.focus();
|
|
@@ -69,10 +129,16 @@ export class MgTabs {
|
|
|
69
129
|
}
|
|
70
130
|
};
|
|
71
131
|
}
|
|
132
|
+
validateSize(newValue) {
|
|
133
|
+
if (!sizes.includes(newValue)) {
|
|
134
|
+
throw new Error(`<mg-tabs> prop "size" must be one of : ${sizes.join(', ')}`);
|
|
135
|
+
}
|
|
136
|
+
this.classList.add(`mg-tabs--size-${this.size}`);
|
|
137
|
+
}
|
|
72
138
|
validateItems(newValue) {
|
|
73
139
|
// String array
|
|
74
140
|
if (allItemsAreString(newValue)) {
|
|
75
|
-
this.tabs = newValue.map(item => ({ label: item }));
|
|
141
|
+
this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
|
|
76
142
|
}
|
|
77
143
|
// Object array
|
|
78
144
|
else if (newValue && newValue.every(item => isTabItem(item))) {
|
|
@@ -83,39 +149,49 @@ export class MgTabs {
|
|
|
83
149
|
}
|
|
84
150
|
}
|
|
85
151
|
validateActiveTab(newValue) {
|
|
86
|
-
if (
|
|
152
|
+
if (newValue < 1 || newValue > this.tabs.length) {
|
|
87
153
|
throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
|
|
88
154
|
}
|
|
155
|
+
else {
|
|
156
|
+
this.setActiveTab(newValue);
|
|
157
|
+
}
|
|
89
158
|
}
|
|
90
159
|
/*************
|
|
91
160
|
* Lifecycle *
|
|
92
161
|
*************/
|
|
93
162
|
/**
|
|
94
163
|
* Check if component props are well configured on init
|
|
164
|
+
*
|
|
165
|
+
* @returns {void}
|
|
95
166
|
*/
|
|
96
167
|
componentWillLoad() {
|
|
97
168
|
// Check tabs format
|
|
98
169
|
this.validateItems(this.items);
|
|
99
170
|
this.validateActiveTab(this.activeTab);
|
|
171
|
+
this.validateSize(this.size);
|
|
100
172
|
this.validateSlots();
|
|
101
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Render
|
|
176
|
+
*
|
|
177
|
+
* @returns {HTMLElement} HTML Element
|
|
178
|
+
*/
|
|
102
179
|
render() {
|
|
103
180
|
return (h(Host, null,
|
|
104
|
-
h("
|
|
105
|
-
|
|
106
|
-
|
|
181
|
+
h("div", { class: this.classList.join() },
|
|
182
|
+
h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => (h("button", { role: "tab", id: this.getElementId(this.identifier, index), class: {
|
|
183
|
+
[`${this.buttonTabBaseClass}`]: true,
|
|
184
|
+
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasGivenStatus(tab, Status.ACTIVE),
|
|
185
|
+
[`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasGivenStatus(tab, Status.DISABLED),
|
|
186
|
+
[`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasGivenStatus(tab, Status.HIDDEN),
|
|
187
|
+
}, tabindex: this.tabHasGivenStatus(tab, Status.ACTIVE) ? 0 : -1, "aria-selected": this.tabHasGivenStatus(tab, Status.ACTIVE).toString(), "aria-controls": this.getElementId(this.tabPanel, index), onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": this.getTabIndex(index), disabled: this.tabHasGivenStatus(tab, Status.DISABLED) },
|
|
107
188
|
tab.icon !== undefined && h("mg-icon", { icon: tab.icon }),
|
|
108
189
|
tab.label,
|
|
109
|
-
tab.badge !== undefined && h("mg-badge", { variant: "info", value: tab.badge.value, label: tab.badge.label })))
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const tabIndex = index + 1;
|
|
113
|
-
return (h("article", { role: "tabpanel", id: `pannel-${tabIndex}`, hidden: tabIndex !== this.activeTab, "aria-labelledby": `${this.identifier}-${this.activeTab}`, tabindex: tabIndex === this.activeTab ? 0 : -1, class: "mg-tabs__content-container" },
|
|
114
|
-
h("slot", { name: `tab_content-${tabIndex}` })));
|
|
115
|
-
})));
|
|
190
|
+
tab.badge !== undefined && h("mg-badge", { variant: "info", value: tab.badge.value, label: tab.badge.label }))))),
|
|
191
|
+
this.tabs.map((tab, index) => (h("article", { role: "tabpanel", id: this.getElementId(this.tabPanel, index), hidden: !this.tabHasGivenStatus(tab, Status.ACTIVE), "aria-labelledby": this.getElementId(this.identifier, index), tabindex: this.tabHasGivenStatus(tab, Status.ACTIVE) ? 0 : -1, class: "mg-tabs__content-container" },
|
|
192
|
+
h("slot", { name: this.getElementId('tab_content', index) })))))));
|
|
116
193
|
}
|
|
117
194
|
static get is() { return "mg-tabs"; }
|
|
118
|
-
static get encapsulation() { return "scoped"; }
|
|
119
195
|
static get originalStyleUrls() { return {
|
|
120
196
|
"$": ["mg-tabs.scss"]
|
|
121
197
|
}; }
|
|
@@ -132,7 +208,7 @@ export class MgTabs {
|
|
|
132
208
|
"references": {}
|
|
133
209
|
},
|
|
134
210
|
"required": false,
|
|
135
|
-
"optional":
|
|
211
|
+
"optional": false,
|
|
136
212
|
"docs": {
|
|
137
213
|
"tags": [],
|
|
138
214
|
"text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
|
|
@@ -158,6 +234,24 @@ export class MgTabs {
|
|
|
158
234
|
"attribute": "label",
|
|
159
235
|
"reflect": false
|
|
160
236
|
},
|
|
237
|
+
"size": {
|
|
238
|
+
"type": "string",
|
|
239
|
+
"mutable": false,
|
|
240
|
+
"complexType": {
|
|
241
|
+
"original": "string",
|
|
242
|
+
"resolved": "string",
|
|
243
|
+
"references": {}
|
|
244
|
+
},
|
|
245
|
+
"required": false,
|
|
246
|
+
"optional": false,
|
|
247
|
+
"docs": {
|
|
248
|
+
"tags": [],
|
|
249
|
+
"text": "Define tabs size"
|
|
250
|
+
},
|
|
251
|
+
"attribute": "size",
|
|
252
|
+
"reflect": false,
|
|
253
|
+
"defaultValue": "'regular'"
|
|
254
|
+
},
|
|
161
255
|
"items": {
|
|
162
256
|
"type": "unknown",
|
|
163
257
|
"mutable": false,
|
|
@@ -201,8 +295,27 @@ export class MgTabs {
|
|
|
201
295
|
"tabs": {},
|
|
202
296
|
"classList": {}
|
|
203
297
|
}; }
|
|
298
|
+
static get events() { return [{
|
|
299
|
+
"method": "activeTabChange",
|
|
300
|
+
"name": "active-tab-change",
|
|
301
|
+
"bubbles": true,
|
|
302
|
+
"cancelable": true,
|
|
303
|
+
"composed": true,
|
|
304
|
+
"docs": {
|
|
305
|
+
"tags": [],
|
|
306
|
+
"text": "Emited event when active tab change"
|
|
307
|
+
},
|
|
308
|
+
"complexType": {
|
|
309
|
+
"original": "number",
|
|
310
|
+
"resolved": "number",
|
|
311
|
+
"references": {}
|
|
312
|
+
}
|
|
313
|
+
}]; }
|
|
204
314
|
static get elementRef() { return "element"; }
|
|
205
315
|
static get watchers() { return [{
|
|
316
|
+
"propName": "size",
|
|
317
|
+
"methodName": "validateSize"
|
|
318
|
+
}, {
|
|
206
319
|
"propName": "items",
|
|
207
320
|
"methodName": "validateItems"
|
|
208
321
|
}, {
|
|
@@ -1,4 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
import fr from './fr
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import en from './en/messages.json';
|
|
2
|
+
import fr from './fr/messages.json';
|
|
3
|
+
const defaultLocale = 'en';
|
|
4
|
+
const messages = { en, fr };
|
|
5
|
+
/**
|
|
6
|
+
* Get locale
|
|
7
|
+
*
|
|
8
|
+
* @param {HTMLElement} element element that needs to know the locale to use
|
|
9
|
+
* @returns {string} locale
|
|
10
|
+
*/
|
|
11
|
+
const getLocale = (element) => {
|
|
12
|
+
var _a;
|
|
13
|
+
return ((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang) || navigator.language || defaultLocale;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Get Intl object
|
|
17
|
+
* We load the defined locale but for now we only support the first subtag for messages
|
|
18
|
+
*
|
|
19
|
+
* @param {HTMLElement} element element we need to get the language
|
|
20
|
+
* @returns {{ locale: string; messages: unknown }} messages object
|
|
21
|
+
*/
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
export const initLocales = (element) => {
|
|
24
|
+
// Get local
|
|
25
|
+
const locale = getLocale(element);
|
|
26
|
+
// Only keep first subtag
|
|
27
|
+
const localeSubtag = locale.split('-').shift();
|
|
28
|
+
// Return
|
|
29
|
+
return {
|
|
30
|
+
locale,
|
|
31
|
+
messages: messages[localeSubtag] || messages[defaultLocale],
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export default {
|
|
3
|
+
title: 'Style/Helpers',
|
|
4
|
+
argTypes: {
|
|
5
|
+
align: {
|
|
6
|
+
options: ['left', 'right'],
|
|
7
|
+
control: { type: 'select' },
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
const Template = args => (h("div", null,
|
|
12
|
+
h("h1", null, "Helpers"),
|
|
13
|
+
h("h2", null, ".mg-group-elements"),
|
|
14
|
+
h("p", null,
|
|
15
|
+
"Buttons can be grouped in an HTMLelement using the ",
|
|
16
|
+
h("code", null, ".mg-group-elements"),
|
|
17
|
+
" class, it will ensure a 10px margin space between them, even verticaly. Above exemples are using it."),
|
|
18
|
+
h("p", null,
|
|
19
|
+
"By adding the ",
|
|
20
|
+
h("code", null, ".mg-group-elements--align-right"),
|
|
21
|
+
" class you 'll set a right alignment of the button, even when line breaks."),
|
|
22
|
+
h("h3", null, "Demo"),
|
|
23
|
+
h("div", { class: `mg-group-elements${args.align === 'right' ? ' mg-group-elements--align-right' : ''}` },
|
|
24
|
+
h("mg-button", null, "First Button"),
|
|
25
|
+
h("mg-button", { label: "" },
|
|
26
|
+
h("mg-icon", { icon: "info-circle" }),
|
|
27
|
+
"Second Button"),
|
|
28
|
+
h("mg-button", { "is-icon": true, label: "Third button" },
|
|
29
|
+
h("mg-icon", { icon: "info-circle" })))));
|
|
30
|
+
export const Helpers = Template.bind({});
|
|
31
|
+
Helpers.args = {
|
|
32
|
+
align: 'left',
|
|
33
|
+
};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Create random ID
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* @param {string} prefix add prefix to created ID
|
|
5
|
+
* @param {number} length ID length
|
|
4
6
|
* @returns {string} ID
|
|
5
7
|
*/
|
|
6
8
|
export function createID(prefix = '', length = 10) {
|
|
7
9
|
let ID = '';
|
|
8
10
|
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
9
11
|
const charsLength = chars.length;
|
|
10
|
-
for (
|
|
12
|
+
for (let i = 0; i < length; i++) {
|
|
11
13
|
ID += chars.charAt(Math.floor(Math.random() * charsLength));
|
|
12
14
|
}
|
|
13
15
|
return (prefix !== '' ? `${prefix}-` : '') + ID;
|
|
@@ -20,7 +22,8 @@ export class ClassList {
|
|
|
20
22
|
constructor(classlist = []) {
|
|
21
23
|
/**
|
|
22
24
|
* Add class
|
|
23
|
-
*
|
|
25
|
+
*
|
|
26
|
+
* @param {string} className class name to add
|
|
24
27
|
* @returns {void}
|
|
25
28
|
*/
|
|
26
29
|
this.add = (className) => {
|
|
@@ -30,7 +33,8 @@ export class ClassList {
|
|
|
30
33
|
};
|
|
31
34
|
/**
|
|
32
35
|
* Delete class
|
|
33
|
-
*
|
|
36
|
+
*
|
|
37
|
+
* @param {string} className class name to delete
|
|
34
38
|
* @returns {void}
|
|
35
39
|
*/
|
|
36
40
|
this.delete = (className) => {
|
|
@@ -41,15 +45,17 @@ export class ClassList {
|
|
|
41
45
|
};
|
|
42
46
|
/**
|
|
43
47
|
* Check if class exist in list
|
|
44
|
-
*
|
|
45
|
-
* @
|
|
48
|
+
*
|
|
49
|
+
* @param {string} className class name to check
|
|
50
|
+
* @returns {boolean} class name is in the list
|
|
46
51
|
*/
|
|
47
52
|
this.has = (className) => {
|
|
48
53
|
return this.classes.includes(className);
|
|
49
54
|
};
|
|
50
55
|
/**
|
|
51
56
|
* Join classes seperated by spaces
|
|
52
|
-
*
|
|
57
|
+
*
|
|
58
|
+
* @returns {string} joined values
|
|
53
59
|
*/
|
|
54
60
|
this.join = () => {
|
|
55
61
|
return this.classes.join(' ');
|
|
@@ -59,8 +65,9 @@ export class ClassList {
|
|
|
59
65
|
}
|
|
60
66
|
/**
|
|
61
67
|
* Check if all items are string
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
68
|
+
*
|
|
69
|
+
* @param {string[]} items items to check
|
|
70
|
+
* @returns {boolean} all items are string
|
|
64
71
|
*/
|
|
65
72
|
export function allItemsAreString(items) {
|
|
66
73
|
return items && items.every(item => typeof item === 'string');
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { locale, currency } from '../locales';
|
|
2
1
|
/**
|
|
3
2
|
* Format number to the locale currency
|
|
4
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* @param {number} number number to format
|
|
5
|
+
* @param {string} locale locale to apply
|
|
6
|
+
* @param {string} currency currency to apply
|
|
5
7
|
* @returns {string} formatted currency
|
|
6
8
|
*/
|
|
7
|
-
export function localeCurrency(number) {
|
|
9
|
+
export function localeCurrency(number, locale, currency) {
|
|
8
10
|
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
13
|
* Format number to locale
|
|
12
|
-
*
|
|
14
|
+
*
|
|
15
|
+
* @param {number} number number to format
|
|
16
|
+
* @param {string} locale locale to apply
|
|
13
17
|
* @returns {string} formatted number
|
|
14
18
|
*/
|
|
15
|
-
export function localeNumber(number) {
|
|
19
|
+
export function localeNumber(number, locale) {
|
|
16
20
|
return new Intl.NumberFormat(locale).format(number);
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
@@ -21,10 +25,12 @@ export function localeNumber(number) {
|
|
|
21
25
|
export const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
22
26
|
/**
|
|
23
27
|
* Locale date format
|
|
24
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* @param {string} date date to format
|
|
30
|
+
* @param {string} locale locale to apply
|
|
25
31
|
* @returns {string} formatted date
|
|
26
32
|
*/
|
|
27
|
-
export function localeDate(date) {
|
|
33
|
+
export function localeDate(date, locale) {
|
|
28
34
|
if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
|
|
29
35
|
return '';
|
|
30
36
|
}
|
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
import { newE2EPage } from '@stencil/core/testing';
|
|
2
|
+
/**
|
|
3
|
+
* Create E2E page
|
|
4
|
+
*
|
|
5
|
+
* @param {string} htmlString html to render
|
|
6
|
+
* @returns {Promise<DesignSystemE2EPage>} page
|
|
7
|
+
*/
|
|
2
8
|
export async function createPage(htmlString) {
|
|
3
|
-
const
|
|
4
|
-
html: `<link rel="stylesheet" href="http://localhost:3333/build/variables.css" /><meta charset="UTF-8">${htmlString}`,
|
|
5
|
-
viewportWidth: 600,
|
|
6
|
-
};
|
|
9
|
+
const defaultSize = 600;
|
|
7
10
|
const page = (await newE2EPage());
|
|
8
|
-
|
|
9
|
-
await page.
|
|
10
|
-
await page.setContent(options.html, { waitUntil: 'networkidle0' });
|
|
11
|
+
await page.setViewport({ width: defaultSize, height: defaultSize });
|
|
12
|
+
await page.setContent(`<link rel="stylesheet" href="http://localhost:3333/build/variables.css" /><meta charset="UTF-8">${htmlString}`, { waitUntil: 'networkidle0' });
|
|
11
13
|
await page.evaluateHandle('document.fonts.ready');
|
|
12
14
|
// monkey patch screenshot function to add some extra features
|
|
13
15
|
const screenshot = page.screenshot;
|
|
14
|
-
page.screenshot = async
|
|
16
|
+
page.screenshot = async () => {
|
|
17
|
+
let width = page.viewport().width;
|
|
18
|
+
let height = page.viewport().height;
|
|
19
|
+
// if viewport has not been redefined
|
|
20
|
+
if (page.viewport().width === defaultSize && page.viewport().height === defaultSize) {
|
|
21
|
+
const htmlElement = await page.$('html');
|
|
22
|
+
const boundingBox = await htmlElement.boundingBox();
|
|
23
|
+
width = Math.round(boundingBox.width);
|
|
24
|
+
height = Math.round(boundingBox.height);
|
|
25
|
+
}
|
|
15
26
|
return screenshot.call(page, {
|
|
16
|
-
clip: {
|
|
17
|
-
x: 0,
|
|
18
|
-
y: 0,
|
|
19
|
-
width: page.viewport().width,
|
|
20
|
-
height: page.viewport().height,
|
|
21
|
-
},
|
|
27
|
+
clip: { x: 0, y: 0, width, height },
|
|
22
28
|
});
|
|
23
29
|
};
|
|
24
30
|
return page;
|
|
25
31
|
}
|
|
26
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Clone Deep function
|
|
34
|
+
*
|
|
35
|
+
* @param {unknown} obj object to clone
|
|
36
|
+
* @returns {unknown} cloned json
|
|
37
|
+
*/
|
|
38
|
+
export const cloneDeep = (obj) => JSON.parse(JSON.stringify(obj));
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
--color-info: var(--color-info-h), var(--color-info-s), var(--color-info-l);
|
|
54
54
|
|
|
55
55
|
/* Danger */
|
|
56
|
-
/* #
|
|
57
|
-
/* rgb(
|
|
56
|
+
/* #db1f29; */
|
|
57
|
+
/* rgb(219, 31, 41); */
|
|
58
58
|
--color-danger-h: 357;
|
|
59
|
-
--color-danger-s:
|
|
60
|
-
--color-danger-l:
|
|
59
|
+
--color-danger-s: 75%;
|
|
60
|
+
--color-danger-l: 49%;
|
|
61
61
|
--color-danger: var(--color-danger-h), var(--color-danger-s), var(--color-danger-l);
|
|
62
62
|
|
|
63
63
|
/* Dark */
|
|
@@ -76,6 +76,21 @@
|
|
|
76
76
|
--color-light-l: 100%;
|
|
77
77
|
--color-light: var(--color-light-h), var(--color-light-s), var(--color-light-l);
|
|
78
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
|
+
|
|
79
94
|
/*
|
|
80
95
|
Global
|
|
81
96
|
*/
|
|
@@ -84,6 +99,7 @@
|
|
|
84
99
|
/*
|
|
85
100
|
<mg-icon>
|
|
86
101
|
*/
|
|
102
|
+
--mg-icon-small-size: 1.2rem;
|
|
87
103
|
--mg-icon-regular-size: 1.6rem;
|
|
88
104
|
--mg-icon-large-size: 2.4rem;
|
|
89
105
|
--mg-icon-extra-large-size: 3.6rem;
|
|
@@ -95,6 +111,8 @@
|
|
|
95
111
|
--mg-button-border-radius: 0.3rem;
|
|
96
112
|
--mg-button-icon-border-radius: var(--default-size);
|
|
97
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 */
|
|
98
116
|
|
|
99
117
|
/* Primary */
|
|
100
118
|
--mg-button-primary-color-h: var(--color-dark-h);
|
|
@@ -140,6 +158,20 @@
|
|
|
140
158
|
*/
|
|
141
159
|
--mg-message-border-radius: 0.3rem;
|
|
142
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
|
+
|
|
143
175
|
/*
|
|
144
176
|
Layout
|
|
145
177
|
*/
|
|
@@ -148,7 +180,6 @@
|
|
|
148
180
|
/*
|
|
149
181
|
Forms
|
|
150
182
|
*/
|
|
151
|
-
--mg-form-group-vertical-space: 1.5rem;
|
|
152
183
|
|
|
153
184
|
/*
|
|
154
185
|
<mg-input-...>
|
|
@@ -158,6 +189,9 @@
|
|
|
158
189
|
--mg-inputs-color: #b5c2c9;
|
|
159
190
|
--mg-inputs-spacer: 1rem;
|
|
160
191
|
|
|
192
|
+
/* Error message background */
|
|
193
|
+
--mg-inputs-error-bg-color: var(--color-danger-h), calc(var(--color-danger-s) + 5%), calc(var(--color-danger-l) + 49%);
|
|
194
|
+
|
|
161
195
|
/* Input focus shadow */
|
|
162
196
|
/* #b5c2c9 */
|
|
163
197
|
/* rgb(0, 221, 255); */
|