@chatbotkit/react 0.5.0 → 0.7.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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @chatbotkit/react
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- - Refactored project scripts.
|
|
8
|
+
- Introduced a new usage method.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @chatbotkit/sdk@0.14.0
|
|
14
|
+
|
|
15
|
+
## 0.6.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- Added auto-scrolling component.
|
|
20
|
+
|
|
3
21
|
## 0.5.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.AutoScrollAnchor = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
function AutoScrollAnchor() {
|
|
29
|
+
return react_1.default.createElement("div", { className: "auto-scroll-anchor ![height:1px]" });
|
|
30
|
+
}
|
|
31
|
+
exports.AutoScrollAnchor = AutoScrollAnchor;
|
|
32
|
+
/**
|
|
33
|
+
* @param {{
|
|
34
|
+
* anchor?: 'top'|'bottom',
|
|
35
|
+
* childList?: boolean,
|
|
36
|
+
* subtree?: boolean,
|
|
37
|
+
* block?: 'start'|'end',
|
|
38
|
+
* delay?: number,
|
|
39
|
+
* [name: string]: any
|
|
40
|
+
* }} props
|
|
41
|
+
*/
|
|
42
|
+
function AutoScroller({ anchor = 'bottom', childList = true, subtree = false, block = 'end', delay = 3000, disabled, children, ...props }) {
|
|
43
|
+
const rootRef = (0, react_1.useRef)();
|
|
44
|
+
(0, react_1.useEffect)(() => {
|
|
45
|
+
if (disabled) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
let visible = false;
|
|
49
|
+
let pause = false;
|
|
50
|
+
let timeout = 0;
|
|
51
|
+
const io = new IntersectionObserver((entries) => {
|
|
52
|
+
if (pause) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
visible = entries.some((entry) => entry.isIntersecting);
|
|
56
|
+
});
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
io.observe(rootRef.current?.querySelector('.auto-scroll-anchor'));
|
|
59
|
+
const mo = new MutationObserver(() => {
|
|
60
|
+
if (!visible) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
pause = true;
|
|
64
|
+
rootRef.current
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
?.querySelector('.auto-scroll-anchor')
|
|
67
|
+
?.scrollIntoView({ behavior: 'smooth', block });
|
|
68
|
+
clearTimeout(timeout);
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
timeout = setTimeout(() => {
|
|
71
|
+
visible = true;
|
|
72
|
+
pause = false;
|
|
73
|
+
}, delay);
|
|
74
|
+
});
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
mo.observe(rootRef.current, { childList, subtree });
|
|
77
|
+
return () => {
|
|
78
|
+
io.disconnect();
|
|
79
|
+
mo.disconnect();
|
|
80
|
+
};
|
|
81
|
+
}, [disabled]);
|
|
82
|
+
return (
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
react_1.default.createElement("div", { ref: rootRef, ...props },
|
|
85
|
+
anchor === 'top' ? react_1.default.createElement(AutoScrollAnchor, { key: "top" }) : null,
|
|
86
|
+
children,
|
|
87
|
+
anchor === 'bottom' ? react_1.default.createElement(AutoScrollAnchor, { key: "bottom" }) : null));
|
|
88
|
+
}
|
|
89
|
+
exports.default = AutoScroller;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function AutoScrollAnchor(): React.JSX.Element;
|
|
2
|
+
/**
|
|
3
|
+
* @param {{
|
|
4
|
+
* anchor?: 'top'|'bottom',
|
|
5
|
+
* childList?: boolean,
|
|
6
|
+
* subtree?: boolean,
|
|
7
|
+
* block?: 'start'|'end',
|
|
8
|
+
* delay?: number,
|
|
9
|
+
* [name: string]: any
|
|
10
|
+
* }} props
|
|
11
|
+
*/
|
|
12
|
+
export default function AutoScroller({ anchor, childList, subtree, block, delay, disabled, children, ...props }: {
|
|
13
|
+
[name: string]: any;
|
|
14
|
+
anchor?: "top" | "bottom" | undefined;
|
|
15
|
+
childList?: boolean | undefined;
|
|
16
|
+
subtree?: boolean | undefined;
|
|
17
|
+
block?: "end" | "start" | undefined;
|
|
18
|
+
delay?: number | undefined;
|
|
19
|
+
}): React.JSX.Element;
|
|
20
|
+
import React from 'react';
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as AutoTextarea } from "./components/AutoTextarea.
|
|
2
|
-
export { default as useConversationManager } from "./hooks/useConversationManager.
|
|
1
|
+
export { default as AutoTextarea } from "./components/AutoTextarea.js";
|
|
2
|
+
export { default as useConversationManager } from "./hooks/useConversationManager.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function AutoScrollAnchor(): React.JSX.Element;
|
|
2
|
+
/**
|
|
3
|
+
* @param {{
|
|
4
|
+
* anchor?: 'top'|'bottom',
|
|
5
|
+
* childList?: boolean,
|
|
6
|
+
* subtree?: boolean,
|
|
7
|
+
* block?: 'start'|'end',
|
|
8
|
+
* delay?: number,
|
|
9
|
+
* [name: string]: any
|
|
10
|
+
* }} props
|
|
11
|
+
*/
|
|
12
|
+
export default function AutoScroller({ anchor, childList, subtree, block, delay, disabled, children, ...props }: {
|
|
13
|
+
[name: string]: any;
|
|
14
|
+
anchor?: "top" | "bottom" | undefined;
|
|
15
|
+
childList?: boolean | undefined;
|
|
16
|
+
subtree?: boolean | undefined;
|
|
17
|
+
block?: "end" | "start" | undefined;
|
|
18
|
+
delay?: number | undefined;
|
|
19
|
+
}): React.JSX.Element;
|
|
20
|
+
import React from 'react';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
export function AutoScrollAnchor() {
|
|
3
|
+
return React.createElement("div", { className: "auto-scroll-anchor ![height:1px]" });
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* @param {{
|
|
7
|
+
* anchor?: 'top'|'bottom',
|
|
8
|
+
* childList?: boolean,
|
|
9
|
+
* subtree?: boolean,
|
|
10
|
+
* block?: 'start'|'end',
|
|
11
|
+
* delay?: number,
|
|
12
|
+
* [name: string]: any
|
|
13
|
+
* }} props
|
|
14
|
+
*/
|
|
15
|
+
export default function AutoScroller({ anchor = 'bottom', childList = true, subtree = false, block = 'end', delay = 3000, disabled, children, ...props }) {
|
|
16
|
+
const rootRef = useRef();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (disabled) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
let visible = false;
|
|
22
|
+
let pause = false;
|
|
23
|
+
let timeout = 0;
|
|
24
|
+
const io = new IntersectionObserver((entries) => {
|
|
25
|
+
if (pause) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
visible = entries.some((entry) => entry.isIntersecting);
|
|
29
|
+
});
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
io.observe(rootRef.current?.querySelector('.auto-scroll-anchor'));
|
|
32
|
+
const mo = new MutationObserver(() => {
|
|
33
|
+
if (!visible) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
pause = true;
|
|
37
|
+
rootRef.current
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
?.querySelector('.auto-scroll-anchor')
|
|
40
|
+
?.scrollIntoView({ behavior: 'smooth', block });
|
|
41
|
+
clearTimeout(timeout);
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
timeout = setTimeout(() => {
|
|
44
|
+
visible = true;
|
|
45
|
+
pause = false;
|
|
46
|
+
}, delay);
|
|
47
|
+
});
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
mo.observe(rootRef.current, { childList, subtree });
|
|
50
|
+
return () => {
|
|
51
|
+
io.disconnect();
|
|
52
|
+
mo.disconnect();
|
|
53
|
+
};
|
|
54
|
+
}, [disabled]);
|
|
55
|
+
return (
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
React.createElement("div", { ref: rootRef, ...props },
|
|
58
|
+
anchor === 'top' ? React.createElement(AutoScrollAnchor, { key: "top" }) : null,
|
|
59
|
+
children,
|
|
60
|
+
anchor === 'bottom' ? React.createElement(AutoScrollAnchor, { key: "bottom" }) : null));
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chatbotkit/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "The fastest way to build advanced AI chat bots",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": {
|
|
@@ -33,6 +33,16 @@
|
|
|
33
33
|
"default": "./dist/esm/index.js"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
+
"./components/AutoScroller.js": {
|
|
37
|
+
"require": {
|
|
38
|
+
"types": "./dist/cjs/components/AutoScroller.d.ts",
|
|
39
|
+
"default": "./dist/cjs/components/AutoScroller.cjs"
|
|
40
|
+
},
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/esm/components/AutoScroller.d.ts",
|
|
43
|
+
"default": "./dist/esm/components/AutoScroller.js"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
36
46
|
"./components/AutoTextarea.js": {
|
|
37
47
|
"require": {
|
|
38
48
|
"types": "./dist/cjs/components/AutoTextarea.d.ts",
|
|
@@ -77,11 +87,11 @@
|
|
|
77
87
|
"scripts": {
|
|
78
88
|
"build": "run-s build:*",
|
|
79
89
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
80
|
-
"build:cjs_rename": "
|
|
81
|
-
"build:cjs_rewrite_cjs": "
|
|
82
|
-
"build:cjs_rewrite_ts": "
|
|
90
|
+
"build:cjs_rename": "node ../../scripts/rename-cjs.js",
|
|
91
|
+
"build:cjs_rewrite_cjs": "node ../../scripts/rewrite-cjs.js",
|
|
92
|
+
"build:cjs_rewrite_ts": "node ../../scripts/rewrite-ts.js",
|
|
83
93
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
84
|
-
"build:exports": "node scripts/build-exports.js",
|
|
94
|
+
"build:exports": "node ../../scripts/build-exports.js",
|
|
85
95
|
"test": "true"
|
|
86
96
|
},
|
|
87
97
|
"types": "./dist/esm/index.d.ts",
|