@dataloop-ai/components 0.19.124 → 0.19.125
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
|
@@ -190,6 +190,7 @@
|
|
|
190
190
|
<dl-select-option
|
|
191
191
|
v-if="showAllItems"
|
|
192
192
|
:multiselect="multiselect"
|
|
193
|
+
:select-children="selectChildren"
|
|
193
194
|
:with-wave="withWave"
|
|
194
195
|
clickable
|
|
195
196
|
:model-value="allFiltersModel"
|
|
@@ -270,6 +271,7 @@
|
|
|
270
271
|
:key="getKeyForOption(option)"
|
|
271
272
|
clickable
|
|
272
273
|
:multiselect="multiselect"
|
|
274
|
+
:select-children="selectChildren"
|
|
273
275
|
:class="{
|
|
274
276
|
selected:
|
|
275
277
|
option === selectedOption &&
|
|
@@ -443,6 +445,13 @@ export default defineComponent({
|
|
|
443
445
|
menuClass: {
|
|
444
446
|
type: String,
|
|
445
447
|
default: null
|
|
448
|
+
},
|
|
449
|
+
/**
|
|
450
|
+
* when multiselect is true, this will select all children of the selected option
|
|
451
|
+
*/
|
|
452
|
+
selectChildren: {
|
|
453
|
+
type: Boolean,
|
|
454
|
+
default: true
|
|
446
455
|
}
|
|
447
456
|
},
|
|
448
457
|
emits: [
|
|
@@ -473,8 +482,8 @@ export default defineComponent({
|
|
|
473
482
|
}
|
|
474
483
|
const handleModelValueUpdate = (val: any) => {
|
|
475
484
|
emit('update:model-value', val)
|
|
476
|
-
emit('change', val)
|
|
477
485
|
emit('selected', val)
|
|
486
|
+
emit('change', val)
|
|
478
487
|
}
|
|
479
488
|
|
|
480
489
|
return {
|
|
@@ -83,7 +83,9 @@
|
|
|
83
83
|
:key="`${componentId}-${getValue(child)}-${index}`"
|
|
84
84
|
>
|
|
85
85
|
<dl-select-option
|
|
86
|
+
:ref="`option-${getValue(child)}`"
|
|
86
87
|
:multiselect="multiselect"
|
|
88
|
+
:select-children="selectChildren"
|
|
87
89
|
:count="count"
|
|
88
90
|
clickable
|
|
89
91
|
:model-value="modelValue"
|
|
@@ -123,13 +125,13 @@
|
|
|
123
125
|
<script lang="ts">
|
|
124
126
|
import { defineComponent, PropType } from 'vue-demi'
|
|
125
127
|
import { DlListItem } from '../../../basic'
|
|
126
|
-
import { DlIcon, DlCheckbox } from '../../../essential'
|
|
128
|
+
import { DlIcon, DlCheckbox, DlEllipsis } from '../../../essential'
|
|
127
129
|
import { DlItemSection } from '../../../shared'
|
|
128
130
|
import { v4 } from 'uuid'
|
|
129
131
|
import { debounce } from 'lodash'
|
|
130
132
|
import { stateManager } from '../../../../StateManager'
|
|
131
133
|
import { DlSelectOptionType, getCaseInsensitiveInput, getLabel } from '../utils'
|
|
132
|
-
import { DlSelectedValueType } from '../../types'
|
|
134
|
+
import { DlSelectedValueType, DlSelectOption } from '../../types'
|
|
133
135
|
|
|
134
136
|
const ValueTypes = [Array, Boolean, String, Number, Object, Function]
|
|
135
137
|
|
|
@@ -139,7 +141,8 @@ export default defineComponent({
|
|
|
139
141
|
DlListItem,
|
|
140
142
|
DlItemSection,
|
|
141
143
|
DlCheckbox,
|
|
142
|
-
DlIcon
|
|
144
|
+
DlIcon,
|
|
145
|
+
DlEllipsis
|
|
143
146
|
},
|
|
144
147
|
model: {
|
|
145
148
|
prop: 'modelValue',
|
|
@@ -177,6 +180,10 @@ export default defineComponent({
|
|
|
177
180
|
fitContent: {
|
|
178
181
|
type: Boolean,
|
|
179
182
|
default: false
|
|
183
|
+
},
|
|
184
|
+
selectChildren: {
|
|
185
|
+
type: Boolean,
|
|
186
|
+
default: true
|
|
180
187
|
}
|
|
181
188
|
},
|
|
182
189
|
emits: [
|
|
@@ -189,6 +196,7 @@ export default defineComponent({
|
|
|
189
196
|
data() {
|
|
190
197
|
return {
|
|
191
198
|
showChildren: this.isExpanded,
|
|
199
|
+
updatingLeaf: false,
|
|
192
200
|
componentId: v4(),
|
|
193
201
|
uuid: `dl-select-option-${v4()}`
|
|
194
202
|
}
|
|
@@ -252,14 +260,74 @@ export default defineComponent({
|
|
|
252
260
|
|
|
253
261
|
return html
|
|
254
262
|
},
|
|
263
|
+
getAllChildren(children: any[]) {
|
|
264
|
+
let flattened: any[] = []
|
|
265
|
+
if (!children) return flattened
|
|
266
|
+
for (const child of children) {
|
|
267
|
+
flattened.push(this.getOptionValue(child))
|
|
268
|
+
if (this.getChildren(child)) {
|
|
269
|
+
flattened = flattened.concat(
|
|
270
|
+
this.getAllChildren(this.getChildren(child))
|
|
271
|
+
)
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return flattened
|
|
275
|
+
},
|
|
255
276
|
handleSingleSelect(value?: any) {
|
|
256
277
|
this.$emit('selected', value ?? this.value)
|
|
278
|
+
|
|
279
|
+
if (this.multiselect && this.selectChildren) {
|
|
280
|
+
const hasChildren = !!(
|
|
281
|
+
this.getOptionByValue(value ?? this.value) as DlSelectOption
|
|
282
|
+
)?.children?.length
|
|
283
|
+
if (hasChildren) {
|
|
284
|
+
this.updatingLeaf = true
|
|
285
|
+
this.$nextTick(() => {
|
|
286
|
+
// select all children rerecursively and update model value
|
|
287
|
+
const children = this.getAllChildren(
|
|
288
|
+
this.children ?? []
|
|
289
|
+
)
|
|
290
|
+
children.push(value ?? this.value)
|
|
291
|
+
const newModelValue = Array.from(
|
|
292
|
+
new Set([
|
|
293
|
+
...(this.modelValue as any[]),
|
|
294
|
+
...children
|
|
295
|
+
] as any)
|
|
296
|
+
)
|
|
297
|
+
this.$emit('update:model-value', newModelValue)
|
|
298
|
+
this.updatingLeaf = false
|
|
299
|
+
})
|
|
300
|
+
}
|
|
301
|
+
}
|
|
257
302
|
},
|
|
258
303
|
handleSingleDeselect(value?: any) {
|
|
259
304
|
this.$emit('deselected', value ?? this.value)
|
|
305
|
+
|
|
306
|
+
if (this.multiselect && this.selectChildren) {
|
|
307
|
+
const hasChildren = !!(
|
|
308
|
+
this.getOptionByValue(value ?? this.value) as DlSelectOption
|
|
309
|
+
)?.children?.length
|
|
310
|
+
if (hasChildren) {
|
|
311
|
+
this.updatingLeaf = true
|
|
312
|
+
this.$nextTick(() => {
|
|
313
|
+
// deselect all children recursively and update model value
|
|
314
|
+
const children = this.getAllChildren(
|
|
315
|
+
this.children ?? []
|
|
316
|
+
)
|
|
317
|
+
children.push(value ?? this.value)
|
|
318
|
+
const newModelValue = (this.modelValue as any[]).filter(
|
|
319
|
+
(v) => !children.includes(v)
|
|
320
|
+
)
|
|
321
|
+
this.$emit('update:model-value', newModelValue)
|
|
322
|
+
this.updatingLeaf = false
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
}
|
|
260
326
|
},
|
|
261
327
|
handleCheckboxUpdate(newVal: string[] | boolean, e: Event): void {
|
|
262
|
-
this
|
|
328
|
+
if (!this.updatingLeaf) {
|
|
329
|
+
this.$emit('update:model-value', newVal, e)
|
|
330
|
+
}
|
|
263
331
|
},
|
|
264
332
|
handleClick(e: Event) {
|
|
265
333
|
e.stopPropagation()
|
|
@@ -287,6 +355,19 @@ export default defineComponent({
|
|
|
287
355
|
getValue(option: any) {
|
|
288
356
|
return typeof option === 'object' ? option.value : null
|
|
289
357
|
},
|
|
358
|
+
getOptionByValue(value: any): DlSelectOptionType {
|
|
359
|
+
if (this.value === value) {
|
|
360
|
+
return this as any as DlSelectOptionType
|
|
361
|
+
}
|
|
362
|
+
if (this.children) {
|
|
363
|
+
const child =
|
|
364
|
+
this.children.find((child) => {
|
|
365
|
+
return this.getValue(child) === value
|
|
366
|
+
}) ?? null
|
|
367
|
+
|
|
368
|
+
return child as DlSelectOptionType
|
|
369
|
+
}
|
|
370
|
+
},
|
|
290
371
|
isReadonlyOption(option: any) {
|
|
291
372
|
return !!option?.readonly
|
|
292
373
|
}
|
|
@@ -684,14 +684,14 @@ const treeOptions = [
|
|
|
684
684
|
label: 'root1',
|
|
685
685
|
value: 'root1',
|
|
686
686
|
children: [
|
|
687
|
-
{ label: 'child 1', value: '
|
|
688
|
-
{ label: 'child 2', value: '
|
|
687
|
+
{ label: 'child 1', value: 'c111' },
|
|
688
|
+
{ label: 'child 2', value: 'c21' },
|
|
689
689
|
{
|
|
690
690
|
label: 'child 3',
|
|
691
|
-
value: '
|
|
691
|
+
value: 'c31',
|
|
692
692
|
children: [
|
|
693
|
-
{ label: 'child 4', value: '
|
|
694
|
-
{ label: 'child 5', value: '
|
|
693
|
+
{ label: 'child 4', value: '41' },
|
|
694
|
+
{ label: 'child 5', value: '51' }
|
|
695
695
|
]
|
|
696
696
|
}
|
|
697
697
|
]
|