@handled-ai/design-system 0.18.31 → 0.18.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,166 +0,0 @@
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
- <ExternalLink
101
- aria-hidden="true"
102
- data-slot="related-record-action-card-external-icon"
103
- className={cn(
104
- "h-3.5 w-3.5 shrink-0 text-muted-foreground transition-colors",
105
- isDisabled ? "" : "group-active:text-primary"
106
- )}
107
- />
108
- )}
109
- </>
110
- )
111
-
112
- if (isDisabled) {
113
- return (
114
- <div
115
- aria-disabled="true"
116
- data-kind={kind}
117
- data-slot="related-record-action-card"
118
- data-testid={testId}
119
- className={cn(
120
- "group flex w-full items-center gap-3 rounded-lg border px-3 py-2 text-left transition-colors",
121
- "cursor-not-allowed border-border/60 bg-muted/20 text-muted-foreground opacity-70",
122
- className
123
- )}
124
- >
125
- {content}
126
- </div>
127
- )
128
- }
129
-
130
- if (href) {
131
- return (
132
- <a
133
- href={href}
134
- target={external ? "_blank" : undefined}
135
- rel={external ? "noopener noreferrer" : undefined}
136
- data-kind={kind}
137
- data-slot="related-record-action-card"
138
- data-testid={testId}
139
- className={cn(
140
- "group flex w-full items-center gap-3 rounded-lg border border-border bg-background px-3 py-2 text-left transition-colors",
141
- "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",
142
- className
143
- )}
144
- >
145
- {content}
146
- </a>
147
- )
148
- }
149
-
150
- return (
151
- <button
152
- type="button"
153
- onClick={onClick}
154
- data-kind={kind}
155
- data-slot="related-record-action-card"
156
- data-testid={testId}
157
- className={cn(
158
- "group flex w-full items-center gap-3 rounded-lg border border-border bg-background px-3 py-2 text-left transition-colors",
159
- "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",
160
- className
161
- )}
162
- >
163
- {content}
164
- </button>
165
- )
166
- }