@copilotkit/react-textarea 0.27.0-alpha.2 → 0.27.0-alpha.4
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/.turbo/turbo-build.log +153 -154
- package/CHANGELOG.md +35 -6
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +1745 -35
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-element.mjs +51 -3
- package/dist/components/base-copilot-textarea/render-element.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +49 -3
- package/dist/components/base-copilot-textarea/render-placeholder.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +86 -4
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs.map +1 -1
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +57 -3
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs.map +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +2192 -47
- package/dist/components/copilot-textarea/copilot-textarea.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +17 -3
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +137 -3
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs.map +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +875 -18
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +558 -12
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +581 -13
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +102 -5
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs.map +1 -1
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +581 -14
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs.map +1 -1
- package/dist/components/index.mjs +2193 -48
- package/dist/components/index.mjs.map +1 -1
- package/dist/components/manual-ui/chip-with-icon.mjs +5 -6
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +211 -6
- package/dist/components/source-search-box/source-search-box.mjs.map +1 -1
- package/dist/components/ui/button.mjs +85 -4
- package/dist/components/ui/button.mjs.map +1 -1
- package/dist/components/ui/card.mjs +53 -7
- package/dist/components/ui/card.mjs.map +1 -1
- package/dist/components/ui/command.mjs +244 -5
- package/dist/components/ui/command.mjs.map +1 -1
- package/dist/components/ui/dialog.mjs +144 -4
- package/dist/components/ui/dialog.mjs.map +1 -1
- package/dist/components/ui/label.mjs +60 -4
- package/dist/components/ui/label.mjs.map +1 -1
- package/dist/components/ui/separator.mjs +50 -8
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/textarea.mjs +48 -7
- package/dist/components/ui/textarea.mjs.map +1 -1
- package/dist/context/index.mjs +0 -2
- package/dist/context/index.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +158 -6
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +168 -4
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +148 -5
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs.map +1 -1
- package/dist/hooks/index.mjs +0 -2
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +114 -14
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs.map +1 -1
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +166 -14
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs.map +1 -1
- package/dist/hooks/misc/use-autosize-textarea.mjs +15 -3
- package/dist/hooks/misc/use-autosize-textarea.mjs.map +1 -1
- package/dist/index.css +0 -3
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.mjs +2195 -50
- package/dist/index.mjs.map +1 -1
- package/dist/lib/debouncer.mjs +51 -3
- package/dist/lib/debouncer.mjs.map +1 -1
- package/dist/lib/editor-to-text.mjs +43 -3
- package/dist/lib/editor-to-text.mjs.map +1 -1
- package/dist/lib/get-text-around-cursor.mjs +102 -3
- package/dist/lib/get-text-around-cursor.mjs.map +1 -1
- package/dist/lib/retry.mjs +17 -3
- package/dist/lib/retry.mjs.map +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +25 -3
- package/dist/lib/slatejs-edits/add-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +20 -3
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs.map +1 -1
- package/dist/lib/slatejs-edits/replace-text.mjs +27 -3
- package/dist/lib/slatejs-edits/replace-text.mjs.map +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +106 -3
- package/dist/lib/slatejs-edits/with-partial-history.mjs.map +1 -1
- package/dist/lib/stream-promise-flatten.mjs +47 -3
- package/dist/lib/stream-promise-flatten.mjs.map +1 -1
- package/dist/lib/utils.mjs +71 -3
- package/dist/lib/utils.mjs.map +1 -1
- package/dist/lib/utils.test.mjs +0 -1
- package/dist/lib/utils.test.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs +0 -2
- package/dist/types/autosuggestions-config/autosuggestions-config-user-specified.mjs.map +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +274 -8
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/editing-api-config.mjs +87 -3
- package/dist/types/autosuggestions-config/editing-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/index.d.ts +0 -1
- package/dist/types/autosuggestions-config/index.mjs +274 -10
- package/dist/types/autosuggestions-config/index.mjs.map +1 -1
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +78 -3
- package/dist/types/autosuggestions-config/insertions-api-config.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs +0 -2
- package/dist/types/autosuggestions-config/subtypes/make-system-prompt.mjs.map +1 -1
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs +0 -2
- package/dist/types/autosuggestions-config/subtypes/minimal-chat-gpt-message.mjs.map +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +64 -3
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs.map +1 -1
- package/dist/types/base/autosuggestion-state.mjs +0 -2
- package/dist/types/base/autosuggestion-state.mjs.map +1 -1
- package/dist/types/base/autosuggestions-bare-function.mjs +0 -2
- package/dist/types/base/autosuggestions-bare-function.mjs.map +1 -1
- package/dist/types/base/base-autosuggestions-config.mjs +26 -3
- package/dist/types/base/base-autosuggestions-config.mjs.map +1 -1
- package/dist/types/base/base-copilot-textarea-props.mjs +0 -2
- package/dist/types/base/base-copilot-textarea-props.mjs.map +1 -1
- package/dist/types/base/custom-editor.mjs +0 -2
- package/dist/types/base/custom-editor.mjs.map +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +17 -4
- package/dist/types/base/editor-autocomplete-state.mjs.map +1 -1
- package/dist/types/base/index.mjs +26 -4
- package/dist/types/base/index.mjs.map +1 -1
- package/dist/types/html-copilot-textarea-element.mjs +0 -2
- package/dist/types/html-copilot-textarea-element.mjs.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.mjs +275 -12
- package/dist/types/index.mjs.map +1 -1
- package/package.json +3 -4
- package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +15 -9
- package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +22 -6
- package/src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx +1 -1
- package/src/types/autosuggestions-config/autosuggestions-config.tsx +0 -1
- package/src/types/autosuggestions-config/editing-api-config.tsx +22 -17
- package/src/types/autosuggestions-config/index.ts +0 -2
- package/src/types/autosuggestions-config/insertions-api-config.tsx +11 -6
- package/dist/chunk-224UKA7C.mjs +0 -33
- package/dist/chunk-224UKA7C.mjs.map +0 -1
- package/dist/chunk-22SLIB4K.mjs +0 -46
- package/dist/chunk-22SLIB4K.mjs.map +0 -1
- package/dist/chunk-2C7O2EVM.mjs +0 -27
- package/dist/chunk-2C7O2EVM.mjs.map +0 -1
- package/dist/chunk-2QDCE7PD.mjs +0 -29
- package/dist/chunk-2QDCE7PD.mjs.map +0 -1
- package/dist/chunk-3PQ7GSFE.mjs +0 -17
- package/dist/chunk-3PQ7GSFE.mjs.map +0 -1
- package/dist/chunk-47L4PLG4.mjs +0 -45
- package/dist/chunk-47L4PLG4.mjs.map +0 -1
- package/dist/chunk-4NHVQZ67.mjs +0 -107
- package/dist/chunk-4NHVQZ67.mjs.map +0 -1
- package/dist/chunk-5FO6ISW4.mjs +0 -3
- package/dist/chunk-5FO6ISW4.mjs.map +0 -1
- package/dist/chunk-5UNJXFUO.mjs +0 -29
- package/dist/chunk-5UNJXFUO.mjs.map +0 -1
- package/dist/chunk-5ZCVCVRZ.mjs +0 -19
- package/dist/chunk-5ZCVCVRZ.mjs.map +0 -1
- package/dist/chunk-6TZ6V3QI.mjs +0 -217
- package/dist/chunk-6TZ6V3QI.mjs.map +0 -1
- package/dist/chunk-72P3KOHZ.mjs +0 -91
- package/dist/chunk-72P3KOHZ.mjs.map +0 -1
- package/dist/chunk-7LSRNPNI.mjs +0 -59
- package/dist/chunk-7LSRNPNI.mjs.map +0 -1
- package/dist/chunk-7SUZ6CXM.mjs +0 -47
- package/dist/chunk-7SUZ6CXM.mjs.map +0 -1
- package/dist/chunk-COUN55HQ.mjs +0 -53
- package/dist/chunk-COUN55HQ.mjs.map +0 -1
- package/dist/chunk-DE5K76I2.mjs +0 -3
- package/dist/chunk-DE5K76I2.mjs.map +0 -1
- package/dist/chunk-DRV2FOHZ.mjs +0 -65
- package/dist/chunk-DRV2FOHZ.mjs.map +0 -1
- package/dist/chunk-ECR45NSD.mjs +0 -101
- package/dist/chunk-ECR45NSD.mjs.map +0 -1
- package/dist/chunk-EPBVNDKE.mjs +0 -46
- package/dist/chunk-EPBVNDKE.mjs.map +0 -1
- package/dist/chunk-FJNUPSQK.mjs +0 -72
- package/dist/chunk-FJNUPSQK.mjs.map +0 -1
- package/dist/chunk-FP2EKU3L.mjs +0 -28
- package/dist/chunk-FP2EKU3L.mjs.map +0 -1
- package/dist/chunk-GQN2HYFJ.mjs +0 -22
- package/dist/chunk-GQN2HYFJ.mjs.map +0 -1
- package/dist/chunk-H4VKQGVU.mjs +0 -3
- package/dist/chunk-H4VKQGVU.mjs.map +0 -1
- package/dist/chunk-HSCZA5TS.mjs +0 -27
- package/dist/chunk-HSCZA5TS.mjs.map +0 -1
- package/dist/chunk-IU3WTXLQ.mjs +0 -3
- package/dist/chunk-IU3WTXLQ.mjs.map +0 -1
- package/dist/chunk-JJLQVT7S.mjs +0 -10
- package/dist/chunk-JJLQVT7S.mjs.map +0 -1
- package/dist/chunk-K5LNB36H.mjs +0 -80
- package/dist/chunk-K5LNB36H.mjs.map +0 -1
- package/dist/chunk-KDVMG3XF.mjs +0 -63
- package/dist/chunk-KDVMG3XF.mjs.map +0 -1
- package/dist/chunk-KFQZHRPJ.mjs +0 -19
- package/dist/chunk-KFQZHRPJ.mjs.map +0 -1
- package/dist/chunk-KNQIEOFP.mjs +0 -18
- package/dist/chunk-KNQIEOFP.mjs.map +0 -1
- package/dist/chunk-KTTN5H7S.mjs +0 -202
- package/dist/chunk-KTTN5H7S.mjs.map +0 -1
- package/dist/chunk-L7VVZH4Q.mjs +0 -3
- package/dist/chunk-L7VVZH4Q.mjs.map +0 -1
- package/dist/chunk-LQZBI6XD.mjs +0 -112
- package/dist/chunk-LQZBI6XD.mjs.map +0 -1
- package/dist/chunk-M2DR4KVB.mjs +0 -33
- package/dist/chunk-M2DR4KVB.mjs.map +0 -1
- package/dist/chunk-MMVDU6DF.mjs +0 -3
- package/dist/chunk-MMVDU6DF.mjs.map +0 -1
- package/dist/chunk-MRXNTQOX.mjs +0 -55
- package/dist/chunk-MRXNTQOX.mjs.map +0 -1
- package/dist/chunk-OHO4G6DR.mjs +0 -19
- package/dist/chunk-OHO4G6DR.mjs.map +0 -1
- package/dist/chunk-P4QVFRLY.mjs +0 -103
- package/dist/chunk-P4QVFRLY.mjs.map +0 -1
- package/dist/chunk-PTZVE6NC.mjs +0 -94
- package/dist/chunk-PTZVE6NC.mjs.map +0 -1
- package/dist/chunk-QDFAIRQF.mjs +0 -45
- package/dist/chunk-QDFAIRQF.mjs.map +0 -1
- package/dist/chunk-RBR32FWA.mjs +0 -74
- package/dist/chunk-RBR32FWA.mjs.map +0 -1
- package/dist/chunk-SBV2KVF5.mjs +0 -99
- package/dist/chunk-SBV2KVF5.mjs.map +0 -1
- package/dist/chunk-T6MTDQZ7.mjs +0 -45
- package/dist/chunk-T6MTDQZ7.mjs.map +0 -1
- package/dist/chunk-VPEH6V7T.mjs +0 -83
- package/dist/chunk-VPEH6V7T.mjs.map +0 -1
- package/dist/chunk-WADHCMPK.mjs +0 -3
- package/dist/chunk-WADHCMPK.mjs.map +0 -1
- package/dist/chunk-WFTAAA7R.mjs +0 -44
- package/dist/chunk-WFTAAA7R.mjs.map +0 -1
- package/dist/chunk-WJHSY5T6.mjs +0 -3
- package/dist/chunk-WJHSY5T6.mjs.map +0 -1
- package/dist/chunk-WTASPE2W.mjs +0 -105
- package/dist/chunk-WTASPE2W.mjs.map +0 -1
- package/dist/chunk-XV7MLLXQ.mjs +0 -18
- package/dist/chunk-XV7MLLXQ.mjs.map +0 -1
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.d.ts +0 -27
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +0 -4
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs.map +0 -1
- package/src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx +0 -69
|
@@ -1,15 +1,582 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
var __async = (__this, __arguments, generator) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
var fulfilled = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.next(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var rejected = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.throw(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/hooks/misc/use-autosize-textarea.tsx
|
|
51
|
+
import { useEffect } from "react";
|
|
52
|
+
var useAutosizeTextArea = (textAreaRef, value) => {
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (textAreaRef.current !== null) {
|
|
55
|
+
textAreaRef.current.style.height = "0px";
|
|
56
|
+
const scrollHeight = textAreaRef.current.scrollHeight;
|
|
57
|
+
textAreaRef.current.style.height = scrollHeight + "px";
|
|
58
|
+
}
|
|
59
|
+
}, [textAreaRef, value]);
|
|
60
|
+
};
|
|
61
|
+
var use_autosize_textarea_default = useAutosizeTextArea;
|
|
62
|
+
|
|
63
|
+
// src/components/source-search-box/source-search-box.tsx
|
|
64
|
+
import { useState } from "react";
|
|
65
|
+
|
|
66
|
+
// src/components/ui/command.tsx
|
|
67
|
+
import * as React from "react";
|
|
68
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
69
|
+
|
|
70
|
+
// src/lib/utils.ts
|
|
71
|
+
import { clsx } from "clsx";
|
|
72
|
+
import { customAlphabet } from "nanoid";
|
|
73
|
+
import { twMerge } from "tailwind-merge";
|
|
74
|
+
function cn(...inputs) {
|
|
75
|
+
return twMerge(clsx(inputs));
|
|
76
|
+
}
|
|
77
|
+
var nanoid = customAlphabet(
|
|
78
|
+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
79
|
+
7
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// src/components/ui/command.tsx
|
|
83
|
+
import { jsx } from "react/jsx-runtime";
|
|
84
|
+
var Command = React.forwardRef((_a, ref) => {
|
|
85
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
86
|
+
return /* @__PURE__ */ jsx(
|
|
87
|
+
CommandPrimitive,
|
|
88
|
+
__spreadValues({
|
|
89
|
+
ref,
|
|
90
|
+
className: cn(
|
|
91
|
+
"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
|
|
92
|
+
className
|
|
93
|
+
)
|
|
94
|
+
}, props)
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
Command.displayName = CommandPrimitive.displayName;
|
|
98
|
+
var CommandInput = React.forwardRef((_a, ref) => {
|
|
99
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
100
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: /* @__PURE__ */ jsx(
|
|
101
|
+
CommandPrimitive.Input,
|
|
102
|
+
__spreadValues({
|
|
103
|
+
ref,
|
|
104
|
+
className: cn(
|
|
105
|
+
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
106
|
+
className
|
|
107
|
+
)
|
|
108
|
+
}, props)
|
|
109
|
+
) });
|
|
110
|
+
});
|
|
111
|
+
CommandInput.displayName = CommandPrimitive.Input.displayName;
|
|
112
|
+
var CommandList = React.forwardRef((_a, ref) => {
|
|
113
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
114
|
+
return /* @__PURE__ */ jsx(
|
|
115
|
+
CommandPrimitive.List,
|
|
116
|
+
__spreadValues({
|
|
117
|
+
ref,
|
|
118
|
+
className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden pb-2", className)
|
|
119
|
+
}, props)
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
CommandList.displayName = CommandPrimitive.List.displayName;
|
|
123
|
+
var CommandEmpty = React.forwardRef((props, ref) => /* @__PURE__ */ jsx(CommandPrimitive.Empty, __spreadValues({ ref, className: "py-6 text-center text-sm" }, props)));
|
|
124
|
+
CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
|
|
125
|
+
var CommandGroup = React.forwardRef((_a, ref) => {
|
|
126
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
127
|
+
return /* @__PURE__ */ jsx(
|
|
128
|
+
CommandPrimitive.Group,
|
|
129
|
+
__spreadValues({
|
|
130
|
+
ref,
|
|
131
|
+
className: cn(
|
|
132
|
+
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
|
|
133
|
+
className
|
|
134
|
+
)
|
|
135
|
+
}, props)
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
CommandGroup.displayName = CommandPrimitive.Group.displayName;
|
|
139
|
+
var CommandSeparator = React.forwardRef((_a, ref) => {
|
|
140
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
141
|
+
return /* @__PURE__ */ jsx(
|
|
142
|
+
CommandPrimitive.Separator,
|
|
143
|
+
__spreadValues({
|
|
144
|
+
ref,
|
|
145
|
+
className: cn("-mx-1 h-px bg-border", className)
|
|
146
|
+
}, props)
|
|
147
|
+
);
|
|
148
|
+
});
|
|
149
|
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
|
|
150
|
+
var CommandItem = React.forwardRef((_a, ref) => {
|
|
151
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
152
|
+
return /* @__PURE__ */ jsx(
|
|
153
|
+
CommandPrimitive.Item,
|
|
154
|
+
__spreadValues({
|
|
155
|
+
ref,
|
|
156
|
+
className: cn(
|
|
157
|
+
"relative flex cursor-default select-none items-center rounded-sm text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
158
|
+
className
|
|
159
|
+
)
|
|
160
|
+
}, props)
|
|
161
|
+
);
|
|
162
|
+
});
|
|
163
|
+
CommandItem.displayName = CommandPrimitive.Item.displayName;
|
|
164
|
+
var CommandShortcut = (_a) => {
|
|
165
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
166
|
+
return /* @__PURE__ */ jsx(
|
|
167
|
+
"span",
|
|
168
|
+
__spreadValues({
|
|
169
|
+
className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className)
|
|
170
|
+
}, props)
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
174
|
+
|
|
175
|
+
// src/components/source-search-box/source-search-box.tsx
|
|
176
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
177
|
+
function SourceSearchBox(props) {
|
|
178
|
+
const [selectedValue, setSelectedValue] = useState("");
|
|
179
|
+
return /* @__PURE__ */ jsxs(
|
|
180
|
+
Command,
|
|
181
|
+
{
|
|
182
|
+
className: "rounded-lg border shadow-md",
|
|
183
|
+
value: selectedValue,
|
|
184
|
+
onValueChange: (value) => {
|
|
185
|
+
setSelectedValue(value);
|
|
186
|
+
},
|
|
187
|
+
filter: (value, search) => {
|
|
188
|
+
if (props.searchTerm === "")
|
|
189
|
+
return 1;
|
|
190
|
+
if (value.startsWith(props.searchTerm))
|
|
191
|
+
return 1;
|
|
192
|
+
return 0;
|
|
193
|
+
},
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ jsx2(
|
|
196
|
+
CommandInput,
|
|
197
|
+
{
|
|
198
|
+
value: props.searchTerm,
|
|
199
|
+
className: "rounded-t-lg hidden",
|
|
200
|
+
placeholder: "Search for a command..."
|
|
201
|
+
}
|
|
202
|
+
),
|
|
203
|
+
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
204
|
+
/* @__PURE__ */ jsx2(CommandEmpty, { children: "No results found." }),
|
|
205
|
+
/* @__PURE__ */ jsx2(CommandGroup, { heading: "Available resources", children: props.suggestedFiles.map((filePointer) => {
|
|
206
|
+
return /* @__PURE__ */ jsx2(
|
|
207
|
+
CommandItem,
|
|
208
|
+
{
|
|
209
|
+
value: filePointer.name,
|
|
210
|
+
onSelect: (value) => {
|
|
211
|
+
props.onSelectedFile(filePointer);
|
|
212
|
+
},
|
|
213
|
+
children: /* @__PURE__ */ jsxs("div", { className: " px-3 flex flex-row gap-1 items-center", children: [
|
|
214
|
+
/* @__PURE__ */ jsx2(Logo, { width: "20px", height: "20px", children: /* @__PURE__ */ jsx2(
|
|
215
|
+
"img",
|
|
216
|
+
{
|
|
217
|
+
src: filePointer.iconImageUri,
|
|
218
|
+
alt: filePointer.sourceApplication,
|
|
219
|
+
className: "w-full h-full"
|
|
220
|
+
}
|
|
221
|
+
) }),
|
|
222
|
+
filePointer.name
|
|
223
|
+
] })
|
|
224
|
+
},
|
|
225
|
+
`word-${filePointer.sourceApplication}.${filePointer.name}`
|
|
226
|
+
);
|
|
227
|
+
}) }),
|
|
228
|
+
/* @__PURE__ */ jsx2(CommandSeparator, {})
|
|
229
|
+
] })
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
function Logo({
|
|
235
|
+
children,
|
|
236
|
+
width,
|
|
237
|
+
height
|
|
238
|
+
}) {
|
|
239
|
+
return /* @__PURE__ */ jsx2("div", { className: "flex items-center justify-center", style: { width, height }, children });
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// src/components/ui/button.tsx
|
|
243
|
+
import * as React2 from "react";
|
|
244
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
245
|
+
import { cva } from "class-variance-authority";
|
|
246
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
247
|
+
var buttonVariants = cva(
|
|
248
|
+
"inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
249
|
+
{
|
|
250
|
+
variants: {
|
|
251
|
+
variant: {
|
|
252
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
253
|
+
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
|
|
254
|
+
outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
|
|
255
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
256
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
257
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
258
|
+
},
|
|
259
|
+
size: {
|
|
260
|
+
default: "h-10 px-4 py-2",
|
|
261
|
+
sm: "h-9 rounded-md px-3",
|
|
262
|
+
lg: "h-11 rounded-md px-8",
|
|
263
|
+
icon: "h-10 w-10"
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
defaultVariants: {
|
|
267
|
+
variant: "default",
|
|
268
|
+
size: "default"
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
var Button = React2.forwardRef(
|
|
273
|
+
(_a, ref) => {
|
|
274
|
+
var _b = _a, { className, variant, size, asChild = false } = _b, props = __objRest(_b, ["className", "variant", "size", "asChild"]);
|
|
275
|
+
const Comp = asChild ? Slot : "button";
|
|
276
|
+
return /* @__PURE__ */ jsx3(Comp, __spreadValues({ className: cn(buttonVariants({ variant, size, className })), ref }, props));
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
Button.displayName = "Button";
|
|
280
|
+
|
|
281
|
+
// src/components/ui/label.tsx
|
|
282
|
+
import * as React3 from "react";
|
|
283
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
284
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
285
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
286
|
+
var labelVariants = cva2(
|
|
287
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
288
|
+
);
|
|
289
|
+
var Label = React3.forwardRef((_a, ref) => {
|
|
290
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
291
|
+
return /* @__PURE__ */ jsx4(LabelPrimitive.Root, __spreadValues({ ref, className: cn(labelVariants(), className) }, props));
|
|
292
|
+
});
|
|
293
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
294
|
+
|
|
295
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
296
|
+
import { useCallback, useContext, useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
297
|
+
|
|
298
|
+
// src/lib/stream-promise-flatten.ts
|
|
299
|
+
function streamPromiseFlatten(promise) {
|
|
300
|
+
return new ReadableStream({
|
|
301
|
+
start(controller) {
|
|
302
|
+
return __async(this, null, function* () {
|
|
303
|
+
try {
|
|
304
|
+
const stream = yield promise;
|
|
305
|
+
const reader = stream.getReader();
|
|
306
|
+
while (true) {
|
|
307
|
+
const { done, value } = yield reader.read();
|
|
308
|
+
if (done) {
|
|
309
|
+
controller.close();
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
controller.enqueue(value);
|
|
313
|
+
}
|
|
314
|
+
} catch (error) {
|
|
315
|
+
controller.error(error);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
323
|
+
import { CopilotContext } from "@copilotkit/react-core";
|
|
324
|
+
|
|
325
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx
|
|
326
|
+
import Chip from "@mui/material/Chip/Chip.js";
|
|
327
|
+
import Avatar from "@mui/material/Avatar/Avatar.js";
|
|
328
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
329
|
+
var IncludedFilesPreview = ({
|
|
330
|
+
includedFiles,
|
|
331
|
+
setIncludedFiles
|
|
332
|
+
}) => {
|
|
333
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-2 mt-2", children: [
|
|
334
|
+
/* @__PURE__ */ jsx5(Label, { className: "", children: "Included context:" }),
|
|
335
|
+
/* @__PURE__ */ jsx5("div", { className: "flex flex-wrap gap-2", children: includedFiles.map((filePointer, index) => {
|
|
336
|
+
return /* @__PURE__ */ jsx5(
|
|
337
|
+
FileChipPreview,
|
|
338
|
+
{
|
|
339
|
+
filePointer,
|
|
340
|
+
onDelete: () => {
|
|
341
|
+
setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
`file-${filePointer.sourceApplication}.${filePointer.name}`
|
|
345
|
+
);
|
|
346
|
+
}) })
|
|
347
|
+
] });
|
|
348
|
+
};
|
|
349
|
+
var FileChipPreview = ({ filePointer, onDelete }) => {
|
|
350
|
+
return /* @__PURE__ */ jsx5(
|
|
351
|
+
Chip,
|
|
352
|
+
{
|
|
353
|
+
label: filePointer.name,
|
|
354
|
+
onDelete,
|
|
355
|
+
avatar: /* @__PURE__ */ jsx5(
|
|
356
|
+
Avatar,
|
|
357
|
+
{
|
|
358
|
+
src: filePointer.iconImageUri,
|
|
359
|
+
alt: filePointer.sourceApplication,
|
|
360
|
+
sx: { backgroundColor: "transparent" }
|
|
361
|
+
}
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
);
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx
|
|
368
|
+
import { Fragment, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
369
|
+
var HoveringInsertionPromptBoxCore = ({
|
|
370
|
+
performInsertion,
|
|
371
|
+
state,
|
|
372
|
+
insertionOrEditingFunction,
|
|
373
|
+
contextCategories
|
|
374
|
+
}) => {
|
|
375
|
+
const { getDocumentsContext } = useContext(CopilotContext);
|
|
376
|
+
const [editSuggestion, setEditSuggestion] = useState2("");
|
|
377
|
+
const [suggestionIsLoading, setSuggestionIsLoading] = useState2(false);
|
|
378
|
+
const [adjustmentPrompt, setAdjustmentPrompt] = useState2("");
|
|
379
|
+
const [generatingSuggestion, setGeneratingSuggestion] = useState2(
|
|
380
|
+
null
|
|
381
|
+
);
|
|
382
|
+
const adjustmentTextAreaRef = useRef(null);
|
|
383
|
+
const suggestionTextAreaRef = useRef(null);
|
|
384
|
+
const [filePointers, setFilePointers] = useState2([]);
|
|
385
|
+
const [suggestedFiles, setSuggestedFiles] = useState2([]);
|
|
386
|
+
useEffect2(() => {
|
|
387
|
+
setSuggestedFiles(getDocumentsContext(contextCategories));
|
|
388
|
+
}, [contextCategories, getDocumentsContext]);
|
|
389
|
+
use_autosize_textarea_default(suggestionTextAreaRef, editSuggestion || "");
|
|
390
|
+
use_autosize_textarea_default(adjustmentTextAreaRef, adjustmentPrompt || "");
|
|
391
|
+
useEffect2(() => {
|
|
392
|
+
var _a;
|
|
393
|
+
(_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
|
|
394
|
+
}, []);
|
|
395
|
+
useEffect2(() => {
|
|
396
|
+
if (!generatingSuggestion) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
if (generatingSuggestion.locked) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
setEditSuggestion("");
|
|
403
|
+
const reader = generatingSuggestion.getReader();
|
|
404
|
+
const read = () => __async(void 0, null, function* () {
|
|
405
|
+
setSuggestionIsLoading(true);
|
|
406
|
+
while (true) {
|
|
407
|
+
const { done, value } = yield reader.read();
|
|
408
|
+
if (done) {
|
|
409
|
+
break;
|
|
410
|
+
}
|
|
411
|
+
setEditSuggestion((prev) => {
|
|
412
|
+
const newSuggestion = prev + value;
|
|
413
|
+
if (suggestionTextAreaRef.current) {
|
|
414
|
+
suggestionTextAreaRef.current.scrollTop = suggestionTextAreaRef.current.scrollHeight;
|
|
415
|
+
}
|
|
416
|
+
return newSuggestion;
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
setSuggestionIsLoading(false);
|
|
420
|
+
});
|
|
421
|
+
read();
|
|
422
|
+
return () => {
|
|
423
|
+
const releaseLockIfNotClosed = () => __async(void 0, null, function* () {
|
|
424
|
+
try {
|
|
425
|
+
yield reader.closed;
|
|
426
|
+
} catch (e) {
|
|
427
|
+
reader.releaseLock();
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
releaseLockIfNotClosed();
|
|
431
|
+
};
|
|
432
|
+
}, [generatingSuggestion]);
|
|
433
|
+
const beginGeneratingAdjustment = useCallback(() => __async(void 0, null, function* () {
|
|
434
|
+
if (!adjustmentPrompt.trim()) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
let modificationState = state.editorState;
|
|
438
|
+
if (editSuggestion !== "") {
|
|
439
|
+
modificationState.selectedText = editSuggestion;
|
|
440
|
+
}
|
|
441
|
+
const adjustmentSuggestionTextStreamPromise = insertionOrEditingFunction(
|
|
442
|
+
modificationState,
|
|
443
|
+
adjustmentPrompt,
|
|
444
|
+
filePointers,
|
|
445
|
+
new AbortController().signal
|
|
446
|
+
);
|
|
447
|
+
const adjustmentSuggestionTextStream = streamPromiseFlatten(
|
|
448
|
+
adjustmentSuggestionTextStreamPromise
|
|
449
|
+
);
|
|
450
|
+
setGeneratingSuggestion(adjustmentSuggestionTextStream);
|
|
451
|
+
}), [
|
|
452
|
+
adjustmentPrompt,
|
|
453
|
+
editSuggestion,
|
|
454
|
+
state.editorState,
|
|
455
|
+
insertionOrEditingFunction,
|
|
456
|
+
filePointers
|
|
457
|
+
]);
|
|
458
|
+
const isLoading = suggestionIsLoading;
|
|
459
|
+
const textToEdit = editSuggestion || state.editorState.selectedText;
|
|
460
|
+
const adjustmentLabel = textToEdit === "" ? "Describe the text you want to insert" : "Describe adjustments to the suggested text";
|
|
461
|
+
const placeholder = textToEdit === "" ? "e.g. 'summarize the client's top 3 pain-points from @CallTranscript'" : "e.g. 'make it more formal', 'be more specific', ...";
|
|
462
|
+
const AdjustmentPromptComponent = /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
463
|
+
/* @__PURE__ */ jsx6(Label, { className: "", children: adjustmentLabel }),
|
|
464
|
+
/* @__PURE__ */ jsxs3("div", { className: "relative w-full flex items-center", children: [
|
|
465
|
+
/* @__PURE__ */ jsx6(
|
|
466
|
+
"textarea",
|
|
467
|
+
{
|
|
468
|
+
disabled: suggestionIsLoading,
|
|
469
|
+
ref: adjustmentTextAreaRef,
|
|
470
|
+
value: adjustmentPrompt,
|
|
471
|
+
onChange: (e) => setAdjustmentPrompt(e.target.value),
|
|
472
|
+
onKeyDown: (e) => {
|
|
473
|
+
if (e.key === "Enter" && e.shiftKey) {
|
|
474
|
+
e.preventDefault();
|
|
475
|
+
setAdjustmentPrompt(adjustmentPrompt + "\n");
|
|
476
|
+
} else if (e.key === "Enter") {
|
|
477
|
+
e.preventDefault();
|
|
478
|
+
beginGeneratingAdjustment();
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
placeholder,
|
|
482
|
+
style: { minHeight: "3rem" },
|
|
483
|
+
className: "w-full bg-slate-100 h-auto h-min-14 text-sm p-2 rounded-md resize-none overflow-visible focus:outline-none focus:ring-0 focus:border-non pr-[3rem]",
|
|
484
|
+
rows: 1
|
|
485
|
+
}
|
|
486
|
+
),
|
|
487
|
+
/* @__PURE__ */ jsx6(
|
|
488
|
+
"button",
|
|
489
|
+
{
|
|
490
|
+
onClick: beginGeneratingAdjustment,
|
|
491
|
+
className: "absolute right-2 bg-blue-500 text-white w-8 h-8 rounded-full flex items-center justify-center",
|
|
492
|
+
children: /* @__PURE__ */ jsx6("i", { className: "material-icons", children: "arrow_forward" })
|
|
493
|
+
}
|
|
494
|
+
)
|
|
495
|
+
] })
|
|
496
|
+
] });
|
|
497
|
+
const SuggestionComponent = /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
498
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex justify-between items-end w-full", children: [
|
|
499
|
+
/* @__PURE__ */ jsx6(Label, { className: "mt-4", children: "Suggested:" }),
|
|
500
|
+
/* @__PURE__ */ jsx6("div", { className: "ml-auto", children: isLoading && /* @__PURE__ */ jsx6("div", { className: "flex justify-center items-center", children: /* @__PURE__ */ jsx6(
|
|
501
|
+
"div",
|
|
502
|
+
{
|
|
503
|
+
className: "inline-block h-4 w-4 animate-spin rounded-full border-4 border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]",
|
|
504
|
+
role: "status",
|
|
505
|
+
children: /* @__PURE__ */ jsx6("span", { className: "!absolute !-m-px !h-px !w-px !overflow-hidden !whitespace-nowrap !border-0 !p-0 ![clip:rect(0,0,0,0)]", children: "Loading..." })
|
|
506
|
+
}
|
|
507
|
+
) }) })
|
|
508
|
+
] }),
|
|
509
|
+
/* @__PURE__ */ jsx6(
|
|
510
|
+
"textarea",
|
|
511
|
+
{
|
|
512
|
+
ref: suggestionTextAreaRef,
|
|
513
|
+
value: editSuggestion,
|
|
514
|
+
disabled: suggestionIsLoading,
|
|
515
|
+
onChange: (e) => setEditSuggestion(e.target.value),
|
|
516
|
+
className: "w-full text-base p-2 border border-gray-300 rounded-md resize-none bg-green-50",
|
|
517
|
+
style: { overflow: "auto", maxHeight: "10em" }
|
|
518
|
+
}
|
|
519
|
+
)
|
|
520
|
+
] });
|
|
521
|
+
const SubmitComponent = /* @__PURE__ */ jsx6("div", { className: "flex w-full gap-4 justify-start", children: /* @__PURE__ */ jsxs3(
|
|
522
|
+
Button,
|
|
523
|
+
{
|
|
524
|
+
className: " bg-green-700 text-white",
|
|
525
|
+
onClick: () => {
|
|
526
|
+
performInsertion(editSuggestion);
|
|
527
|
+
},
|
|
528
|
+
children: [
|
|
529
|
+
"Insert ",
|
|
530
|
+
/* @__PURE__ */ jsx6("i", { className: "material-icons", children: "check" })
|
|
531
|
+
]
|
|
532
|
+
}
|
|
533
|
+
) });
|
|
534
|
+
const sourceSearchCandidate = adjustmentPrompt.split(" ").pop();
|
|
535
|
+
const sourceSearchWord = (sourceSearchCandidate == null ? void 0 : sourceSearchCandidate.startsWith("@")) ? sourceSearchCandidate.slice(1) : void 0;
|
|
536
|
+
return /* @__PURE__ */ jsxs3("div", { className: "w-full flex flex-col items-start relative gap-2", children: [
|
|
537
|
+
AdjustmentPromptComponent,
|
|
538
|
+
filePointers.length > 0 && /* @__PURE__ */ jsx6(IncludedFilesPreview, { includedFiles: filePointers, setIncludedFiles: setFilePointers }),
|
|
539
|
+
sourceSearchWord !== void 0 && /* @__PURE__ */ jsx6(
|
|
540
|
+
SourceSearchBox,
|
|
541
|
+
{
|
|
542
|
+
searchTerm: sourceSearchWord,
|
|
543
|
+
suggestedFiles,
|
|
544
|
+
onSelectedFile: (filePointer) => {
|
|
545
|
+
var _a;
|
|
546
|
+
setAdjustmentPrompt(adjustmentPrompt.replace(new RegExp(`@${sourceSearchWord}$`), ""));
|
|
547
|
+
setFilePointers((prev) => [...prev, filePointer]);
|
|
548
|
+
(_a = adjustmentTextAreaRef.current) == null ? void 0 : _a.focus();
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
),
|
|
552
|
+
generatingSuggestion ? SuggestionComponent : null,
|
|
553
|
+
generatingSuggestion ? SubmitComponent : null
|
|
554
|
+
] });
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
// src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.tsx
|
|
558
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
559
|
+
var HoveringInsertionPromptBox = (props) => {
|
|
560
|
+
return /* @__PURE__ */ jsx7(
|
|
561
|
+
"div",
|
|
562
|
+
{
|
|
563
|
+
className: "flex flex-col justify-center items-center space-y-4 rounded-md border shadow-lg p-4 border-gray- bg-white",
|
|
564
|
+
style: { width: "35rem" },
|
|
565
|
+
children: /* @__PURE__ */ jsx7(
|
|
566
|
+
HoveringInsertionPromptBoxCore,
|
|
567
|
+
{
|
|
568
|
+
state: {
|
|
569
|
+
editorState: props.editorState
|
|
570
|
+
},
|
|
571
|
+
insertionOrEditingFunction: props.apiConfig.insertionOrEditingFunction,
|
|
572
|
+
performInsertion: props.performInsertion,
|
|
573
|
+
contextCategories: props.contextCategories
|
|
574
|
+
}
|
|
575
|
+
)
|
|
576
|
+
}
|
|
577
|
+
);
|
|
578
|
+
};
|
|
579
|
+
export {
|
|
580
|
+
HoveringInsertionPromptBox
|
|
581
|
+
};
|
|
15
582
|
//# sourceMappingURL=index.mjs.map
|