sprintify-ui 0.0.140 → 0.0.141

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": "sprintify-ui",
3
- "version": "0.0.140",
3
+ "version": "0.0.141",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build-fast": "rimraf dist && vite build",
@@ -22,7 +22,7 @@
22
22
  "humanize-duration": "^3.0.0",
23
23
  "lodash": "^4.17.21",
24
24
  "luxon": "^3.0.0",
25
- "maska": "^2.1.1",
25
+ "maska": "^2.1.3",
26
26
  "microtip": "^0.2.2",
27
27
  "object-to-formdata": "^4.4.2",
28
28
  "pikaday": "^1.8.2",
@@ -19,29 +19,8 @@
19
19
  >
20
20
  {{ prefix }}
21
21
  </div>
22
- <input
23
- ref="input"
24
- v-maska:[maskOptions]
25
- :value="modelValue"
26
- :type="type"
27
- :name="nameInternal"
28
- :step="step"
29
- :min="min"
30
- :max="max"
31
- :disabled="disabled"
32
- :placeholder="placeholder"
33
- :required="requiredInternal"
34
- class="w-full border-none bg-white outline-none focus:z-[1] focus:ring-2 focus:ring-primary-600 focus:ring-offset-1 disabled:cursor-not-allowed disabled:text-slate-300"
35
- :class="{
36
- 'rounded-l': !iconLeft && !prefix,
37
- 'rounded-r': !iconRight && !suffix,
38
- }"
39
- :autocomplete="autocomplete ? 'on' : 'off'"
40
- @keydown.enter="onEnter"
41
- @input="emitUpdate(transformInputValue($event))"
42
- @focus="$emit('focus', $event)"
43
- @blur="$emit('blur', $event)"
44
- />
22
+ <input v-if="hasMask" ref="input" v-maska:[maskOptions] v-bind="bindings" />
23
+ <input v-else ref="input" v-bind="bindings" />
45
24
  <div
46
25
  v-if="suffix"
47
26
  class="flex shrink-0 items-center justify-center border-l px-4 transition-colors"
@@ -65,7 +44,7 @@
65
44
  </template>
66
45
 
67
46
  <script lang="ts" setup>
68
- import { get, isString } from 'lodash';
47
+ import { get } from 'lodash';
69
48
  import { PropType } from 'vue';
70
49
  import { BaseIcon } from '@/index';
71
50
  import { useField } from '@/composables/field';
@@ -156,6 +135,37 @@ const maskOptions = computed(() => {
156
135
  return undefined;
157
136
  });
158
137
 
138
+ const hasMask = computed(() => {
139
+ return !!props.mask;
140
+ });
141
+
142
+ const bindings = computed<any>(() => {
143
+ return {
144
+ value: props.modelValue,
145
+ type: props.type,
146
+ name: nameInternal.value,
147
+ step: props.step,
148
+ min: props.min,
149
+ max: props.max,
150
+ disabled: props.disabled,
151
+ placeholder: props.placeholder,
152
+ required: requiredInternal.value,
153
+ autocomplete: props.autocomplete ? 'on' : 'off',
154
+ class: {
155
+ 'rounded-l': !props.iconLeft && !props.prefix,
156
+ 'rounded-r': !props.iconRight && !props.suffix,
157
+ 'w-full border-none bg-white outline-none focus:z-[1] focus:ring-2 focus:ring-primary-600 focus:ring-offset-1 disabled:cursor-not-allowed disabled:text-slate-300':
158
+ true,
159
+ },
160
+ onKeydown: {
161
+ enter: onEnter,
162
+ },
163
+ onInput: update,
164
+ onFocus: (e: Event) => emit('focus', e),
165
+ onBlur: (e: Event) => emit('blur', e),
166
+ };
167
+ });
168
+
159
169
  const maskInternal = computed(() => {
160
170
  if (props.mask === 'phone') {
161
171
  return '(###) ###-####';
@@ -186,18 +196,12 @@ const { nameInternal, requiredInternal, hasErrorInternal, emitUpdate } =
186
196
  emit: emit,
187
197
  });
188
198
 
189
- function transformInputValue(event: Event | null): string | null {
199
+ function update(event: any | null) {
190
200
  if (event === null) {
191
- return null;
192
- }
193
-
194
- const value = get(event, 'target.value', null);
195
-
196
- if (isString(value)) {
197
- return value;
201
+ emitUpdate(null);
198
202
  }
199
203
 
200
- return '';
204
+ return emitUpdate(get(event, 'target.value', ''));
201
205
  }
202
206
 
203
207
  function onEnter(e: Event) {