@maggioli-design-system/mds-push-notification 1.6.0 → 1.6.1
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/collection/common/locale.js +8 -10
- package/dist/collection/type/language.js +1 -0
- package/dist/documentation.json +1 -1
- package/dist/stats.json +5 -3
- package/dist/types/common/locale.d.ts +5 -3
- package/dist/types/type/language.d.ts +1 -0
- package/dist/types/type/preference.d.ts +1 -1
- package/documentation.json +17 -2
- package/package.json +5 -5
- package/src/common/locale.ts +14 -10
- package/src/type/language.ts +4 -0
- package/src/type/preference.ts +1 -0
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import Handlebars from "handlebars";
|
|
2
2
|
export class Locale {
|
|
3
3
|
constructor(configData) {
|
|
4
|
-
this.
|
|
4
|
+
this.rollbackLanguage = 'en';
|
|
5
5
|
this.lang = (element) => {
|
|
6
|
-
|
|
7
|
-
if (closestElement) {
|
|
8
|
-
if (closestElement.lang) {
|
|
9
|
-
this.language = closestElement.lang;
|
|
6
|
+
this.closestElement = element.closest('[lang]');
|
|
7
|
+
if (this.closestElement) {
|
|
8
|
+
if (this.closestElement.lang) {
|
|
9
|
+
this.language = this.closestElement.lang;
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
this.language = this.
|
|
13
|
+
this.language = this.rollbackLanguage;
|
|
14
14
|
};
|
|
15
15
|
this.pluralize = (tag, context) => {
|
|
16
|
-
|
|
17
|
-
const languagePhrase = (_a = this.config[this.language][tag]) !== null && _a !== void 0 ? _a : this.config[this.defaultLanguage][tag];
|
|
16
|
+
const languagePhrase = this.config[this.language] ? this.config[this.language][tag] : this.config[this.rollbackLanguage][tag];
|
|
18
17
|
const phrases = [];
|
|
19
18
|
if (Array.isArray(languagePhrase)) {
|
|
20
19
|
phrases.push(languagePhrase[0]);
|
|
@@ -39,11 +38,10 @@ export class Locale {
|
|
|
39
38
|
return template(context);
|
|
40
39
|
};
|
|
41
40
|
this.get = (tag, context) => {
|
|
42
|
-
var _a;
|
|
43
41
|
if (context) {
|
|
44
42
|
return this.pluralize(tag, context);
|
|
45
43
|
}
|
|
46
|
-
return
|
|
44
|
+
return this.config[this.language] ? this.config[this.language][tag] : this.config[this.rollbackLanguage][tag];
|
|
47
45
|
};
|
|
48
46
|
this.config = configData;
|
|
49
47
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/documentation.json
CHANGED
package/dist/stats.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2024-09-
|
|
2
|
+
"timestamp": "2024-09-13T08:54:30",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "node",
|
|
5
5
|
"version": "20.10.0"
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
"fsNamespace": "mds-push-notification",
|
|
10
10
|
"components": 1,
|
|
11
11
|
"entries": 1,
|
|
12
|
-
"bundles":
|
|
12
|
+
"bundles": 93,
|
|
13
13
|
"outputs": [
|
|
14
14
|
{
|
|
15
15
|
"name": "dist-collection",
|
|
16
|
-
"files":
|
|
16
|
+
"files": 45,
|
|
17
17
|
"generatedFiles": [
|
|
18
18
|
"./dist/collection/common/aria.js",
|
|
19
19
|
"./dist/collection/common/file.js",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"./dist/collection/type/floating-ui.js",
|
|
54
54
|
"./dist/collection/type/form-rel.js",
|
|
55
55
|
"./dist/collection/type/input.js",
|
|
56
|
+
"./dist/collection/type/language.js",
|
|
56
57
|
"./dist/collection/type/loading.js",
|
|
57
58
|
"./dist/collection/type/preference.js",
|
|
58
59
|
"./dist/collection/type/text.js",
|
|
@@ -878,6 +879,7 @@
|
|
|
878
879
|
"./src/type/floating-ui.ts": [],
|
|
879
880
|
"./src/type/form-rel.ts": [],
|
|
880
881
|
"./src/type/input.ts": [],
|
|
882
|
+
"./src/type/language.ts": [],
|
|
881
883
|
"./src/type/loading.ts": [],
|
|
882
884
|
"./src/type/preference.ts": [],
|
|
883
885
|
"./src/type/text.ts": [],
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
type LocaleConfig = {
|
|
2
|
+
el?: Record<string, string | string[]>;
|
|
3
|
+
en: Record<string, string | string[]>;
|
|
4
|
+
es?: Record<string, string | string[]>;
|
|
2
5
|
it?: Record<string, string | string[]>;
|
|
3
|
-
en?: Record<string, string | string[]>;
|
|
4
|
-
gr?: Record<string, string | string[]>;
|
|
5
6
|
};
|
|
6
7
|
export declare class Locale {
|
|
7
|
-
|
|
8
|
+
rollbackLanguage: string;
|
|
8
9
|
language: string;
|
|
9
10
|
config: LocaleConfig;
|
|
11
|
+
closestElement: HTMLElement;
|
|
10
12
|
constructor(configData: LocaleConfig);
|
|
11
13
|
lang: (element: HTMLElement) => void;
|
|
12
14
|
private pluralize;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type LanguageType = 'auto' | `${Lowercase<string>}${Lowercase<string>}` | `${Lowercase<string>}${Lowercase<string>}${Lowercase<string>}`;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type UIPreferenceType = 'animation' | 'consumption' | 'contrast' | 'theme';
|
|
1
|
+
export type UIPreferenceType = 'animation' | 'consumption' | 'contrast' | 'theme' | 'language';
|
|
2
2
|
export type ConsumptionModeType = 'high' | 'medium' | 'low';
|
package/documentation.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2024-09-
|
|
2
|
+
"timestamp": "2024-09-13T08:12:14",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
5
|
"version": "4.21.0",
|
|
@@ -520,7 +520,7 @@
|
|
|
520
520
|
"path": "src/components/mds-chip/meta/interface.ts"
|
|
521
521
|
},
|
|
522
522
|
"src/components/mds-dropdown/meta/types.ts::DropdownInteractionType": {
|
|
523
|
-
"declaration": "export type DropdownInteractionType =\n | 'click'\n | 'mouseover'",
|
|
523
|
+
"declaration": "export type DropdownInteractionType =\n | 'click'\n | 'none'\n | 'mouseover'",
|
|
524
524
|
"docstring": "",
|
|
525
525
|
"path": "src/components/mds-dropdown/meta/types.ts"
|
|
526
526
|
},
|
|
@@ -734,6 +734,11 @@
|
|
|
734
734
|
"docstring": "",
|
|
735
735
|
"path": "src/components/mds-pref-animation/meta/types.ts"
|
|
736
736
|
},
|
|
737
|
+
"src/event-detail/preference.ts::MdsPrefChangeEventDetail": {
|
|
738
|
+
"declaration": "export interface MdsPrefChangeEventDetail {\n preference: UIPreferenceType\n}",
|
|
739
|
+
"docstring": "",
|
|
740
|
+
"path": "src/event-detail/preference.ts"
|
|
741
|
+
},
|
|
737
742
|
"src/type/preference.ts::ConsumptionModeType": {
|
|
738
743
|
"declaration": "export type ConsumptionModeType =\n | 'high'\n | 'medium'\n | 'low'",
|
|
739
744
|
"docstring": "",
|
|
@@ -744,6 +749,16 @@
|
|
|
744
749
|
"docstring": "",
|
|
745
750
|
"path": "src/components/mds-pref-contrast/meta/types.ts"
|
|
746
751
|
},
|
|
752
|
+
"src/type/language.ts::LanguageType": {
|
|
753
|
+
"declaration": "export type LanguageType =\n | 'auto'\n | `${Lowercase<string>}${Lowercase<string>}`\n | `${Lowercase<string>}${Lowercase<string>}${Lowercase<string>}`",
|
|
754
|
+
"docstring": "",
|
|
755
|
+
"path": "src/type/language.ts"
|
|
756
|
+
},
|
|
757
|
+
"src/event-detail/language.ts::MdsPrefLanguageEventDetail": {
|
|
758
|
+
"declaration": "export interface MdsPrefLanguageEventDetail {\n language?: LanguageType\n}",
|
|
759
|
+
"docstring": "",
|
|
760
|
+
"path": "src/event-detail/language.ts"
|
|
761
|
+
},
|
|
747
762
|
"src/components/mds-pref-theme/meta/types.ts::ThemeModeType": {
|
|
748
763
|
"declaration": "export type ThemeModeType =\n | 'light'\n | 'dark'\n | 'system'",
|
|
749
764
|
"docstring": "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maggioli-design-system/mds-push-notification",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "mds-push-notification is a web-component from Magma Design System, built with StencilJS, TypeScript, Storybook. It's based on the web-component standard and it's designed to be agnostic from the JavaScirpt framework you are using.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"test": "stencil test --spec --e2e"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@maggioli-design-system/mds-button": "4.18.
|
|
28
|
-
"@maggioli-design-system/mds-icon": "2.10.
|
|
29
|
-
"@maggioli-design-system/mds-text": "4.4.
|
|
30
|
-
"@maggioli-design-system/styles": "15.3.
|
|
27
|
+
"@maggioli-design-system/mds-button": "4.18.1",
|
|
28
|
+
"@maggioli-design-system/mds-icon": "2.10.4",
|
|
29
|
+
"@maggioli-design-system/mds-text": "4.4.1",
|
|
30
|
+
"@maggioli-design-system/styles": "15.3.1",
|
|
31
31
|
"@stencil/core": "4.21.0"
|
|
32
32
|
},
|
|
33
33
|
"license": "MIT",
|
package/src/common/locale.ts
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
import Handlebars from 'handlebars'
|
|
2
2
|
|
|
3
3
|
type LocaleConfig = {
|
|
4
|
+
el?: Record<string, string | string[]>
|
|
5
|
+
en: Record<string, string | string[]>
|
|
6
|
+
es?: Record<string, string | string[]>
|
|
4
7
|
it?: Record<string, string | string[]>
|
|
5
|
-
en?: Record<string, string | string[]>
|
|
6
|
-
gr?: Record<string, string | string[]>
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export class Locale {
|
|
10
|
-
|
|
11
|
+
rollbackLanguage: string = 'en'
|
|
11
12
|
language: string
|
|
12
13
|
config: LocaleConfig
|
|
14
|
+
closestElement:HTMLElement
|
|
13
15
|
|
|
14
16
|
constructor (configData: LocaleConfig) {
|
|
15
17
|
this.config = configData
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
lang = (element: HTMLElement): void => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
this.closestElement = element.closest('[lang]') as HTMLElement
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
if (this.closestElement) {
|
|
25
|
+
if (this.closestElement.lang) {
|
|
26
|
+
this.language = this.closestElement.lang
|
|
23
27
|
return
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
this.language = this.
|
|
31
|
+
this.language = this.rollbackLanguage
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
private pluralize = (tag: string | string[], context: Record<string, string | number>): string => {
|
|
31
35
|
|
|
32
|
-
const languagePhrase: string | string[] = this.config[this.language][tag]
|
|
36
|
+
const languagePhrase: string | string[] = this.config[this.language] ? this.config[this.language][tag] : this.config[this.rollbackLanguage][tag]
|
|
33
37
|
const phrases: string[] = []
|
|
34
38
|
|
|
35
39
|
if (Array.isArray(languagePhrase)) {
|
|
@@ -61,6 +65,6 @@ export class Locale {
|
|
|
61
65
|
if (context) {
|
|
62
66
|
return this.pluralize(tag, context)
|
|
63
67
|
}
|
|
64
|
-
return this.config[this.language][tag]
|
|
68
|
+
return this.config[this.language] ? this.config[this.language][tag] : this.config[this.rollbackLanguage][tag]
|
|
65
69
|
}
|
|
66
70
|
}
|