@mgdis/mg-components 6.14.0 → 6.15.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-DzBkSgSK.js → index-BGxkpQwi.js} +7 -1
- package/dist/cjs/{index-DUJwxnoi.js → index-CpENFzEo.js} +2 -2
- package/dist/cjs/{index-CwjAofQ1.js → index-iUZvsp-F.js} +55 -31
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mg-action-more_37.cjs.entry.js +431 -208
- package/dist/cjs/mg-alert.cjs.entry.js +4 -4
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/cjs/mg-input-combobox.cjs.entry.js +145 -81
- package/dist/cjs/mg-input-rich-text-editor.cjs.entry.js +1248 -16004
- package/dist/cjs/{mg-input.conf-WTsvDfpC.js → mg-input.conf-CwjEAih3.js} +7 -0
- package/dist/cjs/mg-input.utils-D-ASK4ua.js +49 -0
- package/dist/cjs/mg-loader.cjs.entry.js +4 -4
- package/dist/cjs/mg-progress.cjs.entry.js +3 -3
- package/dist/collection/assets/icons/index.js +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +6 -0
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.js +93 -22
- package/dist/collection/components/molecules/inputs/mg-input/mg-input.utils.js +21 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +2 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.js +49 -106
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +123 -48
- package/dist/collection/components/molecules/inputs/mg-input-combobox/mg-input-combobox.js +140 -56
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +63 -10
- package/dist/collection/components/molecules/inputs/mg-input-rich-text-editor/mg-input-rich-text-editor.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +54 -6
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +2 -2
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +142 -9
- package/dist/collection/components/molecules/internals/mg-item-more/mg-item-more.js +1 -1
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +2 -2
- 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-form/mg-form.js +1 -1
- 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 +1 -1
- 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-table/mg-table.js +2 -2
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +1 -1
- package/dist/collection/locales/en/messages.json +23 -14
- package/dist/collection/locales/fr/messages.json +24 -15
- package/dist/components/index2.js +3 -3
- package/dist/components/index3.js +55 -31
- package/dist/components/mg-action-more.js +2 -2
- package/dist/components/mg-alert.js +2 -2
- package/dist/components/mg-badge2.js +1 -1
- package/dist/components/mg-button2.js +1 -1
- package/dist/components/mg-card2.js +1 -1
- package/dist/components/mg-character-left2.js +1 -1
- package/dist/components/mg-details.js +1 -97
- package/dist/components/mg-details2.js +99 -0
- package/dist/components/mg-divider2.js +1 -1
- package/dist/components/mg-form.js +2 -2
- package/dist/components/mg-icon2.js +1 -1
- package/dist/components/mg-illustrated-message.js +2 -2
- package/dist/components/mg-input-checkbox-paginated2.js +43 -124
- package/dist/components/mg-input-checkbox.js +136 -62
- package/dist/components/mg-input-combobox.js +135 -63
- package/dist/components/mg-input-date.js +9 -3
- package/dist/components/mg-input-numeric.js +14 -3
- package/dist/components/mg-input-password.js +10 -4
- package/dist/components/mg-input-radio.js +54 -13
- package/dist/components/mg-input-rich-text-editor.js +1266 -16016
- package/dist/components/mg-input-select2.js +45 -9
- package/dist/components/mg-input-text2.js +10 -4
- package/dist/components/mg-input-textarea.js +10 -4
- package/dist/components/mg-input-title2.js +1 -1
- package/dist/components/mg-input-toggle.js +97 -12
- package/dist/components/mg-input.utils.js +24 -0
- package/dist/components/mg-input2.js +100 -23
- package/dist/components/mg-item-more2.js +2 -2
- package/dist/components/mg-loader2.js +2 -2
- package/dist/components/mg-menu-item2.js +1 -1
- package/dist/components/mg-message2.js +3 -3
- package/dist/components/mg-modal.js +3 -3
- package/dist/components/mg-pagination.js +233 -1
- package/dist/components/mg-panel.js +14 -8
- package/dist/components/mg-popover-content2.js +2 -2
- package/dist/components/mg-popover2.js +2 -2
- package/dist/components/mg-progress.js +2 -2
- package/dist/components/mg-skip-links.js +2 -2
- package/dist/components/mg-table.js +3 -3
- package/dist/components/mg-tabs.js +1 -311
- package/dist/components/mg-tabs2.js +313 -0
- package/dist/components/mg-tag.js +1 -1
- package/dist/components/mg-tooltip-content2.js +1 -1
- package/dist/components/mg-tooltip2.js +2 -2
- package/dist/esm/{index-Bv7NHR-W.js → index-CKB-AnCZ.js} +55 -31
- package/dist/esm/{index-Degtjvph.js → index-DhAOnZJn.js} +7 -1
- package/dist/esm/{index-Dr7GYvIz.js → index-WtiuOkLj.js} +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-action-more_37.entry.js +426 -203
- package/dist/esm/mg-alert.entry.js +4 -4
- package/dist/esm/mg-components.js +4 -4
- package/dist/esm/mg-input-combobox.entry.js +125 -61
- package/dist/esm/mg-input-rich-text-editor.entry.js +1249 -16005
- package/dist/esm/{mg-input.conf-CNgv8hc5.js → mg-input.conf-BAUTlb6r.js} +7 -1
- package/dist/esm/mg-input.utils-BYI03zSi.js +46 -0
- package/dist/esm/mg-loader.entry.js +4 -4
- package/dist/esm/mg-progress.entry.js +3 -3
- package/dist/mg-components/locales/en/messages.json +23 -14
- package/dist/mg-components/locales/fr/messages.json +24 -15
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-31856cff.entry.js +1 -0
- package/dist/mg-components/{p-056ba467.entry.js → p-420daa1e.entry.js} +1 -1
- package/dist/mg-components/{p-d13a6fdc.entry.js → p-47e19783.entry.js} +1 -1
- package/dist/mg-components/p-67af6274.entry.js +1 -0
- package/dist/mg-components/p-698dfc6c.entry.js +1 -0
- package/dist/mg-components/p-BAUTlb6r.js +1 -0
- package/dist/mg-components/p-CKB-AnCZ.js +1 -0
- package/dist/mg-components/p-DhAOnZJn.js +2 -0
- package/dist/mg-components/p-PuX-pdL4.js +1 -0
- package/dist/mg-components/p-WtiuOkLj.js +1 -0
- package/dist/mg-components/p-a0fa44cf.entry.js +1 -0
- package/dist/types/assets/icons/index.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +13 -0
- package/dist/types/components/molecules/inputs/mg-input/mg-input.d.ts +15 -4
- package/dist/types/components/molecules/inputs/mg-input/mg-input.utils.d.ts +8 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox-paginated/mg-input-checkbox-paginated.d.ts +17 -40
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +1 -2
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +36 -9
- package/dist/types/components/molecules/inputs/mg-input-combobox/mg-input-combobox.d.ts +17 -3
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +18 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +18 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +40 -4
- package/dist/types/components.d.ts +69 -40
- package/ide/intellij/web-types.json +148 -22
- package/ide/vscode/html-custom-data.json +143 -9
- package/package.json +15 -15
- package/dist/cjs/events.utils-D5SAtkpQ.js +0 -25
- package/dist/components/mg-pagination2.js +0 -229
- package/dist/esm/events.utils-yMGqY8YG.js +0 -23
- package/dist/mg-components/p-625c463c.entry.js +0 -1
- package/dist/mg-components/p-Bv7NHR-W.js +0 -1
- package/dist/mg-components/p-CNgv8hc5.js +0 -1
- package/dist/mg-components/p-Degtjvph.js +0 -2
- package/dist/mg-components/p-Dr7GYvIz.js +0 -1
- package/dist/mg-components/p-c522f3c1.entry.js +0 -1
- package/dist/mg-components/p-cac23bd7.entry.js +0 -1
- package/dist/mg-components/p-e75f5383.entry.js +0 -10
- package/dist/mg-components/p-yMGqY8YG.js +0 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
import { i as isValidString, t as toString, a as isValideID } from './index2.js';
|
|
2
|
+
import { i as isValidString, t as toString, a as isValideID, h as isObject } from './index2.js';
|
|
3
|
+
import { i as initLocales } from './index3.js';
|
|
4
|
+
import { d as defineCustomElement$5 } from './mg-details2.js';
|
|
3
5
|
import { d as defineCustomElement$4 } from './mg-icon2.js';
|
|
4
6
|
import { d as defineCustomElement$3 } from './mg-input-title2.js';
|
|
5
7
|
import { d as defineCustomElement$2 } from './mg-tooltip2.js';
|
|
@@ -17,9 +19,16 @@ const classFieldset = 'mg-c-input--fieldset';
|
|
|
17
19
|
const classDisabled = 'mg-c-input--disabled';
|
|
18
20
|
const classReadonly = 'mg-c-input--readonly';
|
|
19
21
|
const classVerticalList = 'mg-c-input--vertical-list';
|
|
22
|
+
/**
|
|
23
|
+
* Define cutom errors
|
|
24
|
+
*/
|
|
25
|
+
const CustomError = {
|
|
26
|
+
NoValue: 'noValue',
|
|
27
|
+
};
|
|
20
28
|
|
|
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}}";
|
|
29
|
+
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{--mg-c-details-spacing:0;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}}";
|
|
22
30
|
|
|
31
|
+
const isValidErrorMessageType = (msg) => isObject(msg) && ['summary', 'details'].every(key => typeof msg[key] === 'string');
|
|
23
32
|
const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLElement {
|
|
24
33
|
constructor() {
|
|
25
34
|
super();
|
|
@@ -27,6 +36,8 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
27
36
|
this.__attachShadow();
|
|
28
37
|
this.slotLabel = 'label';
|
|
29
38
|
this.slotError = 'error';
|
|
39
|
+
this.slotSummary = 'summary';
|
|
40
|
+
this.slotDetails = 'details';
|
|
30
41
|
this.slotHelpText = 'help-text';
|
|
31
42
|
// style
|
|
32
43
|
this.classInput = 'mg-c-input';
|
|
@@ -68,6 +79,44 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
68
79
|
* Element is disabled
|
|
69
80
|
*/
|
|
70
81
|
this.isVerticalList = false;
|
|
82
|
+
/**
|
|
83
|
+
* Render error message details element
|
|
84
|
+
*/
|
|
85
|
+
this.renderErrorDetailsMessage = (message) => {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
// remove error slot if it is NOT a MG-DETAIL
|
|
88
|
+
if (((_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.nodeName) !== 'MG-DETAILS') {
|
|
89
|
+
(_b = this.errorMessageSlotElement) === null || _b === void 0 ? void 0 : _b.remove();
|
|
90
|
+
}
|
|
91
|
+
// create OR update error summary
|
|
92
|
+
let summarySlotElement = this.element.querySelector(`[slot=${this.slotError}] [slot=${this.slotSummary}]`);
|
|
93
|
+
if (summarySlotElement === null) {
|
|
94
|
+
summarySlotElement = document.createElement('span');
|
|
95
|
+
summarySlotElement.setAttribute('slot', this.slotSummary);
|
|
96
|
+
}
|
|
97
|
+
summarySlotElement.innerHTML = message.summary;
|
|
98
|
+
// create OR update error details
|
|
99
|
+
let detailsSlotElement = this.element.querySelector(`[slot=${this.slotError}] [slot=${this.slotDetails}]`);
|
|
100
|
+
if (detailsSlotElement === null) {
|
|
101
|
+
detailsSlotElement = document.createElement('p');
|
|
102
|
+
detailsSlotElement.setAttribute('slot', this.slotDetails);
|
|
103
|
+
detailsSlotElement.classList.add('mg-c-input__error-details');
|
|
104
|
+
}
|
|
105
|
+
detailsSlotElement.innerHTML = message.details;
|
|
106
|
+
// create error mg-details
|
|
107
|
+
let mgDetails = this.element.querySelector(`mg-details[slot=${this.slotError}]`);
|
|
108
|
+
if (mgDetails === null) {
|
|
109
|
+
mgDetails = document.createElement('mg-details');
|
|
110
|
+
mgDetails.classList.add('mg-c-input__error');
|
|
111
|
+
mgDetails.toggleClosed = this.messages.details.toggleClosed;
|
|
112
|
+
mgDetails.toggleOpened = this.messages.details.toggleOpened;
|
|
113
|
+
mgDetails.hideSummary = true;
|
|
114
|
+
mgDetails.appendChild(summarySlotElement);
|
|
115
|
+
mgDetails.appendChild(detailsSlotElement);
|
|
116
|
+
this.element.appendChild(mgDetails);
|
|
117
|
+
}
|
|
118
|
+
this.errorMessageSlotElement = mgDetails;
|
|
119
|
+
};
|
|
71
120
|
/**
|
|
72
121
|
* Get tooltip node
|
|
73
122
|
* @returns mg-tooltip
|
|
@@ -105,16 +154,14 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
105
154
|
}
|
|
106
155
|
}
|
|
107
156
|
watchErrorMessage(newValue) {
|
|
108
|
-
|
|
109
|
-
if (newValue !== undefined) {
|
|
157
|
+
if (isValidString(newValue) || isValidErrorMessageType(newValue)) {
|
|
110
158
|
this.element.classList.add(this.classHasError);
|
|
111
|
-
this.renderErrorMessage();
|
|
112
159
|
}
|
|
113
160
|
else {
|
|
114
161
|
this.element.classList.remove(this.classHasError);
|
|
115
|
-
(_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.remove();
|
|
116
|
-
this.errorMessageSlotElement = undefined;
|
|
117
162
|
}
|
|
163
|
+
// update error message slot
|
|
164
|
+
this.renderErrorMessageSlot();
|
|
118
165
|
}
|
|
119
166
|
watchHelpText(newValue) {
|
|
120
167
|
var _a;
|
|
@@ -143,14 +190,12 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
143
190
|
// Help text
|
|
144
191
|
if (this.helpText !== undefined) {
|
|
145
192
|
this.renderHelpText();
|
|
146
|
-
|
|
147
|
-
ariaDescribedbyIDs.add(this.helpTextId);
|
|
193
|
+
ariaDescribedbyIDs.add(this.helpTextId);
|
|
148
194
|
}
|
|
149
195
|
// Error Message
|
|
150
196
|
if (this.errorMessage !== undefined) {
|
|
151
|
-
this.
|
|
152
|
-
|
|
153
|
-
ariaDescribedbyIDs.add(this.helpTextErrorId);
|
|
197
|
+
this.renderErrorMessageSlot();
|
|
198
|
+
ariaDescribedbyIDs.add(this.helpTextErrorId);
|
|
154
199
|
}
|
|
155
200
|
this.element.querySelectorAll('input,select,textarea,[role="switch"]').forEach(element => {
|
|
156
201
|
if (ariaDescribedbyIDs.size > 0) {
|
|
@@ -216,17 +261,41 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
216
261
|
this.element.appendChild(labelSlotElement);
|
|
217
262
|
}
|
|
218
263
|
/**
|
|
219
|
-
* Render error message
|
|
264
|
+
* Render error message element
|
|
220
265
|
*/
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if
|
|
266
|
+
renderErrorStringMessage(message) {
|
|
267
|
+
var _a;
|
|
268
|
+
// remove error slot if it is a MG-DETAIL
|
|
269
|
+
if (((_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.nodeName) === 'MG-DETAILS') {
|
|
270
|
+
this.errorMessageSlotElement.remove();
|
|
271
|
+
}
|
|
272
|
+
// create element if it does NOT exist
|
|
273
|
+
else if (this.errorMessageSlotElement === null) {
|
|
224
274
|
this.errorMessageSlotElement = document.createElement('div');
|
|
225
|
-
this.errorMessageSlotElement.setAttribute('slot', this.slotError);
|
|
226
275
|
this.element.appendChild(this.errorMessageSlotElement);
|
|
227
276
|
}
|
|
228
|
-
this.errorMessageSlotElement.
|
|
229
|
-
|
|
277
|
+
this.errorMessageSlotElement.innerHTML = message;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Render error message slot element
|
|
281
|
+
*/
|
|
282
|
+
renderErrorMessageSlot() {
|
|
283
|
+
var _a;
|
|
284
|
+
this.errorMessageSlotElement = this.element.querySelector(`[slot=${this.slotError}]`);
|
|
285
|
+
if (this.errorMessage !== undefined) {
|
|
286
|
+
if (typeof this.errorMessage === 'string') {
|
|
287
|
+
this.renderErrorStringMessage(this.errorMessage);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
this.renderErrorDetailsMessage(this.errorMessage);
|
|
291
|
+
}
|
|
292
|
+
this.errorMessageSlotElement.setAttribute('slot', this.slotError);
|
|
293
|
+
this.errorMessageSlotElement.setAttribute('id', this.helpTextErrorId);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
(_a = this.errorMessageSlotElement) === null || _a === void 0 ? void 0 : _a.remove();
|
|
297
|
+
this.errorMessageSlotElement = undefined;
|
|
298
|
+
}
|
|
230
299
|
}
|
|
231
300
|
/**
|
|
232
301
|
* Render help text message
|
|
@@ -248,6 +317,9 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
248
317
|
* Check if component props are well configured on init
|
|
249
318
|
*/
|
|
250
319
|
componentWillLoad() {
|
|
320
|
+
// Get locales
|
|
321
|
+
this.messages = initLocales(this.element).messages;
|
|
322
|
+
// Validate
|
|
251
323
|
this.watchIdentifier(this.identifier);
|
|
252
324
|
this.watchLabel();
|
|
253
325
|
this.watchClass();
|
|
@@ -272,7 +344,7 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
272
344
|
*/
|
|
273
345
|
render() {
|
|
274
346
|
const isGroup = this.isFieldset && !this.isReadonly;
|
|
275
|
-
return (h(Host, { key: '
|
|
347
|
+
return (h(Host, { key: '0641f834a725708ce254e82a86c3a75f1c183c0a', class: this.element.classList.toString(), role: isGroup ? 'group' : undefined, "aria-labelledby": isGroup ? `${this.identifier}-title` : undefined }, h("div", { key: '7d96f125694996407b8cecd9491366c39fd0d05f', class: { 'mg-c-input__title': true, 'mg-u-visually-hidden': this.labelHide } }, h("slot", { key: '43720fcecc55de1cae61607b2ae2c3b224e18dbd', name: this.slotLabel }), this.tooltip && (this.tooltipPosition === 'label' || this.labelOnTop) && !this.labelHide && this.renderTooltip()), h("div", { key: '1d9c6fc50758fd2b87d9a15b9983f6e944a9851e', class: "mg-c-input__input-container" }, h("div", { key: '983153a1e0d5777d11cc61af47a4231f093d7e9e', class: "mg-c-input__input" }, h("slot", { key: 'e3ae53d7484b193538c7c5ed68d02ddf3428eff4' }), this.tooltip && !this.labelOnTop && (this.tooltipPosition === 'input' || this.labelHide) && this.renderTooltip()), this.helptextMessageSlotElement && (h("div", { key: '2981238a76e52f4a9c5da6465934bb4edd653e96', class: "mg-c-input__help-text" }, h("slot", { key: 'feee3da8096260e11419b82cb2d281c8d73541d1', name: this.slotHelpText }))), !this.isDisabled && this.errorMessage && (h("div", { key: '1d5a709cfe3c9a1f7da68a260dd480f189ee5301', class: "mg-c-input__error", "aria-live": "assertive" }, h("slot", { key: '4f9f9545ffbdc7c53b77c5153daaf9b15b360fd7', name: this.slotError }))))));
|
|
276
348
|
}
|
|
277
349
|
get element() { return this; }
|
|
278
350
|
static get watchers() { return {
|
|
@@ -290,7 +362,7 @@ const MgInput = /*@__PURE__*/ proxyCustomElement(class MgInput extends HTMLEleme
|
|
|
290
362
|
"isFieldset": ["watchLabel"]
|
|
291
363
|
}; }
|
|
292
364
|
static get style() { return mgInputCss; }
|
|
293
|
-
}, [
|
|
365
|
+
}, [257, "mg-input", {
|
|
294
366
|
"identifier": [1],
|
|
295
367
|
"label": [1],
|
|
296
368
|
"labelOnTop": [4, "label-on-top"],
|
|
@@ -323,13 +395,18 @@ function defineCustomElement() {
|
|
|
323
395
|
if (typeof customElements === "undefined") {
|
|
324
396
|
return;
|
|
325
397
|
}
|
|
326
|
-
const components = ["mg-input", "mg-icon", "mg-input-title", "mg-tooltip", "mg-tooltip-content"];
|
|
398
|
+
const components = ["mg-input", "mg-details", "mg-icon", "mg-input-title", "mg-tooltip", "mg-tooltip-content"];
|
|
327
399
|
components.forEach(tagName => { switch (tagName) {
|
|
328
400
|
case "mg-input":
|
|
329
401
|
if (!customElements.get(tagName)) {
|
|
330
402
|
customElements.define(tagName, MgInput);
|
|
331
403
|
}
|
|
332
404
|
break;
|
|
405
|
+
case "mg-details":
|
|
406
|
+
if (!customElements.get(tagName)) {
|
|
407
|
+
defineCustomElement$5();
|
|
408
|
+
}
|
|
409
|
+
break;
|
|
333
410
|
case "mg-icon":
|
|
334
411
|
if (!customElements.get(tagName)) {
|
|
335
412
|
defineCustomElement$4();
|
|
@@ -354,4 +431,4 @@ function defineCustomElement() {
|
|
|
354
431
|
}
|
|
355
432
|
defineCustomElement();
|
|
356
433
|
|
|
357
|
-
export { MgInput as M, classDisabled as a, classFieldset as b, classReadonly as c, defineCustomElement as d, classVerticalList as e, widths as w };
|
|
434
|
+
export { CustomError as C, MgInput as M, classDisabled as a, classFieldset as b, classReadonly as c, defineCustomElement as d, classVerticalList as e, widths as w };
|
|
@@ -262,7 +262,7 @@ const MgMenu = /*@__PURE__*/ proxyCustomElement(class MgMenu extends HTMLElement
|
|
|
262
262
|
"size": ["validateSize"]
|
|
263
263
|
}; }
|
|
264
264
|
static get style() { return mgMenuCss; }
|
|
265
|
-
}, [
|
|
265
|
+
}, [257, "mg-menu", {
|
|
266
266
|
"label": [1],
|
|
267
267
|
"direction": [513],
|
|
268
268
|
"itemmore": [16],
|
|
@@ -424,7 +424,7 @@ const MgItemMore = /*@__PURE__*/ proxyCustomElement(class MgItemMore extends HTM
|
|
|
424
424
|
"size": ["validateSize"]
|
|
425
425
|
}; }
|
|
426
426
|
static get style() { return mgItemMoreCss; }
|
|
427
|
-
}, [
|
|
427
|
+
}, [257, "mg-item-more", {
|
|
428
428
|
"icon": [16],
|
|
429
429
|
"slotlabel": [16],
|
|
430
430
|
"size": [1],
|
|
@@ -36,14 +36,14 @@ const MgLoader = /*@__PURE__*/ proxyCustomElement(class MgLoader extends HTMLEle
|
|
|
36
36
|
* @returns HTML Element
|
|
37
37
|
*/
|
|
38
38
|
render() {
|
|
39
|
-
return (h("div", { key: '
|
|
39
|
+
return (h("div", { key: 'b74028455b7003824fa5618b1751d05a91ab7071', class: "mg-c-loader", "aria-live": "polite" }, h("mg-icon", { key: '204acdb8f881b348148020214c05269878852c4f', icon: "loader", spin: true }), h("span", { key: '40f1792354df01ec9af61ab128575ea166f34cb5', class: { 'mg-u-visually-hidden': this.messageHide } }, this.message || this.messages.loader.inProgress)));
|
|
40
40
|
}
|
|
41
41
|
get element() { return this; }
|
|
42
42
|
static get watchers() { return {
|
|
43
43
|
"message": ["watchMessage"]
|
|
44
44
|
}; }
|
|
45
45
|
static get style() { return mgLoaderCss; }
|
|
46
|
-
}, [
|
|
46
|
+
}, [257, "mg-loader", {
|
|
47
47
|
"message": [1],
|
|
48
48
|
"messageHide": [4, "message-hide"]
|
|
49
49
|
}, undefined, {
|
|
@@ -412,7 +412,7 @@ const MgMenuItem = /*@__PURE__*/ proxyCustomElement(class MgMenuItem extends HTM
|
|
|
412
412
|
"data-has-focus": ["watchDataHasFocus"]
|
|
413
413
|
}; }
|
|
414
414
|
static get style() { return mgMenuItemCss; }
|
|
415
|
-
}, [
|
|
415
|
+
}, [257, "mg-menu-item", {
|
|
416
416
|
"identifier": [513],
|
|
417
417
|
"href": [1],
|
|
418
418
|
"target": [1],
|
|
@@ -96,9 +96,9 @@ const MgMessage = /*@__PURE__*/ proxyCustomElement(class MgMessage extends HTMLE
|
|
|
96
96
|
* @returns HTML Element
|
|
97
97
|
*/
|
|
98
98
|
render() {
|
|
99
|
-
return (h("div", { key: '
|
|
99
|
+
return (h("div", { key: 'a113514956d6a3ef9fada1a20baa7b00843e5b96', class: this.classCollection.join() }, h("mg-card", { key: 'db894eb3d0f3cb9b18681e0925e0fd1bdcd208e2', shadow: true }, this.variantStyle === 'bar-left' && h("span", { key: '37eb3a027be82ab006fe30dd07bce88f526fc263', class: "mg-c-message__bar" }), h("span", { key: '76a3b6bf2d27ec85b3e9b7235cf5bba933ac02e2', class: "mg-c-message__icon" }, h("mg-icon", { key: '2988764c8a3d272dab5e749a8dc95643b9ead573', icon: this.getIcon() })), h("div", { key: '64e57835d18f433965eda9260efeb74055489c6e', class: "mg-c-message__content" }, h("span", { key: 'a2032d4fe0eec962cd9bb1e12119709bcb6ff53c', class: "mg-c-message__content-slot" }, h("slot", { key: 'dfe5f7315e8f8d66ccb195d8e7f7862eb803e6d9' })), this.hasActions && [
|
|
100
100
|
h("span", { class: "mg-c-message__content-separator", key: "content-separator" }),
|
|
101
|
-
h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, h("slot", { key: '
|
|
101
|
+
h("span", { class: "mg-c-message__content-actions-slot", key: "content-actions-slot" }, h("slot", { key: 'db1782730e0bffb168b8ec23410e6836f572715c', name: "actions" })),
|
|
102
102
|
]))));
|
|
103
103
|
}
|
|
104
104
|
get element() { return this; }
|
|
@@ -107,7 +107,7 @@ const MgMessage = /*@__PURE__*/ proxyCustomElement(class MgMessage extends HTMLE
|
|
|
107
107
|
"variantStyle": ["watchVariantStyle"]
|
|
108
108
|
}; }
|
|
109
109
|
static get style() { return mgMessageCss; }
|
|
110
|
-
}, [
|
|
110
|
+
}, [257, "mg-message", {
|
|
111
111
|
"variant": [1],
|
|
112
112
|
"variantStyle": [1, "variant-style"],
|
|
113
113
|
"classCollection": [32],
|
|
@@ -118,11 +118,11 @@ const MgModal$1 = /*@__PURE__*/ proxyCustomElement(class MgModal extends HTMLEle
|
|
|
118
118
|
* @returns HTML Element
|
|
119
119
|
*/
|
|
120
120
|
render() {
|
|
121
|
-
return (h("dialog", { key: '
|
|
121
|
+
return (h("dialog", { key: '783b289712deb419fa7ac4c9f371add80054af6b', role: this.dialogRole, id: this.identifier, class: this.classCollection.join(), "aria-labelledby": this.titleId, ref: (el) => {
|
|
122
122
|
if (el !== null) {
|
|
123
123
|
this.dialog = el;
|
|
124
124
|
}
|
|
125
|
-
} }, h("mg-card", { key: '
|
|
125
|
+
} }, h("mg-card", { key: 'd6006f296ab50a192229e09e6e01a3313ab69cce', shadow: true }, h("div", { key: '76bc44557dc4b4bcce40b54d5d4bfa381f7906af', class: "mg-c-modal__dialog" }, h("header", { key: '08ba473f429ae57434dd321575f9eaf97e41f7a9', class: "mg-c-modal__header" }, this.closeButton && (h("span", { key: 'd96baeaaefdb5541da7ee7bc58c3901b3d64ed33', class: "mg-c-modal__close-button" }, h("mg-button", { key: 'f43486e05e337fad6e54b8a0b07b9d13aad50acc', "is-icon": true, variant: "flat", label: this.messages.modal.closeButton, onClick: this.handleClose }, h("mg-icon", { key: '3278e25d15abdefb56cc3c67e7a8ec500d90547b', icon: "cross" })))), h("h1", { key: 'd9246055be4cb938f4aff20fcdc53b3a7c119d20', class: "mg-c-modal__title", id: this.titleId }, this.modalTitle)), h("article", { key: 'bce8cd10a2fffdf726df6d07b9f81da1fd693038', class: "mg-c-modal__content" }, h("slot", { key: '9db561d8462fe9a3afc6be543f2ef3b189f3efd4' })), this.hasActions && (h("footer", { key: '226e235454dce60eb8b5652add3b23e1cf480fc7', class: "mg-c-modal__footer" }, h("slot", { key: '8352666de0db98e96c52a419c939574285972571', name: "actions" })))))));
|
|
126
126
|
}
|
|
127
127
|
get element() { return this; }
|
|
128
128
|
static get watchers() { return {
|
|
@@ -132,7 +132,7 @@ const MgModal$1 = /*@__PURE__*/ proxyCustomElement(class MgModal extends HTMLEle
|
|
|
132
132
|
"open": ["watchOpen"]
|
|
133
133
|
}; }
|
|
134
134
|
static get style() { return mgModalCss; }
|
|
135
|
-
}, [
|
|
135
|
+
}, [257, "mg-modal", {
|
|
136
136
|
"identifier": [1],
|
|
137
137
|
"dialogRole": [1, "dialog-role"],
|
|
138
138
|
"modalTitle": [1, "modal-title"],
|
|
@@ -1,4 +1,236 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { c as createID, a as isValideID, t as toString, i as isValidString } from './index2.js';
|
|
3
|
+
import { i as initLocales } from './index3.js';
|
|
4
|
+
import { d as defineCustomElement$9 } from './mg-button2.js';
|
|
5
|
+
import { d as defineCustomElement$8 } from './mg-details2.js';
|
|
6
|
+
import { d as defineCustomElement$7 } from './mg-icon2.js';
|
|
7
|
+
import { d as defineCustomElement$6 } from './mg-input2.js';
|
|
8
|
+
import { d as defineCustomElement$5 } from './mg-input-select2.js';
|
|
9
|
+
import { d as defineCustomElement$4 } from './mg-input-title2.js';
|
|
10
|
+
import { d as defineCustomElement$3 } from './mg-tooltip2.js';
|
|
11
|
+
import { d as defineCustomElement$2 } from './mg-tooltip-content2.js';
|
|
12
|
+
|
|
13
|
+
const NavigationAction = {
|
|
14
|
+
NEXT: 'next',
|
|
15
|
+
PREVIOUS: 'previous',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const mgPaginationCss = ".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}}.mg-c-pagination{display:flex;align-items:center;gap:var(--mg-b-spacing-actions)}.mg-c-pagination__page-count{display:flex;align-items:center;gap:var(--mg-b-size-4)}.mg-c-pagination.mg-c-pagination--hide-page-count{gap:0}";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Range generator
|
|
22
|
+
*
|
|
23
|
+
* ```
|
|
24
|
+
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
25
|
+
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
26
|
+
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
27
|
+
* then with Array.from(Array(...)) we get the complete array with "index" values instead of "empty" values
|
|
28
|
+
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
29
|
+
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
30
|
+
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* range(1, 1) = [1]
|
|
34
|
+
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
35
|
+
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
36
|
+
* @param start - start range
|
|
37
|
+
* @param end - start end
|
|
38
|
+
* @param step - step size
|
|
39
|
+
* @returns range numbers
|
|
40
|
+
*/
|
|
41
|
+
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
42
|
+
const MgPagination$1 = /*@__PURE__*/ proxyCustomElement(class MgPagination extends HTMLElement {
|
|
43
|
+
constructor() {
|
|
44
|
+
super();
|
|
45
|
+
this.__registerHost();
|
|
46
|
+
this.__attachShadow();
|
|
47
|
+
this.currentPageChange = createEvent(this, "current-page-change", 7);
|
|
48
|
+
/**
|
|
49
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
50
|
+
* If not set, it will be created.
|
|
51
|
+
*/
|
|
52
|
+
this.identifier = createID('mg-pagination');
|
|
53
|
+
/**
|
|
54
|
+
* Hide navigation label
|
|
55
|
+
*/
|
|
56
|
+
this.hideNavigationLabels = false;
|
|
57
|
+
/**
|
|
58
|
+
* Hide select input
|
|
59
|
+
*/
|
|
60
|
+
this.hidePageCount = false;
|
|
61
|
+
/**
|
|
62
|
+
* Component total pages
|
|
63
|
+
*/
|
|
64
|
+
this.totalPages = 1;
|
|
65
|
+
/**
|
|
66
|
+
* Component current page
|
|
67
|
+
*/
|
|
68
|
+
this.currentPage = 1;
|
|
69
|
+
/**
|
|
70
|
+
* Change current page from target
|
|
71
|
+
* @param target - target page
|
|
72
|
+
*/
|
|
73
|
+
this.goToPage = (target) => {
|
|
74
|
+
this.currentPage = target;
|
|
75
|
+
};
|
|
76
|
+
/************
|
|
77
|
+
* Handlers *
|
|
78
|
+
************/
|
|
79
|
+
/**
|
|
80
|
+
* select handler
|
|
81
|
+
* @param event - value change event
|
|
82
|
+
*/
|
|
83
|
+
this.handleSelect = (event) => {
|
|
84
|
+
const to = Number(event.target.value);
|
|
85
|
+
this.goToPage(to > 0 ? to : 1);
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Go to 'previous/next' page button handler
|
|
89
|
+
* @param action - navigation action
|
|
90
|
+
* @param disabled - button disable state
|
|
91
|
+
*/
|
|
92
|
+
this.handleGoToPage = (action, disabled) => {
|
|
93
|
+
!disabled && this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
watchIdentifier(newValue) {
|
|
97
|
+
if (!isValideID(newValue)) {
|
|
98
|
+
console.error(`<mg-pagination> prop "identifier" value is invalid. Passed value: ${toString(newValue)}.`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
validateTotalPages(newValue) {
|
|
102
|
+
if (newValue < 1) {
|
|
103
|
+
throw new Error(`<mg-pagination> prop "totalPages" must be greater than 0. Passed value: ${toString(newValue)}.`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
validateCurrentPage(newValue) {
|
|
107
|
+
if (newValue < 1) {
|
|
108
|
+
throw new Error(`<mg-pagination> prop "currentPage" must be greater than 0. Passed value: ${toString(newValue)}.`);
|
|
109
|
+
}
|
|
110
|
+
else if (newValue > this.totalPages) {
|
|
111
|
+
throw new Error('<mg-pagination> prop "currentPage" can not be greater than total page.');
|
|
112
|
+
}
|
|
113
|
+
this.currentPageChange.emit(newValue);
|
|
114
|
+
}
|
|
115
|
+
watchPaginationMessages(newValue) {
|
|
116
|
+
if (Boolean(newValue) && (typeof newValue !== 'object' || !['next', 'previous', 'nextLabel', 'previousLabel'].every(key => isValidString(newValue[key])))) {
|
|
117
|
+
throw new Error('<mg-pagination> prop "messages" must be a valid "PaginationMessagesType".');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/*************
|
|
121
|
+
* Lifecycle *
|
|
122
|
+
*************/
|
|
123
|
+
/**
|
|
124
|
+
* Check if props are well configured on init
|
|
125
|
+
*/
|
|
126
|
+
componentWillLoad() {
|
|
127
|
+
// Get locales
|
|
128
|
+
this.localesMessages = initLocales(this.element).messages;
|
|
129
|
+
// Validate
|
|
130
|
+
this.watchIdentifier(this.identifier);
|
|
131
|
+
this.validateTotalPages(this.totalPages);
|
|
132
|
+
this.validateCurrentPage(this.currentPage);
|
|
133
|
+
this.watchPaginationMessages(this.messages);
|
|
134
|
+
// Set default label
|
|
135
|
+
if (this.label === undefined || this.label === '') {
|
|
136
|
+
this.label = this.localesMessages.pagination.label;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Render
|
|
141
|
+
* @returns HTML Element
|
|
142
|
+
*/
|
|
143
|
+
render() {
|
|
144
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
145
|
+
const navigationMessages = {
|
|
146
|
+
next: (_b = (_a = this.messages) === null || _a === void 0 ? void 0 : _a.next) !== null && _b !== void 0 ? _b : this.localesMessages.general.next,
|
|
147
|
+
previous: (_d = (_c = this.messages) === null || _c === void 0 ? void 0 : _c.previous) !== null && _d !== void 0 ? _d : this.localesMessages.general.previous,
|
|
148
|
+
nextLabel: (_f = (_e = this.messages) === null || _e === void 0 ? void 0 : _e.nextLabel) !== null && _f !== void 0 ? _f : this.localesMessages.pagination.nextLabel,
|
|
149
|
+
previousLabel: (_h = (_g = this.messages) === null || _g === void 0 ? void 0 : _g.previousLabel) !== null && _h !== void 0 ? _h : this.localesMessages.pagination.previousLabel,
|
|
150
|
+
};
|
|
151
|
+
const navigationActionButton = (disabled, action) => {
|
|
152
|
+
return (h("mg-button", { label: navigationMessages[`${action}Label`],
|
|
153
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
154
|
+
onClick: () => this.handleGoToPage(action, disabled), disabled: disabled, variant: "flat", isIcon: this.hideNavigationLabels }, action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }), !this.hideNavigationLabels && navigationMessages[action], action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
|
|
155
|
+
};
|
|
156
|
+
return (h(Host, { hidden: this.totalPages < 2 }, h("nav", { role: "navigation", "aria-label": this.label, id: this.identifier, class: { 'mg-c-pagination': true, 'mg-c-pagination--hide-page-count': this.hidePageCount } }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), !this.hidePageCount && (h("div", { class: "mg-c-pagination__page-count" }, h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.localesMessages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), h("span", { class: "mg-u-visually-hidden" }, this.localesMessages.pagination.page, " ", this.currentPage), "/ ", this.totalPages, " ", this.totalPages > 1 ? this.localesMessages.pagination.pages : this.localesMessages.pagination.page)), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT))));
|
|
157
|
+
}
|
|
158
|
+
get element() { return this; }
|
|
159
|
+
static get watchers() { return {
|
|
160
|
+
"identifier": ["watchIdentifier"],
|
|
161
|
+
"totalPages": ["validateTotalPages"],
|
|
162
|
+
"currentPage": ["validateCurrentPage"],
|
|
163
|
+
"messages": ["watchPaginationMessages"]
|
|
164
|
+
}; }
|
|
165
|
+
static get style() { return mgPaginationCss; }
|
|
166
|
+
}, [257, "mg-pagination", {
|
|
167
|
+
"identifier": [1],
|
|
168
|
+
"label": [1025],
|
|
169
|
+
"hideNavigationLabels": [4, "hide-navigation-labels"],
|
|
170
|
+
"hidePageCount": [4, "hide-page-count"],
|
|
171
|
+
"totalPages": [2, "total-pages"],
|
|
172
|
+
"currentPage": [1538, "current-page"],
|
|
173
|
+
"messages": [16]
|
|
174
|
+
}, undefined, {
|
|
175
|
+
"identifier": ["watchIdentifier"],
|
|
176
|
+
"totalPages": ["validateTotalPages"],
|
|
177
|
+
"currentPage": ["validateCurrentPage"],
|
|
178
|
+
"messages": ["watchPaginationMessages"]
|
|
179
|
+
}]);
|
|
180
|
+
function defineCustomElement$1() {
|
|
181
|
+
if (typeof customElements === "undefined") {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const components = ["mg-pagination", "mg-button", "mg-details", "mg-icon", "mg-input", "mg-input-select", "mg-input-title", "mg-tooltip", "mg-tooltip-content"];
|
|
185
|
+
components.forEach(tagName => { switch (tagName) {
|
|
186
|
+
case "mg-pagination":
|
|
187
|
+
if (!customElements.get(tagName)) {
|
|
188
|
+
customElements.define(tagName, MgPagination$1);
|
|
189
|
+
}
|
|
190
|
+
break;
|
|
191
|
+
case "mg-button":
|
|
192
|
+
if (!customElements.get(tagName)) {
|
|
193
|
+
defineCustomElement$9();
|
|
194
|
+
}
|
|
195
|
+
break;
|
|
196
|
+
case "mg-details":
|
|
197
|
+
if (!customElements.get(tagName)) {
|
|
198
|
+
defineCustomElement$8();
|
|
199
|
+
}
|
|
200
|
+
break;
|
|
201
|
+
case "mg-icon":
|
|
202
|
+
if (!customElements.get(tagName)) {
|
|
203
|
+
defineCustomElement$7();
|
|
204
|
+
}
|
|
205
|
+
break;
|
|
206
|
+
case "mg-input":
|
|
207
|
+
if (!customElements.get(tagName)) {
|
|
208
|
+
defineCustomElement$6();
|
|
209
|
+
}
|
|
210
|
+
break;
|
|
211
|
+
case "mg-input-select":
|
|
212
|
+
if (!customElements.get(tagName)) {
|
|
213
|
+
defineCustomElement$5();
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
case "mg-input-title":
|
|
217
|
+
if (!customElements.get(tagName)) {
|
|
218
|
+
defineCustomElement$4();
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
case "mg-tooltip":
|
|
222
|
+
if (!customElements.get(tagName)) {
|
|
223
|
+
defineCustomElement$3();
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
case "mg-tooltip-content":
|
|
227
|
+
if (!customElements.get(tagName)) {
|
|
228
|
+
defineCustomElement$2();
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
} });
|
|
232
|
+
}
|
|
233
|
+
defineCustomElement$1();
|
|
2
234
|
|
|
3
235
|
const MgPagination = MgPagination$1;
|
|
4
236
|
const defineCustomElement = defineCustomElement$1;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
2
|
import { c as createID, C as ClassList, a as isValideID, t as toString, i as isValidString } from './index2.js';
|
|
3
3
|
import { i as initLocales } from './index3.js';
|
|
4
|
-
import { d as defineCustomElement$
|
|
5
|
-
import { d as defineCustomElement$
|
|
6
|
-
import { d as defineCustomElement$
|
|
4
|
+
import { d as defineCustomElement$b } from './mg-button2.js';
|
|
5
|
+
import { d as defineCustomElement$a } from './mg-card2.js';
|
|
6
|
+
import { d as defineCustomElement$9 } from './mg-character-left2.js';
|
|
7
|
+
import { d as defineCustomElement$8 } from './mg-details2.js';
|
|
7
8
|
import { d as defineCustomElement$7 } from './mg-icon2.js';
|
|
8
9
|
import { d as defineCustomElement$6 } from './mg-input2.js';
|
|
9
10
|
import { d as defineCustomElement$5 } from './mg-input-text2.js';
|
|
@@ -217,7 +218,7 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class MgPanel extends HTMLEle
|
|
|
217
218
|
*/
|
|
218
219
|
render() {
|
|
219
220
|
const headerId = `${this.identifier}-header`;
|
|
220
|
-
return (h("section", { key: '
|
|
221
|
+
return (h("section", { key: '6d9b0759cf8d6a8e94a1a6598f45fc00288ca22a', class: this.classCollection.join(), id: this.identifier }, h("mg-card", { key: '21b0d991daf053506097333df58d3b98ec2e5b0e', shadow: this.shadow }, h("header", { key: 'abd9dbeb13d85c9a66aac13e7b32e6a83e2ded57', class: { 'mg-c-panel__header': true, 'mg-c-panel__header--reverse': this.titlePosition === 'right' }, id: headerId }, this.renderHeaderChildren()), h("article", { key: '23c74b70bd275fb18c853a1b7a0a4b4ff5a4c605', class: "mg-c-panel__content", id: `${this.identifier}-content`, "aria-labelledby": headerId, hidden: !this.expanded }, h("slot", { key: '15561936437c960768c4954f45df4045ac3dee03' })))));
|
|
221
222
|
}
|
|
222
223
|
get element() { return this; }
|
|
223
224
|
static get watchers() { return {
|
|
@@ -230,7 +231,7 @@ const MgPanel$1 = /*@__PURE__*/ proxyCustomElement(class MgPanel extends HTMLEle
|
|
|
230
231
|
"expandToggleDisplay": ["validateExpandToggleDisplay"]
|
|
231
232
|
}; }
|
|
232
233
|
static get style() { return mgPanelCss; }
|
|
233
|
-
}, [
|
|
234
|
+
}, [257, "mg-panel", {
|
|
234
235
|
"identifier": [1],
|
|
235
236
|
"panelTitle": [1025, "panel-title"],
|
|
236
237
|
"titlePattern": [1, "title-pattern"],
|
|
@@ -257,7 +258,7 @@ function defineCustomElement$1() {
|
|
|
257
258
|
if (typeof customElements === "undefined") {
|
|
258
259
|
return;
|
|
259
260
|
}
|
|
260
|
-
const components = ["mg-panel", "mg-button", "mg-card", "mg-character-left", "mg-icon", "mg-input", "mg-input-text", "mg-input-title", "mg-tooltip", "mg-tooltip-content"];
|
|
261
|
+
const components = ["mg-panel", "mg-button", "mg-card", "mg-character-left", "mg-details", "mg-icon", "mg-input", "mg-input-text", "mg-input-title", "mg-tooltip", "mg-tooltip-content"];
|
|
261
262
|
components.forEach(tagName => { switch (tagName) {
|
|
262
263
|
case "mg-panel":
|
|
263
264
|
if (!customElements.get(tagName)) {
|
|
@@ -266,15 +267,20 @@ function defineCustomElement$1() {
|
|
|
266
267
|
break;
|
|
267
268
|
case "mg-button":
|
|
268
269
|
if (!customElements.get(tagName)) {
|
|
269
|
-
defineCustomElement$
|
|
270
|
+
defineCustomElement$b();
|
|
270
271
|
}
|
|
271
272
|
break;
|
|
272
273
|
case "mg-card":
|
|
273
274
|
if (!customElements.get(tagName)) {
|
|
274
|
-
defineCustomElement$
|
|
275
|
+
defineCustomElement$a();
|
|
275
276
|
}
|
|
276
277
|
break;
|
|
277
278
|
case "mg-character-left":
|
|
279
|
+
if (!customElements.get(tagName)) {
|
|
280
|
+
defineCustomElement$9();
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
case "mg-details":
|
|
278
284
|
if (!customElements.get(tagName)) {
|
|
279
285
|
defineCustomElement$8();
|
|
280
286
|
}
|