@vit-foundation/ui 0.15.0 → 0.16.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/README.md +10 -10
- package/dist/components/jobs/JobList.svelte +11 -19
- package/dist/components/jobs/JobList.svelte.d.ts +1 -1
- package/dist/components/layout/Footer.svelte +9 -15
- package/dist/components/layout/Nav.svelte +10 -15
- package/dist/components/projects/ProjectCard.svelte +2 -2
- package/dist/components/projects/ProjectCard.svelte.d.ts +1 -1
- package/dist/components/team/CollaboratorList.svelte +10 -16
- package/dist/components/timeline/Timeline.svelte +10 -23
- package/dist/components/timeline/TimelineMilestone.svelte +2 -2
- package/dist/components/timeline/TimelineMilestone.svelte.d.ts +1 -1
- package/dist/components/weeklies/WeeklieCard.svelte +2 -2
- package/dist/components/weeklies/WeeklieCard.svelte.d.ts +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/messages.js +5 -1
- package/dist/config/types.d.ts +35 -3
- package/dist/content-components.d.ts +5 -1
- package/dist/content-components.js +4 -1
- package/dist/edit/chrome/EditPanel.svelte +2 -2
- package/dist/edit/chrome/EditPanel.svelte.d.ts +2 -2
- package/dist/edit/chrome/PropertyRow.svelte +40 -9
- package/dist/edit/chrome/PropertyRow.svelte.d.ts +6 -2
- package/dist/edit/collection.svelte.d.ts +49 -0
- package/dist/edit/collection.svelte.js +39 -0
- package/dist/edit/helpers.d.ts +5 -5
- package/dist/edit/helpers.js +2 -2
- package/dist/edit/index.d.ts +4 -1
- package/dist/edit/index.js +1 -0
- package/dist/edit/types.d.ts +24 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/utils/milestones.d.ts +15 -0
- package/dist/utils/milestones.js +17 -0
- package/dist/utils/paths.d.ts +6 -0
- package/dist/utils/paths.js +14 -0
- package/dist/utils/url-filters.svelte.d.ts +58 -0
- package/dist/utils/url-filters.svelte.js +47 -0
- package/dist/utils/weekly-list.svelte.d.ts +82 -0
- package/dist/utils/weekly-list.svelte.js +120 -0
- package/package.json +1 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { buildQueryString } from './paths.js';
|
|
2
|
+
import { createUrlFilters } from './url-filters.svelte.js';
|
|
3
|
+
/**
|
|
4
|
+
* The weeklies index's URL defaults: the value a param stands for when it is
|
|
5
|
+
* absent. Both halves of the URL contract — this module omitting a default,
|
|
6
|
+
* the host's query schema supplying one — must name the same values, so a
|
|
7
|
+
* host derives its schema defaults from here rather than restating them.
|
|
8
|
+
*/
|
|
9
|
+
export const WEEKLY_LIST_DEFAULTS = { sort: 'desc', page: 1 };
|
|
10
|
+
/** The index's path, shared by the mirrored URL and the paging hrefs. */
|
|
11
|
+
const WEEKLIES_PATH = '/weeklies';
|
|
12
|
+
/**
|
|
13
|
+
* The weeklies index view: the filters that ride the URL, the page the
|
|
14
|
+
* server rendered, and the page a filter change refetched in place.
|
|
15
|
+
*
|
|
16
|
+
* The two disagree by design — a changed filter returns to the first page
|
|
17
|
+
* while the URL still carries the old one — and reconciling them was four
|
|
18
|
+
* `$state` cells, an `$effect` and three `$derived` sitting in a route file,
|
|
19
|
+
* where nothing could reach them. Two things went wrong there: `loadError`
|
|
20
|
+
* was never cleared on navigation, so a failed refetch kept its alert on
|
|
21
|
+
* screen above fresh results; and a failed refetch left the URL, the grid
|
|
22
|
+
* and the pagination status giving three different answers.
|
|
23
|
+
*
|
|
24
|
+
* `createUrlFilters` owns the URL and deliberately not the fetching, because
|
|
25
|
+
* the transparency page filters client-side over data it already has. This
|
|
26
|
+
* owns the fetching and the reconciliation, for the one page that does both.
|
|
27
|
+
*/
|
|
28
|
+
export function createWeeklyList(config) {
|
|
29
|
+
// The client's answer, or null while the server's still stands.
|
|
30
|
+
let clientItems = $state(null);
|
|
31
|
+
let clientTotal = $state(null);
|
|
32
|
+
let isLoading = $state(false);
|
|
33
|
+
let loadError = $state(false);
|
|
34
|
+
const filters = createUrlFilters({
|
|
35
|
+
path: WEEKLIES_PATH,
|
|
36
|
+
initial: () => ({ ...config.server().query }),
|
|
37
|
+
// A param is left out exactly when it holds the value the parse would
|
|
38
|
+
// have supplied anyway, so both sides read the same declaration —
|
|
39
|
+
// otherwise "oldest first" builds a link that reloads as newest-first.
|
|
40
|
+
toQuery: (values) => ({
|
|
41
|
+
q: values.q,
|
|
42
|
+
theme: values.theme,
|
|
43
|
+
sort: values.sort !== WEEKLY_LIST_DEFAULTS.sort ? values.sort : null
|
|
44
|
+
}),
|
|
45
|
+
onChange: () => void refresh(),
|
|
46
|
+
replaceUrl: config.replaceUrl
|
|
47
|
+
});
|
|
48
|
+
$effect(() => {
|
|
49
|
+
// Paging is a real navigation, so the load re-runs and replaces the
|
|
50
|
+
// server data. Reading it here registers the dependency and drops the
|
|
51
|
+
// client override, which would otherwise keep the previous filter's
|
|
52
|
+
// first page on screen while the URL claimed to be on page 2.
|
|
53
|
+
config.server();
|
|
54
|
+
clientItems = null;
|
|
55
|
+
clientTotal = null;
|
|
56
|
+
// Cleared with the rest: the route file reset only the two lists, so a
|
|
57
|
+
// refetch that failed kept its alert across the next navigation.
|
|
58
|
+
loadError = false;
|
|
59
|
+
});
|
|
60
|
+
async function refresh() {
|
|
61
|
+
isLoading = true;
|
|
62
|
+
const { q, theme, sort } = filters.values;
|
|
63
|
+
try {
|
|
64
|
+
const result = await config.fetchPage({
|
|
65
|
+
q: q || undefined,
|
|
66
|
+
theme,
|
|
67
|
+
sort,
|
|
68
|
+
limit: config.server().pageSize,
|
|
69
|
+
locale: config.locale()
|
|
70
|
+
});
|
|
71
|
+
clientItems = result.items;
|
|
72
|
+
clientTotal = result.total;
|
|
73
|
+
loadError = false;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Keep the stale list on screen; `loadError` explains the failure.
|
|
77
|
+
loadError = true;
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
isLoading = false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
get items() {
|
|
85
|
+
return clientItems ?? config.server().weeklies;
|
|
86
|
+
},
|
|
87
|
+
get total() {
|
|
88
|
+
return clientTotal ?? config.server().total;
|
|
89
|
+
},
|
|
90
|
+
get page() {
|
|
91
|
+
return clientItems ? 1 : config.server().page;
|
|
92
|
+
},
|
|
93
|
+
get isLoading() {
|
|
94
|
+
return isLoading;
|
|
95
|
+
},
|
|
96
|
+
get loadError() {
|
|
97
|
+
return loadError;
|
|
98
|
+
},
|
|
99
|
+
get filters() {
|
|
100
|
+
return filters.values;
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* Paging is this module's concern and not the URL module's — the
|
|
104
|
+
* transparency page filters a list it already has and has no page at
|
|
105
|
+
* all — so the page number is added here rather than held in the
|
|
106
|
+
* filter state. That is also what makes a filter change drop it: the
|
|
107
|
+
* mirrored URL carries only filters, and a changed filter invalidates
|
|
108
|
+
* the position within the old result set.
|
|
109
|
+
*/
|
|
110
|
+
hrefFor(page) {
|
|
111
|
+
return `${WEEKLIES_PATH}${buildQueryString({
|
|
112
|
+
...filters.query,
|
|
113
|
+
page: page > WEEKLY_LIST_DEFAULTS.page ? String(page) : null
|
|
114
|
+
})}`;
|
|
115
|
+
},
|
|
116
|
+
update(patch) {
|
|
117
|
+
filters.update(patch);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|