@arraypress/extension-kit 1.2.0 → 1.3.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 +100 -17
- package/bin/extension-kit.js +46 -10
- package/package.json +1 -1
- package/src/build/index.d.ts +4 -2
- package/src/build/index.js +6 -2
- package/src/build/store-frame.d.ts +176 -0
- package/src/build/store-frame.js +241 -0
- package/src/build/test-build.d.ts +85 -0
- package/src/build/test-build.js +82 -0
- package/src/build/toolbar-icons.d.ts +36 -18
- package/src/build/toolbar-icons.js +91 -24
- package/src/build/vendor.d.ts +78 -8
- package/src/build/vendor.js +133 -10
- package/src/build/zip.d.ts +3 -2
- package/src/build/zip.js +6 -4
- package/src/dom/focus.d.ts +28 -0
- package/src/dom/focus.js +36 -0
- package/src/dom/setup.d.ts +54 -0
- package/src/dom/setup.js +46 -0
- package/src/index.d.ts +8 -1
- package/src/index.js +7 -1
- package/src/sites/sites.d.ts +82 -0
- package/src/sites/sites.js +128 -0
- package/src/styles/chrome-ui.css +13 -6
- package/src/testing/browser.d.ts +52 -0
- package/src/testing/browser.js +79 -0
- package/src/testing/e2e.d.ts +18 -5
- package/src/testing/e2e.js +17 -5
- package/src/testing/index.d.ts +8 -3
- package/src/testing/index.js +10 -3
- package/src/testing/pool.d.ts +23 -0
- package/src/testing/pool.js +33 -0
- package/src/testing/time.d.ts +35 -0
- package/src/testing/time.js +46 -0
- package/src/ui/menu.d.ts +13 -6
- package/src/ui/menu.js +11 -7
- package/src/ui/site-list.d.ts +199 -0
- package/src/ui/site-list.js +194 -0
- package/src/ui/text-dialog.js +3 -1
- package/src/ui/toast.d.ts +25 -9
- package/src/ui/toast.js +25 -11
package/src/ui/toast.js
CHANGED
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
* after a delete: "Deleted “Research” Undo". One per page, made by
|
|
4
4
|
* {@link createToast}; a new message replaces the last and restarts the wait.
|
|
5
5
|
*
|
|
6
|
+
* It's a manual `popover`, so it shows in the top layer: over anything the
|
|
7
|
+
* page stacks (a content script's toast over a site's own fixed bars), and
|
|
8
|
+
* never clipped by an ancestor.
|
|
9
|
+
*
|
|
6
10
|
* @module ui/toast
|
|
7
11
|
*/
|
|
8
12
|
|
|
13
|
+
import { rootDocument } from '../dom/focus.js';
|
|
14
|
+
|
|
9
15
|
/** How long chrome://bookmarks shows a toast (its cr-toast-manager's `duration`), in ms. */
|
|
10
16
|
export const TOAST_MS = 10_000;
|
|
11
17
|
|
|
@@ -16,38 +22,44 @@ export const TOAST_MS = 10_000;
|
|
|
16
22
|
* @property {string} [undoLabel] The undo button's text. Default "Undo".
|
|
17
23
|
* @property {number} [duration] How long a toast stays, in ms. Default {@link TOAST_MS}.
|
|
18
24
|
* @property {number} [undoDuration] How long one with Undo stays. Default `duration`.
|
|
19
|
-
* @property {
|
|
25
|
+
* @property {ParentNode} [root] Where the toast goes: an element, or a shadow root (a content
|
|
26
|
+
* script's). Default the page's `body`.
|
|
27
|
+
* @property {Document} [doc] The page. Default `root`'s document, else `document`.
|
|
20
28
|
*/
|
|
21
29
|
|
|
22
30
|
/**
|
|
23
31
|
* A page's toast.
|
|
24
32
|
*
|
|
25
33
|
* @typedef {object} Toast
|
|
26
|
-
* @property {HTMLElement} element The `#toast` element (`role="status"`), in
|
|
34
|
+
* @property {HTMLElement} element The `#toast` element (`role="status"`, `popover="manual"`), in
|
|
35
|
+
* `root`; `:popover-open` while it shows.
|
|
27
36
|
* @property {(text: string, undo?: (() => unknown) | null) => void} show Show `text`, with an Undo
|
|
28
37
|
* button that hides the toast and runs `undo` when one is given.
|
|
29
38
|
* @property {() => void} hide Take it down (and its Undo with it).
|
|
30
39
|
*/
|
|
31
40
|
|
|
32
41
|
/**
|
|
33
|
-
* Make the page's toast: `<div id="toast" class="toast" role="status"
|
|
34
|
-
* `#toast-text` and an Undo button `#toast-undo`,
|
|
35
|
-
* when the page loads, so screen readers know the
|
|
42
|
+
* Make the page's toast: `<div id="toast" class="toast" role="status"
|
|
43
|
+
* popover="manual">` with `#toast-text` and an Undo button `#toast-undo`,
|
|
44
|
+
* closed until shown. Make it when the page loads, so screen readers know the
|
|
45
|
+
* live region before it speaks.
|
|
36
46
|
*
|
|
37
|
-
* @param {ToastOptions} [options] - The Undo text, how long it stays, and
|
|
47
|
+
* @param {ToastOptions} [options] - The Undo text, how long it stays, and where it goes.
|
|
38
48
|
* @returns {Toast} The toast.
|
|
39
49
|
* @example
|
|
40
50
|
* const toast = createToast();
|
|
41
51
|
* await deleteWorkspace(workspace);
|
|
42
52
|
* toast.show(`Deleted “${workspace.name}”`, () => restore(workspace));
|
|
53
|
+
* // In a content script's shadow root:
|
|
54
|
+
* createToast({ root: host.attachShadow({ mode: 'open' }), duration: 4000 });
|
|
43
55
|
*/
|
|
44
|
-
export function createToast({ undoLabel = 'Undo', duration = TOAST_MS, undoDuration = duration, doc =
|
|
56
|
+
export function createToast({ undoLabel = 'Undo', duration = TOAST_MS, undoDuration = duration, root, doc = rootDocument(root) } = {}) {
|
|
45
57
|
const toast = doc.createElement('div');
|
|
46
58
|
toast.id = 'toast';
|
|
47
59
|
toast.className = 'toast';
|
|
48
60
|
toast.setAttribute('role', 'status');
|
|
49
61
|
toast.setAttribute('aria-live', 'polite');
|
|
50
|
-
toast.
|
|
62
|
+
toast.popover = 'manual';
|
|
51
63
|
const text = doc.createElement('span');
|
|
52
64
|
text.id = 'toast-text';
|
|
53
65
|
const undoButton = doc.createElement('button');
|
|
@@ -56,7 +68,7 @@ export function createToast({ undoLabel = 'Undo', duration = TOAST_MS, undoDurat
|
|
|
56
68
|
undoButton.textContent = undoLabel;
|
|
57
69
|
undoButton.hidden = true;
|
|
58
70
|
toast.append(text, undoButton);
|
|
59
|
-
doc.body.append(toast);
|
|
71
|
+
(root ?? doc.body).append(toast);
|
|
60
72
|
|
|
61
73
|
/** @type {ReturnType<typeof setTimeout> | undefined} */
|
|
62
74
|
let timer;
|
|
@@ -65,7 +77,7 @@ export function createToast({ undoLabel = 'Undo', duration = TOAST_MS, undoDurat
|
|
|
65
77
|
|
|
66
78
|
const hide = () => {
|
|
67
79
|
clearTimeout(timer);
|
|
68
|
-
toast.
|
|
80
|
+
toast.togglePopover(false);
|
|
69
81
|
undoLast = null;
|
|
70
82
|
};
|
|
71
83
|
undoButton.addEventListener('click', () => {
|
|
@@ -81,7 +93,9 @@ export function createToast({ undoLabel = 'Undo', duration = TOAST_MS, undoDurat
|
|
|
81
93
|
text.textContent = message;
|
|
82
94
|
undoButton.hidden = !undo;
|
|
83
95
|
undoLast = undo;
|
|
84
|
-
|
|
96
|
+
// Hidden and shown again, so it's the newest in the top layer (over a popover since).
|
|
97
|
+
toast.togglePopover(false);
|
|
98
|
+
toast.togglePopover(true);
|
|
85
99
|
timer = setTimeout(hide, undo ? undoDuration : duration);
|
|
86
100
|
},
|
|
87
101
|
hide,
|