@tekkare/auriga 0.2.224 → 0.2.226

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/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "0.2.224"
7
+ "version": "0.2.226"
8
8
  }
@@ -344,7 +344,10 @@ export default defineComponent({
344
344
  };
345
345
  }
346
346
  if (props.tooltipOptions) {
347
- props.options["tooltip"] = props.tooltipOptions;
347
+ props.options["tooltip"] = {
348
+ shared: props.sharedTooltip,
349
+ ...props.tooltipOptions
350
+ };
348
351
  } else {
349
352
  props.options["tooltip"] = {
350
353
  y: {
@@ -1,24 +1,20 @@
1
1
  <template>
2
- <div ref="element" class="oip_list gap-6">
2
+ <div class="oip_list gap-6">
3
3
  <div
4
4
  v-if="custom"
5
- :class="custom && isBig && !showMore ? 'fix-height' : ''"
6
- :style="
7
- custom && isBig && !showMore
8
- ? 'max-height: ' + maxLines * 16.6 + 'px'
9
- : ''
10
- "
5
+ ref="content"
6
+ :class="showMore ? '' : 'fix-height'"
7
+ :style="showMore ? '' : `max-height: ${clampHeight}px`"
11
8
  >
12
9
  <slot />
13
10
  </div>
14
11
 
15
12
  <p
16
13
  v-else-if="typeof value === 'string'"
17
- :class="isBig && !showMore ? 'crop' : ''"
14
+ ref="content"
15
+ :class="showMore ? '' : 'crop'"
18
16
  :style="
19
- isBig && !showMore
20
- ? ` -webkit-line-clamp: ${maxLines}; line-clamp: {maxLines};`
21
- : ''
17
+ showMore ? '' : `-webkit-line-clamp: ${maxLines}; line-clamp: ${maxLines};`
22
18
  "
23
19
  class="wrap-line"
24
20
  >
@@ -37,11 +33,13 @@
37
33
  <script>
38
34
  import {
39
35
  onMounted,
36
+ onBeforeUnmount,
40
37
  ref,
41
- computed,
38
+ nextTick,
42
39
  watch,
43
40
  defineComponent
44
41
  } from "vue";
42
+ const FALLBACK_LINE_HEIGHT = 16.6;
45
43
  export default defineComponent({
46
44
  name: "tableRowCrop",
47
45
  /* components: { argIcon, argStyle }, */
@@ -50,31 +48,59 @@ export default defineComponent({
50
48
  custom: { type: Boolean, default: false },
51
49
  maxLines: { type: Number, default: 3 }
52
50
  },
53
- setup(props, { emit }) {
54
- const isBig = ref(false);
55
- const element = ref(null);
56
- const height = computed(() => element.value?.offsetHeight);
51
+ setup(props) {
52
+ const content = ref(null);
57
53
  const showMore = ref(false);
58
54
  const showReadMore = ref(false);
55
+ const clampHeight = ref(props.maxLines * FALLBACK_LINE_HEIGHT);
59
56
  function toggleShowMore() {
60
57
  showMore.value = !showMore.value;
61
58
  }
62
- onMounted(() => {
63
- if (height.value > props.maxLines * 16.6) {
64
- isBig.value = true;
65
- showReadMore.value = true;
66
- } else showReadMore.value = false;
59
+ function readClampHeight() {
60
+ const el = content.value;
61
+ if (!el) return;
62
+ const lineHeight = Number.parseFloat(getComputedStyle(el).lineHeight);
63
+ clampHeight.value = Number.isFinite(lineHeight) && lineHeight > 0 ? props.maxLines * lineHeight : props.maxLines * FALLBACK_LINE_HEIGHT;
64
+ }
65
+ function measure() {
66
+ if (showMore.value) return;
67
+ const el = content.value;
68
+ if (!el) {
69
+ showReadMore.value = false;
70
+ return;
71
+ }
72
+ showReadMore.value = el.scrollHeight > el.clientHeight + 1;
73
+ }
74
+ let observer = null;
75
+ onMounted(async () => {
76
+ await nextTick();
77
+ readClampHeight();
78
+ await nextTick();
79
+ measure();
80
+ if (typeof ResizeObserver !== "undefined" && content.value) {
81
+ observer = new ResizeObserver(() => measure());
82
+ observer.observe(content.value);
83
+ }
84
+ });
85
+ onBeforeUnmount(() => {
86
+ observer?.disconnect();
87
+ observer = null;
67
88
  });
68
89
  watch(
69
- () => height.value,
70
- () => {
71
- if (height.value > props.maxLines * 16.6) {
72
- isBig.value = true;
73
- showReadMore.value = true;
74
- } else showReadMore.value = false;
90
+ () => [props.value, props.maxLines],
91
+ async () => {
92
+ await nextTick();
93
+ readClampHeight();
94
+ await nextTick();
95
+ measure();
75
96
  }
76
97
  );
77
- return { isBig, element, showMore, toggleShowMore, showReadMore };
98
+ watch(showMore, async (expanded) => {
99
+ if (expanded) return;
100
+ await nextTick();
101
+ measure();
102
+ });
103
+ return { content, showMore, showReadMore, clampHeight, toggleShowMore };
78
104
  }
79
105
  });
80
106
  </script>
@@ -11,11 +11,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
11
11
  default: number;
12
12
  };
13
13
  }>, {
14
- isBig: import("vue").Ref<boolean, boolean>;
15
- element: import("vue").Ref<null, null>;
14
+ content: import("vue").Ref<HTMLElement | null, HTMLElement | null>;
16
15
  showMore: import("vue").Ref<boolean, boolean>;
17
- toggleShowMore: () => void;
18
16
  showReadMore: import("vue").Ref<boolean, boolean>;
17
+ clampHeight: import("vue").Ref<number, number>;
18
+ toggleShowMore: () => void;
19
19
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
20
20
  value: {
21
21
  default: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekkare/auriga",
3
- "version": "0.2.224",
3
+ "version": "0.2.226",
4
4
  "description": "Aurgia is a UI kit developped by Tekkare",
5
5
  "license": "MIT",
6
6
  "type": "module",