diff --git a/docs/pages/kselectinkmodal.vue b/docs/pages/kselectinkmodal.vue new file mode 100644 index 000000000..4174300fb --- /dev/null +++ b/docs/pages/kselectinkmodal.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/docs/tableOfContents.js b/docs/tableOfContents.js index 96fe3ba3b..19d39b2cc 100644 --- a/docs/tableOfContents.js +++ b/docs/tableOfContents.js @@ -259,6 +259,11 @@ export default [ isCode: true, keywords: ['field', 'box'], }), + new Page({ + path: '/kselectinkmodal', + title: 'KSelectInKModal', + isCode: true, + }), new Page({ path: '/kswitch', title: 'KSwitch', diff --git a/lib/KSelect/KeenUiSelect.vue b/lib/KSelect/KeenUiSelect.vue index b966eec45..f2af0d30c 100644 --- a/lib/KSelect/KeenUiSelect.vue +++ b/lib/KSelect/KeenUiSelect.vue @@ -1,182 +1,136 @@ - + diff --git a/lib/KSelect/KeenUiSelectOption.vue b/lib/KSelect/KeenUiSelectOption.vue index a3b93fd31..f72a4e7ef 100644 --- a/lib/KSelect/KeenUiSelectOption.vue +++ b/lib/KSelect/KeenUiSelectOption.vue @@ -1,14 +1,24 @@ - + diff --git a/lib/KSelect/index.vue b/lib/KSelect/index.vue index a92a9008e..872e1354d 100644 --- a/lib/KSelect/index.vue +++ b/lib/KSelect/index.vue @@ -6,7 +6,7 @@ 'k-select-inline': inline, 'k-select-disabled': disabled, }" - :value="selection" + :modelValue="selection" :options="options" :label="label" :floatingLabel="floatingLabel" diff --git a/lib/KSelect/mixins/RespondsToExternalClick.vue b/lib/KSelect/mixins/RespondsToExternalClick.vue new file mode 100644 index 000000000..31b49d675 --- /dev/null +++ b/lib/KSelect/mixins/RespondsToExternalClick.vue @@ -0,0 +1,38 @@ +import events from '../../keen/helpers/events'; + +export default { + emits: ['external-click'], + + beforeUnmount() { + if (typeof this.destroyExternalClickListener === 'function') { + this.removeExternalClickListener(); + } + }, + + methods: { + addExternalClickListener(elements = [this.$el], callback = null, options = { passive: true }) { + elements = Array.isArray(elements) ? elements : [elements]; + + this.destroyExternalClickListener = events.on('click', document, e => { + for (let i = 0; i < elements.length; i++) { + if (elements[i].contains(e.target)) { + return; // End early, click was internal + } + } + + if (typeof callback === 'function') { + callback(e); + } else { + this.$emit('external-click', e); + } + }, options); + }, + + removeExternalClickListener() { + if (this.destroyExternalClickListener) { + this.destroyExternalClickListener(); + this.destroyExternalClickListener = null; + } + } + } +}; diff --git a/lib/KSelectinKModal.vue b/lib/KSelectinKModal.vue new file mode 100644 index 000000000..aae83ede6 --- /dev/null +++ b/lib/KSelectinKModal.vue @@ -0,0 +1,15 @@ + + + + +