@poolse/react-ui 2.0.12 → 2.1.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/index.cjs +3 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -38
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -49,43 +49,6 @@ function PoolseFonts() {
|
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
// src/grouping.ts
|
|
53
|
-
function computeGroupPosition(msg, prev, next, windowMs) {
|
|
54
|
-
const continuesPrev = sameGroup(msg, prev, windowMs);
|
|
55
|
-
const continuesNext = sameGroup(next, msg, windowMs);
|
|
56
|
-
if (continuesPrev && continuesNext) return "middle";
|
|
57
|
-
if (continuesPrev) return "last";
|
|
58
|
-
if (continuesNext) return "first";
|
|
59
|
-
return "standalone";
|
|
60
|
-
}
|
|
61
|
-
function sameGroup(a, b, windowMs) {
|
|
62
|
-
if (!a || !b) return false;
|
|
63
|
-
if (a.sender_id !== b.sender_id) return false;
|
|
64
|
-
if (!sameDay(a.inserted_at, b.inserted_at)) return false;
|
|
65
|
-
const ta = new Date(a.inserted_at).getTime();
|
|
66
|
-
const tb = new Date(b.inserted_at).getTime();
|
|
67
|
-
return Math.abs(ta - tb) <= windowMs;
|
|
68
|
-
}
|
|
69
|
-
function sameDay(a, b) {
|
|
70
|
-
const da = new Date(a);
|
|
71
|
-
const db = new Date(b);
|
|
72
|
-
return da.getFullYear() === db.getFullYear() && da.getMonth() === db.getMonth() && da.getDate() === db.getDate();
|
|
73
|
-
}
|
|
74
|
-
function formatDayLabel(iso, now = /* @__PURE__ */ new Date()) {
|
|
75
|
-
const d = new Date(iso);
|
|
76
|
-
const startOfDay = (x) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime();
|
|
77
|
-
const diffDays = Math.floor((startOfDay(now) - startOfDay(d)) / 864e5);
|
|
78
|
-
if (diffDays === 0) return "Today";
|
|
79
|
-
if (diffDays === 1) return "Yesterday";
|
|
80
|
-
if (diffDays < 7) {
|
|
81
|
-
return d.toLocaleDateString(void 0, { weekday: "long" });
|
|
82
|
-
}
|
|
83
|
-
if (d.getFullYear() === now.getFullYear()) {
|
|
84
|
-
return d.toLocaleDateString(void 0, { weekday: "short", day: "numeric", month: "short" });
|
|
85
|
-
}
|
|
86
|
-
return d.toLocaleDateString(void 0, { day: "numeric", month: "short", year: "numeric" });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
52
|
// src/listAutocomplete.ts
|
|
90
53
|
var UNORDERED_RE = /^(\s*)([-*+]) (.*)$/;
|
|
91
54
|
var ORDERED_RE = /^(\s*)(\d+)\. (.*)$/;
|
|
@@ -2228,8 +2191,8 @@ function ConversationView({
|
|
|
2228
2191
|
}
|
|
2229
2192
|
const prev = idx > 0 ? messages[idx - 1] ?? null : null;
|
|
2230
2193
|
const next = idx < messages.length - 1 ? messages[idx + 1] ?? null : null;
|
|
2231
|
-
const groupPosition = grouping ? computeGroupPosition(msg, prev, next, groupingWindowMs) : "standalone";
|
|
2232
|
-
const showDaySeparator = daySeparators && (prev === null || !sameDay(msg.inserted_at, prev.inserted_at));
|
|
2194
|
+
const groupPosition = grouping ? react$1.computeGroupPosition(msg, prev, next, groupingWindowMs) : "standalone";
|
|
2195
|
+
const showDaySeparator = daySeparators && (prev === null || !react$1.sameDay(msg.inserted_at, prev.inserted_at));
|
|
2233
2196
|
const enriched = quotations && msg.quoted_message_id && !msg.quoted_message ? (() => {
|
|
2234
2197
|
const original = messages.find((m) => m.id === msg.quoted_message_id);
|
|
2235
2198
|
if (!original) return msg;
|
|
@@ -2248,7 +2211,7 @@ function ConversationView({
|
|
|
2248
2211
|
const isSelf = me !== null && msg.sender_id === me.id;
|
|
2249
2212
|
const readState = readReceipts && isSelf && maxReadByOthers !== null ? maxReadByOthers >= msg.sequence ? "read" : "sent" : void 0;
|
|
2250
2213
|
return /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
2251
|
-
showDaySeparator && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-day-separator", "aria-hidden": "false", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: formatDayLabel(msg.inserted_at) }) }),
|
|
2214
|
+
showDaySeparator && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "poolse-day-separator", "aria-hidden": "false", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: react$1.formatDayLabel(msg.inserted_at) }) }),
|
|
2252
2215
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2253
2216
|
MessageRow,
|
|
2254
2217
|
{
|