@reforma/components 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Composer/Composer.module.css +1 -0
- package/dist/Composer/Composer.module.css.js +26 -0
- package/dist/Composer/Composer.module.css.js.map +1 -0
- package/dist/Composer/RichField.d.ts +3 -0
- package/dist/Composer/RichField.d.ts.map +1 -0
- package/dist/Composer/RichField.js +44 -0
- package/dist/Composer/RichField.js.map +1 -0
- package/dist/Composer/context.d.ts +44 -0
- package/dist/Composer/context.d.ts.map +1 -0
- package/dist/Composer/context.js +205 -0
- package/dist/Composer/context.js.map +1 -0
- package/dist/Composer/index.d.ts +5 -0
- package/dist/Composer/index.d.ts.map +1 -0
- package/dist/Composer/index.js +18 -0
- package/dist/{CreateComposer → Composer}/index.js.map +1 -1
- package/dist/Composer/parts.d.ts +22 -0
- package/dist/Composer/parts.d.ts.map +1 -0
- package/dist/Composer/parts.js +231 -0
- package/dist/Composer/parts.js.map +1 -0
- package/dist/{CreateComposer → Composer}/types.d.ts +6 -6
- package/dist/Composer/types.d.ts.map +1 -0
- package/dist/Modal/Modal.js +2 -2
- package/dist/Modal/Modal.js.map +1 -1
- package/dist/chat/Message/streamdown/codeCitation.d.ts.map +1 -1
- package/dist/chat/Message/streamdown/codeCitation.js +7 -7
- package/dist/chat/Message/streamdown/codeCitation.js.map +1 -1
- package/dist/chat/Message/turn/MessageTurnStore.js +23 -23
- package/dist/chat/Message/turn/MessageTurnStore.js.map +1 -1
- package/dist/chat/Tool/install-dependencies/InstallDependenciesTool.d.ts.map +1 -1
- package/dist/chat/Tool/install-dependencies/InstallDependenciesTool.js +2 -1
- package/dist/chat/Tool/install-dependencies/InstallDependenciesTool.js.map +1 -1
- package/dist/chat/Tool/mountTool.d.ts +6 -0
- package/dist/chat/Tool/mountTool.d.ts.map +1 -0
- package/dist/chat/Tool/project-env/ProjectEnvTool.d.ts.map +1 -1
- package/dist/chat/Tool/project-env/ProjectEnvTool.js +2 -1
- package/dist/chat/Tool/project-env/ProjectEnvTool.js.map +1 -1
- package/dist/chat/Tool/shell/ToolShell.d.ts.map +1 -1
- package/dist/chat/Tool/shell/ToolShell.js +86 -79
- package/dist/chat/Tool/shell/ToolShell.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +317 -304
- package/dist/index.js.map +1 -1
- package/dist/modals/ConfirmModal.d.ts +3 -1
- package/dist/modals/ConfirmModal.d.ts.map +1 -1
- package/dist/modals/ConfirmModal.js +61 -55
- package/dist/modals/ConfirmModal.js.map +1 -1
- package/dist/node_modules/react-aria/dist/private/interactions/useFocusable.js.map +1 -1
- package/package.json +2 -2
- package/dist/CreateComposer/CreateComposer.d.ts +0 -26
- package/dist/CreateComposer/CreateComposer.d.ts.map +0 -1
- package/dist/CreateComposer/CreateComposer.js +0 -338
- package/dist/CreateComposer/CreateComposer.js.map +0 -1
- package/dist/CreateComposer/CreateComposer.module.css +0 -1
- package/dist/CreateComposer/CreateComposer.module.css.js +0 -24
- package/dist/CreateComposer/CreateComposer.module.css.js.map +0 -1
- package/dist/CreateComposer/index.d.ts +0 -3
- package/dist/CreateComposer/index.d.ts.map +0 -1
- package/dist/CreateComposer/index.js +0 -5
- package/dist/CreateComposer/types.d.ts.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -6,9 +6,11 @@ export type OpenConfirmModalOptions = {
|
|
|
6
6
|
message: ReactNode;
|
|
7
7
|
confirmLabel?: string;
|
|
8
8
|
cancelLabel?: string;
|
|
9
|
+
/** Omit Cancel. The confirm button is the only action. */
|
|
10
|
+
showCancel?: boolean;
|
|
9
11
|
destructive?: boolean;
|
|
10
12
|
onConfirm: () => void | Promise<void>;
|
|
11
13
|
};
|
|
12
14
|
export declare function openConfirmModal(options: OpenConfirmModalOptions, modalOptions?: ModalOptionsRaw): Modal<import("..").ModalOptions<any>>;
|
|
13
|
-
export declare function ConfirmModalContent({ title, message, confirmLabel, cancelLabel, destructive, onConfirm, }: OpenConfirmModalOptions): import("react").JSX.Element;
|
|
15
|
+
export declare function ConfirmModalContent({ title, message, confirmLabel, cancelLabel, showCancel, destructive, onConfirm, }: OpenConfirmModalOptions): import("react").JSX.Element;
|
|
14
16
|
//# sourceMappingURL=ConfirmModal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmModal.d.ts","sourceRoot":"","sources":["../../src/modals/ConfirmModal.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAmB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmModal.d.ts","sourceRoot":"","sources":["../../src/modals/ConfirmModal.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,EAAmB,MAAM,UAAU,CAAC;AAKlD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,MAAM,uBAAuB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzC,CAAC;AAcF,wBAAgB,gBAAgB,CAC5B,OAAO,EAAE,uBAAuB,EAChC,YAAY,CAAC,EAAE,eAAe,yCAOjC;AAED,wBAAgB,mBAAmB,CAAC,EAChC,KAAK,EACL,OAAO,EACP,YAAwB,EACxB,WAAsB,EACtB,UAAiB,EACjB,WAAW,EACX,SAAS,GACZ,EAAE,uBAAuB,+BAoFzB"}
|
|
@@ -1,102 +1,108 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { Box as
|
|
3
|
-
import { Button as
|
|
1
|
+
import { useState as y } from "react";
|
|
2
|
+
import { Box as c } from "../Box/Box.js";
|
|
3
|
+
import { Button as f } from "../Button/Button.js";
|
|
4
4
|
import { useModalContext as E } from "../Modal/hooks/useModalProvider.js";
|
|
5
5
|
import M from "../Modal/Modal.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
6
|
+
import { Show as D } from "../Show/Show.js";
|
|
7
|
+
import { Text as m } from "../Text/Text.js";
|
|
8
|
+
import { toast as w } from "../Toast/Toast.js";
|
|
9
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
10
|
+
const P = 101100, C = {
|
|
10
11
|
shadow: !0,
|
|
11
12
|
width: 380,
|
|
12
13
|
clickOut: !0,
|
|
13
14
|
closeOnEscape: !0,
|
|
14
15
|
closeButton: !1,
|
|
15
|
-
zIndex:
|
|
16
|
+
zIndex: P
|
|
16
17
|
};
|
|
17
|
-
function
|
|
18
|
+
function j(i, e) {
|
|
18
19
|
return M.create({
|
|
19
|
-
...
|
|
20
|
-
...
|
|
21
|
-
component: /* @__PURE__ */
|
|
20
|
+
...C,
|
|
21
|
+
...e,
|
|
22
|
+
component: /* @__PURE__ */ t(v, {
|
|
22
23
|
...i
|
|
23
24
|
})
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
+
function v({
|
|
27
28
|
title: i,
|
|
28
|
-
message:
|
|
29
|
-
confirmLabel:
|
|
30
|
-
cancelLabel:
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
message: e,
|
|
30
|
+
confirmLabel: p = "Confirm",
|
|
31
|
+
cancelLabel: h = "Cancel",
|
|
32
|
+
showCancel: a = !0,
|
|
33
|
+
destructive: g,
|
|
34
|
+
onConfirm: O
|
|
33
35
|
}) {
|
|
34
36
|
const {
|
|
35
|
-
modal:
|
|
36
|
-
} = E(), [
|
|
37
|
-
if (
|
|
37
|
+
modal: o
|
|
38
|
+
} = E(), [n, d] = y(!1), l = async () => {
|
|
39
|
+
if (n)
|
|
38
40
|
return;
|
|
39
|
-
|
|
41
|
+
d(!0);
|
|
40
42
|
const {
|
|
41
|
-
clickOut:
|
|
42
|
-
closeOnEscape:
|
|
43
|
-
} =
|
|
44
|
-
|
|
43
|
+
clickOut: r,
|
|
44
|
+
closeOnEscape: x
|
|
45
|
+
} = o.currentOptions;
|
|
46
|
+
o.updateOptions({
|
|
45
47
|
clickOut: !1,
|
|
46
48
|
closeOnEscape: !1
|
|
47
49
|
});
|
|
48
50
|
try {
|
|
49
|
-
await
|
|
50
|
-
} catch (
|
|
51
|
-
|
|
52
|
-
clickOut:
|
|
53
|
-
closeOnEscape:
|
|
54
|
-
}),
|
|
55
|
-
message:
|
|
51
|
+
await O(), o.cancel();
|
|
52
|
+
} catch (u) {
|
|
53
|
+
d(!1), o.updateOptions({
|
|
54
|
+
clickOut: r,
|
|
55
|
+
closeOnEscape: x
|
|
56
|
+
}), w.error({
|
|
57
|
+
message: u instanceof Error ? u.message : "Something went wrong. Please try again."
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
};
|
|
59
|
-
return /* @__PURE__ */ c
|
|
61
|
+
return /* @__PURE__ */ s(c, {
|
|
60
62
|
gap: "xl",
|
|
61
63
|
padding: "xxl",
|
|
62
|
-
onKeyDown: (
|
|
63
|
-
|
|
64
|
+
onKeyDown: (r) => {
|
|
65
|
+
r.key !== "Enter" || r.defaultPrevented || n || r.target instanceof HTMLButtonElement || r.target instanceof HTMLAnchorElement || (r.preventDefault(), l());
|
|
64
66
|
},
|
|
65
|
-
children: [/* @__PURE__ */ c
|
|
67
|
+
children: [/* @__PURE__ */ s(c, {
|
|
66
68
|
gap: "md",
|
|
67
|
-
children: [/* @__PURE__ */
|
|
69
|
+
children: [/* @__PURE__ */ t(m, {
|
|
68
70
|
variant: "heading-3",
|
|
69
71
|
children: i
|
|
70
|
-
}), typeof
|
|
72
|
+
}), typeof e == "string" ? /* @__PURE__ */ t(m, {
|
|
71
73
|
variant: "md",
|
|
72
74
|
color: "secondary",
|
|
73
|
-
children:
|
|
74
|
-
}) :
|
|
75
|
-
}), /* @__PURE__ */ c
|
|
75
|
+
children: e
|
|
76
|
+
}) : e]
|
|
77
|
+
}), /* @__PURE__ */ s(c, {
|
|
76
78
|
direction: "row",
|
|
77
79
|
gap: "md",
|
|
78
80
|
fullWidth: !0,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
justify: a ? void 0 : "end",
|
|
82
|
+
equalWidth: a || void 0,
|
|
83
|
+
children: [/* @__PURE__ */ t(D, {
|
|
84
|
+
when: a,
|
|
85
|
+
children: /* @__PURE__ */ t(f, {
|
|
86
|
+
variant: "bordered",
|
|
87
|
+
isDisabled: n,
|
|
88
|
+
onPress: () => o.cancel(),
|
|
89
|
+
children: h
|
|
90
|
+
})
|
|
91
|
+
}), /* @__PURE__ */ t(f, {
|
|
86
92
|
autoFocus: !0,
|
|
87
|
-
color:
|
|
88
|
-
isPending:
|
|
89
|
-
isDisabled:
|
|
93
|
+
color: g ? "danger" : "primary",
|
|
94
|
+
isPending: n,
|
|
95
|
+
isDisabled: n,
|
|
90
96
|
onPress: () => {
|
|
91
97
|
l();
|
|
92
98
|
},
|
|
93
|
-
children:
|
|
99
|
+
children: p
|
|
94
100
|
})]
|
|
95
101
|
})]
|
|
96
102
|
});
|
|
97
103
|
}
|
|
98
104
|
export {
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
v as ConfirmModalContent,
|
|
106
|
+
j as openConfirmModal
|
|
101
107
|
};
|
|
102
108
|
//# sourceMappingURL=ConfirmModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmModal.js","sources":["../../src/modals/ConfirmModal.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { Modal, useModalContext } from '../Modal';\nimport { Text } from '../Text';\nimport { toast } from '../Toast';\n\nimport type { ReactNode } from 'react';\nimport type { ModalOptionsRaw } from '../Modal/typings';\n\nexport type OpenConfirmModalOptions = {\n title: string;\n message: ReactNode;\n confirmLabel?: string;\n cancelLabel?: string;\n destructive?: boolean;\n onConfirm: () => void | Promise<void>;\n};\n\n/** Keep in sync with `--z-confirm` in `@reforma/
|
|
1
|
+
{"version":3,"file":"ConfirmModal.js","sources":["../../src/modals/ConfirmModal.tsx"],"sourcesContent":["import { useState } from 'react';\n\nimport { Box } from '../Box';\nimport { Button } from '../Button';\nimport { Modal, useModalContext } from '../Modal';\nimport { Show } from '../Show';\nimport { Text } from '../Text';\nimport { toast } from '../Toast';\n\nimport type { ReactNode } from 'react';\nimport type { ModalOptionsRaw } from '../Modal/typings';\n\nexport type OpenConfirmModalOptions = {\n title: string;\n message: ReactNode;\n confirmLabel?: string;\n cancelLabel?: string;\n /** Omit Cancel. The confirm button is the only action. */\n showCancel?: boolean;\n destructive?: boolean;\n onConfirm: () => void | Promise<void>;\n};\n\n/** Keep in sync with `--z-confirm` in `@reforma/styles`. */\nconst CONFIRM_MODAL_Z_INDEX = 101100;\n\nconst DEFAULT_MODAL_OPTIONS: ModalOptionsRaw = {\n shadow: true,\n width: 380,\n clickOut: true,\n closeOnEscape: true,\n closeButton: false,\n zIndex: CONFIRM_MODAL_Z_INDEX,\n};\n\nexport function openConfirmModal(\n options: OpenConfirmModalOptions,\n modalOptions?: ModalOptionsRaw\n) {\n return Modal.create({\n ...DEFAULT_MODAL_OPTIONS,\n ...modalOptions,\n component: <ConfirmModalContent { ...options } />,\n });\n}\n\nexport function ConfirmModalContent({\n title,\n message,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n showCancel = true,\n destructive,\n onConfirm,\n}: OpenConfirmModalOptions) {\n const { modal } = useModalContext();\n const [isPending, setIsPending] = useState(false);\n\n const handleConfirm = async() => {\n if (isPending) {\n return;\n }\n\n setIsPending(true);\n const { clickOut, closeOnEscape } = modal.currentOptions;\n modal.updateOptions({ clickOut: false, closeOnEscape: false });\n\n try {\n await onConfirm();\n modal.cancel();\n }\n catch(error) {\n setIsPending(false);\n modal.updateOptions({ clickOut, closeOnEscape });\n toast.error({\n message: error instanceof Error ? error.message : 'Something went wrong. Please try again.',\n });\n }\n };\n\n return (\n <Box\n gap=\"xl\"\n padding=\"xxl\"\n onKeyDown={ (event) => {\n if (event.key !== 'Enter' || event.defaultPrevented || isPending) {\n return;\n }\n\n // Overlay / non-button focus: Enter confirms. Focused Cancel still cancels via its own activation.\n if (event.target instanceof HTMLButtonElement || event.target instanceof HTMLAnchorElement) {\n return;\n }\n\n event.preventDefault();\n void handleConfirm();\n } }\n >\n <Box gap=\"md\">\n <Text variant=\"heading-3\">{title}</Text>\n {typeof message === 'string'\n ? (\n <Text variant=\"md\" color=\"secondary\">\n {message}\n </Text>\n )\n : message}\n </Box>\n\n <Box\n direction=\"row\"\n gap=\"md\"\n fullWidth\n justify={ showCancel ? undefined : 'end' }\n equalWidth={ showCancel || undefined }\n >\n <Show when={ showCancel }>\n <Button\n variant=\"bordered\"\n isDisabled={ isPending }\n onPress={ () => modal.cancel() }\n >\n {cancelLabel}\n </Button>\n </Show>\n\n <Button\n autoFocus\n color={ destructive ? 'danger' : 'primary' }\n isPending={ isPending }\n isDisabled={ isPending }\n onPress={ () => void handleConfirm() }\n >\n {confirmLabel}\n </Button>\n </Box>\n </Box>\n );\n}\n"],"names":["CONFIRM_MODAL_Z_INDEX","DEFAULT_MODAL_OPTIONS","openConfirmModal","options","modalOptions","Modal","ConfirmModalContent","title","message","confirmLabel","cancelLabel","showCancel","destructive","onConfirm","modal","useModalContext","isPending","setIsPending","useState","handleConfirm","clickOut","closeOnEscape","error","toast","Box","event","_jsxs","_jsx","Text","Show","Button"],"mappings":";;;;;;;;;AASA,MAAMA,IAAwB,QACxBC,IAAwB;AAAA,EAC5B,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,UAAU;AAAA,EACV,eAAe;AAAA,EACf,aAAa;AAAA,EACb,QAAQD;AACV;AACO,SAASE,EAAiBC,GAASC,GAAc;AACtD,SAAOC,EAAM,OAAO;AAAA,IAClB,GAAGJ;AAAA,IACH,GAAGG;AAAA,IACH,6BAA6BE,GAAqB;AAAA,MAChD,GAAGH;AAAA,IAAA,CACJ;AAAA,EAAA,CACF;AACH;AACO,SAASG,EAAoB;AAAA,EAClC,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,aAAAC,IAAc;AAAA,EACd,YAAAC,IAAa;AAAA,EACb,aAAAC;AAAA,EACA,WAAAC;AACF,GAAG;AACD,QAAM;AAAA,IACJ,OAAAC;AAAA,EAAA,IACEC,EAAA,GACE,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAK,GAC1CC,IAAgB,YAAY;AAChC,QAAIH;AACF;AAEF,IAAAC,EAAa,EAAI;AACjB,UAAM;AAAA,MACJ,UAAAG;AAAA,MACA,eAAAC;AAAA,IAAA,IACEP,EAAM;AACV,IAAAA,EAAM,cAAc;AAAA,MAClB,UAAU;AAAA,MACV,eAAe;AAAA,IAAA,CAChB;AACD,QAAI;AACF,YAAMD,EAAA,GACNC,EAAM,OAAA;AAAA,IACR,SAASQ,GAAO;AACd,MAAAL,EAAa,EAAK,GAClBH,EAAM,cAAc;AAAA,QAClB,UAAAM;AAAA,QACA,eAAAC;AAAA,MAAA,CACD,GACDE,EAAM,MAAM;AAAA,QACV,SAASD,aAAiB,QAAQA,EAAM,UAAU;AAAA,MAAA,CACnD;AAAA,IACH;AAAA,EACF;AACA,2BAA0BE,GAAK;AAAA,IAC7B,KAAK;AAAA,IACL,SAAS;AAAA,IACT,WAAW,CAAAC,MAAS;AAClB,MAAIA,EAAM,QAAQ,WAAWA,EAAM,oBAAoBT,KAKnDS,EAAM,kBAAkB,qBAAqBA,EAAM,kBAAkB,sBAGzEA,EAAM,eAAA,GACDN,EAAA;AAAA,IACP;AAAA,IACA,UAAU,CAAcO,gBAAAA,EAAMF,GAAK;AAAA,MACjC,KAAK;AAAA,MACL,UAAU,CAAcG,gBAAAA,EAAKC,GAAM;AAAA,QACjC,SAAS;AAAA,QACT,UAAUrB;AAAA,MAAA,CACX,GAAG,OAAOC,KAAY,6BAA6BoB,GAAM;AAAA,QACxD,SAAS;AAAA,QACT,OAAO;AAAA,QACP,UAAUpB;AAAA,MAAA,CACX,IAAIA,CAAO;AAAA,IAAA,CACb,GAAgBkB,gBAAAA,EAAMF,GAAK;AAAA,MAC1B,WAAW;AAAA,MACX,KAAK;AAAA,MACL,WAAW;AAAA,MACX,SAASb,IAAa,SAAY;AAAA,MAClC,YAAYA,KAAc;AAAA,MAC1B,UAAU,CAAcgB,gBAAAA,EAAKE,GAAM;AAAA,QACjC,MAAMlB;AAAA,QACN,4BAA4BmB,GAAQ;AAAA,UAClC,SAAS;AAAA,UACT,YAAYd;AAAA,UACZ,SAAS,MAAMF,EAAM,OAAA;AAAA,UACrB,UAAUJ;AAAA,QAAA,CACX;AAAA,MAAA,CACF,GAAgBiB,gBAAAA,EAAKG,GAAQ;AAAA,QAC5B,WAAW;AAAA,QACX,OAAOlB,IAAc,WAAW;AAAA,QAChC,WAAAI;AAAA,QACA,YAAYA;AAAA,QACZ,SAAS,MAAA;AAAM,UAAKG,EAAA;AAAA;AAAA,QACpB,UAAUV;AAAA,MAAA,CACX,CAAC;AAAA,IAAA,CACH,CAAC;AAAA,EAAA,CACH;AACH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocusable.js","sources":["../../../../../../../../node_modules/react-aria/dist/private/interactions/useFocusable.mjs"],"sourcesContent":["import {focusSafely as $f192c2f16961cbe0$export$80f3e147d781571c} from \"./focusSafely.mjs\";\nimport {getOwnerWindow as $d447af545b77c9f1$export$f21a1ffae260145a} from \"../utils/domHelpers.mjs\";\nimport {isFocusable as $3b8b240c1bf84ab9$export$4c063cf1350e6fed} from \"../utils/isFocusable.mjs\";\nimport {mergeProps as $bbaa08b3cd72f041$export$9d1611c77c2fe928} from \"../utils/mergeProps.mjs\";\nimport {mergeRefs as $4064df0d6f9620e1$export$c9058316764c140e} from \"../utils/mergeRefs.mjs\";\nimport {useFocus as $1e74c67db218ce67$export$f8168d8dd8fd66e6} from \"./useFocus.mjs\";\nimport {useKeyboard as $8296dad1a4c5e0dc$export$8f71654801c2f7cd} from \"./useKeyboard.mjs\";\nimport {useObjectRef as $03e8ab2d84d7657a$export$4338b53315abf666} from \"../utils/useObjectRef.mjs\";\nimport {useSyncRef as $b7115c395c64f7b5$export$4debdb1a3f0fa79e} from \"../utils/useSyncRef.mjs\";\nimport $fKWKs$react, {useContext as $fKWKs$useContext, useRef as $fKWKs$useRef, useEffect as $fKWKs$useEffect, forwardRef as $fKWKs$forwardRef} from \"react\";\n\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */ \n\n\n\n\n\n\n\n\n\nlet $d1116acdf220c2da$export$f9762fab77588ecb = /*#__PURE__*/ (0, $fKWKs$react).createContext(null);\nfunction $d1116acdf220c2da$var$useFocusableContext(ref) {\n let context = (0, $fKWKs$useContext)($d1116acdf220c2da$export$f9762fab77588ecb) || {};\n (0, $b7115c395c64f7b5$export$4debdb1a3f0fa79e)(context, ref);\n // eslint-disable-next-line\n let { ref: _, ...otherProps } = context;\n return otherProps;\n}\nconst $d1116acdf220c2da$export$13f3202a3e5ddd5 = /*#__PURE__*/ (0, $fKWKs$react).forwardRef(function FocusableProvider(props, ref) {\n let { children: children, ...otherProps } = props;\n let objRef = (0, $03e8ab2d84d7657a$export$4338b53315abf666)(ref);\n let context = {\n ...otherProps,\n ref: objRef\n };\n return /*#__PURE__*/ (0, $fKWKs$react).createElement($d1116acdf220c2da$export$f9762fab77588ecb.Provider, {\n value: context\n }, children);\n});\nfunction $d1116acdf220c2da$export$4c014de7c8940b4c(props, domRef) {\n let { focusProps: focusProps } = (0, $1e74c67db218ce67$export$f8168d8dd8fd66e6)(props);\n let { keyboardProps: keyboardProps } = (0, $8296dad1a4c5e0dc$export$8f71654801c2f7cd)(props);\n let interactions = (0, $bbaa08b3cd72f041$export$9d1611c77c2fe928)(focusProps, keyboardProps);\n let domProps = $d1116acdf220c2da$var$useFocusableContext(domRef);\n let interactionProps = props.isDisabled ? {} : domProps;\n let autoFocusRef = (0, $fKWKs$useRef)(props.autoFocus);\n (0, $fKWKs$useEffect)(()=>{\n if (autoFocusRef.current && domRef.current) (0, $f192c2f16961cbe0$export$80f3e147d781571c)(domRef.current);\n autoFocusRef.current = false;\n }, [\n domRef\n ]);\n // Always set a tabIndex so that Safari allows focusing native buttons and inputs.\n let tabIndex = props.excludeFromTabOrder ? -1 : 0;\n if (props.isDisabled) tabIndex = undefined;\n return {\n focusableProps: (0, $bbaa08b3cd72f041$export$9d1611c77c2fe928)({\n ...interactions,\n tabIndex: tabIndex\n }, interactionProps)\n };\n}\nconst $d1116acdf220c2da$export$35a3bebf7ef2d934 = /*#__PURE__*/ (0, $fKWKs$forwardRef)(({ children: children, ...props }, ref)=>{\n ref = (0, $03e8ab2d84d7657a$export$4338b53315abf666)(ref);\n let { focusableProps: focusableProps } = $d1116acdf220c2da$export$4c014de7c8940b4c(props, ref);\n let child = (0, $fKWKs$react).Children.only(children);\n (0, $fKWKs$useEffect)(()=>{\n if (process.env.NODE_ENV === 'production') return;\n let el = ref.current;\n if (!el || !(el instanceof (0, $d447af545b77c9f1$export$f21a1ffae260145a)(el).Element)) {\n console.error('<Focusable> child must forward its ref to a DOM element.');\n return;\n }\n if (!props.isDisabled && !(0, $3b8b240c1bf84ab9$export$4c063cf1350e6fed)(el)) {\n console.warn('<Focusable> child must be focusable. Please ensure the tabIndex prop is passed through.');\n return;\n }\n if (el.localName !== 'button' && el.localName !== 'input' && el.localName !== 'select' && el.localName !== 'textarea' && el.localName !== 'a' && el.localName !== 'area' && el.localName !== 'summary' && el.localName !== 'img' && el.localName !== 'svg') {\n let role = el.getAttribute('role');\n if (!role) console.warn('<Focusable> child must have an interactive ARIA role.');\n else if (// https://w3c.github.io/aria/#widget_roles\n role !== 'application' && role !== 'button' && role !== 'checkbox' && role !== 'combobox' && role !== 'gridcell' && role !== 'link' && role !== 'menuitem' && role !== 'menuitemcheckbox' && role !== 'menuitemradio' && role !== 'option' && role !== 'radio' && role !== 'searchbox' && role !== 'separator' && role !== 'slider' && role !== 'spinbutton' && role !== 'switch' && role !== 'tab' && role !== 'tabpanel' && role !== 'textbox' && role !== 'treeitem' && // aria-describedby is also announced on these roles\n role !== 'img' && role !== 'meter' && role !== 'progressbar') console.warn(`<Focusable> child must have an interactive ARIA role. Got \"${role}\".`);\n }\n }, [\n ref,\n props.isDisabled\n ]);\n // @ts-ignore\n let childRef = parseInt((0, $fKWKs$react).version, 10) < 19 ? child.ref : child.props.ref;\n return /*#__PURE__*/ (0, $fKWKs$react).cloneElement(child, {\n ...(0, $bbaa08b3cd72f041$export$9d1611c77c2fe928)(focusableProps, child.props),\n // @ts-ignore\n // oxlint-disable-next-line react/react-compiler\n ref: (0, $4064df0d6f9620e1$export$c9058316764c140e)(childRef, ref)\n });\n});\n\n\nexport {$d1116acdf220c2da$export$f9762fab77588ecb as FocusableContext, $d1116acdf220c2da$export$13f3202a3e5ddd5 as FocusableProvider, $d1116acdf220c2da$export$4c014de7c8940b4c as useFocusable, $d1116acdf220c2da$export$35a3bebf7ef2d934 as Focusable};\n//# sourceMappingURL=useFocusable.mjs.map\n"],"names":["$d1116acdf220c2da$export$f9762fab77588ecb","$fKWKs$react","$d1116acdf220c2da$export$13f3202a3e5ddd5","props","ref","children","otherProps","objRef","$03e8ab2d84d7657a$export$4338b53315abf666","context"],"mappings":";;AA+BG,IAACA,IAA8DC,gBAAAA,EAAc,cAAc,IAAI;AAQ7F,MAACC,IAA6DD,gBAAAA,EAAc,WAAW,SAA2BE,GAAOC,GAAK;AAC/H,MAAI,EAAE,UAAUC,GAAU,GAAGC,EAAU,IAAKH,GACxCI,IAAaC,EAA2CJ,CAAG,GAC3DK,IAAU;AAAA,IACV,GAAGH;AAAA,IACH,KAAKC;AAAA,EACb;AACI,SAAyBN,gBAAAA,EAAc,cAAcD,EAA0C,UAAU;AAAA,IACrG,OAAOS;AAAA,EACf,GAAOJ,CAAQ;AACf,CAAC;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"useFocusable.js","sources":["../../../../../../../../node_modules/react-aria/dist/private/interactions/useFocusable.mjs"],"sourcesContent":["import {focusSafely as $f192c2f16961cbe0$export$80f3e147d781571c} from \"./focusSafely.mjs\";\nimport {getOwnerWindow as $d447af545b77c9f1$export$f21a1ffae260145a} from \"../utils/domHelpers.mjs\";\nimport {isFocusable as $3b8b240c1bf84ab9$export$4c063cf1350e6fed} from \"../utils/isFocusable.mjs\";\nimport {mergeProps as $bbaa08b3cd72f041$export$9d1611c77c2fe928} from \"../utils/mergeProps.mjs\";\nimport {mergeRefs as $4064df0d6f9620e1$export$c9058316764c140e} from \"../utils/mergeRefs.mjs\";\nimport {useFocus as $1e74c67db218ce67$export$f8168d8dd8fd66e6} from \"./useFocus.mjs\";\nimport {useKeyboard as $8296dad1a4c5e0dc$export$8f71654801c2f7cd} from \"./useKeyboard.mjs\";\nimport {useObjectRef as $03e8ab2d84d7657a$export$4338b53315abf666} from \"../utils/useObjectRef.mjs\";\nimport {useSyncRef as $b7115c395c64f7b5$export$4debdb1a3f0fa79e} from \"../utils/useSyncRef.mjs\";\nimport $fKWKs$react, {useContext as $fKWKs$useContext, useRef as $fKWKs$useRef, useEffect as $fKWKs$useEffect, forwardRef as $fKWKs$forwardRef} from \"react\";\n\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */ \n\n\n\n\n\n\n\n\n\nlet $d1116acdf220c2da$export$f9762fab77588ecb = /*#__PURE__*/ (0, $fKWKs$react).createContext(null);\nfunction $d1116acdf220c2da$var$useFocusableContext(ref) {\n let context = (0, $fKWKs$useContext)($d1116acdf220c2da$export$f9762fab77588ecb) || {};\n (0, $b7115c395c64f7b5$export$4debdb1a3f0fa79e)(context, ref);\n // eslint-disable-next-line\n let { ref: _, ...otherProps } = context;\n return otherProps;\n}\nconst $d1116acdf220c2da$export$13f3202a3e5ddd5 = /*#__PURE__*/ (0, $fKWKs$react).forwardRef(function FocusableProvider(props, ref) {\n let { children: children, ...otherProps } = props;\n let objRef = (0, $03e8ab2d84d7657a$export$4338b53315abf666)(ref);\n let context = {\n ...otherProps,\n ref: objRef\n };\n return /*#__PURE__*/ (0, $fKWKs$react).createElement($d1116acdf220c2da$export$f9762fab77588ecb.Provider, {\n value: context\n }, children);\n});\nfunction $d1116acdf220c2da$export$4c014de7c8940b4c(props, domRef) {\n let { focusProps: focusProps } = (0, $1e74c67db218ce67$export$f8168d8dd8fd66e6)(props);\n let { keyboardProps: keyboardProps } = (0, $8296dad1a4c5e0dc$export$8f71654801c2f7cd)(props);\n let interactions = (0, $bbaa08b3cd72f041$export$9d1611c77c2fe928)(focusProps, keyboardProps);\n let domProps = $d1116acdf220c2da$var$useFocusableContext(domRef);\n let interactionProps = props.isDisabled ? {} : domProps;\n let autoFocusRef = (0, $fKWKs$useRef)(props.autoFocus);\n (0, $fKWKs$useEffect)(()=>{\n if (autoFocusRef.current && domRef.current) (0, $f192c2f16961cbe0$export$80f3e147d781571c)(domRef.current);\n autoFocusRef.current = false;\n }, [\n domRef\n ]);\n // Always set a tabIndex so that Safari allows focusing native buttons and inputs.\n let tabIndex = props.excludeFromTabOrder ? -1 : 0;\n if (props.isDisabled) tabIndex = undefined;\n return {\n focusableProps: (0, $bbaa08b3cd72f041$export$9d1611c77c2fe928)({\n ...interactions,\n tabIndex: tabIndex\n }, interactionProps)\n };\n}\nconst $d1116acdf220c2da$export$35a3bebf7ef2d934 = /*#__PURE__*/ (0, $fKWKs$forwardRef)(({ children: children, ...props }, ref)=>{\n ref = (0, $03e8ab2d84d7657a$export$4338b53315abf666)(ref);\n let { focusableProps: focusableProps } = $d1116acdf220c2da$export$4c014de7c8940b4c(props, ref);\n let child = (0, $fKWKs$react).Children.only(children);\n (0, $fKWKs$useEffect)(()=>{\n if (process.env.NODE_ENV === 'production') return;\n let el = ref.current;\n if (!el || !(el instanceof (0, $d447af545b77c9f1$export$f21a1ffae260145a)(el).Element)) {\n console.error('<Focusable> child must forward its ref to a DOM element.');\n return;\n }\n if (!props.isDisabled && !(0, $3b8b240c1bf84ab9$export$4c063cf1350e6fed)(el, {\n skipVisibilityCheck: true\n })) {\n console.warn('<Focusable> child must be focusable. Please ensure the tabIndex prop is passed through.');\n return;\n }\n if (el.localName !== 'button' && el.localName !== 'input' && el.localName !== 'select' && el.localName !== 'textarea' && el.localName !== 'a' && el.localName !== 'area' && el.localName !== 'summary' && el.localName !== 'img' && el.localName !== 'svg') {\n let role = el.getAttribute('role');\n if (!role) console.warn('<Focusable> child must have an interactive ARIA role.');\n else if (// https://w3c.github.io/aria/#widget_roles\n role !== 'application' && role !== 'button' && role !== 'checkbox' && role !== 'combobox' && role !== 'gridcell' && role !== 'link' && role !== 'menuitem' && role !== 'menuitemcheckbox' && role !== 'menuitemradio' && role !== 'option' && role !== 'radio' && role !== 'searchbox' && role !== 'separator' && role !== 'slider' && role !== 'spinbutton' && role !== 'switch' && role !== 'tab' && role !== 'tabpanel' && role !== 'textbox' && role !== 'treeitem' && // aria-describedby is also announced on these roles\n role !== 'img' && role !== 'meter' && role !== 'progressbar') console.warn(`<Focusable> child must have an interactive ARIA role. Got \"${role}\".`);\n }\n }, [\n ref,\n props.isDisabled\n ]);\n // @ts-ignore\n let childRef = parseInt((0, $fKWKs$react).version, 10) < 19 ? child.ref : child.props.ref;\n return /*#__PURE__*/ (0, $fKWKs$react).cloneElement(child, {\n ...(0, $bbaa08b3cd72f041$export$9d1611c77c2fe928)(focusableProps, child.props),\n // @ts-ignore\n // oxlint-disable-next-line react/react-compiler\n ref: (0, $4064df0d6f9620e1$export$c9058316764c140e)(childRef, ref)\n });\n});\n\n\nexport {$d1116acdf220c2da$export$f9762fab77588ecb as FocusableContext, $d1116acdf220c2da$export$13f3202a3e5ddd5 as FocusableProvider, $d1116acdf220c2da$export$4c014de7c8940b4c as useFocusable, $d1116acdf220c2da$export$35a3bebf7ef2d934 as Focusable};\n//# sourceMappingURL=useFocusable.mjs.map\n"],"names":["$d1116acdf220c2da$export$f9762fab77588ecb","$fKWKs$react","$d1116acdf220c2da$export$13f3202a3e5ddd5","props","ref","children","otherProps","objRef","$03e8ab2d84d7657a$export$4338b53315abf666","context"],"mappings":";;AA+BG,IAACA,IAA8DC,gBAAAA,EAAc,cAAc,IAAI;AAQ7F,MAACC,IAA6DD,gBAAAA,EAAc,WAAW,SAA2BE,GAAOC,GAAK;AAC/H,MAAI,EAAE,UAAUC,GAAU,GAAGC,EAAU,IAAKH,GACxCI,IAAaC,EAA2CJ,CAAG,GAC3DK,IAAU;AAAA,IACV,GAAGH;AAAA,IACH,KAAKC;AAAA,EACb;AACI,SAAyBN,gBAAAA,EAAc,cAAcD,EAA0C,UAAU;AAAA,IACrG,OAAOS;AAAA,EACf,GAAOJ,CAAQ;AACf,CAAC;","x_google_ignoreList":[0]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@reforma/components",
|
|
3
3
|
"description": "A components library for Reforma",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.3",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"author": "Reforma, Inc. <dev@reforma.ai>",
|
|
8
8
|
"repository": {
|
|
@@ -69,7 +69,6 @@
|
|
|
69
69
|
"@reforma/constants": "workspace:*",
|
|
70
70
|
"@reforma/icons": "workspace:*",
|
|
71
71
|
"@reforma/lib": "workspace:*",
|
|
72
|
-
"@reforma/tokens": "workspace:*",
|
|
73
72
|
"@reforma/types": "workspace:*",
|
|
74
73
|
"@shikijs/transformers": "^4.0.2",
|
|
75
74
|
"@streamdown/cjk": "1.0.3",
|
|
@@ -113,6 +112,7 @@
|
|
|
113
112
|
},
|
|
114
113
|
"devDependencies": {
|
|
115
114
|
"@babel/preset-react": "^7.26.3",
|
|
115
|
+
"@reforma/styles": "workspace:*",
|
|
116
116
|
"@vitejs/plugin-react-swc": "^3.7.0",
|
|
117
117
|
"vite": "^7.0.0",
|
|
118
118
|
"vite-plugin-babel": "^1.3.0",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import type { CreateComposerUploadResult, CreateComposerValue } from './types';
|
|
3
|
-
export type CreateComposerProps = {
|
|
4
|
-
value: CreateComposerValue;
|
|
5
|
-
onChange: (value: CreateComposerValue) => void;
|
|
6
|
-
onSubmit: () => void;
|
|
7
|
-
uploadFile: (file: File) => Promise<CreateComposerUploadResult>;
|
|
8
|
-
busy?: boolean;
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
autoFocus?: boolean;
|
|
11
|
-
className?: string;
|
|
12
|
-
header?: ReactNode;
|
|
13
|
-
/** Extra controls next to send (e.g. admin grade strip). */
|
|
14
|
-
toolbarEnd?: ReactNode;
|
|
15
|
-
submitHotkey?: 'enter' | 'mod+enter';
|
|
16
|
-
/** Fixed min rows for the rich field (create project uses 3). */
|
|
17
|
-
rows?: number;
|
|
18
|
-
/** Footer hint under the shell. Default: mod+enter copy. */
|
|
19
|
-
hint?: ReactNode | false;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* MobX-free create-project composer: prompt, plan mode, attachments, submit.
|
|
23
|
-
* Host supplies {@link uploadFile}; handoff / auth stay outside.
|
|
24
|
-
*/
|
|
25
|
-
export declare function CreateComposer({ value, onChange, onSubmit, uploadFile, busy, placeholder, autoFocus, className, header, toolbarEnd, submitHotkey, rows, hint, }: CreateComposerProps): import("react").JSX.Element;
|
|
26
|
-
//# sourceMappingURL=CreateComposer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CreateComposer.d.ts","sourceRoot":"","sources":["../../src/CreateComposer/CreateComposer.tsx"],"names":[],"mappings":"AAYA,OAAO,EAMH,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AAsBf,OAAO,KAAK,EAER,0BAA0B,EAC1B,mBAAmB,EACtB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,mBAAmB,GAAG;IAC9B,KAAK,EAAE,mBAAmB,CAAC;IAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAChE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IACrC,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4DAA4D;IAC5D,IAAI,CAAC,EAAE,SAAS,GAAG,KAAK,CAAC;CAC5B,CAAC;AAmCF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,IAAY,EACZ,WAAkC,EAClC,SAAgB,EAChB,SAAS,EACT,MAAM,EACN,UAAU,EACV,YAA0B,EAC1B,IAAQ,EACR,IAAI,GACP,EAAE,mBAAmB,+BAmVrB"}
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import { coerceUploadMimeType as _, MAX_CHAT_ATTACHMENT_BYTES_PER_FILE as P, MAX_CHAT_ATTACHMENT_BYTES_TOTAL as B, COMPOSER_PASTE_AS_FILE_MIN_CHARS as ee } from "@reforma/constants";
|
|
2
|
-
import { Plan as te } from "@reforma/icons/12";
|
|
3
|
-
import { Plus as re, Clip as ne, Plan as oe } from "@reforma/icons/14";
|
|
4
|
-
import { SendBold as ae } from "@reforma/icons/16";
|
|
5
|
-
import { revokeObjectURL as S, formatFileSize as I, createObjectURL as ie, cn as se } from "@reforma/lib";
|
|
6
|
-
import { useRef as T, useState as H, useEffect as ce, useMemo as le, useCallback as L } from "react";
|
|
7
|
-
import { Button as j } from "../Button/Button.js";
|
|
8
|
-
import { Attachments as de, Attachment as me } from "../chat/Attachment/Attachment.js";
|
|
9
|
-
import { FileDropOverlay as ue } from "../FileDropOverlay/FileDropOverlay.js";
|
|
10
|
-
import { For as pe } from "../For/For.js";
|
|
11
|
-
import { useFileDrag as fe } from "../hooks/useFileDrag.js";
|
|
12
|
-
import { Hotkey as he } from "../Hotkey/Hotkey.js";
|
|
13
|
-
import { Menu as ge, MenuItem as k } from "../List/Menu.js";
|
|
14
|
-
import { Popover as ve } from "../Popover/Popover.js";
|
|
15
|
-
import { PopoverScroll as ye } from "../Popover/PopoverScroll.js";
|
|
16
|
-
import { plainTextToDoc as Te, docToPlainText as Ae } from "../RichInput/composerDoc.js";
|
|
17
|
-
import { RichInput as xe } from "../RichInput/RichInput.js";
|
|
18
|
-
import { Show as z } from "../Show/Show.js";
|
|
19
|
-
import { Badge as Pe } from "../Tag/Badge.js";
|
|
20
|
-
import { Text as Se } from "../Text/Text.js";
|
|
21
|
-
import { toast as D } from "../Toast/Toast.js";
|
|
22
|
-
import l from "./CreateComposer.module.css.js";
|
|
23
|
-
import { jsxs as u, jsx as t } from "react/jsx-runtime";
|
|
24
|
-
import { MenuTrigger as ze } from "react-aria-components";
|
|
25
|
-
function De(i) {
|
|
26
|
-
let a = 0;
|
|
27
|
-
for (const d of i)
|
|
28
|
-
typeof d.size == "number" && Number.isFinite(d.size) && (a += d.size);
|
|
29
|
-
return a;
|
|
30
|
-
}
|
|
31
|
-
function Me(i) {
|
|
32
|
-
return i.length === 0 ? !0 : i.every((a) => a.uploadStatus === "ready" && !!a.url);
|
|
33
|
-
}
|
|
34
|
-
function M(i, a, d) {
|
|
35
|
-
return {
|
|
36
|
-
...i,
|
|
37
|
-
attachments: i.attachments.map((p) => p.clientId === a ? {
|
|
38
|
-
...p,
|
|
39
|
-
...d
|
|
40
|
-
} : p)
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function Ke({
|
|
44
|
-
value: i,
|
|
45
|
-
onChange: a,
|
|
46
|
-
onSubmit: d,
|
|
47
|
-
uploadFile: p,
|
|
48
|
-
busy: b = !1,
|
|
49
|
-
placeholder: w = "What should it do?",
|
|
50
|
-
autoFocus: U = !0,
|
|
51
|
-
className: C,
|
|
52
|
-
header: $,
|
|
53
|
-
toolbarEnd: E,
|
|
54
|
-
submitHotkey: V = "mod+enter",
|
|
55
|
-
rows: v = 3,
|
|
56
|
-
hint: R
|
|
57
|
-
}) {
|
|
58
|
-
const O = T(null), A = T(null), c = T(i);
|
|
59
|
-
c.current = i;
|
|
60
|
-
const f = T(/* @__PURE__ */ new Map()), [W, X] = H(!1), [Y, q] = H(!0);
|
|
61
|
-
ce(() => {
|
|
62
|
-
const e = f.current;
|
|
63
|
-
return () => {
|
|
64
|
-
for (const r of c.current.attachments)
|
|
65
|
-
S(r.preview);
|
|
66
|
-
e.clear();
|
|
67
|
-
};
|
|
68
|
-
}, []);
|
|
69
|
-
const G = le(() => Te(i.prompt), [i.prompt]), F = !!i.prompt.trim() && Me(i.attachments) && !b, x = L(async (e, r) => {
|
|
70
|
-
const o = await p(r), s = c.current;
|
|
71
|
-
if (!s.attachments.some((m) => m.clientId === e)) {
|
|
72
|
-
f.current.delete(e);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (o.ok) {
|
|
76
|
-
const m = s.attachments.find((g) => g.clientId === e)?.preview;
|
|
77
|
-
S(m), f.current.delete(e), a(M(s, e, {
|
|
78
|
-
id: o.data.id,
|
|
79
|
-
url: o.data.url,
|
|
80
|
-
filename: o.data.name ?? r.name,
|
|
81
|
-
mediaType: o.data.mimeType ?? _(r.name, r.type),
|
|
82
|
-
size: o.data.size ?? r.size,
|
|
83
|
-
uploadStatus: "ready",
|
|
84
|
-
uploadError: void 0,
|
|
85
|
-
preview: void 0
|
|
86
|
-
}));
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
a(M(s, e, {
|
|
90
|
-
uploadStatus: "error",
|
|
91
|
-
uploadError: o.message ?? "Upload failed"
|
|
92
|
-
}));
|
|
93
|
-
}, [a, p]), y = L((e) => {
|
|
94
|
-
const r = [...e], o = [];
|
|
95
|
-
let s = 0;
|
|
96
|
-
const m = De(c.current.attachments);
|
|
97
|
-
for (const n of r) {
|
|
98
|
-
if (n.size > P) {
|
|
99
|
-
D.warning({
|
|
100
|
-
title: "Attachment too large",
|
|
101
|
-
message: `${n.name} is over the ${I(P, {
|
|
102
|
-
round: "up"
|
|
103
|
-
})} per-file limit.`
|
|
104
|
-
});
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
if (m + s + n.size > B) {
|
|
108
|
-
D.warning({
|
|
109
|
-
title: "Attachments too large",
|
|
110
|
-
message: `Adding ${n.name} would exceed the ${I(B, {
|
|
111
|
-
round: "up"
|
|
112
|
-
})} combined limit.`
|
|
113
|
-
});
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
o.push(n), s += n.size;
|
|
117
|
-
}
|
|
118
|
-
if (o.length === 0)
|
|
119
|
-
return;
|
|
120
|
-
const g = o.map((n) => ({
|
|
121
|
-
clientId: crypto.randomUUID(),
|
|
122
|
-
filename: n.name,
|
|
123
|
-
mediaType: _(n.name, n.type),
|
|
124
|
-
size: n.size,
|
|
125
|
-
lastModified: n.lastModified,
|
|
126
|
-
uploadStatus: "uploading",
|
|
127
|
-
preview: ie(n) ?? void 0
|
|
128
|
-
}));
|
|
129
|
-
for (let n = 0; n < o.length; n++)
|
|
130
|
-
f.current.set(g[n].clientId, o[n]);
|
|
131
|
-
const Z = {
|
|
132
|
-
...c.current,
|
|
133
|
-
attachments: [...c.current.attachments, ...g]
|
|
134
|
-
};
|
|
135
|
-
a(Z);
|
|
136
|
-
for (let n = 0; n < o.length; n++)
|
|
137
|
-
x(g[n].clientId, o[n]);
|
|
138
|
-
}, [a, x]), h = fe({
|
|
139
|
-
onFileDragOver: X,
|
|
140
|
-
onFilesDropped: (e) => y(e)
|
|
141
|
-
}), J = (e) => {
|
|
142
|
-
const r = c.current, o = r.attachments.find((s) => s.clientId === e);
|
|
143
|
-
S(o?.preview), f.current.delete(e), a({
|
|
144
|
-
...r,
|
|
145
|
-
attachments: r.attachments.filter((s) => s.clientId !== e)
|
|
146
|
-
});
|
|
147
|
-
}, K = (e) => {
|
|
148
|
-
const r = c.current, o = r.attachments.find((m) => m.clientId === e), s = f.current.get(e);
|
|
149
|
-
if (!(!o || o.uploadStatus !== "error")) {
|
|
150
|
-
if (!s) {
|
|
151
|
-
D.warning({
|
|
152
|
-
title: "Could not retry",
|
|
153
|
-
message: "Remove the file and attach it again."
|
|
154
|
-
});
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
a(M(r, e, {
|
|
158
|
-
uploadStatus: "uploading",
|
|
159
|
-
uploadError: void 0
|
|
160
|
-
})), x(e, s);
|
|
161
|
-
}
|
|
162
|
-
}, N = () => {
|
|
163
|
-
F && d();
|
|
164
|
-
}, Q = R === !1 ? null : R ?? /* @__PURE__ */ u(Se, {
|
|
165
|
-
variant: "sm",
|
|
166
|
-
color: "secondary",
|
|
167
|
-
children: ["Press", " ", /* @__PURE__ */ t(he, {
|
|
168
|
-
hotkey: ["mod", "enter"],
|
|
169
|
-
textVariant: "xs"
|
|
170
|
-
}), " ", "to create the project"]
|
|
171
|
-
});
|
|
172
|
-
return /* @__PURE__ */ u("div", {
|
|
173
|
-
className: se(l.root, C),
|
|
174
|
-
onDragEnter: h.onDragEnter,
|
|
175
|
-
onDragLeave: h.onDragLeave,
|
|
176
|
-
onDragOver: h.onDragOver,
|
|
177
|
-
onDrop: h.onDrop,
|
|
178
|
-
onPaste: h.onPaste,
|
|
179
|
-
children: [/* @__PURE__ */ t(ue, {
|
|
180
|
-
open: W,
|
|
181
|
-
label: "Drop files to attach"
|
|
182
|
-
}), $, /* @__PURE__ */ u("div", {
|
|
183
|
-
className: l.shell,
|
|
184
|
-
children: [/* @__PURE__ */ t(z, {
|
|
185
|
-
when: i.attachments.length > 0,
|
|
186
|
-
children: /* @__PURE__ */ t("div", {
|
|
187
|
-
className: l.attachments,
|
|
188
|
-
children: /* @__PURE__ */ t(de, {
|
|
189
|
-
size: "sm",
|
|
190
|
-
children: /* @__PURE__ */ t(pe, {
|
|
191
|
-
each: i.attachments,
|
|
192
|
-
children: (e) => /* @__PURE__ */ t(me, {
|
|
193
|
-
data: {
|
|
194
|
-
id: e.id,
|
|
195
|
-
url: e.url ?? e.preview,
|
|
196
|
-
filename: e.filename,
|
|
197
|
-
mediaType: e.mediaType,
|
|
198
|
-
size: e.size,
|
|
199
|
-
lastModified: e.lastModified
|
|
200
|
-
},
|
|
201
|
-
loading: e.uploadStatus === "uploading",
|
|
202
|
-
error: e.uploadStatus === "error",
|
|
203
|
-
onRetry: () => K(e.clientId),
|
|
204
|
-
onRemove: () => J(e.clientId)
|
|
205
|
-
}, e.clientId)
|
|
206
|
-
})
|
|
207
|
-
})
|
|
208
|
-
})
|
|
209
|
-
}), /* @__PURE__ */ u("div", {
|
|
210
|
-
className: l.main,
|
|
211
|
-
"data-expanded": Y || void 0,
|
|
212
|
-
"data-min-rows": v != null || void 0,
|
|
213
|
-
onPointerDown: (e) => {
|
|
214
|
-
e.target === e.currentTarget && A.current?.focus();
|
|
215
|
-
},
|
|
216
|
-
children: [/* @__PURE__ */ u("div", {
|
|
217
|
-
className: l.addButton,
|
|
218
|
-
children: [/* @__PURE__ */ t("input", {
|
|
219
|
-
ref: O,
|
|
220
|
-
type: "file",
|
|
221
|
-
multiple: !0,
|
|
222
|
-
tabIndex: -1,
|
|
223
|
-
style: {
|
|
224
|
-
display: "none"
|
|
225
|
-
},
|
|
226
|
-
onChange: (e) => {
|
|
227
|
-
e.target.files?.length && y(e.target.files), e.target.value = "";
|
|
228
|
-
}
|
|
229
|
-
}), /* @__PURE__ */ u(ze, {
|
|
230
|
-
children: [/* @__PURE__ */ t(j, {
|
|
231
|
-
type: "button",
|
|
232
|
-
iconOnly: !0,
|
|
233
|
-
rounded: !0,
|
|
234
|
-
variant: "filling",
|
|
235
|
-
size: "sm",
|
|
236
|
-
tooltip: "Add",
|
|
237
|
-
children: /* @__PURE__ */ t(re, {})
|
|
238
|
-
}), /* @__PURE__ */ t(ve, {
|
|
239
|
-
placement: "top start",
|
|
240
|
-
spacing: "xs",
|
|
241
|
-
children: /* @__PURE__ */ t(ye, {
|
|
242
|
-
children: /* @__PURE__ */ u(ge, {
|
|
243
|
-
"aria-label": "Add to prompt",
|
|
244
|
-
size: "sm",
|
|
245
|
-
children: [/* @__PURE__ */ t(k, {
|
|
246
|
-
id: "files",
|
|
247
|
-
text: "Files",
|
|
248
|
-
icon: /* @__PURE__ */ t(ne, {}),
|
|
249
|
-
onAction: () => O.current?.click()
|
|
250
|
-
}), /* @__PURE__ */ t(k, {
|
|
251
|
-
id: "plan",
|
|
252
|
-
text: "Plan mode",
|
|
253
|
-
icon: /* @__PURE__ */ t(oe, {}),
|
|
254
|
-
onAction: () => {
|
|
255
|
-
a({
|
|
256
|
-
...c.current,
|
|
257
|
-
planMode: !0
|
|
258
|
-
}), A.current?.focus();
|
|
259
|
-
}
|
|
260
|
-
})]
|
|
261
|
-
})
|
|
262
|
-
})
|
|
263
|
-
})]
|
|
264
|
-
}), /* @__PURE__ */ t(z, {
|
|
265
|
-
when: i.planMode,
|
|
266
|
-
children: /* @__PURE__ */ t(Pe, {
|
|
267
|
-
size: "sm",
|
|
268
|
-
color: "success",
|
|
269
|
-
rounded: !0,
|
|
270
|
-
textValue: "Plan mode",
|
|
271
|
-
"aria-label": "Plan mode",
|
|
272
|
-
icon: /* @__PURE__ */ t(te, {}),
|
|
273
|
-
removePlacement: "leading",
|
|
274
|
-
onRemove: () => a({
|
|
275
|
-
...c.current,
|
|
276
|
-
planMode: !1
|
|
277
|
-
}),
|
|
278
|
-
children: "Plan mode"
|
|
279
|
-
})
|
|
280
|
-
})]
|
|
281
|
-
}), /* @__PURE__ */ t("div", {
|
|
282
|
-
className: l.textareaWrap,
|
|
283
|
-
children: /* @__PURE__ */ t(xe, {
|
|
284
|
-
ref: A,
|
|
285
|
-
value: G,
|
|
286
|
-
onChange: (e) => {
|
|
287
|
-
const r = Ae(e);
|
|
288
|
-
a({
|
|
289
|
-
...c.current,
|
|
290
|
-
prompt: r
|
|
291
|
-
}), q(v != null || r.includes(`
|
|
292
|
-
`) || r.length > 40);
|
|
293
|
-
},
|
|
294
|
-
autoFocus: U,
|
|
295
|
-
minHeight: v ? v * 22 : 20,
|
|
296
|
-
maxHeight: 280,
|
|
297
|
-
placeholder: w,
|
|
298
|
-
className: l.textarea,
|
|
299
|
-
"aria-label": w,
|
|
300
|
-
submitOnEnter: V === "enter",
|
|
301
|
-
onSubmit: () => N(),
|
|
302
|
-
onPasteFiles: (e) => y(e),
|
|
303
|
-
onPasteText: (e) => {
|
|
304
|
-
if (e.length < ee)
|
|
305
|
-
return !1;
|
|
306
|
-
const r = new File([e], "paste.txt", {
|
|
307
|
-
type: "text/plain"
|
|
308
|
-
});
|
|
309
|
-
return r.size > P ? !1 : (y([r]), !0);
|
|
310
|
-
}
|
|
311
|
-
})
|
|
312
|
-
}), /* @__PURE__ */ t(z, {
|
|
313
|
-
when: E,
|
|
314
|
-
children: /* @__PURE__ */ t("div", {
|
|
315
|
-
className: l.toolbarEnd,
|
|
316
|
-
children: E
|
|
317
|
-
})
|
|
318
|
-
}), /* @__PURE__ */ t(j, {
|
|
319
|
-
iconOnly: !0,
|
|
320
|
-
rounded: !0,
|
|
321
|
-
color: "primary",
|
|
322
|
-
variant: "filled",
|
|
323
|
-
size: "sm",
|
|
324
|
-
className: l.sendButton,
|
|
325
|
-
isDisabled: !F,
|
|
326
|
-
isPending: b,
|
|
327
|
-
tooltip: "Create project",
|
|
328
|
-
onPress: () => N(),
|
|
329
|
-
children: /* @__PURE__ */ t(ae, {})
|
|
330
|
-
})]
|
|
331
|
-
})]
|
|
332
|
-
}), Q]
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
export {
|
|
336
|
-
Ke as CreateComposer
|
|
337
|
-
};
|
|
338
|
-
//# sourceMappingURL=CreateComposer.js.map
|