@loj-lang/rdsl-runtime 0.5.0 → 0.6.1
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/Badge.d.ts +2 -1
- package/dist/components/Badge.d.ts.map +1 -1
- package/dist/components/Badge.js +2 -2
- package/dist/components/ConfirmDialog.d.ts +6 -1
- package/dist/components/ConfirmDialog.d.ts.map +1 -1
- package/dist/components/ConfirmDialog.js +35 -6
- package/dist/components/DataTable.d.ts +35 -2
- package/dist/components/DataTable.d.ts.map +1 -1
- package/dist/components/DataTable.js +64 -38
- package/dist/components/DropdownButton.d.ts +11 -0
- package/dist/components/DropdownButton.d.ts.map +1 -0
- package/dist/components/DropdownButton.js +9 -0
- package/dist/components/ErrorBoundary.d.ts +18 -0
- package/dist/components/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/ErrorBoundary.js +19 -0
- package/dist/components/ErrorState.d.ts +6 -0
- package/dist/components/ErrorState.d.ts.map +1 -0
- package/dist/components/ErrorState.js +25 -0
- package/dist/components/FilterBar.d.ts +2 -0
- package/dist/components/FilterBar.d.ts.map +1 -1
- package/dist/components/FilterBar.js +3 -2
- package/dist/components/FormField.d.ts +7 -2
- package/dist/components/FormField.d.ts.map +1 -1
- package/dist/components/FormField.js +16 -5
- package/dist/components/GroupedDataTable.d.ts.map +1 -1
- package/dist/components/GroupedDataTable.js +40 -59
- package/dist/components/Pagination.js +1 -1
- package/dist/components/PivotDataTable.d.ts.map +1 -1
- package/dist/components/PivotDataTable.js +42 -65
- package/dist/components/Tag.d.ts +2 -1
- package/dist/components/Tag.d.ts.map +1 -1
- package/dist/components/Tag.js +2 -2
- package/dist/components/WorkflowSummary.js +6 -6
- package/dist/components/readFormatting.d.ts +2 -0
- package/dist/components/readFormatting.d.ts.map +1 -0
- package/dist/components/readFormatting.js +1 -0
- package/dist/derivations.d.ts +3 -0
- package/dist/derivations.d.ts.map +1 -0
- package/dist/derivations.js +1 -0
- package/dist/hooks/browserStorage.d.ts +3 -0
- package/dist/hooks/browserStorage.d.ts.map +1 -0
- package/dist/hooks/browserStorage.js +1 -0
- package/dist/hooks/deleteConfirmation.d.ts +20 -0
- package/dist/hooks/deleteConfirmation.d.ts.map +1 -0
- package/dist/hooks/deleteConfirmation.js +21 -0
- package/dist/hooks/exportDownload.d.ts +16 -0
- package/dist/hooks/exportDownload.d.ts.map +1 -0
- package/dist/hooks/exportDownload.js +55 -0
- package/dist/hooks/formDerivations.d.ts +7 -0
- package/dist/hooks/formDerivations.d.ts.map +1 -0
- package/dist/hooks/formDerivations.js +23 -0
- package/dist/hooks/formSeeds.d.ts +12 -0
- package/dist/hooks/formSeeds.d.ts.map +1 -0
- package/dist/hooks/formSeeds.js +26 -0
- package/dist/hooks/navigation.d.ts +37 -0
- package/dist/hooks/navigation.d.ts.map +1 -1
- package/dist/hooks/navigation.js +107 -70
- package/dist/hooks/readModelStore.d.ts +29 -0
- package/dist/hooks/readModelStore.d.ts.map +1 -0
- package/dist/hooks/readModelStore.js +135 -0
- package/dist/hooks/recordScopedWorkflow.d.ts +13 -0
- package/dist/hooks/recordScopedWorkflow.d.ts.map +1 -0
- package/dist/hooks/recordScopedWorkflow.js +40 -0
- package/dist/hooks/resourceClient.d.ts +39 -0
- package/dist/hooks/resourceClient.d.ts.map +1 -1
- package/dist/hooks/resourceClient.js +205 -71
- package/dist/hooks/resourceErrors.d.ts +13 -0
- package/dist/hooks/resourceErrors.d.ts.map +1 -0
- package/dist/hooks/resourceErrors.js +140 -0
- package/dist/hooks/resourceRowActions.d.ts +17 -0
- package/dist/hooks/resourceRowActions.d.ts.map +1 -0
- package/dist/hooks/resourceRowActions.js +48 -0
- package/dist/hooks/resourceStore.d.ts +2 -24
- package/dist/hooks/resourceStore.d.ts.map +1 -1
- package/dist/hooks/resourceStore.js +1 -164
- package/dist/hooks/resourceTarget.d.ts +1 -1
- package/dist/hooks/resourceTarget.d.ts.map +1 -1
- package/dist/hooks/resourceTarget.js +1 -22
- package/dist/hooks/serverListStore.d.ts +3 -0
- package/dist/hooks/serverListStore.d.ts.map +1 -0
- package/dist/hooks/serverListStore.js +1 -0
- package/dist/hooks/sessionCaches.d.ts +6 -0
- package/dist/hooks/sessionCaches.d.ts.map +1 -0
- package/dist/hooks/sessionCaches.js +14 -0
- package/dist/hooks/transitionedSetter.d.ts +2 -0
- package/dist/hooks/transitionedSetter.d.ts.map +1 -0
- package/dist/hooks/transitionedSetter.js +9 -0
- package/dist/hooks/useAuth.d.ts +18 -0
- package/dist/hooks/useAuth.d.ts.map +1 -1
- package/dist/hooks/useAuth.js +30 -0
- package/dist/hooks/useCollectionView.d.ts +2 -8
- package/dist/hooks/useCollectionView.d.ts.map +1 -1
- package/dist/hooks/useCollectionView.js +8 -36
- package/dist/hooks/useDocumentMetadata.d.ts.map +1 -1
- package/dist/hooks/useDocumentMetadata.js +57 -0
- package/dist/hooks/useGroupedCollectionView.d.ts +2 -7
- package/dist/hooks/useGroupedCollectionView.d.ts.map +1 -1
- package/dist/hooks/useGroupedCollectionView.js +8 -52
- package/dist/hooks/useI18n.d.ts +21 -0
- package/dist/hooks/useI18n.d.ts.map +1 -0
- package/dist/hooks/useI18n.js +86 -0
- package/dist/hooks/useReadModel.d.ts +15 -0
- package/dist/hooks/useReadModel.d.ts.map +1 -1
- package/dist/hooks/useReadModel.js +127 -40
- package/dist/hooks/useResource.d.ts +7 -0
- package/dist/hooks/useResource.d.ts.map +1 -1
- package/dist/hooks/useResource.js +159 -3
- package/dist/hooks/useStoredState.d.ts +15 -0
- package/dist/hooks/useStoredState.d.ts.map +1 -0
- package/dist/hooks/useStoredState.js +28 -0
- package/dist/hooks/useToast.d.ts.map +1 -1
- package/dist/hooks/useToast.js +1 -1
- package/dist/hooks/workflowTransition.d.ts +21 -0
- package/dist/hooks/workflowTransition.d.ts.map +1 -0
- package/dist/hooks/workflowTransition.js +54 -0
- package/dist/index.d.ts +35 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -5
- package/dist/policies/can.d.ts +2 -14
- package/dist/policies/can.d.ts.map +1 -1
- package/dist/policies/can.js +1 -160
- package/dist/workflow.d.ts +3 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +1 -0
- package/package.json +142 -26
|
@@ -1,164 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const resourceClientIds = new WeakMap();
|
|
3
|
-
let nextClientId = 1;
|
|
4
|
-
function storeKey(client, api) {
|
|
5
|
-
const resourceClient = client;
|
|
6
|
-
let id = resourceClientIds.get(resourceClient);
|
|
7
|
-
if (!id) {
|
|
8
|
-
id = nextClientId;
|
|
9
|
-
nextClientId += 1;
|
|
10
|
-
resourceClientIds.set(resourceClient, id);
|
|
11
|
-
}
|
|
12
|
-
return `${id}:${api}`;
|
|
13
|
-
}
|
|
14
|
-
function notifyState(state) {
|
|
15
|
-
for (const listener of state.listeners) {
|
|
16
|
-
listener();
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function resourceLeaf(api) {
|
|
20
|
-
const parts = api.split('/').filter(Boolean);
|
|
21
|
-
return parts[parts.length - 1] ?? 'record';
|
|
22
|
-
}
|
|
23
|
-
function syncNextId(api, state) {
|
|
24
|
-
const prefix = `${resourceLeaf(api)}-`;
|
|
25
|
-
let max = 0;
|
|
26
|
-
for (const item of state.items) {
|
|
27
|
-
if (!item.id.startsWith(prefix))
|
|
28
|
-
continue;
|
|
29
|
-
const suffix = Number(item.id.slice(prefix.length));
|
|
30
|
-
if (Number.isFinite(suffix) && suffix > max) {
|
|
31
|
-
max = suffix;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
state.nextId = max + 1;
|
|
35
|
-
}
|
|
36
|
-
function createSyntheticId(api, state) {
|
|
37
|
-
const id = `${resourceLeaf(api)}-${state.nextId}`;
|
|
38
|
-
state.nextId += 1;
|
|
39
|
-
return id;
|
|
40
|
-
}
|
|
41
|
-
function createResourceStore(client, api) {
|
|
42
|
-
const state = {
|
|
43
|
-
items: [],
|
|
44
|
-
listeners: new Set(),
|
|
45
|
-
error: null,
|
|
46
|
-
pendingCount: 0,
|
|
47
|
-
resolvedOnce: false,
|
|
48
|
-
inFlightLoad: null,
|
|
49
|
-
nextId: 1,
|
|
50
|
-
};
|
|
51
|
-
async function runMutation(mutate) {
|
|
52
|
-
state.pendingCount += 1;
|
|
53
|
-
state.error = null;
|
|
54
|
-
notifyState(state);
|
|
55
|
-
try {
|
|
56
|
-
const result = await mutate();
|
|
57
|
-
state.resolvedOnce = true;
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
state.error = error;
|
|
62
|
-
state.resolvedOnce = true;
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
finally {
|
|
66
|
-
state.pendingCount = Math.max(0, state.pendingCount - 1);
|
|
67
|
-
notifyState(state);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
subscribe(listener) {
|
|
72
|
-
state.listeners.add(listener);
|
|
73
|
-
return () => {
|
|
74
|
-
state.listeners.delete(listener);
|
|
75
|
-
};
|
|
76
|
-
},
|
|
77
|
-
getSnapshot() {
|
|
78
|
-
return {
|
|
79
|
-
items: state.items,
|
|
80
|
-
error: state.error,
|
|
81
|
-
pendingCount: state.pendingCount,
|
|
82
|
-
resolvedOnce: state.resolvedOnce,
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
getById(id) {
|
|
86
|
-
return state.items.find((item) => item.id === id);
|
|
87
|
-
},
|
|
88
|
-
load(force = false) {
|
|
89
|
-
if (!force && state.resolvedOnce && !state.error) {
|
|
90
|
-
return Promise.resolve(state.items);
|
|
91
|
-
}
|
|
92
|
-
if (state.inFlightLoad) {
|
|
93
|
-
return state.inFlightLoad;
|
|
94
|
-
}
|
|
95
|
-
state.pendingCount += 1;
|
|
96
|
-
state.error = null;
|
|
97
|
-
notifyState(state);
|
|
98
|
-
state.inFlightLoad = client.list(api)
|
|
99
|
-
.then((items) => {
|
|
100
|
-
state.items = [...items];
|
|
101
|
-
state.error = null;
|
|
102
|
-
state.resolvedOnce = true;
|
|
103
|
-
syncNextId(api, state);
|
|
104
|
-
return state.items;
|
|
105
|
-
})
|
|
106
|
-
.catch((error) => {
|
|
107
|
-
state.error = error;
|
|
108
|
-
state.resolvedOnce = true;
|
|
109
|
-
throw error;
|
|
110
|
-
})
|
|
111
|
-
.finally(() => {
|
|
112
|
-
state.pendingCount = Math.max(0, state.pendingCount - 1);
|
|
113
|
-
state.inFlightLoad = null;
|
|
114
|
-
notifyState(state);
|
|
115
|
-
});
|
|
116
|
-
return state.inFlightLoad;
|
|
117
|
-
},
|
|
118
|
-
createItem(input) {
|
|
119
|
-
return runMutation(async () => {
|
|
120
|
-
const created = await client.create(api, input);
|
|
121
|
-
const nextRecord = {
|
|
122
|
-
...created,
|
|
123
|
-
id: String(created.id ?? createSyntheticId(api, state)),
|
|
124
|
-
};
|
|
125
|
-
state.items = [...state.items, nextRecord];
|
|
126
|
-
syncNextId(api, state);
|
|
127
|
-
return nextRecord;
|
|
128
|
-
});
|
|
129
|
-
},
|
|
130
|
-
updateItem(id, input) {
|
|
131
|
-
return runMutation(async () => {
|
|
132
|
-
const current = state.items.find((item) => item.id === id);
|
|
133
|
-
const updated = await client.update(api, id, input);
|
|
134
|
-
const nextRecord = {
|
|
135
|
-
...current,
|
|
136
|
-
...input,
|
|
137
|
-
...updated,
|
|
138
|
-
id: String(updated.id ?? id),
|
|
139
|
-
};
|
|
140
|
-
state.items = state.items.map((item) => item.id === id ? nextRecord : item);
|
|
141
|
-
return nextRecord;
|
|
142
|
-
});
|
|
143
|
-
},
|
|
144
|
-
deleteItem(id) {
|
|
145
|
-
return runMutation(async () => {
|
|
146
|
-
await client.delete(api, id);
|
|
147
|
-
state.items = state.items.filter((item) => item.id !== id);
|
|
148
|
-
});
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
export function getResourceStore(client, api) {
|
|
153
|
-
const key = storeKey(client, api);
|
|
154
|
-
const existing = resourceStores.get(key);
|
|
155
|
-
if (existing)
|
|
156
|
-
return existing;
|
|
157
|
-
const created = createResourceStore(client, api);
|
|
158
|
-
resourceStores.set(key, created);
|
|
159
|
-
return created;
|
|
160
|
-
}
|
|
161
|
-
export function resetResourceStoreTestState() {
|
|
162
|
-
resourceStores.clear();
|
|
163
|
-
nextClientId = 1;
|
|
164
|
-
}
|
|
1
|
+
export { clearResourceStores, getResourceStore, resetResourceStoreTestState, } from '../../../runtime-core/dist/resourceStore.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { matchesResourceTarget } from '../../../runtime-core/dist/resourceTarget.js';
|
|
2
2
|
//# sourceMappingURL=resourceTarget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resourceTarget.d.ts","sourceRoot":"","sources":["../../src/hooks/resourceTarget.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resourceTarget.d.ts","sourceRoot":"","sources":["../../src/hooks/resourceTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC"}
|
|
@@ -1,22 +1 @@
|
|
|
1
|
-
|
|
2
|
-
return target.trim().replace(/^\/+|\/+$/g, '');
|
|
3
|
-
}
|
|
4
|
-
function apiLeaf(api) {
|
|
5
|
-
const normalized = normalizeTarget(api);
|
|
6
|
-
const parts = normalized.split('/').filter(Boolean);
|
|
7
|
-
return parts[parts.length - 1] ?? normalized;
|
|
8
|
-
}
|
|
9
|
-
export function matchesResourceTarget(api, target) {
|
|
10
|
-
if (typeof target !== 'string' || target.trim() === '')
|
|
11
|
-
return false;
|
|
12
|
-
const normalizedTarget = normalizeTarget(target);
|
|
13
|
-
const normalizedApi = normalizeTarget(api);
|
|
14
|
-
const leaf = apiLeaf(api);
|
|
15
|
-
return [
|
|
16
|
-
normalizedApi,
|
|
17
|
-
leaf,
|
|
18
|
-
`${leaf}.list`,
|
|
19
|
-
`resource.${leaf}`,
|
|
20
|
-
`resource.${leaf}.list`,
|
|
21
|
-
].includes(normalizedTarget);
|
|
22
|
-
}
|
|
1
|
+
export { matchesResourceTarget } from '../../../runtime-core/dist/resourceTarget.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { ServerListStore, ServerListStoreClient, ServerListStorePage, ServerListStoreQuery, ServerListStoreSnapshot, } from '../../../runtime-core/dist/serverListStore.js';
|
|
2
|
+
export { clearServerListStores, getServerListStore, resetServerListStoreTestState, } from '../../../runtime-core/dist/serverListStore.js';
|
|
3
|
+
//# sourceMappingURL=serverListStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverListStore.d.ts","sourceRoot":"","sources":["../../src/hooks/serverListStore.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,+CAA+C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { clearServerListStores, getServerListStore, resetServerListStoreTestState, } from '../../../runtime-core/dist/serverListStore.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionCaches.d.ts","sourceRoot":"","sources":["../../src/hooks/sessionCaches.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAKzC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { clearResourceClientCaches } from './resourceClient.js';
|
|
2
|
+
import { clearReadModelStores } from './readModelStore.js';
|
|
3
|
+
import { clearResourceStores } from './resourceStore.js';
|
|
4
|
+
import { clearServerListStores } from './serverListStore.js';
|
|
5
|
+
/**
|
|
6
|
+
* Clears all cached resource data. Call on logout to prevent
|
|
7
|
+
* stale data from one user session leaking into the next.
|
|
8
|
+
*/
|
|
9
|
+
export function clearSessionCaches() {
|
|
10
|
+
clearReadModelStores();
|
|
11
|
+
clearServerListStores();
|
|
12
|
+
clearResourceStores();
|
|
13
|
+
clearResourceClientCaches();
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transitionedSetter.d.ts","sourceRoot":"","sources":["../../src/hooks/transitionedSetter.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAOnG"}
|
package/dist/hooks/useAuth.d.ts
CHANGED
|
@@ -3,8 +3,25 @@ export interface AuthUser {
|
|
|
3
3
|
role?: string;
|
|
4
4
|
[key: string]: unknown;
|
|
5
5
|
}
|
|
6
|
+
export interface AuthSession {
|
|
7
|
+
accessToken: string;
|
|
8
|
+
tokenType?: 'Bearer' | 'bearer' | string;
|
|
9
|
+
}
|
|
10
|
+
export interface AuthLoginProvider {
|
|
11
|
+
id: string;
|
|
12
|
+
label: string;
|
|
13
|
+
}
|
|
6
14
|
export interface AuthState {
|
|
7
15
|
currentUser: AuthUser | null;
|
|
16
|
+
session?: AuthSession | null;
|
|
17
|
+
refreshSession?: (() => Promise<AuthSession | null>) | null;
|
|
18
|
+
onUnauthorized?: (() => void | Promise<void>) | null;
|
|
19
|
+
loginHref?: string | null;
|
|
20
|
+
loginProviders?: AuthLoginProvider[] | null;
|
|
21
|
+
beginLogin?: ((providerId: string) => void | Promise<void>) | null;
|
|
22
|
+
logout?: (() => void | Promise<void>) | null;
|
|
23
|
+
authPending?: boolean | null;
|
|
24
|
+
authError?: string | null;
|
|
8
25
|
}
|
|
9
26
|
interface AuthProviderProps {
|
|
10
27
|
value: AuthState;
|
|
@@ -12,5 +29,6 @@ interface AuthProviderProps {
|
|
|
12
29
|
}
|
|
13
30
|
export declare function AuthProvider({ value, children }: AuthProviderProps): any;
|
|
14
31
|
export declare function useAuth(): AuthState;
|
|
32
|
+
export declare function useAuthAccessToken(): string;
|
|
15
33
|
export {};
|
|
16
34
|
//# sourceMappingURL=useAuth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../src/hooks/useAuth.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,QAAQ;IACvB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;CAC1C;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC7B,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7B,cAAc,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;IAC5D,cAAc,CAAC,EAAE,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;IACrD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,CAAC,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;IAC5C,UAAU,CAAC,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;IACnE,MAAM,CAAC,EAAE,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;IAC7C,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,UAAU,iBAAiB;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AA0BD,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,iBAAiB,OAoBlE;AAED,wBAAgB,OAAO,IAAI,SAAS,CAEnC;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAG3C"}
|
package/dist/hooks/useAuth.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { clearSessionCaches } from './sessionCaches.js';
|
|
3
|
+
import { resolveAuthAccessToken, shouldClearSessionCaches, } from '../../../runtime-core/dist/auth.js';
|
|
2
4
|
const AuthContext = React.createContext(undefined);
|
|
3
5
|
function readGlobalAuth() {
|
|
4
6
|
if (typeof window === 'undefined') {
|
|
@@ -8,13 +10,41 @@ function readGlobalAuth() {
|
|
|
8
10
|
if (value && typeof value === 'object') {
|
|
9
11
|
return {
|
|
10
12
|
currentUser: value.currentUser ?? null,
|
|
13
|
+
session: value.session ?? null,
|
|
14
|
+
refreshSession: value.refreshSession ?? null,
|
|
15
|
+
onUnauthorized: value.onUnauthorized ?? null,
|
|
16
|
+
loginHref: value.loginHref ?? null,
|
|
17
|
+
loginProviders: value.loginProviders ?? null,
|
|
18
|
+
beginLogin: value.beginLogin ?? null,
|
|
19
|
+
logout: value.logout ?? null,
|
|
20
|
+
authPending: value.authPending ?? null,
|
|
21
|
+
authError: value.authError ?? null,
|
|
11
22
|
};
|
|
12
23
|
}
|
|
13
24
|
return { currentUser: null };
|
|
14
25
|
}
|
|
15
26
|
export function AuthProvider({ value, children }) {
|
|
27
|
+
const prevUserIdRef = React.useRef(value.currentUser?.id);
|
|
28
|
+
const prevAccessTokenRef = React.useRef(value.session?.accessToken);
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
const prevId = prevUserIdRef.current;
|
|
31
|
+
const nextId = value.currentUser?.id;
|
|
32
|
+
const prevAccessToken = prevAccessTokenRef.current;
|
|
33
|
+
const nextAccessToken = value.session?.accessToken;
|
|
34
|
+
prevUserIdRef.current = nextId;
|
|
35
|
+
prevAccessTokenRef.current = nextAccessToken;
|
|
36
|
+
// Clear caches when auth identity changes after the initial mount:
|
|
37
|
+
// logout, switch user, or token rotation for the same user.
|
|
38
|
+
if (shouldClearSessionCaches(prevId, nextId, prevAccessToken, nextAccessToken)) {
|
|
39
|
+
clearSessionCaches();
|
|
40
|
+
}
|
|
41
|
+
}, [value.currentUser?.id, value.session?.accessToken]);
|
|
16
42
|
return React.createElement(AuthContext.Provider, { value }, children);
|
|
17
43
|
}
|
|
18
44
|
export function useAuth() {
|
|
19
45
|
return React.useContext(AuthContext) ?? readGlobalAuth();
|
|
20
46
|
}
|
|
47
|
+
export function useAuthAccessToken() {
|
|
48
|
+
const auth = useAuth();
|
|
49
|
+
return resolveAuthAccessToken(auth.session);
|
|
50
|
+
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
totalPages: number;
|
|
4
|
-
}
|
|
5
|
-
export interface CollectionSortState {
|
|
6
|
-
field: string;
|
|
7
|
-
direction: 'asc' | 'desc';
|
|
8
|
-
}
|
|
1
|
+
import type { CollectionPaginationState, CollectionSortState } from '../../../runtime-core/dist/collectionView.js';
|
|
2
|
+
export type { CollectionPaginationState, CollectionSortState, } from '../../../runtime-core/dist/collectionView.js';
|
|
9
3
|
export interface UseCollectionViewOptions {
|
|
10
4
|
pageSize?: number;
|
|
11
5
|
paginate?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCollectionView.d.ts","sourceRoot":"","sources":["../../src/hooks/useCollectionView.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCollectionView.d.ts","sourceRoot":"","sources":["../../src/hooks/useCollectionView.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,8CAA8C,CAAC;AACtD,YAAY,EACV,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,8CAA8C,CAAC;AAEtD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;IAC/D,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;IACnD,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,KAAK,IAAI,CAAC;IACpD,UAAU,EAAE,yBAAyB,CAAC;IACtC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EACxD,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,OAAO,GAAE,wBAA6B,GACrC,uBAAuB,CAAC,CAAC,CAAC,CAmD5B"}
|
|
@@ -1,46 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
if (typeof left === 'number' && typeof right === 'number') {
|
|
4
|
-
return left - right;
|
|
5
|
-
}
|
|
6
|
-
return String(left ?? '').localeCompare(String(right ?? ''));
|
|
7
|
-
}
|
|
8
|
-
function filterItems(items, filters) {
|
|
9
|
-
return items.filter((item) => Object.entries(filters).every(([key, rawFilter]) => {
|
|
10
|
-
const filterValue = rawFilter.trim();
|
|
11
|
-
if (filterValue === '')
|
|
12
|
-
return true;
|
|
13
|
-
const value = item[key];
|
|
14
|
-
return String(value ?? '').toLowerCase().includes(filterValue.toLowerCase());
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
17
|
-
function sortItems(items, sort) {
|
|
18
|
-
if (!sort)
|
|
19
|
-
return [...items];
|
|
20
|
-
const sorted = [...items];
|
|
21
|
-
sorted.sort((left, right) => {
|
|
22
|
-
const comparison = compareValues(left[sort.field], right[sort.field]);
|
|
23
|
-
return sort.direction === 'asc' ? comparison : comparison * -1;
|
|
24
|
-
});
|
|
25
|
-
return sorted;
|
|
26
|
-
}
|
|
2
|
+
import { filterCollectionItems, paginateCollectionItems, sortCollectionItems, } from '../../../runtime-core/dist/collectionView.js';
|
|
27
3
|
export function useCollectionView(items, options = {}) {
|
|
28
4
|
const pageSize = options.pageSize ?? 20;
|
|
29
5
|
const paginate = options.paginate ?? true;
|
|
30
6
|
const [filters, setFiltersState] = React.useState({});
|
|
31
7
|
const [sort, setSortState] = React.useState(null);
|
|
32
8
|
const [page, setPage] = React.useState(1);
|
|
33
|
-
const filteredItems = React.useMemo(() =>
|
|
34
|
-
const sortedItems = React.useMemo(() =>
|
|
35
|
-
const
|
|
36
|
-
const currentPage =
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
return sortedItems;
|
|
40
|
-
}
|
|
41
|
-
const start = (currentPage - 1) * pageSize;
|
|
42
|
-
return sortedItems.slice(start, start + pageSize);
|
|
43
|
-
}, [currentPage, pageSize, paginate, sortedItems]);
|
|
9
|
+
const filteredItems = React.useMemo(() => filterCollectionItems(items, filters), [items, filters]);
|
|
10
|
+
const sortedItems = React.useMemo(() => sortCollectionItems(filteredItems, sort), [filteredItems, sort]);
|
|
11
|
+
const paged = React.useMemo(() => paginateCollectionItems(sortedItems, page, pageSize, paginate), [page, pageSize, paginate, sortedItems]);
|
|
12
|
+
const currentPage = paged.page;
|
|
13
|
+
const totalPages = paged.totalPages;
|
|
14
|
+
const data = paged.data;
|
|
44
15
|
React.useEffect(() => {
|
|
45
16
|
if (currentPage !== page) {
|
|
46
17
|
setPage(currentPage);
|
|
@@ -67,6 +38,7 @@ export function useCollectionView(items, options = {}) {
|
|
|
67
38
|
pagination: {
|
|
68
39
|
page: currentPage,
|
|
69
40
|
totalPages,
|
|
41
|
+
totalItems: paged.totalItems,
|
|
70
42
|
},
|
|
71
43
|
setPagination,
|
|
72
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDocumentMetadata.d.ts","sourceRoot":"","sources":["../../src/hooks/useDocumentMetadata.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"useDocumentMetadata.d.ts","sourceRoot":"","sources":["../../src/hooks/useDocumentMetadata.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAmDpE"}
|
|
@@ -6,6 +6,15 @@ export function useDocumentMetadata(metadata) {
|
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
const resolvedTitle = applyTitleTemplate(metadata.title, metadata.defaultTitle ?? null, metadata.titleTemplate ?? null);
|
|
9
|
+
const previousTitle = document.title;
|
|
10
|
+
const previousDescription = snapshotHeadElement(`meta[name="description"]`);
|
|
11
|
+
const previousRobots = snapshotHeadElement(`meta[name="robots"]`);
|
|
12
|
+
const previousOgTitle = snapshotHeadElement(`meta[property="og:title"]`);
|
|
13
|
+
const previousOgDescription = snapshotHeadElement(`meta[property="og:description"]`);
|
|
14
|
+
const previousOgImage = snapshotHeadElement(`meta[property="og:image"]`);
|
|
15
|
+
const previousOgSiteName = snapshotHeadElement(`meta[property="og:site_name"]`);
|
|
16
|
+
const previousCanonical = snapshotHeadElement('link[rel="canonical"]');
|
|
17
|
+
const previousFavicon = snapshotHeadElement('link[rel="icon"]');
|
|
9
18
|
if (resolvedTitle) {
|
|
10
19
|
document.title = resolvedTitle;
|
|
11
20
|
}
|
|
@@ -17,6 +26,17 @@ export function useDocumentMetadata(metadata) {
|
|
|
17
26
|
setPropertyMeta('og:site_name', metadata.siteName ?? null);
|
|
18
27
|
setCanonicalHref(metadata.canonicalPath ?? null);
|
|
19
28
|
setFaviconHref(metadata.favicon ?? null);
|
|
29
|
+
return () => {
|
|
30
|
+
document.title = previousTitle;
|
|
31
|
+
restoreHeadElement(previousDescription);
|
|
32
|
+
restoreHeadElement(previousRobots);
|
|
33
|
+
restoreHeadElement(previousOgTitle);
|
|
34
|
+
restoreHeadElement(previousOgDescription);
|
|
35
|
+
restoreHeadElement(previousOgImage);
|
|
36
|
+
restoreHeadElement(previousOgSiteName);
|
|
37
|
+
restoreHeadElement(previousCanonical);
|
|
38
|
+
restoreHeadElement(previousFavicon);
|
|
39
|
+
};
|
|
20
40
|
}, [
|
|
21
41
|
metadata.title,
|
|
22
42
|
metadata.defaultTitle,
|
|
@@ -39,6 +59,43 @@ function applyTitleTemplate(title, defaultTitle, titleTemplate) {
|
|
|
39
59
|
}
|
|
40
60
|
return titleTemplate.replace(/\{title\}/g, effectiveTitle);
|
|
41
61
|
}
|
|
62
|
+
function snapshotHeadElement(selector) {
|
|
63
|
+
const element = document.head.querySelector(selector);
|
|
64
|
+
if (!element) {
|
|
65
|
+
return {
|
|
66
|
+
selector,
|
|
67
|
+
tagName: selector.startsWith('link[') ? 'link' : 'meta',
|
|
68
|
+
attributes: {},
|
|
69
|
+
existed: false,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
selector,
|
|
74
|
+
tagName: element.tagName.toLowerCase(),
|
|
75
|
+
attributes: readElementAttributes(element),
|
|
76
|
+
existed: true,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function restoreHeadElement(snapshot) {
|
|
80
|
+
const existing = document.head.querySelector(snapshot.selector);
|
|
81
|
+
if (!snapshot.existed) {
|
|
82
|
+
existing?.remove();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const element = existing ?? document.createElement(snapshot.tagName);
|
|
86
|
+
for (const [name, value] of Object.entries(snapshot.attributes)) {
|
|
87
|
+
element.setAttribute(name, value);
|
|
88
|
+
}
|
|
89
|
+
if (!existing) {
|
|
90
|
+
document.head.appendChild(element);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function readElementAttributes(element) {
|
|
94
|
+
return Array.from(element.attributes).reduce((attributes, attribute) => {
|
|
95
|
+
attributes[attribute.name] = attribute.value;
|
|
96
|
+
return attributes;
|
|
97
|
+
}, {});
|
|
98
|
+
}
|
|
42
99
|
function setNamedMeta(name, content) {
|
|
43
100
|
const selector = `meta[name="${name}"]`;
|
|
44
101
|
let element = document.head.querySelector(selector);
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
+
import type { GroupedCollectionViewGroup } from '../../../runtime-core/dist/collectionView.js';
|
|
2
|
+
export type { GroupedCollectionViewGroup } from '../../../runtime-core/dist/collectionView.js';
|
|
1
3
|
import type { CollectionPaginationState, CollectionSortState } from './useCollectionView.js';
|
|
2
|
-
export interface GroupedCollectionViewGroup<T extends {
|
|
3
|
-
id: string;
|
|
4
|
-
}> {
|
|
5
|
-
id: string;
|
|
6
|
-
values: Record<string, unknown>;
|
|
7
|
-
rows: T[];
|
|
8
|
-
}
|
|
9
4
|
export interface UseGroupedCollectionViewOptions {
|
|
10
5
|
pageSize?: number;
|
|
11
6
|
paginate?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGroupedCollectionView.d.ts","sourceRoot":"","sources":["../../src/hooks/useGroupedCollectionView.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGroupedCollectionView.d.ts","sourceRoot":"","sources":["../../src/hooks/useGroupedCollectionView.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC/F,YAAY,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC/F,OAAO,KAAK,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7F,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,8BAA8B,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;IACtE,MAAM,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,SAAS,EAAE,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACjC,OAAO,EAAE,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,KAAK,IAAI,CAAC;IACpD,UAAU,EAAE,yBAAyB,CAAC;IACtC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED,wBAAgB,wBAAwB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAC/D,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,OAAO,GAAE,+BAAoC,GAC5C,8BAA8B,CAAC,CAAC,CAAC,CA2CnC"}
|
|
@@ -1,61 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
if (typeof left === 'number' && typeof right === 'number') {
|
|
4
|
-
return left - right;
|
|
5
|
-
}
|
|
6
|
-
return String(left ?? '').localeCompare(String(right ?? ''));
|
|
7
|
-
}
|
|
8
|
-
function sortItems(items, sort) {
|
|
9
|
-
if (!sort)
|
|
10
|
-
return [...items];
|
|
11
|
-
const sorted = [...items];
|
|
12
|
-
sorted.sort((left, right) => {
|
|
13
|
-
const comparison = compareValues(left[sort.field], right[sort.field]);
|
|
14
|
-
return sort.direction === 'asc' ? comparison : comparison * -1;
|
|
15
|
-
});
|
|
16
|
-
return sorted;
|
|
17
|
-
}
|
|
18
|
-
function groupItems(items, groupBy) {
|
|
19
|
-
if (groupBy.length === 0) {
|
|
20
|
-
return items.map((item) => ({
|
|
21
|
-
id: String(item.id),
|
|
22
|
-
values: {},
|
|
23
|
-
rows: [item],
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
const groups = new Map();
|
|
27
|
-
for (const item of items) {
|
|
28
|
-
const values = Object.fromEntries(groupBy.map((field) => [field, item[field]]));
|
|
29
|
-
const id = JSON.stringify(groupBy.map((field) => [field, values[field]]));
|
|
30
|
-
const existing = groups.get(id);
|
|
31
|
-
if (existing) {
|
|
32
|
-
existing.rows.push(item);
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
groups.set(id, {
|
|
36
|
-
id,
|
|
37
|
-
values,
|
|
38
|
-
rows: [item],
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return Array.from(groups.values());
|
|
42
|
-
}
|
|
2
|
+
import { groupCollectionItems, paginateCollectionItems, sortCollectionItems, } from '../../../runtime-core/dist/collectionView.js';
|
|
43
3
|
export function useGroupedCollectionView(items, groupBy, options = {}) {
|
|
44
4
|
const pageSize = options.pageSize ?? 20;
|
|
45
5
|
const paginate = options.paginate ?? true;
|
|
46
6
|
const [sort, setSortState] = React.useState(null);
|
|
47
7
|
const [page, setPage] = React.useState(1);
|
|
48
|
-
const sortedItems = React.useMemo(() =>
|
|
49
|
-
const allGroups = React.useMemo(() =>
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
return allGroups;
|
|
55
|
-
}
|
|
56
|
-
const start = (currentPage - 1) * pageSize;
|
|
57
|
-
return allGroups.slice(start, start + pageSize);
|
|
58
|
-
}, [allGroups, currentPage, pageSize, paginate]);
|
|
8
|
+
const sortedItems = React.useMemo(() => sortCollectionItems(items, sort), [items, sort]);
|
|
9
|
+
const allGroups = React.useMemo(() => groupCollectionItems(sortedItems, groupBy), [sortedItems, groupBy]);
|
|
10
|
+
const paged = React.useMemo(() => paginateCollectionItems(allGroups, page, pageSize, paginate), [allGroups, page, pageSize, paginate]);
|
|
11
|
+
const totalPages = paged.totalPages;
|
|
12
|
+
const currentPage = paged.page;
|
|
13
|
+
const groups = paged.data;
|
|
59
14
|
React.useEffect(() => {
|
|
60
15
|
if (currentPage !== page) {
|
|
61
16
|
setPage(currentPage);
|
|
@@ -76,6 +31,7 @@ export function useGroupedCollectionView(items, groupBy, options = {}) {
|
|
|
76
31
|
pagination: {
|
|
77
32
|
page: currentPage,
|
|
78
33
|
totalPages,
|
|
34
|
+
totalItems: paged.totalItems,
|
|
79
35
|
},
|
|
80
36
|
setPagination,
|
|
81
37
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { I18nBundle, I18nMessage, I18nMessageValue } from '../../../runtime-core/dist/i18n.js';
|
|
2
|
+
export type { I18nBundle, I18nMessage, I18nMessageDescriptor, I18nMessageValue, } from '../../../runtime-core/dist/i18n.js';
|
|
3
|
+
export interface I18nState {
|
|
4
|
+
locale: string;
|
|
5
|
+
messages?: I18nBundle;
|
|
6
|
+
setLocale?: (locale: string) => void | Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
interface I18nProviderProps {
|
|
9
|
+
value: I18nState;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export declare function resolveMessageText<TValue = I18nMessageValue>(message: I18nMessage | unknown, fallback?: string): string;
|
|
13
|
+
export declare function resolveMessageTextWithBundle<TValue = I18nMessageValue>(message: I18nMessage | unknown, messages?: I18nBundle, fallback?: string): string;
|
|
14
|
+
export declare function humanizeEnumValue(value: string): string;
|
|
15
|
+
export declare function resolveEnumValueText(value: string, keyPrefix?: string, labels?: Record<string, string>): string;
|
|
16
|
+
export declare function resolveUnknownEnumValue(value: unknown, keyPrefix?: string, labels?: Record<string, string>): string;
|
|
17
|
+
export declare function buildEnumValueRenderer(keyPrefix?: string, labels?: Record<string, string>): (value: unknown) => string;
|
|
18
|
+
export declare function resolveWorkflowStepMessage(message: I18nMessage | unknown, step: unknown, fallback?: string | null): string | null;
|
|
19
|
+
export declare function I18nProvider({ value, children }: I18nProviderProps): any;
|
|
20
|
+
export declare function useI18n(): I18nState;
|
|
21
|
+
//# sourceMappingURL=useI18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../src/hooks/useI18n.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EAEX,gBAAgB,EACjB,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EACV,UAAU,EACV,WAAW,EACX,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,oCAAoC,CAAC;AAE5C,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD;AAED,UAAU,iBAAiB;IACzB,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAMD,wBAAgB,kBAAkB,CAAC,MAAM,GAAG,gBAAgB,EAC1D,OAAO,EAAE,WAAW,GAAG,OAAO,EAC9B,QAAQ,SAAK,GACZ,MAAM,CAER;AAED,wBAAgB,4BAA4B,CAAC,MAAM,GAAG,gBAAgB,EACpE,OAAO,EAAE,WAAW,GAAG,OAAO,EAC9B,QAAQ,CAAC,EAAE,UAAU,EACrB,QAAQ,SAAK,GACZ,MAAM,CAER;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CAER;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,MAAM,CAER;AAED,wBAAgB,sBAAsB,CACpC,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAE5B;AASD,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,WAAW,GAAG,OAAO,EAC9B,IAAI,EAAE,OAAO,EACb,QAAQ,GAAE,MAAM,GAAG,IAAS,GAC3B,MAAM,GAAG,IAAI,CAwBf;AAED,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,iBAAiB,OAwBlE;AAED,wBAAgB,OAAO,IAAI,SAAS,CAKnC"}
|