pukaad-ui-lib 1.402.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
3
  "configKey": "pukaadUI",
4
- "version": "1.402.0",
4
+ "version": "1.404.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -60,9 +60,13 @@
60
60
 
61
61
  <!-- ปุ่มขยายเต็มจอ -->
62
62
  <slot v-if="props.fullscreenButton" name="fullscreen" :click="onFullscreen">
63
- <div class="absolute top-[16px] right-[16px] z-10">
64
- <Button circle color="dark" @click="onFullscreen">
65
- <Icon name="lucide:maximize" />
63
+ <div class="absolute top-[24px] right-[24px] z-10">
64
+ <Button variant="text" @click="onFullscreen">
65
+ <Icon
66
+ name="fa7-solid:up-right-and-down-left-from-center"
67
+ :size="24"
68
+ class="text-white"
69
+ />
66
70
  </Button>
67
71
  </div>
68
72
  </slot>
@@ -50,10 +50,10 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
50
50
  name: string;
51
51
  required: boolean;
52
52
  placeholder: string;
53
- gap: string;
54
53
  labelDetail: string;
55
54
  placeholderDetail: string;
56
55
  requiredDetail: boolean;
56
+ gap: string;
57
57
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
58
58
  declare const _default: typeof __VLS_export;
59
59
  export default _default;
@@ -50,10 +50,10 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
50
50
  name: string;
51
51
  required: boolean;
52
52
  placeholder: string;
53
- gap: string;
54
53
  labelDetail: string;
55
54
  placeholderDetail: string;
56
55
  requiredDetail: boolean;
56
+ gap: string;
57
57
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
58
58
  declare const _default: typeof __VLS_export;
59
59
  export default _default;
@@ -35,8 +35,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
35
35
  fullHeight: boolean;
36
36
  fullWidth: boolean;
37
37
  limit: number;
38
- accept: string;
39
38
  disabledErrorMessage: boolean;
39
+ accept: string;
40
40
  labelIcon: string;
41
41
  disabledDrop: boolean;
42
42
  column: boolean;
@@ -35,8 +35,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
35
35
  fullHeight: boolean;
36
36
  fullWidth: boolean;
37
37
  limit: number;
38
- accept: string;
39
38
  disabledErrorMessage: boolean;
39
+ accept: string;
40
40
  labelIcon: string;
41
41
  disabledDrop: boolean;
42
42
  column: boolean;
@@ -22,8 +22,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
22
22
  }>, {
23
23
  id: string;
24
24
  name: string;
25
- disabledForgotPassword: boolean;
26
25
  new: boolean;
26
+ disabledForgotPassword: boolean;
27
27
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
28
  declare const _default: typeof __VLS_export;
29
29
  export default _default;
@@ -22,8 +22,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
22
22
  }>, {
23
23
  id: string;
24
24
  name: string;
25
- disabledForgotPassword: boolean;
26
25
  new: boolean;
26
+ disabledForgotPassword: boolean;
27
27
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
28
  declare const _default: typeof __VLS_export;
29
29
  export default _default;
@@ -11,12 +11,12 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
11
11
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
12
  "update:modelValue": (value: File | null) => any;
13
13
  } & {
14
- complete: (file: File) => any;
15
14
  remove: () => any;
15
+ complete: (file: File) => any;
16
16
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
17
17
  "onUpdate:modelValue"?: ((value: File | null) => any) | undefined;
18
- onComplete?: ((file: File) => any) | undefined;
19
18
  onRemove?: (() => any) | undefined;
19
+ onComplete?: ((file: File) => any) | undefined;
20
20
  }>, {
21
21
  name: string;
22
22
  disabledErrorMessage: boolean;
@@ -11,12 +11,12 @@ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
11
11
  declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
12
  "update:modelValue": (value: File | null) => any;
13
13
  } & {
14
- complete: (file: File) => any;
15
14
  remove: () => any;
15
+ complete: (file: File) => any;
16
16
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
17
17
  "onUpdate:modelValue"?: ((value: File | null) => any) | undefined;
18
- onComplete?: ((file: File) => any) | undefined;
19
18
  onRemove?: (() => any) | undefined;
19
+ onComplete?: ((file: File) => any) | undefined;
20
20
  }>, {
21
21
  name: string;
22
22
  disabledErrorMessage: 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;
@@ -24,8 +24,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
24
24
  }) => any) | undefined;
25
25
  }>, {
26
26
  title: string;
27
- confirmText: string;
28
27
  disabledForgotPassword: boolean;
28
+ confirmText: string;
29
29
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
30
  declare const _default: typeof __VLS_export;
31
31
  export default _default;
@@ -24,8 +24,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
24
24
  }) => any) | undefined;
25
25
  }>, {
26
26
  title: string;
27
- confirmText: string;
28
27
  disabledForgotPassword: boolean;
28
+ confirmText: string;
29
29
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
30
30
  declare const _default: typeof __VLS_export;
31
31
  export default _default;
@@ -32,8 +32,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
32
32
  }>, {
33
33
  title: string;
34
34
  mode: "login" | "secure";
35
- confirmText: string;
36
35
  disabledForgotPassword: boolean;
36
+ confirmText: string;
37
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
38
  declare const _default: typeof __VLS_export;
39
39
  export default _default;
@@ -32,8 +32,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
32
32
  }>, {
33
33
  title: string;
34
34
  mode: "login" | "secure";
35
- confirmText: string;
36
35
  disabledForgotPassword: boolean;
36
+ confirmText: string;
37
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
38
  declare const _default: typeof __VLS_export;
39
39
  export default _default;
@@ -1,9 +1,12 @@
1
1
  <template>
2
- <div>แก้หมด</div>
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, computed } from "vue";
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 measure = document.createElement("span");
26
+ const width = root.clientWidth;
27
+ if (!width) return;
31
28
  const cs = getComputedStyle(root);
32
- measure.style.cssText = `visibility:hidden;position:absolute;left:0;top:0;pointer-events:none;white-space:normal;width:${root.clientWidth}px;font:${cs.font};line-height:${cs.lineHeight};`;
33
- root.appendChild(measure);
34
- let lineHeightStr = cs.lineHeight;
35
- let lineHeight = 0;
36
- if (lineHeightStr.endsWith("px")) {
37
- lineHeight = parseFloat(lineHeightStr);
38
- } else {
39
- const fontSizeStr = cs.fontSize;
40
- const fontSize = fontSizeStr.endsWith("px") ? parseFloat(fontSizeStr) : 16;
41
- lineHeight = fontSize * 1.5;
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 + " ... \u0E14\u0E39\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21";
45
- if (measure.scrollHeight <= maxHeight + 1) {
46
- displayText.value = fullText;
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
- const candidate = fullText.slice(0, mid).trimEnd() + "... \u0E14\u0E39\u0E40\u0E1E\u0E34\u0E48\u0E21\u0E40\u0E15\u0E34\u0E21";
58
- measure.textContent = candidate;
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
- root.removeChild(measure);
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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.402.0",
3
+ "version": "1.404.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",