pukaad-ui-lib 1.384.0 → 1.386.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.384.0",
4
+ "version": "1.386.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -2,6 +2,7 @@ import type { CardContentMenuState } from "#pukaad-ui/types/components/card/card
2
2
  type __VLS_Props = {
3
3
  state?: CardContentMenuState;
4
4
  isPinned?: boolean;
5
+ isLiked?: boolean;
5
6
  isBookmarked?: boolean;
6
7
  isShow?: boolean;
7
8
  };
@@ -11,6 +12,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
11
12
  onAction?: ((name: string) => any) | undefined;
12
13
  }>, {
13
14
  isPinned: boolean;
15
+ isLiked: boolean;
14
16
  isBookmarked: boolean;
15
17
  isShow: boolean;
16
18
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -19,6 +19,7 @@ import { computed } from "vue";
19
19
  const props = defineProps({
20
20
  state: { type: String, required: false },
21
21
  isPinned: { type: Boolean, required: false, default: false },
22
+ isLiked: { type: Boolean, required: false, default: false },
22
23
  isBookmarked: { type: Boolean, required: false, default: false },
23
24
  isShow: { type: Boolean, required: false, default: false }
24
25
  });
@@ -38,6 +39,7 @@ const actions = computed(() => {
38
39
  }
39
40
  if (props.state === "content") {
40
41
  return [
42
+ { name: "like", icon: "lucide:heart", isActive: props.isLiked },
41
43
  { name: "bookmark", icon: "lucide:bookmark", isActive: props.isBookmarked },
42
44
  { name: "preview", icon: "lucide:tv-minimal-play" }
43
45
  ];
@@ -2,6 +2,7 @@ import type { CardContentMenuState } from "#pukaad-ui/types/components/card/card
2
2
  type __VLS_Props = {
3
3
  state?: CardContentMenuState;
4
4
  isPinned?: boolean;
5
+ isLiked?: boolean;
5
6
  isBookmarked?: boolean;
6
7
  isShow?: boolean;
7
8
  };
@@ -11,6 +12,7 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {
11
12
  onAction?: ((name: string) => any) | undefined;
12
13
  }>, {
13
14
  isPinned: boolean;
15
+ isLiked: boolean;
14
16
  isBookmarked: boolean;
15
17
  isShow: boolean;
16
18
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -39,7 +39,7 @@ const timeState = computed(() => {
39
39
  color: "bg-destructive"
40
40
  };
41
41
  }
42
- const diffDays = Math.ceil(target.diff(now.value, "day", true));
42
+ const diffDays = Math.floor(target.diff(now.value, "day", true));
43
43
  return {
44
44
  text: `\u0E40\u0E2B\u0E25\u0E37\u0E2D ${diffDays} \u0E27\u0E31\u0E19`,
45
45
  color: diffDays < 7 ? "bg-warning" : "bg-success"
@@ -24,6 +24,7 @@
24
24
  <CardContentMenu
25
25
  :state="props.state"
26
26
  :is-pinned="!!props.item.pinned"
27
+ :is-liked="!!props.item.liked"
27
28
  :is-bookmarked="!!props.item.bookmarked"
28
29
  :is-show="hovering"
29
30
  @action="onMenuAction"
@@ -96,7 +96,7 @@ const reactions = [
96
96
  {
97
97
  name: "bookmarked",
98
98
  icon: "lucide:bookmark",
99
- iconReacted: "fa6-solid:bookmark",
99
+ iconReacted: "pukaad:bookmark-solid",
100
100
  action: toggleBookmark
101
101
  },
102
102
  {
@@ -128,11 +128,33 @@ async function toggleLike() {
128
128
  reaction.liked = previousLiked;
129
129
  counts.liked += previousLiked ? 1 : -1;
130
130
  }
131
+ } else if (props.state === "content" && props.id) {
132
+ try {
133
+ await api(`/contents/${props.id}/like`, {
134
+ method: reaction.liked ? "POST" : "DELETE"
135
+ });
136
+ } catch (error) {
137
+ console.error(error);
138
+ reaction.liked = previousLiked;
139
+ counts.liked += previousLiked ? 1 : -1;
140
+ }
131
141
  }
132
142
  }
133
- function toggleBookmark() {
134
- reaction.bookmarked = !reaction.bookmarked;
143
+ async function toggleBookmark() {
144
+ const previousBookmarked = reaction.bookmarked;
145
+ reaction.bookmarked = !previousBookmarked;
135
146
  counts.bookmarked += reaction.bookmarked ? 1 : -1;
147
+ if (props.state === "content" && props.id) {
148
+ try {
149
+ await api(`/contents/${props.id}/bookmark`, {
150
+ method: reaction.bookmarked ? "POST" : "DELETE"
151
+ });
152
+ } catch (error) {
153
+ console.error(error);
154
+ reaction.bookmarked = previousBookmarked;
155
+ counts.bookmarked += previousBookmarked ? 1 : -1;
156
+ }
157
+ }
136
158
  }
137
159
  function toggleComment() {
138
160
  console.log("comment ");
@@ -21,6 +21,7 @@ export interface RawContentCard {
21
21
  }[];
22
22
  is_pinned?: boolean;
23
23
  is_liked?: boolean;
24
+ is_bookmarked?: boolean;
24
25
  expire_at?: string;
25
26
  }
26
27
  export interface MapContentToCardOptions {
@@ -13,9 +13,10 @@ export const mapContentToCard = (raw, options = {}) => {
13
13
  const item = {
14
14
  id: raw.id,
15
15
  type,
16
- location: place?.address || place?.name,
16
+ location: place?.name || place?.address,
17
17
  pinned: !!raw.is_pinned,
18
- bookmarked: !!raw.is_liked,
18
+ liked: !!raw.is_liked,
19
+ bookmarked: !!raw.is_bookmarked,
19
20
  expireAt: options.showExpiry ? raw.expire_at : void 0
20
21
  };
21
22
  if (type === "postIt") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pukaad-ui-lib",
3
- "version": "1.384.0",
3
+ "version": "1.386.0",
4
4
  "description": "pukaad-ui for MeMSG",
5
5
  "repository": {
6
6
  "type": "git",