@dust-tt/sparkle 0.5.8 → 0.5.9
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 +7 -7
- package/dist/cjs/index.js.map +4 -4
- package/dist/esm/components/AttachmentChip.d.ts +10 -2
- package/dist/esm/components/AttachmentChip.d.ts.map +1 -1
- package/dist/esm/components/AttachmentChip.js +13 -9
- package/dist/esm/components/AttachmentChip.js.map +1 -1
- package/dist/esm/components/Card.js +1 -1
- package/dist/esm/components/Chip.d.ts +1 -1
- package/dist/esm/components/Chip.d.ts.map +1 -1
- package/dist/esm/stories/AttachmentChip.stories.d.ts +3 -0
- package/dist/esm/stories/AttachmentChip.stories.d.ts.map +1 -1
- package/dist/esm/stories/AttachmentChip.stories.js +39 -6
- package/dist/esm/stories/AttachmentChip.stories.js.map +1 -1
- package/dist/esm/stories/Chip.stories.d.ts +1 -30
- package/dist/esm/stories/Chip.stories.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/AttachmentChip.tsx +62 -23
- package/src/components/Card.tsx +1 -1
- package/src/components/Chip.tsx +1 -1
- package/src/stories/AttachmentChip.stories.tsx +51 -6
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { CHIP_COLORS, CHIP_SIZES } from "./Chip";
|
|
3
|
+
import { DoubleIconProps, IconProps } from "./Icon";
|
|
2
4
|
import { LinkWrapperProps } from "./LinkWrapper";
|
|
5
|
+
type AttachmentChipIconProps = IconProps | DoubleIconProps;
|
|
3
6
|
interface AttachmentChipBaseProps {
|
|
4
7
|
label: string;
|
|
5
|
-
icon?:
|
|
8
|
+
icon?: AttachmentChipIconProps;
|
|
9
|
+
size?: (typeof CHIP_SIZES)[number];
|
|
10
|
+
color?: (typeof CHIP_COLORS)[number];
|
|
6
11
|
className?: string;
|
|
12
|
+
isBusy?: boolean;
|
|
13
|
+
onRemove?: () => void;
|
|
14
|
+
onClick?: () => void;
|
|
7
15
|
}
|
|
8
16
|
type AttachmentChipButtonProps = AttachmentChipBaseProps & {
|
|
9
17
|
href?: never;
|
|
@@ -12,6 +20,6 @@ type AttachmentChipButtonProps = AttachmentChipBaseProps & {
|
|
|
12
20
|
};
|
|
13
21
|
type AttachmentChipLinkProps = AttachmentChipBaseProps & Omit<LinkWrapperProps, "children">;
|
|
14
22
|
type AttachmentChipProps = AttachmentChipButtonProps | AttachmentChipLinkProps;
|
|
15
|
-
export declare function AttachmentChip({ label,
|
|
23
|
+
export declare function AttachmentChip({ icon, className, label, size, color, isBusy, onRemove, onClick, ...linkProps }: AttachmentChipProps): React.JSX.Element;
|
|
16
24
|
export {};
|
|
17
25
|
//# sourceMappingURL=AttachmentChip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentChip.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentChip.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AttachmentChip.d.ts","sourceRoot":"","sources":["../../../src/components/AttachmentChip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAQ,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAc,eAAe,EAAQ,SAAS,EAAE,MAAM,QAAQ,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAQjD,KAAK,uBAAuB,GAAG,SAAS,GAAG,eAAe,CAAC;AAQ3D,UAAU,uBAAuB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,uBAAuB,CAAC;IAC/B,IAAI,CAAC,EAAE,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,KAAK,yBAAyB,GAAG,uBAAuB,GAAG;IACzD,IAAI,CAAC,EAAE,KAAK,CAAC;CACd,GAAG;KACD,CAAC,IAAI,MAAM,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK;CACxD,CAAC;AAEF,KAAK,uBAAuB,GAAG,uBAAuB,GACpD,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC;AAErC,KAAK,mBAAmB,GAAG,yBAAyB,GAAG,uBAAuB,CAAC;AAE/E,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,SAAS,EACT,KAAK,EACL,IAAI,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,OAAO,EACP,GAAG,SAAS,EACb,EAAE,mBAAmB,qBAsCrB"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import { cva } from "class-variance-authority";
|
|
3
2
|
import React from "react";
|
|
4
3
|
import { cn } from "../lib/utils";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
const
|
|
4
|
+
import { Chip } from "./Chip";
|
|
5
|
+
import { DoubleIcon, Icon } from "./Icon";
|
|
6
|
+
const attachmentChipOverrides = cn("s-rounded-lg s-px-2 s-py-1 s-heading-sm s-gap-1.5", "s-bg-background s-text-foreground s-max-w-44", "dark:s-bg-background-night dark:s-text-foreground-night");
|
|
7
|
+
function isDoubleIconProps(props) {
|
|
8
|
+
return "mainIcon" in props;
|
|
9
|
+
}
|
|
8
10
|
export function AttachmentChip(_a) {
|
|
9
|
-
var { label,
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
var { icon, className, label, size, color, isBusy, onRemove, onClick } = _a, linkProps = __rest(_a, ["icon", "className", "label", "size", "color", "isBusy", "onRemove", "onClick"]);
|
|
12
|
+
const iconElement = icon && (React.createElement("div", { className: "s-shrink-0" }, isDoubleIconProps(icon) ? React.createElement(DoubleIcon, Object.assign({}, icon)) : React.createElement(Icon, Object.assign({}, icon))));
|
|
13
|
+
const chipClassName = cn(attachmentChipOverrides, className);
|
|
14
|
+
if ("href" in linkProps && linkProps.href) {
|
|
15
|
+
return (React.createElement(Chip, Object.assign({ className: chipClassName, label: label, size: size, color: color, isBusy: isBusy, onRemove: onRemove }, linkProps), iconElement));
|
|
16
|
+
}
|
|
17
|
+
return (React.createElement(Chip, { className: chipClassName, label: label, size: size, color: color, isBusy: isBusy, onRemove: onRemove, onClick: onClick }, iconElement));
|
|
14
18
|
}
|
|
15
19
|
//# sourceMappingURL=AttachmentChip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentChip.js","sourceRoot":"","sources":["../../../src/components/AttachmentChip.tsx"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AttachmentChip.js","sourceRoot":"","sources":["../../../src/components/AttachmentChip.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,IAAI,EAA2B,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,UAAU,EAAmB,IAAI,EAAa,MAAM,QAAQ,CAAC;AAGtE,MAAM,uBAAuB,GAAG,EAAE,CAChC,mDAAmD,EACnD,8CAA8C,EAC9C,yDAAyD,CAC1D,CAAC;AAIF,SAAS,iBAAiB,CACxB,KAA8B,EACJ;IAC1B,OAAO,UAAU,IAAI,KAAK,CAAC;AAAA,CAC5B;AAwBD,MAAM,UAAU,cAAc,CAAC,EAUT,EAAE;QAVO,EAC7B,IAAI,EACJ,SAAS,EACT,KAAK,EACL,IAAI,EACJ,KAAK,EACL,MAAM,EACN,QAAQ,EACR,OAAO,OAEa,EADjB,SAAS,cATiB,gFAU9B,CADa;IAEZ,MAAM,WAAW,GAAG,IAAI,IAAI,CAC1B,6BAAK,SAAS,EAAC,YAAY,IACxB,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,oBAAC,UAAU,oBAAK,IAAI,EAAI,CAAC,CAAC,CAAC,oBAAC,IAAI,oBAAK,IAAI,EAAI,CACpE,CACP,CAAC;IAEF,MAAM,aAAa,GAAG,EAAE,CAAC,uBAAuB,EAAE,SAAS,CAAC,CAAC;IAE7D,IAAI,MAAM,IAAI,SAAS,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC;QAC1C,OAAO,CACL,oBAAC,IAAI,kBACH,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,IACd,SAAS,GAEZ,WAAW,CACP,CACR,CAAC;IACJ,CAAC;IAED,OAAO,CACL,oBAAC,IAAI,IACH,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,IAEf,WAAW,CACP,CACR,CAAC;AAAA,CACH"}
|
|
@@ -56,7 +56,7 @@ export const Card = React.forwardRef((_a, ref) => {
|
|
|
56
56
|
Card.displayName = "Card";
|
|
57
57
|
const CardActions = React.forwardRef((_a, ref) => {
|
|
58
58
|
var { children } = _a, props = __rest(_a, ["children"]);
|
|
59
|
-
return (React.createElement("div", Object.assign({ ref: ref, className: cn("s-absolute s-right-2 s-top-2 sm:s-opacity-0
|
|
59
|
+
return (React.createElement("div", Object.assign({ ref: ref, className: cn("s-absolute s-right-2 s-top-2 s-transition-opacity sm:s-opacity-0", "group-focus-within/card:s-opacity-100 group-hover/card:s-opacity-100") }, props), children));
|
|
60
60
|
});
|
|
61
61
|
CardActions.displayName = "CardActions";
|
|
62
62
|
export const CardActionButton = React.forwardRef((_a, ref) => {
|
|
@@ -22,7 +22,7 @@ type ChipButtonProps = ChipBaseProps & {
|
|
|
22
22
|
type ChipLinkProps = ChipBaseProps & Omit<LinkWrapperProps, "children"> & {
|
|
23
23
|
onClick?: never;
|
|
24
24
|
};
|
|
25
|
-
type ChipProps = ChipLinkProps | ChipButtonProps;
|
|
25
|
+
export type ChipProps = ChipLinkProps | ChipButtonProps;
|
|
26
26
|
declare const Chip: React.ForwardRefExoticComponent<ChipProps & React.RefAttributes<HTMLDivElement>>;
|
|
27
27
|
export { Chip };
|
|
28
28
|
//# sourceMappingURL=Chip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../../src/components/Chip.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAExD,OAAO,EAGL,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAM9B,eAAO,MAAM,UAAU,+BAAgC,CAAC;AAExD,KAAK,YAAY,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhD,eAAO,MAAM,WAAW,oGAUd,CAAC;AAEX,KAAK,aAAa,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AA+GlD,KAAK,aAAa,GAAG;IACnB,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB,CA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UAAU,CAAC,CAAC,CAAC,EAAE,KAAK;CACxD,CAAC;AAEF,KAAK,aAAa,GAAG,aAAa,GAChC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG;IACnC,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,CAAC;AAEJ,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,eAAe,CAAC;AAOxD,QAAA,MAAM,IAAI,kFAoFT,CAAC;AAIF,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -14,4 +14,7 @@ export declare const Document: Story;
|
|
|
14
14
|
export declare const Image: Story;
|
|
15
15
|
export declare const Text: Story;
|
|
16
16
|
export declare const LongLabel: Story;
|
|
17
|
+
export declare const WithDoubleIcon: Story;
|
|
18
|
+
export declare const WithDoubleIconAndLink: Story;
|
|
19
|
+
export declare const WithChipColor: Story;
|
|
17
20
|
//# sourceMappingURL=AttachmentChip.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentChip.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/AttachmentChip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD,QAAA,MAAM,IAAI;;;;;;;CAO6B,CAAC;AAExC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAWnC,eAAO,MAAM,QAAQ,EAAE,KAYtB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAYnB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAYlB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAYvB,CAAC"}
|
|
1
|
+
{"version":3,"file":"AttachmentChip.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/AttachmentChip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD,QAAA,MAAM,IAAI;;;;;;;CAO6B,CAAC;AAExC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAWnC,eAAO,MAAM,QAAQ,EAAE,KAYtB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAYnB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAYlB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAYvB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAY5B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,KAcnC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAa3B,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { AttachmentChip } from "../components";
|
|
3
|
-
import { DocumentIcon, DocumentTextIcon } from "../icons/app";
|
|
4
|
-
import { NotionLogo } from "../logo";
|
|
3
|
+
import { DocumentIcon, DocumentTextIcon, FolderIcon } from "../icons/app";
|
|
4
|
+
import { DriveLogo, NotionLogo } from "../logo";
|
|
5
5
|
const meta = {
|
|
6
6
|
title: "Components/AttachmentChip",
|
|
7
7
|
component: AttachmentChip,
|
|
@@ -20,7 +20,7 @@ const ParagraphWrapper = ({ children }) => (React.createElement("div", { classNa
|
|
|
20
20
|
export const Document = {
|
|
21
21
|
args: {
|
|
22
22
|
label: "document.pdf",
|
|
23
|
-
icon: NotionLogo,
|
|
23
|
+
icon: { visual: NotionLogo },
|
|
24
24
|
},
|
|
25
25
|
decorators: [
|
|
26
26
|
(Story) => (React.createElement(ParagraphWrapper, null,
|
|
@@ -30,7 +30,7 @@ export const Document = {
|
|
|
30
30
|
export const Image = {
|
|
31
31
|
args: {
|
|
32
32
|
label: "image.jpg",
|
|
33
|
-
icon: NotionLogo,
|
|
33
|
+
icon: { visual: NotionLogo },
|
|
34
34
|
},
|
|
35
35
|
decorators: [
|
|
36
36
|
(Story) => (React.createElement(ParagraphWrapper, null,
|
|
@@ -40,7 +40,7 @@ export const Image = {
|
|
|
40
40
|
export const Text = {
|
|
41
41
|
args: {
|
|
42
42
|
label: "text.txt",
|
|
43
|
-
icon: DocumentTextIcon,
|
|
43
|
+
icon: { visual: DocumentTextIcon },
|
|
44
44
|
},
|
|
45
45
|
decorators: [
|
|
46
46
|
(Story) => (React.createElement(ParagraphWrapper, null,
|
|
@@ -50,7 +50,40 @@ export const Text = {
|
|
|
50
50
|
export const LongLabel = {
|
|
51
51
|
args: {
|
|
52
52
|
label: "very_long_document_name_that_will_be_truncated.pdf",
|
|
53
|
-
icon: DocumentIcon,
|
|
53
|
+
icon: { visual: DocumentIcon },
|
|
54
|
+
},
|
|
55
|
+
decorators: [
|
|
56
|
+
(Story) => (React.createElement(ParagraphWrapper, null,
|
|
57
|
+
React.createElement(Story, null))),
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
export const WithDoubleIcon = {
|
|
61
|
+
args: {
|
|
62
|
+
label: "My Drive Folder",
|
|
63
|
+
icon: { mainIcon: FolderIcon, secondaryIcon: DriveLogo, size: "sm" },
|
|
64
|
+
},
|
|
65
|
+
decorators: [
|
|
66
|
+
(Story) => (React.createElement(ParagraphWrapper, null,
|
|
67
|
+
React.createElement(Story, null))),
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
export const WithDoubleIconAndLink = {
|
|
71
|
+
args: {
|
|
72
|
+
label: "Notion Document",
|
|
73
|
+
icon: { mainIcon: DocumentIcon, secondaryIcon: NotionLogo, size: "sm" },
|
|
74
|
+
href: "https://notion.so",
|
|
75
|
+
target: "_blank",
|
|
76
|
+
},
|
|
77
|
+
decorators: [
|
|
78
|
+
(Story) => (React.createElement(ParagraphWrapper, null,
|
|
79
|
+
React.createElement(Story, null))),
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
export const WithChipColor = {
|
|
83
|
+
args: {
|
|
84
|
+
label: "Success chip",
|
|
85
|
+
icon: { visual: DocumentIcon },
|
|
86
|
+
color: "success",
|
|
54
87
|
},
|
|
55
88
|
decorators: [
|
|
56
89
|
(Story) => (React.createElement(ParagraphWrapper, null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttachmentChip.stories.js","sourceRoot":"","sources":["../../../src/stories/AttachmentChip.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"AttachmentChip.stories.js","sourceRoot":"","sources":["../../../src/stories/AttachmentChip.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,2BAA2B;IAClC,SAAS,EAAE,cAAc;IACzB,UAAU,EAAE;QACV,MAAM,EAAE,UAAU;KACnB;IACD,IAAI,EAAE,CAAC,UAAU,CAAC;CACmB,CAAC;AAExC,eAAe,IAAI,CAAC;AAGpB,MAAM,gBAAgB,GAAG,CAAC,EAAE,QAAQ,EAAiC,EAAE,EAAE,CAAC,CACxE,6BAAK,SAAS,EAAC,gDAAgD;IAC7D,2BAAG,SAAS,EAAC,6CAA6C;QACxD,8BAAM,SAAS,EAAC,kCAAkC,aAAc;;QACjD,QAAQ;oBACrB,CACA,CACP,CAAC;AAEF,MAAM,CAAC,MAAM,QAA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AE,EAAE,CAAC,CACT,oBAAC,gBAAgB;YACf,oBAAC,KAAK,OAAG,CACQ,CACpB;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAU;IAC1C,IAAI,EAAE;QACJ,KAAK,EAAE,iBAAiB;QACxB,IAAI,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE;QACvE,IAAI,EAAE,mBAAmB;QACzB,MAAM,EAAE,QAAQ;KACjB;IACD,UAAU,EAAE;QACV,CAAC,KAAK,EAAE,EAAE,CAAC,CACT,oBAAC,gBAAgB;YACf,oBAAC,KAAK,OAAG,CACQ,CACpB;KACF;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAU;IAClC,IAAI,EAAE;QACJ,KAAK,EAAE,cAAc;QACrB,IAAI,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE;QAC9B,KAAK,EAAE,SAAS;KACjB;IACD,UAAU,EAAE;QACV,CAAC,KAAK,EAAE,EAAE,CAAC,CACT,oBAAC,gBAAgB;YACf,oBAAC,KAAK,OAAG,CACQ,CACpB;KACF;CACF,CAAC"}
|
|
@@ -2,36 +2,7 @@ import type { StoryObj } from "@storybook/react";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: React.ForwardRefExoticComponent<(
|
|
6
|
-
size?: "mini" | "sm" | "xs" | undefined;
|
|
7
|
-
color?: "blue" | "golden" | "green" | "highlight" | "info" | "primary" | "rose" | "success" | "warning" | undefined;
|
|
8
|
-
label?: string | undefined;
|
|
9
|
-
children?: React.ReactNode;
|
|
10
|
-
className?: string | undefined;
|
|
11
|
-
isBusy?: boolean | undefined;
|
|
12
|
-
icon?: React.ComponentType | undefined;
|
|
13
|
-
onRemove?: (() => void) | undefined;
|
|
14
|
-
} & {
|
|
15
|
-
onClick?: (() => void) | undefined;
|
|
16
|
-
} & {
|
|
17
|
-
href?: undefined;
|
|
18
|
-
rel?: undefined;
|
|
19
|
-
replace?: undefined;
|
|
20
|
-
shallow?: undefined;
|
|
21
|
-
target?: undefined;
|
|
22
|
-
prefetch?: undefined;
|
|
23
|
-
}) | ({
|
|
24
|
-
size?: "mini" | "sm" | "xs" | undefined;
|
|
25
|
-
color?: "blue" | "golden" | "green" | "highlight" | "info" | "primary" | "rose" | "success" | "warning" | undefined;
|
|
26
|
-
label?: string | undefined;
|
|
27
|
-
children?: React.ReactNode;
|
|
28
|
-
className?: string | undefined;
|
|
29
|
-
isBusy?: boolean | undefined;
|
|
30
|
-
icon?: React.ComponentType | undefined;
|
|
31
|
-
onRemove?: (() => void) | undefined;
|
|
32
|
-
} & Omit<import("../components").LinkWrapperProps, "children"> & {
|
|
33
|
-
onClick?: undefined;
|
|
34
|
-
})) & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
component: React.ForwardRefExoticComponent<import("../components/Chip").ChipProps & React.RefAttributes<HTMLDivElement>>;
|
|
35
6
|
tags: string[];
|
|
36
7
|
parameters: {
|
|
37
8
|
layout: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/Chip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,QAAA,MAAM,IAAI
|
|
1
|
+
{"version":3,"file":"Chip.stories.d.ts","sourceRoot":"","sources":["../../../src/stories/Chip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCmB,CAAC;AAE9B,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAGnC,eAAO,MAAM,KAAK,EAAE,KAQnB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAQtB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAS1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAuB3B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAsFvB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
|
-
import { cva } from "class-variance-authority";
|
|
2
1
|
import React from "react";
|
|
3
2
|
|
|
4
3
|
import { cn } from "@sparkle/lib/utils";
|
|
5
4
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"s-text-foreground dark:s-text-foreground-night",
|
|
15
|
-
"s-max-w-44"
|
|
16
|
-
)
|
|
5
|
+
import { Chip, CHIP_COLORS, CHIP_SIZES } from "./Chip";
|
|
6
|
+
import { DoubleIcon, DoubleIconProps, Icon, IconProps } from "./Icon";
|
|
7
|
+
import { LinkWrapperProps } from "./LinkWrapper";
|
|
8
|
+
|
|
9
|
+
const attachmentChipOverrides = cn(
|
|
10
|
+
"s-rounded-lg s-px-2 s-py-1 s-heading-sm s-gap-1.5",
|
|
11
|
+
"s-bg-background s-text-foreground s-max-w-44",
|
|
12
|
+
"dark:s-bg-background-night dark:s-text-foreground-night"
|
|
17
13
|
);
|
|
18
14
|
|
|
15
|
+
type AttachmentChipIconProps = IconProps | DoubleIconProps;
|
|
16
|
+
|
|
17
|
+
function isDoubleIconProps(
|
|
18
|
+
props: AttachmentChipIconProps
|
|
19
|
+
): props is DoubleIconProps {
|
|
20
|
+
return "mainIcon" in props;
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
interface AttachmentChipBaseProps {
|
|
20
24
|
label: string;
|
|
21
|
-
icon?:
|
|
25
|
+
icon?: AttachmentChipIconProps;
|
|
26
|
+
size?: (typeof CHIP_SIZES)[number];
|
|
27
|
+
color?: (typeof CHIP_COLORS)[number];
|
|
22
28
|
className?: string;
|
|
29
|
+
isBusy?: boolean;
|
|
30
|
+
onRemove?: () => void;
|
|
31
|
+
onClick?: () => void;
|
|
23
32
|
}
|
|
24
33
|
|
|
25
34
|
type AttachmentChipButtonProps = AttachmentChipBaseProps & {
|
|
@@ -34,21 +43,51 @@ type AttachmentChipLinkProps = AttachmentChipBaseProps &
|
|
|
34
43
|
type AttachmentChipProps = AttachmentChipButtonProps | AttachmentChipLinkProps;
|
|
35
44
|
|
|
36
45
|
export function AttachmentChip({
|
|
37
|
-
label,
|
|
38
46
|
icon,
|
|
39
47
|
className,
|
|
40
|
-
|
|
48
|
+
label,
|
|
49
|
+
size,
|
|
50
|
+
color,
|
|
51
|
+
isBusy,
|
|
52
|
+
onRemove,
|
|
53
|
+
onClick,
|
|
54
|
+
...linkProps
|
|
41
55
|
}: AttachmentChipProps) {
|
|
42
|
-
const
|
|
43
|
-
<div className=
|
|
44
|
-
<
|
|
45
|
-
<span className="s-pointer s-grow s-truncate">{label}</span>
|
|
56
|
+
const iconElement = icon && (
|
|
57
|
+
<div className="s-shrink-0">
|
|
58
|
+
{isDoubleIconProps(icon) ? <DoubleIcon {...icon} /> : <Icon {...icon} />}
|
|
46
59
|
</div>
|
|
47
60
|
);
|
|
48
61
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
|
|
62
|
+
const chipClassName = cn(attachmentChipOverrides, className);
|
|
63
|
+
|
|
64
|
+
if ("href" in linkProps && linkProps.href) {
|
|
65
|
+
return (
|
|
66
|
+
<Chip
|
|
67
|
+
className={chipClassName}
|
|
68
|
+
label={label}
|
|
69
|
+
size={size}
|
|
70
|
+
color={color}
|
|
71
|
+
isBusy={isBusy}
|
|
72
|
+
onRemove={onRemove}
|
|
73
|
+
{...linkProps}
|
|
74
|
+
>
|
|
75
|
+
{iconElement}
|
|
76
|
+
</Chip>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Chip
|
|
82
|
+
className={chipClassName}
|
|
83
|
+
label={label}
|
|
84
|
+
size={size}
|
|
85
|
+
color={color}
|
|
86
|
+
isBusy={isBusy}
|
|
87
|
+
onRemove={onRemove}
|
|
88
|
+
onClick={onClick}
|
|
89
|
+
>
|
|
90
|
+
{iconElement}
|
|
91
|
+
</Chip>
|
|
53
92
|
);
|
|
54
93
|
}
|
package/src/components/Card.tsx
CHANGED
|
@@ -212,7 +212,7 @@ const CardActions = React.forwardRef<
|
|
|
212
212
|
<div
|
|
213
213
|
ref={ref}
|
|
214
214
|
className={cn(
|
|
215
|
-
"s-absolute s-right-2 s-top-2 sm:s-opacity-0
|
|
215
|
+
"s-absolute s-right-2 s-top-2 s-transition-opacity sm:s-opacity-0",
|
|
216
216
|
"group-focus-within/card:s-opacity-100 group-hover/card:s-opacity-100"
|
|
217
217
|
)}
|
|
218
218
|
{...props}
|
package/src/components/Chip.tsx
CHANGED
|
@@ -160,7 +160,7 @@ type ChipLinkProps = ChipBaseProps &
|
|
|
160
160
|
onClick?: never;
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
type ChipProps = ChipLinkProps | ChipButtonProps;
|
|
163
|
+
export type ChipProps = ChipLinkProps | ChipButtonProps;
|
|
164
164
|
|
|
165
165
|
// TODO(yuka: 1606): we should update this component so that you cannot have both
|
|
166
166
|
// onClick and onRemove at the same time. We should use div when there is no onClick,
|
|
@@ -2,8 +2,8 @@ import type { Meta, StoryObj } from "@storybook/react";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
|
|
4
4
|
import { AttachmentChip } from "@sparkle/components";
|
|
5
|
-
import { DocumentIcon, DocumentTextIcon } from "@sparkle/icons/app";
|
|
6
|
-
import { NotionLogo } from "@sparkle/logo";
|
|
5
|
+
import { DocumentIcon, DocumentTextIcon, FolderIcon } from "@sparkle/icons/app";
|
|
6
|
+
import { DriveLogo, NotionLogo } from "@sparkle/logo";
|
|
7
7
|
|
|
8
8
|
const meta = {
|
|
9
9
|
title: "Components/AttachmentChip",
|
|
@@ -29,7 +29,7 @@ const ParagraphWrapper = ({ children }: { children: React.ReactNode }) => (
|
|
|
29
29
|
export const Document: Story = {
|
|
30
30
|
args: {
|
|
31
31
|
label: "document.pdf",
|
|
32
|
-
icon: NotionLogo,
|
|
32
|
+
icon: { visual: NotionLogo },
|
|
33
33
|
},
|
|
34
34
|
decorators: [
|
|
35
35
|
(Story) => (
|
|
@@ -43,7 +43,7 @@ export const Document: Story = {
|
|
|
43
43
|
export const Image: Story = {
|
|
44
44
|
args: {
|
|
45
45
|
label: "image.jpg",
|
|
46
|
-
icon: NotionLogo,
|
|
46
|
+
icon: { visual: NotionLogo },
|
|
47
47
|
},
|
|
48
48
|
decorators: [
|
|
49
49
|
(Story) => (
|
|
@@ -57,7 +57,7 @@ export const Image: Story = {
|
|
|
57
57
|
export const Text: Story = {
|
|
58
58
|
args: {
|
|
59
59
|
label: "text.txt",
|
|
60
|
-
icon: DocumentTextIcon,
|
|
60
|
+
icon: { visual: DocumentTextIcon },
|
|
61
61
|
},
|
|
62
62
|
decorators: [
|
|
63
63
|
(Story) => (
|
|
@@ -71,7 +71,52 @@ export const Text: Story = {
|
|
|
71
71
|
export const LongLabel: Story = {
|
|
72
72
|
args: {
|
|
73
73
|
label: "very_long_document_name_that_will_be_truncated.pdf",
|
|
74
|
-
icon: DocumentIcon,
|
|
74
|
+
icon: { visual: DocumentIcon },
|
|
75
|
+
},
|
|
76
|
+
decorators: [
|
|
77
|
+
(Story) => (
|
|
78
|
+
<ParagraphWrapper>
|
|
79
|
+
<Story />
|
|
80
|
+
</ParagraphWrapper>
|
|
81
|
+
),
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const WithDoubleIcon: Story = {
|
|
86
|
+
args: {
|
|
87
|
+
label: "My Drive Folder",
|
|
88
|
+
icon: { mainIcon: FolderIcon, secondaryIcon: DriveLogo, size: "sm" },
|
|
89
|
+
},
|
|
90
|
+
decorators: [
|
|
91
|
+
(Story) => (
|
|
92
|
+
<ParagraphWrapper>
|
|
93
|
+
<Story />
|
|
94
|
+
</ParagraphWrapper>
|
|
95
|
+
),
|
|
96
|
+
],
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const WithDoubleIconAndLink: Story = {
|
|
100
|
+
args: {
|
|
101
|
+
label: "Notion Document",
|
|
102
|
+
icon: { mainIcon: DocumentIcon, secondaryIcon: NotionLogo, size: "sm" },
|
|
103
|
+
href: "https://notion.so",
|
|
104
|
+
target: "_blank",
|
|
105
|
+
},
|
|
106
|
+
decorators: [
|
|
107
|
+
(Story) => (
|
|
108
|
+
<ParagraphWrapper>
|
|
109
|
+
<Story />
|
|
110
|
+
</ParagraphWrapper>
|
|
111
|
+
),
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const WithChipColor: Story = {
|
|
116
|
+
args: {
|
|
117
|
+
label: "Success chip",
|
|
118
|
+
icon: { visual: DocumentIcon },
|
|
119
|
+
color: "success",
|
|
75
120
|
},
|
|
76
121
|
decorators: [
|
|
77
122
|
(Story) => (
|