chesai-ui 0.16.16 → 0.16.17
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.
|
@@ -1,95 +1,98 @@
|
|
|
1
|
-
import { jsx as i, jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { clsx as
|
|
4
|
-
import { LoadingIndicator as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as i, jsxs as k } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as z, useRef as p, useState as D, useEffect as a, useImperativeHandle as q, useLayoutEffect as T } from "react";
|
|
3
|
+
import { clsx as A } from "clsx";
|
|
4
|
+
import { LoadingIndicator as C } from "../loadingIndicator/index.mjs";
|
|
5
|
+
const F = z(
|
|
6
6
|
({
|
|
7
7
|
children: m,
|
|
8
|
-
onLoadOlder:
|
|
9
|
-
hasMore:
|
|
8
|
+
onLoadOlder: x,
|
|
9
|
+
hasMore: g,
|
|
10
10
|
isLoading: u,
|
|
11
|
-
loader:
|
|
12
|
-
autoScrollThreshold:
|
|
13
|
-
loadThreshold:
|
|
14
|
-
onAtBottomChange:
|
|
15
|
-
behavior:
|
|
16
|
-
className:
|
|
17
|
-
viewportClassName:
|
|
18
|
-
...
|
|
19
|
-
},
|
|
20
|
-
const
|
|
11
|
+
loader: R,
|
|
12
|
+
autoScrollThreshold: f = 120,
|
|
13
|
+
loadThreshold: v = 50,
|
|
14
|
+
onAtBottomChange: w,
|
|
15
|
+
behavior: b = "instant",
|
|
16
|
+
className: y,
|
|
17
|
+
viewportClassName: I,
|
|
18
|
+
...N
|
|
19
|
+
}, L) => {
|
|
20
|
+
const n = p(null), h = p(null), e = p({
|
|
21
21
|
previousScrollHeight: 0,
|
|
22
22
|
previousScrollTop: 0,
|
|
23
23
|
isAtBottom: !0,
|
|
24
24
|
isLoadingOlder: !1
|
|
25
|
-
}), [
|
|
25
|
+
}), [G, H] = D(!0);
|
|
26
26
|
a(() => {
|
|
27
|
-
|
|
27
|
+
e.current.isLoadingOlder = u;
|
|
28
28
|
}, [u]);
|
|
29
|
-
const
|
|
30
|
-
const { scrollTop:
|
|
31
|
-
return
|
|
32
|
-
},
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
top:
|
|
38
|
-
behavior: t ||
|
|
39
|
-
}),
|
|
29
|
+
const O = (t) => {
|
|
30
|
+
const { scrollTop: r, scrollHeight: o, clientHeight: c } = t;
|
|
31
|
+
return o - c - r <= f;
|
|
32
|
+
}, S = (t) => {
|
|
33
|
+
const r = n.current;
|
|
34
|
+
if (!r) return;
|
|
35
|
+
const o = r.scrollHeight - r.clientHeight;
|
|
36
|
+
r.scrollTo({
|
|
37
|
+
top: o,
|
|
38
|
+
behavior: t || b
|
|
39
|
+
}), e.current.isAtBottom = !0, d(!0);
|
|
40
40
|
}, d = (t) => {
|
|
41
|
-
|
|
41
|
+
e.current.isAtBottom !== t && (e.current.isAtBottom = t, H(t), w?.(t));
|
|
42
42
|
};
|
|
43
|
-
|
|
44
|
-
scrollToBottom: (t) =>
|
|
45
|
-
getHTMLElement: () =>
|
|
46
|
-
isAtBottom: () =>
|
|
43
|
+
q(L, () => ({
|
|
44
|
+
scrollToBottom: (t) => S(t),
|
|
45
|
+
getHTMLElement: () => n.current,
|
|
46
|
+
isAtBottom: () => e.current.isAtBottom
|
|
47
47
|
}));
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
d(
|
|
48
|
+
const j = (t) => {
|
|
49
|
+
const r = t.currentTarget, { scrollTop: o, scrollHeight: c } = r;
|
|
50
|
+
e.current.previousScrollTop = o, e.current.previousScrollHeight = c;
|
|
51
|
+
const l = O(r);
|
|
52
|
+
d(l), o <= v && g && !e.current.isLoadingOlder && (e.current.isLoadingOlder = !0, x());
|
|
53
53
|
};
|
|
54
|
-
return
|
|
55
|
-
const t =
|
|
56
|
-
t && (
|
|
57
|
-
}),
|
|
58
|
-
const t =
|
|
54
|
+
return T(() => {
|
|
55
|
+
const t = n.current;
|
|
56
|
+
t && (e.current.previousScrollHeight = t.scrollHeight, e.current.previousScrollTop = t.scrollTop);
|
|
57
|
+
}), T(() => {
|
|
58
|
+
const t = n.current;
|
|
59
59
|
if (!t) return;
|
|
60
|
-
const { previousScrollHeight:
|
|
61
|
-
s > 0 &&
|
|
60
|
+
const { previousScrollHeight: r, previousScrollTop: o, isAtBottom: c } = e.current, l = t.scrollHeight, s = l - r;
|
|
61
|
+
s > 0 && o <= v + 10 ? t.scrollTop = o + s : c && (t.scrollTop = l - t.clientHeight);
|
|
62
62
|
}, [m]), a(() => {
|
|
63
|
-
const t =
|
|
64
|
-
if (!t || !
|
|
65
|
-
const
|
|
66
|
-
const {
|
|
67
|
-
|
|
63
|
+
const t = n.current, r = h.current;
|
|
64
|
+
if (!t || !r) return;
|
|
65
|
+
const o = new ResizeObserver(() => {
|
|
66
|
+
const { previousScrollHeight: c, previousScrollTop: l, isAtBottom: s } = e.current, E = c - t.clientHeight - l <= f;
|
|
67
|
+
if (s || E) {
|
|
68
|
+
const B = t.scrollHeight - t.clientHeight;
|
|
69
|
+
t.scrollTop = B, e.current.previousScrollHeight = t.scrollHeight, e.current.previousScrollTop = B, e.current.isAtBottom = !0, H(!0);
|
|
70
|
+
}
|
|
68
71
|
});
|
|
69
|
-
return
|
|
70
|
-
}, []), a(() => {
|
|
71
|
-
|
|
72
|
+
return o.observe(r), () => o.disconnect();
|
|
73
|
+
}, [f]), a(() => {
|
|
74
|
+
S("instant");
|
|
72
75
|
}, []), /* @__PURE__ */ i(
|
|
73
76
|
"div",
|
|
74
77
|
{
|
|
75
|
-
ref:
|
|
76
|
-
onScroll:
|
|
77
|
-
className:
|
|
78
|
+
ref: n,
|
|
79
|
+
onScroll: j,
|
|
80
|
+
className: A(
|
|
78
81
|
"flex flex-col overflow-y-auto h-full w-full outline-none",
|
|
79
|
-
|
|
82
|
+
I
|
|
80
83
|
),
|
|
81
84
|
style: {
|
|
82
85
|
overflowAnchor: "none"
|
|
83
86
|
// Override browser anchoring to allow custom precision offsets
|
|
84
87
|
},
|
|
85
|
-
...
|
|
86
|
-
children: /* @__PURE__ */
|
|
88
|
+
...N,
|
|
89
|
+
children: /* @__PURE__ */ k(
|
|
87
90
|
"div",
|
|
88
91
|
{
|
|
89
92
|
ref: h,
|
|
90
|
-
className:
|
|
93
|
+
className: A("flex flex-col w-full", y),
|
|
91
94
|
children: [
|
|
92
|
-
|
|
95
|
+
g && /* @__PURE__ */ i("div", { className: "flex w-full items-center justify-center py-4 min-h-[48px]", children: u ? R || /* @__PURE__ */ i(C, { variant: "material-morph-background" }) : /* @__PURE__ */ i("div", { className: "h-px bg-transparent w-full" }) }),
|
|
93
96
|
m
|
|
94
97
|
]
|
|
95
98
|
}
|
|
@@ -98,7 +101,7 @@ const q = E(
|
|
|
98
101
|
);
|
|
99
102
|
}
|
|
100
103
|
);
|
|
101
|
-
|
|
104
|
+
F.displayName = "ReverseInfiniteScroll";
|
|
102
105
|
export {
|
|
103
|
-
|
|
106
|
+
F as ReverseInfiniteScroll
|
|
104
107
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chesai-ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.17",
|
|
5
|
+
"packageManager": "pnpm@10.12.1",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
8
|
"url": "https://github.com/ayhamdev/chesai-ui"
|
|
@@ -24,6 +25,19 @@
|
|
|
24
25
|
"engines": {
|
|
25
26
|
"node": ">=22"
|
|
26
27
|
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"dev": "bunx storybook dev -p 8000",
|
|
30
|
+
"build": "storybook build",
|
|
31
|
+
"build:lib": "tsc && vite build",
|
|
32
|
+
"build:docs": "npx ts-node ./scripts/generate-llm.ts",
|
|
33
|
+
"lint": "npx @biomejs/biome lint --write ./src",
|
|
34
|
+
"format": "npx @biomejs/biome check --write --organize-imports-enabled=true ./src",
|
|
35
|
+
"test": "vitest",
|
|
36
|
+
"test:cov": "vitest run --coverage",
|
|
37
|
+
"gen:context": "bun run ./scripts/context.ts",
|
|
38
|
+
"git:diff-merge": "git diff --unified=2000 $(git merge-base main HEAD)...HEAD",
|
|
39
|
+
"git:diff": "git diff --unified=2000 > git-changes.txt"
|
|
40
|
+
},
|
|
27
41
|
"dependencies": {
|
|
28
42
|
"@capacitor/app": "^8.0.0",
|
|
29
43
|
"@capacitor/core": "^8.0.1",
|
|
@@ -155,18 +169,5 @@
|
|
|
155
169
|
"biome lint --write --no-errors-on-unmatched --files-ignore-unknown=true",
|
|
156
170
|
"biome format --write --no-errors-on-unmatched"
|
|
157
171
|
]
|
|
158
|
-
},
|
|
159
|
-
"scripts": {
|
|
160
|
-
"dev": "bunx storybook dev -p 8000",
|
|
161
|
-
"build": "storybook build",
|
|
162
|
-
"build:lib": "tsc && vite build",
|
|
163
|
-
"build:docs": "npx ts-node ./scripts/generate-llm.ts",
|
|
164
|
-
"lint": "npx @biomejs/biome lint --write ./src",
|
|
165
|
-
"format": "npx @biomejs/biome check --write --organize-imports-enabled=true ./src",
|
|
166
|
-
"test": "vitest",
|
|
167
|
-
"test:cov": "vitest run --coverage",
|
|
168
|
-
"gen:context": "bun run ./scripts/context.ts",
|
|
169
|
-
"git:diff-merge": "git diff --unified=2000 $(git merge-base main HEAD)...HEAD",
|
|
170
|
-
"git:diff": "git diff --unified=2000 > git-changes.txt"
|
|
171
172
|
}
|
|
172
|
-
}
|
|
173
|
+
}
|