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 j } from "react/jsx-runtime";
2
- import { forwardRef as E, useRef as f, useState as k, useEffect as a, useImperativeHandle as z, useLayoutEffect as H } from "react";
3
- import { clsx as T } from "clsx";
4
- import { LoadingIndicator as D } from "../loadingIndicator/index.mjs";
5
- const q = E(
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: B,
9
- hasMore: p,
8
+ onLoadOlder: x,
9
+ hasMore: g,
10
10
  isLoading: u,
11
- loader: S,
12
- autoScrollThreshold: A = 120,
13
- loadThreshold: g = 50,
14
- onAtBottomChange: x,
15
- behavior: R = "instant",
16
- className: b,
17
- viewportClassName: y,
18
- ...I
19
- }, w) => {
20
- const c = f(null), h = f(null), o = f({
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
- }), [C, L] = k(!0);
25
+ }), [G, H] = D(!0);
26
26
  a(() => {
27
- o.current.isLoadingOlder = u;
27
+ e.current.isLoadingOlder = u;
28
28
  }, [u]);
29
- const N = (t) => {
30
- const { scrollTop: e, scrollHeight: r, clientHeight: l } = t;
31
- return r - l - e <= A;
32
- }, v = (t) => {
33
- const e = c.current;
34
- if (!e) return;
35
- const r = e.scrollHeight - e.clientHeight;
36
- e.scrollTo({
37
- top: r,
38
- behavior: t || R
39
- }), o.current.isAtBottom = !0, d(!0);
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
- o.current.isAtBottom !== t && (o.current.isAtBottom = t, L(t), x?.(t));
41
+ e.current.isAtBottom !== t && (e.current.isAtBottom = t, H(t), w?.(t));
42
42
  };
43
- z(w, () => ({
44
- scrollToBottom: (t) => v(t),
45
- getHTMLElement: () => c.current,
46
- isAtBottom: () => o.current.isAtBottom
43
+ q(L, () => ({
44
+ scrollToBottom: (t) => S(t),
45
+ getHTMLElement: () => n.current,
46
+ isAtBottom: () => e.current.isAtBottom
47
47
  }));
48
- const O = (t) => {
49
- const e = t.currentTarget, { scrollTop: r, scrollHeight: l, clientHeight: n } = e;
50
- o.current.previousScrollTop = r;
51
- const s = N(e);
52
- d(s), r <= g && p && !o.current.isLoadingOlder && (o.current.isLoadingOlder = !0, B());
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 H(() => {
55
- const t = c.current;
56
- t && (o.current.previousScrollHeight = t.scrollHeight, o.current.previousScrollTop = t.scrollTop);
57
- }), H(() => {
58
- const t = c.current;
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: e, previousScrollTop: r, isAtBottom: l } = o.current, n = t.scrollHeight, s = n - e;
61
- s > 0 && r <= g + 10 ? t.scrollTop = r + s : l && (t.scrollTop = n - t.clientHeight);
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 = c.current, e = h.current;
64
- if (!t || !e) return;
65
- const r = new ResizeObserver(() => {
66
- const { isAtBottom: l } = o.current;
67
- l && (t.scrollTop = t.scrollHeight - t.clientHeight);
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 r.observe(e), () => r.disconnect();
70
- }, []), a(() => {
71
- v("instant");
72
+ return o.observe(r), () => o.disconnect();
73
+ }, [f]), a(() => {
74
+ S("instant");
72
75
  }, []), /* @__PURE__ */ i(
73
76
  "div",
74
77
  {
75
- ref: c,
76
- onScroll: O,
77
- className: T(
78
+ ref: n,
79
+ onScroll: j,
80
+ className: A(
78
81
  "flex flex-col overflow-y-auto h-full w-full outline-none",
79
- y
82
+ I
80
83
  ),
81
84
  style: {
82
85
  overflowAnchor: "none"
83
86
  // Override browser anchoring to allow custom precision offsets
84
87
  },
85
- ...I,
86
- children: /* @__PURE__ */ j(
88
+ ...N,
89
+ children: /* @__PURE__ */ k(
87
90
  "div",
88
91
  {
89
92
  ref: h,
90
- className: T("flex flex-col w-full", b),
93
+ className: A("flex flex-col w-full", y),
91
94
  children: [
92
- p && /* @__PURE__ */ i("div", { className: "flex w-full items-center justify-center py-4 min-h-[48px]", children: u ? S || /* @__PURE__ */ i(D, { variant: "material-morph-background" }) : /* @__PURE__ */ i("div", { className: "h-px bg-transparent w-full" }) }),
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
- q.displayName = "ReverseInfiniteScroll";
104
+ F.displayName = "ReverseInfiniteScroll";
102
105
  export {
103
- q as ReverseInfiniteScroll
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.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
+ }