@signal24/vue-foundation 4.25.5 → 4.25.7
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.
|
@@ -55,12 +55,25 @@
|
|
|
55
55
|
|
|
56
56
|
Selected value: {{ selectedDelayedOption3 ?? '-' }}
|
|
57
57
|
</div>
|
|
58
|
+
|
|
59
|
+
<div>
|
|
60
|
+
<VfSmartSelect
|
|
61
|
+
v-model="selectedCreateOption"
|
|
62
|
+
:options="createOptions"
|
|
63
|
+
:formatter="o => o.label"
|
|
64
|
+
:value-extractor="o => o.value"
|
|
65
|
+
:on-create-item="createOption"
|
|
66
|
+
:show-create-text-on-new-item="true"
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
Selected value: {{ selectedCreateOption ?? '-' }}
|
|
70
|
+
</div>
|
|
58
71
|
</div>
|
|
59
72
|
</template>
|
|
60
73
|
|
|
61
74
|
<script lang="ts" setup>
|
|
62
|
-
import { cloneDeep } from 'lodash';
|
|
63
|
-
import { onMounted, ref } from 'vue';
|
|
75
|
+
import { cloneDeep, compact } from 'lodash';
|
|
76
|
+
import { computed, onMounted, ref } from 'vue';
|
|
64
77
|
|
|
65
78
|
import VfSmartSelect from '@/components/vf-smart-select.vue';
|
|
66
79
|
|
|
@@ -90,11 +103,22 @@ const selectedInstantOption2 = ref<IOption | null>(null);
|
|
|
90
103
|
const selectedDelayedOption1 = ref<IOption | null>(options[1]);
|
|
91
104
|
const selectedDelayedOption2 = ref<string | null>('2');
|
|
92
105
|
const selectedDelayedOption3 = ref<string | null>('19'); // intentionally invalid value
|
|
106
|
+
const selectedCreateOption = ref<string | null>(null);
|
|
107
|
+
|
|
108
|
+
const createdOptionTitle = ref<string>();
|
|
109
|
+
const createOptions = computed(() =>
|
|
110
|
+
compact([createdOptionTitle.value && { label: createdOptionTitle.value, value: 'new' }, ...(delayedOptions.value || [])])
|
|
111
|
+
);
|
|
93
112
|
|
|
94
113
|
function setDelayedOptions() {
|
|
95
114
|
delayedOptions.value = cloneDeep(options);
|
|
96
115
|
}
|
|
97
116
|
|
|
117
|
+
function createOption(name: string) {
|
|
118
|
+
createdOptionTitle.value = name;
|
|
119
|
+
selectedCreateOption.value = 'new';
|
|
120
|
+
}
|
|
121
|
+
|
|
98
122
|
onMounted(() => setTimeout(setDelayedOptions, 1000));
|
|
99
123
|
</script>
|
|
100
124
|
|