@everymatrix/pam-metadata 1.71.2
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/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/index-42065499.js +1184 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/cjs/pam-metadata-f2657afb.js +227 -0
- package/dist/cjs/pam-metadata.cjs.js +25 -0
- package/dist/cjs/pam-metadata_2.cjs.entry.js +183 -0
- package/dist/collection/collection-manifest.json +19 -0
- package/dist/collection/components/pam-metadata/index.js +1 -0
- package/dist/collection/components/pam-metadata/pam-metadata.css +28 -0
- package/dist/collection/components/pam-metadata/pam-metadata.js +272 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +71 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/index-c1c08349.js +1157 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/pam-metadata-072ea225.js +225 -0
- package/dist/esm/pam-metadata.js +20 -0
- package/dist/esm/pam-metadata_2.entry.js +178 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/pam-metadata/app-globals-0f993ce5.js +1 -0
- package/dist/pam-metadata/index-c1c08349.js +2 -0
- package/dist/pam-metadata/index.esm.js +1 -0
- package/dist/pam-metadata/pam-metadata-072ea225.js +1 -0
- package/dist/pam-metadata/pam-metadata.esm.js +1 -0
- package/dist/pam-metadata/pam-metadata_2.entry.js +1 -0
- package/dist/stencil.config.dev.js +19 -0
- package/dist/stencil.config.js +19 -0
- package/dist/storybook/main.js +43 -0
- package/dist/storybook/preview.js +9 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-metadata/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-metadata/.stencil/packages/stencil/pam-metadata/stencil.config.d.ts +2 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-metadata/.stencil/packages/stencil/pam-metadata/stencil.config.dev.d.ts +2 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-metadata/.stencil/packages/stencil/pam-metadata/storybook/main.d.ts +3 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-metadata/.stencil/packages/stencil/pam-metadata/storybook/preview.d.ts +70 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-metadata/.stencil/tools/plugins/index.d.ts +3 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-metadata/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-metadata/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-metadata/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
- package/dist/types/components/pam-metadata/index.d.ts +1 -0
- package/dist/types/components/pam-metadata/pam-metadata.d.ts +26 -0
- package/dist/types/components.d.ts +55 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/locale.utils.d.ts +4 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +26 -0
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
|
|
3
|
+
import { getTranslations, translate } from "../../utils/locale.utils";
|
|
4
|
+
import dayjs from "dayjs";
|
|
5
|
+
import "../../../../../ui-skeleton/dist/types/index";
|
|
6
|
+
export class PamMetadata {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.data = null;
|
|
9
|
+
this.getData = () => {
|
|
10
|
+
const url = new URL(`api/v1/players/${this.userId}/player-identifiable-information/`, this.endpoint);
|
|
11
|
+
const headers = new Headers({ 'X-SessionID': this.session });
|
|
12
|
+
const options = { method: 'GET', headers };
|
|
13
|
+
return fetch(url.href, options).then(res => {
|
|
14
|
+
if (res.ok) {
|
|
15
|
+
return res.json().then(res => res);
|
|
16
|
+
}
|
|
17
|
+
throw new Error;
|
|
18
|
+
}).catch(() => {
|
|
19
|
+
window.postMessage({ type: 'WidgetNotification', data: { type: 'error', message: translate('errorFetchMessage', this.language) } }, window.location.href);
|
|
20
|
+
return null;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
this.formatDate = (date) => {
|
|
24
|
+
return dayjs(date).format(this.dateFormat);
|
|
25
|
+
};
|
|
26
|
+
this.loadingSkeleton = (h("div", { class: "LoadingSkeleton" }, h("div", { class: "Title" }, h("ui-skeleton", { structure: "title", width: "100%", height: "18px" })), h("div", { class: "Text" }, h("ui-skeleton", { structure: "text", width: "100%", height: "14px" }))));
|
|
27
|
+
this.language = 'en';
|
|
28
|
+
this.endpoint = '';
|
|
29
|
+
this.session = '';
|
|
30
|
+
this.userId = '';
|
|
31
|
+
this.dateFormat = 'DD/MM/YYYY HH:mm';
|
|
32
|
+
this.mbSource = '';
|
|
33
|
+
this.clientStyling = '';
|
|
34
|
+
this.clientStylingUrl = '';
|
|
35
|
+
this.translationUrl = '';
|
|
36
|
+
this.isLoading = true;
|
|
37
|
+
}
|
|
38
|
+
handleClientStylingChange(newValue, oldValue) {
|
|
39
|
+
if (newValue != oldValue) {
|
|
40
|
+
setClientStyling(this.stylingContainer, this.clientStyling);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
handleClientStylingUrlChange(newValue, oldValue) {
|
|
44
|
+
if (newValue != oldValue) {
|
|
45
|
+
setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
handleMbSourceChange(newValue, oldValue) {
|
|
49
|
+
if (newValue != oldValue) {
|
|
50
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
componentWillLoad() {
|
|
54
|
+
this.getData().then(res => res && (this.data = res.player, this.isLoading = false));
|
|
55
|
+
if (this.translationUrl) {
|
|
56
|
+
return getTranslations(this.translationUrl);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
componentDidLoad() {
|
|
60
|
+
if (this.stylingContainer) {
|
|
61
|
+
if (this.mbSource)
|
|
62
|
+
setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
63
|
+
if (this.clientStyling)
|
|
64
|
+
setClientStyling(this.stylingContainer, this.clientStyling);
|
|
65
|
+
if (this.clientStylingUrl)
|
|
66
|
+
setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
disconnectedCallback() {
|
|
70
|
+
this.stylingSubscription && this.stylingSubscription.unsubscribe();
|
|
71
|
+
}
|
|
72
|
+
render() {
|
|
73
|
+
return (h("div", { key: '36a2665c4e000c17c8bc847b009f64a91d1b1ce4', ref: (el) => (this.stylingContainer = el), class: "PamMetadata" }, this.isLoading
|
|
74
|
+
? this.loadingSkeleton
|
|
75
|
+
: h("div", { class: "TextContainer" }, h("h4", null, translate('title')), h("div", { innerHTML: translate('lastLoginText', this.language, { values: { lastLoginTimestamp: this.formatDate(this.data.statusInfo.lastLogin) } }) }))));
|
|
76
|
+
}
|
|
77
|
+
static get is() { return "pam-metadata"; }
|
|
78
|
+
static get encapsulation() { return "shadow"; }
|
|
79
|
+
static get originalStyleUrls() {
|
|
80
|
+
return {
|
|
81
|
+
"$": ["pam-metadata.scss"]
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
static get styleUrls() {
|
|
85
|
+
return {
|
|
86
|
+
"$": ["pam-metadata.css"]
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
static get properties() {
|
|
90
|
+
return {
|
|
91
|
+
"language": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"mutable": false,
|
|
94
|
+
"complexType": {
|
|
95
|
+
"original": "string",
|
|
96
|
+
"resolved": "string",
|
|
97
|
+
"references": {}
|
|
98
|
+
},
|
|
99
|
+
"required": false,
|
|
100
|
+
"optional": false,
|
|
101
|
+
"docs": {
|
|
102
|
+
"tags": [],
|
|
103
|
+
"text": ""
|
|
104
|
+
},
|
|
105
|
+
"attribute": "language",
|
|
106
|
+
"reflect": true,
|
|
107
|
+
"defaultValue": "'en'"
|
|
108
|
+
},
|
|
109
|
+
"endpoint": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"mutable": false,
|
|
112
|
+
"complexType": {
|
|
113
|
+
"original": "string",
|
|
114
|
+
"resolved": "string",
|
|
115
|
+
"references": {}
|
|
116
|
+
},
|
|
117
|
+
"required": false,
|
|
118
|
+
"optional": false,
|
|
119
|
+
"docs": {
|
|
120
|
+
"tags": [],
|
|
121
|
+
"text": ""
|
|
122
|
+
},
|
|
123
|
+
"attribute": "endpoint",
|
|
124
|
+
"reflect": true,
|
|
125
|
+
"defaultValue": "''"
|
|
126
|
+
},
|
|
127
|
+
"session": {
|
|
128
|
+
"type": "string",
|
|
129
|
+
"mutable": false,
|
|
130
|
+
"complexType": {
|
|
131
|
+
"original": "string",
|
|
132
|
+
"resolved": "string",
|
|
133
|
+
"references": {}
|
|
134
|
+
},
|
|
135
|
+
"required": false,
|
|
136
|
+
"optional": false,
|
|
137
|
+
"docs": {
|
|
138
|
+
"tags": [],
|
|
139
|
+
"text": ""
|
|
140
|
+
},
|
|
141
|
+
"attribute": "session",
|
|
142
|
+
"reflect": true,
|
|
143
|
+
"defaultValue": "''"
|
|
144
|
+
},
|
|
145
|
+
"userId": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"mutable": false,
|
|
148
|
+
"complexType": {
|
|
149
|
+
"original": "string",
|
|
150
|
+
"resolved": "string",
|
|
151
|
+
"references": {}
|
|
152
|
+
},
|
|
153
|
+
"required": false,
|
|
154
|
+
"optional": false,
|
|
155
|
+
"docs": {
|
|
156
|
+
"tags": [],
|
|
157
|
+
"text": ""
|
|
158
|
+
},
|
|
159
|
+
"attribute": "user-id",
|
|
160
|
+
"reflect": true,
|
|
161
|
+
"defaultValue": "''"
|
|
162
|
+
},
|
|
163
|
+
"dateFormat": {
|
|
164
|
+
"type": "string",
|
|
165
|
+
"mutable": false,
|
|
166
|
+
"complexType": {
|
|
167
|
+
"original": "string",
|
|
168
|
+
"resolved": "string",
|
|
169
|
+
"references": {}
|
|
170
|
+
},
|
|
171
|
+
"required": false,
|
|
172
|
+
"optional": false,
|
|
173
|
+
"docs": {
|
|
174
|
+
"tags": [],
|
|
175
|
+
"text": ""
|
|
176
|
+
},
|
|
177
|
+
"attribute": "date-format",
|
|
178
|
+
"reflect": true,
|
|
179
|
+
"defaultValue": "'DD/MM/YYYY HH:mm'"
|
|
180
|
+
},
|
|
181
|
+
"mbSource": {
|
|
182
|
+
"type": "string",
|
|
183
|
+
"mutable": false,
|
|
184
|
+
"complexType": {
|
|
185
|
+
"original": "string",
|
|
186
|
+
"resolved": "string",
|
|
187
|
+
"references": {}
|
|
188
|
+
},
|
|
189
|
+
"required": false,
|
|
190
|
+
"optional": false,
|
|
191
|
+
"docs": {
|
|
192
|
+
"tags": [],
|
|
193
|
+
"text": ""
|
|
194
|
+
},
|
|
195
|
+
"attribute": "mb-source",
|
|
196
|
+
"reflect": true,
|
|
197
|
+
"defaultValue": "''"
|
|
198
|
+
},
|
|
199
|
+
"clientStyling": {
|
|
200
|
+
"type": "string",
|
|
201
|
+
"mutable": false,
|
|
202
|
+
"complexType": {
|
|
203
|
+
"original": "string",
|
|
204
|
+
"resolved": "string",
|
|
205
|
+
"references": {}
|
|
206
|
+
},
|
|
207
|
+
"required": false,
|
|
208
|
+
"optional": false,
|
|
209
|
+
"docs": {
|
|
210
|
+
"tags": [],
|
|
211
|
+
"text": ""
|
|
212
|
+
},
|
|
213
|
+
"attribute": "client-styling",
|
|
214
|
+
"reflect": true,
|
|
215
|
+
"defaultValue": "''"
|
|
216
|
+
},
|
|
217
|
+
"clientStylingUrl": {
|
|
218
|
+
"type": "string",
|
|
219
|
+
"mutable": false,
|
|
220
|
+
"complexType": {
|
|
221
|
+
"original": "string",
|
|
222
|
+
"resolved": "string",
|
|
223
|
+
"references": {}
|
|
224
|
+
},
|
|
225
|
+
"required": false,
|
|
226
|
+
"optional": false,
|
|
227
|
+
"docs": {
|
|
228
|
+
"tags": [],
|
|
229
|
+
"text": ""
|
|
230
|
+
},
|
|
231
|
+
"attribute": "client-styling-url",
|
|
232
|
+
"reflect": true,
|
|
233
|
+
"defaultValue": "''"
|
|
234
|
+
},
|
|
235
|
+
"translationUrl": {
|
|
236
|
+
"type": "string",
|
|
237
|
+
"mutable": false,
|
|
238
|
+
"complexType": {
|
|
239
|
+
"original": "string",
|
|
240
|
+
"resolved": "string",
|
|
241
|
+
"references": {}
|
|
242
|
+
},
|
|
243
|
+
"required": false,
|
|
244
|
+
"optional": false,
|
|
245
|
+
"docs": {
|
|
246
|
+
"tags": [],
|
|
247
|
+
"text": ""
|
|
248
|
+
},
|
|
249
|
+
"attribute": "translation-url",
|
|
250
|
+
"reflect": true,
|
|
251
|
+
"defaultValue": "''"
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
static get states() {
|
|
256
|
+
return {
|
|
257
|
+
"isLoading": {}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
static get watchers() {
|
|
261
|
+
return [{
|
|
262
|
+
"propName": "clientStyling",
|
|
263
|
+
"methodName": "handleClientStylingChange"
|
|
264
|
+
}, {
|
|
265
|
+
"propName": "clientStylingUrl",
|
|
266
|
+
"methodName": "handleClientStylingUrlChange"
|
|
267
|
+
}, {
|
|
268
|
+
"propName": "mbSource",
|
|
269
|
+
"methodName": "handleMbSourceChange"
|
|
270
|
+
}];
|
|
271
|
+
}
|
|
272
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/pam-metadata';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
const TRANSLATIONS = {
|
|
3
|
+
"en": {
|
|
4
|
+
title: "Player Info",
|
|
5
|
+
lastLoginText: "Last login date: {lastLoginTimestamp}.",
|
|
6
|
+
errorFetchMessage: "There was an error when fetching last login date"
|
|
7
|
+
},
|
|
8
|
+
"tr": {
|
|
9
|
+
title: "Oyuncu Bilgisi",
|
|
10
|
+
lastLoginText: "Son giriş tarihi: {lastLoginTimestamp}.",
|
|
11
|
+
errorFetchMessage: "Son giriş tarihi alınırken bir hata oluştu"
|
|
12
|
+
},
|
|
13
|
+
"ro": {
|
|
14
|
+
title: "Informații jucător",
|
|
15
|
+
lastLoginText: "Data ultimei autentificări: {lastLoginTimestamp}.",
|
|
16
|
+
errorFetchMessage: "A apărut o eroare la preluarea datei ultimei autentificări"
|
|
17
|
+
},
|
|
18
|
+
"hr": {
|
|
19
|
+
title: "Informacije o igraču",
|
|
20
|
+
lastLoginText: "Datum zadnje prijave: {lastLoginTimestamp}.",
|
|
21
|
+
errorFetchMessage: "Došlo je do pogreške prilikom dohvaćanja datuma zadnje prijave"
|
|
22
|
+
},
|
|
23
|
+
"pt-br": {
|
|
24
|
+
title: "Informações do Jogador",
|
|
25
|
+
lastLoginText: "Data do último login: {lastLoginTimestamp}.",
|
|
26
|
+
errorFetchMessage: "Ocorreu um erro ao buscar a data do último login"
|
|
27
|
+
},
|
|
28
|
+
"es-mx": {
|
|
29
|
+
title: "Información del Jugador",
|
|
30
|
+
lastLoginText: "Fecha del último inicio de sesión: {lastLoginTimestamp}.",
|
|
31
|
+
errorFetchMessage: "Hubo un error al obtener la fecha del último inicio de sesión"
|
|
32
|
+
},
|
|
33
|
+
"es": {
|
|
34
|
+
title: "Información del Jugador",
|
|
35
|
+
lastLoginText: "Fecha del último inicio de sesión: {lastLoginTimestamp}.",
|
|
36
|
+
errorFetchMessage: "Hubo un error al obtener la fecha del último inicio de sesión"
|
|
37
|
+
},
|
|
38
|
+
"pt": {
|
|
39
|
+
title: "Informações do Jogador",
|
|
40
|
+
lastLoginText: "Data do último login: {lastLoginTimestamp}.",
|
|
41
|
+
errorFetchMessage: "Ocorreu um erro ao buscar a data do último login"
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export const getTranslations = (url) => {
|
|
45
|
+
return new Promise((resolve) => {
|
|
46
|
+
fetch(url)
|
|
47
|
+
.then((res) => res.json())
|
|
48
|
+
.then((data) => {
|
|
49
|
+
Object.keys(data).forEach((lang) => {
|
|
50
|
+
if (!TRANSLATIONS[lang]) {
|
|
51
|
+
TRANSLATIONS[lang] = {};
|
|
52
|
+
}
|
|
53
|
+
for (let key in data[lang]) {
|
|
54
|
+
TRANSLATIONS[lang][key] = data[lang][key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
resolve(true);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
export const translate = (key, customLang, values) => {
|
|
62
|
+
const lang = customLang;
|
|
63
|
+
let translation = TRANSLATIONS[((lang !== undefined) && (lang in TRANSLATIONS)) ? lang : DEFAULT_LANGUAGE][key];
|
|
64
|
+
if (values !== undefined) {
|
|
65
|
+
for (const [key, value] of Object.entries(values.values)) {
|
|
66
|
+
const regex = new RegExp(`{${key}}`, 'g');
|
|
67
|
+
translation = translation.replace(regex, value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return translation;
|
|
71
|
+
};
|