@mgdis/mg-components 5.2.0 → 5.4.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 (90) hide show
  1. package/dist/cjs/loader.cjs.js +1 -1
  2. package/dist/cjs/{mg-badge_27.cjs.entry.js → mg-badge_29.cjs.entry.js} +496 -79
  3. package/dist/cjs/mg-components.cjs.js +1 -1
  4. package/dist/collection/collection-manifest.json +3 -1
  5. package/dist/collection/components/atoms/mg-badge/mg-badge.css +6 -0
  6. package/dist/collection/components/atoms/mg-badge/mg-badge.js +14 -19
  7. package/dist/collection/components/atoms/mg-button/mg-button.css +6 -1
  8. package/dist/collection/components/atoms/mg-button/mg-button.js +1 -1
  9. package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +20 -4
  10. package/dist/collection/components/atoms/mg-icon/mg-icon.css +27 -0
  11. package/dist/collection/components/atoms/mg-icon/mg-icon.js +19 -7
  12. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +94 -52
  13. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +7 -0
  14. package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +7 -0
  15. package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +6 -0
  16. package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +7 -0
  17. package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +7 -0
  18. package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +6 -0
  19. package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +6 -0
  20. package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +6 -0
  21. package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +6 -0
  22. package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +87 -0
  23. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +8 -0
  24. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +10 -0
  25. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +173 -0
  26. package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +32 -0
  27. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +22 -0
  28. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +343 -0
  29. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +320 -0
  30. package/dist/collection/components/molecules/mg-details/mg-details.css +6 -0
  31. package/dist/collection/components/molecules/mg-form/mg-form.js +1 -1
  32. package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +6 -0
  33. package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +3 -0
  34. package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +67 -17
  35. package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +10 -4
  36. package/dist/collection/locales/index.js +3 -1
  37. package/dist/collection/variables.css +23 -1
  38. package/dist/components/index.d.ts +2 -0
  39. package/dist/components/index.js +2 -0
  40. package/dist/components/index2.js +3 -1
  41. package/dist/components/mg-badge2.js +2 -2
  42. package/dist/components/mg-button2.js +2 -2
  43. package/dist/components/mg-details.js +1 -1
  44. package/dist/components/mg-form.js +1 -1
  45. package/dist/components/mg-icon2.js +23 -5
  46. package/dist/components/mg-input-checkbox.js +1 -1
  47. package/dist/components/mg-input-date.js +1 -1
  48. package/dist/components/mg-input-numeric.js +1 -1
  49. package/dist/components/mg-input-password.js +1 -1
  50. package/dist/components/mg-input-radio.js +1 -1
  51. package/dist/components/mg-input-select2.js +1 -1
  52. package/dist/components/mg-input-text2.js +1 -1
  53. package/dist/components/mg-input-textarea.js +1 -1
  54. package/dist/components/mg-input-toggle.js +1 -1
  55. package/dist/components/mg-menu-item.d.ts +11 -0
  56. package/dist/components/mg-menu-item.js +269 -0
  57. package/dist/components/mg-menu.conf.js +10 -0
  58. package/dist/components/mg-menu.d.ts +11 -0
  59. package/dist/components/mg-menu.js +137 -0
  60. package/dist/components/mg-pagination.js +1 -1
  61. package/dist/components/mg-tabs.js +6 -2
  62. package/dist/components/mg-tooltip2.js +94 -52
  63. package/dist/esm/loader.js +1 -1
  64. package/dist/esm/{mg-badge_27.entry.js → mg-badge_29.entry.js} +495 -80
  65. package/dist/esm/mg-components.js +1 -1
  66. package/dist/mg-components/mg-components.css +1 -1
  67. package/dist/mg-components/mg-components.esm.js +1 -1
  68. package/dist/mg-components/p-059a9a59.entry.js +1 -0
  69. package/dist/mg-components/variables.css +23 -1
  70. package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +2 -2
  71. package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +5 -5
  72. package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +8 -8
  73. package/dist/types/components/atoms/mg-icon/doc/mg-icon.stories.d.ts +2 -2
  74. package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +10 -2
  75. package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +7 -6
  76. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +15 -0
  77. package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +17 -0
  78. package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +7 -0
  79. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +64 -0
  80. package/dist/types/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.d.ts +11 -0
  81. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +24 -0
  82. package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +115 -0
  83. package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +1 -1
  84. package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +12 -4
  85. package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +6 -6
  86. package/dist/types/components.d.ts +91 -14
  87. package/dist/types/locales/index.d.ts +7 -1
  88. package/dist/types/stories/icons.stories.d.ts +1 -1
  89. package/package.json +2 -2
  90. package/dist/mg-components/p-b2b07c3f.entry.js +0 -1
