@copilotkit/react-textarea 0.24.0 → 0.25.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/.turbo/turbo-build.log +99 -99
- package/CHANGELOG.md +11 -0
- package/dist/{chunk-WJYQWL4I.mjs → chunk-2C7O2EVM.mjs} +1 -1
- package/dist/{chunk-WJYQWL4I.mjs.map → chunk-2C7O2EVM.mjs.map} +1 -1
- package/dist/{chunk-KCHYD3EB.mjs → chunk-2CDXHWVF.mjs} +1 -1
- package/dist/chunk-2CDXHWVF.mjs.map +1 -0
- package/dist/{chunk-GCMQHIRF.mjs → chunk-2QDCE7PD.mjs} +1 -1
- package/dist/chunk-2QDCE7PD.mjs.map +1 -0
- package/dist/{chunk-ND5PXTAW.mjs → chunk-3PQ7GSFE.mjs} +1 -1
- package/dist/chunk-3PQ7GSFE.mjs.map +1 -0
- package/dist/{chunk-GIJ3JZ4P.mjs → chunk-5IISSXS2.mjs} +11 -11
- package/dist/chunk-5IISSXS2.mjs.map +1 -0
- package/dist/{chunk-RQHOUUXQ.mjs → chunk-5UNJXFUO.mjs} +1 -1
- package/dist/{chunk-RQHOUUXQ.mjs.map → chunk-5UNJXFUO.mjs.map} +1 -1
- package/dist/{chunk-JYVC4AW3.mjs → chunk-74HF6Q3L.mjs} +26 -27
- package/dist/chunk-74HF6Q3L.mjs.map +1 -0
- package/dist/{chunk-MPME5BW2.mjs → chunk-7LSRNPNI.mjs} +1 -1
- package/dist/chunk-7LSRNPNI.mjs.map +1 -0
- package/dist/{chunk-4UYKBG35.mjs → chunk-7SZDD6XT.mjs} +4 -8
- package/dist/chunk-7SZDD6XT.mjs.map +1 -0
- package/dist/{chunk-AQHORK66.mjs → chunk-7VKOE5UL.mjs} +6 -10
- package/dist/chunk-7VKOE5UL.mjs.map +1 -0
- package/dist/{chunk-463BFNUP.mjs → chunk-AUCHS4VR.mjs} +2 -2
- package/dist/chunk-AUCHS4VR.mjs.map +1 -0
- package/dist/{chunk-JAFCXEPU.mjs → chunk-BLRAOGXD.mjs} +2 -2
- package/dist/{chunk-JAFCXEPU.mjs.map → chunk-BLRAOGXD.mjs.map} +1 -1
- package/dist/{chunk-O4MHJSK2.mjs → chunk-CK7Q3Y5A.mjs} +2 -2
- package/dist/{chunk-IXJ2HCOA.mjs → chunk-ECR45NSD.mjs} +1 -1
- package/dist/chunk-ECR45NSD.mjs.map +1 -0
- package/dist/{chunk-OELUUJZY.mjs → chunk-EZCKXWQF.mjs} +1 -1
- package/dist/chunk-EZCKXWQF.mjs.map +1 -0
- package/dist/{chunk-KGKLUWKW.mjs → chunk-F626GQCD.mjs} +1 -1
- package/dist/chunk-F626GQCD.mjs.map +1 -0
- package/dist/{chunk-5EJ5XOGP.mjs → chunk-FK2XUDQQ.mjs} +2 -2
- package/dist/chunk-FK2XUDQQ.mjs.map +1 -0
- package/dist/chunk-FP2EKU3L.mjs +28 -0
- package/dist/chunk-FP2EKU3L.mjs.map +1 -0
- package/dist/{chunk-F3MHL6ZY.mjs → chunk-GQN2HYFJ.mjs} +2 -5
- package/dist/chunk-GQN2HYFJ.mjs.map +1 -0
- package/dist/{chunk-AXN37AHC.mjs → chunk-K5LNB36H.mjs} +1 -1
- package/dist/chunk-K5LNB36H.mjs.map +1 -0
- package/dist/{chunk-JHTAOLEW.mjs → chunk-KDVMG3XF.mjs} +1 -1
- package/dist/chunk-KDVMG3XF.mjs.map +1 -0
- package/dist/{chunk-2NURR2DX.mjs → chunk-KMXSZRIA.mjs} +2 -2
- package/dist/chunk-KMXSZRIA.mjs.map +1 -0
- package/dist/{chunk-4S5ZJH3I.mjs → chunk-KNQIEOFP.mjs} +1 -1
- package/dist/{chunk-4S5ZJH3I.mjs.map → chunk-KNQIEOFP.mjs.map} +1 -1
- package/dist/{chunk-YQU7WG7T.mjs → chunk-LZ3UOAQ4.mjs} +3 -3
- package/dist/chunk-LZ3UOAQ4.mjs.map +1 -0
- package/dist/{chunk-NKW5OU2S.mjs → chunk-M2DR4KVB.mjs} +1 -1
- package/dist/chunk-M2DR4KVB.mjs.map +1 -0
- package/dist/{chunk-GUH3Y2H4.mjs → chunk-NTLVQENP.mjs} +5 -5
- package/dist/chunk-NTLVQENP.mjs.map +1 -0
- package/dist/{chunk-O5OWT5GE.mjs → chunk-PDCIGRCE.mjs} +8 -29
- package/dist/chunk-PDCIGRCE.mjs.map +1 -0
- package/dist/{chunk-YW3REYX6.mjs → chunk-QRKKPCUD.mjs} +2 -4
- package/dist/chunk-QRKKPCUD.mjs.map +1 -0
- package/dist/{chunk-RR6OQGTI.mjs → chunk-RBR32FWA.mjs} +1 -1
- package/dist/chunk-RBR32FWA.mjs.map +1 -0
- package/dist/{chunk-YTOPHPSG.mjs → chunk-T6MTDQZ7.mjs} +1 -1
- package/dist/chunk-T6MTDQZ7.mjs.map +1 -0
- package/dist/{chunk-QJDMIGLU.mjs → chunk-TZLW7PBU.mjs} +9 -12
- package/dist/chunk-TZLW7PBU.mjs.map +1 -0
- package/dist/{chunk-CSGFJU3L.mjs → chunk-U3LUDDT5.mjs} +2 -2
- package/dist/chunk-U3LUDDT5.mjs.map +1 -0
- package/dist/{chunk-LNAIMEB2.mjs → chunk-UEQYKC4W.mjs} +1 -1
- package/dist/chunk-UEQYKC4W.mjs.map +1 -0
- package/dist/{chunk-OD7ZMOVE.mjs → chunk-V55OPCG4.mjs} +2 -2
- package/dist/chunk-V55OPCG4.mjs.map +1 -0
- package/dist/{chunk-4HHYJGZE.mjs → chunk-VYECMH73.mjs} +7 -25
- package/dist/chunk-VYECMH73.mjs.map +1 -0
- package/dist/{chunk-3L6CNVCE.mjs → chunk-W2ZHOUV6.mjs} +5 -5
- package/dist/chunk-W2ZHOUV6.mjs.map +1 -0
- package/dist/{chunk-UHD44NC5.mjs → chunk-WVRTFPNO.mjs} +10 -20
- package/dist/chunk-WVRTFPNO.mjs.map +1 -0
- package/dist/{chunk-4LOLCQGR.mjs → chunk-ZEHF3AXH.mjs} +4 -9
- package/dist/chunk-ZEHF3AXH.mjs.map +1 -0
- package/dist/{chunk-XHUMROEY.mjs → chunk-ZKRM3DIR.mjs} +1 -1
- package/dist/chunk-ZKRM3DIR.mjs.map +1 -0
- package/dist/{chunk-WLPYYGES.mjs → chunk-ZMNOLW5V.mjs} +6 -16
- package/dist/chunk-ZMNOLW5V.mjs.map +1 -0
- package/dist/components/base-copilot-textarea/base-copilot-textarea.mjs +31 -31
- package/dist/components/base-copilot-textarea/render-element.mjs +1 -1
- package/dist/components/base-copilot-textarea/render-placeholder.mjs +1 -1
- package/dist/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.mjs +2 -2
- package/dist/components/base-copilot-textarea/use-add-branding-css.mjs +1 -1
- package/dist/components/copilot-textarea/copilot-textarea.mjs +40 -40
- package/dist/components/hovering-toolbar/hovering-editor-provider.d.ts +1 -1
- package/dist/components/hovering-toolbar/hovering-editor-provider.mjs +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar-components.mjs +1 -1
- package/dist/components/hovering-toolbar/hovering-toolbar.mjs +15 -15
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.mjs +10 -10
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box.mjs +11 -11
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.mjs +3 -3
- package/dist/components/hovering-toolbar/text-insertion-prompt-box/index.mjs +11 -11
- package/dist/components/index.mjs +40 -40
- package/dist/components/manual-ui/chip-with-icon.mjs +1 -5
- package/dist/components/manual-ui/chip-with-icon.mjs.map +1 -1
- package/dist/components/source-search-box/source-search-box.mjs +4 -4
- package/dist/components/ui/button.mjs +2 -2
- package/dist/components/ui/card.mjs +46 -42
- package/dist/components/ui/card.mjs.map +1 -1
- package/dist/components/ui/command.mjs +3 -3
- package/dist/components/ui/dialog.mjs +2 -2
- package/dist/components/ui/label.mjs +2 -2
- package/dist/components/ui/separator.mjs +14 -16
- package/dist/components/ui/separator.mjs.map +1 -1
- package/dist/components/ui/textarea.mjs +1 -1
- package/dist/components/ui/textarea.mjs.map +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.d.ts +1 -1
- package/dist/hooks/base-copilot-textarea-implementation/use-autosuggestions.mjs +4 -4
- package/dist/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.mjs +2 -2
- package/dist/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.mjs +3 -3
- package/dist/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.mjs +8 -8
- package/dist/hooks/make-autosuggestions-function/use-make-standard-insertion-function.mjs +8 -8
- package/dist/hooks/misc/use-autosize-textarea.mjs +1 -1
- package/dist/index.mjs +40 -40
- package/dist/lib/debouncer.mjs +1 -1
- package/dist/lib/editor-to-text.mjs +1 -1
- package/dist/lib/get-text-around-cursor.mjs +1 -1
- package/dist/lib/retry.mjs +1 -1
- package/dist/lib/slatejs-edits/add-autocompletions.mjs +1 -1
- package/dist/lib/slatejs-edits/clear-autocompletions.mjs +1 -1
- package/dist/lib/slatejs-edits/replace-text.mjs +1 -1
- package/dist/lib/slatejs-edits/with-partial-history.mjs +1 -1
- package/dist/lib/stream-promise-flatten.mjs +1 -1
- package/dist/lib/utils.mjs +1 -1
- package/dist/types/autosuggestions-config/autosuggestions-config.mjs +5 -5
- package/dist/types/autosuggestions-config/editing-api-config.mjs +1 -1
- package/dist/types/autosuggestions-config/index.mjs +6 -6
- package/dist/types/autosuggestions-config/insertions-api-config.mjs +1 -1
- package/dist/types/autosuggestions-config/subtypes/chatlike-api-endpoint.mjs +1 -1
- package/dist/types/autosuggestions-config/suggestions-api-config.mjs +1 -1
- package/dist/types/base/base-autosuggestions-config.d.ts +55 -2
- package/dist/types/base/base-autosuggestions-config.mjs +1 -1
- package/dist/types/base/editor-autocomplete-state.mjs +2 -2
- package/dist/types/base/index.mjs +1 -1
- package/dist/types/index.mjs +6 -6
- package/package.json +2 -2
- package/src/components/base-copilot-textarea/base-copilot-textarea.tsx +31 -37
- package/src/components/base-copilot-textarea/render-element.tsx +3 -5
- package/src/components/base-copilot-textarea/render-placeholder.tsx +2 -4
- package/src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx +2 -5
- package/src/components/base-copilot-textarea/use-add-branding-css.tsx +2 -4
- package/src/components/copilot-textarea/copilot-textarea.tsx +11 -18
- package/src/components/hovering-toolbar/hovering-editor-provider.tsx +1 -3
- package/src/components/hovering-toolbar/hovering-toolbar-components.tsx +14 -31
- package/src/components/hovering-toolbar/hovering-toolbar.tsx +4 -16
- package/src/components/hovering-toolbar/text-insertion-prompt-box/hovering-insertion-prompt-box-core.tsx +11 -25
- package/src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx +2 -7
- package/src/components/manual-ui/chip-with-icon.tsx +3 -12
- package/src/components/source-search-box/source-search-box.tsx +2 -12
- package/src/components/ui/button.tsx +6 -13
- package/src/components/ui/card.tsx +35 -65
- package/src/components/ui/command.tsx +8 -21
- package/src/components/ui/dialog.tsx +8 -29
- package/src/components/ui/label.tsx +3 -8
- package/src/components/ui/separator.tsx +13 -18
- package/src/components/ui/textarea.tsx +3 -4
- package/src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts +13 -27
- package/src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx +1 -5
- package/src/hooks/base-copilot-textarea-implementation/use-populate-copilot-textarea-ref.ts +4 -11
- package/src/hooks/make-autosuggestions-function/use-make-standard-autosuggestions-function.tsx +5 -10
- package/src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx +15 -35
- package/src/hooks/misc/use-autosize-textarea.tsx +1 -4
- package/src/lib/debouncer.ts +1 -3
- package/src/lib/editor-to-text.ts +4 -7
- package/src/lib/get-text-around-cursor.ts +2 -14
- package/src/lib/retry.tsx +1 -1
- package/src/lib/slatejs-edits/add-autocompletions.ts +2 -2
- package/src/lib/slatejs-edits/clear-autocompletions.ts +1 -4
- package/src/lib/slatejs-edits/replace-text.ts +1 -1
- package/src/lib/slatejs-edits/with-partial-history.ts +4 -11
- package/src/lib/stream-promise-flatten.ts +1 -3
- package/src/lib/utils.ts +4 -8
- package/src/types/autosuggestions-config/autosuggestions-config-user-specified.tsx +3 -7
- package/src/types/autosuggestions-config/autosuggestions-config.tsx +5 -18
- package/src/types/autosuggestions-config/editing-api-config.tsx +3 -5
- package/src/types/autosuggestions-config/insertions-api-config.tsx +2 -3
- package/src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx +18 -26
- package/src/types/autosuggestions-config/subtypes/make-system-prompt.ts +1 -4
- package/src/types/autosuggestions-config/suggestions-api-config.tsx +2 -3
- package/src/types/base/autosuggestions-bare-function.ts +2 -2
- package/src/types/base/base-autosuggestions-config.tsx +80 -3
- package/src/types/base/editor-autocomplete-state.ts +1 -1
- package/dist/chunk-2NURR2DX.mjs.map +0 -1
- package/dist/chunk-3L6CNVCE.mjs.map +0 -1
- package/dist/chunk-463BFNUP.mjs.map +0 -1
- package/dist/chunk-4HHYJGZE.mjs.map +0 -1
- package/dist/chunk-4LOLCQGR.mjs.map +0 -1
- package/dist/chunk-4UYKBG35.mjs.map +0 -1
- package/dist/chunk-5EJ5XOGP.mjs.map +0 -1
- package/dist/chunk-6Z2ATUNY.mjs +0 -15
- package/dist/chunk-6Z2ATUNY.mjs.map +0 -1
- package/dist/chunk-AQHORK66.mjs.map +0 -1
- package/dist/chunk-AXN37AHC.mjs.map +0 -1
- package/dist/chunk-CSGFJU3L.mjs.map +0 -1
- package/dist/chunk-F3MHL6ZY.mjs.map +0 -1
- package/dist/chunk-GCMQHIRF.mjs.map +0 -1
- package/dist/chunk-GIJ3JZ4P.mjs.map +0 -1
- package/dist/chunk-GUH3Y2H4.mjs.map +0 -1
- package/dist/chunk-IXJ2HCOA.mjs.map +0 -1
- package/dist/chunk-JHTAOLEW.mjs.map +0 -1
- package/dist/chunk-JYVC4AW3.mjs.map +0 -1
- package/dist/chunk-KCHYD3EB.mjs.map +0 -1
- package/dist/chunk-KGKLUWKW.mjs.map +0 -1
- package/dist/chunk-LNAIMEB2.mjs.map +0 -1
- package/dist/chunk-MPME5BW2.mjs.map +0 -1
- package/dist/chunk-ND5PXTAW.mjs.map +0 -1
- package/dist/chunk-NKW5OU2S.mjs.map +0 -1
- package/dist/chunk-O5OWT5GE.mjs.map +0 -1
- package/dist/chunk-OD7ZMOVE.mjs.map +0 -1
- package/dist/chunk-OELUUJZY.mjs.map +0 -1
- package/dist/chunk-QJDMIGLU.mjs.map +0 -1
- package/dist/chunk-RR6OQGTI.mjs.map +0 -1
- package/dist/chunk-UHD44NC5.mjs.map +0 -1
- package/dist/chunk-WLPYYGES.mjs.map +0 -1
- package/dist/chunk-XHUMROEY.mjs.map +0 -1
- package/dist/chunk-YQU7WG7T.mjs.map +0 -1
- package/dist/chunk-YTOPHPSG.mjs.map +0 -1
- package/dist/chunk-YW3REYX6.mjs.map +0 -1
- /package/dist/{chunk-O4MHJSK2.mjs.map → chunk-CK7Q3Y5A.mjs.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cn } from './chunk-
|
|
1
|
+
import { cn } from './chunk-F626GQCD.mjs';
|
|
2
2
|
import { __objRest, __spreadValues, __spreadProps } from './chunk-MRXNTQOX.mjs';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
@@ -8,11 +8,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
8
8
|
var Dialog = DialogPrimitive.Root;
|
|
9
9
|
var DialogTrigger = DialogPrimitive.Trigger;
|
|
10
10
|
var DialogPortal = (_a) => {
|
|
11
|
-
var _b = _a, {
|
|
12
|
-
className
|
|
13
|
-
} = _b, props = __objRest(_b, [
|
|
14
|
-
"className"
|
|
15
|
-
]);
|
|
11
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
16
12
|
return /* @__PURE__ */ jsx(DialogPrimitive.Portal, __spreadValues({
|
|
17
13
|
className: cn(className)
|
|
18
14
|
}, props));
|
|
@@ -62,30 +58,16 @@ var DialogContent = React.forwardRef((_a, ref) => {
|
|
|
62
58
|
});
|
|
63
59
|
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
64
60
|
var DialogHeader = (_a) => {
|
|
65
|
-
var _b = _a, {
|
|
66
|
-
className
|
|
67
|
-
} = _b, props = __objRest(_b, [
|
|
68
|
-
"className"
|
|
69
|
-
]);
|
|
61
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
70
62
|
return /* @__PURE__ */ jsx("div", __spreadValues({
|
|
71
|
-
className: cn(
|
|
72
|
-
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
73
|
-
className
|
|
74
|
-
)
|
|
63
|
+
className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className)
|
|
75
64
|
}, props));
|
|
76
65
|
};
|
|
77
66
|
DialogHeader.displayName = "DialogHeader";
|
|
78
67
|
var DialogFooter = (_a) => {
|
|
79
|
-
var _b = _a, {
|
|
80
|
-
className
|
|
81
|
-
} = _b, props = __objRest(_b, [
|
|
82
|
-
"className"
|
|
83
|
-
]);
|
|
68
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
84
69
|
return /* @__PURE__ */ jsx("div", __spreadValues({
|
|
85
|
-
className: cn(
|
|
86
|
-
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
87
|
-
className
|
|
88
|
-
)
|
|
70
|
+
className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)
|
|
89
71
|
}, props));
|
|
90
72
|
};
|
|
91
73
|
DialogFooter.displayName = "DialogFooter";
|
|
@@ -93,10 +75,7 @@ var DialogTitle = React.forwardRef((_a, ref) => {
|
|
|
93
75
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
94
76
|
return /* @__PURE__ */ jsx(DialogPrimitive.Title, __spreadValues({
|
|
95
77
|
ref,
|
|
96
|
-
className: cn(
|
|
97
|
-
"text-lg font-semibold leading-none tracking-tight",
|
|
98
|
-
className
|
|
99
|
-
)
|
|
78
|
+
className: cn("text-lg font-semibold leading-none tracking-tight", className)
|
|
100
79
|
}, props));
|
|
101
80
|
});
|
|
102
81
|
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
@@ -111,4 +90,4 @@ DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
|
111
90
|
|
|
112
91
|
export { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger };
|
|
113
92
|
//# sourceMappingURL=out.js.map
|
|
114
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
//# sourceMappingURL=chunk-PDCIGRCE.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/ui/dialog.tsx"],"names":[],"mappings":";;;;;;;;;;AAEA,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,SAAS,SAAS;AAShB,cAkCI,YAlCJ;AAbF;AAQA,IAAM,SAAyB;AAE/B,IAAM,gBAAgC;AAEtC,IAAM,eAAe,CAAC,OAA4D;AAA5D,eAAE,YAZxB,IAYsB,IAAgB,kBAAhB,IAAgB,CAAd;AACtB,6BAAiB,wBAAhB;AAAA,IAAuB,WAAW,GAAG,SAAS;AAAA,KAAO,MAAO;AAAA;AAE/D,aAAa,cAA8B,uBAAO;AAElD,IAAM,gBAAsB,iBAG1B,CAAC,IAAyB,QAAK;AAA9B,eAAE,YApBL,IAoBG,IAAgB,kBAAhB,IAAgB,CAAd;AACH,6BAAiB,yBAAhB;AAAA,IACC;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,KACI,MACN;AAAA,CACD;AACD,cAAc,cAA8B,wBAAQ;AAEpD,IAAM,gBAAsB,iBAG1B,CAAC,IAAmC,QAAK;AAAxC,eAAE,aAAW,SAnChB,IAmCG,IAA0B,kBAA1B,IAA0B,CAAxB,aAAW;AACd,8BAAC;A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Y","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\n\nconst Dialog = DialogPrimitive.Root;\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = ({ className, ...props }: DialogPrimitive.DialogPortalProps) => (\n <DialogPrimitive.Portal className={cn(className)} {...props} />\n);\nDialogPortal.displayName = DialogPrimitive.Portal.displayName;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n \"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg md:w-full\",\n className,\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close className=\"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground\">\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div className={cn(\"flex flex-col space-y-1.5 text-center sm:text-left\", className)} {...props} />\n);\nDialogHeader.displayName = \"DialogHeader\";\n\nconst DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2\", className)}\n {...props}\n />\n);\nDialogFooter.displayName = \"DialogFooter\";\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\"text-lg font-semibold leading-none tracking-tight\", className)}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogFooter,\n DialogTitle,\n DialogDescription,\n};\n"]}
|
|
@@ -7,9 +7,7 @@ var HoveringEditorContext = createContext({
|
|
|
7
7
|
setIsDisplayed: () => {
|
|
8
8
|
}
|
|
9
9
|
});
|
|
10
|
-
var HoveringEditorProvider = ({
|
|
11
|
-
children
|
|
12
|
-
}) => {
|
|
10
|
+
var HoveringEditorProvider = ({ children }) => {
|
|
13
11
|
const [isDisplayed, setIsDisplayed] = useState(false);
|
|
14
12
|
return /* @__PURE__ */ jsx(HoveringEditorContext.Provider, {
|
|
15
13
|
value: { isDisplayed, setIsDisplayed },
|
|
@@ -20,4 +18,4 @@ var useHoveringEditorContext = () => useContext(HoveringEditorContext);
|
|
|
20
18
|
|
|
21
19
|
export { HoveringEditorProvider, useHoveringEditorContext };
|
|
22
20
|
//# sourceMappingURL=out.js.map
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-QRKKPCUD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/hovering-toolbar/hovering-editor-provider.tsx"],"names":[],"mappings":";AAAA,SAAgB,eAAe,UAAU,kBAA6B;AAoBlE;AAbJ,IAAM,wBAAwB,cAA0C;AAAA,EACtE,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EAAC;AACzB,CAAC;AAMM,IAAM,yBAAyB,CAAC,EAAE,SAAS,MAAmC;AACnF,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AAEpD,SACE,oBAAC,sBAAsB,UAAtB;AAAA,IAA+B,OAAO,EAAE,aAAa,eAAe;AAAA,IAClE;AAAA,GACH;AAEJ;AAEO,IAAM,2BAA2B,MAAM,WAAW,qBAAqB","sourcesContent":["import React, { createContext, useState, useContext, ReactNode } from \"react\";\n\ninterface HoveringEditorContextProps {\n isDisplayed: boolean;\n setIsDisplayed: (value: boolean) => void;\n}\n\nconst HoveringEditorContext = createContext<HoveringEditorContextProps>({\n isDisplayed: false,\n setIsDisplayed: () => {},\n});\n\ninterface HoveringEditorProviderProps {\n children: ReactNode;\n}\n\nexport const HoveringEditorProvider = ({ children }: HoveringEditorProviderProps) => {\n const [isDisplayed, setIsDisplayed] = useState(false);\n\n return (\n <HoveringEditorContext.Provider value={{ isDisplayed, setIsDisplayed }}>\n {children}\n </HoveringEditorContext.Provider>\n );\n};\n\nexport const useHoveringEditorContext = () => useContext(HoveringEditorContext);\n"]}
|
|
@@ -71,4 +71,4 @@ var defaultInsertionsApiConfig = {
|
|
|
71
71
|
|
|
72
72
|
export { defaultInsertionsApiConfig, defaultInsertionsFewShotMessages, defaultInsertionsMakeSystemPrompt };
|
|
73
73
|
//# sourceMappingURL=out.js.map
|
|
74
|
-
//# sourceMappingURL=chunk-
|
|
74
|
+
//# sourceMappingURL=chunk-RBR32FWA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/autosuggestions-config/insertions-api-config.tsx"],"names":[],"mappings":";AASO,IAAM,oCAAsD,CACjE,iBACA,kBACG;AACH,SAAO;AAAA;AAAA;AAAA,mBAGW;AAAA;AAAA;AAAA;AAAA,EAIlB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeF;AAEO,IAAM,mCAA4D;AAAA,EACvE;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,SACE;AAAA,EACJ;AACF;AAEO,IAAM,6BAAkD;AAAA,EAC7D,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AACnB","sourcesContent":["import { MakeSystemPrompt } from \"./subtypes/make-system-prompt\";\nimport { MinimalChatGPTMessage } from \"./subtypes/minimal-chat-gpt-message\";\n\nexport interface InsertionsApiConfig {\n makeSystemPrompt: MakeSystemPrompt;\n fewShotMessages: MinimalChatGPTMessage[];\n forwardedParams: { [key: string]: any } | undefined;\n}\n\nexport const defaultInsertionsMakeSystemPrompt: MakeSystemPrompt = (\n textareaPurpose,\n contextString,\n) => {\n return `You are a versatile writing assistant.\n \nThe user is writing some text.\nThe purpose is: \\\"${textareaPurpose}\\\"\n\nThe following external context is also provided. Use it to help you make better suggestions!!!\n\\`\\`\\`\n${contextString}\n\\`\\`\\`\n\nThe user also provides you with a prompt for INSERTIONS into the text they are writing. \nYour job is to come up with an INSERTION into the text that the user would like AS BEST YOU CAN.\nOnly insert a SHORT segment. Usually 1 sentence, or at most 1 paragraph.\n\nAdjust yourself to the user's style and implied intent.\n\nThe user will provide the text before and after the cursor, as well as the insertion prompt. You should use this to infer the best relevant insertion.\n<TextAfterCursor>\n<TextBeforeCursor>\n<InsertionPrompt>\n<YourSuggestion>\n`;\n};\n\nexport const defaultInsertionsFewShotMessages: MinimalChatGPTMessage[] = [\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: \"While I was there I also picked up some apples, oranges, and bananas.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: \"This morning I woke up and went straight to the grocery store.\",\n },\n {\n role: \"user\",\n name: \"InsertionPrompt\",\n content: \"I bought a big watermelon\",\n },\n {\n role: \"assistant\",\n content:\n \" When I arrived I went straight to the produce section and picked out a big watermelon. \",\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content:\n \"and (iii) to the appointment of the Equityholders' Representative pursuant to Section 10.7 of the Merger Agreement and to the provisions thereof.\",\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content:\n 'The Optionholder, in the Optionholder\\'s capacity as a holder of vested Options, hereby irrevocably and unconditionally agrees: (i) that the Optionholder shall be deemed an \"Equityholder\" under the Merger Agreement and shall be entitled to the rights and benefits, and subject to the obligations, of an \"Equityholder\" thereunder;',\n },\n {\n role: \"user\",\n name: \"InsertionPrompt\",\n content: \"add section about the optionholder's pro rata share\",\n },\n {\n role: \"assistant\",\n content:\n ' (ii) that, for purposes of this Agreement and the Merger Agreement, the applicable percentage set forth opposite the name of the Optionholder in the Distribution Waterfall shall be such the Optionholder\\'s \"Pro Rata Share\"; ',\n },\n];\n\nexport const defaultInsertionsApiConfig: InsertionsApiConfig = {\n makeSystemPrompt: defaultInsertionsMakeSystemPrompt,\n fewShotMessages: defaultInsertionsFewShotMessages,\n forwardedParams: undefined,\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/editor-to-text.ts"],"names":[],"mappings":";AAAA,SAAiC,eAAe;AAKhD,SAAS,6BACP,QACA,OACuB;AAEvB,QAAM,2BAA2B,IAAI;AAAA,IACnC,MACG,IAAI,CAAC,MAAM,UAAU;AACpB,UAAI,QAAQ,UAAU,IAAI,KAAK,OAAO,SAAS,IAAI,GAAG;AACpD,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT,CAAC,EACA,OAAO,CAAC,UAAU,UAAU,EAAE;AAAA,EACnC;AAIA,QAAM,oBAAoB,MAAM,OAAO,CAAC,MAAM,UAAU;AACtD,UAAM,WAAW,yBAAyB,IAAI,KAAK;AACnD,QAAI,UAAU;AACZ,aAAO;AAAA,IACT;AAEA,UAAM,sBACJ,yBAAyB,IAAI,QAAQ,CAAC,KAAK,yBAAyB,IAAI,QAAQ,CAAC;AACnF,QAAI,qBAAqB;AACvB,aAAQ,KAAa,SAAS;AAAA,IAChC;AAEA,WAAO;AAAA,EACT,CAAC;AAED,SAAO,kBACJ,IAAI,CAAC,SAAS;AACb,QAAI,QAAQ,UAAU,IAAI,GAAG;AAC3B,cAAQ,KAAK,MAAM;AAAA,QACjB,KAAK;AACH,iBAAO,6BAA6B,QAAQ,KAAK,QAAQ;AAAA,QAC3D,KAAK;AACH,iBAAO,CAAC;AAAA,MACZ;AAAA,IACF,OAAO;AACL,aAAO,CAAC,IAAI;AAAA,IACd;AAAA,EACF,CAAC,EACA,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,GAAG,GAAG,CAAC,CAAC;AAC7C;AAEO,IAAM,eAAe,CAAC,WAAqD;AAChF,QAAM,YAAY,6BAA6B,QAAQ,OAAO,QAAQ;AAEtE,QAAM,OAAO,UAAU,IAAI,CAAC,kBAAkB,cAAc,IAAI,EAAE,KAAK,IAAI;AAE3E,SAAO;AACT","sourcesContent":["import { BaseEditor, Descendant, Element } from \"slate\";\nimport { HistoryEditor } from \"slate-history\";\nimport { ReactEditor } from \"slate-react\";\nimport { SuggestionAwareText } from \"../types/base/custom-editor\";\n\nfunction nodeChildrenToTextComponents(\n editor: BaseEditor & ReactEditor & HistoryEditor,\n nodes: Descendant[],\n): SuggestionAwareText[] {\n // find inlineable elements\n const indeciesOfInlineElements = new Set(\n nodes\n .map((node, index) => {\n if (Element.isElement(node) && editor.isInline(node)) {\n return index;\n }\n return -1;\n })\n .filter((index) => index !== -1),\n );\n\n // ignorable elements = inline elements,\n // or neighbors of inline elements that are {text: \"\"}\n const nonIgnorableItems = nodes.filter((node, index) => {\n const isInline = indeciesOfInlineElements.has(index);\n if (isInline) {\n return false;\n }\n\n const isNeighbourOfInline =\n indeciesOfInlineElements.has(index - 1) || indeciesOfInlineElements.has(index + 1);\n if (isNeighbourOfInline) {\n return (node as any).text !== \"\";\n }\n\n return true;\n });\n\n return nonIgnorableItems\n .map((node) => {\n if (Element.isElement(node)) {\n switch (node.type) {\n case \"paragraph\":\n return nodeChildrenToTextComponents(editor, node.children);\n case \"suggestion\":\n return [];\n }\n } else {\n return [node];\n }\n })\n .reduce((acc, val) => acc.concat(val), []);\n}\n\nexport const editorToText = (editor: BaseEditor & ReactEditor & HistoryEditor) => {\n const flattened = nodeChildrenToTextComponents(editor, editor.children);\n\n const text = flattened.map((textComponent) => textComponent.text).join(\"\\n\");\n\n return text;\n};\n"]}
|
|
@@ -8,17 +8,14 @@ var ChatlikeApiEndpoint = class {
|
|
|
8
8
|
static fromCopilotApiConfig(copilotApiConfig) {
|
|
9
9
|
return new ChatlikeApiEndpoint(
|
|
10
10
|
(abortSignal, messages, forwardedProps) => __async(this, null, function* () {
|
|
11
|
-
const res = yield fetch(
|
|
12
|
-
|
|
13
|
-
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
signal: abortSignal
|
|
20
|
-
}
|
|
21
|
-
);
|
|
11
|
+
const res = yield fetch(copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint, {
|
|
12
|
+
method: "POST",
|
|
13
|
+
headers: __spreadValues({}, copilotApiConfig.headers),
|
|
14
|
+
body: JSON.stringify(__spreadProps(__spreadValues(__spreadValues({}, forwardedProps), copilotApiConfig.body), {
|
|
15
|
+
messages
|
|
16
|
+
})),
|
|
17
|
+
signal: abortSignal
|
|
18
|
+
});
|
|
22
19
|
const bodySteram = res.body;
|
|
23
20
|
if (!bodySteram) {
|
|
24
21
|
throw new Error("The response body is empty.");
|
|
@@ -35,4 +32,4 @@ var ChatlikeApiEndpoint = class {
|
|
|
35
32
|
|
|
36
33
|
export { ChatlikeApiEndpoint };
|
|
37
34
|
//# sourceMappingURL=out.js.map
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-TZLW7PBU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/autosuggestions-config/subtypes/chatlike-api-endpoint.tsx"],"names":[],"mappings":";;;;;;;AAAA,SAA2B,oCAAoC;AAexD,IAAM,sBAAN,MAA0B;AAAA,EAG/B,YAAY,KAAuC;AACjD,SAAK,MAAM;AAAA,EACb;AAAA,EAOA,OAAO,qBAAqB,kBAAyD;AACnF,WAAO,IAAI;AAAA,MACT,CACE,aACA,UACA,mBACG;AACH,cAAM,MAAM,MAAM,MAAM,6BAA6B,gBAAgB,EAAE,iBAAiB;AAAA,UACtF,QAAQ;AAAA,UACR,SAAS,mBACJ,iBAAiB;AAAA,UAEtB,MAAM,KAAK,UAAU,gDAChB,iBACA,iBAAiB,OAFD;AAAA,YAGnB;AAAA,UACF,EAAC;AAAA,UACD,QAAQ;AAAA,QACV,CAAC;AAED,cAAM,aAAgD,IAAI;AAC1D,YAAI,CAAC,YAAY;AACf,gBAAM,IAAI,MAAM,6BAA6B;AAAA,QAC/C;AAGA,cAAM,eAAe,WAAW,YAAY,IAAI,kBAAkB,CAAC;AAEnE,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAAA,EAOA,OAAO,OAAO,KAA4D;AACxE,WAAO,IAAI,oBAAoB,GAAG;AAAA,EACpC;AACF","sourcesContent":["import { CopilotApiConfig, copilotApiConfigExtrapolator } from \"@copilotkit/react-core\";\nimport { MinimalChatGPTMessage } from \"./minimal-chat-gpt-message\";\n\nexport type ChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any },\n) => Promise<string>;\n\nexport type StreamingChatlikeApiEndpointImpl = (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any },\n) => Promise<ReadableStream<string>>;\n\nexport class ChatlikeApiEndpoint {\n public run: StreamingChatlikeApiEndpointImpl;\n\n constructor(run: StreamingChatlikeApiEndpointImpl) {\n this.run = run;\n }\n\n /**\n * Creates a new instance of ChatlikeApiEndpoint with the provided API endpoint.\n * @param apiEndpoint The URL of the OpenAI-compatible API endpoint.\n * @returns A new instance of ChatlikeApiEndpoint.\n */\n static fromCopilotApiConfig(copilotApiConfig: CopilotApiConfig): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(\n async (\n abortSignal: AbortSignal,\n messages: MinimalChatGPTMessage[],\n forwardedProps?: { [key: string]: any },\n ) => {\n const res = await fetch(copilotApiConfigExtrapolator(copilotApiConfig).chatApiEndpoint, {\n method: \"POST\",\n headers: {\n ...copilotApiConfig.headers,\n },\n body: JSON.stringify({\n ...forwardedProps,\n ...copilotApiConfig.body,\n messages: messages,\n }),\n signal: abortSignal,\n });\n\n const bodySteram: ReadableStream<Uint8Array> | null = res.body;\n if (!bodySteram) {\n throw new Error(\"The response body is empty.\");\n }\n\n // map the stream to a stream of strings\n const stringStream = bodySteram.pipeThrough(new TextDecoderStream());\n\n return stringStream;\n },\n );\n }\n\n /**\n * Creates a fully customized instance of ChatlikeApiEndpoint.\n * @param run - The implementation of the ChatlikeApiEndpointImpl interface.\n * @returns A new instance of ChatlikeApiEndpoint .\n */\n static custom(run: StreamingChatlikeApiEndpointImpl): ChatlikeApiEndpoint {\n return new ChatlikeApiEndpoint(run);\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { withPartialHistory, defaultShouldSave } from './chunk-
|
|
1
|
+
import { withPartialHistory, defaultShouldSave } from './chunk-2CDXHWVF.mjs';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { createEditor, Element } from 'slate';
|
|
4
4
|
import { withReact } from 'slate-react';
|
|
@@ -62,4 +62,4 @@ function useCopilotTextareaEditor() {
|
|
|
62
62
|
|
|
63
63
|
export { useCopilotTextareaEditor };
|
|
64
64
|
//# sourceMappingURL=out.js.map
|
|
65
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-U3LUDDT5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/base-copilot-textarea-implementation/use-copilot-textarea-editor.tsx"],"names":["editor"],"mappings":";;;;;;AAAA,SAAS,eAAe;AACxB,SAAS,cAAc,eAAe;AACtC,SAAS,iBAAiB;AAQ1B,IAAM,aAAkC,CAAC,IAAI,SAAS;AACpD,QAAM,mBAAmB;AAEzB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iBAAO,QAAQ;AAAA,QACjB;AACE,iBAAO,SAAS,OAAO;AAAA,MAC3B;AAAA,IACF;AAEA,WAAOA;AAAA,EACT,GAAG,CAAC,CAAC;AAEL,SAAO;AACT","sourcesContent":["import { useMemo } from \"react\";\nimport { createEditor, Element } from \"slate\";\nimport { withReact } from \"slate-react\";\nimport {\n defaultShouldSave,\n ShouldSaveToHistory,\n withPartialHistory,\n} from \"../../lib/slatejs-edits/with-partial-history\";\nimport { CustomEditor } from \"../../types/base/custom-editor\";\n\nconst shouldSave: ShouldSaveToHistory = (op, prev) => {\n const excludedNodeType = \"suggestion\";\n // Check if the operation involves the suggestion inline node type\n if (\n op.type === \"insert_node\" &&\n Element.isElement(op.node) &&\n op.node.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type === \"remove_node\" &&\n Element.isElement(op.node) &&\n op.node.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type === \"set_node\" &&\n \"type\" in op.newProperties &&\n op.newProperties.type === excludedNodeType\n ) {\n return false;\n }\n\n if (op.type == \"set_node\" && \"type\" in op.properties && op.properties.type === excludedNodeType) {\n return false;\n }\n\n if (\n op.type === \"merge_node\" &&\n \"type\" in op.properties &&\n op.properties.type === excludedNodeType\n ) {\n return false;\n }\n\n if (\n op.type === \"split_node\" &&\n \"type\" in op.properties &&\n op.properties.type === excludedNodeType\n ) {\n return false;\n }\n\n // Otherwise, save the operation to history\n return defaultShouldSave(op, prev);\n};\n\nexport function useCopilotTextareaEditor(): CustomEditor {\n const editor = useMemo(() => {\n const editor = withPartialHistory(withReact(createEditor()), shouldSave);\n\n const { isVoid } = editor;\n editor.isVoid = (element) => {\n switch (element.type) {\n case \"suggestion\":\n return true;\n default:\n return isVoid(element);\n }\n };\n\n const { markableVoid } = editor;\n editor.markableVoid = (element) => {\n switch (element.type) {\n case \"suggestion\":\n return true;\n default:\n return markableVoid(element);\n }\n };\n\n const { isInline } = editor;\n editor.isInline = (element) => {\n switch (element.type) {\n case \"suggestion\":\n return element.inline;\n default:\n return isInline(element);\n }\n };\n\n return editor;\n }, []);\n\n return editor;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/base-copilot-textarea/render-element.tsx"],"names":[],"mappings":";;;;;;AAUe,cAgBX,YAhBW;AANR,SAAS,0BACd,kBACuB;AACvB,SAAO,CAAC,UAA8B;AACpC,YAAQ,MAAM,QAAQ,MAAM;AAAA,MAC1B,KAAK;AACH,eAAO,oBAAC,mCAAmB,MAAO;AAAA,MACpC,KAAK;AACH,eAAO,oBAAC,oDAAsB,QAAtB;AAAA,UAA6B;AAAA,UAAoC;AAAA,IAC7E;AAAA,EACF;AACF;AAEA,IAAM,iBAAiB,CAAC,UAA8B;AACpD,SAAO,oBAAC,wCAAQ,MAAM,aAAd;AAAA,IAA2B,gBAAM;AAAA,IAAS;AACpD;AACA,IAAM,oBAAoB,CACxB,UAGG;AACH,SACE,qBAAC,yCACK,MAAM,aADX;AAAA,IAEC,OAAO,mBACF,MAAM;AAAA,IAEX,iBAAiB;AAAA,IAEhB;AAAA,YAAM;AAAA,MACN,MAAM,QAAQ,SAAS,gBAAgB,MAAM,QAAQ;AAAA;AAAA,IACxD;AAEJ","sourcesContent":["import { RenderElementProps } from \"slate-react\";\n\nexport type RenderElementFunction = (props: RenderElementProps) => JSX.Element;\n\nexport function makeRenderElementFunction(\n suggestionsStyle: React.CSSProperties,\n): RenderElementFunction {\n return (props: RenderElementProps) => {\n switch (props.element.type) {\n case \"paragraph\":\n return <DefaultElement {...props} />;\n case \"suggestion\":\n return <SuggestionElement {...props} suggestionsStyle={suggestionsStyle} />;\n }\n };\n}\n\nconst DefaultElement = (props: RenderElementProps) => {\n return <div {...props.attributes}>{props.children}</div>;\n};\nconst SuggestionElement = (\n props: RenderElementProps & {\n suggestionsStyle: React.CSSProperties;\n },\n) => {\n return (\n <span\n {...props.attributes}\n style={{\n ...props.suggestionsStyle,\n }}\n contentEditable={false}\n >\n {props.children /* https://github.com/ianstormtaylor/slate/issues/3930 */}\n {props.element.type === \"suggestion\" && props.element.content}\n </span>\n );\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { editorToText } from './chunk-
|
|
1
|
+
import { editorToText } from './chunk-T6MTDQZ7.mjs';
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
3
|
import { useSlateSelector } from 'slate-react';
|
|
4
4
|
import { Range } from 'slate';
|
|
@@ -42,4 +42,4 @@ function usePrevious(value) {
|
|
|
42
42
|
|
|
43
43
|
export { TrackerTextEditedSinceLastCursorMovement };
|
|
44
44
|
//# sourceMappingURL=out.js.map
|
|
45
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-V55OPCG4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/base-copilot-textarea/track-cursor-moved-since-last-text-change.tsx"],"names":[],"mappings":";;;;;AAAA,SAAgB,WAAW,cAAc;AAEzC,SAAS,wBAAwB;AACjC,SAAS,aAAa;AA0Bb;AApBF,SAAS,yCACd,OACa;AACb,QAAM,cAAmC,iBAAiB,CAAC,WAAW;AAAA,IACpE,WAAW,MAAM;AAAA,IACjB,MAAM,aAAa,KAAK;AAAA,EAC1B,EAAE;AAEF,QAAM,gBAAgB,YAAY,WAAW;AAE7C,YAAU,MAAM;AACd,QAAI,CAAC,eAAe;AAClB;AAAA,IACF;AAEA,QAAI,gCAAgC,eAAe,WAAW,GAAG;AAC/D,YAAM,kCAAkC,IAAI;AAAA,IAC9C;AAAA,EACF,GAAG,CAAC,MAAM,mCAAmC,WAAW,CAAC;AAEzD,SAAO,gCAAE;AACX;AAKA,IAAM,kCAAkC,CAAC,MAA2B,SAA8B;AAEhG,QAAM,qBAAqB,CAAC,iBAAiB,KAAK,WAAW,KAAK,SAAS;AAG3E,QAAM,aAAa,KAAK,SAAS,KAAK;AAEtC,SAAO,sBAAsB;AAC/B;AACA,IAAM,mBAAmB,CAAC,GAAkB,MAAqB;AAC/D,MAAI,CAAC,KAAK,CAAC;AAAG,WAAO;AACrB,MAAI,CAAC,KAAK,CAAC;AAAG,WAAO;AACrB,SAAO,MAAM,OAAO,GAAG,CAAC;AAC1B;AACA,SAAS,YAAe,OAAyB;AAC/C,QAAM,MAAM,OAAU;AAEtB,YAAU,MAAM;AACd,QAAI,UAAU;AAAA,EAChB,CAAC;AAED,SAAO,IAAI;AACb","sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { BaseSelection } from \"slate\";\nimport { useSlateSelector } from \"slate-react\";\nimport { Range } from \"slate\";\nimport { editorToText } from \"../../lib/editor-to-text\";\n\ninterface TrackerTextEditedSinceLastCursorMovementProps {\n setCursorMovedSinceLastTextChange: (value: boolean) => void;\n}\nexport function TrackerTextEditedSinceLastCursorMovement(\n props: TrackerTextEditedSinceLastCursorMovementProps,\n): JSX.Element {\n const cursorState: RelevantEditorState = useSlateSelector((state) => ({\n selection: state.selection,\n text: editorToText(state),\n }));\n\n const previousState = usePrevious(cursorState);\n\n useEffect(() => {\n if (!previousState) {\n return;\n }\n\n if (cursorChangedWithoutTextChanged(previousState, cursorState)) {\n props.setCursorMovedSinceLastTextChange(true);\n }\n }, [props.setCursorMovedSinceLastTextChange, cursorState]);\n\n return <></>;\n}\ntype RelevantEditorState = {\n selection: BaseSelection;\n text: string;\n};\nconst cursorChangedWithoutTextChanged = (prev: RelevantEditorState, next: RelevantEditorState) => {\n // Check if the selection has changed\n const isSelectionChanged = !isSelectionEqual(prev.selection, next.selection);\n\n // Check if the text content remains the same\n const isTextSame = prev.text === next.text;\n\n return isSelectionChanged && isTextSame;\n};\nconst isSelectionEqual = (a: BaseSelection, b: BaseSelection) => {\n if (!a && !b) return true;\n if (!a || !b) return false;\n return Range.equals(a, b);\n};\nfunction usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = value;\n });\n\n return ref.current;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChatlikeApiEndpoint } from './chunk-
|
|
2
|
-
import { retry } from './chunk-
|
|
1
|
+
import { ChatlikeApiEndpoint } from './chunk-TZLW7PBU.mjs';
|
|
2
|
+
import { retry } from './chunk-KNQIEOFP.mjs';
|
|
3
3
|
import { __async } from './chunk-MRXNTQOX.mjs';
|
|
4
4
|
import { CopilotContext } from '@copilotkit/react-core';
|
|
5
5
|
import { useContext, useCallback } from 'react';
|
|
@@ -35,11 +35,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
35
35
|
}
|
|
36
36
|
];
|
|
37
37
|
const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
|
|
38
|
-
return yield apiEndpoint.run(
|
|
39
|
-
abortSignal,
|
|
40
|
-
messages,
|
|
41
|
-
insertionApiConfig.forwardedParams
|
|
42
|
-
);
|
|
38
|
+
return yield apiEndpoint.run(abortSignal, messages, insertionApiConfig.forwardedParams);
|
|
43
39
|
}));
|
|
44
40
|
return res;
|
|
45
41
|
}),
|
|
@@ -79,11 +75,7 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
79
75
|
}
|
|
80
76
|
];
|
|
81
77
|
const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);
|
|
82
|
-
return yield apiEndpoint.run(
|
|
83
|
-
abortSignal,
|
|
84
|
-
messages,
|
|
85
|
-
editingApiConfig.forwardedParams
|
|
86
|
-
);
|
|
78
|
+
return yield apiEndpoint.run(abortSignal, messages, editingApiConfig.forwardedParams);
|
|
87
79
|
}));
|
|
88
80
|
return res;
|
|
89
81
|
}),
|
|
@@ -92,19 +84,9 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
92
84
|
const insertionOrEditingFunction = useCallback(
|
|
93
85
|
(editorState, insertionPrompt, documents, abortSignal) => __async(this, null, function* () {
|
|
94
86
|
if (editorState.selectedText === "") {
|
|
95
|
-
return yield insertionFunction(
|
|
96
|
-
editorState,
|
|
97
|
-
insertionPrompt,
|
|
98
|
-
documents,
|
|
99
|
-
abortSignal
|
|
100
|
-
);
|
|
87
|
+
return yield insertionFunction(editorState, insertionPrompt, documents, abortSignal);
|
|
101
88
|
} else {
|
|
102
|
-
return yield editingFunction(
|
|
103
|
-
editorState,
|
|
104
|
-
insertionPrompt,
|
|
105
|
-
documents,
|
|
106
|
-
abortSignal
|
|
107
|
-
);
|
|
89
|
+
return yield editingFunction(editorState, insertionPrompt, documents, abortSignal);
|
|
108
90
|
}
|
|
109
91
|
}),
|
|
110
92
|
[insertionFunction, editingFunction]
|
|
@@ -114,4 +96,4 @@ function useMakeStandardInsertionOrEditingFunction(textareaPurpose, contextCateg
|
|
|
114
96
|
|
|
115
97
|
export { useMakeStandardInsertionOrEditingFunction };
|
|
116
98
|
//# sourceMappingURL=out.js.map
|
|
117
|
-
//# sourceMappingURL=chunk-
|
|
99
|
+
//# sourceMappingURL=chunk-VYECMH73.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/make-autosuggestions-function/use-make-standard-insertion-function.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,SAAS,sBAAsB;AAC/B,SAAS,aAAa,kBAAkB;AA0BjC,SAAS,0CACd,iBACA,mBACA,oBACA,kBACwC;AACxC,QAAM,EAAE,kBAAkB,iBAAiB,IAAI,WAAW,cAAc;AAExE,QAAM,oBAAoB;AAAA,IACxB,CACE,aACA,iBACA,WACA,gBACG;AACH,YAAM,MAAM,MAAM,MAAM,MAAY;AAClC,cAAM,WAAoC;AAAA,UACxC;AAAA,YACE,MAAM;AAAA,YACN,SAAS,mBAAmB;AAAA,cAC1B;AAAA,cACA,iBAAiB,WAAW,iBAAiB;AAAA,YAC/C;AAAA,UACF;AAAA,UACA,GAAG,mBAAmB;AAAA,UACtB;AAAA,YACE,MAAM;AAAA,YACN,MAAM;AAAA,YACN,SAAS,YAA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,YAAY,iBAAiB,IAAI;AACnC,eAAO,MAAM,kBAAkB,aAAa,iBAAiB,WAAW,WAAW;AAAA,MACrF,OAAO;AACL,eAAO,MAAM,gBAAgB,aAAa,iBAAiB,WAAW,WAAW;AAAA,MACnF;AAAA,IACF;AAAA,IACA,CAAC,mBAAmB,eAAe;AAAA,EACrC;AAEA,SAAO;AACT","sourcesContent":["import { CopilotContext } from \"@copilotkit/react-core\";\nimport { useCallback, useContext } from \"react\";\nimport { ChatlikeApiEndpoint, MinimalChatGPTMessage } from \"../../types\";\nimport { retry } from \"../../lib/retry\";\nimport {\n EditingEditorState,\n Generator_InsertionOrEditingSuggestion,\n InsertionEditorApiConfig,\n InsertionEditorState,\n} from \"../../types/base/autosuggestions-bare-function\";\nimport { InsertionsApiConfig } from \"../../types/autosuggestions-config/insertions-api-config\";\nimport { EditingApiConfig } from \"../../types/autosuggestions-config/editing-api-config\";\nimport { DocumentPointer } from \"@copilotkit/react-core\";\n\n/**\n * Returns a memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n * The function takes in the text before and after the cursor, and an abort signal.\n * It sends a POST request to the API endpoint with the messages array containing the system message, few shot messages, and user messages.\n * The function returns the suggestion from the API response.\n *\n * @param textareaPurpose - The purpose of the textarea. This is included in the system message.\n * @param apiEndpoint - The API endpoint to send the autosuggestion request to.\n * @param makeSystemMessage - A function that takes in a context string and returns a system message to include in the autosuggestion request.\n * @param fewShotMessages - An array of few shot messages to include in the autosuggestion request.\n * @param contextCategories - The categories of context strings we want to include. By default, we include the (default) \"global\" context category.\n * @returns A memoized function that sends a request to the specified API endpoint to get an autosuggestion for the user's input.\n */\nexport function useMakeStandardInsertionOrEditingFunction(\n textareaPurpose: string,\n contextCategories: string[],\n insertionApiConfig: InsertionsApiConfig,\n editingApiConfig: EditingApiConfig,\n): Generator_InsertionOrEditingSuggestion {\n const { getContextString, copilotApiConfig } = useContext(CopilotContext);\n\n const insertionFunction = useCallback(\n async (\n editorState: EditingEditorState,\n insertionPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: insertionApiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(documents, contextCategories),\n ),\n },\n ...insertionApiConfig.fewShotMessages,\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: editorState.textAfterCursor,\n },\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: editorState.textBeforeCursor,\n },\n {\n role: \"user\",\n name: \"InsertionPrompt\",\n content: insertionPrompt,\n },\n ];\n\n const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);\n return await apiEndpoint.run(abortSignal, messages, insertionApiConfig.forwardedParams);\n });\n\n return res;\n },\n [insertionApiConfig, getContextString, contextCategories, textareaPurpose],\n );\n\n const editingFunction = useCallback(\n async (\n editorState: EditingEditorState,\n editingPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n const res = await retry(async () => {\n const messages: MinimalChatGPTMessage[] = [\n {\n role: \"system\",\n content: editingApiConfig.makeSystemPrompt(\n textareaPurpose,\n getContextString(documents, contextCategories),\n ),\n },\n ...editingApiConfig.fewShotMessages,\n {\n role: \"user\",\n name: \"TextBeforeCursor\",\n content: editorState.textBeforeCursor,\n },\n {\n role: \"user\",\n name: \"TextToEdit\",\n content: editorState.selectedText,\n },\n {\n role: \"user\",\n name: \"TextAfterCursor\",\n content: editorState.textAfterCursor,\n },\n {\n role: \"user\",\n name: \"EditingPrompt\",\n content: editingPrompt,\n },\n ];\n\n const apiEndpoint = ChatlikeApiEndpoint.fromCopilotApiConfig(copilotApiConfig);\n return await apiEndpoint.run(abortSignal, messages, editingApiConfig.forwardedParams);\n });\n\n return res;\n },\n [editingApiConfig, getContextString, contextCategories, textareaPurpose],\n );\n\n const insertionOrEditingFunction = useCallback(\n async (\n editorState: EditingEditorState,\n insertionPrompt: string,\n documents: DocumentPointer[],\n abortSignal: AbortSignal,\n ) => {\n if (editorState.selectedText === \"\") {\n return await insertionFunction(editorState, insertionPrompt, documents, abortSignal);\n } else {\n return await editingFunction(editorState, insertionPrompt, documents, abortSignal);\n }\n },\n [insertionFunction, editingFunction],\n );\n\n return insertionOrEditingFunction;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { HoveringInsertionPromptBox } from './chunk-
|
|
2
|
-
import { useHoveringEditorContext } from './chunk-
|
|
3
|
-
import { Portal, Menu } from './chunk-
|
|
4
|
-
import { getTextAroundSelection, getFullEditorTextWithNewlines } from './chunk-
|
|
1
|
+
import { HoveringInsertionPromptBox } from './chunk-CK7Q3Y5A.mjs';
|
|
2
|
+
import { useHoveringEditorContext } from './chunk-QRKKPCUD.mjs';
|
|
3
|
+
import { Portal, Menu } from './chunk-ZKRM3DIR.mjs';
|
|
4
|
+
import { getTextAroundSelection, getFullEditorTextWithNewlines } from './chunk-ECR45NSD.mjs';
|
|
5
5
|
import { useRef, useState, useEffect } from 'react';
|
|
6
6
|
import { Transforms } from 'slate';
|
|
7
7
|
import { useSlate, useSlateSelection } from 'slate-react';
|
|
@@ -105,4 +105,4 @@ function editorState(editor, selection) {
|
|
|
105
105
|
|
|
106
106
|
export { HoveringToolbar };
|
|
107
107
|
//# sourceMappingURL=out.js.map
|
|
108
|
-
//# sourceMappingURL=chunk-
|
|
108
|
+
//# sourceMappingURL=chunk-W2ZHOUV6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/hovering-toolbar/hovering-toolbar.tsx"],"names":["selection"],"mappings":";;;;;;;;;;;;;;;;AACA,SAAS,WAAoB,QAAQ,gBAAgB;AACrD,SAAiD,kBAAkB;AACnE,SAAS,UAAU,yBAAyB;AAgHlC;AA7FH,IAAM,kBAAuE,CAAC,UAAU;AAC7F,QAAM,MAAM,OAAuB,IAAI;AACvC,QAAM,SAAS,SAAS;AACxB,QAAM,YAAY,kBAAkB;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UAAM,qBAAqB,CAAC,UAAsB;AAChD,UAAI,IAAI,WAAW,CAAC,IAAI,QAAQ,SAAS,MAAM,MAAc,GAAG;AAC9D,uBAAe,KAAK;AAAA,MACtB;AAAA,IACF;AAEA,aAAS,iBAAiB,aAAa,kBAAkB;AACzD,WAAO,MAAM;AACX,eAAS,oBAAoB,aAAa,kBAAkB;AAAA,IAC9D;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,CAAC;AAExB,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,SACE,oBAAC;AAAA,IACC,8BAAC;AAAA,MACC;AAAA,MACA,WACE,MAAM,sBACN;AAAA,MAGD,yBAAe,aACd,oBAAC;AAAA,QACC,aAAa,YAAY,QAAQ,SAAS;AAAA,QAC1C,WAAW,MAAM;AAAA,QACjB,aAAa,MAAM;AACjB,yBAAe,KAAK;AAAA,QACtB;AAAA,QACA,kBAAkB,CAAC,iBAAiB;AAClC,kBAAQ,IAAI,iBAAiB,YAAY;AAEzC,qBAAW,OAAO,QAAQ,EAAE,IAAI,UAAU,CAAC;AAC3C,qBAAW,WAAW,QAAQ,cAAc;AAAA,YAC1C,IAAI;AAAA,UACN,CAAC;AACD,yBAAe,KAAK;AAAA,QACtB;AAAA,QACA,mBAAmB,MAAM;AAAA,OAC3B;AAAA,KAEJ;AAAA,GACF;AAEJ;AAEA,SAAS,YAAY,QAAgB,WAAyC;AAC5E,QAAM,mBAAmB,uBAAuB,MAAM;AACtD,MAAI,kBAAkB;AACpB,WAAO;AAAA,EACT;AAEA,SAAO;AAAA,IACL,kBAAkB,8BAA8B,MAAM;AAAA,IACtD,iBAAiB;AAAA,IACjB,cAAc;AAAA,EAChB;AACF","sourcesContent":["import { css } from \"@emotion/css\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { BaseSelection, Editor, Range, Location, Transforms } from \"slate\";\nimport { useSlate, useSlateSelection } from \"slate-react\";\nimport { HoveringInsertionPromptBox } from \"./text-insertion-prompt-box\";\nimport { Button, Icon, Menu, Portal } from \"./hovering-toolbar-components\";\nimport { useHoveringEditorContext } from \"./hovering-editor-provider\";\nimport {\n getFullEditorTextWithNewlines,\n getTextAroundSelection,\n} from \"../../lib/get-text-around-cursor\";\nimport {\n EditingEditorState,\n InsertionEditorApiConfig,\n} from \"../../types/base/autosuggestions-bare-function\";\n\nexport interface HoveringToolbarProps {\n apiConfig: InsertionEditorApiConfig;\n contextCategories: string[];\n hoverMenuClassname: string | undefined;\n}\n\nexport const HoveringToolbar: (props: HoveringToolbarProps) => JSX.Element | null = (props) => {\n const ref = useRef<HTMLDivElement>(null);\n const editor = useSlate();\n const selection = useSlateSelection();\n const { isDisplayed, setIsDisplayed } = useHoveringEditorContext();\n\n // only render on client\n const [isClient, setIsClient] = useState(false);\n useEffect(() => {\n setIsClient(true);\n }, []);\n\n useEffect(() => {\n const el = ref.current;\n const { selection } = editor;\n\n if (!el) {\n return;\n }\n\n if (!selection) {\n el.removeAttribute(\"style\");\n return;\n }\n\n const domSelection = window.getSelection();\n if (!domSelection) {\n return;\n }\n\n const domRange = domSelection.getRangeAt(0);\n const rect = domRange.getBoundingClientRect();\n\n // We use window = (0,0,0,0) as a signal that the selection is not in the original copilot-textarea,\n // but inside the hovering window.\n //\n // in such case, we simply do nothing.\n if (rect.top === 0 && rect.left === 0 && rect.width === 0 && rect.height === 0) {\n return;\n }\n\n const minGapFromEdge = 60;\n const verticalOffsetFromCorner = 35;\n const horizontalOffsetFromCorner = 15;\n let top = rect.top + window.scrollY - el.offsetHeight + verticalOffsetFromCorner;\n // make sure top is in the viewport and not too close to the edge\n if (top < minGapFromEdge) {\n top = rect.bottom + window.scrollY + minGapFromEdge;\n } else if (top + el.offsetHeight > window.innerHeight - minGapFromEdge) {\n top = rect.top + window.scrollY - el.offsetHeight - minGapFromEdge;\n }\n\n let left =\n rect.left + window.scrollX - el.offsetWidth / 2 + rect.width / 2 + horizontalOffsetFromCorner;\n // make sure left is in the viewport and not too close to the edge\n if (left < minGapFromEdge) {\n left = minGapFromEdge;\n } else if (left + el.offsetWidth > window.innerWidth - minGapFromEdge) {\n left = window.innerWidth - el.offsetWidth - minGapFromEdge;\n }\n\n el.style.opacity = \"1\";\n el.style.top = `${top}px`;\n el.style.left = `${left}px`;\n });\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (ref.current && !ref.current.contains(event.target as Node)) {\n setIsDisplayed(false);\n }\n };\n\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [ref, setIsDisplayed]);\n\n if (!isClient) {\n return null;\n }\n\n return (\n <Portal>\n <Menu\n ref={ref}\n className={\n props.hoverMenuClassname ||\n \"p-2 absolute z-10 top-[-10000px] left-[-10000px] mt-[-6px] opacity-0 transition-opacity duration-700\"\n }\n >\n {isDisplayed && selection && (\n <HoveringInsertionPromptBox\n editorState={editorState(editor, selection)}\n apiConfig={props.apiConfig}\n closeWindow={() => {\n setIsDisplayed(false);\n }}\n performInsertion={(insertedText) => {\n console.log(\"inserted text\", insertedText);\n // replace the selection with the inserted text\n Transforms.delete(editor, { at: selection });\n Transforms.insertText(editor, insertedText, {\n at: selection,\n });\n setIsDisplayed(false);\n }}\n contextCategories={props.contextCategories}\n />\n )}\n </Menu>\n </Portal>\n );\n};\n\nfunction editorState(editor: Editor, selection: Location): EditingEditorState {\n const textAroundCursor = getTextAroundSelection(editor);\n if (textAroundCursor) {\n return textAroundCursor;\n }\n\n return {\n textBeforeCursor: getFullEditorTextWithNewlines(editor),\n textAfterCursor: \"\",\n selectedText: \"\",\n };\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { areEqual_autocompleteState } from './chunk-
|
|
2
|
-
import { nullableCompatibleEqualityCheck } from './chunk-
|
|
3
|
-
import { Debouncer } from './chunk-
|
|
1
|
+
import { areEqual_autocompleteState } from './chunk-BLRAOGXD.mjs';
|
|
2
|
+
import { nullableCompatibleEqualityCheck } from './chunk-F626GQCD.mjs';
|
|
3
|
+
import { Debouncer } from './chunk-M2DR4KVB.mjs';
|
|
4
4
|
import { __async } from './chunk-MRXNTQOX.mjs';
|
|
5
5
|
import { useState, useCallback, useMemo, useEffect } from 'react';
|
|
6
6
|
|
|
7
|
-
function useAutosuggestions(debounceTime,
|
|
7
|
+
function useAutosuggestions(debounceTime, shouldAcceptAutosuggestionOnKeyPress, autosuggestionFunction, insertAutocompleteSuggestion, disableWhenEmpty, disabled) {
|
|
8
8
|
const [previousAutocompleteState, setPreviousAutocompleteState] = useState(null);
|
|
9
9
|
const [currentAutocompleteSuggestion, setCurrentAutocompleteSuggestion] = useState(null);
|
|
10
10
|
const awaitForAndAppendSuggestion = useCallback(
|
|
@@ -15,10 +15,7 @@ function useAutosuggestions(debounceTime, acceptAutosuggestionKey, autosuggestio
|
|
|
15
15
|
if (disableWhenEmpty && editorAutocompleteState.textBeforeCursor === "" && editorAutocompleteState.textAfterCursor === "") {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
const suggestion = yield autosuggestionFunction(
|
|
19
|
-
editorAutocompleteState,
|
|
20
|
-
abortSignal
|
|
21
|
-
);
|
|
18
|
+
const suggestion = yield autosuggestionFunction(editorAutocompleteState, abortSignal);
|
|
22
19
|
if (!suggestion || abortSignal.aborted) {
|
|
23
20
|
throw new DOMException("Aborted", "AbortError");
|
|
24
21
|
}
|
|
@@ -27,17 +24,10 @@ function useAutosuggestions(debounceTime, acceptAutosuggestionKey, autosuggestio
|
|
|
27
24
|
point: editorAutocompleteState.cursorPoint
|
|
28
25
|
});
|
|
29
26
|
}),
|
|
30
|
-
[
|
|
31
|
-
autosuggestionFunction,
|
|
32
|
-
setCurrentAutocompleteSuggestion,
|
|
33
|
-
disableWhenEmpty,
|
|
34
|
-
disabled
|
|
35
|
-
]
|
|
27
|
+
[autosuggestionFunction, setCurrentAutocompleteSuggestion, disableWhenEmpty, disabled]
|
|
36
28
|
);
|
|
37
29
|
const debouncedFunction = useMemo(
|
|
38
|
-
() => new Debouncer(
|
|
39
|
-
debounceTime
|
|
40
|
-
),
|
|
30
|
+
() => new Debouncer(debounceTime),
|
|
41
31
|
[debounceTime]
|
|
42
32
|
);
|
|
43
33
|
useEffect(() => {
|
|
@@ -75,7 +65,7 @@ function useAutosuggestions(debounceTime, acceptAutosuggestionKey, autosuggestio
|
|
|
75
65
|
const keyDownHandler = useCallback(
|
|
76
66
|
(event) => {
|
|
77
67
|
if (currentAutocompleteSuggestion) {
|
|
78
|
-
if (event
|
|
68
|
+
if (shouldAcceptAutosuggestionOnKeyPress(event)) {
|
|
79
69
|
event.preventDefault();
|
|
80
70
|
insertAutocompleteSuggestion(currentAutocompleteSuggestion);
|
|
81
71
|
setCurrentAutocompleteSuggestion(null);
|
|
@@ -86,7 +76,7 @@ function useAutosuggestions(debounceTime, acceptAutosuggestionKey, autosuggestio
|
|
|
86
76
|
currentAutocompleteSuggestion,
|
|
87
77
|
setCurrentAutocompleteSuggestion,
|
|
88
78
|
insertAutocompleteSuggestion,
|
|
89
|
-
|
|
79
|
+
shouldAcceptAutosuggestionOnKeyPress
|
|
90
80
|
]
|
|
91
81
|
);
|
|
92
82
|
return {
|
|
@@ -98,4 +88,4 @@ function useAutosuggestions(debounceTime, acceptAutosuggestionKey, autosuggestio
|
|
|
98
88
|
|
|
99
89
|
export { useAutosuggestions };
|
|
100
90
|
//# sourceMappingURL=out.js.map
|
|
101
|
-
//# sourceMappingURL=chunk-
|
|
91
|
+
//# sourceMappingURL=chunk-WVRTFPNO.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/base-copilot-textarea-implementation/use-autosuggestions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,aAAa,WAAW,SAAS,gBAAgB;AAgBnD,SAAS,mBACd,cACA,sCACA,wBACA,8BACA,kBACA,UAC0B;AAC1B,QAAM,CAAC,2BAA2B,4BAA4B,IAC5D,SAAyC,IAAI;AAE/C,QAAM,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,gBAAM,eAAe;AACrB,uCAA6B,6BAA6B;AAC1D,2CAAiC,IAAI;AAAA,QACvC;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,EACpB;AACF","sourcesContent":["import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Debouncer } from \"../../lib/debouncer\";\nimport { nullableCompatibleEqualityCheck } from \"../../lib/utils\";\nimport { AutosuggestionsBareFunction } from \"../../types/base\";\nimport { AutosuggestionState } from \"../../types/base/autosuggestion-state\";\nimport {\n EditorAutocompleteState,\n areEqual_autocompleteState,\n} from \"../../types/base/editor-autocomplete-state\";\n\nexport interface UseAutosuggestionsResult {\n currentAutocompleteSuggestion: AutosuggestionState | null;\n onChangeHandler: (newEditorState: EditorAutocompleteState | null) => void;\n onKeyDownHandler: (event: React.KeyboardEvent<HTMLDivElement>) => void;\n}\n\nexport function useAutosuggestions(\n debounceTime: number,\n shouldAcceptAutosuggestionOnKeyPress: (event: React.KeyboardEvent<HTMLDivElement>) => boolean,\n autosuggestionFunction: AutosuggestionsBareFunction,\n insertAutocompleteSuggestion: (suggestion: AutosuggestionState) => void,\n disableWhenEmpty: boolean,\n disabled: boolean,\n): UseAutosuggestionsResult {\n const [previousAutocompleteState, setPreviousAutocompleteState] =\n useState<EditorAutocompleteState | null>(null);\n\n const [currentAutocompleteSuggestion, setCurrentAutocompleteSuggestion] =\n useState<AutosuggestionState | null>(null);\n\n const awaitForAndAppendSuggestion: (\n editorAutocompleteState: EditorAutocompleteState,\n abortSignal: AbortSignal,\n ) => Promise<void> = useCallback(\n async (editorAutocompleteState: EditorAutocompleteState, abortSignal: AbortSignal) => {\n // early return if disabled\n if (disabled) {\n return;\n }\n\n if (\n disableWhenEmpty &&\n editorAutocompleteState.textBeforeCursor === \"\" &&\n editorAutocompleteState.textAfterCursor === \"\"\n ) {\n return;\n }\n\n // fetch the suggestion\n const suggestion = await autosuggestionFunction(editorAutocompleteState, abortSignal);\n\n // We'll assume for now that the autocomplete function might or might not respect the abort signal.\n if (!suggestion || abortSignal.aborted) {\n throw new DOMException(\"Aborted\", \"AbortError\");\n }\n\n setCurrentAutocompleteSuggestion({\n text: suggestion,\n point: editorAutocompleteState.cursorPoint,\n });\n },\n [autosuggestionFunction, setCurrentAutocompleteSuggestion, disableWhenEmpty, disabled],\n );\n\n const debouncedFunction = useMemo(\n () => new Debouncer<[editorAutocompleteState: EditorAutocompleteState]>(debounceTime),\n [debounceTime],\n );\n\n // clean current state when unmounting or disabling\n useEffect(() => {\n return () => {\n debouncedFunction.cancel();\n setCurrentAutocompleteSuggestion(null);\n };\n }, [debouncedFunction, disabled]);\n\n const onChange = useCallback(\n (newEditorState: EditorAutocompleteState | null) => {\n const editorStateHasChanged = !nullableCompatibleEqualityCheck(\n areEqual_autocompleteState,\n previousAutocompleteState,\n newEditorState,\n );\n setPreviousAutocompleteState(newEditorState);\n\n // if no change, do nothing\n if (!editorStateHasChanged) {\n return;\n }\n\n // if change, then first null out the current suggestion\n setCurrentAutocompleteSuggestion(null);\n\n // then try to get a new suggestion, debouncing to avoid too many requests while typing\n if (newEditorState) {\n debouncedFunction.debounce(awaitForAndAppendSuggestion, newEditorState);\n } else {\n debouncedFunction.cancel();\n }\n },\n [\n previousAutocompleteState,\n setPreviousAutocompleteState,\n debouncedFunction,\n awaitForAndAppendSuggestion,\n setCurrentAutocompleteSuggestion,\n ],\n );\n\n const keyDownHandler = useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (currentAutocompleteSuggestion) {\n if (shouldAcceptAutosuggestionOnKeyPress(event)) {\n event.preventDefault();\n insertAutocompleteSuggestion(currentAutocompleteSuggestion);\n setCurrentAutocompleteSuggestion(null);\n }\n }\n },\n [\n currentAutocompleteSuggestion,\n setCurrentAutocompleteSuggestion,\n insertAutocompleteSuggestion,\n shouldAcceptAutosuggestionOnKeyPress,\n ],\n );\n\n return {\n currentAutocompleteSuggestion,\n onChangeHandler: onChange,\n onKeyDownHandler: keyDownHandler,\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Label } from './chunk-
|
|
1
|
+
import { Label } from './chunk-FK2XUDQQ.mjs';
|
|
2
2
|
import Chip from '@mui/material/Chip/Chip.js';
|
|
3
3
|
import Avatar from '@mui/material/Avatar/Avatar.js';
|
|
4
4
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
@@ -20,9 +20,7 @@ var IncludedFilesPreview = ({
|
|
|
20
20
|
return /* @__PURE__ */ jsx(FileChipPreview, {
|
|
21
21
|
filePointer,
|
|
22
22
|
onDelete: () => {
|
|
23
|
-
setIncludedFiles(
|
|
24
|
-
(prev) => prev.filter((fp) => fp !== filePointer)
|
|
25
|
-
);
|
|
23
|
+
setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));
|
|
26
24
|
}
|
|
27
25
|
}, `file-${filePointer.sourceApplication}.${filePointer.name}`);
|
|
28
26
|
})
|
|
@@ -30,10 +28,7 @@ var IncludedFilesPreview = ({
|
|
|
30
28
|
]
|
|
31
29
|
});
|
|
32
30
|
};
|
|
33
|
-
var FileChipPreview = ({
|
|
34
|
-
filePointer,
|
|
35
|
-
onDelete
|
|
36
|
-
}) => {
|
|
31
|
+
var FileChipPreview = ({ filePointer, onDelete }) => {
|
|
37
32
|
return /* @__PURE__ */ jsx(Chip, {
|
|
38
33
|
label: filePointer.name,
|
|
39
34
|
onDelete,
|
|
@@ -47,4 +42,4 @@ var FileChipPreview = ({
|
|
|
47
42
|
|
|
48
43
|
export { FileChipPreview, IncludedFilesPreview };
|
|
49
44
|
//# sourceMappingURL=out.js.map
|
|
50
|
-
//# sourceMappingURL=chunk-
|
|
45
|
+
//# sourceMappingURL=chunk-ZEHF3AXH.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/hovering-toolbar/text-insertion-prompt-box/included-files-preview.tsx"],"names":[],"mappings":";;;;;AAGA,OAAO,UAAU;AACjB,OAAO,YAAY;AAYf,SACE,KADF;AALG,IAAM,uBAA4D,CAAC;AAAA,EACxE;AAAA,EACA;AACF,MAAM;AACJ,SACE,qBAAC;AAAA,IAAI,WAAU;AAAA,IACb;AAAA,0BAAC;AAAA,QAAM,WAAU;AAAA,QAAG;AAAA,OAAiB;AAAA,MACrC,oBAAC;AAAA,QAAI,WAAU;AAAA,QACZ,wBAAc,IAAI,CAAC,aAAa,UAAU;AACzC,iBACE,oBAAC;AAAA,YAEC;AAAA,YACA,UAAU,MAAM;AACd,+BAAiB,CAAC,SAAS,KAAK,OAAO,CAAC,OAAO,OAAO,WAAW,CAAC;AAAA,YACpE;AAAA,aAJK,QAAQ,YAAY,qBAAqB,YAAY,MAK5D;AAAA,QAEJ,CAAC;AAAA,OACH;AAAA;AAAA,GACF;AAEJ;AAOO,IAAM,kBAAiD,CAAC,EAAE,aAAa,SAAS,MAAM;AAC3F,SACE,oBAAC;AAAA,IACC,OAAO,YAAY;AAAA,IACnB;AAAA,IACA,QACE,oBAAC;AAAA,MACC,KAAK,YAAY;AAAA,MACjB,KAAK,YAAY;AAAA,MACjB,IAAI,EAAE,iBAAiB,cAAc;AAAA,KACtC;AAAA,GAEL;AAEJ","sourcesContent":["import { DocumentPointer } from \"@copilotkit/react-core\";\nimport { Label } from \"../../ui/label\";\nimport React from \"react\";\nimport Chip from \"@mui/material/Chip/Chip.js\";\nimport Avatar from \"@mui/material/Avatar/Avatar.js\";\n\nexport interface IncludedFilesPreviewProps {\n includedFiles: DocumentPointer[];\n setIncludedFiles: React.Dispatch<React.SetStateAction<DocumentPointer[]>>;\n}\n\nexport const IncludedFilesPreview: React.FC<IncludedFilesPreviewProps> = ({\n includedFiles,\n setIncludedFiles,\n}) => {\n return (\n <div className=\"flex flex-col gap-2 mt-2\">\n <Label className=\"\">Included context:</Label>\n <div className=\"flex flex-wrap gap-2\">\n {includedFiles.map((filePointer, index) => {\n return (\n <FileChipPreview\n key={`file-${filePointer.sourceApplication}.${filePointer.name}`}\n filePointer={filePointer}\n onDelete={() => {\n setIncludedFiles((prev) => prev.filter((fp) => fp !== filePointer));\n }}\n />\n );\n })}\n </div>\n </div>\n );\n};\n\nexport interface FileChipPreviewProp {\n filePointer: DocumentPointer;\n onDelete: () => void;\n}\n\nexport const FileChipPreview: React.FC<FileChipPreviewProp> = ({ filePointer, onDelete }) => {\n return (\n <Chip\n label={filePointer.name}\n onDelete={onDelete}\n avatar={\n <Avatar\n src={filePointer.iconImageUri}\n alt={filePointer.sourceApplication}\n sx={{ backgroundColor: \"transparent\" }}\n ></Avatar>\n }\n />\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/hovering-toolbar/hovering-toolbar-components.tsx"],"names":[],"mappings":";;;;;;;AAAA,SAAS,KAAK,UAAU;AACxB,OAAO,WAAuC;AAC9C,OAAO,cAAc;AAsBjB;AAfG,IAAM,SAAS,MAAM;AAAA,EAC1B,CACE,IAWA,QACA;AAZA,iBACE;AAAA;AAAA,MACA;AAAA,MACA;AAAA,IAdN,IAWI,IAIK,kBAJL,IAIK;AAAA,MAHH;AAAA,MACA;AAAA,MACA;AAAA;AAUF,+BAAC,yCACK,QADL;AAAA,MAEC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA;AAAA,mBAEW,WAAY,SAAS,UAAU,SAAU,SAAS,UAAU;AAAA;AAAA,MAEzE;AAAA,MACF;AAAA;AAEJ;AAEO,IAAM,OAAO,MAAM;AAAA,EACxB,CAAC,IAAuD,QAAkC;AAAzF,iBAAE,YAvCL,IAuCG,IAAgB,kBAAhB,IAAgB,CAAd;AACD,+BAAC,yCACK,QADL;AAAA,MAEC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA;AAAA;AAAA;AAAA,MAIF;AAAA,MACF;AAAA;AAEJ;AAEO,IAAM,OAAO,MAAM;AAAA,EACxB,CAAC,IAAuD,QAAiC;AAAxF,iBAAE,YAxDL,IAwDG,IAAgB,kBAAhB,IAAgB,CAAd;AACD,+BAAC,wCACK,QADL;AAAA,MAEC,gBAAa;AAAA,MACb;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MASF;AAAA,MACF;AAAA;AAEJ;AACO,IAAM,SAAS,CAAC,EAAE,SAAS,MAAqC;AACrE,SAAO,OAAO,aAAa,WAAW,SAAS,aAAa,UAAU,SAAS,IAAI,IAAI;AACzF;AAEO,IAAM,UAAU,MAAM;AAAA,EAC3B,CAAC,IAAuD,QAA2B;AAAlF,iBAAE,YAjFL,IAiFG,IAAgB,kBAAhB,IAAgB,CAAd;AACD,+BAAC,uCACK,QADL;AAAA,MAEC;AAAA,MACA,WAAW;AAAA,QACT;AAAA,QACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOF;AAAA,MACF;AAAA;AAEJ","sourcesContent":["import { css, cx } from \"@emotion/css\";\nimport React, { PropsWithChildren, Ref } from \"react\";\nimport ReactDOM from \"react-dom\";\n\ninterface BaseProps {\n className: string;\n [key: string]: unknown;\n}\n\nexport const Button = React.forwardRef(\n (\n {\n className,\n active,\n reversed,\n ...props\n }: PropsWithChildren<\n {\n active: boolean;\n reversed: boolean;\n } & BaseProps\n >,\n ref: Ref<HTMLSpanElement | null>,\n ) => (\n <span\n {...props}\n ref={ref as Ref<HTMLSpanElement>}\n className={cx(\n className,\n css`\n cursor: pointer;\n color: ${reversed ? (active ? \"white\" : \"#aaa\") : active ? \"black\" : \"#ccc\"};\n `,\n )}\n />\n ),\n);\n\nexport const Icon = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref: Ref<HTMLSpanElement | null>) => (\n <span\n {...props}\n ref={ref as Ref<HTMLSpanElement>}\n className={cx(\n \"material-icons\",\n className,\n css`\n font-size: 18px;\n vertical-align: text-bottom;\n `,\n )}\n />\n ),\n);\n\nexport const Menu = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref: Ref<HTMLDivElement | null>) => (\n <div\n {...props}\n data-test-id=\"menu\"\n ref={ref as Ref<HTMLDivElement>}\n className={cx(\n className,\n css`\n & > * {\n display: inline-block;\n }\n\n & > * + * {\n margin-left: 15px;\n }\n `,\n )}\n />\n ),\n);\nexport const Portal = ({ children }: { children: React.ReactNode }) => {\n return typeof document === \"object\" ? ReactDOM.createPortal(children, document.body) : null;\n};\n\nexport const Toolbar = React.forwardRef(\n ({ className, ...props }: PropsWithChildren<BaseProps>, ref?: Ref<HTMLDivElement>) => (\n <Menu\n {...props}\n ref={ref}\n className={cx(\n className,\n css`\n position: relative;\n padding: 1px 18px 17px;\n margin: 0 -20px;\n border-bottom: 2px solid #eee;\n margin-bottom: 20px;\n `,\n )}\n />\n ),\n);\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Dialog, DialogContent } from './chunk-
|
|
2
|
-
import { cn } from './chunk-
|
|
1
|
+
import { Dialog, DialogContent } from './chunk-PDCIGRCE.mjs';
|
|
2
|
+
import { cn } from './chunk-F626GQCD.mjs';
|
|
3
3
|
import { __objRest, __spreadValues, __spreadProps } from './chunk-MRXNTQOX.mjs';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { Command as Command$1 } from 'cmdk';
|
|
@@ -47,10 +47,7 @@ var CommandList = React.forwardRef((_a, ref) => {
|
|
|
47
47
|
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
48
48
|
return /* @__PURE__ */ jsx(Command$1.List, __spreadValues({
|
|
49
49
|
ref,
|
|
50
|
-
className: cn(
|
|
51
|
-
"max-h-[300px] overflow-y-auto overflow-x-hidden pb-2",
|
|
52
|
-
className
|
|
53
|
-
)
|
|
50
|
+
className: cn("max-h-[300px] overflow-y-auto overflow-x-hidden pb-2", className)
|
|
54
51
|
}, props));
|
|
55
52
|
});
|
|
56
53
|
CommandList.displayName = Command$1.List.displayName;
|
|
@@ -90,20 +87,13 @@ var CommandItem = React.forwardRef((_a, ref) => {
|
|
|
90
87
|
});
|
|
91
88
|
CommandItem.displayName = Command$1.Item.displayName;
|
|
92
89
|
var CommandShortcut = (_a) => {
|
|
93
|
-
var _b = _a, {
|
|
94
|
-
className
|
|
95
|
-
} = _b, props = __objRest(_b, [
|
|
96
|
-
"className"
|
|
97
|
-
]);
|
|
90
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
98
91
|
return /* @__PURE__ */ jsx("span", __spreadValues({
|
|
99
|
-
className: cn(
|
|
100
|
-
"ml-auto text-xs tracking-widest text-muted-foreground",
|
|
101
|
-
className
|
|
102
|
-
)
|
|
92
|
+
className: cn("ml-auto text-xs tracking-widest text-muted-foreground", className)
|
|
103
93
|
}, props));
|
|
104
94
|
};
|
|
105
95
|
CommandShortcut.displayName = "CommandShortcut";
|
|
106
96
|
|
|
107
97
|
export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut };
|
|
108
98
|
//# sourceMappingURL=out.js.map
|
|
109
|
-
//# sourceMappingURL=chunk-
|
|
99
|
+
//# sourceMappingURL=chunk-ZMNOLW5V.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/ui/command.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,YAAY,WAAW;AAEvB,SAAS,WAAW,wBAAwB;AAU1C;AAdF;AAUA,IAAM,UAAgB,iBAGpB,CAAC,IAAyB,QAAK;AAA9B,eAAE,YAbL,IAaG,IAAgB,kBAAhB,IAAgB,CAAd;AACH,6BAAC;AAAA,IACC;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,KACI,MACN;AAAA,CACD;AACD,QAAQ,cAAc,iBAAiB;AAIvC,IAAM,gBAAgB,CAAC,OAA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9B,eAAE,YAnGL,IAmGG,IAAgB,kBAAhB,IAAgB,CAAd;AACH,6BAAC,iBAAiB,WAAjB;AAAA,IACC;AAAA,IACA,WAAW,GAAG,wBAAwB,SAAS;AAAA,KAC3C,MACN;AAAA,CACD;AACD,iBAAiB,cAAc,iBAAiB,UAAU;AAE1D,IAAM,cAAoB,iBAGxB,CAAC,IAAyB,QAAK;AAA9B,eAAE,YA/GL,IA+GG,IAAgB,kBAAhB,IAAgB,CAAd;AACH,6BAAC,iBAAiB,MAAjB;AAAA,IACC;AAAA,IACA,WAAW;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,KACI,MACN;AAAA,CACD;AAED,YAAY,cAAc,iBAAiB,KAAK;AAEhD,IAAM,kBAAkB,CAAC,OAAmE;AAAnE,eAAE,YA5H3B,IA4HyB,IAAgB,kBAAhB,IAAgB,CAAd;AACzB,SACE,oBAAC;AAAA,IACC,WAAW,GAAG,yDAAyD,SAAS;AAAA,KAC5E,MACN;AAEJ;AACA,gBAAgB,cAAc","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { DialogProps } from \"@radix-ui/react-dialog\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { Search } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\nimport { Dialog, DialogContent } from \"./dialog\";\n\nconst Command = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive\n ref={ref}\n className={cn(\n \"flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground\",\n className,\n )}\n {...props}\n />\n));\nCommand.displayName = CommandPrimitive.displayName;\n\ninterface CommandDialogProps extends DialogProps {}\n\nconst CommandDialog = ({ children, ...props }: CommandDialogProps) => {\n return (\n <Dialog {...props}>\n <DialogContent className=\"overflow-hidden p-0 shadow-lg\">\n <Command className=\"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5\">\n {children}\n </Command>\n </DialogContent>\n </Dialog>\n );\n};\n\nconst CommandInput = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Input>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>\n>(({ className, ...props }, ref) => (\n <div className=\"flex items-center border-b px-3\" cmdk-input-wrapper=\"\">\n {/* <Search className=\"mr-2 h-4 w-4 shrink-0 opacity-50\" /> */}\n <CommandPrimitive.Input\n ref={ref}\n className={cn(\n \"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\",\n className,\n )}\n {...props}\n />\n </div>\n));\n\nCommandInput.displayName = CommandPrimitive.Input.displayName;\n\nconst CommandList = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.List>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.List\n ref={ref}\n className={cn(\"max-h-[300px] overflow-y-auto overflow-x-hidden pb-2\", className)}\n {...props}\n />\n));\n\nCommandList.displayName = CommandPrimitive.List.displayName;\n\nconst CommandEmpty = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Empty>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>\n>((props, ref) => (\n <CommandPrimitive.Empty ref={ref} className=\"py-6 text-center text-sm\" {...props} />\n));\n\nCommandEmpty.displayName = CommandPrimitive.Empty.displayName;\n\nconst CommandGroup = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Group>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Group\n ref={ref}\n className={cn(\n \"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\",\n className,\n )}\n {...props}\n />\n));\n\nCommandGroup.displayName = CommandPrimitive.Group.displayName;\n\nconst CommandSeparator = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Separator>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Separator\n ref={ref}\n className={cn(\"-mx-1 h-px bg-border\", className)}\n {...props}\n />\n));\nCommandSeparator.displayName = CommandPrimitive.Separator.displayName;\n\nconst CommandItem = React.forwardRef<\n React.ElementRef<typeof CommandPrimitive.Item>,\n React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>\n>(({ className, ...props }, ref) => (\n <CommandPrimitive.Item\n ref={ref}\n className={cn(\n \"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\",\n className,\n )}\n {...props}\n />\n));\n\nCommandItem.displayName = CommandPrimitive.Item.displayName;\n\nconst CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {\n return (\n <span\n className={cn(\"ml-auto text-xs tracking-widest text-muted-foreground\", className)}\n {...props}\n />\n );\n};\nCommandShortcut.displayName = \"CommandShortcut\";\n\nexport {\n Command,\n CommandDialog,\n CommandInput,\n CommandList,\n CommandEmpty,\n CommandGroup,\n CommandItem,\n CommandShortcut,\n CommandSeparator,\n};\n"]}
|