@dust-tt/sparkle 0.2.285 → 0.2.287-rc-1
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 +28 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/Input.d.ts +6 -2
- package/dist/esm/components/Input.d.ts.map +1 -1
- package/dist/esm/components/Input.js +22 -4
- package/dist/esm/components/Input.js.map +1 -1
- package/dist/esm/components/NavigationList.d.ts +1 -1
- package/dist/esm/components/NavigationList.d.ts.map +1 -1
- package/dist/esm/components/NavigationList.js +6 -10
- package/dist/esm/components/NavigationList.js.map +1 -1
- package/dist/esm/stories/Input.stories.d.ts.map +1 -1
- package/dist/esm/stories/Input.stories.js +11 -11
- package/dist/esm/stories/Input.stories.js.map +1 -1
- package/dist/esm/stories/NavigationList.stories.d.ts.map +1 -1
- package/dist/esm/stories/NavigationList.stories.js +9 -6
- package/dist/esm/stories/NavigationList.stories.js.map +1 -1
- package/dist/sparkle.css +0 -5
- package/package.json +1 -1
- package/src/components/Input.tsx +41 -9
- package/src/components/NavigationList.tsx +6 -21
- package/src/stories/Input.stories.tsx +23 -21
- package/src/stories/NavigationList.stories.tsx +31 -4
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
declare const MESSAGE_STATUS: readonly ["info", "default", "error"];
|
|
3
|
+
type MessageStatus = (typeof MESSAGE_STATUS)[number];
|
|
2
4
|
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "value"> {
|
|
3
|
-
|
|
5
|
+
message?: string;
|
|
6
|
+
messageStatus?: MessageStatus;
|
|
4
7
|
value?: string | null;
|
|
5
|
-
|
|
8
|
+
isError?: boolean;
|
|
6
9
|
className?: string;
|
|
7
10
|
label?: string;
|
|
8
11
|
}
|
|
9
12
|
export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
13
|
+
export {};
|
|
10
14
|
//# sourceMappingURL=Input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../../../src/components/Input.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAQ1C,QAAA,MAAM,cAAc,uCAAwC,CAAC;AAE7D,KAAK,aAAa,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAErD,MAAM,WAAW,UACf,SAAQ,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAClE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA6CD,eAAO,MAAM,KAAK,qFA0CjB,CAAC"}
|
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
import { __assign, __rest } from "tslib";
|
|
2
2
|
import { cva } from "class-variance-authority";
|
|
3
3
|
import React, { forwardRef } from "react";
|
|
4
|
+
import { Icon } from "../components/Icon";
|
|
5
|
+
import { InformationCircleStrokeIcon } from "../icons";
|
|
4
6
|
import { cn } from "../lib/utils";
|
|
5
7
|
import { Label } from "./Label";
|
|
8
|
+
var MESSAGE_STATUS = ["info", "default", "error"];
|
|
6
9
|
var INPUT_STATES = ["error", "disabled", "default"];
|
|
10
|
+
var messageVariantStyles = {
|
|
11
|
+
info: "s-text-muted-foreground",
|
|
12
|
+
default: "s-text-muted-foreground",
|
|
13
|
+
error: "s-text-foreground-warning",
|
|
14
|
+
};
|
|
7
15
|
var stateVariantStyles = {
|
|
8
16
|
default: "focus-visible:s-ring-ring",
|
|
9
17
|
disabled: "disabled:s-cursor-not-allowed disabled:s-opacity-50 disabled:s-text-muted-foreground",
|
|
10
18
|
error: "s-border-border-warning focus:s-ring-ring-warning",
|
|
11
19
|
};
|
|
20
|
+
var messageVariant = cva("", {
|
|
21
|
+
variants: {
|
|
22
|
+
status: messageVariantStyles,
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
status: "info",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
12
28
|
var inputStyleClasses = cva(cn("s-text-sm s-bg-background s-rounded-xl s-border s-border-border-dark s-flex s-h-9 s-w-full s-px-3 s-py-1.5 ", "file:s-border-0 file:s-bg-transparent file:s-text-sm file:s-font-medium file:s-text-foreground", "placeholder:s-text-muted-foreground", "focus-visible:s-outline-none focus-visible:s-ring-2 focus-visible:s-ring-offset-2 focus-visible:s-border-border-dark"), {
|
|
13
29
|
variants: {
|
|
14
30
|
state: stateVariantStyles,
|
|
@@ -18,12 +34,14 @@ var inputStyleClasses = cva(cn("s-text-sm s-bg-background s-rounded-xl s-border
|
|
|
18
34
|
},
|
|
19
35
|
});
|
|
20
36
|
export var Input = forwardRef(function (_a, ref) {
|
|
21
|
-
var className = _a.className,
|
|
22
|
-
var state =
|
|
23
|
-
return (React.createElement("div", { className: "s-flex s-flex-col s-gap-1
|
|
37
|
+
var className = _a.className, message = _a.message, messageStatus = _a.messageStatus, value = _a.value, label = _a.label, isError = _a.isError, disabled = _a.disabled, props = __rest(_a, ["className", "message", "messageStatus", "value", "label", "isError", "disabled"]);
|
|
38
|
+
var state = isError ? "error" : disabled ? "disabled" : "default";
|
|
39
|
+
return (React.createElement("div", { className: "s-flex s-flex-col s-gap-1" },
|
|
24
40
|
label && React.createElement(Label, { htmlFor: props.name }, label),
|
|
25
41
|
React.createElement("input", __assign({ ref: ref, className: cn(inputStyleClasses({ state: state }), className), "data-1p-ignore": props.type !== "password", value: value !== null && value !== void 0 ? value : undefined, disabled: disabled }, props)),
|
|
26
|
-
|
|
42
|
+
message && (React.createElement("div", { className: cn("s-ml-3.5 s-flex s-items-center s-gap-1 s-text-xs", messageVariant({ status: messageStatus })) },
|
|
43
|
+
messageStatus === "info" && (React.createElement(Icon, { visual: InformationCircleStrokeIcon, size: "xs" })),
|
|
44
|
+
message))));
|
|
27
45
|
});
|
|
28
46
|
Input.displayName = "Input";
|
|
29
47
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/Input.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../src/components/Input.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,IAAM,cAAc,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AAc7D,IAAM,YAAY,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AAItD,IAAM,oBAAoB,GAAkC;IAC1D,IAAI,EAAE,yBAAyB;IAC/B,OAA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,aAAL,KAAK,cAAL,KAAK,GAAI,SAAS,EACzB,QAAQ,EAAE,QAAQ,IACd,KAAK,EACT;QACD,OAAO,IAAI,CACV,6BACE,SAAS,EAAE,EAAE,CACX,kDAAkD,EAClD,cAAc,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAC1C;YAEA,aAAa,KAAK,MAAM,IAAI,CAC3B,oBAAC,IAAI,IAAC,MAAM,EAAE,2BAA2B,EAAE,IAAI,EAAC,IAAI,GAAG,CACxD;YACA,OAAO,CACJ,CACP,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,KAAK,CAAC,WAAW,GAAG,OAAO,CAAC"}
|
|
@@ -6,7 +6,7 @@ interface NavigationListItemProps extends React.HTMLAttributes<HTMLDivElement>,
|
|
|
6
6
|
selected?: boolean;
|
|
7
7
|
label?: string;
|
|
8
8
|
icon?: React.ComponentType;
|
|
9
|
-
|
|
9
|
+
moreMenu?: React.ReactNode;
|
|
10
10
|
}
|
|
11
11
|
declare const NavigationListItem: React.ForwardRefExoticComponent<NavigationListItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
12
12
|
declare const variantStyles: (props?: ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationList.d.ts","sourceRoot":"","sources":["../../../src/components/NavigationList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,
|
|
1
|
+
{"version":3,"file":"NavigationList.d.ts","sourceRoot":"","sources":["../../../src/components/NavigationList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAqB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AA6B3E,QAAA,MAAM,cAAc,6GASlB,CAAC;AAGH,UAAU,uBACR,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAC1C,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,WAAW,CAAC;IAClD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,QAAA,MAAM,kBAAkB,gGAqEvB,CAAC;AAGF,QAAA,MAAM,aAAa;;mFAUjB,CAAC;AAEH,UAAU,wBACR,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAC1C,YAAY,CAAC,OAAO,aAAa,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,mBAAmB,iGAWvB,CAAC;AAIH,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { __assign, __read, __rest } from "tslib";
|
|
2
2
|
import { cva } from "class-variance-authority";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import {
|
|
5
|
-
import { MoreIcon } from "../icons";
|
|
4
|
+
import { Icon, LinkWrapper } from "../components";
|
|
6
5
|
import { cn } from "../lib/utils";
|
|
7
6
|
var listStyles = cva("s-flex", {
|
|
8
7
|
variants: {
|
|
@@ -28,11 +27,10 @@ var NavigationList = React.forwardRef(function (_a, ref) {
|
|
|
28
27
|
});
|
|
29
28
|
NavigationList.displayName = "NavigationList";
|
|
30
29
|
var NavigationListItem = React.forwardRef(function (_a, ref) {
|
|
31
|
-
var className = _a.className, selected = _a.selected, label = _a.label, icon = _a.icon, href = _a.href, target = _a.target, rel = _a.rel, replace = _a.replace, shallow = _a.shallow, props = __rest(_a, ["className", "selected", "label", "icon", "href", "target", "rel", "replace", "shallow"]);
|
|
32
|
-
var _b = __read(React.useState(false), 2),
|
|
33
|
-
var _c = __read(React.useState(false), 2), isPressed = _c[0], setIsPressed = _c[1];
|
|
30
|
+
var className = _a.className, selected = _a.selected, label = _a.label, icon = _a.icon, href = _a.href, target = _a.target, rel = _a.rel, replace = _a.replace, shallow = _a.shallow, moreMenu = _a.moreMenu, props = __rest(_a, ["className", "selected", "label", "icon", "href", "target", "rel", "replace", "shallow", "moreMenu"]);
|
|
31
|
+
var _b = __read(React.useState(false), 2), isPressed = _b[0], setIsPressed = _b[1];
|
|
34
32
|
var handleMouseDown = function (event) {
|
|
35
|
-
if (!event.target.closest(".
|
|
33
|
+
if (!event.target.closest(".button-class")) {
|
|
36
34
|
setIsPressed(true);
|
|
37
35
|
}
|
|
38
36
|
};
|
|
@@ -40,14 +38,12 @@ var NavigationListItem = React.forwardRef(function (_a, ref) {
|
|
|
40
38
|
React.createElement("div", { className: listStyles({
|
|
41
39
|
layout: "item",
|
|
42
40
|
state: selected ? "selected" : isPressed ? "active" : "unselected",
|
|
43
|
-
}),
|
|
44
|
-
setIsHovered(false);
|
|
41
|
+
}), onMouseLeave: function () {
|
|
45
42
|
setIsPressed(false);
|
|
46
43
|
}, onMouseDown: handleMouseDown, onMouseUp: function () { return setIsPressed(false); } },
|
|
47
44
|
icon && React.createElement(Icon, { visual: icon, size: "sm" }),
|
|
48
45
|
label && (React.createElement("span", { className: "s-grow s-overflow-hidden s-text-ellipsis s-whitespace-nowrap" }, label)),
|
|
49
|
-
|
|
50
|
-
React.createElement(Button, { variant: "ghost", icon: MoreIcon, size: "xs", onClick: function (e) { return e.stopPropagation(); }, onMouseDown: function (e) { return e.stopPropagation(); }, onMouseUp: function (e) { return e.stopPropagation(); } }))))));
|
|
46
|
+
selected && moreMenu && (React.createElement("div", { className: "-s-mr-2 s-flex s-h-4 s-items-center" }, moreMenu)))));
|
|
51
47
|
return (React.createElement(LinkWrapper, { href: href, target: target, rel: rel, replace: replace, shallow: shallow, className: className }, content));
|
|
52
48
|
});
|
|
53
49
|
NavigationListItem.displayName = "NavigationListItem";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationList.js","sourceRoot":"","sources":["../../../src/components/NavigationList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,
|
|
1
|
+
{"version":3,"file":"NavigationList.js","sourceRoot":"","sources":["../../../src/components/NavigationList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,WAAW,EAAoB,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,IAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,EAAE;IAC/B,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,SAAS,EAAE,sCAAsC;YACjD,IAAI,EAAE,EAAE,CACN,4LAA4L,EAC5L,+EAA+E,EAC/E,kDAAkD,CACnD;SACF;QACD,KAAK,EAAE;YACL,MAAM,EAAE,2BAA2B;YACnC,QAAQ,EAAE,oDAAoD;YAC9D,UAAU,EAAE,yBAAyB;SACtC;KACF;IACD,eAAe,EAAE;QACf,MAAM,EAAE,WAAW;QACnB,KAAK,EAAE,YAAY;KACpB;CACF,CAAC,CAAC;AAEH,IAAM,WAAW,GAAG,GAAG,CACrB,+FAA+F,CAChG,CAAC;AAEF,IAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CAGrC,UAAC,EAAuB,EAAE,GAAG;IAA1B,IAAA,SAAS,eAAA,EAAK,KAAK,cAArB,aAAuB,CAAF;IAAY,OAAA,CAClC,sCACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,EAAE,SA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],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,QAAA,MAAM,IAAI;;;CAGoB,CAAC;AAE/B,eAAe,IAAI,CAAC;AAEpB,eAAO,MAAM,YAAY,
|
|
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,yBA8ExB,CAAC"}
|
|
@@ -7,18 +7,18 @@ var meta = {
|
|
|
7
7
|
export default meta;
|
|
8
8
|
export var InputExample = function () { return (React.createElement("div", { className: "s-flex s-flex-col s-gap-20" },
|
|
9
9
|
React.createElement("div", { className: "s-grid s-grid-cols-3 s-gap-4" },
|
|
10
|
-
React.createElement(Input, { placeholder: "placeholder", name: "input" }),
|
|
11
|
-
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value",
|
|
12
|
-
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value",
|
|
13
|
-
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value",
|
|
14
|
-
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "disabled", disabled: true,
|
|
10
|
+
React.createElement(Input, { placeholder: "placeholder", name: "input", message: "Name must be unique", messageStatus: "info" }),
|
|
11
|
+
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value", message: "errored because it's a very long message", messageStatus: "error" }),
|
|
12
|
+
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value", message: "Default message" }),
|
|
13
|
+
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value", message: "errored because it's a very long message", messageStatus: "error" }),
|
|
14
|
+
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "disabled", disabled: true, messageStatus: "error" })),
|
|
15
15
|
React.createElement("div", { className: "s-grid s-grid-cols-3 s-gap-4" },
|
|
16
16
|
React.createElement(Input, { placeholder: "placeholder", name: "input" }),
|
|
17
|
-
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value",
|
|
18
|
-
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value",
|
|
19
|
-
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value",
|
|
20
|
-
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "test",
|
|
17
|
+
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value", message: "errored because it's a very long message", messageStatus: "error" }),
|
|
18
|
+
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value", message: "Default message" }),
|
|
19
|
+
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "value", message: "errored because it's a very long message", messageStatus: "error" }),
|
|
20
|
+
React.createElement(Input, { placeholder: "placeholder", name: "input", value: "test", messageStatus: "error" })),
|
|
21
21
|
React.createElement("div", { className: "s-grid s-grid-cols-3 s-gap-4" },
|
|
22
|
-
React.createElement(Input, { placeholder: "placeholder", name: "input", label: "Firstname",
|
|
23
|
-
React.createElement(Input, { placeholder: "placeholder", name: "input", label: "Lastname",
|
|
22
|
+
React.createElement(Input, { placeholder: "placeholder", name: "input", label: "Firstname", isError: true }),
|
|
23
|
+
React.createElement(Input, { placeholder: "placeholder", name: "input", label: "Lastname", message: "Input your lastname", messageStatus: "info", isError: true })))); };
|
|
24
24
|
//# sourceMappingURL=Input.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.stories.js","sourceRoot":"","sources":["../../../src/stories/Input.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,IAAM,IAAI,GAAG;IACX,KAAK,EAAE,kBAAkB;IACzB,SAAS,EAAE,KAAK;CACY,CAAC;AAE/B,eAAe,IAAI,CAAC;AAEpB,MAAM,CAAC,IAAM,YAAY,GAAG,cAAM,OAAA,CAChC,6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a,EAAC,IAAI,EAAC,OAAO,GAAG;QAChD,oBAAC,KAAK,IACJ,WAAW,EAAC,aAAa,EACzB,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,OAAO,EACb,OAAO,EAAC,0CAA0C,EAClD,aAAa,EAAC,OAAO,GACrB;QACF,oBAAC,KAAK,IACJ,WAAW,EAAC,aAAa,EACzB,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,OAAO,EACb,OAAO,EAAC,iBAAiB,GACzB;QACF,oBAAC,KAAK,IACJ,WAAW,EAAC,aAAa,EACzB,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,OAAO,EACb,OAAO,EAAC,0CAA0C,EAClD,aAAa,EAAC,OAAO,GACrB;QACF,oBAAC,KAAK,IACJ,WAAW,EAAC,aAAa,EACzB,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,MAAM,EACZ,aAAa,EAAC,OAAO,GACrB,CACE;IACN,6BAAK,SAAS,EAAC,8BAA8B;QAC3C,oBAAC,KAAK,IAAC,WAAW,EAAC,aAAa,EAAC,IAAI,EAAC,OAAO,EAAC,KAAK,EAAC,WAAW,EAAC,OAAO,SAAG;QAC1E,oBAAC,KAAK,IACJ,WAAW,EAAC,aAAa,EACzB,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,UAAU,EAChB,OAAO,EAAC,qBAAqB,EAC7B,aAAa,EAAC,MAAM,EACpB,OAAO,SACP,CACE,CACF,CACP,EA9EiC,CA8EjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationList.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/NavigationList.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"NavigationList.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/NavigationList.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAkBnD,QAAA,MAAM,IAAI;;CAEM,CAAC;AAEjB,eAAe,IAAI,CAAC;AAOpB,eAAO,MAAM,qBAAqB,yBA+DjC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __read } from "tslib";
|
|
2
2
|
import React, { useEffect, useState } from "react";
|
|
3
|
-
import { NavigationList, NavigationListItem, NavigationListLabel, ScrollArea, ScrollBar, } from "../index_with_tw_base";
|
|
3
|
+
import { Button, MoreIcon, NavigationList, NavigationListItem, NavigationListLabel, NewDropdownMenu, NewDropdownMenuContent, NewDropdownMenuItem, NewDropdownMenuTrigger, PencilSquareIcon, ScrollArea, ScrollBar, TrashIcon, } from "../index_with_tw_base";
|
|
4
4
|
var meta = {
|
|
5
5
|
title: "Primitives/NavigationList",
|
|
6
6
|
};
|
|
@@ -13,22 +13,25 @@ export var NewNavigationListDemo = function () {
|
|
|
13
13
|
var _a = __read(useState(null), 2), selectedIndex = _a[0], setSelectedIndex = _a[1];
|
|
14
14
|
var _b = __read(useState([]), 2), conversationTitles = _b[0], setConversationTitles = _b[1];
|
|
15
15
|
useEffect(function () {
|
|
16
|
-
// Generate random titles for each date section only once
|
|
17
16
|
setConversationTitles([
|
|
18
17
|
{ label: "Today", items: getRandomTitles(5) },
|
|
19
18
|
{ label: "Yesterday", items: getRandomTitles(10) },
|
|
20
19
|
]);
|
|
21
|
-
console.log(conversationTitles); // Add this line
|
|
22
20
|
}, []);
|
|
23
|
-
// Flatten the items array to easily manage indices
|
|
24
21
|
var allItems = conversationTitles.flatMap(function (section) { return section.items; });
|
|
22
|
+
var getMoreMenu = function (title) { return (React.createElement(NewDropdownMenu, null,
|
|
23
|
+
React.createElement(NewDropdownMenuTrigger, { asChild: true },
|
|
24
|
+
React.createElement(Button, { variant: "ghost", icon: MoreIcon, size: "xs" })),
|
|
25
|
+
React.createElement(NewDropdownMenuContent, null,
|
|
26
|
+
React.createElement(NewDropdownMenuItem, { label: "Rename ".concat(title), icon: PencilSquareIcon, onClick: function (e) { return e.stopPropagation(); } }),
|
|
27
|
+
React.createElement(NewDropdownMenuItem, { label: "Delete", icon: TrashIcon, variant: "warning", onClick: function (e) { return e.stopPropagation(); } })))); };
|
|
25
28
|
return (React.createElement("div", { className: "s-h-[400px] s-w-[200px] s-py-12" },
|
|
26
29
|
React.createElement(ScrollArea, null,
|
|
27
30
|
React.createElement(NavigationList, { className: "s-w-full" }, conversationTitles.map(function (section, sectionIndex) { return (React.createElement(React.Fragment, { key: sectionIndex },
|
|
28
31
|
React.createElement(NavigationListLabel, { label: section.label }),
|
|
29
32
|
section.items.map(function (title, index) {
|
|
30
|
-
var itemIndex = allItems.indexOf(title);
|
|
31
|
-
return (React.createElement(NavigationListItem, { key: index, selected: itemIndex === selectedIndex, onClick: function () { return setSelectedIndex(itemIndex); }, label: title, className: "s-w-full" }));
|
|
33
|
+
var itemIndex = allItems.indexOf(title);
|
|
34
|
+
return (React.createElement(NavigationListItem, { key: index, selected: itemIndex === selectedIndex, onClick: function () { return setSelectedIndex(itemIndex); }, label: title, className: "s-w-full", moreMenu: getMoreMenu(title) }));
|
|
32
35
|
}))); })),
|
|
33
36
|
React.createElement(ScrollBar, null))));
|
|
34
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationList.stories.js","sourceRoot":"","sources":["../../../src/stories/NavigationList.stories.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEnD,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,SAAS,GACV,MAAM,uBAAuB,CAAC;AAE/B,IAAM,IAAI,GAAG;IACX,KAAK,EAAE,2BAA2B;CACpB,CAAC;AAEjB,eAAe,IAAI,CAAC;AAEpB,IAAM,eAAe,GAAG,UAAC,KAAa;IACpC,IAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,cAAM,OAAA,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,EAAn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BAA8B;IAC9B,gCAAgC;IAChC,+BAA+B;IAC/B,uBAAuB;IACvB,2BAA2B;IAC3B,4BAA4B;IAC5B,8BAA8B;IAC9B,2BAA2B;IAC3B,4BAA4B;IAC5B,0BAA0B;IAC1B,yBAAyB;IACzB,2BAA2B;IAC3B,2BAA2B;IAC3B,4BAA4B;IAC5B,0BAA0B;IAC1B,uCAAuC;IACvC,2BAA2B;IAC3B,6BAA6B;IAC7B,4BAA4B;IAC5B,gCAAgC;IAChC,6BAA6B;IAC7B,2BAA2B;IAC3B,iCAAiC;IACjC,2BAA2B;IAC3B,8BAA8B;IAC9B,0BAA0B;IAC1B,+BAA+B;IAC/B,6BAA6B;IAC7B,qCAAqC;IACrC,mCAAmC;IACnC,wBAAwB;IACxB,+BAA+B;IAC/B,0BAA0B;IAC1B,2BAA2B;IAC3B,0BAA0B;IAC1B,qBAAqB;IACrB,gCAAgC;IAChC,qCAAqC;IACrC,kCAAkC;IAClC,iCAAiC;IACjC,4BAA4B;IAC5B,4BAA4B;IAC5B,gCAAgC;IAChC,sCAAsC;IACtC,2BAA2B;IAC3B,uCAAuC;IACvC,2BAA2B;IAC3B,sBAAsB;IACtB,+BAA+B;IAC/B,0BAA0B;IAC1B,8BAA8B;IAC9B,6BAA6B;IAC7B,6BAA6B;IAC7B,0BAA0B;IAC1B,gCAAgC;IAChC,0BAA0B;IAC1B,yBAAyB;IACzB,uBAAuB;IACvB,mCAAmC;IACnC,uBAAuB;IACvB,0BAA0B;IAC1B,6BAA6B;IAC7B,wBAAwB;IACxB,6BAA6B;IAC7B,iCAAiC;IACjC,yBAAyB;IACzB,8BAA8B;IAC9B,0BAA0B;IAC1B,8BAA8B;CAC/B,CAAC"}
|
package/dist/sparkle.css
CHANGED
package/package.json
CHANGED
package/src/components/Input.tsx
CHANGED
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority";
|
|
2
2
|
import React, { forwardRef } from "react";
|
|
3
3
|
|
|
4
|
+
import { Icon } from "@sparkle/components/Icon";
|
|
5
|
+
import { InformationCircleStrokeIcon } from "@sparkle/icons";
|
|
4
6
|
import { cn } from "@sparkle/lib/utils";
|
|
5
7
|
|
|
6
8
|
import { Label } from "./Label";
|
|
7
9
|
|
|
10
|
+
const MESSAGE_STATUS = ["info", "default", "error"] as const;
|
|
11
|
+
|
|
12
|
+
type MessageStatus = (typeof MESSAGE_STATUS)[number];
|
|
13
|
+
|
|
8
14
|
export interface InputProps
|
|
9
15
|
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "value"> {
|
|
10
|
-
|
|
16
|
+
message?: string;
|
|
17
|
+
messageStatus?: MessageStatus;
|
|
11
18
|
value?: string | null;
|
|
12
|
-
|
|
19
|
+
isError?: boolean;
|
|
13
20
|
className?: string;
|
|
14
21
|
label?: string;
|
|
15
22
|
}
|
|
@@ -18,12 +25,28 @@ const INPUT_STATES = ["error", "disabled", "default"];
|
|
|
18
25
|
|
|
19
26
|
type InputStateType = (typeof INPUT_STATES)[number];
|
|
20
27
|
|
|
28
|
+
const messageVariantStyles: Record<MessageStatus, string> = {
|
|
29
|
+
info: "s-text-muted-foreground",
|
|
30
|
+
default: "s-text-muted-foreground",
|
|
31
|
+
error: "s-text-foreground-warning",
|
|
32
|
+
};
|
|
33
|
+
|
|
21
34
|
const stateVariantStyles: Record<InputStateType, string> = {
|
|
22
35
|
default: "focus-visible:s-ring-ring",
|
|
23
36
|
disabled:
|
|
24
37
|
"disabled:s-cursor-not-allowed disabled:s-opacity-50 disabled:s-text-muted-foreground",
|
|
25
38
|
error: "s-border-border-warning focus:s-ring-ring-warning",
|
|
26
39
|
};
|
|
40
|
+
|
|
41
|
+
const messageVariant = cva("", {
|
|
42
|
+
variants: {
|
|
43
|
+
status: messageVariantStyles,
|
|
44
|
+
},
|
|
45
|
+
defaultVariants: {
|
|
46
|
+
status: "info",
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
27
50
|
const inputStyleClasses = cva(
|
|
28
51
|
cn(
|
|
29
52
|
"s-text-sm s-bg-background s-rounded-xl s-border s-border-border-dark s-flex s-h-9 s-w-full s-px-3 s-py-1.5 ",
|
|
@@ -45,18 +68,19 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
|
45
68
|
(
|
|
46
69
|
{
|
|
47
70
|
className,
|
|
48
|
-
|
|
71
|
+
message,
|
|
72
|
+
messageStatus ,
|
|
49
73
|
value,
|
|
50
74
|
label,
|
|
75
|
+
isError,
|
|
51
76
|
disabled,
|
|
52
|
-
showErrorLabel = false,
|
|
53
77
|
...props
|
|
54
78
|
},
|
|
55
79
|
ref
|
|
56
80
|
) => {
|
|
57
|
-
const state =
|
|
81
|
+
const state = isError ? "error" : disabled ? "disabled" : "default";
|
|
58
82
|
return (
|
|
59
|
-
<div className="s-flex s-flex-col s-gap-1
|
|
83
|
+
<div className="s-flex s-flex-col s-gap-1">
|
|
60
84
|
{label && <Label htmlFor={props.name}>{label}</Label>}
|
|
61
85
|
<input
|
|
62
86
|
ref={ref}
|
|
@@ -66,9 +90,17 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
|
66
90
|
disabled={disabled}
|
|
67
91
|
{...props}
|
|
68
92
|
/>
|
|
69
|
-
{
|
|
70
|
-
<div
|
|
71
|
-
{
|
|
93
|
+
{message && (
|
|
94
|
+
<div
|
|
95
|
+
className={cn(
|
|
96
|
+
"s-ml-3.5 s-flex s-items-center s-gap-1 s-text-xs",
|
|
97
|
+
messageVariant({ status: messageStatus })
|
|
98
|
+
)}
|
|
99
|
+
>
|
|
100
|
+
{messageStatus === "info" && (
|
|
101
|
+
<Icon visual={InformationCircleStrokeIcon} size="xs" />
|
|
102
|
+
)}
|
|
103
|
+
{message}
|
|
72
104
|
</div>
|
|
73
105
|
)}
|
|
74
106
|
</div>
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
Icon,
|
|
7
|
-
LinkWrapper,
|
|
8
|
-
LinkWrapperProps,
|
|
9
|
-
} from "@sparkle/components/";
|
|
10
|
-
import { MoreIcon } from "@sparkle/icons";
|
|
4
|
+
import { Icon, LinkWrapper, LinkWrapperProps } from "@sparkle/components/";
|
|
11
5
|
import { cn } from "@sparkle/lib/utils";
|
|
12
6
|
|
|
13
7
|
const listStyles = cva("s-flex", {
|
|
@@ -54,7 +48,7 @@ interface NavigationListItemProps
|
|
|
54
48
|
selected?: boolean;
|
|
55
49
|
label?: string;
|
|
56
50
|
icon?: React.ComponentType;
|
|
57
|
-
|
|
51
|
+
moreMenu?: React.ReactNode;
|
|
58
52
|
}
|
|
59
53
|
|
|
60
54
|
const NavigationListItem = React.forwardRef<
|
|
@@ -72,15 +66,15 @@ const NavigationListItem = React.forwardRef<
|
|
|
72
66
|
rel,
|
|
73
67
|
replace,
|
|
74
68
|
shallow,
|
|
69
|
+
moreMenu,
|
|
75
70
|
...props
|
|
76
71
|
},
|
|
77
72
|
ref
|
|
78
73
|
) => {
|
|
79
|
-
const [isHovered, setIsHovered] = React.useState(false);
|
|
80
74
|
const [isPressed, setIsPressed] = React.useState(false);
|
|
81
75
|
|
|
82
76
|
const handleMouseDown = (event: React.MouseEvent) => {
|
|
83
|
-
if (!(event.target as HTMLElement).closest(".
|
|
77
|
+
if (!(event.target as HTMLElement).closest(".button-class")) {
|
|
84
78
|
setIsPressed(true);
|
|
85
79
|
}
|
|
86
80
|
};
|
|
@@ -92,9 +86,7 @@ const NavigationListItem = React.forwardRef<
|
|
|
92
86
|
layout: "item",
|
|
93
87
|
state: selected ? "selected" : isPressed ? "active" : "unselected",
|
|
94
88
|
})}
|
|
95
|
-
onMouseEnter={() => setIsHovered(true)}
|
|
96
89
|
onMouseLeave={() => {
|
|
97
|
-
setIsHovered(false);
|
|
98
90
|
setIsPressed(false);
|
|
99
91
|
}}
|
|
100
92
|
onMouseDown={handleMouseDown}
|
|
@@ -106,16 +98,9 @@ const NavigationListItem = React.forwardRef<
|
|
|
106
98
|
{label}
|
|
107
99
|
</span>
|
|
108
100
|
)}
|
|
109
|
-
{
|
|
101
|
+
{selected && moreMenu && (
|
|
110
102
|
<div className="-s-mr-2 s-flex s-h-4 s-items-center">
|
|
111
|
-
|
|
112
|
-
variant="ghost"
|
|
113
|
-
icon={MoreIcon}
|
|
114
|
-
size="xs"
|
|
115
|
-
onClick={(e) => e.stopPropagation()}
|
|
116
|
-
onMouseDown={(e) => e.stopPropagation()}
|
|
117
|
-
onMouseUp={(e) => e.stopPropagation()}
|
|
118
|
-
/>
|
|
103
|
+
{moreMenu}
|
|
119
104
|
</div>
|
|
120
105
|
)}
|
|
121
106
|
</div>
|
|
@@ -13,33 +13,38 @@ export default meta;
|
|
|
13
13
|
export const InputExample = () => (
|
|
14
14
|
<div className="s-flex s-flex-col s-gap-20">
|
|
15
15
|
<div className="s-grid s-grid-cols-3 s-gap-4">
|
|
16
|
-
<Input
|
|
16
|
+
<Input
|
|
17
|
+
placeholder="placeholder"
|
|
18
|
+
name="input"
|
|
19
|
+
message="Name must be unique"
|
|
20
|
+
messageStatus="info"
|
|
21
|
+
/>
|
|
17
22
|
<Input
|
|
18
23
|
placeholder="placeholder"
|
|
19
24
|
name="input"
|
|
20
25
|
value="value"
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
message="errored because it's a very long message"
|
|
27
|
+
messageStatus="error"
|
|
23
28
|
/>
|
|
24
29
|
<Input
|
|
25
30
|
placeholder="placeholder"
|
|
26
31
|
name="input"
|
|
27
32
|
value="value"
|
|
28
|
-
|
|
33
|
+
message="Default message"
|
|
29
34
|
/>
|
|
30
35
|
<Input
|
|
31
36
|
placeholder="placeholder"
|
|
32
37
|
name="input"
|
|
33
38
|
value="value"
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
message="errored because it's a very long message"
|
|
40
|
+
messageStatus="error"
|
|
36
41
|
/>
|
|
37
42
|
<Input
|
|
38
43
|
placeholder="placeholder"
|
|
39
44
|
name="input"
|
|
40
45
|
value="disabled"
|
|
41
|
-
disabled
|
|
42
|
-
|
|
46
|
+
disabled
|
|
47
|
+
messageStatus="error"
|
|
43
48
|
/>
|
|
44
49
|
</div>
|
|
45
50
|
<div className="s-grid s-grid-cols-3 s-gap-4">
|
|
@@ -48,41 +53,38 @@ export const InputExample = () => (
|
|
|
48
53
|
placeholder="placeholder"
|
|
49
54
|
name="input"
|
|
50
55
|
value="value"
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
message="errored because it's a very long message"
|
|
57
|
+
messageStatus="error"
|
|
53
58
|
/>
|
|
54
59
|
<Input
|
|
55
60
|
placeholder="placeholder"
|
|
56
61
|
name="input"
|
|
57
62
|
value="value"
|
|
58
|
-
|
|
63
|
+
message="Default message"
|
|
59
64
|
/>
|
|
60
65
|
<Input
|
|
61
66
|
placeholder="placeholder"
|
|
62
67
|
name="input"
|
|
63
68
|
value="value"
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
message="errored because it's a very long message"
|
|
70
|
+
messageStatus="error"
|
|
66
71
|
/>
|
|
67
72
|
<Input
|
|
68
73
|
placeholder="placeholder"
|
|
69
74
|
name="input"
|
|
70
75
|
value="test"
|
|
71
|
-
|
|
76
|
+
messageStatus="error"
|
|
72
77
|
/>
|
|
73
78
|
</div>
|
|
74
79
|
<div className="s-grid s-grid-cols-3 s-gap-4">
|
|
75
|
-
<Input
|
|
76
|
-
placeholder="placeholder"
|
|
77
|
-
name="input"
|
|
78
|
-
label="Firstname"
|
|
79
|
-
showErrorLabel
|
|
80
|
-
/>
|
|
80
|
+
<Input placeholder="placeholder" name="input" label="Firstname" isError />
|
|
81
81
|
<Input
|
|
82
82
|
placeholder="placeholder"
|
|
83
83
|
name="input"
|
|
84
84
|
label="Lastname"
|
|
85
|
-
|
|
85
|
+
message="Input your lastname"
|
|
86
|
+
messageStatus="info"
|
|
87
|
+
isError
|
|
86
88
|
/>
|
|
87
89
|
</div>
|
|
88
90
|
</div>
|