@makolabs/ripple 0.0.1-dev.2 → 0.0.1-dev.4
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 +229 -96
- package/dist/button/Button.svelte +46 -0
- package/dist/button/Button.svelte.d.ts +4 -0
- package/dist/button/button.d.ts +136 -0
- package/dist/button/button.js +167 -0
- package/dist/button/index.d.ts +1 -0
- package/dist/button/index.js +1 -0
- package/dist/drawer/Drawer.svelte +213 -0
- package/dist/drawer/Drawer.svelte.d.ts +4 -0
- package/dist/drawer/drawer.d.ts +177 -0
- package/dist/drawer/drawer.js +80 -0
- package/dist/drawer/index.d.ts +2 -0
- package/dist/drawer/index.js +1 -0
- package/dist/elements/badge/Badge.svelte +35 -0
- package/dist/elements/badge/Badge.svelte.d.ts +4 -0
- package/dist/elements/badge/badge.d.ts +193 -0
- package/dist/elements/badge/badge.js +65 -0
- package/dist/elements/badge/index.d.ts +2 -0
- package/dist/elements/badge/index.js +2 -0
- package/dist/elements/dropdown/Dropdown.svelte +272 -0
- package/dist/elements/dropdown/Dropdown.svelte.d.ts +4 -0
- package/dist/elements/dropdown/Select.svelte +230 -0
- package/dist/elements/dropdown/Select.svelte.d.ts +4 -0
- package/dist/elements/dropdown/dropdown.d.ts +274 -0
- package/dist/elements/dropdown/dropdown.js +89 -0
- package/dist/elements/dropdown/index.d.ts +3 -0
- package/dist/elements/dropdown/index.js +2 -0
- package/dist/elements/dropdown/select.d.ts +220 -0
- package/dist/elements/dropdown/select.js +74 -0
- package/dist/header/Breadcrumbs.svelte +72 -0
- package/dist/header/Breadcrumbs.svelte.d.ts +4 -0
- package/dist/header/PageHeader.svelte +30 -0
- package/dist/header/PageHeader.svelte.d.ts +4 -0
- package/dist/header/breadcrumbs.d.ts +220 -0
- package/dist/header/breadcrumbs.js +81 -0
- package/dist/header/index.d.ts +4 -0
- package/dist/header/index.js +2 -0
- package/dist/header/pageheaders.d.ts +10 -0
- package/dist/header/pageheaders.js +1 -0
- package/dist/helper/cls.d.ts +1 -0
- package/dist/helper/cls.js +4 -0
- package/dist/helper/nav.svelte.d.ts +6 -0
- package/dist/helper/nav.svelte.js +23 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +18 -1
- package/dist/layout/card/Card.svelte +44 -0
- package/dist/layout/card/Card.svelte.d.ts +4 -0
- package/dist/layout/card/StatsCard.svelte +236 -0
- package/dist/layout/card/StatsCard.svelte.d.ts +4 -0
- package/dist/layout/card/card.d.ts +139 -0
- package/dist/layout/card/card.js +50 -0
- package/dist/layout/card/index.d.ts +4 -0
- package/dist/layout/card/index.js +2 -0
- package/dist/layout/card/stats-card.d.ts +208 -0
- package/dist/layout/card/stats-card.js +73 -0
- package/dist/layout/index.d.ts +7 -1
- package/dist/layout/index.js +7 -1
- package/dist/layout/navbar/Navbar.svelte +206 -0
- package/dist/layout/navbar/Navbar.svelte.d.ts +4 -0
- package/dist/layout/navbar/index.d.ts +2 -0
- package/dist/layout/navbar/index.js +2 -0
- package/dist/layout/navbar/navbar.d.ts +228 -0
- package/dist/layout/navbar/navbar.js +98 -0
- package/dist/layout/sidebar/NavGroup.svelte +101 -0
- package/dist/layout/sidebar/NavGroup.svelte.d.ts +4 -0
- package/dist/layout/sidebar/NavItem.svelte +29 -0
- package/dist/layout/sidebar/NavItem.svelte.d.ts +4 -0
- package/dist/layout/sidebar/Sidebar.svelte +145 -0
- package/dist/layout/sidebar/Sidebar.svelte.d.ts +4 -0
- package/dist/layout/sidebar/index.d.ts +2 -0
- package/dist/layout/sidebar/index.js +1 -0
- package/dist/layout/sidebar/sidebar.d.ts +46 -0
- package/dist/layout/sidebar/sidebar.js +1 -0
- package/dist/layout/table/Cells.svelte +111 -0
- package/dist/layout/table/Cells.svelte.d.ts +27 -0
- package/dist/layout/table/Table.svelte +413 -0
- package/dist/layout/table/Table.svelte.d.ts +4 -0
- package/dist/layout/table/index.d.ts +3 -0
- package/dist/layout/table/index.js +2 -0
- package/dist/layout/table/table.d.ts +303 -0
- package/dist/layout/table/table.js +149 -0
- package/dist/layout/tabs/Tab.svelte +57 -0
- package/dist/layout/tabs/Tab.svelte.d.ts +4 -0
- package/dist/layout/tabs/TabContent.svelte +31 -0
- package/dist/layout/tabs/TabContent.svelte.d.ts +4 -0
- package/dist/layout/tabs/TabGroup.svelte +57 -0
- package/dist/layout/tabs/TabGroup.svelte.d.ts +4 -0
- package/dist/layout/tabs/index.d.ts +3 -0
- package/dist/layout/tabs/index.js +3 -0
- package/dist/layout/tabs/tabs.d.ts +155 -0
- package/dist/layout/tabs/tabs.js +156 -0
- package/dist/modal/Modal.svelte +206 -0
- package/dist/modal/Modal.svelte.d.ts +4 -0
- package/dist/modal/index.d.ts +1 -0
- package/dist/modal/index.js +1 -0
- package/dist/modal/modal.d.ts +234 -0
- package/dist/modal/modal.js +81 -0
- package/dist/types/variants.d.ts +21 -0
- package/dist/types/variants.js +19 -0
- package/package.json +100 -102
- package/dist/layout/Card.svelte +0 -179
- package/dist/layout/Card.svelte.d.ts +0 -208
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { tv } from '../helper/cls.js';
|
|
2
|
+
export const buttonVariants = tv({
|
|
3
|
+
base: `
|
|
4
|
+
inline-flex items-center justify-center font-medium transition-colors focus-visible:outline-none
|
|
5
|
+
focus-visible:ring-2 focus-visible:ring-offset-2 cursor-pointer
|
|
6
|
+
`,
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
solid: '',
|
|
10
|
+
outline: 'border bg-transparent',
|
|
11
|
+
ghost: 'bg-transparent hover:bg-opacity-10',
|
|
12
|
+
link: 'bg-transparent underline-offset-4 hover:underline shadow-none'
|
|
13
|
+
},
|
|
14
|
+
color: {
|
|
15
|
+
default: 'bg-default-900 text-white hover:bg-default-800 focus-visible:ring-default-500',
|
|
16
|
+
primary: 'bg-primary-600 text-white hover:bg-primary-700 focus-visible:ring-primary-500',
|
|
17
|
+
secondary: 'bg-secondary-600 text-white hover:bg-secondary-700 focus-visible:ring-secondary-500',
|
|
18
|
+
info: 'bg-info-600 text-white hover:bg-info-700 focus-visible:ring-info-500',
|
|
19
|
+
success: 'bg-success-600 text-white hover:bg-success-700 focus-visible:ring-success-500',
|
|
20
|
+
warning: 'bg-warning-600 text-white hover:bg-warning-700 focus-visible:ring-warning-500',
|
|
21
|
+
danger: 'bg-danger-600 text-white hover:bg-danger-700 focus-visible:ring-danger-500'
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
xs: 'h-7 px-2 text-xs',
|
|
25
|
+
sm: 'h-8 px-3 text-sm',
|
|
26
|
+
base: 'h-9 px-4 text-sm',
|
|
27
|
+
lg: 'h-10 px-5 text-base',
|
|
28
|
+
xl: 'h-12 px-6 text-lg',
|
|
29
|
+
'2xl': 'h-14 px-8 text-xl'
|
|
30
|
+
},
|
|
31
|
+
rounded: {
|
|
32
|
+
none: 'rounded-none',
|
|
33
|
+
xs: 'rounded-xs',
|
|
34
|
+
sm: 'rounded-sm',
|
|
35
|
+
base: 'rounded-md',
|
|
36
|
+
lg: 'rounded-lg',
|
|
37
|
+
xl: 'rounded-xl',
|
|
38
|
+
'2xl': 'rounded-2xl',
|
|
39
|
+
full: 'rounded-full'
|
|
40
|
+
},
|
|
41
|
+
isLoading: {
|
|
42
|
+
true: 'animate-pulse'
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
compoundVariants: [
|
|
46
|
+
// Remove background for non-solid variants
|
|
47
|
+
{
|
|
48
|
+
variant: ['outline', 'ghost', 'link'],
|
|
49
|
+
class: 'bg-transparent hover:bg-transparent'
|
|
50
|
+
},
|
|
51
|
+
// Outline variants
|
|
52
|
+
{
|
|
53
|
+
variant: 'outline',
|
|
54
|
+
color: 'default',
|
|
55
|
+
class: 'border-default-200 text-default-700 hover:bg-default-50 hover:border-default-300 focus-visible:ring-default-300'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
variant: 'outline',
|
|
59
|
+
color: 'primary',
|
|
60
|
+
class: 'border-primary-200 text-primary-700 hover:bg-primary-50 hover:border-primary-300 focus-visible:ring-primary-300'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
variant: 'outline',
|
|
64
|
+
color: 'secondary',
|
|
65
|
+
class: 'border-secondary-200 text-secondary-700 hover:bg-secondary-50 hover:border-secondary-300 focus-visible:ring-secondary-300'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
variant: 'outline',
|
|
69
|
+
color: 'info',
|
|
70
|
+
class: 'border-info-200 text-info-700 hover:bg-info-50 hover:border-info-300 focus-visible:ring-info-300'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
variant: 'outline',
|
|
74
|
+
color: 'success',
|
|
75
|
+
class: 'border-success-200 text-success-700 hover:bg-success-50 hover:border-success-300 focus-visible:ring-success-300'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
variant: 'outline',
|
|
79
|
+
color: 'warning',
|
|
80
|
+
class: 'border-warning-200 text-warning-700 hover:bg-warning-50 hover:border-warning-300 focus-visible:ring-warning-300'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
variant: 'outline',
|
|
84
|
+
color: 'danger',
|
|
85
|
+
class: 'border-danger-200 text-danger-700 hover:bg-danger-50 hover:border-danger-300 focus-visible:ring-danger-300'
|
|
86
|
+
},
|
|
87
|
+
// Ghost variants
|
|
88
|
+
{
|
|
89
|
+
variant: 'ghost',
|
|
90
|
+
color: 'default',
|
|
91
|
+
class: 'text-default-700 hover:bg-default-100 focus-visible:ring-default-300'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
variant: 'ghost',
|
|
95
|
+
color: 'primary',
|
|
96
|
+
class: 'text-primary-700 hover:bg-primary-100 focus-visible:ring-primary-300'
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
variant: 'ghost',
|
|
100
|
+
color: 'secondary',
|
|
101
|
+
class: 'text-secondary-700 hover:bg-secondary-100 focus-visible:ring-secondary-300'
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
variant: 'ghost',
|
|
105
|
+
color: 'info',
|
|
106
|
+
class: 'text-info-700 hover:bg-info-100 focus-visible:ring-info-300'
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
variant: 'ghost',
|
|
110
|
+
color: 'success',
|
|
111
|
+
class: 'text-success-700 hover:bg-success-100 focus-visible:ring-success-300'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
variant: 'ghost',
|
|
115
|
+
color: 'warning',
|
|
116
|
+
class: 'text-warning-700 hover:bg-warning-100 focus-visible:ring-warning-300'
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
variant: 'ghost',
|
|
120
|
+
color: 'danger',
|
|
121
|
+
class: 'text-danger-700 hover:bg-danger-100 focus-visible:ring-danger-300'
|
|
122
|
+
},
|
|
123
|
+
// Link variants
|
|
124
|
+
{
|
|
125
|
+
variant: 'link',
|
|
126
|
+
color: 'default',
|
|
127
|
+
class: 'text-default-700 hover:text-default-800 focus-visible:ring-default-300'
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
variant: 'link',
|
|
131
|
+
color: 'primary',
|
|
132
|
+
class: 'text-primary-700 hover:text-primary-800 focus-visible:ring-primary-300'
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
variant: 'link',
|
|
136
|
+
color: 'secondary',
|
|
137
|
+
class: 'text-secondary-700 hover:text-secondary-800 focus-visible:ring-secondary-300'
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
variant: 'link',
|
|
141
|
+
color: 'info',
|
|
142
|
+
class: 'text-info-700 hover:text-info-800 focus-visible:ring-info-300'
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
variant: 'link',
|
|
146
|
+
color: 'success',
|
|
147
|
+
class: 'text-success-700 hover:text-success-800 focus-visible:ring-success-300'
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
variant: 'link',
|
|
151
|
+
color: 'warning',
|
|
152
|
+
class: 'text-warning-700 hover:text-warning-800 focus-visible:ring-warning-300'
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
variant: 'link',
|
|
156
|
+
color: 'danger',
|
|
157
|
+
class: 'text-danger-700 hover:text-danger-800 focus-visible:ring-danger-300'
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
defaultVariants: {
|
|
161
|
+
variant: 'solid',
|
|
162
|
+
color: 'default',
|
|
163
|
+
size: 'base',
|
|
164
|
+
rounded: 'base',
|
|
165
|
+
isLoading: false
|
|
166
|
+
}
|
|
167
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Button } from './Button.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Button } from './Button.svelte';
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount, onDestroy, tick } from 'svelte';
|
|
3
|
+
import { browser } from '$app/environment';
|
|
4
|
+
import { fade, fly } from 'svelte/transition';
|
|
5
|
+
import { quintOut } from 'svelte/easing';
|
|
6
|
+
import { cn } from '../helper/cls.js';
|
|
7
|
+
import { drawer, type DrawerProps } from './drawer.js';
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
open = $bindable(false),
|
|
11
|
+
onclose: onClose = () => {},
|
|
12
|
+
title,
|
|
13
|
+
position = 'right',
|
|
14
|
+
size = 'sm',
|
|
15
|
+
children,
|
|
16
|
+
header,
|
|
17
|
+
class: className = '',
|
|
18
|
+
backdropclass: backdropClassName = '',
|
|
19
|
+
contentclass: contentClassName = '',
|
|
20
|
+
headerclass: headerClassName = '',
|
|
21
|
+
bodyclass: bodyClassName = '',
|
|
22
|
+
titleclass: titleClassName = ''
|
|
23
|
+
}: DrawerProps = $props();
|
|
24
|
+
|
|
25
|
+
let drawerElement: HTMLDivElement | undefined = $state();
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
base,
|
|
29
|
+
backdrop,
|
|
30
|
+
contentWrapper,
|
|
31
|
+
content,
|
|
32
|
+
header: headerVClass,
|
|
33
|
+
body,
|
|
34
|
+
footer: footerVClass,
|
|
35
|
+
title: titleClass,
|
|
36
|
+
closeButton
|
|
37
|
+
} = $derived(
|
|
38
|
+
drawer({
|
|
39
|
+
open,
|
|
40
|
+
position,
|
|
41
|
+
size
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const baseClass = $derived(cn(base(), className));
|
|
46
|
+
const backdropClass = $derived(cn(backdrop(), backdropClassName));
|
|
47
|
+
const contentWrapperClass = $derived(cn(contentWrapper(), contentClassName));
|
|
48
|
+
const contentClass = $derived(cn(content(), ''));
|
|
49
|
+
const headerClass = $derived(cn(headerVClass(), headerClassName));
|
|
50
|
+
const bodyClass = $derived(cn(body(), bodyClassName));
|
|
51
|
+
const titleClasses = $derived(cn(titleClass(), titleClassName));
|
|
52
|
+
const closeButtonClasses = $derived(cn(closeButton(), ''));
|
|
53
|
+
|
|
54
|
+
function handleBackdropClick(e: MouseEvent) {
|
|
55
|
+
if (e.target === e.currentTarget) {
|
|
56
|
+
onClose();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function handleEscapeKey(e: KeyboardEvent) {
|
|
61
|
+
if (e.key === 'Escape' && open) {
|
|
62
|
+
onClose();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function handleCloseClick() {
|
|
67
|
+
onClose();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let previouslyFocusedElement: HTMLElement | null = null;
|
|
71
|
+
|
|
72
|
+
function trapFocus(element: HTMLElement) {
|
|
73
|
+
const focusableElements = element.querySelectorAll(
|
|
74
|
+
'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (focusableElements.length === 0) return;
|
|
78
|
+
|
|
79
|
+
const firstElement = focusableElements[0] as HTMLElement;
|
|
80
|
+
const lastElement = focusableElements[focusableElements.length - 1] as HTMLElement;
|
|
81
|
+
|
|
82
|
+
function handleTabKey(e: KeyboardEvent) {
|
|
83
|
+
if (e.key !== 'Tab') return;
|
|
84
|
+
|
|
85
|
+
if (e.shiftKey) {
|
|
86
|
+
if (document.activeElement === firstElement) {
|
|
87
|
+
lastElement.focus();
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
if (document.activeElement === lastElement) {
|
|
92
|
+
firstElement.focus();
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
element.addEventListener('keydown', handleTabKey);
|
|
99
|
+
firstElement.focus();
|
|
100
|
+
|
|
101
|
+
return () => {
|
|
102
|
+
element.removeEventListener('keydown', handleTabKey);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
onMount(() => {
|
|
107
|
+
document.addEventListener('keydown', handleEscapeKey);
|
|
108
|
+
return () => {
|
|
109
|
+
document.removeEventListener('keydown', handleEscapeKey);
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
$effect(() => {
|
|
114
|
+
if (!browser) return;
|
|
115
|
+
if (open) {
|
|
116
|
+
previouslyFocusedElement = document.activeElement as HTMLElement;
|
|
117
|
+
document.body.style.overflow = 'hidden';
|
|
118
|
+
|
|
119
|
+
tick().then(() => {
|
|
120
|
+
if (drawerElement) {
|
|
121
|
+
trapFocus(drawerElement);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
} else {
|
|
125
|
+
document.body.style.overflow = '';
|
|
126
|
+
if (previouslyFocusedElement) {
|
|
127
|
+
previouslyFocusedElement.focus();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
onDestroy(() => {
|
|
133
|
+
if (browser && document.body.style.overflow === 'hidden') {
|
|
134
|
+
document.body.style.overflow = '';
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
function getTransition() {
|
|
139
|
+
const duration = 300;
|
|
140
|
+
const options = { duration, easing: quintOut };
|
|
141
|
+
|
|
142
|
+
switch (position) {
|
|
143
|
+
case 'left':
|
|
144
|
+
return { x: -300, ...options };
|
|
145
|
+
case 'right':
|
|
146
|
+
return { x: 300, ...options };
|
|
147
|
+
default:
|
|
148
|
+
return { x: 300, ...options };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
</script>
|
|
152
|
+
|
|
153
|
+
{#if browser}
|
|
154
|
+
<div
|
|
155
|
+
class={baseClass}
|
|
156
|
+
bind:this={drawerElement}
|
|
157
|
+
role="dialog"
|
|
158
|
+
aria-modal="true"
|
|
159
|
+
aria-labelledby={title ? 'drawer-title' : undefined}
|
|
160
|
+
>
|
|
161
|
+
{#key open}
|
|
162
|
+
<!-- Backdrop -->
|
|
163
|
+
<button
|
|
164
|
+
class={backdropClass}
|
|
165
|
+
onclick={handleBackdropClick}
|
|
166
|
+
transition:fade={{ duration: 200 }}
|
|
167
|
+
aria-label="Close drawer"
|
|
168
|
+
></button>
|
|
169
|
+
|
|
170
|
+
<!-- Drawer content -->
|
|
171
|
+
<div class={contentWrapperClass} transition:fly={getTransition()}>
|
|
172
|
+
<div class={contentClass}>
|
|
173
|
+
<!-- Header -->
|
|
174
|
+
{#if header || title}
|
|
175
|
+
<div class={headerClass}>
|
|
176
|
+
{#if header}
|
|
177
|
+
{@render header()}
|
|
178
|
+
{:else}
|
|
179
|
+
{#if title}
|
|
180
|
+
<h3 id="drawer-title" class={titleClasses}>{title}</h3>
|
|
181
|
+
{/if}
|
|
182
|
+
<button
|
|
183
|
+
type="button"
|
|
184
|
+
class={closeButtonClasses}
|
|
185
|
+
onclick={handleCloseClick}
|
|
186
|
+
aria-label="Close drawer"
|
|
187
|
+
>
|
|
188
|
+
<svg
|
|
189
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
190
|
+
width="12"
|
|
191
|
+
height="12"
|
|
192
|
+
viewBox="0 0 12 12"
|
|
193
|
+
>
|
|
194
|
+
<path
|
|
195
|
+
fill="currentColor"
|
|
196
|
+
d="m1.897 2.054l.073-.084a.75.75 0 0 1 .976-.073l.084.073L6 4.939l2.97-2.97a.75.75 0 1 1 1.06 1.061L7.061 6l2.97 2.97a.75.75 0 0 1 .072.976l-.073.084a.75.75 0 0 1-.976.073l-.084-.073L6 7.061l-2.97 2.97A.75.75 0 1 1 1.97 8.97L4.939 6l-2.97-2.97a.75.75 0 0 1-.072-.976l.073-.084z"
|
|
197
|
+
/>
|
|
198
|
+
</svg>
|
|
199
|
+
</button>
|
|
200
|
+
{/if}
|
|
201
|
+
</div>
|
|
202
|
+
{/if}
|
|
203
|
+
|
|
204
|
+
<div class={bodyClass}>
|
|
205
|
+
{#if children}
|
|
206
|
+
{@render children()}
|
|
207
|
+
{/if}
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
{/key}
|
|
212
|
+
</div>
|
|
213
|
+
{/if}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { VariantSizes } from '../types/variants.js';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
export declare const drawer: import("tailwind-variants").TVReturnType<{
|
|
4
|
+
open: {
|
|
5
|
+
true: {
|
|
6
|
+
base: string;
|
|
7
|
+
backdrop: string;
|
|
8
|
+
contentWrapper: string;
|
|
9
|
+
};
|
|
10
|
+
false: {
|
|
11
|
+
base: string;
|
|
12
|
+
backdrop: string;
|
|
13
|
+
contentWrapper: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
position: {
|
|
17
|
+
left: {
|
|
18
|
+
contentWrapper: string;
|
|
19
|
+
content: string;
|
|
20
|
+
};
|
|
21
|
+
right: {
|
|
22
|
+
contentWrapper: string;
|
|
23
|
+
content: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
size: {
|
|
27
|
+
xs: {
|
|
28
|
+
contentWrapper: string;
|
|
29
|
+
};
|
|
30
|
+
sm: {
|
|
31
|
+
contentWrapper: string;
|
|
32
|
+
};
|
|
33
|
+
base: {
|
|
34
|
+
contentWrapper: string;
|
|
35
|
+
};
|
|
36
|
+
lg: {
|
|
37
|
+
contentWrapper: string;
|
|
38
|
+
};
|
|
39
|
+
xl: {
|
|
40
|
+
contentWrapper: string;
|
|
41
|
+
};
|
|
42
|
+
'2xl': {
|
|
43
|
+
contentWrapper: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
}, {
|
|
47
|
+
base: string;
|
|
48
|
+
backdrop: string;
|
|
49
|
+
contentWrapper: string;
|
|
50
|
+
content: string;
|
|
51
|
+
header: string;
|
|
52
|
+
body: string;
|
|
53
|
+
footer: string;
|
|
54
|
+
title: string;
|
|
55
|
+
closeButton: string;
|
|
56
|
+
}, undefined, {
|
|
57
|
+
open: {
|
|
58
|
+
true: {
|
|
59
|
+
base: string;
|
|
60
|
+
backdrop: string;
|
|
61
|
+
contentWrapper: string;
|
|
62
|
+
};
|
|
63
|
+
false: {
|
|
64
|
+
base: string;
|
|
65
|
+
backdrop: string;
|
|
66
|
+
contentWrapper: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
position: {
|
|
70
|
+
left: {
|
|
71
|
+
contentWrapper: string;
|
|
72
|
+
content: string;
|
|
73
|
+
};
|
|
74
|
+
right: {
|
|
75
|
+
contentWrapper: string;
|
|
76
|
+
content: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
size: {
|
|
80
|
+
xs: {
|
|
81
|
+
contentWrapper: string;
|
|
82
|
+
};
|
|
83
|
+
sm: {
|
|
84
|
+
contentWrapper: string;
|
|
85
|
+
};
|
|
86
|
+
base: {
|
|
87
|
+
contentWrapper: string;
|
|
88
|
+
};
|
|
89
|
+
lg: {
|
|
90
|
+
contentWrapper: string;
|
|
91
|
+
};
|
|
92
|
+
xl: {
|
|
93
|
+
contentWrapper: string;
|
|
94
|
+
};
|
|
95
|
+
'2xl': {
|
|
96
|
+
contentWrapper: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
}, {
|
|
100
|
+
base: string;
|
|
101
|
+
backdrop: string;
|
|
102
|
+
contentWrapper: string;
|
|
103
|
+
content: string;
|
|
104
|
+
header: string;
|
|
105
|
+
body: string;
|
|
106
|
+
footer: string;
|
|
107
|
+
title: string;
|
|
108
|
+
closeButton: string;
|
|
109
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
110
|
+
open: {
|
|
111
|
+
true: {
|
|
112
|
+
base: string;
|
|
113
|
+
backdrop: string;
|
|
114
|
+
contentWrapper: string;
|
|
115
|
+
};
|
|
116
|
+
false: {
|
|
117
|
+
base: string;
|
|
118
|
+
backdrop: string;
|
|
119
|
+
contentWrapper: string;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
position: {
|
|
123
|
+
left: {
|
|
124
|
+
contentWrapper: string;
|
|
125
|
+
content: string;
|
|
126
|
+
};
|
|
127
|
+
right: {
|
|
128
|
+
contentWrapper: string;
|
|
129
|
+
content: string;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
size: {
|
|
133
|
+
xs: {
|
|
134
|
+
contentWrapper: string;
|
|
135
|
+
};
|
|
136
|
+
sm: {
|
|
137
|
+
contentWrapper: string;
|
|
138
|
+
};
|
|
139
|
+
base: {
|
|
140
|
+
contentWrapper: string;
|
|
141
|
+
};
|
|
142
|
+
lg: {
|
|
143
|
+
contentWrapper: string;
|
|
144
|
+
};
|
|
145
|
+
xl: {
|
|
146
|
+
contentWrapper: string;
|
|
147
|
+
};
|
|
148
|
+
'2xl': {
|
|
149
|
+
contentWrapper: string;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
}, {
|
|
153
|
+
base: string;
|
|
154
|
+
backdrop: string;
|
|
155
|
+
contentWrapper: string;
|
|
156
|
+
content: string;
|
|
157
|
+
header: string;
|
|
158
|
+
body: string;
|
|
159
|
+
footer: string;
|
|
160
|
+
title: string;
|
|
161
|
+
closeButton: string;
|
|
162
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
163
|
+
export type DrawerProps = {
|
|
164
|
+
open?: boolean;
|
|
165
|
+
onclose?: () => void;
|
|
166
|
+
title?: string;
|
|
167
|
+
position?: keyof typeof drawer.variants.position;
|
|
168
|
+
size?: VariantSizes;
|
|
169
|
+
class?: string;
|
|
170
|
+
backdropclass?: string;
|
|
171
|
+
contentclass?: string;
|
|
172
|
+
headerclass?: string;
|
|
173
|
+
bodyclass?: string;
|
|
174
|
+
titleclass?: string;
|
|
175
|
+
children?: Snippet;
|
|
176
|
+
header?: Snippet;
|
|
177
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
export const drawer = tv({
|
|
3
|
+
slots: {
|
|
4
|
+
base: 'fixed inset-0 z-50 flex overflow-hidden',
|
|
5
|
+
backdrop: 'fixed inset-0 transition-opacity bg-black/50',
|
|
6
|
+
contentWrapper: 'absolute flex flex-col transform transition-transform',
|
|
7
|
+
content: 'flex flex-col h-full w-full overflow-y-auto bg-white',
|
|
8
|
+
header: 'flex items-center justify-between px-4 py-3 border-b border-gray-200',
|
|
9
|
+
body: 'flex-1 overflow-y-auto p-4',
|
|
10
|
+
footer: 'flex justify-end border-t border-gray-200 p-4',
|
|
11
|
+
title: 'text-default-900 leading-6 text-base font-semibold',
|
|
12
|
+
closeButton: 'text-gray-400 hover:text-gray-500 rounded-md cursor-pointer'
|
|
13
|
+
},
|
|
14
|
+
variants: {
|
|
15
|
+
open: {
|
|
16
|
+
true: {
|
|
17
|
+
base: 'visible',
|
|
18
|
+
backdrop: 'visible opacity-100',
|
|
19
|
+
contentWrapper: 'visible translate-x-0 translate-y-0'
|
|
20
|
+
},
|
|
21
|
+
false: {
|
|
22
|
+
base: 'invisible',
|
|
23
|
+
backdrop: 'invisible opacity-0',
|
|
24
|
+
contentWrapper: 'invisible'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
position: {
|
|
28
|
+
left: {
|
|
29
|
+
contentWrapper: 'left-0 h-full',
|
|
30
|
+
content: 'rounded-r-lg'
|
|
31
|
+
},
|
|
32
|
+
right: {
|
|
33
|
+
contentWrapper: 'right-0 h-full',
|
|
34
|
+
content: 'rounded-l-lg'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
size: {
|
|
38
|
+
xs: {
|
|
39
|
+
contentWrapper: 'w-64'
|
|
40
|
+
},
|
|
41
|
+
sm: {
|
|
42
|
+
contentWrapper: 'w-80'
|
|
43
|
+
},
|
|
44
|
+
base: {
|
|
45
|
+
contentWrapper: 'w-96'
|
|
46
|
+
},
|
|
47
|
+
lg: {
|
|
48
|
+
contentWrapper: 'w-[32rem]'
|
|
49
|
+
},
|
|
50
|
+
xl: {
|
|
51
|
+
contentWrapper: 'w-[40rem]'
|
|
52
|
+
},
|
|
53
|
+
'2xl': {
|
|
54
|
+
contentWrapper: 'w-[48rem]'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
compoundVariants: [
|
|
59
|
+
// Position-specific transforms when closed
|
|
60
|
+
{
|
|
61
|
+
position: 'left',
|
|
62
|
+
open: false,
|
|
63
|
+
class: {
|
|
64
|
+
contentWrapper: '-translate-x-full'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
position: 'right',
|
|
69
|
+
open: false,
|
|
70
|
+
class: {
|
|
71
|
+
contentWrapper: 'translate-x-full'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
defaultVariants: {
|
|
76
|
+
open: false,
|
|
77
|
+
position: 'right',
|
|
78
|
+
size: 'sm'
|
|
79
|
+
}
|
|
80
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Drawer } from './Drawer.svelte';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../helper/cls.js';
|
|
3
|
+
import { badge, type BadgeProps } from './badge.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
size = 'base',
|
|
7
|
+
color = 'default',
|
|
8
|
+
class: className = '',
|
|
9
|
+
children,
|
|
10
|
+
onclose: onClose
|
|
11
|
+
}: BadgeProps = $props();
|
|
12
|
+
|
|
13
|
+
const { base } = $derived(
|
|
14
|
+
badge({
|
|
15
|
+
size,
|
|
16
|
+
color
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const baseClass = $derived(cn(base(), className));
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<div class={baseClass}>
|
|
24
|
+
{@render children()}
|
|
25
|
+
{#if onClose}
|
|
26
|
+
<button type="button" onclick={onClose} class="cursor-pointer" aria-label="Close">
|
|
27
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
|
28
|
+
<path
|
|
29
|
+
fill="currentColor"
|
|
30
|
+
d="M26.113 4.116a1.25 1.25 0 0 1 1.768 1.768L17.766 15.999l10.115 10.114a1.25 1.25 0 1 1-1.768 1.768L16 17.766L5.884 27.881a1.25 1.25 0 1 1-1.768-1.768L14.231 16L4.116 5.884a1.25 1.25 0 1 1 1.768-1.768l10.115 10.115z"
|
|
31
|
+
/>
|
|
32
|
+
</svg>
|
|
33
|
+
</button>
|
|
34
|
+
{/if}
|
|
35
|
+
</div>
|