@protobase/ui 0.54.3 → 0.54.5
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/chat/chat-divider.d.ts +4 -1
- package/dist/chat/chat-divider.js +5 -1
- package/dist/chat/chat-thread.js +2 -16
- package/dist/chat/read-place.js +22 -0
- package/dist/package.js +1 -1
- package/dist/shell/assets/{app-BsVAjtGl.js → app-7LGt1Apg.js} +4 -4
- package/dist/shell/assets/{index-BKxEM_Qu.js → index-DvC8OI3c.js} +2 -2
- package/dist/shell/assets/{records-map-B6OP5rj7.js → records-map-C-UIoBtb.js} +2 -2
- package/dist/shell/assets/shared-protobase-ui-Cc69lTef.js +2 -0
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +1 -1
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/app-7LGt1Apg.js.map +1 -0
- package/dist/shell-source-maps/assets/{index-BKxEM_Qu.js.map → index-DvC8OI3c.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-B6OP5rj7.js.map → records-map-C-UIoBtb.js.map} +1 -1
- package/dist/shell-source-maps/assets/shared-protobase-ui-Cc69lTef.js.map +1 -0
- package/package.json +4 -4
- package/dist/shell/assets/shared-protobase-ui-DgebLa3S.js +0 -2
- package/dist/shell-source-maps/assets/app-BsVAjtGl.js.map +0 -1
- package/dist/shell-source-maps/assets/shared-protobase-ui-DgebLa3S.js.map +0 -1
|
@@ -10,6 +10,9 @@ export type ChatDividerProps =
|
|
|
10
10
|
tone: 'new';
|
|
11
11
|
label?: string;
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* A line across a chat with a label in its middle, between the messages of two days or above the new ones. Marked
|
|
15
|
+
* `data-chat-divider`, so a thread keeps the reader's place on the message below it, not on the divider.
|
|
16
|
+
*/
|
|
14
17
|
export declare const ChatDivider: ({ tone, label }: ChatDividerProps) => import("react").JSX.Element;
|
|
15
18
|
//#endregion
|
|
@@ -2,7 +2,10 @@ import { cn } from "../lib/cn.js";
|
|
|
2
2
|
import { text } from "./messages.js";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
//#region src/chat/chat-divider.tsx
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* A line across a chat with a label in its middle, between the messages of two days or above the new ones. Marked
|
|
7
|
+
* `data-chat-divider`, so a thread keeps the reader's place on the message below it, not on the divider.
|
|
8
|
+
*/
|
|
6
9
|
const ChatDivider = ({ tone = "day", label }) => {
|
|
7
10
|
const shown = label ?? text("newMessages");
|
|
8
11
|
const line = cn("h-px flex-1", tone === "new" ? "bg-danger" : "bg-border");
|
|
@@ -10,6 +13,7 @@ const ChatDivider = ({ tone = "day", label }) => {
|
|
|
10
13
|
role: "separator",
|
|
11
14
|
"aria-label": shown,
|
|
12
15
|
"data-tone": tone,
|
|
16
|
+
"data-chat-divider": "",
|
|
13
17
|
className: "flex items-center gap-3 text-xs font-medium",
|
|
14
18
|
children: [
|
|
15
19
|
/* @__PURE__ */ jsx("span", { className: line }),
|
package/dist/chat/chat-thread.js
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import { cn } from "../lib/cn.js";
|
|
2
2
|
import { Button } from "../primitives/button.js";
|
|
3
3
|
import { text } from "./messages.js";
|
|
4
|
-
import {
|
|
4
|
+
import { scrollAfterChange } from "./thread-scroll.js";
|
|
5
|
+
import { readPlace } from "./read-place.js";
|
|
5
6
|
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
//#region src/chat/chat-thread.tsx
|
|
8
|
-
/** The message the reader is reading: the first whose bottom shows. */
|
|
9
|
-
const readPlace = (box, list, followKey) => {
|
|
10
|
-
const top = box.getBoundingClientRect().top;
|
|
11
|
-
const element = [...list.children].find((child) => child.getBoundingClientRect().bottom > top);
|
|
12
|
-
const anchor = element && { anchor: {
|
|
13
|
-
element,
|
|
14
|
-
top: element.getBoundingClientRect().top - top
|
|
15
|
-
} };
|
|
16
|
-
return {
|
|
17
|
-
atEnd: isAtEnd(box),
|
|
18
|
-
first: list.firstElementChild ?? void 0,
|
|
19
|
-
followKey,
|
|
20
|
-
...anchor
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
9
|
/**
|
|
24
10
|
* The scrolling list of a chat's messages. A reader at the end follows new messages; one who scrolled back stays where
|
|
25
11
|
* they are until `followKey` changes, and earlier messages loaded above keep them on the message they were reading. It
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isAtEnd } from "./thread-scroll.js";
|
|
2
|
+
//#region src/chat/read-place.ts
|
|
3
|
+
/**
|
|
4
|
+
* The message the reader is reading: the first whose bottom shows, or the first below the top when none shows. Never a
|
|
5
|
+
* divider, since a day divider moves to the new first message when earlier ones of the same day load above it.
|
|
6
|
+
*/
|
|
7
|
+
const readPlace = (box, list, followKey) => {
|
|
8
|
+
const top = box.getBoundingClientRect().top;
|
|
9
|
+
const element = Array.from(list.children).find((child) => !child.hasAttribute("data-chat-divider") && child.getBoundingClientRect().bottom > top);
|
|
10
|
+
const anchor = element && { anchor: {
|
|
11
|
+
element,
|
|
12
|
+
top: element.getBoundingClientRect().top - top
|
|
13
|
+
} };
|
|
14
|
+
return {
|
|
15
|
+
atEnd: isAtEnd(box),
|
|
16
|
+
first: list.firstElementChild ?? void 0,
|
|
17
|
+
followKey,
|
|
18
|
+
...anchor
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { readPlace };
|
package/dist/package.js
CHANGED