@likable-hair/svelte 3.1.46 → 3.1.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.
- package/dist/components/composed/list/PaginatedTable.svelte +3 -1
- package/dist/components/composed/list/PaginatedTable.svelte.d.ts +4 -0
- package/dist/components/simple/charts/GanymedeBarChart.svelte +9 -6
- package/dist/components/simple/charts/GanymedeBarChart.svelte.d.ts +3 -0
- package/dist/components/simple/lists/SimpleTable.svelte +130 -7
- package/dist/components/simple/lists/SimpleTable.svelte.d.ts +8 -0
- package/dist/utils/countries.js +2 -2
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ export let headers = [], items = [], sortedBy = void 0, sortDirection = void 0,
|
|
|
14
14
|
{ label: "20", value: 20 },
|
|
15
15
|
{ label: "50", value: 50 },
|
|
16
16
|
{ label: "100", value: 100 }
|
|
17
|
-
], hideRowsPerPage = false, totalElements = void 0, rowsPerPage = 20, filters = [], searchBarColumns = void 0, searchBarVisible = true, searchBarPlaceholder = "Type something to search...", lang = "en", editFilterMode = "one-edit", showActiveFilters = true;
|
|
17
|
+
], hideRowsPerPage = false, totalElements = void 0, rowsPerPage = 20, filters = [], searchBarColumns = void 0, searchBarVisible = true, searchBarPlaceholder = "Type something to search...", lang = "en", editFilterMode = "one-edit", showActiveFilters = true, resizableColumns = false, resizedColumnSizeWithPadding = {};
|
|
18
18
|
export let calculateRowStyles = void 0;
|
|
19
19
|
export let calculateRowClasses = void 0;
|
|
20
20
|
let searchBarInput, searchText = void 0;
|
|
@@ -109,6 +109,8 @@ function handleFiltersChange() {
|
|
|
109
109
|
on:rowClick
|
|
110
110
|
{calculateRowStyles}
|
|
111
111
|
{calculateRowClasses}
|
|
112
|
+
{resizableColumns}
|
|
113
|
+
bind:resizedColumnSizeWithPadding
|
|
112
114
|
>
|
|
113
115
|
<svelte:fragment slot="header" let:head>
|
|
114
116
|
<slot name="header" {head} >
|
|
@@ -28,6 +28,10 @@ declare const __propDef: {
|
|
|
28
28
|
lang?: "it" | "en" | undefined;
|
|
29
29
|
editFilterMode?: "one-edit" | "multi-edit" | undefined;
|
|
30
30
|
showActiveFilters?: boolean | undefined;
|
|
31
|
+
resizableColumns?: boolean | undefined;
|
|
32
|
+
resizedColumnSizeWithPadding?: {
|
|
33
|
+
[value: string]: number;
|
|
34
|
+
} | undefined;
|
|
31
35
|
calculateRowStyles?: CalculateRowStyles | undefined;
|
|
32
36
|
calculateRowClasses?: CalculateRowClasses | undefined;
|
|
33
37
|
};
|
|
@@ -30,15 +30,18 @@ let mounted = false, zoomMounted = false;
|
|
|
30
30
|
onMount(() => {
|
|
31
31
|
mounted = true;
|
|
32
32
|
});
|
|
33
|
-
let rgbTooltipColor = void 0;
|
|
34
|
-
let rgbTooltipBackgroundColor = void 0;
|
|
35
|
-
let rgbBackgroundColor = void 0;
|
|
33
|
+
export let rgbTooltipColor = void 0;
|
|
34
|
+
export let rgbTooltipBackgroundColor = void 0;
|
|
35
|
+
export let rgbBackgroundColor = void 0;
|
|
36
36
|
$:
|
|
37
|
-
rgbTooltipColor
|
|
37
|
+
if (!rgbTooltipColor && !!$theme.colors?.[$theme.active]["dark"]["primary"]["300"])
|
|
38
|
+
rgbTooltipColor = $theme.colors?.[$theme.active]["dark"]["primary"]["300"];
|
|
38
39
|
$:
|
|
39
|
-
rgbTooltipBackgroundColor
|
|
40
|
+
if (!rgbTooltipBackgroundColor && !!$theme.colors?.[$theme.active]["dark"]["primary"]["900"])
|
|
41
|
+
rgbTooltipBackgroundColor = $theme.colors?.[$theme.active]["dark"]["primary"]["900"];
|
|
40
42
|
$:
|
|
41
|
-
rgbBackgroundColor
|
|
43
|
+
if (!rgbBackgroundColor && !!$theme.colors?.[$theme.active]["dark"]["background"]["200"])
|
|
44
|
+
rgbBackgroundColor = $theme.colors?.[$theme.active]["dark"]["background"]["200"];
|
|
42
45
|
$:
|
|
43
46
|
finalTooltipColor = !!rgbTooltipColor ? `rgb(${rgbTooltipColor}, .8)` : void 0;
|
|
44
47
|
$:
|
|
@@ -25,6 +25,9 @@ declare const __propDef: {
|
|
|
25
25
|
tooltipLabel?: ((tooltip: import("chart.js").TooltipItem<"bar">) => string) | undefined;
|
|
26
26
|
yTickLabel?: ((tickValue: string | number, index: number, ticks: any[]) => (string | number)) | undefined;
|
|
27
27
|
xTickLabel?: ((tickValue: string | number, index: number, ticks: any[]) => (string | number)) | undefined;
|
|
28
|
+
rgbTooltipColor?: string | undefined;
|
|
29
|
+
rgbTooltipBackgroundColor?: string | undefined;
|
|
30
|
+
rgbBackgroundColor?: string | undefined;
|
|
28
31
|
};
|
|
29
32
|
events: {
|
|
30
33
|
[evt: string]: CustomEvent<any>;
|
|
@@ -3,13 +3,34 @@
|
|
|
3
3
|
<script>import "../../../css/main.css";
|
|
4
4
|
import "./SimpleTable.css";
|
|
5
5
|
import Icon from "../media/Icon.svelte";
|
|
6
|
-
import { createEventDispatcher } from "svelte";
|
|
6
|
+
import { createEventDispatcher, onMount } from "svelte";
|
|
7
7
|
let clazz = {};
|
|
8
8
|
export { clazz as class };
|
|
9
9
|
const dispatch = createEventDispatcher();
|
|
10
|
-
export let headers = [], items = [], sortedBy = void 0, sortDirection = "asc";
|
|
10
|
+
export let headers = [], items = [], sortedBy = void 0, sortDirection = "asc", resizableColumns = false, resizedColumnSizeWithPadding = {};
|
|
11
11
|
export let calculateRowStyles = void 0;
|
|
12
12
|
export let calculateRowClasses = void 0;
|
|
13
|
+
onMount(() => {
|
|
14
|
+
if (resizableColumns) {
|
|
15
|
+
for (const head of [...headers, { value: "slot-append" }]) {
|
|
16
|
+
let th = document.getElementById(head.value);
|
|
17
|
+
if (!!th) {
|
|
18
|
+
let { paddingLeft, paddingRight } = getComputedStyle(th);
|
|
19
|
+
let widthWihtPadding;
|
|
20
|
+
if (!!resizedColumnSizeWithPadding[head.value]) {
|
|
21
|
+
widthWihtPadding = resizedColumnSizeWithPadding[head.value];
|
|
22
|
+
} else {
|
|
23
|
+
widthWihtPadding = th.getBoundingClientRect().width;
|
|
24
|
+
resizedColumnSizeWithPadding[head.value] = widthWihtPadding;
|
|
25
|
+
}
|
|
26
|
+
let width = widthWihtPadding - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
27
|
+
th.style.width = `${width}px`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
let table = document.getElementsByClassName("table")[0];
|
|
31
|
+
table.classList.add("resizable");
|
|
32
|
+
}
|
|
33
|
+
});
|
|
13
34
|
function handleHeaderClick(header) {
|
|
14
35
|
if (header.sortable) {
|
|
15
36
|
if (!!sortedBy && header.value == sortedBy) {
|
|
@@ -36,20 +57,82 @@ function handleRowClick(item) {
|
|
|
36
57
|
function formatDate(dateTime, dateFormat) {
|
|
37
58
|
return dateTime.setLocale(dateFormat.locale).toFormat(dateFormat.format);
|
|
38
59
|
}
|
|
60
|
+
function resize(node) {
|
|
61
|
+
let th = node.parentElement;
|
|
62
|
+
let thead = document.getElementsByClassName("thead").item(0);
|
|
63
|
+
if (!!th && !!thead && thead instanceof HTMLElement) {
|
|
64
|
+
let mouseMoveHandler = function(e) {
|
|
65
|
+
if (resizing && !!th) {
|
|
66
|
+
width += e.movementX;
|
|
67
|
+
let { paddingLeft, paddingRight } = getComputedStyle(th);
|
|
68
|
+
let minWidth = headers.find((h) => h.value === th.id)?.minWidth;
|
|
69
|
+
let minWidthPx = void 0;
|
|
70
|
+
if (!!minWidth && minWidth.endsWith("px")) {
|
|
71
|
+
minWidthPx = parseInt(minWidth, 10);
|
|
72
|
+
}
|
|
73
|
+
let actualMinWidth = (minWidthPx || 50) - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
74
|
+
if (width > actualMinWidth) {
|
|
75
|
+
th.style.width = width + "px";
|
|
76
|
+
resizedColumnSizeWithPadding[th.id] = th.getBoundingClientRect().width;
|
|
77
|
+
dispatch("columnResize", {
|
|
78
|
+
id: th.id,
|
|
79
|
+
newWidthPx: width
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}, mouseUpHandler = function(e) {
|
|
84
|
+
if (!!th) {
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
resizing = false;
|
|
87
|
+
let { paddingLeft, paddingRight } = getComputedStyle(th);
|
|
88
|
+
width = th.getBoundingClientRect().width - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
89
|
+
}
|
|
90
|
+
}, mouseDownHandler = function(e) {
|
|
91
|
+
if (!!th) {
|
|
92
|
+
e.stopPropagation();
|
|
93
|
+
resizing = true;
|
|
94
|
+
let { paddingLeft, paddingRight } = getComputedStyle(th);
|
|
95
|
+
width = th.getBoundingClientRect().width - parseFloat(paddingLeft) - parseFloat(paddingRight);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
let resizing = false;
|
|
99
|
+
let { width } = th.getBoundingClientRect();
|
|
100
|
+
node.addEventListener("mousedown", mouseDownHandler);
|
|
101
|
+
document.addEventListener("mouseup", mouseUpHandler);
|
|
102
|
+
document.addEventListener("mousemove", mouseMoveHandler);
|
|
103
|
+
return {
|
|
104
|
+
destroy() {
|
|
105
|
+
node.removeEventListener("mousedown", mouseDownHandler);
|
|
106
|
+
document.removeEventListener("mouseup", mouseUpHandler);
|
|
107
|
+
document.removeEventListener("mousemove", mouseMoveHandler);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
39
112
|
</script>
|
|
40
113
|
|
|
41
114
|
{#if !!items && Array.isArray(items)}
|
|
42
|
-
<div class="simple-table-container {clazz.container || ''}">
|
|
115
|
+
<div class="simple-table-container {clazz.container || ''}" class:resizable={resizableColumns}>
|
|
43
116
|
<table class="table">
|
|
44
117
|
<thead class="thead {clazz.header || ''}">
|
|
45
118
|
<tr>
|
|
46
119
|
{#each headers as head}
|
|
47
120
|
<th
|
|
48
|
-
|
|
121
|
+
tabindex="0"
|
|
122
|
+
style={`${resizableColumns || !head.width ? '' : `width: ${head.width}`}`}
|
|
49
123
|
style:min-width={head.minWidth}
|
|
50
124
|
class:sortable={head.sortable}
|
|
51
|
-
on:
|
|
125
|
+
on:mousedown={() => handleHeaderClick(head)}
|
|
126
|
+
on:keydown={(e) => {
|
|
127
|
+
if(e.key == 'Enter') {
|
|
128
|
+
handleHeaderClick(head)
|
|
129
|
+
}
|
|
130
|
+
}}
|
|
131
|
+
id={head.value}
|
|
52
132
|
>
|
|
133
|
+
{#if resizableColumns}
|
|
134
|
+
<div class="resizer" use:resize></div>
|
|
135
|
+
{/if}
|
|
53
136
|
<slot name="header" {head}>
|
|
54
137
|
<span class="header-label">
|
|
55
138
|
<slot name="headerLabel">
|
|
@@ -74,7 +157,7 @@ function formatDate(dateTime, dateFormat) {
|
|
|
74
157
|
</th>
|
|
75
158
|
{/each}
|
|
76
159
|
{#if $$slots.rowActions || $$slots.append}
|
|
77
|
-
<th>
|
|
160
|
+
<th id="slot-append">
|
|
78
161
|
<slot name="append" index={-1} items={undefined} />
|
|
79
162
|
</th>
|
|
80
163
|
{/if}
|
|
@@ -121,7 +204,7 @@ function formatDate(dateTime, dateFormat) {
|
|
|
121
204
|
{:else}
|
|
122
205
|
{item[header.value]}
|
|
123
206
|
{/if}
|
|
124
|
-
{:else}
|
|
207
|
+
{:else}
|
|
125
208
|
{item[header.value]}
|
|
126
209
|
{/if}
|
|
127
210
|
</td>
|
|
@@ -140,6 +223,29 @@ function formatDate(dateTime, dateFormat) {
|
|
|
140
223
|
{/if}
|
|
141
224
|
|
|
142
225
|
<style>
|
|
226
|
+
.simple-table-container.resizable {
|
|
227
|
+
overflow-x: auto;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.resizer {
|
|
231
|
+
width: 2px;
|
|
232
|
+
display: none;
|
|
233
|
+
position: absolute;
|
|
234
|
+
right: 5%;
|
|
235
|
+
top: 10%;
|
|
236
|
+
bottom: 10%;
|
|
237
|
+
z-index: 1000;
|
|
238
|
+
background-color: rgb(var(--simple-table-column-resizer-color, var(--global-color-contrast-400)));
|
|
239
|
+
cursor: col-resize;
|
|
240
|
+
background-clip: content-box;
|
|
241
|
+
padding: 0px 5px 0px 5px;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
th:hover .resizer {
|
|
245
|
+
display: inline-block;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
|
|
143
249
|
.simple-table-container {
|
|
144
250
|
width: var(--simple-table-width, var(--simple-table-default-width));
|
|
145
251
|
min-width: var(
|
|
@@ -197,6 +303,10 @@ function formatDate(dateTime, dateFormat) {
|
|
|
197
303
|
user-select: none;
|
|
198
304
|
}
|
|
199
305
|
|
|
306
|
+
.table.resizable .thead th.sortable {
|
|
307
|
+
transition: none;
|
|
308
|
+
}
|
|
309
|
+
|
|
200
310
|
.thead th.sortable:hover {
|
|
201
311
|
color: var(
|
|
202
312
|
--simple-table-header-hover-color,
|
|
@@ -271,10 +381,23 @@ function formatDate(dateTime, dateFormat) {
|
|
|
271
381
|
width: 100%;
|
|
272
382
|
}
|
|
273
383
|
|
|
384
|
+
.table.resizable {
|
|
385
|
+
table-layout: fixed;
|
|
386
|
+
width: fit-content;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
.table.resizable td, th {
|
|
390
|
+
text-overflow: ellipsis;
|
|
391
|
+
overflow: hidden;
|
|
392
|
+
white-space: nowrap;
|
|
393
|
+
}
|
|
394
|
+
|
|
274
395
|
th {
|
|
275
396
|
text-align: start;
|
|
276
397
|
padding-left: 10px;
|
|
277
398
|
min-width: 100px;
|
|
399
|
+
position: relative;
|
|
400
|
+
user-select: none;
|
|
278
401
|
}
|
|
279
402
|
|
|
280
403
|
td {
|
|
@@ -35,6 +35,10 @@ declare const __propDef: {
|
|
|
35
35
|
items?: Item[] | undefined;
|
|
36
36
|
sortedBy?: string | undefined;
|
|
37
37
|
sortDirection?: "desc" | "asc" | undefined;
|
|
38
|
+
resizableColumns?: boolean | undefined;
|
|
39
|
+
resizedColumnSizeWithPadding?: {
|
|
40
|
+
[value: string]: number;
|
|
41
|
+
} | undefined;
|
|
38
42
|
calculateRowStyles?: CalculateRowStyles | undefined;
|
|
39
43
|
calculateRowClasses?: CalculateRowClasses | undefined;
|
|
40
44
|
};
|
|
@@ -46,6 +50,10 @@ declare const __propDef: {
|
|
|
46
50
|
rowClick: CustomEvent<{
|
|
47
51
|
item: Item;
|
|
48
52
|
}>;
|
|
53
|
+
columnResize: CustomEvent<{
|
|
54
|
+
id: string;
|
|
55
|
+
newWidthPx: number;
|
|
56
|
+
}>;
|
|
49
57
|
} & {
|
|
50
58
|
[evt: string]: CustomEvent<any>;
|
|
51
59
|
};
|
package/dist/utils/countries.js
CHANGED
|
@@ -42,7 +42,7 @@ export const countriesList = [
|
|
|
42
42
|
{ alpha2: "CF", name: "Central African Republic" },
|
|
43
43
|
{ alpha2: "CG", name: "Congo" },
|
|
44
44
|
{ alpha2: "CH", name: "Switzerland" },
|
|
45
|
-
{ alpha2: "CI", name: "
|
|
45
|
+
{ alpha2: "CI", name: "Cote d'Ivoire" },
|
|
46
46
|
{ alpha2: "CK", name: "Cook Islands" },
|
|
47
47
|
{ alpha2: "CL", name: "Chile" },
|
|
48
48
|
{ alpha2: "CM", name: "Cameroon" },
|
|
@@ -223,7 +223,7 @@ export const countriesList = [
|
|
|
223
223
|
{ alpha2: "TM", name: "Turkmenistan" },
|
|
224
224
|
{ alpha2: "TN", name: "Tunisia" },
|
|
225
225
|
{ alpha2: "TO", name: "Tonga" },
|
|
226
|
-
{ alpha2: "TR", name: "
|
|
226
|
+
{ alpha2: "TR", name: "Turkiye" },
|
|
227
227
|
{ alpha2: "TT", name: "Trinidad and Tobago" },
|
|
228
228
|
{ alpha2: "TV", name: "Tuvalu" },
|
|
229
229
|
{ alpha2: "TW", name: "Taiwan, Province of China" },
|