@handled-ai/design-system 0.18.30 → 0.18.32
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/components/badge.d.ts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/pill.d.ts +1 -1
- package/dist/components/related-record-action-card.d.ts +19 -0
- package/dist/components/related-record-action-card.js +150 -0
- package/dist/components/related-record-action-card.js.map +1 -0
- package/dist/components/tabs.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/__tests__/related-record-action-card.test.tsx +123 -0
- package/src/components/related-record-action-card.tsx +169 -0
- package/src/index.ts +1 -0
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { VariantProps } from 'class-variance-authority';
|
|
4
4
|
|
|
5
5
|
declare const badgeVariants: (props?: ({
|
|
6
|
-
variant?: "default" | "secondary" | "destructive" | "outline" | "ghost" |
|
|
6
|
+
variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
|
|
7
7
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
8
8
|
declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
|
|
9
9
|
asChild?: boolean;
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { VariantProps } from 'class-variance-authority';
|
|
4
4
|
|
|
5
5
|
declare const buttonVariants: (props?: ({
|
|
6
|
-
variant?: "default" | "secondary" | "destructive" | "outline" | "ghost" |
|
|
6
|
+
variant?: "link" | "default" | "secondary" | "destructive" | "outline" | "ghost" | null | undefined;
|
|
7
7
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
8
8
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
9
9
|
declare function Button({ className, variant, size, asChild, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
|
@@ -12,7 +12,7 @@ import { VariantProps } from 'class-variance-authority';
|
|
|
12
12
|
*/
|
|
13
13
|
type PillStatus = "success" | "warning" | "error" | "neutral" | "info";
|
|
14
14
|
declare const pillVariants: (props?: ({
|
|
15
|
-
variant?: "default" | "secondary" | "destructive" | "outline" | "ghost" | "
|
|
15
|
+
variant?: "error" | "default" | "secondary" | "destructive" | "outline" | "ghost" | "neutral" | "info" | "success" | "warning" | null | undefined;
|
|
16
16
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
17
17
|
interface PillProps extends React.ComponentProps<"span">, VariantProps<typeof pillVariants> {
|
|
18
18
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type RelatedRecordActionCardKind = "case" | "account" | "opportunity" | "salesforce" | "generic";
|
|
4
|
+
type RelatedRecordActionIcon = "salesforce" | React.ReactNode;
|
|
5
|
+
interface RelatedRecordActionCardProps {
|
|
6
|
+
kind: RelatedRecordActionCardKind;
|
|
7
|
+
label: string;
|
|
8
|
+
subtitle?: string;
|
|
9
|
+
disabledReason?: string;
|
|
10
|
+
href?: string;
|
|
11
|
+
external?: boolean;
|
|
12
|
+
icon?: RelatedRecordActionIcon;
|
|
13
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
14
|
+
className?: string;
|
|
15
|
+
testId?: string;
|
|
16
|
+
}
|
|
17
|
+
declare function RelatedRecordActionCard({ kind, label, subtitle, disabledReason, href, external, icon, onClick, className, testId, }: RelatedRecordActionCardProps): React.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { RelatedRecordActionCard, type RelatedRecordActionCardKind, type RelatedRecordActionCardProps, type RelatedRecordActionIcon };
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { ExternalLink } from "lucide-react";
|
|
6
|
+
import { BRAND_ICONS } from "../lib/icons.js";
|
|
7
|
+
import { cn } from "../lib/utils.js";
|
|
8
|
+
function renderActionIcon(icon, kind) {
|
|
9
|
+
if (icon === "salesforce" || kind === "salesforce") {
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
"img",
|
|
12
|
+
{
|
|
13
|
+
src: BRAND_ICONS.salesforce,
|
|
14
|
+
alt: "Salesforce",
|
|
15
|
+
className: "h-4 w-4 object-contain",
|
|
16
|
+
draggable: false
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
if (icon) {
|
|
21
|
+
return icon;
|
|
22
|
+
}
|
|
23
|
+
return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: kind.slice(0, 1).toUpperCase() });
|
|
24
|
+
}
|
|
25
|
+
function RelatedRecordActionCard({
|
|
26
|
+
kind,
|
|
27
|
+
label,
|
|
28
|
+
subtitle,
|
|
29
|
+
disabledReason,
|
|
30
|
+
href,
|
|
31
|
+
external,
|
|
32
|
+
icon,
|
|
33
|
+
onClick,
|
|
34
|
+
className,
|
|
35
|
+
testId
|
|
36
|
+
}) {
|
|
37
|
+
const isDisabled = Boolean(disabledReason) || !href && !onClick;
|
|
38
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
39
|
+
/* @__PURE__ */ jsx(
|
|
40
|
+
"span",
|
|
41
|
+
{
|
|
42
|
+
"data-slot": "related-record-action-card-icon",
|
|
43
|
+
className: cn(
|
|
44
|
+
"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border text-xs font-semibold transition-colors",
|
|
45
|
+
isDisabled ? "border-border/60 bg-muted/40 text-muted-foreground" : "border-border bg-muted/30 text-muted-foreground group-hover:bg-muted/60 group-active:text-primary"
|
|
46
|
+
),
|
|
47
|
+
children: renderActionIcon(icon, kind)
|
|
48
|
+
}
|
|
49
|
+
),
|
|
50
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
"span",
|
|
53
|
+
{
|
|
54
|
+
"data-slot": "related-record-action-card-label",
|
|
55
|
+
className: cn(
|
|
56
|
+
"block truncate text-sm font-medium transition-colors",
|
|
57
|
+
isDisabled ? "text-muted-foreground" : "text-foreground group-active:text-primary"
|
|
58
|
+
),
|
|
59
|
+
children: label
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
subtitle && /* @__PURE__ */ jsx(
|
|
63
|
+
"span",
|
|
64
|
+
{
|
|
65
|
+
"data-slot": "related-record-action-card-subtitle",
|
|
66
|
+
className: "mt-0.5 block truncate text-xs text-muted-foreground",
|
|
67
|
+
children: subtitle
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
disabledReason && /* @__PURE__ */ jsx(
|
|
71
|
+
"span",
|
|
72
|
+
{
|
|
73
|
+
"data-slot": "related-record-action-card-disabled-reason",
|
|
74
|
+
className: "mt-1 block text-xs text-muted-foreground",
|
|
75
|
+
children: disabledReason
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
] }),
|
|
79
|
+
external && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
80
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "opens in a new tab" }),
|
|
81
|
+
/* @__PURE__ */ jsx(
|
|
82
|
+
ExternalLink,
|
|
83
|
+
{
|
|
84
|
+
"aria-hidden": "true",
|
|
85
|
+
"data-slot": "related-record-action-card-external-icon",
|
|
86
|
+
className: cn(
|
|
87
|
+
"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-colors",
|
|
88
|
+
isDisabled ? "" : "group-active:text-primary"
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
)
|
|
92
|
+
] })
|
|
93
|
+
] });
|
|
94
|
+
if (isDisabled) {
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
"aria-disabled": "true",
|
|
99
|
+
"data-kind": kind,
|
|
100
|
+
"data-slot": "related-record-action-card",
|
|
101
|
+
"data-testid": testId,
|
|
102
|
+
className: cn(
|
|
103
|
+
"group flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-colors",
|
|
104
|
+
"cursor-not-allowed border-border/60 bg-muted/20 text-muted-foreground opacity-70",
|
|
105
|
+
className
|
|
106
|
+
),
|
|
107
|
+
children: content
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
if (href) {
|
|
112
|
+
return /* @__PURE__ */ jsx(
|
|
113
|
+
"a",
|
|
114
|
+
{
|
|
115
|
+
href,
|
|
116
|
+
target: external ? "_blank" : void 0,
|
|
117
|
+
rel: external ? "noopener noreferrer" : void 0,
|
|
118
|
+
"data-kind": kind,
|
|
119
|
+
"data-slot": "related-record-action-card",
|
|
120
|
+
"data-testid": testId,
|
|
121
|
+
className: cn(
|
|
122
|
+
"group flex w-full items-center gap-3 rounded-lg border border-border bg-background px-3 py-2 text-left transition-colors",
|
|
123
|
+
"cursor-pointer hover:bg-muted/50 hover:border-border/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:text-primary",
|
|
124
|
+
className
|
|
125
|
+
),
|
|
126
|
+
children: content
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
return /* @__PURE__ */ jsx(
|
|
131
|
+
"button",
|
|
132
|
+
{
|
|
133
|
+
type: "button",
|
|
134
|
+
onClick,
|
|
135
|
+
"data-kind": kind,
|
|
136
|
+
"data-slot": "related-record-action-card",
|
|
137
|
+
"data-testid": testId,
|
|
138
|
+
className: cn(
|
|
139
|
+
"group flex w-full items-center gap-3 rounded-lg border border-border bg-background px-3 py-2 text-left transition-colors",
|
|
140
|
+
"cursor-pointer hover:bg-muted/50 hover:border-border/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:text-primary",
|
|
141
|
+
className
|
|
142
|
+
),
|
|
143
|
+
children: content
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
RelatedRecordActionCard
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=related-record-action-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/related-record-action-card.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport { ExternalLink } from \"lucide-react\"\n\nimport { BRAND_ICONS } from \"../lib/icons\"\nimport { cn } from \"../lib/utils\"\n\nexport type RelatedRecordActionCardKind = \"case\" | \"account\" | \"opportunity\" | \"salesforce\" | \"generic\"\n\nexport type RelatedRecordActionIcon = \"salesforce\" | React.ReactNode\n\nexport interface RelatedRecordActionCardProps {\n kind: RelatedRecordActionCardKind\n label: string\n subtitle?: string\n disabledReason?: string\n href?: string\n external?: boolean\n icon?: RelatedRecordActionIcon\n onClick?: React.MouseEventHandler<HTMLButtonElement>\n className?: string\n testId?: string\n}\n\nfunction renderActionIcon(icon: RelatedRecordActionIcon | undefined, kind: RelatedRecordActionCardKind) {\n if (icon === \"salesforce\" || kind === \"salesforce\") {\n return (\n <img\n src={BRAND_ICONS.salesforce}\n alt=\"Salesforce\"\n className=\"h-4 w-4 object-contain\"\n draggable={false}\n />\n )\n }\n\n if (icon) {\n return icon\n }\n\n return <span aria-hidden=\"true\">{kind.slice(0, 1).toUpperCase()}</span>\n}\n\nexport function RelatedRecordActionCard({\n kind,\n label,\n subtitle,\n disabledReason,\n href,\n external,\n icon,\n onClick,\n className,\n testId,\n}: RelatedRecordActionCardProps) {\n const isDisabled = Boolean(disabledReason) || (!href && !onClick)\n\n const content = (\n <>\n <span\n data-slot=\"related-record-action-card-icon\"\n className={cn(\n \"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border text-xs font-semibold transition-colors\",\n isDisabled\n ? \"border-border/60 bg-muted/40 text-muted-foreground\"\n : \"border-border bg-muted/30 text-muted-foreground group-hover:bg-muted/60 group-active:text-primary\"\n )}\n >\n {renderActionIcon(icon, kind)}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span\n data-slot=\"related-record-action-card-label\"\n className={cn(\n \"block truncate text-sm font-medium transition-colors\",\n isDisabled ? \"text-muted-foreground\" : \"text-foreground group-active:text-primary\"\n )}\n >\n {label}\n </span>\n {subtitle && (\n <span\n data-slot=\"related-record-action-card-subtitle\"\n className=\"mt-0.5 block truncate text-xs text-muted-foreground\"\n >\n {subtitle}\n </span>\n )}\n {disabledReason && (\n <span\n data-slot=\"related-record-action-card-disabled-reason\"\n className=\"mt-1 block text-xs text-muted-foreground\"\n >\n {disabledReason}\n </span>\n )}\n </span>\n {external && (\n <>\n <span className=\"sr-only\">opens in a new tab</span>\n <ExternalLink\n aria-hidden=\"true\"\n data-slot=\"related-record-action-card-external-icon\"\n className={cn(\n \"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-colors\",\n isDisabled ? \"\" : \"group-active:text-primary\"\n )}\n />\n </>\n )}\n </>\n )\n\n if (isDisabled) {\n return (\n <div\n aria-disabled=\"true\"\n data-kind={kind}\n data-slot=\"related-record-action-card\"\n data-testid={testId}\n className={cn(\n \"group flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-colors\",\n \"cursor-not-allowed border-border/60 bg-muted/20 text-muted-foreground opacity-70\",\n className\n )}\n >\n {content}\n </div>\n )\n }\n\n if (href) {\n return (\n <a\n href={href}\n target={external ? \"_blank\" : undefined}\n rel={external ? \"noopener noreferrer\" : undefined}\n data-kind={kind}\n data-slot=\"related-record-action-card\"\n data-testid={testId}\n className={cn(\n \"group flex w-full items-center gap-3 rounded-lg border border-border bg-background px-3 py-2 text-left transition-colors\",\n \"cursor-pointer hover:bg-muted/50 hover:border-border/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:text-primary\",\n className\n )}\n >\n {content}\n </a>\n )\n }\n\n return (\n <button\n type=\"button\"\n onClick={onClick}\n data-kind={kind}\n data-slot=\"related-record-action-card\"\n data-testid={testId}\n className={cn(\n \"group flex w-full items-center gap-3 rounded-lg border border-border bg-background px-3 py-2 text-left transition-colors\",\n \"cursor-pointer hover:bg-muted/50 hover:border-border/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:text-primary\",\n className\n )}\n >\n {content}\n </button>\n )\n}\n"],"mappings":";AA4BM,SAuEE,UAvEF,KA2CA,YA3CA;AAzBN,SAAS,oBAAoB;AAE7B,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AAmBnB,SAAS,iBAAiB,MAA2C,MAAmC;AACtG,MAAI,SAAS,gBAAgB,SAAS,cAAc;AAClD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,KAAK,YAAY;AAAA,QACjB,KAAI;AAAA,QACJ,WAAU;AAAA,QACV,WAAW;AAAA;AAAA,IACb;AAAA,EAEJ;AAEA,MAAI,MAAM;AACR,WAAO;AAAA,EACT;AAEA,SAAO,oBAAC,UAAK,eAAY,QAAQ,eAAK,MAAM,GAAG,CAAC,EAAE,YAAY,GAAE;AAClE;AAEO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAiC;AAC/B,QAAM,aAAa,QAAQ,cAAc,KAAM,CAAC,QAAQ,CAAC;AAEzD,QAAM,UACJ,iCACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,aAAU;AAAA,QACV,WAAW;AAAA,UACT;AAAA,UACA,aACI,uDACA;AAAA,QACN;AAAA,QAEC,2BAAiB,MAAM,IAAI;AAAA;AAAA,IAC9B;AAAA,IACA,qBAAC,UAAK,WAAU,kBACd;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,aAAU;AAAA,UACV,WAAW;AAAA,YACT;AAAA,YACA,aAAa,0BAA0B;AAAA,UACzC;AAAA,UAEC;AAAA;AAAA,MACH;AAAA,MACC,YACC;AAAA,QAAC;AAAA;AAAA,UACC,aAAU;AAAA,UACV,WAAU;AAAA,UAET;AAAA;AAAA,MACH;AAAA,MAED,kBACC;AAAA,QAAC;AAAA;AAAA,UACC,aAAU;AAAA,UACV,WAAU;AAAA,UAET;AAAA;AAAA,MACH;AAAA,OAEJ;AAAA,IACC,YACC,iCACE;AAAA,0BAAC,UAAK,WAAU,WAAU,gCAAkB;AAAA,MAC5C;AAAA,QAAC;AAAA;AAAA,UACC,eAAY;AAAA,UACZ,aAAU;AAAA,UACV,WAAW;AAAA,YACT;AAAA,YACA,aAAa,KAAK;AAAA,UACpB;AAAA;AAAA,MACF;AAAA,OACF;AAAA,KAEJ;AAGF,MAAI,YAAY;AACd,WACE;AAAA,MAAC;AAAA;AAAA,QACC,iBAAc;AAAA,QACd,aAAW;AAAA,QACX,aAAU;AAAA,QACV,eAAa;AAAA,QACb,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,MAAI,MAAM;AACR,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,QAAQ,WAAW,WAAW;AAAA,QAC9B,KAAK,WAAW,wBAAwB;AAAA,QACxC,aAAW;AAAA,QACX,aAAU;AAAA,QACV,eAAa;AAAA,QACb,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL;AAAA,MACA,aAAW;AAAA,MACX,aAAU;AAAA,MACV,eAAa;AAAA,MACb,WAAW;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -5,7 +5,7 @@ import { Tabs as Tabs$1 } from 'radix-ui';
|
|
|
5
5
|
|
|
6
6
|
declare function Tabs({ className, orientation, ...props }: React.ComponentProps<typeof Tabs$1.Root>): React.JSX.Element;
|
|
7
7
|
declare const tabsListVariants: (props?: ({
|
|
8
|
-
variant?: "
|
|
8
|
+
variant?: "line" | "default" | null | undefined;
|
|
9
9
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
10
10
|
declare function TabsList({ className, variant, ...props }: React.ComponentProps<typeof Tabs$1.List> & VariantProps<typeof tabsListVariants>): React.JSX.Element;
|
|
11
11
|
declare function TabsTrigger({ className, ...props }: React.ComponentProps<typeof Tabs$1.Trigger>): React.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ export { QuickSegment, QuickSegmentProps } from './components/quick-segment.js';
|
|
|
59
59
|
export { QuickActionModal, QuickActionPriority, QuickActionTaskDraft, QuickActionTemplate } from './components/quick-action-modal.js';
|
|
60
60
|
export { ActiveVariant, QuickActionSidebarNav, SidebarNavItem, SidebarNavSection, SidebarUserProfile, UserMenuItem } from './components/quick-action-sidebar-nav.js';
|
|
61
61
|
export { RecommendedAction, RecommendedActionsSection } from './components/recommended-actions-section.js';
|
|
62
|
+
export { RelatedRecordActionCard, RelatedRecordActionCardKind, RelatedRecordActionCardProps, RelatedRecordActionIcon } from './components/related-record-action-card.js';
|
|
62
63
|
export { ReportCard, ReportCardProps } from './components/report-card.js';
|
|
63
64
|
export { RichTextAction, RichTextToolbar, RichTextToolbarProps } from './components/rich-text-toolbar.js';
|
|
64
65
|
export { ScoreAnalysisModal, ScoreAnalysisModalProps, ScoreAnalysisPanel, getScoreLabel } from './components/score-analysis-modal.js';
|
package/dist/index.js
CHANGED
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
} from "./components/quick-action-modal.js";
|
|
62
62
|
export * from "./components/quick-action-sidebar-nav.js";
|
|
63
63
|
export * from "./components/recommended-actions-section.js";
|
|
64
|
+
export * from "./components/related-record-action-card.js";
|
|
64
65
|
export * from "./components/report-card.js";
|
|
65
66
|
export * from "./components/rich-text-toolbar.js";
|
|
66
67
|
export * from "./components/score-analysis-modal.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @handled-ai/design-system\n * UI components and utilities (shadcn-style, New York)\n */\n\n// Utilities\nexport { cn } from \"./lib/utils\"\nexport { BRAND_ICONS, BRAND_GRAPHICS } from \"./lib/icons\"\nexport { displayName, getInitials, shortName, type ProfileLike } from \"./lib/user-display\"\n\n// Hooks\nexport { useIsMobile } from \"./hooks/use-mobile\"\n\n// Components (light — no recharts/nivo/three transitive deps)\nexport * from \"./components/activity-detail\"\nexport * from \"./components/activity-log\"\nexport * from \"./components/agent-popover\"\nexport * from \"./components/agent-widget\"\nexport * from \"./components/avatar\"\nexport * from \"./components/badge\"\nexport * from \"./components/button\"\nexport * from \"./components/card\"\nexport * from \"./components/case-panel-email-composer\"\nexport * from \"./components/case-panel-activity-timeline\"\nexport * from \"./components/case-panel-detail\"\nexport * from \"./components/case-panel-why\"\nexport { CollapsibleSection, type CollapsibleSectionProps } from \"./components/collapsible-section\"\nexport * from \"./components/compliance-badge\"\nexport * from \"./components/contact-chip\"\nexport * from \"./components/contact-list\"\nexport * from \"./components/contextual-quick-action-launcher\"\nexport * from \"./components/dashboard-cards\"\nexport * from \"./components/data-table\"\nexport * from \"./components/data-table-condition-filter\"\nexport * from \"./components/data-table-display\"\nexport * from \"./components/data-table-filter\"\nexport * from \"./components/data-table-quick-views\"\nexport * from \"./components/data-table-toolbar\"\nexport * from \"./components/detail-view\"\nexport * from \"./components/detail-drawer\"\nexport * from \"./components/dialog\"\nexport * from \"./components/dropdown-menu\"\nexport * from \"./components/empty-state\"\nexport * from \"./components/entity-panel\"\nexport { FeedbackFooter, FeedbackChipGroup, FeedbackInput, FeedbackActions, InlineFeedbackControl } from \"./components/feedback-primitives\"\nexport type { FeedbackFooterProps, FeedbackChipTree, FeedbackChipGroupProps, FeedbackInputProps, FeedbackActionsProps, FeedbackSubmitData, PersistedFeedbackData, InlineFeedbackControlProps } from \"./components/feedback-primitives\"\nexport { SignalPriorityPopover } from \"./components/signal-priority-popover\"\nexport type { SignalPriorityPopoverProps, PriorityFactor } from \"./components/signal-priority-popover\"\nexport * from \"./components/filter-chip\"\nexport * from \"./components/inbox-row\"\nexport * from \"./components/inbox-toolbar\"\nexport * from \"./components/inline-banner\"\nexport * from \"./components/input\"\nexport * from \"./components/insights-filter-bar\"\nexport * from \"./components/days-open-cell\"\nexport * from \"./components/linked-entity-cell\"\nexport * from \"./components/item-list\"\nexport * from \"./components/item-list-display\"\nexport * from \"./components/item-list-filter\"\nexport * from \"./components/item-list-toolbar\"\nexport * from \"./components/kbd-hint\"\nexport * from \"./components/label\"\nexport * from \"./components/message\"\nexport * from \"./components/metric-card\"\nexport * from \"./components/performance-metrics-table\"\nexport * from \"./components/pill\"\nexport * from \"./components/preview-list\"\nexport * from \"./components/progress\"\nexport * from \"./components/quick-action-chat-area\"\nexport * from \"./components/quick-segment\"\nexport {\n QuickActionModal,\n type QuickActionPriority,\n type QuickActionTaskDraft,\n type QuickActionTemplate,\n} from \"./components/quick-action-modal\"\nexport * from \"./components/quick-action-sidebar-nav\"\nexport * from \"./components/recommended-actions-section\"\nexport * from \"./components/report-card\"\nexport * from \"./components/rich-text-toolbar\"\nexport * from \"./components/score-analysis-modal\"\nexport * from \"./components/score-breakdown\"\nexport * from \"./components/score-feedback\"\nexport * from \"./components/score-semantics\"\nexport * from \"./components/score-why-chips\"\nexport * from \"./components/score-ring\"\nexport * from \"./components/scroll-area\"\nexport * from \"./components/select\"\nexport * from \"./components/separator\"\nexport * from \"./components/sheet\"\nexport * from \"./components/sidebar\"\nexport * from \"./components/signal-feedback-inline\"\nexport * from \"./components/simple-data-table\"\nexport * from \"./components/skeleton\"\nexport * from \"./components/status-badge\"\nexport * from \"./components/step-timeline\"\nexport * from \"./components/sticky-action-bar\"\nexport * from \"./components/styled-bar-list\"\nexport { DraftFeedbackInline } from \"./components/draft-feedback-inline\"\nexport type { DraftFeedbackInlineProps } from \"./components/draft-feedback-inline\"\nexport { AccountContactsPopover, BrandIcon } from \"./components/account-contacts-popover\"\nexport type { AccountContactsPopoverProps } from \"./components/account-contacts-popover\"\nexport * from \"./components/suggested-actions\"\nexport * from \"./components/switch\"\nexport * from \"./components/table\"\nexport * from \"./components/tabs\"\nexport * from \"./components/textarea\"\nexport * from \"./components/timeline-activity\"\nexport * from \"./components/tooltip\"\nexport * from \"./components/user-display\"\nexport * from \"./components/variable-autocomplete\"\nexport * from \"./components/view-mode-toggle\"\nexport * from \"./components/virtualized-data-table\"\nexport type { ColumnSizingState } from \"@tanstack/react-table\"\n\n// Charts (re-exported for backward compatibility with root imports)\nexport * from \"./charts/index\"\n\n// Prototype template system (re-exported for backward compatibility)\nexport * from \"./prototype/prototype-config\"\nexport * from \"./prototype/prototype-shell\"\nexport * from \"./prototype/prototype-inbox-view\"\nexport * from \"./prototype/prototype-insights-view\"\nexport * from \"./prototype/prototype-accounts-view\"\nexport * from \"./prototype/prototype-admin-view\"\nexport * from \"./prototype/prototype-work-queue-view\"\n"],"mappings":"AAMA,SAAS,UAAU;AACnB,SAAS,aAAa,sBAAsB;AAC5C,SAAS,aAAa,aAAa,iBAAmC;AAGtE,SAAS,mBAAmB;AAG5B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,0BAAwD;AACjE,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,gBAAgB,mBAAmB,eAAe,iBAAiB,6BAA6B;AAEzG,SAAS,6BAA6B;AAEtC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd;AAAA,EACE;AAAA,OAIK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,2BAA2B;AAEpC,SAAS,wBAAwB,iBAAiB;AAElD,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @handled-ai/design-system\n * UI components and utilities (shadcn-style, New York)\n */\n\n// Utilities\nexport { cn } from \"./lib/utils\"\nexport { BRAND_ICONS, BRAND_GRAPHICS } from \"./lib/icons\"\nexport { displayName, getInitials, shortName, type ProfileLike } from \"./lib/user-display\"\n\n// Hooks\nexport { useIsMobile } from \"./hooks/use-mobile\"\n\n// Components (light — no recharts/nivo/three transitive deps)\nexport * from \"./components/activity-detail\"\nexport * from \"./components/activity-log\"\nexport * from \"./components/agent-popover\"\nexport * from \"./components/agent-widget\"\nexport * from \"./components/avatar\"\nexport * from \"./components/badge\"\nexport * from \"./components/button\"\nexport * from \"./components/card\"\nexport * from \"./components/case-panel-email-composer\"\nexport * from \"./components/case-panel-activity-timeline\"\nexport * from \"./components/case-panel-detail\"\nexport * from \"./components/case-panel-why\"\nexport { CollapsibleSection, type CollapsibleSectionProps } from \"./components/collapsible-section\"\nexport * from \"./components/compliance-badge\"\nexport * from \"./components/contact-chip\"\nexport * from \"./components/contact-list\"\nexport * from \"./components/contextual-quick-action-launcher\"\nexport * from \"./components/dashboard-cards\"\nexport * from \"./components/data-table\"\nexport * from \"./components/data-table-condition-filter\"\nexport * from \"./components/data-table-display\"\nexport * from \"./components/data-table-filter\"\nexport * from \"./components/data-table-quick-views\"\nexport * from \"./components/data-table-toolbar\"\nexport * from \"./components/detail-view\"\nexport * from \"./components/detail-drawer\"\nexport * from \"./components/dialog\"\nexport * from \"./components/dropdown-menu\"\nexport * from \"./components/empty-state\"\nexport * from \"./components/entity-panel\"\nexport { FeedbackFooter, FeedbackChipGroup, FeedbackInput, FeedbackActions, InlineFeedbackControl } from \"./components/feedback-primitives\"\nexport type { FeedbackFooterProps, FeedbackChipTree, FeedbackChipGroupProps, FeedbackInputProps, FeedbackActionsProps, FeedbackSubmitData, PersistedFeedbackData, InlineFeedbackControlProps } from \"./components/feedback-primitives\"\nexport { SignalPriorityPopover } from \"./components/signal-priority-popover\"\nexport type { SignalPriorityPopoverProps, PriorityFactor } from \"./components/signal-priority-popover\"\nexport * from \"./components/filter-chip\"\nexport * from \"./components/inbox-row\"\nexport * from \"./components/inbox-toolbar\"\nexport * from \"./components/inline-banner\"\nexport * from \"./components/input\"\nexport * from \"./components/insights-filter-bar\"\nexport * from \"./components/days-open-cell\"\nexport * from \"./components/linked-entity-cell\"\nexport * from \"./components/item-list\"\nexport * from \"./components/item-list-display\"\nexport * from \"./components/item-list-filter\"\nexport * from \"./components/item-list-toolbar\"\nexport * from \"./components/kbd-hint\"\nexport * from \"./components/label\"\nexport * from \"./components/message\"\nexport * from \"./components/metric-card\"\nexport * from \"./components/performance-metrics-table\"\nexport * from \"./components/pill\"\nexport * from \"./components/preview-list\"\nexport * from \"./components/progress\"\nexport * from \"./components/quick-action-chat-area\"\nexport * from \"./components/quick-segment\"\nexport {\n QuickActionModal,\n type QuickActionPriority,\n type QuickActionTaskDraft,\n type QuickActionTemplate,\n} from \"./components/quick-action-modal\"\nexport * from \"./components/quick-action-sidebar-nav\"\nexport * from \"./components/recommended-actions-section\"\nexport * from \"./components/related-record-action-card\"\nexport * from \"./components/report-card\"\nexport * from \"./components/rich-text-toolbar\"\nexport * from \"./components/score-analysis-modal\"\nexport * from \"./components/score-breakdown\"\nexport * from \"./components/score-feedback\"\nexport * from \"./components/score-semantics\"\nexport * from \"./components/score-why-chips\"\nexport * from \"./components/score-ring\"\nexport * from \"./components/scroll-area\"\nexport * from \"./components/select\"\nexport * from \"./components/separator\"\nexport * from \"./components/sheet\"\nexport * from \"./components/sidebar\"\nexport * from \"./components/signal-feedback-inline\"\nexport * from \"./components/simple-data-table\"\nexport * from \"./components/skeleton\"\nexport * from \"./components/status-badge\"\nexport * from \"./components/step-timeline\"\nexport * from \"./components/sticky-action-bar\"\nexport * from \"./components/styled-bar-list\"\nexport { DraftFeedbackInline } from \"./components/draft-feedback-inline\"\nexport type { DraftFeedbackInlineProps } from \"./components/draft-feedback-inline\"\nexport { AccountContactsPopover, BrandIcon } from \"./components/account-contacts-popover\"\nexport type { AccountContactsPopoverProps } from \"./components/account-contacts-popover\"\nexport * from \"./components/suggested-actions\"\nexport * from \"./components/switch\"\nexport * from \"./components/table\"\nexport * from \"./components/tabs\"\nexport * from \"./components/textarea\"\nexport * from \"./components/timeline-activity\"\nexport * from \"./components/tooltip\"\nexport * from \"./components/user-display\"\nexport * from \"./components/variable-autocomplete\"\nexport * from \"./components/view-mode-toggle\"\nexport * from \"./components/virtualized-data-table\"\nexport type { ColumnSizingState } from \"@tanstack/react-table\"\n\n// Charts (re-exported for backward compatibility with root imports)\nexport * from \"./charts/index\"\n\n// Prototype template system (re-exported for backward compatibility)\nexport * from \"./prototype/prototype-config\"\nexport * from \"./prototype/prototype-shell\"\nexport * from \"./prototype/prototype-inbox-view\"\nexport * from \"./prototype/prototype-insights-view\"\nexport * from \"./prototype/prototype-accounts-view\"\nexport * from \"./prototype/prototype-admin-view\"\nexport * from \"./prototype/prototype-work-queue-view\"\n"],"mappings":"AAMA,SAAS,UAAU;AACnB,SAAS,aAAa,sBAAsB;AAC5C,SAAS,aAAa,aAAa,iBAAmC;AAGtE,SAAS,mBAAmB;AAG5B,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,0BAAwD;AACjE,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,gBAAgB,mBAAmB,eAAe,iBAAiB,6BAA6B;AAEzG,SAAS,6BAA6B;AAEtC,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd;AAAA,EACE;AAAA,OAIK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,2BAA2B;AAEpC,SAAS,wBAAwB,iBAAiB;AAElD,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAId,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import "@testing-library/jest-dom/vitest"
|
|
2
|
+
|
|
3
|
+
import React from "react"
|
|
4
|
+
import { fireEvent, render, screen } from "@testing-library/react"
|
|
5
|
+
import { describe, expect, it, vi } from "vitest"
|
|
6
|
+
|
|
7
|
+
import { BRAND_ICONS } from "../../lib/icons"
|
|
8
|
+
import { RelatedRecordActionCard } from "../related-record-action-card"
|
|
9
|
+
|
|
10
|
+
describe("RelatedRecordActionCard", () => {
|
|
11
|
+
it("renders an enabled href as a link with pointer affordance", () => {
|
|
12
|
+
render(
|
|
13
|
+
<RelatedRecordActionCard
|
|
14
|
+
kind="account"
|
|
15
|
+
label="Open account"
|
|
16
|
+
subtitle="Acme Corp"
|
|
17
|
+
href="/accounts/acme"
|
|
18
|
+
testId="record-card"
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
const card = screen.getByTestId("record-card")
|
|
23
|
+
|
|
24
|
+
expect(card.tagName).toBe("A")
|
|
25
|
+
expect(card).toHaveAttribute("href", "/accounts/acme")
|
|
26
|
+
expect(card.className).toContain("cursor-pointer")
|
|
27
|
+
expect(card.className).toContain("hover:bg-muted/50")
|
|
28
|
+
expect(card.className).toContain("hover:border-border/80")
|
|
29
|
+
expect(card.className).toContain("focus-visible:ring-2")
|
|
30
|
+
expect(card.className).toContain("active:text-primary")
|
|
31
|
+
expect(screen.getByText("Acme Corp")).toBeInTheDocument()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it("renders an enabled onClick action as a button and invokes the callback", () => {
|
|
35
|
+
const onClick = vi.fn()
|
|
36
|
+
|
|
37
|
+
render(
|
|
38
|
+
<RelatedRecordActionCard
|
|
39
|
+
kind="case"
|
|
40
|
+
label="Open case"
|
|
41
|
+
onClick={onClick}
|
|
42
|
+
testId="record-card"
|
|
43
|
+
/>
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
const card = screen.getByRole("button", { name: /open case/i })
|
|
47
|
+
|
|
48
|
+
expect(card.tagName).toBe("BUTTON")
|
|
49
|
+
expect(card).toHaveAttribute("type", "button")
|
|
50
|
+
expect(card.className).toContain("cursor-pointer")
|
|
51
|
+
|
|
52
|
+
fireEvent.click(card)
|
|
53
|
+
|
|
54
|
+
expect(onClick).toHaveBeenCalledTimes(1)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it("renders a disabled card when disabledReason is present", () => {
|
|
58
|
+
render(
|
|
59
|
+
<RelatedRecordActionCard
|
|
60
|
+
kind="opportunity"
|
|
61
|
+
label="Open opportunity"
|
|
62
|
+
disabledReason="Connect Salesforce to view this opportunity."
|
|
63
|
+
href="/opportunities/1"
|
|
64
|
+
testId="record-card"
|
|
65
|
+
/>
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
const card = screen.getByTestId("record-card")
|
|
69
|
+
|
|
70
|
+
expect(card.tagName).toBe("DIV")
|
|
71
|
+
expect(card).toHaveAttribute("aria-disabled", "true")
|
|
72
|
+
expect(card.className).toContain("cursor-not-allowed")
|
|
73
|
+
expect(card.className).toContain("text-muted-foreground")
|
|
74
|
+
expect(card.className).not.toContain("cursor-pointer")
|
|
75
|
+
expect(card.className).not.toContain("hover:bg-muted/50")
|
|
76
|
+
expect(screen.getByText("Connect Salesforce to view this opportunity.")).toBeInTheDocument()
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
it("renders a disabled card when no action is available", () => {
|
|
80
|
+
render(<RelatedRecordActionCard kind="generic" label="Unavailable record" testId="record-card" />)
|
|
81
|
+
|
|
82
|
+
const card = screen.getByTestId("record-card")
|
|
83
|
+
|
|
84
|
+
expect(card.tagName).toBe("DIV")
|
|
85
|
+
expect(card).toHaveAttribute("aria-disabled", "true")
|
|
86
|
+
expect(card.className).toContain("cursor-not-allowed")
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it("sets external link attributes and exposes an accessible external-link cue", () => {
|
|
90
|
+
const { container } = render(
|
|
91
|
+
<RelatedRecordActionCard
|
|
92
|
+
kind="salesforce"
|
|
93
|
+
label="Open in Salesforce"
|
|
94
|
+
href="https://example.salesforce.com/001"
|
|
95
|
+
external
|
|
96
|
+
testId="record-card"
|
|
97
|
+
/>
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
const card = screen.getByTestId("record-card")
|
|
101
|
+
|
|
102
|
+
expect(card).toHaveAttribute("target", "_blank")
|
|
103
|
+
expect(card).toHaveAttribute("rel", "noopener noreferrer")
|
|
104
|
+
expect(screen.getByText("opens in a new tab")).toHaveClass("sr-only")
|
|
105
|
+
expect(container.querySelector('[data-slot="related-record-action-card-external-icon"]')).not.toBeNull()
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it("renders the Salesforce brand icon when icon is salesforce", () => {
|
|
109
|
+
const { container } = render(
|
|
110
|
+
<RelatedRecordActionCard
|
|
111
|
+
kind="generic"
|
|
112
|
+
label="Salesforce record"
|
|
113
|
+
href="https://example.salesforce.com/001"
|
|
114
|
+
icon="salesforce"
|
|
115
|
+
/>
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
const icon = container.querySelector('[data-slot="related-record-action-card-icon"] img')
|
|
119
|
+
|
|
120
|
+
expect(icon).toHaveAttribute("src", BRAND_ICONS.salesforce)
|
|
121
|
+
expect(icon).toHaveAttribute("alt", "Salesforce")
|
|
122
|
+
})
|
|
123
|
+
})
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { ExternalLink } from "lucide-react"
|
|
5
|
+
|
|
6
|
+
import { BRAND_ICONS } from "../lib/icons"
|
|
7
|
+
import { cn } from "../lib/utils"
|
|
8
|
+
|
|
9
|
+
export type RelatedRecordActionCardKind = "case" | "account" | "opportunity" | "salesforce" | "generic"
|
|
10
|
+
|
|
11
|
+
export type RelatedRecordActionIcon = "salesforce" | React.ReactNode
|
|
12
|
+
|
|
13
|
+
export interface RelatedRecordActionCardProps {
|
|
14
|
+
kind: RelatedRecordActionCardKind
|
|
15
|
+
label: string
|
|
16
|
+
subtitle?: string
|
|
17
|
+
disabledReason?: string
|
|
18
|
+
href?: string
|
|
19
|
+
external?: boolean
|
|
20
|
+
icon?: RelatedRecordActionIcon
|
|
21
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>
|
|
22
|
+
className?: string
|
|
23
|
+
testId?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function renderActionIcon(icon: RelatedRecordActionIcon | undefined, kind: RelatedRecordActionCardKind) {
|
|
27
|
+
if (icon === "salesforce" || kind === "salesforce") {
|
|
28
|
+
return (
|
|
29
|
+
<img
|
|
30
|
+
src={BRAND_ICONS.salesforce}
|
|
31
|
+
alt="Salesforce"
|
|
32
|
+
className="h-4 w-4 object-contain"
|
|
33
|
+
draggable={false}
|
|
34
|
+
/>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (icon) {
|
|
39
|
+
return icon
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return <span aria-hidden="true">{kind.slice(0, 1).toUpperCase()}</span>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function RelatedRecordActionCard({
|
|
46
|
+
kind,
|
|
47
|
+
label,
|
|
48
|
+
subtitle,
|
|
49
|
+
disabledReason,
|
|
50
|
+
href,
|
|
51
|
+
external,
|
|
52
|
+
icon,
|
|
53
|
+
onClick,
|
|
54
|
+
className,
|
|
55
|
+
testId,
|
|
56
|
+
}: RelatedRecordActionCardProps) {
|
|
57
|
+
const isDisabled = Boolean(disabledReason) || (!href && !onClick)
|
|
58
|
+
|
|
59
|
+
const content = (
|
|
60
|
+
<>
|
|
61
|
+
<span
|
|
62
|
+
data-slot="related-record-action-card-icon"
|
|
63
|
+
className={cn(
|
|
64
|
+
"flex h-8 w-8 shrink-0 items-center justify-center rounded-md border text-xs font-semibold transition-colors",
|
|
65
|
+
isDisabled
|
|
66
|
+
? "border-border/60 bg-muted/40 text-muted-foreground"
|
|
67
|
+
: "border-border bg-muted/30 text-muted-foreground group-hover:bg-muted/60 group-active:text-primary"
|
|
68
|
+
)}
|
|
69
|
+
>
|
|
70
|
+
{renderActionIcon(icon, kind)}
|
|
71
|
+
</span>
|
|
72
|
+
<span className="min-w-0 flex-1">
|
|
73
|
+
<span
|
|
74
|
+
data-slot="related-record-action-card-label"
|
|
75
|
+
className={cn(
|
|
76
|
+
"block truncate text-sm font-medium transition-colors",
|
|
77
|
+
isDisabled ? "text-muted-foreground" : "text-foreground group-active:text-primary"
|
|
78
|
+
)}
|
|
79
|
+
>
|
|
80
|
+
{label}
|
|
81
|
+
</span>
|
|
82
|
+
{subtitle && (
|
|
83
|
+
<span
|
|
84
|
+
data-slot="related-record-action-card-subtitle"
|
|
85
|
+
className="mt-0.5 block truncate text-xs text-muted-foreground"
|
|
86
|
+
>
|
|
87
|
+
{subtitle}
|
|
88
|
+
</span>
|
|
89
|
+
)}
|
|
90
|
+
{disabledReason && (
|
|
91
|
+
<span
|
|
92
|
+
data-slot="related-record-action-card-disabled-reason"
|
|
93
|
+
className="mt-1 block text-xs text-muted-foreground"
|
|
94
|
+
>
|
|
95
|
+
{disabledReason}
|
|
96
|
+
</span>
|
|
97
|
+
)}
|
|
98
|
+
</span>
|
|
99
|
+
{external && (
|
|
100
|
+
<>
|
|
101
|
+
<span className="sr-only">opens in a new tab</span>
|
|
102
|
+
<ExternalLink
|
|
103
|
+
aria-hidden="true"
|
|
104
|
+
data-slot="related-record-action-card-external-icon"
|
|
105
|
+
className={cn(
|
|
106
|
+
"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-colors",
|
|
107
|
+
isDisabled ? "" : "group-active:text-primary"
|
|
108
|
+
)}
|
|
109
|
+
/>
|
|
110
|
+
</>
|
|
111
|
+
)}
|
|
112
|
+
</>
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
if (isDisabled) {
|
|
116
|
+
return (
|
|
117
|
+
<div
|
|
118
|
+
aria-disabled="true"
|
|
119
|
+
data-kind={kind}
|
|
120
|
+
data-slot="related-record-action-card"
|
|
121
|
+
data-testid={testId}
|
|
122
|
+
className={cn(
|
|
123
|
+
"group flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-colors",
|
|
124
|
+
"cursor-not-allowed border-border/60 bg-muted/20 text-muted-foreground opacity-70",
|
|
125
|
+
className
|
|
126
|
+
)}
|
|
127
|
+
>
|
|
128
|
+
{content}
|
|
129
|
+
</div>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (href) {
|
|
134
|
+
return (
|
|
135
|
+
<a
|
|
136
|
+
href={href}
|
|
137
|
+
target={external ? "_blank" : undefined}
|
|
138
|
+
rel={external ? "noopener noreferrer" : undefined}
|
|
139
|
+
data-kind={kind}
|
|
140
|
+
data-slot="related-record-action-card"
|
|
141
|
+
data-testid={testId}
|
|
142
|
+
className={cn(
|
|
143
|
+
"group flex w-full items-center gap-3 rounded-lg border border-border bg-background px-3 py-2 text-left transition-colors",
|
|
144
|
+
"cursor-pointer hover:bg-muted/50 hover:border-border/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:text-primary",
|
|
145
|
+
className
|
|
146
|
+
)}
|
|
147
|
+
>
|
|
148
|
+
{content}
|
|
149
|
+
</a>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<button
|
|
155
|
+
type="button"
|
|
156
|
+
onClick={onClick}
|
|
157
|
+
data-kind={kind}
|
|
158
|
+
data-slot="related-record-action-card"
|
|
159
|
+
data-testid={testId}
|
|
160
|
+
className={cn(
|
|
161
|
+
"group flex w-full items-center gap-3 rounded-lg border border-border bg-background px-3 py-2 text-left transition-colors",
|
|
162
|
+
"cursor-pointer hover:bg-muted/50 hover:border-border/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 active:text-primary",
|
|
163
|
+
className
|
|
164
|
+
)}
|
|
165
|
+
>
|
|
166
|
+
{content}
|
|
167
|
+
</button>
|
|
168
|
+
)
|
|
169
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -76,6 +76,7 @@ export {
|
|
|
76
76
|
} from "./components/quick-action-modal"
|
|
77
77
|
export * from "./components/quick-action-sidebar-nav"
|
|
78
78
|
export * from "./components/recommended-actions-section"
|
|
79
|
+
export * from "./components/related-record-action-card"
|
|
79
80
|
export * from "./components/report-card"
|
|
80
81
|
export * from "./components/rich-text-toolbar"
|
|
81
82
|
export * from "./components/score-analysis-modal"
|