@everymatrix/general-player-login-form 0.0.214 → 0.0.218
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everymatrix/general-player-login-form",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.218",
|
|
4
4
|
"main": "dist/general-player-login-form.js",
|
|
5
5
|
"svelte": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "ae78406d20c106f1d3c352c0e97189a7bdffacfb"
|
|
40
40
|
}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
<svelte:options tag={null} />
|
|
2
2
|
|
|
3
|
-
<script lang="
|
|
3
|
+
<script lang="ts">
|
|
4
4
|
import { onMount } from "svelte";
|
|
5
5
|
import { isMobile } from 'rvhelper';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from '
|
|
7
|
+
// Native bridge
|
|
8
|
+
import { isNative, call as callNative, registerEventListener as registerNativeEventListener } from 'js-native-bridge';
|
|
9
|
+
|
|
10
|
+
import { _, addNewMessages, setLocale, setupI18n } from './i18n';
|
|
11
|
+
import { LoginForm } from './translations';
|
|
12
12
|
|
|
13
13
|
export let imagedesktop:string = '';
|
|
14
14
|
export let captchakey:string = '';
|
|
15
|
+
export let lang:string = '';
|
|
15
16
|
|
|
16
17
|
let mobileView:boolean = false;
|
|
17
18
|
let userAgent:string = window.navigator.userAgent;
|
|
18
19
|
let userValue:string = '';
|
|
19
20
|
let userPassword:string = '';
|
|
21
|
+
// @TODO Typescript type model for loginFormData
|
|
20
22
|
let loginFormData:any = {
|
|
21
23
|
username: '',
|
|
22
24
|
password: ''
|
|
@@ -31,12 +33,17 @@
|
|
|
31
33
|
let isPasswordVisible:boolean = false;
|
|
32
34
|
let isFormDataInvalid:boolean = true;
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
let
|
|
36
|
+
// Native bridge
|
|
37
|
+
let isOnNative:boolean = false;
|
|
38
|
+
let waitingForCredentials:boolean = false;
|
|
36
39
|
|
|
37
40
|
let nativeCredentials:any = {};
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
// setupI18n({ withLocale: 'en', translations: {}});
|
|
43
|
+
|
|
44
|
+
Object.keys(LoginForm).forEach((item:any) => {
|
|
45
|
+
addNewMessages(item, LoginForm[item]);
|
|
46
|
+
});
|
|
40
47
|
|
|
41
48
|
const regexValidators = {
|
|
42
49
|
user: /^(?!(?:.*\d){9})(?=(?:.*[a-zA-Z]){2})^[a-zA-Z\d]*$/,
|
|
@@ -141,10 +148,17 @@
|
|
|
141
148
|
}
|
|
142
149
|
}
|
|
143
150
|
|
|
151
|
+
const initialLoad = ():void => {
|
|
152
|
+
setLocale(lang);
|
|
153
|
+
}
|
|
154
|
+
|
|
144
155
|
onMount(async () => {
|
|
145
|
-
window.addEventListener(
|
|
156
|
+
window.addEventListener("message", messageHandler, false);
|
|
146
157
|
window.postMessage({ type: "LoginRegisterModalActive" }, window.location.href);
|
|
147
158
|
|
|
159
|
+
isOnNative = !!isNative(userAgent);
|
|
160
|
+
waitingForCredentials = isOnNative;
|
|
161
|
+
|
|
148
162
|
if (isOnNative) {
|
|
149
163
|
registerNativeEventListener(
|
|
150
164
|
'GET_CREDENTIALS',
|
|
@@ -177,6 +191,8 @@
|
|
|
177
191
|
window.removeEventListener('message', messageHandler);
|
|
178
192
|
}
|
|
179
193
|
});
|
|
194
|
+
|
|
195
|
+
$: lang && initialLoad();
|
|
180
196
|
</script>
|
|
181
197
|
|
|
182
198
|
<svelte:head>
|
|
@@ -193,35 +209,39 @@
|
|
|
193
209
|
<div class="FormContainer {mobileView ? 'FormMobileContainer' : ''}">
|
|
194
210
|
<div class="FormLeftSide">
|
|
195
211
|
<div class="FormHeader">
|
|
196
|
-
<h4 class="FormHeaderTitle">
|
|
197
|
-
<p class="FormHeaderSubtitle">
|
|
212
|
+
<h4 class="FormHeaderTitle">{$_('loginForm.loginTitle')}</h4>
|
|
213
|
+
<p class="FormHeaderSubtitle">{$_('loginForm.loginSubtitle')} <span class="FormRegisterCallToAction" on:click={() => switchToRegister()}>{$_('loginForm.loginSubtitleRegister')}</span></p>
|
|
198
214
|
</div>
|
|
199
|
-
|
|
200
|
-
<
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
{
|
|
204
|
-
<
|
|
215
|
+
{#if waitingForCredentials}
|
|
216
|
+
<p>Waiting for credentials</p>
|
|
217
|
+
{:else}
|
|
218
|
+
<div class="FormContent">
|
|
219
|
+
<div class="UserContainer {invalidName ? 'InvalidField' : ''}">
|
|
220
|
+
<label for="UserName">{$_('loginForm.loginUsername')}:<span class="FormRequired">*</span></label>
|
|
221
|
+
<input bind:value={userValue} on:keyup={validateUserName} type="text" id="UserName" />
|
|
222
|
+
{#if invalidName}
|
|
223
|
+
<p class="InvalidInput">{$_('loginForm.loginUsernameError')}</p>
|
|
224
|
+
{/if}
|
|
225
|
+
</div>
|
|
226
|
+
<div class="PasswordContainer {invalidPassword ? 'InvalidField' : ''}">
|
|
227
|
+
<label for="Password">{$_('loginForm.loginPassword')}:<span class="FormRequired">*</span></label>
|
|
228
|
+
<input bind:value={userPassword} on:keyup={validatePassword} type="password" id="Password" bind:this={passwordVisibilityToggle} />
|
|
229
|
+
{#if isPasswordVisible}
|
|
230
|
+
<svg on:click={() => hidePassword()} class="TogglePasswordVisibility" xmlns="http://www.w3.org/2000/svg" width="18.844" height="12.887" viewBox="0 0 18.844 12.887"><defs><style>.a{fill:#07072a;}</style></defs><g transform="translate(-110.856 -23.242)"><circle class="a" cx="0.05" cy="0.05" r="0.05" transform="translate(121.017 31.148)"/><g transform="translate(117.499 27.37)"><path class="a" d="M147.413,43.174a2.774,2.774,0,0,0-3.229-3.943Z" transform="translate(-142.164 -39.123)"/><path class="a" d="M137.031,43.1a2.778,2.778,0,0,0,3.447,4.209Z" transform="translate(-136.413 -42.068)"/></g><g transform="translate(110.856 24.899)"><path class="a" 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)"/><path class="a" 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)"/></g><rect class="a" width="0.972" height="15.861" rx="0.486" transform="translate(114.827 23.858) rotate(-39.315)"/></g></svg>
|
|
231
|
+
{:else}
|
|
232
|
+
<svg on:click={() => showPassword()} class="TogglePasswordVisibility" xmlns="http://www.w3.org/2000/svg" width="18.843" height="10.5" viewBox="0 0 18.843 10.5"><defs><style>.a{fill:#07072a;}</style></defs><g transform="translate(-14.185 -27.832)"><path class="a" 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)"/><circle class="a" cx="2.779" cy="2.779" r="2.779" transform="translate(20.827 30.303)"/></g></svg>
|
|
233
|
+
{/if}
|
|
234
|
+
{#if invalidPassword}
|
|
235
|
+
<p class="InvalidInput">{$_('loginForm.loginPasswordError')}</p>
|
|
236
|
+
{/if}
|
|
237
|
+
</div>
|
|
238
|
+
{#if errorMessage}
|
|
239
|
+
<p class="ErrorMessage">{errorMessage}</p>
|
|
205
240
|
{/if}
|
|
241
|
+
<button class="SignInButton" on:click={() => submitLoginForm()} disabled={isFormDataInvalid}>{$_('loginForm.loginButton')}</button>
|
|
242
|
+
<button class="ForgotPasswordButton" on:click={() => switchToForgotPassword()}>{$_('loginForm.loginForgotPassword')}</button>
|
|
206
243
|
</div>
|
|
207
|
-
|
|
208
|
-
<label for="Password">Password:<span class="FormRequired">*</span></label>
|
|
209
|
-
<input bind:value={userPassword} on:keyup={validatePassword} type="password" id="Password" bind:this={passwordVisibilityToggle} />
|
|
210
|
-
{#if isPasswordVisible}
|
|
211
|
-
<svg on:click={() => hidePassword()} class="TogglePasswordVisibility" xmlns="http://www.w3.org/2000/svg" width="18.844" height="12.887" viewBox="0 0 18.844 12.887"><defs><style>.a{fill:#07072a;}</style></defs><g transform="translate(-110.856 -23.242)"><circle class="a" cx="0.05" cy="0.05" r="0.05" transform="translate(121.017 31.148)"/><g transform="translate(117.499 27.37)"><path class="a" d="M147.413,43.174a2.774,2.774,0,0,0-3.229-3.943Z" transform="translate(-142.164 -39.123)"/><path class="a" d="M137.031,43.1a2.778,2.778,0,0,0,3.447,4.209Z" transform="translate(-136.413 -42.068)"/></g><g transform="translate(110.856 24.899)"><path class="a" 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)"/><path class="a" 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)"/></g><rect class="a" width="0.972" height="15.861" rx="0.486" transform="translate(114.827 23.858) rotate(-39.315)"/></g></svg>
|
|
212
|
-
{:else}
|
|
213
|
-
<svg on:click={() => showPassword()} class="TogglePasswordVisibility" xmlns="http://www.w3.org/2000/svg" width="18.843" height="10.5" viewBox="0 0 18.843 10.5"><defs><style>.a{fill:#07072a;}</style></defs><g transform="translate(-14.185 -27.832)"><path class="a" 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)"/><circle class="a" cx="2.779" cy="2.779" r="2.779" transform="translate(20.827 30.303)"/></g></svg>
|
|
214
|
-
{/if}
|
|
215
|
-
{#if invalidPassword}
|
|
216
|
-
<p class="InvalidInput">Password must be 8-20 characters long, and contain at least 1 uppercase letter, 1 number and 1 special character.</p>
|
|
217
|
-
{/if}
|
|
218
|
-
</div>
|
|
219
|
-
{#if errorMessage}
|
|
220
|
-
<p class="ErrorMessage">{errorMessage}</p>
|
|
221
|
-
{/if}
|
|
222
|
-
<button class="SignInButton" on:click={() => submitLoginForm()} disabled={isFormDataInvalid}>Sign In</button>
|
|
223
|
-
<button class="ForgotPasswordButton" on:click={() => switchToForgotPassword()}>I forgot my password</button>
|
|
224
|
-
</div>
|
|
244
|
+
{/if}
|
|
225
245
|
</div>
|
|
226
246
|
{#if !mobileView}
|
|
227
247
|
<div class="FormRightSide" style="background-image: url('{imagedesktop}')"></div>
|
|
@@ -261,7 +281,7 @@
|
|
|
261
281
|
}
|
|
262
282
|
.FormHeaderTitle {
|
|
263
283
|
color: #000000;
|
|
264
|
-
font-size:
|
|
284
|
+
font-size: 20px;
|
|
265
285
|
font-weight: 300;
|
|
266
286
|
padding: 0;
|
|
267
287
|
text-transform: uppercase;
|
package/src/i18n.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dictionary,
|
|
3
|
+
locale,
|
|
4
|
+
addMessages,
|
|
5
|
+
_
|
|
6
|
+
} from 'svelte-i18n';
|
|
7
|
+
|
|
8
|
+
function setupI18n({ withLocale: _locale, translations }) {
|
|
9
|
+
locale.subscribe((data) => {
|
|
10
|
+
if (data == null) {
|
|
11
|
+
dictionary.set(translations);
|
|
12
|
+
locale.set(_locale);
|
|
13
|
+
}
|
|
14
|
+
}); // maybe we will need this to make sure that the i18n is set up only once
|
|
15
|
+
/*dictionary.set(translations);
|
|
16
|
+
locale.set(_locale);*/
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function addNewMessages(lang, dict) {
|
|
20
|
+
addMessages(lang, dict);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function setLocale(_locale) {
|
|
24
|
+
locale.set(_locale);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { _, setupI18n, addNewMessages, setLocale };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const LoginForm = {
|
|
2
|
+
en: {
|
|
3
|
+
loginForm: {
|
|
4
|
+
loginTitle: 'Welcome',
|
|
5
|
+
loginSubtitle: 'Don\'t have an account yet?',
|
|
6
|
+
loginSubtitleRegister: 'Register now',
|
|
7
|
+
loginUsername: 'Username or Email',
|
|
8
|
+
loginUsernameError: 'Name must be at least 2 characters long and contain no special characters. Email should contain \'@\' and a 2-3 letter long domain.',
|
|
9
|
+
loginPassword: 'Password',
|
|
10
|
+
loginPasswordError: 'Password must be 8-20 characters long and contain at least 1 uppercase letter, 1 number and 1 special character.',
|
|
11
|
+
loginButton: 'Login',
|
|
12
|
+
loginForgotPassword: 'I forgot my password'
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
tr: {
|
|
16
|
+
loginForm: {
|
|
17
|
+
loginTitle: 'Hoş geldin',
|
|
18
|
+
loginSubtitle: 'Henüz bir hesabınız yok mu?',
|
|
19
|
+
loginSubtitleRegister: 'Şimdi üye Ol',
|
|
20
|
+
loginUsername: 'Kullanıcı adı ya da email',
|
|
21
|
+
loginUsernameError: 'Ad en az 2 karakter uzunluğunda olmalı ve özel karakter içermemelidir. E-posta \'@\' ve 2-3 harf uzunluğunda bir etki alanı içermelidir.',
|
|
22
|
+
loginPassword: 'Parola',
|
|
23
|
+
loginPasswordError: 'Şifre 8-20 karakter uzunluğunda olmalı ve en az 1 büyük harf, 1 rakam ve 1 özel karakter içermelidir.',
|
|
24
|
+
loginButton: 'Giriş yapmak',
|
|
25
|
+
loginForgotPassword: 'I forgot my password'
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
ro: {
|
|
29
|
+
loginForm: {
|
|
30
|
+
loginTitle: 'Bine ai venit',
|
|
31
|
+
loginSubtitle: 'Nu ai cont?',
|
|
32
|
+
loginSubtitleRegister: 'Inregistreaza-te acum',
|
|
33
|
+
loginUsername: 'Utilizator sau Email',
|
|
34
|
+
loginUsernameError: 'Utilizatorul trebuie sa aiba minim 2 litere si sa nu contina caractere speciale. Email-ul trebuie sa contina \'@\' si domeniul sa aiba 2-3 litere lungime.',
|
|
35
|
+
loginPassword: 'Parola',
|
|
36
|
+
loginPasswordError: 'Parola trebuie sa aiba o lungime de 8-20 de caractere, sa contina cel putin o litera mare, o cifra si un caracter special.',
|
|
37
|
+
loginButton: 'Autentificare',
|
|
38
|
+
loginForgotPassword: 'Mi-am uitat parola'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|