@mgdis/mg-components 6.17.0 → 6.18.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-DCZEYvlH.js +4 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mg-action-more_37.cjs.entry.js +411 -168
- package/dist/cjs/mg-alert.cjs.entry.js +1 -1
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/cjs/mg-fieldset.cjs.entry.js +141 -0
- package/dist/cjs/mg-input-combobox.cjs.entry.js +71 -55
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +33 -20
- package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-HYIzRsy7.js} +5 -0
- package/dist/cjs/mg-loader.cjs.entry.js +1 -1
- package/dist/cjs/mg-progress.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +4 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +178 -18
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +36 -16
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +78 -55
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +41 -22
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +32 -12
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +30 -12
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +31 -12
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +40 -20
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +31 -12
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +44 -25
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +31 -13
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +36 -11
- package/dist/collection/components/molecules/menus/mg-menu/mg-menu.js +5 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +1 -1
- package/dist/collection/components/molecules/mg-alert/mg-alert.js +1 -1
- package/dist/collection/components/molecules/mg-details/mg-details.js +1 -1
- package/dist/collection/components/molecules/mg-fieldset/mg-fieldset.js +404 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +13 -4
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +1 -1
- package/dist/collection/components/molecules/mg-loader/mg-loader.js +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +2 -2
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +2 -2
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +40 -9
- package/dist/collection/components/molecules/mg-popover/mg-popover-content/mg-popover-content.js +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +1 -1
- package/dist/collection/components/molecules/mg-progress/mg-progress.js +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +1 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
- package/dist/components/mg-action-more.js +1 -1
- package/dist/components/mg-alert.js +1 -1
- package/dist/components/mg-details.js +1 -1
- package/dist/components/mg-fieldset.d.ts +11 -0
- package/dist/components/mg-fieldset.js +209 -0
- package/dist/components/mg-form.js +4 -3
- package/dist/components/mg-illustrated-message.js +1 -1
- package/dist/components/mg-input-checkbox-paginated2.js +1 -1
- package/dist/components/mg-input-checkbox.js +28 -15
- package/dist/components/mg-input-combobox.js +71 -55
- package/dist/components/mg-input-date.js +33 -21
- package/dist/components/mg-input-numeric.js +24 -11
- package/dist/components/mg-input-password.js +22 -11
- package/dist/components/mg-input-radio.js +23 -11
- package/dist/components/mg-input-rich-text-editor.js +32 -19
- package/dist/components/mg-input-select2.js +24 -12
- package/dist/components/mg-input-text2.js +36 -24
- package/dist/components/mg-input-textarea.js +23 -12
- package/dist/components/mg-input-toggle.js +35 -10
- package/dist/components/mg-input2.js +117 -18
- package/dist/components/mg-item-more2.js +5 -1
- package/dist/components/mg-loader2.js +1 -1
- package/dist/components/mg-message2.js +2 -2
- package/dist/components/mg-modal.js +2 -2
- package/dist/components/mg-panel.js +36 -7
- package/dist/components/mg-popover-content2.js +1 -1
- package/dist/components/mg-popover2.js +1 -1
- package/dist/components/mg-progress.js +1 -1
- package/dist/components/mg-skip-links.js +1 -1
- package/dist/components/mg-tabs2.js +1 -1
- package/dist/esm/{index-WtiuOkLj.js → index-C7xjtdiw.js} +1 -1
- package/dist/esm/index-T6kOJXP1.js +4 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mg-action-more_37.entry.js +412 -169
- package/dist/esm/mg-alert.entry.js +2 -2
- package/dist/esm/mg-components.js +1 -1
- package/dist/esm/mg-fieldset.entry.js +139 -0
- package/dist/esm/mg-input-combobox.entry.js +72 -56
- package/dist/esm/mg-input-rich-text-editor.entry.js +34 -21
- package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-D9V2v4n2.js} +5 -1
- package/dist/esm/mg-loader.entry.js +2 -2
- package/dist/esm/mg-progress.entry.js +2 -2
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-2bab89c2.entry.js +1 -0
- package/dist/mg-components/{p-0e6b40d6.entry.js → p-5abc77cd.entry.js} +1 -1
- package/dist/mg-components/p-7d2e43b2.entry.js +1 -0
- package/dist/mg-components/{p-5dc3a1fb.entry.js → p-92e5e5a6.entry.js} +1 -1
- package/dist/mg-components/{p-c5da335e.entry.js → p-952288bd.entry.js} +1 -1
- package/dist/mg-components/{p-WtiuOkLj.js → p-C7xjtdiw.js} +1 -1
- package/dist/mg-components/p-D9V2v4n2.js +1 -0
- package/dist/mg-components/p-f2cddd52.entry.js +1 -0
- package/dist/mg-components/{p-397bf67b.entry.js → p-f6afaeb8.entry.js} +1 -1
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +5 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +32 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +4 -2
- package/dist/types/components/molecules/mg-fieldset/mg-fieldset.d.ts +105 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +1 -1
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +8 -1
- package/dist/types/components.d.ts +168 -18
- package/ide/intellij/web-types.json +272 -9
- package/ide/vscode/html-custom-data.json +243 -5
- package/package.json +15 -15
- package/dist/mg-components/p-8a69175b.entry.js +0 -1
- package/dist/mg-components/p-CNgv8hc5.js +0 -1
- package/dist/mg-components/p-d84d87ea.entry.js +0 -1
|
@@ -6,7 +6,7 @@ import { d as defineCustomElement$4 } from './mg-input-title2.js';
|
|
|
6
6
|
import { d as defineCustomElement$3 } from './mg-tooltip2.js';
|
|
7
7
|
import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
|
|
8
8
|
|
|
9
|
-
const mgInputToggleCss = ".mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input__toggle-item-container{overflow:hidden;box-sizing:border-box;padding:var(--mg-b-size-4) var(--mg-b-size-8);border:
|
|
9
|
+
const mgInputToggleCss = ".mg-c-input__readonly-value{min-height:var(--mg-b-font-size);align-self:flex-start;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);overflow-wrap:anywhere}.mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}a{color:inherit;text-decoration:underline}a:hover,a:focus,a:active{text-decoration:none}.mg-c-input__toggle-item-container{overflow:hidden;box-sizing:border-box;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-width:var(--mg-b-size-border);border-radius:calc((var(--mg-b-font-size)*var(--mg-b-line-height) + 2*var(--mg-b-size-4))/var(--mg-c-input-toggle-border-radius-ratio));color:var(--mg-b-color-neutral-110);font-weight:unset;text-overflow:ellipsis;white-space:nowrap}.mg-c-input__toggle-item-container:first-of-type{border-style:solid;border-color:var(--mg-b-color-neutral-80);background-color:var(--mg-b-color-light);font-weight:600}.mg-c-input__button-toggle{display:flex;overflow:hidden;min-width:0;align-items:center;padding:.1rem;border-width:var(--mg-c-input-border-width);border-style:solid;border-color:var(--mg-b-color-neutral-80);border-radius:calc((var(--mg-b-font-size)*var(--mg-b-line-height) + 2*(var(--mg-b-size-4) + var(--mg-b-size-4) + var(--mg-c-input-border-width)))/var(--mg-c-input-toggle-border-radius-ratio));background-color:var(--mg-b-color-neutral-20);cursor:pointer;font-family:var(--mg-b-font-family);font-size:var(--mg-b-small-font-size);line-height:var(--mg-b-size-12)}.mg-c-input__button-toggle:disabled{cursor:default}.mg-c-input__button-toggle:focus{outline-offset:var(--mg-b-size-4)}.mg-c-input.mg-c-input--toggle:not(.mg-c-input--readonly) .mg-c-input__button-toggle{margin-top:var(--mg-b-size-4)}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__button-toggle{background-color:var(--mg-b-color-neutral-110)}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:first-of-type{border:unset;background-color:unset;color:var(--mg-b-color-light);font-weight:unset}.mg-c-input.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:last-of-type{border-style:solid;background-color:var(--mg-b-color-neutral-20);font-weight:600}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__button-toggle{width:100%;min-width:calc(var(--mg-b-size-20)*2);max-width:calc(var(--mg-b-size-20)*2)}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container{display:flex;overflow:unset;min-width:var(--mg-b-size-20);max-width:var(--mg-b-size-20);height:var(--mg-b-size-20);align-items:center;justify-content:center;padding:0;visibility:hidden}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:first-of-type{visibility:visible}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:last-of-type{width:unset}.mg-c-input.mg-c-input--toggle-icon .mg-c-input__toggle-item-container ::slotted(mg-icon){display:flex}.mg-c-input.mg-c-input--toggle-icon.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:first-of-type{min-width:unset;visibility:hidden}.mg-c-input.mg-c-input--toggle-icon.mg-c-input--toggle-is-active .mg-c-input__toggle-item-container:last-of-type{margin-left:auto;visibility:visible}.mg-c-input.mg-c-input--toggle-on-off.mg-c-input--toggle-icon .mg-c-input__toggle-item-container:first-of-type ::slotted(*){display:none}";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* type Option validation function
|
|
@@ -41,7 +41,9 @@ const MgInputToggle$1 = /*@__PURE__*/ proxyCustomElement(class MgInputToggle ext
|
|
|
41
41
|
*/
|
|
42
42
|
this.labelHide = false;
|
|
43
43
|
/**
|
|
44
|
-
* Define if toggle have on/off style
|
|
44
|
+
* Define if toggle have on/off style,
|
|
45
|
+
* the left icon is hidden.
|
|
46
|
+
* Only available in combination with the "isIcon" prop.
|
|
45
47
|
*/
|
|
46
48
|
this.isOnOff = false;
|
|
47
49
|
/**
|
|
@@ -76,7 +78,7 @@ const MgInputToggle$1 = /*@__PURE__*/ proxyCustomElement(class MgInputToggle ext
|
|
|
76
78
|
// Set error message
|
|
77
79
|
this.errorMessage = undefined;
|
|
78
80
|
// Does have a custom error message
|
|
79
|
-
if (!this.valid && errorMessage
|
|
81
|
+
if (!this.valid && typeof errorMessage === 'string') {
|
|
80
82
|
this.errorMessage = errorMessage;
|
|
81
83
|
}
|
|
82
84
|
};
|
|
@@ -91,14 +93,31 @@ const MgInputToggle$1 = /*@__PURE__*/ proxyCustomElement(class MgInputToggle ext
|
|
|
91
93
|
*/
|
|
92
94
|
this.validateSlots = () => {
|
|
93
95
|
const slots = Array.from(this.element.children);
|
|
96
|
+
// validate slots
|
|
94
97
|
if (slots.length !== 2) {
|
|
95
|
-
|
|
98
|
+
if (this.isOnOff && this.isIcon) {
|
|
99
|
+
// ONLY slot="item-2" is required in with isOnOff && isIcon
|
|
100
|
+
if (this.element.querySelector('[slot="item-2"]') === null) {
|
|
101
|
+
throw new Error('<mg-input-toggle> an element with attribute slot="item-2" is required.');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
throw new Error('<mg-input-toggle> 2 slots are required.');
|
|
106
|
+
}
|
|
96
107
|
}
|
|
97
|
-
|
|
108
|
+
// update slots
|
|
109
|
+
if (!this.isIcon) {
|
|
98
110
|
// Due to text-overflow set to ellipsis
|
|
99
111
|
// we need to ensure that slot element have title to display value on mouse over
|
|
100
112
|
slots.forEach(slot => slot.setAttribute('title', slot.textContent));
|
|
101
113
|
}
|
|
114
|
+
else {
|
|
115
|
+
slots.forEach(slot => {
|
|
116
|
+
if (slot.nodeName === 'MG-ICON') {
|
|
117
|
+
slot.size = 'small';
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
102
121
|
};
|
|
103
122
|
/**
|
|
104
123
|
* Get checked item
|
|
@@ -139,10 +158,16 @@ const MgInputToggle$1 = /*@__PURE__*/ proxyCustomElement(class MgInputToggle ext
|
|
|
139
158
|
}
|
|
140
159
|
}
|
|
141
160
|
watchIsOnOff(newValue) {
|
|
142
|
-
if (newValue)
|
|
161
|
+
if (newValue) {
|
|
143
162
|
this.classCollection.add(this.classOnOff);
|
|
144
|
-
|
|
163
|
+
if (!this.isIcon) {
|
|
164
|
+
this.isOnOff = false;
|
|
165
|
+
console.warn('<mg-input-toggle> prop "isOnOff" must be used with "isIcon". Setting isOnOff to false.');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
145
169
|
this.classCollection.delete(this.classOnOff);
|
|
170
|
+
}
|
|
146
171
|
}
|
|
147
172
|
watchIsIcon(newValue) {
|
|
148
173
|
if (newValue)
|
|
@@ -190,7 +215,7 @@ const MgInputToggle$1 = /*@__PURE__*/ proxyCustomElement(class MgInputToggle ext
|
|
|
190
215
|
if (typeof valid !== 'boolean') {
|
|
191
216
|
throw new Error('<mg-input-toggle> method "setError()" param "valid" must be a boolean.');
|
|
192
217
|
}
|
|
193
|
-
else if (!isValidString(errorMessage)) {
|
|
218
|
+
else if (errorMessage !== undefined && !isValidString(errorMessage)) {
|
|
194
219
|
throw new Error('<mg-input-toggle> method "setError()" param "errorMessage" must be a string.');
|
|
195
220
|
}
|
|
196
221
|
else {
|
|
@@ -267,7 +292,7 @@ const MgInputToggle$1 = /*@__PURE__*/ proxyCustomElement(class MgInputToggle ext
|
|
|
267
292
|
*/
|
|
268
293
|
render() {
|
|
269
294
|
const checkedItem = this.getCheckedItem(this.checked);
|
|
270
|
-
return (h("mg-input", { key: '
|
|
295
|
+
return (h("mg-input", { key: '4d87ed13bbd3d3a54303c21001247e1251417326', label: this.label, helpText: this.helpText, identifier: this.identifier, class: this.classCollection.join(), labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, tooltip: this.tooltip, tooltipPosition: this.tooltipPosition, errorMessage: this.errorMessage }, this.readonly ? (checkedItem && h("b", { class: "mg-c-input__readonly-value" }, checkedItem.title)) : (h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-c-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked, ref: el => {
|
|
271
296
|
if (el !== null)
|
|
272
297
|
this.button = el;
|
|
273
298
|
} }, h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-c-input__toggle-item-container" }, h("slot", { name: "item-2" }))))));
|
|
@@ -291,7 +316,7 @@ const MgInputToggle$1 = /*@__PURE__*/ proxyCustomElement(class MgInputToggle ext
|
|
|
291
316
|
"label": [1],
|
|
292
317
|
"labelOnTop": [4, "label-on-top"],
|
|
293
318
|
"labelHide": [4, "label-hide"],
|
|
294
|
-
"isOnOff": [
|
|
319
|
+
"isOnOff": [1028, "is-on-off"],
|
|
295
320
|
"isIcon": [4, "is-icon"],
|
|
296
321
|
"readonly": [4],
|
|
297
322
|
"disabled": [4],
|
|
@@ -13,12 +13,16 @@ const widths = [2, 4, 16, 'full'];
|
|
|
13
13
|
* Possible tootltip postions
|
|
14
14
|
*/
|
|
15
15
|
const tooltipPositions = ['input', 'label'];
|
|
16
|
+
/**
|
|
17
|
+
* Possible label headings
|
|
18
|
+
*/
|
|
19
|
+
const labelHeadings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
16
20
|
const classFieldset = 'mg-c-input--fieldset';
|
|
17
21
|
const classDisabled = 'mg-c-input--disabled';
|
|
18
22
|
const classReadonly = 'mg-c-input--readonly';
|
|
19
23
|
const classVerticalList = 'mg-c-input--vertical-list';
|
|
20
24
|
|
|
21
|
-
const mgInputCss = ".mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}/*!\n * @prop --mg-c-input-border-width: Defines the width of the input border. Default value is `--mg-b-size-border`.\n * @prop --mg-c-input-border-radius: Defines the border radius of the input. Default value is `--mg-b-size-radius`.\n * @prop --mg-c-input-color-border: Defines the color of the input border. Default value is `rgb(181, 194, 201)`.\n * @prop --mg-c-input-placeholder-color-text: Defines the color of the placeholder text. Default value is `rgb(181, 194, 201)`.\n * @prop --mg-c-input-color-box-shadow-focus: Defines the shadow color of the input when focused. Default value is `rgba(0, 221, 255, 0.5)`.\n * @prop --mg-c-input-error-color-background: Defines the background color of the input error message. Default value is `color-mix(in srgb, var(--mg-b-color-danger), white 95%)`.\n * @prop --mg-c-input-toggle-border-radius-ratio: Defines the border radius ratio of the input toggle. Default value is `2`.\n * @prop --mg-c-input-check-size: Defines the size of the input check. Default value is `--mg-b-size-16`.\n */:host{display:block}.mg-c-input__input mg-icon,.mg-c-input__error mg-icon{display:flex}.mg-c-input{display:flex;min-height:var(--mg-b-size-min-height);align-items:flex-start}.mg-c-input__input-container{width:100%;min-height:var(--mg-b-size-min-height)}.mg-c-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-b-size-16);height:var(--mg-b-size-16);margin-left:var(--mg-b-size-8)}@media print{.mg-c-input__input-container mg-tooltip{display:none}}.mg-c-input__input{display:flex;min-height:var(--mg-b-size-min-height);align-items:center;justify-content:start}.mg-c-input__input mg-tooltip{align-self:baseline;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__input ::slotted(.mg-c-input__button-toggle:disabled){opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input__title{display:flex;width:var(--mg-c-input-title-width, auto);flex-shrink:0;align-items:baseline;justify-content:flex-end;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);margin-right:var(--mg-c-input-title-horizontal-space, var(--mg-b-size-8));text-align:right}.mg-c-input__title slot[name=label]+mg-tooltip{margin-left:var(--mg-b-size-4)}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__error{display:inline-block;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-radius:var(--mg-b-size-radius);background:var(--mg-c-input-error-color-background);color:var(--mg-b-color-danger)}.mg-c-input__error ::slotted(*),.mg-c-input__help-text ::slotted(*){font-size:var(--mg-b-font-size-small);text-align:start}:host(:not(.mg-c-input--textarea)) .mg-c-input__input+.mg-c-input__error,:host(:not(.mg-c-input--textarea)) .mg-c-input__input+.mg-c-input__help-text{margin-top:var(--mg-b-size-4)}:host(.mg-c-input.mg-c-input--readonly) .mg-c-input__input mg-tooltip{margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2)}:host(.mg-c-input){display:flex;margin-bottom:var(--mg-c-input-margin-bottom, 0)}:host(.mg-c-input.mg-c-input--checkbox) .mg-c-input__input,:host(.mg-c-input.mg-c-input--radio) .mg-c-input__input{min-height:unset;align-items:flex-start}:host(.mg-c-input.mg-c-input--checkbox,.mg-c-input.mg-c-input--radio) .mg-c-input__input{min-height:unset}:host(.mg-c-input.mg-c-input--fieldset:not(.mg-c-input--checkbox-multi,.mg-c-input--readonly)) .mg-c-input__input-container mg-tooltip{margin-left:var(--mg-b-size-32)}:host(.mg-c-input.mg-c-input--label-on-top){flex-direction:column}:host(.mg-c-input.mg-c-input--label-on-top) .mg-c-input__title{width:100%;flex:0;justify-content:flex-start;margin-top:0;margin-right:0;margin-bottom:var(--mg-b-size-4);text-align:left}:host(.mg-c-input.mg-c-input--label-on-top) .mg-c-input__title ::slotted(mg-input-title){flex-shrink:1}@media screen and (max-width: 767px){:host(.mg-c-input){flex-direction:column}:host(.mg-c-input) .mg-c-input__title{width:100%;flex:0;justify-content:flex-start;margin-top:0;margin-right:0;margin-bottom:var(--mg-b-size-4);text-align:left}:host(.mg-c-input) .mg-c-input__title ::slotted(mg-input-title){flex-shrink:1}}";
|
|
25
|
+
const mgInputCss = ".mg-u-visually-hidden{position:absolute !important;overflow:hidden !important;width:.1rem !important;height:.1rem !important;padding:0 !important;border:0 !important;margin:-0.1rem !important;clip:rect(0.1rem, 0.1rem, 0.1rem, 0.1rem) !important;clip-path:inset(50%) !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}@media (prefers-reduced-motion){*{animation:none !important;transition:none !important}}/*!\n * @prop --mg-c-input-border-width: Defines the width of the input border. Default value is `--mg-b-size-border`.\n * @prop --mg-c-input-border-radius: Defines the border radius of the input. Default value is `--mg-b-size-radius`.\n * @prop --mg-c-input-color-border: Defines the color of the input border. Default value is `rgb(181, 194, 201)`.\n * @prop --mg-c-input-placeholder-color-text: Defines the color of the placeholder text. Default value is `rgb(181, 194, 201)`.\n * @prop --mg-c-input-color-box-shadow-focus: Defines the shadow color of the input when focused. Default value is `rgba(0, 221, 255, 0.5)`.\n * @prop --mg-c-input-error-color-background: Defines the background color of the input error message. Default value is `color-mix(in srgb, var(--mg-b-color-danger), white 95%)`.\n * @prop --mg-c-input-toggle-border-radius-ratio: Defines the border radius ratio of the input toggle. Default value is `2`.\n * @prop --mg-c-input-check-size: Defines the size of the input check. Default value is `--mg-b-size-16`.\n */:host{display:block}.mg-c-input__input mg-icon,.mg-c-input__error mg-icon{display:flex}.mg-c-input{display:flex;min-height:var(--mg-b-size-min-height);align-items:flex-start}.mg-c-input__input-container{width:100%;min-height:var(--mg-b-size-min-height)}.mg-c-input__input-container mg-tooltip{display:inline-flex;width:var(--mg-b-size-16);height:var(--mg-b-size-16);margin-left:var(--mg-b-size-8)}@media print{.mg-c-input__input-container mg-tooltip{display:none}}.mg-c-input__input{display:flex;min-height:var(--mg-b-size-min-height);align-items:center;justify-content:start}.mg-c-input__input mg-tooltip{align-self:baseline;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-size-16))/2)}.mg-c-input__input ::slotted(.mg-c-input__button-toggle:disabled){opacity:var(--mg-b-opacity-element-disabled)}.mg-c-input__title{display:flex;width:var(--mg-c-input-title-width, auto);flex-shrink:0;align-items:baseline;justify-content:flex-end;margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2);margin-right:var(--mg-c-input-title-horizontal-space, var(--mg-b-size-8));text-align:right}.mg-c-input__title slot[name=label]+mg-tooltip{margin-left:var(--mg-b-size-4)}.mg-c-input__title mg-icon{display:inline-flex;vertical-align:text-bottom}.mg-c-input__error{display:inline-block;padding:var(--mg-b-size-4) var(--mg-b-size-8);border-radius:var(--mg-b-size-radius);background:var(--mg-c-input-error-color-background);color:var(--mg-b-color-danger)}.mg-c-input__error ::slotted(*),.mg-c-input__help-text ::slotted(*){font-size:var(--mg-b-font-size-small);text-align:start}:host(:not(.mg-c-input--textarea)) .mg-c-input__input+.mg-c-input__error,:host(:not(.mg-c-input--textarea)) .mg-c-input__input+.mg-c-input__help-text{margin-top:var(--mg-b-size-4)}:host(.mg-c-input.mg-c-input--readonly) .mg-c-input__input mg-tooltip{margin-top:calc((var(--mg-b-size-min-height) - var(--mg-b-font-size)*var(--mg-b-line-height))/2)}:host(.mg-c-input){display:flex;margin-bottom:var(--mg-c-input-margin-bottom, 0)}:host(.mg-c-input.mg-c-input--checkbox) .mg-c-input__input,:host(.mg-c-input.mg-c-input--toggle) .mg-c-input__input,:host(.mg-c-input.mg-c-input--radio) .mg-c-input__input{min-height:unset;align-items:flex-start}:host(.mg-c-input.mg-c-input--checkbox,.mg-c-input.mg-c-input--radio) .mg-c-input__input{min-height:unset}:host(.mg-c-input.mg-c-input--fieldset:not(.mg-c-input--checkbox-multi,.mg-c-input--readonly)) .mg-c-input__input-container mg-tooltip{margin-left:var(--mg-b-size-32)}:host(.mg-c-input.mg-c-input--toggle) .mg-c-input__input-container{min-width:0;flex:1}:host(.mg-c-input.mg-c-input--label-on-top){flex-direction:column}:host(.mg-c-input.mg-c-input--label-on-top) .mg-c-input__title{width:100%;flex:0;justify-content:flex-start;margin-top:0;margin-right:0;margin-bottom:var(--mg-b-size-4);text-align:left}:host(.mg-c-input.mg-c-input--label-on-top) .mg-c-input__title ::slotted(mg-input-title){flex-shrink:1}:host(.mg-c-input.mg-c-input--inputs-on-bottom) .mg-c-input__help-text{margin-top:var(--mg-b-size-4);margin-bottom:var(--mg-b-size-12)}:host(.mg-c-input.mg-c-input--inputs-on-bottom) .mg-c-input__error{margin-bottom:var(--mg-b-size-20)}:host(.mg-c-input.mg-c-input--inputs-on-bottom.mg-c-input--fieldset){--mg-c-input-title-width:var(--mg-c-form-inputs-title-width, calc(28 * var(--mg-b-size-8)));--mg-c-input-title-horizontal-space:var(--mg-b-size-32)}:host(.mg-c-input.mg-c-input--inputs-on-bottom.mg-c-input--fieldset) ::slotted(*){--mg-c-input-margin-bottom:var(--mg-b-size-16)}:host(.mg-c-input.mg-c-input--label-border-display) .mg-c-input__title{border-bottom:var(--mg-b-size-border) solid var(--mg-c-divider-color-background)}:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__title{margin-bottom:0}:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input-title__text{margin-top:var(--mg-b-font-size-8);margin-bottom:var(--mg-b-font-size-8)}:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__help-text,:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__error{margin-top:0;margin-bottom:var(--mg-b-size-4)}:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__help-text+.mg-c-input__input,:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__error+.mg-c-input__input{margin-top:var(--mg-b-size-12)}:host(.mg-c-input.mg-c-input--has-heading) .mg-c-input__help-text+.mg-c-input__error{margin-top:var(--mg-b-size-4)}:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__title{margin-bottom:var(--mg-b-size-16)}:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__help-text,:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__error{margin-bottom:0}:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__help-text+.mg-c-input__input,:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__error+.mg-c-input__input{margin-top:var(--mg-b-size-16)}:host(.mg-c-input.mg-c-input--has-heading.mg-c-input--label-border-display) .mg-c-input__help-text+.mg-c-input__error{margin-top:var(--mg-b-size-8)}@media screen and (max-width: 767px){:host(.mg-c-input){flex-direction:column}:host(.mg-c-input) .mg-c-input__title{width:100%;flex:0;justify-content:flex-start;margin-top:0;margin-right:0;margin-bottom:var(--mg-b-size-4);text-align:left}:host(.mg-c-input) .mg-c-input__title ::slotted(mg-input-title){flex-shrink:1}}";
|
|
22
26
|
|
|
23
27
|
const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLElement {
|
|
24
28
|
constructor(registerHost) {
|
|
@@ -34,6 +38,9 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
34
38
|
this.classInput = 'mg-c-input';
|
|
35
39
|
this.classHasError = 'mg-c-input--has-error';
|
|
36
40
|
this.classLabelOnTop = 'mg-c-input--label-on-top';
|
|
41
|
+
this.classHasHeading = 'mg-c-input--has-heading';
|
|
42
|
+
this.classLabelBorderDisplay = 'mg-c-input--label-border-display';
|
|
43
|
+
this.classInputsOnBottom = 'mg-c-input--inputs-on-bottom';
|
|
37
44
|
/**
|
|
38
45
|
* Define if label is displayed on top
|
|
39
46
|
*/
|
|
@@ -42,6 +49,11 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
42
49
|
* Define if label is visible
|
|
43
50
|
*/
|
|
44
51
|
this.labelHide = false;
|
|
52
|
+
/**
|
|
53
|
+
* Define if label border is visible
|
|
54
|
+
* You must pair this mode with `labelOnTop`and `fieldset` class
|
|
55
|
+
*/
|
|
56
|
+
this.labelBorderDisplay = false;
|
|
45
57
|
/**
|
|
46
58
|
* Define tooltip position
|
|
47
59
|
*/
|
|
@@ -50,6 +62,10 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
50
62
|
* Define if input is required
|
|
51
63
|
*/
|
|
52
64
|
this.required = false;
|
|
65
|
+
/**
|
|
66
|
+
* Display inputs after help-text and error message
|
|
67
|
+
*/
|
|
68
|
+
this.inputsOnBottom = false;
|
|
53
69
|
/**
|
|
54
70
|
* Define aria-describedby ids to link with
|
|
55
71
|
*/
|
|
@@ -70,11 +86,44 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
70
86
|
* Element is disabled
|
|
71
87
|
*/
|
|
72
88
|
this.isVerticalList = false;
|
|
89
|
+
/************
|
|
90
|
+
* Methods *
|
|
91
|
+
************/
|
|
92
|
+
/**
|
|
93
|
+
* Update element aria-describedby
|
|
94
|
+
* @param element - element to update
|
|
95
|
+
* @param ariaDescribedbyIDs - ariaDescribedbyIDs references
|
|
96
|
+
*/
|
|
97
|
+
this.updateElementAriaDescribedby = (element, ariaDescribedbyIDs) => {
|
|
98
|
+
if (ariaDescribedbyIDs.size > 0) {
|
|
99
|
+
element.setAttribute('aria-describedby', Array.from(ariaDescribedbyIDs).join(' '));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
element.removeAttribute('aria-describedby');
|
|
103
|
+
}
|
|
104
|
+
};
|
|
73
105
|
/**
|
|
74
106
|
* Get tooltip node
|
|
75
107
|
* @returns mg-tooltip
|
|
76
108
|
*/
|
|
77
109
|
this.renderTooltip = () => (h("mg-tooltip", { identifier: `${this.identifier}-tooltip`, message: this.tooltip }, h("mg-icon", { icon: "info-circle" })));
|
|
110
|
+
/**
|
|
111
|
+
* Get input container element
|
|
112
|
+
* @returns ordered elements
|
|
113
|
+
*/
|
|
114
|
+
this.inputContainerElements = () => {
|
|
115
|
+
const elements = [
|
|
116
|
+
this.helptextMessageSlotElement && (h("div", { class: "mg-c-input__help-text" }, h("slot", { name: this.slotHelpText }))),
|
|
117
|
+
!this.isDisabled && this.errorMessage && (h("div", { class: "mg-c-input__error", "aria-live": "assertive" }, h("slot", { name: this.slotError }))),
|
|
118
|
+
];
|
|
119
|
+
const inputSlot = (h("div", { class: "mg-c-input__input" }, h("slot", null), this.tooltip && !this.labelOnTop && (this.tooltipPosition === 'input' || this.labelHide) && this.renderTooltip()));
|
|
120
|
+
if (this.inputsOnBottom) {
|
|
121
|
+
return [...elements, inputSlot];
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
return [inputSlot, ...elements];
|
|
125
|
+
}
|
|
126
|
+
};
|
|
78
127
|
}
|
|
79
128
|
watchIdentifier(newValue) {
|
|
80
129
|
if (!isValidString(newValue)) {
|
|
@@ -101,6 +150,26 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
101
150
|
throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide".');
|
|
102
151
|
}
|
|
103
152
|
}
|
|
153
|
+
watchlabelHeading(newValue) {
|
|
154
|
+
if (this.isFieldset && this.labelOnTop && labelHeadings.includes(newValue)) {
|
|
155
|
+
this.element.classList.add(this.classHasHeading);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
if ((!this.isFieldset && newValue !== undefined) || typeof newValue === 'string') {
|
|
159
|
+
throw new Error(`<mg-input> prop "labelHeading" must be used with a fieldset and be one of: ${labelHeadings.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
160
|
+
}
|
|
161
|
+
this.labelHeading = undefined;
|
|
162
|
+
this.element.classList.remove(this.classHasHeading);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
watchLabelBorderDisplay(newValue) {
|
|
166
|
+
if (this.isFieldset && this.labelOnTop && newValue) {
|
|
167
|
+
this.element.classList.add(this.classLabelBorderDisplay);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
this.element.classList.remove(this.classLabelBorderDisplay);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
104
173
|
watchTooltipPosition(newValue) {
|
|
105
174
|
if (!tooltipPositions.includes(newValue)) {
|
|
106
175
|
throw new Error(`<mg-input> prop "tooltipPosition" must be one of: ${tooltipPositions.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
@@ -120,7 +189,7 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
120
189
|
}
|
|
121
190
|
watchHelpText(newValue) {
|
|
122
191
|
var _a;
|
|
123
|
-
if (newValue && !this.isReadonly) {
|
|
192
|
+
if (isValidString(newValue) && !this.isReadonly) {
|
|
124
193
|
this.renderHelpText();
|
|
125
194
|
}
|
|
126
195
|
else {
|
|
@@ -128,6 +197,14 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
128
197
|
this.helptextMessageSlotElement = undefined;
|
|
129
198
|
}
|
|
130
199
|
}
|
|
200
|
+
watchInputsOnBottom(newValue) {
|
|
201
|
+
if (newValue) {
|
|
202
|
+
this.element.classList.add(this.classInputsOnBottom);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
this.element.classList.remove(this.classInputsOnBottom);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
131
208
|
watchAriaDescribedbyIDs() {
|
|
132
209
|
if (this.isReadonly) {
|
|
133
210
|
return;
|
|
@@ -143,23 +220,26 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
143
220
|
// a11y IDs
|
|
144
221
|
const ariaDescribedbyIDs = new Set(this.ariaDescribedbyIDs);
|
|
145
222
|
// Help text
|
|
146
|
-
if (this.helpText
|
|
223
|
+
if (isValidString(this.helpText)) {
|
|
147
224
|
this.renderHelpText();
|
|
148
225
|
if (!ariaDescribedbyIDs.has(this.helpTextId))
|
|
149
226
|
ariaDescribedbyIDs.add(this.helpTextId);
|
|
150
227
|
}
|
|
151
228
|
// Error Message
|
|
152
|
-
if (this.errorMessage
|
|
229
|
+
if (isValidString(this.errorMessage)) {
|
|
153
230
|
this.renderErrorMessage();
|
|
154
231
|
if (!ariaDescribedbyIDs.has(this.helpTextErrorId))
|
|
155
232
|
ariaDescribedbyIDs.add(this.helpTextErrorId);
|
|
156
233
|
}
|
|
157
|
-
this.element.querySelectorAll('input,select,textarea,[role="switch"]')
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
234
|
+
const inputs = this.element.querySelectorAll('input,select,textarea,[role="switch"]');
|
|
235
|
+
inputs.forEach((element) => {
|
|
236
|
+
this.updateElementAriaDescribedby(element, ariaDescribedbyIDs);
|
|
237
|
+
});
|
|
238
|
+
// use timeout to await for legend render for componentWillLoad hook
|
|
239
|
+
setTimeout(() => {
|
|
240
|
+
const legend = this.element.querySelector('legend');
|
|
241
|
+
if (legend !== null) {
|
|
242
|
+
this.updateElementAriaDescribedby(legend, ariaDescribedbyIDs);
|
|
163
243
|
}
|
|
164
244
|
});
|
|
165
245
|
}
|
|
@@ -189,9 +269,6 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
189
269
|
this.renderLabel();
|
|
190
270
|
}
|
|
191
271
|
}
|
|
192
|
-
/************
|
|
193
|
-
* Methods *
|
|
194
|
-
************/
|
|
195
272
|
/**
|
|
196
273
|
* Render input label
|
|
197
274
|
*/
|
|
@@ -211,11 +288,21 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
211
288
|
labelSlotElement.setAttribute(attr, val);
|
|
212
289
|
});
|
|
213
290
|
// create label element
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
291
|
+
if (labelHeadings.includes(this.labelHeading)) {
|
|
292
|
+
let label = this.element.shadowRoot.querySelector(this.labelHeading);
|
|
293
|
+
if (label === null) {
|
|
294
|
+
label = document.createElement(this.labelHeading);
|
|
295
|
+
label.classList.add('mg-c-input-title__text');
|
|
296
|
+
labelSlotElement.appendChild(label);
|
|
297
|
+
}
|
|
298
|
+
label.textContent = this.label;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
labelSlotElement.textContent = this.label;
|
|
302
|
+
}
|
|
218
303
|
this.element.appendChild(labelSlotElement);
|
|
304
|
+
// update aria-describedby
|
|
305
|
+
this.watchAriaDescribedbyIDs();
|
|
219
306
|
}
|
|
220
307
|
/**
|
|
221
308
|
* Render error message
|
|
@@ -258,6 +345,9 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
258
345
|
this.watchTooltipPosition(this.tooltipPosition);
|
|
259
346
|
this.watchHelpText(this.helpText);
|
|
260
347
|
this.watchErrorMessage(this.errorMessage);
|
|
348
|
+
this.watchInputsOnBottom(this.inputsOnBottom);
|
|
349
|
+
this.watchlabelHeading(this.labelHeading);
|
|
350
|
+
this.watchLabelBorderDisplay(this.labelBorderDisplay);
|
|
261
351
|
}
|
|
262
352
|
/**
|
|
263
353
|
* Validate slots
|
|
@@ -274,16 +364,19 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
274
364
|
*/
|
|
275
365
|
render() {
|
|
276
366
|
const isGroup = this.isFieldset && !this.isReadonly;
|
|
277
|
-
return (h(Host, { key: '
|
|
367
|
+
return (h(Host, { key: 'fbab18280a709407c83f324127e8de6cbb05fe7c', class: this.element.classList.toString(), role: isGroup ? 'group' : undefined, "aria-labelledby": isGroup ? `${this.identifier}-title` : undefined }, h("div", { key: 'ac0924c244b9fa87d02e659a5710ee93d12a202f', class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': this.labelHide } }, h("slot", { key: 'c825af33ba0a6c209d02d6487422347f7d8acfed', name: this.slotLabel }), this.tooltip && (this.tooltipPosition === 'label' || this.labelOnTop) && !this.labelHide && this.renderTooltip()), h("div", { key: '805e1eedfdea132f3ea4fd11da761810a3d7c939', class: "mg-c-input__input-container" }, this.inputContainerElements())));
|
|
278
368
|
}
|
|
279
369
|
get element() { return this; }
|
|
280
370
|
static get watchers() { return {
|
|
281
371
|
"identifier": ["watchIdentifier", "watchAriaDescribedbyIDs"],
|
|
282
372
|
"labelOnTop": ["watchLabelOnTop", "watchLabelConfig"],
|
|
283
373
|
"labelHide": ["watchLabelConfig"],
|
|
374
|
+
"labelHeading": ["watchlabelHeading"],
|
|
375
|
+
"labelBorderDisplay": ["watchLabelBorderDisplay"],
|
|
284
376
|
"tooltipPosition": ["watchTooltipPosition"],
|
|
285
377
|
"errorMessage": ["watchErrorMessage", "watchAriaDescribedbyIDs"],
|
|
286
378
|
"helpText": ["watchHelpText", "watchAriaDescribedbyIDs"],
|
|
379
|
+
"inputsOnBottom": ["watchInputsOnBottom"],
|
|
287
380
|
"ariaDescribedbyIDs": ["watchAriaDescribedbyIDs"],
|
|
288
381
|
"class": ["watchClass", "watchLabel"],
|
|
289
382
|
"label": ["watchLabel"],
|
|
@@ -297,11 +390,14 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
297
390
|
"label": [1],
|
|
298
391
|
"labelOnTop": [4, "label-on-top"],
|
|
299
392
|
"labelHide": [4, "label-hide"],
|
|
393
|
+
"labelHeading": [1025, "label-heading"],
|
|
394
|
+
"labelBorderDisplay": [4, "label-border-display"],
|
|
300
395
|
"tooltip": [1],
|
|
301
396
|
"tooltipPosition": [1, "tooltip-position"],
|
|
302
397
|
"required": [4],
|
|
303
398
|
"errorMessage": [1, "error-message"],
|
|
304
399
|
"helpText": [1, "help-text"],
|
|
400
|
+
"inputsOnBottom": [4, "inputs-on-bottom"],
|
|
305
401
|
"ariaDescribedbyIDs": [1025, "aria-describedby-i-ds"],
|
|
306
402
|
"isFieldset": [32],
|
|
307
403
|
"isReadonly": [32],
|
|
@@ -311,9 +407,12 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
311
407
|
"identifier": ["watchIdentifier", "watchAriaDescribedbyIDs"],
|
|
312
408
|
"labelOnTop": ["watchLabelOnTop", "watchLabelConfig"],
|
|
313
409
|
"labelHide": ["watchLabelConfig"],
|
|
410
|
+
"labelHeading": ["watchlabelHeading"],
|
|
411
|
+
"labelBorderDisplay": ["watchLabelBorderDisplay"],
|
|
314
412
|
"tooltipPosition": ["watchTooltipPosition"],
|
|
315
413
|
"errorMessage": ["watchErrorMessage", "watchAriaDescribedbyIDs"],
|
|
316
414
|
"helpText": ["watchHelpText", "watchAriaDescribedbyIDs"],
|
|
415
|
+
"inputsOnBottom": ["watchInputsOnBottom"],
|
|
317
416
|
"ariaDescribedbyIDs": ["watchAriaDescribedbyIDs"],
|
|
318
417
|
"class": ["watchClass", "watchLabel"],
|
|
319
418
|
"label": ["watchLabel"],
|
|
@@ -194,6 +194,10 @@ const MgMenu = /*@__PURE__*/ proxyCustomElement(class MgMenu extends HTMLElement
|
|
|
194
194
|
* @param event - mg-item-loaded "item-loaded" custom event
|
|
195
195
|
*/
|
|
196
196
|
updateItemListener(event) {
|
|
197
|
+
// `<mg-action-more>` element doesn't need `data-has-focus` attribute
|
|
198
|
+
if (event.target.nodeName === 'MG-ACTION-MORE') {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
197
201
|
const itemToWatch = event.target.nodeName === 'MG-ITEM-MORE' ? event.target.shadowRoot.querySelector('mg-menu-item') : event.target;
|
|
198
202
|
['click', 'focus'].forEach(trigger => {
|
|
199
203
|
itemToWatch.addEventListener(trigger, () => {
|
|
@@ -254,7 +258,7 @@ const MgMenu = /*@__PURE__*/ proxyCustomElement(class MgMenu extends HTMLElement
|
|
|
254
258
|
* @returns HTML Element
|
|
255
259
|
*/
|
|
256
260
|
render() {
|
|
257
|
-
return (h(Host, { key: '
|
|
261
|
+
return (h(Host, { key: '753833b01b86d6983f5d063f5598e2187b147a6e', role: "list", "aria-label": this.label }, h("slot", { key: '56702e49f5a97feddeb66e6271bd898061aa0d48' })));
|
|
258
262
|
}
|
|
259
263
|
get element() { return this; }
|
|
260
264
|
static get watchers() { return {
|
|
@@ -38,7 +38,7 @@ const MgLoader = /*@__PURE__*/ proxyCustomElement(class MgLoader extends HTMLEle
|
|
|
38
38
|
* @returns HTML Element
|
|
39
39
|
*/
|
|
40
40
|
render() {
|
|
41
|
-
return (h("div", { key: '
|
|
41
|
+
return (h("div", { key: '739b4cbacd8a8da056dbb1445c40fac2cf26766a', class: "mg-c-loader", "aria-live": "polite" }, h("mg-icon", { key: '95d3cbf26fcd6dbf0dad4853bf55aa66385f1aba', icon: "loader", spin: true }), h("span", { key: 'f6322cd3054d8976bd2ec24f86a2d6bb60ca7ae1', class: { 'mg-u-visually-hidden': this.messageHide } }, this.message || this.messages.loader.inProgress)));
|
|
42
42
|
}
|
|
43
43
|
get element() { return this; }
|
|
44
44
|
static get watchers() { return {
|
|
@@ -98,9 +98,9 @@ const MgMessage = /*@__PURE__*/ proxyCustomElement(class MgMessage extends HTMLE
|
|
|
98
98
|
* @returns HTML Element
|
|
99
99
|
*/
|
|
100
100
|
render() {
|
|
101
|
-
return (h("div", { key: '
|
|
101
|
+
return (h("div", { key: 'f99bf527eb2c6005eeaec11f89aaa08f8865ea57', class: this.classCollection.join() }, h("mg-card", { key: 'beede3cd97b022d947c216b6bba454a104ba5790', shadow: true }, this.variantStyle === 'bar-left' && h("span", { key: '515828d725a996c9d57b39ad75e9373150a1b78a', class: "mg-c-message__bar" }), h("span", { key: '02ae41c66af25c2611b9b6cb8c87a1ad99346fa3', class: "mg-c-message__icon" }, h("mg-icon", { key: '3eadb40ed0dfa5ec51155608a67769c5fee3d402', icon: this.getIcon() })), h("div", { key: 'b832251e8f330d00b512bcd508ae9bf6e5f511cb', class: "mg-c-message__content" }, h("span", { key: 'c3520fc49bd5c3c187a83823050ceb9ca8c12d46', class: "mg-c-message__content-slot" }, h("slot", { key: 'f4064dff9536cbb76e45c5c4c1a89621da9531b2' })), this.hasActions && [
|
|
102
102
|
h("span", { class: "mg-c-message__content-separator", key: "content-separator" }),
|
|
103
|
-
h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, h("slot", { key: '
|
|
103
|
+
h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, h("slot", { key: '5585f7c14c2c3896cfdb5319414cd82f4d4b3a8b', name: "actions" })),
|
|
104
104
|
]))));
|
|
105
105
|
}
|
|
106
106
|
get element() { return this; }
|
|
@@ -120,11 +120,11 @@ const MgModal$1 = /*@__PURE__*/ proxyCustomElement(class MgModal extends HTMLEle
|
|
|
120
120
|
* @returns HTML Element
|
|
121
121
|
*/
|
|
122
122
|
render() {
|
|
123
|
-
return (h("dialog", { key: '
|
|
123
|
+
return (h("dialog", { key: '2d99322fd3c80b8cbfea70589cf579e0c1c6f06b', role: this.dialogRole, id: this.identifier, class: this.classCollection.join(), "aria-labelledby": this.titleId, ref: (el) => {
|
|
124
124
|
if (el !== null) {
|
|
125
125
|
this.dialog = el;
|
|
126
126
|
}
|
|
127
|
-
} }, h("mg-card", { key: '
|
|
127
|
+
} }, h("mg-card", { key: '32692a6d41ef30b3d3e61ddcfea47350d374ed09', shadow: true }, h("div", { key: 'c87bb43bb069671b65a9759ee293e77975707597', class: "mg-c-modal__dialog" }, h("header", { key: '1272a946878efcf8c69f3b09852ba6938cbe31b0', class: "mg-c-modal__header" }, this.closeButton && (h("span", { key: '0704656c7c5ac4c8d405f2cd673e91f72763ee8f', class: "mg-c-modal__close-button" }, h("mg-button", { key: '4402971c763ee34145de5bd69d367fde68f9d1a2', "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, h("mg-icon", { key: '9e16add6a3e387971507a252671c895b6c94a586', icon: "cross" })))), h("h1", { key: '3e4fc2b4419398528565d382b728b8b752758ddd', class: "mg-c-modal__title", id: this.titleId }, this.modalTitle)), h("article", { key: '170ff6bd9592687baa4c561615f540ad1c7400e4', class: "mg-c-modal__content" }, h("slot", { key: 'cb710e2a57e4c997deac367169b56047af1200b1' })), this.hasActions && (h("footer", { key: '1e08d67caeaaaf75eb97faa11528719ea537c24c', class: "mg-c-modal__footer" }, h("slot", { key: '461ec8e4117477aef08dc6d346ad0bf6007ec12d', name: "actions" })))))));
|
|
128
128
|
}
|
|
129
129
|
get element() { return this; }
|
|
130
130
|
static get watchers() { return {
|
|
@@ -71,6 +71,13 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class MgPanel extends HTMLEle
|
|
|
71
71
|
/************
|
|
72
72
|
* Methods *
|
|
73
73
|
************/
|
|
74
|
+
/**
|
|
75
|
+
* Check if panel-title slot is used
|
|
76
|
+
* @returns true if slot is used
|
|
77
|
+
*/
|
|
78
|
+
this.hasPanelTitleSlot = () => {
|
|
79
|
+
return this.element.querySelector('[slot="panel-title"]') !== null;
|
|
80
|
+
};
|
|
74
81
|
/**
|
|
75
82
|
* Toggle is editing state
|
|
76
83
|
*/
|
|
@@ -124,7 +131,7 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class MgPanel extends HTMLEle
|
|
|
124
131
|
* Render collapse button
|
|
125
132
|
* @returns collpase button
|
|
126
133
|
*/
|
|
127
|
-
this.renderCollapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", "aria-expanded": this.expanded.toString(), "aria-controls": `${this.identifier}-content`, disabled: this.expandToggleDisabled, isIcon: this.expandToggleDisplay === 'icon', label: this.panelTitle }, h("span", { class: "mg-c-panel__collapse-button-content" }, h("mg-icon", { icon: "chevron-up", class: { 'mg-c-panel__collapse-button-icon': true, 'mg-c-panel__collapse-button-icon--reverse': !this.expanded } }), !this.isEditing && this.expandToggleDisplay !== 'icon' && this.panelTitle)));
|
|
134
|
+
this.renderCollapseButton = () => (h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", "aria-expanded": this.expanded.toString(), "aria-controls": `${this.identifier}-content`, disabled: this.expandToggleDisabled, isIcon: this.expandToggleDisplay === 'icon', label: this.expandToggleDisplay === 'icon' ? this.panelTitle : undefined }, h("span", { class: "mg-c-panel__collapse-button-content" }, h("mg-icon", { icon: "chevron-up", class: { 'mg-c-panel__collapse-button-icon': true, 'mg-c-panel__collapse-button-icon--reverse': !this.expanded } }), !this.isEditing && this.expandToggleDisplay !== 'icon' && (this.hasPanelTitleSlot() ? h("slot", { name: "panel-title" }) : this.panelTitle))));
|
|
128
135
|
/**
|
|
129
136
|
* Render edit button
|
|
130
137
|
* @returns edit Button
|
|
@@ -141,7 +148,8 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class MgPanel extends HTMLEle
|
|
|
141
148
|
*/
|
|
142
149
|
this.renderTitle = () => {
|
|
143
150
|
const elementsToRender = [this.renderCollapseButton()];
|
|
144
|
-
if
|
|
151
|
+
// Add edit functionality only if not using slot and title is editable
|
|
152
|
+
if (this.titleEditable && !this.hasPanelTitleSlot()) {
|
|
145
153
|
if (!this.isEditing)
|
|
146
154
|
elementsToRender.push(this.renderEditButton());
|
|
147
155
|
else
|
|
@@ -167,14 +175,24 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class MgPanel extends HTMLEle
|
|
|
167
175
|
}
|
|
168
176
|
}
|
|
169
177
|
validatePanelTitle(newValue) {
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
|
|
178
|
+
if (newValue !== undefined) {
|
|
179
|
+
if (!isValidString(newValue)) {
|
|
180
|
+
throw new Error(`<mg-panel> prop "panelTitle" must be a string. Passed value: ${toString(newValue)}.`);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.titleChange.emit(newValue);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
173
186
|
}
|
|
174
187
|
validateTitlePattern(newValue) {
|
|
175
188
|
if (newValue !== undefined && !this.titleEditable)
|
|
176
189
|
throw new Error(`<mg-panel> prop "titleEditable" must be set to "true".`);
|
|
177
190
|
}
|
|
191
|
+
validateTitleEditable(newValue) {
|
|
192
|
+
if (newValue && this.hasPanelTitleSlot()) {
|
|
193
|
+
throw new Error(`<mg-panel> prop "titleEditable" cannot be used with panel-title slot.`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
178
196
|
validateTitlePosition(newValue) {
|
|
179
197
|
if (!titlePositions.includes(newValue))
|
|
180
198
|
throw new Error(`<mg-panel> prop "titlePosition" must be one of: ${titlePositions.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
@@ -187,6 +205,9 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class MgPanel extends HTMLEle
|
|
|
187
205
|
throw new Error(`<mg-panel> prop "expandToggleDisplay" must be one of: ${expandToggleDisplays.join(', ')}. Passed value: ${toString(newValue)}.`);
|
|
188
206
|
if (newValue === 'icon' && this.titleEditable)
|
|
189
207
|
this.titleEditable = false;
|
|
208
|
+
if (newValue === 'icon' && this.hasPanelTitleSlot()) {
|
|
209
|
+
throw new Error(`<mg-panel> prop "expandToggleDisplay" cannot be "icon" when panel-title slot is used.`);
|
|
210
|
+
}
|
|
190
211
|
}
|
|
191
212
|
/*************
|
|
192
213
|
* Lifecycle *
|
|
@@ -201,9 +222,15 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class MgPanel extends HTMLEle
|
|
|
201
222
|
this.watchIdentifier(this.identifier);
|
|
202
223
|
this.validateTitlePattern(this.titlePattern);
|
|
203
224
|
this.validateTitlePattern(this.titlePatternErrorMessage);
|
|
204
|
-
|
|
225
|
+
// Only validate panelTitle if slot is not used
|
|
226
|
+
if (!this.hasPanelTitleSlot()) {
|
|
227
|
+
if (!isValidString(this.panelTitle))
|
|
228
|
+
throw new Error(`<mg-panel> prop "panelTitle" is required when panel-title slot is not used.`);
|
|
229
|
+
this.validatePanelTitle(this.panelTitle);
|
|
230
|
+
}
|
|
205
231
|
this.validateExpandToggleDisplay(this.expandToggleDisplay);
|
|
206
232
|
this.validateTitlePosition(this.titlePosition);
|
|
233
|
+
this.validateTitleEditable(this.titleEditable);
|
|
207
234
|
}
|
|
208
235
|
/**
|
|
209
236
|
* Edit DOM after render
|
|
@@ -219,7 +246,7 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class MgPanel extends HTMLEle
|
|
|
219
246
|
*/
|
|
220
247
|
render() {
|
|
221
248
|
const headerId = `${this.identifier}-header`;
|
|
222
|
-
return (h("section", { key: '
|
|
249
|
+
return (h("section", { key: '3662204d763051c34ea13de4b7b3f7abc7914b81', class: this.classCollection.join(), id: this.identifier }, h("mg-card", { key: '46f113258172b1d040f65a4d312554b0c0551489', shadow: this.shadow }, h("header", { key: '1d7e7a48a5c4f89d141a5a7e46b220d4f9c082a5', class: { 'mg-c-panel__header': true, 'mg-c-panel__header--reverse': this.titlePosition === 'right' }, id: headerId }, this.renderHeaderChildren()), h("article", { key: 'ab0aec831cc79d982b7556d6e245c80ae2979083', class: "mg-c-panel__content", id: `${this.identifier}-content`, "aria-labelledby": headerId, hidden: !this.expanded }, h("slot", { key: 'e831573fe9d5ff783073d123b7e2a54baad73bfc' })))));
|
|
223
250
|
}
|
|
224
251
|
get element() { return this; }
|
|
225
252
|
static get watchers() { return {
|
|
@@ -227,6 +254,7 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class MgPanel extends HTMLEle
|
|
|
227
254
|
"panelTitle": ["validatePanelTitle"],
|
|
228
255
|
"titlePattern": ["validateTitlePattern"],
|
|
229
256
|
"titlePatternErrorMessage": ["validateTitlePattern"],
|
|
257
|
+
"titleEditable": ["validateTitleEditable"],
|
|
230
258
|
"titlePosition": ["validateTitlePosition"],
|
|
231
259
|
"expanded": ["handleExpanded"],
|
|
232
260
|
"expandToggleDisplay": ["validateExpandToggleDisplay"]
|
|
@@ -251,6 +279,7 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class MgPanel extends HTMLEle
|
|
|
251
279
|
"panelTitle": ["validatePanelTitle"],
|
|
252
280
|
"titlePattern": ["validateTitlePattern"],
|
|
253
281
|
"titlePatternErrorMessage": ["validateTitlePattern"],
|
|
282
|
+
"titleEditable": ["validateTitleEditable"],
|
|
254
283
|
"titlePosition": ["validateTitlePosition"],
|
|
255
284
|
"expanded": ["handleExpanded"],
|
|
256
285
|
"expandToggleDisplay": ["validateExpandToggleDisplay"]
|
|
@@ -55,7 +55,7 @@ const MgPopoverContent = /*@__PURE__*/ proxyCustomElement(class MgPopoverContent
|
|
|
55
55
|
* @returns HTML Element
|
|
56
56
|
*/
|
|
57
57
|
render() {
|
|
58
|
-
return (h(Host, { key: '
|
|
58
|
+
return (h(Host, { key: '054fc82954b39a488f7fe5cb391d89b5fa4a61fe' }, h("mg-card", { key: 'bb89bada37069b50295bd93d988667c3b85eada3', class: this.classCollection.join(), shadow: true }, this.closeButton && (h("mg-button", { key: 'a59d6610574b964be1e2ce34ccd8e31c1395b6ff', "is-icon": true, variant: "flat", label: this.messages.general.close, onClick: this.handleCloseButton }, h("mg-icon", { key: '5bcc9e4eb21396f4fc66a6f1e4d6c5cdf68ec1f4', icon: "cross" }))), h("div", { key: '57be2022f3b61220e1249faeaf2acee9960027fe', class: "mg-c-popover-content__title" }, h("slot", { key: 'c7870e86a9f105cf6b9d4520c77874bce9235d72', name: "title" })), h("slot", { key: '5af8462232625d9c7d694bab46351d5e646f62ca', name: "content" })), h("slot", { key: '599863410dd7d751e82c440cd6c4fb7f2c48d9f3', name: "arrow" })));
|
|
59
59
|
}
|
|
60
60
|
get element() { return this; }
|
|
61
61
|
static get style() { return mgPopoverContentCss; }
|
|
@@ -251,7 +251,7 @@ const MgPopover = /*@__PURE__*/ proxyCustomElement(class MgPopover extends HTMLE
|
|
|
251
251
|
* @returns HTML Element
|
|
252
252
|
*/
|
|
253
253
|
render() {
|
|
254
|
-
return (h(Host, { key: '
|
|
254
|
+
return (h(Host, { key: '2c1506b8e2da100519aeeae75fc5c378a81c473c' }, h("slot", { key: 'f9aea885e8cbc168614c05761829f0a0740eba9e' }), h("slot", { key: 'fa6106a660a73b3761d4783f8d46d401c47b4eb6', name: "content" })));
|
|
255
255
|
}
|
|
256
256
|
get element() { return this; }
|
|
257
257
|
static get watchers() { return {
|