@dust-tt/sparkle 0.2.251 → 0.2.253
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 +38 -12
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/DataTable.d.ts +6 -0
- package/dist/esm/components/DataTable.d.ts.map +1 -1
- package/dist/esm/components/DataTable.js +32 -3
- package/dist/esm/components/DataTable.js.map +1 -1
- package/dist/esm/components/Modal.d.ts +6 -5
- package/dist/esm/components/Modal.d.ts.map +1 -1
- package/dist/esm/components/Modal.js +4 -4
- package/dist/esm/components/Modal.js.map +1 -1
- package/dist/esm/components/TextArea.d.ts +4 -8
- package/dist/esm/components/TextArea.d.ts.map +1 -1
- package/dist/esm/components/TextArea.js +7 -9
- package/dist/esm/components/TextArea.js.map +1 -1
- package/dist/esm/stories/DataTable.stories.js +1 -1
- package/dist/esm/stories/DataTable.stories.js.map +1 -1
- package/dist/esm/stories/Modal.stories.d.ts.map +1 -1
- package/dist/esm/stories/Modal.stories.js +6 -1
- package/dist/esm/stories/Modal.stories.js.map +1 -1
- package/dist/esm/stories/TextArea.stories.d.ts +1 -2
- package/dist/esm/stories/TextArea.stories.d.ts.map +1 -1
- package/dist/esm/stories/TextArea.stories.js +8 -7
- package/dist/esm/stories/TextArea.stories.js.map +1 -1
- package/dist/sparkle.css +6 -0
- package/package.json +1 -1
- package/src/components/DataTable.tsx +52 -2
- package/src/components/Modal.tsx +17 -11
- package/src/components/TextArea.tsx +38 -43
- package/src/stories/DataTable.stories.tsx +1 -1
- package/src/stories/Modal.stories.tsx +17 -0
- package/src/stories/TextArea.stories.tsx +11 -10
|
@@ -1,51 +1,46 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { classNames } from "@sparkle/lib/utils";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
value: string | null;
|
|
8
|
-
onChange: (value: string) => void;
|
|
5
|
+
export interface TextAreaProps
|
|
6
|
+
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
9
7
|
error?: string | null;
|
|
10
8
|
showErrorLabel?: boolean;
|
|
11
|
-
className?: string;
|
|
12
9
|
minRows?: number;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export function TextArea({
|
|
16
|
-
placeholder,
|
|
17
|
-
value,
|
|
18
|
-
onChange,
|
|
19
|
-
error,
|
|
20
|
-
showErrorLabel = false,
|
|
21
|
-
className,
|
|
22
|
-
minRows = 10
|
|
23
|
-
}: TextAreaProps) {
|
|
24
|
-
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
25
12
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
13
|
+
export const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
|
14
|
+
(
|
|
15
|
+
{
|
|
16
|
+
error,
|
|
17
|
+
showErrorLabel = false,
|
|
18
|
+
className,
|
|
19
|
+
minRows = 10,
|
|
20
|
+
...props
|
|
21
|
+
}: TextAreaProps,
|
|
22
|
+
ref
|
|
23
|
+
) => {
|
|
24
|
+
return (
|
|
25
|
+
<div className="s-flex s-flex-col s-gap-1 s-p-px">
|
|
26
|
+
<textarea
|
|
27
|
+
rows={minRows}
|
|
28
|
+
ref={ref}
|
|
29
|
+
className={classNames(
|
|
30
|
+
"overflow-y-auto s-block s-w-full s-min-w-0 s-rounded-xl s-text-sm s-placeholder-element-700 s-transition-all s-duration-200 s-scrollbar-hide",
|
|
31
|
+
!error
|
|
32
|
+
? "s-border-structure-100 focus:s-border-action-300 focus:s-ring-action-300"
|
|
33
|
+
: "s-border-red-500 focus:s-border-red-500 focus:s-ring-red-500",
|
|
34
|
+
"s-border-structure-200 s-bg-structure-50",
|
|
35
|
+
"s-resize-y",
|
|
36
|
+
className ?? ""
|
|
37
|
+
)}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
{error && showErrorLabel && (
|
|
41
|
+
<div className="s-ml-2 s-text-sm s-text-warning-500">{error}</div>
|
|
39
42
|
)}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}}
|
|
45
|
-
/>
|
|
46
|
-
{error && showErrorLabel && (
|
|
47
|
-
<div className="s-ml-2 s-text-sm s-text-warning-500">{error}</div>
|
|
48
|
-
)}
|
|
49
|
-
</div>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
@@ -161,7 +161,7 @@ const columns: ColumnDef<Data>[] = [
|
|
|
161
161
|
width: "100px",
|
|
162
162
|
},
|
|
163
163
|
cell: (info) => (
|
|
164
|
-
<DataTable.
|
|
164
|
+
<DataTable.CellContentWithCopy>{info.row.original.addedBy}</DataTable.CellContentWithCopy>
|
|
165
165
|
),
|
|
166
166
|
},
|
|
167
167
|
{
|
|
@@ -21,6 +21,8 @@ export const ModalExample = () => {
|
|
|
21
21
|
const [inputValue, setInputValue] = useState("initial value");
|
|
22
22
|
const [isRightSideWideModalOpen, setIsRightSideWideModalOpen] =
|
|
23
23
|
useState(false);
|
|
24
|
+
const [isAlertModalOpen, setIsAlertModalOpen] = useState(false);
|
|
25
|
+
|
|
24
26
|
return (
|
|
25
27
|
<Page.Layout gap="md">
|
|
26
28
|
<Modal
|
|
@@ -121,6 +123,20 @@ export const ModalExample = () => {
|
|
|
121
123
|
I'm the modal content
|
|
122
124
|
</div>
|
|
123
125
|
</Modal>
|
|
126
|
+
<Modal
|
|
127
|
+
isOpen={isAlertModalOpen}
|
|
128
|
+
onClose={() => {}}
|
|
129
|
+
onSave={() => {}}
|
|
130
|
+
isSaving={false}
|
|
131
|
+
hasChanged={false}
|
|
132
|
+
variant="side-sm"
|
|
133
|
+
title="Alert modal"
|
|
134
|
+
alertModal
|
|
135
|
+
action={undefined}
|
|
136
|
+
>
|
|
137
|
+
This is an alert modal.
|
|
138
|
+
<Button label="Ok" onClick={() => setIsAlertModalOpen(false)} />
|
|
139
|
+
</Modal>
|
|
124
140
|
<div className="s-flex s-flex-col s-items-start s-gap-3">
|
|
125
141
|
<div className="s-text-lg s-font-bold">Fullscreen</div>
|
|
126
142
|
<Button
|
|
@@ -140,6 +156,7 @@ export const ModalExample = () => {
|
|
|
140
156
|
label="Modal right side wide"
|
|
141
157
|
onClick={() => setIsRightSideWideModalOpen(true)}
|
|
142
158
|
/>
|
|
159
|
+
<Button label="Alert modal" onClick={() => setIsAlertModalOpen(true)} />
|
|
143
160
|
</div>
|
|
144
161
|
</Page.Layout>
|
|
145
162
|
);
|
|
@@ -22,26 +22,27 @@ export const TextAreaExample = () => {
|
|
|
22
22
|
<div className="s-grid s-grid-cols-3 s-gap-4">
|
|
23
23
|
<TextArea
|
|
24
24
|
placeholder="placeholder"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
setTextValues([
|
|
28
|
-
}
|
|
25
|
+
onChange={(e) => {
|
|
26
|
+
console.log(e.target.value)
|
|
27
|
+
setTextValues([e.target.value, textValues[1], textValues[2], textValues[3]])
|
|
28
|
+
}}
|
|
29
29
|
minRows={2}
|
|
30
|
+
defaultValue={textValues[0]}
|
|
30
31
|
/>
|
|
31
32
|
<TextArea
|
|
32
33
|
placeholder="placeholder"
|
|
33
|
-
|
|
34
|
+
defaultValue={textValues[1]}
|
|
34
35
|
error={"errored because blah"}
|
|
35
|
-
onChange={(
|
|
36
|
-
setTextValues([textValues[0],
|
|
36
|
+
onChange={(e) =>
|
|
37
|
+
setTextValues([textValues[0], e.target.value, textValues[2], textValues[3]])
|
|
37
38
|
}
|
|
38
39
|
showErrorLabel
|
|
39
40
|
/>
|
|
40
41
|
<TextArea
|
|
41
42
|
placeholder="placeholder"
|
|
42
|
-
|
|
43
|
-
onChange={(
|
|
44
|
-
setTextValues([textValues[0], textValues[1],
|
|
43
|
+
defaultValue={textValues[2]}
|
|
44
|
+
onChange={(e) =>
|
|
45
|
+
setTextValues([textValues[0], textValues[1], e.target.value, textValues[3]])
|
|
45
46
|
}
|
|
46
47
|
error={"errored because blah"}
|
|
47
48
|
/>
|