sveltacular 0.0.68 → 0.0.69
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.
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
export let style = "standard";
|
|
3
3
|
export let shape = "rounded";
|
|
4
4
|
export let fill = "solid";
|
|
5
|
+
export let compact = false;
|
|
5
6
|
</script>
|
|
6
7
|
|
|
7
|
-
<
|
|
8
|
-
<slot
|
|
9
|
-
</
|
|
8
|
+
<div class="pill {size} {style} {shape} {fill}" class:compact>
|
|
9
|
+
<span><slot /></span>
|
|
10
|
+
</div>
|
|
10
11
|
|
|
11
12
|
<style>.pill {
|
|
12
13
|
display: inline-block;
|
|
@@ -18,6 +19,9 @@ export let fill = "solid";
|
|
|
18
19
|
color: #4a5568;
|
|
19
20
|
font-family: var(--base-font-family, sans-serif);
|
|
20
21
|
}
|
|
22
|
+
.pill.compact {
|
|
23
|
+
padding: 0.125rem;
|
|
24
|
+
}
|
|
21
25
|
.pill.sm {
|
|
22
26
|
font-size: 0.625rem;
|
|
23
27
|
padding: 0.125rem 0.25rem;
|
|
@@ -44,6 +48,31 @@ export let fill = "solid";
|
|
|
44
48
|
.pill.circular {
|
|
45
49
|
border-radius: 50%;
|
|
46
50
|
}
|
|
51
|
+
.pill.circle {
|
|
52
|
+
border-radius: 50%;
|
|
53
|
+
width: 1.75rem;
|
|
54
|
+
height: 1.75rem;
|
|
55
|
+
position: relative;
|
|
56
|
+
}
|
|
57
|
+
.pill.circle.sm {
|
|
58
|
+
width: 1.25rem;
|
|
59
|
+
height: 1.25rem;
|
|
60
|
+
}
|
|
61
|
+
.pill.circle.lg {
|
|
62
|
+
width: 2.25rem;
|
|
63
|
+
height: 2.25rem;
|
|
64
|
+
}
|
|
65
|
+
.pill.circle.xl {
|
|
66
|
+
width: 3rem;
|
|
67
|
+
height: 3rem;
|
|
68
|
+
}
|
|
69
|
+
.pill.circle span {
|
|
70
|
+
display: flex;
|
|
71
|
+
justify-content: center;
|
|
72
|
+
align-items: center;
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 100%;
|
|
75
|
+
}
|
|
47
76
|
.pill.positive {
|
|
48
77
|
background-color: #0a5200;
|
|
49
78
|
color: #fff;
|
|
@@ -4,8 +4,9 @@ declare const __propDef: {
|
|
|
4
4
|
props: {
|
|
5
5
|
size?: FormFieldSizeOptions | undefined;
|
|
6
6
|
style?: "positive" | "negative" | "standard" | undefined;
|
|
7
|
-
shape?: "circular" | "square" | "rounded" | "badge" | undefined;
|
|
7
|
+
shape?: "circle" | "circular" | "square" | "rounded" | "badge" | undefined;
|
|
8
8
|
fill?: "outline" | "solid" | undefined;
|
|
9
|
+
compact?: boolean | undefined;
|
|
9
10
|
};
|
|
10
11
|
events: {
|
|
11
12
|
[evt: string]: CustomEvent<any>;
|
package/dist/helpers/date.d.ts
CHANGED
|
@@ -15,3 +15,4 @@ export declare const dateTimeToInput: (dateTime?: Date) => string;
|
|
|
15
15
|
export declare const isDateString: (date: string) => date is string;
|
|
16
16
|
export declare const isDateTimeString: (dateTime: string) => dateTime is string;
|
|
17
17
|
export declare const isDateOrDateTimeString: (dateOrDateTime: unknown) => dateOrDateTime is string;
|
|
18
|
+
export declare const formatDateTime: (dateTime: string | Date) => string;
|
package/dist/helpers/date.js
CHANGED
|
@@ -113,3 +113,9 @@ export const isDateOrDateTimeString = (dateOrDateTime) => {
|
|
|
113
113
|
return false;
|
|
114
114
|
return isDateString(dateOrDateTime) || isDateTimeString(dateOrDateTime);
|
|
115
115
|
};
|
|
116
|
+
export const formatDateTime = (dateTime) => {
|
|
117
|
+
const date = new Date(dateTime);
|
|
118
|
+
const offset = date.getTimezoneOffset();
|
|
119
|
+
date.setMinutes(date.getMinutes() - offset);
|
|
120
|
+
return date.toISOString().split('.')[0].slice(0, -3);
|
|
121
|
+
};
|
|
@@ -12,6 +12,7 @@ import Button from "../forms/button/button.svelte";
|
|
|
12
12
|
import Empty from "../generic/empty/empty.svelte";
|
|
13
13
|
import Pill from "../generic/pill/pill.svelte";
|
|
14
14
|
import FolderOpenIcon from "../icons/folder-open-icon.svelte";
|
|
15
|
+
import { formatDateTime } from "../index.js";
|
|
15
16
|
import Pagination from "../navigation/pagination/pagination.svelte";
|
|
16
17
|
import Loading from "../placeholders/loading.svelte";
|
|
17
18
|
import TableCaption from "./table-caption.svelte";
|
|
@@ -39,6 +40,10 @@ const format = (row, key) => {
|
|
|
39
40
|
return col.emptyText;
|
|
40
41
|
if (col.format)
|
|
41
42
|
return col.format(row, key);
|
|
43
|
+
if (col.type === "date")
|
|
44
|
+
return formatDateTime(String(row[key])).substring(0, 10);
|
|
45
|
+
if (col.type === "date-time")
|
|
46
|
+
return formatDateTime(String(row[key]));
|
|
42
47
|
return row[key];
|
|
43
48
|
};
|
|
44
49
|
const calculateTotalPages = () => {
|
|
@@ -113,11 +118,11 @@ $:
|
|
|
113
118
|
<TableCell type={col.type || typeof row[col.key]} width={col.width}>
|
|
114
119
|
{#if col.link}
|
|
115
120
|
<a href={col.link(row, col.key)}>{format(row, col.key)}</a>
|
|
116
|
-
|
|
121
|
+
{:else if col.type == 'email' && row[col.key]}
|
|
117
122
|
<a href={`mailto:${row[col.key]}`}>{format(row, col.key)}</a>
|
|
118
123
|
{:else if col.type == 'check'}
|
|
119
124
|
{#if row[col.key]}
|
|
120
|
-
<Pill shape="
|
|
125
|
+
<Pill shape="circle" style="positive" compact>✔</Pill>
|
|
121
126
|
{/if}
|
|
122
127
|
{:else}
|
|
123
128
|
{format(row, col.key)}
|