@mgdis/mg-components 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +29 -0
- package/dist/cjs/css-shim-a22512c4.js +6 -0
- package/dist/cjs/index-85a4a0b6.js +1674 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +35 -0
- package/dist/cjs/mg-badge_20.cjs.entry.js +4661 -0
- package/dist/cjs/mg-components.cjs.js +23 -0
- package/dist/cjs/shadow-css-8940f82d.js +390 -0
- package/dist/collection/collection-manifest.json +31 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +4 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +99 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +148 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +27 -0
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +134 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +236 -0
- package/dist/collection/components/atoms/mg-button/mg-button.stories.js +38 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.css +3 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +133 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +15 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +54 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +57 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +155 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.stories.js +34 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +12 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +95 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.stories.js +21 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js +4 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +73 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +94 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +25 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +44 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +225 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.stories.js +26 -0
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +7 -0
- package/dist/collection/components/molecules/inputs/MgInput.js +130 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +156 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +444 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +57 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +7 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +171 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +467 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +46 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +11 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +199 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +633 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +68 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +195 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +401 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +43 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +156 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +443 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +65 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +201 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +532 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +70 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +222 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +589 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +115 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +217 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +553 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +52 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +213 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +457 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +73 -0
- package/dist/collection/components/molecules/mg-message/mg-message.conf.js +4 -0
- package/dist/collection/components/molecules/mg-message/mg-message.css +94 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +285 -0
- package/dist/collection/components/molecules/mg-message/mg-message.stories.js +43 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +5 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +39 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +218 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +23 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +59 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +249 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.stories.js +36 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +30 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +212 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +40 -0
- package/dist/collection/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/collection/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/collection/fonts/Poppins-Bold.ttf +0 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/locales/index.js +4 -0
- package/dist/collection/stories/buttons.stories.js +43 -0
- package/dist/collection/stories/grids.stories.js +50 -0
- package/dist/collection/stories/icons.stories.js +20 -0
- package/dist/collection/stories/messages.stories.js +44 -0
- package/dist/collection/stories/tags.stories.js +13 -0
- package/dist/collection/stories/typography.stories.js +28 -0
- package/dist/collection/utils/components.utils.js +67 -0
- package/dist/collection/utils/locale.utils.js +32 -0
- package/dist/collection/utils/test.utils.js +26 -0
- package/dist/collection/variables.css +177 -0
- package/dist/collection/variables.scss +177 -0
- package/dist/components/MgInput.js +140 -0
- package/dist/components/components.utils.js +69 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index2.js +54 -0
- package/dist/components/locale.utils.js +35 -0
- package/dist/components/mg-badge.d.ts +11 -0
- package/dist/components/mg-badge.js +6 -0
- package/dist/components/mg-badge2.js +82 -0
- package/dist/components/mg-button.d.ts +11 -0
- package/dist/components/mg-button.js +6 -0
- package/dist/components/mg-button2.js +148 -0
- package/dist/components/mg-character-left.d.ts +11 -0
- package/dist/components/mg-character-left.js +6 -0
- package/dist/components/mg-character-left2.js +77 -0
- package/dist/components/mg-icon.d.ts +11 -0
- package/dist/components/mg-icon.js +6 -0
- package/dist/components/mg-icon2.js +147 -0
- package/dist/components/mg-input-checkbox.d.ts +11 -0
- package/dist/components/mg-input-checkbox.js +222 -0
- package/dist/components/mg-input-date.d.ts +11 -0
- package/dist/components/mg-input-date.js +245 -0
- package/dist/components/mg-input-numeric.d.ts +11 -0
- package/dist/components/mg-input-numeric.js +324 -0
- package/dist/components/mg-input-password.d.ts +11 -0
- package/dist/components/mg-input-password.js +171 -0
- package/dist/components/mg-input-radio.d.ts +11 -0
- package/dist/components/mg-input-radio.js +211 -0
- package/dist/components/mg-input-select.d.ts +11 -0
- package/dist/components/mg-input-select.js +6 -0
- package/dist/components/mg-input-select2.js +243 -0
- package/dist/components/mg-input-text.d.ts +11 -0
- package/dist/components/mg-input-text.js +242 -0
- package/dist/components/mg-input-textarea.d.ts +11 -0
- package/dist/components/mg-input-textarea.js +224 -0
- package/dist/components/mg-input-title.d.ts +11 -0
- package/dist/components/mg-input-title.js +6 -0
- package/dist/components/mg-input-title2.js +55 -0
- package/dist/components/mg-input-toggle.d.ts +11 -0
- package/dist/components/mg-input-toggle.js +247 -0
- package/dist/components/mg-message.d.ts +11 -0
- package/dist/components/mg-message.js +183 -0
- package/dist/components/mg-pagination.d.ts +11 -0
- package/dist/components/mg-pagination.js +175 -0
- package/dist/components/mg-popover.d.ts +11 -0
- package/dist/components/mg-popover.js +183 -0
- package/dist/components/mg-tabs.d.ts +11 -0
- package/dist/components/mg-tabs.js +160 -0
- package/dist/components/mg-tag.d.ts +11 -0
- package/dist/components/mg-tag.js +76 -0
- package/dist/components/mg-tooltip.d.ts +11 -0
- package/dist/components/mg-tooltip.js +6 -0
- package/dist/components/mg-tooltip2.js +150 -0
- package/dist/components/popper.js +1784 -0
- package/dist/esm/css-shim-7c240feb.js +4 -0
- package/dist/esm/index-e3e84606.js +1643 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +31 -0
- package/dist/esm/mg-badge_20.entry.js +4638 -0
- package/dist/esm/mg-components.js +21 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/shadow-css-5d2d01ce.js +388 -0
- package/dist/esm-es5/css-shim-7c240feb.js +1 -0
- package/dist/esm-es5/index-e3e84606.js +1 -0
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +1 -0
- package/dist/esm-es5/mg-badge_20.entry.js +2 -0
- package/dist/esm-es5/mg-components.js +1 -0
- package/dist/esm-es5/shadow-css-5d2d01ce.js +12 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/mg-components/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/mg-components/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/mg-components/fonts/Poppins-Bold.ttf +0 -0
- package/dist/mg-components/index.esm.js +0 -0
- package/dist/mg-components/mg-components.css +1 -0
- package/dist/mg-components/mg-components.esm.js +1 -0
- package/dist/mg-components/mg-components.js +132 -0
- package/dist/mg-components/p-1cd24462.system.js +1 -0
- package/dist/mg-components/p-2e2f6b27.system.entry.js +2 -0
- package/dist/mg-components/p-366a224e.js +1 -0
- package/dist/mg-components/p-422c429b.system.js +1 -0
- package/dist/mg-components/p-50ea2036.system.js +1 -0
- package/dist/mg-components/p-62fa3797.js +1 -0
- package/dist/mg-components/p-71d57b8b.system.js +13 -0
- package/dist/mg-components/p-9a215712.system.js +1 -0
- package/dist/mg-components/p-cbf0464b.entry.js +1 -0
- package/dist/mg-components/p-f6455ab3.js +12 -0
- package/dist/mg-components/variables.css +177 -0
- package/dist/mg-components/variables.scss +177 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +36 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +19 -0
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +4 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +67 -0
- package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +16 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +39 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +7 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +12 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +36 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.stories.d.ts +26 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +24 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +4 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +25 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +14 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +56 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +11 -0
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +10 -0
- package/dist/types/components/molecules/inputs/MgInput.d.ts +35 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +120 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +128 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +7 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +10 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +173 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +21 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +111 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +121 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +15 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +18 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +133 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +14 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +160 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +26 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +150 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +8 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +117 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +7 -0
- package/dist/types/components/molecules/mg-message/mg-message.conf.d.ts +4 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +76 -0
- package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +16 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.conf.d.ts +4 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +53 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +6 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +62 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +12 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +10 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +63 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +7 -0
- package/dist/types/components.d.ts +1987 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/locales/index.d.ts +44 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/stories/buttons.stories.d.ts +13 -0
- package/dist/types/stories/grids.stories.d.ts +5 -0
- package/dist/types/stories/icons.stories.d.ts +13 -0
- package/dist/types/stories/messages.stories.d.ts +13 -0
- package/dist/types/stories/tags.stories.d.ts +5 -0
- package/dist/types/stories/typography.stories.d.ts +5 -0
- package/dist/types/utils/components.utils.d.ts +43 -0
- package/dist/types/utils/locale.utils.d.ts +22 -0
- package/dist/types/utils/test.utils.d.ts +5 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +86 -0
- package/readme.md +159 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { Component, h, Prop, Watch, Event } from '@stencil/core';
|
|
2
|
+
import { createID } from '../../../utils/components.utils';
|
|
3
|
+
import { NavigationAction } from './mg-pagination.conf';
|
|
4
|
+
import { messages } from './../../../locales';
|
|
5
|
+
/**
|
|
6
|
+
* Range generator
|
|
7
|
+
*
|
|
8
|
+
* start by get the range length, add "+ 1" to include last value, ex: Math.ceil((3 + 1 - 1) / 1) => 3
|
|
9
|
+
* then with Array(Math.ceil...) we get the final array with empty values, ex: Array(Math.ceil(2 + 1 - 1) / 1)) => [empty, empty, empty]
|
|
10
|
+
* then with Array(Math.ceil...).keys() we get the Array Iterator from empty values
|
|
11
|
+
* then with Array.from(Array(...)) we get the complete array with "index" values instead of "empty" values
|
|
12
|
+
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()) => [0, 1, 2]
|
|
13
|
+
* finaly we map values from "start" range and apply the "step" coefficiant,
|
|
14
|
+
* ex: Array.from(Array(Math.ceil((2 + 1 - 1) / 1) || 1).keys()).map(x => 1 + x * 1) => [1, 2, 3]
|
|
15
|
+
*
|
|
16
|
+
* range(1, 1) = [1]
|
|
17
|
+
* range(1, 5) = [1, 2, 3, 4, 5]
|
|
18
|
+
* range(10, 20, 2) = [10, 12, 14, 16, 18, 20]
|
|
19
|
+
*
|
|
20
|
+
* @param start
|
|
21
|
+
* @param end
|
|
22
|
+
* @param step
|
|
23
|
+
* @returns {number[]}
|
|
24
|
+
*/
|
|
25
|
+
const range = (start, end, step = 1) => Array.from(Array(Math.ceil((end + 1 - start) / step)).keys()).map(x => start + x * step);
|
|
26
|
+
export class MgPagination {
|
|
27
|
+
constructor() {
|
|
28
|
+
/**************
|
|
29
|
+
* Decorators *
|
|
30
|
+
**************/
|
|
31
|
+
/**
|
|
32
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
33
|
+
* If not set, it will be created.
|
|
34
|
+
*/
|
|
35
|
+
this.identifier = createID('mg-pagination');
|
|
36
|
+
/**
|
|
37
|
+
* Panignation label. Is a short description.
|
|
38
|
+
* Customize default value can be usefull to improve accessibility
|
|
39
|
+
*/
|
|
40
|
+
this.label = 'pagination';
|
|
41
|
+
/**
|
|
42
|
+
* Component total pages
|
|
43
|
+
*/
|
|
44
|
+
this.totalPages = 1;
|
|
45
|
+
/**
|
|
46
|
+
* Component current page
|
|
47
|
+
*/
|
|
48
|
+
this.currentPage = 1;
|
|
49
|
+
/**
|
|
50
|
+
* Change current page from target
|
|
51
|
+
* @param target
|
|
52
|
+
*/
|
|
53
|
+
this.goToPage = (target) => (this.currentPage = target);
|
|
54
|
+
/************
|
|
55
|
+
* Handlers *
|
|
56
|
+
************/
|
|
57
|
+
/**
|
|
58
|
+
* Default click handler
|
|
59
|
+
* @param event
|
|
60
|
+
*/
|
|
61
|
+
this.handleSelect = (event) => {
|
|
62
|
+
const to = Number(event.target.value);
|
|
63
|
+
this.goToPage(to > 0 ? to : 1);
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Go to 'previous/next' page button handler
|
|
67
|
+
* @returns {void}
|
|
68
|
+
*/
|
|
69
|
+
this.handleGoToPage = (action) => this.goToPage(action === NavigationAction.NEXT ? this.currentPage + 1 : this.currentPage - 1);
|
|
70
|
+
}
|
|
71
|
+
validateTotalPages(newValue) {
|
|
72
|
+
if (newValue < 1) {
|
|
73
|
+
throw new Error('<mg-pagination> prop "totalPages" must be greater than 0');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
validateCurrentPage(newValue) {
|
|
77
|
+
if (newValue < 1) {
|
|
78
|
+
throw new Error('<mg-pagination> prop "currentPage" must be greater than 0');
|
|
79
|
+
}
|
|
80
|
+
else if (newValue > this.totalPages) {
|
|
81
|
+
throw new Error('<mg-pagination> prop "currentPage" can not be greater than total page');
|
|
82
|
+
}
|
|
83
|
+
this.currentPageChange.emit(newValue);
|
|
84
|
+
}
|
|
85
|
+
/*************
|
|
86
|
+
* Lifecycle *
|
|
87
|
+
*************/
|
|
88
|
+
componentWillLoad() {
|
|
89
|
+
this.validateTotalPages(this.totalPages);
|
|
90
|
+
this.validateCurrentPage(this.currentPage);
|
|
91
|
+
}
|
|
92
|
+
render() {
|
|
93
|
+
const navigationActionButton = (disabled, action) => (h("mg-button", { identifier: `${this.identifier}-button-${action}`, class: "mg-pagination__button", label: messages.pagination[`${action}Page`],
|
|
94
|
+
// eslint-disable-next-line react/jsx-no-bind
|
|
95
|
+
onClick: () => this.handleGoToPage(action), disabled: disabled, variant: "flat" },
|
|
96
|
+
action === NavigationAction.PREVIOUS && h("mg-icon", { icon: "chevron-left" }),
|
|
97
|
+
messages.pagination[action],
|
|
98
|
+
action === NavigationAction.NEXT && h("mg-icon", { icon: "chevron-right" })));
|
|
99
|
+
return (h("nav", { "aria-label": this.label, id: this.identifier, class: "mg-pagination__nav" },
|
|
100
|
+
navigationActionButton(this.currentPage <= 1, NavigationAction.PREVIOUS),
|
|
101
|
+
h("mg-input-select", { identifier: `${this.identifier}-select`, items: range(1, this.totalPages).map(page => page.toString()), label: messages.pagination.selectPage, "label-hide": true, "on-value-change": this.handleSelect, value: this.currentPage.toString(), "placeholder-hide": true }),
|
|
102
|
+
h("span", { class: "sr-only" },
|
|
103
|
+
messages.pagination.page,
|
|
104
|
+
" ",
|
|
105
|
+
this.currentPage),
|
|
106
|
+
h("span", null,
|
|
107
|
+
"/ ",
|
|
108
|
+
this.totalPages,
|
|
109
|
+
" ",
|
|
110
|
+
this.totalPages > 1 ? messages.pagination.pages : messages.pagination.pages),
|
|
111
|
+
navigationActionButton(this.currentPage >= this.totalPages, NavigationAction.NEXT)));
|
|
112
|
+
}
|
|
113
|
+
static get is() { return "mg-pagination"; }
|
|
114
|
+
static get encapsulation() { return "shadow"; }
|
|
115
|
+
static get originalStyleUrls() { return {
|
|
116
|
+
"$": ["mg-pagination.scss"]
|
|
117
|
+
}; }
|
|
118
|
+
static get styleUrls() { return {
|
|
119
|
+
"$": ["mg-pagination.css"]
|
|
120
|
+
}; }
|
|
121
|
+
static get properties() { return {
|
|
122
|
+
"identifier": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"mutable": false,
|
|
125
|
+
"complexType": {
|
|
126
|
+
"original": "string",
|
|
127
|
+
"resolved": "string",
|
|
128
|
+
"references": {}
|
|
129
|
+
},
|
|
130
|
+
"required": false,
|
|
131
|
+
"optional": true,
|
|
132
|
+
"docs": {
|
|
133
|
+
"tags": [],
|
|
134
|
+
"text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
|
|
135
|
+
},
|
|
136
|
+
"attribute": "identifier",
|
|
137
|
+
"reflect": false,
|
|
138
|
+
"defaultValue": "createID('mg-pagination')"
|
|
139
|
+
},
|
|
140
|
+
"label": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"mutable": false,
|
|
143
|
+
"complexType": {
|
|
144
|
+
"original": "string",
|
|
145
|
+
"resolved": "string",
|
|
146
|
+
"references": {}
|
|
147
|
+
},
|
|
148
|
+
"required": false,
|
|
149
|
+
"optional": false,
|
|
150
|
+
"docs": {
|
|
151
|
+
"tags": [],
|
|
152
|
+
"text": "Panignation label. Is a short description.\nCustomize default value can be usefull to improve accessibility"
|
|
153
|
+
},
|
|
154
|
+
"attribute": "label",
|
|
155
|
+
"reflect": false,
|
|
156
|
+
"defaultValue": "'pagination'"
|
|
157
|
+
},
|
|
158
|
+
"totalPages": {
|
|
159
|
+
"type": "number",
|
|
160
|
+
"mutable": false,
|
|
161
|
+
"complexType": {
|
|
162
|
+
"original": "number",
|
|
163
|
+
"resolved": "number",
|
|
164
|
+
"references": {}
|
|
165
|
+
},
|
|
166
|
+
"required": false,
|
|
167
|
+
"optional": false,
|
|
168
|
+
"docs": {
|
|
169
|
+
"tags": [],
|
|
170
|
+
"text": "Component total pages"
|
|
171
|
+
},
|
|
172
|
+
"attribute": "total-pages",
|
|
173
|
+
"reflect": false,
|
|
174
|
+
"defaultValue": "1"
|
|
175
|
+
},
|
|
176
|
+
"currentPage": {
|
|
177
|
+
"type": "number",
|
|
178
|
+
"mutable": true,
|
|
179
|
+
"complexType": {
|
|
180
|
+
"original": "number",
|
|
181
|
+
"resolved": "number",
|
|
182
|
+
"references": {}
|
|
183
|
+
},
|
|
184
|
+
"required": false,
|
|
185
|
+
"optional": false,
|
|
186
|
+
"docs": {
|
|
187
|
+
"tags": [],
|
|
188
|
+
"text": "Component current page"
|
|
189
|
+
},
|
|
190
|
+
"attribute": "current-page",
|
|
191
|
+
"reflect": true,
|
|
192
|
+
"defaultValue": "1"
|
|
193
|
+
}
|
|
194
|
+
}; }
|
|
195
|
+
static get events() { return [{
|
|
196
|
+
"method": "currentPageChange",
|
|
197
|
+
"name": "current-page-change",
|
|
198
|
+
"bubbles": true,
|
|
199
|
+
"cancelable": true,
|
|
200
|
+
"composed": true,
|
|
201
|
+
"docs": {
|
|
202
|
+
"tags": [],
|
|
203
|
+
"text": "Emmited event when current page change"
|
|
204
|
+
},
|
|
205
|
+
"complexType": {
|
|
206
|
+
"original": "number",
|
|
207
|
+
"resolved": "number",
|
|
208
|
+
"references": {}
|
|
209
|
+
}
|
|
210
|
+
}]; }
|
|
211
|
+
static get watchers() { return [{
|
|
212
|
+
"propName": "totalPages",
|
|
213
|
+
"methodName": "validateTotalPages"
|
|
214
|
+
}, {
|
|
215
|
+
"propName": "currentPage",
|
|
216
|
+
"methodName": "validateCurrentPage"
|
|
217
|
+
}]; }
|
|
218
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export default {
|
|
3
|
+
component: 'mg-pagination',
|
|
4
|
+
title: 'Molecules/mg-pagination',
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
8
|
+
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
9
|
+
*/
|
|
10
|
+
const Template = args => {
|
|
11
|
+
// Extract slot so it won't be render as an attribute
|
|
12
|
+
const totalPages = args.totalPages;
|
|
13
|
+
delete args.totalPages;
|
|
14
|
+
const currentPage = args.currentPage;
|
|
15
|
+
delete args.currentPage;
|
|
16
|
+
// return element
|
|
17
|
+
return h("mg-pagination", Object.assign({}, args, { "total-pages": totalPages, "current-page": currentPage }));
|
|
18
|
+
};
|
|
19
|
+
export const MgPagination = Template.bind({});
|
|
20
|
+
MgPagination.args = {
|
|
21
|
+
totalPages: 5,
|
|
22
|
+
currentPage: 1,
|
|
23
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
mg-popover {
|
|
2
|
+
display: contents;
|
|
3
|
+
}
|
|
4
|
+
mg-popover::slotted(*) {
|
|
5
|
+
display: inline-block;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.mg-popover {
|
|
9
|
+
display: none;
|
|
10
|
+
padding: 1.5rem;
|
|
11
|
+
z-index: 9999;
|
|
12
|
+
border-radius: 0.5rem;
|
|
13
|
+
background-color: hsl(var(--mg-popover-background-color));
|
|
14
|
+
box-shadow: 0 0.3rem 0.8rem 0 rgba(0, 0, 0, 0.1);
|
|
15
|
+
color: hsl(var(--mg-popover-font-color));
|
|
16
|
+
}
|
|
17
|
+
.mg-popover[data-show] {
|
|
18
|
+
display: block;
|
|
19
|
+
}
|
|
20
|
+
.mg-popover mg-button {
|
|
21
|
+
float: right;
|
|
22
|
+
margin-right: calc(0rem - (var(--default-size) - var(--mg-icon-regular-size)) / 2);
|
|
23
|
+
margin-top: calc(0rem - (var(--default-size) - var(--mg-popover-title-font-size) * var(--line-height)) / 2);
|
|
24
|
+
margin-left: 3rem;
|
|
25
|
+
}
|
|
26
|
+
.mg-popover .mg-popover__arrow,
|
|
27
|
+
.mg-popover .mg-popover__arrow::before {
|
|
28
|
+
position: absolute;
|
|
29
|
+
width: 2rem;
|
|
30
|
+
height: 2rem;
|
|
31
|
+
z-index: 9999;
|
|
32
|
+
background: inherit;
|
|
33
|
+
}
|
|
34
|
+
.mg-popover .mg-popover__arrow {
|
|
35
|
+
visibility: hidden;
|
|
36
|
+
}
|
|
37
|
+
.mg-popover .mg-popover__arrow::before {
|
|
38
|
+
visibility: visible;
|
|
39
|
+
content: "";
|
|
40
|
+
transform: rotate(45deg);
|
|
41
|
+
}
|
|
42
|
+
.mg-popover[data-popper-placement^=top] > .mg-popover__arrow {
|
|
43
|
+
bottom: -6px;
|
|
44
|
+
}
|
|
45
|
+
.mg-popover[data-popper-placement^=bottom] > .mg-popover__arrow {
|
|
46
|
+
top: -6px;
|
|
47
|
+
}
|
|
48
|
+
.mg-popover[data-popper-placement^=left] > .mg-popover__arrow {
|
|
49
|
+
right: -6px;
|
|
50
|
+
}
|
|
51
|
+
.mg-popover[data-popper-placement^=right] > .mg-popover__arrow {
|
|
52
|
+
left: -6px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.mg-popover__title ::slotted(*) {
|
|
56
|
+
margin: 0 0 1rem;
|
|
57
|
+
font-size: var(--mg-popover-title-font-size);
|
|
58
|
+
font-weight: 600;
|
|
59
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { Component, Element, Host, h, Prop, Watch } from '@stencil/core';
|
|
2
|
+
import { createID } from '../../../utils/components.utils';
|
|
3
|
+
import { createPopper } from '@popperjs/core';
|
|
4
|
+
import { messages } from '../../../locales';
|
|
5
|
+
export class MgPopover {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.closeButtonId = '';
|
|
8
|
+
/**
|
|
9
|
+
* Sets an `id` attribute.
|
|
10
|
+
* Needed by the input for accessibility `aria-decribedby`.
|
|
11
|
+
*/
|
|
12
|
+
this.identifier = createID('mg-popover');
|
|
13
|
+
/**
|
|
14
|
+
* Popover placement
|
|
15
|
+
*/
|
|
16
|
+
this.placement = 'bottom';
|
|
17
|
+
/**
|
|
18
|
+
* Define if popover has a cross button
|
|
19
|
+
*/
|
|
20
|
+
this.closeButton = false;
|
|
21
|
+
/**
|
|
22
|
+
* Display popover
|
|
23
|
+
*/
|
|
24
|
+
this.display = false;
|
|
25
|
+
/**
|
|
26
|
+
* Disable popover
|
|
27
|
+
*/
|
|
28
|
+
this.disabled = false;
|
|
29
|
+
/**
|
|
30
|
+
* Check if clicked outside of component
|
|
31
|
+
* @param e {event}
|
|
32
|
+
*/
|
|
33
|
+
// Unable to trigger document events in unit tests: https://gitlab.mgdis.fr/core/core-ui/mg-components/-/issues/57
|
|
34
|
+
/* istanbul ignore next */
|
|
35
|
+
this.clickOutside = e => {
|
|
36
|
+
var _a;
|
|
37
|
+
if (!this.disabled && ((_a = e.target.closest(`#${this.identifier}`)) === null || _a === void 0 ? void 0 : _a.parentElement.nodeName) !== 'MG-POPOVER') {
|
|
38
|
+
this.display = false;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Show popover
|
|
43
|
+
* @returns {void}
|
|
44
|
+
*/
|
|
45
|
+
this.show = () => {
|
|
46
|
+
// Make the popover visible
|
|
47
|
+
this.popover.setAttribute('data-show', '');
|
|
48
|
+
// Enable the event listeners
|
|
49
|
+
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: true }] })));
|
|
50
|
+
// Update its position
|
|
51
|
+
this.popper.update();
|
|
52
|
+
// hide when click outside
|
|
53
|
+
// setTimeout is used to prevent event to trigger after creation
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
// Unable to trigger document events in unit tests: https://gitlab.mgdis.fr/core/core-ui/mg-components/-/issues/57
|
|
56
|
+
/* istanbul ignore next */
|
|
57
|
+
document.addEventListener('click', this.clickOutside, false);
|
|
58
|
+
}, 0);
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Hide popover
|
|
62
|
+
* @returns {void}
|
|
63
|
+
*/
|
|
64
|
+
this.hide = () => {
|
|
65
|
+
// Hide the popover
|
|
66
|
+
this.popover.removeAttribute('data-show');
|
|
67
|
+
// Disable the event listeners
|
|
68
|
+
this.popper.setOptions(options => (Object.assign(Object.assign({}, options), { modifiers: [...options.modifiers, { name: 'eventListeners', enabled: false }] })));
|
|
69
|
+
// Remove even listener
|
|
70
|
+
document.removeEventListener('click', this.clickOutside, false);
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Handle action for close button
|
|
74
|
+
* @returns {void}
|
|
75
|
+
*/
|
|
76
|
+
this.handleCloseButton = () => {
|
|
77
|
+
this.display = false;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
handleDisplay(newVal) {
|
|
81
|
+
if (newVal) {
|
|
82
|
+
this.show();
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.hide();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/*************
|
|
89
|
+
* Lifecycle *
|
|
90
|
+
*************/
|
|
91
|
+
componentDidLoad() {
|
|
92
|
+
//Check if slotted title is a heading
|
|
93
|
+
const headingElements = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
|
94
|
+
const slotedTitleElement = this.element.querySelector('[slot="title"]');
|
|
95
|
+
if (slotedTitleElement !== null && !headingElements.includes(slotedTitleElement.tagName.toLowerCase())) {
|
|
96
|
+
throw new Error(`<mg-popover> Slotted title must be a heading: ${headingElements.join(', ')}.`);
|
|
97
|
+
}
|
|
98
|
+
// Set close button id
|
|
99
|
+
if (this.closeButton) {
|
|
100
|
+
this.closeButtonId = `${this.identifier}-close-button`;
|
|
101
|
+
}
|
|
102
|
+
// Get popover content
|
|
103
|
+
this.popover = this.element.querySelector(`#${this.identifier}`);
|
|
104
|
+
//Get interactive element
|
|
105
|
+
const interactiveElement = this.element.firstElementChild;
|
|
106
|
+
// Add aria attributes
|
|
107
|
+
interactiveElement.setAttribute('aria-controls', this.identifier);
|
|
108
|
+
interactiveElement.setAttribute('aria-expanded', `${this.display}`);
|
|
109
|
+
// Create popperjs popover
|
|
110
|
+
this.popper = createPopper(interactiveElement, this.popover, {
|
|
111
|
+
placement: this.placement,
|
|
112
|
+
modifiers: [
|
|
113
|
+
{
|
|
114
|
+
name: 'offset',
|
|
115
|
+
options: {
|
|
116
|
+
offset: [0, 10],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
});
|
|
121
|
+
// Add events to toggle display
|
|
122
|
+
interactiveElement.addEventListener('click', () => {
|
|
123
|
+
if (!this.disabled)
|
|
124
|
+
this.display = !this.display;
|
|
125
|
+
});
|
|
126
|
+
// Add events to hide popover
|
|
127
|
+
this.element.addEventListener('keydown', e => {
|
|
128
|
+
if (!this.disabled && e.code === 'Escape')
|
|
129
|
+
this.display = false;
|
|
130
|
+
});
|
|
131
|
+
this.handleDisplay(this.display);
|
|
132
|
+
}
|
|
133
|
+
render() {
|
|
134
|
+
return (h(Host, null,
|
|
135
|
+
h("slot", null),
|
|
136
|
+
h("div", { id: this.identifier, class: "mg-popover" },
|
|
137
|
+
!this.disabled && this.closeButton && (h("mg-button", { identifier: this.closeButtonId, "is-icon": true, variant: "flat", label: messages.popover.closeButton, onClick: this.handleCloseButton },
|
|
138
|
+
h("mg-icon", { icon: "cross" }))),
|
|
139
|
+
h("div", { class: "mg-popover__title" },
|
|
140
|
+
h("slot", { name: "title" })),
|
|
141
|
+
h("slot", { name: "content" }),
|
|
142
|
+
h("div", { class: "mg-popover__arrow", "data-popper-arrow": true }))));
|
|
143
|
+
}
|
|
144
|
+
static get is() { return "mg-popover"; }
|
|
145
|
+
static get encapsulation() { return "scoped"; }
|
|
146
|
+
static get originalStyleUrls() { return {
|
|
147
|
+
"$": ["mg-popover.scss"]
|
|
148
|
+
}; }
|
|
149
|
+
static get styleUrls() { return {
|
|
150
|
+
"$": ["mg-popover.css"]
|
|
151
|
+
}; }
|
|
152
|
+
static get properties() { return {
|
|
153
|
+
"identifier": {
|
|
154
|
+
"type": "string",
|
|
155
|
+
"mutable": false,
|
|
156
|
+
"complexType": {
|
|
157
|
+
"original": "string",
|
|
158
|
+
"resolved": "string",
|
|
159
|
+
"references": {}
|
|
160
|
+
},
|
|
161
|
+
"required": false,
|
|
162
|
+
"optional": false,
|
|
163
|
+
"docs": {
|
|
164
|
+
"tags": [],
|
|
165
|
+
"text": "Sets an `id` attribute.\nNeeded by the input for accessibility `aria-decribedby`."
|
|
166
|
+
},
|
|
167
|
+
"attribute": "identifier",
|
|
168
|
+
"reflect": false,
|
|
169
|
+
"defaultValue": "createID('mg-popover')"
|
|
170
|
+
},
|
|
171
|
+
"placement": {
|
|
172
|
+
"type": "string",
|
|
173
|
+
"mutable": false,
|
|
174
|
+
"complexType": {
|
|
175
|
+
"original": "| 'auto'\n | 'auto-start'\n | 'auto-end'\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n | 'left'\n | 'left-start'\n | 'left-end'",
|
|
176
|
+
"resolved": "\"auto\" | \"auto-end\" | \"auto-start\" | \"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
|
|
177
|
+
"references": {}
|
|
178
|
+
},
|
|
179
|
+
"required": false,
|
|
180
|
+
"optional": false,
|
|
181
|
+
"docs": {
|
|
182
|
+
"tags": [],
|
|
183
|
+
"text": "Popover placement"
|
|
184
|
+
},
|
|
185
|
+
"attribute": "placement",
|
|
186
|
+
"reflect": false,
|
|
187
|
+
"defaultValue": "'bottom'"
|
|
188
|
+
},
|
|
189
|
+
"closeButton": {
|
|
190
|
+
"type": "boolean",
|
|
191
|
+
"mutable": false,
|
|
192
|
+
"complexType": {
|
|
193
|
+
"original": "boolean",
|
|
194
|
+
"resolved": "boolean",
|
|
195
|
+
"references": {}
|
|
196
|
+
},
|
|
197
|
+
"required": false,
|
|
198
|
+
"optional": false,
|
|
199
|
+
"docs": {
|
|
200
|
+
"tags": [],
|
|
201
|
+
"text": "Define if popover has a cross button"
|
|
202
|
+
},
|
|
203
|
+
"attribute": "close-button",
|
|
204
|
+
"reflect": false,
|
|
205
|
+
"defaultValue": "false"
|
|
206
|
+
},
|
|
207
|
+
"display": {
|
|
208
|
+
"type": "boolean",
|
|
209
|
+
"mutable": true,
|
|
210
|
+
"complexType": {
|
|
211
|
+
"original": "boolean",
|
|
212
|
+
"resolved": "boolean",
|
|
213
|
+
"references": {}
|
|
214
|
+
},
|
|
215
|
+
"required": false,
|
|
216
|
+
"optional": false,
|
|
217
|
+
"docs": {
|
|
218
|
+
"tags": [],
|
|
219
|
+
"text": "Display popover"
|
|
220
|
+
},
|
|
221
|
+
"attribute": "display",
|
|
222
|
+
"reflect": false,
|
|
223
|
+
"defaultValue": "false"
|
|
224
|
+
},
|
|
225
|
+
"disabled": {
|
|
226
|
+
"type": "boolean",
|
|
227
|
+
"mutable": true,
|
|
228
|
+
"complexType": {
|
|
229
|
+
"original": "boolean",
|
|
230
|
+
"resolved": "boolean",
|
|
231
|
+
"references": {}
|
|
232
|
+
},
|
|
233
|
+
"required": false,
|
|
234
|
+
"optional": false,
|
|
235
|
+
"docs": {
|
|
236
|
+
"tags": [],
|
|
237
|
+
"text": "Disable popover"
|
|
238
|
+
},
|
|
239
|
+
"attribute": "disabled",
|
|
240
|
+
"reflect": false,
|
|
241
|
+
"defaultValue": "false"
|
|
242
|
+
}
|
|
243
|
+
}; }
|
|
244
|
+
static get elementRef() { return "element"; }
|
|
245
|
+
static get watchers() { return [{
|
|
246
|
+
"propName": "display",
|
|
247
|
+
"methodName": "handleDisplay"
|
|
248
|
+
}]; }
|
|
249
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export default {
|
|
3
|
+
component: 'mg-popover',
|
|
4
|
+
title: 'Molecules/mg-popover',
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: 'centered',
|
|
7
|
+
docs: { iframeHeight: 600 },
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 1. camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
|
|
12
|
+
* 2. boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
|
|
13
|
+
*/
|
|
14
|
+
const Template = args => {
|
|
15
|
+
// Extract slot so it won't be render as an attribute
|
|
16
|
+
const slotTitle = args.slotTitle;
|
|
17
|
+
delete args.slotTitle;
|
|
18
|
+
const slotContent = args.slotContent;
|
|
19
|
+
delete args.slotContent;
|
|
20
|
+
const closeButton = args.closeButton;
|
|
21
|
+
delete args.closeButton;
|
|
22
|
+
// return element
|
|
23
|
+
return (h("mg-popover", Object.assign({}, args, { "close-button": closeButton }),
|
|
24
|
+
h("mg-button", null, "Button"),
|
|
25
|
+
slotTitle && h("h2", { slot: "title" }, slotTitle),
|
|
26
|
+
slotContent && h("p", { slot: "content" }, slotContent)));
|
|
27
|
+
};
|
|
28
|
+
export const MgPopover = Template.bind({});
|
|
29
|
+
MgPopover.args = {
|
|
30
|
+
slotTitle: `Blu bli blo bla`,
|
|
31
|
+
slotContent: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`,
|
|
32
|
+
identifier: 'identifier',
|
|
33
|
+
closeButton: false,
|
|
34
|
+
disabled: false,
|
|
35
|
+
display: false,
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.mg-tabs__header {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: row;
|
|
4
|
+
flex-wrap: wrap;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.mg-tabs__navigation-button {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
column-gap: 0.5rem;
|
|
11
|
+
padding: 1.8rem 2.4rem 1.5rem;
|
|
12
|
+
background: none;
|
|
13
|
+
border: none;
|
|
14
|
+
border-bottom: 0.3rem solid transparent;
|
|
15
|
+
color: hsl(var(--color-dark));
|
|
16
|
+
line-height: var(--line-height);
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
.mg-tabs__navigation-button:hover, .mg-tabs__navigation-button:focus {
|
|
20
|
+
background-color: hsla(var(--color-info-h), var(--color-info-s), var(--color-info-l), 10%);
|
|
21
|
+
}
|
|
22
|
+
.mg-tabs__navigation-button.mg-tabs__navigation-button--active {
|
|
23
|
+
color: hsl(var(--color-info));
|
|
24
|
+
border-bottom-color: hsl(var(--color-info));
|
|
25
|
+
font-weight: 700;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.mg-tabs__content-container:focus-visible {
|
|
29
|
+
outline-color: transparent;
|
|
30
|
+
}
|