@mgdis/mg-components 3.1.0 → 3.2.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/css-shim-629916b0.js +6 -0
- package/dist/cjs/index-369388eb.js +146 -0
- package/dist/cjs/{index-85a4a0b6.js → index-bead7dbd.js} +78 -2
- package/dist/cjs/loader.cjs.js +4 -4
- package/dist/cjs/mg-badge_21.cjs.entry.js +3313 -0
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-modal.cjs.entry.js +111 -0
- package/dist/cjs/mg-popover.cjs.entry.js +165 -0
- package/dist/cjs/popper-0c3964e7.js +1786 -0
- package/dist/cjs/{shadow-css-8940f82d.js → shadow-css-546083ef.js} +1 -1
- package/dist/collection/collection-manifest.json +4 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +11 -7
- package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +3 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +26 -17
- package/dist/collection/components/atoms/mg-button/mg-button.js +71 -2
- package/dist/collection/components/atoms/mg-button/mg-button.stories.js +5 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +12 -1
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +8 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +8 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +5 -7
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +11 -1
- 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.js +10 -3
- package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +3 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +9 -0
- package/dist/collection/components/molecules/inputs/MgInput.js +20 -14
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +9 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +103 -40
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +27 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +125 -56
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +27 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +144 -68
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +27 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +101 -35
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +9 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +115 -37
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +28 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +132 -51
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +14 -1
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +27 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +155 -53
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +7 -2
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +27 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +108 -42
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +7 -2
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +4 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +60 -31
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +6 -1
- package/dist/collection/components/molecules/mg-form/mg-form.css +15 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +269 -0
- package/dist/collection/components/molecules/mg-form/mg-form.stories.js +58 -0
- package/dist/collection/components/molecules/mg-message/mg-message.css +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +11 -4
- package/dist/collection/components/molecules/mg-message/mg-message.stories.js +5 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +54 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +233 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.stories.js +51 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +32 -12
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +1 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +42 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +255 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.stories.js +31 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +19 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +4 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +14 -3
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +68 -20
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +10 -1
- package/dist/collection/stories/messages.stories.js +1 -1
- package/dist/collection/utils/components.utils.js +16 -9
- package/dist/collection/utils/locale.utils.js +6 -3
- package/dist/collection/utils/test.utils.js +27 -15
- package/dist/collection/variables.css +30 -1
- package/dist/collection/variables.scss +30 -1
- package/dist/components/MgInput.js +20 -14
- package/dist/components/components.utils.js +16 -9
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index2.js +22 -12
- package/dist/components/locale.utils.js +6 -3
- package/dist/components/mg-badge2.js +9 -5
- package/dist/components/mg-button2.js +21 -2
- package/dist/components/mg-character-left2.js +12 -1
- package/dist/components/mg-form.d.ts +11 -0
- package/dist/components/mg-form.js +146 -0
- package/dist/components/mg-icon2.js +20 -2
- package/dist/components/mg-input-checkbox.js +65 -36
- package/dist/components/mg-input-date.js +87 -52
- package/dist/components/mg-input-numeric.js +105 -63
- package/dist/components/mg-input-password.js +60 -29
- package/dist/components/mg-input-radio.js +74 -34
- package/dist/components/mg-input-select2.js +89 -46
- package/dist/components/mg-input-text.js +1 -237
- package/dist/components/mg-input-text2.js +288 -0
- package/dist/components/mg-input-textarea.js +67 -36
- package/dist/components/mg-input-title2.js +13 -4
- package/dist/components/mg-input-toggle.js +30 -22
- package/dist/components/mg-message.js +10 -3
- package/dist/components/mg-modal.d.ts +11 -0
- package/dist/components/mg-modal.js +147 -0
- package/dist/components/mg-pagination.js +31 -11
- package/dist/components/mg-panel.d.ts +11 -0
- package/dist/components/mg-panel.js +210 -0
- package/dist/components/mg-popover.js +20 -5
- package/dist/components/mg-tabs.js +43 -11
- package/dist/components/mg-tag.js +8 -1
- package/dist/components/mg-tooltip2.js +9 -0
- package/dist/esm/css-shim-0993aa3b.js +4 -0
- package/dist/esm/{index-e3e84606.js → index-9e877561.js} +78 -2
- package/dist/esm/index-c346f52d.js +139 -0
- package/dist/esm/loader.js +4 -4
- package/dist/esm/mg-badge_21.entry.js +3289 -0
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/mg-modal.entry.js +107 -0
- package/dist/esm/mg-popover.entry.js +161 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/popper-8874fd6c.js +1784 -0
- package/dist/esm/{shadow-css-5d2d01ce.js → shadow-css-dfa0587f.js} +1 -1
- package/dist/esm-es5/css-shim-0993aa3b.js +1 -0
- package/dist/esm-es5/index-9e877561.js +1 -0
- package/dist/esm-es5/index-c346f52d.js +1 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mg-badge_21.entry.js +2 -0
- package/dist/esm-es5/mg-components.js +1 -1
- package/dist/esm-es5/mg-modal.entry.js +1 -0
- package/dist/esm-es5/mg-popover.entry.js +1 -0
- package/dist/esm-es5/popper-8874fd6c.js +1 -0
- package/dist/esm-es5/{shadow-css-5d2d01ce.js → shadow-css-dfa0587f.js} +0 -0
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/mg-components.js +2 -2
- package/dist/mg-components/p-3633e9e1.system.entry.js +2 -0
- package/dist/mg-components/p-3c14153d.js +1 -0
- package/dist/mg-components/p-55a22b35.system.js +1 -0
- package/dist/mg-components/{p-f6455ab3.js → p-5e796581.js} +0 -0
- package/dist/mg-components/p-656b5efb.system.js +1 -0
- package/dist/mg-components/p-68d6f104.js +1 -0
- package/dist/mg-components/{p-366a224e.js → p-6d49ed95.js} +1 -1
- package/dist/mg-components/p-70177194.entry.js +1 -0
- package/dist/mg-components/{p-71d57b8b.system.js → p-8b2d8a2a.system.js} +0 -0
- package/dist/mg-components/p-8cb61c3f.system.js +1 -0
- package/dist/mg-components/p-ace173b1.js +1 -0
- package/dist/mg-components/p-c46fbd54.entry.js +1 -0
- package/dist/mg-components/p-c90cc4bf.system.js +1 -0
- package/dist/mg-components/p-cd2a4acc.system.entry.js +1 -0
- package/dist/mg-components/p-de1164fa.system.entry.js +1 -0
- package/dist/mg-components/p-dfe25da3.entry.js +1 -0
- package/dist/mg-components/p-e4a502b5.system.js +1 -0
- package/dist/mg-components/variables.css +30 -1
- package/dist/mg-components/variables.scss +30 -1
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -4
- package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +5 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +22 -2
- package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +5 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +13 -2
- package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +9 -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 +11 -1
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +11 -1
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +10 -3
- package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +5 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +11 -2
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +8 -0
- package/dist/types/components/molecules/inputs/MgInput.d.ts +5 -4
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +31 -11
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +39 -14
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +53 -14
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +28 -9
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.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 +37 -8
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +5 -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 +30 -7
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +14 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +46 -10
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +30 -10
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.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 +27 -12
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +5 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +82 -0
- package/dist/types/components/molecules/mg-form/mg-form.stories.d.ts +11 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +11 -4
- package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +10 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +83 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.stories.d.ts +13 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +23 -7
- package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +5 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +110 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.stories.d.ts +6 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +18 -3
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +5 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +21 -6
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +8 -0
- package/dist/types/components.d.ts +365 -78
- package/dist/types/locales/index.d.ts +15 -8
- package/dist/types/utils/components.utils.d.ts +16 -9
- package/dist/types/utils/locale.utils.d.ts +6 -3
- package/dist/types/utils/test.utils.d.ts +13 -1
- package/package.json +13 -9
- package/readme.md +3 -0
- package/dist/cjs/css-shim-a22512c4.js +0 -6
- package/dist/cjs/mg-badge_20.cjs.entry.js +0 -4661
- package/dist/esm/css-shim-7c240feb.js +0 -4
- package/dist/esm/mg-badge_20.entry.js +0 -4638
- package/dist/esm-es5/css-shim-7c240feb.js +0 -1
- package/dist/esm-es5/index-e3e84606.js +0 -1
- package/dist/esm-es5/mg-badge_20.entry.js +0 -2
- 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-422c429b.system.js +0 -1
- package/dist/mg-components/p-62fa3797.js +0 -1
- package/dist/mg-components/p-9a215712.system.js +0 -1
- package/dist/mg-components/p-cbf0464b.entry.js +0 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Component, h, Host, Prop, State, Element, Watch } from '@stencil/core';
|
|
2
2
|
import { createID, ClassList, allItemsAreString } from '../../../utils/components.utils';
|
|
3
|
+
import { sizes } 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 {
|
|
@@ -13,6 +15,10 @@ export class MgTabs {
|
|
|
13
15
|
* If not set, it will be created.
|
|
14
16
|
*/
|
|
15
17
|
this.identifier = createID('mg-tabs');
|
|
18
|
+
/**
|
|
19
|
+
* Define tabs size
|
|
20
|
+
*/
|
|
21
|
+
this.size = 'regular';
|
|
16
22
|
/**
|
|
17
23
|
* Active tab number
|
|
18
24
|
* default: first is 1
|
|
@@ -28,7 +34,8 @@ export class MgTabs {
|
|
|
28
34
|
this.classList = new ClassList(['mg-tabs']);
|
|
29
35
|
/**
|
|
30
36
|
* Handle click events on tabs
|
|
31
|
-
*
|
|
37
|
+
*
|
|
38
|
+
* @param {MouseEvent} event mouse event
|
|
32
39
|
*/
|
|
33
40
|
this.handleClick = (event) => {
|
|
34
41
|
const tabId = event.currentTarget.getAttribute('data-index');
|
|
@@ -36,10 +43,11 @@ export class MgTabs {
|
|
|
36
43
|
};
|
|
37
44
|
/**
|
|
38
45
|
* Handle keyboard event on tabs
|
|
39
|
-
*
|
|
46
|
+
*
|
|
47
|
+
* @param {MouseEvent} event mouse event
|
|
48
|
+
* @returns {void}
|
|
40
49
|
*/
|
|
41
50
|
this.handleKeydown = (event) => {
|
|
42
|
-
let selectedTab;
|
|
43
51
|
let tabId = Number(event.target.getAttribute('data-index'));
|
|
44
52
|
const parent = event.target.parentElement;
|
|
45
53
|
// change selected id from key code
|
|
@@ -52,7 +60,7 @@ export class MgTabs {
|
|
|
52
60
|
tabId--;
|
|
53
61
|
}
|
|
54
62
|
// get selected tab
|
|
55
|
-
selectedTab = parent.querySelector(`[data-index="${tabId}"]`);
|
|
63
|
+
const selectedTab = parent.querySelector(`[data-index="${tabId}"]`);
|
|
56
64
|
// apply selected tab if exist
|
|
57
65
|
if (selectedTab !== null) {
|
|
58
66
|
selectedTab.focus();
|
|
@@ -69,10 +77,16 @@ export class MgTabs {
|
|
|
69
77
|
}
|
|
70
78
|
};
|
|
71
79
|
}
|
|
80
|
+
validateSize(newValue) {
|
|
81
|
+
if (!sizes.includes(newValue)) {
|
|
82
|
+
throw new Error(`<mg-tabs> prop "size" must be one of : ${sizes.join(', ')}`);
|
|
83
|
+
}
|
|
84
|
+
this.classList.add(`mg-tabs--size-${this.size}`);
|
|
85
|
+
}
|
|
72
86
|
validateItems(newValue) {
|
|
73
87
|
// String array
|
|
74
88
|
if (allItemsAreString(newValue)) {
|
|
75
|
-
this.tabs = newValue.map(item => ({ label: item }));
|
|
89
|
+
this.tabs = newValue.map(item => ({ label: item, disabled: false }));
|
|
76
90
|
}
|
|
77
91
|
// Object array
|
|
78
92
|
else if (newValue && newValue.every(item => isTabItem(item))) {
|
|
@@ -92,27 +106,40 @@ export class MgTabs {
|
|
|
92
106
|
*************/
|
|
93
107
|
/**
|
|
94
108
|
* Check if component props are well configured on init
|
|
109
|
+
*
|
|
110
|
+
* @returns {void}
|
|
95
111
|
*/
|
|
96
112
|
componentWillLoad() {
|
|
97
113
|
// Check tabs format
|
|
98
114
|
this.validateItems(this.items);
|
|
99
115
|
this.validateActiveTab(this.activeTab);
|
|
116
|
+
this.validateSize(this.size);
|
|
100
117
|
this.validateSlots();
|
|
101
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Render
|
|
121
|
+
*
|
|
122
|
+
* @returns {HTMLElement} HTML Element
|
|
123
|
+
*/
|
|
102
124
|
render() {
|
|
103
125
|
return (h(Host, null,
|
|
104
|
-
h("
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
h("div", { class: this.classList.join() },
|
|
127
|
+
h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => {
|
|
128
|
+
const tabIndex = index + 1;
|
|
129
|
+
return (h("button", { role: "tab", id: `${this.identifier}-${tabIndex}`, class: {
|
|
130
|
+
'mg-tabs__navigation-button': true,
|
|
131
|
+
'mg-tabs__navigation-button--active': tabIndex === this.activeTab,
|
|
132
|
+
'mg-tabs__navigation-button--disabled': tab.disabled,
|
|
133
|
+
}, tabindex: tabIndex === this.activeTab ? 0 : -1, "aria-selected": (tabIndex === this.activeTab).toString(), "aria-controls": `pannel-${tabIndex}`, onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": tabIndex, disabled: tab.disabled },
|
|
134
|
+
tab.icon !== undefined && h("mg-icon", { icon: tab.icon }),
|
|
135
|
+
tab.label,
|
|
136
|
+
tab.badge !== undefined && h("mg-badge", { variant: "info", value: tab.badge.value, label: tab.badge.label })));
|
|
137
|
+
})),
|
|
138
|
+
this.tabs.map((_tab, index) => {
|
|
139
|
+
const tabIndex = index + 1;
|
|
140
|
+
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" },
|
|
141
|
+
h("slot", { name: `tab_content-${tabIndex}` })));
|
|
142
|
+
}))));
|
|
116
143
|
}
|
|
117
144
|
static get is() { return "mg-tabs"; }
|
|
118
145
|
static get encapsulation() { return "scoped"; }
|
|
@@ -132,7 +159,7 @@ export class MgTabs {
|
|
|
132
159
|
"references": {}
|
|
133
160
|
},
|
|
134
161
|
"required": false,
|
|
135
|
-
"optional":
|
|
162
|
+
"optional": false,
|
|
136
163
|
"docs": {
|
|
137
164
|
"tags": [],
|
|
138
165
|
"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 +185,24 @@ export class MgTabs {
|
|
|
158
185
|
"attribute": "label",
|
|
159
186
|
"reflect": false
|
|
160
187
|
},
|
|
188
|
+
"size": {
|
|
189
|
+
"type": "string",
|
|
190
|
+
"mutable": false,
|
|
191
|
+
"complexType": {
|
|
192
|
+
"original": "string",
|
|
193
|
+
"resolved": "string",
|
|
194
|
+
"references": {}
|
|
195
|
+
},
|
|
196
|
+
"required": false,
|
|
197
|
+
"optional": false,
|
|
198
|
+
"docs": {
|
|
199
|
+
"tags": [],
|
|
200
|
+
"text": "Define tabs size"
|
|
201
|
+
},
|
|
202
|
+
"attribute": "size",
|
|
203
|
+
"reflect": false,
|
|
204
|
+
"defaultValue": "'regular'"
|
|
205
|
+
},
|
|
161
206
|
"items": {
|
|
162
207
|
"type": "unknown",
|
|
163
208
|
"mutable": false,
|
|
@@ -203,6 +248,9 @@ export class MgTabs {
|
|
|
203
248
|
}; }
|
|
204
249
|
static get elementRef() { return "element"; }
|
|
205
250
|
static get watchers() { return [{
|
|
251
|
+
"propName": "size",
|
|
252
|
+
"methodName": "validateSize"
|
|
253
|
+
}, {
|
|
206
254
|
"propName": "items",
|
|
207
255
|
"methodName": "validateItems"
|
|
208
256
|
}, {
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { h } from '@stencil/core';
|
|
2
|
+
import { sizes } from './mg-tabs.conf';
|
|
2
3
|
export default {
|
|
3
4
|
component: 'mg-tabs',
|
|
4
5
|
title: 'Molecules/mg-tabs',
|
|
6
|
+
argTypes: {
|
|
7
|
+
size: {
|
|
8
|
+
options: sizes,
|
|
9
|
+
control: { type: 'select' },
|
|
10
|
+
},
|
|
11
|
+
},
|
|
5
12
|
};
|
|
6
13
|
/**
|
|
7
14
|
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
@@ -19,8 +26,9 @@ const Template = args => {
|
|
|
19
26
|
export const MgTabs = Template.bind({});
|
|
20
27
|
MgTabs.args = {
|
|
21
28
|
items: ['Tab 1', 'Tab 2', 'Tab 3'],
|
|
22
|
-
label: 'Short tabs description.
|
|
29
|
+
label: 'Short tabs description. Needed for accessibility',
|
|
23
30
|
activeTab: undefined,
|
|
31
|
+
size: sizes[0], // regular
|
|
24
32
|
};
|
|
25
33
|
export const MgTabsItems = Template.bind({});
|
|
26
34
|
MgTabsItems.args = Object.assign(Object.assign({}, MgTabs.args), { items: [
|
|
@@ -32,6 +40,7 @@ MgTabsItems.args = Object.assign(Object.assign({}, MgTabs.args), { items: [
|
|
|
32
40
|
{
|
|
33
41
|
label: 'Tab 2',
|
|
34
42
|
badge: { value: 5, label: 'messages' },
|
|
43
|
+
disabled: true,
|
|
35
44
|
},
|
|
36
45
|
{
|
|
37
46
|
label: 'Tab 3',
|
|
@@ -25,7 +25,7 @@ const Template = args => (h("main", null,
|
|
|
25
25
|
h("span", { class: "mg-message__content-slot", innerHTML: args.content })),
|
|
26
26
|
h("span", { class: "mg-message__close-button" },
|
|
27
27
|
h("button", { class: "mg-button mg-button--flat mg-button--icon" },
|
|
28
|
-
h("mg-icon", { icon: "cross"
|
|
28
|
+
h("mg-icon", { icon: "cross" })))),
|
|
29
29
|
h("h2", null, "w/ actions"),
|
|
30
30
|
h("div", { class: `mg-message mg-message--${args.variant}` },
|
|
31
31
|
h("span", { class: "mg-message__icon" },
|
|
@@ -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,7 +1,8 @@
|
|
|
1
1
|
import { locale, currency } from '../locales';
|
|
2
2
|
/**
|
|
3
3
|
* Format number to the locale currency
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* @param {number} number number to format
|
|
5
6
|
* @returns {string} formatted currency
|
|
6
7
|
*/
|
|
7
8
|
export function localeCurrency(number) {
|
|
@@ -9,7 +10,8 @@ export function localeCurrency(number) {
|
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Format number to locale
|
|
12
|
-
*
|
|
13
|
+
*
|
|
14
|
+
* @param {number} number number to format
|
|
13
15
|
* @returns {string} formatted number
|
|
14
16
|
*/
|
|
15
17
|
export function localeNumber(number) {
|
|
@@ -21,7 +23,8 @@ export function localeNumber(number) {
|
|
|
21
23
|
export const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
22
24
|
/**
|
|
23
25
|
* Locale date format
|
|
24
|
-
*
|
|
26
|
+
*
|
|
27
|
+
* @param {string} date date to format
|
|
25
28
|
* @returns {string} formatted date
|
|
26
29
|
*/
|
|
27
30
|
export function localeDate(date) {
|
|
@@ -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));
|
|
@@ -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
|
*/
|
|
@@ -95,6 +110,7 @@
|
|
|
95
110
|
--mg-button-border-radius: 0.3rem;
|
|
96
111
|
--mg-button-icon-border-radius: var(--default-size);
|
|
97
112
|
--mg-button-disabled-opacity: 0.6;
|
|
113
|
+
--mg-button-gradient: 1; /* Can only be 1 or 0 to enable disable gradient */
|
|
98
114
|
|
|
99
115
|
/* Primary */
|
|
100
116
|
--mg-button-primary-color-h: var(--color-dark-h);
|
|
@@ -140,6 +156,20 @@
|
|
|
140
156
|
*/
|
|
141
157
|
--mg-message-border-radius: 0.3rem;
|
|
142
158
|
|
|
159
|
+
/*
|
|
160
|
+
<mg-modal>
|
|
161
|
+
*/
|
|
162
|
+
--mg-modal-border-radius: 0.5rem;
|
|
163
|
+
--mg-modal-title-font-size: 1.8rem;
|
|
164
|
+
--mg-modal-content-font-size: 1.2rem;
|
|
165
|
+
|
|
166
|
+
/*
|
|
167
|
+
<mg-panel>
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
--mg-panel-border-radius: 0.5rem;
|
|
171
|
+
--mg-panel-background: var(--color-info-h) var(--color-info-s) calc(var(--color-info-l) + 68%);
|
|
172
|
+
|
|
143
173
|
/*
|
|
144
174
|
Layout
|
|
145
175
|
*/
|
|
@@ -148,7 +178,6 @@
|
|
|
148
178
|
/*
|
|
149
179
|
Forms
|
|
150
180
|
*/
|
|
151
|
-
--mg-form-group-vertical-space: 1.5rem;
|
|
152
181
|
|
|
153
182
|
/*
|
|
154
183
|
<mg-input-...>
|
|
@@ -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
|
*/
|
|
@@ -95,6 +110,7 @@
|
|
|
95
110
|
--mg-button-border-radius: 0.3rem;
|
|
96
111
|
--mg-button-icon-border-radius: var(--default-size);
|
|
97
112
|
--mg-button-disabled-opacity: 0.6;
|
|
113
|
+
--mg-button-gradient: 1; /* Can only be 1 or 0 to enable disable gradient */
|
|
98
114
|
|
|
99
115
|
/* Primary */
|
|
100
116
|
--mg-button-primary-color-h: var(--color-dark-h);
|
|
@@ -140,6 +156,20 @@
|
|
|
140
156
|
*/
|
|
141
157
|
--mg-message-border-radius: 0.3rem;
|
|
142
158
|
|
|
159
|
+
/*
|
|
160
|
+
<mg-modal>
|
|
161
|
+
*/
|
|
162
|
+
--mg-modal-border-radius: 0.5rem;
|
|
163
|
+
--mg-modal-title-font-size: 1.8rem;
|
|
164
|
+
--mg-modal-content-font-size: 1.2rem;
|
|
165
|
+
|
|
166
|
+
/*
|
|
167
|
+
<mg-panel>
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
--mg-panel-border-radius: 0.5rem;
|
|
171
|
+
--mg-panel-background: var(--color-info-h) var(--color-info-s) calc(var(--color-info-l) + 68%);
|
|
172
|
+
|
|
143
173
|
/*
|
|
144
174
|
Layout
|
|
145
175
|
*/
|
|
@@ -148,7 +178,6 @@
|
|
|
148
178
|
/*
|
|
149
179
|
Forms
|
|
150
180
|
*/
|
|
151
|
-
--mg-form-group-vertical-space: 1.5rem;
|
|
152
181
|
|
|
153
182
|
/*
|
|
154
183
|
<mg-input-...>
|
|
@@ -10,10 +10,11 @@ var InputClass;
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Apply in all input child node the aria-describedby attribute
|
|
13
|
-
*
|
|
14
|
-
* @param
|
|
15
|
-
* @param
|
|
16
|
-
* @
|
|
13
|
+
*
|
|
14
|
+
* @param {VNode[]} children Represent scoped elements
|
|
15
|
+
* @param {Set<string>} ariaDescribedbyIDs List of IDs
|
|
16
|
+
* @param {FunctionalUtilities} utils Stencil.js utils
|
|
17
|
+
* @returns {VNode[]} Children with aria-describedby attribute
|
|
17
18
|
*/
|
|
18
19
|
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
19
20
|
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
@@ -26,7 +27,8 @@ const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(
|
|
|
26
27
|
});
|
|
27
28
|
/**
|
|
28
29
|
* Add classes based on props
|
|
29
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* @param {MgInputProps} props MgInput Interface Props
|
|
30
32
|
*/
|
|
31
33
|
const manageClasses = (props) => {
|
|
32
34
|
props.classList.add('mg-input');
|
|
@@ -41,17 +43,19 @@ const manageClasses = (props) => {
|
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
45
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
+
* Get tagname
|
|
47
|
+
*
|
|
48
|
+
* @param {boolean} isFieldset is fieldset
|
|
46
49
|
* @returns {string} tag name
|
|
47
50
|
*/
|
|
48
51
|
const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
|
|
49
52
|
/**
|
|
50
53
|
* Get input template
|
|
51
|
-
*
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
54
|
-
* @
|
|
54
|
+
*
|
|
55
|
+
* @param {MgInputProps} props MgInput Interface Props
|
|
56
|
+
* @param {VNode[]} children Represent scoped elements
|
|
57
|
+
* @param {FunctionalUtilities} utils Stencil.js utils
|
|
58
|
+
* @returns {VNode[]} input template
|
|
55
59
|
*/
|
|
56
60
|
const MgInput = (props, children, utils) => {
|
|
57
61
|
/**
|
|
@@ -113,15 +117,17 @@ const MgInput = (props, children, utils) => {
|
|
|
113
117
|
const TagName = getTagName(props.isFieldset);
|
|
114
118
|
/**
|
|
115
119
|
* Get tooltip node
|
|
116
|
-
*
|
|
120
|
+
*
|
|
121
|
+
* @returns {VNode[]} mg-tooltip
|
|
117
122
|
*/
|
|
118
123
|
const getTooltip = () => (h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
|
|
119
124
|
h("mg-icon", { icon: "info-circle" })));
|
|
120
125
|
/**
|
|
121
126
|
* Get input title (label) node
|
|
122
|
-
*
|
|
127
|
+
*
|
|
128
|
+
* @returns {VNode[]} mg-input-title
|
|
123
129
|
*/
|
|
124
|
-
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required, "is-legend": props.isFieldset }, props.label));
|
|
130
|
+
const getInputTitle = () => (h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled, "is-legend": props.isFieldset }, props.label));
|
|
125
131
|
return (h(TagName, { class: props.classList.join() },
|
|
126
132
|
props.labelOnTop ? (h("div", { class: "mg-input__title" },
|
|
127
133
|
getInputTitle(),
|
|
@@ -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
|
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 @@ 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 @@ 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 @@ 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 @@ 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
|
function allItemsAreString(items) {
|
|
66
73
|
return items && items.every(item => typeof item === 'string');
|
|
@@ -9,7 +9,7 @@ import type { Components, JSX } from "../types/components";
|
|
|
9
9
|
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
10
10
|
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
11
11
|
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
12
|
-
*
|
|
12
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
13
13
|
* will have to ensure the static assets are copied to its build directory.
|
|
14
14
|
*/
|
|
15
15
|
export declare const setAssetPath: (path: string) => void;
|