@cloudron/pankow 3.5.16 → 3.5.18
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/components/Checkbox.vue
CHANGED
|
@@ -17,7 +17,7 @@ const internalId = uuidv4();
|
|
|
17
17
|
|
|
18
18
|
<template>
|
|
19
19
|
<span class="pankow-checkbox">
|
|
20
|
-
<input :id="id || internalId" class="pankow-checkbox-input" type="checkbox" v-model="model" :disabled="disabled" @input="$emit('update:modelValue', $event.target.checked)"/>
|
|
20
|
+
<input :id="id || internalId" class="pankow-checkbox-input" type="checkbox" v-model="model" :disabled="disabled" :required="$attrs['required']" @input="$emit('update:modelValue', $event.target.checked)"/>
|
|
21
21
|
<slot>
|
|
22
22
|
<label :for="id || internalId" class="pankow-checkbox-input-label">
|
|
23
23
|
{{ label }}
|
|
@@ -85,7 +85,8 @@ const menuModel = computed(() => {
|
|
|
85
85
|
emits('select', selected.value);
|
|
86
86
|
|
|
87
87
|
// let the browser know about the changes
|
|
88
|
-
|
|
88
|
+
// multi selects work different than single, we set the value of the first selected item only to react to required
|
|
89
|
+
nativeSelect.value.value = selected.value.length ? selected.value[0] : null;
|
|
89
90
|
nativeSelect.value.dispatchEvent(new Event('input', { bubbles: true }));
|
|
90
91
|
nativeSelect.value.dispatchEvent(new Event('change', { bubbles: true }));
|
|
91
92
|
}
|
|
@@ -120,6 +121,10 @@ const menuModel = computed(() => {
|
|
|
120
121
|
return ret;
|
|
121
122
|
});
|
|
122
123
|
|
|
124
|
+
function isSelected(item) {
|
|
125
|
+
return selected.value.indexOf(props.optionKey ? item[props.optionKey] : item) !== -1;
|
|
126
|
+
}
|
|
127
|
+
|
|
123
128
|
function onClick(event) {
|
|
124
129
|
if (props.disabled) return;
|
|
125
130
|
|
|
@@ -133,12 +138,16 @@ function onOpen(event) {
|
|
|
133
138
|
menu.value.open(event, elem.value);
|
|
134
139
|
}
|
|
135
140
|
|
|
136
|
-
function onClose(
|
|
141
|
+
function onClose() {
|
|
142
|
+
elem.value.focus();
|
|
143
|
+
emits('close');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function onEscape(event) {
|
|
137
147
|
if (menu.value.isOpen) {
|
|
138
|
-
|
|
139
|
-
if (event) event.stopPropagation();
|
|
148
|
+
event.stopPropagation();
|
|
140
149
|
menu.value.close();
|
|
141
|
-
|
|
150
|
+
onClose();
|
|
142
151
|
}
|
|
143
152
|
}
|
|
144
153
|
|
|
@@ -149,11 +158,11 @@ onMounted(() => {
|
|
|
149
158
|
</script>
|
|
150
159
|
|
|
151
160
|
<template>
|
|
152
|
-
<div class="pankow-multiselect" :class="{ 'pankow-multiselect-disabled': disabled }" ref="elem" tabindex="0" @click="onClick" @keydown.enter="onOpen" @keydown.down.stop="onOpen" @keydown.up.stop="onOpen" @keydown.esc="
|
|
161
|
+
<div class="pankow-multiselect" :class="{ 'pankow-multiselect-disabled': disabled }" ref="elem" tabindex="0" @click="onClick" @keydown.enter="onOpen" @keydown.down.stop="onOpen" @keydown.up.stop="onOpen" @keydown.esc="onEscape">
|
|
153
162
|
<!-- native select for required and accessibility handling -->
|
|
154
163
|
<select ref="nativeSelect" :required="$attrs['required']" multiple style="display: none">
|
|
155
164
|
<option value=""></option>
|
|
156
|
-
<option v-for="item in options" :value="optionKey ? item[optionKey] : item">{{ optionKey }} - {{ item[optionLabel] }}</option>
|
|
165
|
+
<option v-for="item in options" :value="optionKey ? item[optionKey] : item" :selected="isSelected(item) ? true : null">{{ optionKey }} - {{ item[optionLabel] }}</option>
|
|
157
166
|
</select>
|
|
158
167
|
|
|
159
168
|
<Menu ref="menu" :model="menuModel" :close-on-activation="false" @close="onClose" :search-threshold="searchThreshold"></Menu>
|
|
@@ -107,7 +107,6 @@ function onOpen(event) {
|
|
|
107
107
|
|
|
108
108
|
function onClose(event = null) {
|
|
109
109
|
if (menu.value.isOpen) {
|
|
110
|
-
if (event) event.stopPropagation();
|
|
111
110
|
elem.value.focus();
|
|
112
111
|
menu.value.close();
|
|
113
112
|
emits('close');
|
|
@@ -154,6 +153,8 @@ function onKeyDown(event) {
|
|
|
154
153
|
});
|
|
155
154
|
|
|
156
155
|
if (found !== -1) selectIndex(found);
|
|
156
|
+
|
|
157
|
+
event.stopPropagation();
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
function handleDefaultSelect() {
|
|
@@ -170,7 +171,7 @@ watchEffect(handleDefaultSelect);
|
|
|
170
171
|
</script>
|
|
171
172
|
|
|
172
173
|
<template>
|
|
173
|
-
<div class="pankow-singleselect" :class="{ 'pankow-singleselect-disabled': disabled }" ref="elem" tabindex="0" @click="onClick" @keydown.enter="onOpen" @keydown.down.stop.prevent="onSelectNext" @keydown.up.stop.prevent="onSelectPrev" @keydown
|
|
174
|
+
<div class="pankow-singleselect" :class="{ 'pankow-singleselect-disabled': disabled }" ref="elem" tabindex="0" @click="onClick" @keydown.enter="onOpen" @keydown.down.stop.prevent="onSelectNext" @keydown.up.stop.prevent="onSelectPrev" @keydown="onKeyDown($event)">
|
|
174
175
|
<!-- native select for required and accessibility handling -->
|
|
175
176
|
<select v-model="selectedKey" ref="nativeSelect" :required="$attrs['required']" style="display: none">
|
|
176
177
|
<option value=""></option>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudron/pankow",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "3.5.
|
|
4
|
+
"version": "3.5.18",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@vitejs/plugin-vue": "^6.0.2",
|
|
26
26
|
"typescript": "^5.9.3",
|
|
27
|
-
"vite": "^7.2.
|
|
27
|
+
"vite": "^7.2.7",
|
|
28
28
|
"vue": "^3.5.25"
|
|
29
29
|
}
|
|
30
30
|
}
|