@pocketprep/ui-kit 3.0.16 → 3.0.18
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/@pocketprep/ui-kit.js +268 -249
- package/dist/@pocketprep/ui-kit.js.map +1 -1
- package/dist/@pocketprep/ui-kit.umd.cjs +4 -4
- package/dist/@pocketprep/ui-kit.umd.cjs.map +1 -1
- package/lib/components/Onboarding/EmailAuth.vue +8 -12
- package/lib/components/Onboarding/MagicCodeEntry.vue +18 -15
- package/lib/utils.ts +7 -0
- package/package.json +1 -1
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
'uikit-email-auth__magic-code-entry--error': errorMessage,
|
|
13
13
|
}"
|
|
14
14
|
:error="errorMessage"
|
|
15
|
-
|
|
15
|
+
:modelValue="modelValue"
|
|
16
|
+
@update:modelValue="emitUpdateModelValue"
|
|
16
17
|
@error="(err: string) => errorMessage = err"
|
|
17
18
|
@submit="submitSignIn"
|
|
18
19
|
/>
|
|
@@ -25,8 +26,8 @@
|
|
|
25
26
|
:class="{
|
|
26
27
|
'uikit-email-auth__sign-in-btn--error': errorMessage,
|
|
27
28
|
}"
|
|
28
|
-
:disabled="
|
|
29
|
-
:autofocus="
|
|
29
|
+
:disabled="modelValue.length !== 6 || isLoading"
|
|
30
|
+
:autofocus="modelValue.length === 6"
|
|
30
31
|
@click="submitSignIn"
|
|
31
32
|
>
|
|
32
33
|
Sign In
|
|
@@ -60,8 +61,8 @@ import MagicCodeEntry from '../Onboarding/MagicCodeEntry.vue'
|
|
|
60
61
|
export default class EmailAuth extends Vue {
|
|
61
62
|
@Prop({ default: '' }) parentError!: string
|
|
62
63
|
@Prop() email!: string
|
|
64
|
+
@Prop({ default: '' }) modelValue!: string
|
|
63
65
|
|
|
64
|
-
code = ''
|
|
65
66
|
errorMessage = ''
|
|
66
67
|
isLoading = false
|
|
67
68
|
isResending = false
|
|
@@ -78,11 +79,11 @@ export default class EmailAuth extends Vue {
|
|
|
78
79
|
this.isLoading = true
|
|
79
80
|
this.errorMessage = ''
|
|
80
81
|
|
|
81
|
-
if (this.email && this.
|
|
82
|
-
if (this.
|
|
82
|
+
if (this.email && this.modelValue) {
|
|
83
|
+
if (this.modelValue.trim().length !== 6) {
|
|
83
84
|
this.errorMessage = 'Code must be six digits'
|
|
84
85
|
} else {
|
|
85
|
-
this.emitSubmit({ email: this.email, code: this.
|
|
86
|
+
this.emitSubmit({ email: this.email, code: this.modelValue })
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -96,11 +97,6 @@ export default class EmailAuth extends Vue {
|
|
|
96
97
|
this.isResending = false
|
|
97
98
|
}
|
|
98
99
|
|
|
99
|
-
magicCodeChange (code: string) {
|
|
100
|
-
this.code = code
|
|
101
|
-
this.emitUpdateModelValue(code)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
100
|
@Emit('submit')
|
|
105
101
|
emitSubmit (results: { email: string; code: string}) {
|
|
106
102
|
return results
|
|
@@ -10,12 +10,16 @@
|
|
|
10
10
|
}"
|
|
11
11
|
/>
|
|
12
12
|
<input
|
|
13
|
-
|
|
13
|
+
:value="modelValue"
|
|
14
|
+
@input="event => event.target
|
|
15
|
+
&& 'value' in event.target
|
|
16
|
+
&& emitUpdateModelValue(event.target.value as string)
|
|
17
|
+
"
|
|
14
18
|
aria-label="Magic code input field"
|
|
15
19
|
class="uikit-magic-code__code-input"
|
|
16
20
|
type="text"
|
|
17
21
|
maxlength="6"
|
|
18
|
-
:autofocus="
|
|
22
|
+
:autofocus="modelValue.length !== 6"
|
|
19
23
|
@focus="highlightInput = true"
|
|
20
24
|
@blur="highlightInput = false"
|
|
21
25
|
@click="handleClick"
|
|
@@ -25,15 +29,15 @@
|
|
|
25
29
|
</template>
|
|
26
30
|
|
|
27
31
|
<script lang="ts">
|
|
28
|
-
import { Vue, Component,
|
|
32
|
+
import { Vue, Component, Prop, Emit } from 'vue-facing-decorator'
|
|
29
33
|
|
|
30
34
|
@Component
|
|
31
35
|
export default class MagicCodeEntry extends Vue {
|
|
32
36
|
@Prop({ default: false }) error!: boolean
|
|
37
|
+
@Prop({ default: '' }) modelValue!: string
|
|
33
38
|
|
|
34
39
|
highlightInput = false
|
|
35
40
|
cursorIndex = 0
|
|
36
|
-
code = ''
|
|
37
41
|
|
|
38
42
|
mounted () {
|
|
39
43
|
// Ensure proper letter spacing for magic code in case of a11y browser extension overrides
|
|
@@ -65,18 +69,22 @@ export default class MagicCodeEntry extends Vue {
|
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
if (event.key.match(/[0-9]/)) {
|
|
68
|
-
|
|
72
|
+
const code = this.modelValue.slice(0, this.cursorIndex)
|
|
73
|
+
+ event.key + this.modelValue.slice(this.cursorIndex + 1)
|
|
74
|
+
this.emitUpdateModelValue(code)
|
|
69
75
|
this.cursorIndex = Math.min(this.cursorIndex + 1, 5)
|
|
70
76
|
} else if (event.key === 'ArrowLeft') {
|
|
71
77
|
this.cursorIndex = Math.max(this.cursorIndex - 1, 0)
|
|
72
78
|
} else if (event.key === 'ArrowRight') {
|
|
73
79
|
this.cursorIndex = Math.min(this.cursorIndex + 1, 5)
|
|
74
80
|
} else if (event.key === 'Backspace') {
|
|
75
|
-
if (this.
|
|
76
|
-
|
|
77
|
-
.
|
|
81
|
+
if (this.modelValue[this.cursorIndex]) {
|
|
82
|
+
const code = (
|
|
83
|
+
this.modelValue.slice(0, this.cursorIndex) + ' ' + this.modelValue.slice(this.cursorIndex + 1)
|
|
84
|
+
).trimEnd()
|
|
85
|
+
this.emitUpdateModelValue(code)
|
|
78
86
|
}
|
|
79
|
-
this.cursorIndex = Math.min(Math.max(this.cursorIndex - 1, 0), this.
|
|
87
|
+
this.cursorIndex = Math.min(Math.max(this.cursorIndex - 1, 0), this.modelValue.length)
|
|
80
88
|
} else if (event.key === 'Enter') {
|
|
81
89
|
this.emitSubmit()
|
|
82
90
|
}
|
|
@@ -93,7 +101,7 @@ export default class MagicCodeEntry extends Vue {
|
|
|
93
101
|
this.emitError('')
|
|
94
102
|
const pasteValue = event.clipboardData?.getData('text')
|
|
95
103
|
if (pasteValue && typeof Number(pasteValue) === 'number' && pasteValue.length === 6) {
|
|
96
|
-
this.
|
|
104
|
+
this.emitUpdateModelValue('')
|
|
97
105
|
this.cursorIndex = Math.min(pasteValue.length, 5)
|
|
98
106
|
} else if (pasteValue) {
|
|
99
107
|
this.emitError(`Invalid code: ${pasteValue}. Code must be six digits`)
|
|
@@ -101,11 +109,6 @@ export default class MagicCodeEntry extends Vue {
|
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
111
|
|
|
104
|
-
@Watch('code')
|
|
105
|
-
codeChanged (newVal: string) {
|
|
106
|
-
this.emitUpdateModelValue(newVal)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
112
|
@Emit('submit')
|
|
110
113
|
emitSubmit () {
|
|
111
114
|
return true
|
package/lib/utils.ts
CHANGED
|
@@ -43,6 +43,13 @@ export const studyModes = {
|
|
|
43
43
|
iconColor: BrandColors.cadaverous,
|
|
44
44
|
iconColorDM: BrandColors.jungleGreen,
|
|
45
45
|
},
|
|
46
|
+
'6': {
|
|
47
|
+
name: 'Level Up',
|
|
48
|
+
shortName: 'levelUp',
|
|
49
|
+
icon: 'levelup',
|
|
50
|
+
iconColor: BrandColors.cosmos,
|
|
51
|
+
iconColorDM: BrandColors.orchid,
|
|
52
|
+
},
|
|
46
53
|
'10': {
|
|
47
54
|
name: 'Build Your Own',
|
|
48
55
|
shortName: 'custom',
|