pukaad-ui-lib 1.429.2 → 1.430.1

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.429.2",
4
+ "version": "1.430.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -67,18 +67,12 @@
67
67
  <div class="flex flex-col gap-[4px]">
68
68
  <div class="font-body-medium">
69
69
  <span
70
- v-if="item.actor"
70
+ v-if="item.actor && !isGrouped(item)"
71
71
  class="font-body-medium-prominent"
72
72
  >
73
73
  {{ item.actor.name }}
74
74
  </span>
75
75
  {{ item.message }}
76
- <span
77
- v-if="item.grouped_count && item.grouped_count > 1"
78
- class="text-gray font-body-small"
79
- >
80
- ({{ item.grouped_count }} คน)
81
- </span>
82
76
  </div>
83
77
  <div class="text-gray font-body-small">
84
78
  {{ formatRelativeTime(item.created_at) }}
@@ -201,8 +195,7 @@ const markAsRead = async (item) => {
201
195
  try {
202
196
  await api(`/notifications/${item.id}/read`, { method: "PATCH" });
203
197
  item.is_read = true;
204
- const totalUnread = generalNotifications.value.filter((n) => !n.is_read).length + systemNotifications.value.filter((n) => !n.is_read).length;
205
- notificationStore.setUnreadCount(totalUnread);
198
+ notificationStore.fetchUnreadCount();
206
199
  } catch {
207
200
  }
208
201
  };
@@ -219,6 +212,7 @@ const onClickNotification = (item) => {
219
212
  markAsRead(item);
220
213
  emit("select", item);
221
214
  };
