@superinterface/react 1.0.1 → 1.0.3
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/components/messages/Form/index.js +22 -4
- package/dist/components/messages/Form/index.js.map +1 -1
- package/dist/components/spinners/Spinner/index.d.ts +0 -1
- package/dist/components/textareas/TextareaBase/index.d.ts +0 -1
- package/dist/hooks/misc/useInfiniteScroll/index.d.ts +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,15 +4,16 @@ exports.Form = exports.schema = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const themes_1 = require("@radix-ui/themes");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
const Submit_1 = require("./Submit");
|
|
8
|
-
const useIsRunActive_1 = require("../../../hooks/runs/useIsRunActive");
|
|
9
7
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
8
|
const zod_1 = require("zod");
|
|
11
9
|
const zod_2 = require("@hookform/resolvers/zod");
|
|
10
|
+
const react_use_1 = require("react-use");
|
|
11
|
+
const useIsRunActive_1 = require("../../../hooks/runs/useIsRunActive");
|
|
12
12
|
const TextareaBase_1 = require("../../textareas/TextareaBase");
|
|
13
13
|
const useLatestMessage_1 = require("../../../hooks/messages/useLatestMessage");
|
|
14
14
|
const useCreateMessage_1 = require("../../../hooks/messages/useCreateMessage");
|
|
15
15
|
const AssistantNameContext_1 = require("../../../contexts/assistants/AssistantNameContext");
|
|
16
|
+
const Submit_1 = require("./Submit");
|
|
16
17
|
exports.schema = zod_1.z.object({
|
|
17
18
|
content: zod_1.z.string().min(1).max(300),
|
|
18
19
|
});
|
|
@@ -46,14 +47,31 @@ const Form = ({ messagesQueryOptions, runsQueryOptions, createMessageMutationOpt
|
|
|
46
47
|
return (
|
|
47
48
|
// @ts-ignore-next-line
|
|
48
49
|
(_a = latestMessage === null || latestMessage === void 0 ? void 0 : latestMessage.metadata) === null || _a === void 0 ? void 0 : _a.isBlocking);
|
|
49
|
-
}, [latestMessage]);
|
|
50
|
+
}, [latestMessage, isLoading]);
|
|
51
|
+
const isInputDisabled = (0, react_1.useMemo)(() => (isLoading || isDisabled || false), [isLoading, isDisabled]);
|
|
52
|
+
const isInputDisabledPrevious = (0, react_use_1.usePrevious)(isInputDisabled);
|
|
53
|
+
const textareaRef = (0, react_1.useRef)(null);
|
|
54
|
+
const textareaProps = register('content');
|
|
55
|
+
(0, react_1.useEffect)(() => {
|
|
56
|
+
if (isInputDisabled)
|
|
57
|
+
return;
|
|
58
|
+
if (!isInputDisabledPrevious)
|
|
59
|
+
return;
|
|
60
|
+
if (!textareaRef.current)
|
|
61
|
+
return;
|
|
62
|
+
textareaRef.current.focus();
|
|
63
|
+
}, [isInputDisabled, isInputDisabledPrevious, textareaProps]);
|
|
50
64
|
const assistantNameContext = (0, react_1.useContext)(AssistantNameContext_1.AssistantNameContext);
|
|
51
65
|
return ((0, jsx_runtime_1.jsx)(themes_1.Container, { size: "2", px: "2", grow: "0", children: (0, jsx_runtime_1.jsx)(themes_1.Flex, { direction: "column", shrink: "0", children: (0, jsx_runtime_1.jsx)(themes_1.Flex, { direction: "column", shrink: "0", className: "bg-gray-1", pb: "4", children: (0, jsx_runtime_1.jsx)("form", { onSubmit: handleSubmit(onSubmit), children: (0, jsx_runtime_1.jsxs)(themes_1.Flex, { className: `rounded-3 border-gray-5 border border-solid ${errors.content ? 'border-red-9 bg-red-2' : ''}`, p: "2", pl: "4", children: [(0, jsx_runtime_1.jsx)(themes_1.Text, { size: "2", className: "grow", children: (0, jsx_runtime_1.jsx)(themes_1.Flex, { grow: "1", direction: "column", children: (0, jsx_runtime_1.jsx)(TextareaBase_1.TextareaBase, { minRows: 1, placeholder: `Message ${assistantNameContext}...`, disabled: isLoading || isDisabled, onKeyDown: (e) => {
|
|
52
66
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
53
67
|
e.preventDefault();
|
|
54
68
|
handleSubmit(onSubmit)();
|
|
55
69
|
}
|
|
56
|
-
},
|
|
70
|
+
}, autoFocus: true, ...textareaProps, ref: (e) => {
|
|
71
|
+
textareaProps.ref(e);
|
|
72
|
+
// @ts-ignore-next-line
|
|
73
|
+
textareaRef.current = e;
|
|
74
|
+
} }) }) }), (0, jsx_runtime_1.jsx)(themes_1.Flex, { shrink: "0", align: "end", children: (0, jsx_runtime_1.jsx)(Submit_1.Submit, { isLoading: isLoading, isDisabled: isDisabled }) })] }) }) }) }) }));
|
|
57
75
|
};
|
|
58
76
|
exports.Form = Form;
|
|
59
77
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/messages/Form/index.tsx"],"names":[],"mappings":";;;;AAKA,6CAIyB;AACzB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/messages/Form/index.tsx"],"names":[],"mappings":";;;;AAKA,6CAIyB;AACzB,iCAA8D;AAC9D,qDAAwD;AACxD,6BAAuB;AACvB,iDAAqD;AACrD,yCAAuC;AACvC,gEAA4D;AAC5D,sEAAkE;AAClE,wEAAoE;AACpE,wEAAoE;AACpE,qFAAiF;AAEjF,qCAAiC;AAEpB,QAAA,MAAM,GAAG,OAAC,CAAC,MAAM,CAAC;IAC7B,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACpC,CAAC,CAAA;AAYK,MAAM,IAAI,GAAG,CAAC,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,4BAA4B,GACvB,EAAE,EAAE;IACT,MAAM,EACJ,QAAQ,EACR,YAAY,EACZ,SAAS,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,EACnC,KAAK,GACN,GAAG,IAAA,yBAAO,EAAS;QAClB,QAAQ,EAAE,IAAA,iBAAW,EA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,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAA;4CAC1B,CAAC;wCACH,CAAC,EACD,SAAS,WACL,aAAa,EACjB,GAAG,EAAE,CAAC,CAAM,EAAE,EAAE;4CACd,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;4CACpB,uBAAuB;4CACvB,WAAW,CAAC,OAAO,GAAG,CAAC,CAAA;wCACzB,CAAC,GACD,GACG,GACF,EAEP,uBAAC,aAAI,IACH,MAAM,EAAC,GAAG,EACV,KAAK,EAAC,KAAK,YAEX,uBAAC,eAAM,IACL,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,GACtB,GACG,IACF,GACF,GACF,GACF,GACG,CACb,CAAA;AACH,CAAC,CAAA;AAxIY,QAAA,IAAI,QAwIhB"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
2
|
export declare const TextareaBase: import("react").ForwardRefExoticComponent<Omit<import("react-textarea-autosize").TextareaAutosizeProps & import("react").RefAttributes<HTMLTextAreaElement>, "ref"> & import("react").RefAttributes<unknown>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { Messages } from './components/messages/Messages';
|
|
2
2
|
export { Form } from './components/messages/Form';
|
|
3
|
-
export { QueryClient, QueryClientProvider, useQueryClient, } from '@tanstack/react-query';
|
|
3
|
+
export { QueryClient, QueryClientProvider, useQueryClient, useQuery, } from '@tanstack/react-query';
|
|
4
4
|
export { useThreadLifecycles } from './hooks/threads/useThreadLifecycles';
|
|
5
5
|
export { useMessages } from './hooks/messages/useMessages';
|
|
6
6
|
export { useLatestMessage } from './hooks/messages/useLatestMessage';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useIsRunActive = exports.useCreateMessage = exports.useLatestMessage = exports.useMessages = exports.useThreadLifecycles = exports.useQueryClient = exports.QueryClientProvider = exports.QueryClient = exports.Form = exports.Messages = void 0;
|
|
3
|
+
exports.useIsRunActive = exports.useCreateMessage = exports.useLatestMessage = exports.useMessages = exports.useThreadLifecycles = exports.useQuery = exports.useQueryClient = exports.QueryClientProvider = exports.QueryClient = exports.Form = exports.Messages = void 0;
|
|
4
4
|
var Messages_1 = require("./components/messages/Messages");
|
|
5
5
|
Object.defineProperty(exports, "Messages", { enumerable: true, get: function () { return Messages_1.Messages; } });
|
|
6
6
|
var Form_1 = require("./components/messages/Form");
|
|
@@ -9,6 +9,7 @@ var react_query_1 = require("@tanstack/react-query");
|
|
|
9
9
|
Object.defineProperty(exports, "QueryClient", { enumerable: true, get: function () { return react_query_1.QueryClient; } });
|
|
10
10
|
Object.defineProperty(exports, "QueryClientProvider", { enumerable: true, get: function () { return react_query_1.QueryClientProvider; } });
|
|
11
11
|
Object.defineProperty(exports, "useQueryClient", { enumerable: true, get: function () { return react_query_1.useQueryClient; } });
|
|
12
|
+
Object.defineProperty(exports, "useQuery", { enumerable: true, get: function () { return react_query_1.useQuery; } });
|
|
12
13
|
var useThreadLifecycles_1 = require("./hooks/threads/useThreadLifecycles");
|
|
13
14
|
Object.defineProperty(exports, "useThreadLifecycles", { enumerable: true, get: function () { return useThreadLifecycles_1.useThreadLifecycles; } });
|
|
14
15
|
var useMessages_1 = require("./hooks/messages/useMessages");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAAhD,oGAAA,QAAQ,OAAA;AACjB,mDAAiD;AAAxC,4FAAA,IAAI,OAAA;AACb,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAyD;AAAhD,oGAAA,QAAQ,OAAA;AACjB,mDAAiD;AAAxC,4FAAA,IAAI,OAAA;AACb,qDAK8B;AAJ5B,0GAAA,WAAW,OAAA;AACX,kHAAA,mBAAmB,OAAA;AACnB,6GAAA,cAAc,OAAA;AACd,uGAAA,QAAQ,OAAA;AAEV,2EAAyE;AAAhE,0HAAA,mBAAmB,OAAA;AAC5B,4DAA0D;AAAjD,0GAAA,WAAW,OAAA;AACpB,sEAAoE;AAA3D,oHAAA,gBAAgB,OAAA;AACzB,sEAAoE;AAA3D,oHAAA,gBAAgB,OAAA;AACzB,8DAA4D;AAAnD,gHAAA,cAAc,OAAA"}
|