@dust-tt/sparkle 0.2.270 → 0.2.271
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/cjs/index.js +12 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/TextArea.d.ts +6 -3
- package/dist/esm/components/TextArea.d.ts.map +1 -1
- package/dist/esm/components/TextArea.js +16 -6
- package/dist/esm/components/TextArea.js.map +1 -1
- package/dist/esm/stories/TextArea.stories.d.ts +1 -1
- package/dist/sparkle.css +12 -34
- package/package.json +1 -1
- package/src/components/TextArea.tsx +45 -16
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
declare const RESIZE_DIRECTIONS: readonly ["none", "vertical", "horizontal", "both"];
|
|
3
|
+
type ResizeDirectionType = (typeof RESIZE_DIRECTIONS)[number];
|
|
4
|
+
export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
5
|
+
resize?: ResizeDirectionType;
|
|
3
6
|
error?: string | null;
|
|
4
7
|
showErrorLabel?: boolean;
|
|
5
8
|
minRows?: number;
|
|
6
|
-
className?: string;
|
|
7
9
|
}
|
|
8
|
-
|
|
10
|
+
declare const TextArea: React.ForwardRefExoticComponent<TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
11
|
+
export { TextArea };
|
|
9
12
|
//# sourceMappingURL=TextArea.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,WAAW,aACf,SAAQ,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,CAAC;IACzD,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"TextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,QAAA,MAAM,iBAAiB,qDAAsD,CAAC;AAE9E,KAAK,mBAAmB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,MAAM,WAAW,aACf,SAAQ,KAAK,CAAC,sBAAsB,CAAC,mBAAmB,CAAC;IACzD,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAWD,QAAA,MAAM,QAAQ,2FA8Cb,CAAC;AAGF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { cn } from "../lib/utils";
|
|
4
|
+
var RESIZE_DIRECTIONS = ["none", "vertical", "horizontal", "both"];
|
|
5
|
+
var textAreaStyles = cn("s-flex s-w-full s-px-3 s-py-2", "s-transition s-duration-100", "s-text-sm placeholder:s-text-muted-foreground s-text-foreground", "s-ring-offset-background s-border s-border-border-dark s-bg-background s-rounded-xl", "focus-visible:s-outline-none focus-visible:s-ring-2 focus-visible:s-ring-offset-2 ", "disabled:s-cursor-not-allowed disabled:s-opacity-50 disabled:s-text-muted-foreground");
|
|
6
|
+
var TextArea = React.forwardRef(function (_a, ref) {
|
|
7
|
+
var className = _a.className, _b = _a.resize, resize = _b === void 0 ? "both" : _b, _c = _a.minRows, minRows = _c === void 0 ? 10 : _c, error = _a.error, showErrorLabel = _a.showErrorLabel, props = __rest(_a, ["className", "resize", "minRows", "error", "showErrorLabel"]);
|
|
8
|
+
var resizeClass = {
|
|
9
|
+
none: "s-resize-none",
|
|
10
|
+
vertical: "s-resize-y",
|
|
11
|
+
horizontal: "s-resize-x",
|
|
12
|
+
both: "s-resize",
|
|
13
|
+
};
|
|
6
14
|
return (React.createElement("div", { className: "s-flex s-flex-col s-gap-1 s-p-px" },
|
|
7
|
-
React.createElement("textarea", __assign({
|
|
8
|
-
? "s-
|
|
9
|
-
: "s-
|
|
15
|
+
React.createElement("textarea", __assign({ className: cn(textAreaStyles, resizeClass[resize], className, !error
|
|
16
|
+
? cn("s-ring-structure-200 focus:s-ring-action-300", "dark:s-ring-structure-300-dark dark:focus:s-ring-action-300-dark")
|
|
17
|
+
: cn("s-ring-warning-200 focus:s-ring-warning-300", "dark:s-ring-warning-200-dark dark:focus:s-ring-warning-300-dark")), ref: ref, rows: minRows }, props)),
|
|
10
18
|
error && showErrorLabel && (React.createElement("div", { className: "s-ml-2 s-text-sm s-text-warning-500" }, error))));
|
|
11
19
|
});
|
|
20
|
+
TextArea.displayName = "TextArea";
|
|
21
|
+
export { TextArea };
|
|
12
22
|
//# sourceMappingURL=TextArea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea.js","sourceRoot":"","sources":["../../../src/components/TextArea.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"TextArea.js","sourceRoot":"","sources":["../../../src/components/TextArea.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,IAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,CAAU,CAAC;AAY9E,IAAM,cAAc,GAAG,EAAE,CACvB,+BAA+B,EAC/B,6BAA6B,EAC7B,iEAAiE,EACjE,qFAAqF,EACrF,oFAAoF,EACpF,sFAAsF,CACvF,CAAC;AAEF,IAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAC/B,UACE,EAOC,EACD,GAAG;IAPD,IAAA,SAAS,eAAA,EACT,cAAe,EAAf,MAAM,mBAAG,MAAM,KAAA,EACf,eAAY,EAAZ,OAAO,mBAAG,EAAE,KAAA,EACZ,KAAK,WAAA,EACL,cAAc,oBAAA,EACX,KAAK,cANV,6DAOC,CADS;IAIV,IAAM,WAAW,GAAG;QAClB,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,YAAY;QACtB,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,UAAU;KACjB,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,kCAAkC;QAC/C,2CACE,SAAS,EAAE,EAAE,CACX,cAAc,EACd,WAAW,CAAC,MAAM,CAAC,EACnB,SAAS,EACT,CAAC,KAAK;gBACJ,CAAC,CAAC,EAAE,CACA,8CAA8C,EAC9C,kEAAkE,CACnE;gBACH,CAAC,CAAC,EAAE,CACA,6CAA6C,EAC7C,iEAAiE,CAClE,CACN,EACD,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,OAAO,IACT,KAAK,EACT;QACD,KAAK,IAAI,cAAc,IAAI,CAC1B,6BAAK,SAAS,EAAC,qCAAqC,IAAE,KAAK,CAAO,CACnE,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AACF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: React.ForwardRefExoticComponent<import("../components/TextArea").
|
|
4
|
+
component: React.ForwardRefExoticComponent<import("../components/TextArea").TextareaProps & React.RefAttributes<HTMLTextAreaElement>>;
|
|
5
5
|
};
|
|
6
6
|
export default meta;
|
|
7
7
|
export declare const TextAreaExample: () => React.JSX.Element;
|
package/dist/sparkle.css
CHANGED
|
@@ -941,10 +941,6 @@ select {
|
|
|
941
941
|
-webkit-line-clamp: 3;
|
|
942
942
|
}
|
|
943
943
|
|
|
944
|
-
.s-block {
|
|
945
|
-
display: block;
|
|
946
|
-
}
|
|
947
|
-
|
|
948
944
|
.s-inline-block {
|
|
949
945
|
display: inline-block;
|
|
950
946
|
}
|
|
@@ -1465,10 +1461,22 @@ select {
|
|
|
1465
1461
|
user-select: none;
|
|
1466
1462
|
}
|
|
1467
1463
|
|
|
1464
|
+
.s-resize-none {
|
|
1465
|
+
resize: none;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
1468
|
.s-resize-y {
|
|
1469
1469
|
resize: vertical;
|
|
1470
1470
|
}
|
|
1471
1471
|
|
|
1472
|
+
.s-resize-x {
|
|
1473
|
+
resize: horizontal;
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
.s-resize {
|
|
1477
|
+
resize: both;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1472
1480
|
.s-list-decimal {
|
|
1473
1481
|
list-style-type: decimal;
|
|
1474
1482
|
}
|
|
@@ -2064,11 +2072,6 @@ select {
|
|
|
2064
2072
|
border-color: rgb(252 165 165 / var(--tw-border-opacity));
|
|
2065
2073
|
}
|
|
2066
2074
|
|
|
2067
|
-
.s-border-red-500 {
|
|
2068
|
-
--tw-border-opacity: 1;
|
|
2069
|
-
border-color: rgb(239 68 68 / var(--tw-border-opacity));
|
|
2070
|
-
}
|
|
2071
|
-
|
|
2072
2075
|
.s-border-rose-100 {
|
|
2073
2076
|
--tw-border-opacity: 1;
|
|
2074
2077
|
border-color: rgb(255 228 230 / var(--tw-border-opacity));
|
|
@@ -4218,16 +4221,6 @@ select {
|
|
|
4218
4221
|
color: rgb(148 163 184 / var(--tw-placeholder-opacity));
|
|
4219
4222
|
}
|
|
4220
4223
|
|
|
4221
|
-
.s-placeholder-element-700::-moz-placeholder {
|
|
4222
|
-
--tw-placeholder-opacity: 1;
|
|
4223
|
-
color: rgb(100 116 139 / var(--tw-placeholder-opacity));
|
|
4224
|
-
}
|
|
4225
|
-
|
|
4226
|
-
.s-placeholder-element-700::placeholder {
|
|
4227
|
-
--tw-placeholder-opacity: 1;
|
|
4228
|
-
color: rgb(100 116 139 / var(--tw-placeholder-opacity));
|
|
4229
|
-
}
|
|
4230
|
-
|
|
4231
4224
|
.s-opacity-0 {
|
|
4232
4225
|
opacity: 0;
|
|
4233
4226
|
}
|
|
@@ -4688,16 +4681,6 @@ select {
|
|
|
4688
4681
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
4689
4682
|
}
|
|
4690
4683
|
|
|
4691
|
-
.focus\:s-border-action-300:focus {
|
|
4692
|
-
--tw-border-opacity: 1;
|
|
4693
|
-
border-color: rgb(147 197 253 / var(--tw-border-opacity));
|
|
4694
|
-
}
|
|
4695
|
-
|
|
4696
|
-
.focus\:s-border-red-500:focus {
|
|
4697
|
-
--tw-border-opacity: 1;
|
|
4698
|
-
border-color: rgb(239 68 68 / var(--tw-border-opacity));
|
|
4699
|
-
}
|
|
4700
|
-
|
|
4701
4684
|
.focus\:s-bg-action-50-dark:focus {
|
|
4702
4685
|
--tw-bg-opacity: 1;
|
|
4703
4686
|
background-color: rgb(23 37 84 / var(--tw-bg-opacity));
|
|
@@ -4735,11 +4718,6 @@ select {
|
|
|
4735
4718
|
--tw-ring-color: rgb(147 197 253 / var(--tw-ring-opacity));
|
|
4736
4719
|
}
|
|
4737
4720
|
|
|
4738
|
-
.focus\:s-ring-red-500:focus {
|
|
4739
|
-
--tw-ring-opacity: 1;
|
|
4740
|
-
--tw-ring-color: rgb(239 68 68 / var(--tw-ring-opacity));
|
|
4741
|
-
}
|
|
4742
|
-
|
|
4743
4721
|
.focus\:s-ring-warning-300:focus {
|
|
4744
4722
|
--tw-ring-opacity: 1;
|
|
4745
4723
|
--tw-ring-color: rgb(252 165 165 / var(--tw-ring-opacity));
|
package/package.json
CHANGED
|
@@ -1,40 +1,66 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { cn } from "@sparkle/lib/utils";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const RESIZE_DIRECTIONS = ["none", "vertical", "horizontal", "both"] as const;
|
|
6
|
+
|
|
7
|
+
type ResizeDirectionType = (typeof RESIZE_DIRECTIONS)[number];
|
|
8
|
+
|
|
9
|
+
export interface TextareaProps
|
|
6
10
|
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
11
|
+
resize?: ResizeDirectionType;
|
|
7
12
|
error?: string | null;
|
|
8
13
|
showErrorLabel?: boolean;
|
|
9
14
|
minRows?: number;
|
|
10
|
-
className?: string;
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
const textAreaStyles = cn(
|
|
18
|
+
"s-flex s-w-full s-px-3 s-py-2",
|
|
19
|
+
"s-transition s-duration-100",
|
|
20
|
+
"s-text-sm placeholder:s-text-muted-foreground s-text-foreground",
|
|
21
|
+
"s-ring-offset-background s-border s-border-border-dark s-bg-background s-rounded-xl",
|
|
22
|
+
"focus-visible:s-outline-none focus-visible:s-ring-2 focus-visible:s-ring-offset-2 ",
|
|
23
|
+
"disabled:s-cursor-not-allowed disabled:s-opacity-50 disabled:s-text-muted-foreground"
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const TextArea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
14
27
|
(
|
|
15
28
|
{
|
|
16
|
-
error,
|
|
17
|
-
showErrorLabel = false,
|
|
18
29
|
className,
|
|
30
|
+
resize = "both",
|
|
19
31
|
minRows = 10,
|
|
32
|
+
error,
|
|
33
|
+
showErrorLabel,
|
|
20
34
|
...props
|
|
21
|
-
}
|
|
35
|
+
},
|
|
22
36
|
ref
|
|
23
37
|
) => {
|
|
38
|
+
const resizeClass = {
|
|
39
|
+
none: "s-resize-none",
|
|
40
|
+
vertical: "s-resize-y",
|
|
41
|
+
horizontal: "s-resize-x",
|
|
42
|
+
both: "s-resize",
|
|
43
|
+
};
|
|
44
|
+
|
|
24
45
|
return (
|
|
25
46
|
<div className="s-flex s-flex-col s-gap-1 s-p-px">
|
|
26
47
|
<textarea
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
48
|
+
className={cn(
|
|
49
|
+
textAreaStyles,
|
|
50
|
+
resizeClass[resize],
|
|
51
|
+
className,
|
|
31
52
|
!error
|
|
32
|
-
?
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
? cn(
|
|
54
|
+
"s-ring-structure-200 focus:s-ring-action-300",
|
|
55
|
+
"dark:s-ring-structure-300-dark dark:focus:s-ring-action-300-dark"
|
|
56
|
+
)
|
|
57
|
+
: cn(
|
|
58
|
+
"s-ring-warning-200 focus:s-ring-warning-300",
|
|
59
|
+
"dark:s-ring-warning-200-dark dark:focus:s-ring-warning-300-dark"
|
|
60
|
+
)
|
|
37
61
|
)}
|
|
62
|
+
ref={ref}
|
|
63
|
+
rows={minRows}
|
|
38
64
|
{...props}
|
|
39
65
|
/>
|
|
40
66
|
{error && showErrorLabel && (
|
|
@@ -44,3 +70,6 @@ export const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
|
44
70
|
);
|
|
45
71
|
}
|
|
46
72
|
);
|
|
73
|
+
TextArea.displayName = "TextArea";
|
|
74
|
+
|
|
75
|
+
export { TextArea };
|