sv5ui-plus 4.0.0
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 +21 -0
- package/README.md +62 -0
- package/dist/adapters/notify.d.ts +29 -0
- package/dist/adapters/notify.js +88 -0
- package/dist/compat.d.ts +6 -0
- package/dist/compat.js +6 -0
- package/dist/components/BentoGrid/BentoCard.svelte +45 -0
- package/dist/components/BentoGrid/BentoCard.svelte.d.ts +4 -0
- package/dist/components/BentoGrid/BentoGrid.svelte +9 -0
- package/dist/components/BentoGrid/BentoGrid.svelte.d.ts +4 -0
- package/dist/components/BentoGrid/bento-grid.types.d.ts +47 -0
- package/dist/components/BentoGrid/bento-grid.types.js +1 -0
- package/dist/components/BentoGrid/bento-grid.variants.d.ts +30 -0
- package/dist/components/BentoGrid/bento-grid.variants.js +16 -0
- package/dist/components/BentoGrid/index.d.ts +5 -0
- package/dist/components/BentoGrid/index.js +5 -0
- package/dist/components/Chart/Chart.svelte +62 -0
- package/dist/components/Chart/Chart.svelte.d.ts +4 -0
- package/dist/components/Chart/chart.types.d.ts +16 -0
- package/dist/components/Chart/chart.types.js +1 -0
- package/dist/components/Chart/index.d.ts +2 -0
- package/dist/components/Chart/index.js +2 -0
- package/dist/components/Chat/ChatBubble.svelte +30 -0
- package/dist/components/Chat/ChatBubble.svelte.d.ts +4 -0
- package/dist/components/Chat/ChatInput.svelte +50 -0
- package/dist/components/Chat/ChatInput.svelte.d.ts +4 -0
- package/dist/components/Chat/ChatMessage.svelte +15 -0
- package/dist/components/Chat/ChatMessage.svelte.d.ts +4 -0
- package/dist/components/Chat/chat.types.d.ts +63 -0
- package/dist/components/Chat/chat.types.js +1 -0
- package/dist/components/Chat/chat.variants.d.ts +117 -0
- package/dist/components/Chat/chat.variants.js +47 -0
- package/dist/components/Chat/index.d.ts +6 -0
- package/dist/components/Chat/index.js +6 -0
- package/dist/components/CodeBlock/CodeBlock.svelte +66 -0
- package/dist/components/CodeBlock/CodeBlock.svelte.d.ts +5 -0
- package/dist/components/CodeBlock/code-block.types.d.ts +15 -0
- package/dist/components/CodeBlock/code-block.types.js +1 -0
- package/dist/components/CodeBlock/code-block.variants.d.ts +288 -0
- package/dist/components/CodeBlock/code-block.variants.js +69 -0
- package/dist/components/CodeBlock/index.d.ts +2 -0
- package/dist/components/CodeBlock/index.js +1 -0
- package/dist/components/ColorPicker/ColorPicker.svelte +109 -0
- package/dist/components/ColorPicker/ColorPicker.svelte.d.ts +4 -0
- package/dist/components/ColorPicker/color-picker.types.d.ts +26 -0
- package/dist/components/ColorPicker/color-picker.types.js +1 -0
- package/dist/components/ColorPicker/color-picker.variants.d.ts +69 -0
- package/dist/components/ColorPicker/color-picker.variants.js +13 -0
- package/dist/components/ColorPicker/index.d.ts +4 -0
- package/dist/components/ColorPicker/index.js +4 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.svelte +175 -0
- package/dist/components/ConfirmDialog/ConfirmDialog.svelte.d.ts +10 -0
- package/dist/components/ConfirmDialog/confirm.d.ts +9 -0
- package/dist/components/ConfirmDialog/confirm.js +24 -0
- package/dist/components/ConfirmDialog/confirm.types.d.ts +21 -0
- package/dist/components/ConfirmDialog/confirm.types.js +1 -0
- package/dist/components/ConfirmDialog/index.d.ts +4 -0
- package/dist/components/ConfirmDialog/index.js +2 -0
- package/dist/components/Fonts/Fonts.svelte +32 -0
- package/dist/components/Fonts/Fonts.svelte.d.ts +5 -0
- package/dist/components/Fonts/fonts.d.ts +12 -0
- package/dist/components/Fonts/fonts.js +126 -0
- package/dist/components/Fonts/fonts.types.d.ts +40 -0
- package/dist/components/Fonts/fonts.types.js +1 -0
- package/dist/components/Fonts/index.d.ts +3 -0
- package/dist/components/Fonts/index.js +2 -0
- package/dist/components/List/List.svelte +14 -0
- package/dist/components/List/List.svelte.d.ts +4 -0
- package/dist/components/List/ListItem.svelte +64 -0
- package/dist/components/List/ListItem.svelte.d.ts +4 -0
- package/dist/components/List/index.d.ts +5 -0
- package/dist/components/List/index.js +5 -0
- package/dist/components/List/list.types.d.ts +62 -0
- package/dist/components/List/list.types.js +1 -0
- package/dist/components/List/list.variants.d.ts +99 -0
- package/dist/components/List/list.variants.js +42 -0
- package/dist/components/LocaleButton/LocaleButton.svelte +181 -0
- package/dist/components/LocaleButton/LocaleButton.svelte.d.ts +5 -0
- package/dist/components/LocaleButton/index.d.ts +2 -0
- package/dist/components/LocaleButton/index.js +1 -0
- package/dist/components/LocaleButton/locale-button.types.d.ts +208 -0
- package/dist/components/LocaleButton/locale-button.types.js +1 -0
- package/dist/components/LocaleButton/locale-button.variants.d.ts +245 -0
- package/dist/components/LocaleButton/locale-button.variants.js +98 -0
- package/dist/components/Marquee/Marquee.svelte +50 -0
- package/dist/components/Marquee/Marquee.svelte.d.ts +4 -0
- package/dist/components/Marquee/index.d.ts +4 -0
- package/dist/components/Marquee/index.js +4 -0
- package/dist/components/Marquee/marquee.types.d.ts +38 -0
- package/dist/components/Marquee/marquee.types.js +1 -0
- package/dist/components/Marquee/marquee.variants.d.ts +78 -0
- package/dist/components/Marquee/marquee.variants.js +28 -0
- package/dist/components/NavigationMenu/NavigationMenu.svelte +623 -0
- package/dist/components/NavigationMenu/NavigationMenu.svelte.d.ts +5 -0
- package/dist/components/NavigationMenu/index.d.ts +2 -0
- package/dist/components/NavigationMenu/index.js +1 -0
- package/dist/components/NavigationMenu/navigation-menu.types.d.ts +245 -0
- package/dist/components/NavigationMenu/navigation-menu.types.js +1 -0
- package/dist/components/NavigationMenu/navigation-menu.variants.d.ts +543 -0
- package/dist/components/NavigationMenu/navigation-menu.variants.js +287 -0
- package/dist/components/NumberTicker/NumberTicker.svelte +59 -0
- package/dist/components/NumberTicker/NumberTicker.svelte.d.ts +4 -0
- package/dist/components/NumberTicker/index.d.ts +4 -0
- package/dist/components/NumberTicker/index.js +4 -0
- package/dist/components/NumberTicker/number-ticker.types.d.ts +26 -0
- package/dist/components/NumberTicker/number-ticker.types.js +1 -0
- package/dist/components/NumberTicker/number-ticker.variants.d.ts +27 -0
- package/dist/components/NumberTicker/number-ticker.variants.js +6 -0
- package/dist/components/PasswordInput/PasswordInput.svelte +182 -0
- package/dist/components/PasswordInput/PasswordInput.svelte.d.ts +5 -0
- package/dist/components/PasswordInput/index.d.ts +2 -0
- package/dist/components/PasswordInput/index.js +1 -0
- package/dist/components/PasswordInput/password-input.types.d.ts +111 -0
- package/dist/components/PasswordInput/password-input.types.js +1 -0
- package/dist/components/PasswordInput/password-input.variants.d.ts +273 -0
- package/dist/components/PasswordInput/password-input.variants.js +105 -0
- package/dist/components/Prose/Prose.svelte +13 -0
- package/dist/components/Prose/Prose.svelte.d.ts +4 -0
- package/dist/components/Prose/index.d.ts +4 -0
- package/dist/components/Prose/index.js +4 -0
- package/dist/components/Prose/prose.types.d.ts +22 -0
- package/dist/components/Prose/prose.types.js +1 -0
- package/dist/components/Prose/prose.variants.d.ts +45 -0
- package/dist/components/Prose/prose.variants.js +45 -0
- package/dist/components/Resizable/Resizable.svelte +9 -0
- package/dist/components/Resizable/Resizable.svelte.d.ts +4 -0
- package/dist/components/Resizable/index.d.ts +4 -0
- package/dist/components/Resizable/index.js +4 -0
- package/dist/components/Resizable/resizable.types.d.ts +18 -0
- package/dist/components/Resizable/resizable.types.js +1 -0
- package/dist/components/Resizable/resizable.variants.d.ts +48 -0
- package/dist/components/Resizable/resizable.variants.js +17 -0
- package/dist/components/ScrollArea/ScrollArea.svelte +54 -0
- package/dist/components/ScrollArea/ScrollArea.svelte.d.ts +4 -0
- package/dist/components/ScrollArea/index.d.ts +4 -0
- package/dist/components/ScrollArea/index.js +4 -0
- package/dist/components/ScrollArea/scroll-area.types.d.ts +27 -0
- package/dist/components/ScrollArea/scroll-area.types.js +1 -0
- package/dist/components/ScrollArea/scroll-area.variants.d.ts +45 -0
- package/dist/components/ScrollArea/scroll-area.variants.js +27 -0
- package/dist/components/Search/Search.svelte +94 -0
- package/dist/components/Search/Search.svelte.d.ts +4 -0
- package/dist/components/Search/index.d.ts +2 -0
- package/dist/components/Search/index.js +1 -0
- package/dist/components/Search/search.types.d.ts +40 -0
- package/dist/components/Search/search.types.js +1 -0
- package/dist/components/SortableGroup/SortableGroup.svelte +53 -0
- package/dist/components/SortableGroup/SortableGroup.svelte.d.ts +13 -0
- package/dist/components/SortableGroup/index.d.ts +1 -0
- package/dist/components/SortableGroup/index.js +1 -0
- package/dist/components/SortableList/SortableList.svelte +81 -0
- package/dist/components/SortableList/SortableList.svelte.d.ts +26 -0
- package/dist/components/SortableList/index.d.ts +2 -0
- package/dist/components/SortableList/index.js +1 -0
- package/dist/components/SortableList/sortable-list.types.d.ts +21 -0
- package/dist/components/SortableList/sortable-list.types.js +1 -0
- package/dist/components/Spotlight/Spotlight.svelte +31 -0
- package/dist/components/Spotlight/Spotlight.svelte.d.ts +4 -0
- package/dist/components/Spotlight/index.d.ts +4 -0
- package/dist/components/Spotlight/index.js +4 -0
- package/dist/components/Spotlight/spotlight.types.d.ts +22 -0
- package/dist/components/Spotlight/spotlight.types.js +1 -0
- package/dist/components/Spotlight/spotlight.variants.d.ts +39 -0
- package/dist/components/Spotlight/spotlight.variants.js +8 -0
- package/dist/components/TableBulkActionBar/TableBulkActionBar.svelte +38 -0
- package/dist/components/TableBulkActionBar/TableBulkActionBar.svelte.d.ts +5 -0
- package/dist/components/TableBulkActionBar/index.d.ts +2 -0
- package/dist/components/TableBulkActionBar/index.js +1 -0
- package/dist/components/TableBulkActionBar/table-bulk-action-bar.types.d.ts +31 -0
- package/dist/components/TableBulkActionBar/table-bulk-action-bar.types.js +1 -0
- package/dist/components/TableBulkActionBar/table-bulk-action-bar.variants.d.ts +52 -0
- package/dist/components/TableBulkActionBar/table-bulk-action-bar.variants.js +10 -0
- package/dist/components/TreeView/TreeView.svelte +95 -0
- package/dist/components/TreeView/TreeView.svelte.d.ts +4 -0
- package/dist/components/TreeView/index.d.ts +4 -0
- package/dist/components/TreeView/index.js +3 -0
- package/dist/components/TreeView/tree-view.types.d.ts +68 -0
- package/dist/components/TreeView/tree-view.types.js +1 -0
- package/dist/components/TreeView/tree-view.variants.d.ts +69 -0
- package/dist/components/TreeView/tree-view.variants.js +30 -0
- package/dist/config.d.ts +91 -0
- package/dist/config.js +124 -0
- package/dist/editor.d.ts +2 -0
- package/dist/editor.js +2 -0
- package/dist/form/resolve-form-field-name.d.ts +5 -0
- package/dist/form/resolve-form-field-name.js +11 -0
- package/dist/hooks/internal/DragDropProviderScope.svelte +29 -0
- package/dist/hooks/internal/DragDropProviderScope.svelte.d.ts +7 -0
- package/dist/hooks/internal/SortableProvider.svelte +68 -0
- package/dist/hooks/internal/SortableProvider.svelte.d.ts +30 -0
- package/dist/hooks/internal/drag-drop-context.d.ts +12 -0
- package/dist/hooks/internal/drag-drop-context.js +1 -0
- package/dist/hooks/internal/sortable-context.d.ts +26 -0
- package/dist/hooks/internal/sortable-context.js +2 -0
- package/dist/hooks/useDragDrop/index.d.ts +1 -0
- package/dist/hooks/useDragDrop/index.js +1 -0
- package/dist/hooks/useDragDrop/useDragDrop.svelte.d.ts +40 -0
- package/dist/hooks/useDragDrop/useDragDrop.svelte.js +128 -0
- package/dist/hooks/useSortable/index.d.ts +2 -0
- package/dist/hooks/useSortable/index.js +2 -0
- package/dist/hooks/useSortable/sortable-utils.d.ts +1 -0
- package/dist/hooks/useSortable/sortable-utils.js +13 -0
- package/dist/hooks/useSortable/useSortable.svelte.d.ts +60 -0
- package/dist/hooks/useSortable/useSortable.svelte.js +151 -0
- package/dist/hooks/utils.d.ts +1 -0
- package/dist/hooks/utils.js +3 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +30 -0
- package/dist/mcp/cursor.mcp.json +12 -0
- package/dist/mcp/install-template.mjs +55 -0
- package/dist/mcp/server.mjs +338 -0
- package/dist/mcp/sv5ui-plus-docs.data.json +17 -0
- package/dist/theme.css +64 -0
- package/package.json +176 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ChatVariantProps } from './chat.variants.js';
|
|
4
|
+
export interface ChatBubbleProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* Position of the chat bubble (start for receiver, end for sender).
|
|
7
|
+
* @default 'start'
|
|
8
|
+
*/
|
|
9
|
+
position?: ChatVariantProps['position'];
|
|
10
|
+
/**
|
|
11
|
+
* Name of the sender.
|
|
12
|
+
*/
|
|
13
|
+
name?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Timestamp of the message.
|
|
16
|
+
*/
|
|
17
|
+
time?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Snippet for the avatar element.
|
|
20
|
+
*/
|
|
21
|
+
avatar?: Snippet;
|
|
22
|
+
/**
|
|
23
|
+
* The actual chat messages.
|
|
24
|
+
*/
|
|
25
|
+
children?: Snippet;
|
|
26
|
+
}
|
|
27
|
+
export interface ChatMessageProps extends HTMLAttributes<HTMLDivElement> {
|
|
28
|
+
/**
|
|
29
|
+
* Style variant of the message bubble.
|
|
30
|
+
*/
|
|
31
|
+
variant?: ChatVariantProps['variant'];
|
|
32
|
+
/**
|
|
33
|
+
* Position inheritance (used internally for rounded corners).
|
|
34
|
+
* Automatically inherited from ChatBubble if used within it.
|
|
35
|
+
*/
|
|
36
|
+
position?: ChatVariantProps['position'];
|
|
37
|
+
/**
|
|
38
|
+
* The message text or content.
|
|
39
|
+
*/
|
|
40
|
+
children?: Snippet;
|
|
41
|
+
}
|
|
42
|
+
export interface ChatInputProps extends HTMLAttributes<HTMLDivElement> {
|
|
43
|
+
/**
|
|
44
|
+
* Value of the input field.
|
|
45
|
+
*/
|
|
46
|
+
value?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Placeholder text.
|
|
49
|
+
*/
|
|
50
|
+
placeholder?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the input is disabled.
|
|
53
|
+
*/
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Snippet for leading actions (e.g. attachment button).
|
|
57
|
+
*/
|
|
58
|
+
leading?: Snippet;
|
|
59
|
+
/**
|
|
60
|
+
* Snippet for trailing actions (e.g. send button).
|
|
61
|
+
*/
|
|
62
|
+
trailing?: Snippet;
|
|
63
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const chatVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
position: {
|
|
4
|
+
start: {
|
|
5
|
+
bubbleBase: string;
|
|
6
|
+
bubbleContent: string;
|
|
7
|
+
bubbleHeader: string;
|
|
8
|
+
messageBase: string;
|
|
9
|
+
};
|
|
10
|
+
end: {
|
|
11
|
+
bubbleBase: string;
|
|
12
|
+
bubbleContent: string;
|
|
13
|
+
bubbleHeader: string;
|
|
14
|
+
messageBase: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
variant: {
|
|
18
|
+
primary: {
|
|
19
|
+
messageBase: string;
|
|
20
|
+
};
|
|
21
|
+
surface: {
|
|
22
|
+
messageBase: string;
|
|
23
|
+
};
|
|
24
|
+
outline: {
|
|
25
|
+
messageBase: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}, {
|
|
29
|
+
bubbleBase: string;
|
|
30
|
+
bubbleAvatar: string;
|
|
31
|
+
bubbleContent: string;
|
|
32
|
+
bubbleHeader: string;
|
|
33
|
+
bubbleName: string;
|
|
34
|
+
bubbleTime: string;
|
|
35
|
+
messageBase: string;
|
|
36
|
+
inputBase: string;
|
|
37
|
+
inputFieldWrapper: string;
|
|
38
|
+
inputField: string;
|
|
39
|
+
inputActions: string;
|
|
40
|
+
}, undefined, {
|
|
41
|
+
position: {
|
|
42
|
+
start: {
|
|
43
|
+
bubbleBase: string;
|
|
44
|
+
bubbleContent: string;
|
|
45
|
+
bubbleHeader: string;
|
|
46
|
+
messageBase: string;
|
|
47
|
+
};
|
|
48
|
+
end: {
|
|
49
|
+
bubbleBase: string;
|
|
50
|
+
bubbleContent: string;
|
|
51
|
+
bubbleHeader: string;
|
|
52
|
+
messageBase: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
variant: {
|
|
56
|
+
primary: {
|
|
57
|
+
messageBase: string;
|
|
58
|
+
};
|
|
59
|
+
surface: {
|
|
60
|
+
messageBase: string;
|
|
61
|
+
};
|
|
62
|
+
outline: {
|
|
63
|
+
messageBase: string;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
}, {
|
|
67
|
+
bubbleBase: string;
|
|
68
|
+
bubbleAvatar: string;
|
|
69
|
+
bubbleContent: string;
|
|
70
|
+
bubbleHeader: string;
|
|
71
|
+
bubbleName: string;
|
|
72
|
+
bubbleTime: string;
|
|
73
|
+
messageBase: string;
|
|
74
|
+
inputBase: string;
|
|
75
|
+
inputFieldWrapper: string;
|
|
76
|
+
inputField: string;
|
|
77
|
+
inputActions: string;
|
|
78
|
+
}, import("tailwind-variants").TVReturnTypeLike<{
|
|
79
|
+
position: {
|
|
80
|
+
start: {
|
|
81
|
+
bubbleBase: string;
|
|
82
|
+
bubbleContent: string;
|
|
83
|
+
bubbleHeader: string;
|
|
84
|
+
messageBase: string;
|
|
85
|
+
};
|
|
86
|
+
end: {
|
|
87
|
+
bubbleBase: string;
|
|
88
|
+
bubbleContent: string;
|
|
89
|
+
bubbleHeader: string;
|
|
90
|
+
messageBase: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
variant: {
|
|
94
|
+
primary: {
|
|
95
|
+
messageBase: string;
|
|
96
|
+
};
|
|
97
|
+
surface: {
|
|
98
|
+
messageBase: string;
|
|
99
|
+
};
|
|
100
|
+
outline: {
|
|
101
|
+
messageBase: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
}, {
|
|
105
|
+
bubbleBase: string;
|
|
106
|
+
bubbleAvatar: string;
|
|
107
|
+
bubbleContent: string;
|
|
108
|
+
bubbleHeader: string;
|
|
109
|
+
bubbleName: string;
|
|
110
|
+
bubbleTime: string;
|
|
111
|
+
messageBase: string;
|
|
112
|
+
inputBase: string;
|
|
113
|
+
inputFieldWrapper: string;
|
|
114
|
+
inputField: string;
|
|
115
|
+
inputActions: string;
|
|
116
|
+
}>>;
|
|
117
|
+
export type ChatVariantProps = VariantProps<typeof chatVariants>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const chatVariants = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
bubbleBase: 'flex w-full gap-3 py-2',
|
|
5
|
+
bubbleAvatar: 'shrink-0 mt-1',
|
|
6
|
+
bubbleContent: 'flex flex-col gap-1 min-w-0 max-w-[80%]',
|
|
7
|
+
bubbleHeader: 'flex items-center gap-2 text-xs text-surface-500 dark:text-surface-400',
|
|
8
|
+
bubbleName: 'font-semibold text-surface-900 dark:text-surface-50',
|
|
9
|
+
bubbleTime: '',
|
|
10
|
+
messageBase: 'px-4 py-2.5 rounded-2xl text-sm break-words',
|
|
11
|
+
inputBase: 'flex items-end gap-2 p-3 bg-surface-50 dark:bg-surface-900 border-t border-outline-variant',
|
|
12
|
+
inputFieldWrapper: 'flex-1 relative bg-surface-100 dark:bg-surface-800 rounded-2xl border border-outline-variant focus-within:border-primary focus-within:ring-1 focus-within:ring-primary transition-colors',
|
|
13
|
+
inputField: 'w-full bg-transparent border-0 px-4 py-3 min-h-[44px] max-h-32 resize-none focus:ring-0 text-sm outline-none',
|
|
14
|
+
inputActions: 'shrink-0 flex items-center gap-1'
|
|
15
|
+
},
|
|
16
|
+
variants: {
|
|
17
|
+
position: {
|
|
18
|
+
start: {
|
|
19
|
+
bubbleBase: 'justify-start',
|
|
20
|
+
bubbleContent: 'items-start',
|
|
21
|
+
bubbleHeader: 'flex-row',
|
|
22
|
+
messageBase: 'rounded-tl-sm'
|
|
23
|
+
},
|
|
24
|
+
end: {
|
|
25
|
+
bubbleBase: 'justify-end flex-row-reverse',
|
|
26
|
+
bubbleContent: 'items-end',
|
|
27
|
+
bubbleHeader: 'flex-row-reverse',
|
|
28
|
+
messageBase: 'rounded-tr-sm'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
variant: {
|
|
32
|
+
primary: {
|
|
33
|
+
messageBase: 'bg-primary text-on-primary'
|
|
34
|
+
},
|
|
35
|
+
surface: {
|
|
36
|
+
messageBase: 'bg-surface-200 dark:bg-surface-800 text-surface-900 dark:text-surface-50'
|
|
37
|
+
},
|
|
38
|
+
outline: {
|
|
39
|
+
messageBase: 'bg-transparent border border-outline-variant text-surface-900 dark:text-surface-50'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
defaultVariants: {
|
|
44
|
+
position: 'start',
|
|
45
|
+
variant: 'surface'
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script lang="ts" module>export {};
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<script lang="ts">import { getComponentConfig } from "../../config.js";
|
|
5
|
+
import { codeBlockDefaults, codeBlockVariants } from "./code-block.variants.js";
|
|
6
|
+
const config = getComponentConfig("codeBlock", codeBlockDefaults);
|
|
7
|
+
let { title = "Code", code = "", copyText, copyable = true, html, variant = config.defaultVariants.variant, size = config.defaultVariants.size, class: className, ui, children } = $props();
|
|
8
|
+
let copyLabel = $state("Copy");
|
|
9
|
+
const resolvedCopyText = $derived((copyText ?? code).trim());
|
|
10
|
+
const canCopy = $derived(copyable && resolvedCopyText.length > 0);
|
|
11
|
+
const classes = $derived.by(() => {
|
|
12
|
+
const slots = codeBlockVariants({
|
|
13
|
+
variant,
|
|
14
|
+
size
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
root: slots.root({ class: [
|
|
18
|
+
config.slots.root,
|
|
19
|
+
className,
|
|
20
|
+
ui?.root
|
|
21
|
+
] }),
|
|
22
|
+
header: slots.header({ class: [config.slots.header, ui?.header] }),
|
|
23
|
+
title: slots.title({ class: [config.slots.title, ui?.title] }),
|
|
24
|
+
button: slots.button({ class: [config.slots.button, ui?.button] }),
|
|
25
|
+
body: slots.body({ class: [config.slots.body, ui?.body] })
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
function scheduleLabelReset(resetLabel) {
|
|
29
|
+
window.setTimeout(() => {
|
|
30
|
+
copyLabel = resetLabel;
|
|
31
|
+
}, 1200);
|
|
32
|
+
}
|
|
33
|
+
async function handleCopy() {
|
|
34
|
+
if (!canCopy) return;
|
|
35
|
+
if (typeof navigator === "undefined" || !navigator.clipboard) return;
|
|
36
|
+
const resetLabel = copyLabel;
|
|
37
|
+
try {
|
|
38
|
+
await navigator.clipboard.writeText(resolvedCopyText);
|
|
39
|
+
copyLabel = "Copied";
|
|
40
|
+
} catch {
|
|
41
|
+
copyLabel = "Failed";
|
|
42
|
+
}
|
|
43
|
+
scheduleLabelReset(resetLabel);
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<div class={classes.root}>
|
|
48
|
+
<div class={classes.header}>
|
|
49
|
+
<p class={classes.title}>{title}</p>
|
|
50
|
+
<button type="button" class={classes.button} disabled={!canCopy} onclick={handleCopy}>
|
|
51
|
+
{copyLabel}
|
|
52
|
+
</button>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div class={classes.body}>
|
|
56
|
+
{#if html}
|
|
57
|
+
{@html html}
|
|
58
|
+
{:else if children}
|
|
59
|
+
{@render children()}
|
|
60
|
+
{:else}
|
|
61
|
+
<pre class="shiki">
|
|
62
|
+
<code>{code}</code>
|
|
63
|
+
</pre>
|
|
64
|
+
{/if}
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
import type { CodeBlockVariantProps, CodeBlockSlots } from './code-block.variants.js';
|
|
4
|
+
export type CodeBlockProps = {
|
|
5
|
+
title?: string;
|
|
6
|
+
code?: string;
|
|
7
|
+
copyText?: string;
|
|
8
|
+
copyable?: boolean;
|
|
9
|
+
html?: string;
|
|
10
|
+
variant?: NonNullable<CodeBlockVariantProps['variant']>;
|
|
11
|
+
size?: NonNullable<CodeBlockVariantProps['size']>;
|
|
12
|
+
class?: ClassNameValue;
|
|
13
|
+
ui?: Partial<Record<CodeBlockSlots, ClassNameValue>>;
|
|
14
|
+
children?: Snippet;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const codeBlockVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
variant: {
|
|
4
|
+
outline: {
|
|
5
|
+
root: string;
|
|
6
|
+
header: string;
|
|
7
|
+
button: string;
|
|
8
|
+
};
|
|
9
|
+
soft: {
|
|
10
|
+
root: string;
|
|
11
|
+
header: string;
|
|
12
|
+
button: string;
|
|
13
|
+
};
|
|
14
|
+
subtle: {
|
|
15
|
+
root: string;
|
|
16
|
+
header: string;
|
|
17
|
+
button: string;
|
|
18
|
+
};
|
|
19
|
+
solid: {
|
|
20
|
+
root: string;
|
|
21
|
+
header: string;
|
|
22
|
+
button: string;
|
|
23
|
+
};
|
|
24
|
+
ghost: {
|
|
25
|
+
root: string;
|
|
26
|
+
header: string;
|
|
27
|
+
button: string;
|
|
28
|
+
};
|
|
29
|
+
none: {
|
|
30
|
+
root: string;
|
|
31
|
+
header: string;
|
|
32
|
+
button: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
size: {
|
|
36
|
+
sm: {
|
|
37
|
+
header: string;
|
|
38
|
+
button: string;
|
|
39
|
+
body: string;
|
|
40
|
+
};
|
|
41
|
+
md: {
|
|
42
|
+
header: string;
|
|
43
|
+
button: string;
|
|
44
|
+
body: string;
|
|
45
|
+
};
|
|
46
|
+
lg: {
|
|
47
|
+
header: string;
|
|
48
|
+
button: string;
|
|
49
|
+
body: string;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}, {
|
|
53
|
+
root: string;
|
|
54
|
+
header: string;
|
|
55
|
+
title: string;
|
|
56
|
+
button: string;
|
|
57
|
+
body: string;
|
|
58
|
+
}, undefined, {
|
|
59
|
+
variant: {
|
|
60
|
+
outline: {
|
|
61
|
+
root: string;
|
|
62
|
+
header: string;
|
|
63
|
+
button: string;
|
|
64
|
+
};
|
|
65
|
+
soft: {
|
|
66
|
+
root: string;
|
|
67
|
+
header: string;
|
|
68
|
+
button: string;
|
|
69
|
+
};
|
|
70
|
+
subtle: {
|
|
71
|
+
root: string;
|
|
72
|
+
header: string;
|
|
73
|
+
button: string;
|
|
74
|
+
};
|
|
75
|
+
solid: {
|
|
76
|
+
root: string;
|
|
77
|
+
header: string;
|
|
78
|
+
button: string;
|
|
79
|
+
};
|
|
80
|
+
ghost: {
|
|
81
|
+
root: string;
|
|
82
|
+
header: string;
|
|
83
|
+
button: string;
|
|
84
|
+
};
|
|
85
|
+
none: {
|
|
86
|
+
root: string;
|
|
87
|
+
header: string;
|
|
88
|
+
button: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
size: {
|
|
92
|
+
sm: {
|
|
93
|
+
header: string;
|
|
94
|
+
button: string;
|
|
95
|
+
body: string;
|
|
96
|
+
};
|
|
97
|
+
md: {
|
|
98
|
+
header: string;
|
|
99
|
+
button: string;
|
|
100
|
+
body: string;
|
|
101
|
+
};
|
|
102
|
+
lg: {
|
|
103
|
+
header: string;
|
|
104
|
+
button: string;
|
|
105
|
+
body: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}, {
|
|
109
|
+
root: string;
|
|
110
|
+
header: string;
|
|
111
|
+
title: string;
|
|
112
|
+
button: string;
|
|
113
|
+
body: string;
|
|
114
|
+
}, import("tailwind-variants").TVReturnTypeLike<{
|
|
115
|
+
variant: {
|
|
116
|
+
outline: {
|
|
117
|
+
root: string;
|
|
118
|
+
header: string;
|
|
119
|
+
button: string;
|
|
120
|
+
};
|
|
121
|
+
soft: {
|
|
122
|
+
root: string;
|
|
123
|
+
header: string;
|
|
124
|
+
button: string;
|
|
125
|
+
};
|
|
126
|
+
subtle: {
|
|
127
|
+
root: string;
|
|
128
|
+
header: string;
|
|
129
|
+
button: string;
|
|
130
|
+
};
|
|
131
|
+
solid: {
|
|
132
|
+
root: string;
|
|
133
|
+
header: string;
|
|
134
|
+
button: string;
|
|
135
|
+
};
|
|
136
|
+
ghost: {
|
|
137
|
+
root: string;
|
|
138
|
+
header: string;
|
|
139
|
+
button: string;
|
|
140
|
+
};
|
|
141
|
+
none: {
|
|
142
|
+
root: string;
|
|
143
|
+
header: string;
|
|
144
|
+
button: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
size: {
|
|
148
|
+
sm: {
|
|
149
|
+
header: string;
|
|
150
|
+
button: string;
|
|
151
|
+
body: string;
|
|
152
|
+
};
|
|
153
|
+
md: {
|
|
154
|
+
header: string;
|
|
155
|
+
button: string;
|
|
156
|
+
body: string;
|
|
157
|
+
};
|
|
158
|
+
lg: {
|
|
159
|
+
header: string;
|
|
160
|
+
button: string;
|
|
161
|
+
body: string;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
}, {
|
|
165
|
+
root: string;
|
|
166
|
+
header: string;
|
|
167
|
+
title: string;
|
|
168
|
+
button: string;
|
|
169
|
+
body: string;
|
|
170
|
+
}>>;
|
|
171
|
+
export type CodeBlockVariantProps = VariantProps<typeof codeBlockVariants>;
|
|
172
|
+
export type CodeBlockSlots = keyof ReturnType<typeof codeBlockVariants>;
|
|
173
|
+
export declare const codeBlockDefaults: {
|
|
174
|
+
defaultVariants: import("tailwind-variants").TVDefaultVariants<{
|
|
175
|
+
variant: {
|
|
176
|
+
outline: {
|
|
177
|
+
root: string;
|
|
178
|
+
header: string;
|
|
179
|
+
button: string;
|
|
180
|
+
};
|
|
181
|
+
soft: {
|
|
182
|
+
root: string;
|
|
183
|
+
header: string;
|
|
184
|
+
button: string;
|
|
185
|
+
};
|
|
186
|
+
subtle: {
|
|
187
|
+
root: string;
|
|
188
|
+
header: string;
|
|
189
|
+
button: string;
|
|
190
|
+
};
|
|
191
|
+
solid: {
|
|
192
|
+
root: string;
|
|
193
|
+
header: string;
|
|
194
|
+
button: string;
|
|
195
|
+
};
|
|
196
|
+
ghost: {
|
|
197
|
+
root: string;
|
|
198
|
+
header: string;
|
|
199
|
+
button: string;
|
|
200
|
+
};
|
|
201
|
+
none: {
|
|
202
|
+
root: string;
|
|
203
|
+
header: string;
|
|
204
|
+
button: string;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
size: {
|
|
208
|
+
sm: {
|
|
209
|
+
header: string;
|
|
210
|
+
button: string;
|
|
211
|
+
body: string;
|
|
212
|
+
};
|
|
213
|
+
md: {
|
|
214
|
+
header: string;
|
|
215
|
+
button: string;
|
|
216
|
+
body: string;
|
|
217
|
+
};
|
|
218
|
+
lg: {
|
|
219
|
+
header: string;
|
|
220
|
+
button: string;
|
|
221
|
+
body: string;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
}, {
|
|
225
|
+
root: string;
|
|
226
|
+
header: string;
|
|
227
|
+
title: string;
|
|
228
|
+
button: string;
|
|
229
|
+
body: string;
|
|
230
|
+
}, {
|
|
231
|
+
variant: {
|
|
232
|
+
outline: {
|
|
233
|
+
root: string;
|
|
234
|
+
header: string;
|
|
235
|
+
button: string;
|
|
236
|
+
};
|
|
237
|
+
soft: {
|
|
238
|
+
root: string;
|
|
239
|
+
header: string;
|
|
240
|
+
button: string;
|
|
241
|
+
};
|
|
242
|
+
subtle: {
|
|
243
|
+
root: string;
|
|
244
|
+
header: string;
|
|
245
|
+
button: string;
|
|
246
|
+
};
|
|
247
|
+
solid: {
|
|
248
|
+
root: string;
|
|
249
|
+
header: string;
|
|
250
|
+
button: string;
|
|
251
|
+
};
|
|
252
|
+
ghost: {
|
|
253
|
+
root: string;
|
|
254
|
+
header: string;
|
|
255
|
+
button: string;
|
|
256
|
+
};
|
|
257
|
+
none: {
|
|
258
|
+
root: string;
|
|
259
|
+
header: string;
|
|
260
|
+
button: string;
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
size: {
|
|
264
|
+
sm: {
|
|
265
|
+
header: string;
|
|
266
|
+
button: string;
|
|
267
|
+
body: string;
|
|
268
|
+
};
|
|
269
|
+
md: {
|
|
270
|
+
header: string;
|
|
271
|
+
button: string;
|
|
272
|
+
body: string;
|
|
273
|
+
};
|
|
274
|
+
lg: {
|
|
275
|
+
header: string;
|
|
276
|
+
button: string;
|
|
277
|
+
body: string;
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
}, {
|
|
281
|
+
root: string;
|
|
282
|
+
header: string;
|
|
283
|
+
title: string;
|
|
284
|
+
button: string;
|
|
285
|
+
body: string;
|
|
286
|
+
}>;
|
|
287
|
+
slots: Partial<Record<CodeBlockSlots, string>>;
|
|
288
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const codeBlockVariants = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
root: 'mt-4 overflow-hidden rounded-2xl border border-outline-variant bg-surface-container',
|
|
5
|
+
header: 'flex items-center justify-between border-b border-outline-variant',
|
|
6
|
+
title: 'text-sm font-medium text-on-surface-variant',
|
|
7
|
+
button: 'rounded-md border border-outline-variant text-xs font-medium text-on-surface-variant transition-colors hover:bg-surface-container-highest disabled:cursor-not-allowed disabled:opacity-50',
|
|
8
|
+
body: 'bg-surface-container-highest [&_.shiki]:rounded-none [&_.shiki]:overflow-x-auto [&_.shiki]:m-0'
|
|
9
|
+
},
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
outline: {
|
|
13
|
+
root: 'border border-outline-variant bg-surface-container',
|
|
14
|
+
header: 'border-outline-variant',
|
|
15
|
+
button: 'border-outline-variant'
|
|
16
|
+
},
|
|
17
|
+
soft: {
|
|
18
|
+
root: 'border border-outline-variant/60 bg-surface-container/40',
|
|
19
|
+
header: 'border-outline-variant/60',
|
|
20
|
+
button: 'border-outline-variant/60'
|
|
21
|
+
},
|
|
22
|
+
subtle: {
|
|
23
|
+
root: 'border border-outline-variant/40 bg-surface-container/20',
|
|
24
|
+
header: 'border-outline-variant/40',
|
|
25
|
+
button: 'border-outline-variant/40'
|
|
26
|
+
},
|
|
27
|
+
solid: {
|
|
28
|
+
root: 'border border-outline-variant/60 bg-surface-container-high',
|
|
29
|
+
header: 'border-outline-variant/60',
|
|
30
|
+
button: 'border-outline-variant/60'
|
|
31
|
+
},
|
|
32
|
+
ghost: {
|
|
33
|
+
root: 'border border-transparent bg-transparent',
|
|
34
|
+
header: 'border-outline-variant/30',
|
|
35
|
+
button: 'border-outline-variant/30'
|
|
36
|
+
},
|
|
37
|
+
none: {
|
|
38
|
+
root: 'border-0 bg-transparent rounded-none',
|
|
39
|
+
header: 'border-0 px-0',
|
|
40
|
+
button: 'border-outline-variant/40'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
sm: {
|
|
45
|
+
header: 'px-3 py-2',
|
|
46
|
+
button: 'px-2 py-1',
|
|
47
|
+
body: '[&_.shiki]:p-3 [&_.shiki]:text-xs [&_.shiki]:leading-5'
|
|
48
|
+
},
|
|
49
|
+
md: {
|
|
50
|
+
header: 'px-4 py-3',
|
|
51
|
+
button: 'px-2.5 py-1',
|
|
52
|
+
body: '[&_.shiki]:p-4 [&_.shiki]:text-sm [&_.shiki]:leading-6'
|
|
53
|
+
},
|
|
54
|
+
lg: {
|
|
55
|
+
header: 'px-5 py-4',
|
|
56
|
+
button: 'px-3 py-1.5',
|
|
57
|
+
body: '[&_.shiki]:p-5 [&_.shiki]:text-sm [&_.shiki]:leading-6'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
defaultVariants: {
|
|
62
|
+
variant: 'outline',
|
|
63
|
+
size: 'md'
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
export const codeBlockDefaults = {
|
|
67
|
+
defaultVariants: codeBlockVariants.defaultVariants,
|
|
68
|
+
slots: {}
|
|
69
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CodeBlock } from './CodeBlock.svelte';
|