vueless 0.0.323 → 0.0.325
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/composable.mutationObserver/index.js +45 -0
- package/package.json +1 -1
- package/ui.data-table/components/TableRow.vue +37 -6
- package/ui.dropdown-list/composables/attrs.composable.js +0 -7
- package/ui.dropdown-list/index.vue +2 -1
- package/ui.form-select/index.stories.js +7 -0
- package/ui.form-select/index.vue +4 -0
- package/web-types.json +1 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { onBeforeUnmount, onMounted, toValue, watch } from "vue";
|
|
2
|
+
|
|
3
|
+
export function useMutationObserver(
|
|
4
|
+
target,
|
|
5
|
+
callBack,
|
|
6
|
+
config = { childList: true, attributes: true, characterData: true },
|
|
7
|
+
) {
|
|
8
|
+
const observer = new MutationObserver(callBack);
|
|
9
|
+
|
|
10
|
+
onMounted(() => {
|
|
11
|
+
if (!toValue(target)) return;
|
|
12
|
+
|
|
13
|
+
if (Array.isArray) {
|
|
14
|
+
toValue(target).forEach((element) => {
|
|
15
|
+
observer.observe(element, config);
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
observer.observe(toValue(target), config);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
watch(
|
|
23
|
+
() => toValue(target),
|
|
24
|
+
() => {
|
|
25
|
+
if (Array.isArray) {
|
|
26
|
+
toValue(target).forEach((element) => {
|
|
27
|
+
observer.observe(element, config);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
observer.observe(toValue(target), config);
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
deep: true,
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
onBeforeUnmount(() => {
|
|
41
|
+
observer.disconnect();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return { observer };
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -43,29 +43,37 @@
|
|
|
43
43
|
|
|
44
44
|
<div v-if="value?.hasOwnProperty('secondary')">
|
|
45
45
|
<slot :name="`cell-${key}`" :value="value" :row="row">
|
|
46
|
-
<div
|
|
46
|
+
<div
|
|
47
|
+
v-bind="attrs.bodyCellPrimaryAttrs"
|
|
48
|
+
ref="cellRef"
|
|
49
|
+
:data-test="`${dataTest}-${key}-cell`"
|
|
50
|
+
>
|
|
47
51
|
{{ value.primary || HYPHEN_SYMBOL }}
|
|
48
52
|
</div>
|
|
49
53
|
|
|
50
54
|
<div v-bind="attrs.bodyCellSecondaryAttrs">
|
|
51
55
|
<template v-if="Array.isArray(value.secondary)">
|
|
52
|
-
<div v-for="(secondary, idx) in value.secondary" :key="idx">
|
|
56
|
+
<div v-for="(secondary, idx) in value.secondary" ref="cellRef" :key="idx">
|
|
53
57
|
<span v-bind="attrs.bodyCellSecondaryEmptyAttrs">
|
|
54
58
|
{{ secondary }}
|
|
55
59
|
</span>
|
|
56
60
|
</div>
|
|
57
61
|
</template>
|
|
58
62
|
|
|
59
|
-
<
|
|
63
|
+
<div v-else ref="cellRef">
|
|
60
64
|
{{ value.secondary }}
|
|
61
|
-
</
|
|
65
|
+
</div>
|
|
62
66
|
</div>
|
|
63
67
|
</slot>
|
|
64
68
|
</div>
|
|
65
69
|
|
|
66
70
|
<template v-else>
|
|
67
71
|
<slot :name="`cell-${key}`" :value="value" :row="row">
|
|
68
|
-
<div
|
|
72
|
+
<div
|
|
73
|
+
v-bind="attrs.bodyCellPrimaryAttrs"
|
|
74
|
+
ref="cellRef"
|
|
75
|
+
:data-test="`${dataTest}-${key}-cell`"
|
|
76
|
+
>
|
|
69
77
|
{{ value || value === 0 ? value : HYPHEN_SYMBOL }}
|
|
70
78
|
</div>
|
|
71
79
|
</slot>
|
|
@@ -90,11 +98,13 @@
|
|
|
90
98
|
</template>
|
|
91
99
|
|
|
92
100
|
<script setup>
|
|
93
|
-
import { computed } from "vue";
|
|
101
|
+
import { computed, ref } from "vue";
|
|
94
102
|
|
|
95
103
|
import { HYPHEN_SYMBOL } from "../../service.ui";
|
|
96
104
|
import { getFilteredRow } from "../services/table.service.js";
|
|
97
105
|
|
|
106
|
+
import { useMutationObserver } from "../../composable.mutationObserver/index.js";
|
|
107
|
+
|
|
98
108
|
import UIcon from "../../ui.image-icon";
|
|
99
109
|
import UCheckbox from "../../ui.form-checkbox";
|
|
100
110
|
|
|
@@ -137,6 +147,10 @@ const emit = defineEmits(["toggleRowVisibility", "click"]);
|
|
|
137
147
|
|
|
138
148
|
const selectedRows = defineModel("selectedRows", { type: Array, default: () => [] });
|
|
139
149
|
|
|
150
|
+
const cellRef = ref(null);
|
|
151
|
+
|
|
152
|
+
useMutationObserver(cellRef, setCellTitle, { childList: true });
|
|
153
|
+
|
|
140
154
|
const toggleIconConfig = computed(() =>
|
|
141
155
|
props.row?.row?.isHidden
|
|
142
156
|
? props.attrs.bodyCellNestedExpandIconAttrs
|
|
@@ -166,4 +180,21 @@ function onClickToggleRowChild(rowId) {
|
|
|
166
180
|
function onClick(row) {
|
|
167
181
|
emit("click", row);
|
|
168
182
|
}
|
|
183
|
+
|
|
184
|
+
function setCellTitle(mutations) {
|
|
185
|
+
mutations.forEach((mutation) => {
|
|
186
|
+
const { target } = mutation;
|
|
187
|
+
|
|
188
|
+
const isOverflown =
|
|
189
|
+
target.clientWidth < target.scrollWidth || target.clientHeight < target.scrollHeight;
|
|
190
|
+
|
|
191
|
+
if (isOverflown) {
|
|
192
|
+
target.setAttribute("title", target.textContent);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (!isOverflown && target.hasAttribute("title")) {
|
|
196
|
+
target.removeAttribute("title");
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
169
200
|
</script>
|
|
@@ -44,15 +44,8 @@ export default function useAttrs(props) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const optionAttrs = (classes = []) => {
|
|
48
|
-
const mergedClasses = cx([optionClasses.value, ...classes]);
|
|
49
|
-
|
|
50
|
-
return getAttrs("option", { classes: mergedClasses }).value;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
47
|
return {
|
|
54
48
|
...attrs,
|
|
55
|
-
optionAttrs,
|
|
56
49
|
optionClasses,
|
|
57
50
|
hasSlotContent,
|
|
58
51
|
config,
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
<!-- option title -->
|
|
22
22
|
<span
|
|
23
23
|
v-if="!(option && (option.groupLabel || option.isSubGroup)) && !option.isHidden"
|
|
24
|
-
v-bind="optionAttrs
|
|
24
|
+
v-bind="optionAttrs"
|
|
25
|
+
:class="optionHighlight(index, option)"
|
|
25
26
|
@click="select(option)"
|
|
26
27
|
@mouseenter.self="pointerSet(index)"
|
|
27
28
|
>
|
|
@@ -102,6 +102,13 @@ const GroupValuesTemplate = (args) => ({
|
|
|
102
102
|
export const Default = DefaultTemplate.bind({});
|
|
103
103
|
Default.args = {};
|
|
104
104
|
|
|
105
|
+
export const LargeItemList = DefaultTemplate.bind({});
|
|
106
|
+
LargeItemList.args = {
|
|
107
|
+
options: [...new Array(1000)].map((_, index) => {
|
|
108
|
+
return { id: index + 1, label: `value ${index + 1}`, badge: "badge" };
|
|
109
|
+
}),
|
|
110
|
+
};
|
|
111
|
+
|
|
105
112
|
export const Multiple = DefaultTemplate.bind({});
|
|
106
113
|
Multiple.args = { multiple: true, modelValue: [] };
|
|
107
114
|
|
package/ui.form-select/index.vue
CHANGED
|
@@ -684,6 +684,10 @@ const filteredOptions = computed(() => {
|
|
|
684
684
|
)
|
|
685
685
|
: [...props.options];
|
|
686
686
|
|
|
687
|
+
if (!normalizedSearch) {
|
|
688
|
+
return options.slice(0, props.optionsLimit || options.length);
|
|
689
|
+
}
|
|
690
|
+
|
|
687
691
|
options = props.groupValueKey
|
|
688
692
|
? filterAndFlat(options, normalizedSearch, props.labelKey)
|
|
689
693
|
: SelectService.filterOptions(options, normalizedSearch, props.labelKey);
|