flowbite-svelte 1.0.4 → 1.0.5
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/table/Table.svelte
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { setContext } from "svelte";
|
|
3
3
|
import { table as tableCls, TableHead, TableBody } from ".";
|
|
4
4
|
import clsx from "clsx";
|
|
5
|
-
import type { TableProps, TableCtxType
|
|
5
|
+
import type { TableProps, TableCtxType } from "..";
|
|
6
6
|
|
|
7
|
-
let { children, footerSlot, captionSlot, items
|
|
7
|
+
let { children, footerSlot, captionSlot, items, divClass = "relative overflow-x-auto", striped, hoverable, border = true, shadow, color = "default", class: className, ...restProps }: TableProps = $props();
|
|
8
8
|
|
|
9
9
|
const { base, table } = $derived(tableCls({ color, shadow }));
|
|
10
10
|
|
|
@@ -24,12 +24,9 @@
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
setContext("tableCtx", tableCtx);
|
|
27
|
-
let headItems
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
headItems = Object.keys(tableItems[0]).map((key) => ({ text: key.charAt(0).toUpperCase() + key.slice(1) }));
|
|
31
|
-
bodyItems = tableItems.map((item) => Object.values(item));
|
|
32
|
-
}
|
|
27
|
+
let headItems = $derived(items && items.length > 0 ? Object.keys(items[0]).map((key) => ({ text: key.charAt(0).toUpperCase() + key.slice(1) })) : []);
|
|
28
|
+
|
|
29
|
+
let bodyItems = $derived(items && items.length > 0 ? items.map((item) => Object.values(item)) : []);
|
|
33
30
|
</script>
|
|
34
31
|
|
|
35
32
|
<div class={base({ class: divClass })}>
|
|
@@ -37,7 +34,7 @@
|
|
|
37
34
|
{#if captionSlot}
|
|
38
35
|
{@render captionSlot()}
|
|
39
36
|
{/if}
|
|
40
|
-
{#if
|
|
37
|
+
{#if items && items.length > 0}
|
|
41
38
|
<TableHead {headItems} />
|
|
42
39
|
<TableBody {bodyItems} />
|
|
43
40
|
{:else if children}
|
|
@@ -58,7 +55,7 @@
|
|
|
58
55
|
@prop children
|
|
59
56
|
@prop footerSlot
|
|
60
57
|
@prop captionSlot
|
|
61
|
-
@prop items
|
|
58
|
+
@prop items
|
|
62
59
|
@prop divClass = "relative overflow-x-auto"
|
|
63
60
|
@prop striped
|
|
64
61
|
@prop hoverable
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableProps } from "
|
|
1
|
+
import type { TableProps } from "..";
|
|
2
2
|
/**
|
|
3
3
|
* [Go to docs](https://flowbite-svelte.com/)
|
|
4
4
|
* ## Type
|
|
@@ -7,7 +7,7 @@ import type { TableProps } from "../types";
|
|
|
7
7
|
* @prop children
|
|
8
8
|
* @prop footerSlot
|
|
9
9
|
* @prop captionSlot
|
|
10
|
-
* @prop items
|
|
10
|
+
* @prop items
|
|
11
11
|
* @prop divClass = "relative overflow-x-auto"
|
|
12
12
|
* @prop striped
|
|
13
13
|
* @prop hoverable
|