@mgdis/mg-components 3.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-85a4a0b6.js → index-88560a66.js} +123 -48
- package/dist/cjs/index-a39c5567.js +233 -0
- package/dist/cjs/loader.cjs.js +3 -17
- package/dist/cjs/mg-badge_21.cjs.entry.js +3538 -0
- package/dist/cjs/mg-components.cjs.js +3 -7
- package/dist/cjs/mg-modal.cjs.entry.js +117 -0
- package/dist/cjs/mg-popover.cjs.entry.js +170 -0
- package/dist/cjs/popper-71bf3058.js +1790 -0
- package/dist/collection/collection-manifest.json +4 -1
- package/dist/collection/components/atoms/mg-badge/{mg-badge.stories.js → doc/mg-badge.stories.js} +4 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +0 -2
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +26 -10
- package/dist/collection/components/atoms/mg-button/{mg-button.stories.js → doc/mg-button.stories.js} +7 -2
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +1 -1
- package/dist/collection/components/atoms/mg-button/mg-button.css +46 -49
- package/dist/collection/components/atoms/mg-button/mg-button.js +78 -4
- package/dist/collection/components/atoms/mg-character-left/{mg-character-left.stories.js → doc/mg-character-left.stories.js} +8 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +20 -46
- package/dist/collection/components/atoms/mg-icon/{mg-icon.stories.js → doc/mg-icon.stories.js} +1 -1
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +104 -9
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +9 -7
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +33 -7
- package/dist/collection/components/atoms/mg-input-title/{mg-input-title.stories.js → doc/mg-input-title.stories.js} +0 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +4 -4
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +14 -3
- package/dist/collection/components/atoms/mg-tag/{mg-tag.stories.js → doc/mg-tag.stories.js} +4 -1
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +28 -6
- package/dist/collection/components/atoms/mg-tooltip/{mg-tooltip.stories.js → doc/mg-tooltip.stories.js} +14 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +20 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +16 -2
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +1 -7
- package/dist/collection/components/molecules/inputs/MgInput.js +25 -29
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.js → doc/mg-input-checkbox.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +25 -11
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +102 -52
- package/dist/collection/components/molecules/inputs/mg-input-date/{mg-input-date.stories.js → doc/mg-input-date.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +37 -9
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +136 -66
- package/dist/collection/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.js → doc/mg-input-numeric.stories.js} +15 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +38 -10
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +180 -80
- package/dist/collection/components/molecules/inputs/mg-input-password/{mg-input-password.stories.js → doc/mg-input-password.stories.js} +16 -2
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +37 -9
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +108 -47
- package/dist/collection/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.js → doc/mg-input-radio.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +25 -11
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +113 -42
- package/dist/collection/components/molecules/inputs/mg-input-select/{mg-input-select.stories.js → doc/mg-input-select.stories.js} +22 -2
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +39 -10
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +145 -71
- package/dist/collection/components/molecules/inputs/mg-input-text/{mg-input-text.stories.js → doc/mg-input-text.stories.js} +17 -8
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +69 -19
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +184 -83
- package/dist/collection/components/molecules/inputs/mg-input-textarea/{mg-input-textarea.stories.js → doc/mg-input-textarea.stories.js} +16 -5
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +69 -13
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +163 -70
- package/dist/collection/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.js → doc/mg-input-toggle.stories.js} +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +22 -10
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +68 -33
- package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +58 -0
- package/dist/collection/components/molecules/mg-form/mg-form.css +19 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +271 -0
- package/dist/collection/components/molecules/mg-message/{mg-message.stories.js → doc/mg-message.stories.js} +6 -2
- package/dist/collection/components/molecules/mg-message/mg-message.css +1 -1
- package/dist/collection/components/molecules/mg-message/mg-message.js +26 -11
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +51 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +52 -0
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +240 -0
- package/dist/collection/components/molecules/mg-pagination/{mg-pagination.stories.js → doc/mg-pagination.stories.js} +1 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +47 -28
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +39 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +53 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +356 -0
- package/dist/collection/components/molecules/mg-popover/{mg-popover.stories.js → doc/mg-popover.stories.js} +10 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +20 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +37 -12
- package/dist/collection/components/molecules/mg-tabs/{mg-tabs.stories.js → doc/mg-tabs.stories.js} +20 -4
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +11 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +17 -3
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +139 -26
- package/dist/collection/locales/index.js +33 -4
- package/dist/collection/stories/helpers.stories.js +33 -0
- package/dist/collection/utils/components.utils.js +16 -9
- package/dist/collection/utils/locale.utils.js +13 -7
- package/dist/collection/utils/test.utils.js +27 -15
- package/dist/collection/variables.css +39 -5
- package/dist/collection/variables.scss +39 -5
- package/dist/components/MgInput.js +26 -37
- package/dist/components/components.utils.js +16 -9
- package/dist/components/index.d.ts +24 -6
- package/dist/components/index.js +23 -0
- package/dist/components/index2.js +116 -17
- package/dist/components/locale.utils.js +13 -8
- package/dist/components/mg-badge2.js +25 -9
- package/dist/components/mg-button2.js +29 -5
- package/dist/components/mg-character-left2.js +14 -26
- package/dist/components/mg-form.d.ts +11 -0
- package/dist/components/mg-form.js +148 -0
- package/dist/components/mg-icon2.js +138 -17
- package/dist/components/mg-input-checkbox.js +66 -53
- package/dist/components/mg-input-date.js +100 -69
- package/dist/components/mg-input-numeric.js +125 -81
- package/dist/components/mg-input-password.js +69 -48
- package/dist/components/mg-input-radio.js +74 -46
- package/dist/components/mg-input-select2.js +103 -71
- package/dist/components/mg-input-text.js +1 -237
- package/dist/components/mg-input-text2.js +300 -0
- package/dist/components/mg-input-textarea.js +100 -46
- package/dist/components/mg-input-title2.js +13 -4
- package/dist/components/mg-input-toggle.js +39 -31
- package/dist/components/mg-message.js +25 -10
- package/dist/components/mg-modal.d.ts +11 -0
- package/dist/components/mg-modal.js +153 -0
- package/dist/components/mg-pagination.js +45 -31
- package/dist/components/mg-panel.d.ts +11 -0
- package/dist/components/mg-panel.js +244 -0
- package/dist/components/mg-popover.js +31 -11
- package/dist/components/mg-tabs.js +113 -23
- package/dist/components/mg-tag.js +27 -5
- package/dist/components/mg-tooltip2.js +10 -1
- package/dist/components/popper.js +6 -2
- package/dist/esm/{index-e3e84606.js → index-bca81100.js} +124 -46
- package/dist/esm/index-e51ae032.js +228 -0
- package/dist/esm/loader.js +3 -17
- package/dist/esm/mg-badge_21.entry.js +3514 -0
- package/dist/esm/mg-components.js +3 -7
- package/dist/esm/mg-modal.entry.js +113 -0
- package/dist/esm/mg-popover.entry.js +166 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/popper-93ecb064.js +1788 -0
- package/dist/index.js +1 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-003a1344.entry.js +1 -0
- package/dist/mg-components/p-462d648a.entry.js +1 -0
- package/dist/mg-components/p-4c66f794.js +1 -0
- package/dist/mg-components/p-5126ab10.entry.js +1 -0
- package/dist/mg-components/p-780bd52d.js +1 -0
- package/dist/mg-components/p-b14a3443.js +2 -0
- package/dist/mg-components/variables.css +39 -5
- package/dist/mg-components/variables.scss +39 -5
- package/dist/types/components/atoms/mg-badge/{mg-badge.stories.d.ts → doc/mg-badge.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +16 -5
- package/dist/types/components/atoms/mg-button/{mg-button.stories.d.ts → doc/mg-button.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +23 -3
- package/dist/types/components/atoms/mg-character-left/{mg-character-left.stories.d.ts → doc/mg-character-left.stories.d.ts} +9 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +16 -13
- package/dist/types/components/atoms/mg-icon/{mg-icon.stories.d.ts → doc/mg-icon.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +1 -1
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +14 -4
- package/dist/types/components/atoms/mg-input-title/{mg-input-title.stories.d.ts → doc/mg-input-title.stories.d.ts} +0 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +11 -1
- package/dist/types/components/atoms/mg-tag/{mg-tag.stories.d.ts → doc/mg-tag.stories.d.ts} +5 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +18 -4
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +29 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +13 -3
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +6 -4
- package/dist/types/components/molecules/inputs/MgInput.d.ts +7 -8
- package/dist/types/components/molecules/inputs/mg-input-checkbox/{mg-input-checkbox.stories.d.ts → doc/mg-input-checkbox.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +36 -13
- package/dist/types/components/molecules/inputs/mg-input-date/{mg-input-date.stories.d.ts → doc/mg-input-date.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +46 -15
- package/dist/types/components/molecules/inputs/mg-input-numeric/{mg-input-numeric.stories.d.ts → doc/mg-input-numeric.stories.d.ts} +11 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +61 -16
- package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +22 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +35 -11
- package/dist/types/components/molecules/inputs/mg-input-radio/{mg-input-radio.stories.d.ts → doc/mg-input-radio.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +42 -9
- package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +34 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +37 -9
- package/dist/types/components/molecules/inputs/mg-input-text/{mg-input-text.stories.d.ts → doc/mg-input-text.stories.d.ts} +13 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +52 -16
- package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +45 -17
- package/dist/types/components/molecules/inputs/mg-input-toggle/{mg-input-toggle.stories.d.ts → doc/mg-input-toggle.stories.d.ts} +5 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +29 -12
- package/dist/types/components/molecules/{mg-popover/mg-popover.stories.d.ts → mg-form/doc/mg-form.stories.d.ts} +3 -4
- package/dist/types/components/molecules/mg-form/mg-form.d.ts +83 -0
- package/dist/types/components/molecules/mg-message/{mg-message.stories.d.ts → doc/mg-message.stories.d.ts} +10 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +13 -4
- package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +13 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +85 -0
- package/dist/types/components/molecules/mg-pagination/{mg-pagination.stories.d.ts → doc/mg-pagination.stories.d.ts} +5 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +31 -7
- package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +11 -0
- package/dist/types/components/molecules/mg-panel/mg-panel.d.ts +139 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +25 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +8 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +27 -4
- package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +20 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +11 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +70 -6
- package/dist/types/components.d.ts +528 -211
- package/dist/types/locales/index.d.ts +108 -38
- package/dist/types/stories/{buttons.stories.d.ts → helpers.stories.d.ts} +1 -1
- package/dist/types/utils/components.utils.d.ts +16 -9
- package/dist/types/utils/locale.utils.d.ts +13 -6
- package/dist/types/utils/test.utils.d.ts +13 -1
- package/loader/index.js +1 -1
- package/package.json +45 -14
- package/readme.md +9 -35
- package/dist/cjs/css-shim-a22512c4.js +0 -6
- package/dist/cjs/mg-badge_20.cjs.entry.js +0 -4661
- package/dist/cjs/shadow-css-8940f82d.js +0 -390
- package/dist/collection/stories/buttons.stories.js +0 -43
- package/dist/collection/stories/messages.stories.js +0 -44
- package/dist/collection/stories/tags.stories.js +0 -13
- package/dist/esm/css-shim-7c240feb.js +0 -4
- package/dist/esm/mg-badge_20.entry.js +0 -4638
- package/dist/esm/shadow-css-5d2d01ce.js +0 -388
- package/dist/esm-es5/css-shim-7c240feb.js +0 -1
- package/dist/esm-es5/index-e3e84606.js +0 -1
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +0 -1
- package/dist/esm-es5/mg-badge_20.entry.js +0 -2
- package/dist/esm-es5/mg-components.js +0 -1
- package/dist/esm-es5/shadow-css-5d2d01ce.js +0 -12
- package/dist/mg-components/mg-components.js +0 -132
- package/dist/mg-components/p-1cd24462.system.js +0 -1
- package/dist/mg-components/p-2e2f6b27.system.entry.js +0 -2
- package/dist/mg-components/p-366a224e.js +0 -1
- package/dist/mg-components/p-422c429b.system.js +0 -1
- package/dist/mg-components/p-50ea2036.system.js +0 -1
- package/dist/mg-components/p-62fa3797.js +0 -1
- package/dist/mg-components/p-71d57b8b.system.js +0 -13
- package/dist/mg-components/p-9a215712.system.js +0 -1
- package/dist/mg-components/p-cbf0464b.entry.js +0 -1
- package/dist/mg-components/p-f6455ab3.js +0 -12
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +0 -11
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +0 -9
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +0 -14
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +0 -7
- package/dist/types/stories/messages.stories.d.ts +0 -13
- package/dist/types/stories/tags.stories.d.ts +0 -5
|
@@ -0,0 +1,3538 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-88560a66.js');
|
|
6
|
+
const index$1 = require('./index-a39c5567.js');
|
|
7
|
+
const popper = require('./popper-71bf3058.js');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* List of all possibles variants
|
|
11
|
+
*/
|
|
12
|
+
const variants$4 = ['info', 'primary', 'secondary', 'success', 'warning', 'danger'];
|
|
13
|
+
|
|
14
|
+
const mgBadgeCss = ".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-badge{padding:0 0.4rem;height:var(--mg-badge-size);min-width:var(--mg-badge-size);box-sizing:border-box;border:0.1rem solid;border-radius:calc(var(--mg-badge-size) / 2);font-size:var(--mg-badge-font-size);font-weight:600;text-align:center;line-height:var(--mg-badge-size)}.mg-badge.mg-badge--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-badge.mg-badge--primary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-badge.mg-badge--secondary.mg-badge--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-badge.mg-badge--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-badge.mg-badge--success.mg-badge--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-badge.mg-badge--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-badge.mg-badge--warning.mg-badge--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-badge.mg-badge--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-badge.mg-badge--danger.mg-badge--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-badge.mg-badge--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-badge.mg-badge--info.mg-badge--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-badge,mg-badge{display:inline-flex;align-items:center;justify-content:center}";
|
|
15
|
+
|
|
16
|
+
const MgBadge = class {
|
|
17
|
+
constructor(hostRef) {
|
|
18
|
+
index.registerInstance(this, hostRef);
|
|
19
|
+
/************
|
|
20
|
+
* Internal *
|
|
21
|
+
************/
|
|
22
|
+
// classes
|
|
23
|
+
this.classOutline = `mg-badge--outline`;
|
|
24
|
+
/**
|
|
25
|
+
* Define button variant
|
|
26
|
+
*/
|
|
27
|
+
this.variant = variants$4[0]; // info
|
|
28
|
+
/**
|
|
29
|
+
* Component classes
|
|
30
|
+
*/
|
|
31
|
+
this.classList = new index$1.ClassList(['mg-badge']);
|
|
32
|
+
}
|
|
33
|
+
validateValue(newValue) {
|
|
34
|
+
if (`${newValue}`.match(/^(\d+|[?*!a-z])$/i) === null) {
|
|
35
|
+
throw new Error('<mg-badge> prop "value" must be interger or ponctuation character.');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
validateVariant(newValue, oldValue) {
|
|
39
|
+
if (!variants$4.includes(newValue)) {
|
|
40
|
+
throw new Error(`<mg-badge> prop "variant" must be one of : ${variants$4.join(', ')}.`);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
if (oldValue !== undefined) {
|
|
44
|
+
this.classList.delete(`mg-badge--${oldValue}`);
|
|
45
|
+
}
|
|
46
|
+
this.classList.add(`mg-badge--${newValue}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
validateOutline(newValue) {
|
|
50
|
+
if (newValue)
|
|
51
|
+
this.classList.add(this.classOutline);
|
|
52
|
+
else
|
|
53
|
+
this.classList.delete(this.classOutline);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Check if props are well configured on init
|
|
57
|
+
*
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
60
|
+
componentWillLoad() {
|
|
61
|
+
this.validateValue(this.value);
|
|
62
|
+
this.validateVariant(this.variant);
|
|
63
|
+
this.validateOutline(this.outline);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Render
|
|
67
|
+
*
|
|
68
|
+
* @returns {HTMLElement} HTML Element
|
|
69
|
+
*/
|
|
70
|
+
render() {
|
|
71
|
+
return (index.h("span", { class: this.classList.join() }, this.value, index.h("span", { class: "sr-only" }, this.label)));
|
|
72
|
+
}
|
|
73
|
+
static get watchers() { return {
|
|
74
|
+
"value": ["validateValue"],
|
|
75
|
+
"variant": ["validateVariant"],
|
|
76
|
+
"outline": ["validateOutline"]
|
|
77
|
+
}; }
|
|
78
|
+
};
|
|
79
|
+
MgBadge.style = mgBadgeCss;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* List of all possibles variants
|
|
83
|
+
*/
|
|
84
|
+
const variants$3 = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success'];
|
|
85
|
+
|
|
86
|
+
const mgButtonCss = ".mg-button.sc-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;font-family:inherit;text-decoration:none;font-weight:normal;text-align:left;touch-action:manipulation}.mg-button[disabled].sc-mg-button,.mg-button[aria-disabled=true].sc-mg-button,.mg-button.disabled.sc-mg-button{opacity:var(--mg-button-disabled-opacity);cursor:default}.mg-button.mg-button--icon.sc-mg-button{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--primary.sc-mg-button{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%)))}.mg-button.mg-button--primary.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--primary.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--primary.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{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.sc-mg-button{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%)))}.mg-button.mg-button--secondary.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--secondary.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--secondary.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{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.sc-mg-button{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%)))}.mg-button.mg-button--danger.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-button.mg-button--danger-alt.sc-mg-button{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%)))}.mg-button.mg-button--danger-alt.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger-alt.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--danger-alt.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))}.mg-button.mg-button--info.sc-mg-button{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%)))}.mg-button.mg-button--info.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--info.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--info.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-button.mg-button--success.sc-mg-button{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%)))}.mg-button.mg-button--success.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--success.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--success.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))}.mg-button.mg-button--flat.sc-mg-button{background:none;border:none}.mg-button.mg-button--flat.sc-mg-button:hover:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--flat.sc-mg-button:focus:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button,.mg-button.mg-button--flat.sc-mg-button:active:not([disabled],[aria-disabled=true].sc-mg-button,.disabled).sc-mg-button{background:hsla(var(--color-dark), 0.1)}.mg-button.sc-mg-button mg-icon.sc-mg-button:only-child,.mg-button .sc-mg-button-s>mg-icon{display:inline-flex;flex-shrink:0;line-height:1;margin:auto 0}.mg-button.mg-button--loading.sc-mg-button>mg-icon.sc-mg-button{position:absolute;left:50%;top:50%;transform:translate(-50%, -50%)}.mg-button.mg-button--loading.sc-mg-button .mg-button__content.sc-mg-button{opacity:0}.mg-button__content.sc-mg-button{display:flex;align-items:center;column-gap:0.6rem}mg-button.sc-mg-button{display:inline-block}.mg-button.sc-mg-button,mg-button.sc-mg-button{vertical-align:middle;max-width:100%}";
|
|
87
|
+
|
|
88
|
+
const MgButton = class {
|
|
89
|
+
constructor(hostRef) {
|
|
90
|
+
index.registerInstance(this, hostRef);
|
|
91
|
+
/************
|
|
92
|
+
* Internal *
|
|
93
|
+
************/
|
|
94
|
+
this.onClickElementFn = null;
|
|
95
|
+
/**
|
|
96
|
+
* Define button variant
|
|
97
|
+
*/
|
|
98
|
+
this.variant = variants$3[0]; // Primary
|
|
99
|
+
/**
|
|
100
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
101
|
+
* If not set, it will be created.
|
|
102
|
+
*/
|
|
103
|
+
this.identifier = index$1.createID('mg-button');
|
|
104
|
+
/**
|
|
105
|
+
* Disable button
|
|
106
|
+
*/
|
|
107
|
+
this.disabled = false;
|
|
108
|
+
/**
|
|
109
|
+
* Define if button is round.
|
|
110
|
+
* Used for icon button.
|
|
111
|
+
*/
|
|
112
|
+
this.isIcon = false;
|
|
113
|
+
/**
|
|
114
|
+
* Option to set input disable on click, in order to prevent multi-click.
|
|
115
|
+
* Parent component have to remove the attribute 'disabled' when the process ends.
|
|
116
|
+
*/
|
|
117
|
+
this.disableOnClick = false;
|
|
118
|
+
/**
|
|
119
|
+
* Prop to set aria-expanded on button element
|
|
120
|
+
*/
|
|
121
|
+
this.expanded = false;
|
|
122
|
+
/**
|
|
123
|
+
* Option to set aria-haspopup
|
|
124
|
+
* The aria-haspopup state informs assistive technology users that there is a popup and the type of popup it is, but provides no interactivity.
|
|
125
|
+
*/
|
|
126
|
+
this.haspopup = false;
|
|
127
|
+
/**
|
|
128
|
+
* Define if button is loading, default to false.
|
|
129
|
+
* Trigger when button is clicked or key-up ['enter', 'space], then value change to true.
|
|
130
|
+
* It's required to reset to false when action/promise in parent is done to stop the loading state
|
|
131
|
+
*/
|
|
132
|
+
this.loading = false;
|
|
133
|
+
/**
|
|
134
|
+
* Component classes
|
|
135
|
+
*/
|
|
136
|
+
this.classList = new index$1.ClassList(['mg-button']);
|
|
137
|
+
/**
|
|
138
|
+
* Trigger actions onClick event
|
|
139
|
+
*
|
|
140
|
+
* @param {MouseEvent} event click event
|
|
141
|
+
* @returns {void}
|
|
142
|
+
*/
|
|
143
|
+
this.handleClick = (event) => {
|
|
144
|
+
if (this.disabled)
|
|
145
|
+
event.stopPropagation();
|
|
146
|
+
// Used to prevent multi-click.
|
|
147
|
+
if (this.disableOnClick && !this.disabled) {
|
|
148
|
+
this.loading = true;
|
|
149
|
+
this.disabled = true;
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
validateVariant(newValue, oldValue) {
|
|
154
|
+
if (!variants$3.includes(newValue)) {
|
|
155
|
+
throw new Error(`<mg-button> prop "variant" must be one of : ${variants$3.join(', ')}`);
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
if (oldValue !== undefined) {
|
|
159
|
+
this.classList.delete(`mg-button--${oldValue}`);
|
|
160
|
+
}
|
|
161
|
+
this.classList.add(`mg-button--${newValue}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
disabledHandler(isDisabled) {
|
|
165
|
+
// Remove loading when enable
|
|
166
|
+
// Will be set back onclick
|
|
167
|
+
if (!isDisabled && this.disableOnClick) {
|
|
168
|
+
this.loading = false;
|
|
169
|
+
}
|
|
170
|
+
// Manage if onclick
|
|
171
|
+
this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
|
|
172
|
+
}
|
|
173
|
+
loadingHandler(newValue) {
|
|
174
|
+
// we add loading style if it newvalue is true else we remove it
|
|
175
|
+
if (newValue) {
|
|
176
|
+
this.classList.add('mg-button--loading');
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
this.classList.delete('mg-button--loading');
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Check if props are well configured on init
|
|
184
|
+
*
|
|
185
|
+
* @returns {void}
|
|
186
|
+
*/
|
|
187
|
+
componentWillLoad() {
|
|
188
|
+
this.validateVariant(this.variant);
|
|
189
|
+
if (this.isIcon) {
|
|
190
|
+
this.classList.add(`mg-button--icon`);
|
|
191
|
+
if (typeof this.label !== 'string' || this.label === '') {
|
|
192
|
+
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Store the onclick fn
|
|
196
|
+
this.onClickElementFn = this.element.onclick;
|
|
197
|
+
this.disabledHandler(this.disabled);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Render component
|
|
201
|
+
*
|
|
202
|
+
* @returns {HTMLElement} html element
|
|
203
|
+
*/
|
|
204
|
+
render() {
|
|
205
|
+
return (index.h("button", { id: this.identifier, class: this.classList.join(), "aria-label": this.label, "aria-disabled": this.disabled.toString(), "aria-expanded": this.expanded, "aria-controls": this.controls, "aria-haspopup": this.haspopup, onClick: this.handleClick }, this.loading && index.h("mg-icon", { icon: "loader", spin: true }), index.h("div", { class: "mg-button__content" }, index.h("slot", null))));
|
|
206
|
+
}
|
|
207
|
+
get element() { return index.getElement(this); }
|
|
208
|
+
static get watchers() { return {
|
|
209
|
+
"variant": ["validateVariant"],
|
|
210
|
+
"disabled": ["disabledHandler"],
|
|
211
|
+
"loading": ["loadingHandler"]
|
|
212
|
+
}; }
|
|
213
|
+
};
|
|
214
|
+
MgButton.style = mgButtonCss;
|
|
215
|
+
|
|
216
|
+
const mgCharacterLeftCss = "mg-character-left.sc-mg-character-left{display:block}";
|
|
217
|
+
|
|
218
|
+
const MgCharacterLeft = class {
|
|
219
|
+
constructor(hostRef) {
|
|
220
|
+
index.registerInstance(this, hostRef);
|
|
221
|
+
/**
|
|
222
|
+
* Sets the characters to count
|
|
223
|
+
*/
|
|
224
|
+
this.characters = '';
|
|
225
|
+
}
|
|
226
|
+
validateMaxlength(newValue) {
|
|
227
|
+
if (typeof newValue !== 'number') {
|
|
228
|
+
throw new Error('<mg-character-left> prop "maxlength" is required.');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/*************
|
|
232
|
+
* Lifecycle *
|
|
233
|
+
*************/
|
|
234
|
+
/**
|
|
235
|
+
* Check if props are well configured on init
|
|
236
|
+
*
|
|
237
|
+
* @returns {void}
|
|
238
|
+
*/
|
|
239
|
+
componentWillLoad() {
|
|
240
|
+
this.validateMaxlength(this.maxlength);
|
|
241
|
+
this.messages = index$1.initLocales(this.element).messages;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Render component
|
|
245
|
+
*
|
|
246
|
+
* @returns {HTMLElement} HTML Element
|
|
247
|
+
*/
|
|
248
|
+
render() {
|
|
249
|
+
return (index.h("span", { id: this.identifier, "aria-live": "polite" }, index.h("span", { "aria-hidden": "true" }, this.maxlength - this.characters.length, "/", this.maxlength), index.h("span", { class: "sr-only" }, this.messages.nbCharLeft.replace('{counter}', this.maxlength - this.characters.length))));
|
|
250
|
+
}
|
|
251
|
+
get element() { return index.getElement(this); }
|
|
252
|
+
static get watchers() { return {
|
|
253
|
+
"maxlength": ["validateMaxlength"]
|
|
254
|
+
}; }
|
|
255
|
+
};
|
|
256
|
+
MgCharacterLeft.style = mgCharacterLeftCss;
|
|
257
|
+
|
|
258
|
+
const mgFormCss = ".is-asterisk{color:hsl(var(--color-danger))}.mg-form,.mg-form-group{--mg-inputs-margin-bottom:1.5rem;--mg-inputs-title-horizontal-space:3rem;--mg-inputs-title-width:15rem;--mg-inputs-shrink:0}.mg-form.mg-form--all-required,.mg-form-group.mg-form--all-required{--mg-input-title-display:none}.mg-form>p,.mg-form-group>p{font-size:1.2rem}";
|
|
259
|
+
|
|
260
|
+
const MgForm = class {
|
|
261
|
+
constructor(hostRef) {
|
|
262
|
+
index.registerInstance(this, hostRef);
|
|
263
|
+
this.formValid = index.createEvent(this, "form-valid", 7);
|
|
264
|
+
/**
|
|
265
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
266
|
+
* If not set, it will be created.
|
|
267
|
+
*/
|
|
268
|
+
this.identifier = index$1.createID('mg-form');
|
|
269
|
+
/**
|
|
270
|
+
* Input name
|
|
271
|
+
* If not set the value equals the identifier
|
|
272
|
+
*/
|
|
273
|
+
this.name = this.identifier;
|
|
274
|
+
/**
|
|
275
|
+
* Define if form is readonly
|
|
276
|
+
*/
|
|
277
|
+
this.readonly = false;
|
|
278
|
+
/**
|
|
279
|
+
* Define if form is disabled
|
|
280
|
+
*/
|
|
281
|
+
this.disabled = false;
|
|
282
|
+
/**
|
|
283
|
+
* Component classes
|
|
284
|
+
*/
|
|
285
|
+
this.classList = new index$1.ClassList(['mg-form']);
|
|
286
|
+
/**
|
|
287
|
+
* Define required message based on mg-inputs required elements
|
|
288
|
+
* Also
|
|
289
|
+
*
|
|
290
|
+
* @returns {void}
|
|
291
|
+
*/
|
|
292
|
+
this.setRequiredMessage = () => {
|
|
293
|
+
// Get required fields
|
|
294
|
+
const requiredInputs = this.mgInputs.filter(input => input.required && !input.disabled && !this.disabled);
|
|
295
|
+
// All fields are required
|
|
296
|
+
// mg-input-toggle can not be required
|
|
297
|
+
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
298
|
+
this.requiredMessage = this.messages.form.allRequired;
|
|
299
|
+
this.classList.add('mg-form--all-required');
|
|
300
|
+
}
|
|
301
|
+
// Some fields are required
|
|
302
|
+
else if (requiredInputs.length > 0) {
|
|
303
|
+
this.requiredMessage = this.messages.form.required;
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Check if form is valid
|
|
308
|
+
*
|
|
309
|
+
* @returns {void}
|
|
310
|
+
*/
|
|
311
|
+
this.checkValidity = () => {
|
|
312
|
+
const validity = !this.mgInputs.some(input => input.invalid);
|
|
313
|
+
this.valid = validity;
|
|
314
|
+
this.invalid = !validity;
|
|
315
|
+
this.formValid.emit(validity);
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Public method to display errors
|
|
320
|
+
*
|
|
321
|
+
* @returns {Promise<void>}
|
|
322
|
+
*/
|
|
323
|
+
async displayError() {
|
|
324
|
+
if (!this.readonly) {
|
|
325
|
+
this.mgInputs.forEach(input => {
|
|
326
|
+
input.displayError && input.displayError();
|
|
327
|
+
});
|
|
328
|
+
this.checkValidity();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/*************
|
|
332
|
+
* Lifecycle *
|
|
333
|
+
*************/
|
|
334
|
+
/**
|
|
335
|
+
* Check if component props are well configured on init
|
|
336
|
+
*
|
|
337
|
+
* @returns {void}
|
|
338
|
+
*/
|
|
339
|
+
componentWillLoad() {
|
|
340
|
+
// Get locales
|
|
341
|
+
this.messages = index$1.initLocales(this.element).messages;
|
|
342
|
+
// Get slotted mgIputs
|
|
343
|
+
this.mgInputs = Array.from(this.element.querySelectorAll('*')).filter((node) => node.nodeName.startsWith('MG-INPUT-'));
|
|
344
|
+
// Define required message
|
|
345
|
+
this.setRequiredMessage();
|
|
346
|
+
// Check validity when slotted mgImputs are ready
|
|
347
|
+
Promise.all(this.mgInputs.map(async (input) => {
|
|
348
|
+
// Set inputs readonly or disabled based on form configuration
|
|
349
|
+
// Othewise listen to events
|
|
350
|
+
if (this.readonly)
|
|
351
|
+
input.readonly = true;
|
|
352
|
+
else if (this.disabled)
|
|
353
|
+
input.disabled = true;
|
|
354
|
+
else
|
|
355
|
+
input.addEventListener('input-valid', this.checkValidity);
|
|
356
|
+
await input.componentOnReady();
|
|
357
|
+
})).then(() => {
|
|
358
|
+
this.checkValidity();
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Render
|
|
363
|
+
*
|
|
364
|
+
* @returns {HTMLElement} HTML Element
|
|
365
|
+
*/
|
|
366
|
+
render() {
|
|
367
|
+
return (index.h("form", { class: this.classList.join(), id: this.identifier, name: this.name }, this.requiredMessage && index.h("p", { innerHTML: this.requiredMessage }), index.h("slot", null), !this.readonly && !this.disabled && index.h("slot", { name: "actions" })));
|
|
368
|
+
}
|
|
369
|
+
get element() { return index.getElement(this); }
|
|
370
|
+
};
|
|
371
|
+
MgForm.style = mgFormCss;
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Icon SVG paths
|
|
375
|
+
*/
|
|
376
|
+
const icons = {
|
|
377
|
+
'address-card': () => (index.h("path", { fill: "currentColor", d: "M14.21 2.67H1.79c-.63 0-1.14.51-1.14 1.14v8.38c0 .63.51 1.14 1.14 1.14h12.42c.63 0 1.14-.51 1.14-1.14V3.81c0-.63-.51-1.14-1.14-1.14ZM5.35 5c.84 0 1.53.69 1.53 1.53 0 .84-.69 1.53-1.53 1.53-.84 0-1.53-.69-1.53-1.53v-.05c.02-.83.7-1.49 1.53-1.48ZM8 10.59a.5.5 0 0 1-.53.46H3.21a.5.5 0 0 1-.53-.46v-.46c.07-.81.78-1.42 1.6-1.37h.12c.61.26 1.29.26 1.9 0h.12c.81-.04 1.51.56 1.58 1.37v.46Zm5.34-1.26c0 .1-.09.19-.19.19H9.73c-.1 0-.18-.07-.19-.17V9c0-.1.09-.19.19-.19h3.43c.1 0 .18.09.19.19v.33Zm0-1.52c0 .1-.09.18-.19.19H9.73c-.1 0-.19-.09-.19-.19v-.38c0-.1.07-.18.17-.19h3.45c.1 0 .19.09.19.19v.38Zm0-1.52c0 .1-.09.18-.19.19H9.73c-.1 0-.19-.09-.19-.19V5.9c0-.1.09-.19.19-.19h3.43c.11 0 .19.09.19.2v.38Z" })),
|
|
378
|
+
'align-center': () => (index.h("path", { fill: "currentColor", d: "M13.88 5.29H2.12c-.25 0-.45.2-.45.45v.9c0 .25.2.45.45.45h11.76c.25 0 .45-.2.45-.45v-.9c0-.25-.2-.45-.45-.45Zm0 7.24H2.12c-.25 0-.45.2-.45.45v.9c0 .25.2.45.45.45h11.76c.25 0 .45-.2.45-.45v-.9c0-.25-.2-.45-.45-.45ZM4.72 3.48h6.55c.19 0 .34-.15.34-.34V2.01c0-.19-.15-.34-.34-.34H4.72c-.19 0-.34.15-.34.34v1.13c0 .19.15.34.34.34Zm6.55 7.24c.19 0 .34-.15.34-.34V9.25c0-.19-.15-.34-.34-.34H4.72c-.19 0-.34.15-.34.34v1.13c0 .19.15.34.34.34h6.55Z" })),
|
|
379
|
+
'align-justify': () => (index.h("path", { fill: "currentColor", d: "M13.88 12.52H2.12c-.25 0-.45.21-.45.46v.9c0 .25.2.45.45.45h11.76c.25 0 .45-.2.45-.45V13a.466.466 0 0 0-.44-.48h-.01Zm0-3.62H2.12c-.25 0-.45.21-.45.46v.9c0 .25.2.45.45.45h11.76c.25 0 .45-.2.45-.45v-.9c0-.25-.2-.45-.45-.46Zm0-3.61H2.12c-.25 0-.45.2-.45.45v.9c0 .25.2.45.45.46h11.76c.25 0 .45-.21.45-.46v-.9c0-.25-.2-.45-.45-.45Zm0-3.62H2.12c-.25 0-.45.2-.45.45V3c0 .25.2.45.45.46h11.76c.25 0 .45-.21.45-.46v-.9a.45.45 0 0 0-.45-.43Z" })),
|
|
380
|
+
'align-left': () => (index.h("path", { fill: "currentColor", d: "M2 10.71h7.45c.2 0 .36-.16.36-.36V9.27c0-.2-.16-.36-.36-.37H2c-.2 0-.36.17-.36.37v1.08c0 .2.16.36.36.36Zm0-7.23h7.45c.2 0 .36-.17.36-.37V2c0-.2-.16-.36-.36-.36H2a.36.36 0 0 0-.33.36v1.11c0 .19.14.35.33.37Zm11.88 1.81H2.12c-.25 0-.45.2-.45.45v.9c0 .25.2.45.45.46h11.76c.25 0 .45-.21.45-.46v-.9c0-.25-.2-.45-.45-.45Zm0 7.23H2.12c-.25 0-.45.21-.45.46v.9c0 .25.2.45.45.45h11.76c.25 0 .45-.2.45-.45V13c0-.25-.2-.45-.45-.46v-.02Z" })),
|
|
381
|
+
'align-right': () => (index.h("path", { fill: "currentColor", d: "M2.12 7.1h11.76c.25 0 .45-.21.45-.46v-.9c0-.25-.2-.45-.45-.45H2.12c-.25 0-.45.2-.45.45v.9c0 .25.2.45.45.46Zm11.76 5.42H2.12c-.25 0-.45.21-.45.46v.9c0 .25.2.45.45.45h11.76c.25 0 .45-.2.45-.45V13a.466.466 0 0 0-.44-.48h-.01ZM14 1.67H6.55a.36.36 0 0 0-.36.33v1.11c0 .2.16.36.36.37H14c.2 0 .36-.17.36-.37V2a.36.36 0 0 0-.36-.33Zm0 7.23H6.55c-.2 0-.36.17-.36.37v1.08c0 .2.16.36.36.36H14c.2 0 .36-.16.36-.36V9.27c0-.2-.16-.36-.36-.37Z" })),
|
|
382
|
+
'api': () => (index.h("path", { fill: "currentColor", d: "M14.44 11.47h-.02l-.66-.1-.02-.08c-.03-.11-.08-.21-.13-.31l-.04-.07.4-.54v-.02l-.52-.52h-.02l-.54.41-.07-.04c-.1-.05-.2-.09-.31-.13l-.08-.02-.1-.67v-.01h-.73v.02l-.1.66-.08.02c-.11.03-.21.08-.31.13l-.07.04-.55-.41-.52.52v.02l.41.54-.04.07c-.05.1-.09.2-.13.31l-.02.08-.67.1h-.01v.73h.02l.66.1.02.08c.03.1.08.21.13.3l.04.07-.41.55.52.52h.02l.54-.41.07.04c.1.05.2.09.31.13l.08.02.1.67v.01h.73v-.02l.1-.66.08-.02c.11-.03.21-.08.31-.13l.07-.04.55.41.52-.52v-.02l-.4-.54.04-.07c.05-.1.09-.2.13-.31l.02-.08.67-.1h.01v-.73Zm-2.46 1.38c-.56 0-1.01-.45-1.01-1.01s.45-1.01 1.01-1.01 1.01.45 1.01 1.01-.45 1.01-1.01 1.01ZM8.51 5.81c-.11-.09-.27-.14-.5-.14h-.38v1.17h.27c.26 0 .45-.05.58-.15.13-.1.19-.25.19-.44s-.05-.34-.16-.43Zm1.57 5.13-.3-.4c-.1-.1-.09-.27 0-.37l.52-.52c.1-.1.26-.1.37 0l.4.29c.06-.03.13-.06.2-.08l.07-.49c0-.14.12-.25.26-.25h.45a5.44 5.44 0 1 0-10.5-1.99 5.44 5.44 0 0 0 5.44 5.44c.78 0 1.54-.17 2.25-.49v-.6c0-.14.11-.26.26-.26l.49-.07c.02-.07.05-.13.08-.2Zm.18-5.96h.84v3.94h-.84V4.98ZM5.4 8.92l-.29-.94H3.67l-.29.94h-.9l1.39-3.96h1.02l1.4 3.96h-.9Zm3.72-1.74c-.26.23-.64.34-1.13.34h-.36v1.4h-.84V4.98h1.26c.48 0 .84.1 1.09.31.25.21.37.51.37.92 0 .42-.13.75-.4.97ZM4.4 5.57c-.06.23-.23.8-.51 1.71h1.03c-.26-.85-.41-1.33-.45-1.44-.03-.11-.06-.2-.07-.26Z" })),
|
|
383
|
+
'arrow-down': () => (index.h("path", { fill: "currentColor", d: "M13,10.1H10.23a.31.31,0,0,1-.32-.28h0V.94A.3.3,0,0,0,9.59.65H6.37A.32.32,0,0,0,6,.94H6V9.81a.29.29,0,0,1-.31.29H3a.3.3,0,0,0-.31.29.27.27,0,0,0,.08.22l5.06,4.58a.36.36,0,0,0,.46,0l5-4.58a.29.29,0,0,0,0-.42C13.22,10.1,13.12,10.1,13,10.1Z" })),
|
|
384
|
+
'arrow-left': () => (index.h("path", { fill: "currentColor", d: "M5.88,12.93V10.18a.3.3,0,0,1,.28-.32H15a.31.31,0,0,0,.29-.33h0V6.32A.31.31,0,0,0,15,6H6.17a.32.32,0,0,1-.29-.31h0V2.93a.3.3,0,0,0-.28-.32.32.32,0,0,0-.23.09L.79,7.76a.36.36,0,0,0,0,.46l4.58,5a.31.31,0,0,0,.43,0A.4.4,0,0,0,5.88,12.93Z" })),
|
|
385
|
+
'arrow-right': () => (index.h("path", { fill: "currentColor", d: "M10.16,3V5.75a.3.3,0,0,1-.28.32H1a.31.31,0,0,0-.29.33h0V9.61A.31.31,0,0,0,1,9.94H9.87a.29.29,0,0,1,.29.31h0V13a.3.3,0,0,0,.28.32.32.32,0,0,0,.23-.09l4.58-5.06a.36.36,0,0,0,0-.46l-4.58-5a.3.3,0,0,0-.42,0C10.16,2.76,10.16,2.87,10.16,3Z" })),
|
|
386
|
+
'arrow-rotate': () => (index.h("path", { fill: "currentColor", d: "M8.02 1.67c-1.6 0-3.15.59-4.33 1.67a6.316 6.316 0 0 0-.38 8.94 6.324 6.324 0 0 0 8.94.37.29.29 0 0 0 0-.42l-1-1a.296.296 0 0 0-.41 0 4.302 4.302 0 0 1-5.76-.09 4.276 4.276 0 0 1-.21-6.06 4.276 4.276 0 0 1 6.06-.21L9.86 5.95c-.11.12-.18.27-.18.43 0 .34.28.62.62.62h3.44c.34-.01.6-.29.59-.63V2.94a.62.62 0 0 0-.18-.44.61.61 0 0 0-.85 0l-.91.91a6.37 6.37 0 0 0-4.38-1.75h.02Z" })),
|
|
387
|
+
'arrow-rotate-backward': () => (index.h("path", { fill: "currentColor", d: "M8 1.67c-1.63 0-3.2.63-4.38 1.75l-.91-.91a.6.6 0 0 0-.85-.01h-.01a.62.62 0 0 0-.18.44v3.43c-.01.34.25.62.59.63H5.7c.34 0 .62-.28.62-.62 0-.16-.07-.31-.18-.43L5.07 4.87a4.276 4.276 0 0 1 6.06.21 4.276 4.276 0 0 1-.21 6.06 4.302 4.302 0 0 1-5.76.09.296.296 0 0 0-.41 0l-1 1a.29.29 0 0 0 0 .42 6.324 6.324 0 0 0 8.94-.37 6.316 6.316 0 0 0-.38-8.94 6.365 6.365 0 0 0-4.33-1.67Z" })),
|
|
388
|
+
'arrow-up': () => (index.h("path", { fill: "currentColor", d: "M3.06,5.82H5.81a.31.31,0,0,1,.32.28h0V15a.31.31,0,0,0,.33.29H9.67A.3.3,0,0,0,10,15h0V6.11a.3.3,0,0,1,.31-.29h2.75a.3.3,0,0,0,.23-.51L8.23.73a.36.36,0,0,0-.46,0l-5,4.58a.3.3,0,0,0,0,.43C2.82,5.83,2.92,5.82,3.06,5.82Z" })),
|
|
389
|
+
'arrow-up-right-square': () => (index.h("path", { fill: "currentColor", d: "M14.33 3v10A1.34 1.34 0 0 1 13 14.33H3A1.34 1.34 0 0 1 1.67 13V3A1.34 1.34 0 0 1 3 1.67h10A1.34 1.34 0 0 1 14.33 3Zm-2.48.46H8.68a.67.67 0 0 0-.68.7.63.63 0 0 0 .2.47l.91.91-5.53 5.53a.33.33 0 0 0 0 .48l.87.87a.33.33 0 0 0 .48 0l5.53-5.52.91.9a.69.69 0 0 0 1 0 .71.71 0 0 0 .19-.48V4.15a.67.67 0 0 0-.67-.67Z" })),
|
|
390
|
+
'arrows-right-left': () => (index.h("path", { fill: "currentColor", d: "M.73,5.65V5.23a.64.64,0,0,1,.64-.64H12V3.31a.64.64,0,0,1,.64-.64.63.63,0,0,1,.45.18L15.19,5a.63.63,0,0,1,0,.9L13.05,8A.65.65,0,0,1,12,7.57V6.29H1.37a.64.64,0,0,1-.64-.64Zm14,4.06H4.09V8.43A.64.64,0,0,0,3,8L.87,10.11a.63.63,0,0,0,0,.9L3,13.15a.64.64,0,0,0,.91,0,.61.61,0,0,0,.18-.45V11.41H14.73a.63.63,0,0,0,.64-.64h0v-.42a.63.63,0,0,0-.64-.64Z" })),
|
|
391
|
+
'arrows-rotate': () => (index.h("path", { fill: "currentColor", d: "M14.3 6.37V2.94c0-.16-.06-.32-.18-.43a.6.6 0 0 0-.85 0l-.91.91a6.354 6.354 0 0 0-3.31-1.65 6.365 6.365 0 0 0-7.33 5.22h2.14c.16-.72.5-1.38 1-1.92v-.02a4.281 4.281 0 0 1 6.05-.18L9.84 6c-.1.1-.16.24-.18.38 0 .34.28.62.62.62h3.44c.33-.02.59-.3.58-.63ZM1.71 9.63v3.43c0 .16.06.32.18.43a.6.6 0 0 0 .85 0l.91-.91c.92.88 2.09 1.46 3.35 1.66 3.47.57 6.74-1.77 7.31-5.24h-2.14c-.17.74-.54 1.42-1.06 1.97a4.254 4.254 0 0 1-6.02.16l1.07-1.08c.11-.11.17-.27.17-.42A.63.63 0 0 0 5.72 9H2.28c-.33.03-.58.3-.57.63Z" })),
|
|
392
|
+
'arrows-rotate-backward': () => (index.h("path", { fill: "currentColor", d: "M2.3,7h3.4c0.3,0,0.6-0.3,0.6-0.6c0-0.1-0.1-0.3-0.2-0.4L5.1,4.9c1.7-1.6,4.4-1.5,6,0.2c0,0,0,0,0,0 c0.5,0.5,0.8,1.2,1,1.9h2.1C13.7,3.5,10.4,1.2,7,1.8C5.7,2,4.6,2.6,3.6,3.4L2.7,2.5c-0.2-0.2-0.6-0.2-0.8,0c0,0,0,0,0,0l0,0 C1.8,2.6,1.7,2.8,1.7,2.9v3.4C1.7,6.7,1.9,7,2.3,7z M13.7,9h-3.4C9.9,9,9.7,9.3,9.7,9.6c0,0.2,0.1,0.3,0.2,0.4l1.1,1.1 c-1.7,1.6-4.4,1.5-6-0.2C4.4,10.4,4,9.7,3.8,9H1.7c0.6,3.5,3.9,5.8,7.3,5.2c1.3-0.2,2.4-0.8,3.3-1.7l0.9,0.9c0.2,0.2,0.6,0.2,0.8,0 c0,0,0,0,0,0l0,0c0.1-0.1,0.2-0.3,0.2-0.4V9.6C14.3,9.3,14.1,9,13.7,9z" })),
|
|
393
|
+
'ban': () => (index.h("path", { fill: "currentColor", d: "M8 .67A7.33 7.33 0 1 0 15.33 8 7.33 7.33 0 0 0 8 .67Zm3.85 3.48a5.46 5.46 0 0 1 .61 7L4.88 3.54a5.46 5.46 0 0 1 6.97.61Zm-7.7 7.7a5.45 5.45 0 0 1-.61-7l7.58 7.58a5.46 5.46 0 0 1-7-.61Z" })),
|
|
394
|
+
'bell': () => (index.h("path", { fill: "currentColor", d: "M8 15.33a1.7 1.7 0 0 0 1.52-1.83h-3A1.7 1.7 0 0 0 8 15.33ZM13.13 11c-.46-.59-1.32-1.48-1.32-4.42a4.4 4.4 0 0 0-3.05-4.4v-.6A.85.85 0 0 0 8 .67a.85.85 0 0 0-.76.91v.6a4.4 4.4 0 0 0-3 4.44c0 2.94-.86 3.83-1.32 4.42a1 1 0 0 0-.2.63.85.85 0 0 0 .76.91h9.14a.85.85 0 0 0 .76-.91 1.05 1.05 0 0 0-.25-.67Z" })),
|
|
395
|
+
'briefcase': () => (index.h("path", { fill: "currentColor", d: "M13.93 4.33H11V2.07c0-.22-.18-.4-.4-.4H5.4c-.22 0-.4.18-.4.4v2.26H2.07c-.22 0-.4.18-.4.4v8.2c0 .22.18.4.4.4h11.86c.22 0 .4-.18.4-.4v-8.2c0-.22-.18-.4-.4-.4Zm-7.6 0V3h3.34v1.33H6.33Z" })),
|
|
396
|
+
'calculator': () => (index.h("path", { fill: "currentColor", d: "M12.83.67H3.17a.5.5 0 0 0-.5.5v13.66a.5.5 0 0 0 .5.5h9.66a.5.5 0 0 0 .5-.5V1.17a.5.5 0 0 0-.5-.5ZM5.58 13.39a.29.29 0 0 1-.28.3H4.1a.29.29 0 0 1-.3-.28v-1.2a.29.29 0 0 1 .28-.3h1.2a.29.29 0 0 1 .3.28v1.2Zm0-3.28a.29.29 0 0 1-.3.3H4.1a.29.29 0 0 1-.3-.3V8.93a.29.29 0 0 1 .28-.3h1.2a.29.29 0 0 1 .3.28v1.2Zm3.29 3.28a.29.29 0 0 1-.3.3H7.38a.29.29 0 0 1-.3-.3v-1.18a.29.29 0 0 1 .3-.3h1.19a.29.29 0 0 1 .3.3Zm0-3.28a.32.32 0 0 1-.3.3H7.38a.32.32 0 0 1-.3-.3V8.93a.29.29 0 0 1 .3-.3h1.19a.29.29 0 0 1 .3.3Zm3.33 3.28a.29.29 0 0 1-.28.3h-1.25a.29.29 0 0 1-.3-.28V8.93a.29.29 0 0 1 .28-.3h1.25a.29.29 0 0 1 .3.28v4.48Zm0-7.15a.29.29 0 0 1-.3.3H4.1a.29.29 0 0 1-.3-.3V2.61a.29.29 0 0 1 .28-.3h7.82a.29.29 0 0 1 .3.28v3.65Z" })),
|
|
397
|
+
'calendar': () => (index.h("path", { fill: "currentColor", d: "M14.52 4.43h-13V2.92a1.28 1.28 0 0 1 1.25-1.28h10.36A1.39 1.39 0 0 1 14.52 3Zm0 .93v7.91a1.41 1.41 0 0 1-1.4 1.4H2.88a1.41 1.41 0 0 1-1.4-1.4V5.36Zm-3.73 3.37a.35.35 0 0 0 .35.35h1.16a.34.34 0 0 0 .35-.35V7.57a.35.35 0 0 0-.35-.35h-1.16a.35.35 0 0 0-.35.35Zm-5.58 2.56a.35.35 0 0 0-.35-.35H3.7a.35.35 0 0 0-.35.35v1.17a.35.35 0 0 0 .35.35h1.16a.35.35 0 0 0 .35-.35Zm0-3.72a.35.35 0 0 0-.35-.35H3.7a.35.35 0 0 0-.35.35v1.16a.34.34 0 0 0 .35.35h1.16a.35.35 0 0 0 .35-.35Zm3.72 3.72a.35.35 0 0 0-.35-.35H7.42a.35.35 0 0 0-.35.35v1.17a.35.35 0 0 0 .35.35h1.16a.35.35 0 0 0 .35-.35Zm0-3.72a.35.35 0 0 0-.35-.35H7.42a.35.35 0 0 0-.35.35v1.16a.35.35 0 0 0 .35.35h1.16a.35.35 0 0 0 .35-.35Z" })),
|
|
398
|
+
'calendar-euro': () => (index.h("path", { fill: "currentColor", d: "M11.06 3.51h-1.04v.62a.2.2 0 0 1-.2.2H9.4c-.11 0-.21-.09-.21-.2v-.62H4.23v.62c0 .11-.09.2-.21.2h-.41c-.11 0-.21-.09-.21-.2v-.62H2.37c-.57 0-1.03.47-1.03 1.03v7.03c0 .57.47 1.03 1.03 1.03h5.3c-.25-.25-.46-.52-.63-.83H2.68a.53.53 0 0 1-.52-.52V6.61c0-.11.09-.21.21-.21h5.29a4.4 4.4 0 0 1 3.19-1.36c.43 0 .85.06 1.24.18v-.69c0-.57-.46-1.03-1.03-1.03Zm-6.83-.62c0-.11-.09-.21-.21-.21h-.41c-.11 0-.21.09-.21.21v.62h.83v-.62Zm5.79 0c0-.11-.09-.21-.21-.21H9.4c-.11 0-.21.09-.21.21v.62h.83v-.62Zm2.07 3c-.39-.13-.81-.21-1.24-.21-.83 0-1.6.26-2.23.73-.96.69-1.59 1.82-1.59 3.09 0 .86.28 1.65.77 2.29.23.32.52.6.85.83.62.45 1.38.71 2.2.71 2.11 0 3.82-1.72 3.82-3.82 0-1.67-1.08-3.09-2.58-3.61Zm.12 6.18c.01.07-.04.15-.11.16-.09.03-.2.04-.3.05-.14.03-.28.04-.43.04-.61.02-1.18-.18-1.63-.54-.41-.32-.73-.77-.88-1.29h-.37c-.08 0-.15-.06-.15-.15V10c0-.08.07-.14.15-.14h.26v-.5h-.26c-.08 0-.15-.06-.15-.14v-.37c0-.08.07-.14.15-.14h.4a2.576 2.576 0 0 1 2.37-1.7h.1c.22 0 .44.02.64.06.04.01.07.03.08.06.02.03.03.07.02.11l-.02.07-.13.46a.14.14 0 0 1-.17.1c-.15-.03-.3-.04-.45-.05h-.08c-.58.01-1.1.35-1.34.88h1.71c.08.02.12.09.11.17l-.08.36a.15.15 0 0 1-.15.11H9.73c-.01.16-.01.33 0 .5h1.66c.08.02.13.09.11.17l-.07.33c-.02.06-.08.11-.14.11H9.91c.21.56.72.94 1.3 1 .05 0 .1.01.15.01.19 0 .37-.03.55-.06.07-.02.14.03.16.09v.02l.11.52Z" })),
|
|
399
|
+
'check': () => (index.h("path", { fill: "currentColor", d: "m15.27 4.23-1.11-1.18c-.11-.1-.27-.1-.38 0L6 10.36l-3.76-4a.187.187 0 0 0-.26 0L.71 7.6c-.07.07-.07.19 0 .26l5.12 5.41c.07.07.18.07.25 0l1.3-1.23 7.87-7.45c.1-.1.11-.26.01-.37h.01Z" })),
|
|
400
|
+
'check-circle': () => (index.h("path", { fill: "currentColor", d: "M15.33 8A7.33 7.33 0 1 1 8 .67 7.33 7.33 0 0 1 15.33 8Zm-8.18 3.88 5.44-5.44a.46.46 0 0 0 0-.65l-.67-.67a.48.48 0 0 0-.67 0L6.82 9.54 4.75 7.47a.46.46 0 0 0-.65 0l-.67.67a.46.46 0 0 0 0 .65l3.07 3.07a.46.46 0 0 0 .65 0Z" })),
|
|
401
|
+
'chevron-down': () => (index.h("path", { fill: "currentColor", d: "M7.43,12.21.9,5.69a.81.81,0,0,1,0-1.14h0l.76-.77a.81.81,0,0,1,1.14,0L8,9l5.2-5.18a.81.81,0,0,1,1.14,0l.76.77a.8.8,0,0,1,0,1.13h0L8.57,12.21a.79.79,0,0,1-1.13,0Z" })),
|
|
402
|
+
'chevron-down-circle': () => (index.h("path", { fill: "currentColor", d: "M15.33 8A7.33 7.33 0 1 1 8 .67 7.33 7.33 0 0 1 15.33 8ZM8.5 11.37l4-4a.7.7 0 0 0 0-1l-.5-.52a.72.72 0 0 0-1 0l-3 3-3-3a.72.72 0 0 0-1 0l-.5.51a.7.7 0 0 0 0 1l4 4a.7.7 0 0 0 1 0Z" })),
|
|
403
|
+
'chevron-left': () => (index.h("path", { fill: "currentColor", d: "M3.79,7.43,10.31.9a.81.81,0,0,1,1.14,0h0l.77.76a.81.81,0,0,1,0,1.14L7,8l5.18,5.2a.81.81,0,0,1,0,1.14l-.77.76a.8.8,0,0,1-1.13,0h0L3.79,8.57a.79.79,0,0,1,0-1.13Z" })),
|
|
404
|
+
'chevron-left-circle': () => (index.h("path", { fill: "currentColor", d: "M8 15.33C3.95 15.33.67 12.05.67 8S3.95.67 8 .67 15.33 3.95 15.33 8c0 4.05-3.28 7.33-7.33 7.33ZM4.63 8.5l4 4c.27.28.71.28.99.01h.01l.52-.51c.27-.28.27-.72 0-1l-3-3 3-3c.27-.28.27-.72 0-1l-.51-.5a.697.697 0 0 0-.99-.01h-.01l-4 4.01c-.28.27-.28.71-.01.99Z" })),
|
|
405
|
+
'chevron-right': () => (index.h("path", { fill: "currentColor", d: "M12.21,8.57,5.69,15.1a.81.81,0,0,1-1.14,0h0l-.77-.76a.81.81,0,0,1,0-1.14L9,8,3.78,2.8a.81.81,0,0,1,0-1.14L4.55.9A.8.8,0,0,1,5.68.9h0l6.53,6.53a.79.79,0,0,1,0,1.13Z" })),
|
|
406
|
+
'chevron-right-circle': () => (index.h("path", { fill: "currentColor", d: "M8 .67c4.05 0 7.33 3.28 7.33 7.33S12.05 15.33 8 15.33.67 12.05.67 8C.67 3.95 3.95.67 8 .67Zm3.37 6.83-4-4a.697.697 0 0 0-.99-.01h-.01L5.85 4c-.27.28-.27.72 0 1l3 3-3 3c-.27.28-.27.72 0 1l.51.5c.27.28.71.28.99.01h.01l4-4.01c.28-.27.28-.71.01-.99Z" })),
|
|
407
|
+
'chevron-up': () => (index.h("path", { fill: "currentColor", d: "M8.57,3.79l6.53,6.52a.81.81,0,0,1,0,1.14h0l-.76.77a.81.81,0,0,1-1.14,0L8,7,2.8,12.22a.81.81,0,0,1-1.14,0L.9,11.45a.8.8,0,0,1,0-1.13h0L7.43,3.79a.79.79,0,0,1,1.13,0Z" })),
|
|
408
|
+
'chevron-up-circle': () => (index.h("path", { fill: "currentColor", d: "M.67 8C.67 3.95 3.95.67 8 .67S15.33 3.95 15.33 8 12.05 15.33 8 15.33C3.95 15.33.67 12.05.67 8ZM7.5 4.63l-4 4c-.28.27-.28.71-.01.99h.01l.5.53c.28.27.72.27 1 0l3-3 3 3c.28.27.72.27 1 0l.5-.51c.28-.27.28-.71.01-.99h-.01l-4-4.01a.697.697 0 0 0-.99-.01H7.5Z" })),
|
|
409
|
+
'clock': () => (index.h("path", { fill: "currentColor", d: "M8,.67C3.95,.67,.67,3.95,.67,8s3.28,7.33,7.33,7.33,7.33-3.28,7.33-7.33h0C15.33,3.95,12.05,.67,8,.67h0Zm1.69,10.33l-2.61-1.88c-.09-.07-.14-.17-.14-.28V3.84c0-.19,.16-.35,.35-.36h1.42c.2,0,.35,.16,.36,.36V7.93l1.87,1.37c.16,.1,.2,.32,.09,.47v.02h-.01l-.83,1.15c-.12,.15-.34,.18-.5,.06Z" })),
|
|
410
|
+
'conversation': () => (index.h("path", { fill: "currentColor", d: "M11.22,6.48c0-2.11-2.36-3.81-5.28-3.81S.67,4.37.67,6.48a3.15,3.15,0,0,0,1,2.19A5.17,5.17,0,0,1,.72,10a.2.2,0,0,0,0,.21.23.23,0,0,0,.19.12,4.79,4.79,0,0,0,2.25-.6,6.84,6.84,0,0,0,2.82.6C8.86,10.29,11.22,8.58,11.22,6.48Zm3.1,5.23a3.08,3.08,0,0,0,1-2.19C15.28,7.93,14,6.57,12,6a3.84,3.84,0,0,1,0,.48C12,9,9.3,11.05,6,11.05a7.16,7.16,0,0,1-.8-.05A5.6,5.6,0,0,0,10,13.33a6.7,6.7,0,0,0,2.82-.59,4.66,4.66,0,0,0,2.25.59.21.21,0,0,0,.19-.11.2.2,0,0,0,0-.21,5.15,5.15,0,0,1-.91-1.3Z" })),
|
|
411
|
+
'cog': () => (index.h("path", { fill: "currentColor", d: "M14.82 9.76 13.56 9a5.54 5.54 0 0 0 0-2.07l1.26-.72a.36.36 0 0 0 .18-.38A7.5 7.5 0 0 0 13.37 3a.35.35 0 0 0-.44 0l-1.26.72a5.51 5.51 0 0 0-1.79-1V1.21a.34.34 0 0 0-.27-.34 7.29 7.29 0 0 0-3.22 0 .34.34 0 0 0-.28.34v1.45a5.83 5.83 0 0 0-1.79 1L3.06 3a.35.35 0 0 0-.43 0A7.24 7.24 0 0 0 1 5.83a.34.34 0 0 0 .16.41L2.44 7a5.49 5.49 0 0 0 0 2l-1.26.73a.35.35 0 0 0-.16.41A7.24 7.24 0 0 0 2.63 13a.35.35 0 0 0 .43.07l1.26-.73a5.56 5.56 0 0 0 1.79 1v1.45a.35.35 0 0 0 .28.34 7.29 7.29 0 0 0 3.22 0 .35.35 0 0 0 .28-.34v-1.45a6 6 0 0 0 1.79-1l1.26.73a.35.35 0 0 0 .43-.07A7.39 7.39 0 0 0 15 10.17a.37.37 0 0 0-.17-.41Zm-6.82.6A2.36 2.36 0 1 1 10.35 8 2.36 2.36 0 0 1 8 10.36Z" })),
|
|
412
|
+
'comment': () => (index.h("path", { fill: "currentColor", d: "M8 1.67c-3.37-.12-6.21 2.51-6.33 5.88 0 1.36.5 2.68 1.41 3.69-.26 1-.72 1.94-1.36 2.76-.04.08-.04.17 0 .25.03.08.1.13.18.13 1.3-.03 2.54-.55 3.48-1.45.83.34 1.72.51 2.62.5 3.37.12 6.21-2.51 6.33-5.88-.12-3.37-2.96-6-6.33-5.88Zm2.53 8.43c0 .14-.11.25-.25.25H5.73c-.14 0-.25-.1-.26-.24V9.2c0-.17.13-.3.3-.31h4.5c.14 0 .26.12.26.26v.95Zm.92-3.29c0 .17-.13.3-.3.3h-6.3c-.17 0-.3-.13-.3-.3V6c0-.16.12-.29.28-.3H11.15c.16 0 .29.12.3.28V6.81Z" })),
|
|
413
|
+
'credit-card': () => (index.h("path", { fill: "currentColor", d: "M14 2.67H2A1.33 1.33 0 0 0 .67 4v8A1.32 1.32 0 0 0 2 13.33h12A1.32 1.32 0 0 0 15.33 12V4A1.32 1.32 0 0 0 14 2.67M14 12H2V8h12Zm0-6.67H2V4h12Z" })),
|
|
414
|
+
'cross': () => (index.h("path", { fill: "currentColor", d: "M14.26 12.74 9.52 8l4.7-4.7a.29.29 0 0 0 0-.41l-1.1-1.1a.29.29 0 0 0-.41 0L8 6.48 3.26 1.74a.24.24 0 0 0-.34 0L1.74 2.91a.24.24 0 0 0 0 .34L6.48 8l-4.7 4.7a.29.29 0 0 0 0 .41l1.1 1.1a.29.29 0 0 0 .41 0L8 9.52l4.74 4.74a.24.24 0 0 0 .34 0l1.17-1.17a.24.24 0 0 0 0-.34Z" })),
|
|
415
|
+
'cross-circle': () => (index.h("path", { fill: "currentColor", d: "M8.06.67H8A7.33 7.33 0 0 0 .68 8v.1a7.42 7.42 0 0 0 7.23 7.23A7.33 7.33 0 1 0 8.06.67Zm3.6 9.57a.28.28 0 0 1 0 .4l-.19.2-.61.61-.2.19a.27.27 0 0 1-.39 0L8 9.41l-2.23 2.24a.27.27 0 0 1-.39 0l-.2-.2-.6-.6-.19-.2a.28.28 0 0 1 0-.4L6.6 8 4.36 5.76a.28.28 0 0 1 0-.4l1-1a.28.28 0 0 1 .4 0L8 6.59l2.24-2.24a.28.28 0 0 1 .4 0l.2.2.6.6.2.2a.28.28 0 0 1 0 .4L9.42 8Z" })),
|
|
416
|
+
'download': () => (index.h("path", { fill: "currentColor", d: "M6.4 2v4.1c0 .2-.1.3-.3.3H4c-.2 0-.3.1-.3.3 0 .1 0 .2.1.2l4 4c.1.1.3.1.4 0l4-4c.1-.1.1-.3 0-.4-.1-.1-.1-.1-.2-.1H9.9c-.2 0-.3-.1-.3-.3V2c0-.2-.1-.3-.3-.3H6.7c-.1 0-.3.1-.3.3zm7.9 11v1c0 .2-.1.3-.3.3H2c-.2 0-.3-.1-.3-.3v-1c0-.2.1-.3.3-.3h12c.2 0 .3.1.3.3z" })),
|
|
417
|
+
'euro': () => (index.h("path", { fill: "currentColor", d: "M13 13.14a.4.4 0 0 0-.47-.31A7.79 7.79 0 0 1 11 13a4.31 4.31 0 0 1-4-2.79h3.8a.41.41 0 0 0 .39-.31l.19-.9a.39.39 0 0 0-.3-.47H6.51a7.07 7.07 0 0 1 0-1.38h4.89a.4.4 0 0 0 .39-.31l.22-1a.4.4 0 0 0-.3-.47H7a4.2 4.2 0 0 1 3.92-2.45 6.57 6.57 0 0 1 1.26.14.41.41 0 0 0 .47-.29l.4-1.45a.4.4 0 0 0-.28-.48A9.43 9.43 0 0 0 11 .67a7.12 7.12 0 0 0-6.83 4.7h-1.1a.4.4 0 0 0-.4.39v1a.4.4 0 0 0 .4.39h.72a9.08 9.08 0 0 0 0 1.38h-.72a.39.39 0 0 0-.4.39v.93a.4.4 0 0 0 .4.39h1A7 7 0 0 0 11 15.3a8.7 8.7 0 0 0 2-.25.39.39 0 0 0 .3-.46l-.3-1.45Z" })),
|
|
418
|
+
'exclamation-circle': () => (index.h("path", { fill: "currentColor", d: "M8 15.33c4.05 0 7.33-3.28 7.33-7.33S12.05.67 8 .67.67 3.95.67 8 3.95 15.33 8 15.33Zm.95-3.3c0 .15-.12.27-.28.27h-1.4c-.15 0-.28-.12-.28-.27v-1.31c0-.15.12-.28.28-.28h1.4c.15 0 .28.12.28.28v1.31ZM7 3.96c0-.14.11-.25.25-.25H8.7c.14 0 .25.11.25.25v4.8c0 .14-.11.25-.25.25H7.25c-.14 0-.25-.11-.25-.25V3.95Z" })),
|
|
419
|
+
'exclamation-triangle': () => (index.h("path", { fill: "currentColor", d: "m14.3 13.88-6-12a.32.32 0 0 0-.41-.15.31.31 0 0 0-.15.15l-6 12a.31.31 0 0 0 .14.42.32.32 0 0 0 .14 0H14a.31.31 0 0 0 .33-.29.23.23 0 0 0-.03-.13ZM7 6a.28.28 0 0 1 .28-.28h1.46A.28.28 0 0 1 9 6v4a.29.29 0 0 1-.28.29H7.3A.29.29 0 0 1 7 10Zm2 7a.31.31 0 0 1-.31.32H7.34A.32.32 0 0 1 7 13v-1.37a.31.31 0 0 1 .32-.31h1.39a.31.31 0 0 1 .31.31Z" })),
|
|
420
|
+
'eye': () => [
|
|
421
|
+
index.h("circle", { fill: "currentColor", cx: "8.01", cy: "7.96", r: "2.44" }),
|
|
422
|
+
index.h("path", { fill: "currentColor", d: "M15.24 7.59A8.12 8.12 0 0 0 8 2.67 8.12 8.12 0 0 0 .76 7.59a1 1 0 0 0 0 .82A8.12 8.12 0 0 0 8 13.33a8.12 8.12 0 0 0 7.24-4.92 1 1 0 0 0 0-.82ZM8 11.62A3.66 3.66 0 1 1 11.67 8 3.66 3.66 0 0 1 8 11.62Z" }),
|
|
423
|
+
],
|
|
424
|
+
'eye-slash': () => [
|
|
425
|
+
index.h("path", { fill: "currentColor", d: "M10.25 7a2.43 2.43 0 0 0-2.08-1.46ZM6.45 6.1a2.43 2.43 0 1 0 3.85 2.69Z" }),
|
|
426
|
+
index.h("path", { fill: "currentColor", d: "M15.24 7.59A8.13 8.13 0 0 0 8 2.67a8.06 8.06 0 0 0-2.89.64l1.72 1.2A3.58 3.58 0 0 1 8 4.3a3.65 3.65 0 0 1 3.64 3.6l2.77 1.93a7.91 7.91 0 0 0 .81-1.42 1 1 0 0 0 .02-.82ZM.81 3.84 2.51 5A8.16 8.16 0 0 0 .76 7.59a1 1 0 0 0 0 .82A8.13 8.13 0 0 0 8 13.33a8 8 0 0 0 4.32-1.4l2 1.38.81-1.17-13.5-9.47ZM8 11.62A3.66 3.66 0 0 1 4.35 8a3.75 3.75 0 0 1 .29-1.42l5.85 4.11a3.65 3.65 0 0 1-2.49.93Z" }),
|
|
427
|
+
],
|
|
428
|
+
'file': () => [
|
|
429
|
+
index.h("path", { fill: "currentColor", d: "M8.89 4.56V.67H3.35a.66.66 0 0 0-.66.68v13.3a.67.67 0 0 0 .66.68h9.3a.66.66 0 0 0 .66-.68v-9.4H9.55a.67.67 0 0 1-.66-.69Z" }),
|
|
430
|
+
index.h("path", { fill: "currentColor", d: "M13.12 3.67 10.41.87a.63.63 0 0 0-.47-.2h-.17v3.66h3.54v-.17a.69.69 0 0 0-.19-.49Z" }),
|
|
431
|
+
],
|
|
432
|
+
'file-cog': () => (index.h("path", { fill: "currentColor", d: "M9,10.1C9,10.6,8.5,11,8,11l0,0c-0.6,0-1-0.4-1-1c0-0.6,0.4-1,1-1C8.6,9,9,9.4,9,10.1C9,10,9,10,9,10.1z M13.2,3.7l-2.8-2.8c-0.1-0.1-0.3-0.2-0.5-0.2H9.8v3.7h3.5V4.2C13.3,4,13.2,3.8,13.2,3.7L13.2,3.7z M9.6,5.3h3.8v9.4 c0,0.4-0.3,0.6-0.7,0.7H3.3c-0.4,0-0.7-0.3-0.7-0.7c0,0,0,0,0,0V1.3C2.7,1,3,0.7,3.3,0.7h5.5v3.9l0,0C8.9,4.9,9.2,5.2,9.6,5.3 C9.5,5.2,9.5,5.2,9.6,5.3z M10,8L9.5,8.3C9.3,8.1,9,8,8.8,7.9V7.3c0-0.1,0-0.1-0.1-0.1c-0.4-0.1-0.9-0.1-1.3,0 c-0.1,0-0.1,0.1-0.1,0.1v0.6C7,8,6.7,8.1,6.5,8.3L6,8C5.9,8,5.9,8,5.8,8C5.5,8.3,5.3,8.7,5.2,9.1c0,0.1,0,0.1,0.1,0.2l0.5,0.3 c-0.1,0.3-0.1,0.6,0,0.8l-0.5,0.3c-0.1,0-0.1,0.1-0.1,0.2c0.1,0.4,0.4,0.8,0.7,1.1c0.1,0,0.1,0,0.2,0l0.5-0.3 C6.7,11.9,7,12,7.2,12.1v0.6c0,0.1,0,0.1,0.1,0.1c0.4,0.1,0.9,0.1,1.3,0c0.1,0,0.1-0.1,0.1-0.1v-0.5C9,12.1,9.3,12,9.5,11.8l0.5,0.3 c0.1,0,0.1,0,0.2,0c0.3-0.3,0.5-0.7,0.6-1.1c0-0.1,0-0.1-0.1-0.2l0,0l-0.5-0.3c0-0.3,0-0.6,0-0.8l0.5-0.3c0.1,0,0.1-0.1,0.1-0.2 c-0.1-0.4-0.4-0.8-0.6-1.1C10.1,8,10.1,8,10,8z" })),
|
|
433
|
+
'file-download': () => [
|
|
434
|
+
index.h("path", { fill: "currentColor", d: "M13.12 3.67 10.41.87a.63.63 0 0 0-.47-.2h-.17v3.66h3.54v-.17a.69.69 0 0 0-.19-.49Z" }),
|
|
435
|
+
index.h("path", { fill: "currentColor", d: "M13.31 14.65v-9.4H9.55a.67.67 0 0 1-.66-.68V.67H3.35a.67.67 0 0 0-.66.66v13.32a.67.67 0 0 0 .66.68h9.3a.67.67 0 0 0 .66-.66Zm-2.91-4.24-2.54 2.53a.18.18 0 0 1-.26 0l-2.54-2.53a.2.2 0 0 1-.06-.15.18.18 0 0 1 .19-.18h1.34a.2.2 0 0 0 .2-.2V7.27a.19.19 0 0 1 .19-.18h1.63a.18.18 0 0 1 .18.19v2.6a.2.2 0 0 0 .2.2h1.34a.16.16 0 0 1 .14.06.19.19 0 0 1-.01.27Z" }),
|
|
436
|
+
],
|
|
437
|
+
'file-excel': () => (index.h("path", { fill: "currentColor", d: "M8.89 4.43V.67H3.35a.65.65 0 0 0-.66.66v13.34a.65.65 0 0 0 .66.66h9.3a.65.65 0 0 0 .66-.66V5.09H9.55a.65.65 0 0 1-.66-.66Zm1.66 3.2-1.66 2.58 1.66 2.59a.34.34 0 0 1-.1.46.31.31 0 0 1-.18.05h-1a.32.32 0 0 1-.27-.17c-.54-1-1-1.9-1-1.9-.18.41-.28.55-1 1.9a.33.33 0 0 1-.29.18h-1A.34.34 0 0 1 5.4 13a.41.41 0 0 1 0-.18l1.67-2.58-1.62-2.61a.34.34 0 0 1 .1-.46.37.37 0 0 1 .18 0h1a.33.33 0 0 1 .3.17c.72 1.35.55.93 1 1.9 0 0 .17-.33 1-1.9a.33.33 0 0 1 .3-.17h1a.33.33 0 0 1 .33.33.41.41 0 0 1-.11.13ZM13.31 4v.17H9.77V.67h.17a.67.67 0 0 1 .47.19l2.71 2.71a.66.66 0 0 1 .19.43Z" })),
|
|
438
|
+
'file-pdf': () => (index.h("path", { fill: "currentColor", d: "M7.74 8a2.68 2.68 0 0 1-.06-1.3c.24 0 .21 1.02.06 1.3Zm0 1.31a12.5 12.5 0 0 1-.79 1.75 9.8 9.8 0 0 1 1.75-.61 3.63 3.63 0 0 1-1.01-1.14Zm-2.66 3.47s.36-.15 1-1.12a3.71 3.71 0 0 0-1 1.12Zm4.49-7.67h3.78v9.56a.65.65 0 0 1-.66.66H3.31a.66.66 0 0 1-.66-.66V1.33a.65.65 0 0 1 .7-.66h5.56v3.77a.67.67 0 0 0 .66.67Zm-.22 5a2.78 2.78 0 0 1-1.18-1.5 4 4 0 0 0 .17-1.78.7.7 0 0 0-.78-.6.69.69 0 0 0-.56.41 4.58 4.58 0 0 0 .23 2.14 26 26 0 0 1-1.13 2.38c-.76.39-2 1.24-1.52 1.89a.87.87 0 0 0 .6.28c.5 0 1-.5 1.7-1.72A15.24 15.24 0 0 1 9.07 11a4.34 4.34 0 0 0 1.78.54.72.72 0 0 0 .74-.7.78.78 0 0 0-.19-.51c-.4-.4-1.51-.33-2.05-.23Zm3.81-6.53L10.44.86A.71.71 0 0 0 10 .67h-.2v3.55h3.55v-.17a.7.7 0 0 0-.19-.47ZM11.1 10.9c.11-.08-.07-.33-1.19-.25 1.03.44 1.19.25 1.19.25Z" })),
|
|
439
|
+
'file-text': () => (index.h("path", { fill: "currentColor", d: "M8.89 4.56V.67H3.35c-.36 0-.66.3-.66.66v13.32c0 .37.29.67.66.68h9.3c.36 0 .66-.3.66-.66V5.25H9.55c-.37 0-.67-.31-.66-.68Zm1.77 6.75c0 .19-.15.34-.34.35H5.68c-.19 0-.34-.16-.34-.35v-.23c0-.19.15-.34.34-.34h4.64c.19 0 .34.15.34.34v.23Zm0-1.83c0 .19-.15.34-.34.34H5.68c-.19 0-.34-.15-.34-.34v-.23c0-.19.15-.34.34-.34h4.64c.19 0 .34.15.34.34v.23Zm0-2.06v.23c0 .19-.15.34-.34.34H5.68c-.19 0-.34-.15-.34-.34v-.23c0-.19.15-.34.34-.35h4.64c.19 0 .34.16.34.35Zm2.65-3.27v.17H9.77V.67h.17c.18 0 .35.07.47.2l2.71 2.8c.13.13.19.31.19.49Z" })),
|
|
440
|
+
'file-text-outline': () => (index.h("path", { fill: "currentColor", d: "M10.31 10.74H5.69c-.2 0-.36.16-.36.35v.22c0 .19.16.35.36.35h4.62c.2 0 .36-.16.36-.35v-.22c0-.19-.16-.35-.36-.35Zm0-1.84H5.69c-.2 0-.36.16-.36.36v.21c0 .2.16.35.36.35h4.62c.2 0 .36-.15.36-.35v-.21c0-.2-.16-.36-.36-.36Zm0-1.83H5.69c-.2 0-.36.16-.36.35v.22c0 .19.16.35.36.35h4.62c.2 0 .36-.16.36-.35v-.22c0-.19-.16-.35-.36-.35Zm0 3.67H5.69c-.2 0-.36.16-.36.35v.22c0 .19.16.35.36.35h4.62c.2 0 .36-.16.36-.35v-.22c0-.19-.16-.35-.36-.35Zm0-1.84H5.69c-.2 0-.36.16-.36.36v.21c0 .2.16.35.36.35h4.62c.2 0 .36-.15.36-.35v-.21c0-.2-.16-.36-.36-.36Zm0-1.83H5.69c-.2 0-.36.16-.36.35v.22c0 .19.16.35.36.35h4.62c.2 0 .36-.16.36-.35v-.22c0-.19-.16-.35-.36-.35Zm2.76-2.64L9.69.92A.8.8 0 0 0 9.1.67H3.35c-.36 0-.66.3-.66.66v13.32c0 .37.29.67.66.68h9.3c.36 0 .66-.3.66-.66V5.05c0-.23-.07-.45-.24-.62Zm-.76 9.9H3.69V1.67h5.2v2.75c0 .46.37.83.83.83h2.59v9.08Z" })),
|
|
441
|
+
'file-upload': () => [
|
|
442
|
+
index.h("path", { fill: "currentColor", d: "M13.1 3.7 10.4.9c-.1-.1-.3-.2-.5-.2h-.1v3.7h3.5v-.2c0-.2-.1-.4-.2-.5z" }),
|
|
443
|
+
index.h("path", { fill: "currentColor", d: "M13.3 14.6V5.3H9.6c-.4 0-.7-.3-.7-.7V.7H3.3c-.3 0-.6.3-.6.6v13.3c0 .4.3.7.7.7h9.3c.3 0 .6-.3.6-.7zm-3-4.6H8.9c-.1 0-.2.1-.2.2v2.6c0 .1-.1.2-.2.2H6.9c-.1 0-.2-.1-.2-.2v-2.6c0-.1-.1-.2-.2-.2H5.1C5 9.9 5 9.8 5 9.7l2.5-2.6c.1-.1.2-.1.3 0l2.5 2.5.1.1c.1.2 0 .3-.1.3z" }),
|
|
444
|
+
],
|
|
445
|
+
'filter': () => (index.h("path", { fill: "currentColor", d: "M13.74 1.66H2.26a.6.6 0 0 0-.59.6.59.59 0 0 0 .17.42l4.58 4.58v5.1a.58.58 0 0 0 .25.48l2 1.39a.6.6 0 0 0 .83-.15.59.59 0 0 0 .1-.34V7.26l4.58-4.58a.6.6 0 0 0 0-.84.64.64 0 0 0-.44-.18Z" })),
|
|
446
|
+
'floppy-disk': () => (index.h("path", { fill: "currentColor", d: "m13.93 4.44-2.37-2.37c-.25-.25-.6-.4-.96-.4H3.03c-.75 0-1.36.61-1.36 1.36v9.94c0 .75.61 1.36 1.36 1.36h9.94c.75 0 1.36-.61 1.36-1.36V5.4c0-.36-.14-.7-.4-.96ZM8 12.52A1.81 1.81 0 1 1 8 8.9a1.81 1.81 0 0 1 0 3.62Zm2.71-5.77c0 .09-.04.18-.1.24a.35.35 0 0 1-.24.1H3.82c-.19 0-.34-.15-.34-.34V3.82c0-.19.15-.34.34-.34h6.55c.19 0 .34.15.34.34v2.93Z" })),
|
|
447
|
+
'folder': () => (index.h("path", { fill: "currentColor", d: "M14 4.44H8.46L6.62 2.67H2C1.27 2.67.68 3.27.67 4v8c0 .73.6 1.32 1.33 1.33h12c.73 0 1.32-.6 1.33-1.33V5.78c0-.73-.6-1.33-1.33-1.34Z" })),
|
|
448
|
+
'folder-lines': () => (index.h("path", { fill: "currentColor", d: "M14 4.44H8.46L6.62 2.67H2A1.35 1.35 0 0 0 .67 4v8A1.35 1.35 0 0 0 2 13.33h12A1.35 1.35 0 0 0 15.33 12V5.78A1.36 1.36 0 0 0 14 4.44Zm-4.57 6.38a.2.2 0 0 1-.2.2H3.41a.2.2 0 0 1-.2-.2v-.9a.2.2 0 0 1 .2-.2h5.82a.2.2 0 0 1 .2.2Zm3.36-2.95a.2.2 0 0 1-.2.2H3.42a.2.2 0 0 1-.2-.2V7a.2.2 0 0 1 .2-.2h9.17a.2.2 0 0 1 .2.2Z" })),
|
|
449
|
+
'folder-link': () => (index.h("path", { fill: "currentColor", d: "M14 4.44H8.46L6.62 2.67H2C1.27 2.67.68 3.27.67 4v8c0 .73.6 1.32 1.33 1.33h12c.73 0 1.32-.6 1.33-1.33V5.78c0-.73-.6-1.33-1.33-1.34Zm-6.82 6.88H5.65c-1.34 0-2.42-1.08-2.42-2.42 0-1.34 1.08-2.42 2.42-2.42h.84c.14 0 .25.11.25.25 0 .06-.02.13-.06.17-.2.21-.36.45-.49.71-.04.07-.11.13-.19.14h-.33c-.62-.15-1.24.22-1.39.84-.15.62.22 1.24.84 1.39.15.04.31.04.47.02h1.58c.62 0 1.12-.48 1.15-1.1v-.22c-.02-.08 0-.16.06-.22.12-.13.29-.2.47-.2h.45c.12 0 .23.09.25.21.02.14.02.29 0 .43 0 1.32-1.05 2.39-2.37 2.42Zm3.17 0h-.84c-.06 0-.13-.02-.17-.07-.1-.1-.1-.25 0-.35.2-.21.36-.45.49-.71.02-.09.08-.16.17-.19h.36c.63.04 1.18-.43 1.23-1.07.04-.63-.43-1.18-1.07-1.23H8.83c-.64 0-1.15.51-1.15 1.15v.25c.02.08 0 .16-.06.22-.12.13-.29.21-.47.21H6.7c-.13 0-.24-.09-.26-.22-.01-.14-.01-.27 0-.41a2.41 2.41 0 0 1 2.38-2.43h1.52c1.34 0 2.42 1.07 2.43 2.41 0 1.34-1.09 2.42-2.42 2.43Z" })),
|
|
450
|
+
'folder-star': () => (index.h("path", { fill: "currentColor", d: "M14 4.44H8.46L6.62 2.67H2A1.35 1.35 0 0 0 .67 4v8A1.35 1.35 0 0 0 2 13.33h12A1.35 1.35 0 0 0 15.33 12V5.78A1.36 1.36 0 0 0 14 4.44Zm-.2 3.89L12 9.66l.69 2a.22.22 0 0 1-.08.27.26.26 0 0 1-.13.06.39.39 0 0 1-.15-.06l-1.77-1.26L8.75 12a.34.34 0 0 1-.15 0 .31.31 0 0 1-.13 0 .23.23 0 0 1-.08-.27l.69-2-1.81-1.35a.23.23 0 0 1-.1-.17.24.24 0 0 1 .24-.24h2.21l.67-2a.26.26 0 0 1 .15-.14.24.24 0 0 1 .31.14l.67 2h2.2a.26.26 0 0 1 .26.24.3.3 0 0 1-.08.12Z" })),
|
|
451
|
+
'graduation-cap': () => (index.h("path", { fill: "currentColor", d: "M14.93 5.14 8.54 2.76c-.35-.13-.73-.13-1.08 0L1.07 5.14c-.31.13-.48.47-.39.8.04.22.19.39.39.47l1.12.42c-.26.38-.4.84-.41 1.3-.35.28-.47.75-.3 1.16.06.12.14.23.24.31l-.59 3.19c-.06.22.07.45.28.53h1.37c.22-.02.38-.22.36-.44v-.1L2.55 9.6c.32-.31.4-.79.2-1.18a.814.814 0 0 0-.24-.28c0-.38.18-.75.47-1l4.48 1.65c.35.13.73.13 1.08 0l6.39-2.38c.31-.13.48-.47.39-.8a.625.625 0 0 0-.39-.47Zm-6.18 4.5c-.48.18-1.02.18-1.5 0L3.93 8.4l-.33 3.15c0 1 2 1.78 4.4 1.78s4.4-.79 4.4-1.78l-.33-3.15-3.32 1.24Z" })),
|
|
452
|
+
'history': () => [
|
|
453
|
+
index.h("path", { fill: "currentColor", d: "M8,1.67A6.37,6.37,0,0,0,3.6,3.42l-.91-.91a.6.6,0,0,0-.85,0h0a.58.58,0,0,0-.18.43V6.37A.61.61,0,0,0,2.24,7H5.68a.62.62,0,0,0,.62-.62A.69.69,0,0,0,6.12,6L5.05,4.87a4.29,4.29,0,1,1,.1,6.36.3.3,0,0,0-.41,0l-1,1a.3.3,0,0,0,0,.42h0A6.33,6.33,0,1,0,8,1.67Z" }),
|
|
454
|
+
index.h("path", { fill: "currentColor", d: "M9.85,9.3l-.36.36a.3.3,0,0,1-.43,0L7.45,8V5.15a.3.3,0,0,1,.3-.3h.5a.3.3,0,0,1,.3.3V7.58l1.3,1.3A.31.31,0,0,1,9.85,9.3Z" }),
|
|
455
|
+
],
|
|
456
|
+
'home': () => index.h("path", { fill: "currentColor", d: "M6.75 14.33V9.86h2.5v4.47h3.13v-6h1.88L8 1.67l-6.26 6.7h1.88v6Z" }),
|
|
457
|
+
'info-circle': () => (index.h("path", { fill: "currentColor", d: "M8 .67A7.33 7.33 0 1 0 15.33 8 7.33 7.33 0 0 0 8 .67ZM9 12a.29.29 0 0 1-.3.3H7.35a.29.29 0 0 1-.3-.3V7.32A.29.29 0 0 1 7.33 7h1.32a.29.29 0 0 1 .35.3Zm0-6.74a.29.29 0 0 1-.3.3H7.35a.29.29 0 0 1-.3-.3V4a.29.29 0 0 1 .28-.3h1.32a.29.29 0 0 1 .3.28V4Z" })),
|
|
458
|
+
'key': () => (index.h("path", { fill: "currentColor", d: "M8.44 6.67a3.994 3.994 0 0 0-5.1-2.44A3.986 3.986 0 0 0 .9 9.33 3.994 3.994 0 0 0 6 11.77c1.14-.4 2.04-1.3 2.44-2.44h2.89V12H14V9.33h1.33V6.67H8.44ZM4.67 9.33c-.73 0-1.33-.6-1.33-1.33s.6-1.33 1.33-1.33C5.4 6.67 6 7.27 6 8c0 .73-.58 1.32-1.31 1.33h-.02Z" })),
|
|
459
|
+
'laptop': () => (index.h("path", { fill: "currentColor", d: "M12.89 12.08c.68-.02 1.23-.58 1.22-1.26v-6.9c0-.68-.54-1.24-1.22-1.25H3.11c-.68.01-1.23.57-1.22 1.25v6.9c-.01.68.53 1.25 1.22 1.26H.67c-.01.68.53 1.24 1.21 1.25h12.23c.68 0 1.23-.56 1.22-1.24h-2.44ZM3.11 3.92h9.78v6.9H3.11v-6.9ZM8 12.71c-.34 0-.62-.29-.61-.63 0-.34.27-.61.61-.61.34 0 .61.27.61.61 0 .34-.27.63-.61.63Z" })),
|
|
460
|
+
'lines-rectangle': () => (index.h("path", { fill: "currentColor", d: "M12.32.67H3.68c-.56 0-1.01.45-1.01 1.01v12.64c0 .56.45 1.01 1.01 1.01h8.64c.56 0 1.01-.45 1.01-1.01V1.68c0-.56-.45-1.01-1.01-1.01ZM9 11.25H4.67v-2H9v2Zm2.33-4.49H4.67v-2h6.67v2Z" })),
|
|
461
|
+
'life-ring': () => (index.h("path", { fill: "currentColor", d: "M8 .67A7.33 7.33 0 1 0 15.33 8 7.33 7.33 0 0 0 8 .67Zm5.14 3.53-1.88 1.88a3.91 3.91 0 0 0-1.34-1.34l1.88-1.88a6.55 6.55 0 0 1 1.34 1.34ZM8 10.84A2.84 2.84 0 1 1 10.84 8 2.84 2.84 0 0 1 8 10.84Zm-3.8-8 1.88 1.9a3.91 3.91 0 0 0-1.34 1.34L2.86 4.2A6.55 6.55 0 0 1 4.2 2.86ZM2.86 11.8l1.88-1.88a3.91 3.91 0 0 0 1.34 1.34L4.2 13.14a6.55 6.55 0 0 1-1.34-1.34Zm8.94 1.34-1.88-1.88a3.91 3.91 0 0 0 1.34-1.34l1.88 1.88a6.55 6.55 0 0 1-1.34 1.34Z" })),
|
|
462
|
+
'link': () => (index.h("path", { fill: "currentColor", d: "M9.75 6.25a3.748 3.748 0 0 1 0 5.31l-1.66 1.67a3.76 3.76 0 0 1-5.32 0 3.76 3.76 0 0 1 0-5.32l.92-.92c.15-.15.4-.16.56 0 .07.07.11.16.12.26.02.44.1.88.24 1.3.05.14.01.3-.09.41l-.32.32c-.72.67-.76 1.8-.09 2.52s1.8.76 2.52.09c.03-.02.05-.05.07-.07l1.66-1.66c.7-.7.7-1.82 0-2.52-.08-.08-.16-.15-.26-.21a.394.394 0 0 1-.17-.31.98.98 0 0 1 .29-.74l.52-.52c.14-.14.35-.15.51-.04.18.13.35.27.51.43Zm3.49-3.48a3.76 3.76 0 0 0-5.32 0L6.26 4.43a3.772 3.772 0 0 0 .52 5.75c.16.11.37.09.51-.04l.52-.52c.2-.19.3-.46.29-.74a.38.38 0 0 0-.17-.31 1.775 1.775 0 0 1-.26-2.73l1.66-1.66c.68-.71 1.81-.74 2.52-.06.71.68.74 1.81.06 2.52-.02.03-.05.05-.07.07l-.32.32c-.11.11-.14.27-.09.41.14.42.22.86.24 1.3 0 .22.19.39.41.38.1 0 .19-.05.26-.12l.92-.92a3.76 3.76 0 0 0 0-5.32Z" })),
|
|
463
|
+
'list': () => (index.h("path", { fill: "currentColor", d: "M1.9 2.68c-.67 0-1.22.56-1.21 1.23 0 .67.56 1.22 1.23 1.21.67 0 1.22-.56 1.21-1.23 0-.32-.13-.63-.36-.86-.23-.23-.54-.36-.87-.35Zm0 4.09a1.23 1.23 0 1 0 0 2.46 1.23 1.23 0 1 0 0-2.46Zm0 4.09a1.23 1.23 0 1 0 0 2.46 1.23 1.23 0 1 0 0-2.46Zm13 .41H5.18c-.23 0-.41.18-.41.41v.82c0 .23.18.41.41.41h9.75c.23 0 .41-.18.41-.41v-.82c0-.23-.18-.41-.41-.41h-.03Zm0-8.18H5.18c-.23 0-.41.18-.41.41v.81c0 .23.18.41.41.41h9.75c.23 0 .41-.18.41-.41V3.5c0-.23-.18-.41-.41-.41h-.03Zm0 4.09H5.18c-.23 0-.41.18-.41.41v.82c0 .23.18.41.41.41h9.75c.23 0 .41-.18.41-.41v-.82c0-.23-.18-.41-.41-.41h-.03Z" })),
|
|
464
|
+
'loader': () => [
|
|
465
|
+
index.h("path", { fill: "currentColor", class: "loader__full-circle", d: "M8 2.67A5.33 5.33 0 1 1 2.67 8 5.33 5.33 0 0 1 8 2.67m0-2A7.33 7.33 0 1 0 15.33 8 7.33 7.33 0 0 0 8 .67Z" }),
|
|
466
|
+
index.h("path", { fill: "currentColor", d: "M8 2.67v-2A7.33 7.33 0 0 0 .67 8h2A5.33 5.33 0 0 1 8 2.67Z" }),
|
|
467
|
+
],
|
|
468
|
+
'lock': () => (index.h("path", { fill: "currentColor", d: "M12 5.56h-.67v-1.4C11.37 2.28 9.88.71 8 .67 6.12.71 4.63 2.28 4.67 4.16v1.4H4c-.75.02-1.35.64-1.33 1.39V14c.02.73.6 1.31 1.33 1.33h8c.75-.02 1.35-.64 1.33-1.39V7a1.37 1.37 0 0 0-1.28-1.44H12Zm-4 6.28c-.77.04-1.43-.56-1.47-1.33-.04-.77.56-1.43 1.33-1.47.77-.04 1.43.56 1.47 1.33v.07c.02.75-.57 1.38-1.32 1.4H8Zm2.07-6.28H5.93v-1.4A2.12 2.12 0 0 1 8 2c1.17.03 2.1 1 2.07 2.17v1.39Z" })),
|
|
469
|
+
'location': () => (index.h("path", { fill: "currentColor", d: "M8 .67A5.1 5.1 0 0 0 2.67 5.5c0 3.06 3.51 7.88 4.83 9.59a.64.64 0 0 0 1 0c1.32-1.71 4.83-6.53 4.83-9.59A5.1 5.1 0 0 0 8 .67Zm0 6.94a1.74 1.74 0 1 1 1.74-1.73A1.73 1.73 0 0 1 8 7.61Z" })),
|
|
470
|
+
'log-in': () => (index.h("path", { fill: "currentColor", d: "M10.97,7.78h0L6.97,3.78c-.12-.12-.31-.12-.42,0h0c-.07,.06-.12,.15-.13,.24v2.07c0,.17-.13,.3-.3,.32H1.97c-.16,0-.29,.12-.3,.28h0v2.58c0,.16,.12,.29,.28,.3H6.11c.17,0,.3,.14,.3,.31v2.14c0,.16,.12,.29,.28,.3h0c.11,.01,.21-.03,.28-.11l4-4c.11-.12,.11-.3,0-.42Zm3.37,5.26h0v1c0,.16-.13,.28-.28,.28h-4.77c-.16,0-.28-.13-.28-.28v-1c0-.16,.13-.28,.28-.28h3.43V3.3h-3.42c-.16,0-.29-.13-.29-.29V1.97c0-.16,.13-.29,.29-.29h4.76c.16,0,.29,.13,.29,.29v.68h0V13.04Z" })),
|
|
471
|
+
'log-out': () => [
|
|
472
|
+
index.h("path", { fill: "currentColor", d: "M14.25,7.77h0l-4-4a.31.31,0,0,0-.43,0A.34.34,0,0,0,9.7,4V6.07a.32.32,0,0,1-.3.32H5.23a.3.3,0,0,0-.3.3V9.25a.3.3,0,0,0,.3.3H9.4a.31.31,0,0,1,.3.31V12a.3.3,0,0,0,.3.3.33.33,0,0,0,.23-.09l4-4A.29.29,0,0,0,14.25,7.77Z" }),
|
|
473
|
+
index.h("path", { fill: "currentColor", d: "M6.71,12.72H3.27V3.26H6.69A.31.31,0,0,0,7,3V2a.3.3,0,0,0-.31-.3H2A.29.29,0,0,0,1.67,2h0V3h0V14a.27.27,0,0,0,.1.24h0a.32.32,0,0,0,.14.08H6.71A.3.3,0,0,0,7,14V13A.3.3,0,0,0,6.71,12.72Z" }),
|
|
474
|
+
],
|
|
475
|
+
'magnifying-glass': () => (index.h("path", { fill: "currentColor", d: "M11.24 9.5c1.48-2.44.71-5.62-1.73-7.1-.05-.03-.11-.07-.17-.1A5.232 5.232 0 0 0 2.52 4C.94 6.38 1.6 9.59 3.98 11.17a5.142 5.142 0 0 0 5.54.1L12.3 14c.39.39 1.02.39 1.41 0l.33-.33a.996.996 0 0 0 0-1.41l-2.8-2.76Zm-4.4.5c-1.76.02-3.2-1.4-3.22-3.16-.02-1.76 1.4-3.2 3.16-3.22 1.76-.02 3.2 1.4 3.22 3.16v.06A3.193 3.193 0 0 1 6.84 10Z" })),
|
|
476
|
+
'mail': () => (index.h("path", { fill: "currentColor", d: "M13.87 2.67H2.13C1.36 2.64.71 3.23.67 4v8c.03.77.68 1.36 1.45 1.33h11.75c.77.04 1.42-.55 1.46-1.32V4c-.03-.77-.68-1.36-1.45-1.33h-.01Zm0 2.66L8 8.67 2.13 5.33V4L8 7.33 13.87 4v1.33Z" })),
|
|
477
|
+
'notes-outline': () => (index.h("path", { fill: "currentColor", d: "M13.11 4.74v5.38h-3v3H4.73V4.74h8.38m0-1.2H4.73a1.2 1.2 0 0 0-1.2 1.2v8.38a1.2 1.2 0 0 0 1.2 1.19h6l3.59-3.59v-6a1.2 1.2 0 0 0-1.21-1.18Zm-4.19 6.58h-3V8.93h3Zm3-2.39h-6v-1.2h6ZM3.8 11.19h-1V2.81h8.38v1h1.2v-1a1.2 1.2 0 0 0-1.2-1.2H2.81a1.2 1.2 0 0 0-1.2 1.2v8.38a1.2 1.2 0 0 0 1.2 1.2h1Z" })),
|
|
478
|
+
'paper-plane': () => (index.h("path", { fill: "currentColor", d: "M14 1.69 1.84 7a.28.28 0 0 0-.15.36.29.29 0 0 0 .16.15l3.27 1.82a.57.57 0 0 0 .61-.06l6.45-5.57c.05 0 .15-.1.19-.06s0 .14-.06.18l-5.59 6.29a.52.52 0 0 0 0 .63l2.09 3.44a.28.28 0 0 0 .37.12.3.3 0 0 0 .13-.12l5-12.11a.3.3 0 0 0-.14-.37.28.28 0 0 0-.17-.01Z" })),
|
|
479
|
+
'paper-plane-slash': () => (index.h("path", { fill: "currentColor", d: "M2.67,1.69,14.26,13.28l-1,1-2.79-2.8-1.1,2.67a.3.3,0,0,1-.13.12.28.28,0,0,1-.37-.12L6.75,10.74a.52.52,0,0,1,0-.63L7.82,8.9l-.76-.76L5.76,9.27a.57.57,0,0,1-.61.06L1.88,7.51a.29.29,0,0,1-.16-.15A.28.28,0,0,1,1.87,7L4.68,5.76l-3-3Zm11.53,0a.28.28,0,0,0-.22,0L7.53,4.51,9.26,6.24l3-2.54s.15-.1.19-.06,0,.14-.06.18L9.75,6.73l1.88,1.88,2.71-6.54A.3.3,0,0,0,14.2,1.7Z" })),
|
|
480
|
+
'pen': () => (index.h("path", { fill: "currentColor", d: "M1.67,11.69v2.64h2.64l7.78-7.78-2.64-2.64L1.67,11.69ZM14.13,4.51c.27-.28,.27-.72,0-1h0l-1.65-1.64c-.28-.27-.72-.27-1,0h0l-1.28,1.29,2.64,2.64,1.29-1.29Z" })),
|
|
481
|
+
'pen-fancy': () => (index.h("path", { fill: "currentColor", d: "M3.63,8.65c-.24,.07-.43,.26-.5,.5l-1.46,4.37,.11,.12,2.3-2.3c0-.06,0-.13,0-.19,0-.44,.35-.8,.79-.81,.44,0,.8,.35,.81,.79,0,.44-.35,.8-.79,.81,0,0-.01,0-.02,0h-.19l-2.3,2.3,.12,.11,4.37-1.46c.24-.07,.43-.26,.5-.5l.82-2.08-2.49-2.48-2.07,.82ZM10.8,2.35L6.27,7.28l2.42,2.42,4.94-4.52c2.1-1.86-.99-4.92-2.83-2.83Z" })),
|
|
482
|
+
'picture': () => (index.h("path", { fill: "currentColor", d: "M14.33 12.93V3.07a1.4 1.4 0 0 0-1.4-1.4H3.07a1.4 1.4 0 0 0-1.4 1.4v9.86a1.4 1.4 0 0 0 1.4 1.4h9.86a1.4 1.4 0 0 0 1.4-1.4ZM5.54 9.06l1.76 2.11L9.76 8l3.17 4.22H3.07Z" })),
|
|
483
|
+
'play-circle': () => (index.h("path", { fill: "currentColor", d: "M8 .67A7.33 7.33 0 1 0 15.33 8 7.33 7.33 0 0 0 8 .67Zm3.42 8-5.2 3a.72.72 0 0 1-1-.28.73.73 0 0 1-.09-.35V4.92a.71.71 0 0 1 .71-.71 1.06 1.06 0 0 1 .35.09l5.2 3.17a.71.71 0 0 1 .27 1 .64.64 0 0 1-.24.24Z" })),
|
|
484
|
+
'plus': () => (index.h("path", { fill: "currentColor", d: "M9.41 6.59V1.92a.24.24 0 0 0-.24-.25H6.84a.24.24 0 0 0-.25.24v4.68H1.92a.24.24 0 0 0-.25.24v2.33a.24.24 0 0 0 .24.25h4.68v4.67a.24.24 0 0 0 .24.25h2.33a.24.24 0 0 0 .25-.24V9.41h4.67a.24.24 0 0 0 .25-.24V6.84a.24.24 0 0 0-.24-.25H9.41Z" })),
|
|
485
|
+
'plus-circle': () => (index.h("path", { fill: "currentColor", d: "M8,0.7C4,0.7,0.7,4,0.7,8S4,15.3,8,15.3S15.3,12,15.3,8l0,0C15.3,4,12,0.7,8,0.7 C8,0.7,8,0.7,8,0.7z M12.3,8.8c0,0.2-0.2,0.4-0.4,0.4H9.2v2.7c0,0.2-0.2,0.4-0.4,0.4H7.2c-0.2,0-0.4-0.2-0.3-0.4V9.2H4.1 C3.9,9.2,3.7,9,3.7,8.8V7.2c0-0.2,0.2-0.4,0.4-0.3h2.7V4.1c0-0.2,0.2-0.4,0.3-0.4h1.7c0.2,0,0.4,0.2,0.4,0.4v2.7h2.7 c0.2,0,0.4,0.2,0.4,0.3L12.3,8.8z" })),
|
|
486
|
+
'question-circle': () => (index.h("path", { fill: "currentColor", d: "M15.33 8A7.33 7.33 0 1 1 8 .67 7.33 7.33 0 0 1 15.33 8ZM8.2 3.09A3.83 3.83 0 0 0 4.75 5a.35.35 0 0 0 .08.48l1 .78a.36.36 0 0 0 .49-.07c.55-.69.92-1.08 1.68-1.08.61 0 1.35.39 1.35 1s-.36.67-1 1S6.82 8 6.82 9.18v.12a.35.35 0 0 0 .35.35h1.66a.35.35 0 0 0 .35-.35c0-.84 2.46-.88 2.46-3.15A3.37 3.37 0 0 0 8.2 3.09ZM8 10.42a1.37 1.37 0 1 0 1.36 1.37A1.36 1.36 0 0 0 8 10.42Z" })),
|
|
487
|
+
'share': () => (index.h("path", { fill: "currentColor", d: "M13.43,10.67a2,2,0,0,0-2.42.18L5.64,8.28a2.11,2.11,0,0,0,0-.56L11,5.15a2,2,0,0,0,2.42.18,2,2,0,1,0-3.08-1.57L4.83,6.4l-.11-.09a2,2,0,1,0,.12,3.3l5.51,2.63a2,2,0,1,0,3.08-1.57Z" })),
|
|
488
|
+
'shuffle': () => (index.h("path", { fill: "currentColor", d: "M15.13 10.45a.51.51 0 0 1 0 .81l-2.29 1.91c-.29.24-.71.24-1 0-.12-.1-.2-.24-.2-.4v-.95H10c-.09 0-.18-.03-.25-.09l-2-1.8 1.49-1.37 1.51 1.35h.92V9c.04-.35.34-.6.69-.57.18 0 .35.06.48.17l2.29 1.9v-.05ZM1 6.09h2.42l1.51 1.35 1.53-1.36-2-1.8a.41.41 0 0 0-.26-.09H1a.328.328 0 0 0-.34.29v1.33c.02.17.17.3.34.28Zm10.66 0v1c.04.35.34.6.69.57.18 0 .35-.06.48-.17l2.29-1.9a.51.51 0 0 0 0-.81l-2.28-1.95a.81.81 0 0 0-1 0c-.12.1-.2.25-.2.41v1H10c-.09 0-.18.03-.25.09L3.42 9.91H1a.313.313 0 0 0-.34.28v1.33c.02.17.17.3.34.29h3.18c.09 0 .19-.03.26-.09l6.31-5.62h.91Z" })),
|
|
489
|
+
'sitemap': () => (index.h("path", { fill: "currentColor", d: "M3.33 10h-2c-.37 0-.66.3-.66.67v2c0 .36.3.65.66.66h2c.37 0 .66-.29.67-.66v-2c0-.37-.3-.67-.67-.67Zm-.5-1.67H7.5v1h1v-1h4.67v1h1v-1.2c0-.44-.36-.8-.8-.8H8.5V6h.83c.37 0 .67-.3.67-.67v-2c0-.37-.3-.66-.67-.66H6.67c-.37 0-.66.29-.67.66v2c0 .37.3.67.67.67h.83v1.33H2.63c-.44 0-.8.36-.8.8v1.2h1v-1ZM9 10H7c-.37 0-.67.3-.67.67v2c0 .37.3.66.67.66h2c.37 0 .66-.29.67-.66v-2c0-.37-.3-.67-.67-.67Zm5.67 0h-2c-.37 0-.67.3-.67.67v2c0 .37.3.66.67.66h2c.36 0 .65-.3.66-.66v-2c0-.37-.29-.66-.66-.67Z" })),
|
|
490
|
+
'squares': () => (index.h("path", { fill: "currentColor", d: "M2.27 1.67h4.47c.33 0 .6.27.6.6v4.47c0 .33-.27.6-.6.6H2.27c-.33 0-.6-.27-.6-.6V2.27c0-.33.27-.6.6-.6Zm7 0h4.47c.33 0 .6.27.6.6v4.47c0 .33-.27.6-.6.6H9.27c-.33 0-.6-.27-.6-.6V2.27c0-.33.27-.6.6-.6Zm0 7h4.47c.33 0 .6.27.6.6v4.47c0 .33-.27.6-.6.6H9.27c-.33 0-.6-.27-.6-.6V9.27c0-.33.27-.6.6-.6Zm-7 0h4.47c.33 0 .6.27.6.6v4.47c0 .33-.27.6-.6.6H2.27c-.33 0-.6-.27-.6-.6V9.27c0-.33.27-.6.6-.6Z" })),
|
|
491
|
+
'table': () => (index.h("path", { fill: "currentColor", d: "M14.19 2.68H1.81A1.14 1.14 0 0 0 .67 3.82v8.36a1.14 1.14 0 0 0 1.14 1.14h12.38a1.14 1.14 0 0 0 1.14-1.14V3.82a1.14 1.14 0 0 0-1.14-1.14ZM7.24 11.8H2.19V9.52h5.05Zm0-3.8H2.19V5.72h5.05Zm6.57 3.8H8.76V9.52h5.05Zm0-3.8H8.76V5.72h5.05Z" })),
|
|
492
|
+
'tag': () => (index.h("path", { fill: "currentColor", d: "M1.67 7.9V2.85a1.18 1.18 0 0 1 1.18-1.18H7.9a1.18 1.18 0 0 1 .84.33L14 7.26a1.2 1.2 0 0 1 0 1.68L8.94 14a1.2 1.2 0 0 1-1.68 0L2 8.74a1.18 1.18 0 0 1-.33-.84Zm2.77-4.65a1.19 1.19 0 1 0 1.18 1.19 1.19 1.19 0 0 0-1.18-1.19Z" })),
|
|
493
|
+
'tags': () => [
|
|
494
|
+
index.h("path", { fill: "currentColor", d: "M12.08 7.37 7.22 3a1.12 1.12 0 0 0-.78-.29H1.77a1 1 0 0 0-1.1 1v4.21a1 1 0 0 0 .33.71L5.85 13a1.17 1.17 0 0 0 1.55 0l4.68-4.25a.94.94 0 0 0 0-1.38ZM3.23 6.13A1.13 1.13 0 1 1 4.36 5a1.13 1.13 0 0 1-1.13 1.13Z" }),
|
|
495
|
+
index.h("path", { fill: "currentColor", d: "M15 7.37 10.15 3a1.12 1.12 0 0 0-.77-.29H8.26l4.5 4.09a1.76 1.76 0 0 1 0 2.65L8.77 13a1.17 1.17 0 0 0 1.55 0L15 8.79a.94.94 0 0 0 0-1.42Z" }),
|
|
496
|
+
],
|
|
497
|
+
'thumb-up': () => (index.h("path", { fill: "currentColor", d: "M2.11 14.36h1a.45.45 0 0 0 .45-.44V7.17a.45.45 0 0 0-.45-.44h-1a.44.44 0 0 0-.44.44v6.75a.44.44 0 0 0 .44.44Zm12.22-7a1.27 1.27 0 0 0-1.27-1.27H9.71l.61-2.91v-.2a1.07 1.07 0 0 0-.28-.68l-.68-.66-4.17 4.19a1.26 1.26 0 0 0-.37.9v6.36a1.27 1.27 0 0 0 1.27 1.27h5.06a1.24 1.24 0 0 0 1.17-.77l1.92-4.49a1.22 1.22 0 0 0 .09-.46V7.42Z" })),
|
|
498
|
+
'trash': () => [
|
|
499
|
+
index.h("path", { fill: "currentColor", d: "M3.27 14.17c0 .66.54 1.19 1.2 1.2h7l-.05-.02h.08c.64-.02 1.14-.56 1.12-1.2V4.32H3.27v9.85Zm5.97-7.12c0-.33.27-.6.6-.6s.6.27.6.6v5.3c0 .33-.27.6-.6.6s-.6-.27-.6-.6v-5.3Zm-3.5 0c0-.33.27-.59.6-.6.32.02.58.28.6.6v5.3c-.02.32-.28.58-.6.6a.645.645 0 0 1-.6-.6v-5.3Zm7.28-5.39h-2.6V.95a.28.28 0 0 0-.28-.28H5.87a.28.28 0 0 0-.28.28v.72H2.91a.28.28 0 0 0-.28.28V3.1c0 .15.12.28.28.28h10.11c.15 0 .28-.12.28-.28V1.94a.28.28 0 0 0-.28-.28Z" }),
|
|
500
|
+
index.h("path", { fill: "currentColor", d: "M13,2h-2.9L9.9,1.6 C9.8,1.4,9.6,1.2,9.4,1.2H6.6c-0.2,0-0.4,0.1-0.5,0.3L5.8,2H2.9C2.7,2,2.5,2.2,2.5,2.4c0,0,0,0,0,0v0.8c0,0.2,0.2,0.4,0.4,0.4H13 c0.2,0,0.4-0.2,0.4-0.4V2.4C13.4,2.2,13.2,2,13,2z" }),
|
|
501
|
+
],
|
|
502
|
+
'universal-access': () => (index.h("path", { fill: "currentColor", d: "M8 15.33A7.33 7.33 0 1 1 15.33 8 7.34 7.34 0 0 1 8 15.33ZM8 1.71A6.29 6.29 0 1 0 14.29 8 6.29 6.29 0 0 0 8 1.71ZM13.74 8A5.74 5.74 0 1 1 8 2.25 5.75 5.75 0 0 1 13.74 8ZM8 3.77a1.07 1.07 0 1 0 1.07 1.07A1.07 1.07 0 0 0 8 3.77ZM4.67 5.63c-.6-.14-.87.86-.32 1s1.79.43 2.57.55a11.25 11.25 0 0 1-.72 4.47.54.54 0 0 0 .85.65 6.94 6.94 0 0 0 .78-2.42c0-.07.31-.11.33 0a8.73 8.73 0 0 0 .63 2.23c.3.65 1.31.26 1-.38a11.54 11.54 0 0 1-.76-4.58 21.34 21.34 0 0 0 2.41-.45.55.55 0 1 0-.2-1.08 11.47 11.47 0 0 1-6.57.01Z" })),
|
|
503
|
+
'unlink': () => (index.h("path", { fill: "currentColor", d: "M9.74 6.25c-.16-.17-.32-.3-.5-.43-.14-.09-.31-.1-.44 0l1.81 1.81c-.17-.5-.47-.98-.87-1.38Zm-1.1 3.51c-.07.15-.17.28-.29.4l-1.66 1.66s-.04.05-.07.07c-.72.67-1.85.63-2.52-.09-.67-.72-.63-1.85.09-2.52l.32-.32c.1-.11.14-.27.09-.41-.14-.42-.22-.86-.24-1.3a.42.42 0 0 0-.12-.26.395.395 0 0 0-.56 0l-.92.92a3.76 3.76 0 0 0 0 5.32 3.76 3.76 0 0 0 5.32 0l1.66-1.67c.12-.12.23-.25.32-.38L8.64 9.76Zm4.61-7h-.02a3.778 3.778 0 0 0-5.32 0L6.83 3.84l1.41 1.41 1.08-1.08c.68-.71 1.81-.74 2.52-.06.71.68.74 1.81.06 2.52-.02.03-.05.05-.07.07l-.32.32c-.11.11-.14.27-.09.41.13.4.21.81.23 1.23l.44.44c.09 0 .18-.05.24-.11l.92-.92a3.76 3.76 0 0 0 0-5.32Zm.97 10.52-1.03 1.03-5.14-5.14c-.04.17-.12.33-.25.45l-.52.52c-.14.13-.35.15-.51.04-.18-.13-.35-.27-.5-.42-.74-.74-1.11-1.7-1.11-2.67 0-.24.02-.49.08-.73l-3.6-3.6 1.03-1.03 11.55 11.55Z" })),
|
|
504
|
+
'unlock': () => (index.h("path", { fill: "currentColor", d: "M13.33 13.94V7a1.37 1.37 0 0 0-1.28-1.44h-.72v-1.4A3.422 3.422 0 0 0 8 .67 3.4 3.4 0 0 0 4.68 4h1.26C6 2.9 6.9 2.03 8 2c1.17.03 2.1 1 2.07 2.17v1.39H4c-.75.02-1.35.64-1.33 1.39V14c.02.73.6 1.31 1.33 1.33h8c.75-.02 1.35-.64 1.33-1.39ZM8 11.84c-.77.04-1.43-.56-1.47-1.33-.04-.77.56-1.43 1.33-1.47.77-.04 1.43.56 1.47 1.33v.07c.02.75-.57 1.38-1.32 1.4H8Z" })),
|
|
505
|
+
'upload': () => (index.h("path", { fill: "currentColor", d: "M9.58 10.74V6.59a.31.31 0 0 1 .31-.3H12a.3.3 0 0 0 .21-.52l-4-4a.29.29 0 0 0-.42 0l-4 4a.3.3 0 0 0 .21.52h2.11a.31.31 0 0 1 .31.3v4.15a.3.3 0 0 0 .3.3h2.56a.3.3 0 0 0 .3-.3ZM14.33 14v-1a.29.29 0 0 0-.29-.3H2a.29.29 0 0 0-.29.3v1a.29.29 0 0 0 .29.29h12a.29.29 0 0 0 .33-.29Z" })),
|
|
506
|
+
'user': () => (index.h("path", { fill: "currentColor", d: "M8 8.79a3.56 3.56 0 1 0-3.56-3.56A3.56 3.56 0 0 0 8 8.79Zm3.17.79H9.8a4.27 4.27 0 0 1-3.6 0H4.83a3.16 3.16 0 0 0-3.16 3.17v.4a1.18 1.18 0 0 0 1.18 1.18h10.3a1.18 1.18 0 0 0 1.18-1.18v-.4a3.16 3.16 0 0 0-3.16-3.17Z" })),
|
|
507
|
+
'user-circle': () => (index.h("path", { fill: "currentColor", d: "M8 .62C3.95.61.66 3.9.65 7.95c0 4.05 3.28 7.34 7.33 7.35 4.04 0 7.33-3.26 7.35-7.3.02-4.05-3.25-7.36-7.3-7.38H8Zm0 .75c3.64 0 6.59 2.96 6.58 6.6V8c0 1.35-.41 2.66-1.19 3.76a2.713 2.713 0 0 0-2.66-2.37H9.54c-.98.46-2.1.46-3.08 0H5.28c-1.36 0-2.5 1.02-2.67 2.37A6.483 6.483 0 0 1 1.42 8a6.59 6.59 0 0 1 6.55-6.63H8ZM5 5.63c0-1.68 1.37-3.05 3.05-3.05 1.68 0 3.05 1.37 3.05 3.05 0 1.68-1.37 3.05-3.05 3.05H8c-1.66-.03-3-1.39-3-3.05Z" })),
|
|
508
|
+
'user-group': () => (index.h("path", { fill: "currentColor", d: "M13.15 4.12c-.81-.01-1.47.65-1.48 1.46 0 .82.65 1.47 1.46 1.48s1.47-.65 1.48-1.46-.65-1.47-1.46-1.48Zm-10.04.01a1.47 1.47 0 0 0-1.58 1.59c.06.71.62 1.28 1.34 1.34.81.07 1.52-.53 1.59-1.34.06-.81-.54-1.52-1.35-1.59Zm7.36.39c-.22-.84-.87-1.51-1.71-1.75-1.36-.41-2.8.36-3.22 1.72-.18.61-.13 1.27.14 1.85.41.9 1.33 1.48 2.32 1.45 1.41.01 2.56-1.14 2.57-2.55 0-.24-.03-.49-.1-.72Zm-.71 4h-.19c-.99.49-2.14.49-3.13 0h-.19c-1.46 0-2.64 1.18-2.64 2.64v2.69c1.23.93 2.74 1.47 4.39 1.47s3.17-.55 4.4-1.48v-2.68c0-1.46-1.18-2.64-2.64-2.64Zm5.52.25a7.282 7.282 0 0 1-1.65 3.91c-.08.1-.16.19-.25.28-.08.09-.17.18-.25.27v-.55h.03v-.72s.01-.07 0-.1v-.66c.01-1.25-.66-2.4-1.76-3 .27-.26.63-.41 1-.41h1.51c.63.01 1.17.41 1.37.98ZM2.86 11.16v1.52h.01v.55l-.28-.31c-.08-.08-.15-.16-.22-.24A7.238 7.238 0 0 1 .74 8.86c.16-.62.72-1.07 1.4-1.07h1.47c.37-.01.73.12 1.01.37-1.1.6-1.77 1.75-1.76 3Z" })),
|
|
509
|
+
'user-plus': () => (index.h("path", { fill: "currentColor", d: "M14,3.33H12.65V2a.36.36,0,0,0-.35-.33h-.65A.36.36,0,0,0,11.3,2V3.33H10a.34.34,0,0,0-.33.34v.66a.34.34,0,0,0,.33.34H11.3V6a.37.37,0,0,0,.35.33h.65A.37.37,0,0,0,12.65,6V4.67H14a.34.34,0,0,0,.32-.34V3.67A.34.34,0,0,0,14,3.33ZM9.28,9.77h-.2a5.19,5.19,0,0,1-3.91,0H5A3,3,0,0,0,1.7,12.46h0v.72A1.27,1.27,0,0,0,3,14.33h8.25a1.26,1.26,0,0,0,1.36-1.14v-.68A3,3,0,0,0,9.37,9.76H9.28ZM7.13,3.7A2.64,2.64,0,1,1,4.5,6.34h0A2.64,2.64,0,0,1,7.13,3.7Z" })),
|
|
510
|
+
'users': () => (index.h("path", { fill: "currentColor", d: "M12,8.76h-.2a5.24,5.24,0,0,1-3.93,0H7.61a3.05,3.05,0,0,0-3.3,2.75v.69a1.28,1.28,0,0,0,1.38,1.14H14a1.27,1.27,0,0,0,1.37-1.14v-.69A3.07,3.07,0,0,0,12,8.75Zm-6.4-.32A2,2,0,0,0,4.31,8H2.48A1.69,1.69,0,0,0,.65,9.53v.76a.85.85,0,0,0,.91.76H3.45A3.58,3.58,0,0,1,5.61,8.44ZM9.81,2.66A2.65,2.65,0,1,1,7.16,5.31h0A2.65,2.65,0,0,1,9.81,2.66ZM3.31,4.18A1.51,1.51,0,1,1,1.8,5.69,1.51,1.51,0,0,1,3.31,4.18Z" })),
|
|
511
|
+
'wallet': () => (index.h("path", { fill: "currentColor", d: "M13.88 5H3a.43.43 0 0 1-.46-.38.43.43 0 0 1 .46-.43h11a.43.43 0 0 0 .46-.38A1.28 1.28 0 0 0 13 2.67H2.5A1.7 1.7 0 0 0 .67 4.19v7.62a1.7 1.7 0 0 0 1.83 1.52h11.38a1.32 1.32 0 0 0 1.45-1.14V6.1A1.33 1.33 0 0 0 13.88 5Zm-1.21 5.29a1.1 1.1 0 1 1 1.1-1.1 1.1 1.1 0 0 1-1.1 1.05Z" })),
|
|
512
|
+
};
|
|
513
|
+
/**
|
|
514
|
+
* List of all possibles sizes
|
|
515
|
+
*/
|
|
516
|
+
const sizes$1 = ['small', 'regular', 'large', 'extra-large'];
|
|
517
|
+
/**
|
|
518
|
+
* List of all possibles variants
|
|
519
|
+
*/
|
|
520
|
+
const variants$2 = ['success', 'warning', 'danger', 'info'];
|
|
521
|
+
|
|
522
|
+
const mgIconCss = ":host{display:inline-flex;vertical-align:middle}.mg-icon[size=small],.mg-icon.mg-icon--size-small{width:var(--mg-icon-small-size);height:var(--mg-icon-small-size)}.mg-icon[size=regular],.mg-icon.mg-icon--size-regular{width:var(--mg-icon-regular-size);height:var(--mg-icon-regular-size)}.mg-icon[size=large],.mg-icon.mg-icon--size-large{width:var(--mg-icon-large-size);height:var(--mg-icon-large-size)}.mg-icon[size=extra-large],.mg-icon.mg-icon--size-extra-large{width:var(--mg-icon-extra-large-size);height:var(--mg-icon-extra-large-size)}.mg-icon[class*=mg-icon--variant-]{border-radius:var(--mg-message-border-radius);padding:0.3rem}.mg-icon.mg-icon--variant-success{background-color:hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) + 20%))}.mg-icon.mg-icon--variant-warning{background-color:hsl(var(--color-warning-h), var(--color-warning-s), calc(var(--color-warning-l) + 20%))}.mg-icon.mg-icon--variant-danger{background-color:hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) + 20%))}.mg-icon.mg-icon--variant-info{background-color:hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) + 20%))}.loader__full-circle{opacity:0.2}.mg-icon--spin{animation-name:rotate;animation-duration:0.75s;animation-iteration-count:infinite}@keyframes rotate{to{transform:rotate(360deg)}}";
|
|
523
|
+
|
|
524
|
+
const MgIcon = class {
|
|
525
|
+
constructor(hostRef) {
|
|
526
|
+
index.registerInstance(this, hostRef);
|
|
527
|
+
/**
|
|
528
|
+
* Define icon size
|
|
529
|
+
*/
|
|
530
|
+
this.size = 'regular';
|
|
531
|
+
/**
|
|
532
|
+
* Make the icon spin
|
|
533
|
+
*/
|
|
534
|
+
this.spin = false;
|
|
535
|
+
/**
|
|
536
|
+
* Component classes
|
|
537
|
+
*/
|
|
538
|
+
this.classList = new index$1.ClassList(['mg-icon']);
|
|
539
|
+
/**
|
|
540
|
+
* getIcon
|
|
541
|
+
*
|
|
542
|
+
* @returns {HTMLElement} icon html
|
|
543
|
+
*/
|
|
544
|
+
this.getIcon = () => icons[this.icon]();
|
|
545
|
+
}
|
|
546
|
+
validateIcon(newValue, oldValue) {
|
|
547
|
+
if (!Object.keys(icons).includes(newValue)) {
|
|
548
|
+
throw new Error(`<mg-icon> prop "icon" must be one of : ${Object.keys(icons).join(', ')}`);
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
if (oldValue !== undefined) {
|
|
552
|
+
this.classList.delete(`mg-icon--${oldValue}`);
|
|
553
|
+
}
|
|
554
|
+
this.classList.add(`mg-icon--${newValue}`);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
validateSize(newValue, oldValue) {
|
|
558
|
+
if (!sizes$1.includes(newValue)) {
|
|
559
|
+
throw new Error(`<mg-icon> prop "size" must be one of : ${sizes$1.join(', ')}`);
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
if (oldValue !== undefined) {
|
|
563
|
+
this.classList.delete(`mg-icon--size-${oldValue}`);
|
|
564
|
+
}
|
|
565
|
+
this.classList.add(`mg-icon--size-${newValue}`);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
validateVariant(newValue, oldValue) {
|
|
569
|
+
if (newValue !== undefined && !variants$2.includes(newValue)) {
|
|
570
|
+
throw new Error(`<mg-icon> prop "variant" must be one of : ${variants$2.join(', ')}`);
|
|
571
|
+
}
|
|
572
|
+
else if (newValue !== undefined) {
|
|
573
|
+
if (oldValue !== undefined) {
|
|
574
|
+
this.classList.delete(`mg-icon--variant-${oldValue}`);
|
|
575
|
+
}
|
|
576
|
+
this.classList.add(`mg-icon--variant-${newValue}`);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
handleSpin(newValue) {
|
|
580
|
+
if (newValue) {
|
|
581
|
+
this.classList.add('mg-icon--spin');
|
|
582
|
+
}
|
|
583
|
+
else {
|
|
584
|
+
this.classList.delete('mg-icon--spin');
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Check if props are well configured on init
|
|
589
|
+
*
|
|
590
|
+
* @returns {void}
|
|
591
|
+
*/
|
|
592
|
+
componentWillLoad() {
|
|
593
|
+
this.validateIcon(this.icon);
|
|
594
|
+
this.validateSize(this.size);
|
|
595
|
+
this.validateVariant(this.variant);
|
|
596
|
+
this.handleSpin(this.spin);
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Render component
|
|
600
|
+
*
|
|
601
|
+
* @returns {HTMLElement} HTML Element
|
|
602
|
+
*/
|
|
603
|
+
render() {
|
|
604
|
+
return (index.h("svg", { class: this.classList.join(), "aria-hidden": "true", focusable: "false", viewBox: "0 0 16 16" }, this.getIcon()));
|
|
605
|
+
}
|
|
606
|
+
static get watchers() { return {
|
|
607
|
+
"icon": ["validateIcon"],
|
|
608
|
+
"size": ["validateSize"],
|
|
609
|
+
"variant": ["validateVariant"],
|
|
610
|
+
"spin": ["handleSpin"]
|
|
611
|
+
}; }
|
|
612
|
+
};
|
|
613
|
+
MgIcon.style = mgIconCss;
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* Apply in all input child node the aria-describedby attribute
|
|
617
|
+
*
|
|
618
|
+
* @param {VNode[]} children Represent scoped elements
|
|
619
|
+
* @param {Set<string>} ariaDescribedbyIDs List of IDs
|
|
620
|
+
* @param {FunctionalUtilities} utils Stencil.js utils
|
|
621
|
+
* @returns {VNode[]} Children with aria-describedby attribute
|
|
622
|
+
*/
|
|
623
|
+
const applyAriadescribedBy = (children, ariaDescribedbyIDs, utils) => utils.map(children, child => {
|
|
624
|
+
if (['input', 'select', 'textarea'].includes(child.vtag)) {
|
|
625
|
+
return Object.assign(Object.assign({}, child), { vattrs: Object.assign(Object.assign({}, child.vattrs), { 'aria-describedby': [...ariaDescribedbyIDs].join(' ') }) });
|
|
626
|
+
}
|
|
627
|
+
// we recursively apply ariadescribedBy attributes to child input nodes if exists
|
|
628
|
+
if (child.vchildren === null)
|
|
629
|
+
return Object.assign({}, child);
|
|
630
|
+
return Object.assign(Object.assign({}, child), { vchildren: applyAriadescribedBy(child.vchildren, ariaDescribedbyIDs, utils) });
|
|
631
|
+
});
|
|
632
|
+
/**
|
|
633
|
+
* Add classes based on props
|
|
634
|
+
*
|
|
635
|
+
* @param {MgInputProps} props MgInput Interface Props
|
|
636
|
+
*/
|
|
637
|
+
const manageClasses = (props) => {
|
|
638
|
+
props.classList.add('mg-input');
|
|
639
|
+
if (props.labelOnTop)
|
|
640
|
+
props.classList.add('mg-input--label-on-top');
|
|
641
|
+
if (props.readonly)
|
|
642
|
+
props.classList.add('mg-input--readonly');
|
|
643
|
+
if (props.mgWidth !== undefined)
|
|
644
|
+
props.classList.add(`mg-input--width-${props.mgWidth}`);
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* Get tagname
|
|
648
|
+
*
|
|
649
|
+
* @param {boolean} isFieldset is fieldset
|
|
650
|
+
* @returns {string} tag name
|
|
651
|
+
*/
|
|
652
|
+
const getTagName = (isFieldset) => (isFieldset ? 'fieldset' : 'div');
|
|
653
|
+
/**
|
|
654
|
+
* Get input template
|
|
655
|
+
*
|
|
656
|
+
* @param {MgInputProps} props MgInput Interface Props
|
|
657
|
+
* @param {VNode[]} children Represent scoped elements
|
|
658
|
+
* @param {FunctionalUtilities} utils Stencil.js utils
|
|
659
|
+
* @returns {VNode[]} input template
|
|
660
|
+
*/
|
|
661
|
+
const MgInput = (props, children, utils) => {
|
|
662
|
+
/**
|
|
663
|
+
* Check required properties
|
|
664
|
+
*/
|
|
665
|
+
if (typeof props.label !== 'string' || props.label === '') {
|
|
666
|
+
throw new Error('<mg-input> prop "label" is required');
|
|
667
|
+
}
|
|
668
|
+
if (props.labelOnTop && props.labelHide) {
|
|
669
|
+
throw new Error('<mg-input> prop "labelOnTop" must not be paired with the prop "labelHide"');
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Component classes
|
|
673
|
+
*/
|
|
674
|
+
manageClasses(props);
|
|
675
|
+
/**
|
|
676
|
+
* a11y IDs
|
|
677
|
+
*/
|
|
678
|
+
const ariaDescribedbyIDs = new Set(props.ariaDescribedbyIDs);
|
|
679
|
+
// Help text
|
|
680
|
+
const helpTextId = `${props.identifier}-help-text`;
|
|
681
|
+
if (typeof props.helpText === 'string' && props.helpText !== '') {
|
|
682
|
+
ariaDescribedbyIDs.add(helpTextId);
|
|
683
|
+
}
|
|
684
|
+
// Error Message
|
|
685
|
+
const helpTextErrorId = `${props.identifier}-error`;
|
|
686
|
+
if (typeof props.errorMessage === 'string' && props.errorMessage !== '') {
|
|
687
|
+
ariaDescribedbyIDs.add(helpTextErrorId);
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Update input(s) in children
|
|
691
|
+
*/
|
|
692
|
+
if (props.readonly) {
|
|
693
|
+
children = children.filter(child => child.$name$ === 'append-input');
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
children = applyAriadescribedBy(children, ariaDescribedbyIDs, utils);
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Return template
|
|
700
|
+
*
|
|
701
|
+
* +--------+--------------+---------+
|
|
702
|
+
* | label | input | tooltip |
|
|
703
|
+
* | +--------------+---------+
|
|
704
|
+
* | | nb Char Left |
|
|
705
|
+
* | +------------------------+
|
|
706
|
+
* | | Help Text |
|
|
707
|
+
* | +------------------------+
|
|
708
|
+
* | | Error |
|
|
709
|
+
* +--------+------------------------+
|
|
710
|
+
*
|
|
711
|
+
* Error message is based on this aria method: https://www.w3.org/WAI/tutorials/forms/notifications/#on-focus-change
|
|
712
|
+
*/
|
|
713
|
+
const TagName = getTagName(props.isFieldset);
|
|
714
|
+
/**
|
|
715
|
+
* Get tooltip node
|
|
716
|
+
*
|
|
717
|
+
* @returns {VNode[]} mg-tooltip
|
|
718
|
+
*/
|
|
719
|
+
const getTooltip = () => (index.h("mg-tooltip", { identifier: `${props.identifier}-tooltip`, message: props.tooltip },
|
|
720
|
+
index.h("mg-icon", { icon: "info-circle" })));
|
|
721
|
+
/**
|
|
722
|
+
* Get input title (label) node
|
|
723
|
+
*
|
|
724
|
+
* @returns {VNode[]} mg-input-title
|
|
725
|
+
*/
|
|
726
|
+
const getInputTitle = () => (index.h("mg-input-title", { identifier: props.identifier, class: props.labelHide ? 'sr-only' : undefined, required: props.required && !props.disabled, "is-legend": props.isFieldset }, props.label));
|
|
727
|
+
return (index.h(TagName, { class: props.classList.join() },
|
|
728
|
+
props.labelOnTop ? (index.h("div", { class: "mg-input__title" },
|
|
729
|
+
getInputTitle(),
|
|
730
|
+
!props.readonly && props.tooltip && getTooltip())) : (getInputTitle()),
|
|
731
|
+
props.readonly ? (index.h("div", { class: "mg-input__input-container" },
|
|
732
|
+
index.h("strong", null, props.readonlyValue || props.value),
|
|
733
|
+
children)) : (index.h("div", { class: "mg-input__input-container" },
|
|
734
|
+
index.h("div", { class: { 'mg-input__input': true, 'mg-input__input--has-error': props.errorMessage !== undefined } },
|
|
735
|
+
children,
|
|
736
|
+
!props.labelOnTop && props.tooltip && getTooltip()),
|
|
737
|
+
props.helpText && index.h("div", { id: helpTextId, class: "mg-input__help-text", innerHTML: props.helpText }),
|
|
738
|
+
props.errorMessage && !props.readonly && !props.disabled && (index.h("div", { id: helpTextErrorId, class: "mg-input__error", innerHTML: props.errorMessage, "aria-live": "assertive" }))))));
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
const mgInputCheckboxCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{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{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{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: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: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:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}fieldset.mg-input{border:0;margin-left:0;margin-right:0;padding:0}fieldset.mg-input input[type=radio],fieldset.mg-input input[type=checkbox]{flex-shrink:0;width:var(--mg-input-check-size);height:var(--mg-input-check-size);margin-top:calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);margin-right:0.6rem;margin-bottom:0;margin-left:0}fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container{margin-top:0.7rem}.mg-input__input-container mg-tooltip{margin-left:3rem}.mg-input__input-group-container{margin:0;padding:0;list-style:none;display:flex;flex-wrap:wrap;column-gap:2.3rem;row-gap:1rem;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2)}.mg-input__input-group-container--vertical{flex-direction:column}.mg-input__input-group{display:flex;align-items:top}.mg-input__input-group.mg-input__input-group--disabled label{opacity:0.3}.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}";
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* type CheckboxItem validation function
|
|
745
|
+
*
|
|
746
|
+
* @param {CheckboxItem} item Checkbox item
|
|
747
|
+
* @returns {boolean} match item expectations
|
|
748
|
+
*/
|
|
749
|
+
const isCheckboxItem = (item) => typeof item === 'object' && typeof item.title === 'string' && (item.value === null || typeof item.value === 'boolean') && item.value !== undefined;
|
|
750
|
+
const MgInputCheckbox = class {
|
|
751
|
+
constructor(hostRef) {
|
|
752
|
+
index.registerInstance(this, hostRef);
|
|
753
|
+
this.valueChange = index.createEvent(this, "value-change", 7);
|
|
754
|
+
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
755
|
+
/************
|
|
756
|
+
* Internal *
|
|
757
|
+
************/
|
|
758
|
+
// HTML selector
|
|
759
|
+
this.inputs = [];
|
|
760
|
+
/**
|
|
761
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
762
|
+
* If not set, it will be created.
|
|
763
|
+
*/
|
|
764
|
+
this.identifier = index$1.createID('mg-input-checkbox');
|
|
765
|
+
/**
|
|
766
|
+
* Input name
|
|
767
|
+
* If not set the value equals the identifier
|
|
768
|
+
*/
|
|
769
|
+
this.name = this.identifier;
|
|
770
|
+
/**
|
|
771
|
+
* Define if label is visible
|
|
772
|
+
*/
|
|
773
|
+
this.labelHide = false;
|
|
774
|
+
/**
|
|
775
|
+
* Define if inputs are display verticaly
|
|
776
|
+
*/
|
|
777
|
+
this.inputVerticalList = false;
|
|
778
|
+
/**
|
|
779
|
+
* Define if input is required
|
|
780
|
+
*/
|
|
781
|
+
this.required = false;
|
|
782
|
+
/**
|
|
783
|
+
* Define if input is readonly
|
|
784
|
+
*/
|
|
785
|
+
this.readonly = false;
|
|
786
|
+
/**
|
|
787
|
+
* Define if input is disabled
|
|
788
|
+
*/
|
|
789
|
+
this.disabled = false;
|
|
790
|
+
/**
|
|
791
|
+
* Component classes
|
|
792
|
+
*/
|
|
793
|
+
this.classList = new index$1.ClassList(['mg-input--checkbox']);
|
|
794
|
+
/**
|
|
795
|
+
* Formated value for display
|
|
796
|
+
*/
|
|
797
|
+
this.checkboxItems = [];
|
|
798
|
+
/**
|
|
799
|
+
* Handle input event
|
|
800
|
+
*
|
|
801
|
+
* @param {InputEvent} event input event
|
|
802
|
+
*/
|
|
803
|
+
this.handleInput = (event) => {
|
|
804
|
+
this.checkboxItems = this.checkboxItems.map(item => {
|
|
805
|
+
if (item.id === event.target.id) {
|
|
806
|
+
item.value = Boolean(event.target.checked);
|
|
807
|
+
}
|
|
808
|
+
return item;
|
|
809
|
+
});
|
|
810
|
+
this.value = this.checkboxItems.map(o => ({ value: o.value, title: o.title, disabled: o.disabled }));
|
|
811
|
+
this.checkValidity();
|
|
812
|
+
};
|
|
813
|
+
/**
|
|
814
|
+
* Handle blur event
|
|
815
|
+
*/
|
|
816
|
+
this.handleBlur = () => {
|
|
817
|
+
// Check validity
|
|
818
|
+
this.checkValidity();
|
|
819
|
+
this.checkError();
|
|
820
|
+
};
|
|
821
|
+
/**
|
|
822
|
+
* Check if input is valid
|
|
823
|
+
*/
|
|
824
|
+
this.checkValidity = () => {
|
|
825
|
+
if (!this.readonly) {
|
|
826
|
+
const validity = this.getInvalidElement() === undefined;
|
|
827
|
+
// Set validity
|
|
828
|
+
this.valid = validity;
|
|
829
|
+
this.invalid = !validity;
|
|
830
|
+
//Send event
|
|
831
|
+
this.inputValid.emit(validity);
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
/**
|
|
835
|
+
* Check input errors
|
|
836
|
+
*/
|
|
837
|
+
this.checkError = () => {
|
|
838
|
+
const invalidElement = this.getInvalidElement();
|
|
839
|
+
// Set error message
|
|
840
|
+
this.errorMessage = undefined;
|
|
841
|
+
if (!this.valid && invalidElement.validity.valueMissing) {
|
|
842
|
+
this.errorMessage = this.messages.errors.required;
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
/**
|
|
846
|
+
* get invalid element
|
|
847
|
+
*
|
|
848
|
+
* @returns {HTMLInputElement} element
|
|
849
|
+
*/
|
|
850
|
+
this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
|
|
851
|
+
}
|
|
852
|
+
validateValue(newValue) {
|
|
853
|
+
if (newValue && newValue.every(item => isCheckboxItem(item))) {
|
|
854
|
+
this.checkboxItems = newValue.map((item, index) => ({
|
|
855
|
+
id: `${this.identifier}_${index.toString()}`,
|
|
856
|
+
title: item.title,
|
|
857
|
+
value: item.value,
|
|
858
|
+
disabled: item.disabled,
|
|
859
|
+
}));
|
|
860
|
+
this.valueChange.emit(newValue);
|
|
861
|
+
}
|
|
862
|
+
else {
|
|
863
|
+
throw new Error('<mg-input-checkbox> prop "value" is required and all values must be the same type, CheckboxItem.');
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* Public method to display errors
|
|
868
|
+
*
|
|
869
|
+
* @returns {Promise<void>}
|
|
870
|
+
*/
|
|
871
|
+
async displayError() {
|
|
872
|
+
this.checkValidity();
|
|
873
|
+
this.checkError();
|
|
874
|
+
}
|
|
875
|
+
/*************
|
|
876
|
+
* Lifecycle *
|
|
877
|
+
*************/
|
|
878
|
+
/**
|
|
879
|
+
* Check if component props are well configured on init
|
|
880
|
+
*
|
|
881
|
+
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
882
|
+
*/
|
|
883
|
+
componentWillLoad() {
|
|
884
|
+
// Get locales
|
|
885
|
+
this.messages = index$1.initLocales(this.element).messages;
|
|
886
|
+
// Validate
|
|
887
|
+
this.validateValue(this.value);
|
|
888
|
+
// Check validity when component is ready
|
|
889
|
+
// return a promise to process action only in the FIRST render().
|
|
890
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
891
|
+
return setTimeout(() => {
|
|
892
|
+
this.checkValidity();
|
|
893
|
+
}, 0);
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* Render
|
|
897
|
+
*
|
|
898
|
+
* @returns {HTMLElement} HTML Element
|
|
899
|
+
*/
|
|
900
|
+
render() {
|
|
901
|
+
return (index.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 && this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.checkboxItems
|
|
902
|
+
.filter(item => {
|
|
903
|
+
return !this.readonly || item.value;
|
|
904
|
+
})
|
|
905
|
+
.map(input => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.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 => this.inputs.push(el) }), index.h("label", { htmlFor: input.id }, input.title)))))));
|
|
906
|
+
}
|
|
907
|
+
get element() { return index.getElement(this); }
|
|
908
|
+
static get watchers() { return {
|
|
909
|
+
"value": ["validateValue"]
|
|
910
|
+
}; }
|
|
911
|
+
};
|
|
912
|
+
MgInputCheckbox.style = mgInputCheckboxCss;
|
|
913
|
+
|
|
914
|
+
var InputError$1;
|
|
915
|
+
(function (InputError) {
|
|
916
|
+
InputError["MIN"] = "min";
|
|
917
|
+
InputError["MAX"] = "max";
|
|
918
|
+
InputError["MINMAX"] = "minMax";
|
|
919
|
+
InputError["REQUIRED"] = "required";
|
|
920
|
+
})(InputError$1 || (InputError$1 = {}));
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* Format number to the locale currency
|
|
924
|
+
*
|
|
925
|
+
* @param {number} number number to format
|
|
926
|
+
* @param {string} locale locale to apply
|
|
927
|
+
* @param {string} currency currency to apply
|
|
928
|
+
* @returns {string} formatted currency
|
|
929
|
+
*/
|
|
930
|
+
function localeCurrency(number, locale, currency) {
|
|
931
|
+
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Format number to locale
|
|
935
|
+
*
|
|
936
|
+
* @param {number} number number to format
|
|
937
|
+
* @param {string} locale locale to apply
|
|
938
|
+
* @returns {string} formatted number
|
|
939
|
+
*/
|
|
940
|
+
function localeNumber(number, locale) {
|
|
941
|
+
return new Intl.NumberFormat(locale).format(number);
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Date RegExp
|
|
945
|
+
*/
|
|
946
|
+
const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
947
|
+
/**
|
|
948
|
+
* Locale date format
|
|
949
|
+
*
|
|
950
|
+
* @param {string} date date to format
|
|
951
|
+
* @param {string} locale locale to apply
|
|
952
|
+
* @returns {string} formatted date
|
|
953
|
+
*/
|
|
954
|
+
function localeDate(date, locale) {
|
|
955
|
+
if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
|
|
956
|
+
return '';
|
|
957
|
+
}
|
|
958
|
+
return new Intl.DateTimeFormat(locale).format(new Date(date));
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
const mgInputDateCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{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{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{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: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: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:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.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}";
|
|
962
|
+
|
|
963
|
+
const MgInputDate = class {
|
|
964
|
+
constructor(hostRef) {
|
|
965
|
+
index.registerInstance(this, hostRef);
|
|
966
|
+
this.valueChange = index.createEvent(this, "value-change", 7);
|
|
967
|
+
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
968
|
+
// hasError (triggered by blur event)
|
|
969
|
+
this.hasError = false;
|
|
970
|
+
/**
|
|
971
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
972
|
+
* If not set, it will be created.
|
|
973
|
+
*/
|
|
974
|
+
this.identifier = index$1.createID('mg-input-date');
|
|
975
|
+
/**
|
|
976
|
+
* Input name
|
|
977
|
+
* If not set the value equals the identifier
|
|
978
|
+
*/
|
|
979
|
+
this.name = this.identifier;
|
|
980
|
+
/**
|
|
981
|
+
* Define if label is visible
|
|
982
|
+
*/
|
|
983
|
+
this.labelHide = false;
|
|
984
|
+
/**
|
|
985
|
+
* Define if input is required
|
|
986
|
+
*/
|
|
987
|
+
this.required = false;
|
|
988
|
+
/**
|
|
989
|
+
* Define if input is readonly
|
|
990
|
+
*/
|
|
991
|
+
this.readonly = false;
|
|
992
|
+
/**
|
|
993
|
+
* Define if input is disabled
|
|
994
|
+
*/
|
|
995
|
+
this.disabled = false;
|
|
996
|
+
/**
|
|
997
|
+
* Component classes
|
|
998
|
+
*/
|
|
999
|
+
this.classList = new index$1.ClassList(['mg-input--date']);
|
|
1000
|
+
/**
|
|
1001
|
+
* Handle input event
|
|
1002
|
+
*/
|
|
1003
|
+
this.handleInput = () => {
|
|
1004
|
+
this.checkValidity();
|
|
1005
|
+
if (this.hasError) {
|
|
1006
|
+
this.checkError();
|
|
1007
|
+
}
|
|
1008
|
+
this.value = this.input.value;
|
|
1009
|
+
};
|
|
1010
|
+
/**
|
|
1011
|
+
* Handle blur event
|
|
1012
|
+
*/
|
|
1013
|
+
this.handleBlur = () => {
|
|
1014
|
+
this.displayError();
|
|
1015
|
+
};
|
|
1016
|
+
/**
|
|
1017
|
+
* Check if input is valid
|
|
1018
|
+
*/
|
|
1019
|
+
this.checkValidity = () => {
|
|
1020
|
+
if (!this.readonly && this.input !== undefined) {
|
|
1021
|
+
const validity = this.input.checkValidity();
|
|
1022
|
+
// Set validity
|
|
1023
|
+
this.valid = validity;
|
|
1024
|
+
this.invalid = !validity;
|
|
1025
|
+
//Send event
|
|
1026
|
+
this.inputValid.emit(validity);
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
/**
|
|
1030
|
+
* get input error code
|
|
1031
|
+
*
|
|
1032
|
+
* @returns {null | InputError} error code
|
|
1033
|
+
*/
|
|
1034
|
+
this.getInputError = () => {
|
|
1035
|
+
var _a, _b;
|
|
1036
|
+
let inputError = null;
|
|
1037
|
+
// required
|
|
1038
|
+
if (this.input.validity.valueMissing) {
|
|
1039
|
+
inputError = InputError$1.REQUIRED;
|
|
1040
|
+
}
|
|
1041
|
+
// min & max
|
|
1042
|
+
else if ((this.input.validity.rangeUnderflow || this.input.validity.rangeOverflow) && ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 && ((_b = this.max) === null || _b === void 0 ? void 0 : _b.length) > 0) {
|
|
1043
|
+
inputError = InputError$1.MINMAX;
|
|
1044
|
+
}
|
|
1045
|
+
// min
|
|
1046
|
+
else if (this.input.validity.rangeUnderflow) {
|
|
1047
|
+
inputError = InputError$1.MIN;
|
|
1048
|
+
}
|
|
1049
|
+
//max
|
|
1050
|
+
else if (this.input.validity.rangeOverflow) {
|
|
1051
|
+
inputError = InputError$1.MAX;
|
|
1052
|
+
}
|
|
1053
|
+
return inputError;
|
|
1054
|
+
};
|
|
1055
|
+
/**
|
|
1056
|
+
* Set error message
|
|
1057
|
+
*
|
|
1058
|
+
* @returns {void}
|
|
1059
|
+
*/
|
|
1060
|
+
this.setErrorMessage = () => {
|
|
1061
|
+
var _a;
|
|
1062
|
+
const inputError = this.getInputError();
|
|
1063
|
+
// required
|
|
1064
|
+
if (inputError === InputError$1.REQUIRED) {
|
|
1065
|
+
this.errorMessage = this.messages.errors[inputError];
|
|
1066
|
+
}
|
|
1067
|
+
// min, max & minMax
|
|
1068
|
+
else if ([InputError$1.MIN, InputError$1.MAX, InputError$1.MINMAX].includes(inputError)) {
|
|
1069
|
+
this.errorMessage = this.messages.errors.date[inputError].replace('{min}', localeDate(this.min, this.locale)).replace('{max}', localeDate(this.max, this.locale));
|
|
1070
|
+
}
|
|
1071
|
+
// wrong date format
|
|
1072
|
+
// element.validity.badInput is default error message
|
|
1073
|
+
else {
|
|
1074
|
+
this.errorMessage = this.messages.errors.date.badInput.replace('{min}', ((_a = this.min) === null || _a === void 0 ? void 0 : _a.length) > 0 ? localeDate(this.min, this.locale) : localeDate('1900-01-01', this.locale));
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
/**
|
|
1078
|
+
* Check input errors
|
|
1079
|
+
*
|
|
1080
|
+
* @returns {void}
|
|
1081
|
+
*/
|
|
1082
|
+
this.checkError = () => {
|
|
1083
|
+
// Set error message
|
|
1084
|
+
this.errorMessage = undefined;
|
|
1085
|
+
if (!this.valid) {
|
|
1086
|
+
this.setErrorMessage();
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
validateValue(newValue) {
|
|
1091
|
+
if (newValue !== undefined && newValue !== '' && !(typeof newValue === 'string' && dateRegExp.test(newValue))) {
|
|
1092
|
+
throw new Error("<mg-input-date> props 'value' doesn't match pattern: yyyy-mm-dd");
|
|
1093
|
+
}
|
|
1094
|
+
else {
|
|
1095
|
+
this.valueChange.emit(this.value);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
validateMin(newValue) {
|
|
1099
|
+
this.validateDateFormat(newValue);
|
|
1100
|
+
}
|
|
1101
|
+
validateMax(newValue) {
|
|
1102
|
+
this.validateDateFormat(newValue);
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Public method to display errors
|
|
1106
|
+
*
|
|
1107
|
+
* @returns {Promise<void>}
|
|
1108
|
+
*/
|
|
1109
|
+
async displayError() {
|
|
1110
|
+
this.checkValidity();
|
|
1111
|
+
this.checkError();
|
|
1112
|
+
this.hasError = this.invalid;
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Date format validation
|
|
1116
|
+
*
|
|
1117
|
+
* @param {string} date date to validate
|
|
1118
|
+
* @returns {void}
|
|
1119
|
+
*/
|
|
1120
|
+
validateDateFormat(date) {
|
|
1121
|
+
if ((date === null || date === void 0 ? void 0 : date.length) > 0 && !(typeof date === 'string' && dateRegExp.test(date))) {
|
|
1122
|
+
throw new Error("<mg-input-date> props 'min/max' doesn't match pattern: yyyy-mm-dd");
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
/*************
|
|
1126
|
+
* Lifecycle *
|
|
1127
|
+
*************/
|
|
1128
|
+
/**
|
|
1129
|
+
* Check if component props are well configured on init
|
|
1130
|
+
*
|
|
1131
|
+
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
1132
|
+
*/
|
|
1133
|
+
componentWillLoad() {
|
|
1134
|
+
// Get locales
|
|
1135
|
+
const locales = index$1.initLocales(this.element);
|
|
1136
|
+
this.locale = locales.locale;
|
|
1137
|
+
this.messages = locales.messages;
|
|
1138
|
+
// Validate
|
|
1139
|
+
this.validateValue(this.value);
|
|
1140
|
+
this.validateMin(this.min);
|
|
1141
|
+
this.validateMax(this.max);
|
|
1142
|
+
// Check validity when component is ready
|
|
1143
|
+
// return a promise to process action only in the FIRST render().
|
|
1144
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
1145
|
+
return setTimeout(() => {
|
|
1146
|
+
this.checkValidity();
|
|
1147
|
+
}, 0);
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Render
|
|
1151
|
+
*
|
|
1152
|
+
* @returns {HTMLElement} HTML Element
|
|
1153
|
+
*/
|
|
1154
|
+
render() {
|
|
1155
|
+
return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: localeDate(this.value, this.locale), tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "date", class: "mg-input__box", min: this.min, max: this.max, value: this.value, id: this.identifier, name: this.name, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, pattern: "[0-9]{4}-[0-9]{2}-[0-9]{2}", ref: el => (this.input = el) })));
|
|
1156
|
+
}
|
|
1157
|
+
get element() { return index.getElement(this); }
|
|
1158
|
+
static get watchers() { return {
|
|
1159
|
+
"value": ["validateValue"],
|
|
1160
|
+
"min": ["validateMin"],
|
|
1161
|
+
"max": ["validateMax"]
|
|
1162
|
+
}; }
|
|
1163
|
+
};
|
|
1164
|
+
MgInputDate.style = mgInputDateCss;
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* List of all possibles types
|
|
1168
|
+
*/
|
|
1169
|
+
const types = ['decimal', 'integer', 'currency'];
|
|
1170
|
+
var InputError;
|
|
1171
|
+
(function (InputError) {
|
|
1172
|
+
InputError["MIN"] = "min";
|
|
1173
|
+
InputError["MAX"] = "max";
|
|
1174
|
+
InputError["MINMAX"] = "minMax";
|
|
1175
|
+
InputError["REQUIRED"] = "required";
|
|
1176
|
+
})(InputError || (InputError = {}));
|
|
1177
|
+
|
|
1178
|
+
const mgInputNumericCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{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{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{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: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: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:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width: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__box{text-align:var(--mg-inputs-text-align, right)}";
|
|
1179
|
+
|
|
1180
|
+
const MgInputNumeric = class {
|
|
1181
|
+
constructor(hostRef) {
|
|
1182
|
+
index.registerInstance(this, hostRef);
|
|
1183
|
+
this.valueChange = index.createEvent(this, "value-change", 7);
|
|
1184
|
+
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
1185
|
+
// hasError (triggered by blur event)
|
|
1186
|
+
this.hasError = false;
|
|
1187
|
+
/**
|
|
1188
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
1189
|
+
* If not set, it will be created.
|
|
1190
|
+
*/
|
|
1191
|
+
this.identifier = index$1.createID('mg-input-numeric');
|
|
1192
|
+
/**
|
|
1193
|
+
* Input name
|
|
1194
|
+
* If not set the value equals the identifier
|
|
1195
|
+
*/
|
|
1196
|
+
this.name = this.identifier;
|
|
1197
|
+
/**
|
|
1198
|
+
* Define if label is visible
|
|
1199
|
+
*/
|
|
1200
|
+
this.labelHide = false;
|
|
1201
|
+
/**
|
|
1202
|
+
* Define if input is required
|
|
1203
|
+
*/
|
|
1204
|
+
this.required = false;
|
|
1205
|
+
/**
|
|
1206
|
+
* Define if input is readonly
|
|
1207
|
+
*/
|
|
1208
|
+
this.readonly = false;
|
|
1209
|
+
/**
|
|
1210
|
+
* Define if input is disabled
|
|
1211
|
+
*/
|
|
1212
|
+
this.disabled = false;
|
|
1213
|
+
/**
|
|
1214
|
+
* Define numeric type
|
|
1215
|
+
*/
|
|
1216
|
+
this.type = types[0];
|
|
1217
|
+
/**
|
|
1218
|
+
* Define currency
|
|
1219
|
+
*/
|
|
1220
|
+
this.currency = 'USD';
|
|
1221
|
+
/**
|
|
1222
|
+
* Override integer length
|
|
1223
|
+
* integer is the number before the decimal point
|
|
1224
|
+
*/
|
|
1225
|
+
this.integerLength = 13;
|
|
1226
|
+
/**
|
|
1227
|
+
* Override decimal length
|
|
1228
|
+
* decimal is the number after the decimal point
|
|
1229
|
+
*/
|
|
1230
|
+
this.decimalLength = 2;
|
|
1231
|
+
/**
|
|
1232
|
+
* Component classes
|
|
1233
|
+
*/
|
|
1234
|
+
this.classList = new index$1.ClassList(['mg-input--numeric']);
|
|
1235
|
+
/**
|
|
1236
|
+
* Define if input has focus
|
|
1237
|
+
*/
|
|
1238
|
+
this.hasFocus = false;
|
|
1239
|
+
/**
|
|
1240
|
+
* Handle input event
|
|
1241
|
+
*
|
|
1242
|
+
* @returns {void}
|
|
1243
|
+
*/
|
|
1244
|
+
this.handleInput = () => {
|
|
1245
|
+
// Check validity
|
|
1246
|
+
this.checkValidity();
|
|
1247
|
+
if (this.hasError) {
|
|
1248
|
+
this.checkError();
|
|
1249
|
+
}
|
|
1250
|
+
this.value = this.input.value;
|
|
1251
|
+
};
|
|
1252
|
+
/**
|
|
1253
|
+
* Handle focus event
|
|
1254
|
+
*
|
|
1255
|
+
* @returns {void}
|
|
1256
|
+
*/
|
|
1257
|
+
this.handleFocus = () => {
|
|
1258
|
+
this.hasFocus = true;
|
|
1259
|
+
};
|
|
1260
|
+
/**
|
|
1261
|
+
* Handle blur event
|
|
1262
|
+
*
|
|
1263
|
+
* @returns {void}
|
|
1264
|
+
*/
|
|
1265
|
+
this.handleBlur = () => {
|
|
1266
|
+
// Display Error
|
|
1267
|
+
this.displayError();
|
|
1268
|
+
this.hasFocus = false;
|
|
1269
|
+
};
|
|
1270
|
+
/**
|
|
1271
|
+
* Check if input is valid
|
|
1272
|
+
*
|
|
1273
|
+
* @returns {void}
|
|
1274
|
+
*/
|
|
1275
|
+
this.checkValidity = () => {
|
|
1276
|
+
if (!this.readonly) {
|
|
1277
|
+
const validity = this.getInputError() === null;
|
|
1278
|
+
// Set validity
|
|
1279
|
+
this.valid = validity;
|
|
1280
|
+
this.invalid = !validity;
|
|
1281
|
+
//Send event
|
|
1282
|
+
this.inputValid.emit(validity);
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
/**
|
|
1286
|
+
* Set error message
|
|
1287
|
+
*
|
|
1288
|
+
* @returns {void}
|
|
1289
|
+
*/
|
|
1290
|
+
this.setErrorMessage = () => {
|
|
1291
|
+
const inputError = this.getInputError();
|
|
1292
|
+
if (inputError === InputError.REQUIRED) {
|
|
1293
|
+
this.errorMessage = this.messages.errors[inputError];
|
|
1294
|
+
}
|
|
1295
|
+
else {
|
|
1296
|
+
this.errorMessage = this.messages.errors.numeric[inputError].replace('{min}', `${this.formatValue(this.min)}`).replace('{max}', `${this.formatValue(this.max)}`);
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1299
|
+
/**
|
|
1300
|
+
* Check input errors
|
|
1301
|
+
*
|
|
1302
|
+
* @returns {void}
|
|
1303
|
+
*/
|
|
1304
|
+
this.checkError = () => {
|
|
1305
|
+
// Set error message
|
|
1306
|
+
this.errorMessage = undefined;
|
|
1307
|
+
// Update class
|
|
1308
|
+
if (!this.valid) {
|
|
1309
|
+
this.setErrorMessage();
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
/**
|
|
1313
|
+
* Get input error code
|
|
1314
|
+
*
|
|
1315
|
+
* @returns {null | InputError} error code
|
|
1316
|
+
*/
|
|
1317
|
+
this.getInputError = () => {
|
|
1318
|
+
let inputError = null;
|
|
1319
|
+
if (this.input === undefined)
|
|
1320
|
+
return inputError;
|
|
1321
|
+
// required
|
|
1322
|
+
if (!this.input.checkValidity() && this.input.validity.valueMissing) {
|
|
1323
|
+
inputError = InputError.REQUIRED;
|
|
1324
|
+
}
|
|
1325
|
+
// Min & Max
|
|
1326
|
+
else if (this.min !== undefined && this.numericValue < this.min && this.max === undefined) {
|
|
1327
|
+
// Only a min value is set
|
|
1328
|
+
inputError = InputError.MIN;
|
|
1329
|
+
}
|
|
1330
|
+
else if (this.max !== undefined && this.numericValue > this.max && this.min === undefined) {
|
|
1331
|
+
// Only a max value is set
|
|
1332
|
+
inputError = InputError.MAX;
|
|
1333
|
+
}
|
|
1334
|
+
else if ((this.min !== undefined && this.numericValue < this.min) || (this.max !== undefined && this.numericValue > this.max)) {
|
|
1335
|
+
// both min and max values are set
|
|
1336
|
+
inputError = InputError.MINMAX;
|
|
1337
|
+
}
|
|
1338
|
+
return inputError;
|
|
1339
|
+
};
|
|
1340
|
+
/**
|
|
1341
|
+
* Format value based on type
|
|
1342
|
+
*
|
|
1343
|
+
* @param {number} value value to format
|
|
1344
|
+
* @returns {string} formated local value
|
|
1345
|
+
*/
|
|
1346
|
+
this.formatValue = (value) => (this.type === 'currency' ? localeCurrency(value, this.locale, this.currency) : localeNumber(value, this.locale));
|
|
1347
|
+
/**
|
|
1348
|
+
* Validate append slot
|
|
1349
|
+
*
|
|
1350
|
+
* @returns {void}
|
|
1351
|
+
*/
|
|
1352
|
+
this.validateAppendSlot = () => {
|
|
1353
|
+
const slotAppendInput = this.element.querySelector('[slot="append-input"]');
|
|
1354
|
+
if (slotAppendInput !== null) {
|
|
1355
|
+
this.classList.add(slotAppendInput.nodeName === 'MG-BUTTON' ? 'mg-input--is-input-group-append' : 'mg-input--is-append-input-slot-content');
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
validateValue(newValue) {
|
|
1360
|
+
if (newValue !== undefined && newValue !== null) {
|
|
1361
|
+
// Split number and decimal
|
|
1362
|
+
const [integer, decimal = ''] = newValue.replace('-', '').split(/[\.,]/);
|
|
1363
|
+
// Regex
|
|
1364
|
+
const regex = this.type === 'integer' ? /^[\-]?\d+$/ : /^[\-]?\d+[.,]?\d*$/;
|
|
1365
|
+
// Filter input
|
|
1366
|
+
if (newValue === '' || (newValue.match(regex) && integer.length <= this.integerLength && decimal.length <= (this.type === 'integer' ? 0 : this.decimalLength))) {
|
|
1367
|
+
this.storedValue = newValue;
|
|
1368
|
+
}
|
|
1369
|
+
else if (this.storedValue !== undefined) {
|
|
1370
|
+
newValue = this.storedValue;
|
|
1371
|
+
}
|
|
1372
|
+
else {
|
|
1373
|
+
newValue = null;
|
|
1374
|
+
}
|
|
1375
|
+
// Set value and input value
|
|
1376
|
+
this.value = newValue;
|
|
1377
|
+
if (this.input !== undefined)
|
|
1378
|
+
this.input.value = this.value;
|
|
1379
|
+
// emit numeric value
|
|
1380
|
+
this.numericValue = this.value !== '' && this.value !== null ? parseFloat(this.value.replace(',', '.')) : null;
|
|
1381
|
+
this.valueChange.emit(this.numericValue);
|
|
1382
|
+
// Set readonlyValue
|
|
1383
|
+
this.readonlyValue = this.numericValue !== null ? this.formatValue(this.numericValue) : '';
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
validateType(newValue) {
|
|
1387
|
+
if (!types.includes(newValue)) {
|
|
1388
|
+
throw new Error(`<mg-input-numeric> prop "type" must be one of : ${types.join(', ')}`);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
validateIntegerLength(newValue) {
|
|
1392
|
+
if (newValue < 1) {
|
|
1393
|
+
throw new Error(`<mg-input-numeric> prop "integer-length" must be a positive number.`);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
validateDecimalLength(newValue) {
|
|
1397
|
+
if (newValue < 1) {
|
|
1398
|
+
throw new Error(`<mg-input-numeric> prop "decimal-length" must be a positive number, consider using prop "type" to "integer" instead.`);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Public method to display errors
|
|
1403
|
+
*
|
|
1404
|
+
* @returns {Promise<void>}
|
|
1405
|
+
*/
|
|
1406
|
+
async displayError() {
|
|
1407
|
+
this.checkValidity();
|
|
1408
|
+
this.checkError();
|
|
1409
|
+
this.hasError = this.invalid;
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1412
|
+
* Displayed value in input
|
|
1413
|
+
* Change on focus/blur
|
|
1414
|
+
*
|
|
1415
|
+
* @returns {string} display value
|
|
1416
|
+
*/
|
|
1417
|
+
displayValue() {
|
|
1418
|
+
return this.hasFocus ? this.value : this.readonlyValue;
|
|
1419
|
+
}
|
|
1420
|
+
/*************
|
|
1421
|
+
* Lifecycle *
|
|
1422
|
+
*************/
|
|
1423
|
+
/**
|
|
1424
|
+
* Check if component props are well configured on init
|
|
1425
|
+
*
|
|
1426
|
+
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
1427
|
+
*/
|
|
1428
|
+
componentWillLoad() {
|
|
1429
|
+
// Get locales
|
|
1430
|
+
const locales = index$1.initLocales(this.element);
|
|
1431
|
+
this.locale = locales.locale;
|
|
1432
|
+
this.messages = locales.messages;
|
|
1433
|
+
// Validate
|
|
1434
|
+
this.validateValue(this.value);
|
|
1435
|
+
this.validateType(this.type);
|
|
1436
|
+
this.validateIntegerLength(this.integerLength);
|
|
1437
|
+
this.validateDecimalLength(this.decimalLength);
|
|
1438
|
+
this.validateAppendSlot();
|
|
1439
|
+
// Check validity when component is ready
|
|
1440
|
+
// return a promise to process action only in the FIRST render().
|
|
1441
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
1442
|
+
return setTimeout(() => {
|
|
1443
|
+
this.checkValidity();
|
|
1444
|
+
}, 0);
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* Render
|
|
1448
|
+
*
|
|
1449
|
+
* @returns {HTMLElement} HTML Element
|
|
1450
|
+
*/
|
|
1451
|
+
render() {
|
|
1452
|
+
return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "text", class: "mg-input__box", value: this.displayValue(), id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), index.h("slot", { name: "append-input" })));
|
|
1453
|
+
}
|
|
1454
|
+
get element() { return index.getElement(this); }
|
|
1455
|
+
static get watchers() { return {
|
|
1456
|
+
"value": ["validateValue"],
|
|
1457
|
+
"type": ["validateType"],
|
|
1458
|
+
"integerLength": ["validateIntegerLength"],
|
|
1459
|
+
"decimalLength": ["validateDecimalLength"]
|
|
1460
|
+
}; }
|
|
1461
|
+
};
|
|
1462
|
+
MgInputNumeric.style = mgInputNumericCss;
|
|
1463
|
+
|
|
1464
|
+
const mgInputPasswordCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{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{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{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: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: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:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width: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}";
|
|
1465
|
+
|
|
1466
|
+
const MgInputPassword = class {
|
|
1467
|
+
constructor(hostRef) {
|
|
1468
|
+
index.registerInstance(this, hostRef);
|
|
1469
|
+
this.valueChange = index.createEvent(this, "value-change", 7);
|
|
1470
|
+
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
1471
|
+
// hasError (triggered by blur event)
|
|
1472
|
+
this.hasError = false;
|
|
1473
|
+
/**
|
|
1474
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
1475
|
+
* If not set, it will be created.
|
|
1476
|
+
*/
|
|
1477
|
+
this.identifier = index$1.createID('mg-input-password');
|
|
1478
|
+
/**
|
|
1479
|
+
* Input name
|
|
1480
|
+
* If not set the value equals the identifier
|
|
1481
|
+
*/
|
|
1482
|
+
this.name = this.identifier;
|
|
1483
|
+
/**
|
|
1484
|
+
* Define if label is visible
|
|
1485
|
+
*/
|
|
1486
|
+
this.labelHide = false;
|
|
1487
|
+
/**
|
|
1488
|
+
* Define if input is required
|
|
1489
|
+
*/
|
|
1490
|
+
this.required = false;
|
|
1491
|
+
/**
|
|
1492
|
+
* Define if input is readonly
|
|
1493
|
+
*/
|
|
1494
|
+
this.readonly = false;
|
|
1495
|
+
/**
|
|
1496
|
+
* Define if input is disabled
|
|
1497
|
+
*/
|
|
1498
|
+
this.disabled = false;
|
|
1499
|
+
/**
|
|
1500
|
+
* Define input width
|
|
1501
|
+
*/
|
|
1502
|
+
this.mgWidth = 'full';
|
|
1503
|
+
/**
|
|
1504
|
+
* Component classes
|
|
1505
|
+
*/
|
|
1506
|
+
this.classList = new index$1.ClassList(['mg-input--password']);
|
|
1507
|
+
/**
|
|
1508
|
+
* Handle input event
|
|
1509
|
+
*/
|
|
1510
|
+
this.handleInput = () => {
|
|
1511
|
+
this.checkValidity();
|
|
1512
|
+
if (this.hasError) {
|
|
1513
|
+
this.checkError();
|
|
1514
|
+
}
|
|
1515
|
+
this.value = this.input.value;
|
|
1516
|
+
};
|
|
1517
|
+
/**
|
|
1518
|
+
* Handle blur event
|
|
1519
|
+
*/
|
|
1520
|
+
this.handleBlur = () => {
|
|
1521
|
+
this.displayError();
|
|
1522
|
+
};
|
|
1523
|
+
/**
|
|
1524
|
+
* Check if input is valid
|
|
1525
|
+
*/
|
|
1526
|
+
this.checkValidity = () => {
|
|
1527
|
+
if (!this.readonly && this.input !== undefined) {
|
|
1528
|
+
const validity = this.input.checkValidity();
|
|
1529
|
+
// Set validity
|
|
1530
|
+
this.valid = validity;
|
|
1531
|
+
this.invalid = !validity;
|
|
1532
|
+
//Send event
|
|
1533
|
+
this.inputValid.emit(validity);
|
|
1534
|
+
}
|
|
1535
|
+
};
|
|
1536
|
+
/**
|
|
1537
|
+
* Check input errors
|
|
1538
|
+
*/
|
|
1539
|
+
this.checkError = () => {
|
|
1540
|
+
// Set error message
|
|
1541
|
+
this.errorMessage = undefined;
|
|
1542
|
+
// required
|
|
1543
|
+
if (!this.valid && this.input.validity.valueMissing) {
|
|
1544
|
+
this.errorMessage = this.messages.errors.required;
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
}
|
|
1548
|
+
handleValue(newValue) {
|
|
1549
|
+
this.valueChange.emit(newValue);
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* Public method to display errors
|
|
1553
|
+
*
|
|
1554
|
+
* @returns {Promise<void>}
|
|
1555
|
+
*/
|
|
1556
|
+
async displayError() {
|
|
1557
|
+
this.checkValidity();
|
|
1558
|
+
this.checkError();
|
|
1559
|
+
this.hasError = this.invalid;
|
|
1560
|
+
}
|
|
1561
|
+
/*************
|
|
1562
|
+
* Lifecycle *
|
|
1563
|
+
*************/
|
|
1564
|
+
/**
|
|
1565
|
+
* Check if component props are well configured on init
|
|
1566
|
+
*
|
|
1567
|
+
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
1568
|
+
*/
|
|
1569
|
+
componentWillLoad() {
|
|
1570
|
+
// Get locales
|
|
1571
|
+
this.messages = index$1.initLocales(this.element).messages;
|
|
1572
|
+
// Check validity when component is ready
|
|
1573
|
+
// return a promise to process action only in the FIRST render().
|
|
1574
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
1575
|
+
return setTimeout(() => {
|
|
1576
|
+
this.checkValidity();
|
|
1577
|
+
}, 0);
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Render
|
|
1581
|
+
*
|
|
1582
|
+
* @returns {HTMLElement} HTML Element
|
|
1583
|
+
*/
|
|
1584
|
+
render() {
|
|
1585
|
+
return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.value !== undefined ? '•'.repeat(this.value.length) : undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("input", { type: "password", class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) })));
|
|
1586
|
+
}
|
|
1587
|
+
get element() { return index.getElement(this); }
|
|
1588
|
+
static get watchers() { return {
|
|
1589
|
+
"value": ["handleValue"]
|
|
1590
|
+
}; }
|
|
1591
|
+
};
|
|
1592
|
+
MgInputPassword.style = mgInputPasswordCss;
|
|
1593
|
+
|
|
1594
|
+
const mgInputRadioCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{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{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{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: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: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:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}fieldset.mg-input{border:0;margin-left:0;margin-right:0;padding:0}fieldset.mg-input input[type=radio],fieldset.mg-input input[type=checkbox]{flex-shrink:0;width:var(--mg-input-check-size);height:var(--mg-input-check-size);margin-top:calc((var(--font-size) * var(--line-height) - var(--mg-input-check-size)) / 2);margin-right:0.6rem;margin-bottom:0;margin-left:0}fieldset.mg-input.mg-input--label-on-top .mg-input__input-group-container{margin-top:0.7rem}.mg-input__input-container mg-tooltip{margin-left:3rem}.mg-input__input-group-container{margin:0;padding:0;list-style:none;display:flex;flex-wrap:wrap;column-gap:2.3rem;row-gap:1rem;margin-top:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2)}.mg-input__input-group-container--vertical{flex-direction:column}.mg-input__input-group{display:flex;align-items:top}.mg-input__input-group.mg-input__input-group--disabled label{opacity:0.3}.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}";
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* type Option validation function
|
|
1598
|
+
*
|
|
1599
|
+
* @param {RadioOption} option radio option
|
|
1600
|
+
* @returns {boolean} radio option type is valid
|
|
1601
|
+
*/
|
|
1602
|
+
const isOption$2 = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
1603
|
+
const MgInputRadio = class {
|
|
1604
|
+
constructor(hostRef) {
|
|
1605
|
+
index.registerInstance(this, hostRef);
|
|
1606
|
+
this.valueChange = index.createEvent(this, "value-change", 7);
|
|
1607
|
+
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
1608
|
+
/************
|
|
1609
|
+
* Internal *
|
|
1610
|
+
************/
|
|
1611
|
+
// HTML selector
|
|
1612
|
+
this.inputs = [];
|
|
1613
|
+
/**
|
|
1614
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
1615
|
+
* If not set, it will be created.
|
|
1616
|
+
*/
|
|
1617
|
+
this.identifier = index$1.createID('mg-input-radio');
|
|
1618
|
+
/**
|
|
1619
|
+
* Input name
|
|
1620
|
+
* If not set the value equals the identifier
|
|
1621
|
+
*/
|
|
1622
|
+
this.name = this.identifier;
|
|
1623
|
+
/**
|
|
1624
|
+
* Define if label is displayed on top
|
|
1625
|
+
*/
|
|
1626
|
+
this.labelOnTop = false;
|
|
1627
|
+
/**
|
|
1628
|
+
* Define if label is visible
|
|
1629
|
+
*/
|
|
1630
|
+
this.labelHide = false;
|
|
1631
|
+
/**
|
|
1632
|
+
* Define if inputs are display verticaly
|
|
1633
|
+
*/
|
|
1634
|
+
this.inputVerticalList = false;
|
|
1635
|
+
/**
|
|
1636
|
+
* Define if input is required
|
|
1637
|
+
*/
|
|
1638
|
+
this.required = false;
|
|
1639
|
+
/**
|
|
1640
|
+
* Define if input is readonly
|
|
1641
|
+
*/
|
|
1642
|
+
this.readonly = false;
|
|
1643
|
+
/**
|
|
1644
|
+
* Define if input is disabled
|
|
1645
|
+
*/
|
|
1646
|
+
this.disabled = false;
|
|
1647
|
+
/**
|
|
1648
|
+
* Component classes
|
|
1649
|
+
*/
|
|
1650
|
+
this.classList = new index$1.ClassList(['mg-input--radio']);
|
|
1651
|
+
/**
|
|
1652
|
+
* Handle input event
|
|
1653
|
+
*
|
|
1654
|
+
* @param {event} event input event
|
|
1655
|
+
* @returns {void}
|
|
1656
|
+
*/
|
|
1657
|
+
this.handleInput = (event) => {
|
|
1658
|
+
this.checkValidity();
|
|
1659
|
+
this.value = this.options[event.target.value].value;
|
|
1660
|
+
};
|
|
1661
|
+
/**
|
|
1662
|
+
* Handle blur event
|
|
1663
|
+
*
|
|
1664
|
+
* @returns {void}
|
|
1665
|
+
*/
|
|
1666
|
+
this.handleBlur = () => {
|
|
1667
|
+
this.checkValidity();
|
|
1668
|
+
this.checkError();
|
|
1669
|
+
};
|
|
1670
|
+
/**
|
|
1671
|
+
* Check if input is valid
|
|
1672
|
+
*
|
|
1673
|
+
* @returns {void}
|
|
1674
|
+
*/
|
|
1675
|
+
this.checkValidity = () => {
|
|
1676
|
+
if (!this.readonly) {
|
|
1677
|
+
const validity = this.getInvalidElement() === undefined;
|
|
1678
|
+
// Set validity
|
|
1679
|
+
this.valid = validity;
|
|
1680
|
+
this.invalid = !validity;
|
|
1681
|
+
//Send event
|
|
1682
|
+
this.inputValid.emit(validity);
|
|
1683
|
+
}
|
|
1684
|
+
};
|
|
1685
|
+
/**
|
|
1686
|
+
* Check input errors
|
|
1687
|
+
*
|
|
1688
|
+
* @returns {void}
|
|
1689
|
+
*/
|
|
1690
|
+
this.checkError = () => {
|
|
1691
|
+
const invalidElement = this.getInvalidElement();
|
|
1692
|
+
// Set error message
|
|
1693
|
+
this.errorMessage = undefined;
|
|
1694
|
+
if (!this.valid && invalidElement.validity.valueMissing) {
|
|
1695
|
+
this.errorMessage = this.messages.errors.required;
|
|
1696
|
+
}
|
|
1697
|
+
};
|
|
1698
|
+
/**
|
|
1699
|
+
* get invalid element
|
|
1700
|
+
*
|
|
1701
|
+
* @returns {HTMLInputElement} element
|
|
1702
|
+
*/
|
|
1703
|
+
this.getInvalidElement = () => this.inputs.find((element) => !element.disabled && !element.checkValidity());
|
|
1704
|
+
}
|
|
1705
|
+
handleValue(newValue) {
|
|
1706
|
+
this.valueChange.emit(newValue);
|
|
1707
|
+
}
|
|
1708
|
+
validateItems(newValue) {
|
|
1709
|
+
// Validate if items have required min length
|
|
1710
|
+
if (typeof newValue === 'object' && newValue.length < 2) {
|
|
1711
|
+
throw new Error('<mg-input-radio> prop "items" require at least 2 items.');
|
|
1712
|
+
}
|
|
1713
|
+
// String array
|
|
1714
|
+
else if (index$1.allItemsAreString(newValue)) {
|
|
1715
|
+
this.options = newValue.map(item => ({ title: item, value: item, disabled: this.disabled }));
|
|
1716
|
+
}
|
|
1717
|
+
// Object array
|
|
1718
|
+
else if (newValue && newValue.every(item => isOption$2(item))) {
|
|
1719
|
+
this.options = newValue;
|
|
1720
|
+
}
|
|
1721
|
+
else {
|
|
1722
|
+
throw new Error('<mg-input-radio> prop "items" is required and all items must be the same type, string or RadioOption.');
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Public method to display errors
|
|
1727
|
+
*
|
|
1728
|
+
* @returns {Promise<void>}
|
|
1729
|
+
*/
|
|
1730
|
+
async displayError() {
|
|
1731
|
+
this.checkValidity();
|
|
1732
|
+
this.checkError();
|
|
1733
|
+
}
|
|
1734
|
+
/*************
|
|
1735
|
+
* Lifecycle *
|
|
1736
|
+
*************/
|
|
1737
|
+
/**
|
|
1738
|
+
* Check if component props are well configured on init
|
|
1739
|
+
*
|
|
1740
|
+
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
1741
|
+
*/
|
|
1742
|
+
componentWillLoad() {
|
|
1743
|
+
// Get locales
|
|
1744
|
+
this.messages = index$1.initLocales(this.element).messages;
|
|
1745
|
+
// Validate
|
|
1746
|
+
this.validateItems(this.items);
|
|
1747
|
+
// Check validity when component is ready
|
|
1748
|
+
// return a promise to process action only in the FIRST render().
|
|
1749
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
1750
|
+
return setTimeout(() => {
|
|
1751
|
+
this.checkValidity();
|
|
1752
|
+
}, 0);
|
|
1753
|
+
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Render
|
|
1756
|
+
*
|
|
1757
|
+
* @returns {HTMLElement} HTML Element
|
|
1758
|
+
*/
|
|
1759
|
+
render() {
|
|
1760
|
+
return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, disabled: this.disabled, readonly: this.readonly, mgWidth: undefined, value: this.value, readonlyValue: this.value, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: true }, index.h("ul", { class: { 'mg-input__input-group-container': true, 'mg-input__input-group-container--vertical': this.inputVerticalList } }, this.options.map((input, index$1) => (index.h("li", { class: { 'mg-input__input-group': true, 'mg-input__input-group--disabled': this.disabled || input.disabled } }, index.h("input", { type: "radio", id: this.identifier + '_' + index$1, name: this.identifier, value: index$1, checked: JSON.stringify(this.value) === JSON.stringify(this.options[index$1].value), disabled: this.disabled || input.disabled, required: this.required, onBlur: this.handleBlur, onInput: this.handleInput, ref: el => this.inputs.push(el) }), index.h("label", { htmlFor: this.identifier + '_' + index$1 }, input.title)))))));
|
|
1761
|
+
}
|
|
1762
|
+
get element() { return index.getElement(this); }
|
|
1763
|
+
static get watchers() { return {
|
|
1764
|
+
"value": ["handleValue"],
|
|
1765
|
+
"items": ["validateItems"]
|
|
1766
|
+
}; }
|
|
1767
|
+
};
|
|
1768
|
+
MgInputRadio.style = mgInputRadioCss;
|
|
1769
|
+
|
|
1770
|
+
const mgInputSelectCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{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{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{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: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: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:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width: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__box{width:100%;padding-top:0;padding-bottom:0;padding-right:1rem}";
|
|
1771
|
+
|
|
1772
|
+
/**
|
|
1773
|
+
* Check if item is a well configured option
|
|
1774
|
+
*
|
|
1775
|
+
* @param {SelectOption} option select option
|
|
1776
|
+
* @returns {boolean} select option type is valid
|
|
1777
|
+
*/
|
|
1778
|
+
const isOption$1 = (option) => typeof option === 'object' && typeof option.title === 'string';
|
|
1779
|
+
/**
|
|
1780
|
+
* Group options
|
|
1781
|
+
*
|
|
1782
|
+
* @param {(SelectOption | OptGroup)[]} acc reduce accumulator
|
|
1783
|
+
* @param {SelectOption} item item to add
|
|
1784
|
+
* @param {string} item.group item group
|
|
1785
|
+
* @param {string} item.title item title
|
|
1786
|
+
* @param {unknown} item.value item value
|
|
1787
|
+
* @param {boolean} item.disabled is item disabled
|
|
1788
|
+
* @returns {(SelectOption | OptGroup)[]} grouped options
|
|
1789
|
+
*/
|
|
1790
|
+
const groupOptions = (acc, { group, title, value, disabled }) => {
|
|
1791
|
+
if (group !== undefined) {
|
|
1792
|
+
// Check if group is already created
|
|
1793
|
+
const optGroup = acc.find(grp => grp.group === group);
|
|
1794
|
+
// Add to group
|
|
1795
|
+
if (optGroup !== undefined) {
|
|
1796
|
+
optGroup.options.push({ title, value, disabled });
|
|
1797
|
+
}
|
|
1798
|
+
// Create group
|
|
1799
|
+
else {
|
|
1800
|
+
acc.push({ group, options: [{ title, value, disabled }] });
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
else {
|
|
1804
|
+
acc.push({ title, value, disabled });
|
|
1805
|
+
}
|
|
1806
|
+
return acc;
|
|
1807
|
+
};
|
|
1808
|
+
const MgInputSelect = class {
|
|
1809
|
+
constructor(hostRef) {
|
|
1810
|
+
index.registerInstance(this, hostRef);
|
|
1811
|
+
this.valueChange = index.createEvent(this, "value-change", 7);
|
|
1812
|
+
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
1813
|
+
// hasError (triggered by blur event)
|
|
1814
|
+
this.hasError = false;
|
|
1815
|
+
/**
|
|
1816
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
1817
|
+
* If not set, it will be created.
|
|
1818
|
+
*/
|
|
1819
|
+
this.identifier = index$1.createID('mg-input-select');
|
|
1820
|
+
/**
|
|
1821
|
+
* Input name
|
|
1822
|
+
* If not set the value equals the identifier
|
|
1823
|
+
*/
|
|
1824
|
+
this.name = this.identifier;
|
|
1825
|
+
/**
|
|
1826
|
+
* Define if label is visible
|
|
1827
|
+
*/
|
|
1828
|
+
this.labelHide = false;
|
|
1829
|
+
/**
|
|
1830
|
+
* Option to remove placeholder
|
|
1831
|
+
*/
|
|
1832
|
+
this.placeholderHide = false;
|
|
1833
|
+
/**
|
|
1834
|
+
* Option to disable placeholder
|
|
1835
|
+
*/
|
|
1836
|
+
this.placeholderDisabled = false;
|
|
1837
|
+
/**
|
|
1838
|
+
* Define if input is required
|
|
1839
|
+
*/
|
|
1840
|
+
this.required = false;
|
|
1841
|
+
/**
|
|
1842
|
+
* Define if input is readonly
|
|
1843
|
+
*/
|
|
1844
|
+
this.readonly = false;
|
|
1845
|
+
/**
|
|
1846
|
+
* Define if input is disabled
|
|
1847
|
+
*/
|
|
1848
|
+
this.disabled = false;
|
|
1849
|
+
/**
|
|
1850
|
+
* Component classes
|
|
1851
|
+
*/
|
|
1852
|
+
this.classList = new index$1.ClassList(['mg-input--select']);
|
|
1853
|
+
/**
|
|
1854
|
+
* Handle input event
|
|
1855
|
+
*/
|
|
1856
|
+
this.handleInput = () => {
|
|
1857
|
+
this.checkValidity();
|
|
1858
|
+
if (this.hasError) {
|
|
1859
|
+
this.checkError();
|
|
1860
|
+
}
|
|
1861
|
+
if (this.input.value !== '') {
|
|
1862
|
+
this.value = index$1.allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.title === this.input.value).value;
|
|
1863
|
+
}
|
|
1864
|
+
else {
|
|
1865
|
+
this.value = null;
|
|
1866
|
+
}
|
|
1867
|
+
};
|
|
1868
|
+
/**
|
|
1869
|
+
* Handle blur event
|
|
1870
|
+
*/
|
|
1871
|
+
this.handleBlur = () => {
|
|
1872
|
+
this.displayError();
|
|
1873
|
+
};
|
|
1874
|
+
/**
|
|
1875
|
+
* Check if input is valid
|
|
1876
|
+
*/
|
|
1877
|
+
this.checkValidity = () => {
|
|
1878
|
+
if (!this.readonly && this.input !== undefined) {
|
|
1879
|
+
const validity = this.input.checkValidity && this.input.checkValidity();
|
|
1880
|
+
// Set validity
|
|
1881
|
+
this.valid = validity;
|
|
1882
|
+
this.invalid = !validity;
|
|
1883
|
+
//Send event
|
|
1884
|
+
this.inputValid.emit(validity);
|
|
1885
|
+
}
|
|
1886
|
+
};
|
|
1887
|
+
/**
|
|
1888
|
+
* Check input errors
|
|
1889
|
+
*/
|
|
1890
|
+
this.checkError = () => {
|
|
1891
|
+
// Set error message
|
|
1892
|
+
this.errorMessage = undefined;
|
|
1893
|
+
if (!this.valid && this.input.validity.valueMissing) {
|
|
1894
|
+
this.errorMessage = this.messages.errors.required;
|
|
1895
|
+
}
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1898
|
+
handleValue(newValue) {
|
|
1899
|
+
if (newValue !== null) {
|
|
1900
|
+
this.readonlyValue = index$1.allItemsAreString(this.items) ? this.input.value : this.items.find(item => item.value === newValue).title;
|
|
1901
|
+
}
|
|
1902
|
+
else {
|
|
1903
|
+
this.readonlyValue = null;
|
|
1904
|
+
}
|
|
1905
|
+
this.valueChange.emit(newValue);
|
|
1906
|
+
}
|
|
1907
|
+
validateItems(newValue) {
|
|
1908
|
+
// String array
|
|
1909
|
+
if (index$1.allItemsAreString(newValue)) {
|
|
1910
|
+
this.valueExist = newValue.includes(this.value);
|
|
1911
|
+
this.options = newValue.map((item) => ({ title: item, value: item }));
|
|
1912
|
+
}
|
|
1913
|
+
// Object array
|
|
1914
|
+
else if (newValue && newValue.every(item => isOption$1(item))) {
|
|
1915
|
+
this.valueExist = newValue.map(item => item.value).includes(this.value);
|
|
1916
|
+
// Grouped object options
|
|
1917
|
+
if (newValue.some(item => item.group !== undefined)) {
|
|
1918
|
+
this.options = newValue.reduce(groupOptions, []);
|
|
1919
|
+
}
|
|
1920
|
+
// Standart object options
|
|
1921
|
+
else {
|
|
1922
|
+
this.options = newValue;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
else {
|
|
1926
|
+
throw new Error('<mg-input-select> prop "items" is required and all items must be the same type, string or Option.');
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
/**
|
|
1930
|
+
* Public method to display errors
|
|
1931
|
+
*
|
|
1932
|
+
* @returns {Promise<void>}
|
|
1933
|
+
*/
|
|
1934
|
+
async displayError() {
|
|
1935
|
+
this.checkValidity();
|
|
1936
|
+
this.checkError();
|
|
1937
|
+
this.hasError = this.invalid;
|
|
1938
|
+
}
|
|
1939
|
+
/*************
|
|
1940
|
+
* Lifecycle *
|
|
1941
|
+
*************/
|
|
1942
|
+
/**
|
|
1943
|
+
* Check if component props are well configured on init
|
|
1944
|
+
*
|
|
1945
|
+
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
1946
|
+
*/
|
|
1947
|
+
componentWillLoad() {
|
|
1948
|
+
// Get locales
|
|
1949
|
+
this.messages = index$1.initLocales(this.element).messages;
|
|
1950
|
+
// Validate
|
|
1951
|
+
this.validateItems(this.items);
|
|
1952
|
+
// Set default placeholder
|
|
1953
|
+
if (this.placeholder === undefined || this.placeholder === '') {
|
|
1954
|
+
this.placeholder = this.messages.input.select.placeholder;
|
|
1955
|
+
}
|
|
1956
|
+
// Check validity when component is ready
|
|
1957
|
+
// return a promise to process action only in the FIRST render().
|
|
1958
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
1959
|
+
return setTimeout(() => {
|
|
1960
|
+
this.checkValidity();
|
|
1961
|
+
}, 0);
|
|
1962
|
+
}
|
|
1963
|
+
/**
|
|
1964
|
+
* Render
|
|
1965
|
+
*
|
|
1966
|
+
* @returns {HTMLElement} HTML Element
|
|
1967
|
+
*/
|
|
1968
|
+
render() {
|
|
1969
|
+
return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: this.readonlyValue, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("select", { class: "mg-input__box", id: this.identifier, name: this.name, title: this.placeholder, disabled: this.disabled, required: this.required, onInput: this.handleInput, onBlur: this.handleBlur, ref: el => (this.input = el) }, (!this.placeholderHide || !this.valueExist) && ( // In case passed value does not match any option we display the placeholder
|
|
1970
|
+
index.h("option", { value: "", disabled: this.placeholderDisabled && this.valueExist }, this.placeholder)), this.options.map(option => option.group !== undefined ? (index.h("optgroup", { label: option.group }, option.options.map(optgroup => (index.h("option", { value: optgroup.title, selected: JSON.stringify(this.value) === JSON.stringify(optgroup.value), disabled: optgroup.disabled }, optgroup.title))))) : (index.h("option", { value: option.title, selected: JSON.stringify(this.value) === JSON.stringify(option.value), disabled: option.disabled }, option.title))))));
|
|
1971
|
+
}
|
|
1972
|
+
get element() { return index.getElement(this); }
|
|
1973
|
+
static get watchers() { return {
|
|
1974
|
+
"value": ["handleValue"],
|
|
1975
|
+
"items": ["validateItems"]
|
|
1976
|
+
}; }
|
|
1977
|
+
};
|
|
1978
|
+
MgInputSelect.style = mgInputSelectCss;
|
|
1979
|
+
|
|
1980
|
+
const mgInputTextCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{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{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{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: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: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:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.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--has-icon .mg-input__with-character-left>mg-icon{position:absolute;top:50%;left:var(--mg-inputs-spacer);color:var(--mg-inputs-color);transform:translateY(-50%)}.mg-input.mg-input--has-icon .mg-input__with-character-left .mg-input__box{padding-left:calc(var(--mg-icon-regular-size) + var(--mg-inputs-spacer) * 2)}.mg-input__with-character-left{position:relative;display:inline-flex;width:100%}.mg-input.is-focused .mg-input__with-character-left .mg-input__box{padding-right:calc(var(--mg-character-left-message-length) * 1ch + 0.8rem)}.mg-input__with-character-left mg-character-left{position:absolute;display:none;top:50%;right:1rem;opacity:0.6;transform:translateY(-50%);font-size:1.1rem}.mg-input.is-focused .mg-input__with-character-left mg-character-left{display:block}";
|
|
1981
|
+
|
|
1982
|
+
const MgInputText = class {
|
|
1983
|
+
constructor(hostRef) {
|
|
1984
|
+
index.registerInstance(this, hostRef);
|
|
1985
|
+
this.valueChange = index.createEvent(this, "value-change", 7);
|
|
1986
|
+
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
1987
|
+
/************
|
|
1988
|
+
* Internal *
|
|
1989
|
+
************/
|
|
1990
|
+
// classes
|
|
1991
|
+
this.classFocus = 'is-focused';
|
|
1992
|
+
this.classIsInputGroupAppend = 'mg-input--is-input-group-append';
|
|
1993
|
+
this.classHasIcon = 'mg-input--has-icon';
|
|
1994
|
+
// hasError (triggered by blur event)
|
|
1995
|
+
this.hasError = false;
|
|
1996
|
+
/**
|
|
1997
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
1998
|
+
* If not set, it will be created.
|
|
1999
|
+
*/
|
|
2000
|
+
this.identifier = index$1.createID('mg-input-text');
|
|
2001
|
+
/**
|
|
2002
|
+
* Input name
|
|
2003
|
+
* If not set the value equals the identifier
|
|
2004
|
+
*/
|
|
2005
|
+
this.name = this.identifier;
|
|
2006
|
+
/**
|
|
2007
|
+
* Input type
|
|
2008
|
+
*/
|
|
2009
|
+
this.type = 'text';
|
|
2010
|
+
/**
|
|
2011
|
+
* Define if label is visible
|
|
2012
|
+
*/
|
|
2013
|
+
this.labelHide = false;
|
|
2014
|
+
/**
|
|
2015
|
+
* Input max length
|
|
2016
|
+
*/
|
|
2017
|
+
this.maxlength = 400;
|
|
2018
|
+
/**
|
|
2019
|
+
* Define if input is required
|
|
2020
|
+
*/
|
|
2021
|
+
this.required = false;
|
|
2022
|
+
/**
|
|
2023
|
+
* Define if input is readonly
|
|
2024
|
+
*/
|
|
2025
|
+
this.readonly = false;
|
|
2026
|
+
/**
|
|
2027
|
+
* Define if input is disabled
|
|
2028
|
+
*/
|
|
2029
|
+
this.disabled = false;
|
|
2030
|
+
/**
|
|
2031
|
+
* Define input width
|
|
2032
|
+
*/
|
|
2033
|
+
this.mgWidth = 'full';
|
|
2034
|
+
/**
|
|
2035
|
+
* Define if component should display character left
|
|
2036
|
+
*/
|
|
2037
|
+
this.displayCharacterLeft = true;
|
|
2038
|
+
/**
|
|
2039
|
+
* Component classes
|
|
2040
|
+
*/
|
|
2041
|
+
this.classList = new index$1.ClassList(['mg-input--text']);
|
|
2042
|
+
/**
|
|
2043
|
+
* Handle input event
|
|
2044
|
+
*
|
|
2045
|
+
* @returns {void}
|
|
2046
|
+
*/
|
|
2047
|
+
this.handleInput = () => {
|
|
2048
|
+
this.checkValidity();
|
|
2049
|
+
if (this.hasError) {
|
|
2050
|
+
this.checkError();
|
|
2051
|
+
}
|
|
2052
|
+
this.value = this.input.value;
|
|
2053
|
+
};
|
|
2054
|
+
/**
|
|
2055
|
+
* Handle focus event
|
|
2056
|
+
*
|
|
2057
|
+
* @returns {void}
|
|
2058
|
+
*/
|
|
2059
|
+
this.handleFocus = () => {
|
|
2060
|
+
this.classList.add(this.classFocus);
|
|
2061
|
+
this.classList = new index$1.ClassList(this.classList.classes);
|
|
2062
|
+
};
|
|
2063
|
+
/**
|
|
2064
|
+
* Handle blur event
|
|
2065
|
+
*
|
|
2066
|
+
* @returns {void}
|
|
2067
|
+
*/
|
|
2068
|
+
this.handleBlur = () => {
|
|
2069
|
+
// Manage focus
|
|
2070
|
+
this.classList.delete(this.classFocus);
|
|
2071
|
+
this.classList = new index$1.ClassList(this.classList.classes);
|
|
2072
|
+
// Display Error
|
|
2073
|
+
this.displayError();
|
|
2074
|
+
};
|
|
2075
|
+
/**
|
|
2076
|
+
* Check if input is valid
|
|
2077
|
+
*
|
|
2078
|
+
* @returns {void}
|
|
2079
|
+
*/
|
|
2080
|
+
this.checkValidity = () => {
|
|
2081
|
+
if (!this.readonly && this.input !== undefined) {
|
|
2082
|
+
const validity = this.input.checkValidity();
|
|
2083
|
+
// Set validity
|
|
2084
|
+
this.valid = validity;
|
|
2085
|
+
this.invalid = !validity;
|
|
2086
|
+
//Send event
|
|
2087
|
+
this.inputValid.emit(validity);
|
|
2088
|
+
}
|
|
2089
|
+
};
|
|
2090
|
+
/**
|
|
2091
|
+
* Check input errors
|
|
2092
|
+
*
|
|
2093
|
+
* @returns {void}
|
|
2094
|
+
*/
|
|
2095
|
+
this.checkError = () => {
|
|
2096
|
+
// Set error message
|
|
2097
|
+
this.errorMessage = undefined;
|
|
2098
|
+
// Does not match pattern
|
|
2099
|
+
if (!this.valid && this.input.validity.patternMismatch) {
|
|
2100
|
+
this.errorMessage = this.patternErrorMessage;
|
|
2101
|
+
}
|
|
2102
|
+
// required
|
|
2103
|
+
else if (!this.valid && this.input.validity.valueMissing) {
|
|
2104
|
+
this.errorMessage = this.messages.errors.required;
|
|
2105
|
+
}
|
|
2106
|
+
};
|
|
2107
|
+
/**
|
|
2108
|
+
* Validate patern configuration
|
|
2109
|
+
*
|
|
2110
|
+
* @returns {void}
|
|
2111
|
+
*/
|
|
2112
|
+
this.validatePattern = () => {
|
|
2113
|
+
if (this.pattern &&
|
|
2114
|
+
typeof this.pattern === 'string' &&
|
|
2115
|
+
this.pattern !== '' &&
|
|
2116
|
+
(this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
|
|
2117
|
+
throw new Error('<mg-input-text> prop "pattern" must be paired with the prop "patternErrorMessage"');
|
|
2118
|
+
}
|
|
2119
|
+
};
|
|
2120
|
+
/**
|
|
2121
|
+
* Validate append slot
|
|
2122
|
+
*
|
|
2123
|
+
* @returns {void}
|
|
2124
|
+
*/
|
|
2125
|
+
this.validateAppendSlot = () => {
|
|
2126
|
+
const slotAppendInput = Array.from(this.element.querySelectorAll('[slot="append-input"]'));
|
|
2127
|
+
if (slotAppendInput.length === 1) {
|
|
2128
|
+
this.classList.add(slotAppendInput[0].nodeName === 'MG-BUTTON' ? this.classIsInputGroupAppend : 'mg-input--is-append-input-slot-content');
|
|
2129
|
+
}
|
|
2130
|
+
else if (slotAppendInput.filter(slot => slot.nodeName === 'MG-BUTTON').length > 1) {
|
|
2131
|
+
this.classList.add(this.classIsInputGroupAppend);
|
|
2132
|
+
this.classList.add('mg-input--has-buttons-group-append');
|
|
2133
|
+
}
|
|
2134
|
+
};
|
|
2135
|
+
}
|
|
2136
|
+
handleValue(newValue) {
|
|
2137
|
+
this.valueChange.emit(newValue);
|
|
2138
|
+
}
|
|
2139
|
+
validateIcon(newValue) {
|
|
2140
|
+
if (newValue !== undefined) {
|
|
2141
|
+
this.classList.add(this.classHasIcon);
|
|
2142
|
+
}
|
|
2143
|
+
else {
|
|
2144
|
+
this.classList.delete(this.classHasIcon);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
/**
|
|
2148
|
+
* Public method to play input focus
|
|
2149
|
+
*
|
|
2150
|
+
* @returns {Promise<void>}
|
|
2151
|
+
*/
|
|
2152
|
+
async setFocus() {
|
|
2153
|
+
this.input.focus();
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2156
|
+
* Public method to display errors
|
|
2157
|
+
*
|
|
2158
|
+
* @returns {Promise<void>}
|
|
2159
|
+
*/
|
|
2160
|
+
async displayError() {
|
|
2161
|
+
this.checkValidity();
|
|
2162
|
+
this.checkError();
|
|
2163
|
+
this.hasError = this.invalid;
|
|
2164
|
+
}
|
|
2165
|
+
/*************
|
|
2166
|
+
* Lifecycle *
|
|
2167
|
+
*************/
|
|
2168
|
+
/**
|
|
2169
|
+
* Check if component props are well configured on init
|
|
2170
|
+
*
|
|
2171
|
+
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2172
|
+
*/
|
|
2173
|
+
componentWillLoad() {
|
|
2174
|
+
// Get locales
|
|
2175
|
+
this.messages = index$1.initLocales(this.element).messages;
|
|
2176
|
+
this.characterLeftId = `${this.identifier}-character-left`;
|
|
2177
|
+
// Validate
|
|
2178
|
+
this.validateIcon(this.icon);
|
|
2179
|
+
this.validatePattern();
|
|
2180
|
+
this.validateAppendSlot();
|
|
2181
|
+
// Check validity when component is ready
|
|
2182
|
+
// return a promise to process action only in the FIRST render().
|
|
2183
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
2184
|
+
return setTimeout(() => {
|
|
2185
|
+
this.checkValidity();
|
|
2186
|
+
}, 0);
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* Render
|
|
2190
|
+
*
|
|
2191
|
+
* @returns {HTMLElement} HTML Element
|
|
2192
|
+
*/
|
|
2193
|
+
render() {
|
|
2194
|
+
return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("div", { class: "mg-input__with-character-left", style: {
|
|
2195
|
+
'--mg-character-left-message-length': (this.displayCharacterLeft
|
|
2196
|
+
? (this.maxlength - (this.value || '').length).toString().length + this.maxlength.toString().length + 1
|
|
2197
|
+
: 0).toString(),
|
|
2198
|
+
} }, this.icon !== undefined && index.h("mg-icon", { icon: this.icon }), index.h("input", { type: this.type, class: "mg-input__box", value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, maxlength: this.maxlength, disabled: this.disabled, required: this.required, pattern: this.pattern, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), this.displayCharacterLeft && this.maxlength && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength }))), index.h("slot", { name: "append-input" })));
|
|
2199
|
+
}
|
|
2200
|
+
get element() { return index.getElement(this); }
|
|
2201
|
+
static get watchers() { return {
|
|
2202
|
+
"value": ["handleValue"],
|
|
2203
|
+
"icon": ["validateIcon"]
|
|
2204
|
+
}; }
|
|
2205
|
+
};
|
|
2206
|
+
MgInputText.style = mgInputTextCss;
|
|
2207
|
+
|
|
2208
|
+
const mgInputTextareaCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{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{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{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: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: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:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.mg-input__box{padding:calc((var(--default-size) - var(--font-size) * var(--line-height)) / 2) var(--mg-inputs-spacer);height:var(--default-size);box-sizing:border-box;border-width:var(--mg-inputs-border-width);border-style:solid;border-color:var(--mg-inputs-color);border-radius:var(--mg-inputs-border-radius);background-color:hsl(var(--color-light));font-family:inherit;color:hsl(var(--color-dark));font-size:var(--font-size);text-align:var(--mg-inputs-text-align, left)}.mg-input__box::placeholder{color:var(--mg-inputs-color);font-style:italic}.mg-input__box:focus{box-shadow:0 0 0.6rem hsla(var(--mg-inputs-color-shadow-focus-hsl), 0.5)}.mg-input__box:disabled{opacity:0.3}.mg-input.mg-input--is-input-group-append{--mg-button-border-radius-top-left:0;--mg-button-border-radius-bottom-left:0;}.mg-input.mg-input--is-input-group-append .mg-input__box{margin-right:-0.1rem;border-top-right-radius:0%;border-bottom-right-radius:0%}.mg-input.mg-input--is-input-group-append .mg-input__box:focus-visible{outline-style:solid;outline-offset:-0.2rem;outline-width:0.2rem}.mg-input.mg-input--is-input-group-append.mg-input--readonly slot[name=append-input]{display:none}.mg-input.mg-input--label-on-top .mg-input__box{width:auto;max-width:100%}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]){--mg-button-border-radius-top-right:0;--mg-button-border-radius-bottom-right:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:not(:last-of-type)){--mg-button-border-right-width:0}.mg-input.mg-input--has-buttons-group-append ::slotted([slot=append-input]:last-of-type){--mg-button-border-radius-top-right:var(--mg-inputs-border-radius);--mg-button-border-radius-bottom-right:var(--mg-inputs-border-radius)}.mg-input.mg-input--is-append-input-slot-content:not(.mg-input--readonly) ::slotted([slot=append-input]){padding-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input.mg-input--width-full:not(.mg-input--label-on-top){justify-content:space-between}.mg-input.mg-input--width-full .mg-input__input-container{flex:auto;width:100%}.mg-input.mg-input--width-full .mg-input__input-container .mg-input__box{width:100%}.mg-input.mg-input--width-16 .mg-input__box{width:21rem}.mg-input.mg-input--width-4 .mg-input__box{width:7rem}.mg-input.mg-input--width-2 .mg-input__box{width:5rem}.mg-input mg-character-left{opacity:0.6;font-size:1.1rem}.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__help-text,.mg-input.mg-input--has-display-character-left .mg-input__input+.mg-input__error{margin-top:0}.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__box{display:block;height:auto;resize:none}.mg-input .mg-input__box.mg-input__box--resizable{resize:both}.mg-input .mg-input__box.mg-input__box--resizable-horizontal{resize:horizontal}.mg-input .mg-input__box.mg-input__box--resizable-vertical{resize:vertical}.mg-input__with-character-left{width:100%}.mg-input__with-character-left mg-character-left{display:block;visibility:hidden;margin-top:0.2rem;text-align:end}.mg-input.is-focused .mg-input__with-character-left mg-character-left{visibility:visible}@-moz-document url-prefix(){.mg-input__box{overflow-x:hidden}}";
|
|
2209
|
+
|
|
2210
|
+
const MgInputTextarea = class {
|
|
2211
|
+
constructor(hostRef) {
|
|
2212
|
+
index.registerInstance(this, hostRef);
|
|
2213
|
+
this.valueChange = index.createEvent(this, "value-change", 7);
|
|
2214
|
+
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
2215
|
+
/************
|
|
2216
|
+
* Internal *
|
|
2217
|
+
************/
|
|
2218
|
+
// classes
|
|
2219
|
+
this.classFocus = 'is-focused';
|
|
2220
|
+
this.classHasDisplayCharacterLeft = 'mg-input--has-display-character-left';
|
|
2221
|
+
// hasError (triggered by blur event)
|
|
2222
|
+
this.hasError = false;
|
|
2223
|
+
/**
|
|
2224
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
2225
|
+
* If not set, it will be created.
|
|
2226
|
+
*/
|
|
2227
|
+
this.identifier = index$1.createID('mg-input-textarea');
|
|
2228
|
+
/**
|
|
2229
|
+
* Input name
|
|
2230
|
+
* If not set the value equals the identifier
|
|
2231
|
+
*/
|
|
2232
|
+
this.name = this.identifier;
|
|
2233
|
+
/**
|
|
2234
|
+
* Define if label is visible
|
|
2235
|
+
*/
|
|
2236
|
+
this.labelHide = false;
|
|
2237
|
+
/**
|
|
2238
|
+
* Input max length
|
|
2239
|
+
*/
|
|
2240
|
+
this.maxlength = 4000;
|
|
2241
|
+
/**
|
|
2242
|
+
* Define if input is required
|
|
2243
|
+
*/
|
|
2244
|
+
this.required = false;
|
|
2245
|
+
/**
|
|
2246
|
+
* Define if input is readonly
|
|
2247
|
+
*/
|
|
2248
|
+
this.readonly = false;
|
|
2249
|
+
/**
|
|
2250
|
+
* Define if input is disabled
|
|
2251
|
+
*/
|
|
2252
|
+
this.disabled = false;
|
|
2253
|
+
/**
|
|
2254
|
+
* Define input width
|
|
2255
|
+
*/
|
|
2256
|
+
this.mgWidth = 'full';
|
|
2257
|
+
/**
|
|
2258
|
+
* Define the number of visible text lines for the control
|
|
2259
|
+
*/
|
|
2260
|
+
this.rows = 3;
|
|
2261
|
+
/**
|
|
2262
|
+
* Define if component should display character left
|
|
2263
|
+
*/
|
|
2264
|
+
this.displayCharacterLeft = true;
|
|
2265
|
+
/**
|
|
2266
|
+
* Define if input is resizable
|
|
2267
|
+
*/
|
|
2268
|
+
this.resizable = 'none';
|
|
2269
|
+
/**
|
|
2270
|
+
* Component classes
|
|
2271
|
+
*/
|
|
2272
|
+
this.classList = new index$1.ClassList(['mg-input--textarea']);
|
|
2273
|
+
/**
|
|
2274
|
+
* Handle input event
|
|
2275
|
+
*/
|
|
2276
|
+
this.handleInput = () => {
|
|
2277
|
+
if (this.hasError) {
|
|
2278
|
+
this.checkValidity();
|
|
2279
|
+
this.checkError();
|
|
2280
|
+
}
|
|
2281
|
+
this.value = this.input.value;
|
|
2282
|
+
};
|
|
2283
|
+
/**
|
|
2284
|
+
* Handle focus event
|
|
2285
|
+
*/
|
|
2286
|
+
this.handleFocus = () => {
|
|
2287
|
+
this.classList.add(this.classFocus);
|
|
2288
|
+
this.classList = new index$1.ClassList(this.classList.classes);
|
|
2289
|
+
};
|
|
2290
|
+
/**
|
|
2291
|
+
* Handle blur event
|
|
2292
|
+
*/
|
|
2293
|
+
this.handleBlur = () => {
|
|
2294
|
+
// Manage focus
|
|
2295
|
+
this.classList.delete(this.classFocus);
|
|
2296
|
+
this.classList = new index$1.ClassList(this.classList.classes);
|
|
2297
|
+
// Display Error
|
|
2298
|
+
this.displayError();
|
|
2299
|
+
};
|
|
2300
|
+
/**
|
|
2301
|
+
* Get pattern validity
|
|
2302
|
+
* Pattern is not defined on textarea field : https://developer.mozilla.org/fr/docs/Web/HTML/Element/Textarea
|
|
2303
|
+
*
|
|
2304
|
+
* @returns {boolean} is pattern valid
|
|
2305
|
+
*/
|
|
2306
|
+
this.getPatternValidity = () => this.pattern === undefined || new RegExp(`^${this.pattern}$`, 'u').test(this.value);
|
|
2307
|
+
/**
|
|
2308
|
+
* Check if input is valid
|
|
2309
|
+
*/
|
|
2310
|
+
this.checkValidity = () => {
|
|
2311
|
+
if (!this.readonly && this.input !== undefined) {
|
|
2312
|
+
const validity = this.input.checkValidity && this.input.checkValidity() && this.getPatternValidity();
|
|
2313
|
+
// Set validity
|
|
2314
|
+
this.valid = validity;
|
|
2315
|
+
this.invalid = !validity;
|
|
2316
|
+
//Send event
|
|
2317
|
+
this.inputValid.emit(validity);
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
/**
|
|
2321
|
+
* Check input errors
|
|
2322
|
+
*/
|
|
2323
|
+
this.checkError = () => {
|
|
2324
|
+
// Set error message
|
|
2325
|
+
this.errorMessage = undefined;
|
|
2326
|
+
// Does not match pattern
|
|
2327
|
+
if (!this.valid && !this.getPatternValidity()) {
|
|
2328
|
+
this.errorMessage = this.patternErrorMessage;
|
|
2329
|
+
}
|
|
2330
|
+
// required
|
|
2331
|
+
else if (!this.valid && this.input.validity.valueMissing) {
|
|
2332
|
+
this.errorMessage = this.messages.errors.required;
|
|
2333
|
+
}
|
|
2334
|
+
};
|
|
2335
|
+
/**
|
|
2336
|
+
* Validate pattern configuration
|
|
2337
|
+
*/
|
|
2338
|
+
this.validatePattern = () => {
|
|
2339
|
+
if (this.pattern &&
|
|
2340
|
+
typeof this.pattern === 'string' &&
|
|
2341
|
+
this.pattern !== '' &&
|
|
2342
|
+
(this.patternErrorMessage === undefined || typeof this.patternErrorMessage !== 'string' || this.patternErrorMessage === '')) {
|
|
2343
|
+
throw new Error('<mg-input-textarea> prop "pattern" must be paired with the prop "patternErrorMessage"');
|
|
2344
|
+
}
|
|
2345
|
+
};
|
|
2346
|
+
}
|
|
2347
|
+
handleValue(newValue) {
|
|
2348
|
+
this.checkValidity();
|
|
2349
|
+
this.valueChange.emit(newValue);
|
|
2350
|
+
}
|
|
2351
|
+
validateDisplayCharacterLeft(newValue) {
|
|
2352
|
+
if (newValue) {
|
|
2353
|
+
this.classList.add(this.classHasDisplayCharacterLeft);
|
|
2354
|
+
}
|
|
2355
|
+
else {
|
|
2356
|
+
this.classList.delete(this.classHasDisplayCharacterLeft);
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
/**
|
|
2360
|
+
* Public method to display errors
|
|
2361
|
+
*
|
|
2362
|
+
* @returns {Promise<void>}
|
|
2363
|
+
*/
|
|
2364
|
+
async displayError() {
|
|
2365
|
+
this.checkValidity();
|
|
2366
|
+
this.checkError();
|
|
2367
|
+
this.hasError = this.invalid;
|
|
2368
|
+
}
|
|
2369
|
+
/*************
|
|
2370
|
+
* Lifecycle *
|
|
2371
|
+
*************/
|
|
2372
|
+
/**
|
|
2373
|
+
* Check if component props are well configured on init
|
|
2374
|
+
*
|
|
2375
|
+
* @returns {ReturnType<typeof setTimeout>} timeout
|
|
2376
|
+
*/
|
|
2377
|
+
componentWillLoad() {
|
|
2378
|
+
// Get locales
|
|
2379
|
+
this.messages = index$1.initLocales(this.element).messages;
|
|
2380
|
+
this.characterLeftId = `${this.identifier}-character-left`;
|
|
2381
|
+
// Validate
|
|
2382
|
+
this.validateDisplayCharacterLeft(this.displayCharacterLeft);
|
|
2383
|
+
this.validatePattern();
|
|
2384
|
+
// Check validity when component is ready
|
|
2385
|
+
// return a promise to process action only in the FIRST render().
|
|
2386
|
+
// https://stenciljs.com/docs/component-lifecycle#componentwillload
|
|
2387
|
+
return setTimeout(() => {
|
|
2388
|
+
this.checkValidity();
|
|
2389
|
+
}, 0);
|
|
2390
|
+
}
|
|
2391
|
+
/**
|
|
2392
|
+
* Render
|
|
2393
|
+
*
|
|
2394
|
+
* @returns {HTMLElement} HTML Element
|
|
2395
|
+
*/
|
|
2396
|
+
render() {
|
|
2397
|
+
return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [this.characterLeftId], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: this.required, readonly: this.readonly, mgWidth: this.mgWidth, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: this.tooltip, helpText: this.helpText, errorMessage: this.errorMessage, isFieldset: false }, index.h("div", { class: "mg-input__with-character-left" }, index.h("textarea", { class: {
|
|
2398
|
+
'mg-input__box': true,
|
|
2399
|
+
'mg-input__box--resizable': this.resizable === 'both',
|
|
2400
|
+
'mg-input__box--resizable-horizontal': this.resizable === 'horizontal',
|
|
2401
|
+
'mg-input__box--resizable-vertical': this.resizable === 'vertical',
|
|
2402
|
+
}, value: this.value, id: this.identifier, name: this.name, placeholder: this.placeholder, title: this.placeholder, rows: this.rows, maxlength: this.maxlength, disabled: this.disabled, required: this.required, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur, ref: el => (this.input = el) }), this.displayCharacterLeft && this.maxlength && (index.h("mg-character-left", { identifier: this.characterLeftId, characters: this.value, maxlength: this.maxlength })))));
|
|
2403
|
+
}
|
|
2404
|
+
get element() { return index.getElement(this); }
|
|
2405
|
+
static get watchers() { return {
|
|
2406
|
+
"value": ["handleValue"],
|
|
2407
|
+
"displayCharacterLeft": ["validateDisplayCharacterLeft"]
|
|
2408
|
+
}; }
|
|
2409
|
+
};
|
|
2410
|
+
MgInputTextarea.style = mgInputTextareaCss;
|
|
2411
|
+
|
|
2412
|
+
const mgInputTitleCss = ".is-asterisk.sc-mg-input-title{color:hsl(var(--color-danger))}legend.mg-input-title.sc-mg-input-title{padding-left:0;padding-right:0}.mg-input-title__required.sc-mg-input-title{display:var(--mg-input-title-display, unset)}";
|
|
2413
|
+
|
|
2414
|
+
const MgInputTitle = class {
|
|
2415
|
+
constructor(hostRef) {
|
|
2416
|
+
index.registerInstance(this, hostRef);
|
|
2417
|
+
/**
|
|
2418
|
+
* Switch from label to fieldset sementic
|
|
2419
|
+
*/
|
|
2420
|
+
this.isLegend = false;
|
|
2421
|
+
/**
|
|
2422
|
+
* Component parent tagname
|
|
2423
|
+
*/
|
|
2424
|
+
this.tagName = 'label';
|
|
2425
|
+
this.getTagName = () => {
|
|
2426
|
+
this.tagName = this.isLegend ? 'legend' : 'label';
|
|
2427
|
+
};
|
|
2428
|
+
}
|
|
2429
|
+
/*************
|
|
2430
|
+
* Lifecycle *
|
|
2431
|
+
*************/
|
|
2432
|
+
/**
|
|
2433
|
+
* Init tag name
|
|
2434
|
+
*
|
|
2435
|
+
* @returns {void}
|
|
2436
|
+
*/
|
|
2437
|
+
componentWillLoad() {
|
|
2438
|
+
this.getTagName();
|
|
2439
|
+
}
|
|
2440
|
+
/**
|
|
2441
|
+
* Render
|
|
2442
|
+
*
|
|
2443
|
+
* @returns {HTMLElement} HTML Element
|
|
2444
|
+
*/
|
|
2445
|
+
render() {
|
|
2446
|
+
const TagName = this.tagName;
|
|
2447
|
+
// \u00A0 represent a
|
|
2448
|
+
return (index.h(TagName, { class: "mg-input-title", htmlFor: this.isLegend ? undefined : this.identifier }, index.h("slot", null), this.required && (index.h("span", { class: "mg-input-title__required" }, "\u00A0", index.h("span", { class: "is-asterisk" }, "*")))));
|
|
2449
|
+
}
|
|
2450
|
+
};
|
|
2451
|
+
MgInputTitle.style = mgInputTitleCss;
|
|
2452
|
+
|
|
2453
|
+
const mgInputToggleCss = ":host{display:block}.mg-input{display:flex;align-items:flex-start;min-height:var(--default-size);max-width:100%;margin-bottom:var(--mg-inputs-margin-bottom, 0);}.mg-input mg-input-title{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{flex-direction:column}.mg-input.mg-input--label-on-top .mg-input__input-container{width:100%}.mg-input__title{display:flex;align-items:baseline;margin-bottom:0.3rem}.mg-input__title mg-input-title{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: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: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:flex}.mg-input__input-container .mg-input__help-text,.mg-input__input-container .mg-input__error{text-align:start;font-size:1.2rem}.mg-input__input{display:flex;}.mg-input__input mg-tooltip{margin-top:calc((var(--default-size) - var(--mg-icon-regular-size)) / 2)}.mg-input__input.mg-input__input--has-error .mg-input__box{border-color:hsl(var(--color-danger))}.mg-input__input+.mg-input__help-text,.mg-input__input+.mg-input__error{margin-top:0.5rem}.mg-input__error{display:inline-block;margin-top:0.2rem;padding:0.3rem 0.8rem;border-radius:0.3rem;background:hsl(var(--mg-inputs-error-bg-color));color:hsl(var(--color-danger))}.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{flex:auto;min-width:0}.mg-input__button-toggle{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__button-toggle:disabled{cursor:default}.mg-input__toggle-item-container{padding:0.5rem 0.9rem;border:0;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:flex;justify-content: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: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:flex}.mg-input.mg-input--toggle-disabled .mg-input__button-toggle{opacity:0.3}";
|
|
2454
|
+
|
|
2455
|
+
/**
|
|
2456
|
+
* type Option validation function
|
|
2457
|
+
*
|
|
2458
|
+
* @param {ToggleValue} option radio option
|
|
2459
|
+
* @returns {boolean} toggle option type is valid
|
|
2460
|
+
*/
|
|
2461
|
+
const isOption = (option) => typeof option === 'object' && typeof option.title === 'string' && option.value !== undefined;
|
|
2462
|
+
const MgInputToggle = class {
|
|
2463
|
+
constructor(hostRef) {
|
|
2464
|
+
index.registerInstance(this, hostRef);
|
|
2465
|
+
this.valueChange = index.createEvent(this, "value-change", 7);
|
|
2466
|
+
this.inputValid = index.createEvent(this, "input-valid", 7);
|
|
2467
|
+
/************
|
|
2468
|
+
* Internal *
|
|
2469
|
+
************/
|
|
2470
|
+
// classes
|
|
2471
|
+
this.classReadonly = 'mg-input--toggle-readonly';
|
|
2472
|
+
this.classDisabled = 'mg-input--toggle-disabled';
|
|
2473
|
+
this.classIsActive = 'mg-input--toggle-is-active';
|
|
2474
|
+
this.classOnOff = 'mg-input--toggle-on-off';
|
|
2475
|
+
this.classIcon = 'mg-input--toggle-icon';
|
|
2476
|
+
/**
|
|
2477
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
2478
|
+
* If not set, it will be created.
|
|
2479
|
+
*/
|
|
2480
|
+
this.identifier = index$1.createID('mg-input-toggle');
|
|
2481
|
+
/**
|
|
2482
|
+
* Input name
|
|
2483
|
+
* If not set the value equals the identifier
|
|
2484
|
+
*/
|
|
2485
|
+
this.name = this.identifier;
|
|
2486
|
+
/**
|
|
2487
|
+
* Define if label is visible
|
|
2488
|
+
*/
|
|
2489
|
+
this.labelHide = false;
|
|
2490
|
+
/**
|
|
2491
|
+
* Define if toggle have on/off style
|
|
2492
|
+
*/
|
|
2493
|
+
this.isOnOff = false;
|
|
2494
|
+
/**
|
|
2495
|
+
* Define if toggle display icon
|
|
2496
|
+
*/
|
|
2497
|
+
this.isIcon = false;
|
|
2498
|
+
/**
|
|
2499
|
+
* Define if input is readonly
|
|
2500
|
+
*/
|
|
2501
|
+
this.readonly = false;
|
|
2502
|
+
/**
|
|
2503
|
+
* Define if input is disabled
|
|
2504
|
+
*/
|
|
2505
|
+
this.disabled = false;
|
|
2506
|
+
/**
|
|
2507
|
+
* Component classes
|
|
2508
|
+
*/
|
|
2509
|
+
this.classList = new index$1.ClassList(['mg-input--toggle']);
|
|
2510
|
+
/**
|
|
2511
|
+
* Checked internal value
|
|
2512
|
+
*/
|
|
2513
|
+
this.checked = false;
|
|
2514
|
+
/**
|
|
2515
|
+
* Change checked value
|
|
2516
|
+
*
|
|
2517
|
+
* @returns {void}
|
|
2518
|
+
*/
|
|
2519
|
+
this.toggleChecked = () => {
|
|
2520
|
+
this.checked = !this.checked;
|
|
2521
|
+
};
|
|
2522
|
+
/**
|
|
2523
|
+
* Slots validation
|
|
2524
|
+
*
|
|
2525
|
+
* @returns {void}
|
|
2526
|
+
*/
|
|
2527
|
+
this.validateSlots = () => {
|
|
2528
|
+
const slots = Array.from(this.element.children);
|
|
2529
|
+
if (slots.length !== 2) {
|
|
2530
|
+
throw new Error('<mg-input-toggle> 2 slots are required.');
|
|
2531
|
+
}
|
|
2532
|
+
else if (!this.isIcon) {
|
|
2533
|
+
// Due to text-overflow set to ellipsis
|
|
2534
|
+
// we need to ensure that slot element have title to display value on mouse over
|
|
2535
|
+
slots.forEach(slot => slot.setAttribute('title', slot.textContent));
|
|
2536
|
+
}
|
|
2537
|
+
};
|
|
2538
|
+
}
|
|
2539
|
+
handleValue(newValue) {
|
|
2540
|
+
// Swich to the right option
|
|
2541
|
+
this.setChecked();
|
|
2542
|
+
// Emit value-change event
|
|
2543
|
+
this.valueChange.emit(newValue);
|
|
2544
|
+
}
|
|
2545
|
+
validateItems(newValue) {
|
|
2546
|
+
if (typeof newValue === 'object' && this.items.length !== 2) {
|
|
2547
|
+
throw new Error('<mg-input-toggle> prop "items" require 2 items.');
|
|
2548
|
+
}
|
|
2549
|
+
// String array
|
|
2550
|
+
else if (index$1.allItemsAreString(newValue)) {
|
|
2551
|
+
this.options = newValue.map(item => ({ title: item, value: item }));
|
|
2552
|
+
}
|
|
2553
|
+
// Object array
|
|
2554
|
+
else if (newValue && newValue.every(item => isOption(item))) {
|
|
2555
|
+
this.options = newValue;
|
|
2556
|
+
}
|
|
2557
|
+
else {
|
|
2558
|
+
throw new Error('<mg-input-toggle> prop "items" is required and all items must be the same type: ToggleValue.');
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
handleIsOnOff(newValue) {
|
|
2562
|
+
if (newValue)
|
|
2563
|
+
this.classList.add(this.classOnOff);
|
|
2564
|
+
else
|
|
2565
|
+
this.classList.delete(this.classOnOff);
|
|
2566
|
+
}
|
|
2567
|
+
handleIsIcon(newValue) {
|
|
2568
|
+
if (newValue)
|
|
2569
|
+
this.classList.add(this.classIcon);
|
|
2570
|
+
else
|
|
2571
|
+
this.classList.delete(this.classIcon);
|
|
2572
|
+
}
|
|
2573
|
+
handleReadonly(newValue) {
|
|
2574
|
+
if (newValue)
|
|
2575
|
+
this.classList.add(this.classReadonly);
|
|
2576
|
+
else
|
|
2577
|
+
this.classList.delete(this.classReadonly);
|
|
2578
|
+
}
|
|
2579
|
+
handleDisabled(newValue) {
|
|
2580
|
+
if (newValue)
|
|
2581
|
+
this.classList.add(this.classDisabled);
|
|
2582
|
+
else
|
|
2583
|
+
this.classList.delete(this.classDisabled);
|
|
2584
|
+
}
|
|
2585
|
+
handleChecked(newValue) {
|
|
2586
|
+
// style
|
|
2587
|
+
if (newValue)
|
|
2588
|
+
this.classList.add(this.classIsActive);
|
|
2589
|
+
else
|
|
2590
|
+
this.classList.delete(this.classIsActive);
|
|
2591
|
+
// update value
|
|
2592
|
+
this.value = this.options[newValue ? 1 : 0].value;
|
|
2593
|
+
}
|
|
2594
|
+
/**
|
|
2595
|
+
* set checked state
|
|
2596
|
+
*
|
|
2597
|
+
* @returns {void}
|
|
2598
|
+
*/
|
|
2599
|
+
setChecked() {
|
|
2600
|
+
// has "value" props type is not a boolean, it is bind/render as an attributes/props
|
|
2601
|
+
// true props will be represent by "true" string so we convert it has boolean
|
|
2602
|
+
// true attribute will be represent by "" string so we convert it has boolean
|
|
2603
|
+
// https://stenciljs.com/docs/properties
|
|
2604
|
+
if (['', 'true'].includes(this.value) && this.options.find(option => option.value) !== undefined) {
|
|
2605
|
+
this.value = true;
|
|
2606
|
+
}
|
|
2607
|
+
this.checked = this.value === this.options[1].value;
|
|
2608
|
+
}
|
|
2609
|
+
/*************
|
|
2610
|
+
* Lifecycle *
|
|
2611
|
+
*************/
|
|
2612
|
+
/**
|
|
2613
|
+
* Check if component props are well configured on init
|
|
2614
|
+
*/
|
|
2615
|
+
componentWillLoad() {
|
|
2616
|
+
// Check items format
|
|
2617
|
+
this.validateItems(this.items);
|
|
2618
|
+
// Check slots
|
|
2619
|
+
this.validateSlots();
|
|
2620
|
+
// init checked value
|
|
2621
|
+
this.setChecked();
|
|
2622
|
+
// apply handler
|
|
2623
|
+
this.handleIsOnOff(this.isOnOff);
|
|
2624
|
+
this.handleIsIcon(this.isIcon);
|
|
2625
|
+
this.handleReadonly(this.readonly);
|
|
2626
|
+
this.handleDisabled(this.disabled);
|
|
2627
|
+
}
|
|
2628
|
+
/**
|
|
2629
|
+
* Render
|
|
2630
|
+
*
|
|
2631
|
+
* @returns {HTMLElement} HTML Element
|
|
2632
|
+
*/
|
|
2633
|
+
render() {
|
|
2634
|
+
return (index.h(MgInput, { identifier: this.identifier, classList: this.classList, ariaDescribedbyIDs: [], label: this.label, labelOnTop: this.labelOnTop, labelHide: this.labelHide, required: undefined, readonly: undefined, mgWidth: undefined, disabled: this.disabled, value: this.value, readonlyValue: undefined, tooltip: !this.readonly && this.tooltip, helpText: this.helpText, errorMessage: undefined, isFieldset: false }, index.h("button", { type: "button", role: "switch", "aria-checked": this.checked.toString(), "aria-readonly": this.disabled || this.readonly, id: this.identifier, class: "mg-input__button-toggle", disabled: this.disabled || this.readonly, onClick: this.toggleChecked }, index.h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, index.h("slot", { name: "item-1" })), index.h("span", { "aria-hidden": "true", class: "mg-input__toggle-item-container" }, index.h("slot", { name: "item-2" })))));
|
|
2635
|
+
}
|
|
2636
|
+
get element() { return index.getElement(this); }
|
|
2637
|
+
static get watchers() { return {
|
|
2638
|
+
"value": ["handleValue"],
|
|
2639
|
+
"items": ["validateItems"],
|
|
2640
|
+
"isOnOff": ["handleIsOnOff"],
|
|
2641
|
+
"isIcon": ["handleIsIcon"],
|
|
2642
|
+
"readonly": ["handleReadonly"],
|
|
2643
|
+
"disabled": ["handleDisabled"],
|
|
2644
|
+
"checked": ["handleChecked"]
|
|
2645
|
+
}; }
|
|
2646
|
+
};
|
|
2647
|
+
MgInputToggle.style = mgInputToggleCss;
|
|
2648
|
+
|
|
2649
|
+
/**
|
|
2650
|
+
* List of all possibles message variants
|
|
2651
|
+
*/
|
|
2652
|
+
const variants$1 = ['info', 'warning', 'success', 'danger'];
|
|
2653
|
+
|
|
2654
|
+
const mgMessageCss = ".mg-message{display:inline-block;position:relative;box-sizing:border-box;min-height:var(--default-size);overflow:hidden;background-color:white;border-radius:var(--mg-message-border-radius);box-shadow:var(--box-shadow)}.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:flex;flex-wrap:wrap;justify-content:flex-end;align-content:stretch;padding:0 1rem 0 3.8rem}.mg-message__content-slot{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%}";
|
|
2655
|
+
|
|
2656
|
+
const MgMessage = class {
|
|
2657
|
+
constructor(hostRef) {
|
|
2658
|
+
index.registerInstance(this, hostRef);
|
|
2659
|
+
this.componentShow = index.createEvent(this, "component-show", 7);
|
|
2660
|
+
this.componentHide = index.createEvent(this, "component-hide", 7);
|
|
2661
|
+
/************
|
|
2662
|
+
* Internal *
|
|
2663
|
+
************/
|
|
2664
|
+
// classes
|
|
2665
|
+
this.classHide = 'mg-message--hide';
|
|
2666
|
+
// IDs
|
|
2667
|
+
this.closeButtonId = '';
|
|
2668
|
+
// Stored timer setted when hide action is run from setTimeOut
|
|
2669
|
+
this.storedTimer = null;
|
|
2670
|
+
/**
|
|
2671
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
2672
|
+
* If not set, it will be created.
|
|
2673
|
+
*/
|
|
2674
|
+
this.identifier = index$1.createID('mg-message');
|
|
2675
|
+
/**
|
|
2676
|
+
* Message variant
|
|
2677
|
+
*/
|
|
2678
|
+
this.variant = variants$1[0]; // info
|
|
2679
|
+
/**
|
|
2680
|
+
* Define if message has a cross button
|
|
2681
|
+
* RG 01: https://jira.mgdis.fr/browse/PDA9-140
|
|
2682
|
+
*/
|
|
2683
|
+
this.closeButton = false;
|
|
2684
|
+
/**
|
|
2685
|
+
* Define if message is hidden
|
|
2686
|
+
*/
|
|
2687
|
+
this.hide = false;
|
|
2688
|
+
/**
|
|
2689
|
+
* Component classes
|
|
2690
|
+
*/
|
|
2691
|
+
this.classList = new index$1.ClassList(['mg-message']);
|
|
2692
|
+
/**
|
|
2693
|
+
* Define if component is using actions slot
|
|
2694
|
+
*/
|
|
2695
|
+
this.hasActions = false;
|
|
2696
|
+
/**
|
|
2697
|
+
* Handle close button
|
|
2698
|
+
*/
|
|
2699
|
+
this.handleClose = () => {
|
|
2700
|
+
this.hide = true;
|
|
2701
|
+
};
|
|
2702
|
+
/**
|
|
2703
|
+
* Hide component whith delay
|
|
2704
|
+
*/
|
|
2705
|
+
this.hideWithDelay = () => {
|
|
2706
|
+
if (this.delay > 0 && this.hide !== true) {
|
|
2707
|
+
this.storedTimer = setTimeout(() => (this.hide = true), this.delay * 1000);
|
|
2708
|
+
}
|
|
2709
|
+
else if (this.storedTimer !== null) {
|
|
2710
|
+
clearTimeout(this.storedTimer);
|
|
2711
|
+
}
|
|
2712
|
+
};
|
|
2713
|
+
/**
|
|
2714
|
+
* Get icon corresponding to variant
|
|
2715
|
+
*
|
|
2716
|
+
* @returns {string} icon
|
|
2717
|
+
*/
|
|
2718
|
+
this.getIcon = () => {
|
|
2719
|
+
switch (this.variant) {
|
|
2720
|
+
case 'info':
|
|
2721
|
+
return 'info-circle';
|
|
2722
|
+
case 'warning':
|
|
2723
|
+
return 'exclamation-triangle';
|
|
2724
|
+
case 'success':
|
|
2725
|
+
return 'check-circle';
|
|
2726
|
+
case 'danger':
|
|
2727
|
+
return 'exclamation-circle';
|
|
2728
|
+
}
|
|
2729
|
+
};
|
|
2730
|
+
}
|
|
2731
|
+
validateDelay(newValue) {
|
|
2732
|
+
if (newValue && newValue < 2) {
|
|
2733
|
+
throw new Error(`<mg-message> prop "delay" must be greater than 2 seconds.`);
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
validateVariant(newValue, oldValue) {
|
|
2737
|
+
if (!variants$1.includes(newValue)) {
|
|
2738
|
+
throw new Error(`<mg-message> prop "variant" must be one of : ${variants$1.join(', ')}`);
|
|
2739
|
+
}
|
|
2740
|
+
else {
|
|
2741
|
+
if (oldValue !== undefined) {
|
|
2742
|
+
this.classList.delete(`mg-message--${oldValue}`);
|
|
2743
|
+
}
|
|
2744
|
+
this.classList.add(`mg-message--${newValue}`);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
validateCloseButton(newValue) {
|
|
2748
|
+
if (newValue && this.hasActions) {
|
|
2749
|
+
this.closeButton = false;
|
|
2750
|
+
throw new Error('<mg-message> prop "close-button" can\'t be used with the actions slot.');
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
validateHide(newValue) {
|
|
2754
|
+
if (newValue) {
|
|
2755
|
+
this.componentHide.emit();
|
|
2756
|
+
this.classList.add(this.classHide);
|
|
2757
|
+
}
|
|
2758
|
+
else {
|
|
2759
|
+
this.componentShow.emit();
|
|
2760
|
+
this.classList.delete(this.classHide);
|
|
2761
|
+
}
|
|
2762
|
+
this.hideWithDelay();
|
|
2763
|
+
}
|
|
2764
|
+
/*************
|
|
2765
|
+
* Lifecycle *
|
|
2766
|
+
*************/
|
|
2767
|
+
/**
|
|
2768
|
+
* Check if component props are well configured on init
|
|
2769
|
+
*/
|
|
2770
|
+
componentWillLoad() {
|
|
2771
|
+
// Get locales
|
|
2772
|
+
this.messages = index$1.initLocales(this.element).messages;
|
|
2773
|
+
// Validate
|
|
2774
|
+
this.validateVariant(this.variant);
|
|
2775
|
+
// Check if close button is an can be activated
|
|
2776
|
+
this.hasActions = this.element.querySelector('[slot="actions"]') !== null;
|
|
2777
|
+
this.validateCloseButton(this.closeButton);
|
|
2778
|
+
if (this.closeButton) {
|
|
2779
|
+
this.classList.add('mg-message--close-button');
|
|
2780
|
+
this.closeButtonId = `${this.identifier}-close-button`;
|
|
2781
|
+
}
|
|
2782
|
+
this.validateDelay(this.delay);
|
|
2783
|
+
this.validateHide(this.hide);
|
|
2784
|
+
}
|
|
2785
|
+
/**
|
|
2786
|
+
* Render
|
|
2787
|
+
*
|
|
2788
|
+
* @returns {HTMLElement} HTML Element
|
|
2789
|
+
*/
|
|
2790
|
+
render() {
|
|
2791
|
+
return (index.h("div", { id: this.identifier, class: this.classList.join(), role: this.variant === 'info' ? 'status' : 'alert' }, index.h("span", { class: "mg-message__icon" }, index.h("mg-icon", { icon: this.getIcon() })), index.h("div", { class: "mg-message__content" }, index.h("span", { class: "mg-message__content-slot" }, index.h("slot", null)), this.hasActions && index.h("span", { class: "mg-message__content-separator" }), this.hasActions && (index.h("span", { class: "mg-message__content-actions-slot" }, index.h("slot", { name: "actions" })))), this.closeButton && (index.h("span", { class: "mg-message__close-button" }, index.h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: this.messages.message.closeButton, onClick: this.handleClose }, index.h("mg-icon", { icon: "cross" }))))));
|
|
2792
|
+
}
|
|
2793
|
+
get element() { return index.getElement(this); }
|
|
2794
|
+
static get watchers() { return {
|
|
2795
|
+
"delay": ["validateDelay"],
|
|
2796
|
+
"variant": ["validateVariant"],
|
|
2797
|
+
"closeButton": ["validateCloseButton"],
|
|
2798
|
+
"hide": ["validateHide"]
|
|
2799
|
+
}; }
|
|
2800
|
+
};
|
|
2801
|
+
MgMessage.style = mgMessageCss;
|
|
2802
|
+
|
|
2803
|
+
var NavigationAction;
|
|
2804
|
+
(function (NavigationAction) {
|
|
2805
|
+
NavigationAction["NEXT"] = "next";
|
|
2806
|
+
NavigationAction["PREVIOUS"] = "previous";
|
|
2807
|
+
})(NavigationAction || (NavigationAction = {}));
|
|
2808
|
+
|
|
2809
|
+
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:flex;align-items:center;flex-direction:row}.mg-pagination__nav mg-input-select{margin-right:0.5rem}.mg-pagination__button{display:flex}.mg-pagination__button:first-of-type{margin-right:1rem}.mg-pagination__button:last-of-type{margin-left:1rem}";
|
|
2810
|
+
|
|
2811
|
+
/**
|
|
2812
|
+
* Range generator
|
|
2813
|
+
*
|
|
2814
|
+
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
2815
|
+
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
2816
|
+
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
2817
|
+
* then with Array.from(Array(...)) we get the complete array with "index" values instead of "empty" values
|
|
2818
|
+
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
2819
|
+
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
2820
|
+
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
2821
|
+
*
|
|
2822
|
+
* range(1, 1) = [1]
|
|
2823
|
+
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
2824
|
+
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
2825
|
+
*
|
|
2826
|
+
* @param {number} start start range
|
|
2827
|
+
* @param {number} end start end
|
|
2828
|
+
* @param {number} step step size
|
|
2829
|
+
* @returns {number[]} range numbers
|
|
2830
|
+
*/
|
|
2831
|
+
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
2832
|
+
const MgPagination = class {
|
|
2833
|
+
constructor(hostRef) {
|
|
2834
|
+
index.registerInstance(this, hostRef);
|
|
2835
|
+
this.currentPageChange = index.createEvent(this, "current-page-change", 7);
|
|
2836
|
+
/**
|
|
2837
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
2838
|
+
* If not set, it will be created.
|
|
2839
|
+
*/
|
|
2840
|
+
this.identifier = index$1.createID('mg-pagination');
|
|
2841
|
+
/**
|
|
2842
|
+
* Component total pages
|
|
2843
|
+
*/
|
|
2844
|
+
this.totalPages = 1;
|
|
2845
|
+
/**
|
|
2846
|
+
* Component current page
|
|
2847
|
+
*/
|
|
2848
|
+
this.currentPage = 1;
|
|
2849
|
+
/**
|
|
2850
|
+
* Change current page from target
|
|
2851
|
+
*
|
|
2852
|
+
* @param {number} target target page
|
|
2853
|
+
* @returns {void}
|
|
2854
|
+
*/
|
|
2855
|
+
this.goToPage = (target) => {
|
|
2856
|
+
this.currentPage = target;
|
|
2857
|
+
};
|
|
2858
|
+
/************
|
|
2859
|
+
* Handlers *
|
|
2860
|
+
************/
|
|
2861
|
+
/**
|
|
2862
|
+
* select handler
|
|
2863
|
+
*
|
|
2864
|
+
* @param {InputEvent} event value change event
|
|
2865
|
+
* @returns {void}
|
|
2866
|
+
*/
|
|
2867
|
+
this.handleSelect = (event) => {
|
|
2868
|
+
const to = Number(event.target.value);
|
|
2869
|
+
this.goToPage(to > 0 ? to : 1);
|
|
2870
|
+
};
|
|
2871
|
+
/**
|
|
2872
|
+
* Go to 'previous/next' page button handler
|
|
2873
|
+
*
|
|
2874
|
+
* @param {string} action navigation action
|
|
2875
|
+
* @returns {void}
|
|
2876
|
+
*/
|
|
2877
|
+
this.handleGoToPage = (action) => {
|
|
2878
|
+
this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
2879
|
+
};
|
|
2880
|
+
}
|
|
2881
|
+
validateTotalPages(newValue) {
|
|
2882
|
+
if (newValue < 1) {
|
|
2883
|
+
throw new Error('<mg-pagination> prop "totalPages" must be greater than 0');
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
validateCurrentPage(newValue) {
|
|
2887
|
+
if (newValue < 1) {
|
|
2888
|
+
throw new Error('<mg-pagination> prop "currentPage" must be greater than 0');
|
|
2889
|
+
}
|
|
2890
|
+
else if (newValue > this.totalPages) {
|
|
2891
|
+
throw new Error('<mg-pagination> prop "currentPage" can not be greater than total page');
|
|
2892
|
+
}
|
|
2893
|
+
this.currentPageChange.emit(newValue);
|
|
2894
|
+
}
|
|
2895
|
+
/*************
|
|
2896
|
+
* Lifecycle *
|
|
2897
|
+
*************/
|
|
2898
|
+
/**
|
|
2899
|
+
* Check if props are well configured on init
|
|
2900
|
+
*
|
|
2901
|
+
* @returns {void}
|
|
2902
|
+
*/
|
|
2903
|
+
componentWillLoad() {
|
|
2904
|
+
// Get locales
|
|
2905
|
+
this.messages = index$1.initLocales(this.element).messages;
|
|
2906
|
+
// Validate
|
|
2907
|
+
this.validateTotalPages(this.totalPages);
|
|
2908
|
+
this.validateCurrentPage(this.currentPage);
|
|
2909
|
+
// Set default label
|
|
2910
|
+
if (this.label === undefined || this.label === '') {
|
|
2911
|
+
this.label = this.messages.pagination.label;
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Render
|
|
2916
|
+
*
|
|
2917
|
+
* @returns {HTMLElement} HTML Element
|
|
2918
|
+
*/
|
|
2919
|
+
render() {
|
|
2920
|
+
const navigationActionButton = (disabled, action) => (index.h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: this.messages.pagination[`${action}Page`],
|
|
2921
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
2922
|
+
onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" }, action === NavigationAction.PREVIOUS && index.h("mg-icon", { icon: "chevron-left" }), this.messages.general[action], action === NavigationAction.NEXT && index.h("mg-icon", { icon: "chevron-right" })));
|
|
2923
|
+
return (index.h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination__nav" }, navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS), index.h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: this.messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }), index.h("span", { class: "sr-only" }, this.messages.pagination.page, " ", this.currentPage), index.h("span", null, "/ ", this.totalPages, " ", this.totalPages > 1 ? this.messages.pagination.pages : this.messages.pagination.page), navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
|
|
2924
|
+
}
|
|
2925
|
+
get element() { return index.getElement(this); }
|
|
2926
|
+
static get watchers() { return {
|
|
2927
|
+
"totalPages": ["validateTotalPages"],
|
|
2928
|
+
"currentPage": ["validateCurrentPage"]
|
|
2929
|
+
}; }
|
|
2930
|
+
};
|
|
2931
|
+
MgPagination.style = mgPaginationCss;
|
|
2932
|
+
|
|
2933
|
+
const mgPanelCss = ".mg-panel{background-color:hsl(var(--mg-panel-background));border-radius:var(--mg-panel-border-radius);box-shadow:var(--box-shadow)}.mg-panel__header{display:flex;flex-wrap:wrap;justify-content:space-between;padding:0 1rem 0 0.3rem;align-items:flex-start}.mg-panel__header-left,.mg-panel__header-right{display:flex;margin:0.3rem 0}.mg-panel__header-left--full{flex:1 1 auto}.mg-panel__header-right{flex:1 auto}.mg-panel__header-left mg-input-text{flex-grow:1}.mg-panel__collapse-button .mg-button{font-family:var(--font-family-heading);font-size:1.4rem;font-weight:500}.mg-panel__collapse-button,.mg-panel__edit-button{margin:0 0.3rem 0 0}.mg-panel__content{padding:1.5rem}.mg-panel ::slotted([slot=header-right]){display:flex;flex-wrap:wrap;gap:1rem;margin-left:auto}";
|
|
2934
|
+
|
|
2935
|
+
const MgPanel = class {
|
|
2936
|
+
constructor(hostRef) {
|
|
2937
|
+
index.registerInstance(this, hostRef);
|
|
2938
|
+
this.titleChange = index.createEvent(this, "title-change", 7);
|
|
2939
|
+
this.expandedChange = index.createEvent(this, "expanded-change", 7);
|
|
2940
|
+
/**
|
|
2941
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
2942
|
+
* If not set, it will be created.
|
|
2943
|
+
*/
|
|
2944
|
+
this.identifier = index$1.createID('mg-panel');
|
|
2945
|
+
/**
|
|
2946
|
+
* Panel is opened
|
|
2947
|
+
*/
|
|
2948
|
+
this.expanded = false;
|
|
2949
|
+
/**
|
|
2950
|
+
* Disable possibility to toggle expand
|
|
2951
|
+
*/
|
|
2952
|
+
this.expandToggleDisabled = false;
|
|
2953
|
+
/**
|
|
2954
|
+
* Panel title is editabled
|
|
2955
|
+
*/
|
|
2956
|
+
this.titleEditable = false;
|
|
2957
|
+
/**
|
|
2958
|
+
* Component classes
|
|
2959
|
+
*/
|
|
2960
|
+
this.classList = new index$1.ClassList(['mg-panel']);
|
|
2961
|
+
/**
|
|
2962
|
+
* Title is in edition mode
|
|
2963
|
+
*/
|
|
2964
|
+
this.isEditing = false;
|
|
2965
|
+
/************
|
|
2966
|
+
* Methods *
|
|
2967
|
+
************/
|
|
2968
|
+
/**
|
|
2969
|
+
* Toggle is editing state
|
|
2970
|
+
*
|
|
2971
|
+
* @returns {void}
|
|
2972
|
+
*/
|
|
2973
|
+
this.toggleIsEditing = () => {
|
|
2974
|
+
this.isEditing = !this.isEditing;
|
|
2975
|
+
};
|
|
2976
|
+
/************
|
|
2977
|
+
* Handlers *
|
|
2978
|
+
************/
|
|
2979
|
+
/**
|
|
2980
|
+
* Collapse button click handler
|
|
2981
|
+
*
|
|
2982
|
+
* @returns {void}
|
|
2983
|
+
*/
|
|
2984
|
+
this.handleCollapseButton = () => {
|
|
2985
|
+
if (!this.expandToggleDisabled) {
|
|
2986
|
+
this.expanded = !this.expanded;
|
|
2987
|
+
}
|
|
2988
|
+
};
|
|
2989
|
+
/**
|
|
2990
|
+
* Edit button click handler
|
|
2991
|
+
*
|
|
2992
|
+
* @returns {void}
|
|
2993
|
+
*/
|
|
2994
|
+
this.handleEditButton = () => {
|
|
2995
|
+
this.toggleIsEditing();
|
|
2996
|
+
};
|
|
2997
|
+
/**
|
|
2998
|
+
* Update title handler
|
|
2999
|
+
*
|
|
3000
|
+
* @param {CustomEvent<string>} event input value change event
|
|
3001
|
+
* @returns {void}
|
|
3002
|
+
*/
|
|
3003
|
+
this.handleUpdateTitle = (event) => {
|
|
3004
|
+
this.updatedPanelTitle = event.detail;
|
|
3005
|
+
};
|
|
3006
|
+
/**
|
|
3007
|
+
* Cancel edition button handler
|
|
3008
|
+
*
|
|
3009
|
+
* @returns {void}
|
|
3010
|
+
*/
|
|
3011
|
+
this.handleCancelEditButton = () => {
|
|
3012
|
+
this.updatedPanelTitle = undefined;
|
|
3013
|
+
this.toggleIsEditing();
|
|
3014
|
+
};
|
|
3015
|
+
/**
|
|
3016
|
+
* Validate edition button handler
|
|
3017
|
+
*
|
|
3018
|
+
* @returns {void}
|
|
3019
|
+
*/
|
|
3020
|
+
this.handleValidateEditButton = () => {
|
|
3021
|
+
if (this.editInputElement.valid) {
|
|
3022
|
+
if (this.updatedPanelTitle !== undefined)
|
|
3023
|
+
this.panelTitle = this.updatedPanelTitle;
|
|
3024
|
+
this.toggleIsEditing();
|
|
3025
|
+
}
|
|
3026
|
+
};
|
|
3027
|
+
/**
|
|
3028
|
+
* Header left conditional render
|
|
3029
|
+
*
|
|
3030
|
+
* @typedef {HTMLElement} HTMLMgButtonElement
|
|
3031
|
+
* @returns {HTMLMgButtonElement | HTMLElement | HTMLElement[]} header left element
|
|
3032
|
+
*/
|
|
3033
|
+
this.headerLeft = () => {
|
|
3034
|
+
const collapseButton = () => (index.h("mg-button", { onClick: this.handleCollapseButton, variant: "flat", class: "mg-panel__collapse-button", identifier: `${this.identifier}-collapse-button`, expanded: this.expanded, controls: `${this.identifier}-content`, disabled: this.expandToggleDisabled }, index.h("mg-icon", { icon: this.expanded ? 'chevron-up' : 'chevron-down' }), !this.isEditing && this.panelTitle));
|
|
3035
|
+
if (this.titleEditable && !this.isEditing) {
|
|
3036
|
+
return [
|
|
3037
|
+
collapseButton(),
|
|
3038
|
+
index.h("mg-button", { "is-icon": true, variant: "flat", class: "mg-panel__edit-button", label: this.messages.panel.editLabel, onClick: this.handleEditButton, identifier: `${this.identifier}-edit-button` }, index.h("mg-icon", { icon: "pen" })),
|
|
3039
|
+
];
|
|
3040
|
+
}
|
|
3041
|
+
if (this.titleEditable && this.isEditing) {
|
|
3042
|
+
return [
|
|
3043
|
+
collapseButton(),
|
|
3044
|
+
index.h("mg-input-text", { label: this.messages.panel.editLabel, "label-hide": true, value: this.panelTitle, "onValue-change": this.handleUpdateTitle, displayCharacterLeft: false, pattern: this.titlePattern, "pattern-error-message": this.titlePatternErrorMessage, identifier: `${this.identifier}-edition-input`, ref: el => (this.editInputElement = el) }, index.h("mg-button", { slot: "append-input", label: this.messages.general.cancel, "is-icon": true, variant: "secondary", onClick: this.handleCancelEditButton, identifier: `${this.identifier}-edition-button-cancel` }, index.h("mg-icon", { icon: "cross" })), index.h("mg-button", { slot: "append-input", label: this.messages.general.confirm, "is-icon": true, variant: "secondary", onClick: this.handleValidateEditButton, identifier: `${this.identifier}-edition-button-validate` }, index.h("mg-icon", { icon: "check" }))),
|
|
3045
|
+
];
|
|
3046
|
+
}
|
|
3047
|
+
return collapseButton();
|
|
3048
|
+
};
|
|
3049
|
+
}
|
|
3050
|
+
handelTileChange(newValue) {
|
|
3051
|
+
this.titleChange.emit(newValue);
|
|
3052
|
+
}
|
|
3053
|
+
validatetitlePattern(newValue) {
|
|
3054
|
+
if (newValue && !this.titleEditable) {
|
|
3055
|
+
throw new Error('<mg-panel> prop "titleEditable" must be set to `true`.');
|
|
3056
|
+
}
|
|
3057
|
+
if (newValue && this.titlePatternErrorMessage === undefined) {
|
|
3058
|
+
throw new Error('<mg-panel> prop "titlePattern" must be paired with the prop "titlePatternErrorMessage".');
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
handleExpanded(newValue) {
|
|
3062
|
+
this.expandedChange.emit(newValue);
|
|
3063
|
+
}
|
|
3064
|
+
/*************
|
|
3065
|
+
* Lifecycle *
|
|
3066
|
+
*************/
|
|
3067
|
+
/**
|
|
3068
|
+
* Check if props are well configured on init
|
|
3069
|
+
*
|
|
3070
|
+
* @returns {void}
|
|
3071
|
+
*/
|
|
3072
|
+
componentWillLoad() {
|
|
3073
|
+
// Get locales
|
|
3074
|
+
this.messages = index$1.initLocales(this.element).messages;
|
|
3075
|
+
// Validate
|
|
3076
|
+
this.validatetitlePattern(this.titlePattern);
|
|
3077
|
+
}
|
|
3078
|
+
/**
|
|
3079
|
+
* Edit DOM after render
|
|
3080
|
+
*
|
|
3081
|
+
* @returns {void}
|
|
3082
|
+
*/
|
|
3083
|
+
componentDidRender() {
|
|
3084
|
+
// when we are editing we get focus on edition input
|
|
3085
|
+
if (this.isEditing) {
|
|
3086
|
+
this.editInputElement.setFocus();
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
/**
|
|
3090
|
+
* Render component
|
|
3091
|
+
*
|
|
3092
|
+
* @returns {HTMLElement} html element
|
|
3093
|
+
*/
|
|
3094
|
+
render() {
|
|
3095
|
+
return (index.h("section", { class: this.classList.join(), id: this.identifier }, index.h("header", { class: "mg-panel__header", id: `${this.identifier}-header` }, index.h("div", { class: `mg-panel__header-left ${this.isEditing ? 'mg-panel__header-left--full' : ''}` }, this.headerLeft()), index.h("div", { class: "mg-panel__header-right" }, index.h("slot", { name: "header-right" }))), index.h("article", { class: "mg-panel__content", id: `${this.identifier}-content`, "aria-labelledby": `${this.identifier}-header`, hidden: !this.expanded }, index.h("slot", null))));
|
|
3096
|
+
}
|
|
3097
|
+
get element() { return index.getElement(this); }
|
|
3098
|
+
static get watchers() { return {
|
|
3099
|
+
"panelTitle": ["handelTileChange"],
|
|
3100
|
+
"titlePattern": ["validatetitlePattern"],
|
|
3101
|
+
"expanded": ["handleExpanded"]
|
|
3102
|
+
}; }
|
|
3103
|
+
};
|
|
3104
|
+
MgPanel.style = mgPanelCss;
|
|
3105
|
+
|
|
3106
|
+
var Status;
|
|
3107
|
+
(function (Status) {
|
|
3108
|
+
Status["VISIBLE"] = "visible";
|
|
3109
|
+
Status["HIDDEN"] = "hidden";
|
|
3110
|
+
Status["DISABLED"] = "disabled";
|
|
3111
|
+
Status["ACTIVE"] = "active";
|
|
3112
|
+
})(Status || (Status = {}));
|
|
3113
|
+
/**
|
|
3114
|
+
* List of all possibles sizes
|
|
3115
|
+
*/
|
|
3116
|
+
const sizes = ['regular', 'large'];
|
|
3117
|
+
|
|
3118
|
+
const mgTabsCss = ".mg-tabs.mg-tabs--size-regular .mg-tabs__navigation-button{padding:calc(1rem + 0.3rem) calc(1rem * 1.3) 1rem}.mg-tabs.mg-tabs--size-large .mg-tabs__navigation-button{padding:calc(1.8rem + 0.3rem) calc(1.8rem * 1.3) 1.8rem}.mg-tabs__header{display:flex;flex-direction:row;flex-wrap:wrap}.mg-tabs__navigation-button{display:flex;align-items:center;column-gap:0.5rem;background:none;border:none;border-bottom:0.3rem solid transparent;color:hsl(var(--color-dark));line-height:var(--line-height);cursor:pointer}.mg-tabs__navigation-button:disabled,.mg-tabs__navigation-button--disabled{cursor:default;opacity:30%}.mg-tabs__navigation-button:hover:not(:disabled),.mg-tabs__navigation-button:focus:not(:disabled){background-color:hsla(var(--color-info-h), var(--color-info-s), var(--color-info-l), 10%)}.mg-tabs__navigation-button.mg-tabs__navigation-button--active{color:hsl(var(--color-info));border-bottom-color:hsl(var(--color-info));font-weight:700}.mg-tabs__navigation-button.mg-tabs__navigation-button--hidden{display:none}.mg-tabs__content-container:focus-visible{outline:none}";
|
|
3119
|
+
|
|
3120
|
+
/**
|
|
3121
|
+
* type TabItem validation function
|
|
3122
|
+
*
|
|
3123
|
+
* @param {TabItem} tab tab item
|
|
3124
|
+
* @returns {boolean} tab item type is valid
|
|
3125
|
+
*/
|
|
3126
|
+
const isTabItem = (tab) => typeof tab === 'object' && typeof tab.label === 'string';
|
|
3127
|
+
const MgTabs = class {
|
|
3128
|
+
constructor(hostRef) {
|
|
3129
|
+
index.registerInstance(this, hostRef);
|
|
3130
|
+
this.activeTabChange = index.createEvent(this, "active-tab-change", 7);
|
|
3131
|
+
/************
|
|
3132
|
+
* Internal *
|
|
3133
|
+
************/
|
|
3134
|
+
this.tabPanel = 'panel';
|
|
3135
|
+
this.startIndex = 1;
|
|
3136
|
+
this.buttonTabBaseClass = 'mg-tabs__navigation-button';
|
|
3137
|
+
/**
|
|
3138
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
3139
|
+
* If not set, it will be created.
|
|
3140
|
+
*/
|
|
3141
|
+
this.identifier = index$1.createID('mg-tabs');
|
|
3142
|
+
/**
|
|
3143
|
+
* Define tabs size
|
|
3144
|
+
*/
|
|
3145
|
+
this.size = 'regular';
|
|
3146
|
+
/**
|
|
3147
|
+
* Active tab number
|
|
3148
|
+
* default: first is 1
|
|
3149
|
+
*/
|
|
3150
|
+
this.activeTab = 1;
|
|
3151
|
+
/**
|
|
3152
|
+
* Component tabs
|
|
3153
|
+
*/
|
|
3154
|
+
this.tabs = [];
|
|
3155
|
+
/**
|
|
3156
|
+
* Component classes
|
|
3157
|
+
*/
|
|
3158
|
+
this.classList = new index$1.ClassList(['mg-tabs']);
|
|
3159
|
+
/**
|
|
3160
|
+
* Method to set active tab
|
|
3161
|
+
*
|
|
3162
|
+
* @param {number} tabKey item tab key to set to ACTIVE status
|
|
3163
|
+
* @returns {void}
|
|
3164
|
+
*/
|
|
3165
|
+
this.setActiveTab = (tabKey) => {
|
|
3166
|
+
// reset active tabs
|
|
3167
|
+
this.tabs.forEach(tab => {
|
|
3168
|
+
if (this.tabHasGivenStatus(tab, Status.ACTIVE))
|
|
3169
|
+
tab.status = Status.VISIBLE;
|
|
3170
|
+
});
|
|
3171
|
+
// set active tab from given tab key
|
|
3172
|
+
this.tabs[tabKey - this.startIndex].status = Status.ACTIVE;
|
|
3173
|
+
// emit change active tab key event
|
|
3174
|
+
this.activeTabChange.emit(tabKey);
|
|
3175
|
+
};
|
|
3176
|
+
/**
|
|
3177
|
+
* Method to know if given tab has the given status
|
|
3178
|
+
*
|
|
3179
|
+
* @param {TabItem} tab item tab key to set to ACTIVE status
|
|
3180
|
+
* @param {Status} status status to valide
|
|
3181
|
+
* @returns {boolean} status comparaison
|
|
3182
|
+
*/
|
|
3183
|
+
this.tabHasGivenStatus = (tab, status) => tab.status === status;
|
|
3184
|
+
/**
|
|
3185
|
+
* Method to get element id from index
|
|
3186
|
+
*
|
|
3187
|
+
* @param {string} element to get id
|
|
3188
|
+
* @param {number} index to generate id
|
|
3189
|
+
* @returns {string} generated element id
|
|
3190
|
+
*/
|
|
3191
|
+
this.getElementId = (element, index) => `${element}-${this.getTabIndex(index)}`;
|
|
3192
|
+
/**
|
|
3193
|
+
* Method to get tab index
|
|
3194
|
+
*
|
|
3195
|
+
* @param {number} index to get
|
|
3196
|
+
* @returns {number} index
|
|
3197
|
+
*/
|
|
3198
|
+
this.getTabIndex = (index) => index + this.startIndex;
|
|
3199
|
+
/**
|
|
3200
|
+
* Handle click events on tabs
|
|
3201
|
+
*
|
|
3202
|
+
* @param {MouseEvent} event mouse event
|
|
3203
|
+
*/
|
|
3204
|
+
this.handleClick = (event) => {
|
|
3205
|
+
const tabId = event.currentTarget.getAttribute('data-index');
|
|
3206
|
+
this.activeTab = Number(tabId);
|
|
3207
|
+
};
|
|
3208
|
+
/**
|
|
3209
|
+
* get navigation button class from given status
|
|
3210
|
+
*
|
|
3211
|
+
* @param {Status} status button tab status
|
|
3212
|
+
* @param {boolean} isSelector set if we need a CSS selector with the dot '.' at the begin. default value = false.
|
|
3213
|
+
* @returns {string} button class/selector variant
|
|
3214
|
+
*/
|
|
3215
|
+
this.getNavigationButtonClass = (status, isSelector = false) => `${isSelector ? '.' : ''}${this.buttonTabBaseClass}--${status}`;
|
|
3216
|
+
/**
|
|
3217
|
+
* Handle keyboard event on tabs
|
|
3218
|
+
*
|
|
3219
|
+
* @param {MouseEvent} event mouse event
|
|
3220
|
+
* @returns {void}
|
|
3221
|
+
*/
|
|
3222
|
+
this.handleKeydown = (event) => {
|
|
3223
|
+
let tabId = Number(event.target.getAttribute('data-index'));
|
|
3224
|
+
const parent = event.target.parentElement;
|
|
3225
|
+
// change selected id from key code
|
|
3226
|
+
if (event.key === 'ArrowRight') {
|
|
3227
|
+
tabId++;
|
|
3228
|
+
}
|
|
3229
|
+
else if (event.key === 'ArrowLeft') {
|
|
3230
|
+
tabId--;
|
|
3231
|
+
}
|
|
3232
|
+
// get selected tab if NOT hidden, disabled
|
|
3233
|
+
const selectedTab = parent.querySelector(`[data-index="${tabId}"]:not(${[this.getNavigationButtonClass(Status.HIDDEN, true), this.getNavigationButtonClass(Status.DISABLED, true)].join()})`);
|
|
3234
|
+
// apply selected tab if exist
|
|
3235
|
+
if (selectedTab !== null) {
|
|
3236
|
+
selectedTab.focus();
|
|
3237
|
+
this.activeTab = tabId;
|
|
3238
|
+
}
|
|
3239
|
+
};
|
|
3240
|
+
/**
|
|
3241
|
+
* Validate slots setting
|
|
3242
|
+
*/
|
|
3243
|
+
this.validateSlots = () => {
|
|
3244
|
+
const slots = Array.from(this.element.children).filter(slot => { var _a; return (_a = slot.getAttribute('slot')) === null || _a === void 0 ? void 0 : _a.includes('tab_content-'); });
|
|
3245
|
+
if (slots.length !== this.tabs.length) {
|
|
3246
|
+
throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
|
|
3247
|
+
}
|
|
3248
|
+
};
|
|
3249
|
+
}
|
|
3250
|
+
validateSize(newValue) {
|
|
3251
|
+
if (!sizes.includes(newValue)) {
|
|
3252
|
+
throw new Error(`<mg-tabs> prop "size" must be one of : ${sizes.join(', ')}`);
|
|
3253
|
+
}
|
|
3254
|
+
this.classList.add(`mg-tabs--size-${this.size}`);
|
|
3255
|
+
}
|
|
3256
|
+
validateItems(newValue) {
|
|
3257
|
+
// String array
|
|
3258
|
+
if (index$1.allItemsAreString(newValue)) {
|
|
3259
|
+
this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
|
|
3260
|
+
}
|
|
3261
|
+
// Object array
|
|
3262
|
+
else if (newValue && newValue.every(item => isTabItem(item))) {
|
|
3263
|
+
this.tabs = newValue;
|
|
3264
|
+
}
|
|
3265
|
+
else {
|
|
3266
|
+
throw new Error('<mg-tabs> prop "items" is required and all items must be the same type: TabItem.');
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
validateActiveTab(newValue) {
|
|
3270
|
+
if (newValue < 1 || newValue > this.tabs.length) {
|
|
3271
|
+
throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
|
|
3272
|
+
}
|
|
3273
|
+
else {
|
|
3274
|
+
this.setActiveTab(newValue);
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
/*************
|
|
3278
|
+
* Lifecycle *
|
|
3279
|
+
*************/
|
|
3280
|
+
/**
|
|
3281
|
+
* Check if component props are well configured on init
|
|
3282
|
+
*
|
|
3283
|
+
* @returns {void}
|
|
3284
|
+
*/
|
|
3285
|
+
componentWillLoad() {
|
|
3286
|
+
// Check tabs format
|
|
3287
|
+
this.validateItems(this.items);
|
|
3288
|
+
this.validateActiveTab(this.activeTab);
|
|
3289
|
+
this.validateSize(this.size);
|
|
3290
|
+
this.validateSlots();
|
|
3291
|
+
}
|
|
3292
|
+
/**
|
|
3293
|
+
* Render
|
|
3294
|
+
*
|
|
3295
|
+
* @returns {HTMLElement} HTML Element
|
|
3296
|
+
*/
|
|
3297
|
+
render() {
|
|
3298
|
+
return (index.h(index.Host, null, index.h("div", { class: this.classList.join() }, index.h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index$1) => (index.h("button", { role: "tab", id: this.getElementId(this.identifier, index$1), class: {
|
|
3299
|
+
[`${this.buttonTabBaseClass}`]: true,
|
|
3300
|
+
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasGivenStatus(tab, Status.ACTIVE),
|
|
3301
|
+
[`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasGivenStatus(tab, Status.DISABLED),
|
|
3302
|
+
[`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasGivenStatus(tab, Status.HIDDEN),
|
|
3303
|
+
}, tabindex: this.tabHasGivenStatus(tab, Status.ACTIVE) ? 0 : -1, "aria-selected": this.tabHasGivenStatus(tab, Status.ACTIVE).toString(), "aria-controls": this.getElementId(this.tabPanel, index$1), onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": this.getTabIndex(index$1), disabled: this.tabHasGivenStatus(tab, Status.DISABLED) }, tab.icon !== undefined && index.h("mg-icon", { icon: tab.icon }), tab.label, tab.badge !== undefined && index.h("mg-badge", { variant: "info", value: tab.badge.value, label: tab.badge.label }))))), this.tabs.map((tab, index$1) => (index.h("article", { role: "tabpanel", id: this.getElementId(this.tabPanel, index$1), hidden: !this.tabHasGivenStatus(tab, Status.ACTIVE), "aria-labelledby": this.getElementId(this.identifier, index$1), tabindex: this.tabHasGivenStatus(tab, Status.ACTIVE) ? 0 : -1, class: "mg-tabs__content-container" }, index.h("slot", { name: this.getElementId('tab_content', index$1) })))))));
|
|
3304
|
+
}
|
|
3305
|
+
get element() { return index.getElement(this); }
|
|
3306
|
+
static get watchers() { return {
|
|
3307
|
+
"size": ["validateSize"],
|
|
3308
|
+
"items": ["validateItems"],
|
|
3309
|
+
"activeTab": ["validateActiveTab"]
|
|
3310
|
+
}; }
|
|
3311
|
+
};
|
|
3312
|
+
MgTabs.style = mgTabsCss;
|
|
3313
|
+
|
|
3314
|
+
/**
|
|
3315
|
+
* List of all possibles variants
|
|
3316
|
+
*/
|
|
3317
|
+
const variants = ['primary', 'secondary', 'success', 'warning', 'danger', 'info'];
|
|
3318
|
+
|
|
3319
|
+
const mgTagCss = ".mg-tag{padding:calc((var(--mg-tag-height) - 0.2rem - var(--mg-tag-font-size) * var(--line-height)) / 2) 0.6rem;min-height:var(--mg-tag-height);box-sizing:border-box;border-radius:var(--mg-tag-border-radius);border:0.1rem solid;font-size:var(--mg-tag-font-size);font-weight:600;text-align:center}.mg-tag.mg-tag--primary{background-color:hsl(var(--color-dark));border-color:hsl(var(--color-dark));color:hsl(var(--color-light))}.mg-tag.mg-tag--primary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary{background-color:hsl(var(--color-light));border-color:hsl(var(--color-light));color:hsl(var(--color-dark))}.mg-tag.mg-tag--secondary.mg-tag--outline{background-color:transparent;color:hsl(var(--color-light))}.mg-tag.mg-tag--success{background-color:hsl(var(--color-success));border-color:hsl(var(--color-success));color:hsl(var(--color-dark))}.mg-tag.mg-tag--success.mg-tag--outline{background-color:transparent;color:hsl(var(--color-success))}.mg-tag.mg-tag--warning{background-color:hsl(var(--color-warning));border-color:hsl(var(--color-warning));color:hsl(var(--color-dark))}.mg-tag.mg-tag--warning.mg-tag--outline{background-color:transparent;color:hsl(var(--color-warning))}.mg-tag.mg-tag--danger{background-color:hsl(var(--color-danger));border-color:hsl(var(--color-danger));color:hsl(var(--color-light))}.mg-tag.mg-tag--danger.mg-tag--outline{background-color:transparent;color:hsl(var(--color-danger))}.mg-tag.mg-tag--info{background-color:hsl(var(--color-info));border-color:hsl(var(--color-info));color:hsl(var(--color-light))}.mg-tag.mg-tag--info.mg-tag--outline{background-color:transparent;color:hsl(var(--color-info))}.mg-tag,mg-tag{display:inline-block;vertical-align:middle}";
|
|
3320
|
+
|
|
3321
|
+
const MgTag = class {
|
|
3322
|
+
constructor(hostRef) {
|
|
3323
|
+
index.registerInstance(this, hostRef);
|
|
3324
|
+
/************
|
|
3325
|
+
* Internal *
|
|
3326
|
+
************/
|
|
3327
|
+
// classes
|
|
3328
|
+
this.classOutline = `mg-tag--outline`;
|
|
3329
|
+
/**************
|
|
3330
|
+
* Decorators *
|
|
3331
|
+
**************/
|
|
3332
|
+
/**
|
|
3333
|
+
* Define button variant
|
|
3334
|
+
*/
|
|
3335
|
+
this.variant = variants[0]; // primary
|
|
3336
|
+
/**
|
|
3337
|
+
* Component classes
|
|
3338
|
+
*/
|
|
3339
|
+
this.classList = new index$1.ClassList(['mg-tag']);
|
|
3340
|
+
}
|
|
3341
|
+
validateVariant(newValue, oldValue) {
|
|
3342
|
+
if (!variants.includes(newValue)) {
|
|
3343
|
+
throw new Error(`<mg-tag> prop "variant" must be one of : ${variants.join(', ')}.`);
|
|
3344
|
+
}
|
|
3345
|
+
else {
|
|
3346
|
+
if (oldValue !== undefined) {
|
|
3347
|
+
this.classList.delete(`mg-tag--${oldValue}`);
|
|
3348
|
+
}
|
|
3349
|
+
this.classList.add(`mg-tag--${newValue}`);
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
validateOutline(newValue) {
|
|
3353
|
+
if (newValue)
|
|
3354
|
+
this.classList.add(this.classOutline);
|
|
3355
|
+
else
|
|
3356
|
+
this.classList.delete(this.classOutline);
|
|
3357
|
+
}
|
|
3358
|
+
/*************
|
|
3359
|
+
* Lifecycle *
|
|
3360
|
+
*************/
|
|
3361
|
+
/**
|
|
3362
|
+
* Check if props are well configured on init
|
|
3363
|
+
*
|
|
3364
|
+
* @returns {void}
|
|
3365
|
+
*/
|
|
3366
|
+
componentWillLoad() {
|
|
3367
|
+
this.validateVariant(this.variant);
|
|
3368
|
+
this.validateOutline(this.outline);
|
|
3369
|
+
}
|
|
3370
|
+
/**
|
|
3371
|
+
* Render
|
|
3372
|
+
*
|
|
3373
|
+
* @returns {HTMLElement} HTML Element
|
|
3374
|
+
*/
|
|
3375
|
+
render() {
|
|
3376
|
+
return (index.h("span", { class: this.classList.join() }, index.h("slot", null)));
|
|
3377
|
+
}
|
|
3378
|
+
static get watchers() { return {
|
|
3379
|
+
"variant": ["validateVariant"],
|
|
3380
|
+
"outline": ["validateOutline"]
|
|
3381
|
+
}; }
|
|
3382
|
+
};
|
|
3383
|
+
MgTag.style = mgTagCss;
|
|
3384
|
+
|
|
3385
|
+
const mgTooltipCss = ".sc-mg-tooltip-h{display:inline-block}.mg-tooltip.sc-mg-tooltip{display:none;padding:0.5rem 0.8rem;z-index:9999;border-radius:var(--mg-tooltip-border-radius);background-color:hsl(var(--mg-tooltip-background-color));color:hsl(var(--mg-tooltip-font-color));text-align:start}.mg-tooltip[data-show].sc-mg-tooltip{display:block}.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip,.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip::before{position:absolute;width:0.8rem;height:0.8rem;z-index:9999;background:inherit}.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip{visibility:hidden}.mg-tooltip.sc-mg-tooltip .mg-tooltip__arrow.sc-mg-tooltip::before{visibility:visible;content:\"\";transform:rotate(45deg)}.mg-tooltip[data-popper-placement^=top].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{bottom:-4px}.mg-tooltip[data-popper-placement^=bottom].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{top:-4px}.mg-tooltip[data-popper-placement^=left].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{right:-4px}.mg-tooltip[data-popper-placement^=right].sc-mg-tooltip>.mg-tooltip__arrow.sc-mg-tooltip{left:-4px}";
|
|
3386
|
+
|
|
3387
|
+
const MgTooltip = class {
|
|
3388
|
+
constructor(hostRef) {
|
|
3389
|
+
index.registerInstance(this, hostRef);
|
|
3390
|
+
/**
|
|
3391
|
+
* Sets an `id` attribute.
|
|
3392
|
+
* Needed by the input for accessibility `aria-decribedby`.
|
|
3393
|
+
*/
|
|
3394
|
+
this.identifier = index$1.createID('mg-tooltip');
|
|
3395
|
+
/**
|
|
3396
|
+
* Tooltip placement
|
|
3397
|
+
*/
|
|
3398
|
+
this.placement = 'bottom';
|
|
3399
|
+
/**
|
|
3400
|
+
* Display tooltip
|
|
3401
|
+
*/
|
|
3402
|
+
this.display = false;
|
|
3403
|
+
/**
|
|
3404
|
+
* Disable tooltip
|
|
3405
|
+
*/
|
|
3406
|
+
this.disabled = false;
|
|
3407
|
+
/**
|
|
3408
|
+
* Show tooltip
|
|
3409
|
+
*
|
|
3410
|
+
* @returns {void}
|
|
3411
|
+
*/
|
|
3412
|
+
this.show = () => {
|
|
3413
|
+
// Make the tooltip visible
|
|
3414
|
+
this.tooltip.setAttribute('data-show', '');
|
|
3415
|
+
// Enable the event listeners
|
|
3416
|
+
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
3417
|
+
// Update its position
|
|
3418
|
+
this.popper.update();
|
|
3419
|
+
};
|
|
3420
|
+
/**
|
|
3421
|
+
* Hide tooltip
|
|
3422
|
+
*
|
|
3423
|
+
* @returns {void}
|
|
3424
|
+
*/
|
|
3425
|
+
this.hide = () => {
|
|
3426
|
+
// Hide the tooltip
|
|
3427
|
+
this.tooltip.removeAttribute('data-show');
|
|
3428
|
+
// Disable the event listeners
|
|
3429
|
+
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
|
|
3430
|
+
};
|
|
3431
|
+
}
|
|
3432
|
+
handleDisplay(newVal) {
|
|
3433
|
+
if (newVal) {
|
|
3434
|
+
this.show();
|
|
3435
|
+
}
|
|
3436
|
+
else {
|
|
3437
|
+
this.hide();
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
/*************
|
|
3441
|
+
* Lifecycle *
|
|
3442
|
+
*************/
|
|
3443
|
+
/**
|
|
3444
|
+
* Get slotted element
|
|
3445
|
+
* Check if it already contain an interactive element, if not we need to add a tabIndex attribute
|
|
3446
|
+
* We need to attach the focused element to the tooltip (aria-describedby)
|
|
3447
|
+
*
|
|
3448
|
+
* @returns {void}
|
|
3449
|
+
*/
|
|
3450
|
+
componentDidLoad() {
|
|
3451
|
+
var _a;
|
|
3452
|
+
// Get tooltip element
|
|
3453
|
+
this.tooltip = this.element.querySelector(`#${this.identifier}`);
|
|
3454
|
+
// get slotted element
|
|
3455
|
+
const slotElement = this.element.firstElementChild;
|
|
3456
|
+
// Get interactive element
|
|
3457
|
+
const interactiveElements = ['a', 'button', 'input', 'textarea', 'select']; //! Might needs updates
|
|
3458
|
+
const interactiveElement = this.element.querySelector(interactiveElements.join(',')) || ((_a = slotElement.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(interactiveElements.join(',')));
|
|
3459
|
+
// define selected element to become tooltip selector
|
|
3460
|
+
const tooltipedElement = interactiveElement || slotElement;
|
|
3461
|
+
// Add tabindex to slotted element if we can't find any interactive element
|
|
3462
|
+
if (interactiveElement === null || interactiveElement === undefined)
|
|
3463
|
+
slotElement.tabIndex = 0;
|
|
3464
|
+
// Set aria-describedby
|
|
3465
|
+
const ariaDescribedby = slotElement.getAttribute('aria-describedby');
|
|
3466
|
+
if (ariaDescribedby === null) {
|
|
3467
|
+
tooltipedElement.setAttribute('aria-describedby', this.identifier);
|
|
3468
|
+
}
|
|
3469
|
+
else {
|
|
3470
|
+
slotElement.setAttribute('aria-describedby', `${ariaDescribedby} ${this.identifier}`);
|
|
3471
|
+
}
|
|
3472
|
+
// Create popperjs tooltip
|
|
3473
|
+
this.popper = popper.createPopper(tooltipedElement, this.tooltip, {
|
|
3474
|
+
placement: this.placement,
|
|
3475
|
+
modifiers: [
|
|
3476
|
+
{
|
|
3477
|
+
name: 'offset',
|
|
3478
|
+
options: {
|
|
3479
|
+
offset: [0, 8],
|
|
3480
|
+
},
|
|
3481
|
+
},
|
|
3482
|
+
],
|
|
3483
|
+
});
|
|
3484
|
+
// Add events
|
|
3485
|
+
['mouseenter', 'focus'].forEach(event => {
|
|
3486
|
+
tooltipedElement.addEventListener(event, () => {
|
|
3487
|
+
if (!this.disabled)
|
|
3488
|
+
this.display = true;
|
|
3489
|
+
});
|
|
3490
|
+
});
|
|
3491
|
+
['mouseleave', 'blur', 'keydown'].forEach(event => {
|
|
3492
|
+
tooltipedElement.addEventListener(event, (e) => {
|
|
3493
|
+
// we continue to process ONLY for KeyboardEvents 'Escape'
|
|
3494
|
+
if (e.type === 'keydown' && e.code !== 'Escape') {
|
|
3495
|
+
return;
|
|
3496
|
+
}
|
|
3497
|
+
if (!this.disabled)
|
|
3498
|
+
this.display = false;
|
|
3499
|
+
});
|
|
3500
|
+
});
|
|
3501
|
+
this.handleDisplay(this.display);
|
|
3502
|
+
}
|
|
3503
|
+
/**
|
|
3504
|
+
* Render
|
|
3505
|
+
*
|
|
3506
|
+
* @returns {HTMLElement} HTML Element
|
|
3507
|
+
*/
|
|
3508
|
+
render() {
|
|
3509
|
+
return (index.h(index.Host, null, index.h("slot", null), index.h("div", { role: "tooltip", id: this.identifier, class: "mg-tooltip", innerHTML: this.message }, index.h("div", { class: "mg-tooltip__arrow", "data-popper-arrow": true }))));
|
|
3510
|
+
}
|
|
3511
|
+
get element() { return index.getElement(this); }
|
|
3512
|
+
static get watchers() { return {
|
|
3513
|
+
"display": ["handleDisplay"]
|
|
3514
|
+
}; }
|
|
3515
|
+
};
|
|
3516
|
+
MgTooltip.style = mgTooltipCss;
|
|
3517
|
+
|
|
3518
|
+
exports.mg_badge = MgBadge;
|
|
3519
|
+
exports.mg_button = MgButton;
|
|
3520
|
+
exports.mg_character_left = MgCharacterLeft;
|
|
3521
|
+
exports.mg_form = MgForm;
|
|
3522
|
+
exports.mg_icon = MgIcon;
|
|
3523
|
+
exports.mg_input_checkbox = MgInputCheckbox;
|
|
3524
|
+
exports.mg_input_date = MgInputDate;
|
|
3525
|
+
exports.mg_input_numeric = MgInputNumeric;
|
|
3526
|
+
exports.mg_input_password = MgInputPassword;
|
|
3527
|
+
exports.mg_input_radio = MgInputRadio;
|
|
3528
|
+
exports.mg_input_select = MgInputSelect;
|
|
3529
|
+
exports.mg_input_text = MgInputText;
|
|
3530
|
+
exports.mg_input_textarea = MgInputTextarea;
|
|
3531
|
+
exports.mg_input_title = MgInputTitle;
|
|
3532
|
+
exports.mg_input_toggle = MgInputToggle;
|
|
3533
|
+
exports.mg_message = MgMessage;
|
|
3534
|
+
exports.mg_pagination = MgPagination;
|
|
3535
|
+
exports.mg_panel = MgPanel;
|
|
3536
|
+
exports.mg_tabs = MgTabs;
|
|
3537
|
+
exports.mg_tag = MgTag;
|
|
3538
|
+
exports.mg_tooltip = MgTooltip;
|