@mgdis/mg-components 5.5.0 → 5.6.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-4dcc1812.js} +11 -1
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/mg-badge_30.cjs.entry.js +742 -244
- package/dist/cjs/mg-components.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +4 -4
- 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 +3 -3
- package/dist/collection/components/atoms/mg-button/mg-button.css +2 -1
- package/dist/collection/components/atoms/mg-card/mg-card.css +13 -6
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +13 -3
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +6 -6
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +3 -3
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +2 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +4 -1
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +3 -3
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +3 -3
- package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +43 -11
- 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 -18
- package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +5 -10
- 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 +47 -21
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +118 -70
- 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 +53 -12
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +8 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +7 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +72 -14
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +48 -4
- package/dist/collection/components/molecules/mg-skip-links/doc/mg-skip-links.stories.js +1 -1
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +32 -1
- package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +5 -3
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +11 -7
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +101 -54
- package/dist/collection/locales/en/messages.json +4 -0
- package/dist/collection/locales/fr/messages.json +4 -0
- package/dist/collection/locales/index.js +2 -25
- 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/navigation-button.scss +76 -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 +169 -0
- package/dist/collection/utils/components.utils.js +50 -0
- package/dist/collection/utils/locale.utils.js +22 -0
- package/dist/collection/utils/unit.test.utils.js +37 -32
- package/dist/collection/variables.css +9 -9
- package/dist/components/components.utils.js +51 -1
- package/dist/components/index2.js +65 -18
- package/dist/components/mg-badge2.js +4 -4
- package/dist/components/mg-button2.js +1 -1
- package/dist/components/mg-card2.js +1 -1
- package/dist/components/mg-icon2.js +13 -3
- package/dist/components/mg-illustrated-message.js +4 -3
- package/dist/components/mg-input-date.js +6 -4
- package/dist/components/mg-input-numeric.js +2 -3
- package/dist/components/mg-input-password.js +1 -1
- package/dist/components/mg-input-select2.js +8 -4
- package/dist/components/mg-input-text2.js +1 -1
- package/dist/components/mg-input-textarea.js +1 -1
- package/dist/components/mg-menu-item.js +1 -253
- package/dist/components/mg-menu-item2.js +517 -0
- package/dist/components/mg-menu.js +138 -21
- package/dist/components/mg-message.js +54 -13
- package/dist/components/mg-modal.js +1 -1
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-popover.js +1 -190
- package/dist/components/mg-popover2.js +212 -0
- package/dist/components/mg-skip-links.js +16 -2
- package/dist/components/mg-tabs.js +100 -52
- package/dist/components/mg-tag.js +4 -4
- package/dist/components/mg-tooltip2.js +4 -4
- package/dist/esm/{index-78edde1d.js → index-dc9a2348.js} +11 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/mg-badge_30.entry.js +742 -244
- package/dist/esm/mg-components.js +3 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/mg-components/locales/en/messages.json +4 -0
- package/dist/mg-components/locales/fr/messages.json +4 -0
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/{p-125c54ca.js → p-182bd802.js} +2 -2
- package/dist/mg-components/p-f7da9dd2.entry.js +1 -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/navigation-button.scss +76 -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 +9 -9
- 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-toggle/mg-input-toggle.conf.d.ts +1 -1
- package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +5 -0
- 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 +55 -15
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +21 -4
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +12 -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 +44 -12
- package/dist/types/locales/index.d.ts +10 -9
- package/dist/types/stencil-public-runtime.d.ts +39 -3
- package/dist/types/utils/behaviors.utils.d.ts +83 -0
- package/dist/types/utils/components.utils.d.ts +14 -0
- package/dist/types/utils/locale.utils.d.ts +13 -0
- package/dist/types/utils/unit.test.utils.d.ts +50 -14
- package/package.json +26 -26
- package/readme.md +22 -13
- package/dist/components/locale.utils.js +0 -40
- package/dist/components/mg-menu.conf.js +0 -10
- package/dist/mg-components/p-4961c96c.entry.js +0 -1
|
@@ -133,7 +133,7 @@ export interface ListenOptions {
|
|
|
133
133
|
*/
|
|
134
134
|
passive?: boolean;
|
|
135
135
|
}
|
|
136
|
-
export
|
|
136
|
+
export type ListenTargetOptions = 'body' | 'document' | 'window';
|
|
137
137
|
export interface StateDecorator {
|
|
138
138
|
(): PropertyDecorator;
|
|
139
139
|
}
|
|
@@ -214,8 +214,8 @@ export declare const State: StateDecorator;
|
|
|
214
214
|
* https://stenciljs.com/docs/reactive-data#watch-decorator
|
|
215
215
|
*/
|
|
216
216
|
export declare const Watch: WatchDecorator;
|
|
217
|
-
export
|
|
218
|
-
export
|
|
217
|
+
export type ResolutionHandler = (elm: HTMLElement) => string | undefined | null;
|
|
218
|
+
export type ErrorHandler = (err: any, element?: HTMLElement) => void;
|
|
219
219
|
/**
|
|
220
220
|
* `setMode()` is used for libraries which provide multiple "modes" for styles.
|
|
221
221
|
*/
|
|
@@ -433,8 +433,44 @@ interface HostAttributes {
|
|
|
433
433
|
ref?: (el: HTMLElement | null) => void;
|
|
434
434
|
[prop: string]: any;
|
|
435
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Utilities for working with functional Stencil components. An object
|
|
438
|
+
* conforming to this interface is passed by the Stencil runtime as the third
|
|
439
|
+
* argument to a functional component, allowing component authors to work with
|
|
440
|
+
* features like children.
|
|
441
|
+
*
|
|
442
|
+
* The children of a functional component will be passed as the second
|
|
443
|
+
* argument, so a functional component which uses these utils to transform its
|
|
444
|
+
* children might look like the following:
|
|
445
|
+
*
|
|
446
|
+
* ```ts
|
|
447
|
+
* export const AddClass: FunctionalComponent = (_, children, utils) => (
|
|
448
|
+
* utils.map(children, child => ({
|
|
449
|
+
* ...child,
|
|
450
|
+
* vattrs: {
|
|
451
|
+
* ...child.vattrs,
|
|
452
|
+
* class: `${child.vattrs.class} add-class`
|
|
453
|
+
* }
|
|
454
|
+
* }))
|
|
455
|
+
* );
|
|
456
|
+
* ```
|
|
457
|
+
*
|
|
458
|
+
* For more see the Stencil documentation, here:
|
|
459
|
+
* https://stenciljs.com/docs/functional-components
|
|
460
|
+
*/
|
|
436
461
|
export interface FunctionalUtilities {
|
|
462
|
+
/**
|
|
463
|
+
* Utility for reading the children of a functional component at runtime.
|
|
464
|
+
* Since the Stencil runtime uses a different interface for children it is
|
|
465
|
+
* not recommendeded to read the children directly, and is preferable to use
|
|
466
|
+
* this utility to, for instance, perform a side effect for each child.
|
|
467
|
+
*/
|
|
437
468
|
forEach: (children: VNode[], cb: (vnode: ChildNode, index: number, array: ChildNode[]) => void) => void;
|
|
469
|
+
/**
|
|
470
|
+
* Utility for transforming the children of a functional component. Given an
|
|
471
|
+
* array of children and a callback this will return a list of the results of
|
|
472
|
+
* passing each child to the supplied callback.
|
|
473
|
+
*/
|
|
438
474
|
map: (children: VNode[], cb: (vnode: ChildNode, index: number, array: ChildNode[]) => ChildNode) => VNode[];
|
|
439
475
|
}
|
|
440
476
|
export interface FunctionalComponent<T = {}> {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export declare enum OverflowBehaviorElements {
|
|
2
|
+
MORE = "data-overflow-more",
|
|
3
|
+
BASE_INDEX = "data-overflow-base-index",
|
|
4
|
+
PROXY_INDEX = "data-overflow-proxy-index"
|
|
5
|
+
}
|
|
6
|
+
export declare class OverflowBehavior {
|
|
7
|
+
private element;
|
|
8
|
+
private render;
|
|
9
|
+
private resizeObserver;
|
|
10
|
+
private moreELement;
|
|
11
|
+
private children;
|
|
12
|
+
constructor(element: Element, render: () => HTMLElement);
|
|
13
|
+
/**********
|
|
14
|
+
* Public *
|
|
15
|
+
**********/
|
|
16
|
+
/**
|
|
17
|
+
* Disconnect ResizeObserver
|
|
18
|
+
*
|
|
19
|
+
* @returns {void}
|
|
20
|
+
*/
|
|
21
|
+
disconnect: () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Update more element status if active child
|
|
24
|
+
*
|
|
25
|
+
* @returns {void}
|
|
26
|
+
*/
|
|
27
|
+
updateActiveStatus: () => void;
|
|
28
|
+
/************
|
|
29
|
+
* Internal *
|
|
30
|
+
************/
|
|
31
|
+
/**
|
|
32
|
+
* run overflow behavior
|
|
33
|
+
*
|
|
34
|
+
* @param {number} width width of the container
|
|
35
|
+
* @returns {void}
|
|
36
|
+
*/
|
|
37
|
+
private run;
|
|
38
|
+
/**
|
|
39
|
+
* Update displayed items in container from a given available space
|
|
40
|
+
*
|
|
41
|
+
* @param {number} availableWidth available width in container to display child items
|
|
42
|
+
* @returns {void}
|
|
43
|
+
*/
|
|
44
|
+
private updateDisplayedItems;
|
|
45
|
+
/**
|
|
46
|
+
* Utility method to know if item overflow partialy or totaly in the container
|
|
47
|
+
*
|
|
48
|
+
* @param {number} cumulateWidth previous sibling elements cumulate width + item width
|
|
49
|
+
* @param {HTMLElement} item item HTML element
|
|
50
|
+
* @param {number} availableWidth container available width
|
|
51
|
+
* @returns {boolean} truthy if element is overflow
|
|
52
|
+
*/
|
|
53
|
+
private isOverflowElement;
|
|
54
|
+
/**
|
|
55
|
+
* Utility method to know if a given element is the 'MORE' element
|
|
56
|
+
*
|
|
57
|
+
* @param {Element} element element to match with 'MORE' element
|
|
58
|
+
* @returns {boolean} truthy if element is the 'MORE' element
|
|
59
|
+
*/
|
|
60
|
+
private isMoreElement;
|
|
61
|
+
/**
|
|
62
|
+
* Toggle display item element
|
|
63
|
+
*
|
|
64
|
+
* @param {HTMLElement} item item to control
|
|
65
|
+
* @param {boolean} isHidden is item hidden
|
|
66
|
+
* @returns {void}
|
|
67
|
+
*/
|
|
68
|
+
private toggleItem;
|
|
69
|
+
/**
|
|
70
|
+
* Toggle element's hidde attribute
|
|
71
|
+
*
|
|
72
|
+
* @param {Element} element element to toggle
|
|
73
|
+
* @param {boolean} isHidden element is hidden
|
|
74
|
+
* @returns {void}
|
|
75
|
+
*/
|
|
76
|
+
private toggleElement;
|
|
77
|
+
/**
|
|
78
|
+
* Remove hidden attributes on all items
|
|
79
|
+
*
|
|
80
|
+
* @returns {void}
|
|
81
|
+
*/
|
|
82
|
+
private restoreItems;
|
|
83
|
+
}
|
|
@@ -60,3 +60,17 @@ export declare const isTagName: (element: Element, tagNames: string[]) => boolea
|
|
|
60
60
|
* Focusable elements query selector
|
|
61
61
|
*/
|
|
62
62
|
export declare const focusableElements = "a[href], button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"]), [identifier]";
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param {Window} localWindow the window we are lookink for other windows
|
|
66
|
+
* @returns {Window[]} The list of windows found
|
|
67
|
+
*/
|
|
68
|
+
export declare const getWindows: (localWindow: Window) => Window[];
|
|
69
|
+
/**
|
|
70
|
+
* Get parent windows
|
|
71
|
+
*
|
|
72
|
+
* @param {Window} localWindow the window we are lookink for parents
|
|
73
|
+
* @param {Window[]} windows The list of allready found windows
|
|
74
|
+
* @returns {Window[]} The list of windows found
|
|
75
|
+
*/
|
|
76
|
+
export declare const getParentWindows: (localWindow: Window, windows?: Window[]) => Window[];
|
|
@@ -27,3 +27,16 @@ export declare const dateRegExp: RegExp;
|
|
|
27
27
|
* @returns {string} formatted date
|
|
28
28
|
*/
|
|
29
29
|
export declare function localeDate(date: string, locale: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Get locale and messages
|
|
32
|
+
* We load the defined locale but for now we only support the first subtag for messages
|
|
33
|
+
*
|
|
34
|
+
* @param {HTMLElement} element element we need to get the language
|
|
35
|
+
* @param {unknown} messages messages to use
|
|
36
|
+
* @param {string} defaultLocale default messages locale
|
|
37
|
+
* @returns {{ locale: string; messages: unknown }} messages object
|
|
38
|
+
*/
|
|
39
|
+
export declare const getLocaleMessages: (element: HTMLElement, messages: unknown, defaultLocale: string) => {
|
|
40
|
+
locale: string;
|
|
41
|
+
messages: unknown;
|
|
42
|
+
};
|
|
@@ -10,11 +10,11 @@ export declare const cloneDeep: (obj: unknown) => unknown;
|
|
|
10
10
|
*
|
|
11
11
|
* @param mutationObserverMock - Parameter that is sent to the `Object.defineProperty`
|
|
12
12
|
* overwrite method. `jest.fn()` mock functions can be passed here if the goal is to not only
|
|
13
|
-
* mock the
|
|
13
|
+
* mock the mutation observer, but its methods.
|
|
14
14
|
* You can manually fire an intersection entry:
|
|
15
15
|
* @param {Function} mutationObserverMock.disconnect disconnect function
|
|
16
|
-
* @param {Function} mutationObserverMock.observe observe
|
|
17
|
-
* @param {Function} mutationObserverMock.takeRecords takeRecords
|
|
16
|
+
* @param {Function} mutationObserverMock.observe observe function
|
|
17
|
+
* @param {Function} mutationObserverMock.takeRecords takeRecords function
|
|
18
18
|
* @returns {MutationObserver} Mocked MutationObserver
|
|
19
19
|
* @example
|
|
20
20
|
* ```
|
|
@@ -28,15 +28,51 @@ export declare const cloneDeep: (obj: unknown) => unknown;
|
|
|
28
28
|
* fireMo([{ type: 'childList', addedNodes: [AMockElemenet, AnotherMockElemenet], target: yourMockElemenet }]);;
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
disconnect:
|
|
33
|
-
observe:
|
|
34
|
-
takeRecords:
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
type SetupMutationObserverMockParams = {
|
|
32
|
+
disconnect: MutationObserver['disconnect'];
|
|
33
|
+
observe: MutationObserver['observe'];
|
|
34
|
+
takeRecords: MutationObserver['takeRecords'];
|
|
35
|
+
};
|
|
36
|
+
export declare const setupMutationObserverMock: ({ disconnect, observe, takeRecords }: SetupMutationObserverMockParams) => typeof MutationObserver;
|
|
37
|
+
/**
|
|
38
|
+
* Utility function that mocks the `ResizeObserver` API. Recommended to execute inside `beforeEach`.
|
|
39
|
+
*
|
|
40
|
+
* @param resizeObserverMock - Parameter that is sent to the `Object.defineProperty`
|
|
41
|
+
* overwrite method. `jest.fn()` mock functions can be passed here if the goal is to not only
|
|
42
|
+
* mock the resize observer, but its methods.
|
|
43
|
+
* You can manually fire an intersection entry:
|
|
44
|
+
* @param {Function} resizeObserverMock.disconnect disconnect function
|
|
45
|
+
* @param {Function} resizeObserverMock.observe observe function
|
|
46
|
+
* @returns {ResizeObserver} Mocked ResizeObserver
|
|
47
|
+
* @example
|
|
48
|
+
* ```
|
|
49
|
+
* let fireRo;
|
|
50
|
+
* setupResizeObserverMock({
|
|
51
|
+
* observe: function () {
|
|
52
|
+
* fireRo = this.cb;
|
|
53
|
+
* },
|
|
54
|
+
* });
|
|
55
|
+
* ...
|
|
56
|
+
* fireRo([{
|
|
57
|
+
* borderBoxSize: ResizeObserverSize[],
|
|
58
|
+
* contentBoxSize: ResizeObserverSize[],
|
|
59
|
+
* contentRect: DOMRectReadOnly,
|
|
60
|
+
* devicePixelContentBoxSize: ResizeObserverSize[],
|
|
61
|
+
* target: yourMockElemenet
|
|
62
|
+
* }]);;
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
type setupResizeObserverMockParams = {
|
|
66
|
+
disconnect: ResizeObserver['disconnect'];
|
|
67
|
+
observe: ResizeObserver['observe'];
|
|
42
68
|
};
|
|
69
|
+
export declare const setupResizeObserverMock: ({ disconnect, observe }: setupResizeObserverMockParams) => typeof ResizeObserver;
|
|
70
|
+
/**
|
|
71
|
+
* force popover id when component use randomed identifier
|
|
72
|
+
*
|
|
73
|
+
* @param {Element} item element wich include mg-popover
|
|
74
|
+
* @param {string} id new fixed id
|
|
75
|
+
* @returns {void}
|
|
76
|
+
*/
|
|
77
|
+
export declare const forcePopoverId: (item: Element, id: string) => void;
|
|
78
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mgdis/mg-components",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "MG Components",
|
|
5
5
|
"packageManager": "pnpm@7.17.1",
|
|
6
6
|
"engineStrict": true,
|
|
@@ -28,50 +28,50 @@
|
|
|
28
28
|
"outputName": "junit.xml"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@popperjs/core": "^2.11.
|
|
32
|
-
"@stencil/core": "^2.
|
|
31
|
+
"@popperjs/core": "^2.11.6",
|
|
32
|
+
"@stencil/core": "^2.21.0",
|
|
33
33
|
"normalize.css": "^8.0.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@babel/core": "^7.20.
|
|
37
|
-
"@babel/plugin-transform-react-jsx": "^7.
|
|
36
|
+
"@babel/core": "^7.20.12",
|
|
37
|
+
"@babel/plugin-transform-react-jsx": "^7.20.7",
|
|
38
38
|
"@pxtrn/storybook-addon-docs-stencil": "^6.4.1",
|
|
39
39
|
"@stencil/eslint-plugin": "^0.4.0",
|
|
40
40
|
"@stencil/sass": "^1.5.2",
|
|
41
|
-
"@storybook/addon-a11y": "^6.5.
|
|
42
|
-
"@storybook/addon-actions": "^6.5.
|
|
43
|
-
"@storybook/addon-docs": "^6.5.
|
|
44
|
-
"@storybook/addon-essentials": "^6.5.
|
|
45
|
-
"@storybook/addon-links": "^6.5.
|
|
46
|
-
"@storybook/html": "^6.5.
|
|
41
|
+
"@storybook/addon-a11y": "^6.5.15",
|
|
42
|
+
"@storybook/addon-actions": "^6.5.15",
|
|
43
|
+
"@storybook/addon-docs": "^6.5.15",
|
|
44
|
+
"@storybook/addon-essentials": "^6.5.15",
|
|
45
|
+
"@storybook/addon-links": "^6.5.15",
|
|
46
|
+
"@storybook/html": "^6.5.15",
|
|
47
47
|
"@storybook/preset-scss": "^1.0.3",
|
|
48
48
|
"@types/jest": "^26.0.24",
|
|
49
|
-
"@types/jest-image-snapshot": "^4.3.
|
|
49
|
+
"@types/jest-image-snapshot": "^4.3.2",
|
|
50
50
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
51
51
|
"@typescript-eslint/parser": "^4.33.0",
|
|
52
|
-
"babel-loader": "^8.
|
|
52
|
+
"babel-loader": "^8.3.0",
|
|
53
53
|
"babel-plugin-jsx-pragmatic": "^1.0.2",
|
|
54
|
-
"chromatic": "^6.
|
|
54
|
+
"chromatic": "^6.14.0",
|
|
55
55
|
"css-loader": "^5.2.7",
|
|
56
56
|
"eslint": "^7.32.0",
|
|
57
|
-
"eslint-plugin-jsdoc": "^38.
|
|
58
|
-
"eslint-plugin-jsx-a11y": "^6.
|
|
59
|
-
"eslint-plugin-react": "^7.
|
|
60
|
-
"eslint-plugin-storybook": "^0.6.
|
|
57
|
+
"eslint-plugin-jsdoc": "^38.1.6",
|
|
58
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
59
|
+
"eslint-plugin-react": "^7.32.0",
|
|
60
|
+
"eslint-plugin-storybook": "^0.6.10",
|
|
61
61
|
"husky": "^7.0.4",
|
|
62
62
|
"jest": "^26.6.3",
|
|
63
63
|
"jest-cli": "^26.6.3",
|
|
64
64
|
"jest-image-snapshot": "^4.5.1",
|
|
65
|
-
"jest-junit": "^13.
|
|
66
|
-
"jsx-dom": "^8.0.
|
|
65
|
+
"jest-junit": "^13.2.0",
|
|
66
|
+
"jsx-dom": "^8.0.3",
|
|
67
67
|
"npm-run-all": "^4.1.5",
|
|
68
|
-
"prettier": "^2.
|
|
69
|
-
"puppeteer": "^13.
|
|
70
|
-
"sass": "^1.
|
|
71
|
-
"sass-loader": "^10.
|
|
68
|
+
"prettier": "^2.8.2",
|
|
69
|
+
"puppeteer": "^13.7.0",
|
|
70
|
+
"sass": "^1.57.1",
|
|
71
|
+
"sass-loader": "^10.4.1",
|
|
72
72
|
"style-loader": "^2.0.0",
|
|
73
|
-
"ts-node": "^10.
|
|
74
|
-
"turbo": "^1.
|
|
73
|
+
"ts-node": "^10.9.1",
|
|
74
|
+
"turbo": "^1.7.0",
|
|
75
75
|
"typescript": "~4.4.4"
|
|
76
76
|
},
|
|
77
77
|
"license": "BSD-3-Clause",
|
package/readme.md
CHANGED
|
@@ -20,45 +20,47 @@ To run MG Components, clone this repository, go to your new directory and run:
|
|
|
20
20
|
# This repository uses pnpm as package manager
|
|
21
21
|
corepack enable
|
|
22
22
|
pnpm i
|
|
23
|
-
|
|
23
|
+
pnpm start
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
To build for production, run:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
|
|
29
|
+
pnpm build
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
To run tests for the components, run:
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
|
|
35
|
+
pnpm test
|
|
36
36
|
|
|
37
37
|
# only unit tests
|
|
38
|
-
|
|
38
|
+
pnpm test:unit
|
|
39
39
|
|
|
40
40
|
# only e2e tests
|
|
41
|
-
|
|
41
|
+
pnpm test:e2e
|
|
42
42
|
|
|
43
43
|
# filter on filename
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
pnpm test -- mg-icon
|
|
45
|
+
pnpm test:unit -- mg-icon
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
<!-- Not working for now: To regenerate snapshot you must add the `-u` parameter. -->
|
|
49
49
|
|
|
50
|
+
To regenerate snapshot you must add the `--updateSnapshot` parameter.
|
|
51
|
+
|
|
50
52
|
For E2E tests you **must** use [WSL](https://docs.microsoft.com/fr-fr/windows/wsl/install) or a Linux OS to get the same screenshots as the GitLab CI.
|
|
51
53
|
|
|
52
54
|
To add a component, run:
|
|
53
55
|
|
|
54
56
|
```bash
|
|
55
|
-
|
|
57
|
+
pnpm generate component-path
|
|
56
58
|
|
|
57
59
|
# example for an atom
|
|
58
|
-
|
|
60
|
+
pnpm generate atoms/mg-icon
|
|
59
61
|
|
|
60
62
|
# example for a molecule
|
|
61
|
-
|
|
63
|
+
pnpm generate molecules/mg-message
|
|
62
64
|
```
|
|
63
65
|
|
|
64
66
|
## Naming Components
|
|
@@ -126,10 +128,17 @@ The plugin [storybook-addon-docs-stencil
|
|
|
126
128
|
### run
|
|
127
129
|
|
|
128
130
|
```bash
|
|
129
|
-
|
|
131
|
+
pnpm storybook
|
|
130
132
|
```
|
|
131
133
|
|
|
132
134
|
### Notes
|
|
133
135
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
To display components in our `stories`, we use the `filterArgs` method to only show the necessary arguments in the code example. It takes in the first parameter an object containing the arguments to be used, and in the second parameter, an object containing the component default values.
|
|
137
|
+
|
|
138
|
+
```JS
|
|
139
|
+
const Template = (args: any): HTMLElement => (
|
|
140
|
+
<mg-tooltip {...filterArgs(args, { placement: 'bottom' })}>
|
|
141
|
+
<mg-icon icon="info-circle"></mg-icon>
|
|
142
|
+
</mg-tooltip>
|
|
143
|
+
);
|
|
144
|
+
```
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format number to the locale currency
|
|
3
|
-
*
|
|
4
|
-
* @param {number} number number to format
|
|
5
|
-
* @param {string} locale locale to apply
|
|
6
|
-
* @param {string} currency currency to apply
|
|
7
|
-
* @returns {string} formatted currency
|
|
8
|
-
*/
|
|
9
|
-
function localeCurrency(number, locale, currency) {
|
|
10
|
-
return new Intl.NumberFormat(locale, { style: 'currency', currency }).format(number);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Format number to locale
|
|
14
|
-
*
|
|
15
|
-
* @param {number} number number to format
|
|
16
|
-
* @param {string} locale locale to apply
|
|
17
|
-
* @returns {string} formatted number
|
|
18
|
-
*/
|
|
19
|
-
function localeNumber(number, locale) {
|
|
20
|
-
return new Intl.NumberFormat(locale).format(number);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Date RegExp
|
|
24
|
-
*/
|
|
25
|
-
const dateRegExp = /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/;
|
|
26
|
-
/**
|
|
27
|
-
* Locale date format
|
|
28
|
-
*
|
|
29
|
-
* @param {string} date date to format
|
|
30
|
-
* @param {string} locale locale to apply
|
|
31
|
-
* @returns {string} formatted date
|
|
32
|
-
*/
|
|
33
|
-
function localeDate(date, locale) {
|
|
34
|
-
if (typeof date !== 'string' || date === '' || !dateRegExp.test(date)) {
|
|
35
|
-
return '';
|
|
36
|
-
}
|
|
37
|
-
return new Intl.DateTimeFormat(locale).format(new Date(date));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export { localeCurrency as a, localeNumber as b, dateRegExp as d, localeDate as l };
|