vueless 0.0.324 → 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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.324",
3
+ "version": "0.0.325",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -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 :data-test="`${dataTest}-${key}-cell`" v-bind="attrs.bodyCellPrimaryAttrs">
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
- <template v-else>
63
+ <div v-else ref="cellRef">
60
64
  {{ value.secondary }}
61
- </template>
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 :data-test="`${dataTest}-${key}-cell`" v-bind="attrs.bodyCellPrimaryAttrs">
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>
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.324",
4
+ "version": "0.0.325",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",