@makolabs/ripple 0.0.1-dev.3 → 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,303 @@
|
|
|
1
|
+
import type { ClassValue } from 'tailwind-variants';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { VariantColors, VariantSizes } from '../../types/variants.js';
|
|
4
|
+
export type DataRow = Record<string, any>;
|
|
5
|
+
export type KeyType = keyof DataRow;
|
|
6
|
+
export type StatusType = 'active' | 'inactive' | 'pending' | 'error' | 'default';
|
|
7
|
+
export type TableColumn<T extends DataRow = any> = {
|
|
8
|
+
key: KeyType;
|
|
9
|
+
header: string;
|
|
10
|
+
cell?: Snippet<[row: T, key: KeyType, index?: number]>;
|
|
11
|
+
sortable?: boolean;
|
|
12
|
+
sortKey?: string;
|
|
13
|
+
align?: 'left' | 'center' | 'right';
|
|
14
|
+
width?: string;
|
|
15
|
+
class?: ClassValue;
|
|
16
|
+
};
|
|
17
|
+
export type SortDirection = 'asc' | 'desc' | null;
|
|
18
|
+
export type SortState = {
|
|
19
|
+
column: string | null;
|
|
20
|
+
direction: SortDirection;
|
|
21
|
+
};
|
|
22
|
+
export declare const table: import("tailwind-variants").TVReturnType<{
|
|
23
|
+
size: {
|
|
24
|
+
xs: {
|
|
25
|
+
th: string;
|
|
26
|
+
td: string;
|
|
27
|
+
};
|
|
28
|
+
sm: {
|
|
29
|
+
th: string;
|
|
30
|
+
td: string;
|
|
31
|
+
};
|
|
32
|
+
base: {
|
|
33
|
+
th: string;
|
|
34
|
+
td: string;
|
|
35
|
+
};
|
|
36
|
+
lg: {
|
|
37
|
+
th: string;
|
|
38
|
+
td: string;
|
|
39
|
+
};
|
|
40
|
+
xl: {
|
|
41
|
+
th: string;
|
|
42
|
+
td: string;
|
|
43
|
+
};
|
|
44
|
+
'2xl': {
|
|
45
|
+
th: string;
|
|
46
|
+
td: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
color: {
|
|
50
|
+
default: {
|
|
51
|
+
th: string;
|
|
52
|
+
};
|
|
53
|
+
primary: {
|
|
54
|
+
th: string;
|
|
55
|
+
tr: string;
|
|
56
|
+
};
|
|
57
|
+
secondary: {
|
|
58
|
+
th: string;
|
|
59
|
+
tr: string;
|
|
60
|
+
};
|
|
61
|
+
info: {
|
|
62
|
+
th: string;
|
|
63
|
+
tr: string;
|
|
64
|
+
};
|
|
65
|
+
success: {
|
|
66
|
+
th: string;
|
|
67
|
+
tr: string;
|
|
68
|
+
};
|
|
69
|
+
warning: {
|
|
70
|
+
th: string;
|
|
71
|
+
tr: string;
|
|
72
|
+
};
|
|
73
|
+
danger: {
|
|
74
|
+
th: string;
|
|
75
|
+
tr: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
bordered: {
|
|
79
|
+
true: {
|
|
80
|
+
table: string;
|
|
81
|
+
th: string;
|
|
82
|
+
td: string;
|
|
83
|
+
};
|
|
84
|
+
false: {
|
|
85
|
+
table: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
striped: {
|
|
89
|
+
true: {
|
|
90
|
+
tr: string;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
}, {
|
|
94
|
+
base: string;
|
|
95
|
+
wrapper: string;
|
|
96
|
+
table: string;
|
|
97
|
+
thead: string;
|
|
98
|
+
tbody: string;
|
|
99
|
+
tr: string;
|
|
100
|
+
th: string;
|
|
101
|
+
td: string;
|
|
102
|
+
footer: string;
|
|
103
|
+
pagination: string;
|
|
104
|
+
emptyState: string;
|
|
105
|
+
sortButton: string;
|
|
106
|
+
sortIcon: string;
|
|
107
|
+
}, undefined, {
|
|
108
|
+
size: {
|
|
109
|
+
xs: {
|
|
110
|
+
th: string;
|
|
111
|
+
td: string;
|
|
112
|
+
};
|
|
113
|
+
sm: {
|
|
114
|
+
th: string;
|
|
115
|
+
td: string;
|
|
116
|
+
};
|
|
117
|
+
base: {
|
|
118
|
+
th: string;
|
|
119
|
+
td: string;
|
|
120
|
+
};
|
|
121
|
+
lg: {
|
|
122
|
+
th: string;
|
|
123
|
+
td: string;
|
|
124
|
+
};
|
|
125
|
+
xl: {
|
|
126
|
+
th: string;
|
|
127
|
+
td: string;
|
|
128
|
+
};
|
|
129
|
+
'2xl': {
|
|
130
|
+
th: string;
|
|
131
|
+
td: string;
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
color: {
|
|
135
|
+
default: {
|
|
136
|
+
th: string;
|
|
137
|
+
};
|
|
138
|
+
primary: {
|
|
139
|
+
th: string;
|
|
140
|
+
tr: string;
|
|
141
|
+
};
|
|
142
|
+
secondary: {
|
|
143
|
+
th: string;
|
|
144
|
+
tr: string;
|
|
145
|
+
};
|
|
146
|
+
info: {
|
|
147
|
+
th: string;
|
|
148
|
+
tr: string;
|
|
149
|
+
};
|
|
150
|
+
success: {
|
|
151
|
+
th: string;
|
|
152
|
+
tr: string;
|
|
153
|
+
};
|
|
154
|
+
warning: {
|
|
155
|
+
th: string;
|
|
156
|
+
tr: string;
|
|
157
|
+
};
|
|
158
|
+
danger: {
|
|
159
|
+
th: string;
|
|
160
|
+
tr: string;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
bordered: {
|
|
164
|
+
true: {
|
|
165
|
+
table: string;
|
|
166
|
+
th: string;
|
|
167
|
+
td: string;
|
|
168
|
+
};
|
|
169
|
+
false: {
|
|
170
|
+
table: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
striped: {
|
|
174
|
+
true: {
|
|
175
|
+
tr: string;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
}, {
|
|
179
|
+
base: string;
|
|
180
|
+
wrapper: string;
|
|
181
|
+
table: string;
|
|
182
|
+
thead: string;
|
|
183
|
+
tbody: string;
|
|
184
|
+
tr: string;
|
|
185
|
+
th: string;
|
|
186
|
+
td: string;
|
|
187
|
+
footer: string;
|
|
188
|
+
pagination: string;
|
|
189
|
+
emptyState: string;
|
|
190
|
+
sortButton: string;
|
|
191
|
+
sortIcon: string;
|
|
192
|
+
}, import("tailwind-variants").TVReturnType<{
|
|
193
|
+
size: {
|
|
194
|
+
xs: {
|
|
195
|
+
th: string;
|
|
196
|
+
td: string;
|
|
197
|
+
};
|
|
198
|
+
sm: {
|
|
199
|
+
th: string;
|
|
200
|
+
td: string;
|
|
201
|
+
};
|
|
202
|
+
base: {
|
|
203
|
+
th: string;
|
|
204
|
+
td: string;
|
|
205
|
+
};
|
|
206
|
+
lg: {
|
|
207
|
+
th: string;
|
|
208
|
+
td: string;
|
|
209
|
+
};
|
|
210
|
+
xl: {
|
|
211
|
+
th: string;
|
|
212
|
+
td: string;
|
|
213
|
+
};
|
|
214
|
+
'2xl': {
|
|
215
|
+
th: string;
|
|
216
|
+
td: string;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
color: {
|
|
220
|
+
default: {
|
|
221
|
+
th: string;
|
|
222
|
+
};
|
|
223
|
+
primary: {
|
|
224
|
+
th: string;
|
|
225
|
+
tr: string;
|
|
226
|
+
};
|
|
227
|
+
secondary: {
|
|
228
|
+
th: string;
|
|
229
|
+
tr: string;
|
|
230
|
+
};
|
|
231
|
+
info: {
|
|
232
|
+
th: string;
|
|
233
|
+
tr: string;
|
|
234
|
+
};
|
|
235
|
+
success: {
|
|
236
|
+
th: string;
|
|
237
|
+
tr: string;
|
|
238
|
+
};
|
|
239
|
+
warning: {
|
|
240
|
+
th: string;
|
|
241
|
+
tr: string;
|
|
242
|
+
};
|
|
243
|
+
danger: {
|
|
244
|
+
th: string;
|
|
245
|
+
tr: string;
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
bordered: {
|
|
249
|
+
true: {
|
|
250
|
+
table: string;
|
|
251
|
+
th: string;
|
|
252
|
+
td: string;
|
|
253
|
+
};
|
|
254
|
+
false: {
|
|
255
|
+
table: string;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
striped: {
|
|
259
|
+
true: {
|
|
260
|
+
tr: string;
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
}, {
|
|
264
|
+
base: string;
|
|
265
|
+
wrapper: string;
|
|
266
|
+
table: string;
|
|
267
|
+
thead: string;
|
|
268
|
+
tbody: string;
|
|
269
|
+
tr: string;
|
|
270
|
+
th: string;
|
|
271
|
+
td: string;
|
|
272
|
+
footer: string;
|
|
273
|
+
pagination: string;
|
|
274
|
+
emptyState: string;
|
|
275
|
+
sortButton: string;
|
|
276
|
+
sortIcon: string;
|
|
277
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
278
|
+
export type TableProps<T extends DataRow = any> = {
|
|
279
|
+
data: T[];
|
|
280
|
+
columns: TableColumn<T>[];
|
|
281
|
+
color?: VariantColors;
|
|
282
|
+
size?: VariantSizes;
|
|
283
|
+
bordered?: boolean;
|
|
284
|
+
striped?: boolean;
|
|
285
|
+
emptyStateText?: string;
|
|
286
|
+
pageSize?: number;
|
|
287
|
+
selectable?: boolean;
|
|
288
|
+
selected?: T[];
|
|
289
|
+
class?: ClassValue;
|
|
290
|
+
wrapperclass?: ClassValue;
|
|
291
|
+
tableclass?: ClassValue;
|
|
292
|
+
theadclass?: ClassValue;
|
|
293
|
+
tbodyclass?: ClassValue;
|
|
294
|
+
trclass?: ClassValue;
|
|
295
|
+
thclass?: ClassValue;
|
|
296
|
+
tdclass?: ClassValue;
|
|
297
|
+
footerclass?: ClassValue;
|
|
298
|
+
onrowclick?: (row: T, index: number) => void;
|
|
299
|
+
onsort?: (sortState: SortState) => void;
|
|
300
|
+
onselect?: (selected: T[]) => void;
|
|
301
|
+
rowclass?: (row: T, index: number) => ClassValue;
|
|
302
|
+
loading?: boolean;
|
|
303
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { tv } from 'tailwind-variants';
|
|
2
|
+
// Prebuild Cell rendering options
|
|
3
|
+
// Snippet 1 - Date
|
|
4
|
+
// Snippet 2 - Currency
|
|
5
|
+
// Snippet 3 - Percentage
|
|
6
|
+
// Snippet 4 - Phone Number
|
|
7
|
+
// Snippet 5 - Email
|
|
8
|
+
// Snippet 6 - Status
|
|
9
|
+
// Snippet 7 - Time
|
|
10
|
+
export const table = tv({
|
|
11
|
+
slots: {
|
|
12
|
+
base: 'w-full',
|
|
13
|
+
wrapper: 'overflow-x-auto',
|
|
14
|
+
table: 'min-w-full divide-y divide-default-200',
|
|
15
|
+
thead: '',
|
|
16
|
+
tbody: 'divide-y divide-default-200',
|
|
17
|
+
tr: 'transition-colors hover:bg-default-50',
|
|
18
|
+
th: 'font-semibold whitespace-nowrap',
|
|
19
|
+
td: 'whitespace-nowrap',
|
|
20
|
+
footer: 'p-4',
|
|
21
|
+
pagination: 'flex items-center justify-between',
|
|
22
|
+
emptyState: 'p-8 text-center text-default-500',
|
|
23
|
+
sortButton: 'inline-flex gap-1 items-center cursor-pointer focus:outline-none',
|
|
24
|
+
sortIcon: 'h-4 w-4'
|
|
25
|
+
},
|
|
26
|
+
variants: {
|
|
27
|
+
size: {
|
|
28
|
+
xs: {
|
|
29
|
+
th: 'px-2 py-1.5 text-xs',
|
|
30
|
+
td: 'px-2 py-1.5 text-xs'
|
|
31
|
+
},
|
|
32
|
+
sm: {
|
|
33
|
+
th: 'px-3 py-2 text-xs',
|
|
34
|
+
td: 'px-3 py-2 text-sm'
|
|
35
|
+
},
|
|
36
|
+
base: {
|
|
37
|
+
th: 'px-4 py-3 text-sm',
|
|
38
|
+
td: 'px-4 py-3 text-sm'
|
|
39
|
+
},
|
|
40
|
+
lg: {
|
|
41
|
+
th: 'px-6 py-4 text-sm',
|
|
42
|
+
td: 'px-6 py-4 text-base'
|
|
43
|
+
},
|
|
44
|
+
xl: {
|
|
45
|
+
th: 'px-8 py-5 text-base',
|
|
46
|
+
td: 'px-8 py-5 text-base'
|
|
47
|
+
},
|
|
48
|
+
'2xl': {
|
|
49
|
+
th: 'px-10 py-6 text-lg',
|
|
50
|
+
td: 'px-10 py-6 text-lg'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
color: {
|
|
54
|
+
default: {
|
|
55
|
+
th: 'text-default-700 bg-default-50'
|
|
56
|
+
},
|
|
57
|
+
primary: {
|
|
58
|
+
th: 'text-primary-700 bg-primary-50',
|
|
59
|
+
tr: 'hover:bg-primary-50'
|
|
60
|
+
},
|
|
61
|
+
secondary: {
|
|
62
|
+
th: 'text-secondary-700 bg-secondary-50',
|
|
63
|
+
tr: 'hover:bg-secondary-50'
|
|
64
|
+
},
|
|
65
|
+
info: {
|
|
66
|
+
th: 'text-info-700 bg-info-50',
|
|
67
|
+
tr: 'hover:bg-info-50'
|
|
68
|
+
},
|
|
69
|
+
success: {
|
|
70
|
+
th: 'text-success-700 bg-success-50',
|
|
71
|
+
tr: 'hover:bg-success-50'
|
|
72
|
+
},
|
|
73
|
+
warning: {
|
|
74
|
+
th: 'text-warning-700 bg-warning-50',
|
|
75
|
+
tr: 'hover:bg-warning-50'
|
|
76
|
+
},
|
|
77
|
+
danger: {
|
|
78
|
+
th: 'text-danger-700 bg-danger-50',
|
|
79
|
+
tr: 'hover:bg-danger-50'
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
bordered: {
|
|
83
|
+
true: {
|
|
84
|
+
table: 'border-separate border-spacing-0 border border-default-200 rounded-md overflow-hidden',
|
|
85
|
+
th: 'border-b border-default-200',
|
|
86
|
+
td: 'border-b border-default-200'
|
|
87
|
+
},
|
|
88
|
+
false: {
|
|
89
|
+
table: 'border-none'
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
striped: {
|
|
93
|
+
true: {
|
|
94
|
+
tr: 'even:bg-default-50'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
compoundVariants: [
|
|
99
|
+
// Add compound variants for striped + color combinations
|
|
100
|
+
{
|
|
101
|
+
striped: true,
|
|
102
|
+
color: 'primary',
|
|
103
|
+
class: {
|
|
104
|
+
tr: 'even:bg-primary-50'
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
striped: true,
|
|
109
|
+
color: 'secondary',
|
|
110
|
+
class: {
|
|
111
|
+
tr: 'even:bg-secondary-50'
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
striped: true,
|
|
116
|
+
color: 'info',
|
|
117
|
+
class: {
|
|
118
|
+
tr: 'even:bg-info-50'
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
striped: true,
|
|
123
|
+
color: 'success',
|
|
124
|
+
class: {
|
|
125
|
+
tr: 'even:bg-success-50'
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
striped: true,
|
|
130
|
+
color: 'warning',
|
|
131
|
+
class: {
|
|
132
|
+
tr: 'even:bg-warning-50'
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
striped: true,
|
|
137
|
+
color: 'danger',
|
|
138
|
+
class: {
|
|
139
|
+
tr: 'even:bg-danger-50'
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
defaultVariants: {
|
|
144
|
+
size: 'base',
|
|
145
|
+
color: 'default',
|
|
146
|
+
bordered: true,
|
|
147
|
+
striped: false
|
|
148
|
+
}
|
|
149
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../helper/cls.js';
|
|
3
|
+
import { tabs, type TabProps } from './tabs.js';
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
value = '',
|
|
7
|
+
label = '',
|
|
8
|
+
icon: Icon = undefined,
|
|
9
|
+
selected = false,
|
|
10
|
+
disabled = false,
|
|
11
|
+
color = 'primary',
|
|
12
|
+
size = 'base',
|
|
13
|
+
onclick = () => {}
|
|
14
|
+
}: TabProps = $props();
|
|
15
|
+
|
|
16
|
+
function handleClick(event: Event & { currentTarget: EventTarget & HTMLButtonElement }) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
if (!disabled) {
|
|
19
|
+
onclick(event);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { trigger } = $derived(
|
|
24
|
+
tabs({
|
|
25
|
+
selected,
|
|
26
|
+
color,
|
|
27
|
+
size
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const triggerClass = $derived(cn(trigger()));
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<button
|
|
35
|
+
class={triggerClass}
|
|
36
|
+
aria-current={selected ? 'page' : undefined}
|
|
37
|
+
aria-disabled={disabled ? 'true' : undefined}
|
|
38
|
+
tabindex={disabled ? -1 : 0}
|
|
39
|
+
role="tab"
|
|
40
|
+
id={`tab-${value}`}
|
|
41
|
+
aria-controls={`panel-${value}`}
|
|
42
|
+
aria-selected={selected ? 'true' : 'false'}
|
|
43
|
+
onclick={handleClick}
|
|
44
|
+
onkeydown={(e) => {
|
|
45
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
handleClick(e);
|
|
48
|
+
}
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{#if Icon}
|
|
52
|
+
<span class="mr-2">
|
|
53
|
+
<Icon aria-hidden="true" class="size-5" />
|
|
54
|
+
</span>
|
|
55
|
+
{/if}
|
|
56
|
+
<span>{label}</span>
|
|
57
|
+
</button>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../helper/cls.js';
|
|
3
|
+
import type { TabContentProps } from './tabs.js';
|
|
4
|
+
import { getContext } from 'svelte';
|
|
5
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
6
|
+
|
|
7
|
+
let { value = '', persisted = false, panelClass = '', children }: TabContentProps = $props();
|
|
8
|
+
|
|
9
|
+
const getSelected = getContext('getSelected') as () => string;
|
|
10
|
+
const selected = $derived(getSelected());
|
|
11
|
+
const tabPanelClass = $derived(cn(panelClass));
|
|
12
|
+
const active = $derived(selected === value);
|
|
13
|
+
|
|
14
|
+
let divProps: HTMLAttributes<HTMLDivElement> = $derived({
|
|
15
|
+
id: `panel-${value}`,
|
|
16
|
+
role: 'tabpanel',
|
|
17
|
+
class: tabPanelClass,
|
|
18
|
+
'aria-labelledby': `tab-${value}`,
|
|
19
|
+
tabindex: 0
|
|
20
|
+
});
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
{#if persisted}
|
|
24
|
+
<div {...divProps} style={active ? 'display: block' : 'display: none'}>
|
|
25
|
+
{@render children?.(value)}
|
|
26
|
+
</div>
|
|
27
|
+
{:else if active}
|
|
28
|
+
<div {...divProps}>
|
|
29
|
+
{@render children?.(value)}
|
|
30
|
+
</div>
|
|
31
|
+
{/if}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../helper/cls.js';
|
|
3
|
+
import Tab from './Tab.svelte';
|
|
4
|
+
import { tabs, type TabsProps } from './tabs.js';
|
|
5
|
+
import { setContext } from 'svelte';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
tabs: tabItems = [],
|
|
9
|
+
selected = $bindable(''),
|
|
10
|
+
color = 'primary',
|
|
11
|
+
size = 'base',
|
|
12
|
+
class: className = '',
|
|
13
|
+
listClass = '',
|
|
14
|
+
panelClass = '',
|
|
15
|
+
onchange = () => {},
|
|
16
|
+
children
|
|
17
|
+
}: TabsProps = $props();
|
|
18
|
+
|
|
19
|
+
const { base, list, panel } = $derived(
|
|
20
|
+
tabs({
|
|
21
|
+
color,
|
|
22
|
+
size
|
|
23
|
+
})
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const baseClass = $derived(cn(base(), className));
|
|
27
|
+
const listClass_ = $derived(cn(list(), listClass));
|
|
28
|
+
const panelClass_ = $derived(cn(panel(), panelClass));
|
|
29
|
+
|
|
30
|
+
function handleTabClick(value: string) {
|
|
31
|
+
selected = value;
|
|
32
|
+
onchange(value);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setContext('getSelected', () => selected);
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<div class={baseClass}>
|
|
39
|
+
<div class={listClass_} role="tablist">
|
|
40
|
+
{#each tabItems as tab (tab.value)}
|
|
41
|
+
<Tab
|
|
42
|
+
value={tab.value}
|
|
43
|
+
label={tab.label}
|
|
44
|
+
icon={tab.icon}
|
|
45
|
+
selected={tab.value === selected}
|
|
46
|
+
disabled={tab.disabled}
|
|
47
|
+
{color}
|
|
48
|
+
{size}
|
|
49
|
+
onclick={() => handleTabClick(tab.value)}
|
|
50
|
+
/>
|
|
51
|
+
{/each}
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<div class={panelClass_}>
|
|
55
|
+
{@render children?.(selected)}
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|