@bagelink/vue 1.4.54 → 1.4.56

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.4.54",
4
+ "version": "1.4.56",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Neveh Allon",
@@ -113,8 +113,9 @@ function inputHandler() {
113
113
  const numeric = formattedValue.replace(/[^\d.-]/g, '')
114
114
  const emptyValue = ['', '-', '.', '-.'].includes(numeric)
115
115
  const isTypingDecimal = formattedValue.endsWith('.')
116
+ const isTypingTrailingZeros = /\.\d*0$/.test(numeric) // Check if ending with decimal followed by digits ending in 0
116
117
 
117
- if (emptyValue || isTypingDecimal) {
118
+ if (emptyValue || isTypingDecimal || isTypingTrailingZeros) {
118
119
  emit('update:modelValue', numeric === '-' ? '-' : numeric)
119
120
  return
120
121
  }
@@ -126,8 +127,8 @@ function inputHandler() {
126
127
 
127
128
  watch(() => numberValue, () => {
128
129
  nextTick(() => {
129
- // Don't reformat if user is currently typing a decimal
130
- if (formattedValue.endsWith('.')) return
130
+ // Don't reformat if user is currently typing a decimal or trailing zeros
131
+ if (formattedValue.endsWith('.') || /\.\d*0$/.test(formattedValue)) return
131
132
  formattedValue = numberValue !== undefined ? formatNumber(numberValue) : ''
132
133
  })
133
134
  })
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import type { IconType, ValidateInputBaseT } from '@bagelink/vue'
3
- import { Icon, useDebounceFn, useValidateFieldValue } from '@bagelink/vue'
3
+ import { Icon, sleep, useDebounceFn, useValidateFieldValue } from '@bagelink/vue'
4
+ import { until } from '@vueuse/core'
4
5
 
5
6
  import { onMounted, watch } from 'vue'
6
7
 
@@ -79,74 +80,43 @@ const hasFocus = () => document.activeElement === input
79
80
  const focus = () => input?.focus()
80
81
  defineExpose({ focus, hasFocus })
81
82
 
82
- onMounted(() => {
83
- if (props.autofocus) setTimeout(() => input?.focus(), 10)
83
+ onMounted(async () => {
84
+ if (props.autofocus) {
85
+ await until(() => input).toBeTruthy()
86
+ await sleep(400)
87
+ input?.focus()
88
+ }
84
89
  if (props.defaultValue && !props.modelValue) inputVal = props.defaultValue
85
90
  })
86
91
  </script>
87
92
 
88
93
  <template>
89
94
  <div
90
- class="bagel-input text-input"
91
- :class="{
95
+ class="bagel-input text-input" :class="{
92
96
  dense,
93
97
  small,
94
98
  shrink,
95
99
  code,
96
100
  textInputIconWrap: icon,
97
101
  txtInputIconStart: iconStart,
98
- }"
99
- :title="title"
102
+ }" :title="title"
100
103
  >
101
104
  <label :for="id">
102
105
  {{ label }} <span v-if="required && label">*</span>
103
106
 
104
107
  <input
105
- v-if="!multiline && !autoheight && !code && inputRows < 2"
106
- :id
107
- ref="input"
108
- v-model.trim="inputVal"
109
- :name
110
- :title
111
- :autocomplete
112
- :type
113
- :rows="1"
114
- :placeholder="placeholder || label"
115
- :disabled
116
- :required
117
- :pattern
118
- v-bind="nativeInputAttrs"
119
- @focusout="onFocusout"
120
- @focus="onFocus"
121
- @input="updateInputVal"
108
+ v-if="!multiline && !autoheight && !code && inputRows < 2" :id ref="input" v-model.trim="inputVal"
109
+ :name :title :autocomplete :type :rows="1" :placeholder="placeholder || label" :disabled :required
110
+ :pattern v-bind="nativeInputAttrs" @focusout="onFocusout" @focus="onFocus" @input="updateInputVal"
122
111
  >
123
112
  <textarea
124
- v-else
125
- :id
126
- ref="input"
127
- v-model="inputVal"
128
- :name
129
- :title
130
- :type
131
- :rows="inputRows"
132
- :placeholder="placeholder || label"
133
- :disabled
134
- :required
135
- :pattern
136
- v-bind="nativeInputAttrs"
137
- @input="updateInputVal"
138
- @focusout="onFocusout"
113
+ v-else :id ref="input" v-model="inputVal" :name :title :type :rows="inputRows"
114
+ :placeholder="placeholder || label" :disabled :required :pattern v-bind="nativeInputAttrs"
115
+ @input="updateInputVal" @focusout="onFocusout"
139
116
  />
140
117
  <p v-if="helptext" class="opacity-7 light">{{ helptext }}</p>
141
- <Icon
142
- v-if="iconStart"
143
- class="iconStart"
144
- :icon="iconStart"
145
- />
146
- <Icon
147
- v-if="icon"
148
- :icon
149
- />
118
+ <Icon v-if="iconStart" class="iconStart" :icon="iconStart" />
119
+ <Icon v-if="icon" :icon />
150
120
  </label>
151
121
  </div>
152
122
  </template>
@@ -178,6 +148,7 @@ onMounted(() => {
178
148
  background: var(--bgl-code-bg) !important;
179
149
  color: var(--bgl-light-text) !important;
180
150
  }
151
+
181
152
  .code textarea::placeholder {
182
153
  color: var(--bgl-light-text) !important;
183
154
  opacity: 0.3;
@@ -206,22 +177,25 @@ onMounted(() => {
206
177
  .textInputIconWrap .bgl_icon-font {
207
178
  color: var(--input-color);
208
179
  position: absolute;
209
- inset-inline-end:calc(var(--input-height) / 3 - 0.25rem);
180
+ inset-inline-end: calc(var(--input-height) / 3 - 0.25rem);
210
181
  margin-top: calc(var(--input-height) / 2 + 0.1rem);
211
182
  line-height: 0;
212
183
  }
213
- .textInputIconWrap input{
184
+
185
+ .textInputIconWrap input {
214
186
  padding-inline-end: calc(var(--input-height) / 3 + 1.5rem);
215
187
  }
216
188
 
217
189
  .txtInputIconStart .iconStart {
218
190
  color: var(--input-color);
219
191
  position: absolute;
220
- inset-inline-start:calc(var(--input-height) / 3 - 0.25rem);
221
- margin-top: calc(var(--input-height) / 2 );
192
+ inset-inline-start: calc(var(--input-height) / 3 - 0.25rem);
193
+ margin-top: calc(var(--input-height) / 2);
222
194
  line-height: 0;
223
195
  }
224
- .txtInputIconStart input, .txtInputIconStart textarea{
196
+
197
+ .txtInputIconStart input,
198
+ .txtInputIconStart textarea {
225
199
  padding-inline-start: calc(var(--input-height) / 3 + 1.5rem);
226
200
  }
227
201