@pocketprep/ui-kit 3.0.17 → 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.
@@ -12,7 +12,8 @@
12
12
  'uikit-email-auth__magic-code-entry--error': errorMessage,
13
13
  }"
14
14
  :error="errorMessage"
15
- @update:modelValue="magicCodeChange"
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="code.length !== 6 || isLoading"
29
- :autofocus="code.length === 6"
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.code) {
82
- if (this.code.trim().length !== 6) {
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.code })
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
- v-model="code"
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="code.length !== 6"
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, Watch, Prop, Emit } from 'vue-facing-decorator'
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
- this.code = this.code.slice(0, this.cursorIndex) + event.key + this.code.slice(this.cursorIndex + 1)
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.code[this.cursorIndex]) {
76
- this.code = (this.code.slice(0, this.cursorIndex) + ' ' + this.code.slice(this.cursorIndex + 1))
77
- .trimRight()
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.code.length)
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.code = ''
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pocketprep/ui-kit",
3
- "version": "3.0.17",
3
+ "version": "3.0.18",
4
4
  "description": "Pocket Prep UI Kit",
5
5
  "author": "pocketprep",
6
6
  "scripts": {