admins-components 1.1.0 → 1.2.0
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/README.md +5 -0
- package/admins-components/.vscode/extensions.json +3 -0
- package/admins-components/README.md +5 -0
- package/admins-components/index.html +13 -0
- package/admins-components/package.json +21 -0
- package/admins-components/public/vite.svg +1 -0
- package/admins-components/src/App.vue +30 -0
- package/admins-components/src/assets/vue.svg +1 -0
- package/admins-components/src/components/HelloWorld.vue +41 -0
- package/admins-components/src/main.ts +5 -0
- package/admins-components/src/style.css +79 -0
- package/admins-components/src/vite-env.d.ts +1 -0
- package/admins-components/tsconfig.app.json +14 -0
- package/admins-components/tsconfig.json +7 -0
- package/admins-components/tsconfig.node.json +24 -0
- package/admins-components/vite.config.ts +7 -0
- package/index.html +13 -0
- package/package.json +9 -23
- package/src/App.vue +5 -0
- package/src/assets/dropdown.scss +61 -0
- package/src/assets/dropdowncallback.scss +57 -0
- package/src/assets/dropdownmenu.scss +33 -0
- package/src/assets/filtercompact.scss +6 -0
- package/src/assets/filtercontrol.scss +23 -0
- package/src/assets/iconbutton.scss +31 -0
- package/src/assets/main.scss +38 -0
- package/src/assets/paginatorcontrol.scss +16 -0
- package/src/assets/propertyselector.scss +12 -0
- package/src/assets/tabletolist.scss +115 -0
- package/src/assets/tabletolistoptions.scss +22 -0
- package/src/assets/textlistbox.scss +16 -0
- package/src/assets/toastcomponent.scss +23 -0
- package/src/components/CheckBox.vue +25 -0
- package/src/components/CheckBoxList.vue +48 -0
- package/src/components/DropDown.vue +203 -0
- package/src/components/DropDownCallBack.vue +109 -0
- package/src/components/DropDownMenu.vue +88 -0
- package/src/components/FilterCompact.vue +146 -0
- package/src/components/FilterControl.vue +133 -0
- package/src/components/IconButton.vue +25 -0
- package/src/components/PaginatorControl.vue +82 -0
- package/src/components/RadioButton.vue +21 -0
- package/src/components/RadioButtonGroup.vue +28 -0
- package/src/components/SpinningProgress.vue +9 -0
- package/src/components/TableToList.vue +281 -0
- package/src/components/TableToListOptions.vue +99 -0
- package/src/components/TextListBox.vue +50 -0
- package/src/components/ToastComponent.vue +82 -0
- package/src/components/ToastWrapper.vue +44 -0
- package/src/index.ts +56 -0
- package/src/main.ts +5 -0
- package/src/style.css +79 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.app.json +14 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +24 -0
- package/vite.config.ts +49 -0
- package/dist/index.css +0 -1
- package/dist/index.mjs +0 -948
- package/dist/index.umd.js +0 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
.t2l-table-view {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.t2l-table-header-label {
|
|
7
|
+
background-color: var(--bs-gray-200);
|
|
8
|
+
font-weight: bold;
|
|
9
|
+
border-bottom: 1px solid var(--bs-gray-400);
|
|
10
|
+
padding: 0.5rem;
|
|
11
|
+
flex-direction: row;
|
|
12
|
+
align-items: center;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.t2l-table-header-filter {
|
|
16
|
+
background-color: var(--bs-gray-200);
|
|
17
|
+
font-weight: bold;
|
|
18
|
+
border-bottom: 1px solid var(--bs-gray-400);
|
|
19
|
+
padding: 0.3rem;
|
|
20
|
+
flex-direction: row;
|
|
21
|
+
align-items: center;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.t2l-rows {
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
flex: 1;
|
|
27
|
+
overflow-y: auto;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.t2l-row {
|
|
31
|
+
border-bottom: 1px solid var(--bs-gray-400);
|
|
32
|
+
padding: 0.3rem;
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: row;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.t2l-cell {
|
|
38
|
+
padding: 0.3rem;
|
|
39
|
+
display: flex;
|
|
40
|
+
flex: 1;
|
|
41
|
+
align-items: center;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.t2l-select {
|
|
45
|
+
padding: 0.3rem;
|
|
46
|
+
display: flex;
|
|
47
|
+
flex: 1;
|
|
48
|
+
align-items: center;
|
|
49
|
+
max-width: 3rem;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.t2l-cell-label {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.t2l-actions {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: row;
|
|
59
|
+
gap: 0.5rem;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.t2l-card-view {
|
|
63
|
+
display: none;
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.t2l-card-col {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
flex: 1;
|
|
71
|
+
gap: 1rem;
|
|
72
|
+
overflow-y: auto;
|
|
73
|
+
align-items: start;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.t2l-card-select {
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
align-items: center;
|
|
81
|
+
flex: 1;
|
|
82
|
+
max-width: 2rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.t2l-card-filters {
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
gap: 0.5rem;
|
|
88
|
+
padding: 0.5rem;
|
|
89
|
+
background-color: var(--bs-gray-200);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.t2l-property {
|
|
93
|
+
display: flex;
|
|
94
|
+
flex-direction: column;
|
|
95
|
+
flex: 1;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.t2l-label {
|
|
99
|
+
font-weight: bold;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.t2l-footer {
|
|
103
|
+
padding: 1rem;
|
|
104
|
+
background-color: var(--bs-gray-200);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@media (max-width: 1024px) {
|
|
108
|
+
.t2l-table-view {
|
|
109
|
+
display: none;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.t2l-card-view {
|
|
113
|
+
display: flex;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.options-header {
|
|
2
|
+
cursor: pointer;
|
|
3
|
+
font-size: 0.8rem;
|
|
4
|
+
padding: 0.2rem;
|
|
5
|
+
border-top: 1px solid var(--bs-gray-200);
|
|
6
|
+
border-right: 1px solid var(--bs-gray-200);
|
|
7
|
+
border-top-right-radius: 3px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.options-header:hover {
|
|
11
|
+
opacity: 0.7;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.options-body {
|
|
15
|
+
font-size: 0.8rem;
|
|
16
|
+
padding: 1rem;
|
|
17
|
+
background-color: var(--bs-gray-100);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.options-header-label {
|
|
21
|
+
font-weight: bold;
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.toast-info {
|
|
2
|
+
background: var(--bs-blue);
|
|
3
|
+
color: white;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.toast-success {
|
|
7
|
+
background: var(--bs-green);
|
|
8
|
+
color: white;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.toast-warning {
|
|
12
|
+
background: var(--bs-orange);
|
|
13
|
+
color: white;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.toast-error {
|
|
17
|
+
background: var(--bs-red);
|
|
18
|
+
color: white;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.toast-zindex {
|
|
22
|
+
z-index: 1100;
|
|
23
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{ id: string; label: string; checked: boolean }>();
|
|
3
|
+
|
|
4
|
+
defineEmits<{
|
|
5
|
+
(e: "changed", option: { id: string; checked: boolean }): void;
|
|
6
|
+
}>();
|
|
7
|
+
</script>
|
|
8
|
+
<template>
|
|
9
|
+
<div class="form-check">
|
|
10
|
+
<input
|
|
11
|
+
class="form-check-input"
|
|
12
|
+
type="checkbox"
|
|
13
|
+
:checked="checked"
|
|
14
|
+
value=""
|
|
15
|
+
:id="id"
|
|
16
|
+
@change="
|
|
17
|
+
$emit('changed', {
|
|
18
|
+
id,
|
|
19
|
+
checked: ($event as any).target.checked,
|
|
20
|
+
})
|
|
21
|
+
"
|
|
22
|
+
/>
|
|
23
|
+
<label class="form-check-label" :for="id"> {{ label }} </label>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import CheckBox from "./CheckBox.vue";
|
|
3
|
+
|
|
4
|
+
defineProps<{
|
|
5
|
+
items: CheckBoxListItem[];
|
|
6
|
+
callback: (id: string, checked: boolean) => any;
|
|
7
|
+
}>();
|
|
8
|
+
|
|
9
|
+
export interface CheckBoxListItem {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string;
|
|
12
|
+
checked: boolean;
|
|
13
|
+
|
|
14
|
+
childrend: CheckBoxListItem[];
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
<template>
|
|
18
|
+
<template v-for="item in items" :key="item.id">
|
|
19
|
+
<div class="cbl-container">
|
|
20
|
+
<CheckBox
|
|
21
|
+
:id="item.id"
|
|
22
|
+
:label="item.label"
|
|
23
|
+
:checked="item.checked"
|
|
24
|
+
@changed="callback($event.id, $event.checked)"
|
|
25
|
+
></CheckBox>
|
|
26
|
+
<div class="cbl-childrend-container">
|
|
27
|
+
<CheckBoxList
|
|
28
|
+
v-if="item.childrend"
|
|
29
|
+
:items="item.childrend"
|
|
30
|
+
:callback="callback"
|
|
31
|
+
></CheckBoxList>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<style scoped>
|
|
38
|
+
.cbl-container {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.cbl-childrend-container {
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
padding-left: 1rem;
|
|
47
|
+
}
|
|
48
|
+
</style>
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onMounted, ref, watch, type Ref } from "vue";
|
|
3
|
+
|
|
4
|
+
const props = defineProps<{
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
selected?: string | undefined | null;
|
|
8
|
+
options: Ref<DropDownItem[]>;
|
|
9
|
+
opentop?: boolean;
|
|
10
|
+
disableFilter?: boolean;
|
|
11
|
+
storeselected?: boolean;
|
|
12
|
+
filterevent?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}>();
|
|
15
|
+
|
|
16
|
+
watch(props.options, () => {
|
|
17
|
+
if (props.filterevent) {
|
|
18
|
+
filtered.value = props.options.value;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
watch(
|
|
23
|
+
() => props.selected,
|
|
24
|
+
() => {
|
|
25
|
+
trySetSelected();
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
watch(
|
|
30
|
+
() => props.label,
|
|
31
|
+
() => {
|
|
32
|
+
trySetSelected();
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const emits = defineEmits<{
|
|
37
|
+
(e: "selected", option: DropDownItem): void;
|
|
38
|
+
(e: "filtered", filter: string): void;
|
|
39
|
+
}>();
|
|
40
|
+
|
|
41
|
+
const select = (o: DropDownItem) => {
|
|
42
|
+
if (!props.storeselected) display.value = o.label;
|
|
43
|
+
|
|
44
|
+
emits("selected", o);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const CLEAR = "törlés";
|
|
48
|
+
const display = ref("");
|
|
49
|
+
|
|
50
|
+
const trySetSelected = () => {
|
|
51
|
+
if (props.options.value) {
|
|
52
|
+
const found = props.options.value.find((i) => i.id == props.selected);
|
|
53
|
+
if (found) {
|
|
54
|
+
display.value = found.label;
|
|
55
|
+
} else {
|
|
56
|
+
filter("");
|
|
57
|
+
display.value = props.label;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
onMounted(() => {
|
|
63
|
+
if (props.label) display.value = props.label;
|
|
64
|
+
|
|
65
|
+
trySetSelected();
|
|
66
|
+
|
|
67
|
+
lastFilter = "";
|
|
68
|
+
|
|
69
|
+
document.addEventListener("click", function () {
|
|
70
|
+
if (disp.value == "block") disp.value = "none";
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
window.addEventListener("scrolled", function () {
|
|
74
|
+
if (disp.value == "block") disp.value = "none";
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
setMenuTop();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
let lastFilter = "";
|
|
81
|
+
const filter = (sel: string) => {
|
|
82
|
+
lastFilter = sel;
|
|
83
|
+
|
|
84
|
+
if (!props.filterevent) {
|
|
85
|
+
if (sel == "") filtered.value = props.options.value;
|
|
86
|
+
else
|
|
87
|
+
filtered.value = props.options.value.filter((i) =>
|
|
88
|
+
i.label.toLowerCase().includes(sel.toLowerCase())
|
|
89
|
+
);
|
|
90
|
+
} else {
|
|
91
|
+
emits("filtered", sel);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const filtered = ref([] as DropDownItem[]);
|
|
96
|
+
|
|
97
|
+
const clear = () => {
|
|
98
|
+
select({ label: props.label!, id: "" });
|
|
99
|
+
filter("");
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const showDelayed = () => {
|
|
103
|
+
if (disp.value == "block") {
|
|
104
|
+
disp.value = "none";
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
setTimeout(() => {
|
|
108
|
+
disp.value = "block";
|
|
109
|
+
}, 10);
|
|
110
|
+
|
|
111
|
+
setTimeout(setMenuTop, 20);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const setMenuTop = () => {
|
|
115
|
+
const ddtb = DropDownTriggerButton.value as any;
|
|
116
|
+
const ddm = DropDownMenu.value as any;
|
|
117
|
+
|
|
118
|
+
if (props.opentop) {
|
|
119
|
+
ddm.style.top =
|
|
120
|
+
ddtb.getBoundingClientRect().y - ddm.offsetHeight + "px";
|
|
121
|
+
} else {
|
|
122
|
+
ddm.style.top =
|
|
123
|
+
ddtb.getBoundingClientRect().y + ddtb.offsetHeight + "px";
|
|
124
|
+
|
|
125
|
+
// it is needed if the dropdown is displayed in an absolute positioned stuff, uggly but working
|
|
126
|
+
if (
|
|
127
|
+
ddtb.getBoundingClientRect().y - ddm.getBoundingClientRect().y !=
|
|
128
|
+
-ddtb.offsetHeight
|
|
129
|
+
) {
|
|
130
|
+
ddm.style.top =
|
|
131
|
+
parseInt(ddm.style.top.substring(0, ddm.style.top.length - 2)) +
|
|
132
|
+
(ddtb.getBoundingClientRect().y -
|
|
133
|
+
ddm.getBoundingClientRect().y) +
|
|
134
|
+
ddtb.offsetHeight +
|
|
135
|
+
"px";
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (ddSearch.value) (ddSearch as any).value.focus();
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const DropDownTriggerButton = ref(null);
|
|
143
|
+
const DropDownMenu = ref(null);
|
|
144
|
+
|
|
145
|
+
const disp = ref("none" as "none" | "block");
|
|
146
|
+
|
|
147
|
+
const ddSearch = ref(null);
|
|
148
|
+
</script>
|
|
149
|
+
|
|
150
|
+
<script lang="ts">
|
|
151
|
+
export interface DropDownItem {
|
|
152
|
+
icon?: string;
|
|
153
|
+
label: string;
|
|
154
|
+
id: string;
|
|
155
|
+
}
|
|
156
|
+
</script>
|
|
157
|
+
|
|
158
|
+
<template>
|
|
159
|
+
<div :id="id" class="dd-flex">
|
|
160
|
+
<button
|
|
161
|
+
ref="DropDownTriggerButton"
|
|
162
|
+
class="btn btn-outline-secondary dd-toggle dd-flex"
|
|
163
|
+
type="button"
|
|
164
|
+
:disabled="disabled"
|
|
165
|
+
@click="
|
|
166
|
+
filter(lastFilter);
|
|
167
|
+
showDelayed();
|
|
168
|
+
"
|
|
169
|
+
>
|
|
170
|
+
<div class="dd-label">{{ display }}</div>
|
|
171
|
+
</button>
|
|
172
|
+
<div class="dd-menu" :style="{ display: disp }" ref="DropDownMenu">
|
|
173
|
+
<button
|
|
174
|
+
v-if="display != props.label"
|
|
175
|
+
type="button"
|
|
176
|
+
class="btn btn-outline-secondary dd-button"
|
|
177
|
+
@click="clear()"
|
|
178
|
+
>
|
|
179
|
+
{{ CLEAR }}
|
|
180
|
+
</button>
|
|
181
|
+
<input
|
|
182
|
+
ref="ddSearch"
|
|
183
|
+
v-if="!disableFilter"
|
|
184
|
+
type="text "
|
|
185
|
+
class="form-control"
|
|
186
|
+
placeholder="keresés"
|
|
187
|
+
@input="filter(($event.target as any).value)"
|
|
188
|
+
@click="$event.stopPropagation()"
|
|
189
|
+
/>
|
|
190
|
+
<div class="dd-item-list">
|
|
191
|
+
<div
|
|
192
|
+
v-for="o in filtered"
|
|
193
|
+
:key="o.id"
|
|
194
|
+
class="dd-item"
|
|
195
|
+
@click="select(o)"
|
|
196
|
+
>
|
|
197
|
+
<i v-if="o.icon" :class="o.icon" class="dd-item__icon"></i
|
|
198
|
+
>{{ o.label }}
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
</template>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onMounted, ref, type Ref } from "vue";
|
|
3
|
+
|
|
4
|
+
const props = defineProps<{
|
|
5
|
+
id: string;
|
|
6
|
+
default: DropDownCallBackItem;
|
|
7
|
+
selected?: string;
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
options: Ref<DropDownCallBackItem[]>;
|
|
10
|
+
}>();
|
|
11
|
+
|
|
12
|
+
const select = (o: DropDownCallBackItem) => {
|
|
13
|
+
if (o == props.default) {
|
|
14
|
+
display.value.callback("");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
display.value = o;
|
|
18
|
+
display.value.callback(display.value.value);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const CLEAR = "törlés";
|
|
22
|
+
const display = ref(props.default);
|
|
23
|
+
|
|
24
|
+
const trySetSelected = () => {
|
|
25
|
+
if (props.selected && props.options.value) {
|
|
26
|
+
const found = props.options.value.find(
|
|
27
|
+
(i) => i.value == props.selected
|
|
28
|
+
);
|
|
29
|
+
if (found) {
|
|
30
|
+
display.value = found;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
onMounted(() => {
|
|
36
|
+
trySetSelected();
|
|
37
|
+
|
|
38
|
+
document.addEventListener("click", function () {
|
|
39
|
+
if (disp.value == "block") disp.value = "none";
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export interface DropDownCallBackItem {
|
|
44
|
+
icon?: string;
|
|
45
|
+
label: string;
|
|
46
|
+
value: string;
|
|
47
|
+
callback: (property: string) => any;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const showDelayed = () => {
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
disp.value = "block";
|
|
53
|
+
}, 10);
|
|
54
|
+
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
top.value = (DropDownTriggerButton.value as any).offsetHeight;
|
|
57
|
+
}, 20);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const DropDownTriggerButton = ref(null);
|
|
61
|
+
const DropDownMenu = ref(null);
|
|
62
|
+
const top = ref(0);
|
|
63
|
+
|
|
64
|
+
const disp = ref("none" as "none" | "block");
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<template>
|
|
68
|
+
<div class="ddc-flex" :id="id">
|
|
69
|
+
<button
|
|
70
|
+
ref="DropDownTriggerButton"
|
|
71
|
+
class="btn btn-outline-secondary ddc-button"
|
|
72
|
+
type="button"
|
|
73
|
+
:disabled="!enabled"
|
|
74
|
+
@click="showDelayed()"
|
|
75
|
+
>
|
|
76
|
+
<span class="ddc-row"
|
|
77
|
+
><i :class="display.icon" class="ddc-icon"></i
|
|
78
|
+
><span class="ddc-label">{{ display.label }}</span></span
|
|
79
|
+
>
|
|
80
|
+
</button>
|
|
81
|
+
<div
|
|
82
|
+
class="ddc-menu"
|
|
83
|
+
:style="{ display: disp, 'margin-top': top + 'px' }"
|
|
84
|
+
ref="DropDownMenu"
|
|
85
|
+
>
|
|
86
|
+
<button
|
|
87
|
+
v-if="display != props.default"
|
|
88
|
+
type="button"
|
|
89
|
+
class="btn btn-outline-secondary ddc-button"
|
|
90
|
+
@click="select(props.default)"
|
|
91
|
+
>
|
|
92
|
+
{{ CLEAR }}
|
|
93
|
+
</button>
|
|
94
|
+
<div class="dd-item-list">
|
|
95
|
+
<div
|
|
96
|
+
v-for="o in options.value"
|
|
97
|
+
:key="o.label"
|
|
98
|
+
class="ddc-item"
|
|
99
|
+
@click="select(o)"
|
|
100
|
+
>
|
|
101
|
+
<span class="ddc-item"
|
|
102
|
+
><i :class="o.icon" class="ddc-icon"></i
|
|
103
|
+
><span class="ddc-label">{{ o.label }}</span></span
|
|
104
|
+
>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</template>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onMounted, ref } from "vue";
|
|
3
|
+
|
|
4
|
+
const props = defineProps<{
|
|
5
|
+
label?: string;
|
|
6
|
+
icon?: string;
|
|
7
|
+
options: DropDownMenuItem[];
|
|
8
|
+
item: any;
|
|
9
|
+
id: string;
|
|
10
|
+
right?: boolean;
|
|
11
|
+
}>();
|
|
12
|
+
|
|
13
|
+
export interface DropDownMenuItem {
|
|
14
|
+
icon: string;
|
|
15
|
+
label: string;
|
|
16
|
+
command: (item: any) => any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
onMounted(() => {
|
|
20
|
+
document.addEventListener("click", function () {
|
|
21
|
+
if (show.value) show.value = false;
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const show = ref(false);
|
|
26
|
+
|
|
27
|
+
const showDelayed = () => {
|
|
28
|
+
setTimeout(() => {
|
|
29
|
+
show.value = true;
|
|
30
|
+
}, 10);
|
|
31
|
+
|
|
32
|
+
setTimeout(setMenuTop, 20);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const setMenuTop = () => {
|
|
36
|
+
const ddtb = DropDownTriggerButton.value as any;
|
|
37
|
+
const ddm = DropDownMenu.value as any;
|
|
38
|
+
|
|
39
|
+
ddm.style.top = ddtb.getBoundingClientRect().y + ddtb.offsetHeight + "px";
|
|
40
|
+
|
|
41
|
+
// it is needed if the dropdown is displayed in an absolute positioned stuff, uggly but working
|
|
42
|
+
if (
|
|
43
|
+
ddtb.getBoundingClientRect().y - ddm.getBoundingClientRect().y !=
|
|
44
|
+
-ddtb.offsetHeight
|
|
45
|
+
) {
|
|
46
|
+
ddm.style.top =
|
|
47
|
+
parseInt(ddm.style.top.substring(0, ddm.style.top.length - 2)) +
|
|
48
|
+
(ddtb.getBoundingClientRect().y - ddm.getBoundingClientRect().y) +
|
|
49
|
+
ddtb.offsetHeight +
|
|
50
|
+
"px";
|
|
51
|
+
}
|
|
52
|
+
ddm.style.left =
|
|
53
|
+
ddtb.getBoundingClientRect().x - (props.right ? 100 : 0) + "px";
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const DropDownTriggerButton = ref(null);
|
|
57
|
+
const DropDownMenu = ref(null);
|
|
58
|
+
const top = ref(0);
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<template>
|
|
62
|
+
<div class="d-flex" :id="id">
|
|
63
|
+
<button
|
|
64
|
+
ref="DropDownTriggerButton"
|
|
65
|
+
class="btn btn-outline-secondary"
|
|
66
|
+
type="button"
|
|
67
|
+
@click="showDelayed()"
|
|
68
|
+
>
|
|
69
|
+
<span class="ddm-label" v-if="label">{{ label }} </span>
|
|
70
|
+
<span class="ddm-label" v-if="icon"><i :class="icon"></i></span>
|
|
71
|
+
</button>
|
|
72
|
+
<div
|
|
73
|
+
class="ddm-menu"
|
|
74
|
+
v-if="show"
|
|
75
|
+
ref="DropDownMenu"
|
|
76
|
+
:style="{ 'margin-top': top + 'px' }"
|
|
77
|
+
>
|
|
78
|
+
<div
|
|
79
|
+
v-for="opt in options"
|
|
80
|
+
:key="opt.icon"
|
|
81
|
+
class="ddm-item"
|
|
82
|
+
@click="opt.command(item)"
|
|
83
|
+
>
|
|
84
|
+
<i :class="opt.icon"></i>{{ opt.label }}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</template>
|