@mgdis/mg-components 3.3.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-bead7dbd.js → index-88560a66.js} +47 -48
- package/dist/cjs/{index-369388eb.js → index-a39c5567.js} +97 -10
- package/dist/cjs/loader.cjs.js +3 -17
- package/dist/cjs/mg-badge_21.cjs.entry.js +461 -281
- package/dist/cjs/mg-components.cjs.js +3 -7
- package/dist/cjs/mg-modal.cjs.entry.js +12 -6
- package/dist/cjs/mg-popover.cjs.entry.js +15 -6
- package/dist/cjs/{popper-0c3964e7.js → popper-71bf3058.js} +6 -2
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.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 +15 -3
- package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +2 -2
- package/dist/collection/components/atoms/mg-button/mg-button.css +6 -30
- package/dist/collection/components/atoms/mg-button/mg-button.js +7 -2
- package/dist/collection/components/atoms/mg-character-left/{mg-character-left.stories.js → doc/mg-character-left.stories.js} +1 -1
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +10 -47
- 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 +86 -10
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +4 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +22 -6
- 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-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +1 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +19 -4
- 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 +7 -2
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
- package/dist/collection/components/molecules/inputs/MgInput.js +5 -15
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +19 -13
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +8 -21
- package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +19 -18
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +19 -18
- package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +9 -2
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +20 -19
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +43 -19
- package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +10 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +19 -18
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +17 -22
- package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +19 -13
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +8 -15
- package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +10 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +20 -18
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +24 -31
- package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +11 -7
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +51 -28
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +42 -43
- package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +10 -4
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +51 -22
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +64 -37
- package/dist/collection/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.js → doc/mg-input-toggle.stories.js} +0 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +18 -9
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +9 -3
- package/dist/collection/components/molecules/mg-form/{mg-form.stories.js → doc/mg-form.stories.js} +0 -0
- package/dist/collection/components/molecules/mg-form/mg-form.css +4 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +5 -3
- package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +15 -7
- package/dist/collection/components/molecules/mg-modal/{mg-modal.stories.js → doc/mg-modal.stories.js} +0 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +5 -7
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +10 -4
- package/dist/collection/components/molecules/mg-pagination/{mg-pagination.stories.js → doc/mg-pagination.stories.js} +0 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +17 -18
- package/dist/collection/components/molecules/mg-panel/{mg-panel.stories.js → doc/mg-panel.stories.js} +0 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +5 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +10 -9
- 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.js +19 -5
- package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +11 -5
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +7 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +3 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +72 -26
- package/dist/collection/locales/index.js +33 -4
- package/dist/collection/stories/helpers.stories.js +33 -0
- package/dist/collection/utils/locale.utils.js +7 -4
- package/dist/collection/variables.css +10 -5
- package/dist/collection/variables.scss +10 -5
- package/dist/components/MgInput.js +6 -23
- package/dist/components/index.d.ts +23 -5
- package/dist/components/index.js +23 -0
- package/dist/components/index2.js +97 -8
- package/dist/components/locale.utils.js +7 -5
- package/dist/components/mg-badge2.js +16 -4
- package/dist/components/mg-button2.js +8 -3
- package/dist/components/mg-character-left2.js +4 -27
- package/dist/components/mg-form.js +6 -4
- package/dist/components/mg-icon2.js +109 -17
- package/dist/components/mg-input-checkbox.js +11 -27
- package/dist/components/mg-input-date.js +21 -25
- package/dist/components/mg-input-numeric.js +28 -26
- package/dist/components/mg-input-password.js +18 -28
- package/dist/components/mg-input-radio.js +10 -22
- package/dist/components/mg-input-select2.js +24 -35
- package/dist/components/mg-input-text2.js +38 -26
- package/dist/components/mg-input-textarea.js +43 -20
- package/dist/components/mg-input-toggle.js +11 -11
- package/dist/components/mg-message.js +16 -8
- package/dist/components/mg-modal.js +11 -5
- package/dist/components/mg-pagination.js +16 -22
- package/dist/components/mg-panel.js +8 -7
- package/dist/components/mg-popover.js +13 -4
- package/dist/components/mg-tabs.js +75 -21
- package/dist/components/mg-tag.js +20 -5
- package/dist/components/mg-tooltip2.js +1 -1
- package/dist/components/popper.js +6 -2
- package/dist/esm/{index-9e877561.js → index-bca81100.js} +48 -46
- package/dist/esm/{index-c346f52d.js → index-e51ae032.js} +97 -8
- package/dist/esm/loader.js +3 -17
- package/dist/esm/mg-badge_21.entry.js +458 -278
- package/dist/esm/mg-components.js +3 -7
- package/dist/esm/mg-modal.entry.js +12 -6
- package/dist/esm/mg-popover.entry.js +15 -6
- package/dist/esm/{popper-8874fd6c.js → popper-93ecb064.js} +6 -2
- 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 +10 -5
- package/dist/mg-components/variables.scss +10 -5
- package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -1
- package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +1 -1
- package/dist/types/components/atoms/mg-character-left/{mg-character-left.stories.d.ts → doc/mg-character-left.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +5 -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.d.ts +3 -3
- 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-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +8 -1
- 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 +2 -1
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +0 -6
- package/dist/types/components/molecules/inputs/MgInput.d.ts +2 -4
- package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +5 -2
- package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +7 -1
- package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +6 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +8 -2
- package/dist/types/components/molecules/inputs/mg-input-password/{mg-input-password.stories.d.ts → doc/mg-input-password.stories.d.ts} +8 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +7 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +5 -1
- package/dist/types/components/molecules/inputs/mg-input-select/{mg-input-select.stories.d.ts → doc/mg-input-select.stories.d.ts} +11 -5
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +7 -2
- package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +8 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +7 -7
- package/dist/types/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.d.ts → doc/mg-input-textarea.stories.d.ts} +8 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +14 -6
- package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.stories.d.ts} +0 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +2 -0
- package/dist/types/components/molecules/mg-form/{mg-form.stories.d.ts → doc/mg-form.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -0
- package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +2 -0
- package/dist/types/components/molecules/mg-modal/{mg-modal.stories.d.ts → doc/mg-modal.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +2 -0
- package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +8 -0
- package/dist/types/components/molecules/mg-panel/{mg-panel.stories.d.ts → doc/mg-panel.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +5 -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 +9 -1
- package/dist/types/components/molecules/mg-tabs/{mg-tabs.stories.d.ts → doc/mg-tabs.stories.d.ts} +0 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +7 -1
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +44 -0
- package/dist/types/components.d.ts +149 -151
- package/dist/types/locales/index.d.ts +109 -46
- package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
- package/dist/types/utils/locale.utils.d.ts +7 -3
- package/loader/index.js +1 -1
- package/package.json +41 -14
- package/readme.md +6 -35
- package/dist/cjs/css-shim-629916b0.js +0 -6
- package/dist/cjs/shadow-css-546083ef.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-0993aa3b.js +0 -4
- package/dist/esm/shadow-css-dfa0587f.js +0 -388
- package/dist/esm-es5/css-shim-0993aa3b.js +0 -1
- package/dist/esm-es5/index-9e877561.js +0 -1
- package/dist/esm-es5/index-c346f52d.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_21.entry.js +0 -2
- package/dist/esm-es5/mg-components.js +0 -1
- package/dist/esm-es5/mg-modal.entry.js +0 -1
- package/dist/esm-es5/mg-popover.entry.js +0 -1
- package/dist/esm-es5/popper-8874fd6c.js +0 -1
- package/dist/esm-es5/shadow-css-dfa0587f.js +0 -12
- package/dist/mg-components/mg-components.js +0 -132
- package/dist/mg-components/p-136c8d6f.system.entry.js +0 -2
- package/dist/mg-components/p-3c14153d.js +0 -1
- package/dist/mg-components/p-50ea2036.system.js +0 -1
- package/dist/mg-components/p-55a22b35.system.js +0 -1
- package/dist/mg-components/p-5e796581.js +0 -12
- package/dist/mg-components/p-656b5efb.system.js +0 -1
- package/dist/mg-components/p-68d6f104.js +0 -1
- package/dist/mg-components/p-6d49ed95.js +0 -1
- package/dist/mg-components/p-6f173f62.system.entry.js +0 -1
- package/dist/mg-components/p-70177194.entry.js +0 -1
- package/dist/mg-components/p-8b2d8a2a.system.js +0 -13
- package/dist/mg-components/p-8cb61c3f.system.js +0 -1
- package/dist/mg-components/p-ace173b1.js +0 -1
- package/dist/mg-components/p-b7488a4c.entry.js +0 -1
- package/dist/mg-components/p-c1ffb2e1.entry.js +0 -1
- package/dist/mg-components/p-c90cc4bf.system.js +0 -1
- package/dist/mg-components/p-de1164fa.system.entry.js +0 -1
- package/dist/mg-components/p-e4a502b5.system.js +0 -1
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +0 -12
- package/dist/types/stories/messages.stories.d.ts +0 -13
- package/dist/types/stories/tags.stories.d.ts +0 -5
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Component, Event, h, Prop, State, Method, Watch } from '@stencil/core';
|
|
1
|
+
import { Component, Element, Event, h, Prop, State, Method, Watch } from '@stencil/core';
|
|
2
2
|
import { MgInput } from '../MgInput';
|
|
3
|
-
import { InputClass } from '../MgInput.conf';
|
|
4
3
|
import { createID, ClassList } from '../../../../utils/components.utils';
|
|
5
|
-
import {
|
|
4
|
+
import { initLocales } from '../../../../locales';
|
|
6
5
|
export class MgInputTextarea {
|
|
7
6
|
constructor() {
|
|
8
7
|
/************
|
|
@@ -10,7 +9,9 @@ export class MgInputTextarea {
|
|
|
10
9
|
************/
|
|
11
10
|
// classes
|
|
12
11
|
this.classFocus = 'is-focused';
|
|
13
|
-
this.
|
|
12
|
+
this.classHasDisplayCharacterLeft = 'mg-input--has-display-character-left';
|
|
13
|
+
// hasError (triggered by blur event)
|
|
14
|
+
this.hasError = false;
|
|
14
15
|
/**
|
|
15
16
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
16
17
|
* If not set, it will be created.
|
|
@@ -44,7 +45,7 @@ export class MgInputTextarea {
|
|
|
44
45
|
/**
|
|
45
46
|
* Define input width
|
|
46
47
|
*/
|
|
47
|
-
this.
|
|
48
|
+
this.mgWidth = 'full';
|
|
48
49
|
/**
|
|
49
50
|
* Define the number of visible text lines for the control
|
|
50
51
|
*/
|
|
@@ -53,6 +54,10 @@ export class MgInputTextarea {
|
|
|
53
54
|
* Define if component should display character left
|
|
54
55
|
*/
|
|
55
56
|
this.displayCharacterLeft = true;
|
|
57
|
+
/**
|
|
58
|
+
* Define if input is resizable
|
|
59
|
+
*/
|
|
60
|
+
this.resizable = 'none';
|
|
56
61
|
/**
|
|
57
62
|
* Component classes
|
|
58
63
|
*/
|
|
@@ -61,6 +66,10 @@ export class MgInputTextarea {
|
|
|
61
66
|
* Handle input event
|
|
62
67
|
*/
|
|
63
68
|
this.handleInput = () => {
|
|
69
|
+
if (this.hasError) {
|
|
70
|
+
this.checkValidity();
|
|
71
|
+
this.checkError();
|
|
72
|
+
}
|
|
64
73
|
this.value = this.input.value;
|
|
65
74
|
};
|
|
66
75
|
/**
|
|
@@ -77,9 +86,8 @@ export class MgInputTextarea {
|
|
|
77
86
|
// Manage focus
|
|
78
87
|
this.classList.delete(this.classFocus);
|
|
79
88
|
this.classList = new ClassList(this.classList.classes);
|
|
80
|
-
//
|
|
81
|
-
this.
|
|
82
|
-
this.checkError();
|
|
89
|
+
// Display Error
|
|
90
|
+
this.displayError();
|
|
83
91
|
};
|
|
84
92
|
/**
|
|
85
93
|
* Get pattern validity
|
|
@@ -113,14 +121,7 @@ export class MgInputTextarea {
|
|
|
113
121
|
}
|
|
114
122
|
// required
|
|
115
123
|
else if (!this.valid && this.input.validity.valueMissing) {
|
|
116
|
-
this.errorMessage = messages.errors.required;
|
|
117
|
-
}
|
|
118
|
-
// Update class
|
|
119
|
-
if (this.valid) {
|
|
120
|
-
this.classList.delete(this.classError);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
this.classList.add(this.classError);
|
|
124
|
+
this.errorMessage = this.messages.errors.required;
|
|
124
125
|
}
|
|
125
126
|
};
|
|
126
127
|
/**
|
|
@@ -139,6 +140,14 @@ export class MgInputTextarea {
|
|
|
139
140
|
this.checkValidity();
|
|
140
141
|
this.valueChange.emit(newValue);
|
|
141
142
|
}
|
|
143
|
+
validateDisplayCharacterLeft(newValue) {
|
|
144
|
+
if (newValue) {
|
|
145
|
+
this.classList.add(this.classHasDisplayCharacterLeft);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this.classList.delete(this.classHasDisplayCharacterLeft);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
142
151
|
/**
|
|
143
152
|
* Public method to display errors
|
|
144
153
|
*
|
|
@@ -147,6 +156,7 @@ export class MgInputTextarea {
|
|
|
147
156
|
async displayError() {
|
|
148
157
|
this.checkValidity();
|
|
149
158
|
this.checkError();
|
|
159
|
+
this.hasError = this.invalid;
|
|
150
160
|
}
|
|
151
161
|
/*************
|
|
152
162
|
* Lifecycle *
|
|
@@ -157,6 +167,11 @@ export class MgInputTextarea {
|
|
|
157
167
|
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
158
168
|
*/
|
|
159
169
|
componentWillLoad() {
|
|
170
|
+
// Get locales
|
|
171
|
+
this.messages = initLocales(this.element).messages;
|
|
172
|
+
this.characterLeftId = `${this.identifier}-character-left`;
|
|
173
|
+
// Validate
|
|
174
|
+
this.validateDisplayCharacterLeft(this.displayCharacterLeft);
|
|
160
175
|
this.validatePattern();
|
|
161
176
|
// Check validity when component is ready
|
|
162
177
|
// return a promise to process action only in the FIRST render().
|
|
@@ -171,8 +186,15 @@ export class MgInputTextarea {
|
|
|
171
186
|
* @returns {HTMLElement} HTML Element
|
|
172
187
|
*/
|
|
173
188
|
render() {
|
|
174
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly,
|
|
175
|
-
h("
|
|
189
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false },
|
|
190
|
+
h("div", { class: "mg-input__with-character-left" },
|
|
191
|
+
h("textarea", { class: {
|
|
192
|
+
'mg-input__box': true,
|
|
193
|
+
'mg-input__box--resizable': this.resizable === 'both',
|
|
194
|
+
'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
195
|
+
'mg-input__box--resizable-vertical': this.resizable === 'vertical',
|
|
196
|
+
}, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }),
|
|
197
|
+
this.displayCharacterLeft && this.maxlength && (h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
|
|
176
198
|
}
|
|
177
199
|
static get is() { return "mg-input-textarea"; }
|
|
178
200
|
static get encapsulation() { return "shadow"; }
|
|
@@ -377,7 +399,7 @@ export class MgInputTextarea {
|
|
|
377
399
|
"reflect": false,
|
|
378
400
|
"defaultValue": "false"
|
|
379
401
|
},
|
|
380
|
-
"
|
|
402
|
+
"mgWidth": {
|
|
381
403
|
"type": "any",
|
|
382
404
|
"mutable": false,
|
|
383
405
|
"complexType": {
|
|
@@ -396,7 +418,7 @@ export class MgInputTextarea {
|
|
|
396
418
|
"tags": [],
|
|
397
419
|
"text": "Define input width"
|
|
398
420
|
},
|
|
399
|
-
"attribute": "width",
|
|
421
|
+
"attribute": "mg-width",
|
|
400
422
|
"reflect": false,
|
|
401
423
|
"defaultValue": "'full'"
|
|
402
424
|
},
|
|
@@ -487,23 +509,6 @@ export class MgInputTextarea {
|
|
|
487
509
|
"reflect": false,
|
|
488
510
|
"defaultValue": "true"
|
|
489
511
|
},
|
|
490
|
-
"characterLeftTemplate": {
|
|
491
|
-
"type": "string",
|
|
492
|
-
"mutable": false,
|
|
493
|
-
"complexType": {
|
|
494
|
-
"original": "string",
|
|
495
|
-
"resolved": "string",
|
|
496
|
-
"references": {}
|
|
497
|
-
},
|
|
498
|
-
"required": false,
|
|
499
|
-
"optional": false,
|
|
500
|
-
"docs": {
|
|
501
|
-
"tags": [],
|
|
502
|
-
"text": "Template to use for characters left sentence"
|
|
503
|
-
},
|
|
504
|
-
"attribute": "character-left-template",
|
|
505
|
-
"reflect": false
|
|
506
|
-
},
|
|
507
512
|
"helpText": {
|
|
508
513
|
"type": "string",
|
|
509
514
|
"mutable": false,
|
|
@@ -554,6 +559,24 @@ export class MgInputTextarea {
|
|
|
554
559
|
},
|
|
555
560
|
"attribute": "invalid",
|
|
556
561
|
"reflect": false
|
|
562
|
+
},
|
|
563
|
+
"resizable": {
|
|
564
|
+
"type": "string",
|
|
565
|
+
"mutable": false,
|
|
566
|
+
"complexType": {
|
|
567
|
+
"original": "'none' | 'both' | 'horizontal' | 'vertical'",
|
|
568
|
+
"resolved": "\"both\" | \"horizontal\" | \"none\" | \"vertical\"",
|
|
569
|
+
"references": {}
|
|
570
|
+
},
|
|
571
|
+
"required": false,
|
|
572
|
+
"optional": false,
|
|
573
|
+
"docs": {
|
|
574
|
+
"tags": [],
|
|
575
|
+
"text": "Define if input is resizable"
|
|
576
|
+
},
|
|
577
|
+
"attribute": "resizable",
|
|
578
|
+
"reflect": false,
|
|
579
|
+
"defaultValue": "'none'"
|
|
557
580
|
}
|
|
558
581
|
}; }
|
|
559
582
|
static get states() { return {
|
|
@@ -612,8 +635,12 @@ export class MgInputTextarea {
|
|
|
612
635
|
}
|
|
613
636
|
}
|
|
614
637
|
}; }
|
|
638
|
+
static get elementRef() { return "element"; }
|
|
615
639
|
static get watchers() { return [{
|
|
616
640
|
"propName": "value",
|
|
617
641
|
"methodName": "handleValue"
|
|
642
|
+
}, {
|
|
643
|
+
"propName": "displayCharacterLeft",
|
|
644
|
+
"methodName": "validateDisplayCharacterLeft"
|
|
618
645
|
}]; }
|
|
619
646
|
}
|
|
File without changes
|
|
@@ -11,16 +11,9 @@
|
|
|
11
11
|
min-height: var(--default-size);
|
|
12
12
|
max-width: 100%;
|
|
13
13
|
margin-bottom: var(--mg-inputs-margin-bottom, 0);
|
|
14
|
-
/* Style when input is not valid */
|
|
15
14
|
/* Label */
|
|
16
15
|
/* Label-on-top */
|
|
17
16
|
}
|
|
18
|
-
.mg-input.is-not-valid {
|
|
19
|
-
color: hsl(var(--color-danger));
|
|
20
|
-
}
|
|
21
|
-
.mg-input.is-not-valid .mg-input__box {
|
|
22
|
-
border-color: hsl(var(--color-danger));
|
|
23
|
-
}
|
|
24
17
|
.mg-input mg-input-title {
|
|
25
18
|
flex-shrink: var(--mg-inputs-shrink, 1);
|
|
26
19
|
width: var(--mg-inputs-title-width, auto);
|
|
@@ -74,6 +67,11 @@
|
|
|
74
67
|
.mg-input__input-container mg-icon {
|
|
75
68
|
display: flex;
|
|
76
69
|
}
|
|
70
|
+
.mg-input__input-container .mg-input__help-text,
|
|
71
|
+
.mg-input__input-container .mg-input__error {
|
|
72
|
+
text-align: start;
|
|
73
|
+
font-size: 1.2rem;
|
|
74
|
+
}
|
|
77
75
|
|
|
78
76
|
.mg-input__input {
|
|
79
77
|
display: flex;
|
|
@@ -82,11 +80,22 @@
|
|
|
82
80
|
.mg-input__input mg-tooltip {
|
|
83
81
|
margin-top: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);
|
|
84
82
|
}
|
|
85
|
-
.mg-input__input
|
|
86
|
-
|
|
83
|
+
.mg-input__input.mg-input__input--has-error .mg-input__box {
|
|
84
|
+
border-color: hsl(var(--color-danger));
|
|
85
|
+
}
|
|
86
|
+
.mg-input__input + .mg-input__help-text, .mg-input__input + .mg-input__error {
|
|
87
87
|
margin-top: 0.5rem;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
.mg-input__error {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
margin-top: 0.2rem;
|
|
93
|
+
padding: 0.3rem 0.8rem;
|
|
94
|
+
border-radius: 0.3rem;
|
|
95
|
+
background: hsl(var(--mg-inputs-error-bg-color));
|
|
96
|
+
color: hsl(var(--color-danger));
|
|
97
|
+
}
|
|
98
|
+
|
|
90
99
|
/**
|
|
91
100
|
* A11Y
|
|
92
101
|
*/
|
|
@@ -19,6 +19,8 @@ export class MgInputToggle {
|
|
|
19
19
|
this.classReadonly = 'mg-input--toggle-readonly';
|
|
20
20
|
this.classDisabled = 'mg-input--toggle-disabled';
|
|
21
21
|
this.classIsActive = 'mg-input--toggle-is-active';
|
|
22
|
+
this.classOnOff = 'mg-input--toggle-on-off';
|
|
23
|
+
this.classIcon = 'mg-input--toggle-icon';
|
|
22
24
|
/**
|
|
23
25
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
24
26
|
* If not set, it will be created.
|
|
@@ -106,11 +108,15 @@ export class MgInputToggle {
|
|
|
106
108
|
}
|
|
107
109
|
handleIsOnOff(newValue) {
|
|
108
110
|
if (newValue)
|
|
109
|
-
this.classList.add(
|
|
111
|
+
this.classList.add(this.classOnOff);
|
|
112
|
+
else
|
|
113
|
+
this.classList.delete(this.classOnOff);
|
|
110
114
|
}
|
|
111
115
|
handleIsIcon(newValue) {
|
|
112
116
|
if (newValue)
|
|
113
|
-
this.classList.add(
|
|
117
|
+
this.classList.add(this.classIcon);
|
|
118
|
+
else
|
|
119
|
+
this.classList.delete(this.classIcon);
|
|
114
120
|
}
|
|
115
121
|
handleReadonly(newValue) {
|
|
116
122
|
if (newValue)
|
|
@@ -173,7 +179,7 @@ export class MgInputToggle {
|
|
|
173
179
|
* @returns {HTMLElement} HTML Element
|
|
174
180
|
*/
|
|
175
181
|
render() {
|
|
176
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined,
|
|
182
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false },
|
|
177
183
|
h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked },
|
|
178
184
|
h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" },
|
|
179
185
|
h("slot", { name: "item-1" })),
|
package/dist/collection/components/molecules/mg-form/{mg-form.stories.js → doc/mg-form.stories.js}
RENAMED
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, Element, Event, h, Method, Prop, State } from '@stencil/core';
|
|
2
2
|
import { createID, ClassList } from '../../../utils/components.utils';
|
|
3
|
-
import {
|
|
3
|
+
import { initLocales } from '../../../locales';
|
|
4
4
|
export class MgForm {
|
|
5
5
|
constructor() {
|
|
6
6
|
/**
|
|
@@ -37,12 +37,12 @@ export class MgForm {
|
|
|
37
37
|
// All fields are required
|
|
38
38
|
// mg-input-toggle can not be required
|
|
39
39
|
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
40
|
-
this.requiredMessage = messages.form.allRequired;
|
|
40
|
+
this.requiredMessage = this.messages.form.allRequired;
|
|
41
41
|
this.classList.add('mg-form--all-required');
|
|
42
42
|
}
|
|
43
43
|
// Some fields are required
|
|
44
44
|
else if (requiredInputs.length > 0) {
|
|
45
|
-
this.requiredMessage = messages.form.required;
|
|
45
|
+
this.requiredMessage = this.messages.form.required;
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
@@ -79,6 +79,8 @@ export class MgForm {
|
|
|
79
79
|
* @returns {void}
|
|
80
80
|
*/
|
|
81
81
|
componentWillLoad() {
|
|
82
|
+
// Get locales
|
|
83
|
+
this.messages = initLocales(this.element).messages;
|
|
82
84
|
// Get slotted mgIputs
|
|
83
85
|
this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
|
|
84
86
|
// Define required message
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Component, Element, Event, h, Prop, State, Watch } from '@stencil/core';
|
|
2
2
|
import { createID, ClassList } from '../../../utils/components.utils';
|
|
3
3
|
import { variants } from './mg-message.conf';
|
|
4
|
-
import {
|
|
4
|
+
import { initLocales } from '../../../locales';
|
|
5
5
|
export class MgMessage {
|
|
6
6
|
constructor() {
|
|
7
7
|
/************
|
|
8
8
|
* Internal *
|
|
9
9
|
************/
|
|
10
|
+
// classes
|
|
11
|
+
this.classHide = 'mg-message--hide';
|
|
12
|
+
// IDs
|
|
10
13
|
this.closeButtonId = '';
|
|
11
14
|
// Stored timer setted when hide action is run from setTimeOut
|
|
12
15
|
this.storedTimer = null;
|
|
@@ -82,10 +85,12 @@ export class MgMessage {
|
|
|
82
85
|
if (!variants.includes(newValue)) {
|
|
83
86
|
throw new Error(`<mg-message> prop "variant" must be one of : ${variants.join(', ')}`);
|
|
84
87
|
}
|
|
85
|
-
|
|
86
|
-
|
|
88
|
+
else {
|
|
89
|
+
if (oldValue !== undefined) {
|
|
90
|
+
this.classList.delete(`mg-message--${oldValue}`);
|
|
91
|
+
}
|
|
92
|
+
this.classList.add(`mg-message--${newValue}`);
|
|
87
93
|
}
|
|
88
|
-
this.classList.add(`mg-message--${this.variant}`);
|
|
89
94
|
}
|
|
90
95
|
validateCloseButton(newValue) {
|
|
91
96
|
if (newValue && this.hasActions) {
|
|
@@ -96,11 +101,11 @@ export class MgMessage {
|
|
|
96
101
|
validateHide(newValue) {
|
|
97
102
|
if (newValue) {
|
|
98
103
|
this.componentHide.emit();
|
|
99
|
-
this.classList.add(
|
|
104
|
+
this.classList.add(this.classHide);
|
|
100
105
|
}
|
|
101
106
|
else {
|
|
102
107
|
this.componentShow.emit();
|
|
103
|
-
this.classList.delete(
|
|
108
|
+
this.classList.delete(this.classHide);
|
|
104
109
|
}
|
|
105
110
|
this.hideWithDelay();
|
|
106
111
|
}
|
|
@@ -111,6 +116,9 @@ export class MgMessage {
|
|
|
111
116
|
* Check if component props are well configured on init
|
|
112
117
|
*/
|
|
113
118
|
componentWillLoad() {
|
|
119
|
+
// Get locales
|
|
120
|
+
this.messages = initLocales(this.element).messages;
|
|
121
|
+
// Validate
|
|
114
122
|
this.validateVariant(this.variant);
|
|
115
123
|
// Check if close button is an can be activated
|
|
116
124
|
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
@@ -138,7 +146,7 @@ export class MgMessage {
|
|
|
138
146
|
this.hasActions && (h("span", { class: "mg-message__content-actions-slot" },
|
|
139
147
|
h("slot", { name: "actions" })))),
|
|
140
148
|
this.closeButton && (h("span", { class: "mg-message__close-button" },
|
|
141
|
-
h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: messages.message.closeButton, onClick: this.handleClose },
|
|
149
|
+
h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose },
|
|
142
150
|
h("mg-icon", { icon: "cross" }))))));
|
|
143
151
|
}
|
|
144
152
|
static get is() { return "mg-message"; }
|
|
File without changes
|
|
@@ -9,13 +9,11 @@
|
|
|
9
9
|
left: 0;
|
|
10
10
|
z-index: 1000;
|
|
11
11
|
padding: 2rem 0;
|
|
12
|
-
background-color: hsla(var(--color-light),
|
|
12
|
+
background-color: hsla(var(--color-light), 85%);
|
|
13
13
|
}
|
|
14
14
|
.mg-modal__dialog {
|
|
15
15
|
display: flex;
|
|
16
16
|
flex-direction: column;
|
|
17
|
-
flex: none;
|
|
18
|
-
/* IE FIX */
|
|
19
17
|
align-self: center;
|
|
20
18
|
row-gap: 3rem;
|
|
21
19
|
padding: 1.5rem 2.5rem;
|
|
@@ -37,16 +35,16 @@
|
|
|
37
35
|
font-size: var(--mg-modal-title-font-size);
|
|
38
36
|
font-weight: 600;
|
|
39
37
|
}
|
|
40
|
-
.mg-modal__content {
|
|
41
|
-
overflow-y: auto;
|
|
42
|
-
}
|
|
43
38
|
.mg-modal__close-button {
|
|
44
39
|
float: right;
|
|
45
40
|
height: var(--mg-modal-title-font-size);
|
|
46
41
|
margin-top: calc((var(--default-size) - var(--mg-modal-title-font-size) * var(--line-height)) / 2 * -1);
|
|
47
42
|
margin-right: calc((var(--default-size) - var(--mg-icon-regular-size)) / 2 * -1);
|
|
48
43
|
}
|
|
49
|
-
.mg-modal .mg-modal__content
|
|
44
|
+
.mg-modal .mg-modal__content {
|
|
45
|
+
overflow-y: auto;
|
|
46
|
+
}
|
|
47
|
+
.mg-modal .mg-modal__content::slotted(*) {
|
|
50
48
|
font-size: var(--mg-modal-content-font-size);
|
|
51
49
|
}
|
|
52
50
|
.mg-modal.mg-modal--hide {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Component, h, Prop, State, Watch, Element, Event, Listen } from '@stencil/core';
|
|
2
2
|
import { createID, ClassList } from '../../../utils/components.utils';
|
|
3
|
-
import {
|
|
3
|
+
import { initLocales } from '../../../locales';
|
|
4
4
|
export class MgModal {
|
|
5
5
|
constructor() {
|
|
6
6
|
/************
|
|
7
7
|
* Internal *
|
|
8
8
|
************/
|
|
9
|
+
// Classes
|
|
10
|
+
this.classHide = 'mg-modal--hide';
|
|
11
|
+
// IDs
|
|
9
12
|
this.closeButtonId = '';
|
|
10
13
|
this.titleId = '';
|
|
11
14
|
/**
|
|
@@ -48,11 +51,11 @@ export class MgModal {
|
|
|
48
51
|
validateHide(newValue) {
|
|
49
52
|
if (newValue) {
|
|
50
53
|
this.componentHide.emit();
|
|
51
|
-
this.classList.add(
|
|
54
|
+
this.classList.add(this.classHide);
|
|
52
55
|
}
|
|
53
56
|
else {
|
|
54
57
|
this.componentShow.emit();
|
|
55
|
-
this.classList.delete(
|
|
58
|
+
this.classList.delete(this.classHide);
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
/**
|
|
@@ -76,6 +79,9 @@ export class MgModal {
|
|
|
76
79
|
* @returns {void}
|
|
77
80
|
*/
|
|
78
81
|
componentWillLoad() {
|
|
82
|
+
// Get locales
|
|
83
|
+
this.messages = initLocales(this.element).messages;
|
|
84
|
+
// Validate
|
|
79
85
|
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
80
86
|
this.hasContent = this.element.querySelector('[slot="content"]') !== null;
|
|
81
87
|
if (this.closeButton) {
|
|
@@ -94,7 +100,7 @@ export class MgModal {
|
|
|
94
100
|
h("article", { class: "mg-modal__dialog" },
|
|
95
101
|
h("header", { class: "mg-modal__header" },
|
|
96
102
|
this.closeButton && (h("span", { class: "mg-modal__close-button" },
|
|
97
|
-
h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: messages.modal.closeButton, onClick: this.handleClose },
|
|
103
|
+
h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose },
|
|
98
104
|
h("mg-icon", { icon: "cross" })))),
|
|
99
105
|
h("h1", { class: "mg-modal__title", id: this.titleId }, this.modalTitle)),
|
|
100
106
|
this.hasContent && (h("article", { class: "mg-modal__content" },
|
|
File without changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Component, h, Prop, Watch, Event } from '@stencil/core';
|
|
1
|
+
import { Component, Element, h, Prop, Watch, Event } from '@stencil/core';
|
|
2
2
|
import { createID } from '../../../utils/components.utils';
|
|
3
3
|
import { NavigationAction } from './mg-pagination.conf';
|
|
4
|
-
import {
|
|
4
|
+
import { initLocales } from './../../../locales';
|
|
5
5
|
/**
|
|
6
6
|
* Range generator
|
|
7
7
|
*
|
|
@@ -25,19 +25,11 @@ import { messages } from './../../../locales';
|
|
|
25
25
|
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
26
26
|
export class MgPagination {
|
|
27
27
|
constructor() {
|
|
28
|
-
/**************
|
|
29
|
-
* Decorators *
|
|
30
|
-
**************/
|
|
31
28
|
/**
|
|
32
29
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
33
30
|
* If not set, it will be created.
|
|
34
31
|
*/
|
|
35
32
|
this.identifier = createID('mg-pagination');
|
|
36
|
-
/**
|
|
37
|
-
* Panignation label. Is a short description.
|
|
38
|
-
* Customize default value can be usefull to improve accessibility
|
|
39
|
-
*/
|
|
40
|
-
this.label = 'pagination';
|
|
41
33
|
/**
|
|
42
34
|
* Component total pages
|
|
43
35
|
*/
|
|
@@ -101,8 +93,15 @@ export class MgPagination {
|
|
|
101
93
|
* @returns {void}
|
|
102
94
|
*/
|
|
103
95
|
componentWillLoad() {
|
|
96
|
+
// Get locales
|
|
97
|
+
this.messages = initLocales(this.element).messages;
|
|
98
|
+
// Validate
|
|
104
99
|
this.validateTotalPages(this.totalPages);
|
|
105
100
|
this.validateCurrentPage(this.currentPage);
|
|
101
|
+
// Set default label
|
|
102
|
+
if (this.label === undefined || this.label === '') {
|
|
103
|
+
this.label = this.messages.pagination.label;
|
|
104
|
+
}
|
|
106
105
|
}
|
|
107
106
|
/**
|
|
108
107
|
* Render
|
|
@@ -110,24 +109,24 @@ export class MgPagination {
|
|
|
110
109
|
* @returns {HTMLElement} HTML Element
|
|
111
110
|
*/
|
|
112
111
|
render() {
|
|
113
|
-
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: messages.pagination[`${action}Page`],
|
|
112
|
+
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: this.messages.pagination[`${action}Page`],
|
|
114
113
|
// eslint-disable-next-line react/jsx-no-bind
|
|
115
114
|
onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" },
|
|
116
115
|
action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }),
|
|
117
|
-
messages.general[action],
|
|
116
|
+
this.messages.general[action],
|
|
118
117
|
action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
|
|
119
118
|
return (h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination__nav" },
|
|
120
119
|
navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS),
|
|
121
|
-
h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }),
|
|
120
|
+
h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }),
|
|
122
121
|
h("span", { class: "sr-only" },
|
|
123
|
-
messages.pagination.page,
|
|
122
|
+
this.messages.pagination.page,
|
|
124
123
|
" ",
|
|
125
124
|
this.currentPage),
|
|
126
125
|
h("span", null,
|
|
127
126
|
"/ ",
|
|
128
127
|
this.totalPages,
|
|
129
128
|
" ",
|
|
130
|
-
this.totalPages > 1 ? messages.pagination.pages : messages.pagination.page),
|
|
129
|
+
this.totalPages > 1 ? this.messages.pagination.pages : this.messages.pagination.page),
|
|
131
130
|
navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
|
|
132
131
|
}
|
|
133
132
|
static get is() { return "mg-pagination"; }
|
|
@@ -159,7 +158,7 @@ export class MgPagination {
|
|
|
159
158
|
},
|
|
160
159
|
"label": {
|
|
161
160
|
"type": "string",
|
|
162
|
-
"mutable":
|
|
161
|
+
"mutable": true,
|
|
163
162
|
"complexType": {
|
|
164
163
|
"original": "string",
|
|
165
164
|
"resolved": "string",
|
|
@@ -172,8 +171,7 @@ export class MgPagination {
|
|
|
172
171
|
"text": "Panignation label. Is a short description.\nCustomize default value can be usefull to improve accessibility"
|
|
173
172
|
},
|
|
174
173
|
"attribute": "label",
|
|
175
|
-
"reflect": false
|
|
176
|
-
"defaultValue": "'pagination'"
|
|
174
|
+
"reflect": false
|
|
177
175
|
},
|
|
178
176
|
"totalPages": {
|
|
179
177
|
"type": "number",
|
|
@@ -228,6 +226,7 @@ export class MgPagination {
|
|
|
228
226
|
"references": {}
|
|
229
227
|
}
|
|
230
228
|
}]; }
|
|
229
|
+
static get elementRef() { return "element"; }
|
|
231
230
|
static get watchers() { return [{
|
|
232
231
|
"propName": "totalPages",
|
|
233
232
|
"methodName": "validateTotalPages"
|
|
File without changes
|
|
@@ -30,10 +30,14 @@
|
|
|
30
30
|
flex-grow: 1;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
.mg-panel__collapse-button {
|
|
33
|
+
.mg-panel__collapse-button .mg-button {
|
|
34
34
|
font-family: var(--font-family-heading);
|
|
35
35
|
font-size: 1.4rem;
|
|
36
36
|
font-weight: 500;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.mg-panel__collapse-button,
|
|
40
|
+
.mg-panel__edit-button {
|
|
37
41
|
margin: 0 0.3rem 0 0;
|
|
38
42
|
}
|
|
39
43
|
|