@dotss/tictoccroc 0.9.0 → 0.9.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/shared/components/ChatKit/ImageMessage/ImageMessage.mjs +7 -6
- package/dist/shared/components/ChatKit/Message/Message.utils.mjs +15 -3
- package/dist/shared/components/ChatKit/Message/Message.utils.test.d.ts +1 -0
- package/dist/shared/components/Image/Image.mjs +113 -111
- package/dist/shared/components/Image/Image.utils.d.ts +7 -0
- package/dist/shared/components/Image/Image.utils.mjs +21 -0
- package/dist/shared/components/Image/Image.utils.test.d.ts +1 -0
- package/package.json +2 -2
|
@@ -62,22 +62,23 @@ function C({ id: y, assets: b, mine: C, status: w, regDatetime: T, unreadUserCou
|
|
|
62
62
|
overflow: "hidden"
|
|
63
63
|
},
|
|
64
64
|
children: b.map((e, n) => {
|
|
65
|
-
let i = b.length % h === 1 && n === b.length - 1, a = i ? g : v, o = e.state ?? "NORMAL", u = o === "NORMAL" ? void 0 : r(o)
|
|
65
|
+
let i = b.length % h === 1 && n === b.length - 1, a = i ? g : v, o = e.state ?? "NORMAL", u = o === "NORMAL" ? void 0 : r(o), d = !!j, _ = o === "NORMAL" ? `${n + 1}번째 사진` : `${n + 1}번째 사진, ${u}`;
|
|
66
66
|
return /* @__PURE__ */ p(s, {
|
|
67
|
-
tag: "button",
|
|
68
|
-
type: "button",
|
|
67
|
+
tag: d ? "button" : "div",
|
|
68
|
+
type: d ? "button" : void 0,
|
|
69
|
+
role: d ? void 0 : "img",
|
|
69
70
|
flexDirection: "column",
|
|
70
71
|
justifyContent: "center",
|
|
71
72
|
alignItems: "center",
|
|
72
73
|
gap: 1,
|
|
73
|
-
onClick: () => j
|
|
74
|
-
"aria-label": o === "NORMAL" ? `${
|
|
74
|
+
onClick: d ? () => j(n) : void 0,
|
|
75
|
+
"aria-label": d && o === "NORMAL" ? `${_} 보기` : _,
|
|
75
76
|
inlineCSS: {
|
|
76
77
|
gridColumn: i ? "1 / -1" : void 0,
|
|
77
78
|
padding: 0,
|
|
78
79
|
border: "none",
|
|
79
80
|
background: z[20],
|
|
80
|
-
cursor: "pointer"
|
|
81
|
+
cursor: d ? "pointer" : "default"
|
|
81
82
|
},
|
|
82
83
|
children: o === "NORMAL" ? /* @__PURE__ */ p(t, {
|
|
83
84
|
src: e.source,
|
|
@@ -15,8 +15,20 @@ function t(e) {
|
|
|
15
15
|
}))];
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
var n = {
|
|
19
|
+
SUCCEEDED: "전송됨",
|
|
20
|
+
FAILED: "전송 실패",
|
|
21
|
+
PENDING: "전송 중"
|
|
22
|
+
};
|
|
23
|
+
function r({ mine: t, status: r, unreadUserCount: i, content: a, regDatetime: o }) {
|
|
24
|
+
let s = n[r];
|
|
25
|
+
return [
|
|
26
|
+
t ? "나" : "상대방",
|
|
27
|
+
a,
|
|
28
|
+
i && i > 0 ? "읽지 않음" : "읽음",
|
|
29
|
+
s,
|
|
30
|
+
e(o).format("YYYY년 MM월 DD일 A h:mm")
|
|
31
|
+
].join(", ");
|
|
20
32
|
}
|
|
21
33
|
//#endregion
|
|
22
|
-
export {
|
|
34
|
+
export { r as getMessageLabel, t as markMessageGroupBoundaries };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,134 +2,136 @@ import e from "../../hooks/useInView/index.mjs";
|
|
|
2
2
|
import t from "../../hooks/useIsomorphicLayoutEffect/index.mjs";
|
|
3
3
|
import n from "../../utils/getImageUrl/index.mjs";
|
|
4
4
|
import r from "./Image.error.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { convertHeicToPng as ee, isHeicSource as i } from "./Image.utils.mjs";
|
|
6
|
+
import { forwardRef as a, useEffect as o, useImperativeHandle as s, useRef as c, useState as l } from "react";
|
|
7
|
+
import { Flexbox as u, Skeleton as d } from "@dotss/ui";
|
|
8
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
8
9
|
//#region shared/components/Image/Image.tsx
|
|
9
|
-
var
|
|
10
|
-
let F =
|
|
11
|
-
|
|
12
|
-
let { isInView:
|
|
10
|
+
var h = a(({ src: a, width: h, height: g, fit: _ = "cover", position: v = "center", alt: y, scale: b = 2, onLoad: x, onLazyLoad: S, lazy: C = !1, borderRadius: w, disabledResizing: T = !1, withIntrinsicRatio: E = !1, enableBlurPlaceholder: D = !1, enableFallback: O = !1, enableErrorFallback: k = !0, renderErrorFallback: A, wrapperProps: j = {}, inViewOptions: te = {}, onError: M, ...N }, P) => {
|
|
11
|
+
let F = c(null), I = c(!1), L = c(null), R = c(M);
|
|
12
|
+
R.current = M, s(P, () => L.current);
|
|
13
|
+
let { isInView: z } = e(F, {
|
|
13
14
|
threshold: .4,
|
|
14
|
-
...
|
|
15
|
-
}), [
|
|
15
|
+
...te
|
|
16
|
+
}), [B, V] = l(!1), [H, U] = l(!1), [W, G] = l(!1), [K, ne] = l(!1), [q, J] = l(n({
|
|
16
17
|
mode: "original",
|
|
17
|
-
src:
|
|
18
|
-
width:
|
|
19
|
-
height:
|
|
20
|
-
fit:
|
|
21
|
-
position:
|
|
22
|
-
scale:
|
|
23
|
-
disabledResizing:
|
|
24
|
-
})), Y = i
|
|
18
|
+
src: a,
|
|
19
|
+
width: h,
|
|
20
|
+
height: g,
|
|
21
|
+
fit: _,
|
|
22
|
+
position: v,
|
|
23
|
+
scale: b,
|
|
24
|
+
disabledResizing: T
|
|
25
|
+
})), Y = i(a), X = D ? n({
|
|
25
26
|
mode: "blur",
|
|
26
|
-
src:
|
|
27
|
-
width:
|
|
28
|
-
fit:
|
|
29
|
-
position:
|
|
27
|
+
src: a,
|
|
28
|
+
width: h,
|
|
29
|
+
fit: _,
|
|
30
|
+
position: v,
|
|
30
31
|
scale: 1 / 3,
|
|
31
|
-
disabledResizing:
|
|
32
|
+
disabledResizing: T
|
|
32
33
|
}) : null, Z = (e) => {
|
|
33
|
-
|
|
34
|
+
U(!0), G(!1), typeof x == "function" && x(e);
|
|
34
35
|
}, Q = (e) => {
|
|
35
|
-
typeof M == "function" && M(e.nativeEvent),
|
|
36
|
-
}, $ = () =>
|
|
37
|
-
return
|
|
38
|
-
if (
|
|
36
|
+
Y && !q.startsWith("blob:") || (typeof M == "function" && M(e.nativeEvent), G(!0), U(!1));
|
|
37
|
+
}, $ = () => ne(!0);
|
|
38
|
+
return o(() => {
|
|
39
|
+
if (C && F.current) {
|
|
39
40
|
let e = () => {
|
|
40
|
-
|
|
41
|
+
z && V(!0);
|
|
41
42
|
};
|
|
42
43
|
return e(), window.appScreenContent?.addEventListener("scroll", e), window.addEventListener("resize", e), window.addEventListener("orientationchange", e), () => {
|
|
43
44
|
window.appScreenContent?.removeEventListener("scroll", e), window.removeEventListener("resize", e), window.removeEventListener("orientationchange", e);
|
|
44
45
|
};
|
|
45
46
|
}
|
|
46
|
-
}),
|
|
47
|
-
typeof
|
|
48
|
-
}, [
|
|
49
|
-
let e = L.current, t = (e) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
toType: "image/png"
|
|
54
|
-
});
|
|
55
|
-
J(URL.createObjectURL(i)), e.onload = () => {
|
|
56
|
-
e.style.opacity = "1", H(!0), W(!1), e.onload = null, e.onerror = null;
|
|
47
|
+
}), o(() => {
|
|
48
|
+
typeof S == "function" && B && !I.current && (I.current = !0, S());
|
|
49
|
+
}, [S, B]), t(() => {
|
|
50
|
+
let e = L.current, t = !1, n = (e) => {
|
|
51
|
+
ee(a).then((n) => {
|
|
52
|
+
t || (J(URL.createObjectURL(n)), e.onload = () => {
|
|
53
|
+
e.style.opacity = "1", U(!0), G(!1), e.onload = null, e.onerror = null;
|
|
57
54
|
}, e.onerror = () => {
|
|
58
|
-
|
|
59
|
-
};
|
|
55
|
+
G(!0), U(!1), e.onload = null, e.onerror = null;
|
|
56
|
+
});
|
|
57
|
+
}).catch((e) => {
|
|
58
|
+
t || (G(!0), U(!1), typeof R.current == "function" && R.current(new ErrorEvent("error", {
|
|
59
|
+
error: e,
|
|
60
|
+
message: e.message
|
|
61
|
+
})));
|
|
60
62
|
});
|
|
61
63
|
};
|
|
62
|
-
return e?.complete ? Y ? e.src.startsWith("blob:") || (e.style.transition = "opacity 0.3s", e.style.opacity = "0",
|
|
63
|
-
e.style.opacity = "1",
|
|
64
|
+
return e?.complete ? Y ? e.src.startsWith("blob:") || (e.style.transition = "opacity 0.3s", e.style.opacity = "0", n(e)) : e.naturalWidth > 0 ? (e.style.transition = "none", e.style.opacity = "1", U(!0)) : (e.style.opacity = "0", G(!0)) : e && (e.style.transition = "opacity 0.3s", e.style.opacity = "0", e.onload = () => {
|
|
65
|
+
e.style.opacity = "1", U(!0), e.onload = null;
|
|
64
66
|
}, e.onerror = () => {
|
|
65
67
|
if (!Y) {
|
|
66
|
-
|
|
68
|
+
G(!0), e.onerror = null;
|
|
67
69
|
return;
|
|
68
70
|
}
|
|
69
|
-
|
|
71
|
+
G(!1), e.style.transition = "opacity 0.3s", e.style.opacity = "0", n(e);
|
|
70
72
|
}), () => {
|
|
71
|
-
e && (e.onload = null, e.onerror = null);
|
|
73
|
+
t = !0, e && (e.onload = null, e.onerror = null);
|
|
72
74
|
};
|
|
73
75
|
}, [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
B,
|
|
77
|
+
a,
|
|
76
78
|
Y
|
|
77
|
-
]),
|
|
79
|
+
]), o(() => {
|
|
78
80
|
J(n({
|
|
79
81
|
mode: "original",
|
|
80
|
-
src:
|
|
81
|
-
width:
|
|
82
|
-
height:
|
|
83
|
-
fit:
|
|
84
|
-
position:
|
|
85
|
-
scale:
|
|
86
|
-
disabledResizing:
|
|
82
|
+
src: a,
|
|
83
|
+
width: h,
|
|
84
|
+
height: g,
|
|
85
|
+
fit: _,
|
|
86
|
+
position: v,
|
|
87
|
+
scale: b,
|
|
88
|
+
disabledResizing: T
|
|
87
89
|
}));
|
|
88
90
|
}, [
|
|
89
|
-
|
|
90
|
-
m,
|
|
91
|
+
a,
|
|
91
92
|
h,
|
|
92
93
|
g,
|
|
93
94
|
_,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
v,
|
|
96
|
+
b,
|
|
97
|
+
T
|
|
98
|
+
]), C ? /* @__PURE__ */ m(u, {
|
|
99
|
+
...j,
|
|
98
100
|
ref: F,
|
|
99
|
-
inlineCSS:
|
|
101
|
+
inlineCSS: E ? {
|
|
100
102
|
position: "relative",
|
|
101
|
-
paddingTop: `calc(100% / ${
|
|
103
|
+
paddingTop: `calc(100% / ${h} * ${g})`,
|
|
102
104
|
minWidth: "100%",
|
|
103
|
-
borderRadius:
|
|
105
|
+
borderRadius: w,
|
|
104
106
|
overflow: "hidden",
|
|
105
|
-
...
|
|
107
|
+
...j?.inlineCSS
|
|
106
108
|
} : {
|
|
107
109
|
position: "relative",
|
|
108
|
-
width:
|
|
109
|
-
minWidth:
|
|
110
|
-
height:
|
|
111
|
-
borderRadius:
|
|
110
|
+
width: h,
|
|
111
|
+
minWidth: h,
|
|
112
|
+
height: g,
|
|
113
|
+
borderRadius: w,
|
|
112
114
|
overflow: "hidden",
|
|
113
|
-
...
|
|
115
|
+
...j?.inlineCSS
|
|
114
116
|
},
|
|
115
117
|
children: [
|
|
116
|
-
|
|
118
|
+
O && /* @__PURE__ */ p(d, {
|
|
117
119
|
width: "100%",
|
|
118
120
|
height: "100%",
|
|
119
|
-
borderRadius:
|
|
121
|
+
borderRadius: w || 0,
|
|
120
122
|
inlineCSS: {
|
|
121
123
|
position: "absolute",
|
|
122
124
|
top: 0,
|
|
123
125
|
left: 0,
|
|
124
|
-
opacity:
|
|
126
|
+
opacity: H || D && K ? 0 : 1,
|
|
125
127
|
transition: "opacity 0.3s"
|
|
126
128
|
}
|
|
127
129
|
}),
|
|
128
|
-
|
|
130
|
+
D && X && B && /* @__PURE__ */ p("img", {
|
|
129
131
|
src: X,
|
|
130
132
|
alt: "",
|
|
131
|
-
width:
|
|
132
|
-
height:
|
|
133
|
+
width: h,
|
|
134
|
+
height: g,
|
|
133
135
|
onLoad: $,
|
|
134
136
|
draggable: !1,
|
|
135
137
|
style: {
|
|
@@ -139,21 +141,21 @@ var m = i(({ src: i, width: m, height: h, fit: g = "cover", position: _ = "cente
|
|
|
139
141
|
width: "100%",
|
|
140
142
|
height: "100%",
|
|
141
143
|
filter: "blur(5px)",
|
|
142
|
-
opacity:
|
|
144
|
+
opacity: K && !H ? 1 : 0,
|
|
143
145
|
transition: "opacity 0.3s",
|
|
144
|
-
objectFit:
|
|
145
|
-
objectPosition:
|
|
146
|
+
objectFit: _,
|
|
147
|
+
objectPosition: v
|
|
146
148
|
}
|
|
147
149
|
}),
|
|
148
|
-
|
|
150
|
+
B && /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ p("img", {
|
|
149
151
|
ref: L,
|
|
150
152
|
src: q,
|
|
151
|
-
alt:
|
|
152
|
-
width:
|
|
153
|
-
height:
|
|
153
|
+
alt: y,
|
|
154
|
+
width: h,
|
|
155
|
+
height: g,
|
|
154
156
|
onLoad: Z,
|
|
155
157
|
onError: Q,
|
|
156
|
-
"aria-hidden":
|
|
158
|
+
"aria-hidden": W,
|
|
157
159
|
draggable: !1,
|
|
158
160
|
...N,
|
|
159
161
|
style: {
|
|
@@ -165,46 +167,46 @@ var m = i(({ src: i, width: m, height: h, fit: g = "cover", position: _ = "cente
|
|
|
165
167
|
transition: "opacity 0.3s",
|
|
166
168
|
...N.style
|
|
167
169
|
}
|
|
168
|
-
}),
|
|
170
|
+
}), k && W && (A?.() || /* @__PURE__ */ p(r, {}))] })
|
|
169
171
|
]
|
|
170
|
-
}) : /* @__PURE__ */
|
|
171
|
-
...
|
|
172
|
+
}) : /* @__PURE__ */ m(u, {
|
|
173
|
+
...j,
|
|
172
174
|
ref: F,
|
|
173
|
-
inlineCSS:
|
|
175
|
+
inlineCSS: E ? {
|
|
174
176
|
position: "relative",
|
|
175
|
-
paddingTop: `calc(100% / ${
|
|
177
|
+
paddingTop: `calc(100% / ${h} * ${g})`,
|
|
176
178
|
minWidth: "100%",
|
|
177
179
|
transition: "padding-top 0.2s",
|
|
178
|
-
borderRadius:
|
|
180
|
+
borderRadius: w,
|
|
179
181
|
overflow: "hidden",
|
|
180
|
-
...
|
|
182
|
+
...j?.inlineCSS
|
|
181
183
|
} : {
|
|
182
184
|
position: "relative",
|
|
183
|
-
width:
|
|
184
|
-
minWidth:
|
|
185
|
-
height:
|
|
186
|
-
borderRadius:
|
|
185
|
+
width: h,
|
|
186
|
+
minWidth: h,
|
|
187
|
+
height: g,
|
|
188
|
+
borderRadius: w,
|
|
187
189
|
overflow: "hidden",
|
|
188
|
-
...
|
|
190
|
+
...j?.inlineCSS
|
|
189
191
|
},
|
|
190
192
|
children: [
|
|
191
|
-
|
|
193
|
+
O && /* @__PURE__ */ p(d, {
|
|
192
194
|
width: "100%",
|
|
193
195
|
height: "100%",
|
|
194
|
-
borderRadius:
|
|
196
|
+
borderRadius: w || 0,
|
|
195
197
|
inlineCSS: {
|
|
196
198
|
position: "absolute",
|
|
197
199
|
top: 0,
|
|
198
200
|
left: 0,
|
|
199
|
-
opacity:
|
|
201
|
+
opacity: H || D && K ? 0 : 1,
|
|
200
202
|
transition: "opacity 0.3s"
|
|
201
203
|
}
|
|
202
204
|
}),
|
|
203
|
-
|
|
205
|
+
D && X && /* @__PURE__ */ p("img", {
|
|
204
206
|
src: X,
|
|
205
207
|
alt: "",
|
|
206
|
-
width:
|
|
207
|
-
height:
|
|
208
|
+
width: h,
|
|
209
|
+
height: g,
|
|
208
210
|
onLoad: $,
|
|
209
211
|
draggable: !1,
|
|
210
212
|
style: {
|
|
@@ -214,19 +216,19 @@ var m = i(({ src: i, width: m, height: h, fit: g = "cover", position: _ = "cente
|
|
|
214
216
|
width: "100%",
|
|
215
217
|
height: "100%",
|
|
216
218
|
filter: "blur(5px)",
|
|
217
|
-
opacity:
|
|
219
|
+
opacity: K && !H ? 1 : 0,
|
|
218
220
|
transition: "opacity 0.3s"
|
|
219
221
|
}
|
|
220
222
|
}),
|
|
221
|
-
/* @__PURE__ */
|
|
223
|
+
/* @__PURE__ */ p("img", {
|
|
222
224
|
ref: L,
|
|
223
225
|
src: q,
|
|
224
|
-
alt:
|
|
225
|
-
width:
|
|
226
|
-
height:
|
|
226
|
+
alt: y,
|
|
227
|
+
width: h,
|
|
228
|
+
height: g,
|
|
227
229
|
onLoad: Z,
|
|
228
230
|
onError: Q,
|
|
229
|
-
"aria-hidden":
|
|
231
|
+
"aria-hidden": W,
|
|
230
232
|
draggable: !1,
|
|
231
233
|
...N,
|
|
232
234
|
style: {
|
|
@@ -239,9 +241,9 @@ var m = i(({ src: i, width: m, height: h, fit: g = "cover", position: _ = "cente
|
|
|
239
241
|
...N.style
|
|
240
242
|
}
|
|
241
243
|
}),
|
|
242
|
-
|
|
244
|
+
k && W && (A?.() || /* @__PURE__ */ p(r, {}))
|
|
243
245
|
]
|
|
244
246
|
});
|
|
245
247
|
});
|
|
246
248
|
//#endregion
|
|
247
|
-
export {
|
|
249
|
+
export { h as default };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region shared/components/Image/Image.utils.ts
|
|
2
|
+
var e = [".heic", ".heif"];
|
|
3
|
+
function t(t) {
|
|
4
|
+
let n = t?.toLowerCase() ?? "";
|
|
5
|
+
return e.some((e) => n.endsWith(e));
|
|
6
|
+
}
|
|
7
|
+
var n = /* @__PURE__ */ new Map();
|
|
8
|
+
function r(e) {
|
|
9
|
+
let t = n.get(e);
|
|
10
|
+
if (t) return t;
|
|
11
|
+
let r = window.fetch(e).then((e) => e.blob()).then(async (e) => {
|
|
12
|
+
let { heicTo: t } = await import("heic-to");
|
|
13
|
+
return t({
|
|
14
|
+
blob: e,
|
|
15
|
+
type: "image/png"
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
return n.set(e, r), r.catch(() => n.delete(e)), r;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { r as convertHeicToPng, t as isHeicSource };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotss/tictoccroc",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.1",
|
|
5
5
|
"description": "Tictoccroc shared components, hooks, utils, and APIs for Dotss",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"@emotion/react": "^11.14.0",
|
|
140
140
|
"@emotion/styled": "^11.14.0",
|
|
141
141
|
"dayjs": "^1.11.13",
|
|
142
|
-
"
|
|
142
|
+
"heic-to": "1.5.2",
|
|
143
143
|
"dompurify": "^3.3.1",
|
|
144
144
|
"marked": "^17.0.3",
|
|
145
145
|
"react": "^18.0.0 || ^19.0.0",
|