@dust-tt/sparkle 0.2.248 → 0.2.249
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 +5 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/Input.d.ts +2 -1
- package/dist/esm/components/Input.d.ts.map +1 -1
- package/dist/esm/components/Input.js +6 -5
- package/dist/esm/components/Input.js.map +1 -1
- package/dist/esm/components/Searchbar.d.ts +9 -7
- package/dist/esm/components/Searchbar.d.ts.map +1 -1
- package/dist/esm/components/Searchbar.js.map +1 -1
- package/dist/esm/stories/Input.stories.d.ts +14 -2
- package/dist/esm/stories/Input.stories.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Input.tsx +76 -65
- package/src/components/Searchbar.tsx +12 -11
|
@@ -11,7 +11,8 @@ type InputProps = {
|
|
|
11
11
|
disabled?: boolean;
|
|
12
12
|
className?: string;
|
|
13
13
|
label?: string;
|
|
14
|
+
maxLength?: number;
|
|
14
15
|
};
|
|
15
|
-
export declare
|
|
16
|
+
export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
16
17
|
export {};
|
|
17
18
|
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAS1C,KAAK,UAAU,GAAG;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,KAAK,qFAoEjB,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
2
|
import { classNames } from "../lib/utils";
|
|
3
3
|
var sizeInputClasses = {
|
|
4
4
|
sm: "s-text-base s-rounded-md s-py-1.5 s-pl-4 s-pr-8",
|
|
5
5
|
md: "s-text-lg s-rounded-lg s-py-2 s-pl-4 s-pr-10",
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
var placeholder = _a.placeholder, value = _a.value, _b = _a.size, size = _b === void 0 ? "sm" : _b, onChange = _a.onChange, error = _a.error, _c = _a.showErrorLabel, showErrorLabel = _c === void 0 ? false : _c, name = _a.name, _d = _a.isPassword, isPassword = _d === void 0 ? false : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.className, className = _f === void 0 ? "" : _f, label = _a.label;
|
|
7
|
+
export var Input = forwardRef(function (_a, ref) {
|
|
8
|
+
var placeholder = _a.placeholder, value = _a.value, _b = _a.size, size = _b === void 0 ? "sm" : _b, onChange = _a.onChange, error = _a.error, _c = _a.showErrorLabel, showErrorLabel = _c === void 0 ? false : _c, name = _a.name, _d = _a.isPassword, isPassword = _d === void 0 ? false : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.className, className = _f === void 0 ? "" : _f, label = _a.label, maxLength = _a.maxLength;
|
|
9
9
|
return (React.createElement("div", { className: "s-flex s-flex-col s-gap-1 s-p-px" },
|
|
10
10
|
label && (React.createElement("label", { htmlFor: name, className: "s-pb-1 s-text-sm s-font-medium s-text-element-700 dark:s-text-element-700-dark" }, label)),
|
|
11
|
-
React.createElement("input", { type: isPassword ? "password" : "text", name: name, id: name, className: classNames("s-w-full s-border-0 s-outline-none s-ring-1 focus:s-outline-none focus:s-ring-2", "s-bg-structure-50 s-placeholder-element-700", "dark:s-bg-structure-50-dark dark:s-placeholder-element-700-dark", sizeInputClasses[size], "s-transition-all s-duration-300 s-ease-out", className !== null && className !== void 0 ? className : "", !error
|
|
11
|
+
React.createElement("input", { ref: ref, type: isPassword ? "password" : "text", name: name, id: name, maxLength: maxLength, className: classNames("s-w-full s-border-0 s-outline-none s-ring-1 focus:s-outline-none focus:s-ring-2", "s-bg-structure-50 s-placeholder-element-700", "dark:s-bg-structure-50-dark dark:s-placeholder-element-700-dark", sizeInputClasses[size], "s-transition-all s-duration-300 s-ease-out", className !== null && className !== void 0 ? className : "", !error
|
|
12
12
|
? classNames("s-ring-structure-200 focus:s-ring-action-300", "dark:s-ring-structure-300-dark dark:focus:s-ring-action-300-dark")
|
|
13
13
|
: classNames("s-ring-warning-200 focus:s-ring-warning-300", "dark:s-ring-warning-200-dark dark:focus:s-ring-warning-300-dark"), disabled
|
|
14
14
|
? "s-text-element-500 hover:s-cursor-not-allowed"
|
|
@@ -16,5 +16,6 @@ export function Input(_a) {
|
|
|
16
16
|
onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value);
|
|
17
17
|
}, "data-1p-ignore": !isPassword, disabled: disabled }),
|
|
18
18
|
React.createElement("div", { className: "s-ml-2 s-text-sm s-text-warning-500" }, showErrorLabel && error ? error : null)));
|
|
19
|
-
}
|
|
19
|
+
});
|
|
20
|
+
Input.displayName = "Input";
|
|
20
21
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/Input.tsx"],"names":[],"mappings":"AAAA,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,CAAC,CAAC,UAAU,CACR,8CAA8C,EAC9C,kEAAkE,CACnE;gBACH,CAAC,CAAC,UAAU,CACR,6CAA6C,EAC7C,iEAAiE,CAClE,EACL,QAAQ;gBACN,CAAC,CAAC,+CAA+C;gBACjD,CAAC,CAAC,iDAAiD,CACtD,EACD,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,EAClB,QAAQ,EAAE,UAAC,CAAC;gBACV,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC,oBACe,CAAC,UAAU,EAC3B,QAAQ,EAAE,QAAQ,GAClB;QACF,6BAAK,SAAS,EAAC,qCAAqC,IACjD,cAAc,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CACnC,CACF,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,KAAK,CAAC,WAAW,GAAG,OAAO,CAAA"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
type SearchbarProps = {
|
|
3
3
|
placeholder: string;
|
|
4
4
|
value: string | null;
|
|
5
|
-
onChange?: (
|
|
6
|
-
onKeyDown?: (
|
|
5
|
+
onChange?: (value: string) => void;
|
|
6
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
7
7
|
name: string;
|
|
8
|
-
size?: "xs" | "sm" | "md"
|
|
9
|
-
disabled?: boolean
|
|
10
|
-
className?: string
|
|
11
|
-
}
|
|
8
|
+
size?: "xs" | "sm" | "md";
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const Searchbar: React.ForwardRefExoticComponent<SearchbarProps & React.RefAttributes<HTMLInputElement>>;
|
|
13
|
+
export {};
|
|
12
14
|
//# sourceMappingURL=Searchbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Searchbar.d.ts","sourceRoot":"","sources":["../../../src/components/Searchbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAmB1C,
|
|
1
|
+
{"version":3,"file":"Searchbar.d.ts","sourceRoot":"","sources":["../../../src/components/Searchbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAmB1C,KAAK,cAAc,GAAG;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAA;AAED,eAAO,MAAM,SAAS,yFAyErB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Searchbar.js","sourceRoot":"","sources":["../../../src/components/Searchbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,IAAM,WAAW,GAAG;IAClB,EAAE,EAAE,6CAA6C;IACjD,EAAE,EAAE,6CAA6C;IACjD,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,EAAE,EAAE,IAAI,EACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,UAAU,CACnB,6FAA6F,EAC7F,mFAAmF,EACnF,8CAA8C,EAC9C,kEAAkE,EAClE,4CAA4C,EAC5C,WAAW,CAAC,IAAI,CAAC,EACjB,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,EACf,QAAQ;gBACN,CAAC,CAAC,qCAAqC;gBACvC,CAAC,CAAC,oBAAoB,CACzB,EACD,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,EAClB,QAAQ,EAAE,UAAC,CAAC;gBACV,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC,EACD,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,GAClB;QACF,6BACE,SAAS,EAAE,UAAU,CACnB,+DAA+D,EAC/D,WAAW,CAAC,IAAI,CAAC,CAClB,IAEA,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CACnB,oBAAC,UAAU,IACT,IAAI,EAAE,SAAS,EACf,OAAO,EAAC,WAAW,EACnB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,eAAe,GACxB,CACH,CAAC,CAAC,CAAC,CACF,6BACE,SAAS,EAAE,UAAU,CACnB,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,CACvD;YAED,oBAAC,IAAI,IAAC,MAAM,EAAE,yBAAyB,EAAE,IAAI,EAAE,IAAI,GAAI,CACnD,CACP,CACG,CACF,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC"}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Input } from "../index_with_tw_base";
|
|
3
2
|
declare const meta: {
|
|
4
3
|
title: string;
|
|
5
|
-
component:
|
|
4
|
+
component: React.ForwardRefExoticComponent<{
|
|
5
|
+
placeholder: string;
|
|
6
|
+
size?: "sm" | "md" | undefined;
|
|
7
|
+
value: string | null;
|
|
8
|
+
onChange?: ((value: string) => void) | undefined;
|
|
9
|
+
error?: string | null | undefined;
|
|
10
|
+
showErrorLabel?: boolean | undefined;
|
|
11
|
+
name: string;
|
|
12
|
+
isPassword?: boolean | undefined;
|
|
13
|
+
disabled?: boolean | undefined;
|
|
14
|
+
className?: string | undefined;
|
|
15
|
+
label?: string | undefined;
|
|
16
|
+
maxLength?: number | undefined;
|
|
17
|
+
} & React.RefAttributes<HTMLInputElement>>;
|
|
6
18
|
};
|
|
7
19
|
export default meta;
|
|
8
20
|
export declare const InputExample: () => React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/Input.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Input.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/Input.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;CAGoB,CAAC;AAE/B,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,YAAY,yBAmFxB,CAAC"}
|
package/package.json
CHANGED
package/src/components/Input.tsx
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
2
|
|
|
3
3
|
import { classNames } from "@sparkle/lib/utils";
|
|
4
4
|
|
|
5
|
+
const sizeInputClasses = {
|
|
6
|
+
sm: "s-text-base s-rounded-md s-py-1.5 s-pl-4 s-pr-8",
|
|
7
|
+
md: "s-text-lg s-rounded-lg s-py-2 s-pl-4 s-pr-10",
|
|
8
|
+
};
|
|
9
|
+
|
|
5
10
|
type InputProps = {
|
|
6
11
|
placeholder: string;
|
|
7
12
|
size?: "sm" | "md";
|
|
@@ -14,71 +19,77 @@ type InputProps = {
|
|
|
14
19
|
disabled?: boolean;
|
|
15
20
|
className?: string;
|
|
16
21
|
label?: string;
|
|
22
|
+
maxLength?: number;
|
|
17
23
|
};
|
|
18
24
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)}
|
|
47
|
-
<input
|
|
48
|
-
type={isPassword ? "password" : "text"}
|
|
49
|
-
name={name}
|
|
50
|
-
id={name}
|
|
51
|
-
className={classNames(
|
|
52
|
-
"s-w-full s-border-0 s-outline-none s-ring-1 focus:s-outline-none focus:s-ring-2",
|
|
53
|
-
"s-bg-structure-50 s-placeholder-element-700",
|
|
54
|
-
"dark:s-bg-structure-50-dark dark:s-placeholder-element-700-dark",
|
|
55
|
-
sizeInputClasses[size],
|
|
56
|
-
"s-transition-all s-duration-300 s-ease-out",
|
|
57
|
-
className ?? "",
|
|
58
|
-
!error
|
|
59
|
-
? classNames(
|
|
60
|
-
"s-ring-structure-200 focus:s-ring-action-300",
|
|
61
|
-
"dark:s-ring-structure-300-dark dark:focus:s-ring-action-300-dark"
|
|
62
|
-
)
|
|
63
|
-
: classNames(
|
|
64
|
-
"s-ring-warning-200 focus:s-ring-warning-300",
|
|
65
|
-
"dark:s-ring-warning-200-dark dark:focus:s-ring-warning-300-dark"
|
|
66
|
-
),
|
|
67
|
-
disabled
|
|
68
|
-
? "s-text-element-500 hover:s-cursor-not-allowed"
|
|
69
|
-
: "s-text-element-900 dark:s-text-element-800-dark"
|
|
25
|
+
export const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
26
|
+
(
|
|
27
|
+
{
|
|
28
|
+
placeholder,
|
|
29
|
+
value,
|
|
30
|
+
size = "sm",
|
|
31
|
+
onChange,
|
|
32
|
+
error,
|
|
33
|
+
showErrorLabel = false,
|
|
34
|
+
name,
|
|
35
|
+
isPassword = false,
|
|
36
|
+
disabled = false,
|
|
37
|
+
className = "",
|
|
38
|
+
label,
|
|
39
|
+
maxLength,
|
|
40
|
+
},
|
|
41
|
+
ref
|
|
42
|
+
) => {
|
|
43
|
+
return (
|
|
44
|
+
<div className="s-flex s-flex-col s-gap-1 s-p-px">
|
|
45
|
+
{label && (
|
|
46
|
+
<label
|
|
47
|
+
htmlFor={name}
|
|
48
|
+
className="s-pb-1 s-text-sm s-font-medium s-text-element-700 dark:s-text-element-700-dark"
|
|
49
|
+
>
|
|
50
|
+
{label}
|
|
51
|
+
</label>
|
|
70
52
|
)}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
53
|
+
<input
|
|
54
|
+
ref={ref}
|
|
55
|
+
type={isPassword ? "password" : "text"}
|
|
56
|
+
name={name}
|
|
57
|
+
id={name}
|
|
58
|
+
maxLength={maxLength}
|
|
59
|
+
className={classNames(
|
|
60
|
+
"s-w-full s-border-0 s-outline-none s-ring-1 focus:s-outline-none focus:s-ring-2",
|
|
61
|
+
"s-bg-structure-50 s-placeholder-element-700",
|
|
62
|
+
"dark:s-bg-structure-50-dark dark:s-placeholder-element-700-dark",
|
|
63
|
+
sizeInputClasses[size],
|
|
64
|
+
"s-transition-all s-duration-300 s-ease-out",
|
|
65
|
+
className ?? "",
|
|
66
|
+
!error
|
|
67
|
+
? classNames(
|
|
68
|
+
"s-ring-structure-200 focus:s-ring-action-300",
|
|
69
|
+
"dark:s-ring-structure-300-dark dark:focus:s-ring-action-300-dark"
|
|
70
|
+
)
|
|
71
|
+
: classNames(
|
|
72
|
+
"s-ring-warning-200 focus:s-ring-warning-300",
|
|
73
|
+
"dark:s-ring-warning-200-dark dark:focus:s-ring-warning-300-dark"
|
|
74
|
+
),
|
|
75
|
+
disabled
|
|
76
|
+
? "s-text-element-500 hover:s-cursor-not-allowed"
|
|
77
|
+
: "s-text-element-900 dark:s-text-element-800-dark"
|
|
78
|
+
)}
|
|
79
|
+
placeholder={placeholder}
|
|
80
|
+
value={value ?? ""}
|
|
81
|
+
onChange={(e) => {
|
|
82
|
+
onChange?.(e.target.value);
|
|
83
|
+
}}
|
|
84
|
+
data-1p-ignore={!isPassword}
|
|
85
|
+
disabled={disabled}
|
|
86
|
+
/>
|
|
87
|
+
<div className="s-ml-2 s-text-sm s-text-warning-500">
|
|
88
|
+
{showErrorLabel && error ? error : null}
|
|
89
|
+
</div>
|
|
81
90
|
</div>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
Input.displayName = "Input"
|
|
@@ -17,18 +17,19 @@ const iconClasses = {
|
|
|
17
17
|
md: "s-pr-4",
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
type SearchbarProps = {
|
|
21
|
+
placeholder: string;
|
|
22
|
+
value: string | null;
|
|
23
|
+
onChange?: (value: string) => void;
|
|
24
|
+
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
25
|
+
name: string;
|
|
26
|
+
size?: "xs" | "sm" | "md";
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
className?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
20
31
|
export const Searchbar = forwardRef<
|
|
21
|
-
HTMLInputElement,
|
|
22
|
-
{
|
|
23
|
-
placeholder: string;
|
|
24
|
-
value: string | null;
|
|
25
|
-
onChange?: (value: string) => void;
|
|
26
|
-
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
27
|
-
name: string;
|
|
28
|
-
size?: "xs" | "sm" | "md";
|
|
29
|
-
disabled?: boolean;
|
|
30
|
-
className?: string;
|
|
31
|
-
}
|
|
32
|
+
HTMLInputElement, SearchbarProps
|
|
32
33
|
>(
|
|
33
34
|
(
|
|
34
35
|
{
|