@nucleux/message-scroller 0.0.0-stage → 0.6.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/LICENSE +21 -0
- package/README.md +25 -2
- package/dist/index.cjs +63 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nucleux
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nucleux/message-scroller
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Auto-scrolling chat transcript container — Nucleux agentic UI for React.
|
|
4
|
+
|
|
5
|
+
Part of **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** — agentic UI components for React. Install a single component, or the full kit via [`@nucleux/react`](https://www.npmjs.com/package/@nucleux/react).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @nucleux/message-scroller @nucleux/tokens
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`react` / `react-dom` are peer dependencies.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { MessageScroller } from "@nucleux/message-scroller";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Requires the theme once in your app: `import "@nucleux/tokens/styles.css";`
|
|
22
|
+
and the Tailwind preset from `@nucleux/tokens/preset`.
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
MIT © Nucleux
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var lucideReact = require('lucide-react');
|
|
6
|
+
var utils = require('@nucleux/utils');
|
|
7
|
+
var hooks = require('@nucleux/hooks');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
function _interopNamespace(e) {
|
|
11
|
+
if (e && e.__esModule) return e;
|
|
12
|
+
var n = Object.create(null);
|
|
13
|
+
if (e) {
|
|
14
|
+
Object.keys(e).forEach(function (k) {
|
|
15
|
+
if (k !== 'default') {
|
|
16
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return e[k]; }
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
|
+
|
|
30
|
+
// src/index.tsx
|
|
31
|
+
var MessageScroller = React__namespace.forwardRef(
|
|
32
|
+
({ autoScrollKey, hideScrollButton = false, className, children, ...props }, _ref) => {
|
|
33
|
+
const { ref, pinned, scrollToBottom } = hooks.useAutoScroll({
|
|
34
|
+
dependency: autoScrollKey
|
|
35
|
+
});
|
|
36
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex min-h-0 flex-1 flex-col", children: [
|
|
37
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
ref,
|
|
41
|
+
className: utils.cn("flex-1 space-y-4 overflow-y-auto scroll-smooth p-4", className),
|
|
42
|
+
...props,
|
|
43
|
+
children
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
!hideScrollButton && !pinned && /* @__PURE__ */ jsxRuntime.jsx(
|
|
47
|
+
"button",
|
|
48
|
+
{
|
|
49
|
+
type: "button",
|
|
50
|
+
onClick: () => scrollToBottom(),
|
|
51
|
+
"aria-label": "Scroll to latest",
|
|
52
|
+
className: "absolute bottom-4 left-1/2 -translate-x-1/2 inline-flex size-9 items-center justify-center rounded-full border border-border bg-background text-foreground shadow-md transition-transform hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring animate-nx-fade-in",
|
|
53
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDown, { className: "size-4" })
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
] });
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
MessageScroller.displayName = "MessageScroller";
|
|
60
|
+
|
|
61
|
+
exports.MessageScroller = MessageScroller;
|
|
62
|
+
//# sourceMappingURL=index.cjs.map
|
|
63
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["React","useAutoScroll","jsxs","jsx","cn","ArrowDown"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBO,IAAM,eAAA,GAAwBA,gBAAA,CAAA,UAAA;AAAA,EACnC,CAAC,EAAE,aAAA,EAAe,gBAAA,GAAmB,KAAA,EAAO,WAAW,QAAA,EAAU,GAAG,KAAA,EAAM,EAAG,IAAA,KAAS;AACpF,IAAA,MAAM,EAAE,GAAA,EAAK,MAAA,EAAQ,cAAA,KAAmBC,mBAAA,CAA8B;AAAA,MACpE,UAAA,EAAY;AAAA,KACb,CAAA;AAED,IAAA,uBACEC,eAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,uCAAA,EACb,QAAA,EAAA;AAAA,sBAAAC,cAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,GAAA;AAAA,UACA,SAAA,EAAWC,QAAA,CAAG,oDAAA,EAAsD,SAAS,CAAA;AAAA,UAC5E,GAAG,KAAA;AAAA,UAEH;AAAA;AAAA,OACH;AAAA,MACC,CAAC,gBAAA,IAAoB,CAAC,MAAA,oBACrBD,cAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,QAAA;AAAA,UACL,OAAA,EAAS,MAAM,cAAA,EAAe;AAAA,UAC9B,YAAA,EAAW,kBAAA;AAAA,UACX,SAAA,EAAU,sSAAA;AAAA,UAEV,QAAA,kBAAAA,cAAA,CAACE,qBAAA,EAAA,EAAU,SAAA,EAAU,QAAA,EAAS;AAAA;AAAA;AAChC,KAAA,EAEJ,CAAA;AAAA,EAEJ;AACF;AACA,eAAA,CAAgB,WAAA,GAAc,iBAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { ArrowDown } from \"lucide-react\";\nimport { cn } from \"@nucleux/utils\";\nimport { useAutoScroll } from \"@nucleux/hooks\";\n\nexport interface MessageScrollerProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Change this whenever messages are added so the view re-pins to bottom. */\n autoScrollKey?: unknown;\n /** Disable the sticky \"scroll to bottom\" affordance. */\n hideScrollButton?: boolean;\n}\n\n/**\n * Scrollable transcript container that keeps itself pinned to the newest\n * message while content streams, and surfaces a \"jump to latest\" button when\n * the user scrolls away.\n */\nexport const MessageScroller = React.forwardRef<HTMLDivElement, MessageScrollerProps>(\n ({ autoScrollKey, hideScrollButton = false, className, children, ...props }, _ref) => {\n const { ref, pinned, scrollToBottom } = useAutoScroll<HTMLDivElement>({\n dependency: autoScrollKey,\n });\n\n return (\n <div className=\"relative flex min-h-0 flex-1 flex-col\">\n <div\n ref={ref}\n className={cn(\"flex-1 space-y-4 overflow-y-auto scroll-smooth p-4\", className)}\n {...props}\n >\n {children}\n </div>\n {!hideScrollButton && !pinned && (\n <button\n type=\"button\"\n onClick={() => scrollToBottom()}\n aria-label=\"Scroll to latest\"\n className=\"absolute bottom-4 left-1/2 -translate-x-1/2 inline-flex size-9 items-center justify-center rounded-full border border-border bg-background text-foreground shadow-md transition-transform hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring animate-nx-fade-in\"\n >\n <ArrowDown className=\"size-4\" />\n </button>\n )}\n </div>\n );\n },\n);\nMessageScroller.displayName = \"MessageScroller\";\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface MessageScrollerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** Change this whenever messages are added so the view re-pins to bottom. */
|
|
5
|
+
autoScrollKey?: unknown;
|
|
6
|
+
/** Disable the sticky "scroll to bottom" affordance. */
|
|
7
|
+
hideScrollButton?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Scrollable transcript container that keeps itself pinned to the newest
|
|
11
|
+
* message while content streams, and surfaces a "jump to latest" button when
|
|
12
|
+
* the user scrolls away.
|
|
13
|
+
*/
|
|
14
|
+
declare const MessageScroller: React.ForwardRefExoticComponent<MessageScrollerProps & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
+
|
|
16
|
+
export { MessageScroller, type MessageScrollerProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface MessageScrollerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** Change this whenever messages are added so the view re-pins to bottom. */
|
|
5
|
+
autoScrollKey?: unknown;
|
|
6
|
+
/** Disable the sticky "scroll to bottom" affordance. */
|
|
7
|
+
hideScrollButton?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Scrollable transcript container that keeps itself pinned to the newest
|
|
11
|
+
* message while content streams, and surfaces a "jump to latest" button when
|
|
12
|
+
* the user scrolls away.
|
|
13
|
+
*/
|
|
14
|
+
declare const MessageScroller: React.ForwardRefExoticComponent<MessageScrollerProps & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
+
|
|
16
|
+
export { MessageScroller, type MessageScrollerProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ArrowDown } from 'lucide-react';
|
|
4
|
+
import { cn } from '@nucleux/utils';
|
|
5
|
+
import { useAutoScroll } from '@nucleux/hooks';
|
|
6
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
// src/index.tsx
|
|
9
|
+
var MessageScroller = React.forwardRef(
|
|
10
|
+
({ autoScrollKey, hideScrollButton = false, className, children, ...props }, _ref) => {
|
|
11
|
+
const { ref, pinned, scrollToBottom } = useAutoScroll({
|
|
12
|
+
dependency: autoScrollKey
|
|
13
|
+
});
|
|
14
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative flex min-h-0 flex-1 flex-col", children: [
|
|
15
|
+
/* @__PURE__ */ jsx(
|
|
16
|
+
"div",
|
|
17
|
+
{
|
|
18
|
+
ref,
|
|
19
|
+
className: cn("flex-1 space-y-4 overflow-y-auto scroll-smooth p-4", className),
|
|
20
|
+
...props,
|
|
21
|
+
children
|
|
22
|
+
}
|
|
23
|
+
),
|
|
24
|
+
!hideScrollButton && !pinned && /* @__PURE__ */ jsx(
|
|
25
|
+
"button",
|
|
26
|
+
{
|
|
27
|
+
type: "button",
|
|
28
|
+
onClick: () => scrollToBottom(),
|
|
29
|
+
"aria-label": "Scroll to latest",
|
|
30
|
+
className: "absolute bottom-4 left-1/2 -translate-x-1/2 inline-flex size-9 items-center justify-center rounded-full border border-border bg-background text-foreground shadow-md transition-transform hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring animate-nx-fade-in",
|
|
31
|
+
children: /* @__PURE__ */ jsx(ArrowDown, { className: "size-4" })
|
|
32
|
+
}
|
|
33
|
+
)
|
|
34
|
+
] });
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
MessageScroller.displayName = "MessageScroller";
|
|
38
|
+
|
|
39
|
+
export { MessageScroller };
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;;AAiBO,IAAM,eAAA,GAAwB,KAAA,CAAA,UAAA;AAAA,EACnC,CAAC,EAAE,aAAA,EAAe,gBAAA,GAAmB,KAAA,EAAO,WAAW,QAAA,EAAU,GAAG,KAAA,EAAM,EAAG,IAAA,KAAS;AACpF,IAAA,MAAM,EAAE,GAAA,EAAK,MAAA,EAAQ,cAAA,KAAmB,aAAA,CAA8B;AAAA,MACpE,UAAA,EAAY;AAAA,KACb,CAAA;AAED,IAAA,uBACE,IAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,uCAAA,EACb,QAAA,EAAA;AAAA,sBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,GAAA;AAAA,UACA,SAAA,EAAW,EAAA,CAAG,oDAAA,EAAsD,SAAS,CAAA;AAAA,UAC5E,GAAG,KAAA;AAAA,UAEH;AAAA;AAAA,OACH;AAAA,MACC,CAAC,gBAAA,IAAoB,CAAC,MAAA,oBACrB,GAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,IAAA,EAAK,QAAA;AAAA,UACL,OAAA,EAAS,MAAM,cAAA,EAAe;AAAA,UAC9B,YAAA,EAAW,kBAAA;AAAA,UACX,SAAA,EAAU,sSAAA;AAAA,UAEV,QAAA,kBAAA,GAAA,CAAC,SAAA,EAAA,EAAU,SAAA,EAAU,QAAA,EAAS;AAAA;AAAA;AAChC,KAAA,EAEJ,CAAA;AAAA,EAEJ;AACF;AACA,eAAA,CAAgB,WAAA,GAAc,iBAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { ArrowDown } from \"lucide-react\";\nimport { cn } from \"@nucleux/utils\";\nimport { useAutoScroll } from \"@nucleux/hooks\";\n\nexport interface MessageScrollerProps extends React.HTMLAttributes<HTMLDivElement> {\n /** Change this whenever messages are added so the view re-pins to bottom. */\n autoScrollKey?: unknown;\n /** Disable the sticky \"scroll to bottom\" affordance. */\n hideScrollButton?: boolean;\n}\n\n/**\n * Scrollable transcript container that keeps itself pinned to the newest\n * message while content streams, and surfaces a \"jump to latest\" button when\n * the user scrolls away.\n */\nexport const MessageScroller = React.forwardRef<HTMLDivElement, MessageScrollerProps>(\n ({ autoScrollKey, hideScrollButton = false, className, children, ...props }, _ref) => {\n const { ref, pinned, scrollToBottom } = useAutoScroll<HTMLDivElement>({\n dependency: autoScrollKey,\n });\n\n return (\n <div className=\"relative flex min-h-0 flex-1 flex-col\">\n <div\n ref={ref}\n className={cn(\"flex-1 space-y-4 overflow-y-auto scroll-smooth p-4\", className)}\n {...props}\n >\n {children}\n </div>\n {!hideScrollButton && !pinned && (\n <button\n type=\"button\"\n onClick={() => scrollToBottom()}\n aria-label=\"Scroll to latest\"\n className=\"absolute bottom-4 left-1/2 -translate-x-1/2 inline-flex size-9 items-center justify-center rounded-full border border-border bg-background text-foreground shadow-md transition-transform hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring animate-nx-fade-in\"\n >\n <ArrowDown className=\"size-4\" />\n </button>\n )}\n </div>\n );\n },\n);\nMessageScroller.displayName = \"MessageScroller\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nucleux/message-scroller",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": ">=18",
|
|
22
|
+
"react-dom": ">=18"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@nucleux/hooks": "0.6.0",
|
|
26
|
+
"@nucleux/utils": "0.6.0",
|
|
27
|
+
"lucide-react": "^0.469.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"tsup": "^8.3.5",
|
|
31
|
+
"typescript": "^5.7.2",
|
|
32
|
+
"@types/react": "^18.3.18",
|
|
33
|
+
"react": "^18.3.1"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/intelligaia-open-labs/nucleux.git",
|
|
42
|
+
"directory": "packages/message-scroller"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
|
|
45
|
+
"description": "Auto-scrolling message list container — Nucleux agentic UI for React.",
|
|
46
|
+
"keywords": [
|
|
47
|
+
"nucleux",
|
|
48
|
+
"react",
|
|
49
|
+
"ui",
|
|
50
|
+
"components",
|
|
51
|
+
"agentic",
|
|
52
|
+
"ai",
|
|
53
|
+
"tailwind",
|
|
54
|
+
"message-scroller"
|
|
55
|
+
],
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup"
|
|
58
|
+
}
|
|
6
59
|
}
|