@makolabs/ripple 0.0.1-dev.44 → 0.0.1-dev.48
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.
|
@@ -18,12 +18,7 @@
|
|
|
18
18
|
icon: Icon
|
|
19
19
|
}: AccordionProps = $props();
|
|
20
20
|
|
|
21
|
-
const {
|
|
22
|
-
base,
|
|
23
|
-
header,
|
|
24
|
-
title: titleClass,
|
|
25
|
-
body
|
|
26
|
-
} = accordion({ color, open, bordered });
|
|
21
|
+
const { base, header, title: titleClass, body } = accordion({ color, open, bordered });
|
|
27
22
|
|
|
28
23
|
function handleClick() {
|
|
29
24
|
open = !open;
|
|
@@ -58,23 +53,25 @@
|
|
|
58
53
|
</div>
|
|
59
54
|
</div>
|
|
60
55
|
{@render summary?.()}
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
56
|
+
{#if children}
|
|
57
|
+
<div class="flex items-center">
|
|
58
|
+
<svg
|
|
59
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
60
|
+
width="20"
|
|
61
|
+
height="20"
|
|
62
|
+
viewBox="0 0 20 20"
|
|
63
|
+
class="text-default-500 size-5 transition-transform duration-200"
|
|
64
|
+
class:rotate-180={open}
|
|
65
|
+
>
|
|
66
|
+
<path
|
|
67
|
+
fill="currentColor"
|
|
68
|
+
d="M15.794 7.733a.75.75 0 0 1-.026 1.06l-5.25 5.001a.75.75 0 0 1-1.035 0l-5.25-5a.75.75 0 0 1 1.034-1.087l4.734 4.509l4.733-4.51a.75.75 0 0 1 1.06.027"
|
|
69
|
+
/>
|
|
70
|
+
</svg>
|
|
71
|
+
</div>
|
|
72
|
+
{/if}
|
|
76
73
|
</button>
|
|
77
|
-
{#if open}
|
|
74
|
+
{#if open && children}
|
|
78
75
|
<div class={body()} {id}>
|
|
79
76
|
{@render children()}
|
|
80
77
|
</div>
|
package/dist/index.d.ts
CHANGED
|
@@ -198,11 +198,8 @@ export type SortState = {
|
|
|
198
198
|
export type TableProps<T extends DataRow = any> = {
|
|
199
199
|
data: T[];
|
|
200
200
|
columns: TableColumn<T>[];
|
|
201
|
-
color?: VariantColors;
|
|
202
|
-
size?: VariantSizes;
|
|
203
201
|
bordered?: boolean;
|
|
204
202
|
striped?: boolean;
|
|
205
|
-
emptyStateText?: string;
|
|
206
203
|
pageSize?: number;
|
|
207
204
|
selectable?: boolean;
|
|
208
205
|
selected?: T[];
|
|
@@ -220,6 +217,7 @@ export type TableProps<T extends DataRow = any> = {
|
|
|
220
217
|
onselect?: (selected: T[]) => void;
|
|
221
218
|
rowclass?: (row: T, index: number) => ClassValue;
|
|
222
219
|
loading?: boolean;
|
|
220
|
+
expandedContent?: Snippet<[T]>;
|
|
223
221
|
};
|
|
224
222
|
export type BreadcrumbItem = {
|
|
225
223
|
label: string;
|
|
@@ -726,7 +724,7 @@ export type AccordionProps = {
|
|
|
726
724
|
id?: string;
|
|
727
725
|
title?: string;
|
|
728
726
|
description?: string;
|
|
729
|
-
children
|
|
727
|
+
children?: Snippet;
|
|
730
728
|
summary?: Snippet;
|
|
731
729
|
open?: boolean;
|
|
732
730
|
color?: VariantColors;
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import { cn } from '../../helper/cls.js';
|
|
3
3
|
import { table } from './table.js';
|
|
4
4
|
import type { TableProps, SortDirection, SortState } from '../../index.js';
|
|
5
|
+
|
|
5
6
|
let {
|
|
6
7
|
data = [],
|
|
7
8
|
columns = [],
|
|
8
|
-
color = 'default',
|
|
9
|
-
size = 'base',
|
|
10
9
|
bordered = true,
|
|
11
10
|
striped = false,
|
|
12
11
|
pageSize = 10,
|
|
@@ -25,7 +24,8 @@
|
|
|
25
24
|
tdclass: tdClass = '',
|
|
26
25
|
footerclass: footerClass = '',
|
|
27
26
|
rowclass = () => '',
|
|
28
|
-
loading = false
|
|
27
|
+
loading = false,
|
|
28
|
+
expandedContent
|
|
29
29
|
}: TableProps<any> = $props();
|
|
30
30
|
|
|
31
31
|
let sortColumn = $state('');
|
|
@@ -36,38 +36,36 @@
|
|
|
36
36
|
const pagination = $derived(pageSize > 0 && data.length > pageSize);
|
|
37
37
|
|
|
38
38
|
const {
|
|
39
|
-
base,
|
|
40
|
-
wrapper,
|
|
39
|
+
base: baseClass,
|
|
40
|
+
wrapper: wrapperBaseClass,
|
|
41
41
|
table: tableBaseClass,
|
|
42
|
-
thead,
|
|
43
|
-
tbody,
|
|
44
|
-
tr,
|
|
45
|
-
th,
|
|
46
|
-
td,
|
|
47
|
-
footer,
|
|
48
|
-
pagination:
|
|
49
|
-
emptyState,
|
|
50
|
-
sortButton,
|
|
51
|
-
sortIcon
|
|
42
|
+
thead: theadBaseClass,
|
|
43
|
+
tbody: tbodyBaseClass,
|
|
44
|
+
tr: trBaseClass,
|
|
45
|
+
th: thBaseClass,
|
|
46
|
+
td: tdBaseClass,
|
|
47
|
+
footer: footerBaseClass,
|
|
48
|
+
pagination: paginationBaseClass,
|
|
49
|
+
emptyState: emptyStateBaseClass,
|
|
50
|
+
sortButton: sortButtonBaseClass,
|
|
51
|
+
sortIcon: sortIconBaseClass
|
|
52
52
|
} = $derived(
|
|
53
53
|
table({
|
|
54
|
-
size,
|
|
55
|
-
color,
|
|
56
54
|
bordered,
|
|
57
55
|
striped
|
|
58
56
|
})
|
|
59
57
|
);
|
|
60
58
|
|
|
61
|
-
const baseClasses = $derived(cn(
|
|
62
|
-
const wrapperClasses = $derived(cn(
|
|
59
|
+
const baseClasses = $derived(cn(baseClass(), classname));
|
|
60
|
+
const wrapperClasses = $derived(cn(wrapperBaseClass(), wrapperClass));
|
|
63
61
|
const tableClasses = $derived(cn(tableBaseClass(), tableClass));
|
|
64
|
-
const theadClasses = $derived(cn(
|
|
65
|
-
const tbodyClasses = $derived(cn(
|
|
66
|
-
const trClasses = $derived(cn(
|
|
67
|
-
const thClasses = $derived(cn(
|
|
68
|
-
const tdClasses = $derived(cn(
|
|
69
|
-
const footerClasses = $derived(cn(
|
|
70
|
-
const emptyStateClasses = $derived(
|
|
62
|
+
const theadClasses = $derived(cn(theadBaseClass(), theadClass));
|
|
63
|
+
const tbodyClasses = $derived(cn(tbodyBaseClass(), tbodyClass));
|
|
64
|
+
const trClasses = $derived(cn(trBaseClass(), trClass));
|
|
65
|
+
const thClasses = $derived(cn(thBaseClass(), thClass));
|
|
66
|
+
const tdClasses = $derived(cn(tdBaseClass(), tdClass));
|
|
67
|
+
const footerClasses = $derived(cn(footerBaseClass(), footerClass));
|
|
68
|
+
const emptyStateClasses = $derived(emptyStateBaseClass());
|
|
71
69
|
|
|
72
70
|
// Handle pagination
|
|
73
71
|
const totalPages = $derived(Math.ceil(data.length / pageSize));
|
|
@@ -175,12 +173,12 @@
|
|
|
175
173
|
{#if column.sortable}
|
|
176
174
|
<button
|
|
177
175
|
type="button"
|
|
178
|
-
class={
|
|
176
|
+
class={sortButtonBaseClass()}
|
|
179
177
|
onclick={() => toggleSort(column.sortKey || column.key)}
|
|
180
178
|
aria-label={`Sort by ${column.header}`}
|
|
181
179
|
>
|
|
182
180
|
{column.header}
|
|
183
|
-
<span class={
|
|
181
|
+
<span class={sortIconBaseClass()}>
|
|
184
182
|
{#if sortColumn === (column.sortKey || column.key)}
|
|
185
183
|
{#if sortDirection === 'asc'}
|
|
186
184
|
<svg
|
|
@@ -315,6 +313,13 @@
|
|
|
315
313
|
</td>
|
|
316
314
|
{/each}
|
|
317
315
|
</tr>
|
|
316
|
+
{#if expandedContent}
|
|
317
|
+
<tr class="expandedContent-row">
|
|
318
|
+
<td colspan={selectable ? columns.length + 1 : columns.length} class="border-0 p-0">
|
|
319
|
+
{@render expandedContent(row)}
|
|
320
|
+
</td>
|
|
321
|
+
</tr>
|
|
322
|
+
{/if}
|
|
318
323
|
{/each}
|
|
319
324
|
{/if}
|
|
320
325
|
</tbody>
|
|
@@ -323,7 +328,7 @@
|
|
|
323
328
|
|
|
324
329
|
{#if pagination && totalPages > 1}
|
|
325
330
|
<div class={footerClasses}>
|
|
326
|
-
<div class={
|
|
331
|
+
<div class={paginationBaseClass()}>
|
|
327
332
|
<div class="flex items-center gap-2">
|
|
328
333
|
<span class="text-default-500 text-sm">
|
|
329
334
|
Showing {Math.min((currentPage - 1) * pageSize + 1, data.length)}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { ClassValue } from 'tailwind-variants';
|
|
2
|
-
import type { VariantColors, VariantSizes } from '../../index.js';
|
|
3
1
|
export declare const table: import("tailwind-variants").TVReturnType<{
|
|
4
2
|
size: {
|
|
5
3
|
xs: {
|
|
@@ -256,29 +254,3 @@ export declare const table: import("tailwind-variants").TVReturnType<{
|
|
|
256
254
|
sortButton: string;
|
|
257
255
|
sortIcon: string;
|
|
258
256
|
}, undefined, unknown, unknown, undefined>>;
|
|
259
|
-
export type TableProps<T extends DataRow = any> = {
|
|
260
|
-
data: T[];
|
|
261
|
-
columns: TableColumn<T>[];
|
|
262
|
-
color?: VariantColors;
|
|
263
|
-
size?: VariantSizes;
|
|
264
|
-
bordered?: boolean;
|
|
265
|
-
striped?: boolean;
|
|
266
|
-
emptyStateText?: string;
|
|
267
|
-
pageSize?: number;
|
|
268
|
-
selectable?: boolean;
|
|
269
|
-
selected?: T[];
|
|
270
|
-
class?: ClassValue;
|
|
271
|
-
wrapperclass?: ClassValue;
|
|
272
|
-
tableclass?: ClassValue;
|
|
273
|
-
theadclass?: ClassValue;
|
|
274
|
-
tbodyclass?: ClassValue;
|
|
275
|
-
trclass?: ClassValue;
|
|
276
|
-
thclass?: ClassValue;
|
|
277
|
-
tdclass?: ClassValue;
|
|
278
|
-
footerclass?: ClassValue;
|
|
279
|
-
onrowclick?: (row: T, index: number) => void;
|
|
280
|
-
onsort?: (sortState: SortState) => void;
|
|
281
|
-
onselect?: (selected: T[]) => void;
|
|
282
|
-
rowclass?: (row: T, index: number) => ClassValue;
|
|
283
|
-
loading?: boolean;
|
|
284
|
-
};
|