@windrun-huaiin/third-ui 5.10.3 → 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.
@@ -2854,48 +2854,14 @@ function getElementRef(element) {
2854
2854
  return element.props.ref || element.ref;
2855
2855
  }
2856
2856
 
2857
- // ../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.mjs
2858
- import { clsx } from "clsx";
2859
- var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
2860
- var cx = clsx;
2861
- var cva = (base, config) => (props) => {
2862
- var _config_compoundVariants;
2863
- if ((config === null || config === void 0 ? void 0 : config.variants) == null) return cx(base, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
2864
- const { variants, defaultVariants } = config;
2865
- const getVariantClassNames = Object.keys(variants).map((variant) => {
2866
- const variantProp = props === null || props === void 0 ? void 0 : props[variant];
2867
- const defaultVariantProp = defaultVariants === null || defaultVariants === void 0 ? void 0 : defaultVariants[variant];
2868
- if (variantProp === null) return null;
2869
- const variantKey = falsyToString(variantProp) || falsyToString(defaultVariantProp);
2870
- return variants[variant][variantKey];
2871
- });
2872
- const propsWithoutUndefined = props && Object.entries(props).reduce((acc, param) => {
2873
- let [key, value] = param;
2874
- if (value === void 0) {
2875
- return acc;
2876
- }
2877
- acc[key] = value;
2878
- return acc;
2879
- }, {});
2880
- const getCompoundVariantClassNames = config === null || config === void 0 ? void 0 : (_config_compoundVariants = config.compoundVariants) === null || _config_compoundVariants === void 0 ? void 0 : _config_compoundVariants.reduce((acc, param) => {
2881
- let _a = param, { class: cvClass, className: cvClassName } = _a, compoundVariantOptions = __objRest(_a, ["class", "className"]);
2882
- return Object.entries(compoundVariantOptions).every((param2) => {
2883
- let [key, value] = param2;
2884
- return Array.isArray(value) ? value.includes(__spreadValues(__spreadValues({}, defaultVariants), propsWithoutUndefined)[key]) : __spreadValues(__spreadValues({}, defaultVariants), propsWithoutUndefined)[key] === value;
2885
- }) ? [
2886
- ...acc,
2887
- cvClass,
2888
- cvClassName
2889
- ] : acc;
2890
- }, []);
2891
- return cx(base, getVariantClassNames, getCompoundVariantClassNames, props === null || props === void 0 ? void 0 : props.class, props === null || props === void 0 ? void 0 : props.className);
2892
- };
2857
+ // ../base-ui/src/ui/button.tsx
2858
+ import { cva } from "class-variance-authority";
2893
2859
 
2894
2860
  // ../lib/src/utils.ts
2895
- import { clsx as clsx2 } from "clsx";
2861
+ import { clsx } from "clsx";
2896
2862
  import { twMerge } from "tailwind-merge";
2897
2863
  function cn(...inputs) {
2898
- return twMerge(clsx2(inputs));
2864
+ return twMerge(clsx(inputs));
2899
2865
  }
2900
2866
 
2901
2867
  // ../base-ui/src/ui/button.tsx
@@ -6193,7 +6159,150 @@ function XButton(props) {
6193
6159
  )
6194
6160
  ] });
6195
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
+ }
6196
6304
  export {
6305
+ AIPromptTextarea,
6197
6306
  AdsAlertDialog,
6198
6307
  CTA,
6199
6308
  FAQ,