@everymatrix/user-login 1.0.69

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 (44) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-465784fc.js +1240 -0
  3. package/dist/cjs/index.cjs.js +2 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/user-login.cjs.entry.js +312 -0
  6. package/dist/cjs/user-login.cjs.js +25 -0
  7. package/dist/collection/collection-manifest.json +12 -0
  8. package/dist/collection/components/user-login/index.js +1 -0
  9. package/dist/collection/components/user-login/user-login.css +166 -0
  10. package/dist/collection/components/user-login/user-login.js +407 -0
  11. package/dist/collection/index.js +1 -0
  12. package/dist/collection/utils/locale.utils.js +102 -0
  13. package/dist/collection/utils/utils.js +3 -0
  14. package/dist/esm/app-globals-0f993ce5.js +3 -0
  15. package/dist/esm/index-4e85bfaa.js +1214 -0
  16. package/dist/esm/index.js +1 -0
  17. package/dist/esm/loader.js +11 -0
  18. package/dist/esm/user-login.entry.js +308 -0
  19. package/dist/esm/user-login.js +20 -0
  20. package/dist/index.cjs.js +1 -0
  21. package/dist/index.js +1 -0
  22. package/dist/stencil.config.dev.js +17 -0
  23. package/dist/stencil.config.js +17 -0
  24. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/user-login/.stencil/packages/stencil/user-login/stencil.config.d.ts +2 -0
  25. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/user-login/.stencil/packages/stencil/user-login/stencil.config.dev.d.ts +2 -0
  26. package/dist/types/components/user-login/index.d.ts +1 -0
  27. package/dist/types/components/user-login/user-login.d.ts +82 -0
  28. package/dist/types/components.d.ts +117 -0
  29. package/dist/types/index.d.ts +1 -0
  30. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  31. package/dist/types/utils/locale.utils.d.ts +2 -0
  32. package/dist/types/utils/utils.d.ts +1 -0
  33. package/dist/user-login/index.esm.js +0 -0
  34. package/dist/user-login/p-a86a26ad.js +2 -0
  35. package/dist/user-login/p-bbb59f0e.entry.js +1 -0
  36. package/dist/user-login/p-e1255160.js +1 -0
  37. package/dist/user-login/user-login.esm.js +1 -0
  38. package/loader/cdn.js +1 -0
  39. package/loader/index.cjs.js +1 -0
  40. package/loader/index.d.ts +24 -0
  41. package/loader/index.es2017.js +1 -0
  42. package/loader/index.js +2 -0
  43. package/loader/package.json +11 -0
  44. package/package.json +26 -0
