@makolabs/ripple 0.0.1-dev.44 → 0.0.1-dev.47

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/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;
@@ -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: paginationClass,
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(base(), classname));
62
- const wrapperClasses = $derived(cn(wrapper(), wrapperClass));
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(thead(), theadClass));
65
- const tbodyClasses = $derived(cn(tbody(), tbodyClass));
66
- const trClasses = $derived(cn(tr(), trClass));
67
- const thClasses = $derived(cn(th(), thClass));
68
- const tdClasses = $derived(cn(td(), tdClass));
69
- const footerClasses = $derived(cn(footer(), footerClass));
70
- const emptyStateClasses = $derived(emptyState());
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={sortButton()}
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={sortIcon()}>
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={paginationClass}>
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
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makolabs/ripple",
3
- "version": "0.0.1-dev.44",
3
+ "version": "0.0.1-dev.47",
4
4
  "description": "Simple Svelte 5 powered component library ✨",
5
5
  "repository": {
6
6
  "type": "git",