@mgdis/mg-components 5.0.0 → 5.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/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{mg-badge_24.cjs.entry.js → mg-badge_27.cjs.entry.js} +543 -64
- package/dist/cjs/mg-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +1 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +8 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +39 -1
- package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +18 -0
- package/dist/collection/components/atoms/mg-card/mg-card.css +7 -0
- package/dist/collection/components/atoms/mg-card/mg-card.js +26 -0
- package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +18 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.css +9 -0
- package/dist/collection/components/atoms/mg-divider/mg-divider.js +57 -0
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -5
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.conf.js +0 -20
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +1 -1
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +2 -1
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +1 -0
- package/dist/collection/components/molecules/mg-details/mg-details.css +29 -0
- package/dist/collection/components/molecules/mg-details/mg-details.js +26 -4
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +2 -1
- package/dist/collection/components/molecules/mg-modal/mg-modal.js +52 -4
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +5 -14
- package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -5
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +1 -1
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +3 -2
- package/dist/collection/utils/components.utils.js +10 -6
- package/dist/collection/variables.css +17 -2
- package/dist/components/components.utils.js +11 -7
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/mg-button2.js +21 -2
- package/dist/components/mg-card.d.ts +11 -0
- package/dist/components/mg-card.js +42 -0
- package/dist/components/mg-details.js +8 -3
- package/dist/components/mg-divider.d.ts +11 -0
- package/dist/components/mg-divider.js +51 -0
- package/dist/components/mg-modal.js +53 -5
- package/dist/components/mg-panel.js +1 -1
- package/dist/components/mg-popover.js +3 -2
- package/dist/components/mg-tooltip2.js +2 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mg-badge_24.entry.js → mg-badge_27.entry.js} +490 -14
- package/dist/esm/mg-components.js +1 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-e131701a.entry.js +1 -0
- package/dist/mg-components/variables.css +17 -2
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +6 -0
- package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-card/mg-card.d.ts +11 -0
- package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-divider/mg-divider.d.ts +15 -0
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.conf.d.ts +0 -8
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +1 -1
- package/dist/types/components/molecules/mg-details/mg-details.d.ts +4 -0
- package/dist/types/components/molecules/mg-modal/mg-modal.d.ts +8 -0
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +1 -1
- package/dist/types/components.d.ts +55 -6
- package/dist/types/utils/components.utils.d.ts +7 -3
- package/package.json +4 -3
- package/dist/cjs/index-179621c8.js +0 -244
- package/dist/cjs/mg-modal.cjs.entry.js +0 -128
- package/dist/collection/components/molecules/mg-popover/mg-popover.conf.js +0 -20
- package/dist/esm/index-7efedd97.js +0 -238
- package/dist/esm/mg-modal.entry.js +0 -124
- package/dist/mg-components/p-5f89600c.js +0 -1
- package/dist/mg-components/p-b60a4c53.entry.js +0 -1
- package/dist/mg-components/p-df947fa5.entry.js +0 -1
- package/dist/types/components/molecules/mg-popover/mg-popover.conf.d.ts +0 -8
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class MgDivider {
|
|
2
|
+
/**************
|
|
3
|
+
* Decorators *
|
|
4
|
+
**************/
|
|
5
|
+
/**
|
|
6
|
+
* Define component size
|
|
7
|
+
*/
|
|
8
|
+
size: 'regular' | 'full';
|
|
9
|
+
/**
|
|
10
|
+
* Render
|
|
11
|
+
*
|
|
12
|
+
* @returns {HTMLElement} HTML Element
|
|
13
|
+
*/
|
|
14
|
+
render(): HTMLElement;
|
|
15
|
+
}
|
|
@@ -6,15 +6,9 @@ declare const _default: {
|
|
|
6
6
|
};
|
|
7
7
|
argTypes: {
|
|
8
8
|
placement: {
|
|
9
|
-
options: readonly ["auto", "auto-start", "auto-end", "top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "right", "right-start", "right-end", "left", "left-start", "left-end"];
|
|
10
9
|
control: {
|
|
11
10
|
type: string;
|
|
12
11
|
};
|
|
13
|
-
table: {
|
|
14
|
-
defaultValue: {
|
|
15
|
-
summary: string;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
12
|
};
|
|
19
13
|
};
|
|
20
14
|
};
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* List of all possibles placements
|
|
3
|
-
*/
|
|
4
|
-
export declare const placements: readonly ["auto", "auto-start", "auto-end", "top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "right", "right-start", "right-end", "left", "left-start", "left-end"];
|
|
5
|
-
/**
|
|
6
|
-
* Placement type from placements
|
|
7
|
-
*/
|
|
8
|
-
export declare type Placement = typeof placements[number];
|
|
9
1
|
export declare enum Guard {
|
|
10
2
|
FOCUS = "focus",
|
|
11
3
|
HOVER_TOOLTIP_ELEMENT = "hoverTooltipGuard",
|
|
@@ -4,6 +4,7 @@ export declare class MgModal {
|
|
|
4
4
|
/************
|
|
5
5
|
* Internal *
|
|
6
6
|
************/
|
|
7
|
+
private modalFocusableElements;
|
|
7
8
|
private classHide;
|
|
8
9
|
private closeButtonId;
|
|
9
10
|
private titleId;
|
|
@@ -60,6 +61,7 @@ export declare class MgModal {
|
|
|
60
61
|
* @returns {void}
|
|
61
62
|
*/
|
|
62
63
|
handleKeyDown(event: KeyboardEvent): void;
|
|
64
|
+
private setFocus;
|
|
63
65
|
/*************
|
|
64
66
|
* Handlers *
|
|
65
67
|
*************/
|
|
@@ -78,6 +80,12 @@ export declare class MgModal {
|
|
|
78
80
|
* @returns {void}
|
|
79
81
|
*/
|
|
80
82
|
componentWillLoad(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Add observer on component to set focus when displayed
|
|
85
|
+
*
|
|
86
|
+
* @returns {void}
|
|
87
|
+
*/
|
|
88
|
+
componentDidLoad(): void;
|
|
81
89
|
/**
|
|
82
90
|
* Render
|
|
83
91
|
*
|
|
@@ -12,15 +12,9 @@ declare const _default: {
|
|
|
12
12
|
};
|
|
13
13
|
argTypes: {
|
|
14
14
|
placement: {
|
|
15
|
-
options: readonly ["auto", "auto-start", "auto-end", "top", "top-start", "top-end", "bottom", "bottom-start", "bottom-end", "right", "right-start", "right-end", "left", "left-start", "left-end"];
|
|
16
15
|
control: {
|
|
17
16
|
type: string;
|
|
18
17
|
};
|
|
19
|
-
table: {
|
|
20
|
-
defaultValue: {
|
|
21
|
-
summary: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
18
|
};
|
|
25
19
|
};
|
|
26
20
|
};
|
|
@@ -12,9 +12,8 @@ import { Width } from "./components/molecules/inputs/MgInput.conf";
|
|
|
12
12
|
import { RadioOption } from "./components/molecules/inputs/mg-input-radio/mg-input-radio.conf";
|
|
13
13
|
import { SelectOption } from "./components/molecules/inputs/mg-input-select/mg-input-select.conf";
|
|
14
14
|
import { ToggleValue } from "./components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf";
|
|
15
|
-
import { Placement } from "
|
|
15
|
+
import { Placement } from "@popperjs/core";
|
|
16
16
|
import { TabItem } from "./components/molecules/mg-tabs/mg-tabs.conf";
|
|
17
|
-
import { Placement as Placement1 } from "./components/atoms/mg-tooltip/mg-tooltip.conf";
|
|
18
17
|
export namespace Components {
|
|
19
18
|
interface MgBadge {
|
|
20
19
|
/**
|
|
@@ -47,6 +46,10 @@ export namespace Components {
|
|
|
47
46
|
* Define form id to attach button with. If this attribute is not set, the <button> is associated with its ancestor <form> element.
|
|
48
47
|
*/
|
|
49
48
|
"form": string;
|
|
49
|
+
/**
|
|
50
|
+
* Set button to full-width
|
|
51
|
+
*/
|
|
52
|
+
"fullWidth": boolean;
|
|
50
53
|
/**
|
|
51
54
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
52
55
|
*/
|
|
@@ -68,6 +71,8 @@ export namespace Components {
|
|
|
68
71
|
*/
|
|
69
72
|
"variant": VariantType;
|
|
70
73
|
}
|
|
74
|
+
interface MgCard {
|
|
75
|
+
}
|
|
71
76
|
interface MgCharacterLeft {
|
|
72
77
|
/**
|
|
73
78
|
* Sets the characters to count
|
|
@@ -87,6 +92,10 @@ export namespace Components {
|
|
|
87
92
|
* Define if details are diplayed
|
|
88
93
|
*/
|
|
89
94
|
"expanded": boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Hide summary element
|
|
97
|
+
*/
|
|
98
|
+
"hideSummary": boolean;
|
|
90
99
|
/**
|
|
91
100
|
* Displayed title when details are closed
|
|
92
101
|
*/
|
|
@@ -96,6 +105,12 @@ export namespace Components {
|
|
|
96
105
|
*/
|
|
97
106
|
"toggleOpened": string;
|
|
98
107
|
}
|
|
108
|
+
interface MgDivider {
|
|
109
|
+
/**
|
|
110
|
+
* Define component size
|
|
111
|
+
*/
|
|
112
|
+
"size": 'regular' | 'full';
|
|
113
|
+
}
|
|
99
114
|
interface MgForm {
|
|
100
115
|
/**
|
|
101
116
|
* Define if form is disabled
|
|
@@ -1007,7 +1022,7 @@ export namespace Components {
|
|
|
1007
1022
|
/**
|
|
1008
1023
|
* Tooltip placement
|
|
1009
1024
|
*/
|
|
1010
|
-
"placement":
|
|
1025
|
+
"placement": Placement;
|
|
1011
1026
|
}
|
|
1012
1027
|
}
|
|
1013
1028
|
export interface MgDetailsCustomEvent<T> extends CustomEvent<T> {
|
|
@@ -1091,6 +1106,12 @@ declare global {
|
|
|
1091
1106
|
prototype: HTMLMgButtonElement;
|
|
1092
1107
|
new (): HTMLMgButtonElement;
|
|
1093
1108
|
};
|
|
1109
|
+
interface HTMLMgCardElement extends Components.MgCard, HTMLStencilElement {
|
|
1110
|
+
}
|
|
1111
|
+
var HTMLMgCardElement: {
|
|
1112
|
+
prototype: HTMLMgCardElement;
|
|
1113
|
+
new (): HTMLMgCardElement;
|
|
1114
|
+
};
|
|
1094
1115
|
interface HTMLMgCharacterLeftElement extends Components.MgCharacterLeft, HTMLStencilElement {
|
|
1095
1116
|
}
|
|
1096
1117
|
var HTMLMgCharacterLeftElement: {
|
|
@@ -1103,6 +1124,12 @@ declare global {
|
|
|
1103
1124
|
prototype: HTMLMgDetailsElement;
|
|
1104
1125
|
new (): HTMLMgDetailsElement;
|
|
1105
1126
|
};
|
|
1127
|
+
interface HTMLMgDividerElement extends Components.MgDivider, HTMLStencilElement {
|
|
1128
|
+
}
|
|
1129
|
+
var HTMLMgDividerElement: {
|
|
1130
|
+
prototype: HTMLMgDividerElement;
|
|
1131
|
+
new (): HTMLMgDividerElement;
|
|
1132
|
+
};
|
|
1106
1133
|
interface HTMLMgFormElement extends Components.MgForm, HTMLStencilElement {
|
|
1107
1134
|
}
|
|
1108
1135
|
var HTMLMgFormElement: {
|
|
@@ -1232,8 +1259,10 @@ declare global {
|
|
|
1232
1259
|
interface HTMLElementTagNameMap {
|
|
1233
1260
|
"mg-badge": HTMLMgBadgeElement;
|
|
1234
1261
|
"mg-button": HTMLMgButtonElement;
|
|
1262
|
+
"mg-card": HTMLMgCardElement;
|
|
1235
1263
|
"mg-character-left": HTMLMgCharacterLeftElement;
|
|
1236
1264
|
"mg-details": HTMLMgDetailsElement;
|
|
1265
|
+
"mg-divider": HTMLMgDividerElement;
|
|
1237
1266
|
"mg-form": HTMLMgFormElement;
|
|
1238
1267
|
"mg-icon": HTMLMgIconElement;
|
|
1239
1268
|
"mg-illustrated-message": HTMLMgIllustratedMessageElement;
|
|
@@ -1289,6 +1318,10 @@ declare namespace LocalJSX {
|
|
|
1289
1318
|
* Define form id to attach button with. If this attribute is not set, the <button> is associated with its ancestor <form> element.
|
|
1290
1319
|
*/
|
|
1291
1320
|
"form"?: string;
|
|
1321
|
+
/**
|
|
1322
|
+
* Set button to full-width
|
|
1323
|
+
*/
|
|
1324
|
+
"fullWidth"?: boolean;
|
|
1292
1325
|
/**
|
|
1293
1326
|
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
1294
1327
|
*/
|
|
@@ -1310,6 +1343,8 @@ declare namespace LocalJSX {
|
|
|
1310
1343
|
*/
|
|
1311
1344
|
"variant"?: VariantType;
|
|
1312
1345
|
}
|
|
1346
|
+
interface MgCard {
|
|
1347
|
+
}
|
|
1313
1348
|
interface MgCharacterLeft {
|
|
1314
1349
|
/**
|
|
1315
1350
|
* Sets the characters to count
|
|
@@ -1329,6 +1364,10 @@ declare namespace LocalJSX {
|
|
|
1329
1364
|
* Define if details are diplayed
|
|
1330
1365
|
*/
|
|
1331
1366
|
"expanded"?: boolean;
|
|
1367
|
+
/**
|
|
1368
|
+
* Hide summary element
|
|
1369
|
+
*/
|
|
1370
|
+
"hideSummary"?: boolean;
|
|
1332
1371
|
/**
|
|
1333
1372
|
* Emmited event when expanded change
|
|
1334
1373
|
*/
|
|
@@ -1336,11 +1375,17 @@ declare namespace LocalJSX {
|
|
|
1336
1375
|
/**
|
|
1337
1376
|
* Displayed title when details are closed
|
|
1338
1377
|
*/
|
|
1339
|
-
"toggleClosed"
|
|
1378
|
+
"toggleClosed": string;
|
|
1340
1379
|
/**
|
|
1341
1380
|
* Displayed title when details are opened
|
|
1342
1381
|
*/
|
|
1343
|
-
"toggleOpened"
|
|
1382
|
+
"toggleOpened": string;
|
|
1383
|
+
}
|
|
1384
|
+
interface MgDivider {
|
|
1385
|
+
/**
|
|
1386
|
+
* Define component size
|
|
1387
|
+
*/
|
|
1388
|
+
"size"?: 'regular' | 'full';
|
|
1344
1389
|
}
|
|
1345
1390
|
interface MgForm {
|
|
1346
1391
|
/**
|
|
@@ -2319,13 +2364,15 @@ declare namespace LocalJSX {
|
|
|
2319
2364
|
/**
|
|
2320
2365
|
* Tooltip placement
|
|
2321
2366
|
*/
|
|
2322
|
-
"placement"?:
|
|
2367
|
+
"placement"?: Placement;
|
|
2323
2368
|
}
|
|
2324
2369
|
interface IntrinsicElements {
|
|
2325
2370
|
"mg-badge": MgBadge;
|
|
2326
2371
|
"mg-button": MgButton;
|
|
2372
|
+
"mg-card": MgCard;
|
|
2327
2373
|
"mg-character-left": MgCharacterLeft;
|
|
2328
2374
|
"mg-details": MgDetails;
|
|
2375
|
+
"mg-divider": MgDivider;
|
|
2329
2376
|
"mg-form": MgForm;
|
|
2330
2377
|
"mg-icon": MgIcon;
|
|
2331
2378
|
"mg-illustrated-message": MgIllustratedMessage;
|
|
@@ -2355,8 +2402,10 @@ declare module "@stencil/core" {
|
|
|
2355
2402
|
interface IntrinsicElements {
|
|
2356
2403
|
"mg-badge": LocalJSX.MgBadge & JSXBase.HTMLAttributes<HTMLMgBadgeElement>;
|
|
2357
2404
|
"mg-button": LocalJSX.MgButton & JSXBase.HTMLAttributes<HTMLMgButtonElement>;
|
|
2405
|
+
"mg-card": LocalJSX.MgCard & JSXBase.HTMLAttributes<HTMLMgCardElement>;
|
|
2358
2406
|
"mg-character-left": LocalJSX.MgCharacterLeft & JSXBase.HTMLAttributes<HTMLMgCharacterLeftElement>;
|
|
2359
2407
|
"mg-details": LocalJSX.MgDetails & JSXBase.HTMLAttributes<HTMLMgDetailsElement>;
|
|
2408
|
+
"mg-divider": LocalJSX.MgDivider & JSXBase.HTMLAttributes<HTMLMgDividerElement>;
|
|
2360
2409
|
"mg-form": LocalJSX.MgForm & JSXBase.HTMLAttributes<HTMLMgFormElement>;
|
|
2361
2410
|
"mg-icon": LocalJSX.MgIcon & JSXBase.HTMLAttributes<HTMLMgIconElement>;
|
|
2362
2411
|
"mg-illustrated-message": LocalJSX.MgIllustratedMessage & JSXBase.HTMLAttributes<HTMLMgIllustratedMessageElement>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param {number} length ID length
|
|
6
6
|
* @returns {string} ID
|
|
7
7
|
*/
|
|
8
|
-
export declare
|
|
8
|
+
export declare const createID: (prefix?: string, length?: number) => string;
|
|
9
9
|
/**
|
|
10
10
|
* Class to manage component classlist
|
|
11
11
|
* Set() are not working when imported in project
|
|
@@ -47,7 +47,7 @@ export declare class ClassList {
|
|
|
47
47
|
* @param {string[]} items items to check
|
|
48
48
|
* @returns {boolean} all items are string
|
|
49
49
|
*/
|
|
50
|
-
export declare
|
|
50
|
+
export declare const allItemsAreString: (items: string[]) => boolean;
|
|
51
51
|
/**
|
|
52
52
|
* Check if element is a heading
|
|
53
53
|
*
|
|
@@ -55,4 +55,8 @@ export declare function allItemsAreString(items: string[]): boolean;
|
|
|
55
55
|
* @param {string[]} tagNames allowed tag names list
|
|
56
56
|
* @returns {boolean} element is a heading
|
|
57
57
|
*/
|
|
58
|
-
export declare
|
|
58
|
+
export declare const isTagName: (element: Element, tagNames: string[]) => boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Focusable elements query selector
|
|
61
|
+
*/
|
|
62
|
+
export declare const focusableElements = "a[href], button, input, textarea, select, details, [tabindex]:not([tabindex=\"-1\"]), [identifier]";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mgdis/mg-components",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "MG Components",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@popperjs/core": "^2.11.2",
|
|
45
|
-
"@stencil/core": "^2.18.
|
|
45
|
+
"@stencil/core": "^2.18.1",
|
|
46
46
|
"normalize.css": "^8.0.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
@@ -70,13 +70,14 @@
|
|
|
70
70
|
"eslint-plugin-jsdoc": "^38.0.6",
|
|
71
71
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
|
72
72
|
"eslint-plugin-react": "^7.26.1",
|
|
73
|
-
"eslint-plugin-storybook": "^0.6.
|
|
73
|
+
"eslint-plugin-storybook": "^0.6.6",
|
|
74
74
|
"husky": "^7.0.4",
|
|
75
75
|
"jest": "^26.6.3",
|
|
76
76
|
"jest-cli": "^26.6.3",
|
|
77
77
|
"jest-image-snapshot": "^4.5.1",
|
|
78
78
|
"jest-junit": "^13.0.0",
|
|
79
79
|
"jsx-dom": "^8.0.1-beta.1",
|
|
80
|
+
"mutation-observer": "^1.0.3",
|
|
80
81
|
"npm-run-all": "^4.1.5",
|
|
81
82
|
"prettier": "^2.5.1",
|
|
82
83
|
"puppeteer": "^13.3.2",
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Create random ID
|
|
5
|
-
*
|
|
6
|
-
* @param {string} prefix add prefix to created ID
|
|
7
|
-
* @param {number} length ID length
|
|
8
|
-
* @returns {string} ID
|
|
9
|
-
*/
|
|
10
|
-
function createID(prefix = '', length = 10) {
|
|
11
|
-
let ID = '';
|
|
12
|
-
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
13
|
-
const charsLength = chars.length;
|
|
14
|
-
for (let i = 0; i < length; i++) {
|
|
15
|
-
ID += chars.charAt(Math.floor(Math.random() * charsLength));
|
|
16
|
-
}
|
|
17
|
-
return (prefix !== '' ? `${prefix}-` : '') + ID;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Class to manage component classlist
|
|
21
|
-
* Set() are not working when imported in project
|
|
22
|
-
*/
|
|
23
|
-
class ClassList {
|
|
24
|
-
constructor(classlist = []) {
|
|
25
|
-
/**
|
|
26
|
-
* Add class
|
|
27
|
-
*
|
|
28
|
-
* @param {string} className class name to add
|
|
29
|
-
* @returns {void}
|
|
30
|
-
*/
|
|
31
|
-
this.add = (className) => {
|
|
32
|
-
if (!this.has(className)) {
|
|
33
|
-
this.classes.push(className);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Delete class
|
|
38
|
-
*
|
|
39
|
-
* @param {string} className class name to delete
|
|
40
|
-
* @returns {void}
|
|
41
|
-
*/
|
|
42
|
-
this.delete = (className) => {
|
|
43
|
-
const index = this.classes.indexOf(className);
|
|
44
|
-
if (index > -1) {
|
|
45
|
-
this.classes.splice(index, 1);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Check if class exist in list
|
|
50
|
-
*
|
|
51
|
-
* @param {string} className class name to check
|
|
52
|
-
* @returns {boolean} class name is in the list
|
|
53
|
-
*/
|
|
54
|
-
this.has = (className) => {
|
|
55
|
-
return this.classes.includes(className);
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Join classes seperated by spaces
|
|
59
|
-
*
|
|
60
|
-
* @returns {string} joined values
|
|
61
|
-
*/
|
|
62
|
-
this.join = () => {
|
|
63
|
-
return this.classes.join(' ');
|
|
64
|
-
};
|
|
65
|
-
this.classes = classlist;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Check if all items are string
|
|
70
|
-
*
|
|
71
|
-
* @param {string[]} items items to check
|
|
72
|
-
* @returns {boolean} all items are string
|
|
73
|
-
*/
|
|
74
|
-
function allItemsAreString(items) {
|
|
75
|
-
return items && items.every(item => typeof item === 'string');
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Check if element is a heading
|
|
79
|
-
*
|
|
80
|
-
* @param {Element} element slotted element
|
|
81
|
-
* @param {string[]} tagNames allowed tag names list
|
|
82
|
-
* @returns {boolean} element is a heading
|
|
83
|
-
*/
|
|
84
|
-
function isTagName(element, tagNames) {
|
|
85
|
-
return tagNames.includes(element === null || element === void 0 ? void 0 : element.tagName.toLowerCase());
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const errors$1 = {
|
|
89
|
-
required: "This field is required.",
|
|
90
|
-
date: {
|
|
91
|
-
badInput: "The date format must be <span aria-hidden=\"true\">mm/dd/yyyy</span><span class=\"sr-only\">m m / d d / y y y y</span> and the date must be greater than {min}",
|
|
92
|
-
min: "The date cannot be earlier than {min}",
|
|
93
|
-
max: "The date cannot be later than {max}",
|
|
94
|
-
minMax: "The date must be between {min} and {max}"
|
|
95
|
-
},
|
|
96
|
-
numeric: {
|
|
97
|
-
min: "The value cannot be less than {min}",
|
|
98
|
-
max: "The value cannot be greater than {max}",
|
|
99
|
-
minMax: "The value must be between {min} et {max}"
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
const nbCharLeft$1 = "{counter} characters left.";
|
|
103
|
-
const input$1 = {
|
|
104
|
-
select: {
|
|
105
|
-
placeholder: "Select a value"
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
const form$1 = {
|
|
109
|
-
required: "Fields with a <strong class=\"is-asterisk\">*</strong> are required",
|
|
110
|
-
allRequired: "All fields are required"
|
|
111
|
-
};
|
|
112
|
-
const message$1 = {
|
|
113
|
-
closeButton: "Close message"
|
|
114
|
-
};
|
|
115
|
-
const modal$1 = {
|
|
116
|
-
closeButton: "Close modal"
|
|
117
|
-
};
|
|
118
|
-
const pagination$1 = {
|
|
119
|
-
label: "Pagination",
|
|
120
|
-
page: "page",
|
|
121
|
-
pages: "pages",
|
|
122
|
-
nextPage: "Next page",
|
|
123
|
-
previousPage: "Previous page",
|
|
124
|
-
selectPage: "Select the page to display."
|
|
125
|
-
};
|
|
126
|
-
const panel$1 = {
|
|
127
|
-
editLabel: "Edit section title."
|
|
128
|
-
};
|
|
129
|
-
const general$1 = {
|
|
130
|
-
confirm: "Confirm",
|
|
131
|
-
cancel: "Cancel",
|
|
132
|
-
close: "Close",
|
|
133
|
-
next: "next",
|
|
134
|
-
previous: "previous"
|
|
135
|
-
};
|
|
136
|
-
const en = {
|
|
137
|
-
errors: errors$1,
|
|
138
|
-
nbCharLeft: nbCharLeft$1,
|
|
139
|
-
input: input$1,
|
|
140
|
-
form: form$1,
|
|
141
|
-
message: message$1,
|
|
142
|
-
modal: modal$1,
|
|
143
|
-
pagination: pagination$1,
|
|
144
|
-
panel: panel$1,
|
|
145
|
-
general: general$1
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const errors = {
|
|
149
|
-
required: "Ce champ est obligatoire.",
|
|
150
|
-
date: {
|
|
151
|
-
badInput: "Le format de la date doit être du type <span aria-hidden=\"true\">jj/mm/aaaa</span><span class=\"sr-only\">j j / m m / a a a a</span> et la date supérieure au {min}",
|
|
152
|
-
min: "La date ne peut pas être antérieure au {min}",
|
|
153
|
-
max: "La date ne peut pas être postérieure au {max}",
|
|
154
|
-
minMax: "La date doit être comprise entre le {min} et le {max}"
|
|
155
|
-
},
|
|
156
|
-
numeric: {
|
|
157
|
-
min: "La valeur ne peut pas être inférieure à {min}",
|
|
158
|
-
max: "La valeur ne peut pas être supérieure à {max}",
|
|
159
|
-
minMax: "La valeur doit être comprise entre {min} et {max}"
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
const nbCharLeft = "{counter} caractères disponibles.";
|
|
163
|
-
const input = {
|
|
164
|
-
select: {
|
|
165
|
-
placeholder: "Sélectionnez une valeur"
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
const form = {
|
|
169
|
-
required: "Les champs marqués d'un <strong class=\"is-asterisk\">*</strong> sont obligatoires",
|
|
170
|
-
allRequired: "Tous les champs sont obligatoires"
|
|
171
|
-
};
|
|
172
|
-
const message = {
|
|
173
|
-
closeButton: "Fermer le message"
|
|
174
|
-
};
|
|
175
|
-
const modal = {
|
|
176
|
-
closeButton: "Fermer la modale"
|
|
177
|
-
};
|
|
178
|
-
const pagination = {
|
|
179
|
-
label: "Pagination",
|
|
180
|
-
page: "page",
|
|
181
|
-
pages: "pages",
|
|
182
|
-
nextPage: "Page suivante",
|
|
183
|
-
previousPage: "Page précédente",
|
|
184
|
-
selectPage: "Sélectionner la page à afficher."
|
|
185
|
-
};
|
|
186
|
-
const panel = {
|
|
187
|
-
editLabel: "Modifier le titre de la section."
|
|
188
|
-
};
|
|
189
|
-
const general = {
|
|
190
|
-
confirm: "Valider",
|
|
191
|
-
cancel: "Annuler",
|
|
192
|
-
close: "Fermer",
|
|
193
|
-
next: "suivant",
|
|
194
|
-
previous: "précédent"
|
|
195
|
-
};
|
|
196
|
-
const fr = {
|
|
197
|
-
errors: errors,
|
|
198
|
-
nbCharLeft: nbCharLeft,
|
|
199
|
-
input: input,
|
|
200
|
-
form: form,
|
|
201
|
-
message: message,
|
|
202
|
-
modal: modal,
|
|
203
|
-
pagination: pagination,
|
|
204
|
-
panel: panel,
|
|
205
|
-
general: general
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
const defaultLocale = 'en';
|
|
209
|
-
const messages = { en, fr };
|
|
210
|
-
/**
|
|
211
|
-
* Get locale
|
|
212
|
-
*
|
|
213
|
-
* @param {HTMLElement} element element that needs to know the locale to use
|
|
214
|
-
* @returns {string} locale
|
|
215
|
-
*/
|
|
216
|
-
const getLocale = (element) => {
|
|
217
|
-
var _a;
|
|
218
|
-
return ((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang) || navigator.language || defaultLocale;
|
|
219
|
-
};
|
|
220
|
-
/**
|
|
221
|
-
* Get Intl object
|
|
222
|
-
* We load the defined locale but for now we only support the first subtag for messages
|
|
223
|
-
*
|
|
224
|
-
* @param {HTMLElement} element element we need to get the language
|
|
225
|
-
* @returns {{ locale: string; messages: unknown }} messages object
|
|
226
|
-
*/
|
|
227
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
228
|
-
const initLocales = (element) => {
|
|
229
|
-
// Get local
|
|
230
|
-
const locale = getLocale(element);
|
|
231
|
-
// Only keep first subtag
|
|
232
|
-
const localeSubtag = locale.split('-').shift();
|
|
233
|
-
// Return
|
|
234
|
-
return {
|
|
235
|
-
locale,
|
|
236
|
-
messages: messages[localeSubtag] || messages[defaultLocale],
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
exports.ClassList = ClassList;
|
|
241
|
-
exports.allItemsAreString = allItemsAreString;
|
|
242
|
-
exports.createID = createID;
|
|
243
|
-
exports.initLocales = initLocales;
|
|
244
|
-
exports.isTagName = isTagName;
|