@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.
@@ -1,51 +1,46 @@
1
- import React, { useRef } from "react";
1
+ import React from "react";
2
2
 
3
3
  import { classNames } from "@sparkle/lib/utils";
4
4
 
5
- type TextAreaProps = {
6
- placeholder: string;
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
- return (
27
- <div className="s-flex s-flex-col s-gap-1 s-p-px">
28
- <textarea
29
- rows={minRows}
30
- ref={textareaRef}
31
- className={classNames(
32
- "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",
33
- !error
34
- ? "s-border-structure-100 focus:s-border-action-300 focus:s-ring-action-300"
35
- : "s-border-red-500 focus:s-border-red-500 focus:s-ring-red-500",
36
- "s-border-structure-200 s-bg-structure-50",
37
- "s-resize-y",
38
- className ?? ""
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
- placeholder={placeholder}
41
- value={value ?? ""}
42
- onChange={(e) => {
43
- onChange(e.target.value);
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.CellContent>{info.row.original.addedBy}</DataTable.CellContent>
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
- value={textValues[0]}
26
- onChange={(v) =>
27
- setTextValues([v, textValues[1], textValues[2], textValues[3]])
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
- value={textValues[1]}
34
+ defaultValue={textValues[1]}
34
35
  error={"errored because blah"}
35
- onChange={(v) =>
36
- setTextValues([textValues[0], v, textValues[2], textValues[3]])
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
- value={textValues[2]}
43
- onChange={(v) =>
44
- setTextValues([textValues[0], textValues[1], v, textValues[3]])
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
  />