@moontra/moonui 2.3.9 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +84 -7
- package/dist/index.d.ts +84 -7
- package/dist/index.global.js +30 -30
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +399 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +395 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/ui/index.ts +8 -0
- package/src/components/ui/input.tsx +92 -19
- package/src/components/ui/pagination.tsx +1 -1
- package/src/components/ui/scroll-reveal.tsx +245 -0
- package/src/components/ui/table.tsx +40 -14
- package/src/components/ui/textarea.tsx +194 -20
package/dist/index.js
CHANGED
|
@@ -2026,10 +2026,10 @@ var inputVariants = classVarianceAuthority.cva(
|
|
|
2026
2026
|
{
|
|
2027
2027
|
variants: {
|
|
2028
2028
|
variant: {
|
|
2029
|
-
standard: "border border-gray-300 dark:border-gray-700 rounded-md px-3 py-2 hover:border-gray-400 dark:hover:border-gray-600 focus-visible:ring-2 focus-visible:ring-primary/30 dark:focus-visible:ring-primary/20 focus-visible:border-primary dark:focus-visible:border-primary/80 dark:bg-gray-
|
|
2030
|
-
filled: "border border-transparent bg-gray-100 dark:bg-gray-800
|
|
2029
|
+
standard: "border border-gray-300 dark:border-gray-700 rounded-md px-3 py-2 hover:border-gray-400 dark:hover:border-gray-600 focus-visible:ring-2 focus-visible:ring-primary/30 dark:focus-visible:ring-primary/20 focus-visible:border-primary dark:focus-visible:border-primary/80 dark:bg-gray-800/80 dark:shadow-inner dark:shadow-gray-950/10",
|
|
2030
|
+
filled: "border border-transparent bg-gray-100 dark:bg-gray-800 rounded-md px-3 py-2 hover:bg-gray-200 dark:hover:bg-gray-700 focus-visible:ring-2 focus-visible:ring-primary/30 dark:focus-visible:ring-primary/20 dark:shadow-inner dark:shadow-gray-950/10",
|
|
2031
2031
|
ghost: "border-none bg-transparent shadow-none px-1 dark:text-gray-300 dark:placeholder:text-gray-500 hover:bg-gray-100/50 dark:hover:bg-gray-800/30 focus-visible:bg-transparent",
|
|
2032
|
-
underline: "border-t-0 border-l-0 border-r-0 border-b border-gray-300 dark:border-gray-600 rounded-none px-0 py-2 hover:border-gray-400 dark:hover:border-gray-500 focus-visible:ring-0 focus-visible:border-b-2 focus-visible:border-primary dark:focus-visible:border-primary/80 dark:text-gray-300"
|
|
2032
|
+
underline: "border-t-0 border-l-0 border-r-0 border-b border-gray-300 dark:border-gray-600 rounded-none px-0 py-2 hover:border-gray-400 dark:hover:border-gray-500 focus-visible:ring-0 focus-visible:border-b-2 focus-visible:border-primary dark:focus-visible:border-primary/80 dark:text-gray-300 dark:bg-transparent"
|
|
2033
2033
|
},
|
|
2034
2034
|
size: {
|
|
2035
2035
|
sm: "h-8 text-xs",
|
|
@@ -2089,12 +2089,59 @@ var Input = t__namespace.forwardRef(
|
|
|
2089
2089
|
rightIcon,
|
|
2090
2090
|
rightButton,
|
|
2091
2091
|
alwaysShowMessage = false,
|
|
2092
|
+
label,
|
|
2093
|
+
floatingLabel = false,
|
|
2094
|
+
floatingLabelClassName,
|
|
2095
|
+
value,
|
|
2096
|
+
defaultValue,
|
|
2097
|
+
onChange,
|
|
2098
|
+
onFocus,
|
|
2099
|
+
onBlur,
|
|
2100
|
+
placeholder,
|
|
2092
2101
|
...props
|
|
2093
2102
|
}, ref) => {
|
|
2103
|
+
const [isFocused, setIsFocused] = t__namespace.useState(false);
|
|
2104
|
+
const [internalValue, setInternalValue] = t__namespace.useState(value || defaultValue || "");
|
|
2105
|
+
const hasValue = internalValue !== "" && internalValue !== null && internalValue !== void 0;
|
|
2106
|
+
const isLabelActive = isFocused || hasValue;
|
|
2107
|
+
const handleFocus = (e) => {
|
|
2108
|
+
setIsFocused(true);
|
|
2109
|
+
onFocus?.(e);
|
|
2110
|
+
};
|
|
2111
|
+
const handleBlur = (e) => {
|
|
2112
|
+
setIsFocused(false);
|
|
2113
|
+
onBlur?.(e);
|
|
2114
|
+
};
|
|
2115
|
+
const handleChange = (e) => {
|
|
2116
|
+
setInternalValue(e.target.value);
|
|
2117
|
+
onChange?.(e);
|
|
2118
|
+
};
|
|
2119
|
+
t__namespace.useEffect(() => {
|
|
2120
|
+
if (value !== void 0) {
|
|
2121
|
+
setInternalValue(value);
|
|
2122
|
+
}
|
|
2123
|
+
}, [value]);
|
|
2094
2124
|
const showMessage = alwaysShowMessage || error || success;
|
|
2095
2125
|
const messageType = error ? "error" : success ? "success" : "normal";
|
|
2096
2126
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5 w-full", children: [
|
|
2097
2127
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("moonui-theme", inputWrapperVariants({ size }), wrapperClassName), children: [
|
|
2128
|
+
floatingLabel && label && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2129
|
+
"label",
|
|
2130
|
+
{
|
|
2131
|
+
htmlFor: props.id,
|
|
2132
|
+
className: cn(
|
|
2133
|
+
"absolute transition-all duration-200 pointer-events-none",
|
|
2134
|
+
leftIcon || loading ? "left-10" : "left-3",
|
|
2135
|
+
"text-gray-500 dark:text-gray-400",
|
|
2136
|
+
isLabelActive ? "top-0 -translate-y-1/2 text-xs bg-background dark:bg-gray-800 px-1" : "top-1/2 -translate-y-1/2 text-sm",
|
|
2137
|
+
isFocused && "text-primary dark:text-primary",
|
|
2138
|
+
!!error && "text-error",
|
|
2139
|
+
disabled && "opacity-50",
|
|
2140
|
+
floatingLabelClassName
|
|
2141
|
+
),
|
|
2142
|
+
children: label
|
|
2143
|
+
}
|
|
2144
|
+
),
|
|
2098
2145
|
leftIcon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute left-3 text-gray-500 flex items-center justify-center pointer-events-none", children: loading ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-4 w-4 animate-spin" }) : leftIcon }),
|
|
2099
2146
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2100
2147
|
"input",
|
|
@@ -2119,6 +2166,12 @@ var Input = t__namespace.forwardRef(
|
|
|
2119
2166
|
"data-success": !!success ? "" : void 0,
|
|
2120
2167
|
"aria-invalid": !!error || !!isError || void 0,
|
|
2121
2168
|
"aria-describedby": error ? `${props.id || ""}-error` : success ? `${props.id || ""}-success` : void 0,
|
|
2169
|
+
value,
|
|
2170
|
+
defaultValue,
|
|
2171
|
+
onChange: handleChange,
|
|
2172
|
+
onFocus: handleFocus,
|
|
2173
|
+
onBlur: handleBlur,
|
|
2174
|
+
placeholder: floatingLabel ? isLabelActive ? placeholder : "" : placeholder,
|
|
2122
2175
|
...props
|
|
2123
2176
|
}
|
|
2124
2177
|
),
|
|
@@ -7132,7 +7185,7 @@ var TableRow = t__namespace.forwardRef(({ className, ...props }, ref) => /* @__P
|
|
|
7132
7185
|
));
|
|
7133
7186
|
TableRow.displayName = "TableRow";
|
|
7134
7187
|
var TableHead = t__namespace.forwardRef(
|
|
7135
|
-
({ className, sortable, sorted, onSort, children, ...props }, ref) => {
|
|
7188
|
+
({ className, sortable, sorted, onSort, align = "left", children, ...props }, ref) => {
|
|
7136
7189
|
const renderSortIcon = () => {
|
|
7137
7190
|
if (!sortable)
|
|
7138
7191
|
return null;
|
|
@@ -7192,34 +7245,48 @@ var TableHead = t__namespace.forwardRef(
|
|
|
7192
7245
|
}
|
|
7193
7246
|
);
|
|
7194
7247
|
};
|
|
7248
|
+
const alignmentClasses = {
|
|
7249
|
+
left: "text-left justify-start",
|
|
7250
|
+
center: "text-center justify-center",
|
|
7251
|
+
right: "text-right justify-end"
|
|
7252
|
+
};
|
|
7195
7253
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7196
7254
|
"th",
|
|
7197
7255
|
{
|
|
7198
7256
|
ref,
|
|
7199
7257
|
className: cn(
|
|
7200
|
-
"h-10 px-4
|
|
7258
|
+
"h-10 px-4 align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
7259
|
+
alignmentClasses[align].split(" ")[0],
|
|
7260
|
+
// text alignment
|
|
7201
7261
|
sortable && "cursor-pointer hover:text-foreground select-none",
|
|
7202
7262
|
className
|
|
7203
7263
|
),
|
|
7204
7264
|
onClick: sortable ? onSort : void 0,
|
|
7205
7265
|
...props,
|
|
7206
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
|
|
7266
|
+
children: sortable || align !== "left" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center", alignmentClasses[align].split(" ")[1]), children: [
|
|
7207
7267
|
children,
|
|
7208
7268
|
sortable && renderSortIcon()
|
|
7209
|
-
] })
|
|
7269
|
+
] }) : children
|
|
7210
7270
|
}
|
|
7211
7271
|
);
|
|
7212
7272
|
}
|
|
7213
7273
|
);
|
|
7214
7274
|
TableHead.displayName = "TableHead";
|
|
7215
|
-
var TableCell = t__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7275
|
+
var TableCell = t__namespace.forwardRef(({ className, align = "left", ...props }, ref) => {
|
|
7276
|
+
const alignmentClass = {
|
|
7277
|
+
left: "text-left",
|
|
7278
|
+
center: "text-center",
|
|
7279
|
+
right: "text-right"
|
|
7280
|
+
}[align];
|
|
7281
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
7282
|
+
"td",
|
|
7283
|
+
{
|
|
7284
|
+
ref,
|
|
7285
|
+
className: cn("moonui-theme", "p-4 align-middle [&:has([role=checkbox])]:pr-0", alignmentClass, className),
|
|
7286
|
+
...props
|
|
7287
|
+
}
|
|
7288
|
+
);
|
|
7289
|
+
});
|
|
7223
7290
|
TableCell.displayName = "TableCell";
|
|
7224
7291
|
var TableCaption = t__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
7225
7292
|
"caption",
|
|
@@ -10778,6 +10845,188 @@ var ScrollBar = t__namespace.forwardRef(({ className, orientation = "vertical",
|
|
|
10778
10845
|
}
|
|
10779
10846
|
));
|
|
10780
10847
|
ScrollBar.displayName = ScrollAreaScrollbar.displayName;
|
|
10848
|
+
var defaultVariants = {
|
|
10849
|
+
up: {
|
|
10850
|
+
hidden: { opacity: 0, y: 50 },
|
|
10851
|
+
visible: { opacity: 1, y: 0 }
|
|
10852
|
+
},
|
|
10853
|
+
down: {
|
|
10854
|
+
hidden: { opacity: 0, y: -50 },
|
|
10855
|
+
visible: { opacity: 1, y: 0 }
|
|
10856
|
+
},
|
|
10857
|
+
left: {
|
|
10858
|
+
hidden: { opacity: 0, x: 50 },
|
|
10859
|
+
visible: { opacity: 1, x: 0 }
|
|
10860
|
+
},
|
|
10861
|
+
right: {
|
|
10862
|
+
hidden: { opacity: 0, x: -50 },
|
|
10863
|
+
visible: { opacity: 1, x: 0 }
|
|
10864
|
+
},
|
|
10865
|
+
fade: {
|
|
10866
|
+
hidden: { opacity: 0 },
|
|
10867
|
+
visible: { opacity: 1 }
|
|
10868
|
+
},
|
|
10869
|
+
scale: {
|
|
10870
|
+
hidden: { opacity: 0, scale: 0.8 },
|
|
10871
|
+
visible: { opacity: 1, scale: 1 }
|
|
10872
|
+
},
|
|
10873
|
+
blur: {
|
|
10874
|
+
hidden: { opacity: 0, filter: "blur(10px)" },
|
|
10875
|
+
visible: { opacity: 1, filter: "blur(0px)" }
|
|
10876
|
+
}
|
|
10877
|
+
};
|
|
10878
|
+
var ScrollReveal = t__namespace.forwardRef(
|
|
10879
|
+
({
|
|
10880
|
+
children,
|
|
10881
|
+
direction = "up",
|
|
10882
|
+
delay = 0,
|
|
10883
|
+
duration = 0.6,
|
|
10884
|
+
distance = 50,
|
|
10885
|
+
threshold = 0.1,
|
|
10886
|
+
triggerOnce = true,
|
|
10887
|
+
stagger = 0,
|
|
10888
|
+
className,
|
|
10889
|
+
variants,
|
|
10890
|
+
animate: animate2 = true,
|
|
10891
|
+
style,
|
|
10892
|
+
id
|
|
10893
|
+
}, ref) => {
|
|
10894
|
+
const controls = framerMotion.useAnimation();
|
|
10895
|
+
const elementRef = t__namespace.useRef(null);
|
|
10896
|
+
const isInView = framerMotion.useInView(elementRef, {
|
|
10897
|
+
amount: threshold,
|
|
10898
|
+
once: triggerOnce
|
|
10899
|
+
});
|
|
10900
|
+
const customVariants = t__namespace.useMemo(() => {
|
|
10901
|
+
if (variants)
|
|
10902
|
+
return variants;
|
|
10903
|
+
const baseVariants = defaultVariants[direction] || defaultVariants.up;
|
|
10904
|
+
return {
|
|
10905
|
+
hidden: {
|
|
10906
|
+
...baseVariants.hidden,
|
|
10907
|
+
...direction === "up" && { y: distance },
|
|
10908
|
+
...direction === "down" && { y: -distance },
|
|
10909
|
+
...direction === "left" && { x: distance },
|
|
10910
|
+
...direction === "right" && { x: -distance }
|
|
10911
|
+
},
|
|
10912
|
+
visible: baseVariants.visible
|
|
10913
|
+
};
|
|
10914
|
+
}, [direction, distance, variants]);
|
|
10915
|
+
t__namespace.useEffect(() => {
|
|
10916
|
+
if (!animate2)
|
|
10917
|
+
return;
|
|
10918
|
+
if (isInView) {
|
|
10919
|
+
controls.start("visible");
|
|
10920
|
+
} else if (!triggerOnce) {
|
|
10921
|
+
controls.start("hidden");
|
|
10922
|
+
}
|
|
10923
|
+
}, [isInView, controls, triggerOnce, animate2]);
|
|
10924
|
+
t__namespace.useImperativeHandle(ref, () => elementRef.current);
|
|
10925
|
+
if (!animate2) {
|
|
10926
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10927
|
+
"div",
|
|
10928
|
+
{
|
|
10929
|
+
ref: elementRef,
|
|
10930
|
+
className,
|
|
10931
|
+
style,
|
|
10932
|
+
id,
|
|
10933
|
+
children
|
|
10934
|
+
}
|
|
10935
|
+
);
|
|
10936
|
+
}
|
|
10937
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10938
|
+
framerMotion.motion.div,
|
|
10939
|
+
{
|
|
10940
|
+
ref: elementRef,
|
|
10941
|
+
variants: customVariants,
|
|
10942
|
+
initial: "hidden",
|
|
10943
|
+
animate: controls,
|
|
10944
|
+
transition: {
|
|
10945
|
+
duration,
|
|
10946
|
+
delay: delay + stagger,
|
|
10947
|
+
ease: "easeOut"
|
|
10948
|
+
},
|
|
10949
|
+
className: cn(className),
|
|
10950
|
+
style,
|
|
10951
|
+
id,
|
|
10952
|
+
children
|
|
10953
|
+
}
|
|
10954
|
+
);
|
|
10955
|
+
}
|
|
10956
|
+
);
|
|
10957
|
+
ScrollReveal.displayName = "ScrollReveal";
|
|
10958
|
+
var ScrollRevealContainer = t__namespace.forwardRef(
|
|
10959
|
+
({ children, stagger = 0.1, className, style, id }, ref) => {
|
|
10960
|
+
const containerRef = t__namespace.useRef(null);
|
|
10961
|
+
const isInView = framerMotion.useInView(containerRef, { amount: 0.1, once: true });
|
|
10962
|
+
t__namespace.useImperativeHandle(ref, () => containerRef.current);
|
|
10963
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10964
|
+
framerMotion.motion.div,
|
|
10965
|
+
{
|
|
10966
|
+
ref: containerRef,
|
|
10967
|
+
initial: "hidden",
|
|
10968
|
+
animate: isInView ? "visible" : "hidden",
|
|
10969
|
+
variants: {
|
|
10970
|
+
hidden: {},
|
|
10971
|
+
visible: {
|
|
10972
|
+
transition: {
|
|
10973
|
+
staggerChildren: stagger
|
|
10974
|
+
}
|
|
10975
|
+
}
|
|
10976
|
+
},
|
|
10977
|
+
className: cn(className),
|
|
10978
|
+
style,
|
|
10979
|
+
id,
|
|
10980
|
+
children
|
|
10981
|
+
}
|
|
10982
|
+
);
|
|
10983
|
+
}
|
|
10984
|
+
);
|
|
10985
|
+
ScrollRevealContainer.displayName = "ScrollRevealContainer";
|
|
10986
|
+
var ScrollRevealItem = t__namespace.forwardRef(
|
|
10987
|
+
({
|
|
10988
|
+
children,
|
|
10989
|
+
direction = "up",
|
|
10990
|
+
duration = 0.6,
|
|
10991
|
+
distance = 50,
|
|
10992
|
+
className,
|
|
10993
|
+
variants,
|
|
10994
|
+
style,
|
|
10995
|
+
id
|
|
10996
|
+
}, ref) => {
|
|
10997
|
+
const customVariants = t__namespace.useMemo(() => {
|
|
10998
|
+
if (variants)
|
|
10999
|
+
return variants;
|
|
11000
|
+
const baseVariants = defaultVariants[direction] || defaultVariants.up;
|
|
11001
|
+
return {
|
|
11002
|
+
hidden: {
|
|
11003
|
+
...baseVariants.hidden,
|
|
11004
|
+
...direction === "up" && { y: distance },
|
|
11005
|
+
...direction === "down" && { y: -distance },
|
|
11006
|
+
...direction === "left" && { x: distance },
|
|
11007
|
+
...direction === "right" && { x: -distance }
|
|
11008
|
+
},
|
|
11009
|
+
visible: baseVariants.visible
|
|
11010
|
+
};
|
|
11011
|
+
}, [direction, distance, variants]);
|
|
11012
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
11013
|
+
framerMotion.motion.div,
|
|
11014
|
+
{
|
|
11015
|
+
ref,
|
|
11016
|
+
variants: customVariants,
|
|
11017
|
+
transition: {
|
|
11018
|
+
duration,
|
|
11019
|
+
ease: "easeOut"
|
|
11020
|
+
},
|
|
11021
|
+
className: cn(className),
|
|
11022
|
+
style,
|
|
11023
|
+
id,
|
|
11024
|
+
children
|
|
11025
|
+
}
|
|
11026
|
+
);
|
|
11027
|
+
}
|
|
11028
|
+
);
|
|
11029
|
+
ScrollRevealItem.displayName = "ScrollRevealItem";
|
|
10781
11030
|
var separatorVariants = classVarianceAuthority.cva(
|
|
10782
11031
|
"shrink-0 bg-border",
|
|
10783
11032
|
{
|
|
@@ -12144,32 +12393,147 @@ var TagsInput = t__namespace.forwardRef(
|
|
|
12144
12393
|
}
|
|
12145
12394
|
);
|
|
12146
12395
|
TagsInput.displayName = "TagsInput";
|
|
12396
|
+
var textareaVariants = classVarianceAuthority.cva(
|
|
12397
|
+
[
|
|
12398
|
+
"flex w-full rounded-md px-3 py-2 text-sm transition-all duration-200",
|
|
12399
|
+
"text-foreground placeholder:text-muted-foreground dark:placeholder:text-gray-500",
|
|
12400
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
12401
|
+
"focus-visible:outline-none dark:text-gray-200",
|
|
12402
|
+
"resize-none"
|
|
12403
|
+
// Always disable manual resize, we control it
|
|
12404
|
+
],
|
|
12405
|
+
{
|
|
12406
|
+
variants: {
|
|
12407
|
+
variant: {
|
|
12408
|
+
default: "border border-gray-300 dark:border-gray-700 bg-background dark:bg-gray-800/80 hover:border-gray-400 dark:hover:border-gray-600 focus-visible:ring-2 focus-visible:ring-primary/30 dark:focus-visible:ring-primary/20 focus-visible:border-primary dark:focus-visible:border-primary/80 dark:shadow-inner dark:shadow-gray-950/10",
|
|
12409
|
+
outline: "border-2 border-gray-300 dark:border-gray-700 bg-transparent hover:border-gray-400 dark:hover:border-gray-600 focus-visible:border-primary dark:focus-visible:border-primary/80",
|
|
12410
|
+
ghost: "border-none bg-transparent hover:bg-gray-100/50 dark:hover:bg-gray-800/30 focus-visible:bg-transparent",
|
|
12411
|
+
underline: "border-t-0 border-l-0 border-r-0 border-b-2 border-gray-300 dark:border-gray-600 rounded-none px-0 hover:border-gray-400 dark:hover:border-gray-500 focus-visible:ring-0 focus-visible:border-primary dark:focus-visible:border-primary/80 bg-transparent dark:bg-transparent"
|
|
12412
|
+
},
|
|
12413
|
+
size: {
|
|
12414
|
+
sm: "min-h-[60px] text-xs",
|
|
12415
|
+
md: "min-h-[80px] text-sm",
|
|
12416
|
+
lg: "min-h-[120px] text-base"
|
|
12417
|
+
},
|
|
12418
|
+
isError: {
|
|
12419
|
+
true: "border-error focus-visible:ring-error/30 focus-visible:border-error hover:border-error/80 dark:hover:border-error/80",
|
|
12420
|
+
false: ""
|
|
12421
|
+
},
|
|
12422
|
+
isSuccess: {
|
|
12423
|
+
true: "border-success focus-visible:ring-success/30 focus-visible:border-success hover:border-success/80 dark:hover:border-success/80",
|
|
12424
|
+
false: ""
|
|
12425
|
+
}
|
|
12426
|
+
},
|
|
12427
|
+
defaultVariants: {
|
|
12428
|
+
variant: "default",
|
|
12429
|
+
size: "md",
|
|
12430
|
+
isError: false,
|
|
12431
|
+
isSuccess: false
|
|
12432
|
+
}
|
|
12433
|
+
}
|
|
12434
|
+
);
|
|
12147
12435
|
var Textarea = t__namespace.forwardRef(
|
|
12148
12436
|
({
|
|
12149
12437
|
className,
|
|
12150
|
-
|
|
12438
|
+
wrapperClassName,
|
|
12439
|
+
messageClassName,
|
|
12151
12440
|
variant,
|
|
12152
12441
|
size,
|
|
12153
12442
|
error,
|
|
12154
12443
|
success,
|
|
12155
12444
|
loading,
|
|
12156
|
-
autoResize,
|
|
12445
|
+
autoResize = false,
|
|
12157
12446
|
maxHeight,
|
|
12158
|
-
characterCount,
|
|
12447
|
+
characterCount = false,
|
|
12448
|
+
disabled,
|
|
12449
|
+
maxLength,
|
|
12450
|
+
value,
|
|
12451
|
+
defaultValue,
|
|
12452
|
+
onChange,
|
|
12159
12453
|
...props
|
|
12160
12454
|
}, ref) => {
|
|
12161
|
-
|
|
12162
|
-
|
|
12163
|
-
|
|
12164
|
-
|
|
12165
|
-
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
|
|
12169
|
-
|
|
12170
|
-
|
|
12455
|
+
const textareaRef = t__namespace.useRef(null);
|
|
12456
|
+
const [internalValue, setInternalValue] = t__namespace.useState(value || defaultValue || "");
|
|
12457
|
+
t__namespace.useImperativeHandle(ref, () => textareaRef.current);
|
|
12458
|
+
const adjustHeight = t__namespace.useCallback(() => {
|
|
12459
|
+
const textarea = textareaRef.current;
|
|
12460
|
+
if (!textarea || !autoResize)
|
|
12461
|
+
return;
|
|
12462
|
+
textarea.style.height = "auto";
|
|
12463
|
+
const newHeight = textarea.scrollHeight;
|
|
12464
|
+
if (maxHeight && newHeight > maxHeight) {
|
|
12465
|
+
textarea.style.height = `${maxHeight}px`;
|
|
12466
|
+
textarea.style.overflowY = "auto";
|
|
12467
|
+
} else {
|
|
12468
|
+
textarea.style.height = `${newHeight}px`;
|
|
12469
|
+
textarea.style.overflowY = "hidden";
|
|
12171
12470
|
}
|
|
12172
|
-
);
|
|
12471
|
+
}, [autoResize, maxHeight]);
|
|
12472
|
+
t__namespace.useEffect(() => {
|
|
12473
|
+
adjustHeight();
|
|
12474
|
+
}, [internalValue, adjustHeight]);
|
|
12475
|
+
t__namespace.useEffect(() => {
|
|
12476
|
+
if (value !== void 0) {
|
|
12477
|
+
setInternalValue(value);
|
|
12478
|
+
}
|
|
12479
|
+
}, [value]);
|
|
12480
|
+
const handleChange = (e) => {
|
|
12481
|
+
setInternalValue(e.target.value);
|
|
12482
|
+
onChange?.(e);
|
|
12483
|
+
};
|
|
12484
|
+
const currentLength = String(internalValue).length;
|
|
12485
|
+
const showCharCount = characterCount && (maxLength !== void 0 || currentLength > 0);
|
|
12486
|
+
const errorMessage = typeof error === "string" ? error : void 0;
|
|
12487
|
+
const successMessage = typeof success === "string" ? success : void 0;
|
|
12488
|
+
const showMessage = errorMessage || successMessage;
|
|
12489
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("moonui-theme", "space-y-1.5 w-full", wrapperClassName), children: [
|
|
12490
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
12491
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
12492
|
+
"textarea",
|
|
12493
|
+
{
|
|
12494
|
+
ref: textareaRef,
|
|
12495
|
+
className: cn(
|
|
12496
|
+
textareaVariants({
|
|
12497
|
+
variant,
|
|
12498
|
+
size,
|
|
12499
|
+
isError: !!error,
|
|
12500
|
+
isSuccess: !!success
|
|
12501
|
+
}),
|
|
12502
|
+
loading && "pr-10",
|
|
12503
|
+
className
|
|
12504
|
+
),
|
|
12505
|
+
disabled: disabled || loading,
|
|
12506
|
+
value,
|
|
12507
|
+
defaultValue,
|
|
12508
|
+
onChange: handleChange,
|
|
12509
|
+
maxLength,
|
|
12510
|
+
"aria-invalid": !!error || void 0,
|
|
12511
|
+
"aria-describedby": errorMessage ? `${props.id || ""}-error` : successMessage ? `${props.id || ""}-success` : void 0,
|
|
12512
|
+
...props
|
|
12513
|
+
}
|
|
12514
|
+
),
|
|
12515
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute top-3 right-3 text-gray-500", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-4 w-4 animate-spin", "aria-hidden": "true" }) })
|
|
12516
|
+
] }),
|
|
12517
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
|
|
12518
|
+
showMessage && /* @__PURE__ */ jsxRuntime.jsx(
|
|
12519
|
+
"p",
|
|
12520
|
+
{
|
|
12521
|
+
className: cn(
|
|
12522
|
+
"text-xs transition-all",
|
|
12523
|
+
errorMessage && "text-error",
|
|
12524
|
+
successMessage && "text-success",
|
|
12525
|
+
messageClassName
|
|
12526
|
+
),
|
|
12527
|
+
id: errorMessage ? `${props.id || ""}-error` : successMessage ? `${props.id || ""}-success` : void 0,
|
|
12528
|
+
children: errorMessage || successMessage
|
|
12529
|
+
}
|
|
12530
|
+
),
|
|
12531
|
+
showCharCount && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-muted-foreground dark:text-gray-500 ml-auto", children: [
|
|
12532
|
+
currentLength,
|
|
12533
|
+
maxLength !== void 0 && ` / ${maxLength}`
|
|
12534
|
+
] })
|
|
12535
|
+
] })
|
|
12536
|
+
] });
|
|
12173
12537
|
}
|
|
12174
12538
|
);
|
|
12175
12539
|
Textarea.displayName = "Textarea";
|
|
@@ -12624,6 +12988,9 @@ exports.MoonUIRadioLabel = RadioLabel;
|
|
|
12624
12988
|
exports.MoonUIRichTextEditor = RichTextEditor;
|
|
12625
12989
|
exports.MoonUIScrollArea = ScrollArea2;
|
|
12626
12990
|
exports.MoonUIScrollBar = ScrollBar;
|
|
12991
|
+
exports.MoonUIScrollReveal = ScrollReveal;
|
|
12992
|
+
exports.MoonUIScrollRevealContainer = ScrollRevealContainer;
|
|
12993
|
+
exports.MoonUIScrollRevealItem = ScrollRevealItem;
|
|
12627
12994
|
exports.MoonUISelect = Select;
|
|
12628
12995
|
exports.MoonUISelectContent = SelectContent;
|
|
12629
12996
|
exports.MoonUISelectGroup = SelectGroup;
|
|
@@ -12697,6 +13064,9 @@ exports.RadioLabel = RadioLabel;
|
|
|
12697
13064
|
exports.RichTextEditor = RichTextEditor;
|
|
12698
13065
|
exports.ScrollArea = ScrollArea2;
|
|
12699
13066
|
exports.ScrollBar = ScrollBar;
|
|
13067
|
+
exports.ScrollReveal = ScrollReveal;
|
|
13068
|
+
exports.ScrollRevealContainer = ScrollRevealContainer;
|
|
13069
|
+
exports.ScrollRevealItem = ScrollRevealItem;
|
|
12700
13070
|
exports.Select = Select;
|
|
12701
13071
|
exports.SelectContent = SelectContent;
|
|
12702
13072
|
exports.SelectGroup = SelectGroup;
|