markdown-flow-ui 0.3.12 → 0.3.13
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/_virtual/index10.cjs +1 -1
- package/dist/_virtual/index10.es.js +3 -2
- package/dist/_virtual/index10.es.js.map +1 -1
- package/dist/_virtual/index11.cjs +1 -1
- package/dist/_virtual/index11.es.js +2 -3
- package/dist/_virtual/index11.es.js.map +1 -1
- package/dist/_virtual/index3.cjs +1 -1
- package/dist/_virtual/index3.es.js +5 -4
- package/dist/_virtual/index3.es.js.map +1 -1
- package/dist/_virtual/index4.cjs +1 -1
- package/dist/_virtual/index4.es.js +4 -5
- package/dist/_virtual/index4.es.js.map +1 -1
- package/dist/_virtual/index6.cjs +1 -1
- package/dist/_virtual/index6.es.js +2 -5
- package/dist/_virtual/index6.es.js.map +1 -1
- package/dist/_virtual/index8.cjs +1 -1
- package/dist/_virtual/index8.es.js +5 -2
- package/dist/_virtual/index8.es.js.map +1 -1
- package/dist/assets/markdown-flow-ui.css +1 -1
- package/dist/components/ContentRender/ImageInputGroup.cjs +1 -1
- package/dist/components/ContentRender/ImageInputGroup.cjs.map +1 -1
- package/dist/components/ContentRender/ImageInputGroup.es.js +37 -36
- package/dist/components/ContentRender/ImageInputGroup.es.js.map +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.cjs +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.cjs.map +1 -1
- package/dist/components/ContentRender/MarkdownFlowInput.es.js +26 -29
- package/dist/components/ContentRender/MarkdownFlowInput.es.js.map +1 -1
- package/dist/components/ui/inputGroup/textarea.cjs +1 -1
- package/dist/components/ui/inputGroup/textarea.es.js +1 -1
- package/dist/markdown-flow-ui-lib.css +1 -1
- package/dist/markdown-flow-ui.css +1 -1
- package/dist/node_modules/classnames/index.cjs +1 -1
- package/dist/node_modules/classnames/index.es.js +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.cjs +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.es.js +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.cjs +1 -1
- package/dist/node_modules/rc-input/es/BaseInput.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/ResizableTextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/TextArea.es.js +1 -1
- package/dist/node_modules/rc-textarea/es/index.cjs +1 -1
- package/dist/node_modules/rc-textarea/es/index.es.js +1 -1
- package/dist/node_modules/rc-util/es/ref.cjs +1 -1
- package/dist/node_modules/rc-util/es/ref.es.js +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.cjs +1 -1
- package/dist/node_modules/remark-flow/dist/interaction-plugin-core.es.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.cjs +1 -1
- package/dist/node_modules/style-to-object/cjs/index.es.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageInputGroup.cjs","sources":["../../../src/components/ContentRender/ImageInputGroup.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport { ImagePlus, LoaderCircle, X } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\nimport type { MarkdownFlowLocale } from \"../../lib/locale\";\nimport { InputGroup, InputGroupButton } from \"../ui/inputGroup/input-group\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\n\n/** Controlled upload state. The host owns validation, persistence and errors. */\nexport interface ImageInputOptions {\n /** Uploaded image URLs in submission order. */\n images: readonly string[];\n /** Prevent submission and attachment changes while uploads are pending. */\n uploading?: boolean;\n /** Disable attachment changes independently of text editing. */\n disabled?: boolean;\n /** Receive the selected files; update images after uploading them. */\n onSelect?: (files: File[]) => void;\n /** Remove an uploaded image by its index. */\n onRemove?: (index: number) => void;\n /** File picker filter. Defaults to image files. */\n accept?: string;\n /** Disable adding more images when this count is reached. */\n maxImages?: number;\n /** Resolve display URLs without changing the URLs returned on submission. */\n resolvePreviewUrl?: (url: string) => string;\n}\n\ninterface ImageInputGroupProps extends React.ComponentProps<typeof InputGroup> {\n showImageInput?: boolean;\n imageInput?: ImageInputOptions;\n disabled?: boolean;\n locale?: MarkdownFlowLocale;\n}\n\n/** Keep attachment controls inside the same border as the text input. */\nexport function ImageInputGroup({\n showImageInput = false,\n imageInput,\n disabled,\n locale,\n children,\n className,\n ...props\n}: ImageInputGroupProps) {\n const input = useRef<HTMLInputElement>(null);\n const texts = getContentRenderLocaleTexts(locale);\n const images = imageInput?.images ?? [];\n const uploading = Boolean(imageInput?.uploading);\n const pickerDisabled =\n disabled ||\n imageInput?.disabled ||\n uploading ||\n !imageInput?.onSelect ||\n (imageInput.maxImages !== undefined &&\n images.length >= imageInput.maxImages);\n const hasAttachments = showImageInput || images.length > 0;\n\n return (\n <InputGroup\n {...props}\n data-disabled={disabled}\n className={cn(\n
|
|
1
|
+
{"version":3,"file":"ImageInputGroup.cjs","sources":["../../../src/components/ContentRender/ImageInputGroup.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport { ImagePlus, LoaderCircle, X } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\nimport type { MarkdownFlowLocale } from \"../../lib/locale\";\nimport { InputGroup, InputGroupButton } from \"../ui/inputGroup/input-group\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\n\n/** Controlled upload state. The host owns validation, persistence and errors. */\nexport interface ImageInputOptions {\n /** Uploaded image URLs in submission order. */\n images: readonly string[];\n /** Prevent submission and attachment changes while uploads are pending. */\n uploading?: boolean;\n /** Disable attachment changes independently of text editing. */\n disabled?: boolean;\n /** Receive the selected files; update images after uploading them. */\n onSelect?: (files: File[]) => void;\n /** Remove an uploaded image by its index. */\n onRemove?: (index: number) => void;\n /** File picker filter. Defaults to image files. */\n accept?: string;\n /** Disable adding more images when this count is reached. */\n maxImages?: number;\n /** Resolve display URLs without changing the URLs returned on submission. */\n resolvePreviewUrl?: (url: string) => string;\n}\n\ninterface ImageInputGroupProps extends React.ComponentProps<typeof InputGroup> {\n showImageInput?: boolean;\n imageInput?: ImageInputOptions;\n disabled?: boolean;\n locale?: MarkdownFlowLocale;\n}\n\n/** Keep attachment controls inside the same border as the text input. */\nexport function ImageInputGroup({\n showImageInput = false,\n imageInput,\n disabled,\n locale,\n children,\n className,\n ...props\n}: ImageInputGroupProps) {\n const input = useRef<HTMLInputElement>(null);\n const texts = getContentRenderLocaleTexts(locale);\n const images = imageInput?.images ?? [];\n const uploading = Boolean(imageInput?.uploading);\n const pickerDisabled =\n disabled ||\n imageInput?.disabled ||\n uploading ||\n !imageInput?.onSelect ||\n (imageInput.maxImages !== undefined &&\n images.length >= imageInput.maxImages);\n const hasAttachments = showImageInput || images.length > 0;\n const rowAlignment = \"items-end\";\n\n return (\n <InputGroup\n {...props}\n data-disabled={disabled}\n className={cn(\n \"h-auto\",\n hasAttachments ? \"flex-col items-stretch\" : rowAlignment,\n className\n )}\n >\n {images.length > 0 ? (\n <span className=\"flex w-full flex-wrap gap-2 px-3 pt-2 pb-1\">\n {images.map((url, index) => {\n const source = imageInput?.resolvePreviewUrl?.(url) ?? url;\n // Only web URLs become active links; local data previews remain display-only.\n const href =\n source.startsWith(\"/\") || /^https?:\\/\\//i.test(source)\n ? source\n : undefined;\n return (\n <span key={`${url}-${index}`} className=\"relative inline-flex\">\n <a href={href} target=\"_blank\" rel=\"noreferrer\">\n {/* eslint-disable-next-line @next/next/no-img-element -- Host upload and data URLs bypass framework-specific image optimization. */}\n <img\n src={source}\n alt={`${texts.attachedImageLabel} ${index + 1}`}\n className=\"h-14 w-14 rounded-md border object-contain\"\n />\n </a>\n {!disabled && imageInput?.onRemove ? (\n <button\n type=\"button\"\n aria-label={`${texts.removeImageLabel} ${index + 1}`}\n disabled={uploading || imageInput.disabled}\n onClick={() => imageInput.onRemove?.(index)}\n className=\"absolute -end-1 -top-1 inline-flex size-5 items-center justify-center rounded-full border bg-white text-gray-700 disabled:opacity-50\"\n >\n <X className=\"size-3\" aria-hidden=\"true\" />\n </button>\n ) : null}\n </span>\n );\n })}\n </span>\n ) : null}\n {hasAttachments ? (\n <span className={cn(\"flex w-full min-w-0\", rowAlignment)}>\n {showImageInput && !disabled ? (\n <>\n <input\n ref={input}\n type=\"file\"\n accept={imageInput?.accept ?? \"image/*\"}\n multiple\n hidden\n disabled={pickerDisabled}\n onChange={(event) => {\n const files = Array.from(event.currentTarget.files ?? []);\n event.currentTarget.value = \"\";\n if (!pickerDisabled && files.length)\n imageInput?.onSelect?.(files);\n }}\n />\n <InputGroupButton\n type=\"button\"\n size=\"icon-sm\"\n variant=\"ghost\"\n disabled={pickerDisabled}\n onClick={() => input.current?.click()}\n aria-label={\n uploading ? texts.imageUploadingLabel : texts.addImageLabel\n }\n title={texts.addImageLabel}\n className=\"ms-1\"\n >\n {uploading ? (\n <LoaderCircle\n className=\"size-4 animate-spin\"\n aria-hidden=\"true\"\n />\n ) : (\n <ImagePlus className=\"size-4\" aria-hidden=\"true\" />\n )}\n </InputGroupButton>\n </>\n ) : null}\n {children}\n </span>\n ) : (\n children\n )}\n </InputGroup>\n );\n}\n"],"names":["ImageInputGroup","showImageInput","imageInput","disabled","locale","children","className","props","input","useRef","texts","getContentRenderLocaleTexts","images","uploading","pickerDisabled","hasAttachments","rowAlignment","jsxs","InputGroup","cn","jsx","url","index","source","href","X","Fragment","event","files","InputGroupButton","LoaderCircle","ImagePlus"],"mappings":"udAoCO,SAASA,EAAgB,CAC9B,eAAAC,EAAiB,GACjB,WAAAC,EACA,SAAAC,EACA,OAAAC,EACA,SAAAC,EACA,UAAAC,EACA,GAAGC,CACL,EAAyB,CACvB,MAAMC,EAAQC,EAAAA,OAAyB,IAAI,EACrCC,EAAQC,EAAAA,4BAA4BP,CAAM,EAC1CQ,EAASV,GAAY,QAAU,CAAA,EAC/BW,EAAY,EAAQX,GAAY,UAChCY,EACJX,GACAD,GAAY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SAAA,CACE,SAAA,CAAAN,EAAAA,IAAC,QAAA,CACC,IAAKZ,EACL,KAAK,OACL,OAAQN,GAAY,QAAU,UAC9B,SAAQ,GACR,OAAM,GACN,SAAUY,EACV,SAAWa,GAAU,CACnB,MAAMC,EAAQ,MAAM,KAAKD,EAAM,cAAc,OAAS,EAAE,EACxDA,EAAM,cAAc,MAAQ,GACxB,CAACb,GAAkBc,EAAM,QAC3B1B,GAAY,WAAW0B,CAAK,CAChC,CAAA,CAAA,EAEFR,EAAAA,IAACS,EAAAA,iBAAA,CACC,KAAK,SACL,KAAK,UACL,QAAQ,QACR,SAAUf,EACV,QAAS,IAAMN,EAAM,SAAS,MAAA,EAC9B,aACEK,EAAYH,EAAM,oBAAsBA,EAAM,cAEhD,MAAOA,EAAM,cACb,UAAU,OAET,SAAAG,EACCO,EAAAA,IAACU,EAAAA,QAAA,CACC,UAAU,sBACV,cAAY,MAAA,CAAA,EAGdV,EAAAA,IAACW,EAAAA,QAAA,CAAU,UAAU,SAAS,cAAY,MAAA,CAAO,CAAA,CAAA,CAErD,CAAA,CACF,EACE,KACH1B,CAAA,CAAA,CACH,EAEAA,CAAA,CAAA,CAAA,CAIR"}
|
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import { jsxs as c, jsx as t, Fragment as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { InputGroup as L, InputGroupButton as
|
|
5
|
-
import { getContentRenderLocaleTexts as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
function
|
|
1
|
+
import { jsxs as c, jsx as t, Fragment as w } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as y } from "react";
|
|
3
|
+
import { cn as b } from "../../lib/utils.es.js";
|
|
4
|
+
import { InputGroup as L, InputGroupButton as $ } from "../ui/inputGroup/input-group.es.js";
|
|
5
|
+
import { getContentRenderLocaleTexts as k } from "./contentRenderI18n.es.js";
|
|
6
|
+
import z from "../../node_modules/lucide-react/dist/esm/icons/x.es.js";
|
|
7
|
+
import C from "../../node_modules/lucide-react/dist/esm/icons/loader-circle.es.js";
|
|
8
|
+
import j from "../../node_modules/lucide-react/dist/esm/icons/image-plus.es.js";
|
|
9
|
+
function D({
|
|
10
10
|
showImageInput: d = !1,
|
|
11
11
|
imageInput: e,
|
|
12
12
|
disabled: s,
|
|
13
|
-
locale:
|
|
13
|
+
locale: g,
|
|
14
14
|
children: f,
|
|
15
|
-
className:
|
|
16
|
-
...
|
|
15
|
+
className: x,
|
|
16
|
+
...N
|
|
17
17
|
}) {
|
|
18
|
-
const p =
|
|
18
|
+
const p = y(null), r = k(g), o = e?.images ?? [], n = !!e?.uploading, m = s || e?.disabled || n || !e?.onSelect || e.maxImages !== void 0 && o.length >= e.maxImages, u = d || o.length > 0, h = "items-end";
|
|
19
19
|
return /* @__PURE__ */ c(
|
|
20
20
|
L,
|
|
21
21
|
{
|
|
22
|
-
...
|
|
22
|
+
...N,
|
|
23
23
|
"data-disabled": s,
|
|
24
|
-
className:
|
|
25
|
-
|
|
26
|
-
u
|
|
24
|
+
className: b(
|
|
25
|
+
"h-auto",
|
|
26
|
+
u ? "flex-col items-stretch" : h,
|
|
27
|
+
x
|
|
27
28
|
),
|
|
28
29
|
children: [
|
|
29
|
-
o.length > 0 ? /* @__PURE__ */ t("span", { className: "flex w-full flex-wrap gap-2 px-3 pt-2 pb-1", children: o.map((
|
|
30
|
-
const i = e?.resolvePreviewUrl?.(
|
|
30
|
+
o.length > 0 ? /* @__PURE__ */ t("span", { className: "flex w-full flex-wrap gap-2 px-3 pt-2 pb-1", children: o.map((l, a) => {
|
|
31
|
+
const i = e?.resolvePreviewUrl?.(l) ?? l, v = i.startsWith("/") || /^https?:\/\//i.test(i) ? i : void 0;
|
|
31
32
|
return /* @__PURE__ */ c("span", { className: "relative inline-flex", children: [
|
|
32
|
-
/* @__PURE__ */ t("a", { href:
|
|
33
|
+
/* @__PURE__ */ t("a", { href: v, target: "_blank", rel: "noreferrer", children: /* @__PURE__ */ t(
|
|
33
34
|
"img",
|
|
34
35
|
{
|
|
35
36
|
src: i,
|
|
36
|
-
alt: `${
|
|
37
|
+
alt: `${r.attachedImageLabel} ${a + 1}`,
|
|
37
38
|
className: "h-14 w-14 rounded-md border object-contain"
|
|
38
39
|
}
|
|
39
40
|
) }),
|
|
@@ -41,17 +42,17 @@ function U({
|
|
|
41
42
|
"button",
|
|
42
43
|
{
|
|
43
44
|
type: "button",
|
|
44
|
-
"aria-label": `${
|
|
45
|
+
"aria-label": `${r.removeImageLabel} ${a + 1}`,
|
|
45
46
|
disabled: n || e.disabled,
|
|
46
47
|
onClick: () => e.onRemove?.(a),
|
|
47
48
|
className: "absolute -end-1 -top-1 inline-flex size-5 items-center justify-center rounded-full border bg-white text-gray-700 disabled:opacity-50",
|
|
48
|
-
children: /* @__PURE__ */ t(
|
|
49
|
+
children: /* @__PURE__ */ t(z, { className: "size-3", "aria-hidden": "true" })
|
|
49
50
|
}
|
|
50
51
|
) : null
|
|
51
|
-
] }, `${
|
|
52
|
+
] }, `${l}-${a}`);
|
|
52
53
|
}) }) : null,
|
|
53
|
-
u ? /* @__PURE__ */ c("span", { className: "flex w-full min-w-0
|
|
54
|
-
d && !s ? /* @__PURE__ */ c(
|
|
54
|
+
u ? /* @__PURE__ */ c("span", { className: b("flex w-full min-w-0", h), children: [
|
|
55
|
+
d && !s ? /* @__PURE__ */ c(w, { children: [
|
|
55
56
|
/* @__PURE__ */ t(
|
|
56
57
|
"input",
|
|
57
58
|
{
|
|
@@ -61,30 +62,30 @@ function U({
|
|
|
61
62
|
multiple: !0,
|
|
62
63
|
hidden: !0,
|
|
63
64
|
disabled: m,
|
|
64
|
-
onChange: (
|
|
65
|
-
const a = Array.from(
|
|
66
|
-
|
|
65
|
+
onChange: (l) => {
|
|
66
|
+
const a = Array.from(l.currentTarget.files ?? []);
|
|
67
|
+
l.currentTarget.value = "", !m && a.length && e?.onSelect?.(a);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
),
|
|
70
71
|
/* @__PURE__ */ t(
|
|
71
|
-
|
|
72
|
+
$,
|
|
72
73
|
{
|
|
73
74
|
type: "button",
|
|
74
75
|
size: "icon-sm",
|
|
75
76
|
variant: "ghost",
|
|
76
77
|
disabled: m,
|
|
77
78
|
onClick: () => p.current?.click(),
|
|
78
|
-
"aria-label": n ?
|
|
79
|
-
title:
|
|
80
|
-
className: "ms-1
|
|
79
|
+
"aria-label": n ? r.imageUploadingLabel : r.addImageLabel,
|
|
80
|
+
title: r.addImageLabel,
|
|
81
|
+
className: "ms-1",
|
|
81
82
|
children: n ? /* @__PURE__ */ t(
|
|
82
|
-
|
|
83
|
+
C,
|
|
83
84
|
{
|
|
84
85
|
className: "size-4 animate-spin",
|
|
85
86
|
"aria-hidden": "true"
|
|
86
87
|
}
|
|
87
|
-
) : /* @__PURE__ */ t(
|
|
88
|
+
) : /* @__PURE__ */ t(j, { className: "size-4", "aria-hidden": "true" })
|
|
88
89
|
}
|
|
89
90
|
)
|
|
90
91
|
] }) : null,
|
|
@@ -95,6 +96,6 @@ function U({
|
|
|
95
96
|
);
|
|
96
97
|
}
|
|
97
98
|
export {
|
|
98
|
-
|
|
99
|
+
D as ImageInputGroup
|
|
99
100
|
};
|
|
100
101
|
//# sourceMappingURL=ImageInputGroup.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageInputGroup.es.js","sources":["../../../src/components/ContentRender/ImageInputGroup.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport { ImagePlus, LoaderCircle, X } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\nimport type { MarkdownFlowLocale } from \"../../lib/locale\";\nimport { InputGroup, InputGroupButton } from \"../ui/inputGroup/input-group\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\n\n/** Controlled upload state. The host owns validation, persistence and errors. */\nexport interface ImageInputOptions {\n /** Uploaded image URLs in submission order. */\n images: readonly string[];\n /** Prevent submission and attachment changes while uploads are pending. */\n uploading?: boolean;\n /** Disable attachment changes independently of text editing. */\n disabled?: boolean;\n /** Receive the selected files; update images after uploading them. */\n onSelect?: (files: File[]) => void;\n /** Remove an uploaded image by its index. */\n onRemove?: (index: number) => void;\n /** File picker filter. Defaults to image files. */\n accept?: string;\n /** Disable adding more images when this count is reached. */\n maxImages?: number;\n /** Resolve display URLs without changing the URLs returned on submission. */\n resolvePreviewUrl?: (url: string) => string;\n}\n\ninterface ImageInputGroupProps extends React.ComponentProps<typeof InputGroup> {\n showImageInput?: boolean;\n imageInput?: ImageInputOptions;\n disabled?: boolean;\n locale?: MarkdownFlowLocale;\n}\n\n/** Keep attachment controls inside the same border as the text input. */\nexport function ImageInputGroup({\n showImageInput = false,\n imageInput,\n disabled,\n locale,\n children,\n className,\n ...props\n}: ImageInputGroupProps) {\n const input = useRef<HTMLInputElement>(null);\n const texts = getContentRenderLocaleTexts(locale);\n const images = imageInput?.images ?? [];\n const uploading = Boolean(imageInput?.uploading);\n const pickerDisabled =\n disabled ||\n imageInput?.disabled ||\n uploading ||\n !imageInput?.onSelect ||\n (imageInput.maxImages !== undefined &&\n images.length >= imageInput.maxImages);\n const hasAttachments = showImageInput || images.length > 0;\n\n return (\n <InputGroup\n {...props}\n data-disabled={disabled}\n className={cn(\n
|
|
1
|
+
{"version":3,"file":"ImageInputGroup.es.js","sources":["../../../src/components/ContentRender/ImageInputGroup.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport { ImagePlus, LoaderCircle, X } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils\";\nimport type { MarkdownFlowLocale } from \"../../lib/locale\";\nimport { InputGroup, InputGroupButton } from \"../ui/inputGroup/input-group\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\n\n/** Controlled upload state. The host owns validation, persistence and errors. */\nexport interface ImageInputOptions {\n /** Uploaded image URLs in submission order. */\n images: readonly string[];\n /** Prevent submission and attachment changes while uploads are pending. */\n uploading?: boolean;\n /** Disable attachment changes independently of text editing. */\n disabled?: boolean;\n /** Receive the selected files; update images after uploading them. */\n onSelect?: (files: File[]) => void;\n /** Remove an uploaded image by its index. */\n onRemove?: (index: number) => void;\n /** File picker filter. Defaults to image files. */\n accept?: string;\n /** Disable adding more images when this count is reached. */\n maxImages?: number;\n /** Resolve display URLs without changing the URLs returned on submission. */\n resolvePreviewUrl?: (url: string) => string;\n}\n\ninterface ImageInputGroupProps extends React.ComponentProps<typeof InputGroup> {\n showImageInput?: boolean;\n imageInput?: ImageInputOptions;\n disabled?: boolean;\n locale?: MarkdownFlowLocale;\n}\n\n/** Keep attachment controls inside the same border as the text input. */\nexport function ImageInputGroup({\n showImageInput = false,\n imageInput,\n disabled,\n locale,\n children,\n className,\n ...props\n}: ImageInputGroupProps) {\n const input = useRef<HTMLInputElement>(null);\n const texts = getContentRenderLocaleTexts(locale);\n const images = imageInput?.images ?? [];\n const uploading = Boolean(imageInput?.uploading);\n const pickerDisabled =\n disabled ||\n imageInput?.disabled ||\n uploading ||\n !imageInput?.onSelect ||\n (imageInput.maxImages !== undefined &&\n images.length >= imageInput.maxImages);\n const hasAttachments = showImageInput || images.length > 0;\n const rowAlignment = \"items-end\";\n\n return (\n <InputGroup\n {...props}\n data-disabled={disabled}\n className={cn(\n \"h-auto\",\n hasAttachments ? \"flex-col items-stretch\" : rowAlignment,\n className\n )}\n >\n {images.length > 0 ? (\n <span className=\"flex w-full flex-wrap gap-2 px-3 pt-2 pb-1\">\n {images.map((url, index) => {\n const source = imageInput?.resolvePreviewUrl?.(url) ?? url;\n // Only web URLs become active links; local data previews remain display-only.\n const href =\n source.startsWith(\"/\") || /^https?:\\/\\//i.test(source)\n ? source\n : undefined;\n return (\n <span key={`${url}-${index}`} className=\"relative inline-flex\">\n <a href={href} target=\"_blank\" rel=\"noreferrer\">\n {/* eslint-disable-next-line @next/next/no-img-element -- Host upload and data URLs bypass framework-specific image optimization. */}\n <img\n src={source}\n alt={`${texts.attachedImageLabel} ${index + 1}`}\n className=\"h-14 w-14 rounded-md border object-contain\"\n />\n </a>\n {!disabled && imageInput?.onRemove ? (\n <button\n type=\"button\"\n aria-label={`${texts.removeImageLabel} ${index + 1}`}\n disabled={uploading || imageInput.disabled}\n onClick={() => imageInput.onRemove?.(index)}\n className=\"absolute -end-1 -top-1 inline-flex size-5 items-center justify-center rounded-full border bg-white text-gray-700 disabled:opacity-50\"\n >\n <X className=\"size-3\" aria-hidden=\"true\" />\n </button>\n ) : null}\n </span>\n );\n })}\n </span>\n ) : null}\n {hasAttachments ? (\n <span className={cn(\"flex w-full min-w-0\", rowAlignment)}>\n {showImageInput && !disabled ? (\n <>\n <input\n ref={input}\n type=\"file\"\n accept={imageInput?.accept ?? \"image/*\"}\n multiple\n hidden\n disabled={pickerDisabled}\n onChange={(event) => {\n const files = Array.from(event.currentTarget.files ?? []);\n event.currentTarget.value = \"\";\n if (!pickerDisabled && files.length)\n imageInput?.onSelect?.(files);\n }}\n />\n <InputGroupButton\n type=\"button\"\n size=\"icon-sm\"\n variant=\"ghost\"\n disabled={pickerDisabled}\n onClick={() => input.current?.click()}\n aria-label={\n uploading ? texts.imageUploadingLabel : texts.addImageLabel\n }\n title={texts.addImageLabel}\n className=\"ms-1\"\n >\n {uploading ? (\n <LoaderCircle\n className=\"size-4 animate-spin\"\n aria-hidden=\"true\"\n />\n ) : (\n <ImagePlus className=\"size-4\" aria-hidden=\"true\" />\n )}\n </InputGroupButton>\n </>\n ) : null}\n {children}\n </span>\n ) : (\n children\n )}\n </InputGroup>\n );\n}\n"],"names":["ImageInputGroup","showImageInput","imageInput","disabled","locale","children","className","props","input","useRef","texts","getContentRenderLocaleTexts","images","uploading","pickerDisabled","hasAttachments","rowAlignment","jsxs","InputGroup","cn","jsx","url","index","source","href","X","Fragment","event","files","InputGroupButton","LoaderCircle","ImagePlus"],"mappings":";;;;;;;;AAoCO,SAASA,EAAgB;AAAA,EAC9B,gBAAAC,IAAiB;AAAA,EACjB,YAAAC;AAAA,EACA,UAAAC;A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AAA,EAAU,WAAU,UAAS,eAAY,OAAA,CAAO;AAAA,cAAA;AAAA,YAAA;AAAA,UAErD,EAAA,CACF,IACE;AAAA,UACH1B;AAAA,QAAA,EAAA,CACH,IAEAA;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),j=require("../../assets/icons/send_disable.svg.cjs"),k=require("../../assets/icons/send_enable.svg.cjs"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("react/jsx-runtime"),j=require("../../assets/icons/send_disable.svg.cjs"),k=require("../../assets/icons/send_enable.svg.cjs"),u=require("../ui/inputGroup/input-group.cjs"),d=require("../../lib/locale.cjs"),I=require("./contentRenderI18n.cjs"),D=require("./utils/accept-placeholder.cjs"),G=require("./ImageInputGroup.cjs"),M=e=>typeof e=="string"?e:e.src,A=({disabled:e,locale:n,lang:p,dir:g,placeholder:i,sendButtonLabel:x,value:l,title:f,onChange:m,onSend:s,onAcceptPlaceholder:b,sendShortcut:h="enter",className:w,textareaClassName:y,showImageInput:q=!1,imageInput:a})=>{const v=I.getContentRenderLocaleTexts(n),c=x||v.sendButtonLabel,r=e||a?.uploading||!l?.trim()&&!a?.images.length,_=t=>{D.acceptPlaceholder(t,i,e,b)||h!=="enter"||!s||t.nativeEvent.isComposing||t.keyCode===229||t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),r||s())};return o.jsxs(G.ImageInputGroup,{showImageInput:q,imageInput:a,disabled:e,locale:n,dir:g??d.getMarkdownFlowDirection(n),lang:p??d.getMarkdownFlowLanguage(n),"data-disabled":e,className:`input-container bg-white border-[#e5e5e5] shadow-[0_1px_2px_rgba(0,0,0,0.05)] ${w||""}`,children:[o.jsx(u.InputGroupTextarea,{disabled:e,placeholder:i,value:l,onChange:m,onKeyDown:_,className:`text-[16px] leading-5 font-normal text-[#0A0A0A] placeholder:text-[rgba(99,114,128,1)] bg-transparent border-0 shadow-none ps-3 pe-0 py-1.5 min-h-8 ${y||""}`,title:f}),o.jsx(u.InputGroupButton,{type:"button",variant:"ghost",size:"icon-sm",onClick:s,disabled:r,"aria-label":c,style:{cursor:r?"not-allowed":"pointer"},className:"mx-[3px]",children:o.jsx("img",{src:M(r?j.default:k.default),alt:c,className:"size-6"})})]})};exports.default=A;
|
|
2
2
|
//# sourceMappingURL=MarkdownFlowInput.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownFlowInput.cjs","sources":["../../../src/components/ContentRender/MarkdownFlowInput.tsx"],"sourcesContent":["import React from \"react\";\n\nimport sendIconDisable from \"@/assets/icons/send_disable.svg\";\nimport sendIconEnable from \"@/assets/icons/send_enable.svg\";\n\nimport {\n InputGroupButton,\n InputGroupTextarea,\n} from \"../ui/inputGroup/input-group\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\nimport { acceptPlaceholder } from \"./utils/accept-placeholder\";\nimport { ImageInputGroup, type ImageInputOptions } from \"./ImageInputGroup\";\n\ntype MarkdownFlowInputSendShortcut = \"enter\" | \"none\";\n\ninterface MarkdownFlowInputProps {\n /** Show the image picker inside the input. Hidden by default. */\n showImageInput?: boolean;\n /** Host-controlled image upload state and callbacks. */\n imageInput?: ImageInputOptions;\n /** Overrides locale-derived input direction. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n disabled?: boolean;\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language. */\n lang?: string;\n placeholder?: string;\n sendButtonLabel?: string;\n value?: string;\n title?: string;\n onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onSend?: () => void;\n /** Enables Tab completion of an empty input; the host must update its value. */\n onAcceptPlaceholder?: (value: string) => void;\n /**\n * Keyboard policy for sending a multi-line input. `enter` sends on Enter\n * while Shift+Enter keeps its native newline behavior. `none` leaves Enter\n * untouched, which lets mobile consumers reserve the keyboard return key\n * for newlines.\n */\n sendShortcut?: MarkdownFlowInputSendShortcut;\n className?: string;\n textareaClassName?: string;\n}\n\nconst resolveAssetSrc = (asset: string | { src: string }) =>\n typeof asset === \"string\" ? asset : asset.src;\n\nconst MarkdownFlowInput: React.FC<MarkdownFlowInputProps> = ({\n disabled,\n locale,\n lang,\n dir,\n placeholder,\n sendButtonLabel,\n value,\n title,\n onChange,\n onSend,\n onAcceptPlaceholder,\n sendShortcut = \"enter\",\n className,\n textareaClassName,\n showImageInput = false,\n imageInput,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedSendButtonLabel =\n sendButtonLabel || localeTexts.sendButtonLabel;\n const isSendDisabled =\n disabled ||\n imageInput?.uploading ||\n (!value?.trim() && !imageInput?.images.length);\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (acceptPlaceholder(e, placeholder, disabled, onAcceptPlaceholder)) {\n return;\n }\n if (sendShortcut !== \"enter\" || !onSend) {\n return;\n }\n if (e.nativeEvent.isComposing || e.keyCode === 229) {\n return;\n }\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n if (!isSendDisabled) {\n onSend();\n }\n }\n };\n\n return (\n <ImageInputGroup\n showImageInput={showImageInput}\n imageInput={imageInput}\n disabled={disabled}\n locale={locale}\n dir={dir ?? getMarkdownFlowDirection(locale)}\n lang={lang ?? getMarkdownFlowLanguage(locale)}\n data-disabled={disabled}\n className={`input-container
|
|
1
|
+
{"version":3,"file":"MarkdownFlowInput.cjs","sources":["../../../src/components/ContentRender/MarkdownFlowInput.tsx"],"sourcesContent":["import React from \"react\";\n\nimport sendIconDisable from \"@/assets/icons/send_disable.svg\";\nimport sendIconEnable from \"@/assets/icons/send_enable.svg\";\n\nimport {\n InputGroupButton,\n InputGroupTextarea,\n} from \"../ui/inputGroup/input-group\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\nimport { acceptPlaceholder } from \"./utils/accept-placeholder\";\nimport { ImageInputGroup, type ImageInputOptions } from \"./ImageInputGroup\";\n\ntype MarkdownFlowInputSendShortcut = \"enter\" | \"none\";\n\ninterface MarkdownFlowInputProps {\n /** Show the image picker inside the input. Hidden by default. */\n showImageInput?: boolean;\n /** Host-controlled image upload state and callbacks. */\n imageInput?: ImageInputOptions;\n /** Overrides locale-derived input direction. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n disabled?: boolean;\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language. */\n lang?: string;\n placeholder?: string;\n sendButtonLabel?: string;\n value?: string;\n title?: string;\n onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onSend?: () => void;\n /** Enables Tab completion of an empty input; the host must update its value. */\n onAcceptPlaceholder?: (value: string) => void;\n /**\n * Keyboard policy for sending a multi-line input. `enter` sends on Enter\n * while Shift+Enter keeps its native newline behavior. `none` leaves Enter\n * untouched, which lets mobile consumers reserve the keyboard return key\n * for newlines.\n */\n sendShortcut?: MarkdownFlowInputSendShortcut;\n className?: string;\n textareaClassName?: string;\n}\n\nconst resolveAssetSrc = (asset: string | { src: string }) =>\n typeof asset === \"string\" ? asset : asset.src;\n\nconst MarkdownFlowInput: React.FC<MarkdownFlowInputProps> = ({\n disabled,\n locale,\n lang,\n dir,\n placeholder,\n sendButtonLabel,\n value,\n title,\n onChange,\n onSend,\n onAcceptPlaceholder,\n sendShortcut = \"enter\",\n className,\n textareaClassName,\n showImageInput = false,\n imageInput,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedSendButtonLabel =\n sendButtonLabel || localeTexts.sendButtonLabel;\n const isSendDisabled =\n disabled ||\n imageInput?.uploading ||\n (!value?.trim() && !imageInput?.images.length);\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (acceptPlaceholder(e, placeholder, disabled, onAcceptPlaceholder)) {\n return;\n }\n if (sendShortcut !== \"enter\" || !onSend) {\n return;\n }\n if (e.nativeEvent.isComposing || e.keyCode === 229) {\n return;\n }\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n if (!isSendDisabled) {\n onSend();\n }\n }\n };\n\n return (\n <ImageInputGroup\n showImageInput={showImageInput}\n imageInput={imageInput}\n disabled={disabled}\n locale={locale}\n dir={dir ?? getMarkdownFlowDirection(locale)}\n lang={lang ?? getMarkdownFlowLanguage(locale)}\n data-disabled={disabled}\n className={`input-container bg-white border-[#e5e5e5] shadow-[0_1px_2px_rgba(0,0,0,0.05)] ${className || \"\"}`}\n >\n <InputGroupTextarea\n disabled={disabled}\n placeholder={placeholder}\n value={value}\n onChange={onChange}\n onKeyDown={handleKeyDown}\n className={`text-[16px] leading-5 font-normal text-[#0A0A0A] placeholder:text-[rgba(99,114,128,1)] bg-transparent border-0 shadow-none ps-3 pe-0 py-1.5 min-h-8 ${textareaClassName || \"\"}`}\n title={title}\n />\n <InputGroupButton\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n onClick={onSend}\n disabled={isSendDisabled}\n aria-label={resolvedSendButtonLabel}\n style={{ cursor: isSendDisabled ? \"not-allowed\" : \"pointer\" }}\n className=\"mx-[3px]\"\n >\n <img\n src={resolveAssetSrc(\n isSendDisabled ? sendIconDisable : sendIconEnable\n )}\n alt={resolvedSendButtonLabel}\n className=\"size-6\"\n />\n </InputGroupButton>\n </ImageInputGroup>\n );\n};\n\nexport type { MarkdownFlowInputProps, MarkdownFlowInputSendShortcut };\nexport default MarkdownFlowInput;\n"],"names":["resolveAssetSrc","asset","MarkdownFlowInput","disabled","locale","lang","dir","placeholder","sendButtonLabel","value","title","onChange","onSend","onAcceptPlaceholder","sendShortcut","className","textareaClassName","showImageInput","imageInput","localeTexts","getContentRenderLocaleTexts","resolvedSendButtonLabel","isSendDisabled","handleKeyDown","e","acceptPlaceholder","jsxs","ImageInputGroup","getMarkdownFlowDirection","getMarkdownFlowLanguage","jsx","InputGroupTextarea","InputGroupButton","sendIconDisable","sendIconEnable"],"mappings":"8bAkDMA,EAAmBC,GACvB,OAAOA,GAAU,SAAWA,EAAQA,EAAM,IAEtCC,EAAsD,CAAC,CAC3D,SAAAC,EAAA,OACAC,EACA,KAAAC,EACA,IAAAC,EACA,YAAAC,EACA,gBAAAC,EACA,MAAAC,EACA,MAAAC,EACA,SAAAC,EACA,OAAAC,EACA,oBAAAC,EACA,aAAAC,EAAe,QACf,UAAAC,EACA,kBAAAC,EACA,eAAAC,EAAiB,GACjB,WAAAC,CACF,IAAM,CACJ,MAAMC,EAAcC,EAAAA,4BAA4BhB,CAAM,EAChDiB,EACJb,GAAmBW,EAAY,gBAC3BG,EACJnB,GACAe,GAAY,WACX,CAACT,GAAO,QAAU,CAACS,GAAY,OAAO,OACnCK,EAAiBC,GAAgD,CACjEC,EAAAA,kBAAkBD,EAAGjB,EAAaJ,EAAUU,CAAmB,GAG/DC,IAAiB,SAAW,CAACF,GAG7BY,EAAE,YAAY,aAAeA,EAAE,UAAY,KAG3CA,EAAE,MAAQ,SAAW,CAACA,EAAE,WAC1BA,EAAE,eAAA,EACGF,GACHV,EAAA,EAGN,EAEA,OACEc,EAAAA,KAACC,EAAAA,gBAAA,CACC,eAAAV,EACA,WAAAC,EACA,SAAAf,EAAA,OACAC,EACA,IAAKE,GAAOsB,EAAAA,yBAAyBxB,CAAM,EAC3C,KAAMC,GAAQwB,EAAAA,wBAAwBzB,CAAM,EAC5C,gBAAeD,EACf,UAAW,iFAAiFY,GAAa,EAAE,GAE3G,SAAA,CAAAe,EAAAA,IAACC,EAAAA,mBAAA,CACC,SAAA5B,EACA,YAAAI,EACA,MAAAE,EACA,SAAAE,EACA,UAAWY,EACX,UAAW,uJAAuJP,GAAqB,EAAE,GACzL,MAAAN,CAAA,CAAA,EAEFoB,EAAAA,IAACE,EAAAA,iBAAA,CACC,KAAK,SACL,QAAQ,QACR,KAAK,UACL,QAASpB,EACT,SAAUU,EACV,aAAYD,EACZ,MAAO,CAAE,OAAQC,EAAiB,cAAgB,SAAA,EAClD,UAAU,WAEV,SAAAQ,EAAAA,IAAC,MAAA,CACC,IAAK9B,EACHsB,EAAiBW,EAAAA,QAAkBC,EAAAA,OAAA,EAErC,IAAKb,EACL,UAAU,QAAA,CAAA,CACZ,CAAA,CACF,CAAA,CAAA,CAGN"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsxs as D, jsx as
|
|
1
|
+
import { jsxs as D, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import v from "../../assets/icons/send_disable.svg.es.js";
|
|
3
3
|
import I from "../../assets/icons/send_enable.svg.es.js";
|
|
4
4
|
import { InputGroupTextarea as A, InputGroupButton as C } from "../ui/inputGroup/input-group.es.js";
|
|
5
5
|
import { getMarkdownFlowLanguage as L, getMarkdownFlowDirection as N } from "../../lib/locale.es.js";
|
|
6
|
-
import { getContentRenderLocaleTexts as
|
|
7
|
-
import { acceptPlaceholder as
|
|
8
|
-
import { ImageInputGroup as
|
|
9
|
-
const
|
|
10
|
-
disabled:
|
|
6
|
+
import { getContentRenderLocaleTexts as B } from "./contentRenderI18n.es.js";
|
|
7
|
+
import { acceptPlaceholder as E } from "./utils/accept-placeholder.es.js";
|
|
8
|
+
import { ImageInputGroup as F } from "./ImageInputGroup.es.js";
|
|
9
|
+
const G = (t) => typeof t == "string" ? t : t.src, R = ({
|
|
10
|
+
disabled: t,
|
|
11
11
|
locale: r,
|
|
12
12
|
lang: m,
|
|
13
13
|
dir: c,
|
|
@@ -19,39 +19,39 @@ const F = (e) => typeof e == "string" ? e : e.src, R = ({
|
|
|
19
19
|
onSend: n,
|
|
20
20
|
onAcceptPlaceholder: g,
|
|
21
21
|
sendShortcut: x = "enter",
|
|
22
|
-
className:
|
|
23
|
-
textareaClassName:
|
|
24
|
-
showImageInput:
|
|
25
|
-
imageInput:
|
|
22
|
+
className: w,
|
|
23
|
+
textareaClassName: b,
|
|
24
|
+
showImageInput: h = !1,
|
|
25
|
+
imageInput: a
|
|
26
26
|
}) => {
|
|
27
|
-
const y =
|
|
28
|
-
|
|
27
|
+
const y = B(r), l = d || y.sendButtonLabel, o = t || a?.uploading || !p?.trim() && !a?.images.length, k = (e) => {
|
|
28
|
+
E(e, i, t, g) || x !== "enter" || !n || e.nativeEvent.isComposing || e.keyCode === 229 || e.key === "Enter" && !e.shiftKey && (e.preventDefault(), o || n());
|
|
29
29
|
};
|
|
30
30
|
return /* @__PURE__ */ D(
|
|
31
|
-
|
|
31
|
+
F,
|
|
32
32
|
{
|
|
33
|
-
showImageInput:
|
|
34
|
-
imageInput:
|
|
35
|
-
disabled:
|
|
33
|
+
showImageInput: h,
|
|
34
|
+
imageInput: a,
|
|
35
|
+
disabled: t,
|
|
36
36
|
locale: r,
|
|
37
37
|
dir: c ?? N(r),
|
|
38
38
|
lang: m ?? L(r),
|
|
39
|
-
"data-disabled":
|
|
40
|
-
className: `input-container
|
|
39
|
+
"data-disabled": t,
|
|
40
|
+
className: `input-container bg-white border-[#e5e5e5] shadow-[0_1px_2px_rgba(0,0,0,0.05)] ${w || ""}`,
|
|
41
41
|
children: [
|
|
42
|
-
/* @__PURE__ */
|
|
42
|
+
/* @__PURE__ */ s(
|
|
43
43
|
A,
|
|
44
44
|
{
|
|
45
|
-
disabled:
|
|
45
|
+
disabled: t,
|
|
46
46
|
placeholder: i,
|
|
47
47
|
value: p,
|
|
48
48
|
onChange: u,
|
|
49
49
|
onKeyDown: k,
|
|
50
|
-
className: `text-[16px] leading-5 font-normal text-[#0A0A0A] placeholder:text-[rgba(99,114,128,1)] bg-transparent border-0 shadow-none ps-3 pe-0 py-1.5 min-h-
|
|
50
|
+
className: `text-[16px] leading-5 font-normal text-[#0A0A0A] placeholder:text-[rgba(99,114,128,1)] bg-transparent border-0 shadow-none ps-3 pe-0 py-1.5 min-h-8 ${b || ""}`,
|
|
51
51
|
title: f
|
|
52
52
|
}
|
|
53
53
|
),
|
|
54
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ s(
|
|
55
55
|
C,
|
|
56
56
|
{
|
|
57
57
|
type: "button",
|
|
@@ -60,15 +60,12 @@ const F = (e) => typeof e == "string" ? e : e.src, R = ({
|
|
|
60
60
|
onClick: n,
|
|
61
61
|
disabled: o,
|
|
62
62
|
"aria-label": l,
|
|
63
|
-
style: {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
className: "size-6 group self-end mb-[2px]",
|
|
68
|
-
children: /* @__PURE__ */ a(
|
|
63
|
+
style: { cursor: o ? "not-allowed" : "pointer" },
|
|
64
|
+
className: "mx-[3px]",
|
|
65
|
+
children: /* @__PURE__ */ s(
|
|
69
66
|
"img",
|
|
70
67
|
{
|
|
71
|
-
src:
|
|
68
|
+
src: G(
|
|
72
69
|
o ? v : I
|
|
73
70
|
),
|
|
74
71
|
alt: l,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownFlowInput.es.js","sources":["../../../src/components/ContentRender/MarkdownFlowInput.tsx"],"sourcesContent":["import React from \"react\";\n\nimport sendIconDisable from \"@/assets/icons/send_disable.svg\";\nimport sendIconEnable from \"@/assets/icons/send_enable.svg\";\n\nimport {\n InputGroupButton,\n InputGroupTextarea,\n} from \"../ui/inputGroup/input-group\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\nimport { acceptPlaceholder } from \"./utils/accept-placeholder\";\nimport { ImageInputGroup, type ImageInputOptions } from \"./ImageInputGroup\";\n\ntype MarkdownFlowInputSendShortcut = \"enter\" | \"none\";\n\ninterface MarkdownFlowInputProps {\n /** Show the image picker inside the input. Hidden by default. */\n showImageInput?: boolean;\n /** Host-controlled image upload state and callbacks. */\n imageInput?: ImageInputOptions;\n /** Overrides locale-derived input direction. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n disabled?: boolean;\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language. */\n lang?: string;\n placeholder?: string;\n sendButtonLabel?: string;\n value?: string;\n title?: string;\n onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onSend?: () => void;\n /** Enables Tab completion of an empty input; the host must update its value. */\n onAcceptPlaceholder?: (value: string) => void;\n /**\n * Keyboard policy for sending a multi-line input. `enter` sends on Enter\n * while Shift+Enter keeps its native newline behavior. `none` leaves Enter\n * untouched, which lets mobile consumers reserve the keyboard return key\n * for newlines.\n */\n sendShortcut?: MarkdownFlowInputSendShortcut;\n className?: string;\n textareaClassName?: string;\n}\n\nconst resolveAssetSrc = (asset: string | { src: string }) =>\n typeof asset === \"string\" ? asset : asset.src;\n\nconst MarkdownFlowInput: React.FC<MarkdownFlowInputProps> = ({\n disabled,\n locale,\n lang,\n dir,\n placeholder,\n sendButtonLabel,\n value,\n title,\n onChange,\n onSend,\n onAcceptPlaceholder,\n sendShortcut = \"enter\",\n className,\n textareaClassName,\n showImageInput = false,\n imageInput,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedSendButtonLabel =\n sendButtonLabel || localeTexts.sendButtonLabel;\n const isSendDisabled =\n disabled ||\n imageInput?.uploading ||\n (!value?.trim() && !imageInput?.images.length);\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (acceptPlaceholder(e, placeholder, disabled, onAcceptPlaceholder)) {\n return;\n }\n if (sendShortcut !== \"enter\" || !onSend) {\n return;\n }\n if (e.nativeEvent.isComposing || e.keyCode === 229) {\n return;\n }\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n if (!isSendDisabled) {\n onSend();\n }\n }\n };\n\n return (\n <ImageInputGroup\n showImageInput={showImageInput}\n imageInput={imageInput}\n disabled={disabled}\n locale={locale}\n dir={dir ?? getMarkdownFlowDirection(locale)}\n lang={lang ?? getMarkdownFlowLanguage(locale)}\n data-disabled={disabled}\n className={`input-container
|
|
1
|
+
{"version":3,"file":"MarkdownFlowInput.es.js","sources":["../../../src/components/ContentRender/MarkdownFlowInput.tsx"],"sourcesContent":["import React from \"react\";\n\nimport sendIconDisable from \"@/assets/icons/send_disable.svg\";\nimport sendIconEnable from \"@/assets/icons/send_enable.svg\";\n\nimport {\n InputGroupButton,\n InputGroupTextarea,\n} from \"../ui/inputGroup/input-group\";\nimport {\n getMarkdownFlowDirection,\n getMarkdownFlowLanguage,\n type MarkdownFlowLocale,\n} from \"../../lib/locale\";\nimport { getContentRenderLocaleTexts } from \"./contentRenderI18n\";\nimport { acceptPlaceholder } from \"./utils/accept-placeholder\";\nimport { ImageInputGroup, type ImageInputOptions } from \"./ImageInputGroup\";\n\ntype MarkdownFlowInputSendShortcut = \"enter\" | \"none\";\n\ninterface MarkdownFlowInputProps {\n /** Show the image picker inside the input. Hidden by default. */\n showImageInput?: boolean;\n /** Host-controlled image upload state and callbacks. */\n imageInput?: ImageInputOptions;\n /** Overrides locale-derived input direction. */\n dir?: React.HTMLAttributes<HTMLDivElement>[\"dir\"];\n disabled?: boolean;\n locale?: MarkdownFlowLocale;\n /** Overrides the locale-derived language. */\n lang?: string;\n placeholder?: string;\n sendButtonLabel?: string;\n value?: string;\n title?: string;\n onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;\n onSend?: () => void;\n /** Enables Tab completion of an empty input; the host must update its value. */\n onAcceptPlaceholder?: (value: string) => void;\n /**\n * Keyboard policy for sending a multi-line input. `enter` sends on Enter\n * while Shift+Enter keeps its native newline behavior. `none` leaves Enter\n * untouched, which lets mobile consumers reserve the keyboard return key\n * for newlines.\n */\n sendShortcut?: MarkdownFlowInputSendShortcut;\n className?: string;\n textareaClassName?: string;\n}\n\nconst resolveAssetSrc = (asset: string | { src: string }) =>\n typeof asset === \"string\" ? asset : asset.src;\n\nconst MarkdownFlowInput: React.FC<MarkdownFlowInputProps> = ({\n disabled,\n locale,\n lang,\n dir,\n placeholder,\n sendButtonLabel,\n value,\n title,\n onChange,\n onSend,\n onAcceptPlaceholder,\n sendShortcut = \"enter\",\n className,\n textareaClassName,\n showImageInput = false,\n imageInput,\n}) => {\n const localeTexts = getContentRenderLocaleTexts(locale);\n const resolvedSendButtonLabel =\n sendButtonLabel || localeTexts.sendButtonLabel;\n const isSendDisabled =\n disabled ||\n imageInput?.uploading ||\n (!value?.trim() && !imageInput?.images.length);\n const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (acceptPlaceholder(e, placeholder, disabled, onAcceptPlaceholder)) {\n return;\n }\n if (sendShortcut !== \"enter\" || !onSend) {\n return;\n }\n if (e.nativeEvent.isComposing || e.keyCode === 229) {\n return;\n }\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n if (!isSendDisabled) {\n onSend();\n }\n }\n };\n\n return (\n <ImageInputGroup\n showImageInput={showImageInput}\n imageInput={imageInput}\n disabled={disabled}\n locale={locale}\n dir={dir ?? getMarkdownFlowDirection(locale)}\n lang={lang ?? getMarkdownFlowLanguage(locale)}\n data-disabled={disabled}\n className={`input-container bg-white border-[#e5e5e5] shadow-[0_1px_2px_rgba(0,0,0,0.05)] ${className || \"\"}`}\n >\n <InputGroupTextarea\n disabled={disabled}\n placeholder={placeholder}\n value={value}\n onChange={onChange}\n onKeyDown={handleKeyDown}\n className={`text-[16px] leading-5 font-normal text-[#0A0A0A] placeholder:text-[rgba(99,114,128,1)] bg-transparent border-0 shadow-none ps-3 pe-0 py-1.5 min-h-8 ${textareaClassName || \"\"}`}\n title={title}\n />\n <InputGroupButton\n type=\"button\"\n variant=\"ghost\"\n size=\"icon-sm\"\n onClick={onSend}\n disabled={isSendDisabled}\n aria-label={resolvedSendButtonLabel}\n style={{ cursor: isSendDisabled ? \"not-allowed\" : \"pointer\" }}\n className=\"mx-[3px]\"\n >\n <img\n src={resolveAssetSrc(\n isSendDisabled ? sendIconDisable : sendIconEnable\n )}\n alt={resolvedSendButtonLabel}\n className=\"size-6\"\n />\n </InputGroupButton>\n </ImageInputGroup>\n );\n};\n\nexport type { MarkdownFlowInputProps, MarkdownFlowInputSendShortcut };\nexport default MarkdownFlowInput;\n"],"names":["resolveAssetSrc","asset","MarkdownFlowInput","disabled","locale","lang","dir","placeholder","sendButtonLabel","value","title","onChange","onSend","onAcceptPlaceholder","sendShortcut","className","textareaClassName","showImageInput","imageInput","localeTexts","getContentRenderLocaleTexts","resolvedSendButtonLabel","isSendDisabled","handleKeyDown","acceptPlaceholder","jsxs","ImageInputGroup","getMarkdownFlowDirection","getMarkdownFlowLanguage","jsx","InputGroupTextarea","InputGroupButton","sendIconDisable","sendIconEnable"],"mappings":";;;;;;;;AAkDA,MAAMA,IAAkB,CAACC,MACvB,OAAOA,KAAU,WAAWA,IAAQA,EAAM,KAEtCC,IAAsD,CAAC;AAAA,EAC3D,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,MAAAC;AAAA,EACA,KAAAC;AAAA,EACA,aAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,WAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,YAAAC;AACF,MAAM;AACJ,QAAMC,IAAcC,EAA4BhB,CAAM,GAChDiB,IACJb,KAAmBW,EAAY,iBAC3BG,IACJnB,KACAe,GAAY,aACX,CAACT,GAAO,UAAU,CAACS,GAAY,OAAO,QACnCK,IAAgB,CAAC,MAAgD;AACrE,IAAIC,EAAkB,GAAGjB,GAAaJ,GAAUU,CAAmB,KAG/DC,MAAiB,WAAW,CAACF,KAG7B,EAAE,YAAY,eAAe,EAAE,YAAY,OAG3C,EAAE,QAAQ,WAAW,CAAC,EAAE,aAC1B,EAAE,eAAA,GACGU,KACHV,EAAA;AAAA,EAGN;AAEA,SACE,gBAAAa;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,gBAAAT;AAAA,MACA,YAAAC;AAAA,MACA,UAAAf;AAAA,MACA,QAAAC;AAAA,MACA,KAAKE,KAAOqB,EAAyBvB,CAAM;AAAA,MAC3C,MAAMC,KAAQuB,EAAwBxB,CAAM;AAAA,MAC5C,iBAAeD;AAAA,MACf,WAAW,iFAAiFY,KAAa,EAAE;AAAA,MAE3G,UAAA;AAAA,QAAA,gBAAAc;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,UAAA3B;AAAA,YACA,aAAAI;AAAA,YACA,OAAAE;AAAA,YACA,UAAAE;AAAA,YACA,WAAWY;AAAA,YACX,WAAW,uJAAuJP,KAAqB,EAAE;AAAA,YACzL,OAAAN;AAAA,UAAA;AAAA,QAAA;AAAA,QAEF,gBAAAmB;AAAA,UAACE;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,MAAK;AAAA,YACL,SAASnB;AAAA,YACT,UAAUU;AAAA,YACV,cAAYD;AAAA,YACZ,OAAO,EAAE,QAAQC,IAAiB,gBAAgB,UAAA;AAAA,YAClD,WAAU;AAAA,YAEV,UAAA,gBAAAO;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,KAAK7B;AAAA,kBACHsB,IAAiBU,IAAkBC;AAAA,gBAAA;AAAA,gBAErC,KAAKZ;AAAA,gBACL,WAAU;AAAA,cAAA;AAAA,YAAA;AAAA,UACZ;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),d=require("react"),u=require("../../../node_modules/rc-textarea/es/TextArea.cjs");require("../../../_virtual/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),d=require("react"),u=require("../../../node_modules/rc-textarea/es/TextArea.cjs");require("../../../_virtual/index3.cjs");require("../../../node_modules/rc-resize-observer/es/index.cjs");require("../../../node_modules/rc-util/es/hooks/useLayoutEffect.cjs");require("../../../node_modules/rc-util/es/raf.cjs");const s=require("../../../lib/utils.cjs");function c(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const l=c(d),i=l.forwardRef(({className:e,autoSize:t={minRows:1},style:r,...a},n)=>o.jsx(u.default,{ref:n,autoSize:t,className:s.cn("border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 w-full rounded-md border bg-transparent pl-3 py-1.5 text-base shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50","resize-none",e),style:{whiteSpace:"pre-wrap",wordBreak:"break-word",...r},...a}));i.displayName="Textarea";exports.Textarea=i;
|
|
2
2
|
//# sourceMappingURL=textarea.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import * as d from "react";
|
|
3
3
|
import n from "../../../node_modules/rc-textarea/es/TextArea.es.js";
|
|
4
|
-
import "../../../_virtual/
|
|
4
|
+
import "../../../_virtual/index3.es.js";
|
|
5
5
|
import "../../../node_modules/rc-resize-observer/es/index.es.js";
|
|
6
6
|
import "../../../node_modules/rc-util/es/hooks/useLayoutEffect.es.js";
|
|
7
7
|
import "../../../node_modules/rc-util/es/raf.es.js";
|