@swr-data-lab/components 2.40.0 → 2.42.0
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/ChartList/ChartList.svelte +29 -57
- package/dist/ChartList/ChartList.svelte.d.ts +1 -0
- package/dist/ChartList/Row.svelte +64 -0
- package/dist/ChartList/Row.svelte.d.ts +17 -0
- package/dist/Switcher/Switcher.svelte +39 -20
- package/dist/Switcher/Switcher.svelte.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
<script lang="ts">import { dev } from '$app/environment';
|
|
2
|
-
|
|
2
|
+
import Row from './Row.svelte';
|
|
3
|
+
let { project, charts = [], baseUrl } = $props();
|
|
4
|
+
const groups = $derived(Array.from(new Set(charts.map((c) => c.group).filter((c) => typeof c === 'string'))));
|
|
5
|
+
const groupedCharts = $derived.by(() => {
|
|
6
|
+
let res = {};
|
|
7
|
+
groups.forEach((g) => (res[g] = charts.filter((el) => el.group === g)));
|
|
8
|
+
return res;
|
|
9
|
+
});
|
|
10
|
+
const ungroupedCharts = $derived(charts.filter((el) => !el.group));
|
|
3
11
|
</script>
|
|
4
12
|
|
|
5
13
|
<main>
|
|
@@ -9,23 +17,27 @@ let { project, charts, baseUrl } = $props();
|
|
|
9
17
|
<table>
|
|
10
18
|
<thead>
|
|
11
19
|
<tr>
|
|
20
|
+
{#if groups.length > 0}
|
|
21
|
+
<th>Group</th>
|
|
22
|
+
{/if}
|
|
12
23
|
<th>Title</th>
|
|
13
24
|
<th>Embed URL</th>
|
|
14
25
|
</tr>
|
|
15
26
|
</thead>
|
|
16
27
|
<tbody>
|
|
17
|
-
{#each
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
{#each Object.values(groupedCharts) as charts}
|
|
29
|
+
{#each charts as chart, i}
|
|
30
|
+
<Row {chart} group={i === 0} rowspan={groupedCharts[chart.group].length} {baseUrl}
|
|
31
|
+
></Row>
|
|
32
|
+
{/each}
|
|
33
|
+
{/each}
|
|
34
|
+
{#each ungroupedCharts as chart, i}
|
|
35
|
+
<Row
|
|
36
|
+
{chart}
|
|
37
|
+
{baseUrl}
|
|
38
|
+
group={groups.length > 0 && i === 0}
|
|
39
|
+
rowspan={ungroupedCharts.length === 1 ? 1 : 0}
|
|
40
|
+
></Row>
|
|
29
41
|
{/each}
|
|
30
42
|
</tbody>
|
|
31
43
|
</table>
|
|
@@ -69,60 +81,20 @@ h1 em {
|
|
|
69
81
|
}
|
|
70
82
|
|
|
71
83
|
table {
|
|
84
|
+
border: 1px solid var(--color-surfaceBorder);
|
|
72
85
|
border-collapse: collapse;
|
|
73
86
|
border-spacing: 0;
|
|
74
87
|
width: 100%;
|
|
75
|
-
border: 1px solid var(--color-surfaceBorder);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
a {
|
|
79
|
-
display: block;
|
|
80
|
-
color: inherit;
|
|
81
|
-
text-decoration: none;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
th,
|
|
85
|
-
td {
|
|
86
|
-
padding: 0 0.4em;
|
|
87
|
-
text-align: left;
|
|
88
|
-
border-right: 1px solid var(--color-surfaceBorder);
|
|
89
|
-
}
|
|
90
|
-
th:last-child,
|
|
91
|
-
td:last-child {
|
|
92
|
-
border-right: 0;
|
|
93
88
|
}
|
|
94
89
|
|
|
95
90
|
th {
|
|
91
|
+
text-align: left;
|
|
96
92
|
padding: 0.2em 0.4em;
|
|
97
93
|
border-right: 1px solid var(--color-textSecondary);
|
|
98
94
|
border-bottom: 1px solid var(--color-textSecondary);
|
|
99
95
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
border-bottom: 1px solid var(--color-surfaceBorder);
|
|
103
|
-
}
|
|
104
|
-
tr:last-child {
|
|
105
|
-
border-bottom: 0;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
input {
|
|
109
|
-
display: block;
|
|
110
|
-
font-family: monospace;
|
|
111
|
-
width: 100%;
|
|
112
|
-
padding: 0.35em 0;
|
|
113
|
-
font-size: 0.9rem;
|
|
114
|
-
background: var(--color-pageFill);
|
|
115
|
-
color: var(--color-textSecondary);
|
|
116
|
-
border: 0;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
a:hover,
|
|
120
|
-
a:focus-visible {
|
|
121
|
-
text-decoration: underline;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
a:last-child {
|
|
125
|
-
border-bottom: 0;
|
|
96
|
+
th:last-child {
|
|
97
|
+
border-right: 0;
|
|
126
98
|
}
|
|
127
99
|
|
|
128
100
|
.notes {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { dev } from '$app/environment';
|
|
3
|
+
const { chart, group = false, rowspan = 0, baseUrl } = $props();
|
|
4
|
+
|
|
5
|
+
const route = $derived(`/${chart.slug}`);
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<tr>
|
|
9
|
+
{#if group}
|
|
10
|
+
<td {rowspan}>{chart.group}</td>
|
|
11
|
+
{/if}
|
|
12
|
+
<td>
|
|
13
|
+
<a rel="external" href={dev ? route : `./${chart.slug}.html`}>
|
|
14
|
+
{chart.title}
|
|
15
|
+
</a>
|
|
16
|
+
</td>
|
|
17
|
+
<td>
|
|
18
|
+
<input type="text" value={`${baseUrl ?? ''}${route}.html`} />
|
|
19
|
+
</td>
|
|
20
|
+
</tr>
|
|
21
|
+
|
|
22
|
+
<style>
|
|
23
|
+
td {
|
|
24
|
+
padding: 0.15em 0.4em;
|
|
25
|
+
padding-bottom: 0;
|
|
26
|
+
line-height: 1.5;
|
|
27
|
+
text-align: left;
|
|
28
|
+
vertical-align: top;
|
|
29
|
+
border-right: 1px solid var(--color-surfaceBorder);
|
|
30
|
+
&:last-child {
|
|
31
|
+
border-right: 0;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
tr {
|
|
35
|
+
border-bottom: 1px solid var(--color-surfaceBorder);
|
|
36
|
+
&:last-child {
|
|
37
|
+
border-bottom: 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
a {
|
|
41
|
+
display: block;
|
|
42
|
+
color: inherit;
|
|
43
|
+
text-decoration: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
input {
|
|
47
|
+
display: block;
|
|
48
|
+
font-family: monospace;
|
|
49
|
+
width: 100%;
|
|
50
|
+
padding: 0.35em 0;
|
|
51
|
+
font-size: 0.9rem;
|
|
52
|
+
background: var(--color-pageFill);
|
|
53
|
+
color: var(--color-textSecondary);
|
|
54
|
+
border: 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
a:hover,
|
|
58
|
+
a:focus-visible {
|
|
59
|
+
text-decoration: underline;
|
|
60
|
+
}
|
|
61
|
+
a:last-child {
|
|
62
|
+
border-bottom: 0;
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default Row;
|
|
2
|
+
type Row = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Row: import("svelte").Component<{
|
|
7
|
+
chart: any;
|
|
8
|
+
group?: boolean;
|
|
9
|
+
rowspan?: number;
|
|
10
|
+
baseUrl: any;
|
|
11
|
+
}, {}, "">;
|
|
12
|
+
type $$ComponentProps = {
|
|
13
|
+
chart: any;
|
|
14
|
+
group?: boolean;
|
|
15
|
+
rowspan?: number;
|
|
16
|
+
baseUrl: any;
|
|
17
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">import FormLabel from '../FormLabel/FormLabel.svelte';
|
|
2
|
-
let { label, options, size = 'default', hideLabel = false, value = $bindable(null), onchange } = $props();
|
|
2
|
+
let { label, options, size = 'default', hideLabel = false, layout = 'auto', value = $bindable(null), onchange } = $props();
|
|
3
3
|
const groupId = $props.id();
|
|
4
4
|
const groupName = 'select-' + groupId;
|
|
5
5
|
function optionToID(o) {
|
|
@@ -11,7 +11,12 @@ function optionToID(o) {
|
|
|
11
11
|
<div class="legend" class:hidden={hideLabel}>
|
|
12
12
|
<FormLabel as="legend">{label}</FormLabel>
|
|
13
13
|
</div>
|
|
14
|
-
<ul
|
|
14
|
+
<ul
|
|
15
|
+
class:layout-row={layout === 'row'}
|
|
16
|
+
class:layout-column={layout === 'column'}
|
|
17
|
+
class:layout-auto={layout === 'auto'}
|
|
18
|
+
role="list"
|
|
19
|
+
>
|
|
15
20
|
{#each options as o (o)}
|
|
16
21
|
<li class:is-selected={o === value}>
|
|
17
22
|
<label for={optionToID(o)}>
|
|
@@ -44,10 +49,11 @@ ul {
|
|
|
44
49
|
width: 100%;
|
|
45
50
|
display: flex;
|
|
46
51
|
flex-direction: column;
|
|
47
|
-
overflow:
|
|
52
|
+
overflow-x: auto;
|
|
48
53
|
padding: 0;
|
|
49
54
|
margin: 0;
|
|
50
|
-
border: 1px solid var(--color-textSecondary);
|
|
55
|
+
border-top: 1px solid var(--color-textSecondary);
|
|
56
|
+
border-left: 1px solid var(--color-textSecondary);
|
|
51
57
|
color: var(--color-textPrimary);
|
|
52
58
|
background: var(--color-surfaceFill);
|
|
53
59
|
border-radius: var(--br-small);
|
|
@@ -57,13 +63,21 @@ ul {
|
|
|
57
63
|
flex-flow: row;
|
|
58
64
|
}
|
|
59
65
|
}
|
|
66
|
+
ul.layout-row {
|
|
67
|
+
flex-flow: row;
|
|
68
|
+
}
|
|
69
|
+
ul.layout-column {
|
|
70
|
+
flex-direction: column;
|
|
71
|
+
}
|
|
60
72
|
|
|
61
73
|
li {
|
|
62
74
|
display: contents;
|
|
63
75
|
}
|
|
64
76
|
li:last-child label {
|
|
65
|
-
border-right:
|
|
66
|
-
|
|
77
|
+
border-bottom-right-radius: var(--br-small);
|
|
78
|
+
}
|
|
79
|
+
li:first-child label {
|
|
80
|
+
border-top-left-radius: var(--br-small);
|
|
67
81
|
}
|
|
68
82
|
|
|
69
83
|
input {
|
|
@@ -82,36 +96,41 @@ label {
|
|
|
82
96
|
line-height: 1;
|
|
83
97
|
white-space: nowrap;
|
|
84
98
|
padding: 0 1em;
|
|
85
|
-
cursor: pointer;
|
|
86
99
|
margin: 0;
|
|
87
|
-
|
|
100
|
+
cursor: pointer;
|
|
88
101
|
display: flex;
|
|
102
|
+
justify-content: center;
|
|
103
|
+
align-items: center;
|
|
89
104
|
color: currentColor;
|
|
90
105
|
position: relative;
|
|
91
106
|
transition: var(--fast);
|
|
92
107
|
text-underline-offset: 0.1em;
|
|
93
|
-
border-right: 1px solid var(--color-textSecondary);
|
|
94
108
|
height: 2.25em;
|
|
109
|
+
border-right: 1px solid var(--color-textSecondary);
|
|
110
|
+
border-bottom: 1px solid var(--color-textSecondary);
|
|
111
|
+
flex-grow: 1;
|
|
95
112
|
}
|
|
96
113
|
@media (min-width: 425px) {
|
|
97
114
|
label {
|
|
98
|
-
justify-content: center;
|
|
99
|
-
padding: 0 1em;
|
|
100
115
|
flex-basis: 0;
|
|
101
|
-
flex-grow: 1;
|
|
102
|
-
border-bottom: 0;
|
|
103
116
|
}
|
|
104
117
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
height: 2.5em;
|
|
108
|
-
}
|
|
118
|
+
.layout-row label {
|
|
119
|
+
flex-basis: 0;
|
|
109
120
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
text-decoration-color: var(--color-textSecondary);
|
|
121
|
+
.layout-column label {
|
|
122
|
+
flex-basis: auto;
|
|
113
123
|
}
|
|
114
124
|
.is-selected label {
|
|
115
125
|
background: var(--color-surfaceHover);
|
|
116
126
|
font-weight: 700;
|
|
127
|
+
}
|
|
128
|
+
@media (prefers-color-scheme: dark) {
|
|
129
|
+
.is-selected label {
|
|
130
|
+
background: var(--gray-dark-2);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
label:hover, label:focus-visible {
|
|
134
|
+
text-decoration: underline;
|
|
135
|
+
text-decoration-color: var(--color-textSecondary);
|
|
117
136
|
}</style>
|
|
@@ -11,7 +11,14 @@ interface SwitcherProps {
|
|
|
11
11
|
* Display size
|
|
12
12
|
*/
|
|
13
13
|
size?: 'default' | 'small';
|
|
14
|
+
/**
|
|
15
|
+
* Hide the main label visually
|
|
16
|
+
*/
|
|
14
17
|
hideLabel?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Force the options to be displayed in a row (even on small screens)
|
|
20
|
+
*/
|
|
21
|
+
layout?: 'row' | 'column' | 'auto';
|
|
15
22
|
/**
|
|
16
23
|
* The currently-selected option (bindable)
|
|
17
24
|
*/
|