@solostylist/ui-kit 1.0.136 → 1.0.138

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.
@@ -9,12 +9,14 @@ export interface SCommentMessageProps {
9
9
  likes?: number;
10
10
  isLiked?: boolean;
11
11
  replies?: SCommentMessageProps[];
12
+ totalReplies?: number;
12
13
  onLike?: (commentId: string | number) => void;
13
14
  onReply?: (commentId: string | number, parentId?: string | number) => void;
14
15
  showReplies?: boolean;
15
16
  avatarSize?: number;
16
17
  level?: number;
17
18
  maxLevel?: number;
19
+ children?: React.ReactNode;
18
20
  sx?: SxProps;
19
21
  }
20
22
  declare const SCommentMessage: React.FC<SCommentMessageProps>;
@@ -1,79 +1,81 @@
1
- import { j as t } from "../jsx-runtime-OVHDjVDe.js";
2
- import { useState as u, useEffect as w } from "react";
3
- import { Box as v, Stack as y, Typography as m, IconButton as W, Button as k, Collapse as H } from "@mui/material";
4
- import A from "../s-avatar/s-avatar.js";
5
- import { F as P } from "../Favorite-DmSF47XC.js";
6
- import { c as I } from "../createSvgIcon-Dq42_0tn.js";
7
- import { E as V } from "../ExpandMore-mZGpvXf6.js";
8
- const Y = I(/* @__PURE__ */ t.jsx("path", {
1
+ import { j as e } from "../jsx-runtime-OVHDjVDe.js";
2
+ import { useState as I, useEffect as T } from "react";
3
+ import { Box as m, Stack as M, Typography as x, IconButton as P, Button as $, Collapse as V } from "@mui/material";
4
+ import Y from "../s-avatar/s-avatar.js";
5
+ import { F as q } from "../Favorite-DmSF47XC.js";
6
+ import { c as S } from "../createSvgIcon-Dq42_0tn.js";
7
+ import { E as G } from "../ExpandMore-mZGpvXf6.js";
8
+ const J = S(/* @__PURE__ */ e.jsx("path", {
9
9
  d: "m12 8-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"
10
- }), "ExpandLess"), q = I(/* @__PURE__ */ t.jsx("path", {
10
+ }), "ExpandLess"), K = S(/* @__PURE__ */ e.jsx("path", {
11
11
  d: "M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3m-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05"
12
- }), "FavoriteBorder"), G = I(/* @__PURE__ */ t.jsx("path", {
12
+ }), "FavoriteBorder"), O = S(/* @__PURE__ */ e.jsx("path", {
13
13
  d: "M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11"
14
- }), "Reply"), J = (a) => {
15
- const c = /* @__PURE__ */ new Date(), d = typeof a == "string" ? new Date(a) : a, x = c.getTime() - d.getTime(), f = Math.floor(x / 1e3), o = Math.floor(f / 60), n = Math.floor(o / 60), e = Math.floor(n / 24), s = Math.floor(e / 7), r = Math.floor(e / 30), i = Math.floor(e / 365);
16
- return f < 60 ? "just now" : o < 60 ? o === 1 ? "1 minute ago" : `${o} minutes ago` : n < 24 ? n === 1 ? "1 hour ago" : `${n} hours ago` : e < 7 ? e === 1 ? "1 day ago" : `${e} days ago` : s < 4 ? s === 1 ? "1 week ago" : `${s} weeks ago` : r < 12 ? r === 1 ? "1 month ago" : `${r} months ago` : i === 1 ? "1 year ago" : `${i} years ago`;
17
- }, K = ({
18
- id: a = Date.now(),
14
+ }), "Reply"), Q = (r) => {
15
+ const c = /* @__PURE__ */ new Date(), d = typeof r == "string" ? new Date(r) : r, h = c.getTime() - d.getTime(), f = Math.floor(h / 1e3), o = Math.floor(f / 60), s = Math.floor(o / 60), t = Math.floor(s / 24), l = Math.floor(t / 7), n = Math.floor(t / 30), a = Math.floor(t / 365);
16
+ return f < 60 ? "just now" : o < 60 ? o === 1 ? "1 minute ago" : `${o} minutes ago` : s < 24 ? s === 1 ? "1 hour ago" : `${s} hours ago` : t < 7 ? t === 1 ? "1 day ago" : `${t} days ago` : l < 4 ? l === 1 ? "1 week ago" : `${l} weeks ago` : n < 12 ? n === 1 ? "1 month ago" : `${n} months ago` : a === 1 ? "1 year ago" : `${a} years ago`;
17
+ }, U = ({
18
+ id: r = Date.now(),
19
19
  userName: c,
20
20
  userAvatar: d,
21
- commentContent: x,
21
+ commentContent: h,
22
22
  datetime: f,
23
23
  likes: o = 0,
24
- isLiked: n = !1,
25
- replies: e = [],
26
- onLike: s,
27
- onReply: r,
28
- showReplies: i = !0,
29
- avatarSize: M = 48,
30
- level: S = 0,
31
- maxLevel: z = 3,
32
- sx: b = {}
24
+ isLiked: s = !1,
25
+ replies: t = [],
26
+ totalReplies: l,
27
+ onLike: n,
28
+ onReply: a,
29
+ showReplies: p = !0,
30
+ avatarSize: C = 48,
31
+ level: z = 0,
32
+ maxLevel: L = 3,
33
+ children: w,
34
+ sx: E = {}
33
35
  }) => {
34
- const [C, h] = u(o), [g, p] = u(n), [j, T] = u(!1), $ = () => {
35
- g ? (h((l) => Math.max(0, l - 1)), p(!1)) : (h((l) => l + 1), p(!0)), s && s(a);
36
- }, E = () => {
37
- r && r(a);
38
- }, R = () => {
39
- T(!j);
40
- }, B = J(f), L = e.length > 0, D = Math.min(S, z) * 2;
41
- return w(() => {
42
- h(o);
43
- }, [o]), w(() => {
44
- p(n);
45
- }, [n]), /* @__PURE__ */ t.jsxs(v, { sx: { pl: D, py: 1, ...b }, children: [
46
- /* @__PURE__ */ t.jsxs(y, { direction: "row", spacing: 2, alignItems: "flex-start", children: [
47
- /* @__PURE__ */ t.jsx(A, { avatar: d, name: c, size: M }),
48
- /* @__PURE__ */ t.jsxs(v, { sx: { flex: 1 }, children: [
49
- /* @__PURE__ */ t.jsxs(y, { direction: "row", alignItems: "center", spacing: 2, mb: 1, children: [
50
- /* @__PURE__ */ t.jsx(m, { variant: "subtitle2", fontWeight: "600", children: c }),
51
- /* @__PURE__ */ t.jsx("div", { children: /* @__PURE__ */ t.jsx(m, { variant: "caption", color: "text.secondary", children: B }) })
36
+ const [k, g] = I(o), [j, u] = I(s), [v, R] = I(!1), B = () => {
37
+ j ? (g((i) => Math.max(0, i - 1)), u(!1)) : (g((i) => i + 1), u(!0)), n && n(r);
38
+ }, D = () => {
39
+ a && a(r);
40
+ }, F = () => {
41
+ R(!v);
42
+ }, W = Q(f), y = l ?? t.length, b = y > 0, H = Math.min(z, L) * 2;
43
+ return T(() => {
44
+ g(o);
45
+ }, [o]), T(() => {
46
+ u(s);
47
+ }, [s]), /* @__PURE__ */ e.jsxs(m, { sx: { pl: H, py: 1, ...E }, children: [
48
+ /* @__PURE__ */ e.jsxs(M, { direction: "row", spacing: 2, alignItems: "flex-start", children: [
49
+ /* @__PURE__ */ e.jsx(Y, { avatar: d, name: c, size: C }),
50
+ /* @__PURE__ */ e.jsxs(m, { sx: { flex: 1 }, children: [
51
+ /* @__PURE__ */ e.jsxs(M, { direction: "row", alignItems: "center", spacing: 2, mb: 1, children: [
52
+ /* @__PURE__ */ e.jsx(x, { variant: "subtitle2", fontWeight: "600", children: c }),
53
+ /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(x, { variant: "caption", color: "text.secondary", children: W }) })
52
54
  ] }),
53
- /* @__PURE__ */ t.jsx(m, { variant: "body2", sx: { mb: 2, lineHeight: 1.6 }, children: x }),
54
- /* @__PURE__ */ t.jsxs(y, { direction: "row", spacing: 1, alignItems: "center", children: [
55
- /* @__PURE__ */ t.jsx(
56
- W,
55
+ /* @__PURE__ */ e.jsx(x, { variant: "body2", sx: { mb: 2, lineHeight: 1.6 }, children: h }),
56
+ /* @__PURE__ */ e.jsxs(M, { direction: "row", spacing: 1, alignItems: "center", children: [
57
+ /* @__PURE__ */ e.jsx(
58
+ P,
57
59
  {
58
60
  size: "small",
59
- onClick: $,
61
+ onClick: B,
60
62
  sx: {
61
- color: g ? "error.main" : "text.secondary",
63
+ color: j ? "error.main" : "text.secondary",
62
64
  p: 0.5,
63
65
  "&:hover": {
64
66
  backgroundColor: "action.hover"
65
67
  }
66
68
  },
67
- children: g ? /* @__PURE__ */ t.jsx(P, { fontSize: "small" }) : /* @__PURE__ */ t.jsx(q, { fontSize: "small" })
69
+ children: j ? /* @__PURE__ */ e.jsx(q, { fontSize: "small" }) : /* @__PURE__ */ e.jsx(K, { fontSize: "small" })
68
70
  }
69
71
  ),
70
- C > 0 && /* @__PURE__ */ t.jsx(m, { variant: "caption", color: "text.secondary", children: C }),
71
- /* @__PURE__ */ t.jsx(
72
- k,
72
+ k > 0 && /* @__PURE__ */ e.jsx(x, { variant: "caption", color: "text.secondary", children: k }),
73
+ /* @__PURE__ */ e.jsx(
74
+ $,
73
75
  {
74
76
  size: "small",
75
- startIcon: /* @__PURE__ */ t.jsx(G, { fontSize: "small" }),
76
- onClick: E,
77
+ startIcon: /* @__PURE__ */ e.jsx(O, { fontSize: "small" }),
78
+ onClick: D,
77
79
  variant: "text",
78
80
  sx: {
79
81
  color: "text.secondary",
@@ -89,12 +91,12 @@ const Y = I(/* @__PURE__ */ t.jsx("path", {
89
91
  children: "Reply"
90
92
  }
91
93
  ),
92
- L && i && /* @__PURE__ */ t.jsxs(
93
- k,
94
+ b && p && /* @__PURE__ */ e.jsxs(
95
+ $,
94
96
  {
95
97
  size: "small",
96
- startIcon: j ? /* @__PURE__ */ t.jsx(Y, { fontSize: "small" }) : /* @__PURE__ */ t.jsx(V, { fontSize: "small" }),
97
- onClick: R,
98
+ startIcon: v ? /* @__PURE__ */ e.jsx(J, { fontSize: "small" }) : /* @__PURE__ */ e.jsx(G, { fontSize: "small" }),
99
+ onClick: F,
98
100
  variant: "text",
99
101
  sx: {
100
102
  color: "primary.main",
@@ -108,30 +110,31 @@ const Y = I(/* @__PURE__ */ t.jsx("path", {
108
110
  }
109
111
  },
110
112
  children: [
111
- e.length,
113
+ y,
112
114
  " ",
113
- e.length === 1 ? "reply" : "replies"
115
+ y === 1 ? "reply" : "replies"
114
116
  ]
115
117
  }
116
118
  )
117
- ] })
119
+ ] }),
120
+ w && /* @__PURE__ */ e.jsx(m, { sx: { mt: 2 }, children: w })
118
121
  ] })
119
122
  ] }),
120
- L && i && /* @__PURE__ */ t.jsx(H, { in: j, children: /* @__PURE__ */ t.jsx(v, { sx: { mt: 2 }, children: e.map((l, F) => /* @__PURE__ */ t.jsx(
121
- K,
123
+ b && p && /* @__PURE__ */ e.jsx(V, { in: v, children: /* @__PURE__ */ e.jsx(m, { sx: { mt: 2 }, children: t.map((i, A) => /* @__PURE__ */ e.jsx(
124
+ U,
122
125
  {
123
- ...l,
124
- level: S + 1,
125
- maxLevel: z,
126
- onLike: s,
127
- onReply: r,
128
- showReplies: i,
129
- avatarSize: Math.max(32, M - 8)
126
+ ...i,
127
+ level: z + 1,
128
+ maxLevel: L,
129
+ onLike: n,
130
+ onReply: a,
131
+ showReplies: p,
132
+ avatarSize: Math.max(32, C - 8)
130
133
  },
131
- l.id || `reply-${F}`
134
+ i.id || `reply-${A}`
132
135
  )) }) })
133
136
  ] });
134
137
  };
135
138
  export {
136
- K as default
139
+ U as default
137
140
  };