@@ -253,6 +253,12 @@
253
253
  outline: none;
254
254
  }
255
255
 
256
+ @media (prefers-reduced-motion) {
257
+ .mg-a11y-animation {
258
+ animation: none !important;
259
+ transition: none !important;
260
+ }
261
+ }
256
262
  /* Component Custom Style */
257
263
  .mg-input .mg-input__box {
258
264
  display: block;
@@ -118,6 +118,12 @@
118
118
  outline: none;
119
119
  }
120
120
 
121
+ @media (prefers-reduced-motion) {
122
+ .mg-a11y-animation {
123
+ animation: none !important;
124
+ transition: none !important;
125
+ }
126
+ }
121
127
  /**
122
128
  * Toogle
123
129
  */
@@ -0,0 +1,87 @@
1
+ import { h } from '@stencil/core';
2
+ import { filterArgs } from '../../../../../../.storybook/utils';
3
+ import { Status } from '../../mg-menu-item/mg-menu-item.conf';
4
+ import { Direction } from '../mg-menu.conf';
5
+ export default {
6
+ component: 'mg-menu',
7
+ title: 'Beta/menus/mg-menu',
8
+ argTypes: {
9
+ direction: {
10
+ options: [undefined, Direction.HORIZONTAL, Direction.VERTICAL],
11
+ control: { type: 'select' },
12
+ },
13
+ },
14
+ };
15
+ const getItemArgs = ({ size, label, direction, status, metadata, icon, badge, content, submenu }) => ({
16
+ size: size !== undefined ? size : direction === Direction.VERTICAL ? 'medium' : undefined,
17
+ status,
18
+ slot: {
19
+ label,
20
+ metadata,
21
+ icon,
22
+ badge,
23
+ content,
24
+ submenu,
25
+ },
26
+ });
27
+ const getMenuArgs = (direction, level = 0, isSubmenu = false) => ({
28
+ label: 'Batman menu',
29
+ direction,
30
+ slot: {
31
+ items: [
32
+ getItemArgs({
33
+ label: 'label 1',
34
+ direction,
35
+ }),
36
+ getItemArgs({
37
+ label: 'label 2',
38
+ direction,
39
+ status: Status.DISABLED,
40
+ }),
41
+ getItemArgs({
42
+ label: 'label 3 with long text',
43
+ direction,
44
+ badge: true,
45
+ icon: true,
46
+ }),
47
+ getItemArgs({
48
+ label: 'label 4',
49
+ direction,
50
+ badge: true,
51
+ icon: true,
52
+ status: Status.ACTIVE,
53
+ submenu: level,
54
+ }),
55
+ getItemArgs({
56
+ label: 'label 5',
57
+ direction,
58
+ icon: true,
59
+ metadata: 'my metadata',
60
+ content: true,
61
+ size: !isSubmenu && direction === Direction.HORIZONTAL ? 'regular' : undefined,
62
+ }),
63
+ ],
64
+ },
65
+ });
66
+ const menu = args => h("mg-menu", Object.assign({}, filterArgs(args, { direction: Direction.HORIZONTAL })), args.slot.items.map(item => menuItem(item)));
67
+ const menuItem = args => {
68
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
69
+ return (h("mg-menu-item", Object.assign({}, filterArgs(args)), ((_a = args.slot) === null || _a === void 0 ? void 0 : _a.label) && h("span", { slot: "label" }, (_b = args.slot) === null || _b === void 0 ? void 0 : _b.label), ((_c = args.slot) === null || _c === void 0 ? void 0 : _c.metadata) && h("span", { slot: "metadata" }, (_d = args.slot) === null || _d === void 0 ? void 0 : _d.metadata), ((_e = args.slot) === null || _e === void 0 ? void 0 : _e.icon) && h("mg-icon", { slot: "illustration", icon: "user" }), ((_f = args.slot) === null || _f === void 0 ? void 0 : _f.badge) && (h("mg-badge", { slot: "information", label: "information", value: "1" }, (_g = args.slot) === null || _g === void 0 ? void 0 : _g.icon)), ((_h = args.slot) === null || _h === void 0 ? void 0 : _h.content) && (h("div", null, h("h3", null, "Demo title"), h("p", null, "some content"))), ((_j = args.slot) === null || _j === void 0 ? void 0 : _j.submenu) && menu(getMenuArgs(Direction.VERTICAL, ((_k = args.slot) === null || _k === void 0 ? void 0 : _k.submenu) - 1, true))));
70
+ };
71
+ /**
72
+ * Template
73
+ *
74
+ * @param {any} args component arguments
75
+ * @returns {HTMLElement} HTMLElement
76
+ */
77
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
78
+ const Template = (args) => h("div", null, menu(args));
79
+ export const MgMenuHorizontal = Template.bind({});
80
+ MgMenuHorizontal.args = getMenuArgs(Direction.HORIZONTAL, 2);
81
+ export const MgMenuVertical = Template.bind({});
82
+ MgMenuVertical.args = getMenuArgs(Direction.VERTICAL, 2);
83
+ const TemplateSmallContainer = (args) => {
84
+ return h("div", { style: { width: '25rem', height: '20rem' } }, menu(args));
85
+ };
86
+ export const MgMenuVerticalSmallContainer = TemplateSmallContainer.bind({});
87
+ MgMenuVerticalSmallContainer.args = Object.assign({}, MgMenuVertical.args);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Menu direction type
3
+ */
4
+ export var Direction;
5
+ (function (Direction) {
6
+ Direction["VERTICAL"] = "vertical";
7
+ Direction["HORIZONTAL"] = "horizontal";
8
+ })(Direction || (Direction = {}));
@@ -0,0 +1,10 @@
1
+ :host {
2
+ display: flex;
3
+ background-color: hsl(var(--mg-menu-background-color-hsl, var(--color-light)));
4
+ }
5
+
6
+ :host([direction=vertical]) {
7
+ flex-direction: column;
8
+ height: 100%;
9
+ overflow-y: auto;
10
+ }
@@ -0,0 +1,173 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import { Direction } from './mg-menu.conf';
3
+ export class MgMenu {
4
+ constructor() {
5
+ /************
6
+ * Internal *
7
+ ************/
8
+ this.name = 'mg-menu';
9
+ this.focusedMenuItem = 0;
10
+ /**
11
+ * Component display direction. Default: "horizontal"
12
+ */
13
+ this.direction = Direction.HORIZONTAL;
14
+ /**
15
+ * Close matching menu-item
16
+ *
17
+ * @param {HTMLMgMenuItemElement} item menu-item to close
18
+ * @param {boolean} condition addionnal condition
19
+ * @returns {void}
20
+ */
21
+ this.closeMenuItem = (item, condition) => {
22
+ if (!this.isChildMenu && condition) {
23
+ item.expanded = false;
24
+ }
25
+ };
26
+ /**
27
+ * Store menu-items on component init and add listeners
28
+ */
29
+ this.initMenuItems = () => {
30
+ // store all menu-items
31
+ this.menuItems = Array.from(this.element.children).filter(child => child.nodeName === 'MG-MENU-ITEM');
32
+ // add listeners on menu item and edit index
33
+ this.menuItems.forEach((item, menuItemIndex) => {
34
+ ['click', 'focus'].forEach(trigger => {
35
+ (item.shadowRoot.querySelector('button') || item.shadowRoot.querySelector('a')).addEventListener(trigger, (event) => {
36
+ event.preventDefault();
37
+ event.stopPropagation();
38
+ this.focusedMenuItem = menuItemIndex;
39
+ // reset expanded on previous active menu item
40
+ this.menuItems.forEach((item, index) => {
41
+ this.closeMenuItem(item, index !== this.focusedMenuItem);
42
+ });
43
+ });
44
+ });
45
+ });
46
+ };
47
+ }
48
+ validateLabel(newValue) {
49
+ if (newValue === undefined) {
50
+ throw new Error(`<${this.name}> prop "label" is required.`);
51
+ }
52
+ }
53
+ validateDirection(newValue) {
54
+ if (![Direction.VERTICAL, Direction.HORIZONTAL].includes(newValue)) {
55
+ throw new Error(`<${this.name}> prop "direction" must be one of : ${Direction.HORIZONTAL}, ${Direction.VERTICAL}.`);
56
+ }
57
+ }
58
+ /*************
59
+ * Lifecycle *
60
+ *************/
61
+ /**
62
+ * Validate props
63
+ *
64
+ * @returns {void}
65
+ */
66
+ componentWillLoad() {
67
+ this.validateDirection(this.direction);
68
+ this.validateLabel(this.label);
69
+ }
70
+ /**
71
+ * Check if component slots configuration
72
+ *
73
+ * @returns {ReturnType<typeof setTimeout>} timeout
74
+ */
75
+ componentDidLoad() {
76
+ // update props and states after componentDidLoad hook
77
+ // return a promise to process action only in the FIRST render().
78
+ // https://stenciljs.com/docs/component-lifecycle#componentwillload
79
+ return setTimeout(() => {
80
+ this.initMenuItems();
81
+ this.isChildMenu = this.element.closest('mg-menu-item') !== null;
82
+ // click outside management for child vertical menu
83
+ if (!this.isChildMenu && this.direction === Direction.HORIZONTAL) {
84
+ document.addEventListener('click', (event) => {
85
+ if (event.target.closest('mg-menu') === null) {
86
+ this.menuItems.forEach(item => {
87
+ this.closeMenuItem(item, this.direction === Direction.HORIZONTAL);
88
+ });
89
+ }
90
+ });
91
+ }
92
+ }, 0);
93
+ }
94
+ /**
95
+ * Render
96
+ *
97
+ * @returns {HTMLElement} HTML Element
98
+ */
99
+ render() {
100
+ return (h(Host, { role: this.isChildMenu ? 'menu' : 'menubar', "aria-label": this.label }, h("slot", null)));
101
+ }
102
+ static get is() { return "mg-menu"; }
103
+ static get encapsulation() { return "shadow"; }
104
+ static get originalStyleUrls() {
105
+ return {
106
+ "$": ["mg-menu.scss"]
107
+ };
108
+ }
109
+ static get styleUrls() {
110
+ return {
111
+ "$": ["mg-menu.css"]
112
+ };
113
+ }
114
+ static get properties() {
115
+ return {
116
+ "label": {
117
+ "type": "string",
118
+ "mutable": false,
119
+ "complexType": {
120
+ "original": "string",
121
+ "resolved": "string",
122
+ "references": {}
123
+ },
124
+ "required": true,
125
+ "optional": false,
126
+ "docs": {
127
+ "tags": [],
128
+ "text": "Menu label. Include short menu description.\nRequired for accessibility"
129
+ },
130
+ "attribute": "label",
131
+ "reflect": false
132
+ },
133
+ "direction": {
134
+ "type": "string",
135
+ "mutable": false,
136
+ "complexType": {
137
+ "original": "Direction",
138
+ "resolved": "Direction.HORIZONTAL | Direction.VERTICAL",
139
+ "references": {
140
+ "Direction": {
141
+ "location": "import",
142
+ "path": "./mg-menu.conf"
143
+ }
144
+ }
145
+ },
146
+ "required": false,
147
+ "optional": false,
148
+ "docs": {
149
+ "tags": [],
150
+ "text": "Component display direction. Default: \"horizontal\""
151
+ },
152
+ "attribute": "direction",
153
+ "reflect": true,
154
+ "defaultValue": "Direction.HORIZONTAL"
155
+ }
156
+ };
157
+ }
158
+ static get states() {
159
+ return {
160
+ "isChildMenu": {}
161
+ };
162
+ }
163
+ static get elementRef() { return "element"; }
164
+ static get watchers() {
165
+ return [{
166
+ "propName": "label",
167
+ "methodName": "validateLabel"
168
+ }, {
169
+ "propName": "direction",
170
+ "methodName": "validateDirection"
171
+ }];
172
+ }
173
+ }
@@ -0,0 +1,32 @@
1
+ import { h } from '@stencil/core';
2
+ import { filterArgs } from '../../../../../../.storybook/utils';
3
+ export default {
4
+ component: 'mg-menu-item',
5
+ title: 'Beta/menus/mg-menu-item',
6
+ };
7
+ /**
8
+ * Template
9
+ *
10
+ * @param {any} args component arguments
11
+ * @returns {HTMLElement} HTMLElement
12
+ */
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ const Template = (args) => h("mg-menu-item", Object.assign({}, filterArgs(args)), args.slot);
15
+ export const MgMenuItem = Template.bind({});
16
+ MgMenuItem.args = {
17
+ identifier: 'identifier',
18
+ slot: h("span", { slot: "label" }, "My label"),
19
+ };
20
+ export const MgMenuItemWhitIcon = Template.bind({});
21
+ MgMenuItemWhitIcon.args = Object.assign(Object.assign({}, MgMenuItem.args), { slot: [h("span", { slot: "label" }, "My label"), h("mg-icon", { icon: "user", slot: "illustration" })] });
22
+ export const MgMenuItemWhitBadge = Template.bind({});
23
+ MgMenuItemWhitBadge.args = Object.assign(Object.assign({}, MgMenuItem.args), { slot: [h("span", { slot: "label" }, "My label"), h("mg-badge", { value: "2", label: "hello", slot: "information" })] });
24
+ export const MgMenuItemWhitBadgeAndIcon = Template.bind({});
25
+ MgMenuItemWhitBadgeAndIcon.args = Object.assign(Object.assign({}, MgMenuItem.args), { slot: [h("span", { slot: "label" }, "My label"), h("mg-badge", { value: "2", label: "hello", slot: "information" }), h("mg-icon", { icon: "user", slot: "illustration" })] });
26
+ export const MgMenuItemWhitMetadata = Template.bind({});
27
+ MgMenuItemWhitMetadata.args = Object.assign(Object.assign({}, MgMenuItem.args), { slot: [h("span", { slot: "label" }, "My label"), h("span", { slot: "metadata" }, "My metadata")] });
28
+ export const MgMenuItemWhithSubmenu = Template.bind({});
29
+ MgMenuItemWhithSubmenu.args = Object.assign(Object.assign({}, MgMenuItem.args), { slot: [
30
+ h("span", { slot: "label" }, "My label"),
31
+ h("mg-menu-vertical", { label: "submenu" }, h("mg-menu-item", null, h("span", { slot: "label" }, "Subitem 1")), h("mg-menu-item", null, h("mg-icon", { icon: "user", slot: "illustration" }), h("span", { slot: "label" }, "Subitem 2")), h("mg-menu-item", null, h("span", { slot: "label" }, "Subitem 3"), h("mg-icon", { icon: "user", slot: "illustration" }), h("mg-badge", { value: "2", label: "hello", slot: "information" }))),
32
+ ] });
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Available menu-item positions
3
+ */
4
+ export var ElementPosition;
5
+ (function (ElementPosition) {
6
+ ElementPosition["FIRST"] = "first";
7
+ ElementPosition["LAST"] = "last";
8
+ })(ElementPosition || (ElementPosition = {}));
9
+ /**
10
+ * Available menu item status
11
+ */
12
+ export var Status;
13
+ (function (Status) {
14
+ Status["VISIBLE"] = "visible";
15
+ Status["HIDDEN"] = "hidden";
16
+ Status["DISABLED"] = "disabled";
17
+ Status["ACTIVE"] = "active";
18
+ })(Status || (Status = {}));
19
+ /**
20
+ * List of all possibles sizes
21
+ */
22
+ export const sizes = ['regular', 'medium', 'large'];