@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client 1.117.2
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/LICENSE.txt +82 -0
- package/README.md +149 -0
- package/dist/.forceignore +15 -0
- package/dist/.husky/pre-commit +4 -0
- package/dist/.prettierignore +11 -0
- package/dist/.prettierrc +17 -0
- package/dist/AGENT.md +193 -0
- package/dist/CHANGELOG.md +2128 -0
- package/dist/README.md +28 -0
- package/dist/config/project-scratch-def.json +13 -0
- package/dist/eslint.config.js +7 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/.forceignore +15 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/.graphqlrc.yml +2 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/.prettierignore +9 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/.prettierrc +11 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/CHANGELOG.md +10 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/README.md +75 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/codegen.yml +95 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/components.json +18 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/e2e/app.spec.ts +17 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/eslint.config.js +169 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/feature-react-agentforce-conversation-client.uibundle-meta.xml +7 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/index.html +12 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/package.json +69 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/playwright.config.ts +24 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/scripts/get-graphql-schema.mjs +68 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/scripts/rewrite-e2e-assets.mjs +23 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/api/graphqlClient.ts +25 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/app.tsx +17 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/appLayout.tsx +83 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/assets/icons/book.svg +3 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/assets/icons/copy.svg +4 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/assets/icons/rocket.svg +3 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/assets/icons/star.svg +3 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/assets/images/codey-1.png +0 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/assets/images/codey-2.png +0 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/assets/images/codey-3.png +0 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/assets/images/vibe-codey.svg +194 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/AgentforceConversationClient.tsx +168 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/alerts/status-alert.tsx +49 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/layouts/card-layout.tsx +29 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/alert.tsx +76 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/badge.tsx +48 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/breadcrumb.tsx +109 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/button.tsx +67 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/calendar.tsx +232 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/card.tsx +103 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/checkbox.tsx +32 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/collapsible.tsx +33 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/datePicker.tsx +127 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/dialog.tsx +162 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/field.tsx +237 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/index.ts +84 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/input.tsx +19 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/label.tsx +22 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/pagination.tsx +132 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/popover.tsx +89 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/select.tsx +193 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/separator.tsx +26 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/skeleton.tsx +14 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/sonner.tsx +20 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/spinner.tsx +16 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/table.tsx +114 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/ui/tabs.tsx +88 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/index.ts +6 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/lib/utils.ts +6 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/navigationMenu.tsx +80 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/pages/Home.tsx +12 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/pages/NotFound.tsx +18 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/pages/TestAccPage.tsx +19 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/router-utils.tsx +35 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/routes.tsx +28 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/styles/global.css +135 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/types/conversation.ts +33 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/tsconfig.json +42 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/tsconfig.node.json +13 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/ui-bundle.json +7 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/vite-env.d.ts +1 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/vite.config.ts +106 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/vitest-env.d.ts +2 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/vitest.config.ts +11 -0
- package/dist/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/vitest.setup.ts +1 -0
- package/dist/jest.config.js +6 -0
- package/dist/package-lock.json +9995 -0
- package/dist/package.json +40 -0
- package/dist/scripts/apex/hello.apex +10 -0
- package/dist/scripts/graphql-search.sh +191 -0
- package/dist/scripts/prepare-import-unique-fields.js +122 -0
- package/dist/scripts/setup-cli.mjs +563 -0
- package/dist/scripts/sf-project-setup.mjs +66 -0
- package/dist/scripts/soql/account.soql +6 -0
- package/dist/sfdx-project.json +12 -0
- package/package.json +54 -0
- package/src/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/components/AgentforceConversationClient.tsx +168 -0
- package/src/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/index.ts +6 -0
- package/src/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/pages/TestAccPage.tsx +19 -0
- package/src/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/routes.tsx +23 -0
- package/src/force-app/main/default/uiBundles/feature-react-agentforce-conversation-client/src/types/conversation.ts +33 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";
|
|
8
|
+
import type { AgentforceClientConfig } from "@salesforce/agentforce-conversation-client";
|
|
9
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
10
|
+
import type {
|
|
11
|
+
ResolvedEmbedOptions,
|
|
12
|
+
AgentforceConversationClientProps,
|
|
13
|
+
} from "../types/conversation";
|
|
14
|
+
|
|
15
|
+
const GLOBAL_HOST_ID = "agentforce-conversation-client-global-host";
|
|
16
|
+
const SINGLETON_KEY = "__agentforceConversationClientSingleton";
|
|
17
|
+
|
|
18
|
+
interface AgentforceConversationClientSingleton {
|
|
19
|
+
initPromise?: Promise<void>;
|
|
20
|
+
initialized: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface WindowWithAgentforceSingleton extends Window {
|
|
24
|
+
[SINGLETON_KEY]?: AgentforceConversationClientSingleton;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getSingleton(): AgentforceConversationClientSingleton {
|
|
28
|
+
const win = window as WindowWithAgentforceSingleton;
|
|
29
|
+
if (!win[SINGLETON_KEY]) {
|
|
30
|
+
win[SINGLETON_KEY] = {
|
|
31
|
+
initialized: false,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return win[SINGLETON_KEY]!;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getOrCreateGlobalHost(): HTMLDivElement {
|
|
38
|
+
let host = document.getElementById(GLOBAL_HOST_ID) as HTMLDivElement | null;
|
|
39
|
+
if (!host) {
|
|
40
|
+
host = document.createElement("div");
|
|
41
|
+
host.id = GLOBAL_HOST_ID;
|
|
42
|
+
document.body.appendChild(host);
|
|
43
|
+
}
|
|
44
|
+
return host;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getDefaultEmbedOptions(): ResolvedEmbedOptions {
|
|
48
|
+
return { salesforceOrigin: window.location.origin };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* React wrapper that embeds the Agentforce Conversation Client (copilot/agent UI)
|
|
53
|
+
* using Lightning Out. Requires a valid Salesforce session for the given org.
|
|
54
|
+
* Config is passed through from the consumer to the embed client as-is.
|
|
55
|
+
*/
|
|
56
|
+
export function AgentforceConversationClient({
|
|
57
|
+
agentId,
|
|
58
|
+
inline: inlineProp,
|
|
59
|
+
headerEnabled,
|
|
60
|
+
showHeaderIcon,
|
|
61
|
+
width,
|
|
62
|
+
height,
|
|
63
|
+
styleTokens,
|
|
64
|
+
salesforceOrigin,
|
|
65
|
+
frontdoorUrl,
|
|
66
|
+
}: AgentforceConversationClientProps) {
|
|
67
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
68
|
+
const normalizedAgentforceClientConfig = useMemo<AgentforceClientConfig>(() => {
|
|
69
|
+
const renderingConfig: NonNullable<AgentforceClientConfig["renderingConfig"]> = {
|
|
70
|
+
mode: inlineProp ? "inline" : "floating",
|
|
71
|
+
...(headerEnabled !== undefined && { headerEnabled }),
|
|
72
|
+
...(showHeaderIcon !== undefined && { showHeaderIcon }),
|
|
73
|
+
...{ showAvatar: false },
|
|
74
|
+
...(width !== undefined && { width }),
|
|
75
|
+
...(height !== undefined && { height }),
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
...(agentId !== undefined && { agentId }),
|
|
80
|
+
...(styleTokens !== undefined && { styleTokens }),
|
|
81
|
+
renderingConfig,
|
|
82
|
+
};
|
|
83
|
+
}, [agentId, inlineProp, headerEnabled, showHeaderIcon, width, height, styleTokens]);
|
|
84
|
+
|
|
85
|
+
const inline = normalizedAgentforceClientConfig?.renderingConfig?.mode === "inline";
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (!normalizedAgentforceClientConfig?.agentId) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
"AgentforceConversationClient requires agentId. " +
|
|
91
|
+
"Pass flat props only (agentId, inline, headerEnabled, showHeaderIcon, width, height, styleTokens).",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const singleton = getSingleton();
|
|
96
|
+
if (singleton.initialized || singleton.initPromise) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (inline && !containerRef.current) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const initialize = (options: ResolvedEmbedOptions) => {
|
|
105
|
+
if (singleton.initialized) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const existingEmbed = document.querySelector('lightning-out-application[data-lo="acc"]');
|
|
109
|
+
if (existingEmbed) {
|
|
110
|
+
singleton.initialized = true;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const host = inline ? containerRef.current! : getOrCreateGlobalHost();
|
|
114
|
+
|
|
115
|
+
embedAgentforceClient({
|
|
116
|
+
container: host,
|
|
117
|
+
salesforceOrigin: salesforceOrigin ?? options.salesforceOrigin,
|
|
118
|
+
frontdoorUrl: frontdoorUrl ?? options.frontdoorUrl,
|
|
119
|
+
agentforceClientConfig: normalizedAgentforceClientConfig,
|
|
120
|
+
});
|
|
121
|
+
singleton.initialized = true;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const shouldFetchFrontdoor = window.location.hostname === "localhost";
|
|
125
|
+
|
|
126
|
+
if (shouldFetchFrontdoor) {
|
|
127
|
+
singleton.initPromise = fetch("/__lo/frontdoor")
|
|
128
|
+
.then(async (res) => {
|
|
129
|
+
if (!res.ok) {
|
|
130
|
+
console.error("frontdoor fetch failed");
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const { frontdoorUrl: resolvedFrontdoorUrl } = await res.json();
|
|
134
|
+
initialize({ frontdoorUrl: resolvedFrontdoorUrl });
|
|
135
|
+
})
|
|
136
|
+
.catch((err) => {
|
|
137
|
+
console.error("AgentforceConversationClient: failed to fetch frontdoor URL", err);
|
|
138
|
+
})
|
|
139
|
+
.finally(() => {
|
|
140
|
+
singleton.initPromise = undefined;
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
singleton.initPromise = Promise.resolve()
|
|
144
|
+
.then(() => {
|
|
145
|
+
initialize(getDefaultEmbedOptions());
|
|
146
|
+
})
|
|
147
|
+
.catch((err) => {
|
|
148
|
+
console.error("AgentforceConversationClient: failed to embed Agentforce client", err);
|
|
149
|
+
})
|
|
150
|
+
.finally(() => {
|
|
151
|
+
singleton.initPromise = undefined;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return () => {
|
|
156
|
+
// Intentionally no cleanup:
|
|
157
|
+
// This component guarantees a single LO initialization per window.
|
|
158
|
+
};
|
|
159
|
+
}, [salesforceOrigin, frontdoorUrl, normalizedAgentforceClientConfig, inline]);
|
|
160
|
+
|
|
161
|
+
if (!inline) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return <div ref={containerRef} />;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export default AgentforceConversationClient;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { AlertCircleIcon, CheckCircle2Icon } from 'lucide-react';
|
|
3
|
+
import { Alert, AlertDescription } from '../../components/ui/alert';
|
|
4
|
+
import { useId } from 'react';
|
|
5
|
+
|
|
6
|
+
const statusAlertVariants = cva('', {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
error: '',
|
|
10
|
+
success: '',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
variant: 'error',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
interface StatusAlertProps extends VariantProps<typeof statusAlertVariants> {
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
/** Alert variant type. @default "error" */
|
|
21
|
+
variant?: 'error' | 'success';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Status alert component for displaying error or success messages.
|
|
26
|
+
* Returns null if no children are provided.
|
|
27
|
+
*/
|
|
28
|
+
export function StatusAlert({ children, variant = 'error' }: StatusAlertProps) {
|
|
29
|
+
const descriptionId = useId();
|
|
30
|
+
if (!children) return null;
|
|
31
|
+
|
|
32
|
+
const isError = variant === 'error';
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Alert
|
|
36
|
+
variant={isError ? 'destructive' : 'default'}
|
|
37
|
+
className={statusAlertVariants({ variant })}
|
|
38
|
+
aria-describedby={descriptionId}
|
|
39
|
+
role={isError ? 'alert' : 'status'}
|
|
40
|
+
>
|
|
41
|
+
{isError ? (
|
|
42
|
+
<AlertCircleIcon aria-hidden="true" />
|
|
43
|
+
) : (
|
|
44
|
+
<CheckCircle2Icon aria-hidden="true" />
|
|
45
|
+
)}
|
|
46
|
+
<AlertDescription id={descriptionId}>{children}</AlertDescription>
|
|
47
|
+
</Alert>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Card,
|
|
3
|
+
CardContent,
|
|
4
|
+
CardDescription,
|
|
5
|
+
CardHeader,
|
|
6
|
+
CardTitle,
|
|
7
|
+
} from '../../components/ui/card';
|
|
8
|
+
|
|
9
|
+
interface CardLayoutProps {
|
|
10
|
+
title: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Card layout component for authentication pages.
|
|
17
|
+
* Provides CardHeader with title and optional description, and CardContent.
|
|
18
|
+
*/
|
|
19
|
+
export function CardLayout({ title, description, children }: CardLayoutProps) {
|
|
20
|
+
return (
|
|
21
|
+
<Card>
|
|
22
|
+
<CardHeader>
|
|
23
|
+
<CardTitle className="text-2xl">{title}</CardTitle>
|
|
24
|
+
{description && <CardDescription>{description}</CardDescription>}
|
|
25
|
+
</CardHeader>
|
|
26
|
+
<CardContent>{children}</CardContent>
|
|
27
|
+
</Card>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
import { cn } from '../../lib/utils';
|
|
5
|
+
|
|
6
|
+
const alertVariants = cva(
|
|
7
|
+
"grid gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4 w-full relative group/alert",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: 'bg-card text-card-foreground',
|
|
12
|
+
destructive:
|
|
13
|
+
'text-destructive bg-card *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
variant: 'default',
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
function Alert({
|
|
23
|
+
className,
|
|
24
|
+
variant,
|
|
25
|
+
...props
|
|
26
|
+
}: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>) {
|
|
27
|
+
return (
|
|
28
|
+
<div
|
|
29
|
+
data-slot="alert"
|
|
30
|
+
role="alert"
|
|
31
|
+
className={cn(alertVariants({ variant }), className)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function AlertTitle({ className, ...props }: React.ComponentProps<'div'>) {
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
data-slot="alert-title"
|
|
41
|
+
className={cn(
|
|
42
|
+
'font-medium group-has-[>svg]/alert:col-start-2 [&_a]:hover:text-foreground [&_a]:underline [&_a]:underline-offset-3',
|
|
43
|
+
className
|
|
44
|
+
)}
|
|
45
|
+
{...props}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function AlertDescription({
|
|
51
|
+
className,
|
|
52
|
+
...props
|
|
53
|
+
}: React.ComponentProps<'div'>) {
|
|
54
|
+
return (
|
|
55
|
+
<div
|
|
56
|
+
data-slot="alert-description"
|
|
57
|
+
className={cn(
|
|
58
|
+
'text-muted-foreground text-sm text-balance md:text-pretty [&_p:not(:last-child)]:mb-4 [&_a]:hover:text-foreground [&_a]:underline [&_a]:underline-offset-3',
|
|
59
|
+
className
|
|
60
|
+
)}
|
|
61
|
+
{...props}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function AlertAction({ className, ...props }: React.ComponentProps<'div'>) {
|
|
67
|
+
return (
|
|
68
|
+
<div
|
|
69
|
+
data-slot="alert-action"
|
|
70
|
+
className={cn('absolute top-2 right-2', className)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { Alert, AlertTitle, AlertDescription, AlertAction };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { Slot } from 'radix-ui';
|
|
4
|
+
|
|
5
|
+
import { cn } from '@/lib/utils';
|
|
6
|
+
|
|
7
|
+
const badgeVariants = cva(
|
|
8
|
+
'inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3',
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: 'bg-primary text-primary-foreground [a&]:hover:bg-primary/90',
|
|
13
|
+
secondary:
|
|
14
|
+
'bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90',
|
|
15
|
+
destructive:
|
|
16
|
+
'bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90',
|
|
17
|
+
outline:
|
|
18
|
+
'border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground',
|
|
19
|
+
ghost: '[a&]:hover:bg-accent [a&]:hover:text-accent-foreground',
|
|
20
|
+
link: 'text-primary underline-offset-4 [a&]:hover:underline',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
variant: 'default',
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
function Badge({
|
|
30
|
+
className,
|
|
31
|
+
variant = 'default',
|
|
32
|
+
asChild = false,
|
|
33
|
+
...props
|
|
34
|
+
}: React.ComponentProps<'span'> &
|
|
35
|
+
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
|
36
|
+
const Comp = asChild ? Slot.Root : 'span';
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Comp
|
|
40
|
+
data-slot="badge"
|
|
41
|
+
data-variant={variant}
|
|
42
|
+
className={cn(badgeVariants({ variant }), className)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChevronRight, MoreHorizontal } from 'lucide-react';
|
|
3
|
+
import { Slot } from 'radix-ui';
|
|
4
|
+
|
|
5
|
+
import { cn } from '@/lib/utils';
|
|
6
|
+
|
|
7
|
+
function Breadcrumb({ ...props }: React.ComponentProps<'nav'>) {
|
|
8
|
+
return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function BreadcrumbList({ className, ...props }: React.ComponentProps<'ol'>) {
|
|
12
|
+
return (
|
|
13
|
+
<ol
|
|
14
|
+
data-slot="breadcrumb-list"
|
|
15
|
+
className={cn(
|
|
16
|
+
'flex flex-wrap items-center gap-1.5 text-sm break-words text-muted-foreground sm:gap-2.5',
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function BreadcrumbItem({ className, ...props }: React.ComponentProps<'li'>) {
|
|
25
|
+
return (
|
|
26
|
+
<li
|
|
27
|
+
data-slot="breadcrumb-item"
|
|
28
|
+
className={cn('inline-flex items-center gap-1.5', className)}
|
|
29
|
+
{...props}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function BreadcrumbLink({
|
|
35
|
+
asChild,
|
|
36
|
+
className,
|
|
37
|
+
...props
|
|
38
|
+
}: React.ComponentProps<'a'> & {
|
|
39
|
+
asChild?: boolean;
|
|
40
|
+
}) {
|
|
41
|
+
const Comp = asChild ? Slot.Root : 'a';
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Comp
|
|
45
|
+
data-slot="breadcrumb-link"
|
|
46
|
+
className={cn('transition-colors hover:text-foreground', className)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function BreadcrumbPage({ className, ...props }: React.ComponentProps<'span'>) {
|
|
53
|
+
return (
|
|
54
|
+
<span
|
|
55
|
+
data-slot="breadcrumb-page"
|
|
56
|
+
role="link"
|
|
57
|
+
aria-disabled="true"
|
|
58
|
+
aria-current="page"
|
|
59
|
+
className={cn('font-normal text-foreground', className)}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function BreadcrumbSeparator({
|
|
66
|
+
children,
|
|
67
|
+
className,
|
|
68
|
+
...props
|
|
69
|
+
}: React.ComponentProps<'li'>) {
|
|
70
|
+
return (
|
|
71
|
+
<li
|
|
72
|
+
data-slot="breadcrumb-separator"
|
|
73
|
+
role="presentation"
|
|
74
|
+
aria-hidden="true"
|
|
75
|
+
className={cn('[&>svg]:size-3.5', className)}
|
|
76
|
+
{...props}
|
|
77
|
+
>
|
|
78
|
+
{children ?? <ChevronRight />}
|
|
79
|
+
</li>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function BreadcrumbEllipsis({
|
|
84
|
+
className,
|
|
85
|
+
...props
|
|
86
|
+
}: React.ComponentProps<'span'>) {
|
|
87
|
+
return (
|
|
88
|
+
<span
|
|
89
|
+
data-slot="breadcrumb-ellipsis"
|
|
90
|
+
role="presentation"
|
|
91
|
+
aria-hidden="true"
|
|
92
|
+
className={cn('flex size-9 items-center justify-center', className)}
|
|
93
|
+
{...props}
|
|
94
|
+
>
|
|
95
|
+
<MoreHorizontal className="size-4" />
|
|
96
|
+
<span className="sr-only">More</span>
|
|
97
|
+
</span>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
Breadcrumb,
|
|
103
|
+
BreadcrumbList,
|
|
104
|
+
BreadcrumbItem,
|
|
105
|
+
BreadcrumbLink,
|
|
106
|
+
BreadcrumbPage,
|
|
107
|
+
BreadcrumbSeparator,
|
|
108
|
+
BreadcrumbEllipsis,
|
|
109
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { Slot } from 'radix-ui';
|
|
4
|
+
|
|
5
|
+
import { cn } from '../../lib/utils';
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-lg border border-transparent bg-clip-padding text-sm font-medium focus-visible:ring-3 aria-invalid:ring-3 [&_svg:not([class*='size-'])]:size-4 inline-flex items-center justify-center whitespace-nowrap transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none group/button select-none",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: 'bg-primary text-primary-foreground [a]:hover:bg-primary/80',
|
|
13
|
+
outline:
|
|
14
|
+
'border-border bg-background hover:bg-muted hover:text-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 aria-expanded:bg-muted aria-expanded:text-foreground',
|
|
15
|
+
secondary:
|
|
16
|
+
'bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground',
|
|
17
|
+
ghost:
|
|
18
|
+
'hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground',
|
|
19
|
+
destructive:
|
|
20
|
+
'bg-destructive/10 hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/20 text-destructive focus-visible:border-destructive/40 dark:hover:bg-destructive/30',
|
|
21
|
+
link: 'text-primary underline-offset-4 hover:underline',
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
default:
|
|
25
|
+
'h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
|
|
26
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
27
|
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
28
|
+
lg: 'h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3',
|
|
29
|
+
icon: 'size-8',
|
|
30
|
+
'icon-xs':
|
|
31
|
+
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
32
|
+
'icon-sm':
|
|
33
|
+
'size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg',
|
|
34
|
+
'icon-lg': 'size-9',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
defaultVariants: {
|
|
38
|
+
variant: 'default',
|
|
39
|
+
size: 'default',
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
function Button({
|
|
45
|
+
className,
|
|
46
|
+
variant = 'default',
|
|
47
|
+
size = 'default',
|
|
48
|
+
asChild = false,
|
|
49
|
+
...props
|
|
50
|
+
}: React.ComponentProps<'button'> &
|
|
51
|
+
VariantProps<typeof buttonVariants> & {
|
|
52
|
+
asChild?: boolean;
|
|
53
|
+
}) {
|
|
54
|
+
const Comp = asChild ? Slot.Root : 'button';
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Comp
|
|
58
|
+
data-slot="button"
|
|
59
|
+
data-variant={variant}
|
|
60
|
+
data-size={size}
|
|
61
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
62
|
+
{...(props as any)}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { Button, buttonVariants };
|