@mgdis/mg-components 5.5.0 → 5.7.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-c3450336.js → index-5e7ede97.js} +120 -4
- package/dist/cjs/loader.cjs.js +4 -3
- package/dist/cjs/{mg-badge_30.cjs.entry.js → mg-action-more_31.cjs.entry.js} +1223 -547
- package/dist/cjs/mg-components.cjs.js +7 -3
- package/dist/collection/collection-manifest.json +6 -5
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +13 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +4 -4
- package/dist/collection/components/atoms/mg-button/mg-button.css +9 -22
- package/dist/collection/components/atoms/mg-button/mg-button.js +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.css +13 -6
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +38 -28
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +3 -3
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +6 -6
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +4 -4
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +2 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +14 -17
- package/dist/collection/components/molecules/inputs/MgInput.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +4 -3
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +3 -2
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +5 -2
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +4 -3
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +2 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +8 -4
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +4 -4
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +17 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +27 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +141 -19
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +0 -4
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +48 -21
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +139 -71
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.css +38 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +252 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +2 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +4 -3
- package/dist/collection/components/molecules/mg-message/mg-message.css +7 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +54 -13
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +8 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +19 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +7 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +72 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +64 -7
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +33 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +12 -7
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +105 -57
- package/dist/collection/locales/en/messages.json +10 -1
- package/dist/collection/locales/fr/messages.json +10 -1
- package/dist/collection/locales/index.js +3 -26
- package/dist/collection/styles/a11y.scss +32 -0
- package/dist/collection/styles/components.scss +3 -0
- package/dist/collection/styles/fonts.scss +21 -0
- package/dist/collection/styles/form.scss +3 -0
- package/dist/collection/styles/global.scss +87 -0
- package/dist/collection/styles/layout.scss +29 -0
- package/dist/collection/styles/main.scss +23 -0
- package/dist/collection/styles/mg-icon-animation.scss +6 -0
- package/dist/collection/styles/navigation-button.scss +77 -0
- package/dist/collection/styles/reset-mg-card-slotted-variables.scss +9 -0
- package/dist/collection/styles/typography.scss +75 -0
- package/dist/collection/styles/utilities.scss +21 -0
- package/dist/collection/utils/behaviors.utils.js +151 -0
- package/dist/collection/utils/components.utils.js +52 -0
- package/dist/collection/utils/locale.utils.js +28 -6
- package/dist/collection/utils/unit.test.utils.js +65 -32
- package/dist/collection/variables.css +11 -10
- package/dist/components/MgInput.js +6 -1
- package/dist/components/components.utils.js +53 -1
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.js +2 -1
- package/dist/components/index2.js +79 -20
- package/dist/components/mg-action-more.d.ts +11 -0
- package/dist/components/mg-action-more.js +215 -0
- package/dist/components/mg-badge2.js +5 -5
- package/dist/components/mg-button2.js +2 -2
- package/dist/components/mg-card2.js +1 -1
- package/dist/components/mg-form.js +2 -2
- package/dist/components/mg-icon2.js +41 -31
- package/dist/components/mg-illustrated-message.js +4 -3
- package/dist/components/mg-input-checkbox.js +3 -3
- package/dist/components/mg-input-date.js +7 -5
- package/dist/components/mg-input-numeric.js +3 -4
- package/dist/components/mg-input-password.js +1 -1
- package/dist/components/mg-input-radio.js +2 -2
- package/dist/components/mg-input-select2.js +9 -5
- package/dist/components/mg-input-text2.js +1 -1
- package/dist/components/mg-input-textarea.js +2 -2
- package/dist/components/mg-input-toggle.js +1 -1
- package/dist/components/mg-menu-item.js +1 -253
- package/dist/components/mg-menu-item2.js +520 -0
- package/dist/components/mg-menu.js +1 -129
- package/dist/components/mg-menu2.js +247 -0
- package/dist/components/mg-message.js +55 -14
- package/dist/components/mg-modal.js +1 -1
- package/dist/components/mg-pagination.js +3 -1
- package/dist/components/mg-panel.js +3 -3
- package/dist/components/mg-popover.js +1 -190
- package/dist/components/mg-popover2.js +226 -0
- package/dist/components/mg-skip-links.js +16 -2
- package/dist/components/mg-tabs.js +104 -55
- package/dist/components/mg-tag.js +5 -5
- package/dist/components/mg-tooltip2.js +15 -18
- package/dist/esm/{index-78edde1d.js → index-03cceb11.js} +120 -5
- package/dist/esm/loader.js +4 -3
- package/dist/esm/{mg-badge_30.entry.js → mg-action-more_31.entry.js} +1223 -548
- package/dist/esm/mg-components.js +4 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/mg-components/locales/en/messages.json +10 -1
- package/dist/mg-components/locales/fr/messages.json +10 -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-4cfd5423.entry.js +1 -0
- package/dist/mg-components/p-e126dd84.js +2 -0
- package/dist/mg-components/styles/a11y.scss +32 -0
- package/dist/mg-components/styles/components.scss +3 -0
- package/dist/mg-components/styles/fonts.scss +21 -0
- package/dist/mg-components/styles/form.scss +3 -0
- package/dist/mg-components/styles/global.scss +87 -0
- package/dist/mg-components/styles/layout.scss +29 -0
- package/dist/mg-components/styles/main.scss +23 -0
- package/dist/mg-components/styles/mg-icon-animation.scss +6 -0
- package/dist/mg-components/styles/navigation-button.scss +77 -0
- package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +9 -0
- package/dist/mg-components/styles/typography.scss +75 -0
- package/dist/mg-components/styles/utilities.scss +21 -0
- package/dist/mg-components/variables.css +11 -10
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +2 -2
- 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-select/mg-input-select.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +37 -0
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +51 -3
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +0 -8
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +61 -15
- package/dist/types/components/molecules/mg-action-more/mg-action-more.conf.d.ts +42 -0
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +81 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +21 -4
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +4 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +13 -0
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.conf.d.ts +1 -1
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +15 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +5 -3
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +22 -12
- package/dist/types/components.d.ts +98 -12
- package/dist/types/locales/index.d.ts +21 -10
- package/dist/types/stencil-public-runtime.d.ts +48 -3
- package/dist/types/utils/behaviors.utils.d.ts +77 -0
- package/dist/types/utils/components.utils.d.ts +14 -0
- package/dist/types/utils/locale.utils.d.ts +16 -3
- package/dist/types/utils/unit.test.utils.d.ts +68 -14
- package/loader/index.d.ts +9 -0
- package/package.json +28 -27
- package/readme.md +22 -31
- package/dist/.storybook/utils.js +0 -24
- package/dist/collection/components/atoms/mg-badge/doc/mg-badge.stories.js +0 -27
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +0 -38
- package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +0 -18
- package/dist/collection/components/atoms/mg-character-left/doc/mg-character-left.stories.js +0 -20
- package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +0 -18
- package/dist/collection/components/atoms/mg-icon/doc/mg-icon.stories.js +0 -41
- package/dist/collection/components/atoms/mg-input-title/doc/mg-input-title.stories.js +0 -21
- package/dist/collection/components/atoms/mg-tag/doc/mg-tag.stories.js +0 -22
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -50
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/doc/mg-input-checkbox.stories.js +0 -50
- package/dist/collection/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.js +0 -43
- package/dist/collection/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.js +0 -68
- package/dist/collection/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.js +0 -46
- package/dist/collection/components/molecules/inputs/mg-input-radio/doc/mg-input-radio.stories.js +0 -59
- package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +0 -77
- package/dist/collection/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.js +0 -110
- package/dist/collection/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.js +0 -54
- package/dist/collection/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.js +0 -51
- package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +0 -87
- package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +0 -39
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +0 -24
- package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +0 -47
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +0 -19
- package/dist/collection/components/molecules/mg-message/doc/mg-message.stories.js +0 -39
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +0 -39
- package/dist/collection/components/molecules/mg-pagination/doc/mg-pagination.stories.js +0 -20
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +0 -22
- package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -34
- package/dist/collection/components/molecules/mg-skip-links/doc/mg-skip-links.stories.js +0 -24
- package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +0 -51
- package/dist/collection/stories/grids.stories.js +0 -7
- package/dist/collection/stories/helpers.stories.js +0 -23
- package/dist/collection/stories/icons.stories.js +0 -25
- package/dist/collection/stories/typography.stories.js +0 -24
- package/dist/components/locale.utils.js +0 -40
- package/dist/components/mg-menu.conf.js +0 -10
- package/dist/mg-components/p-125c54ca.js +0 -2
- package/dist/mg-components/p-4961c96c.entry.js +0 -1
- package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +0 -13
- package/dist/types/components/atoms/mg-button/doc/mg-button.stories.d.ts +0 -16
- package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-character-left/doc/mg-character-left.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-icon/doc/mg-icon.stories.d.ts +0 -26
- package/dist/types/components/atoms/mg-input-title/doc/mg-input-title.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tag/doc/mg-tag.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -18
- package/dist/types/components/molecules/inputs/mg-input-checkbox/doc/mg-input-checkbox.stories.d.ts +0 -11
- package/dist/types/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.d.ts +0 -12
- package/dist/types/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.d.ts +0 -32
- package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +0 -22
- package/dist/types/components/molecules/inputs/mg-input-radio/doc/mg-input-radio.stories.d.ts +0 -20
- package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +0 -34
- package/dist/types/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.d.ts +0 -39
- package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +0 -19
- package/dist/types/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.d.ts +0 -12
- package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +0 -17
- package/dist/types/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.d.ts +0 -12
- package/dist/types/components/molecules/mg-details/doc/mg-details.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-form/doc/mg-form.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-message/doc/mg-message.stories.d.ts +0 -26
- package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +0 -13
- package/dist/types/components/molecules/mg-pagination/doc/mg-pagination.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -22
- package/dist/types/components/molecules/mg-skip-links/doc/mg-skip-links.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +0 -20
- package/dist/types/home/runner/work/mg-components/mg-components/.stencil/.storybook/utils.d.ts +0 -1
- package/dist/types/stories/grids.stories.d.ts +0 -5
- package/dist/types/stories/helpers.stories.d.ts +0 -13
- package/dist/types/stories/icons.stories.d.ts +0 -13
- package/dist/types/stories/typography.stories.d.ts +0 -5
|
@@ -20,7 +20,9 @@ const input$1 = {
|
|
|
20
20
|
};
|
|
21
21
|
const form$1 = {
|
|
22
22
|
required: "Fields with a <strong class=\"is-asterisk\">*</strong> are required",
|
|
23
|
-
|
|
23
|
+
requiredSingle: "Field with a <strong class=\"is-asterisk\">*</strong> is required",
|
|
24
|
+
allRequired: "All fields are required",
|
|
25
|
+
allRequiredSingle: "The field is required"
|
|
24
26
|
};
|
|
25
27
|
const message$1 = {
|
|
26
28
|
closeButton: "Close message"
|
|
@@ -49,6 +51,13 @@ const general$1 = {
|
|
|
49
51
|
next: "next",
|
|
50
52
|
previous: "previous"
|
|
51
53
|
};
|
|
54
|
+
const plusMenu$1 = {
|
|
55
|
+
moreLabel: "Additional menu",
|
|
56
|
+
badgeLabel: "Include notification(s)"
|
|
57
|
+
};
|
|
58
|
+
const actionMore$1 = {
|
|
59
|
+
label: "Actions"
|
|
60
|
+
};
|
|
52
61
|
const en = {
|
|
53
62
|
errors: errors$1,
|
|
54
63
|
nbCharLeft: nbCharLeft$1,
|
|
@@ -59,7 +68,9 @@ const en = {
|
|
|
59
68
|
pagination: pagination$1,
|
|
60
69
|
panel: panel$1,
|
|
61
70
|
skipLinks: skipLinks$1,
|
|
62
|
-
general: general$1
|
|
71
|
+
general: general$1,
|
|
72
|
+
plusMenu: plusMenu$1,
|
|
73
|
+
actionMore: actionMore$1
|
|
63
74
|
};
|
|
64
75
|
|
|
65
76
|
const errors = {
|
|
@@ -84,7 +95,9 @@ const input = {
|
|
|
84
95
|
};
|
|
85
96
|
const form = {
|
|
86
97
|
required: "Les champs marqués d'un <strong class=\"is-asterisk\">*</strong> sont obligatoires",
|
|
87
|
-
|
|
98
|
+
requiredSingle: "Le champ marqué d'un <strong class=\"is-asterisk\">*</strong> est obligatoire",
|
|
99
|
+
allRequired: "Tous les champs sont obligatoires",
|
|
100
|
+
allRequiredSingle: "Le champ est obligatoire"
|
|
88
101
|
};
|
|
89
102
|
const message = {
|
|
90
103
|
closeButton: "Fermer le message"
|
|
@@ -113,6 +126,13 @@ const general = {
|
|
|
113
126
|
next: "suivant",
|
|
114
127
|
previous: "précédent"
|
|
115
128
|
};
|
|
129
|
+
const plusMenu = {
|
|
130
|
+
moreLabel: "Menu complémentaire",
|
|
131
|
+
badgeLabel: "Notification(s) incluse(s)"
|
|
132
|
+
};
|
|
133
|
+
const actionMore = {
|
|
134
|
+
label: "Actions"
|
|
135
|
+
};
|
|
116
136
|
const fr = {
|
|
117
137
|
errors: errors,
|
|
118
138
|
nbCharLeft: nbCharLeft,
|
|
@@ -123,34 +143,63 @@ const fr = {
|
|
|
123
143
|
pagination: pagination,
|
|
124
144
|
panel: panel,
|
|
125
145
|
skipLinks: skipLinks,
|
|
126
|
-
general: general
|
|
146
|
+
general: general,
|
|
147
|
+
plusMenu: plusMenu,
|
|
148
|
+
actionMore: actionMore
|
|
127
149
|
};
|
|
128
150
|
|
|
129
|
-
const defaultLocale = 'en';
|
|
130
|
-
const messages = { en, fr };
|
|
131
151
|
/**
|
|
132
|
-
*
|
|
152
|
+
* Format number to the locale currency
|
|
133
153
|
*
|
|
134
|
-
* @param {
|
|
135
|
-
* @
|
|
154
|
+
* @param {number} number number to format
|
|
155
|
+
* @param {string} locale locale to apply
|
|
156
|
+
* @param {string} currency currency to apply
|
|
157
|
+
* @returns {string} formatted currency
|
|
136
158
|
*/
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
// validate locale
|
|
140
|
-
const closestLang = Intl.NumberFormat.supportedLocalesOf((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang);
|
|
141
|
-
return closestLang.length > 0 ? closestLang[0] : navigator.language || defaultLocale;
|
|
159
|
+
const localeCurrency = (number, locale, currency) => {
|
|
160
|
+
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
|
|
142
161
|
};
|
|
143
162
|
/**
|
|
144
|
-
*
|
|
163
|
+
* Format number to locale
|
|
164
|
+
*
|
|
165
|
+
* @param {number} number number to format
|
|
166
|
+
* @param {string} locale locale to apply
|
|
167
|
+
* @returns {string} formatted number
|
|
168
|
+
*/
|
|
169
|
+
const localeNumber = (number, locale) => {
|
|
170
|
+
return new Intl.NumberFormat(locale).format(number);
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Date RegExp
|
|
174
|
+
*/
|
|
175
|
+
const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
176
|
+
/**
|
|
177
|
+
* Locale date format
|
|
178
|
+
*
|
|
179
|
+
* @param {string} date date to format
|
|
180
|
+
* @param {string} locale locale to apply
|
|
181
|
+
* @returns {string} formatted date
|
|
182
|
+
*/
|
|
183
|
+
const localeDate = (date, locale) => {
|
|
184
|
+
if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
|
|
185
|
+
return '';
|
|
186
|
+
}
|
|
187
|
+
return new Intl.DateTimeFormat(locale).format(new Date(date));
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Get locale and messages
|
|
145
191
|
* We load the defined locale but for now we only support the first subtag for messages
|
|
146
192
|
*
|
|
147
193
|
* @param {HTMLElement} element element we need to get the language
|
|
148
|
-
* @
|
|
194
|
+
* @param {unknown} messages messages to use
|
|
195
|
+
* @param {string} defaultLocale default messages locale
|
|
196
|
+
* @returns {{ locale: string; messages: Record<string, unknown> }} messages object
|
|
149
197
|
*/
|
|
150
|
-
|
|
151
|
-
const initLocales = (element) => {
|
|
198
|
+
const getLocaleMessages = (element, messages, defaultLocale) => {
|
|
152
199
|
// Get local
|
|
153
|
-
const
|
|
200
|
+
const closestLangAttribute = element.closest('[lang]');
|
|
201
|
+
const closestLang = Intl.NumberFormat.supportedLocalesOf(closestLangAttribute === null || closestLangAttribute === void 0 ? void 0 : closestLangAttribute.lang);
|
|
202
|
+
const locale = closestLang.length > 0 ? closestLang[0] : navigator.language || defaultLocale;
|
|
154
203
|
// Only keep first subtag
|
|
155
204
|
const localeSubtag = locale.split('-').shift();
|
|
156
205
|
// Return
|
|
@@ -160,4 +209,14 @@ const initLocales = (element) => {
|
|
|
160
209
|
};
|
|
161
210
|
};
|
|
162
211
|
|
|
163
|
-
|
|
212
|
+
const defaultLocale = 'en';
|
|
213
|
+
const messages = { en, fr };
|
|
214
|
+
/**
|
|
215
|
+
* Get Intl object
|
|
216
|
+
*
|
|
217
|
+
* @param {HTMLElement} element element we need to get the language
|
|
218
|
+
* @returns {{ locale: string; messages: Record<string, unknown> }} messages object
|
|
219
|
+
*/
|
|
220
|
+
const initLocales = (element) => getLocaleMessages(element, messages, defaultLocale);
|
|
221
|
+
|
|
222
|
+
export { localeCurrency as a, localeNumber as b, dateRegExp as d, initLocales as i, localeDate as l };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface MgActionMore extends Components.MgActionMore, HTMLElement {}
|
|
4
|
+
export const MgActionMore: {
|
|
5
|
+
prototype: MgActionMore;
|
|
6
|
+
new (): MgActionMore;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { i as initLocales } from './index2.js';
|
|
3
|
+
import { D as Direction, S as Status, d as defineCustomElement$3 } from './mg-menu-item2.js';
|
|
4
|
+
import { c as createID } from './components.utils.js';
|
|
5
|
+
import { d as defineCustomElement$8 } from './mg-badge2.js';
|
|
6
|
+
import { d as defineCustomElement$7 } from './mg-button2.js';
|
|
7
|
+
import { d as defineCustomElement$6 } from './mg-card2.js';
|
|
8
|
+
import { d as defineCustomElement$5 } from './mg-icon2.js';
|
|
9
|
+
import { d as defineCustomElement$4 } from './mg-menu2.js';
|
|
10
|
+
import { d as defineCustomElement$2 } from './mg-popover2.js';
|
|
11
|
+
|
|
12
|
+
const mgActionMoreCss = ".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}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}:host{--mg-popover-padding-vertical:1rem;--mg-popover-padding-horizontal:0}.mg-action-more__chevron{transition:200ms}.mg-action-more__chevron--rotate.mg-action-more__chevron{transform:rotate(180deg)}";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* MgActionMore['items'] type guard
|
|
16
|
+
*
|
|
17
|
+
* @param {unknown} prop commponent items prop
|
|
18
|
+
* @returns {boolean} return true if type is valid
|
|
19
|
+
*/
|
|
20
|
+
const isMgActionMoreItems = (prop) => {
|
|
21
|
+
const items = prop;
|
|
22
|
+
return typeof items === 'object' && items.every(item => typeof item === 'object' && typeof item.label === 'string' && typeof item.mouseEventHandler === 'function');
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* MgActionMore['button'] type guard
|
|
26
|
+
*
|
|
27
|
+
* @param {unknown} prop commponent button prop
|
|
28
|
+
* @returns {boolean} return true if type is valid
|
|
29
|
+
*/
|
|
30
|
+
const isMgActionMoreButton = (prop) => {
|
|
31
|
+
const button = prop;
|
|
32
|
+
return typeof button === 'object' && typeof button.variant === 'string' && typeof button.isIcon === 'boolean';
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* MgActionMore['icon'] type guard
|
|
36
|
+
*
|
|
37
|
+
* @param {unknown} prop commponent icon prop
|
|
38
|
+
* @returns {boolean} return true if type is valid
|
|
39
|
+
*/
|
|
40
|
+
const isMgActionMoreIcon = (prop) => {
|
|
41
|
+
const icon = prop;
|
|
42
|
+
return typeof icon === 'object' && typeof icon.icon === 'string';
|
|
43
|
+
};
|
|
44
|
+
const MgActionMore$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
45
|
+
constructor() {
|
|
46
|
+
super();
|
|
47
|
+
this.__registerHost();
|
|
48
|
+
this.__attachShadow();
|
|
49
|
+
/************
|
|
50
|
+
* Internal *
|
|
51
|
+
************/
|
|
52
|
+
this.name = 'mg-action-more';
|
|
53
|
+
this.mgPopoverIdentifier = createID(this.name);
|
|
54
|
+
/************
|
|
55
|
+
* Merthods *
|
|
56
|
+
***********/
|
|
57
|
+
/**
|
|
58
|
+
* Toogle expanded props
|
|
59
|
+
*
|
|
60
|
+
* @returns {void}
|
|
61
|
+
*/
|
|
62
|
+
this.toggleExpanded = () => {
|
|
63
|
+
this.expanded = !this.expanded;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Button click handler
|
|
67
|
+
*
|
|
68
|
+
* @returns {void}
|
|
69
|
+
*/
|
|
70
|
+
this.handleButton = () => {
|
|
71
|
+
this.toggleExpanded();
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Item click handler
|
|
75
|
+
*
|
|
76
|
+
* @param {MouseEvent} event click event
|
|
77
|
+
* @param {MgActionMoreItemType['mouseEventHandler']} customHandler item['mouseEventHandler']
|
|
78
|
+
* @returns {void}
|
|
79
|
+
*/
|
|
80
|
+
this.handleItemClick = (event, customHandler) => {
|
|
81
|
+
this.expanded = false;
|
|
82
|
+
customHandler(event);
|
|
83
|
+
};
|
|
84
|
+
this.icon = { icon: 'ellipsis' };
|
|
85
|
+
this.button = { variant: 'flat', isIcon: true };
|
|
86
|
+
this.items = undefined;
|
|
87
|
+
this.displayChevron = undefined;
|
|
88
|
+
this.expanded = false;
|
|
89
|
+
}
|
|
90
|
+
validateIcon(newValue) {
|
|
91
|
+
if (newValue && !isMgActionMoreIcon(newValue)) {
|
|
92
|
+
throw new Error(`<${this.name}> prop icon must match MgActionMoreIconType.`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
validateButton(newValue) {
|
|
96
|
+
if (newValue && !isMgActionMoreButton(newValue)) {
|
|
97
|
+
throw new Error(`<${this.name}> prop button must match MgActionMoreButtonType.`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
validateItems(newValue) {
|
|
101
|
+
if (!isMgActionMoreItems(newValue)) {
|
|
102
|
+
throw new Error(`<${this.name}> prop "items" is required and all values must be the same type, MgActionMoreItemType.`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
validateDisplayChevron(newValue) {
|
|
106
|
+
if (newValue && this.button.isIcon === true) {
|
|
107
|
+
throw new Error(`<${this.name}> prop "displayChevron" can't be used with a 'button" prop "isIcon" attribute.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/*************
|
|
111
|
+
* Lifecycle *
|
|
112
|
+
*************/
|
|
113
|
+
/**
|
|
114
|
+
* Validate props
|
|
115
|
+
*
|
|
116
|
+
* @returns {void}
|
|
117
|
+
*/
|
|
118
|
+
componentWillLoad() {
|
|
119
|
+
this.messages = initLocales(this.element).messages.actionMore;
|
|
120
|
+
this.validateItems(this.items);
|
|
121
|
+
this.validateButton(this.button);
|
|
122
|
+
this.validateIcon(this.icon);
|
|
123
|
+
this.validateDisplayChevron(this.displayChevron);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Render
|
|
127
|
+
*
|
|
128
|
+
* @returns {HTMLElement} HTML Element
|
|
129
|
+
*/
|
|
130
|
+
render() {
|
|
131
|
+
const buttonLabel = this.button.label || this.messages.label;
|
|
132
|
+
const buttonContent = [buttonLabel];
|
|
133
|
+
if (!this.button.isIcon && this.displayChevron) {
|
|
134
|
+
buttonContent.push(h("span", { class: {
|
|
135
|
+
[`${this.name}__chevron`]: true,
|
|
136
|
+
[`${this.name}__chevron--rotate`]: this.expanded === true,
|
|
137
|
+
'mg-a11y-animation': true,
|
|
138
|
+
} }, h("mg-icon", { icon: "chevron-down", size: "small" })));
|
|
139
|
+
}
|
|
140
|
+
return (h(Host, { "data-mg-popover-guard": this.mgPopoverIdentifier }, h("span", { class: "mg-action-more" }, h("mg-popover", { identifier: this.mgPopoverIdentifier, display: this.expanded }, h("mg-button", { variant: this.button.variant, isIcon: this.button.isIcon, type: "button", label: buttonLabel, onClick: this.handleButton }, h("mg-icon", Object.assign({}, this.icon)), !this.button.isIcon && buttonContent), h("div", { slot: "content" }, h("mg-menu", { direction: Direction.VERTICAL, label: this.messages.label }, this.items.map(item => {
|
|
141
|
+
var _a;
|
|
142
|
+
return (
|
|
143
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
144
|
+
h("mg-menu-item", { key: item.label, status: item.status || Status.VISIBLE, onClick: e => this.handleItemClick(e, item.mouseEventHandler), href: item.href }, item.icon && h("mg-icon", { icon: item.icon, slot: "image" }), h("span", { slot: "label" }, item.label), ((_a = item.badge) === null || _a === void 0 ? void 0 : _a.label) && h("mg-badge", { label: item.badge.label, value: item.badge.value, slot: "information", variant: "text-color" })));
|
|
145
|
+
})))))));
|
|
146
|
+
}
|
|
147
|
+
get element() { return this; }
|
|
148
|
+
static get watchers() { return {
|
|
149
|
+
"icon": ["validateIcon"],
|
|
150
|
+
"button": ["validateButton"],
|
|
151
|
+
"items": ["validateItems"],
|
|
152
|
+
"displayChevron": ["validateDisplayChevron"]
|
|
153
|
+
}; }
|
|
154
|
+
static get style() { return mgActionMoreCss; }
|
|
155
|
+
}, [1, "mg-action-more", {
|
|
156
|
+
"icon": [16],
|
|
157
|
+
"button": [16],
|
|
158
|
+
"items": [16],
|
|
159
|
+
"displayChevron": [4, "display-chevron"],
|
|
160
|
+
"expanded": [32]
|
|
161
|
+
}]);
|
|
162
|
+
function defineCustomElement$1() {
|
|
163
|
+
if (typeof customElements === "undefined") {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const components = ["mg-action-more", "mg-badge", "mg-button", "mg-card", "mg-icon", "mg-menu", "mg-menu-item", "mg-popover"];
|
|
167
|
+
components.forEach(tagName => { switch (tagName) {
|
|
168
|
+
case "mg-action-more":
|
|
169
|
+
if (!customElements.get(tagName)) {
|
|
170
|
+
customElements.define(tagName, MgActionMore$1);
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
case "mg-badge":
|
|
174
|
+
if (!customElements.get(tagName)) {
|
|
175
|
+
defineCustomElement$8();
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
case "mg-button":
|
|
179
|
+
if (!customElements.get(tagName)) {
|
|
180
|
+
defineCustomElement$7();
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
case "mg-card":
|
|
184
|
+
if (!customElements.get(tagName)) {
|
|
185
|
+
defineCustomElement$6();
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
case "mg-icon":
|
|
189
|
+
if (!customElements.get(tagName)) {
|
|
190
|
+
defineCustomElement$5();
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
case "mg-menu":
|
|
194
|
+
if (!customElements.get(tagName)) {
|
|
195
|
+
defineCustomElement$4();
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
case "mg-menu-item":
|
|
199
|
+
if (!customElements.get(tagName)) {
|
|
200
|
+
defineCustomElement$3();
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
case "mg-popover":
|
|
204
|
+
if (!customElements.get(tagName)) {
|
|
205
|
+
defineCustomElement$2();
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
} });
|
|
209
|
+
}
|
|
210
|
+
defineCustomElement$1();
|
|
211
|
+
|
|
212
|
+
const MgActionMore = MgActionMore$1;
|
|
213
|
+
const defineCustomElement = defineCustomElement$1;
|
|
214
|
+
|
|
215
|
+
export { MgActionMore, defineCustomElement };
|
|
@@ -4,9 +4,9 @@ import { C as ClassList } from './components.utils.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* List of all possibles variants
|
|
6
6
|
*/
|
|
7
|
-
const variants = ['info', 'primary', 'secondary', 'success', 'warning', 'danger'];
|
|
7
|
+
const variants = ['info', 'primary', 'secondary', 'success', 'warning', 'danger', 'text-color'];
|
|
8
8
|
|
|
9
|
-
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}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.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}";
|
|
9
|
+
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}@media (prefers-reduced-motion){.mg-a11y-animation{animation:none !important;transition:none !important}}.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--text-color{background-color:currentColor;border-color:currentColor}.mg-badge.mg-badge--text-color .mg-badge__value{color:hsl(var(--mg-badge-text-color, var(--color-light)))}.mg-badge.mg-badge--text-color.mg-badge--outline{background-color:transparent}.mg-badge.mg-badge--text-color.mg-badge--outline .mg-badge__value{color:currentColor}.mg-badge,mg-badge{display:inline-flex;align-items:center;justify-content:center}";
|
|
10
10
|
|
|
11
11
|
const MgBadge = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
12
12
|
constructor() {
|
|
@@ -26,7 +26,7 @@ const MgBadge = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
26
26
|
}
|
|
27
27
|
validateValue(newValue) {
|
|
28
28
|
if (`${newValue}`.match(/^(\d+\+*|[?*!a-z])$/i) === null) {
|
|
29
|
-
throw new Error('<mg-badge> prop "value" must be
|
|
29
|
+
throw new Error('<mg-badge> prop "value" must be integer or ponctuation character.');
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
validateLabel(newValue) {
|
|
@@ -36,7 +36,7 @@ const MgBadge = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
36
36
|
}
|
|
37
37
|
validateVariant(newValue, oldValue) {
|
|
38
38
|
if (!variants.includes(newValue)) {
|
|
39
|
-
throw new Error(`<mg-badge> prop "variant" must be one of
|
|
39
|
+
throw new Error(`<mg-badge> prop "variant" must be one of: ${variants.join(', ')}.`);
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
42
|
if (oldValue !== undefined) {
|
|
@@ -68,7 +68,7 @@ const MgBadge = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
68
68
|
* @returns {HTMLElement} HTML Element
|
|
69
69
|
*/
|
|
70
70
|
render() {
|
|
71
|
-
return (h("span", { class: this.classList.join() }, this.value, h("span", { class: "sr-only" }, this.label)));
|
|
71
|
+
return (h("span", { class: this.classList.join() }, h("span", { class: "mg-badge__value" }, this.value), h("span", { class: "sr-only" }, this.label)));
|
|
72
72
|
}
|
|
73
73
|
static get watchers() { return {
|
|
74
74
|
"value": ["validateValue"],
|
|
@@ -7,7 +7,7 @@ import { d as defineCustomElement$1 } from './mg-icon2.js';
|
|
|
7
7
|
*/
|
|
8
8
|
const variants = ['primary', 'secondary', 'danger', 'danger-alt', 'info', 'flat', 'success', 'link'];
|
|
9
9
|
|
|
10
|
-
const mgButtonCss = ":host{display:inline-block;vertical-align:middle;max-width:100%}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-button{outline-color:-webkit-focus-ring-color;outline-style:auto;outline-width:0.2rem}:host(:hover) .mg-button--flat:not(.mg-button--disabled)
|
|
10
|
+
const mgButtonCss = ":host{display:inline-block;vertical-align:middle;max-width:100%}:host(:focus-visible){outline:0}:host(:focus-visible) .mg-button{outline-color:-webkit-focus-ring-color;outline-style:auto;outline-width:0.2rem}:host(:hover) .mg-button--flat:not(.mg-button--disabled){background:hsl(var(--color-dark), 0.1)}:host([full-width]){display:block}:host([disabled]),:host([aria-disabled=true]){pointer-events:none}.mg-button.mg-button--primary{border-color:hsl(var(--mg-button-primary-border-color, var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-primary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--primary:not(.mg-button--disabled){background:hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l))}.mg-button.mg-button--secondary{border-color:hsl(var(--mg-button-secondary-border-color, var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--mg-button-secondary-font-color));background:linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--secondary:not(.mg-button--disabled){background:hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l))}.mg-button.mg-button--danger{border-color:hsl(var(--mg-button-danger-border-color, var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger:not(.mg-button--disabled){background:hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l))}.mg-button.mg-button--danger-alt{border-color:hsl(var(--mg-button-danger-alt-border-color, var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-danger));background:linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--danger-alt:not(.mg-button--disabled){background:hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l))}.mg-button.mg-button--info{border-color:hsl(var(--mg-button-info-border-color, var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-neutral));background:linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--info:not(.mg-button--disabled){background:hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l))}.mg-button.mg-button--success{border-color:hsl(var(--mg-button-success-border-color, var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-border-variation) * 10%)));color:hsl(var(--color-dark));background:linear-gradient(to bottom, hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l)), hsl(var(--color-success-h), var(--color-success-s), calc(var(--color-success-l) - var(--mg-button-gradient) * 10%)))}:host(:hover) .mg-button--success:not(.mg-button--disabled){background:hsl(var(--color-success-h), var(--color-success-s), var(--color-success-l))}.mg-button{position:relative;display:inline-flex;align-items:center;column-gap:0.6rem;padding:calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;min-height:var(--default-size);box-sizing:border-box;border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-border-radius));cursor:pointer;background-image:none;border-top-width:var(--mg-button-border-top-width, 0.1rem);border-right-width:var(--mg-button-border-right-width, 0.1rem);border-bottom-width:var(--mg-button-border-bottom-width, 0.1rem);border-left-width:var(--mg-button-border-left-width, 0.1rem);border-style:solid;text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);touch-action:manipulation}.mg-button.mg-button--disabled{opacity:var(--mg-button-disabled-opacity);cursor:default}.mg-button.mg-button--icon{padding:0;justify-content:center;width:var(--default-size);height:var(--default-size);border-top-right-radius:var(--mg-button-border-radius-top-right, var(--mg-button-icon-border-radius));border-top-left-radius:var(--mg-button-border-radius-top-left, var(--mg-button-icon-border-radius));border-bottom-right-radius:var(--mg-button-border-radius-bottom-right, var(--mg-button-icon-border-radius));border-bottom-left-radius:var(--mg-button-border-radius-bottom-left, var(--mg-button-icon-border-radius));font-size:var(--font-size);line-height:var(--font-size)}.mg-button.mg-button--flat{background:none;border:none}.mg-button.mg-button--link{padding:unset;min-height:unset;background:unset;border:unset;border-radius:unset;text-decoration:underline}.mg-button.mg-button--link slot{font-weight:600}.mg-button.mg-button--link:hover{text-decoration:none}.mg-button.mg-button--full-width{display:flex;justify-content:center}.mg-button.mg-button--loading>mg-icon:first-of-type{position:absolute;left:50%;top:50%;transform:translate(-50%, -50%)}.mg-button.mg-button--loading .mg-button__content{opacity:0}.mg-button mg-icon:only-child,.mg-button ::slotted(mg-icon){display:inline-flex;flex-shrink:0;line-height:1;margin:auto 0}.mg-button slot,.mg-button ::slotted(*:not(mg-icon)){text-decoration:none;font-family:inherit;font-weight:var(--mg-button-font-weight, normal);text-align:left;font-size:var(--font-size);display:flex;align-items:center;column-gap:0.6rem}";
|
|
11
11
|
|
|
12
12
|
const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
13
13
|
constructor() {
|
|
@@ -77,7 +77,7 @@ const MgButton = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
77
77
|
}
|
|
78
78
|
validateVariant(newValue, oldValue) {
|
|
79
79
|
if (!variants.includes(newValue)) {
|
|
80
|
-
throw new Error(`<mg-button> prop "variant" must be one of
|
|
80
|
+
throw new Error(`<mg-button> prop "variant" must be one of: ${variants.join(', ')}`);
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
83
|
if (oldValue !== undefined) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
|
|
2
2
|
|
|
3
|
-
const mgCardCss = ".mg-card{position:relative;width:100%;padding:var(--mg-card-padding);overflow:var(--mg-card-overflow);box-sizing:border-box;z-index:inherit;background:var(--mg-card-background);border:var(--mg-card-border);border-radius:var(--mg-card-border-radius);box-shadow:var(--mg-card-box-shadow)}";
|
|
3
|
+
const mgCardCss = ".mg-card{position:relative;width:100%;padding:var(--mg-card-padding, var(--mg-card-padding-default));overflow:var(--mg-card-overflow, var(--mg-card-overflow-default));box-sizing:border-box;z-index:inherit;background:var(--mg-card-background, var(--mg-card-background-default));border:var(--mg-card-border, var(--mg-card-border-default));border-radius:var(--mg-card-border-radius, var(--mg-card-border-radius-default));box-shadow:var(--mg-card-box-shadow, var(--mg-card-box-shadow-default))}.mg-card ::slotted(*){--mg-card-border:var(--mg-card-border-default);--mg-card-padding:var(--mg-card-padding-default);--mg-card-border-radius:var(--mg-card-border-radius-default);--mg-card-background:var(--mg-card-background-default);--mg-card-box-shadow:var(--mg-card-box-shadow-default)}";
|
|
4
4
|
|
|
5
5
|
const MgCard = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
6
6
|
constructor() {
|
|
@@ -31,12 +31,12 @@ const MgForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
31
31
|
// All fields are required
|
|
32
32
|
// mg-input-toggle can not be required
|
|
33
33
|
if (requiredInputs.length > 0 && requiredInputs.length === this.mgInputs.filter(input => input.nodeName !== 'MG-INPUT-TOGGLE').length) {
|
|
34
|
-
this.requiredMessage = this.messages.form.allRequired;
|
|
34
|
+
this.requiredMessage = requiredInputs.length === 1 ? this.messages.form.allRequiredSingle : this.messages.form.allRequired;
|
|
35
35
|
this.classList.add(this.classAllRequired);
|
|
36
36
|
}
|
|
37
37
|
// Some fields are required
|
|
38
38
|
else if (requiredInputs.length > 0) {
|
|
39
|
-
this.requiredMessage = this.messages.form.required;
|
|
39
|
+
this.requiredMessage = requiredInputs.length === 1 ? this.messages.form.requiredSingle : this.messages.form.required;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
};
|