@mgdis/mg-components 5.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{mg-badge_24.cjs.entry.js → mg-badge_27.cjs.entry.js} +892 -295
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +1 -1
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +8 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +41 -3
- package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +18 -0
- package/dist/collection/components/atoms/mg-card/mg-card.css +7 -0
- package/dist/collection/components/atoms/mg-card/mg-card.js +26 -0
- package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +18 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.css +9 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +57 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +1 -1
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -5
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +0 -20
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +2 -1
- package/dist/collection/components/molecules/inputs/MgInput.js +3 -11
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +41 -20
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +50 -39
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +42 -33
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +36 -17
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +35 -14
- package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +2 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +28 -6
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +36 -17
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +38 -19
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +25 -6
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +37 -18
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +1 -1
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +1 -0
- package/dist/collection/components/molecules/mg-details/mg-details.css +29 -0
- package/dist/collection/components/molecules/mg-details/mg-details.js +26 -4
- package/dist/collection/components/molecules/mg-form/mg-form.js +73 -27
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +6 -6
- package/dist/collection/components/molecules/mg-message/mg-message.js +1 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +2 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +48 -4
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +5 -14
- package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -5
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +3 -2
- package/dist/collection/utils/components.utils.js +10 -6
- package/dist/collection/utils/unit.test.utils.js +51 -0
- package/dist/collection/variables.css +23 -8
- package/dist/components/MgInput.js +4 -12
- package/dist/components/components.utils.js +11 -7
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/mg-badge2.js +1 -1
- package/dist/components/mg-button2.js +23 -4
- package/dist/components/mg-card.d.ts +11 -0
- package/dist/components/mg-card.js +42 -0
- package/dist/components/mg-details.js +8 -3
- package/dist/components/mg-divider.d.ts +11 -0
- package/dist/components/mg-divider.js +51 -0
- package/dist/components/mg-form.js +67 -26
- package/dist/components/mg-input-checkbox.js +36 -21
- package/dist/components/mg-input-date.js +44 -39
- package/dist/components/mg-input-numeric.js +37 -34
- package/dist/components/mg-input-password.js +32 -19
- package/dist/components/mg-input-radio.js +30 -15
- package/dist/components/mg-input-select2.js +32 -19
- package/dist/components/mg-input-text2.js +34 -21
- package/dist/components/mg-input-textarea.js +32 -19
- package/dist/components/mg-input-toggle.js +1 -1
- package/dist/components/mg-message.js +1 -1
- package/dist/components/mg-modal.js +49 -5
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-popover.js +3 -2
- package/dist/components/mg-tag.js +1 -1
- package/dist/components/mg-tooltip2.js +2 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mg-badge_24.entry.js → mg-badge_27.entry.js} +839 -245
- package/dist/esm/mg-components.js +1 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-b2b07c3f.entry.js +1 -0
- package/dist/mg-components/variables.css +23 -8
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +8 -2
- package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +11 -0
- package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +15 -0
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +0 -8
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +10 -8
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +3 -8
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +3 -8
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +4 -2
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +4 -3
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +5 -4
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +4 -3
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +21 -1
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +3 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +11 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +1 -1
- package/dist/types/components.d.ts +55 -6
- package/dist/types/utils/components.utils.d.ts +7 -3
- package/package.json +9 -9
- package/dist/cjs/index-179621c8.js +0 -244
- package/dist/cjs/mg-modal.cjs.entry.js +0 -128
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +0 -20
- package/dist/collection/utils/test.utils.js +0 -38
- package/dist/esm/index-7efedd97.js +0 -238
- package/dist/esm/mg-modal.entry.js +0 -124
- package/dist/mg-components/p-5f89600c.js +0 -1
- package/dist/mg-components/p-b60a4c53.entry.js +0 -1
- package/dist/mg-components/p-df947fa5.entry.js +0 -1
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +0 -8
- package/dist/types/utils/test.utils.d.ts +0 -17
|
@@ -7,7 +7,7 @@ import { d as defineCustomElement$1 } from './mg-icon2.js';
|
|
|
7
7
|
*/
|
|
8
8
|
const variants = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success'];
|
|
9
9
|
|
|
10
|
-
const mgButtonCss = ":host{display:inline-block;vertical-align:middle;max-width:100%}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-button:not(.mg-button--disabled){outline-color:-webkit-focus-ring-color;outline-style:auto;outline-width:0.2rem}:host(:hover) .mg-button--flat:not(.mg-button--disabled),:host(:focus) .mg-button--flat:not(.mg-button--disabled),:host(:active) .mg-button--flat:not(.mg-button--disabled){background:hsla(var(--color-dark), 0.1)}.mg-button.mg-button--primary{border-color:hsl(var(--mg-button-primary-border-color, var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-primary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--primary:not(.mg-button--disabled),:host(:focus) .mg-button--primary:not(.mg-button--disabled),:host(:active) .mg-button--primary:not(.mg-button--disabled){background:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l))}.mg-button.mg-button--secondary{border-color:hsl(var(--mg-button-secondary-border-color, var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-secondary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--secondary:not(.mg-button--disabled),:host(:focus) .mg-button--secondary:not(.mg-button--disabled),:host(:active) .mg-button--secondary:not(.mg-button--disabled){background:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l))}.mg-button.mg-button--danger{border-color:hsl(var(--mg-button-danger-border-color, var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger:not(.mg-button--disabled),:host(:focus) .mg-button--danger:not(.mg-button--disabled),:host(:active) .mg-button--danger:not(.mg-button--disabled){background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-button.mg-button--danger-alt{border-color:hsl(var(--mg-button-danger-alt-border-color, var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-danger));background:linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger-alt:not(.mg-button--disabled),:host(:focus) .mg-button--danger-alt:not(.mg-button--disabled),:host(:active) .mg-button--danger-alt:not(.mg-button--disabled){background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))}.mg-button.mg-button--info{border-color:hsl(var(--mg-button-info-border-color, var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--info:not(.mg-button--disabled),:host(:focus) .mg-button--info:not(.mg-button--disabled),:host(:active) .mg-button--info:not(.mg-button--disabled){background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-button.mg-button--success{border-color:hsl(var(--mg-button-success-border-color, var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-dark));background:linear-gradient(to bottom, hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l)), hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--success:not(.mg-button--disabled),:host(:focus) .mg-button--success:not(.mg-button--disabled),:host(:active) .mg-button--success:not(.mg-button--disabled){background:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))}.mg-button{position:relative;display:inline-flex;align-items:center;column-gap:0.6rem;padding:calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;min-height:var(--default-size);box-sizing:border-box;border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-border-radius));cursor:pointer;background-image:none;border-top-width:var(--mg-button-border-top-width, 0.1rem);border-right-width:var(--mg-button-border-right-width, 0.1rem);border-bottom-width:var(--mg-button-border-bottom-width, 0.1rem);border-left-width:var(--mg-button-border-left-width, 0.1rem);border-style:solid;text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);touch-action:manipulation}.mg-button.mg-button--disabled{opacity:var(--mg-button-disabled-opacity);cursor:default}.mg-button.mg-button--icon{padding:0;justify-content:center;width:var(--default-size);height:var(--default-size);border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-icon-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-icon-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-icon-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-icon-border-radius));font-size:var(--font-size);line-height:var(--font-size)}.mg-button.mg-button--flat{background:none;border:none}.mg-button.mg-button--loading>mg-icon:first-of-type{position:absolute;left:50%;top:50%;transform:translate(-50%, -50%)}.mg-button.mg-button--loading .mg-button__content{opacity:0}.mg-button mg-icon:only-child,.mg-button ::slotted(mg-icon){display:inline-flex;flex-shrink:0;line-height:1;margin:auto 0}.mg-button slot,.mg-button ::slotted(*:not(mg-icon)){text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);display:flex;align-items:center;column-gap:0.6rem}";
|
|
10
|
+
const mgButtonCss = ":host{display:inline-block;vertical-align:middle;max-width:100%}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-button:not(.mg-button--disabled){outline-color:-webkit-focus-ring-color;outline-style:auto;outline-width:0.2rem}:host(:hover) .mg-button--flat:not(.mg-button--disabled),:host(:focus) .mg-button--flat:not(.mg-button--disabled),:host(:active) .mg-button--flat:not(.mg-button--disabled){background:hsla(var(--color-dark), 0.1)}:host([full-width]){display:block}.mg-button.mg-button--primary{border-color:hsl(var(--mg-button-primary-border-color, var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-primary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--primary:not(.mg-button--disabled),:host(:focus) .mg-button--primary:not(.mg-button--disabled),:host(:active) .mg-button--primary:not(.mg-button--disabled){background:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l))}.mg-button.mg-button--secondary{border-color:hsl(var(--mg-button-secondary-border-color, var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-secondary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--secondary:not(.mg-button--disabled),:host(:focus) .mg-button--secondary:not(.mg-button--disabled),:host(:active) .mg-button--secondary:not(.mg-button--disabled){background:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l))}.mg-button.mg-button--danger{border-color:hsl(var(--mg-button-danger-border-color, var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger:not(.mg-button--disabled),:host(:focus) .mg-button--danger:not(.mg-button--disabled),:host(:active) .mg-button--danger:not(.mg-button--disabled){background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-button.mg-button--danger-alt{border-color:hsl(var(--mg-button-danger-alt-border-color, var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-danger));background:linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger-alt:not(.mg-button--disabled),:host(:focus) .mg-button--danger-alt:not(.mg-button--disabled),:host(:active) .mg-button--danger-alt:not(.mg-button--disabled){background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))}.mg-button.mg-button--info{border-color:hsl(var(--mg-button-info-border-color, var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--info:not(.mg-button--disabled),:host(:focus) .mg-button--info:not(.mg-button--disabled),:host(:active) .mg-button--info:not(.mg-button--disabled){background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-button.mg-button--success{border-color:hsl(var(--mg-button-success-border-color, var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-dark));background:linear-gradient(to bottom, hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l)), hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--success:not(.mg-button--disabled),:host(:focus) .mg-button--success:not(.mg-button--disabled),:host(:active) .mg-button--success:not(.mg-button--disabled){background:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))}.mg-button{position:relative;display:inline-flex;align-items:center;column-gap:0.6rem;padding:calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;min-height:var(--default-size);box-sizing:border-box;border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-border-radius));cursor:pointer;background-image:none;border-top-width:var(--mg-button-border-top-width, 0.1rem);border-right-width:var(--mg-button-border-right-width, 0.1rem);border-bottom-width:var(--mg-button-border-bottom-width, 0.1rem);border-left-width:var(--mg-button-border-left-width, 0.1rem);border-style:solid;text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);touch-action:manipulation}.mg-button.mg-button--disabled{opacity:var(--mg-button-disabled-opacity);cursor:default}.mg-button.mg-button--icon{padding:0;justify-content:center;width:var(--default-size);height:var(--default-size);border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-icon-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-icon-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-icon-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-icon-border-radius));font-size:var(--font-size);line-height:var(--font-size)}.mg-button.mg-button--flat{background:none;border:none}.mg-button.mg-button--full-width{display:flex;justify-content:center}.mg-button.mg-button--loading>mg-icon:first-of-type{position:absolute;left:50%;top:50%;transform:translate(-50%, -50%)}.mg-button.mg-button--loading .mg-button__content{opacity:0}.mg-button mg-icon:only-child,.mg-button ::slotted(mg-icon){display:inline-flex;flex-shrink:0;line-height:1;margin:auto 0}.mg-button slot,.mg-button ::slotted(*:not(mg-icon)){text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);display:flex;align-items:center;column-gap:0.6rem}";
|
|
11
11
|
|
|
12
12
|
const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
13
13
|
constructor() {
|
|
@@ -20,10 +20,15 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
20
20
|
this.onClickElementFn = null;
|
|
21
21
|
this.classDisabled = 'mg-button--disabled';
|
|
22
22
|
this.classLoading = 'mg-button--loading';
|
|
23
|
+
this.classFullWidth = 'mg-button--full-width';
|
|
23
24
|
/**
|
|
24
25
|
* Define button variant
|
|
25
26
|
*/
|
|
26
27
|
this.variant = variants[0]; // Primary
|
|
28
|
+
/**
|
|
29
|
+
* Set button to full-width
|
|
30
|
+
*/
|
|
31
|
+
this.fullWidth = false;
|
|
27
32
|
/**
|
|
28
33
|
* Define if button is round.
|
|
29
34
|
* Used for icon button.
|
|
@@ -60,7 +65,7 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
60
65
|
}
|
|
61
66
|
};
|
|
62
67
|
/**
|
|
63
|
-
* Handle
|
|
68
|
+
* Handle onKeydown event
|
|
64
69
|
*
|
|
65
70
|
* @param {KeyboardEvent} event keyboard event
|
|
66
71
|
* @returns {void}
|
|
@@ -75,7 +80,7 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
75
80
|
}
|
|
76
81
|
};
|
|
77
82
|
/**
|
|
78
|
-
* Handle
|
|
83
|
+
* Handle onKeyup event
|
|
79
84
|
*
|
|
80
85
|
* @param {KeyboardEvent} event keyboard event
|
|
81
86
|
* @returns {void}
|
|
@@ -98,6 +103,17 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
98
103
|
this.classList.add(`mg-button--${newValue}`);
|
|
99
104
|
}
|
|
100
105
|
}
|
|
106
|
+
validateFullWidth(newValue) {
|
|
107
|
+
if (newValue && this.isIcon) {
|
|
108
|
+
throw new Error('<mg-button> prop "fullWidth" cannot be used with prop "isIcon".');
|
|
109
|
+
}
|
|
110
|
+
else if (newValue) {
|
|
111
|
+
this.classList.add(this.classFullWidth);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.classList.delete(this.classFullWidth);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
101
117
|
disabledHandler(isDisabled) {
|
|
102
118
|
// Remove loading when enable
|
|
103
119
|
// Will be set back onclick
|
|
@@ -130,6 +146,7 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
130
146
|
*/
|
|
131
147
|
componentWillLoad() {
|
|
132
148
|
this.validateVariant(this.variant);
|
|
149
|
+
this.validateFullWidth(this.fullWidth);
|
|
133
150
|
if (this.isIcon) {
|
|
134
151
|
this.classList.add(`mg-button--icon`);
|
|
135
152
|
if (typeof this.label !== 'string' || this.label.trim() === '') {
|
|
@@ -146,11 +163,12 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
146
163
|
* @returns {HTMLElement} html element
|
|
147
164
|
*/
|
|
148
165
|
render() {
|
|
149
|
-
return (h(Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick,
|
|
166
|
+
return (h(Host, { role: "button", tabIndex: this.disabled ? -1 : 0, type: this.type, form: this.form, "full-width": this.fullWidth, "aria-label": this.label, "aria-disabled": this.disabled !== undefined && this.disabled.toString(), onClick: this.handleClick, onKeyup: this.handleKeyup, onKeydown: this.handleKeydown }, h("div", { class: this.classList.join(), id: this.identifier }, this.loading && h("mg-icon", { icon: "loader", spin: true }), h("div", { class: "mg-button__content" }, h("slot", null)))));
|
|
150
167
|
}
|
|
151
168
|
get element() { return this; }
|
|
152
169
|
static get watchers() { return {
|
|
153
170
|
"variant": ["validateVariant"],
|
|
171
|
+
"fullWidth": ["validateFullWidth"],
|
|
154
172
|
"disabled": ["disabledHandler"],
|
|
155
173
|
"loading": ["loadingHandler"]
|
|
156
174
|
}; }
|
|
@@ -160,6 +178,7 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
160
178
|
"identifier": [1],
|
|
161
179
|
"label": [1],
|
|
162
180
|
"type": [1],
|
|
181
|
+
"fullWidth": [1028, "full-width"],
|
|
163
182
|
"form": [1025],
|
|
164
183
|
"disabled": [1028],
|
|
165
184
|
"isIcon": [4, "is-icon"],
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface MgCard extends Components.MgCard, HTMLElement {}
|
|
4
|
+
export const MgCard: {
|
|
5
|
+
prototype: MgCard;
|
|
6
|
+
new (): MgCard;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
const mgCardCss = ".mg-card{padding:var(--mg-card-padding);border-radius:var(--mg-card-border-radius);background:var(--mg-card-background);border:var(--mg-card-border);box-shadow:var(--mg-card-box-shadow)}";
|
|
4
|
+
|
|
5
|
+
const MgCard$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.__registerHost();
|
|
9
|
+
this.__attachShadow();
|
|
10
|
+
}
|
|
11
|
+
/*************
|
|
12
|
+
* Lifecycle *
|
|
13
|
+
*************/
|
|
14
|
+
/**
|
|
15
|
+
* Render
|
|
16
|
+
*
|
|
17
|
+
* @returns {HTMLElement} HTML Element
|
|
18
|
+
*/
|
|
19
|
+
render() {
|
|
20
|
+
return (h("div", { class: "mg-card" }, h("slot", null)));
|
|
21
|
+
}
|
|
22
|
+
static get style() { return mgCardCss; }
|
|
23
|
+
}, [1, "mg-card"]);
|
|
24
|
+
function defineCustomElement$1() {
|
|
25
|
+
if (typeof customElements === "undefined") {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const components = ["mg-card"];
|
|
29
|
+
components.forEach(tagName => { switch (tagName) {
|
|
30
|
+
case "mg-card":
|
|
31
|
+
if (!customElements.get(tagName)) {
|
|
32
|
+
customElements.define(tagName, MgCard$1);
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
} });
|
|
36
|
+
}
|
|
37
|
+
defineCustomElement$1();
|
|
38
|
+
|
|
39
|
+
const MgCard = MgCard$1;
|
|
40
|
+
const defineCustomElement = defineCustomElement$1;
|
|
41
|
+
|
|
42
|
+
export { MgCard, defineCustomElement };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
2
|
import { d as defineCustomElement$2 } from './mg-icon2.js';
|
|
3
3
|
|
|
4
|
-
const mgDetailsCss = ".mg-details summary{display:flex;align-items:baseline;cursor:pointer}.mg-details__toggle{margin-left:1.5rem;flex-shrink:0}.mg-details__details{margin-top:1.5rem}";
|
|
4
|
+
const mgDetailsCss = ".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-details summary{display:flex;align-items:baseline;cursor:pointer}.mg-details__toggle{margin-left:1.5rem;flex-shrink:0;display:flex;align-items:center;align-self:flex-start;gap:0.6rem;min-height:calc(var(--font-size) * var(--line-height))}.mg-details__toggle mg-icon{align-self:self-end}.mg-details__details{margin-top:1.5rem}";
|
|
5
5
|
|
|
6
6
|
const MgDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
7
|
constructor() {
|
|
@@ -9,6 +9,10 @@ const MgDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
9
9
|
this.__registerHost();
|
|
10
10
|
this.__attachShadow();
|
|
11
11
|
this.expandedChange = createEvent(this, "expanded-change", 7);
|
|
12
|
+
/**
|
|
13
|
+
* Hide summary element
|
|
14
|
+
*/
|
|
15
|
+
this.hideSummary = false;
|
|
12
16
|
/**
|
|
13
17
|
* Define if details are diplayed
|
|
14
18
|
*/
|
|
@@ -23,7 +27,7 @@ const MgDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
23
27
|
};
|
|
24
28
|
}
|
|
25
29
|
validateTitles(newValue) {
|
|
26
|
-
if (newValue === undefined || newValue === '') {
|
|
30
|
+
if (newValue === undefined || newValue.trim() === '') {
|
|
27
31
|
throw new Error('<mg-details> prop "toggleClosed" and "toggleOpened" must be defined.');
|
|
28
32
|
}
|
|
29
33
|
}
|
|
@@ -48,7 +52,7 @@ const MgDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
48
52
|
* @returns {HTMLElement} HTML Element
|
|
49
53
|
*/
|
|
50
54
|
render() {
|
|
51
|
-
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), "
|
|
55
|
+
return (h("details", { class: "mg-details", onToggle: this.handleToggle, open: this.expanded, ref: el => (this.details = el) }, h("summary", null, h("slot", { name: "summary" }), h("span", { class: "mg-details__toggle" }, h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), h("span", { class: { 'sr-only': this.hideSummary } }, this.expanded ? this.toggleOpened : this.toggleClosed))), h("div", { class: "mg-details__details" }, h("slot", { name: "details" }))));
|
|
52
56
|
}
|
|
53
57
|
static get watchers() { return {
|
|
54
58
|
"toggleClosed": ["validateTitles"],
|
|
@@ -59,6 +63,7 @@ const MgDetails$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
59
63
|
}, [1, "mg-details", {
|
|
60
64
|
"toggleClosed": [1, "toggle-closed"],
|
|
61
65
|
"toggleOpened": [1, "toggle-opened"],
|
|
66
|
+
"hideSummary": [4, "hide-summary"],
|
|
62
67
|
"expanded": [1028]
|
|
63
68
|
}]);
|
|
64
69
|
function defineCustomElement$1() {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface MgDivider extends Components.MgDivider, HTMLElement {}
|
|
4
|
+
export const MgDivider: {
|
|
5
|
+
prototype: MgDivider;
|
|
6
|
+
new (): MgDivider;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
const mgDividerCss = ".mg-divider{margin:var(--mg-divider-vertical-spacing) auto;width:12rem;height:var(--mg-divider-thickness);background-color:var(--mg-divider-background-color)}.mg-divider.mg-divider--full{width:100%}";
|
|
4
|
+
|
|
5
|
+
const MgDivider$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
this.__registerHost();
|
|
9
|
+
this.__attachShadow();
|
|
10
|
+
/**************
|
|
11
|
+
* Decorators *
|
|
12
|
+
**************/
|
|
13
|
+
/**
|
|
14
|
+
* Define component size
|
|
15
|
+
*/
|
|
16
|
+
this.size = 'regular';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Render
|
|
20
|
+
*
|
|
21
|
+
* @returns {HTMLElement} HTML Element
|
|
22
|
+
*/
|
|
23
|
+
render() {
|
|
24
|
+
return (h("div", { class: {
|
|
25
|
+
'mg-divider': true,
|
|
26
|
+
'mg-divider--full': this.size === 'full',
|
|
27
|
+
} }));
|
|
28
|
+
}
|
|
29
|
+
static get style() { return mgDividerCss; }
|
|
30
|
+
}, [1, "mg-divider", {
|
|
31
|
+
"size": [1]
|
|
32
|
+
}]);
|
|
33
|
+
function defineCustomElement$1() {
|
|
34
|
+
if (typeof customElements === "undefined") {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const components = ["mg-divider"];
|
|
38
|
+
components.forEach(tagName => { switch (tagName) {
|
|
39
|
+
case "mg-divider":
|
|
40
|
+
if (!customElements.get(tagName)) {
|
|
41
|
+
customElements.define(tagName, MgDivider$1);
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
} });
|
|
45
|
+
}
|
|
46
|
+
defineCustomElement$1();
|
|
47
|
+
|
|
48
|
+
const MgDivider = MgDivider$1;
|
|
49
|
+
const defineCustomElement = defineCustomElement$1;
|
|
50
|
+
|
|
51
|
+
export { MgDivider, defineCustomElement };
|
|
@@ -11,6 +11,8 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
11
11
|
this.__attachShadow();
|
|
12
12
|
this.formValid = createEvent(this, "form-valid", 7);
|
|
13
13
|
this.formSubmit = createEvent(this, "form-submit", 7);
|
|
14
|
+
// Classes
|
|
15
|
+
this.classAllRequired = 'mg-form--all-required';
|
|
14
16
|
/**
|
|
15
17
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
16
18
|
* If not set, it will be created.
|
|
@@ -40,17 +42,24 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
40
42
|
* @returns {void}
|
|
41
43
|
*/
|
|
42
44
|
this.setRequiredMessage = () => {
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
if
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
// init required message
|
|
46
|
+
this.requiredMessage = null;
|
|
47
|
+
this.classList.delete(this.classAllRequired);
|
|
48
|
+
// If the form is disabled or readonly none of them are required
|
|
49
|
+
// Check if all fields are not editable (readonly or disabled)
|
|
50
|
+
if (!this.disabled && !this.readonly && !this.mgInputs.every(input => input.disabled || input.readonly)) {
|
|
51
|
+
// Get required fields
|
|
52
|
+
const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !input.readonly);
|
|
53
|
+
// All fields are required
|
|
54
|
+
// mg-input-toggle can not be required
|
|
55
|
+
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
56
|
+
this.requiredMessage = this.messages.form.allRequired;
|
|
57
|
+
this.classList.add(this.classAllRequired);
|
|
58
|
+
}
|
|
59
|
+
// Some fields are required
|
|
60
|
+
else if (requiredInputs.length > 0) {
|
|
61
|
+
this.requiredMessage = this.messages.form.required;
|
|
62
|
+
}
|
|
54
63
|
}
|
|
55
64
|
};
|
|
56
65
|
/**
|
|
@@ -59,15 +68,46 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
59
68
|
* @returns {void}
|
|
60
69
|
*/
|
|
61
70
|
this.checkValidity = () => {
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
71
|
+
// Update required on input event
|
|
72
|
+
this.setRequiredMessage();
|
|
73
|
+
this.valid = !this.mgInputs.some(input => input.invalid);
|
|
74
|
+
this.invalid = !this.valid;
|
|
75
|
+
// We need to send valid event if it is the same value
|
|
76
|
+
this.formValid.emit(this.valid);
|
|
66
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* Handle Form Submit
|
|
80
|
+
*
|
|
81
|
+
* @param {SubmitEvent} event submit event
|
|
82
|
+
* @returns {void}
|
|
83
|
+
*/
|
|
67
84
|
this.handleFormSubmit = (event) => {
|
|
68
85
|
event.preventDefault();
|
|
69
86
|
this.formSubmit.emit();
|
|
70
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Set mgInputs
|
|
90
|
+
*
|
|
91
|
+
* @returns {void}
|
|
92
|
+
*/
|
|
93
|
+
this.setMgInputs = () => {
|
|
94
|
+
// Get slotted mgInputs
|
|
95
|
+
this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
|
|
96
|
+
// Set inputs readonly or disabled based on form configuration
|
|
97
|
+
// Othewise listen to events
|
|
98
|
+
this.mgInputs.map(input => {
|
|
99
|
+
if (this.readonly)
|
|
100
|
+
input.readonly = true;
|
|
101
|
+
else if (this.disabled)
|
|
102
|
+
input.disabled = true;
|
|
103
|
+
else
|
|
104
|
+
input.addEventListener('input-valid', this.checkValidity);
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
handleAttributeChange() {
|
|
109
|
+
this.setMgInputs();
|
|
110
|
+
this.setRequiredMessage();
|
|
71
111
|
}
|
|
72
112
|
/**
|
|
73
113
|
* Public method to display errors
|
|
@@ -93,26 +133,18 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
93
133
|
componentWillLoad() {
|
|
94
134
|
// Get locales
|
|
95
135
|
this.messages = initLocales(this.element).messages;
|
|
96
|
-
// Get slotted mgInputs
|
|
97
|
-
this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
|
|
98
136
|
// Get slotted mgButtons
|
|
99
|
-
this.mgButtons = Array.from(this.element.querySelectorAll('
|
|
137
|
+
this.mgButtons = Array.from(this.element.querySelectorAll('mg-button'));
|
|
100
138
|
// Set button form identifier
|
|
101
139
|
this.mgButtons.forEach(mgButton => {
|
|
102
140
|
mgButton.setAttribute('form', this.identifier);
|
|
103
141
|
});
|
|
142
|
+
// Set mgInputs
|
|
143
|
+
this.setMgInputs();
|
|
104
144
|
// Define required message
|
|
105
145
|
this.setRequiredMessage();
|
|
106
146
|
// Check validity when slotted mgInputs are ready
|
|
107
147
|
Promise.all(this.mgInputs.map(async (input) => {
|
|
108
|
-
// Set inputs readonly or disabled based on form configuration
|
|
109
|
-
// Othewise listen to events
|
|
110
|
-
if (this.readonly)
|
|
111
|
-
input.readonly = true;
|
|
112
|
-
else if (this.disabled)
|
|
113
|
-
input.disabled = true;
|
|
114
|
-
else
|
|
115
|
-
input.addEventListener('input-valid', this.checkValidity);
|
|
116
148
|
try {
|
|
117
149
|
await input.componentOnReady();
|
|
118
150
|
}
|
|
@@ -135,6 +167,10 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
135
167
|
});
|
|
136
168
|
}
|
|
137
169
|
});
|
|
170
|
+
// Update mgInputs when mgForm content change
|
|
171
|
+
new MutationObserver(() => {
|
|
172
|
+
this.setMgInputs();
|
|
173
|
+
}).observe(this.element, { childList: true });
|
|
138
174
|
}
|
|
139
175
|
/**
|
|
140
176
|
* Render
|
|
@@ -145,6 +181,10 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
145
181
|
return (h("form", { class: this.classList.join(), id: this.identifier, name: this.name, ref: el => (this.form = el), onSubmit: this.handleFormSubmit }, this.requiredMessage && h("p", { innerHTML: this.requiredMessage }), h("slot", null), !this.readonly && !this.disabled && h("slot", { name: "actions" })));
|
|
146
182
|
}
|
|
147
183
|
get element() { return this; }
|
|
184
|
+
static get watchers() { return {
|
|
185
|
+
"readonly": ["handleAttributeChange"],
|
|
186
|
+
"disabled": ["handleAttributeChange"]
|
|
187
|
+
}; }
|
|
148
188
|
static get style() { return mgFormCss; }
|
|
149
189
|
}, [1, "mg-form", {
|
|
150
190
|
"identifier": [1],
|
|
@@ -154,6 +194,7 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
154
194
|
"valid": [1028],
|
|
155
195
|
"invalid": [1028],
|
|
156
196
|
"classList": [32],
|
|
197
|
+
"requiredMessage": [32],
|
|
157
198
|
"displayError": [64]
|
|
158
199
|
}]);
|
|
159
200
|
function defineCustomElement$1() {
|
|
@@ -27,6 +27,8 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
27
27
|
************/
|
|
28
28
|
// HTML selector
|
|
29
29
|
this.inputs = [];
|
|
30
|
+
// hasDisplayedError (triggered by blur event)
|
|
31
|
+
this.hasDisplayedError = false;
|
|
30
32
|
/**
|
|
31
33
|
* Input name
|
|
32
34
|
* If not set the value equals the identifier
|
|
@@ -81,25 +83,27 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
81
83
|
this.handleBlur = () => {
|
|
82
84
|
// Check validity
|
|
83
85
|
this.checkValidity();
|
|
84
|
-
this.
|
|
86
|
+
this.setErrorMessage();
|
|
85
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* get invalid element
|
|
90
|
+
*
|
|
91
|
+
* @returns {HTMLInputElement} element
|
|
92
|
+
*/
|
|
93
|
+
this.getInvalidElement = () => this.inputs.find((input) => input !== null && !input.disabled && !input.checkValidity());
|
|
86
94
|
/**
|
|
87
95
|
* Check if input is valid
|
|
88
96
|
*/
|
|
89
97
|
this.checkValidity = () => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.invalid = !validity;
|
|
95
|
-
//Send event
|
|
96
|
-
this.inputValid.emit(validity);
|
|
97
|
-
}
|
|
98
|
+
this.valid = this.readonly || this.disabled || this.getInvalidElement() === undefined;
|
|
99
|
+
this.invalid = !this.valid;
|
|
100
|
+
// We need to send valid event even if it is the same value
|
|
101
|
+
this.inputValid.emit(this.valid);
|
|
98
102
|
};
|
|
99
103
|
/**
|
|
100
|
-
*
|
|
104
|
+
* Set input error message
|
|
101
105
|
*/
|
|
102
|
-
this.
|
|
106
|
+
this.setErrorMessage = () => {
|
|
103
107
|
const invalidElement = this.getInvalidElement();
|
|
104
108
|
// Set error message
|
|
105
109
|
this.errorMessage = undefined;
|
|
@@ -107,12 +111,6 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
107
111
|
this.errorMessage = this.messages.errors.required;
|
|
108
112
|
}
|
|
109
113
|
};
|
|
110
|
-
/**
|
|
111
|
-
* get invalid element
|
|
112
|
-
*
|
|
113
|
-
* @returns {HTMLInputElement} element
|
|
114
|
-
*/
|
|
115
|
-
this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
|
|
116
114
|
}
|
|
117
115
|
validateValue(newValue) {
|
|
118
116
|
if (newValue && newValue.every(item => isCheckboxItem(item))) {
|
|
@@ -128,6 +126,16 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
128
126
|
throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
|
|
129
127
|
}
|
|
130
128
|
}
|
|
129
|
+
handleValidityChange(newValue, _oldValue, prop) {
|
|
130
|
+
this.inputs.forEach(input => {
|
|
131
|
+
input[prop] = newValue;
|
|
132
|
+
});
|
|
133
|
+
this.checkValidity();
|
|
134
|
+
if (this.hasDisplayedError) {
|
|
135
|
+
this.setErrorMessage();
|
|
136
|
+
this.hasDisplayedError = false;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
131
139
|
/**
|
|
132
140
|
* Public method to display errors
|
|
133
141
|
*
|
|
@@ -135,7 +143,8 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
135
143
|
*/
|
|
136
144
|
async displayError() {
|
|
137
145
|
this.checkValidity();
|
|
138
|
-
this.
|
|
146
|
+
this.setErrorMessage();
|
|
147
|
+
this.hasDisplayedError = this.invalid;
|
|
139
148
|
}
|
|
140
149
|
/*************
|
|
141
150
|
* Lifecycle *
|
|
@@ -163,15 +172,21 @@ const MgInputCheckbox$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
|
|
|
163
172
|
* @returns {HTMLElement} HTML Element
|
|
164
173
|
*/
|
|
165
174
|
render() {
|
|
166
|
-
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly
|
|
175
|
+
return (h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: !this.readonly ? this.required : undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value && this.value.toString(), readonlyValue: undefined, tooltip: !this.readonly ? this.tooltip : undefined, helpText: !this.readonly ? this.helpText : undefined, errorMessage: !this.readonly ? this.errorMessage : undefined, isFieldset: true }, h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
|
|
167
176
|
.filter(item => {
|
|
168
177
|
return !this.readonly || item.value;
|
|
169
178
|
})
|
|
170
|
-
.map(input => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el =>
|
|
179
|
+
.map((input, index) => (h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, h("input", { type: "checkbox", id: input.id, name: this.identifier, value: input.value && input.value.toString(), checked: Boolean(input.value), disabled: this.readonly || this.disabled || input.disabled, required: this.required, indeterminate: input.value === null, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => {
|
|
180
|
+
if (el !== null)
|
|
181
|
+
this.inputs[index] = el;
|
|
182
|
+
} }), h("label", { htmlFor: input.id }, input.title)))))));
|
|
171
183
|
}
|
|
172
184
|
get element() { return this; }
|
|
173
185
|
static get watchers() { return {
|
|
174
|
-
"value": ["validateValue"]
|
|
186
|
+
"value": ["validateValue"],
|
|
187
|
+
"required": ["handleValidityChange"],
|
|
188
|
+
"readonly": ["handleValidityChange"],
|
|
189
|
+
"disabled": ["handleValidityChange"]
|
|
175
190
|
}; }
|
|
176
191
|
static get style() { return mgInputCheckboxCss; }
|
|
177
192
|
}, [1, "mg-input-checkbox", {
|