215
+ const isGrouped = (item) => !!item.grouped_count && item.grouped_count > 1;
222
216
  const formatRelativeTime = (dateStr) => {
223
217
  const now = /* @__PURE__ */ new Date();
224
218
  const date = new Date(dateStr);
@@ -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;
53
54
  labelDetail: string;
54
55
  placeholderDetail: string;
55
56
  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;
53
54
  labelDetail: string;
54
55
  placeholderDetail: string;
55
56
  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;
@@ -46,6 +46,8 @@
46
46
  :accept="mediaAccept"
47
47
  :limit="mediaLimit"
48
48
  :preview-size="66"
49
+ :min-video-seconds="1"
50
+ :max-video-seconds="0"
49
51
  :width="66"
50
52
  :height="66"
51
53
  disabled-drop
@@ -37,14 +37,16 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
37
37
  fullHeight: boolean;
38
38
  fullWidth: boolean;
39
39
  limit: number;
40
- disabledErrorMessage: boolean;
41
40
  accept: string;
41
+ disabledErrorMessage: boolean;
42
42
  labelIcon: string;
43
43
  disabledDrop: boolean;
44
44
  column: boolean;
45
45
  showCover: boolean;
46
46
  previewFullSize: boolean;
47
47
  previewSize: number;
48
+ minVideoSeconds: number;
49
+ maxVideoSeconds: number;
48
50
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
49
51
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
50
52
  declare const _default: typeof __VLS_export;
@@ -186,7 +186,9 @@ const props = defineProps({
186
186
  column: { type: Boolean, required: false, default: false },
187
187
  showCover: { type: Boolean, required: false, default: false },
188
188
  previewFullSize: { type: Boolean, required: false, default: false },
189
- previewSize: { type: Number, required: false, default: 98 }
189
+ previewSize: { type: Number, required: false, default: 98 },
190
+ minVideoSeconds: { type: Number, required: false, default: 10 },
191
+ maxVideoSeconds: { type: Number, required: false, default: 60 }
190
192
  });
191
193
  const isDrag = ref(false);
192
194
  const { errorMessage, setErrors } = useField(props.name);
@@ -231,19 +233,19 @@ const createFileItem = async (file) => {
231
233
  return null;
232
234
  }
233
235
  const duration = await getVideoDuration(file);
234
- if (duration < 10) {
236
+ if (props.minVideoSeconds > 0 && duration < props.minVideoSeconds) {
235
237
  $alert.show({
236
238
  type: "error",
237
239
  title: "\u0E40\u0E01\u0E34\u0E14\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14 !",
238
- description: "\u0E40\u0E19\u0E37\u0E48\u0E2D\u0E07\u0E08\u0E32\u0E01\u0E27\u0E34\u0E14\u0E35\u0E42\u0E2D\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13 \u0E21\u0E35\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32 10 \u0E27\u0E34\u0E19\u0E32\u0E17\u0E35"
240
+ description: `\u0E40\u0E19\u0E37\u0E48\u0E2D\u0E07\u0E08\u0E32\u0E01\u0E27\u0E34\u0E14\u0E35\u0E42\u0E2D\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13 \u0E21\u0E35\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32 ${props.minVideoSeconds} \u0E27\u0E34\u0E19\u0E32\u0E17\u0E35`
239
241
  });
240
242
  return null;
241
243
  }
242
- if (duration > 60) {
244
+ if (props.maxVideoSeconds > 0 && duration > props.maxVideoSeconds) {
243
245
  $alert.show({
244
246
  type: "error",
245
247
  title: "\u0E40\u0E01\u0E34\u0E14\u0E02\u0E49\u0E2D\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14 !",
246
- description: "\u0E40\u0E19\u0E37\u0E48\u0E2D\u0E07\u0E08\u0E32\u0E01\u0E27\u0E34\u0E14\u0E35\u0E42\u0E2D\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13 \u0E21\u0E35\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E40\u0E01\u0E34\u0E19 60 \u0E27\u0E34\u0E19\u0E32\u0E17\u0E35"
248
+ description: `\u0E40\u0E19\u0E37\u0E48\u0E2D\u0E07\u0E08\u0E32\u0E01\u0E27\u0E34\u0E14\u0E35\u0E42\u0E2D\u0E02\u0E2D\u0E07\u0E04\u0E38\u0E13 \u0E21\u0E35\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E40\u0E01\u0E34\u0E19 ${props.maxVideoSeconds} \u0E27\u0E34\u0E19\u0E32\u0E17\u0E35`
247
249
  });
248
250
  return null;
249
251
  }
@@ -37,14 +37,16 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
37
37
  fullHeight: boolean;
38
38
  fullWidth: boolean;
39
39
  limit: number;
40
- disabledErrorMessage: boolean;
41
40
  accept: string;
41
+ disabledErrorMessage: boolean;
42
42
  labelIcon: string;
43
43
  disabledDrop: boolean;
44
44
  column: boolean;
45
45
  showCover: boolean;
46
46
  previewFullSize: boolean;
47
47
  previewSize: number;
48
+ minVideoSeconds: number;
49
+ maxVideoSeconds: number;
48
50
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
49
51
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
50
52
  declare const _default: typeof __VLS_export;
@@ -22,8 +22,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
22
22
  }>, {
23
23
  id: string;
24
24
  name: string;
25
- new: boolean;
26
25
  disabledForgotPassword: boolean;
26
+ new: 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
- new: boolean;
26
25
  disabledForgotPassword: boolean;
26
+ new: boolean;
27
27
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
28
  declare const _default: typeof __VLS_export;
29
29
  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
- disabledForgotPassword: boolean;
28
27
  confirmText: string;
28
+ disabledForgotPassword: boolean;
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
- disabledForgotPassword: boolean;
28
27
  confirmText: string;
28
+ disabledForgotPassword: boolean;
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
- disabledForgotPassword: boolean;
36
35
  confirmText: string;
36
+ disabledForgotPassword: boolean;
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
- disabledForgotPassword: boolean;
36
35
  confirmText: string;
36
+ disabledForgotPassword: boolean;
37
37
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
38
38
  declare const _default: typeof __VLS_export;
39
39
  export default _default;
@@ -1,12 +1,15 @@
1
1
  import { defineStore } from "pinia";
2
- import { ref } from "vue";
2
+ import { ref, watch } from "vue";
3
+ import { useDocumentVisibility } from "@vueuse/core";
3
4
  import { useApi } from "./useApi.js";
4
5
  import { useRealtime } from "./useRealtime.js";
5
6
  export const useNotificationStore = defineStore("notification", () => {
6
7
  const api = useApi();
7
- const { onEvent, offEvent } = useRealtime();
8
+ const { onEvent, offEvent, isConnected } = useRealtime();
9
+ const visibility = useDocumentVisibility();
8
10
  const unreadCount = ref(0);
9
11
  const isOpenDrawer = ref(false);
12
+ const isListening = ref(false);
10
13
  const fetchUnreadCount = async () => {
11
14
  try {
12
15
  const response = await api(
@@ -31,10 +34,18 @@ export const useNotificationStore = defineStore("notification", () => {
31
34
  };
32
35
  const initRealtime = () => {
33
36
  onEvent("notification", onNotificationEvent);
37
+ isListening.value = true;
34
38
  };
35
39
  const closeRealtime = () => {
36
40
  offEvent("notification", onNotificationEvent);
41
+ isListening.value = false;
37
42
  };
43
+ watch([isConnected, visibility], ([connected, vis], [wasConnected, prevVis]) => {
44
+ if (!isListening.value) return;
45
+ const reconnected = connected && !wasConnected;
46
+ const becameVisible = vis === "visible" && prevVis !== "visible";
47
+ if (reconnected || becameVisible) fetchUnreadCount();
48
+ });
38
49
  const setUnreadCount = (count) => {
39
50
  unreadCount.value = count;
40
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.429.2",
3
+ "version": "1.430.1",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",