@mdbase-dev/ui 0.2.0 → 0.2.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.
|
@@ -10,7 +10,7 @@ import { ActionButton, CollectionMark, GateFooter, ItemCopy, ItemMore, NoticeBlo
|
|
|
10
10
|
import { SetupReview } from "./SetupReview.js";
|
|
11
11
|
import { BringInBanner, UnsyncedLine } from "./UnsyncedWork.js";
|
|
12
12
|
import { unsyncedApi } from "./unsynced.js";
|
|
13
|
-
import { useAutoStart, useCollectionUi } from "./use-collection-ui.js";
|
|
13
|
+
import { cancelAuthorizationApi, useAutoStart, useCollectionUi } from "./use-collection-ui.js";
|
|
14
14
|
/**
|
|
15
15
|
* Everything before a collection is open: sign-in, choosing, approval, setup
|
|
16
16
|
* review and problems. In phase `ready` it renders the app, with a banner
|
|
@@ -299,18 +299,25 @@ function GateBody({
|
|
|
299
299
|
})]
|
|
300
300
|
});
|
|
301
301
|
case "authorizing":
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
302
|
+
{
|
|
303
|
+
// Signing in from work before connecting: cancelling goes back to it.
|
|
304
|
+
const unsynced = view.purpose === "sign_in" && ui.options.unsynced && unsyncedApi(ui.options.mdbase);
|
|
305
|
+
const cancellable = cancelAuthorizationApi(ui.options.mdbase) !== null || busy === "sign_in" || busy === "add" || busy === "approve";
|
|
306
|
+
return _jsxs("div", {
|
|
307
|
+
className: "mdbase-collections-actions",
|
|
308
|
+
children: [_jsx(ActionButton, {
|
|
309
|
+
tone: "secondary",
|
|
310
|
+
inert: busy === "cancel",
|
|
311
|
+
onClick: actions.reopen,
|
|
312
|
+
children: copy.openWindowAgain
|
|
313
|
+
}), cancellable && _jsx(ActionButton, {
|
|
314
|
+
tone: "quiet",
|
|
315
|
+
inert: busy === "cancel",
|
|
316
|
+
onClick: actions.cancel,
|
|
317
|
+
children: unsynced ? copy.continueWithoutConnecting : copy.cancel
|
|
318
|
+
})]
|
|
319
|
+
});
|
|
320
|
+
}
|
|
314
321
|
case "choosing":
|
|
315
322
|
return _jsxs(_Fragment, {
|
|
316
323
|
children: [view.notice && _jsx(NoticeBlock, {
|
|
@@ -97,7 +97,7 @@ export interface CollectionUiOptions {
|
|
|
97
97
|
readonly unsynced?: CollectionUnsyncedOptions | boolean | undefined;
|
|
98
98
|
}
|
|
99
99
|
/** `add_private` remains available to legacy track callers; both add APIs now emit `add`. */
|
|
100
|
-
export type CollectionActionName = "sign_in" | "add" | "add_private" | "approve" | "select" | "choose_another" | "assess" | "start" | "sign_out" | "setup" | "open_unsynced" | "bring_in" | "discard_unsynced";
|
|
100
|
+
export type CollectionActionName = "sign_in" | "add" | "add_private" | "approve" | "select" | "choose_another" | "assess" | "start" | "sign_out" | "setup" | "open_unsynced" | "bring_in" | "discard_unsynced" | "cancel";
|
|
101
101
|
export interface CollectionUi {
|
|
102
102
|
readonly view: CollectionView;
|
|
103
103
|
readonly copy: CollectionCopy;
|
|
@@ -130,7 +130,9 @@ export interface CollectionActions {
|
|
|
130
130
|
chooseAnother(): void;
|
|
131
131
|
/** Open the Connect window again for the authorization in progress. */
|
|
132
132
|
reopen(): void;
|
|
133
|
-
/**
|
|
133
|
+
/** Stop waiting for Connect: signed out again (or back to work before
|
|
134
|
+
* connecting), or the collection list when signed in. On an SDK without
|
|
135
|
+
* `cancelAuthorization` it only abandons the call this page started. */
|
|
134
136
|
cancel(): void;
|
|
135
137
|
assess(): void;
|
|
136
138
|
start(): void;
|
|
@@ -153,6 +155,15 @@ export interface CollectionActions {
|
|
|
153
155
|
discardUnsynced(): void;
|
|
154
156
|
dismissUnsyncedNotice(): void;
|
|
155
157
|
}
|
|
158
|
+
type CancelAuthorization = (options: {
|
|
159
|
+
readonly signal?: AbortSignal;
|
|
160
|
+
}) => Promise<unknown>;
|
|
161
|
+
/**
|
|
162
|
+
* `mdbase.cancelAuthorization`, or null on an SDK release that predates it.
|
|
163
|
+
* Read structurally because this package builds against the vendored
|
|
164
|
+
* production SDK; drop it once that SDK and the peer floor include it.
|
|
165
|
+
*/
|
|
166
|
+
export declare function cancelAuthorizationApi(mdbase: Mdbase): CancelAuthorization | null;
|
|
156
167
|
/** The first current item across the app's sections. */
|
|
157
168
|
export declare function appOpenItem(sections: readonly CollectionSection[] | undefined): OpenSectionItem | null;
|
|
158
169
|
/**
|
|
@@ -163,3 +174,4 @@ export declare function appOpenItem(sections: readonly CollectionSection[] | und
|
|
|
163
174
|
export declare function useAutoStart(mdbase: Mdbase, enabled?: boolean): void;
|
|
164
175
|
/** Subscribe to the app's mdbase entry and get its view plus gesture-safe actions. */
|
|
165
176
|
export declare function useCollectionUi(options: CollectionUiOptions): CollectionUi;
|
|
177
|
+
export {};
|
|
@@ -5,6 +5,15 @@ import { defaultCollectionCopy, fill } from "./copy.js";
|
|
|
5
5
|
import { actionNotice, collectionView } from "./model.js";
|
|
6
6
|
import { planNeedsReview, unsyncedApi } from "./unsynced.js";
|
|
7
7
|
const popupActions = new Set(["sign_in", "add", "add_private", "approve"]);
|
|
8
|
+
/**
|
|
9
|
+
* `mdbase.cancelAuthorization`, or null on an SDK release that predates it.
|
|
10
|
+
* Read structurally because this package builds against the vendored
|
|
11
|
+
* production SDK; drop it once that SDK and the peer floor include it.
|
|
12
|
+
*/
|
|
13
|
+
export function cancelAuthorizationApi(mdbase) {
|
|
14
|
+
const cancel = mdbase.cancelAuthorization;
|
|
15
|
+
return typeof cancel === "function" ? options => cancel.call(mdbase, options) : null;
|
|
16
|
+
}
|
|
8
17
|
/** The first current item across the app's sections. */
|
|
9
18
|
export function appOpenItem(sections) {
|
|
10
19
|
for (const section of sections ?? []) {
|
|
@@ -224,6 +233,10 @@ export function useCollectionUi(options) {
|
|
|
224
233
|
cancel: () => {
|
|
225
234
|
const current = running.current;
|
|
226
235
|
if (current && popupActions.has(current.name)) current.controller.abort();
|
|
236
|
+
const cancel = cancelAuthorizationApi(mdbase);
|
|
237
|
+
if (cancel) void run("cancel", signal => cancel({
|
|
238
|
+
signal
|
|
239
|
+
}), true);
|
|
227
240
|
},
|
|
228
241
|
assess: () => {
|
|
229
242
|
void run("assess", signal => mdbase.assess({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdbase-dev/ui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -258,6 +258,6 @@
|
|
|
258
258
|
"typecheck": "node scripts/compile-catalogues.mjs && tsc -p tsconfig.json --noEmit"
|
|
259
259
|
},
|
|
260
260
|
"mdbaseRelease": {
|
|
261
|
-
"commit": "
|
|
261
|
+
"commit": "884f642bf70a59990cc82c7bc0abdfcf248021aa"
|
|
262
262
|
}
|
|
263
263
|
}
|