@chatsdk-dev/elements 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/dist/chunk-2LHKM7RD.js +14 -0
- package/dist/chunk-5UMYP6MD.js +10 -0
- package/dist/chunk-AP4MG32M.js +36 -0
- package/dist/chunk-CFM57HOS.js +358 -0
- package/dist/chunk-EGIUE7H2.js +37 -0
- package/dist/chunk-M5OONVIO.js +90 -0
- package/dist/chunk-MXTBCHYC.js +31 -0
- package/dist/chunk-NIC3MOMY.js +55 -0
- package/dist/chunk-QTRMNIG3.js +83 -0
- package/dist/chunk-R7G3RQLU.js +36 -0
- package/dist/chunk-RJG5D2TM.js +113 -0
- package/dist/chunk-SLJNKQ2G.js +125 -0
- package/dist/chunk-TDEFIW2L.js +9 -0
- package/dist/chunk-TDP6D7U7.js +551 -0
- package/dist/chunk-V2ITXC65.js +24 -0
- package/dist/chunk-VS55HRUS.js +16 -0
- package/dist/chunk-VYDYCGJL.js +25 -0
- package/dist/chunk-X5YUF2YM.js +113 -0
- package/dist/chunk-YX46JVQN.js +78 -0
- package/dist/chunk-YXAMLTTT.js +16 -0
- package/dist/chunk-YXFVHSY4.js +51 -0
- package/dist/chunk-ZCSZX3OI.js +4 -0
- package/dist/common/use-copy-to-clipboard.d.ts +3 -0
- package/dist/common/use-copy-to-clipboard.js +33 -0
- package/dist/common/utilts.d.ts +8 -0
- package/dist/common/utilts.js +28 -0
- package/dist/components/ai-elements/actions.d.ts +13 -0
- package/dist/components/ai-elements/actions.js +42 -0
- package/dist/components/ai-elements/agent.d.ts +31 -0
- package/dist/components/ai-elements/agent.js +77 -0
- package/dist/components/ai-elements/artifact.d.ts +27 -0
- package/dist/components/ai-elements/artifact.js +108 -0
- package/dist/components/ai-elements/attachments.d.ts +57 -0
- package/dist/components/ai-elements/attachments.js +258 -0
- package/dist/components/ai-elements/audio-player.d.ts +33 -0
- package/dist/components/ai-elements/audio-player.js +199 -0
- package/dist/components/ai-elements/canvas.d.ts +10 -0
- package/dist/components/ai-elements/canvas.js +24 -0
- package/dist/components/ai-elements/chain-of-thought.d.ts +34 -0
- package/dist/components/ai-elements/chain-of-thought.js +159 -0
- package/dist/components/ai-elements/checkpoint.d.ts +16 -0
- package/dist/components/ai-elements/checkpoint.js +47 -0
- package/dist/components/ai-elements/code-block.d.ts +48 -0
- package/dist/components/ai-elements/code-block.js +1 -0
- package/dist/components/ai-elements/commit.d.ts +68 -0
- package/dist/components/ai-elements/commit.js +314 -0
- package/dist/components/ai-elements/confirmation.d.ts +52 -0
- package/dist/components/ai-elements/confirmation.js +76 -0
- package/dist/components/ai-elements/connection.d.ts +5 -0
- package/dist/components/ai-elements/connection.js +34 -0
- package/dist/components/ai-elements/context.d.ts +36 -0
- package/dist/components/ai-elements/context.js +320 -0
- package/dist/components/ai-elements/controls.d.ts +8 -0
- package/dist/components/ai-elements/controls.js +17 -0
- package/dist/components/ai-elements/conversation.d.ts +27 -0
- package/dist/components/ai-elements/conversation.js +119 -0
- package/dist/components/ai-elements/edge.d.ts +9 -0
- package/dist/components/ai-elements/edge.js +111 -0
- package/dist/components/ai-elements/environment-variables.d.ts +42 -0
- package/dist/components/ai-elements/environment-variables.js +208 -0
- package/dist/components/ai-elements/file-tree.d.ts +30 -0
- package/dist/components/ai-elements/file-tree.js +212 -0
- package/dist/components/ai-elements/image.d.ts +10 -0
- package/dist/components/ai-elements/image.js +23 -0
- package/dist/components/ai-elements/inline-citation.d.ts +42 -0
- package/dist/components/ai-elements/inline-citation.js +203 -0
- package/dist/components/ai-elements/jsx-preview.d.ts +33 -0
- package/dist/components/ai-elements/jsx-preview.js +206 -0
- package/dist/components/ai-elements/loader.d.ts +9 -0
- package/dist/components/ai-elements/loader.js +115 -0
- package/dist/components/ai-elements/message.d.ts +42 -0
- package/dist/components/ai-elements/message.js +259 -0
- package/dist/components/ai-elements/mic-selector.d.ts +49 -0
- package/dist/components/ai-elements/mic-selector.js +252 -0
- package/dist/components/ai-elements/model-selector.d.ts +39 -0
- package/dist/components/ai-elements/model-selector.js +73 -0
- package/dist/components/ai-elements/node.d.ts +25 -0
- package/dist/components/ai-elements/node.js +41 -0
- package/dist/components/ai-elements/open-in-chat.d.ts +32 -0
- package/dist/components/ai-elements/open-in-chat.js +366 -0
- package/dist/components/ai-elements/package-info.d.ts +32 -0
- package/dist/components/ai-elements/package-info.js +162 -0
- package/dist/components/ai-elements/panel.d.ts +8 -0
- package/dist/components/ai-elements/panel.js +17 -0
- package/dist/components/ai-elements/persona.d.ts +50 -0
- package/dist/components/ai-elements/persona.js +209 -0
- package/dist/components/ai-elements/plan.d.ts +29 -0
- package/dist/components/ai-elements/plan.js +95 -0
- package/dist/components/ai-elements/prompt-input.d.ts +153 -0
- package/dist/components/ai-elements/prompt-input.js +939 -0
- package/dist/components/ai-elements/queue.d.ts +65 -0
- package/dist/components/ai-elements/queue.js +179 -0
- package/dist/components/ai-elements/reasoning.d.ts +30 -0
- package/dist/components/ai-elements/reasoning.js +161 -0
- package/dist/components/ai-elements/response.d.ts +9 -0
- package/dist/components/ai-elements/response.js +33 -0
- package/dist/components/ai-elements/sandbox.d.ts +28 -0
- package/dist/components/ai-elements/sandbox.js +98 -0
- package/dist/components/ai-elements/schema-display.d.ts +58 -0
- package/dist/components/ai-elements/schema-display.js +313 -0
- package/dist/components/ai-elements/shimmer.d.ts +14 -0
- package/dist/components/ai-elements/shimmer.js +1 -0
- package/dist/components/ai-elements/snippet.d.ts +22 -0
- package/dist/components/ai-elements/snippet.js +90 -0
- package/dist/components/ai-elements/sources.d.ts +16 -0
- package/dist/components/ai-elements/sources.js +62 -0
- package/dist/components/ai-elements/speech-input.d.ts +57 -0
- package/dist/components/ai-elements/speech-input.js +206 -0
- package/dist/components/ai-elements/stack-trace.d.ts +42 -0
- package/dist/components/ai-elements/stack-trace.js +377 -0
- package/dist/components/ai-elements/suggestion.d.ts +14 -0
- package/dist/components/ai-elements/suggestion.js +41 -0
- package/dist/components/ai-elements/task.d.ts +18 -0
- package/dist/components/ai-elements/task.js +60 -0
- package/dist/components/ai-elements/terminal.d.ts +31 -0
- package/dist/components/ai-elements/terminal.js +203 -0
- package/dist/components/ai-elements/test-results.d.ts +61 -0
- package/dist/components/ai-elements/test-results.js +349 -0
- package/dist/components/ai-elements/tool.d.ts +35 -0
- package/dist/components/ai-elements/tool.js +2 -0
- package/dist/components/ai-elements/toolbar.d.ts +8 -0
- package/dist/components/ai-elements/toolbar.js +18 -0
- package/dist/components/ai-elements/transcription.d.ts +19 -0
- package/dist/components/ai-elements/transcription.js +90 -0
- package/dist/components/ai-elements/voice-selector.d.ts +66 -0
- package/dist/components/ai-elements/voice-selector.js +332 -0
- package/dist/components/ai-elements/web-preview.d.ts +38 -0
- package/dist/components/ai-elements/web-preview.js +214 -0
- package/dist/components/info-card.d.ts +14 -0
- package/dist/components/info-card.js +1 -0
- package/dist/components/responsive-alert-dialog.d.ts +19 -0
- package/dist/components/responsive-alert-dialog.js +1 -0
- package/dist/components/responsive-dialog.d.ts +14 -0
- package/dist/components/responsive-dialog.js +1 -0
- package/dist/config-IcWUmjwj.d.ts +239 -0
- package/dist/features/chat/chat-card.d.ts +5 -0
- package/dist/features/chat/chat-card.js +14 -0
- package/dist/features/chat/chat-element/chat-element.d.ts +8 -0
- package/dist/features/chat/chat-element/chat-element.js +14 -0
- package/dist/features/chat/chat-element/use-chat.d.ts +21 -0
- package/dist/features/chat/chat-element/use-chat.js +14 -0
- package/dist/features/chat/chat-element/use-initial-messages.d.ts +20 -0
- package/dist/features/chat/chat-element/use-initial-messages.js +14 -0
- package/dist/features/chat/chat-header/chat-header.d.ts +8 -0
- package/dist/features/chat/chat-header/chat-header.js +14 -0
- package/dist/features/chat/chat-header/chat-menu.d.ts +5 -0
- package/dist/features/chat/chat-header/chat-menu.js +2 -0
- package/dist/features/chat/chat-history/chat-history-empty.d.ts +5 -0
- package/dist/features/chat/chat-history/chat-history-empty.js +1 -0
- package/dist/features/chat/chat-history/chat-history.d.ts +5 -0
- package/dist/features/chat/chat-history/chat-history.js +14 -0
- package/dist/features/chat/chat-message.d.ts +10 -0
- package/dist/features/chat/chat-message.js +1 -0
- package/dist/features/chat/chat-molecule.d.ts +35 -0
- package/dist/features/chat/chat-molecule.js +14 -0
- package/dist/features/chat/chat-prompt-input.d.ts +16 -0
- package/dist/features/chat/chat-prompt-input.js +14 -0
- package/dist/features/chat/chat.context.d.ts +26 -0
- package/dist/features/chat/chat.context.js +13 -0
- package/dist/features/chat/index.d.ts +14 -0
- package/dist/features/chat/index.js +14 -0
- package/dist/features/chat/queries/query-keys.d.ts +8 -0
- package/dist/features/chat/queries/query-keys.js +1 -0
- package/dist/features/chat/queries/use-create-conversation-mutation.d.ts +29 -0
- package/dist/features/chat/queries/use-create-conversation-mutation.js +38 -0
- package/dist/features/chat/queries/use-get-chat-query.d.ts +9 -0
- package/dist/features/chat/queries/use-get-chat-query.js +14 -0
- package/dist/features/chat/queries/use-get-conversation-query.d.ts +62 -0
- package/dist/features/chat/queries/use-get-conversation-query.js +14 -0
- package/dist/features/chat/queries/use-list-conversations-query.d.ts +29 -0
- package/dist/features/chat/queries/use-list-conversations-query.js +14 -0
- package/dist/features/chat/store.d.ts +13 -0
- package/dist/features/chat/store.js +1 -0
- package/dist/features/chat/utils.d.ts +5 -0
- package/dist/features/chat/utils.js +1 -0
- package/dist/features/data-fetching/use-api-client.d.ts +5 -0
- package/dist/features/data-fetching/use-api-client.js +14 -0
- package/dist/features/logger/logger.d.ts +9 -0
- package/dist/features/logger/logger.js +1 -0
- package/dist/features/molecule/chatsdk-provider.d.ts +19 -0
- package/dist/features/molecule/chatsdk-provider.js +26 -0
- package/dist/features/molecule/constants.d.ts +3 -0
- package/dist/features/molecule/constants.js +1 -0
- package/dist/features/molecule/molecule-provider.d.ts +39 -0
- package/dist/features/molecule/molecule-provider.js +1 -0
- package/dist/features/molecule/store.d.ts +53 -0
- package/dist/features/molecule/store.js +3 -0
- package/dist/features/molecule/types/api.d.ts +8 -0
- package/dist/features/molecule/types/api.js +1 -0
- package/dist/features/molecule/types/callbacks.d.ts +22 -0
- package/dist/features/molecule/types/callbacks.js +1 -0
- package/dist/features/molecule/types/config.d.ts +10 -0
- package/dist/features/molecule/types/config.js +1 -0
- package/dist/features/molecule/types/context.d.ts +11 -0
- package/dist/features/molecule/types/context.js +1 -0
- package/dist/features/molecule/types/locale.d.ts +9 -0
- package/dist/features/molecule/types/locale.js +1 -0
- package/dist/features/molecule/types/theme.d.ts +38 -0
- package/dist/features/molecule/types/theme.js +1 -0
- package/dist/features/molecule/types/translations.d.ts +10 -0
- package/dist/features/molecule/types/translations.js +1 -0
- package/dist/features/molecule/use-merge-global-config.d.ts +22 -0
- package/dist/features/molecule/use-merge-global-config.js +5 -0
- package/dist/features/molecule/use-molecule-config.d.ts +41 -0
- package/dist/features/molecule/use-molecule-config.js +6 -0
- package/dist/features/molecule/utils.d.ts +10 -0
- package/dist/features/molecule/utils.js +1 -0
- package/dist/i18n/config.d.ts +61 -0
- package/dist/i18n/config.js +1 -0
- package/dist/i18n/i18next.d.ts +11 -0
- package/dist/i18n/i18next.js +2 -0
- package/dist/i18n/utils.d.ts +11 -0
- package/dist/i18n/utils.js +6 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/styles.css +6811 -0
- package/package.json +123 -0
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @chatsdk-dev/elements
|
|
2
|
+
|
|
3
|
+
AI components for ChatSDK
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @chatsdk/elements
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @chatsdk/elements
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Chat, ChatSDKProvider } from "@chatsdk-dev/elements";
|
|
17
|
+
import "@chatsdk-dev/elements/styles.css";
|
|
18
|
+
|
|
19
|
+
function App() {
|
|
20
|
+
return (
|
|
21
|
+
<MoleculeProvider
|
|
22
|
+
config={{
|
|
23
|
+
api: {
|
|
24
|
+
convexUrl: process.env.NEXT_PUBLIC_CONVEX_CLOUD_URL,
|
|
25
|
+
},
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<Chat />
|
|
29
|
+
</MoleculeProvider>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
The library uses a configuration system that allows you to customize:
|
|
37
|
+
|
|
38
|
+
- API endpoints
|
|
39
|
+
- Theming and styling
|
|
40
|
+
- Internationalization
|
|
41
|
+
- Context and user settings
|
|
42
|
+
|
|
43
|
+
Info: In the idea of layered composition and the layers particles (base-ui), atoms (shadcn, coss), molecules (patterns lke composed atoms), elements (sophisticated molecules with advanced functionality like api integration, advanced state management etc.) this `elements` package combines the layers molecules and elements as there are so far only a few.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
|
|
3
|
+
// src/features/chat/store.ts
|
|
4
|
+
var createChatStore = () => create((set) => ({
|
|
5
|
+
tab: "chat",
|
|
6
|
+
conversationType: "new",
|
|
7
|
+
selectedConversationId: void 0,
|
|
8
|
+
setTab: (tab) => set({ tab }),
|
|
9
|
+
setSelectedConversationId: (id) => set({ selectedConversationId: id }),
|
|
10
|
+
setConversationType: (type) => set({ conversationType: type })
|
|
11
|
+
}));
|
|
12
|
+
var useChatStore = createChatStore();
|
|
13
|
+
|
|
14
|
+
export { useChatStore };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/features/chat/utils.ts
|
|
2
|
+
function getInitialMessagesFromStrings(messages) {
|
|
3
|
+
return messages.map((message) => ({
|
|
4
|
+
id: crypto.randomUUID(),
|
|
5
|
+
role: "assistant",
|
|
6
|
+
parts: [{ type: "text", text: message }]
|
|
7
|
+
}));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { getInitialMessagesFromStrings };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useChatStore } from './chunk-2LHKM7RD.js';
|
|
2
|
+
import { Ellipsis } from 'lucide-react';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { buttonVariants } from '@chatsdk-dev/ui/components/button';
|
|
5
|
+
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@chatsdk-dev/ui/components/dropdown-menu';
|
|
6
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
function ChatMenu() {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const { setSelectedConversationId, setTab, setConversationType } = useChatStore();
|
|
11
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
12
|
+
/* @__PURE__ */ jsx(
|
|
13
|
+
DropdownMenuTrigger,
|
|
14
|
+
{
|
|
15
|
+
className: buttonVariants({ variant: "transparent" }),
|
|
16
|
+
children: /* @__PURE__ */ jsx(Ellipsis, { className: "size-4" })
|
|
17
|
+
}
|
|
18
|
+
),
|
|
19
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { children: [
|
|
20
|
+
/* @__PURE__ */ jsx(
|
|
21
|
+
DropdownMenuItem,
|
|
22
|
+
{
|
|
23
|
+
onClick: () => {
|
|
24
|
+
setConversationType("new");
|
|
25
|
+
setSelectedConversationId();
|
|
26
|
+
setTab("chat");
|
|
27
|
+
},
|
|
28
|
+
children: t("header.menu.new-conversation-menu-item-label")
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { onClick: () => setTab("history"), children: t("header.menu.history-menu-item-label") })
|
|
32
|
+
] })
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { ChatMenu };
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { Button } from '@chatsdk-dev/ui/components/button';
|
|
2
|
+
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@chatsdk-dev/ui/components/select';
|
|
3
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
4
|
+
import { CheckIcon, CopyIcon } from 'lucide-react';
|
|
5
|
+
import { createContext, memo, useMemo, useState, useRef, useEffect, useContext, useCallback } from 'react';
|
|
6
|
+
import { createHighlighter } from 'shiki';
|
|
7
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
// src/components/ai-elements/code-block.tsx
|
|
10
|
+
var isItalic = (fontStyle) => fontStyle && fontStyle & 1;
|
|
11
|
+
var isBold = (fontStyle) => fontStyle && fontStyle & 2;
|
|
12
|
+
var isUnderline = (fontStyle) => (
|
|
13
|
+
// oxlint-disable-next-line eslint(no-bitwise)
|
|
14
|
+
fontStyle && fontStyle & 4
|
|
15
|
+
);
|
|
16
|
+
var addKeysToTokens = (lines) => lines.map((line, lineIdx) => ({
|
|
17
|
+
key: `line-${lineIdx}`,
|
|
18
|
+
tokens: line.map((token, tokenIdx) => ({
|
|
19
|
+
key: `line-${lineIdx}-${tokenIdx}`,
|
|
20
|
+
token
|
|
21
|
+
}))
|
|
22
|
+
}));
|
|
23
|
+
var TokenSpan = ({ token }) => /* @__PURE__ */ jsx(
|
|
24
|
+
"span",
|
|
25
|
+
{
|
|
26
|
+
className: "dark:!bg-[var(--shiki-dark-bg)] dark:!text-[var(--shiki-dark)]",
|
|
27
|
+
style: {
|
|
28
|
+
backgroundColor: token.bgColor,
|
|
29
|
+
color: token.color,
|
|
30
|
+
fontStyle: isItalic(token.fontStyle) ? "italic" : void 0,
|
|
31
|
+
fontWeight: isBold(token.fontStyle) ? "bold" : void 0,
|
|
32
|
+
textDecoration: isUnderline(token.fontStyle) ? "underline" : void 0,
|
|
33
|
+
...token.htmlStyle
|
|
34
|
+
},
|
|
35
|
+
children: token.content
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
var LINE_NUMBER_CLASSES = cn(
|
|
39
|
+
"block",
|
|
40
|
+
"before:content-[counter(line)]",
|
|
41
|
+
"before:inline-block",
|
|
42
|
+
"before:[counter-increment:line]",
|
|
43
|
+
"before:w-8",
|
|
44
|
+
"before:mr-4",
|
|
45
|
+
"before:text-right",
|
|
46
|
+
"before:text-muted-foreground/50",
|
|
47
|
+
"before:font-mono",
|
|
48
|
+
"before:select-none"
|
|
49
|
+
);
|
|
50
|
+
var LineSpan = ({
|
|
51
|
+
keyedLine,
|
|
52
|
+
showLineNumbers
|
|
53
|
+
}) => /* @__PURE__ */ jsx("span", { className: showLineNumbers ? LINE_NUMBER_CLASSES : "block", children: keyedLine.tokens.length === 0 ? "\n" : keyedLine.tokens.map(({ token, key }) => /* @__PURE__ */ jsx(TokenSpan, { token }, key)) });
|
|
54
|
+
var CodeBlockContext = createContext({
|
|
55
|
+
code: ""
|
|
56
|
+
});
|
|
57
|
+
var highlighterCache = /* @__PURE__ */ new Map();
|
|
58
|
+
var tokensCache = /* @__PURE__ */ new Map();
|
|
59
|
+
var subscribers = /* @__PURE__ */ new Map();
|
|
60
|
+
var getTokensCacheKey = (code, language) => {
|
|
61
|
+
const start = code.slice(0, 100);
|
|
62
|
+
const end = code.length > 100 ? code.slice(-100) : "";
|
|
63
|
+
return `${language}:${code.length}:${start}:${end}`;
|
|
64
|
+
};
|
|
65
|
+
var getHighlighter = (language) => {
|
|
66
|
+
const cached = highlighterCache.get(language);
|
|
67
|
+
if (cached) {
|
|
68
|
+
return cached;
|
|
69
|
+
}
|
|
70
|
+
const highlighterPromise = createHighlighter({
|
|
71
|
+
langs: [language],
|
|
72
|
+
themes: ["github-light", "github-dark"]
|
|
73
|
+
});
|
|
74
|
+
highlighterCache.set(language, highlighterPromise);
|
|
75
|
+
return highlighterPromise;
|
|
76
|
+
};
|
|
77
|
+
var createRawTokens = (code) => ({
|
|
78
|
+
bg: "transparent",
|
|
79
|
+
fg: "inherit",
|
|
80
|
+
tokens: code.split("\n").map(
|
|
81
|
+
(line) => line === "" ? [] : [
|
|
82
|
+
{
|
|
83
|
+
color: "inherit",
|
|
84
|
+
content: line
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
)
|
|
88
|
+
});
|
|
89
|
+
var highlightCode = (code, language, callback) => {
|
|
90
|
+
const tokensCacheKey = getTokensCacheKey(code, language);
|
|
91
|
+
const cached = tokensCache.get(tokensCacheKey);
|
|
92
|
+
if (cached) {
|
|
93
|
+
return cached;
|
|
94
|
+
}
|
|
95
|
+
if (callback) {
|
|
96
|
+
if (!subscribers.has(tokensCacheKey)) {
|
|
97
|
+
subscribers.set(tokensCacheKey, /* @__PURE__ */ new Set());
|
|
98
|
+
}
|
|
99
|
+
subscribers.get(tokensCacheKey)?.add(callback);
|
|
100
|
+
}
|
|
101
|
+
getHighlighter(language).then((highlighter) => {
|
|
102
|
+
const availableLangs = highlighter.getLoadedLanguages();
|
|
103
|
+
const langToUse = availableLangs.includes(language) ? language : "text";
|
|
104
|
+
const result = highlighter.codeToTokens(code, {
|
|
105
|
+
lang: langToUse,
|
|
106
|
+
themes: {
|
|
107
|
+
dark: "github-dark",
|
|
108
|
+
light: "github-light"
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
const tokenized = {
|
|
112
|
+
bg: result.bg ?? "transparent",
|
|
113
|
+
fg: result.fg ?? "inherit",
|
|
114
|
+
tokens: result.tokens
|
|
115
|
+
};
|
|
116
|
+
tokensCache.set(tokensCacheKey, tokenized);
|
|
117
|
+
const subs = subscribers.get(tokensCacheKey);
|
|
118
|
+
if (subs) {
|
|
119
|
+
for (const sub of subs) {
|
|
120
|
+
sub(tokenized);
|
|
121
|
+
}
|
|
122
|
+
subscribers.delete(tokensCacheKey);
|
|
123
|
+
}
|
|
124
|
+
}).catch((error) => {
|
|
125
|
+
console.error("Failed to highlight code:", error);
|
|
126
|
+
subscribers.delete(tokensCacheKey);
|
|
127
|
+
});
|
|
128
|
+
return null;
|
|
129
|
+
};
|
|
130
|
+
var CodeBlockBody = memo(
|
|
131
|
+
({
|
|
132
|
+
tokenized,
|
|
133
|
+
showLineNumbers,
|
|
134
|
+
className
|
|
135
|
+
}) => {
|
|
136
|
+
const preStyle = useMemo(
|
|
137
|
+
() => ({
|
|
138
|
+
backgroundColor: tokenized.bg,
|
|
139
|
+
color: tokenized.fg
|
|
140
|
+
}),
|
|
141
|
+
[tokenized.bg, tokenized.fg]
|
|
142
|
+
);
|
|
143
|
+
const keyedLines = useMemo(
|
|
144
|
+
() => addKeysToTokens(tokenized.tokens),
|
|
145
|
+
[tokenized.tokens]
|
|
146
|
+
);
|
|
147
|
+
return /* @__PURE__ */ jsx(
|
|
148
|
+
"pre",
|
|
149
|
+
{
|
|
150
|
+
className: cn(
|
|
151
|
+
"dark:!bg-[var(--shiki-dark-bg)] dark:!text-[var(--shiki-dark)] m-0 p-4 text-sm",
|
|
152
|
+
className
|
|
153
|
+
),
|
|
154
|
+
style: preStyle,
|
|
155
|
+
children: /* @__PURE__ */ jsx(
|
|
156
|
+
"code",
|
|
157
|
+
{
|
|
158
|
+
className: cn(
|
|
159
|
+
"font-mono text-sm",
|
|
160
|
+
showLineNumbers && "[counter-increment:line_0] [counter-reset:line]"
|
|
161
|
+
),
|
|
162
|
+
children: keyedLines.map((keyedLine) => /* @__PURE__ */ jsx(
|
|
163
|
+
LineSpan,
|
|
164
|
+
{
|
|
165
|
+
keyedLine,
|
|
166
|
+
showLineNumbers
|
|
167
|
+
},
|
|
168
|
+
keyedLine.key
|
|
169
|
+
))
|
|
170
|
+
}
|
|
171
|
+
)
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
},
|
|
175
|
+
(prevProps, nextProps) => prevProps.tokenized === nextProps.tokenized && prevProps.showLineNumbers === nextProps.showLineNumbers && prevProps.className === nextProps.className
|
|
176
|
+
);
|
|
177
|
+
CodeBlockBody.displayName = "CodeBlockBody";
|
|
178
|
+
var CodeBlockContainer = ({
|
|
179
|
+
className,
|
|
180
|
+
language,
|
|
181
|
+
style,
|
|
182
|
+
...props
|
|
183
|
+
}) => /* @__PURE__ */ jsx(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
className: cn(
|
|
187
|
+
"group relative w-full overflow-hidden rounded-md border bg-background text-foreground",
|
|
188
|
+
className
|
|
189
|
+
),
|
|
190
|
+
"data-language": language,
|
|
191
|
+
style: {
|
|
192
|
+
containIntrinsicSize: "auto 200px",
|
|
193
|
+
contentVisibility: "auto",
|
|
194
|
+
...style
|
|
195
|
+
},
|
|
196
|
+
...props
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
var CodeBlockHeader = ({
|
|
200
|
+
children,
|
|
201
|
+
className,
|
|
202
|
+
...props
|
|
203
|
+
}) => /* @__PURE__ */ jsx(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
className: cn(
|
|
207
|
+
"flex items-center justify-between border-b bg-muted/80 px-3 py-2 text-muted-foreground text-xs",
|
|
208
|
+
className
|
|
209
|
+
),
|
|
210
|
+
...props,
|
|
211
|
+
children
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
var CodeBlockTitle = ({
|
|
215
|
+
children,
|
|
216
|
+
className,
|
|
217
|
+
...props
|
|
218
|
+
}) => /* @__PURE__ */ jsx("div", { className: cn("flex items-center gap-2", className), ...props, children });
|
|
219
|
+
var CodeBlockFilename = ({
|
|
220
|
+
children,
|
|
221
|
+
className,
|
|
222
|
+
...props
|
|
223
|
+
}) => /* @__PURE__ */ jsx("span", { className: cn("font-mono", className), ...props, children });
|
|
224
|
+
var CodeBlockActions = ({
|
|
225
|
+
children,
|
|
226
|
+
className,
|
|
227
|
+
...props
|
|
228
|
+
}) => /* @__PURE__ */ jsx(
|
|
229
|
+
"div",
|
|
230
|
+
{
|
|
231
|
+
className: cn("-my-1 -mr-1 flex items-center gap-2", className),
|
|
232
|
+
...props,
|
|
233
|
+
children
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
var CodeBlockContent = ({
|
|
237
|
+
code,
|
|
238
|
+
language,
|
|
239
|
+
showLineNumbers = false
|
|
240
|
+
}) => {
|
|
241
|
+
const rawTokens = useMemo(() => createRawTokens(code), [code]);
|
|
242
|
+
const syncTokens = useMemo(
|
|
243
|
+
() => highlightCode(code, language) ?? rawTokens,
|
|
244
|
+
[code, language, rawTokens]
|
|
245
|
+
);
|
|
246
|
+
const [asyncTokens, setAsyncTokens] = useState(null);
|
|
247
|
+
const asyncKeyRef = useRef({ code, language });
|
|
248
|
+
if (asyncKeyRef.current.code !== code || asyncKeyRef.current.language !== language) {
|
|
249
|
+
asyncKeyRef.current = { code, language };
|
|
250
|
+
setAsyncTokens(null);
|
|
251
|
+
}
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
let cancelled = false;
|
|
254
|
+
highlightCode(code, language, (result) => {
|
|
255
|
+
if (!cancelled) {
|
|
256
|
+
setAsyncTokens(result);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return () => {
|
|
260
|
+
cancelled = true;
|
|
261
|
+
};
|
|
262
|
+
}, [code, language]);
|
|
263
|
+
const tokenized = asyncTokens ?? syncTokens;
|
|
264
|
+
return /* @__PURE__ */ jsx("div", { className: "relative overflow-auto", children: /* @__PURE__ */ jsx(CodeBlockBody, { showLineNumbers, tokenized }) });
|
|
265
|
+
};
|
|
266
|
+
var CodeBlock = ({
|
|
267
|
+
code,
|
|
268
|
+
language,
|
|
269
|
+
showLineNumbers = false,
|
|
270
|
+
className,
|
|
271
|
+
children,
|
|
272
|
+
...props
|
|
273
|
+
}) => {
|
|
274
|
+
const contextValue = useMemo(() => ({ code }), [code]);
|
|
275
|
+
return /* @__PURE__ */ jsx(CodeBlockContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxs(CodeBlockContainer, { className, language, ...props, children: [
|
|
276
|
+
children,
|
|
277
|
+
/* @__PURE__ */ jsx(
|
|
278
|
+
CodeBlockContent,
|
|
279
|
+
{
|
|
280
|
+
code,
|
|
281
|
+
language,
|
|
282
|
+
showLineNumbers
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
] }) });
|
|
286
|
+
};
|
|
287
|
+
var CodeBlockCopyButton = ({
|
|
288
|
+
onCopy,
|
|
289
|
+
onError,
|
|
290
|
+
timeout = 2e3,
|
|
291
|
+
children,
|
|
292
|
+
className,
|
|
293
|
+
...props
|
|
294
|
+
}) => {
|
|
295
|
+
const [isCopied, setIsCopied] = useState(false);
|
|
296
|
+
const timeoutRef = useRef(0);
|
|
297
|
+
const { code } = useContext(CodeBlockContext);
|
|
298
|
+
const copyToClipboard = useCallback(async () => {
|
|
299
|
+
if (typeof window === "undefined" || !navigator?.clipboard?.writeText) {
|
|
300
|
+
onError?.(new Error("Clipboard API not available"));
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
try {
|
|
304
|
+
if (!isCopied) {
|
|
305
|
+
await navigator.clipboard.writeText(code);
|
|
306
|
+
setIsCopied(true);
|
|
307
|
+
onCopy?.();
|
|
308
|
+
timeoutRef.current = window.setTimeout(
|
|
309
|
+
() => setIsCopied(false),
|
|
310
|
+
timeout
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
} catch (error) {
|
|
314
|
+
onError?.(error);
|
|
315
|
+
}
|
|
316
|
+
}, [code, onCopy, onError, timeout, isCopied]);
|
|
317
|
+
useEffect(
|
|
318
|
+
() => () => {
|
|
319
|
+
window.clearTimeout(timeoutRef.current);
|
|
320
|
+
},
|
|
321
|
+
[]
|
|
322
|
+
);
|
|
323
|
+
const Icon = isCopied ? CheckIcon : CopyIcon;
|
|
324
|
+
return /* @__PURE__ */ jsx(
|
|
325
|
+
Button,
|
|
326
|
+
{
|
|
327
|
+
className: cn("shrink-0", className),
|
|
328
|
+
onClick: copyToClipboard,
|
|
329
|
+
size: "icon",
|
|
330
|
+
variant: "ghost",
|
|
331
|
+
...props,
|
|
332
|
+
children: children ?? /* @__PURE__ */ jsx(Icon, { size: 14 })
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
};
|
|
336
|
+
var CodeBlockLanguageSelector = (props) => /* @__PURE__ */ jsx(Select, { ...props });
|
|
337
|
+
var CodeBlockLanguageSelectorTrigger = ({
|
|
338
|
+
className,
|
|
339
|
+
...props
|
|
340
|
+
}) => /* @__PURE__ */ jsx(
|
|
341
|
+
SelectTrigger,
|
|
342
|
+
{
|
|
343
|
+
className: cn(
|
|
344
|
+
"h-7 border-none bg-transparent px-2 text-xs shadow-none",
|
|
345
|
+
className
|
|
346
|
+
),
|
|
347
|
+
size: "sm",
|
|
348
|
+
...props
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
var CodeBlockLanguageSelectorValue = (props) => /* @__PURE__ */ jsx(SelectValue, { ...props });
|
|
352
|
+
var CodeBlockLanguageSelectorContent = ({
|
|
353
|
+
align = "end",
|
|
354
|
+
...props
|
|
355
|
+
}) => /* @__PURE__ */ jsx(SelectContent, { align, ...props });
|
|
356
|
+
var CodeBlockLanguageSelectorItem = (props) => /* @__PURE__ */ jsx(SelectItem, { ...props });
|
|
357
|
+
|
|
358
|
+
export { CodeBlock, CodeBlockActions, CodeBlockContainer, CodeBlockContent, CodeBlockCopyButton, CodeBlockFilename, CodeBlockHeader, CodeBlockLanguageSelector, CodeBlockLanguageSelectorContent, CodeBlockLanguageSelectorItem, CodeBlockLanguageSelectorTrigger, CodeBlockLanguageSelectorValue, CodeBlockTitle, highlightCode };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
// src/components/info-card.tsx
|
|
4
|
+
function InfoCard({
|
|
5
|
+
title,
|
|
6
|
+
description,
|
|
7
|
+
children,
|
|
8
|
+
actionLabel,
|
|
9
|
+
onActionClick,
|
|
10
|
+
className
|
|
11
|
+
}) {
|
|
12
|
+
return /* @__PURE__ */ jsxs(
|
|
13
|
+
"div",
|
|
14
|
+
{
|
|
15
|
+
"data-slot": "info-card",
|
|
16
|
+
className: "rounded-xl border border-gray-200 shadow-sm p-4 bg-white text-gray-900 " + (className ?? ""),
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-3", children: [
|
|
19
|
+
/* @__PURE__ */ jsx("div", { className: "text-lg font-semibold", children: title }),
|
|
20
|
+
description ? /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-500", children: description }) : null
|
|
21
|
+
] }),
|
|
22
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm", children }),
|
|
23
|
+
actionLabel ? /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
|
|
24
|
+
"button",
|
|
25
|
+
{
|
|
26
|
+
type: "button",
|
|
27
|
+
className: "inline-flex items-center justify-center rounded-md bg-blue-600 px-4 py-2 text-white hover:bg-blue-700 active:scale-[0.98]",
|
|
28
|
+
onClick: onActionClick,
|
|
29
|
+
children: actionLabel
|
|
30
|
+
}
|
|
31
|
+
) }) : null
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { InfoCard };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
2
|
+
import { createContext, use } from 'react';
|
|
3
|
+
import { I18nextProvider } from 'react-i18next';
|
|
4
|
+
import { languages } from '@chatsdk-dev/elements/i18n/config';
|
|
5
|
+
import { i18n } from '@chatsdk-dev/elements/i18n/i18next';
|
|
6
|
+
import { getLocaleChainFromLocale } from '@chatsdk-dev/elements/i18n/utils';
|
|
7
|
+
import { jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
// src/features/molecule/molecule-provider.tsx
|
|
10
|
+
var queryClient = new QueryClient();
|
|
11
|
+
function MoleculeTranslationsProvider({
|
|
12
|
+
localeConfig,
|
|
13
|
+
translationsConfig,
|
|
14
|
+
children
|
|
15
|
+
}) {
|
|
16
|
+
let language = localeConfig?.language;
|
|
17
|
+
if (language && !languages.includes(language)) {
|
|
18
|
+
const [_languageTag] = getLocaleChainFromLocale(language);
|
|
19
|
+
if (_languageTag && languages.includes(_languageTag)) {
|
|
20
|
+
language = _languageTag;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
let _i18n = i18n;
|
|
24
|
+
if (language && (i18n.language !== language || i18n.options.formality !== localeConfig?.formality) && Object.keys(i18n.services.resourceStore.data).includes(language)) {
|
|
25
|
+
_i18n = i18n.cloneInstance({
|
|
26
|
+
lng: language,
|
|
27
|
+
formality: localeConfig?.formality
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
if (translationsConfig) {
|
|
31
|
+
for (const [namespace, translations] of Object.entries(
|
|
32
|
+
translationsConfig
|
|
33
|
+
)) {
|
|
34
|
+
for (const [language2, resource] of Object.entries(translations)) {
|
|
35
|
+
_i18n.addResourceBundle(language2, namespace, resource, true, true);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return /* @__PURE__ */ jsx(I18nextProvider, { i18n: _i18n, defaultNS: "molecules", children });
|
|
40
|
+
}
|
|
41
|
+
function createMoleculeContext({
|
|
42
|
+
name
|
|
43
|
+
}) {
|
|
44
|
+
const MoleculeContext = createContext(null);
|
|
45
|
+
function useMolecule() {
|
|
46
|
+
const v = use(MoleculeContext);
|
|
47
|
+
if (!v) throw new Error("Must be used within its MoleculeProvider");
|
|
48
|
+
return v;
|
|
49
|
+
}
|
|
50
|
+
function useMoleculeConfig() {
|
|
51
|
+
const v = use(MoleculeContext);
|
|
52
|
+
if (!v) throw new Error("Must be used within its MoleculeProvider");
|
|
53
|
+
return v.config;
|
|
54
|
+
}
|
|
55
|
+
function useMoleculeComponent() {
|
|
56
|
+
const v = use(MoleculeContext);
|
|
57
|
+
if (!v) throw new Error("Must be used within its MoleculeProvider");
|
|
58
|
+
return v.component;
|
|
59
|
+
}
|
|
60
|
+
function useMoleculeCallbacks() {
|
|
61
|
+
const v = use(MoleculeContext);
|
|
62
|
+
if (!v) throw new Error("Must be used within its MoleculeProvider");
|
|
63
|
+
return v.callbacks;
|
|
64
|
+
}
|
|
65
|
+
function TypedMoleculeProvider({
|
|
66
|
+
config = {},
|
|
67
|
+
component,
|
|
68
|
+
callbacks,
|
|
69
|
+
children
|
|
70
|
+
}) {
|
|
71
|
+
return /* @__PURE__ */ jsx(MoleculeContext.Provider, { value: { config, component, callbacks }, children: /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(
|
|
72
|
+
MoleculeTranslationsProvider,
|
|
73
|
+
{
|
|
74
|
+
localeConfig: config.locale,
|
|
75
|
+
translationsConfig: config.translations,
|
|
76
|
+
children
|
|
77
|
+
}
|
|
78
|
+
) }) });
|
|
79
|
+
}
|
|
80
|
+
TypedMoleculeProvider.displayName = `MoleculeProvider<${name}>`;
|
|
81
|
+
return {
|
|
82
|
+
useMolecule,
|
|
83
|
+
useMoleculeConfig,
|
|
84
|
+
useMoleculeComponent,
|
|
85
|
+
useMoleculeCallbacks,
|
|
86
|
+
MoleculeProvider: TypedMoleculeProvider
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { createMoleculeContext };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getLogger } from './chunk-VS55HRUS.js';
|
|
2
|
+
import { useChatSDKStore } from './chunk-YX46JVQN.js';
|
|
3
|
+
import { mergeConfigs } from './chunk-RJG5D2TM.js';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useShallow } from 'zustand/react/shallow';
|
|
6
|
+
|
|
7
|
+
function useMergeGlobalConfig(config) {
|
|
8
|
+
const globalConfig = useChatSDKStore(
|
|
9
|
+
useShallow((state) => ({
|
|
10
|
+
theme: state.theme,
|
|
11
|
+
locale: state.locale,
|
|
12
|
+
context: state.context,
|
|
13
|
+
api: state.api,
|
|
14
|
+
translations: state.translations,
|
|
15
|
+
logger: state.logger,
|
|
16
|
+
options: state.options
|
|
17
|
+
}))
|
|
18
|
+
);
|
|
19
|
+
const withGlobalConfig = React.useMemo(() => {
|
|
20
|
+
return mergeConfigs(globalConfig, config || {});
|
|
21
|
+
}, [globalConfig, config]);
|
|
22
|
+
const resolvedLogger = getLogger(withGlobalConfig.logger);
|
|
23
|
+
const resolvedLocale = withGlobalConfig.locale ? typeof withGlobalConfig.locale === "object" ? withGlobalConfig.locale : { language: withGlobalConfig.locale, formality: "formal" } : void 0;
|
|
24
|
+
return {
|
|
25
|
+
...withGlobalConfig,
|
|
26
|
+
logger: resolvedLogger,
|
|
27
|
+
locale: resolvedLocale
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { useMergeGlobalConfig };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { cn } from '@chatsdk-dev/ui/lib/utils';
|
|
2
|
+
import { motion } from 'motion/react';
|
|
3
|
+
import { memo, useMemo } from 'react';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/components/ai-elements/shimmer.tsx
|
|
7
|
+
var motionComponentCache = /* @__PURE__ */ new Map();
|
|
8
|
+
var getMotionComponent = (element) => {
|
|
9
|
+
let component = motionComponentCache.get(element);
|
|
10
|
+
if (!component) {
|
|
11
|
+
component = motion.create(element);
|
|
12
|
+
motionComponentCache.set(element, component);
|
|
13
|
+
}
|
|
14
|
+
return component;
|
|
15
|
+
};
|
|
16
|
+
var ShimmerComponent = ({
|
|
17
|
+
children,
|
|
18
|
+
as: Component = "p",
|
|
19
|
+
className,
|
|
20
|
+
duration = 2,
|
|
21
|
+
spread = 2
|
|
22
|
+
}) => {
|
|
23
|
+
const MotionComponent = getMotionComponent(
|
|
24
|
+
Component
|
|
25
|
+
);
|
|
26
|
+
const dynamicSpread = useMemo(
|
|
27
|
+
() => (children?.length ?? 0) * spread,
|
|
28
|
+
[children, spread]
|
|
29
|
+
);
|
|
30
|
+
return /* @__PURE__ */ jsx(
|
|
31
|
+
MotionComponent,
|
|
32
|
+
{
|
|
33
|
+
animate: { backgroundPosition: "0% center" },
|
|
34
|
+
className: cn(
|
|
35
|
+
"relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent",
|
|
36
|
+
"[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",
|
|
37
|
+
className
|
|
38
|
+
),
|
|
39
|
+
initial: { backgroundPosition: "100% center" },
|
|
40
|
+
style: {
|
|
41
|
+
"--spread": `${dynamicSpread}px`,
|
|
42
|
+
backgroundImage: "var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"
|
|
43
|
+
},
|
|
44
|
+
transition: {
|
|
45
|
+
duration,
|
|
46
|
+
ease: "linear",
|
|
47
|
+
repeat: Number.POSITIVE_INFINITY
|
|
48
|
+
},
|
|
49
|
+
children
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
var Shimmer = memo(ShimmerComponent);
|
|
54
|
+
|
|
55
|
+
export { Shimmer };
|