@dataloop-ai/components 0.18.75 → 0.18.76
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
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
:style="sliderStyles"
|
|
6
6
|
>
|
|
7
7
|
<div
|
|
8
|
-
v-if="
|
|
9
|
-
class="slider
|
|
10
|
-
data-test="
|
|
8
|
+
v-if="slim"
|
|
9
|
+
class="slider slim"
|
|
10
|
+
data-test="slim-slider"
|
|
11
11
|
>
|
|
12
12
|
<span class="text capitalize">{{ text }}</span>
|
|
13
13
|
<dl-slider-input
|
|
14
|
-
v-model="
|
|
14
|
+
v-model="value"
|
|
15
15
|
:min="min"
|
|
16
16
|
:max="max"
|
|
17
17
|
:readonly="readonly"
|
|
18
18
|
:disabled="disabled"
|
|
19
19
|
:style="{ marginRight: '10px' }"
|
|
20
|
-
data-test="
|
|
20
|
+
data-test="slim-slider-input"
|
|
21
21
|
/>
|
|
22
22
|
<div class="slider-bar-container">
|
|
23
23
|
<dl-slider-base
|
|
24
|
-
v-model.number="
|
|
24
|
+
v-model.number="value"
|
|
25
25
|
:min="min"
|
|
26
26
|
:max="max"
|
|
27
27
|
:step="step"
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
</div>
|
|
38
38
|
<div
|
|
39
39
|
v-else
|
|
40
|
-
class="slider non-
|
|
41
|
-
data-test="non-
|
|
40
|
+
class="slider non-slim"
|
|
41
|
+
data-test="non-slim-slider"
|
|
42
42
|
>
|
|
43
43
|
<div class="header">
|
|
44
44
|
<div class="row text capitalize">
|
|
@@ -60,24 +60,24 @@
|
|
|
60
60
|
size="12px"
|
|
61
61
|
label="Reset"
|
|
62
62
|
:disabled="disabled || readonly"
|
|
63
|
-
data-test="non-
|
|
63
|
+
data-test="non-slim-slider-button"
|
|
64
64
|
@click="handleResetButtonClick"
|
|
65
65
|
/>
|
|
66
66
|
<dl-slider-input
|
|
67
67
|
id="slider-input"
|
|
68
|
-
v-model="
|
|
68
|
+
v-model="value"
|
|
69
69
|
:min="min"
|
|
70
70
|
:max="max"
|
|
71
71
|
:readonly="readonly"
|
|
72
72
|
:disabled="disabled"
|
|
73
|
-
data-test="non-
|
|
74
|
-
@change="
|
|
73
|
+
data-test="non-slim-slider-input"
|
|
74
|
+
@change="onChange"
|
|
75
75
|
/>
|
|
76
76
|
</div>
|
|
77
77
|
</div>
|
|
78
78
|
<div class="slider-bar-container">
|
|
79
79
|
<dl-slider-base
|
|
80
|
-
v-model.number="
|
|
80
|
+
v-model.number="value"
|
|
81
81
|
:min="min"
|
|
82
82
|
:max="max"
|
|
83
83
|
:step="step"
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
:disabled="disabled"
|
|
88
88
|
:snap="snap"
|
|
89
89
|
:name="name"
|
|
90
|
-
@change="
|
|
90
|
+
@change="onChange"
|
|
91
91
|
/>
|
|
92
92
|
</div>
|
|
93
93
|
</div>
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
</template>
|
|
96
96
|
|
|
97
97
|
<script lang="ts">
|
|
98
|
-
import { defineComponent } from 'vue-demi'
|
|
98
|
+
import { computed, defineComponent, ref, toRefs, watch } from 'vue-demi'
|
|
99
99
|
import { DlSliderBase, DlSliderInput } from './components/'
|
|
100
100
|
import { DlButton } from '../../basic'
|
|
101
101
|
import { DlIcon } from '../../essential'
|
|
@@ -133,7 +133,7 @@ export default defineComponent({
|
|
|
133
133
|
type: Boolean,
|
|
134
134
|
default: false
|
|
135
135
|
},
|
|
136
|
-
|
|
136
|
+
slim: {
|
|
137
137
|
type: Boolean,
|
|
138
138
|
default: false
|
|
139
139
|
},
|
|
@@ -185,60 +185,82 @@ export default defineComponent({
|
|
|
185
185
|
}
|
|
186
186
|
},
|
|
187
187
|
emits: ['update:model-value', 'change'],
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
188
|
+
setup(props, { emit }) {
|
|
189
|
+
const { modelValue, min, max, textColor, width, thumbSize, color } =
|
|
190
|
+
toRefs(props)
|
|
191
|
+
const initialValue = ref(
|
|
192
|
+
modelValue.value === null
|
|
193
|
+
? min.value
|
|
194
|
+
: between(modelValue.value, min.value, max.value)
|
|
195
|
+
)
|
|
196
|
+
const displaySliderInput = ref(false)
|
|
193
197
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
computed: {
|
|
202
|
-
valueUpdate(): string {
|
|
203
|
-
return `${this.modelValue}|${this.min}|${this.max}`
|
|
204
|
-
},
|
|
205
|
-
sliderValue: {
|
|
206
|
-
get(): number {
|
|
207
|
-
return this.value
|
|
198
|
+
const value = computed({
|
|
199
|
+
get: () => {
|
|
200
|
+
return modelValue.value === null
|
|
201
|
+
? min.value
|
|
202
|
+
: between(modelValue.value, min.value, max.value)
|
|
208
203
|
},
|
|
209
|
-
set(val: number
|
|
210
|
-
|
|
211
|
-
'
|
|
212
|
-
|
|
204
|
+
set(val: number) {
|
|
205
|
+
console.log(
|
|
206
|
+
'@@@ intial, cur',
|
|
207
|
+
initialValue.value,
|
|
208
|
+
modelValue.value
|
|
213
209
|
)
|
|
210
|
+
console.log(`@@@ model value update `, val)
|
|
211
|
+
if (val === modelValue.value) {
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
emit('update:model-value', val)
|
|
215
|
+
emit('change', val)
|
|
214
216
|
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
const sliderStyles = computed<Record<string, any>>(() => {
|
|
217
220
|
return {
|
|
218
|
-
'--text-color': getColor(
|
|
219
|
-
'--width':
|
|
220
|
-
'--thumb-size': parseInt(
|
|
221
|
-
'--color': getColor(
|
|
221
|
+
'--text-color': getColor(textColor.value, 'dl-color-darker'),
|
|
222
|
+
'--width': width.value,
|
|
223
|
+
'--thumb-size': parseInt(thumbSize.value) / 2 + 'px',
|
|
224
|
+
'--color': getColor(color.value, 'dl-color-secondary')
|
|
222
225
|
}
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
const onChange = (val: number) => {
|
|
229
|
+
value.value = between(val, min.value, max.value)
|
|
223
230
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
this.value =
|
|
228
|
-
this.modelValue === null
|
|
229
|
-
? this.min
|
|
230
|
-
: between(this.modelValue, this.min, this.max)
|
|
231
|
+
|
|
232
|
+
const handleResetButtonClick = () => {
|
|
233
|
+
onChange(initialValue.value)
|
|
231
234
|
}
|
|
232
|
-
},
|
|
233
|
-
methods: {
|
|
234
|
-
handleChange(value: number) {
|
|
235
|
-
if (this.sliderValue === value) return
|
|
236
235
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
236
|
+
watch(
|
|
237
|
+
modelValue,
|
|
238
|
+
() => {
|
|
239
|
+
if (modelValue.value === value.value) {
|
|
240
|
+
return
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (modelValue.value === null) {
|
|
244
|
+
value.value = min.value
|
|
245
|
+
} else {
|
|
246
|
+
value.value = between(
|
|
247
|
+
modelValue.value,
|
|
248
|
+
min.value,
|
|
249
|
+
max.value
|
|
250
|
+
)
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
{ immediate: true }
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
uuid: `dl-slider-${v4()}`,
|
|
258
|
+
initialValue,
|
|
259
|
+
value,
|
|
260
|
+
sliderStyles,
|
|
261
|
+
displaySliderInput,
|
|
262
|
+
onChange,
|
|
263
|
+
handleResetButtonClick
|
|
242
264
|
}
|
|
243
265
|
}
|
|
244
266
|
})
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
:step="1"
|
|
8
8
|
:min="-100"
|
|
9
9
|
:max="100"
|
|
10
|
-
:
|
|
10
|
+
:slim="slim"
|
|
11
11
|
:readonly="readonly"
|
|
12
12
|
:disabled="disabled"
|
|
13
13
|
@change="handleChange"
|
|
14
14
|
/>
|
|
15
15
|
<div>
|
|
16
|
-
<button @click="
|
|
17
|
-
|
|
16
|
+
<button @click="slim = !slim">
|
|
17
|
+
slim: {{ slim }}
|
|
18
18
|
</button>
|
|
19
19
|
<button @click="readonly = !readonly">
|
|
20
20
|
Readonly: {{ readonly }}
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
Disable: {{ disabled }}
|
|
24
24
|
</button>
|
|
25
25
|
</div>
|
|
26
|
+
<div>
|
|
27
|
+
Events: <br>
|
|
28
|
+
{{ events }}
|
|
29
|
+
</div>
|
|
26
30
|
</div>
|
|
27
31
|
</template>
|
|
28
32
|
|
|
@@ -37,20 +41,23 @@ export default defineComponent({
|
|
|
37
41
|
},
|
|
38
42
|
data() {
|
|
39
43
|
return {
|
|
40
|
-
value:
|
|
41
|
-
|
|
44
|
+
value: null,
|
|
45
|
+
slim: false,
|
|
42
46
|
disabled: false,
|
|
43
|
-
readonly: false
|
|
47
|
+
readonly: false,
|
|
48
|
+
events: []
|
|
44
49
|
}
|
|
45
50
|
},
|
|
46
51
|
watch: {
|
|
47
52
|
value(newValue, oldValue) {
|
|
48
53
|
console.log(`@@@ model value update ${oldValue} to ${newValue}`)
|
|
54
|
+
this.events[0] = `@@@ model value update ${oldValue} to ${newValue}`
|
|
49
55
|
}
|
|
50
56
|
},
|
|
51
57
|
methods: {
|
|
52
58
|
handleChange(value: number) {
|
|
53
59
|
console.log(`@@@ handling change ${value}`)
|
|
60
|
+
this.events[1] = `@@@ handling change ${value}`
|
|
54
61
|
}
|
|
55
62
|
},
|
|
56
63
|
template: 'dl-slider-demo'
|