pukaad-ui-lib 1.403.0 → 1.404.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/dist/module.json +1 -1
- package/dist/runtime/components/image/image-cropper.d.vue.ts +2 -2
- package/dist/runtime/components/image/image-cropper.vue.d.ts +2 -2
- package/dist/runtime/components/input/input-text-field.d.vue.ts +1 -1
- package/dist/runtime/components/input/input-text-field.vue.d.ts +1 -1
- package/dist/runtime/components/input/input-textarea.d.vue.ts +1 -1
- package/dist/runtime/components/input/input-textarea.vue.d.ts +1 -1
- package/dist/runtime/components/read-more-text.vue +31 -30
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -65,14 +65,14 @@ declare const __VLS_export: import("vue").DefineComponent<ImageCropperProps, {
|
|
|
65
65
|
src: string;
|
|
66
66
|
center: boolean;
|
|
67
67
|
crossorigin: "" | "anonymous" | "use-credentials";
|
|
68
|
-
background: boolean;
|
|
69
|
-
modal: boolean;
|
|
70
68
|
responsive: boolean;
|
|
71
69
|
restore: boolean;
|
|
72
70
|
checkCrossOrigin: boolean;
|
|
73
71
|
checkOrientation: boolean;
|
|
72
|
+
modal: boolean;
|
|
74
73
|
guides: boolean;
|
|
75
74
|
highlight: boolean;
|
|
75
|
+
background: boolean;
|
|
76
76
|
autoCrop: boolean;
|
|
77
77
|
movable: boolean;
|
|
78
78
|
rotatable: boolean;
|
|
@@ -65,14 +65,14 @@ declare const __VLS_export: import("vue").DefineComponent<ImageCropperProps, {
|
|
|
65
65
|
src: string;
|
|
66
66
|
center: boolean;
|
|
67
67
|
crossorigin: "" | "anonymous" | "use-credentials";
|
|
68
|
-
background: boolean;
|
|
69
|
-
modal: boolean;
|
|
70
68
|
responsive: boolean;
|
|
71
69
|
restore: boolean;
|
|
72
70
|
checkCrossOrigin: boolean;
|
|
73
71
|
checkOrientation: boolean;
|
|
72
|
+
modal: boolean;
|
|
74
73
|
guides: boolean;
|
|
75
74
|
highlight: boolean;
|
|
75
|
+
background: boolean;
|
|
76
76
|
autoCrop: boolean;
|
|
77
77
|
movable: boolean;
|
|
78
78
|
rotatable: boolean;
|
|
@@ -59,8 +59,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
59
59
|
id: string;
|
|
60
60
|
name: string;
|
|
61
61
|
required: boolean;
|
|
62
|
-
readonly: boolean;
|
|
63
62
|
limit: number;
|
|
63
|
+
readonly: boolean;
|
|
64
64
|
disabledErrorMessage: boolean;
|
|
65
65
|
disabledBorder: boolean;
|
|
66
66
|
showCounter: boolean;
|
|
@@ -59,8 +59,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
59
59
|
id: string;
|
|
60
60
|
name: string;
|
|
61
61
|
required: boolean;
|
|
62
|
-
readonly: boolean;
|
|
63
62
|
limit: number;
|
|
63
|
+
readonly: boolean;
|
|
64
64
|
disabledErrorMessage: boolean;
|
|
65
65
|
disabledBorder: boolean;
|
|
66
66
|
showCounter: boolean;
|
|
@@ -47,8 +47,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
47
47
|
fullHeight: boolean;
|
|
48
48
|
fullWidth: boolean;
|
|
49
49
|
rows: number;
|
|
50
|
-
readonly: boolean;
|
|
51
50
|
limit: number;
|
|
51
|
+
readonly: boolean;
|
|
52
52
|
disabledErrorMessage: boolean;
|
|
53
53
|
disabledBorder: boolean;
|
|
54
54
|
showCounter: boolean;
|
|
@@ -47,8 +47,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
47
47
|
fullHeight: boolean;
|
|
48
48
|
fullWidth: boolean;
|
|
49
49
|
rows: number;
|
|
50
|
-
readonly: boolean;
|
|
51
50
|
limit: number;
|
|
51
|
+
readonly: boolean;
|
|
52
52
|
disabledErrorMessage: boolean;
|
|
53
53
|
disabledBorder: boolean;
|
|
54
54
|
showCounter: boolean;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<div ref="container" class="whitespace-pre-wrap break-words">
|
|
3
|
+
<template v-if="expanded || !isTruncated">{{ props.text }}</template>
|
|
4
|
+
<template v-else>{{ displayText }}...<span class="text-primary cursor-pointer" @click="toggle">ดูเพิ่มเติม</span></template>
|
|
5
|
+
</div>
|
|
3
6
|
</template>
|
|
4
7
|
|
|
5
8
|
<script setup>
|
|
6
|
-
import { onMounted, ref, watch, nextTick
|
|
9
|
+
import { onMounted, ref, watch, nextTick } from "vue";
|
|
7
10
|
const props = defineProps({
|
|
8
11
|
text: { type: String, required: true, default: "" },
|
|
9
12
|
maxLine: { type: Number, required: false, default: 3 }
|
|
@@ -12,13 +15,6 @@ const expanded = ref(false);
|
|
|
12
15
|
const isTruncated = ref(false);
|
|
13
16
|
const displayText = ref("");
|
|
14
17
|
const container = ref(null);
|
|
15
|
-
const formattedText = computed(() => {
|
|
16
|
-
const text = props.text || "";
|
|
17
|
-
return text.replace(
|
|
18
|
-
/@\[([^\]]+)\]\(([^)]+)\)/g,
|
|
19
|
-
'<span class="text-primary font-body-large-prominent">@$1</span>'
|
|
20
|
-
);
|
|
21
|
-
});
|
|
22
18
|
function computeTruncation() {
|
|
23
19
|
const root = container.value;
|
|
24
20
|
if (!root) return;
|
|
@@ -27,25 +23,27 @@ function computeTruncation() {
|
|
|
27
23
|
isTruncated.value = false;
|
|
28
24
|
if (expanded.value) return;
|
|
29
25
|
if (!fullText.trim()) return;
|
|
30
|
-
const
|
|
26
|
+
const width = root.clientWidth;
|
|
27
|
+
if (!width) return;
|
|
31
28
|
const cs = getComputedStyle(root);
|
|
32
|
-
measure
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
const measure = document.createElement("div");
|
|
30
|
+
measure.style.cssText = [
|
|
31
|
+
"visibility:hidden",
|
|
32
|
+
"position:fixed",
|
|
33
|
+
"top:-9999px",
|
|
34
|
+
`width:${width}px`,
|
|
35
|
+
`font:${cs.font}`,
|
|
36
|
+
`line-height:${cs.lineHeight}`,
|
|
37
|
+
`letter-spacing:${cs.letterSpacing}`,
|
|
38
|
+
"white-space:pre-wrap",
|
|
39
|
+
"word-break:break-word"
|
|
40
|
+
].join(";");
|
|
41
|
+
document.body.appendChild(measure);
|
|
42
|
+
const lineHeight = parseFloat(cs.lineHeight) || parseFloat(cs.fontSize) * 1.5;
|
|
43
43
|
const maxHeight = lineHeight * props.maxLine;
|
|
44
|
-
measure.textContent = fullText
|
|
45
|
-
if (measure.scrollHeight <= maxHeight +
|
|
46
|
-
|
|
47
|
-
isTruncated.value = false;
|
|
48
|
-
root.removeChild(measure);
|
|
44
|
+
measure.textContent = fullText;
|
|
45
|
+
if (measure.scrollHeight <= maxHeight + 2) {
|
|
46
|
+
measure.remove();
|
|
49
47
|
return;
|
|
50
48
|
}
|
|
51
49
|
isTruncated.value = true;
|
|
@@ -54,9 +52,8 @@ function computeTruncation() {
|
|
|
54
52
|
let best = 0;
|
|
55
53
|
while (low <= high) {
|
|
56
54
|
const mid = Math.floor((low + high) / 2);
|
|
57
|
-
|
|
58
|
-
measure.
|
|
59
|
-
if (measure.scrollHeight <= maxHeight + 1) {
|
|
55
|
+
measure.textContent = fullText.slice(0, mid).trimEnd() + "...\u0E14\u0E39\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21";
|
|
56
|
+
if (measure.scrollHeight <= maxHeight + 2) {
|
|
60
57
|
best = mid;
|
|
61
58
|
low = mid + 1;
|
|
62
59
|
} else {
|
|
@@ -64,7 +61,7 @@ function computeTruncation() {
|
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
displayText.value = fullText.slice(0, best).trimEnd();
|
|
67
|
-
|
|
64
|
+
measure.remove();
|
|
68
65
|
}
|
|
69
66
|
function toggle() {
|
|
70
67
|
expanded.value = !expanded.value;
|
|
@@ -73,4 +70,8 @@ function toggle() {
|
|
|
73
70
|
onMounted(() => {
|
|
74
71
|
nextTick(computeTruncation);
|
|
75
72
|
});
|
|
73
|
+
watch(
|
|
74
|
+
() => [props.text, props.maxLine],
|
|
75
|
+
() => nextTick(computeTruncation)
|
|
76
|
+
);
|
|
76
77
|
</script>
|