@dataloop-ai/components 0.19.142 → 0.19.144
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
|
@@ -674,7 +674,8 @@ export default defineComponent({
|
|
|
674
674
|
disabled,
|
|
675
675
|
autoTrim,
|
|
676
676
|
debounce,
|
|
677
|
-
trimDebounce
|
|
677
|
+
trimDebounce,
|
|
678
|
+
type
|
|
678
679
|
} = toRefs(props)
|
|
679
680
|
|
|
680
681
|
const isInternalChange = ref(false)
|
|
@@ -728,15 +729,53 @@ export default defineComponent({
|
|
|
728
729
|
return debounced
|
|
729
730
|
})
|
|
730
731
|
|
|
732
|
+
const isValidNumber = (input: string | number) => {
|
|
733
|
+
const parsedNumber = Number(String(input))
|
|
734
|
+
return (
|
|
735
|
+
!isNaN(parsedNumber) &&
|
|
736
|
+
isFinite(parsedNumber) &&
|
|
737
|
+
!/[eE]/.test(String(input)) &&
|
|
738
|
+
parsedNumber >= Number.MIN_SAFE_INTEGER &&
|
|
739
|
+
parsedNumber <= Number.MAX_SAFE_INTEGER
|
|
740
|
+
)
|
|
741
|
+
}
|
|
742
|
+
|
|
731
743
|
const onChange = (e: KeyboardEvent | Event) => {
|
|
732
744
|
isInternalChange.value = true
|
|
733
745
|
isMenuOpen.value = true
|
|
734
746
|
updateSyntax()
|
|
735
747
|
const target = e.target as HTMLElement
|
|
736
|
-
|
|
748
|
+
let toEmit: string | number = target.innerText.replace(
|
|
737
749
|
new RegExp(' ', 'g'),
|
|
738
750
|
' '
|
|
739
751
|
)
|
|
752
|
+
|
|
753
|
+
if (type.value === 'number') {
|
|
754
|
+
if (toEmit === '') {
|
|
755
|
+
toEmit = '0'
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
const isValid = isValidNumber(toEmit)
|
|
759
|
+
if (!isValid) {
|
|
760
|
+
const trimmed = String(modelValue.value).trim()
|
|
761
|
+
input.value.innerHTML = trimmed
|
|
762
|
+
.toString()
|
|
763
|
+
.replace(/ /g, ' ')
|
|
764
|
+
updateSyntax()
|
|
765
|
+
setCaretAtTheEnd(input.value)
|
|
766
|
+
return
|
|
767
|
+
}
|
|
768
|
+
if (!toEmit.endsWith('.')) {
|
|
769
|
+
input.value.innerHTML = String(Number(toEmit))
|
|
770
|
+
.toString()
|
|
771
|
+
.replace(/ /g, ' ')
|
|
772
|
+
updateSyntax()
|
|
773
|
+
setCaretAtTheEnd(input.value)
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
toEmit = Number(toEmit)
|
|
777
|
+
}
|
|
778
|
+
|
|
740
779
|
emit('input', toEmit, e)
|
|
741
780
|
emit('update:model-value', toEmit)
|
|
742
781
|
if (autoTrim.value) {
|
|
@@ -1065,9 +1104,15 @@ export default defineComponent({
|
|
|
1065
1104
|
},
|
|
1066
1105
|
methods: {
|
|
1067
1106
|
onKeydown(e: KeyboardEvent) {
|
|
1068
|
-
if (
|
|
1069
|
-
e.
|
|
1070
|
-
|
|
1107
|
+
if (e.key !== 'Backspace') {
|
|
1108
|
+
if (!/^[\d.]$/.test(e.key)) {
|
|
1109
|
+
e.preventDefault()
|
|
1110
|
+
return
|
|
1111
|
+
}
|
|
1112
|
+
if (!this.isWithinMaxLength) {
|
|
1113
|
+
e.preventDefault()
|
|
1114
|
+
return
|
|
1115
|
+
}
|
|
1071
1116
|
}
|
|
1072
1117
|
},
|
|
1073
1118
|
onClick(e: Event, item: DlInputSuggestion) {
|
|
@@ -1131,6 +1176,9 @@ export default defineComponent({
|
|
|
1131
1176
|
},
|
|
1132
1177
|
onBlur(e: InputEvent): void {
|
|
1133
1178
|
const el = e.target as HTMLElement
|
|
1179
|
+
el.innerText = (el.innerText ?? '').endsWith('.')
|
|
1180
|
+
? el.innerText.slice(0, -1)
|
|
1181
|
+
: el.innerText
|
|
1134
1182
|
el.scroll(0, 0)
|
|
1135
1183
|
this.focused = false
|
|
1136
1184
|
this.$emit('blur', e)
|
|
@@ -1141,8 +1189,9 @@ export default defineComponent({
|
|
|
1141
1189
|
},
|
|
1142
1190
|
onClear(e: any): void {
|
|
1143
1191
|
this.$emit('clear', this.modelValue)
|
|
1144
|
-
this
|
|
1145
|
-
this.$emit('
|
|
1192
|
+
const clearValue = this.type === 'number' ? null : ''
|
|
1193
|
+
this.$emit('input', clearValue, e)
|
|
1194
|
+
this.$emit('update:model-value', clearValue)
|
|
1146
1195
|
|
|
1147
1196
|
const inputRef = this.$refs.input as HTMLInputElement
|
|
1148
1197
|
inputRef.innerHTML = ''
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isNumber } from 'lodash'
|
|
1
|
+
import { debounce, isNumber } from 'lodash'
|
|
2
2
|
import {
|
|
3
3
|
ref,
|
|
4
4
|
computed,
|
|
@@ -129,9 +129,13 @@ export function useTablePaginationState(
|
|
|
129
129
|
innerPagination.value = newPagination
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
emitChanges(newPagination)
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
const emitChanges = debounce((value: TablePagination) => {
|
|
136
|
+
emit('update:pagination', value)
|
|
137
|
+
}, 100)
|
|
138
|
+
|
|
135
139
|
return {
|
|
136
140
|
innerPagination,
|
|
137
141
|
computedPagination,
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
+
<div style="padding-bottom: 10px">
|
|
4
|
+
<div>Number input</div>
|
|
5
|
+
<dl-input
|
|
6
|
+
v-model="numberVal"
|
|
7
|
+
type="number"
|
|
8
|
+
placeholder="Test reactivity"
|
|
9
|
+
:disabled="disabledInput"
|
|
10
|
+
/>
|
|
11
|
+
</div>
|
|
3
12
|
<div style="padding-bottom: 10px">
|
|
4
13
|
<div>switch the disalbed prop: {{ disabledInput }}</div>
|
|
5
14
|
<dl-switch v-model="disabledInput" />
|
|
@@ -311,12 +320,16 @@ export default defineComponent({
|
|
|
311
320
|
const disabledInput = ref<boolean>(false)
|
|
312
321
|
|
|
313
322
|
const textVal = ref<string>('test me')
|
|
323
|
+
const numberVal = ref<number>()
|
|
324
|
+
const emittedNumberValues = ref<number[]>([])
|
|
314
325
|
|
|
315
326
|
const trimmedValue = ref('')
|
|
316
327
|
|
|
317
328
|
return {
|
|
318
329
|
log: console.log,
|
|
319
330
|
textVal,
|
|
331
|
+
emittedNumberValues,
|
|
332
|
+
numberVal,
|
|
320
333
|
disabledInput,
|
|
321
334
|
trimmedValue,
|
|
322
335
|
textInputValue,
|