@dataloop-ai/components 0.19.124 → 0.19.126
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"
|
|
@@ -99,7 +101,7 @@
|
|
|
99
101
|
:filter-term="filterTerm"
|
|
100
102
|
:fit-content="fitContent"
|
|
101
103
|
@update:model-value="handleCheckboxUpdate"
|
|
102
|
-
@selected="handleSingleSelect"
|
|
104
|
+
@selected="handleSingleSelect($event, true)"
|
|
103
105
|
@deselected="handleSingleDeselect"
|
|
104
106
|
@depth-change="$emit('depth-change')"
|
|
105
107
|
>
|
|
@@ -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,78 @@ export default defineComponent({
|
|
|
252
260
|
|
|
253
261
|
return html
|
|
254
262
|
},
|
|
255
|
-
|
|
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
|
+
},
|
|
276
|
+
handleSingleSelect(value?: any, skip?: boolean) {
|
|
256
277
|
this.$emit('selected', value ?? this.value)
|
|
278
|
+
if (skip) {
|
|
279
|
+
return
|
|
280
|
+
}
|
|
281
|
+
if (this.multiselect && this.selectChildren) {
|
|
282
|
+
const hasChildren = !!(
|
|
283
|
+
this.getOptionByValue(value ?? this.value) as DlSelectOption
|
|
284
|
+
)?.children?.length
|
|
285
|
+
if (hasChildren) {
|
|
286
|
+
this.updatingLeaf = true
|
|
287
|
+
this.$nextTick(() => {
|
|
288
|
+
// select all children rerecursively and update model value
|
|
289
|
+
const children = this.getAllChildren(
|
|
290
|
+
this.children ?? []
|
|
291
|
+
)
|
|
292
|
+
children.push(value ?? this.value)
|
|
293
|
+
const newModelValue = Array.from(
|
|
294
|
+
new Set([
|
|
295
|
+
...(this.modelValue as any[]),
|
|
296
|
+
...children
|
|
297
|
+
] as any)
|
|
298
|
+
)
|
|
299
|
+
this.$emit('update:model-value', newModelValue)
|
|
300
|
+
this.updatingLeaf = false
|
|
301
|
+
})
|
|
302
|
+
}
|
|
303
|
+
}
|
|
257
304
|
},
|
|
258
|
-
handleSingleDeselect(value?: any) {
|
|
305
|
+
handleSingleDeselect(value?: any, skip?: boolean) {
|
|
259
306
|
this.$emit('deselected', value ?? this.value)
|
|
307
|
+
if (skip) {
|
|
308
|
+
return
|
|
309
|
+
}
|
|
310
|
+
if (this.multiselect && this.selectChildren) {
|
|
311
|
+
const hasChildren = !!(
|
|
312
|
+
this.getOptionByValue(value ?? this.value) as DlSelectOption
|
|
313
|
+
)?.children?.length
|
|
314
|
+
if (hasChildren) {
|
|
315
|
+
this.updatingLeaf = true
|
|
316
|
+
this.$nextTick(() => {
|
|
317
|
+
// deselect all children recursively and update model value
|
|
318
|
+
const children = this.getAllChildren(
|
|
319
|
+
this.children ?? []
|
|
320
|
+
)
|
|
321
|
+
children.push(value ?? this.value)
|
|
322
|
+
const newModelValue = (this.modelValue as any[]).filter(
|
|
323
|
+
(v) => !children.includes(v)
|
|
324
|
+
)
|
|
325
|
+
this.$emit('update:model-value', newModelValue)
|
|
326
|
+
this.updatingLeaf = false
|
|
327
|
+
})
|
|
328
|
+
}
|
|
329
|
+
}
|
|
260
330
|
},
|
|
261
331
|
handleCheckboxUpdate(newVal: string[] | boolean, e: Event): void {
|
|
262
|
-
this
|
|
332
|
+
if (!this.updatingLeaf) {
|
|
333
|
+
this.$emit('update:model-value', newVal, e)
|
|
334
|
+
}
|
|
263
335
|
},
|
|
264
336
|
handleClick(e: Event) {
|
|
265
337
|
e.stopPropagation()
|
|
@@ -287,6 +359,19 @@ export default defineComponent({
|
|
|
287
359
|
getValue(option: any) {
|
|
288
360
|
return typeof option === 'object' ? option.value : null
|
|
289
361
|
},
|
|
362
|
+
getOptionByValue(value: any): DlSelectOptionType {
|
|
363
|
+
if (this.value === value) {
|
|
364
|
+
return this as any as DlSelectOptionType
|
|
365
|
+
}
|
|
366
|
+
if (this.children) {
|
|
367
|
+
const child =
|
|
368
|
+
this.children.find((child) => {
|
|
369
|
+
return this.getValue(child) === value
|
|
370
|
+
}) ?? null
|
|
371
|
+
|
|
372
|
+
return child as DlSelectOptionType
|
|
373
|
+
}
|
|
374
|
+
},
|
|
290
375
|
isReadonlyOption(option: any) {
|
|
291
376
|
return !!option?.readonly
|
|
292
377
|
}
|
|
@@ -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
|
]
|