@soroka282/rm.ui-kit 0.0.49 → 0.0.50

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.
@@ -1,6 +1,7 @@
1
1
  import { EInputInputmode, EInputType, EInputComponentType, IInputProps } from '../../../types';
2
2
  declare const _default: import('vue').DefineComponent<IInputProps, {
3
3
  focus: () => void;
4
+ blur: () => void;
4
5
  setSelectionRange: () => void;
5
6
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
6
7
  blur: (...args: any[]) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soroka282/rm.ui-kit",
3
- "version": "0.0.49",
3
+ "version": "0.0.50",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/rm.ui-kit.umd.js",
@@ -125,6 +125,9 @@
125
125
  focus: () => {
126
126
  inputEl.value.focus();
127
127
  },
128
+ blur: () => {
129
+ inputEl.value.blur();
130
+ },
128
131
  setSelectionRange: () => {
129
132
  if (props.type !== EInputType.email) {
130
133
  inputEl.value?.setSelectionRange(0, 0);
@@ -28,6 +28,7 @@
28
28
 
29
29
  type InputElement = {
30
30
  focus: () => void;
31
+ blur: () => void;
31
32
  setSelectionRange: (start: number, end: number) => void;
32
33
  };
33
34
 
@@ -36,6 +37,7 @@
36
37
  const errorResponseStatus = ref(false);
37
38
  const isFormSubmitted = ref(false);
38
39
  const isReady = ref(false);
40
+ const activeInput = ref<number | null>(null);
39
41
 
40
42
  const formData = reactive({
41
43
  codeArray: ['', '', '', ''],
@@ -103,12 +105,15 @@
103
105
  formData.codeArray[index] = value;
104
106
 
105
107
  if (value && index < inputs.value.length - 1) {
108
+ inputs.value[index]?.blur();
106
109
  inputs.value[index + 1]?.focus();
107
110
  inputs.value[index + 1]?.setSelectionRange(0, 1);
111
+ activeInput.value = index + 1;
108
112
  }
109
113
 
110
114
  if (!value && index > 0) {
111
115
  inputs.value[index - 1]?.focus();
116
+ activeInput.value = index - 1;
112
117
  }
113
118
 
114
119
  code.value = formData.codeArray.join('') || '';
@@ -131,14 +136,25 @@
131
136
  resetErrorState('code');
132
137
  };
133
138
 
139
+ const resetFocus = (evt: Event) => {
140
+ if (evt.target?.className === 'ui-input') {
141
+ return;
142
+ }
143
+ activeInput.value = null;
144
+ };
145
+
134
146
  onUnmounted(() => {
135
147
  resetForm();
148
+
149
+ document.removeEventListener('click', resetFocus);
136
150
  });
137
151
 
138
152
  onMounted(() => {
139
153
  setTimeout(() => {
140
154
  isReady.value = true;
141
155
  }, 100);
156
+
157
+ document.addEventListener('click', resetFocus);
142
158
  });
143
159
 
144
160
  watch(authStep, (newStep) => {
@@ -165,10 +181,12 @@
165
181
  class="auth-check-code-form__input"
166
182
  :class="{
167
183
  '--error': hasInputCodeError,
184
+ '--active': activeInput === index,
168
185
  }"
169
186
  :inputmode="EInputInputmode.numeric"
170
187
  @update:model-value="update($event.trim(), index)"
171
188
  @input="resetErrorState('code')"
189
+ @click="activeInput = index"
172
190
  />
173
191
  </div>
174
192
  <UIInfo
@@ -241,7 +259,7 @@
241
259
 
242
260
  &:hover,
243
261
  &:focus {
244
- border-color: var(--blue-500);
262
+ border-color: var(--gray-300);
245
263
  }
246
264
 
247
265
  &::placeholder {
@@ -256,6 +274,12 @@
256
274
  border-radius: 8px;
257
275
  }
258
276
  }
277
+
278
+ &.--active {
279
+ &:deep(.ui-input) {
280
+ border-color: var(--blue-500);
281
+ }
282
+ }
259
283
  }
260
284
  }
261
285
  </style>