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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 asphum
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# SV5UI Plus
|
|
2
|
+
|
|
3
|
+
Companion components and hooks for [SV5UI](https://github.com/ndlabdev/sv5ui) and Svelte 5.
|
|
4
|
+
|
|
5
|
+
SV5UI Plus no longer maintains copies of SV5UI components. Version 4 contains only additions that SV5UI does not provide, plus a small compatibility entry point for gradual migration.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add sv5ui sv5ui-plus
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```css
|
|
14
|
+
/* src/routes/layout.css */
|
|
15
|
+
@import 'sv5ui/theme.css';
|
|
16
|
+
@source '../../node_modules/sv5ui-plus/dist';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Import core UI from SV5UI and addons from SV5UI Plus:
|
|
20
|
+
|
|
21
|
+
```svelte
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { Button, Icon } from 'sv5ui'
|
|
24
|
+
import { ColorPicker, ConfirmDialog, Search } from 'sv5ui-plus'
|
|
25
|
+
</script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For an incremental migration from Svelora, `sv5ui-plus/compat` re-exports SV5UI together with SV5UI Plus addons:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { Button, ColorPicker } from 'sv5ui-plus/compat'
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
New code should use the explicit `sv5ui` and `sv5ui-plus` imports.
|
|
35
|
+
|
|
36
|
+
## Addons
|
|
37
|
+
|
|
38
|
+
- Content and display: `BentoGrid`, `Chart`, `Chat`, `CodeBlock`, `Fonts`, `List`, `Marquee`, `NumberTicker`, `Prose`, `Spotlight`
|
|
39
|
+
- Forms and overlays: `ColorPicker`, `ConfirmDialog`, `LocaleButton`, `PasswordInput`, `Search`
|
|
40
|
+
- Layout and data: `Resizable`, `ScrollArea`, `TableBulkActionBar`, `TreeView`
|
|
41
|
+
- Drag and drop: `SortableGroup`, `SortableList`, `useDragDrop`, `useSortable`
|
|
42
|
+
- SvelteKit adapter: `SvelteKitNavigationMenu`
|
|
43
|
+
- Feedback adapter: `notify`
|
|
44
|
+
|
|
45
|
+
The editor entry point remains available as `sv5ui-plus/editor` and proxies `sv5ui/editor`.
|
|
46
|
+
|
|
47
|
+
## Breaking changes in v4
|
|
48
|
+
|
|
49
|
+
- Removed components and hooks already supplied by SV5UI.
|
|
50
|
+
- Icon names use Iconify syntax such as `lucide:edit`.
|
|
51
|
+
- The former `NavigationMenu` addon is exported as `SvelteKitNavigationMenu` to avoid colliding with SV5UI.
|
|
52
|
+
- Core configuration comes from `sv5ui`; SV5UI Plus-specific aliases remain available for migration.
|
|
53
|
+
|
|
54
|
+
## Verification
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
bun run release:verify:full
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
[MIT](LICENSE) © [asphum](https://github.com/asphum)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ToastOptions } from 'sv5ui';
|
|
2
|
+
export interface NotifyOptions extends ToastOptions {
|
|
3
|
+
/** Inline style values merged into the toast style string. */
|
|
4
|
+
styles?: Record<string, string>;
|
|
5
|
+
/** Class values merged into the toast class string. */
|
|
6
|
+
classes?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export interface NotifyPromiseOptions<T = unknown> extends NotifyOptions {
|
|
9
|
+
loading: string;
|
|
10
|
+
success: string | ((data: T) => string);
|
|
11
|
+
error: string | ((error: unknown) => string);
|
|
12
|
+
checkSuccess?: (data: T) => boolean;
|
|
13
|
+
loadingOptions?: NotifyOptions;
|
|
14
|
+
successOptions?: NotifyOptions;
|
|
15
|
+
errorOptions?: NotifyOptions;
|
|
16
|
+
minDuration?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare const notify: {
|
|
19
|
+
success(message: string, options?: NotifyOptions): string | number;
|
|
20
|
+
error(error: unknown, options?: NotifyOptions): string | number;
|
|
21
|
+
info(message: string, options?: NotifyOptions): string | number;
|
|
22
|
+
warning(message: string, options?: NotifyOptions): string | number;
|
|
23
|
+
loading(message: string, options?: NotifyOptions): string | number;
|
|
24
|
+
processing(message: string, options?: NotifyOptions): string | number;
|
|
25
|
+
default(message: string, options?: NotifyOptions): string | number;
|
|
26
|
+
promise<T>(promise: Promise<T>, options: NotifyPromiseOptions<T>): Promise<T>;
|
|
27
|
+
dismiss(id?: string | number): string | number | undefined;
|
|
28
|
+
};
|
|
29
|
+
export type NotifyUtility = typeof notify;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { toast } from 'sv5ui';
|
|
2
|
+
function errorMessage(error) {
|
|
3
|
+
if (typeof error === 'string')
|
|
4
|
+
return error;
|
|
5
|
+
if (error instanceof Error)
|
|
6
|
+
return error.message;
|
|
7
|
+
if (error && typeof error === 'object') {
|
|
8
|
+
const value = error;
|
|
9
|
+
if (typeof value.message === 'string')
|
|
10
|
+
return value.message;
|
|
11
|
+
if (typeof value.error === 'string')
|
|
12
|
+
return value.error;
|
|
13
|
+
return JSON.stringify(error);
|
|
14
|
+
}
|
|
15
|
+
return 'An unknown error occurred';
|
|
16
|
+
}
|
|
17
|
+
function resolveOptions(options) {
|
|
18
|
+
if (!options)
|
|
19
|
+
return undefined;
|
|
20
|
+
const { styles, classes, ...rest } = options;
|
|
21
|
+
const style = styles
|
|
22
|
+
? Object.entries(styles)
|
|
23
|
+
.map(([key, value]) => `${key}: ${value}`)
|
|
24
|
+
.join('; ')
|
|
25
|
+
: undefined;
|
|
26
|
+
const className = classes ? Object.values(classes).join(' ') : undefined;
|
|
27
|
+
return {
|
|
28
|
+
...rest,
|
|
29
|
+
style: [rest.style, style].filter(Boolean).join('; ') || undefined,
|
|
30
|
+
class: [rest.class, className].filter(Boolean).join(' ') || undefined
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export const notify = {
|
|
34
|
+
success(message, options) {
|
|
35
|
+
return toast.success(message, resolveOptions(options));
|
|
36
|
+
},
|
|
37
|
+
error(error, options) {
|
|
38
|
+
return toast.error(errorMessage(error), resolveOptions(options));
|
|
39
|
+
},
|
|
40
|
+
info(message, options) {
|
|
41
|
+
return toast.info(message, resolveOptions(options));
|
|
42
|
+
},
|
|
43
|
+
warning(message, options) {
|
|
44
|
+
return toast.warning(message, resolveOptions(options));
|
|
45
|
+
},
|
|
46
|
+
loading(message, options) {
|
|
47
|
+
return toast.loading(message, {
|
|
48
|
+
duration: Number.POSITIVE_INFINITY,
|
|
49
|
+
...resolveOptions(options)
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
processing(message, options) {
|
|
53
|
+
return toast.loading(message, {
|
|
54
|
+
duration: Number.POSITIVE_INFINITY,
|
|
55
|
+
icon: 'lucide:loader-circle',
|
|
56
|
+
...resolveOptions(options)
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
default(message, options) {
|
|
60
|
+
return toast(message, resolveOptions(options));
|
|
61
|
+
},
|
|
62
|
+
promise(promise, options) {
|
|
63
|
+
const { loading, success, error, checkSuccess, loadingOptions, successOptions, errorOptions, minDuration = 800, ...shared } = options;
|
|
64
|
+
const id = notify.loading(loading, { ...shared, ...loadingOptions });
|
|
65
|
+
const minimum = new Promise((resolve) => setTimeout(resolve, minDuration));
|
|
66
|
+
Promise.all([promise, minimum])
|
|
67
|
+
.then(([data]) => {
|
|
68
|
+
if (checkSuccess && !checkSuccess(data))
|
|
69
|
+
throw data;
|
|
70
|
+
notify.success(typeof success === 'function' ? success(data) : success, {
|
|
71
|
+
...shared,
|
|
72
|
+
...successOptions,
|
|
73
|
+
id
|
|
74
|
+
});
|
|
75
|
+
})
|
|
76
|
+
.catch((reason) => {
|
|
77
|
+
notify.error(typeof error === 'function' ? error(reason) : error, {
|
|
78
|
+
...shared,
|
|
79
|
+
...errorOptions,
|
|
80
|
+
id
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
return promise;
|
|
84
|
+
},
|
|
85
|
+
dismiss(id) {
|
|
86
|
+
return toast.dismiss(id);
|
|
87
|
+
}
|
|
88
|
+
};
|
package/dist/compat.d.ts
ADDED
package/dist/compat.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { Icon } from "sv5ui";
|
|
3
|
+
import { Button } from "sv5ui";
|
|
4
|
+
import { bentoGridVariants } from "./bento-grid.variants.js";
|
|
5
|
+
let { name, description, icon, href, cta = "Learn more", class: className, background, actionSnippet, ...restProps } = $props();
|
|
6
|
+
let styles = $derived(bentoGridVariants());
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<div class={twMerge(styles.cardBase(), className)} {...restProps}>
|
|
10
|
+
<div class={styles.cardBackground()}>
|
|
11
|
+
{#if background}
|
|
12
|
+
{@render background()}
|
|
13
|
+
{/if}
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<!-- Push content up slightly on hover by adjusting group styles or locally -->
|
|
17
|
+
<div class={twMerge(styles.cardContent(), href && 'group-hover:-translate-y-4')}>
|
|
18
|
+
{#if icon}
|
|
19
|
+
<div class={styles.cardIconWrapper()}>
|
|
20
|
+
<Icon {name} class="w-6 h-6" />
|
|
21
|
+
</div>
|
|
22
|
+
{/if}
|
|
23
|
+
|
|
24
|
+
<h3 class={styles.cardTitle()}>{name}</h3>
|
|
25
|
+
|
|
26
|
+
{#if description}
|
|
27
|
+
<p class={styles.cardDescription()}>{description}</p>
|
|
28
|
+
{/if}
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
{#if href || actionSnippet}
|
|
32
|
+
<div class={twMerge(styles.cardAction(), !href && !actionSnippet && 'hidden')}>
|
|
33
|
+
{#if actionSnippet}
|
|
34
|
+
{@render actionSnippet()}
|
|
35
|
+
{:else if href}
|
|
36
|
+
<Button {href} variant="ghost" size="sm" class="pl-0 hover:bg-transparent">
|
|
37
|
+
{cta}
|
|
38
|
+
{#snippet trailingSlot()}
|
|
39
|
+
<Icon name="lucide:arrow-right" class="w-4 h-4 ml-1" />
|
|
40
|
+
{/snippet}
|
|
41
|
+
</Button>
|
|
42
|
+
{/if}
|
|
43
|
+
</div>
|
|
44
|
+
{/if}
|
|
45
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { bentoGridVariants } from "./bento-grid.variants.js";
|
|
3
|
+
let { class: className, children, ...restProps } = $props();
|
|
4
|
+
let styles = $derived(bentoGridVariants());
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<div class={twMerge(styles.gridBase(), className)} {...restProps}>
|
|
8
|
+
{@render children?.()}
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
export interface BentoGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/**
|
|
5
|
+
* Additional CSS classes.
|
|
6
|
+
*/
|
|
7
|
+
class?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The cards to render inside the grid.
|
|
10
|
+
*/
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
export interface BentoCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
/**
|
|
15
|
+
* Title of the card.
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
18
|
+
/**
|
|
19
|
+
* Description text.
|
|
20
|
+
*/
|
|
21
|
+
description?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Icon name.
|
|
24
|
+
*/
|
|
25
|
+
icon?: string;
|
|
26
|
+
/**
|
|
27
|
+
* The href to navigate to when the call-to-action is clicked.
|
|
28
|
+
*/
|
|
29
|
+
href?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Text for the call-to-action button.
|
|
32
|
+
* @default 'Learn more'
|
|
33
|
+
*/
|
|
34
|
+
cta?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Additional CSS classes. Useful for setting grid column/row spans (e.g. `col-span-2`).
|
|
37
|
+
*/
|
|
38
|
+
class?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Snippet for background visual elements (e.g. gradients, images).
|
|
41
|
+
*/
|
|
42
|
+
background?: Snippet;
|
|
43
|
+
/**
|
|
44
|
+
* Snippet for overriding or extending the action area.
|
|
45
|
+
*/
|
|
46
|
+
actionSnippet?: Snippet;
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const bentoGridVariants: import("tailwind-variants").TVReturnType<{}, {
|
|
3
|
+
gridBase: string;
|
|
4
|
+
cardBase: string;
|
|
5
|
+
cardBackground: string;
|
|
6
|
+
cardContent: string;
|
|
7
|
+
cardIconWrapper: string;
|
|
8
|
+
cardTitle: string;
|
|
9
|
+
cardDescription: string;
|
|
10
|
+
cardAction: string;
|
|
11
|
+
}, undefined, {}, {
|
|
12
|
+
gridBase: string;
|
|
13
|
+
cardBase: string;
|
|
14
|
+
cardBackground: string;
|
|
15
|
+
cardContent: string;
|
|
16
|
+
cardIconWrapper: string;
|
|
17
|
+
cardTitle: string;
|
|
18
|
+
cardDescription: string;
|
|
19
|
+
cardAction: string;
|
|
20
|
+
}, import("tailwind-variants").TVReturnTypeLike<{}, {
|
|
21
|
+
gridBase: string;
|
|
22
|
+
cardBase: string;
|
|
23
|
+
cardBackground: string;
|
|
24
|
+
cardContent: string;
|
|
25
|
+
cardIconWrapper: string;
|
|
26
|
+
cardTitle: string;
|
|
27
|
+
cardDescription: string;
|
|
28
|
+
cardAction: string;
|
|
29
|
+
}>>;
|
|
30
|
+
export type BentoGridVariantProps = VariantProps<typeof bentoGridVariants>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const bentoGridVariants = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
gridBase: 'grid grid-cols-1 md:grid-cols-3 gap-4 max-w-7xl mx-auto w-full',
|
|
5
|
+
cardBase: 'group relative flex flex-col justify-between overflow-hidden rounded-xl bg-surface-50 dark:bg-surface-900 border border-outline-variant transition-all hover:shadow-md dark:hover:shadow-surface-800/50',
|
|
6
|
+
cardBackground: 'absolute inset-0 transition-all duration-300 pointer-events-none',
|
|
7
|
+
cardContent: 'pointer-events-none z-10 flex transform-gpu flex-col gap-1 p-6 transition-all duration-300',
|
|
8
|
+
cardIconWrapper: 'mb-2 w-10 h-10 flex items-center justify-center rounded-lg bg-primary-100 dark:bg-primary-900/30 text-primary-600 dark:text-primary-400',
|
|
9
|
+
cardTitle: 'text-lg font-semibold text-surface-900 dark:text-surface-50',
|
|
10
|
+
cardDescription: 'text-sm text-surface-500 dark:text-surface-400',
|
|
11
|
+
cardAction: 'pointer-events-auto absolute bottom-0 left-0 w-full p-6 opacity-0 translate-y-4 transition-all duration-300 group-hover:opacity-100 group-hover:translate-y-0'
|
|
12
|
+
},
|
|
13
|
+
variants: {
|
|
14
|
+
// Variants can be added if we want different styles of grids
|
|
15
|
+
}
|
|
16
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<script lang="ts">import { onDestroy, onMount } from "svelte";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
let { options, series, class: className } = $props();
|
|
4
|
+
let chartContainer = $state(null);
|
|
5
|
+
let chartInstance = null;
|
|
6
|
+
function mergeOptions(nextOptions, nextSeries) {
|
|
7
|
+
const initialOptions = nextSeries ? {
|
|
8
|
+
...nextOptions,
|
|
9
|
+
series: nextSeries
|
|
10
|
+
} : nextOptions;
|
|
11
|
+
return {
|
|
12
|
+
...initialOptions,
|
|
13
|
+
chart: {
|
|
14
|
+
background: "transparent",
|
|
15
|
+
toolbar: { show: false },
|
|
16
|
+
fontFamily: "inherit",
|
|
17
|
+
...initialOptions.chart
|
|
18
|
+
},
|
|
19
|
+
theme: { ...initialOptions.theme },
|
|
20
|
+
tooltip: {
|
|
21
|
+
theme: "dark",
|
|
22
|
+
...initialOptions.tooltip
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
onMount(() => {
|
|
27
|
+
let cancelled = false;
|
|
28
|
+
void (async () => {
|
|
29
|
+
const ApexCharts = (await import("apexcharts")).default;
|
|
30
|
+
if (cancelled || !chartContainer?.isConnected) return;
|
|
31
|
+
const instance = new ApexCharts(chartContainer, mergeOptions(options, series));
|
|
32
|
+
try {
|
|
33
|
+
await instance.render();
|
|
34
|
+
} catch {
|
|
35
|
+
instance.destroy();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (cancelled || !chartContainer?.isConnected) {
|
|
39
|
+
instance.destroy();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
chartInstance = instance;
|
|
43
|
+
/** sync กรณี options/series เปลี่ยนระหว่าง await import/render */
|
|
44
|
+
void chartInstance.updateOptions(mergeOptions(options, series), false, true);
|
|
45
|
+
})();
|
|
46
|
+
return () => {
|
|
47
|
+
cancelled = true;
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
onDestroy(() => {
|
|
51
|
+
chartInstance?.destroy();
|
|
52
|
+
chartInstance = null;
|
|
53
|
+
});
|
|
54
|
+
$effect(() => {
|
|
55
|
+
const nextOptions = options;
|
|
56
|
+
const nextSeries = series;
|
|
57
|
+
if (!chartInstance) return;
|
|
58
|
+
void chartInstance.updateOptions(mergeOptions(nextOptions, nextSeries), false, true);
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<div class={twMerge('w-full', className)} bind:this={chartContainer}></div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ApexOptions } from 'apexcharts';
|
|
2
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
3
|
+
export interface ChartProps {
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for ApexCharts.
|
|
6
|
+
*/
|
|
7
|
+
options: ApexOptions;
|
|
8
|
+
/**
|
|
9
|
+
* Series data. If provided, overrides options.series.
|
|
10
|
+
*/
|
|
11
|
+
series?: ApexOptions['series'];
|
|
12
|
+
/**
|
|
13
|
+
* Tailwind class to apply to the chart container wrapper.
|
|
14
|
+
*/
|
|
15
|
+
class?: ClassNameValue;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { setContext } from "svelte";
|
|
3
|
+
import { chatVariants } from "./chat.variants.js";
|
|
4
|
+
let { position = "start", name, time, class: className, avatar, children, ...restProps } = $props();
|
|
5
|
+
let styles = $derived(chatVariants({ position }));
|
|
6
|
+
// Provide position context to child ChatMessage components for proper rounded corners
|
|
7
|
+
setContext("chat-bubble-position", () => position);
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<div class={twMerge(styles.bubbleBase() as string, className as string)} {...restProps}>
|
|
11
|
+
{#if avatar}
|
|
12
|
+
<div class={styles.bubbleAvatar()}>
|
|
13
|
+
{@render avatar()}
|
|
14
|
+
</div>
|
|
15
|
+
{/if}
|
|
16
|
+
|
|
17
|
+
<div class={styles.bubbleContent()}>
|
|
18
|
+
{#if name || time}
|
|
19
|
+
<div class={styles.bubbleHeader()}>
|
|
20
|
+
{#if name}
|
|
21
|
+
<span class={styles.bubbleName()}>{name}</span>
|
|
22
|
+
{/if}
|
|
23
|
+
{#if time}
|
|
24
|
+
<span class={styles.bubbleTime()}>{time}</span>
|
|
25
|
+
{/if}
|
|
26
|
+
</div>
|
|
27
|
+
{/if}
|
|
28
|
+
{@render children?.()}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { chatVariants } from "./chat.variants.js";
|
|
3
|
+
let { value = $bindable(""), placeholder = "Type a message...", disabled = false, class: className, leading, trailing, ...restProps } = $props();
|
|
4
|
+
let styles = $derived(chatVariants());
|
|
5
|
+
// Auto-resize textarea function could be added here
|
|
6
|
+
function autoResize(node) {
|
|
7
|
+
function resize() {
|
|
8
|
+
node.style.height = "auto";
|
|
9
|
+
node.style.height = node.scrollHeight + "px";
|
|
10
|
+
}
|
|
11
|
+
node.addEventListener("input", resize);
|
|
12
|
+
// Initial resize
|
|
13
|
+
setTimeout(resize, 0);
|
|
14
|
+
return { destroy() {
|
|
15
|
+
node.removeEventListener("input", resize);
|
|
16
|
+
} };
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<div class={twMerge(styles.inputBase() as string, className as string)} {...restProps}>
|
|
21
|
+
{#if leading}
|
|
22
|
+
<div class={styles.inputActions()}>
|
|
23
|
+
{@render leading()}
|
|
24
|
+
</div>
|
|
25
|
+
{/if}
|
|
26
|
+
|
|
27
|
+
<div class={styles.inputFieldWrapper()}>
|
|
28
|
+
<textarea
|
|
29
|
+
bind:value
|
|
30
|
+
{placeholder}
|
|
31
|
+
{disabled}
|
|
32
|
+
rows="1"
|
|
33
|
+
use:autoResize
|
|
34
|
+
class={styles.inputField()}
|
|
35
|
+
onkeydown={(e) => {
|
|
36
|
+
// If you want Shift+Enter for new line, and Enter to submit:
|
|
37
|
+
// if (e.key === 'Enter' && !e.shiftKey) {
|
|
38
|
+
// e.preventDefault()
|
|
39
|
+
// // Dispatch submit event
|
|
40
|
+
// }
|
|
41
|
+
}}
|
|
42
|
+
></textarea>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
{#if trailing}
|
|
46
|
+
<div class={styles.inputActions()}>
|
|
47
|
+
{@render trailing()}
|
|
48
|
+
</div>
|
|
49
|
+
{/if}
|
|
50
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">import { twMerge } from "tailwind-merge";
|
|
2
|
+
import { getContext } from "svelte";
|
|
3
|
+
import { chatVariants } from "./chat.variants.js";
|
|
4
|
+
let { variant = "surface", position: propPosition, class: className, children, ...restProps } = $props();
|
|
5
|
+
const getPositionContext = getContext("chat-bubble-position");
|
|
6
|
+
let position = $derived(propPosition ?? (getPositionContext ? getPositionContext() : "start"));
|
|
7
|
+
let styles = $derived(chatVariants({
|
|
8
|
+
variant,
|
|
9
|
+
position
|
|
10
|
+
}));
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div class={twMerge(styles.messageBase() as string, className as string)} {...restProps}>
|
|
14
|
+
{@render children?.()}
|
|
15
|
+
</div>
|