@mgdis/mg-components 3.1.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/LICENSE +29 -0
- package/dist/cjs/css-shim-a22512c4.js +6 -0
- package/dist/cjs/index-85a4a0b6.js +1674 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +35 -0
- package/dist/cjs/mg-badge_20.cjs.entry.js +4661 -0
- package/dist/cjs/mg-components.cjs.js +23 -0
- package/dist/cjs/shadow-css-8940f82d.js +390 -0
- package/dist/collection/collection-manifest.json +31 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +4 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +99 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +148 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +27 -0
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +134 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +236 -0
- package/dist/collection/components/atoms/mg-button/mg-button.stories.js +38 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.css +3 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +133 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +15 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +54 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +57 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +155 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.stories.js +34 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +12 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +95 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.stories.js +21 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js +4 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +73 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +94 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +25 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +44 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +225 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.stories.js +26 -0
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +7 -0
- package/dist/collection/components/molecules/inputs/MgInput.js +130 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +156 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +444 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +57 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +7 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +171 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +467 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +46 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +11 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +199 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +633 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +68 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +195 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +401 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +43 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +156 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +443 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +65 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +201 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +532 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +70 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +222 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +589 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +115 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +217 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +553 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +52 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +213 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +457 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +73 -0
- package/dist/collection/components/molecules/mg-message/mg-message.conf.js +4 -0
- package/dist/collection/components/molecules/mg-message/mg-message.css +94 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +285 -0
- package/dist/collection/components/molecules/mg-message/mg-message.stories.js +43 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +5 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +39 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +218 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +23 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +59 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +249 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.stories.js +36 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +30 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +212 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +40 -0
- package/dist/collection/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/collection/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/collection/fonts/Poppins-Bold.ttf +0 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/locales/index.js +4 -0
- package/dist/collection/stories/buttons.stories.js +43 -0
- package/dist/collection/stories/grids.stories.js +50 -0
- package/dist/collection/stories/icons.stories.js +20 -0
- package/dist/collection/stories/messages.stories.js +44 -0
- package/dist/collection/stories/tags.stories.js +13 -0
- package/dist/collection/stories/typography.stories.js +28 -0
- package/dist/collection/utils/components.utils.js +67 -0
- package/dist/collection/utils/locale.utils.js +32 -0
- package/dist/collection/utils/test.utils.js +26 -0
- package/dist/collection/variables.css +177 -0
- package/dist/collection/variables.scss +177 -0
- package/dist/components/MgInput.js +140 -0
- package/dist/components/components.utils.js +69 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index2.js +54 -0
- package/dist/components/locale.utils.js +35 -0
- package/dist/components/mg-badge.d.ts +11 -0
- package/dist/components/mg-badge.js +6 -0
- package/dist/components/mg-badge2.js +82 -0
- package/dist/components/mg-button.d.ts +11 -0
- package/dist/components/mg-button.js +6 -0
- package/dist/components/mg-button2.js +148 -0
- package/dist/components/mg-character-left.d.ts +11 -0
- package/dist/components/mg-character-left.js +6 -0
- package/dist/components/mg-character-left2.js +77 -0
- package/dist/components/mg-icon.d.ts +11 -0
- package/dist/components/mg-icon.js +6 -0
- package/dist/components/mg-icon2.js +147 -0
- package/dist/components/mg-input-checkbox.d.ts +11 -0
- package/dist/components/mg-input-checkbox.js +222 -0
- package/dist/components/mg-input-date.d.ts +11 -0
- package/dist/components/mg-input-date.js +245 -0
- package/dist/components/mg-input-numeric.d.ts +11 -0
- package/dist/components/mg-input-numeric.js +324 -0
- package/dist/components/mg-input-password.d.ts +11 -0
- package/dist/components/mg-input-password.js +171 -0
- package/dist/components/mg-input-radio.d.ts +11 -0
- package/dist/components/mg-input-radio.js +211 -0
- package/dist/components/mg-input-select.d.ts +11 -0
- package/dist/components/mg-input-select.js +6 -0
- package/dist/components/mg-input-select2.js +243 -0
- package/dist/components/mg-input-text.d.ts +11 -0
- package/dist/components/mg-input-text.js +242 -0
- package/dist/components/mg-input-textarea.d.ts +11 -0
- package/dist/components/mg-input-textarea.js +224 -0
- package/dist/components/mg-input-title.d.ts +11 -0
- package/dist/components/mg-input-title.js +6 -0
- package/dist/components/mg-input-title2.js +55 -0
- package/dist/components/mg-input-toggle.d.ts +11 -0
- package/dist/components/mg-input-toggle.js +247 -0
- package/dist/components/mg-message.d.ts +11 -0
- package/dist/components/mg-message.js +183 -0
- package/dist/components/mg-pagination.d.ts +11 -0
- package/dist/components/mg-pagination.js +175 -0
- package/dist/components/mg-popover.d.ts +11 -0
- package/dist/components/mg-popover.js +183 -0
- package/dist/components/mg-tabs.d.ts +11 -0
- package/dist/components/mg-tabs.js +160 -0
- package/dist/components/mg-tag.d.ts +11 -0
- package/dist/components/mg-tag.js +76 -0
- package/dist/components/mg-tooltip.d.ts +11 -0
- package/dist/components/mg-tooltip.js +6 -0
- package/dist/components/mg-tooltip2.js +150 -0
- package/dist/components/popper.js +1784 -0
- package/dist/esm/css-shim-7c240feb.js +4 -0
- package/dist/esm/index-e3e84606.js +1643 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +31 -0
- package/dist/esm/mg-badge_20.entry.js +4638 -0
- package/dist/esm/mg-components.js +21 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/shadow-css-5d2d01ce.js +388 -0
- package/dist/esm-es5/css-shim-7c240feb.js +1 -0
- package/dist/esm-es5/index-e3e84606.js +1 -0
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +1 -0
- package/dist/esm-es5/mg-badge_20.entry.js +2 -0
- package/dist/esm-es5/mg-components.js +1 -0
- package/dist/esm-es5/shadow-css-5d2d01ce.js +12 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/mg-components/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/mg-components/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/mg-components/fonts/Poppins-Bold.ttf +0 -0
- package/dist/mg-components/index.esm.js +0 -0
- package/dist/mg-components/mg-components.css +1 -0
- package/dist/mg-components/mg-components.esm.js +1 -0
- package/dist/mg-components/mg-components.js +132 -0
- package/dist/mg-components/p-1cd24462.system.js +1 -0
- package/dist/mg-components/p-2e2f6b27.system.entry.js +2 -0
- package/dist/mg-components/p-366a224e.js +1 -0
- package/dist/mg-components/p-422c429b.system.js +1 -0
- package/dist/mg-components/p-50ea2036.system.js +1 -0
- package/dist/mg-components/p-62fa3797.js +1 -0
- package/dist/mg-components/p-71d57b8b.system.js +13 -0
- package/dist/mg-components/p-9a215712.system.js +1 -0
- package/dist/mg-components/p-cbf0464b.entry.js +1 -0
- package/dist/mg-components/p-f6455ab3.js +12 -0
- package/dist/mg-components/variables.css +177 -0
- package/dist/mg-components/variables.scss +177 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +36 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +19 -0
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +4 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +67 -0
- package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +16 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +39 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +7 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +12 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +36 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.stories.d.ts +26 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +24 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +4 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +25 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +14 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +56 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +11 -0
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +10 -0
- package/dist/types/components/molecules/inputs/MgInput.d.ts +35 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +120 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +128 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +7 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +10 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +173 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +21 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +111 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +121 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +15 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +18 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +133 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +14 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +160 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +26 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +150 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +8 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +117 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +7 -0
- package/dist/types/components/molecules/mg-message/mg-message.conf.d.ts +4 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +76 -0
- package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +16 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.conf.d.ts +4 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +53 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +6 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +62 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +12 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +10 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +63 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +7 -0
- package/dist/types/components.d.ts +1987 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/locales/index.d.ts +44 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/stories/buttons.stories.d.ts +13 -0
- package/dist/types/stories/grids.stories.d.ts +5 -0
- package/dist/types/stories/icons.stories.d.ts +13 -0
- package/dist/types/stories/messages.stories.d.ts +13 -0
- package/dist/types/stories/tags.stories.d.ts +5 -0
- package/dist/types/stories/typography.stories.d.ts +5 -0
- package/dist/types/utils/components.utils.d.ts +43 -0
- package/dist/types/utils/locale.utils.d.ts +22 -0
- package/dist/types/utils/test.utils.d.ts +5 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +86 -0
- package/readme.md +159 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { M as MgInput } from './MgInput.js';
|
|
3
|
+
import { c as createID, C as ClassList, a as allItemsAreString } from './components.utils.js';
|
|
4
|
+
import { d as defineCustomElement$5 } from './mg-character-left2.js';
|
|
5
|
+
import { d as defineCustomElement$4 } from './mg-icon2.js';
|
|
6
|
+
import { d as defineCustomElement$3 } from './mg-input-title2.js';
|
|
7
|
+
import { d as defineCustomElement$2 } from './mg-tooltip2.js';
|
|
8
|
+
|
|
9
|
+
const mgInputToggleCss = ":host{display:block}.mg-input{display:-ms-flexbox;display:flex;-ms-flex-align:start;align-items:flex-start;min-height:var(--default-size);max-width:100%;}.mg-input.is-not-valid{color:hsl(var(--color-danger))}.mg-input.is-not-valid .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input mg-input-title{-ms-flex-negative:var(--mg-inputs-shrink, 1);flex-shrink:var(--mg-inputs-shrink, 1);width:var(--mg-inputs-title-width, auto);margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);margin-right:var(--mg-inputs-title-horizontal-space, var(--mg-inputs-spacer));text-align:right}.mg-input.mg-input--label-on-top{-ms-flex-direction:column;flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:-ms-flexbox;display:flex;-ms-flex-align:baseline;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{-ms-flex-negative:1;flex-shrink:1;width:auto;margin-top:0;margin-right:var(--mg-inputs-spacer);text-align:left}.mg-input__title mg-tooltip{margin-top:0}.mg-input__title mg-icon{display:-ms-inline-flexbox;display:inline-flex;vertical-align:text-bottom}.mg-input__input-container{min-height:var(--default-size);}.mg-input__input-container>strong{display:inline-block;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2);min-height:var(--font-size)}.mg-input__input-container mg-tooltip{display:-ms-inline-flexbox;display:inline-flex;width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size);margin-left:var(--mg-inputs-spacer)}.mg-input__input-container mg-icon{display:-ms-flexbox;display:flex}.mg-input__input{display:-ms-flexbox;display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input+*{text-align:start;margin-top:0.5rem}.sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-input.mg-input.mg-input--toggle .mg-input__input-container{-ms-flex:auto;flex:auto;min-width:0}.mg-input__button-toggle{display:-ms-flexbox;display:flex;padding:0.2rem;min-width:0;background-color:hsl(var(--color-light));border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:calc((var(--font-size) * var(--line-height) + 2 * (0.7rem + var(--mg-inputs-border-width))) / var(--mg-input-toggle-border-radius-ratio));font-size:inherit;line-height:inherit;cursor:pointer}.mg-input__toggle-item-container{padding:0.5rem 0.9rem;border:0;-webkit-box-sizing:border-box;box-sizing:border-box;border-radius:calc((var(--font-size) * var(--line-height) + 1rem) / var(--mg-input-toggle-border-radius-ratio));background-color:unset;font-weight:unset;color:hsl(var(--color-dark));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{font-weight:600;color:hsl(var(--color-info));background-color:hsl(var(--color-info-h), calc(var(--color-info-s) - 64%), calc(var(--color-info-l) + 55%))}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container{display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;width:calc(var(--font-size) * var(--line-height) + 1rem);height:calc(var(--font-size) * var(--line-height) + 1rem);padding:0;visibility:hidden}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container:first-of-type{visibility:visible}.mg-input.mg-input--toggle-icon .mg-input__toggle-item-container ::slotted(mg-icon){display:-ms-flexbox;display:flex}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{visibility:hidden}.mg-input.mg-input--toggle-icon.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{visibility:visible}.mg-input.mg-input--toggle-on-off .mg-input__toggle-item-container:first-of-type{font-weight:600;color:hsl(var(--color-dark));background-color:hsl(var(--color-dark-h), calc(var(--color-dark-s) - 30%), calc(var(--color-dark-l) + 75%))}.mg-input.mg-input--toggle-on-off.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{background-color:unset;font-weight:unset;color:hsl(var(--color-dark))}.mg-input.mg-input--toggle-readonly .mg-input__button-toggle{border-color:transparent;background-color:transparent;cursor:initial}.mg-input.mg-input--toggle-readonly .mg-input__toggle-item-container:last-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:first-of-type{display:none}.mg-input.mg-input--toggle-readonly.mg-input--toggle-is-active .mg-input__toggle-item-container:last-of-type{display:-ms-flexbox;display:flex}.mg-input.mg-input--toggle-disabled .mg-input__button-toggle{opacity:0.3;cursor:not-allowed}";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* type Option validation function
|
|
13
|
+
* @param option
|
|
14
|
+
* @returns {boolean}
|
|
15
|
+
*/
|
|
16
|
+
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
17
|
+
const MgInputToggle$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.__registerHost();
|
|
21
|
+
this.__attachShadow();
|
|
22
|
+
this.valueChange = createEvent(this, "value-change", 7);
|
|
23
|
+
/************
|
|
24
|
+
* Internal *
|
|
25
|
+
************/
|
|
26
|
+
// classes
|
|
27
|
+
this.classReadonly = 'mg-input--toggle-readonly';
|
|
28
|
+
this.classDisabled = 'mg-input--toggle-disabled';
|
|
29
|
+
this.classIsActive = 'mg-input--toggle-is-active';
|
|
30
|
+
/**
|
|
31
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
32
|
+
* If not set, it will be created.
|
|
33
|
+
*/
|
|
34
|
+
this.identifier = createID('mg-input-toggle');
|
|
35
|
+
/**
|
|
36
|
+
* Input name
|
|
37
|
+
* If not set the value equals the identifier
|
|
38
|
+
*/
|
|
39
|
+
this.name = this.identifier;
|
|
40
|
+
/**
|
|
41
|
+
* Define if label is visible
|
|
42
|
+
*/
|
|
43
|
+
this.labelHide = false;
|
|
44
|
+
/**
|
|
45
|
+
* Define if toggle have on/off style
|
|
46
|
+
*/
|
|
47
|
+
this.isOnOff = false;
|
|
48
|
+
/**
|
|
49
|
+
* Define if toggle display icon
|
|
50
|
+
*/
|
|
51
|
+
this.isIcon = false;
|
|
52
|
+
/**
|
|
53
|
+
* Define if input is readonly
|
|
54
|
+
*/
|
|
55
|
+
this.readonly = false;
|
|
56
|
+
/**
|
|
57
|
+
* Define if input is disabled
|
|
58
|
+
*/
|
|
59
|
+
this.disabled = false;
|
|
60
|
+
/**
|
|
61
|
+
* Component classes
|
|
62
|
+
*/
|
|
63
|
+
this.classList = new ClassList(['mg-input--toggle']);
|
|
64
|
+
/**
|
|
65
|
+
* Checked internal value
|
|
66
|
+
*/
|
|
67
|
+
this.checked = false;
|
|
68
|
+
/**
|
|
69
|
+
* Change checked value
|
|
70
|
+
*/
|
|
71
|
+
this.toggleChecked = () => {
|
|
72
|
+
this.setChecked(!this.checked);
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Slots validation
|
|
76
|
+
*/
|
|
77
|
+
this.validateSlots = () => {
|
|
78
|
+
const slots = Array.from(this.element.children);
|
|
79
|
+
if (slots.length !== 2) {
|
|
80
|
+
throw new Error('<mg-input-toggle> 2 slots are required.');
|
|
81
|
+
}
|
|
82
|
+
else if (!this.isIcon) {
|
|
83
|
+
// Due to text-overflow set to ellipsis
|
|
84
|
+
// we need to ensure that slot element have title to display value on mouse over
|
|
85
|
+
slots.forEach(slot => slot.setAttribute('title', slot.textContent));
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
validateItems(newValue) {
|
|
90
|
+
if (typeof newValue === 'object' && this.items.length !== 2) {
|
|
91
|
+
throw new Error('<mg-input-toggle> prop "items" require 2 items.');
|
|
92
|
+
}
|
|
93
|
+
// String array
|
|
94
|
+
else if (allItemsAreString(newValue)) {
|
|
95
|
+
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
96
|
+
}
|
|
97
|
+
// Object array
|
|
98
|
+
else if (newValue && newValue.every(item => isOption(item))) {
|
|
99
|
+
this.options = newValue;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
throw new Error('<mg-input-toggle> prop "items" is required and all items must be the same type: ToggleValue.');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
handleIsOnOff(newValue) {
|
|
106
|
+
if (newValue)
|
|
107
|
+
this.classList.add(`mg-input--toggle-on-off`);
|
|
108
|
+
}
|
|
109
|
+
handleIsIcon(newValue) {
|
|
110
|
+
if (newValue)
|
|
111
|
+
this.classList.add(`mg-input--toggle-icon`);
|
|
112
|
+
}
|
|
113
|
+
handleReadonly(newValue) {
|
|
114
|
+
if (newValue)
|
|
115
|
+
this.classList.add(this.classReadonly);
|
|
116
|
+
else
|
|
117
|
+
this.classList.delete(this.classReadonly);
|
|
118
|
+
}
|
|
119
|
+
handleDisabled(newValue) {
|
|
120
|
+
if (newValue)
|
|
121
|
+
this.classList.add(this.classDisabled);
|
|
122
|
+
else
|
|
123
|
+
this.classList.delete(this.classDisabled);
|
|
124
|
+
}
|
|
125
|
+
handleChecked(newValue) {
|
|
126
|
+
// style
|
|
127
|
+
if (newValue)
|
|
128
|
+
this.classList.add(this.classIsActive);
|
|
129
|
+
else
|
|
130
|
+
this.classList.delete(this.classIsActive);
|
|
131
|
+
// update value
|
|
132
|
+
this.value = this.options[this.checked ? 1 : 0].value;
|
|
133
|
+
this.valueChange.emit(this.value);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* set checked state
|
|
137
|
+
* @param newValue?
|
|
138
|
+
*/
|
|
139
|
+
setChecked(newValue) {
|
|
140
|
+
// has "value" props type is not a boolean, it is bind/render as an attributes/props
|
|
141
|
+
// true props will be represent by "true" string so we convert it has boolean
|
|
142
|
+
// true attribute will be represent by "" string so we convert it has boolean
|
|
143
|
+
// https://stenciljs.com/docs/properties
|
|
144
|
+
if (['', 'true'].includes(this.value) && this.options.find(option => option.value) !== undefined) {
|
|
145
|
+
this.value = true;
|
|
146
|
+
}
|
|
147
|
+
if (newValue !== undefined) {
|
|
148
|
+
this.checked = newValue;
|
|
149
|
+
}
|
|
150
|
+
else if (this.value === this.options[1].value) {
|
|
151
|
+
this.checked = true;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
this.checked = false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/*************
|
|
158
|
+
* Lifecycle *
|
|
159
|
+
*************/
|
|
160
|
+
/**
|
|
161
|
+
* Check if component props are well configured on init
|
|
162
|
+
*/
|
|
163
|
+
componentWillLoad() {
|
|
164
|
+
// Check items format
|
|
165
|
+
this.validateItems(this.items);
|
|
166
|
+
// init checked value
|
|
167
|
+
this.setChecked();
|
|
168
|
+
// apply handler
|
|
169
|
+
this.handleIsOnOff(this.isOnOff);
|
|
170
|
+
this.handleIsIcon(this.isIcon);
|
|
171
|
+
this.handleReadonly(this.readonly);
|
|
172
|
+
this.handleDisabled(this.disabled);
|
|
173
|
+
this.validateSlots();
|
|
174
|
+
}
|
|
175
|
+
render() {
|
|
176
|
+
var _a;
|
|
177
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, width: undefined, disabled: this.disabled, value: (_a = this.value) === null || _a === void 0 ? void 0 : _a.toString(), readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, displayCharacterLeft: undefined, characterLeftTemplate: undefined, maxlength: undefined, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, h("button", { type: "button", role: "switch", "aria-checked": this.checked, "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly,
|
|
178
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
179
|
+
onClick: () => this.toggleChecked() }, h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-1" })), h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, h("slot", { name: "item-2" })))));
|
|
180
|
+
}
|
|
181
|
+
get element() { return this; }
|
|
182
|
+
static get watchers() { return {
|
|
183
|
+
"items": ["validateItems"],
|
|
184
|
+
"isOnOff": ["handleIsOnOff"],
|
|
185
|
+
"isIcon": ["handleIsIcon"],
|
|
186
|
+
"readonly": ["handleReadonly"],
|
|
187
|
+
"disabled": ["handleDisabled"],
|
|
188
|
+
"checked": ["handleChecked"]
|
|
189
|
+
}; }
|
|
190
|
+
static get style() { return mgInputToggleCss; }
|
|
191
|
+
}, [1, "mg-input-toggle", {
|
|
192
|
+
"value": [1032],
|
|
193
|
+
"items": [16],
|
|
194
|
+
"identifier": [1],
|
|
195
|
+
"name": [1],
|
|
196
|
+
"label": [1],
|
|
197
|
+
"labelOnTop": [4, "label-on-top"],
|
|
198
|
+
"labelHide": [4, "label-hide"],
|
|
199
|
+
"isOnOff": [4, "is-on-off"],
|
|
200
|
+
"isIcon": [4, "is-icon"],
|
|
201
|
+
"readonly": [4],
|
|
202
|
+
"disabled": [4],
|
|
203
|
+
"tooltip": [1],
|
|
204
|
+
"helpText": [1, "help-text"],
|
|
205
|
+
"classList": [32],
|
|
206
|
+
"options": [32],
|
|
207
|
+
"checked": [32]
|
|
208
|
+
}]);
|
|
209
|
+
function defineCustomElement$1() {
|
|
210
|
+
if (typeof customElements === "undefined") {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const components = ["mg-input-toggle", "mg-character-left", "mg-icon", "mg-input-title", "mg-tooltip"];
|
|
214
|
+
components.forEach(tagName => { switch (tagName) {
|
|
215
|
+
case "mg-input-toggle":
|
|
216
|
+
if (!customElements.get(tagName)) {
|
|
217
|
+
customElements.define(tagName, MgInputToggle$1);
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
case "mg-character-left":
|
|
221
|
+
if (!customElements.get(tagName)) {
|
|
222
|
+
defineCustomElement$5();
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
case "mg-icon":
|
|
226
|
+
if (!customElements.get(tagName)) {
|
|
227
|
+
defineCustomElement$4();
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
case "mg-input-title":
|
|
231
|
+
if (!customElements.get(tagName)) {
|
|
232
|
+
defineCustomElement$3();
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
case "mg-tooltip":
|
|
236
|
+
if (!customElements.get(tagName)) {
|
|
237
|
+
defineCustomElement$2();
|
|
238
|
+
}
|
|
239
|
+
break;
|
|
240
|
+
} });
|
|
241
|
+
}
|
|
242
|
+
defineCustomElement$1();
|
|
243
|
+
|
|
244
|
+
const MgInputToggle = MgInputToggle$1;
|
|
245
|
+
const defineCustomElement = defineCustomElement$1;
|
|
246
|
+
|
|
247
|
+
export { MgInputToggle, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface MgMessage extends Components.MgMessage, HTMLElement {}
|
|
4
|
+
export const MgMessage: {
|
|
5
|
+
prototype: MgMessage;
|
|
6
|
+
new (): MgMessage;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { c as createID, C as ClassList } from './components.utils.js';
|
|
3
|
+
import { m as messages } from './index2.js';
|
|
4
|
+
import { d as defineCustomElement$3 } from './mg-button2.js';
|
|
5
|
+
import { d as defineCustomElement$2 } from './mg-icon2.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* List of all possibles message variants
|
|
9
|
+
*/
|
|
10
|
+
const variants = ['info', 'warning', 'success', 'danger'];
|
|
11
|
+
|
|
12
|
+
const mgMessageCss = ".mg-message{display:inline-block;position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;min-height:var(--default-size);overflow:hidden;background-color:white;border-radius:var(--mg-message-border-radius);-webkit-box-shadow:0 0.3rem 0.8rem 0 hsla(var(--color-dark), 0.1);box-shadow:0 0.3rem 0.8rem 0 hsla(var(--color-dark), 0.1)}.mg-message::before{content:\"\";position:absolute;top:0;left:0;width:0.3rem;height:100%}.mg-message.mg-message--info::before{background-color:hsl(var(--color-info))}.mg-message.mg-message--info .mg-message__icon{color:hsl(var(--color-info))}.mg-message.mg-message--warning::before{background-color:hsl(var(--color-warning))}.mg-message.mg-message--warning .mg-message__icon{color:hsl(var(--color-warning))}.mg-message.mg-message--success::before{background-color:hsl(var(--color-success))}.mg-message.mg-message--success .mg-message__icon{color:hsl(var(--color-success))}.mg-message.mg-message--danger::before{background-color:hsl(var(--color-danger))}.mg-message.mg-message--danger .mg-message__icon{color:hsl(var(--color-danger))}.mg-message.mg-message--close-button{padding-right:3.4rem}.mg-message.mg-message--hide{display:none}.mg-message ::slotted(*){margin:0;padding:0}.mg-message__icon{position:absolute;top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2);left:1.3rem;line-height:1}.mg-message__content{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:end;justify-content:flex-end;-ms-flex-line-pack:stretch;align-content:stretch;padding:0 1rem 0 3.8rem}.mg-message__content-slot{-ms-flex-positive:1;flex-grow:1;margin:0.84rem 0}.mg-message__content-separator{display:inline-block;width:4.5rem;height:0}.mg-message__content-actions-slot{padding:1rem 0;text-align:right}.mg-message__close-button{position:absolute;top:0;right:0}.mg-message,mg-message{max-width:100%}";
|
|
13
|
+
|
|
14
|
+
const MgMessage$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
this.__registerHost();
|
|
18
|
+
this.__attachShadow();
|
|
19
|
+
this.componentShow = createEvent(this, "component-show", 7);
|
|
20
|
+
this.componentHide = createEvent(this, "component-hide", 7);
|
|
21
|
+
/************
|
|
22
|
+
* Internal *
|
|
23
|
+
************/
|
|
24
|
+
this.closeButtonId = '';
|
|
25
|
+
// Stored timer setted when hide action is run from setTimeOut
|
|
26
|
+
this.storedTimer = null;
|
|
27
|
+
/**
|
|
28
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
29
|
+
* If not set, it will be created.
|
|
30
|
+
*/
|
|
31
|
+
this.identifier = createID('mg-message');
|
|
32
|
+
/**
|
|
33
|
+
* Message variant
|
|
34
|
+
*/
|
|
35
|
+
this.variant = variants[0];
|
|
36
|
+
/**
|
|
37
|
+
* Define if message has a cross button
|
|
38
|
+
* RG 01: https://jira.mgdis.fr/browse/PDA9-140
|
|
39
|
+
*/
|
|
40
|
+
this.closeButton = false;
|
|
41
|
+
/**
|
|
42
|
+
* Define if message is hidden
|
|
43
|
+
*/
|
|
44
|
+
this.hide = false;
|
|
45
|
+
/**
|
|
46
|
+
* Component classes
|
|
47
|
+
*/
|
|
48
|
+
this.classList = new ClassList(['mg-message']);
|
|
49
|
+
/**
|
|
50
|
+
* Define if component is using actions slot
|
|
51
|
+
*/
|
|
52
|
+
this.hasActions = false;
|
|
53
|
+
/**
|
|
54
|
+
* Handle close button
|
|
55
|
+
*/
|
|
56
|
+
this.handleClose = () => {
|
|
57
|
+
this.hide = true;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Hide component whith delay
|
|
61
|
+
*/
|
|
62
|
+
this.hideWithDelay = () => {
|
|
63
|
+
if (this.delay > 0 && this.hide !== true) {
|
|
64
|
+
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
65
|
+
}
|
|
66
|
+
else if (this.storedTimer !== null) {
|
|
67
|
+
clearTimeout(this.storedTimer);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Get icon corresponding to variant
|
|
72
|
+
*/
|
|
73
|
+
this.getIcon = () => {
|
|
74
|
+
switch (this.variant) {
|
|
75
|
+
case 'info':
|
|
76
|
+
return 'info-circle';
|
|
77
|
+
case 'warning':
|
|
78
|
+
return 'exclamation-triangle';
|
|
79
|
+
case 'success':
|
|
80
|
+
return 'check-circle';
|
|
81
|
+
case 'danger':
|
|
82
|
+
return 'exclamation-circle';
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
validateDelay(newValue) {
|
|
87
|
+
if (newValue && newValue < 2) {
|
|
88
|
+
throw new Error(`<mg-message> prop "delay" must be greater than 2 seconds.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
validateVariant(newValue, oldValue) {
|
|
92
|
+
if (!variants.includes(newValue)) {
|
|
93
|
+
throw new Error(`<mg-message> prop "variant" must be one of : ${variants.join(', ')}`);
|
|
94
|
+
}
|
|
95
|
+
if (oldValue !== undefined) {
|
|
96
|
+
this.classList.delete(`mg-message--${oldValue}`);
|
|
97
|
+
}
|
|
98
|
+
this.classList.add(`mg-message--${this.variant}`);
|
|
99
|
+
}
|
|
100
|
+
validateCloseButton(newValue) {
|
|
101
|
+
if (newValue && this.hasActions) {
|
|
102
|
+
this.closeButton = false;
|
|
103
|
+
throw new Error('<mg-message> prop "close-button" can\'t be used with the actions slot.');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
validateHide(newValue) {
|
|
107
|
+
if (newValue) {
|
|
108
|
+
this.componentHide.emit();
|
|
109
|
+
this.classList.add('mg-message--hide');
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.componentShow.emit();
|
|
113
|
+
this.classList.delete('mg-message--hide');
|
|
114
|
+
}
|
|
115
|
+
this.hideWithDelay();
|
|
116
|
+
}
|
|
117
|
+
/*************
|
|
118
|
+
* Lifecycle *
|
|
119
|
+
*************/
|
|
120
|
+
/**
|
|
121
|
+
* Check if component props are well configured on init
|
|
122
|
+
*/
|
|
123
|
+
componentWillLoad() {
|
|
124
|
+
this.validateVariant(this.variant);
|
|
125
|
+
// Check if close button is an can be activated
|
|
126
|
+
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
127
|
+
this.validateCloseButton(this.closeButton);
|
|
128
|
+
if (this.closeButton) {
|
|
129
|
+
this.classList.add('mg-message--close-button');
|
|
130
|
+
this.closeButtonId = `${this.identifier}-close-button`;
|
|
131
|
+
}
|
|
132
|
+
this.validateDelay(this.delay);
|
|
133
|
+
this.validateHide(this.hide);
|
|
134
|
+
}
|
|
135
|
+
render() {
|
|
136
|
+
return (h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, h("span", { class: "mg-message__icon" }, h("mg-icon", { icon: this.getIcon() })), h("div", { class: "mg-message__content" }, h("span", { class: "mg-message__content-slot" }, h("slot", null)), this.hasActions && h("span", { class: "mg-message__content-separator" }), this.hasActions && (h("span", { class: "mg-message__content-actions-slot" }, h("slot", { name: "actions" })))), this.closeButton && (h("span", { class: "mg-message__close-button" }, h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: messages.message.closeButton, onClick: this.handleClose }, h("mg-icon", { icon: "cross" }))))));
|
|
137
|
+
}
|
|
138
|
+
get element() { return this; }
|
|
139
|
+
static get watchers() { return {
|
|
140
|
+
"delay": ["validateDelay"],
|
|
141
|
+
"variant": ["validateVariant"],
|
|
142
|
+
"closeButton": ["validateCloseButton"],
|
|
143
|
+
"hide": ["validateHide"]
|
|
144
|
+
}; }
|
|
145
|
+
static get style() { return mgMessageCss; }
|
|
146
|
+
}, [1, "mg-message", {
|
|
147
|
+
"identifier": [1],
|
|
148
|
+
"delay": [2],
|
|
149
|
+
"variant": [1],
|
|
150
|
+
"closeButton": [4, "close-button"],
|
|
151
|
+
"hide": [1028],
|
|
152
|
+
"classList": [32],
|
|
153
|
+
"hasActions": [32]
|
|
154
|
+
}]);
|
|
155
|
+
function defineCustomElement$1() {
|
|
156
|
+
if (typeof customElements === "undefined") {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const components = ["mg-message", "mg-button", "mg-icon"];
|
|
160
|
+
components.forEach(tagName => { switch (tagName) {
|
|
161
|
+
case "mg-message":
|
|
162
|
+
if (!customElements.get(tagName)) {
|
|
163
|
+
customElements.define(tagName, MgMessage$1);
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
case "mg-button":
|
|
167
|
+
if (!customElements.get(tagName)) {
|
|
168
|
+
defineCustomElement$3();
|
|
169
|
+
}
|
|
170
|
+
break;
|
|
171
|
+
case "mg-icon":
|
|
172
|
+
if (!customElements.get(tagName)) {
|
|
173
|
+
defineCustomElement$2();
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
} });
|
|
177
|
+
}
|
|
178
|
+
defineCustomElement$1();
|
|
179
|
+
|
|
180
|
+
const MgMessage = MgMessage$1;
|
|
181
|
+
const defineCustomElement = defineCustomElement$1;
|
|
182
|
+
|
|
183
|
+
export { MgMessage, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface MgPagination extends Components.MgPagination, HTMLElement {}
|
|
4
|
+
export const MgPagination: {
|
|
5
|
+
prototype: MgPagination;
|
|
6
|
+
new (): MgPagination;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { c as createID } from './components.utils.js';
|
|
3
|
+
import { m as messages } from './index2.js';
|
|
4
|
+
import { d as defineCustomElement$7 } from './mg-button2.js';
|
|
5
|
+
import { d as defineCustomElement$6 } from './mg-character-left2.js';
|
|
6
|
+
import { d as defineCustomElement$5 } from './mg-icon2.js';
|
|
7
|
+
import { d as defineCustomElement$4 } from './mg-input-select2.js';
|
|
8
|
+
import { d as defineCustomElement$3 } from './mg-input-title2.js';
|
|
9
|
+
import { d as defineCustomElement$2 } from './mg-tooltip2.js';
|
|
10
|
+
|
|
11
|
+
var NavigationAction;
|
|
12
|
+
(function (NavigationAction) {
|
|
13
|
+
NavigationAction["NEXT"] = "next";
|
|
14
|
+
NavigationAction["PREVIOUS"] = "previous";
|
|
15
|
+
})(NavigationAction || (NavigationAction = {}));
|
|
16
|
+
|
|
17
|
+
const mgPaginationCss = ".sr-only{border:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}*:focus:not(:focus-visible){outline:none}.mg-pagination__nav{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-direction:row;flex-direction:row}.mg-pagination__nav mg-input-select{margin-right:0.5rem}.mg-pagination__button{display:-ms-flexbox;display:flex}.mg-pagination__button:first-of-type{margin-right:1rem}.mg-pagination__button:last-of-type{margin-left:1rem}";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Range generator
|
|
21
|
+
*
|
|
22
|
+
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
23
|
+
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
24
|
+
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
25
|
+
* then with Array.from(Array(...)) we get the complete array with "index" values instead of "empty" values
|
|
26
|
+
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
27
|
+
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
28
|
+
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
29
|
+
*
|
|
30
|
+
* range(1, 1) = [1]
|
|
31
|
+
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
32
|
+
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
33
|
+
*
|
|
34
|
+
* @param start
|
|
35
|
+
* @param end
|
|
36
|
+
* @param step
|
|
37
|
+
* @returns {number[]}
|
|
38
|
+
*/
|
|
39
|
+
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
40
|
+
const MgPagination$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
41
|
+
constructor() {
|
|
42
|
+
super();
|
|
43
|
+
this.__registerHost();
|
|
44
|
+
this.__attachShadow();
|
|
45
|
+
this.currentPageChange = createEvent(this, "current-page-change", 7);
|
|
46
|
+
/**************
|
|
47
|
+
* Decorators *
|
|
48
|
+
**************/
|
|
49
|
+
/**
|
|
50
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
51
|
+
* If not set, it will be created.
|
|
52
|
+
*/
|
|
53
|
+
this.identifier = createID('mg-pagination');
|
|
54
|
+
/**
|
|
55
|
+
* Panignation label. Is a short description.
|
|
56
|
+
* Customize default value can be usefull to improve accessibility
|
|
57
|
+
*/
|
|
58
|
+
this.label = 'pagination';
|
|
59
|
+
/**
|
|
60
|
+
* Component total pages
|
|
61
|
+
*/
|
|
62
|
+
this.totalPages = 1;
|
|
63
|
+
/**
|
|
64
|
+
* Component current page
|
|
65
|
+
*/
|
|
66
|
+
this.currentPage = 1;
|
|
67
|
+
/**
|
|
68
|
+
* Change current page from target
|
|
69
|
+
* @param target
|
|
70
|
+
*/
|
|
71
|
+
this.goToPage = (target) => (this.currentPage = target);
|
|
72
|
+
/************
|
|
73
|
+
* Handlers *
|
|
74
|
+
************/
|
|
75
|
+
/**
|
|
76
|
+
* Default click handler
|
|
77
|
+
* @param event
|
|
78
|
+
*/
|
|
79
|
+
this.handleSelect = (event) => {
|
|
80
|
+
const to = Number(event.target.value);
|
|
81
|
+
this.goToPage(to > 0 ? to : 1);
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Go to 'previous/next' page button handler
|
|
85
|
+
* @returns {void}
|
|
86
|
+
*/
|
|
87
|
+
this.handleGoToPage = (action) => this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
88
|
+
}
|
|
89
|
+
validateTotalPages(newValue) {
|
|
90
|
+
if (newValue < 1) {
|
|
91
|
+
throw new Error('<mg-pagination> prop "totalPages" must be greater than 0');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
validateCurrentPage(newValue) {
|
|
95
|
+
if (newValue < 1) {
|
|
96
|
+
throw new Error('<mg-pagination> prop "currentPage" must be greater than 0');
|
|
97
|
+
}
|
|
98
|
+
else if (newValue > this.totalPages) {
|
|
99
|
+
throw new Error('<mg-pagination> prop "currentPage" can not be greater than total page');
|
|
100
|
+
}
|
|
101
|
+
this.currentPageChange.emit(newValue);
|
|
102
|
+
}
|
|
103
|
+
/*************
|
|
104
|
+
* Lifecycle *
|
|
105
|
+
*************/
|
|
106
|
+
componentWillLoad() {
|
|
107
|
+
this.validateTotalPages(this.totalPages);
|
|
108
|
+
this.validateCurrentPage(this.currentPage);
|
|
109
|
+
}
|
|
110
|
+
render() {
|
|
111
|
+
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: messages.pagination[`${action}Page`],
|
|
112
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
113
|
+
onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" }, action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }), messages.pagination[action], action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
|
|
114
|
+
return (h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination__nav" }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), h("span", { class: "sr-only" }, messages.pagination.page, " ", this.currentPage), h("span", null, "/ ", this.totalPages, " ", this.totalPages > 1 ? messages.pagination.pages : messages.pagination.pages), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
|
|
115
|
+
}
|
|
116
|
+
static get watchers() { return {
|
|
117
|
+
"totalPages": ["validateTotalPages"],
|
|
118
|
+
"currentPage": ["validateCurrentPage"]
|
|
119
|
+
}; }
|
|
120
|
+
static get style() { return mgPaginationCss; }
|
|
121
|
+
}, [1, "mg-pagination", {
|
|
122
|
+
"identifier": [1],
|
|
123
|
+
"label": [1],
|
|
124
|
+
"totalPages": [2, "total-pages"],
|
|
125
|
+
"currentPage": [1538, "current-page"]
|
|
126
|
+
}]);
|
|
127
|
+
function defineCustomElement$1() {
|
|
128
|
+
if (typeof customElements === "undefined") {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const components = ["mg-pagination", "mg-button", "mg-character-left", "mg-icon", "mg-input-select", "mg-input-title", "mg-tooltip"];
|
|
132
|
+
components.forEach(tagName => { switch (tagName) {
|
|
133
|
+
case "mg-pagination":
|
|
134
|
+
if (!customElements.get(tagName)) {
|
|
135
|
+
customElements.define(tagName, MgPagination$1);
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
case "mg-button":
|
|
139
|
+
if (!customElements.get(tagName)) {
|
|
140
|
+
defineCustomElement$7();
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
case "mg-character-left":
|
|
144
|
+
if (!customElements.get(tagName)) {
|
|
145
|
+
defineCustomElement$6();
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
case "mg-icon":
|
|
149
|
+
if (!customElements.get(tagName)) {
|
|
150
|
+
defineCustomElement$5();
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
case "mg-input-select":
|
|
154
|
+
if (!customElements.get(tagName)) {
|
|
155
|
+
defineCustomElement$4();
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case "mg-input-title":
|
|
159
|
+
if (!customElements.get(tagName)) {
|
|
160
|
+
defineCustomElement$3();
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case "mg-tooltip":
|
|
164
|
+
if (!customElements.get(tagName)) {
|
|
165
|
+
defineCustomElement$2();
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
} });
|
|
169
|
+
}
|
|
170
|
+
defineCustomElement$1();
|
|
171
|
+
|
|
172
|
+
const MgPagination = MgPagination$1;
|
|
173
|
+
const defineCustomElement = defineCustomElement$1;
|
|
174
|
+
|
|
175
|
+
export { MgPagination, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface MgPopover extends Components.MgPopover, HTMLElement {}
|
|
4
|
+
export const MgPopover: {
|
|
5
|
+
prototype: MgPopover;
|
|
6
|
+
new (): MgPopover;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|