sveltacular 0.0.75 → 0.0.76
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.
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
<script>import { AngleUpIcon } from "../../index.js";
|
|
2
|
+
import { hasContext } from "svelte";
|
|
2
3
|
export let open = false;
|
|
3
|
-
export let text;
|
|
4
|
+
export let text = void 0;
|
|
4
5
|
export let style = "standard";
|
|
5
6
|
export let icon = "arrow";
|
|
6
7
|
const onClick = () => {
|
|
7
8
|
open = !open;
|
|
8
9
|
};
|
|
10
|
+
$:
|
|
11
|
+
hasText = text && text.length > 0;
|
|
9
12
|
</script>
|
|
10
13
|
|
|
11
14
|
<div class="dropdown-button {style} icon-{icon}" class:open>
|
|
12
|
-
<button on:click={onClick}>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
<button on:click={onClick} class:hasText>
|
|
16
|
+
{#if hasText}
|
|
17
|
+
<div class="text">
|
|
18
|
+
{text}
|
|
19
|
+
</div>
|
|
20
|
+
{/if}
|
|
16
21
|
<div class="icon">
|
|
17
|
-
<
|
|
22
|
+
<span>
|
|
23
|
+
<AngleUpIcon />
|
|
24
|
+
</span>
|
|
18
25
|
</div>
|
|
19
26
|
</button>
|
|
20
27
|
{#if open}
|
|
@@ -30,7 +37,7 @@ const onClick = () => {
|
|
|
30
37
|
}
|
|
31
38
|
.dropdown-button button {
|
|
32
39
|
width: 100%;
|
|
33
|
-
min-width:
|
|
40
|
+
min-width: 7rem;
|
|
34
41
|
position: relative;
|
|
35
42
|
text-align: left;
|
|
36
43
|
cursor: pointer;
|
|
@@ -45,7 +52,6 @@ const onClick = () => {
|
|
|
45
52
|
line-height: 1.25rem;
|
|
46
53
|
padding: 0.5rem 1rem;
|
|
47
54
|
font-family: var(--base-font-family, sans-serif);
|
|
48
|
-
text-shadow: 0 0 0.125rem rgba(0, 0, 0, 0.5);
|
|
49
55
|
background-color: var(--button-secondary-bg, #555);
|
|
50
56
|
border-color: var(--button-secondary-border, #aaa);
|
|
51
57
|
color: var(--button-secondary-fg, #fff);
|
|
@@ -54,11 +60,22 @@ const onClick = () => {
|
|
|
54
60
|
background-color: var(--button-secondary-hover-bg, #333);
|
|
55
61
|
color: var(--button-secondary-hover-fg, #fff);
|
|
56
62
|
}
|
|
57
|
-
.dropdown-button button .text {
|
|
58
|
-
padding-right: 2rem;
|
|
59
|
-
}
|
|
60
63
|
.dropdown-button button .icon {
|
|
61
64
|
display: block;
|
|
65
|
+
text-align: center;
|
|
66
|
+
line-height: 1.5rem;
|
|
67
|
+
}
|
|
68
|
+
.dropdown-button button .icon span {
|
|
69
|
+
display: inline-block;
|
|
70
|
+
width: 1rem;
|
|
71
|
+
height: 1rem;
|
|
72
|
+
}
|
|
73
|
+
.dropdown-button button.hasText .text {
|
|
74
|
+
padding-right: 2rem;
|
|
75
|
+
min-height: 1.5rem;
|
|
76
|
+
line-height: 1.5rem;
|
|
77
|
+
}
|
|
78
|
+
.dropdown-button button.hasText .icon {
|
|
62
79
|
position: absolute;
|
|
63
80
|
top: 0;
|
|
64
81
|
right: 0;
|
|
@@ -73,8 +90,11 @@ const onClick = () => {
|
|
|
73
90
|
min-width: 100%;
|
|
74
91
|
background-color: #fff;
|
|
75
92
|
color: #000;
|
|
76
|
-
border:
|
|
93
|
+
border-style: solid;
|
|
94
|
+
border-width: 1px;
|
|
95
|
+
border-color: var(--button-secondary-border, #aaa);
|
|
77
96
|
z-index: 999;
|
|
97
|
+
text-align: center;
|
|
78
98
|
}
|
|
79
99
|
.dropdown-button.open .icon {
|
|
80
100
|
transition: transform 0.3s linear;
|
|
@@ -9,10 +9,12 @@ import TableHeader from "./table-header.svelte";
|
|
|
9
9
|
import TableRow from "./table-row.svelte";
|
|
10
10
|
import Table from "./table.svelte";
|
|
11
11
|
import Button from "../forms/button/button.svelte";
|
|
12
|
+
import DropdownItem from "../generic/dropdown-item/dropdown-item.svelte";
|
|
12
13
|
import Empty from "../generic/empty/empty.svelte";
|
|
13
14
|
import Pill from "../generic/pill/pill.svelte";
|
|
14
15
|
import FolderOpenIcon from "../icons/folder-open-icon.svelte";
|
|
15
16
|
import { formatDateTime } from "../index.js";
|
|
17
|
+
import DropdownButton from "../navigation/dropdown-button/dropdown-button.svelte";
|
|
16
18
|
import Pagination from "../navigation/pagination/pagination.svelte";
|
|
17
19
|
import Loading from "../placeholders/loading.svelte";
|
|
18
20
|
import TableCaption from "./table-caption.svelte";
|
|
@@ -21,7 +23,7 @@ export let captionAlign = "center";
|
|
|
21
23
|
export let rows = void 0;
|
|
22
24
|
export let cols;
|
|
23
25
|
export let pagination = void 0;
|
|
24
|
-
export let actions =
|
|
26
|
+
export let actions = void 0;
|
|
25
27
|
export let onPageChange = null;
|
|
26
28
|
const getColType = (col) => {
|
|
27
29
|
if (col.type)
|
|
@@ -74,7 +76,7 @@ const filterRows = () => {
|
|
|
74
76
|
return rows.filter((_row, index) => index >= startIndex && index < endIndex);
|
|
75
77
|
};
|
|
76
78
|
$:
|
|
77
|
-
hasActionCol = actions.length > 0;
|
|
79
|
+
hasActionCol = actions?.items && actions.items.length > 0;
|
|
78
80
|
$:
|
|
79
81
|
colCount = Math.max(1, cols.filter((col) => !col.hide).length) + (hasActionCol ? 1 : 0);
|
|
80
82
|
$:
|
|
@@ -122,7 +124,7 @@ $:
|
|
|
122
124
|
<TableCell type={col.type || typeof row[col.key]} width={col.width}>
|
|
123
125
|
{#if col.link}
|
|
124
126
|
<a href={col.link(row, col.key)}>{format(row, col.key)}</a>
|
|
125
|
-
|
|
127
|
+
{:else if col.type == 'email' && row[col.key]}
|
|
126
128
|
<a href={`mailto:${row[col.key]}`}>{format(row, col.key)}</a>
|
|
127
129
|
{:else if col.type == 'check'}
|
|
128
130
|
{#if row[col.key]}
|
|
@@ -134,11 +136,25 @@ $:
|
|
|
134
136
|
</TableCell>
|
|
135
137
|
{/if}
|
|
136
138
|
{/each}
|
|
137
|
-
{#if hasActionCol}
|
|
139
|
+
{#if hasActionCol && actions}
|
|
138
140
|
<TableCell type="actions">
|
|
139
|
-
{#
|
|
140
|
-
<
|
|
141
|
-
|
|
141
|
+
{#if actions.type === 'dropdown'}
|
|
142
|
+
<DropdownButton text={actions.text ?? ''} style="ghost">
|
|
143
|
+
{#each actions.items as action}
|
|
144
|
+
<DropdownItem on:click={() => action.onClick(row)}>{action.text}</DropdownItem>
|
|
145
|
+
{/each}
|
|
146
|
+
</DropdownButton>
|
|
147
|
+
{:else}
|
|
148
|
+
{#each actions.items as action}
|
|
149
|
+
<Button
|
|
150
|
+
collapse={true}
|
|
151
|
+
size="sm"
|
|
152
|
+
type="button"
|
|
153
|
+
style={actions.type == 'link' ? 'link' : 'secondary'}
|
|
154
|
+
on:click={() => action.onClick(row)}>{action.text}</Button
|
|
155
|
+
>
|
|
156
|
+
{/each}
|
|
157
|
+
{/if}
|
|
142
158
|
</TableCell>
|
|
143
159
|
{/if}
|
|
144
160
|
</TableRow>
|
|
@@ -8,9 +8,13 @@ declare const __propDef: {
|
|
|
8
8
|
cols: DataCol[];
|
|
9
9
|
pagination?: PaginationProperties | undefined;
|
|
10
10
|
actions?: {
|
|
11
|
-
text
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
text?: string | undefined;
|
|
12
|
+
type?: string | undefined;
|
|
13
|
+
items: {
|
|
14
|
+
text: string;
|
|
15
|
+
onClick: (row: JsonObject) => unknown;
|
|
16
|
+
}[];
|
|
17
|
+
} | undefined;
|
|
14
18
|
/**
|
|
15
19
|
* Handle page change, which should return the new filtered/fetched rows.
|
|
16
20
|
*/ onPageChange?: ((pagination: PaginationProperties) => Promise<JsonObject[]>) | null | undefined;
|