@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.
Files changed (142) hide show
  1. package/dist/cjs/{index-c3450336.js → index-4dcc1812.js} +11 -1
  2. package/dist/cjs/loader.cjs.js +3 -3
  3. package/dist/cjs/mg-badge_30.cjs.entry.js +742 -244
  4. package/dist/cjs/mg-components.cjs.js +3 -3
  5. package/dist/collection/collection-manifest.json +4 -4
  6. package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
  7. package/dist/collection/components/atoms/mg-badge/mg-badge.css +13 -0
  8. package/dist/collection/components/atoms/mg-badge/mg-badge.js +3 -3
  9. package/dist/collection/components/atoms/mg-button/mg-button.css +2 -1
  10. package/dist/collection/components/atoms/mg-card/mg-card.css +13 -6
  11. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +13 -3
  12. package/dist/collection/components/atoms/mg-tag/mg-tag.css +6 -6
  13. package/dist/collection/components/atoms/mg-tag/mg-tag.js +3 -3
  14. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +2 -0
  15. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +3 -3
  16. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +3 -3
  17. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +4 -1
  18. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +3 -3
  19. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +3 -3
  20. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +3 -3
  21. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +7 -3
  22. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +3 -3
  23. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +3 -3
  24. package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +43 -11
  25. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +17 -0
  26. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +27 -0
  27. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +141 -18
  28. package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +5 -10
  29. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +0 -4
  30. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +47 -21
  31. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +118 -70
  32. package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +4 -3
  33. package/dist/collection/components/molecules/mg-message/mg-message.css +7 -0
  34. package/dist/collection/components/molecules/mg-message/mg-message.js +53 -12
  35. package/dist/collection/components/molecules/mg-modal/mg-modal.css +8 -1
  36. package/dist/collection/components/molecules/mg-panel/mg-panel.css +7 -0
  37. package/dist/collection/components/molecules/mg-popover/mg-popover.css +72 -14
  38. package/dist/collection/components/molecules/mg-popover/mg-popover.js +48 -4
  39. package/dist/collection/components/molecules/mg-skip-links/doc/mg-skip-links.stories.js +1 -1
  40. package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +32 -1
  41. package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +5 -3
  42. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +11 -7
  43. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +101 -54
  44. package/dist/collection/locales/en/messages.json +4 -0
  45. package/dist/collection/locales/fr/messages.json +4 -0
  46. package/dist/collection/locales/index.js +2 -25
  47. package/dist/collection/styles/a11y.scss +32 -0
  48. package/dist/collection/styles/components.scss +3 -0
  49. package/dist/collection/styles/fonts.scss +21 -0
  50. package/dist/collection/styles/form.scss +3 -0
  51. package/dist/collection/styles/global.scss +87 -0
  52. package/dist/collection/styles/layout.scss +29 -0
  53. package/dist/collection/styles/main.scss +23 -0
  54. package/dist/collection/styles/navigation-button.scss +76 -0
  55. package/dist/collection/styles/reset-mg-card-slotted-variables.scss +9 -0
  56. package/dist/collection/styles/typography.scss +75 -0
  57. package/dist/collection/styles/utilities.scss +21 -0
  58. package/dist/collection/utils/behaviors.utils.js +169 -0
  59. package/dist/collection/utils/components.utils.js +50 -0
  60. package/dist/collection/utils/locale.utils.js +22 -0
  61. package/dist/collection/utils/unit.test.utils.js +37 -32
  62. package/dist/collection/variables.css +9 -9
  63. package/dist/components/components.utils.js +51 -1
  64. package/dist/components/index2.js +65 -18
  65. package/dist/components/mg-badge2.js +4 -4
  66. package/dist/components/mg-button2.js +1 -1
  67. package/dist/components/mg-card2.js +1 -1
  68. package/dist/components/mg-icon2.js +13 -3
  69. package/dist/components/mg-illustrated-message.js +4 -3
  70. package/dist/components/mg-input-date.js +6 -4
  71. package/dist/components/mg-input-numeric.js +2 -3
  72. package/dist/components/mg-input-password.js +1 -1
  73. package/dist/components/mg-input-select2.js +8 -4
  74. package/dist/components/mg-input-text2.js +1 -1
  75. package/dist/components/mg-input-textarea.js +1 -1
  76. package/dist/components/mg-menu-item.js +1 -253
  77. package/dist/components/mg-menu-item2.js +517 -0
  78. package/dist/components/mg-menu.js +138 -21
  79. package/dist/components/mg-message.js +54 -13
  80. package/dist/components/mg-modal.js +1 -1
  81. package/dist/components/mg-panel.js +1 -1
  82. package/dist/components/mg-popover.js +1 -190
  83. package/dist/components/mg-popover2.js +212 -0
  84. package/dist/components/mg-skip-links.js +16 -2
  85. package/dist/components/mg-tabs.js +100 -52
  86. package/dist/components/mg-tag.js +4 -4
  87. package/dist/components/mg-tooltip2.js +4 -4
  88. package/dist/esm/{index-78edde1d.js → index-dc9a2348.js} +11 -1
  89. package/dist/esm/loader.js +3 -3
  90. package/dist/esm/mg-badge_30.entry.js +742 -244
  91. package/dist/esm/mg-components.js +3 -3
  92. package/dist/esm/polyfills/css-shim.js +1 -1
  93. package/dist/mg-components/locales/en/messages.json +4 -0
  94. package/dist/mg-components/locales/fr/messages.json +4 -0
  95. package/dist/mg-components/mg-components.css +1 -1
  96. package/dist/mg-components/mg-components.esm.js +1 -1
  97. package/dist/mg-components/{p-125c54ca.js → p-182bd802.js} +2 -2
  98. package/dist/mg-components/p-f7da9dd2.entry.js +1 -0
  99. package/dist/mg-components/styles/a11y.scss +32 -0
  100. package/dist/mg-components/styles/components.scss +3 -0
  101. package/dist/mg-components/styles/fonts.scss +21 -0
  102. package/dist/mg-components/styles/form.scss +3 -0
  103. package/dist/mg-components/styles/global.scss +87 -0
  104. package/dist/mg-components/styles/layout.scss +29 -0
  105. package/dist/mg-components/styles/main.scss +23 -0
  106. package/dist/mg-components/styles/navigation-button.scss +76 -0
  107. package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +9 -0
  108. package/dist/mg-components/styles/typography.scss +75 -0
  109. package/dist/mg-components/styles/utilities.scss +21 -0
  110. package/dist/mg-components/variables.css +9 -9
  111. package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +2 -2
  112. package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +2 -2
  113. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +2 -2
  114. package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +1 -1
  115. package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -2
  116. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +2 -2
  117. package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
  118. package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
  119. package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
  120. package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +5 -0
  121. package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +37 -0
  122. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +51 -3
  123. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +0 -8
  124. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +55 -15
  125. package/dist/types/components/molecules/mg-message/mg-message.d.ts +21 -4
  126. package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +12 -0
  127. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.conf.d.ts +1 -1
  128. package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +15 -0
  129. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +5 -3
  130. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +22 -12
  131. package/dist/types/components.d.ts +44 -12
  132. package/dist/types/locales/index.d.ts +10 -9
  133. package/dist/types/stencil-public-runtime.d.ts +39 -3
  134. package/dist/types/utils/behaviors.utils.d.ts +83 -0
  135. package/dist/types/utils/components.utils.d.ts +14 -0
  136. package/dist/types/utils/locale.utils.d.ts +13 -0
  137. package/dist/types/utils/unit.test.utils.d.ts +50 -14
  138. package/package.json +26 -26
  139. package/readme.md +22 -13
  140. package/dist/components/locale.utils.js +0 -40
  141. package/dist/components/mg-menu.conf.js +0 -10
  142. 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 declare type ListenTargetOptions = 'body' | 'document' | 'window';
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 declare type ResolutionHandler = (elm: HTMLElement) => string | undefined | null;
218
- export declare type ErrorHandler = (err: any, element?: HTMLElement) => void;
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 resize observer, but its methods.
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 fnuction
17
- * @param {Function} mutationObserverMock.takeRecords takeRecords fnuction
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
- export declare const setupMutationObserverMock: ({ disconnect, observe, takeRecords }: {
32
- disconnect: any;
33
- observe: any;
34
- takeRecords: any;
35
- }) => {
36
- new (fn: any): {
37
- disconnect: () => void;
38
- observe: (target: Node, options?: MutationObserverInit) => void;
39
- takeRecords: () => MutationRecord[];
40
- cb: () => unknown;
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.5.0",
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.2",
32
- "@stencil/core": "^2.20.0",
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.5",
37
- "@babel/plugin-transform-react-jsx": "^7.14.9",
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.14",
42
- "@storybook/addon-actions": "^6.5.14",
43
- "@storybook/addon-docs": "^6.5.14",
44
- "@storybook/addon-essentials": "^6.5.14",
45
- "@storybook/addon-links": "^6.5.14",
46
- "@storybook/html": "^6.5.14",
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.1",
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.2.2",
52
+ "babel-loader": "^8.3.0",
53
53
  "babel-plugin-jsx-pragmatic": "^1.0.2",
54
- "chromatic": "^6.10.1",
54
+ "chromatic": "^6.14.0",
55
55
  "css-loader": "^5.2.7",
56
56
  "eslint": "^7.32.0",
57
- "eslint-plugin-jsdoc": "^38.0.6",
58
- "eslint-plugin-jsx-a11y": "^6.6.1",
59
- "eslint-plugin-react": "^7.26.1",
60
- "eslint-plugin-storybook": "^0.6.8",
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.0.0",
66
- "jsx-dom": "^8.0.1-beta.1",
65
+ "jest-junit": "^13.2.0",
66
+ "jsx-dom": "^8.0.3",
67
67
  "npm-run-all": "^4.1.5",
68
- "prettier": "^2.5.1",
69
- "puppeteer": "^13.3.2",
70
- "sass": "^1.41.0",
71
- "sass-loader": "^10.2.0",
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.7.0",
74
- "turbo": "^1.6.3",
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
- npm run start
23
+ pnpm start
24
24
  ```
25
25
 
26
26
  To build for production, run:
27
27
 
28
28
  ```bash
29
- npm run build
29
+ pnpm build
30
30
  ```
31
31
 
32
32
  To run tests for the components, run:
33
33
 
34
34
  ```bash
35
- npm run test
35
+ pnpm test
36
36
 
37
37
  # only unit tests
38
- npm run test:unit
38
+ pnpm test:unit
39
39
 
40
40
  # only e2e tests
41
- npm run test:e2e
41
+ pnpm test:e2e
42
42
 
43
43
  # filter on filename
44
- npm run test -- mg-icon
45
- npm run test:unit -- mg-icon
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
- npm run generate component-path
57
+ pnpm generate component-path
56
58
 
57
59
  # example for an atom
58
- npm run generate atoms/mg-icon
60
+ pnpm generate atoms/mg-icon
59
61
 
60
62
  # example for a molecule
61
- npm run generate molecules/mg-message
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
- npm run storybook
131
+ pnpm storybook
130
132
  ```
131
133
 
132
134
  ### Notes
133
135
 
134
- - camelCase arguments must be written in the template, for exemple labelOnTop must be placed in the template as label-on-top={args.labelOnTop}
135
- - Boolean arguments with a default true value must be added like display-character-left={args.displayCharacterLeft ? 'true' : 'false'}
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 };
@@ -1,10 +0,0 @@
1
- /**
2
- * Menu direction type
3
- */
4
- var Direction;
5
- (function (Direction) {
6
- Direction["VERTICAL"] = "vertical";
7
- Direction["HORIZONTAL"] = "horizontal";
8
- })(Direction || (Direction = {}));
9
-
10
- export { Direction as D };