@windrun-huaiin/third-ui 5.11.0 → 5.11.1
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/fuma/mdx/index.js +3 -1
- package/dist/fuma/mdx/index.js.map +1 -1
- package/dist/fuma/mdx/index.mjs +3 -1
- package/dist/fuma/mdx/index.mjs.map +1 -1
- package/dist/fuma/server.js +3 -1
- package/dist/fuma/server.js.map +1 -1
- package/dist/fuma/server.mjs +3 -1
- package/dist/fuma/server.mjs.map +1 -1
- package/dist/main/index.d.mts +73 -1
- package/dist/main/index.d.ts +73 -1
- package/dist/main/index.js +144 -0
- package/dist/main/index.js.map +1 -1
- package/dist/main/index.mjs +143 -0
- package/dist/main/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/fuma/mdx/fuma-banner-suit.tsx +1 -2
- package/src/main/index.ts +2 -1
package/dist/main/index.mjs
CHANGED
|
@@ -6159,7 +6159,150 @@ function XButton(props) {
|
|
|
6159
6159
|
)
|
|
6160
6160
|
] });
|
|
6161
6161
|
}
|
|
6162
|
+
|
|
6163
|
+
// src/main/ai-prompt-textarea.tsx
|
|
6164
|
+
import { useEffect as useEffect18, useRef as useRef13 } from "react";
|
|
6165
|
+
import { jsx as jsx57, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
6166
|
+
function AIPromptTextarea({
|
|
6167
|
+
value,
|
|
6168
|
+
onChange,
|
|
6169
|
+
placeholder = "Enter your prompt...",
|
|
6170
|
+
disabled = false,
|
|
6171
|
+
maxWords = 400,
|
|
6172
|
+
wordUnitTitle = "words",
|
|
6173
|
+
minHeight = 150,
|
|
6174
|
+
maxHeight = 300,
|
|
6175
|
+
className = "",
|
|
6176
|
+
showWordCount = true,
|
|
6177
|
+
autoScroll = true,
|
|
6178
|
+
extraScrollSpace = 100,
|
|
6179
|
+
isWordLimit,
|
|
6180
|
+
onWordLimitChange,
|
|
6181
|
+
title,
|
|
6182
|
+
description,
|
|
6183
|
+
embed = false
|
|
6184
|
+
}) {
|
|
6185
|
+
const textareaRef = useRef13(null);
|
|
6186
|
+
const wordArray = value.trim().split(/\s+/).filter(Boolean);
|
|
6187
|
+
const wordCount = wordArray.length;
|
|
6188
|
+
const adjustTextareaHeight = () => {
|
|
6189
|
+
if (textareaRef.current) {
|
|
6190
|
+
const textarea = textareaRef.current;
|
|
6191
|
+
const oldHeight = textarea.style.height;
|
|
6192
|
+
textarea.style.height = "auto";
|
|
6193
|
+
const contentHeight = textarea.scrollHeight;
|
|
6194
|
+
let newHeight = Math.max(contentHeight, minHeight);
|
|
6195
|
+
newHeight = Math.min(newHeight, maxHeight);
|
|
6196
|
+
textarea.style.height = `${newHeight}px`;
|
|
6197
|
+
if (contentHeight > maxHeight) {
|
|
6198
|
+
textarea.style.overflowY = "auto";
|
|
6199
|
+
} else {
|
|
6200
|
+
textarea.style.overflowY = "hidden";
|
|
6201
|
+
}
|
|
6202
|
+
if (autoScroll && (newHeight > parseInt(oldHeight) || !oldHeight)) {
|
|
6203
|
+
setTimeout(() => {
|
|
6204
|
+
const rect = textarea.getBoundingClientRect();
|
|
6205
|
+
window.scrollTo({
|
|
6206
|
+
top: window.pageYOffset + rect.bottom + extraScrollSpace - window.innerHeight,
|
|
6207
|
+
behavior: "smooth"
|
|
6208
|
+
});
|
|
6209
|
+
}, 0);
|
|
6210
|
+
}
|
|
6211
|
+
}
|
|
6212
|
+
};
|
|
6213
|
+
useEffect18(() => {
|
|
6214
|
+
const timer = setTimeout(() => {
|
|
6215
|
+
adjustTextareaHeight();
|
|
6216
|
+
}, 0);
|
|
6217
|
+
return () => clearTimeout(timer);
|
|
6218
|
+
}, [value, minHeight, maxHeight, autoScroll, extraScrollSpace]);
|
|
6219
|
+
const handleInputChange = (e) => {
|
|
6220
|
+
const inputValue = e.target.value;
|
|
6221
|
+
const words = inputValue.trim().split(/\s+/).filter(Boolean);
|
|
6222
|
+
if (wordCount >= maxWords && words.length > maxWords) {
|
|
6223
|
+
onWordLimitChange(true);
|
|
6224
|
+
return;
|
|
6225
|
+
}
|
|
6226
|
+
if (words.length > maxWords) {
|
|
6227
|
+
onChange(words.slice(0, maxWords).join(" "));
|
|
6228
|
+
onWordLimitChange(true);
|
|
6229
|
+
} else {
|
|
6230
|
+
onChange(inputValue);
|
|
6231
|
+
onWordLimitChange(false);
|
|
6232
|
+
}
|
|
6233
|
+
};
|
|
6234
|
+
const handlePaste = (e) => {
|
|
6235
|
+
const paste = e.clipboardData.getData("text");
|
|
6236
|
+
const currentWords = value.trim().split(/\s+/).filter(Boolean);
|
|
6237
|
+
const pasteWords = paste.trim().split(/\s+/).filter(Boolean);
|
|
6238
|
+
if (currentWords.length >= maxWords) {
|
|
6239
|
+
e.preventDefault();
|
|
6240
|
+
onWordLimitChange(true);
|
|
6241
|
+
return;
|
|
6242
|
+
}
|
|
6243
|
+
const allowed = maxWords - currentWords.length;
|
|
6244
|
+
if (pasteWords.length > allowed) {
|
|
6245
|
+
e.preventDefault();
|
|
6246
|
+
const newWords = currentWords.concat(pasteWords.slice(0, allowed));
|
|
6247
|
+
onChange(newWords.join(" "));
|
|
6248
|
+
onWordLimitChange(true);
|
|
6249
|
+
}
|
|
6250
|
+
};
|
|
6251
|
+
const renderTitle = () => {
|
|
6252
|
+
if (title == null ? void 0 : title.trim()) return null;
|
|
6253
|
+
return /* @__PURE__ */ jsxs27("div", { className: "space-y-1", children: [
|
|
6254
|
+
title && /* @__PURE__ */ jsx57("span", { className: "text-xl font-semibold text-foreground", children: title }),
|
|
6255
|
+
(description == null ? void 0 : description.trim()) && /* @__PURE__ */ jsx57("span", { className: "text-sm text-gray-400 ml-1", children: description })
|
|
6256
|
+
] });
|
|
6257
|
+
};
|
|
6258
|
+
const renderTextarea = (isEmbedded = false) => /* @__PURE__ */ jsx57(
|
|
6259
|
+
"textarea",
|
|
6260
|
+
{
|
|
6261
|
+
ref: textareaRef,
|
|
6262
|
+
value,
|
|
6263
|
+
onChange: handleInputChange,
|
|
6264
|
+
onPaste: handlePaste,
|
|
6265
|
+
placeholder,
|
|
6266
|
+
disabled,
|
|
6267
|
+
className: `w-full p-4 bg-transparent ${isEmbedded ? "border-0" : "border-2 border-border rounded-lg"} focus:outline-none focus:border-purple-400 hover:border-purple-500 transition-colors text-foreground placeholder-muted-foreground placeholder:text-base disabled:bg-muted disabled:cursor-not-allowed resize-none ${className}`,
|
|
6268
|
+
style: { minHeight: `${minHeight}px` }
|
|
6269
|
+
}
|
|
6270
|
+
);
|
|
6271
|
+
const renderWordCount = () => {
|
|
6272
|
+
if (!showWordCount) return null;
|
|
6273
|
+
return /* @__PURE__ */ jsx57("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxs27(
|
|
6274
|
+
"span",
|
|
6275
|
+
{
|
|
6276
|
+
className: `text-sm ${wordCount >= maxWords ? "text-red-500" : wordCount > maxWords * 0.75 ? "text-orange-500" : "text-muted-foreground"} ${isWordLimit ? "animate-bounce" : ""}`,
|
|
6277
|
+
onAnimationEnd: () => onWordLimitChange(false),
|
|
6278
|
+
children: [
|
|
6279
|
+
wordCount,
|
|
6280
|
+
"/",
|
|
6281
|
+
maxWords,
|
|
6282
|
+
" ",
|
|
6283
|
+
wordUnitTitle
|
|
6284
|
+
]
|
|
6285
|
+
}
|
|
6286
|
+
) });
|
|
6287
|
+
};
|
|
6288
|
+
if (embed && title) {
|
|
6289
|
+
return /* @__PURE__ */ jsxs27("div", { className: "space-y-2", children: [
|
|
6290
|
+
/* @__PURE__ */ jsxs27("div", { className: "border-2 border-border rounded-lg bg-transparent", children: [
|
|
6291
|
+
/* @__PURE__ */ jsx57("div", { className: "p-4 pb-2", children: renderTitle() }),
|
|
6292
|
+
/* @__PURE__ */ jsx57("hr", { className: "border-t-1 border-border" }),
|
|
6293
|
+
/* @__PURE__ */ jsx57("div", { className: "p-1", children: renderTextarea(true) })
|
|
6294
|
+
] }),
|
|
6295
|
+
renderWordCount()
|
|
6296
|
+
] });
|
|
6297
|
+
}
|
|
6298
|
+
return /* @__PURE__ */ jsxs27("div", { className: "space-y-2", children: [
|
|
6299
|
+
renderTitle(),
|
|
6300
|
+
renderTextarea(),
|
|
6301
|
+
renderWordCount()
|
|
6302
|
+
] });
|
|
6303
|
+
}
|
|
6162
6304
|
export {
|
|
6305
|
+
AIPromptTextarea,
|
|
6163
6306
|
AdsAlertDialog,
|
|
6164
6307
|
CTA,
|
|
6165
6308
|
FAQ,
|