@dataloop-ai/components 0.18.134 → 0.18.136
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 +1 -1
- package/src/components/compound/DlOptionGroup/DlOptionGroup.vue +3 -2
- package/src/components/compound/DlSelect/DlSelect.vue +6 -1
- package/src/components/compound/DlSelect/components/DlSelectOption.vue +26 -2
- package/src/demos/DlOptionGroupDemo.vue +4 -6
- package/src/demos/DlSelectDemo.vue +72 -0
package/package.json
CHANGED
|
@@ -128,7 +128,8 @@ export default defineComponent({
|
|
|
128
128
|
: 'flex-end',
|
|
129
129
|
'--option-group-width':
|
|
130
130
|
this.leftLabel && !this.inline ? '100%' : 'auto',
|
|
131
|
-
'--option-group-max-width': this.maxWidth
|
|
131
|
+
'--option-group-max-width': this.maxWidth,
|
|
132
|
+
'--option-group-gap': this.isInMenu ? '0px' : '10px'
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
},
|
|
@@ -175,7 +176,7 @@ export default defineComponent({
|
|
|
175
176
|
}
|
|
176
177
|
.option-group-wrapper.column {
|
|
177
178
|
flex-direction: column;
|
|
178
|
-
gap:
|
|
179
|
+
gap: var(--option-group-gap);
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
.option {
|
|
@@ -232,6 +232,7 @@
|
|
|
232
232
|
:count="getOptionCount(item)"
|
|
233
233
|
:children="getOptionChildren(item)"
|
|
234
234
|
:capitalized="capitalizedOptions"
|
|
235
|
+
:readonly="isReadonlyOption(item)"
|
|
235
236
|
@update:model-value="handleModelValueUpdate"
|
|
236
237
|
@click="selectOption(item)"
|
|
237
238
|
@selected="handleSelected"
|
|
@@ -272,6 +273,7 @@
|
|
|
272
273
|
:count="getOptionCount(option)"
|
|
273
274
|
:children="getOptionChildren(option)"
|
|
274
275
|
:capitalized="capitalizedOptions"
|
|
276
|
+
:readonly="isReadonlyOption(option)"
|
|
275
277
|
@update:model-value="handleModelValueUpdate"
|
|
276
278
|
@click="selectOption(option)"
|
|
277
279
|
@selected="handleSelected"
|
|
@@ -751,6 +753,9 @@ export default defineComponent({
|
|
|
751
753
|
? option?.children
|
|
752
754
|
: null
|
|
753
755
|
},
|
|
756
|
+
isReadonlyOption(option: any) {
|
|
757
|
+
return !!option?.readonly
|
|
758
|
+
},
|
|
754
759
|
getOptionCount(option: any) {
|
|
755
760
|
return option?.count ?? null
|
|
756
761
|
},
|
|
@@ -791,7 +796,7 @@ export default defineComponent({
|
|
|
791
796
|
this.closeMenu()
|
|
792
797
|
},
|
|
793
798
|
selectOption(selectedOption: DlSelectOptionType) {
|
|
794
|
-
if (this.multiselect) {
|
|
799
|
+
if (this.multiselect || this.isReadonlyOption(selectedOption)) {
|
|
795
800
|
return
|
|
796
801
|
}
|
|
797
802
|
|
|
@@ -4,7 +4,17 @@
|
|
|
4
4
|
:class="identifierClass"
|
|
5
5
|
style="width: 100%"
|
|
6
6
|
>
|
|
7
|
+
<div
|
|
8
|
+
v-if="readonly"
|
|
9
|
+
:class="[{ 'readonly-option': true }, { capitalized }]"
|
|
10
|
+
:style="`padding-left: ${10 + depth * 30}px;`"
|
|
11
|
+
>
|
|
12
|
+
<slot>
|
|
13
|
+
{{ label ? (capitalized ? label.toLowerCase() : label) : null }}
|
|
14
|
+
</slot>
|
|
15
|
+
</div>
|
|
7
16
|
<dl-list-item
|
|
17
|
+
v-else
|
|
8
18
|
class="option"
|
|
9
19
|
:class="{ highlighted: highlightSelected && isSelected }"
|
|
10
20
|
:with-wave="withWave"
|
|
@@ -87,6 +97,7 @@
|
|
|
87
97
|
:highlight-selected="highlightSelected"
|
|
88
98
|
:with-wave="withWave"
|
|
89
99
|
:capitalized="capitalized"
|
|
100
|
+
:readonly="isReadonlyOption(child)"
|
|
90
101
|
@update:model-value="handleCheckboxUpdate"
|
|
91
102
|
@selected="handleSingleSelect"
|
|
92
103
|
@deselected="handleSingleDeselect"
|
|
@@ -136,7 +147,8 @@ export default defineComponent({
|
|
|
136
147
|
},
|
|
137
148
|
depth: { type: Number, default: 0 },
|
|
138
149
|
label: { type: String, default: null },
|
|
139
|
-
capitalized: { type: Boolean, default: false }
|
|
150
|
+
capitalized: { type: Boolean, default: false },
|
|
151
|
+
readonly: { type: Boolean, default: false }
|
|
140
152
|
},
|
|
141
153
|
emits: [
|
|
142
154
|
'update:model-value',
|
|
@@ -147,7 +159,7 @@ export default defineComponent({
|
|
|
147
159
|
],
|
|
148
160
|
data() {
|
|
149
161
|
return {
|
|
150
|
-
showChildren:
|
|
162
|
+
showChildren: !!this.readonly,
|
|
151
163
|
componentId: v4(),
|
|
152
164
|
uuid: `dl-select-option-${v4()}`
|
|
153
165
|
}
|
|
@@ -216,6 +228,9 @@ export default defineComponent({
|
|
|
216
228
|
},
|
|
217
229
|
getValue(option: any) {
|
|
218
230
|
return typeof option === 'object' ? option.value : null
|
|
231
|
+
},
|
|
232
|
+
isReadonlyOption(option: any) {
|
|
233
|
+
return !!option?.readonly
|
|
219
234
|
}
|
|
220
235
|
}
|
|
221
236
|
})
|
|
@@ -269,4 +284,13 @@ export default defineComponent({
|
|
|
269
284
|
.capitalized .checkbox-label {
|
|
270
285
|
text-transform: capitalize !important;
|
|
271
286
|
}
|
|
287
|
+
|
|
288
|
+
.readonly-option {
|
|
289
|
+
height: 28px;
|
|
290
|
+
display: flex;
|
|
291
|
+
align-items: center;
|
|
292
|
+
font-size: 12px;
|
|
293
|
+
line-height: 16px;
|
|
294
|
+
color: var(--dl-color-lighter);
|
|
295
|
+
}
|
|
272
296
|
</style>
|
|
@@ -29,17 +29,15 @@
|
|
|
29
29
|
/>
|
|
30
30
|
|
|
31
31
|
<h1>in menu : The chosen options are {{ switchValue }}</h1>
|
|
32
|
-
<dl-button
|
|
33
|
-
label="Menu"
|
|
34
|
-
@click="$refs.menu.show()"
|
|
35
|
-
>
|
|
32
|
+
<dl-button label="Menu">
|
|
36
33
|
<dl-menu
|
|
37
34
|
ref="menu"
|
|
38
|
-
fit-
|
|
35
|
+
fit-content
|
|
39
36
|
>
|
|
40
37
|
<dl-option-group
|
|
41
38
|
v-model="switchValue"
|
|
42
|
-
|
|
39
|
+
left-label
|
|
40
|
+
type="switch"
|
|
43
41
|
:options="options"
|
|
44
42
|
/>
|
|
45
43
|
</dl-menu>
|
|
@@ -177,6 +177,15 @@
|
|
|
177
177
|
searchable
|
|
178
178
|
capitalized-options
|
|
179
179
|
/>
|
|
180
|
+
Tree options with readonly options
|
|
181
|
+
<dl-select
|
|
182
|
+
v-model="selectedWithChildrenAndReadonly"
|
|
183
|
+
:options="treeOptionsWithReadonly"
|
|
184
|
+
size="m"
|
|
185
|
+
multiselect
|
|
186
|
+
searchable
|
|
187
|
+
capitalized-options
|
|
188
|
+
/>
|
|
180
189
|
With Fit
|
|
181
190
|
<dl-select
|
|
182
191
|
v-model="selectedWithFit"
|
|
@@ -604,6 +613,67 @@ const treeOptions = [
|
|
|
604
613
|
}
|
|
605
614
|
]
|
|
606
615
|
|
|
616
|
+
const treeOptionsWithReadonly = [
|
|
617
|
+
{
|
|
618
|
+
label: 'Without children',
|
|
619
|
+
value: 'r0',
|
|
620
|
+
readonly: true
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
label: 'child 1',
|
|
624
|
+
value: 'r1'
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
label: 'child 2',
|
|
628
|
+
value: 'r2'
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
label: 'child 3',
|
|
632
|
+
value: 'r3'
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
label: 'With children',
|
|
636
|
+
value: 'r4',
|
|
637
|
+
readonly: true,
|
|
638
|
+
children: [
|
|
639
|
+
{ label: 'child 1', value: 'c1' },
|
|
640
|
+
{ label: 'child 2', value: 'c2' },
|
|
641
|
+
{ label: 'child 3', value: 'c3' },
|
|
642
|
+
{ label: 'child 4', value: 'c4' },
|
|
643
|
+
{ label: 'child 5', value: 'c5' }
|
|
644
|
+
]
|
|
645
|
+
},
|
|
646
|
+
{
|
|
647
|
+
label: 'With children & readonly child',
|
|
648
|
+
value: 'r5',
|
|
649
|
+
children: [
|
|
650
|
+
{ label: 'child 1', value: 'c1' },
|
|
651
|
+
{ label: 'child 2', value: 'c2' },
|
|
652
|
+
{ label: 'child 3', value: 'c3', readonly: true },
|
|
653
|
+
{ label: 'child 4', value: 'c4' },
|
|
654
|
+
{ label: 'child 5', value: 'c5' }
|
|
655
|
+
]
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
label: 'Readonly option with children & readonly child',
|
|
659
|
+
value: 'r6',
|
|
660
|
+
readonly: true,
|
|
661
|
+
children: [
|
|
662
|
+
{ label: 'child 1', value: 'c6' },
|
|
663
|
+
{ label: 'child 2', value: 'c7' },
|
|
664
|
+
{
|
|
665
|
+
label: 'child 3',
|
|
666
|
+
value: 'c8',
|
|
667
|
+
readonly: true,
|
|
668
|
+
children: [
|
|
669
|
+
{ label: 'child 4', value: 'c9' },
|
|
670
|
+
{ label: 'child 5', value: 'c10' }
|
|
671
|
+
]
|
|
672
|
+
}
|
|
673
|
+
]
|
|
674
|
+
}
|
|
675
|
+
]
|
|
676
|
+
|
|
607
677
|
export default defineComponent({
|
|
608
678
|
components: { DlSelect, DlIcon, DlChip, DlBadge },
|
|
609
679
|
data() {
|
|
@@ -626,11 +696,13 @@ export default defineComponent({
|
|
|
626
696
|
},
|
|
627
697
|
searchOptions: defaultOptions,
|
|
628
698
|
treeOptions,
|
|
699
|
+
treeOptionsWithReadonly,
|
|
629
700
|
selectedBySearch: undefined,
|
|
630
701
|
selectedByFilteringSearch: [],
|
|
631
702
|
selectedWithEmitValue: 'c1',
|
|
632
703
|
selectedWithChildren: [],
|
|
633
704
|
selectedWithChildrenSearch: [],
|
|
705
|
+
selectedWithChildrenAndReadonly: [],
|
|
634
706
|
selectedWithChildrenCapitalized: [],
|
|
635
707
|
tasksFilter: [],
|
|
636
708
|
showAllOption: true,
|