@@ -0,0 +1,407 @@
1
+ import { h } from "@stencil/core";
2
+ import { getTranslations, translate } from "../../utils/locale.utils";
3
+ export class UserLogin {
4
+ constructor() {
5
+ this.errorCode = '';
6
+ this.setClientStyling = () => {
7
+ let sheet = document.createElement('style');
8
+ sheet.innerHTML = this.clientStyling;
9
+ this.stylingContainer.appendChild(sheet);
10
+ };
11
+ this.setClientStylingURL = () => {
12
+ let url = new URL(this.clientStylingUrl);
13
+ let cssFile = document.createElement('style');
14
+ fetch(url.href)
15
+ .then((res) => res.text())
16
+ .then((data) => {
17
+ cssFile.innerHTML = data;
18
+ setTimeout(() => { this.stylingContainer.appendChild(cssFile); }, 1);
19
+ });
20
+ };
21
+ this.autofillCredentialsHandler = (e) => {
22
+ this.userNameEmail = e.detail.userNameEmail;
23
+ this.userPassword = e.detail.userPassword;
24
+ this.handleLogin();
25
+ };
26
+ this.userLogin = async ({ username, password }) => {
27
+ let headers = {
28
+ 'Content-Type': 'application/json'
29
+ };
30
+ let bodyData = {
31
+ username,
32
+ password
33
+ };
34
+ let options = {
35
+ method: 'POST',
36
+ headers,
37
+ body: JSON.stringify(bodyData),
38
+ };
39
+ fetch(`${this.endpoint}/v1/player/legislation/login`, options)
40
+ .then((res) => {
41
+ return res.json();
42
+ }).then((data) => {
43
+ var _a, _b, _c;
44
+ if ((_a = data.sessionBlockers) === null || _a === void 0 ? void 0 : _a.includes('has-to-set-consents')) {
45
+ window.postMessage({ type: 'PlayerActions', gmversion: 'gm16' }, window.location.href);
46
+ }
47
+ if ((data === null || data === void 0 ? void 0 : data.hasToSetPass) === true) {
48
+ window.postMessage({ type: 'HasToSetPass' }, window.location.href);
49
+ }
50
+ if (data.sessionId) {
51
+ window.postMessage({ type: 'UserSessionID', session: data.sessionId, userid: data.userId }, window.location.href);
52
+ window.postMessage({ type: 'WidgetNotification', data: {
53
+ type: 'success',
54
+ message: translate('successMessage', this.lang)
55
+ } }, window.location.href);
56
+ this.hasError = false;
57
+ }
58
+ else {
59
+ // handles errors thrown by api
60
+ this.hasError = true;
61
+ this.errorCode = (_b = data === null || data === void 0 ? void 0 : data.thirdPartyResponse) === null || _b === void 0 ? void 0 : _b.errorCode;
62
+ this.errorMessage = translate(`${this.errorCode}`, this.lang) || ((_c = data === null || data === void 0 ? void 0 : data.thirdPartyResponse) === null || _c === void 0 ? void 0 : _c.message) || translate('genericError', this.lang);
63
+ if (this.errorMessage) {
64
+ console.error(this.errorMessage);
65
+ this.sendErrorNotification(this.errorMessage);
66
+ }
67
+ }
68
+ }).catch((err) => {
69
+ // handles unexpected errors
70
+ console.error(err);
71
+ this.hasError = true;
72
+ this.errorMessage = translate('genericError', this.lang);
73
+ this.sendErrorNotification(this.errorMessage);
74
+ });
75
+ };
76
+ this.debouncedUserLogin = this.debounce(this.userLogin, 850);
77
+ this.handleLogin = () => {
78
+ this.debouncedUserLogin({
79
+ username: this.userNameEmail,
80
+ password: this.userPassword
81
+ });
82
+ this.dispatchUpdateLoginCredentialsEvent();
83
+ };
84
+ this.handleInputChange = (event, location) => {
85
+ this.hasError = false;
86
+ const inputValue = event.target.value;
87
+ if (location === 'user') {
88
+ this.userNameEmail = inputValue;
89
+ this.isValidUserEmail = this.userEmailValidation(this.userNameEmail);
90
+ }
91
+ else {
92
+ this.userPassword = inputValue;
93
+ this.isValidPassword = this.passwordValidation(inputValue);
94
+ }
95
+ };
96
+ this.userEmailValidation = (input) => {
97
+ const regex = new RegExp(this.userEmailRegex, this.userEmailRegexOptions);
98
+ return regex.test(input);
99
+ };
100
+ this.passwordValidation = (input) => {
101
+ const regex = new RegExp(this.passwordRegex, this.passwordRegexOptions);
102
+ return regex.test(input);
103
+ };
104
+ this.togglePassword = () => {
105
+ this.isPasswordVisible = !this.isPasswordVisible;
106
+ };
107
+ this.resetPassword = () => {
108
+ window.postMessage({ type: "NavForgotPassword" }, window.location.href);
109
+ };
110
+ this.endpoint = '';
111
+ this.lang = 'en';
112
+ this.clientStyling = '';
113
+ this.clientStylingUrl = '';
114
+ this.translationUrl = '';
115
+ this.passwordReset = 'false';
116
+ this.userEmailRegex = undefined;
117
+ this.userEmailRegexOptions = 'i';
118
+ this.passwordRegex = undefined;
119
+ this.passwordRegexOptions = '';
120
+ this.userNameEmail = '';
121
+ this.userPassword = '';
122
+ this.isValidUserEmail = true;
123
+ this.isValidPassword = true;
124
+ this.isPasswordVisible = false;
125
+ this.limitStylingAppends = false;
126
+ this.errorMessage = '';
127
+ this.hasError = false;
128
+ }
129
+ handleNewTranslations() {
130
+ getTranslations(this.translationUrl);
131
+ }
132
+ async componentWillLoad() {
133
+ if (this.translationUrl.length > 2) {
134
+ await getTranslations(this.translationUrl);
135
+ }
136
+ }
137
+ componentDidLoad() {
138
+ window.addEventListener('LoginCredentials', this.autofillCredentialsHandler);
139
+ window.postMessage({ type: 'UserLoginDidLoad' });
140
+ }
141
+ componentDidRender() {
142
+ // start custom styling area
143
+ if (!this.limitStylingAppends && this.stylingContainer) {
144
+ if (this.clientStyling)
145
+ this.setClientStyling();
146
+ if (this.clientStylingUrl)
147
+ this.setClientStylingURL();
148
+ this.limitStylingAppends = true;
149
+ }
150
+ // end custom styling area
151
+ }
152
+ disconnectedCallback() {
153
+ window.removeEventListener('LoginCredentials', this.autofillCredentialsHandler);
154
+ }
155
+ sendErrorNotification(errorMessage) {
156
+ window.postMessage({ type: "HasError", error: errorMessage }, window.location.href);
157
+ window.postMessage({ type: 'WidgetNotification', data: {
158
+ type: 'error',
159
+ message: errorMessage
160
+ } }, window.location.href);
161
+ }
162
+ debounce(func, delay) {
163
+ let timer;
164
+ return function (...args) {
165
+ clearTimeout(timer);
166
+ timer = setTimeout(() => {
167
+ func.apply(this, args);
168
+ }, delay);
169
+ };
170
+ }
171
+ dispatchUpdateLoginCredentialsEvent() {
172
+ if (!this.hasError) {
173
+ this.updateLoginCredentialsEvent = new CustomEvent("UpdateLoginCredentials", {
174
+ bubbles: true,
175
+ detail: {
176
+ userNameEmail: this.userNameEmail,
177
+ userPassword: this.userPassword
178
+ }
179
+ });
180
+ window.dispatchEvent(this.updateLoginCredentialsEvent);
181
+ }
182
+ }
183
+ ;
184
+ render() {
185
+ let visibilityIcon = h("span", { key: '4ccb9d4b1c8209e22320c3667101b9e435d1b604', class: "InputIcon" }, this.isPasswordVisible &&
186
+ h("svg", { key: 'fd168b4ec7ed18213aef15d5c7bcb89183b5626d', onClick: () => this.togglePassword(), class: "TogglePasswordVisibility", part: "TogglePasswordVisibility", xmlns: "http://www.w3.org/2000/svg", width: "18.844", height: "12.887", viewBox: "0 0 18.844 12.887" }, h("g", { key: '3ab8953db8743082bb19d4f97ae6191724145a0e', transform: "translate(-110.856 -23.242)" }, h("circle", { key: '716eb0de02150f4d5791cb7cf1cf7e904de4e8b9', class: "PasswordVisibilityIcon", cx: "0.05", cy: "0.05", r: "0.05", transform: "translate(121.017 31.148)" }), h("g", { key: '4ca623e6f31b09dbf6495fe657e9f6b67bfddbd8', transform: "translate(117.499 27.37)" }, h("path", { key: '0377c51b5536b07d0cefb77ed82d714fc82b5d9e', class: "PasswordVisibilityIcon", d: "M147.413,43.174a2.774,2.774,0,0,0-3.229-3.943Z", transform: "translate(-142.164 -39.123)" }), h("path", { key: '3ee2f6849511a3ce18ccfcaea0b503f1b9e57329', class: "PasswordVisibilityIcon", d: "M137.031,43.1a2.778,2.778,0,0,0,3.447,4.209Z", transform: "translate(-136.413 -42.068)" })), h("g", { key: '24fab8dc6f6ef08ef1a36227156b768925a2a7ba', transform: "translate(110.856 24.899)" }, h("path", { key: 'b41b45065b8f55772bbdfbced34ef4d7736c133a', class: "PasswordVisibilityIcon", d: "M122.538,42.061a7.043,7.043,0,0,1-2.325.53,10.373,10.373,0,0,1-4.393-1.482,36.509,36.509,0,0,1-3.873-2.391.13.13,0,0,1,0-.208,44.141,44.141,0,0,1,3.873-2.651c.394-.233.768-.437,1.13-.622l-.686-.838c-.322.167-.651.347-.99.55a37.989,37.989,0,0,0-3.977,2.729,1.21,1.21,0,0,0-.442.962,1.1,1.1,0,0,0,.494.936,34.416,34.416,0,0,0,3.977,2.469,11.468,11.468,0,0,0,4.886,1.611,8.427,8.427,0,0,0,3.039-.725Z", transform: "translate(-110.856 -33.157)" }), h("path", { key: '39f77d5f4028baf654fdc07a2f03525b994d508f', class: "PasswordVisibilityIcon", d: "M149.119,34.14a45.875,45.875,0,0,0-4.055-2.729,20.541,20.541,0,0,0-2.547-1.248,5.6,5.6,0,0,0-4.79-.017l.7.856a5.254,5.254,0,0,1,1.672-.346,10.072,10.072,0,0,1,4.445,1.663,34.132,34.132,0,0,1,3.925,2.651.13.13,0,0,1,0,.208,40.2,40.2,0,0,1-3.925,2.391c-.179.092-.352.176-.525.26l.684.835c.1-.054.2-.1.309-.159a36.356,36.356,0,0,0,4.055-2.469,1.067,1.067,0,0,0,.52-.936A1.159,1.159,0,0,0,149.119,34.14Z", transform: "translate(-130.743 -29.617)" })), h("rect", { key: '74bdc0477190de8bd67e30e0799ed1d4c255fff0', class: "PasswordVisibilityIcon", width: "0.972", height: "15.861", rx: "0.486", transform: "translate(114.827 23.858) rotate(-39.315)" }))), !this.isPasswordVisible &&
187
+ h("svg", { key: '89e71e7d5fc2af237c7a0af69838a60f997dc0ee', onClick: () => this.togglePassword(), class: "TogglePasswordVisibility PasswordVisible", part: "TogglePasswordVisibility", xmlns: "http://www.w3.org/2000/svg", width: "18.843", height: "10.5", viewBox: "0 0 18.843 10.5" }, h("g", { key: '97447b59b0e079f3b2a154681aef2cef572e445b', transform: "translate(-14.185 -27.832)" }, h("path", { key: 'c35b80be71460f5fc0c469ee807e3f83f5ab1cb9', class: "PasswordVisibilityIcon", d: "M23.541,38.332a11.467,11.467,0,0,1-4.886-1.611,34.413,34.413,0,0,1-3.976-2.469,1.1,1.1,0,0,1-.494-.936,1.21,1.21,0,0,1,.442-.962A37.986,37.986,0,0,1,18.6,29.625a16.06,16.06,0,0,1,2.521-1.248,6.862,6.862,0,0,1,2.417-.546,6.862,6.862,0,0,1,2.417.546,20.541,20.541,0,0,1,2.547,1.248,45.872,45.872,0,0,1,4.054,2.729,1.159,1.159,0,0,1,.468.962,1.067,1.067,0,0,1-.52.936,36.353,36.353,0,0,1-4.054,2.469A11.2,11.2,0,0,1,23.541,38.332Zm0-9.46a9.813,9.813,0,0,0-4.392,1.663,44.138,44.138,0,0,0-3.873,2.651.13.13,0,0,0,0,.208,36.5,36.5,0,0,0,3.873,2.391,10.372,10.372,0,0,0,4.392,1.481,11.051,11.051,0,0,0,4.444-1.481,40.2,40.2,0,0,0,3.925-2.391.13.13,0,0,0,0-.208h0a34.132,34.132,0,0,0-3.925-2.651A10.072,10.072,0,0,0,23.541,28.872Z", transform: "translate(0)" }), h("circle", { key: '3a6bfc9d02b7c66ecd0e07481e1963a6bcab3fb0', class: "PasswordVisibilityIcon", cx: "2.779", cy: "2.779", r: "2.779", transform: "translate(20.827 30.303)" }))));
188
+ let userIdentification = h("div", { key: '5b43adf706d46ce330b81e0bc5e8bbd1bfc2b883', class: "FormBox" }, h("div", { key: '0c53a0428fbcb10876e16d0505cf895c5bffa3bd', class: "FormValue" }, h("div", { key: '8aeda926da67db1e58595287f15d815e7887dc45', class: (!this.isValidUserEmail || this.hasError) ? 'InputBox InputInvalidBox' : 'InputBox' }, h("input", { key: 'bf82f8b419fe217143d3928262b9b256e43a9f79', type: "text", placeholder: '', value: this.userNameEmail, onFocus: (event) => this.handleInputChange(event, 'user'), onInput: (event) => this.handleInputChange(event, 'user'), autocapitalize: "none", required: true }), h("label", { key: '7a0f71f2c013c8d00d0d7c66452e09badfd17bb3', class: (this.userNameEmail ? 'FieldFilledIn' : '') + ' ' + (!this.isValidUserEmail || this.hasError ? 'FieldInvalid' : '') }, translate('userEmail', this.lang)), !this.isValidUserEmail &&
189
+ h("p", { key: 'ed3453e628b9d60f8df2c3c1e04024706c532bfd', class: "InvalidField" }, translate('invalidField', this.lang))), h("div", { key: 'c778082662a1f29bdb6b19799c702ce3b4773a0a', class: (!this.isValidPassword || this.hasError) ? 'InputBox InputInvalidBox' : 'InputBox' }, visibilityIcon, h("input", { key: '7cbdd79f39f986efc4cfadf0577782c86af8eec9', type: this.isPasswordVisible ? "text" : "password", placeholder: '', value: this.userPassword, onFocus: (event) => this.handleInputChange(event, 'password'), onInput: (event) => this.handleInputChange(event, 'password'), autocapitalize: "none", required: true }), h("label", { key: '94d576059031cb459757f417245a241a768137fe', class: (this.userPassword ? 'FieldFilledIn' : '') + ' ' + (!this.isValidPassword || this.hasError ? 'FieldInvalid' : '') }, translate('password', this.lang)), !this.isValidPassword &&
190
+ h("p", { key: '9c961763ac1a5c3af53d63b4b4423f22d341f2a4', class: "InvalidField" }, translate('invalidField', this.lang))), this.passwordReset == 'true' &&
191
+ h("div", { key: '9f0730d9d3000def2d5b0edb2fcef7c2b77633cf', class: "ForgotPassword" }, h("button", { key: '3bd5379cf60cba95c1338968c451366264bec081', onClick: () => this.resetPassword() }, translate('forgotPassword', this.lang))), h("button", { key: '7a5ac0291a075d7c4f1a1f235dc6be2ccfa2239e', disabled: (!this.isValidUserEmail || !this.isValidPassword || !this.userNameEmail || !this.userPassword), class: "SubmitCredentials", onClick: () => this.handleLogin() }, translate('login', this.lang)), this.hasError &&
192
+ h("p", { key: 'f40b7b875d615bb6af19dac753910763638409a8', class: "CredentialsError" }, this.errorMessage)));
193
+ return h("section", { key: '6c0b3e43c5fdd9993a02f11b9bfa817b2a5069f2', ref: el => this.stylingContainer = el }, userIdentification);
194
+ }
195
+ static get is() { return "user-login"; }
196
+ static get encapsulation() { return "shadow"; }
197
+ static get originalStyleUrls() {
198
+ return {
199
+ "$": ["user-login.scss"]
200
+ };
201
+ }
202
+ static get styleUrls() {
203
+ return {
204
+ "$": ["user-login.css"]
205
+ };
206
+ }
207
+ static get properties() {
208
+ return {
209
+ "endpoint": {
210
+ "type": "string",
211
+ "mutable": false,
212
+ "complexType": {
213
+ "original": "string",
214
+ "resolved": "string",
215
+ "references": {}
216
+ },
217
+ "required": false,
218
+ "optional": false,
219
+ "docs": {
220
+ "tags": [],
221
+ "text": "Endpoint"
222
+ },
223
+ "attribute": "endpoint",
224
+ "reflect": true,
225
+ "defaultValue": "''"
226
+ },
227
+ "lang": {
228
+ "type": "string",
229
+ "mutable": true,
230
+ "complexType": {
231
+ "original": "string",
232
+ "resolved": "string",
233
+ "references": {}
234
+ },
235
+ "required": false,
236
+ "optional": false,
237
+ "docs": {
238
+ "tags": [],
239
+ "text": "Language"
240
+ },
241
+ "attribute": "lang",
242
+ "reflect": true,
243
+ "defaultValue": "'en'"
244
+ },
245
+ "clientStyling": {
246
+ "type": "string",
247
+ "mutable": false,
248
+ "complexType": {
249
+ "original": "string",
250
+ "resolved": "string",
251
+ "references": {}
252
+ },
253
+ "required": false,
254
+ "optional": false,
255
+ "docs": {
256
+ "tags": [],
257
+ "text": "Client styling"
258
+ },
259
+ "attribute": "client-styling",
260
+ "reflect": true,
261
+ "defaultValue": "''"
262
+ },
263
+ "clientStylingUrl": {
264
+ "type": "string",
265
+ "mutable": false,
266
+ "complexType": {
267
+ "original": "string",
268
+ "resolved": "string",
269
+ "references": {}
270
+ },
271
+ "required": false,
272
+ "optional": false,
273
+ "docs": {
274
+ "tags": [],
275
+ "text": "Client styling by url"
276
+ },
277
+ "attribute": "client-styling-url",
278
+ "reflect": true,
279
+ "defaultValue": "''"
280
+ },
281
+ "translationUrl": {
282
+ "type": "string",
283
+ "mutable": false,
284
+ "complexType": {
285
+ "original": "string",
286
+ "resolved": "string",
287
+ "references": {}
288
+ },
289
+ "required": false,
290
+ "optional": false,
291
+ "docs": {
292
+ "tags": [],
293
+ "text": "Translation url"
294
+ },
295
+ "attribute": "translation-url",
296
+ "reflect": true,
297
+ "defaultValue": "''"
298
+ },
299
+ "passwordReset": {
300
+ "type": "string",
301
+ "mutable": false,
302
+ "complexType": {
303
+ "original": "string",
304
+ "resolved": "string",
305
+ "references": {}
306
+ },
307
+ "required": false,
308
+ "optional": false,
309
+ "docs": {
310
+ "tags": [],
311
+ "text": "Password reset"
312
+ },
313
+ "attribute": "password-reset",
314
+ "reflect": true,
315
+ "defaultValue": "'false'"
316
+ },
317
+ "userEmailRegex": {
318
+ "type": "string",
319
+ "mutable": false,
320
+ "complexType": {
321
+ "original": "string",
322
+ "resolved": "string",
323
+ "references": {}
324
+ },
325
+ "required": false,
326
+ "optional": false,
327
+ "docs": {
328
+ "tags": [],
329
+ "text": "User email regex"
330
+ },
331
+ "attribute": "user-email-regex",
332
+ "reflect": true
333
+ },
334
+ "userEmailRegexOptions": {
335
+ "type": "string",
336
+ "mutable": false,
337
+ "complexType": {
338
+ "original": "string",
339
+ "resolved": "string",
340
+ "references": {}
341
+ },
342
+ "required": false,
343
+ "optional": false,
344
+ "docs": {
345
+ "tags": [],
346
+ "text": "User email regex options"
347
+ },
348
+ "attribute": "user-email-regex-options",
349
+ "reflect": true,
350
+ "defaultValue": "'i'"
351
+ },
352
+ "passwordRegex": {
353
+ "type": "string",
354
+ "mutable": false,
355
+ "complexType": {
356
+ "original": "string",
357
+ "resolved": "string",
358
+ "references": {}
359
+ },
360
+ "required": false,
361
+ "optional": false,
362
+ "docs": {
363
+ "tags": [],
364
+ "text": "Password regex"
365
+ },
366
+ "attribute": "password-regex",
367
+ "reflect": true
368
+ },
369
+ "passwordRegexOptions": {
370
+ "type": "string",
371
+ "mutable": false,
372
+ "complexType": {
373
+ "original": "string",
374
+ "resolved": "string",
375
+ "references": {}
376
+ },
377
+ "required": false,
378
+ "optional": false,
379
+ "docs": {
380
+ "tags": [],
381
+ "text": "Password regex options"
382
+ },
383
+ "attribute": "password-regex-options",
384
+ "reflect": true,
385
+ "defaultValue": "''"
386
+ }
387
+ };
388
+ }
389
+ static get states() {
390
+ return {
391
+ "userNameEmail": {},
392
+ "userPassword": {},
393
+ "isValidUserEmail": {},
394
+ "isValidPassword": {},
395
+ "isPasswordVisible": {},
396
+ "limitStylingAppends": {},
397
+ "errorMessage": {},
398
+ "hasError": {}
399
+ };
400
+ }
401
+ static get watchers() {
402
+ return [{
403
+ "propName": "translationUrl",
404
+ "methodName": "handleNewTranslations"
405
+ }];
406
+ }
407
+ }
@@ -0,0 +1 @@
1
+ export * from './components';
@@ -0,0 +1,102 @@
1
+ const DEFAULT_LANGUAGE = 'en';
2
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'cz', 'de', 'hr'];
3
+ const TRANSLATIONS = {
4
+ en: {
5
+ invalidField: 'This field is invalid',
6
+ forgotPassword: 'Forgot Password',
7
+ userEmail: 'Username or Email',
8
+ password: 'Password',
9
+ login: 'Login',
10
+ genericError: 'An unexpected error has occured',
11
+ successMessage: 'Login successful'
12
+ },
13
+ ro: {
14
+ invalidField: 'This field is invalid',
15
+ forgotPassword: 'Forgot Password',
16
+ userEmail: 'Username or Email',
17
+ password: 'Password',
18
+ login: 'Login',
19
+ genericError: 'An unexpected error has occured',
20
+ successMessage: 'Login successful'
21
+ },
22
+ hr: {
23
+ invalidField: 'Ovo polje je nevažeće',
24
+ forgotPassword: 'Zaboravljena lozinka',
25
+ userEmail: 'Korisničko ime ili email',
26
+ password: 'Lozinka',
27
+ login: 'Prijava',
28
+ genericError: 'Došlo je do neočekivane pogreške',
29
+ successMessage: 'Prijava uspješna'
30
+ },
31
+ fr: {
32
+ invalidField: 'This field is invalid',
33
+ forgotPassword: 'Forgot Password',
34
+ userEmail: 'Username or Email',
35
+ password: 'Password',
36
+ login: 'Login',
37
+ genericError: 'An unexpected error has occured',
38
+ successMessage: 'Login successful'
39
+ },
40
+ cs: {
41
+ invalidField: 'Ovo polje je nevažeće.',
42
+ forgotPassword: 'Zaboravio sam lozinku ',
43
+ userEmail: 'Korisničko ime ili email',
44
+ password: 'Lozinka',
45
+ login: 'Prijava',
46
+ genericError: 'An unexpected error has occured',
47
+ successMessage: 'Login successful'
48
+ },
49
+ de: {
50
+ invalidField: 'This field is invalid',
51
+ forgotPassword: 'Forgot Password',
52
+ userEmail: 'Username or Email',
53
+ password: 'Password',
54
+ login: 'Login',
55
+ genericError: 'An unexpected error has occured',
56
+ successMessage: 'Login successful'
57
+ },
58
+ 'pt-br': {
59
+ 'invalidField': 'O campo é inválido',
60
+ 'forgotPassword': 'Esqueceu sua senha',
61
+ 'userEmail': 'Usuário ou e-mail',
62
+ 'Password': 'Senha',
63
+ 'login': 'Entrem',
64
+ 'genericError': 'Ocorreu um erro inesperado',
65
+ 'successMessage': 'Você fez login com sucesso'
66
+ },
67
+ 'es-mx': {
68
+ 'invalidField': 'El campo es inválido',
69
+ 'forgotPassword': 'Olvidó contraseña',
70
+ 'userEmail': 'Usuario o Correo Electrónico',
71
+ 'Password': 'Contraseña',
72
+ 'login': 'Entrar',
73
+ 'genericError': 'Ha ocurrido un error inesperado',
74
+ 'successMessage': 'Ha ingreasado de forma exitosa'
75
+ }
76
+ };
77
+ export const getTranslations = (url) => {
78
+ // fetch url, get the data, replace the TRANSLATIONS content
79
+ return new Promise((resolve) => {
80
+ fetch(url)
81
+ .then((res) => res.json())
82
+ .then((data) => {
83
+ Object.keys(data).forEach((item) => {
84
+ for (let key in data[item]) {
85
+ TRANSLATIONS[item][key] = data[item][key];
86
+ }
87
+ });
88
+ resolve(true);
89
+ });
90
+ });
91
+ };
92
+ export const translate = (key, customLang, values) => {
93
+ const lang = customLang;
94
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
95
+ if (values !== undefined) {
96
+ for (const [key, value] of Object.entries(values.values)) {
97
+ const regex = new RegExp(`{${key}}`, 'g');
98
+ translation = translation.replace(regex, value);
99
+ }
100
+ }
101
+ return translation;
102
+ };
@@ -0,0 +1,3 @@
1
+ export function format(first, middle, last) {
2
+ return ((first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : ''));
3
+ }
@@ -0,0 +1,3 @@
1
+ const globalScripts = () => {};
2
+
3
+ export { globalScripts as g };