@monster-orange/den-ui 0.6.6 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monster-orange/den-ui",
3
- "version": "0.6.6",
3
+ "version": "0.7.1",
4
4
  "description": "Den's UI kit: tokens, fonts and shared components, framework-free",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -40,6 +40,13 @@
40
40
  },
41
41
  "./inventory/reference/*": "./inventory/reference/*"
42
42
  },
43
+ "imports": {
44
+ "#den-ui-fonts-dir": {
45
+ "import": "./inventory/fonts-dir.mjs",
46
+ "require": "./inventory/fonts-dir.cjs",
47
+ "default": "./inventory/fonts-dir.mjs"
48
+ }
49
+ },
43
50
  "files": [
44
51
  "src/",
45
52
  "inventory/",
package/src/kit.d.ts CHANGED
@@ -6,16 +6,48 @@ import type {
6
6
  Progress,
7
7
  configureBusy,
8
8
  } from "./busy.js";
9
- import type { HydrateOptions, Shell } from "./shell-client.js";
9
+ import type {
10
+ AccountHydrateOptions,
11
+ AppearanceHandle,
12
+ AppearanceHydrateOptions,
13
+ setWaiting,
14
+ hydrateAppearance,
15
+ BellHandle,
16
+ BellHydrateOptions,
17
+ HydrateOptions,
18
+ ScopeHandle,
19
+ ScopeHydrateOptions,
20
+ SearchHandle,
21
+ SearchHydrateOptions,
22
+ Shell,
23
+ hydrateAccount,
24
+ attachMenuFilter,
25
+ hydrateBell,
26
+ hydrateScope,
27
+ hydrateSearch,
28
+ } from "./shell-client.js";
10
29
  import type {
11
30
  ShellModel,
12
31
  shellHtml,
13
32
  topBarHtml,
33
+ markHtml,
14
34
  railHtml,
15
35
  navItemHtml,
16
36
  versionChipHtml,
17
37
  reportButtonHtml,
18
38
  reportPrefillOf,
39
+ scopeHtml,
40
+ scopeCrumbHtml,
41
+ searchHtml,
42
+ bellButtonHtml,
43
+ bellPanelHtml,
44
+ accountHtml,
45
+ accountWho,
46
+ accountMenuHtml,
47
+ settingsHtml,
48
+ appearanceButtonHtml,
49
+ appearanceMenuHtml,
50
+ waitingHtml,
19
51
  icon,
20
52
  esc,
21
53
  } from "./shell-html.js";
@@ -52,6 +84,25 @@ export interface KitHydrateOptions extends HydrateOptions {
52
84
  versionChip?: boolean;
53
85
  /** false: no [data-den-report] clicks or ⌘⇧F. */
54
86
  report?: boolean;
87
+ /** 0.7.0: the scope crumbs' menus (false: not wired). */
88
+ scope?: ScopeHydrateOptions | false;
89
+ /** 0.7.0: the search field (false: not wired). */
90
+ search?: SearchHydrateOptions | false;
91
+ /** 0.7.0: the bell and its panel (false: not wired). */
92
+ bell?: Omit<BellHydrateOptions, "lang"> | false;
93
+ /** 0.7.0: the account entry as an action (false: not wired). */
94
+ account?: Omit<AccountHydrateOptions, "lang"> | false;
95
+ /** 0.7.0: ◐ ▾ and its menu (wired when given). */
96
+ appearance?: Omit<AppearanceHydrateOptions, "lang">;
97
+ }
98
+ /** The shell hydrate returns: the 0.7.0 pieces it found and wired. */
99
+ export interface KitShell extends Shell {
100
+ scope?: ScopeHandle;
101
+ search?: SearchHandle;
102
+ bell?: BellHandle;
103
+ appearance?: AppearanceHandle;
104
+ /** The account entry's menu, when it has one. */
105
+ account?: AppearanceHandle;
55
106
  }
56
107
  export declare function configure(o?: KitConfig): void;
57
108
  export declare function t(
@@ -69,6 +120,8 @@ export declare const version: {
69
120
  ): string | null;
70
121
  set(label: string): void;
71
122
  unread(on: boolean): void;
123
+ /** 0.7.0: the update-waiting pill after the chip; null hides it. */
124
+ waiting: typeof setWaiting;
72
125
  };
73
126
  export declare const whatsNew: {
74
127
  open(): void;
@@ -108,11 +161,11 @@ export declare const busy: {
108
161
  export declare function hydrate(
109
162
  root: ParentNode,
110
163
  opts?: KitHydrateOptions,
111
- ): Shell;
164
+ ): KitShell;
112
165
  export declare function mount(
113
166
  root: Element,
114
167
  model?: ShellModel & { hydrate?: KitHydrateOptions },
115
- ): Shell;
168
+ ): KitShell;
116
169
 
117
170
  export interface DenUIKit {
118
171
  configure: typeof configure;
@@ -120,11 +173,31 @@ export interface DenUIKit {
120
173
  mount: typeof mount;
121
174
  shellHtml: typeof shellHtml;
122
175
  topBarHtml: typeof topBarHtml;
176
+ markHtml: typeof markHtml;
123
177
  railHtml: typeof railHtml;
124
178
  navItemHtml: typeof navItemHtml;
125
179
  versionChipHtml: typeof versionChipHtml;
126
180
  reportButtonHtml: typeof reportButtonHtml;
127
181
  reportPrefillOf: typeof reportPrefillOf;
182
+ scopeHtml: typeof scopeHtml;
183
+ scopeCrumbHtml: typeof scopeCrumbHtml;
184
+ searchHtml: typeof searchHtml;
185
+ bellButtonHtml: typeof bellButtonHtml;
186
+ bellPanelHtml: typeof bellPanelHtml;
187
+ accountHtml: typeof accountHtml;
188
+ accountWho: typeof accountWho;
189
+ accountMenuHtml: typeof accountMenuHtml;
190
+ settingsHtml: typeof settingsHtml;
191
+ appearanceButtonHtml: typeof appearanceButtonHtml;
192
+ appearanceMenuHtml: typeof appearanceMenuHtml;
193
+ waitingHtml: typeof waitingHtml;
194
+ hydrateAppearance: typeof hydrateAppearance;
195
+ setWaiting: typeof setWaiting;
196
+ hydrateScope: typeof hydrateScope;
197
+ hydrateSearch: typeof hydrateSearch;
198
+ hydrateBell: typeof hydrateBell;
199
+ hydrateAccount: typeof hydrateAccount;
200
+ attachMenuFilter: typeof attachMenuFilter;
128
201
  syncPinToggles: typeof syncPinToggles;
129
202
  icon: typeof icon;
130
203
  esc: typeof esc;
package/src/kit.js CHANGED
@@ -25,6 +25,15 @@
25
25
  * DenUI.mount(root, model) draws shellHtml(model) into root, then
26
26
  * hydrates it (a page with no server render)
27
27
  * DenUI.shellHtml(model) the markup (shell-html.js)
28
+ * DenUI.scopeHtml, searchHtml, bellButtonHtml, bellPanelHtml,
29
+ * accountHtml (0.7.0) the scope crumbs, the search with ⌘K
30
+ * inside, the bell and its panel, and the
31
+ * rail's account entry; hydrate wires them
32
+ * DenUI.settingsHtml, appearanceButtonHtml, appearanceMenuHtml,
33
+ * waitingHtml (0.7.0) the rail's Settings, ◐ ▾ and its menu
34
+ * (hydrate's opts.appearance: { menu,
35
+ * onPick }), the update-waiting pill
36
+ * (DenUI.version.waiting(o | null))
28
37
  * DenUI.version.set(label), .unread(on), .label(running, changelog)
29
38
  * DenUI.whatsNew.open(), .close(), .load(), .setEntries(list)
30
39
  * DenUI.update.set({ version, message, reloadLabel, dismissLabel,
@@ -38,17 +47,40 @@
38
47
  */
39
48
  import { addStrings, kitT, setProduct } from "./strings.js";
40
49
  import {
50
+ accountHtml,
51
+ accountWho,
52
+ accountMenuHtml,
53
+ appearanceButtonHtml,
54
+ appearanceMenuHtml,
55
+ bellButtonHtml,
56
+ bellPanelHtml,
41
57
  esc,
42
58
  icon,
43
59
  navItemHtml,
44
60
  railHtml,
45
61
  reportButtonHtml,
46
62
  reportPrefillOf,
63
+ scopeCrumbHtml,
64
+ scopeHtml,
65
+ searchHtml,
66
+ settingsHtml,
47
67
  shellHtml,
48
68
  topBarHtml,
69
+ markHtml,
49
70
  versionChipHtml,
71
+ waitingHtml,
50
72
  } from "./shell-html.js";
51
- import { hydrateShell, syncPinToggles } from "./shell-client.js";
73
+ import {
74
+ hydrateAccount,
75
+ attachMenuFilter,
76
+ hydrateAppearance,
77
+ hydrateBell,
78
+ hydrateScope,
79
+ hydrateSearch,
80
+ hydrateShell,
81
+ setWaiting,
82
+ syncPinToggles,
83
+ } from "./shell-client.js";
52
84
  import { setUnread, setVersion, versionLabel } from "./version.js";
53
85
  import {
54
86
  closeWhatsNew,
@@ -98,6 +130,8 @@ export const version = {
98
130
  label: versionLabel,
99
131
  set: (label) => setVersion(label),
100
132
  unread: (on) => setUnread(on),
133
+ /** 0.7.0: the update-waiting pill after the chip; null hides it. */
134
+ waiting: (o) => setWaiting(o),
101
135
  };
102
136
 
103
137
  export const whatsNew = {
@@ -149,9 +183,32 @@ export const busy = {
149
183
  configure: configureBusy,
150
184
  };
151
185
 
152
- /** Binds the drawn shell, the chip and Report (see the top). */
186
+ /**
187
+ * Binds the drawn shell, the chip and Report (see the top), and the 0.7.0
188
+ * pieces it finds: the scope crumbs (opts.scope), the search
189
+ * (opts.search: { onActivate }), the bell (opts.bell: { items, title,
190
+ * empty, onOpen, … }), the account entry (opts.account: { onAction }) and
191
+ * ◐ ▾ (opts.appearance: { menu, onPick }; .appearance on the shell).
192
+ * The shell it returns has .scope, .search and .bell for those found.
193
+ * false for any of them: not wired.
194
+ */
153
195
  export function hydrate(root, opts = {}) {
154
196
  const shell = hydrateShell(root, { lang, ...opts });
197
+ if (opts.scope !== false && root.querySelector(".den-scope"))
198
+ shell.scope = hydrateScope(root, opts.scope || {});
199
+ const search = root.querySelector(".den-search");
200
+ if (search && opts.search !== false)
201
+ shell.search = hydrateSearch(search, opts.search || {});
202
+ const bell = root.querySelector(".den-bell");
203
+ if (bell && opts.bell !== false)
204
+ shell.bell = hydrateBell(bell, { lang, ...(opts.bell || {}) });
205
+ if (opts.account !== false) {
206
+ const acct = hydrateAccount(root, { lang, ...(opts.account || {}) });
207
+ if (acct) shell.account = acct;
208
+ }
209
+ const um = root.querySelector(".appearance-btn");
210
+ if (um && opts.appearance)
211
+ shell.appearance = hydrateAppearance(um, { lang, ...opts.appearance });
155
212
  const chip = root.querySelector("#version-pill");
156
213
  if (chip && opts.versionChip !== false)
157
214
  chip.addEventListener("click", () => whatsNew.open());
@@ -202,11 +259,31 @@ const DenUI = {
202
259
  mount,
203
260
  shellHtml,
204
261
  topBarHtml,
262
+ markHtml,
205
263
  railHtml,
206
264
  navItemHtml,
207
265
  versionChipHtml,
208
266
  reportButtonHtml,
209
267
  reportPrefillOf,
268
+ scopeHtml,
269
+ scopeCrumbHtml,
270
+ searchHtml,
271
+ bellButtonHtml,
272
+ bellPanelHtml,
273
+ accountHtml,
274
+ accountWho,
275
+ accountMenuHtml,
276
+ settingsHtml,
277
+ appearanceButtonHtml,
278
+ appearanceMenuHtml,
279
+ waitingHtml,
280
+ hydrateAppearance,
281
+ setWaiting,
282
+ hydrateScope,
283
+ hydrateSearch,
284
+ hydrateBell,
285
+ hydrateAccount,
286
+ attachMenuFilter,
210
287
  syncPinToggles,
211
288
  icon,
212
289
  esc,
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" role="img" aria-label="Den">
2
+ <rect width="32" height="32" rx="7" fill="#3a2e22"/>
3
+ <path d="M5 26.5h22" stroke="#9bbb63" stroke-width="2" stroke-linecap="round"/>
4
+ <path d="M8 26V15a8 8 0 0 1 16 0v11h-4.5V15.5a3.5 3.5 0 0 0-7 0V26z" fill="#f2eee8"/>
5
+ <path d="M13 26v-9.5a3 3 0 0 1 6 0V26z" fill="#c8a46a" opacity="0.9"/>
6
+ </svg>
@@ -52,29 +52,211 @@ function timeout(ms) {
52
52
  );
53
53
  }
54
54
 
55
+ /*
56
+ * Scroll (issue 295). html-to-image clones the page, and a clone starts at
57
+ * scrollTop 0: the window and every scrolled pane would show their top.
58
+ * So, before cloning, each scrolled element's children (and each sticky
59
+ * element) are tagged with a data attribute; after cloning, the SVG is
60
+ * edited so each tagged clone sits where the person sees it:
61
+ *
62
+ * - the window's scroll moves the root clone up (position: relative, top
63
+ * and left), so fixed parts (the top bar, the rail) stay put;
64
+ * - a scrolled element's children move up by its scrollTop/scrollLeft
65
+ * (position: relative, or their own top/left for positioned ones); its
66
+ * bare text is wrapped in a span that moves the same way. Nested panes
67
+ * add up, since each moves inside its parent;
68
+ * - a sticky element becomes position: relative with the offset sticky
69
+ * gave it on screen (measured by setting it static for one synchronous
70
+ * read, so nothing is painted).
71
+ *
72
+ * The image stays the window's size: what is on screen, not the page.
73
+ */
74
+ const TAG = "data-den-shot";
75
+
76
+ const px = (v) => {
77
+ const n = parseFloat(v);
78
+ return Number.isFinite(n) ? n : 0;
79
+ };
80
+
81
+ /**
82
+ * What to change in the clone: [{ el, css, text }], one per live element.
83
+ * `css` is appended to the clone's style; `text` ({ dx, dy }) moves the
84
+ * element's bare text.
85
+ */
86
+ function scrollPlan(skip) {
87
+ const se = document.scrollingElement || document.documentElement;
88
+ const steps = new Map(); // el -> { dx, dy, sticky, clip, text }
89
+ const step = (el) => {
90
+ let m = steps.get(el);
91
+ if (!m) {
92
+ m = { dx: 0, dy: 0, sticky: false, clip: false, text: null };
93
+ steps.set(el, m);
94
+ }
95
+ return m;
96
+ };
97
+ for (const el of document.body ? document.body.querySelectorAll("*") : []) {
98
+ if (el === se || skip(el)) continue;
99
+ if (getComputedStyle(el).position === "sticky") {
100
+ // Where sticky put it, against where it would be without: read with
101
+ // position static for one synchronous moment (nothing is painted).
102
+ const before = el.getBoundingClientRect();
103
+ const v = el.style.getPropertyValue("position");
104
+ const pr = el.style.getPropertyPriority("position");
105
+ el.style.setProperty("position", "static", "important");
106
+ const flat = el.getBoundingClientRect();
107
+ if (v) el.style.setProperty("position", v, pr);
108
+ else el.style.removeProperty("position");
109
+ const m = step(el);
110
+ m.sticky = true;
111
+ m.dx += before.left - flat.left;
112
+ m.dy += before.top - flat.top;
113
+ }
114
+ const st = el.scrollTop;
115
+ const sl = el.scrollLeft;
116
+ if (!st && !sl) continue;
117
+ // A clone can't scroll: no scrollbar (it would show the top), and its
118
+ // children move instead.
119
+ step(el).clip = true;
120
+ for (const c of el.childNodes) {
121
+ if (c.nodeType === 3 && c.nodeValue.trim())
122
+ step(el).text = { dx: -sl, dy: -st };
123
+ if (c.nodeType !== 1 || skip(c)) continue;
124
+ if (getComputedStyle(c).position === "fixed") continue;
125
+ const m = step(c);
126
+ m.dx -= sl;
127
+ m.dy -= st;
128
+ }
129
+ }
130
+ const plan = [];
131
+ for (const [el, m] of steps) {
132
+ let css = m.clip ? "overflow:hidden;" : "";
133
+ if (m.dx || m.dy || m.sticky) {
134
+ const cs = getComputedStyle(el);
135
+ if (cs.position === "absolute" || cs.position === "relative")
136
+ css +=
137
+ `top:${px(cs.top) + m.dy}px;bottom:${px(cs.bottom) - m.dy}px;` +
138
+ `left:${px(cs.left) + m.dx}px;right:${px(cs.right) - m.dx}px;`;
139
+ else
140
+ css += `position:relative;top:${m.dy}px;left:${m.dx}px;bottom:auto;right:auto;`;
141
+ // Sticky parts stay above the content that scrolls under them, now
142
+ // that the moved content is positioned too.
143
+ if (m.sticky && cs.zIndex === "auto") css += "z-index:1;";
144
+ }
145
+ if (css || m.text) plan.push({ el, css, text: m.text });
146
+ }
147
+ return plan;
148
+ }
149
+
150
+ /** The SVG (a data: URL) with each tagged clone changed as planned. */
151
+ function applyPlan(url, plan) {
152
+ const head = "data:image/svg+xml;charset=utf-8,";
153
+ const doc = new DOMParser().parseFromString(
154
+ decodeURIComponent(url.slice(head.length)),
155
+ "image/svg+xml",
156
+ );
157
+ if (doc.getElementsByTagName("parsererror").length) return url;
158
+ const byTag = new Map();
159
+ for (const n of doc.querySelectorAll(`[${TAG}]`)) {
160
+ byTag.set(n.getAttribute(TAG), n);
161
+ n.removeAttribute(TAG);
162
+ }
163
+ plan.forEach((step, i) => {
164
+ const n = byTag.get(String(i));
165
+ if (!n) return;
166
+ // Last in the attribute, so it wins over the copied computed style.
167
+ if (step.css)
168
+ n.setAttribute("style", `${n.getAttribute("style") || ""};${step.css}`);
169
+ if (!step.text) return;
170
+ for (const c of [...n.childNodes]) {
171
+ if (c.nodeType !== 3 || !c.nodeValue.trim()) continue;
172
+ const span = doc.createElementNS(n.namespaceURI, "span");
173
+ span.setAttribute(
174
+ "style",
175
+ `position:relative;top:${step.text.dy}px;left:${step.text.dx}px;`,
176
+ );
177
+ n.replaceChild(span, c);
178
+ span.append(c);
179
+ }
180
+ });
181
+ return head + encodeURIComponent(new XMLSerializer().serializeToString(doc));
182
+ }
183
+
184
+ function imageOf(url) {
185
+ return new Promise((ok, no) => {
186
+ const img = new Image();
187
+ img.onload = () =>
188
+ img
189
+ .decode()
190
+ .catch(() => {})
191
+ .then(() => requestAnimationFrame(() => ok(img)));
192
+ img.onerror = no;
193
+ img.decoding = "async";
194
+ img.src = url;
195
+ });
196
+ }
197
+
55
198
  /**
56
199
  * The page as shown now, as a canvas the size of the window, or null.
57
200
  * `skip(el)`: elements to leave out (the form).
58
201
  */
59
202
  export async function capture({ seconds = 15, skip = () => false } = {}) {
203
+ let plan = [];
60
204
  try {
61
205
  const h2i = await Promise.race([loadLib(), timeout(seconds * 1000)]);
62
206
  const root = document.documentElement;
63
- const canvas = await Promise.race([
64
- h2i.toCanvas(root, {
65
- width: window.innerWidth,
66
- height: window.innerHeight,
67
- pixelRatio: 1,
68
- // The page's own fonts are already there: not fetched again.
69
- skipFonts: true,
70
- backgroundColor: getComputedStyle(document.body).backgroundColor,
71
- filter: (n) => !(n.nodeType === 1 && skip(n)),
72
- }),
73
- timeout(seconds * 1000),
74
- ]);
207
+ const width = window.innerWidth;
208
+ const height = window.innerHeight;
209
+ const backgroundColor = getComputedStyle(document.body).backgroundColor;
210
+ plan = scrollPlan(skip);
211
+ // The window's scroll: the whole clone moves up (and left). Not
212
+ // html-to-image's `style` option: its inset-block, copied from the
213
+ // computed style, comes later in the attribute and wins over top.
214
+ const x = window.scrollX;
215
+ const y = window.scrollY;
216
+ if (x || y)
217
+ plan.push({
218
+ el: root,
219
+ css: `position:relative;top:${-y}px;left:${-x}px;bottom:auto;right:auto;`,
220
+ });
221
+ plan.forEach((step, i) => step.el.setAttribute(TAG, String(i)));
222
+ const opts = {
223
+ width,
224
+ height,
225
+ pixelRatio: 1,
226
+ // The page's own fonts are already there: not fetched again.
227
+ skipFonts: true,
228
+ backgroundColor,
229
+ filter: (n) => !(n.nodeType === 1 && skip(n)),
230
+ };
231
+ let canvas;
232
+ if (!plan.length) {
233
+ canvas = await Promise.race([
234
+ h2i.toCanvas(root, opts),
235
+ timeout(seconds * 1000),
236
+ ]);
237
+ } else {
238
+ const svg = await Promise.race([
239
+ h2i.toSvg(root, opts),
240
+ timeout(seconds * 1000),
241
+ ]);
242
+ for (const step of plan) step.el.removeAttribute(TAG);
243
+ const img = await Promise.race([
244
+ imageOf(applyPlan(svg, plan)),
245
+ timeout(seconds * 1000),
246
+ ]);
247
+ canvas = document.createElement("canvas");
248
+ canvas.width = width;
249
+ canvas.height = height;
250
+ const g = canvas.getContext("2d");
251
+ g.fillStyle = backgroundColor;
252
+ g.fillRect(0, 0, width, height);
253
+ g.drawImage(img, 0, 0, width, height);
254
+ }
75
255
  return canvas && canvas.width > 0 && canvas.height > 0 ? canvas : null;
76
256
  } catch {
77
257
  return null;
258
+ } finally {
259
+ for (const step of plan) step.el.removeAttribute(TAG);
78
260
  }
79
261
  }
80
262
 
@@ -1,3 +1,11 @@
1
+ import type {
2
+ AccountMenu,
3
+ AppearanceMenu,
4
+ BellItem,
5
+ BellPanelOptions,
6
+ WaitingOptions,
7
+ } from "./shell-html.js";
8
+
1
9
  export interface HydrateOptions {
2
10
  lang?: string | (() => string);
3
11
  /** The toggle was pressed: store it, then call shell.setCollapsed(next). */
@@ -29,3 +37,113 @@ export declare function hydrateShell(
29
37
  root: ParentNode,
30
38
  opts?: HydrateOptions,
31
39
  ): Shell;
40
+
41
+ /** 0.7.0: the scope crumbs' menus. */
42
+ export interface ScopeHydrateOptions {
43
+ /** A crumb whose menu is the host's (menu: true) was opened. */
44
+ onOpen?: (key: string, button: HTMLElement) => void;
45
+ }
46
+ export interface ScopeHandle {
47
+ close(): void;
48
+ isOpen(): boolean;
49
+ }
50
+ export declare function hydrateScope(
51
+ root: ParentNode & EventTarget,
52
+ opts?: ScopeHydrateOptions,
53
+ ): ScopeHandle;
54
+ export interface SearchHydrateOptions {
55
+ /** A click or Enter ("click"), ⌘K or Ctrl-K ("key"). */
56
+ onActivate?: (via: string, event?: Event) => void;
57
+ /** false: no ⌘K / Ctrl-K. */
58
+ keys?: boolean;
59
+ }
60
+ export interface SearchHandle {
61
+ activate(via?: string): void;
62
+ destroy(): void;
63
+ }
64
+ export declare function hydrateSearch(
65
+ button: HTMLElement | null,
66
+ opts?: SearchHydrateOptions,
67
+ ): SearchHandle;
68
+ export interface BellHydrateOptions {
69
+ lang?: string | (() => string);
70
+ title?: string;
71
+ titleId?: string;
72
+ items?: BellItem[] | (() => BellItem[]);
73
+ empty?: { text?: string; more?: string };
74
+ foot?: string | (() => string);
75
+ /** The whole content: HTML, or bellPanelHtml's options. */
76
+ panel?: () => string | BellPanelOptions;
77
+ onOpen?: () => void;
78
+ onClose?: () => void;
79
+ /** An Esc while open: true when the host took it (the panel stays). */
80
+ onEscape?: (e: KeyboardEvent) => boolean | void;
81
+ /** The panel's id (default "den-bell-pop"). */
82
+ id?: string;
83
+ }
84
+ export interface BellHandle {
85
+ el: HTMLElement;
86
+ open(): void;
87
+ close(focus?: boolean): void;
88
+ isOpen(): boolean;
89
+ paint(): void;
90
+ setCount(n: number): void;
91
+ }
92
+ export declare function hydrateBell(
93
+ button: HTMLElement,
94
+ opts?: BellHydrateOptions,
95
+ ): BellHandle;
96
+ export interface AccountHydrateOptions {
97
+ lang?: string | (() => string);
98
+ /** The entry as an action (no href, no menu): a click calls it. */
99
+ onAction?: (e: Event) => void;
100
+ /** The entry's menu (`menu: true` on the entry), each time it opens. */
101
+ menu?: () => Omit<AccountMenu, "lang">;
102
+ /** A button entry's pick: "item" and its id. */
103
+ onPick?: (kind: string, value: string | null, row: HTMLElement) => void;
104
+ /** A form entry's submit; preventDefault keeps it from posting. */
105
+ onSubmit?: (e: SubmitEvent, form: HTMLFormElement) => void;
106
+ }
107
+ /**
108
+ * A type-to-filter field for a host's own menu (.den-mi entries), when it
109
+ * has more entries than `filter` allows (past 6 by default): the field
110
+ * (focus it once the menu shows), else null. The menu's rows (and its
111
+ * role and name) move into a `.den-mlist` role="menu" list, id
112
+ * `<menu id>-list`; `menu` keeps its id and becomes the pop-up holding the
113
+ * field, the list and "No match" (a menu owns only its items).
114
+ */
115
+ export declare function attachMenuFilter(
116
+ menu: HTMLElement,
117
+ o?: {
118
+ label?: string;
119
+ lang?: string;
120
+ filter?: boolean | number;
121
+ onClose?: (refocus: boolean) => void;
122
+ },
123
+ ): HTMLInputElement | null;
124
+ /** The account entry: its menu's handle when it has one, else nothing. */
125
+ export declare function hydrateAccount(
126
+ root: ParentNode & EventTarget,
127
+ opts?: AccountHydrateOptions,
128
+ ): AppearanceHandle | void;
129
+ export interface AppearanceHydrateOptions {
130
+ lang?: string | (() => string);
131
+ /** The menu's content, each time it opens. */
132
+ menu?: () => Omit<AppearanceMenu, "lang">;
133
+ /** A pick: "mode", "theme", "language" or "item", and its value. */
134
+ onPick?: (kind: string, value: string | null, row: HTMLElement) => void;
135
+ }
136
+ export interface AppearanceHandle {
137
+ open(): void;
138
+ close(refocus?: boolean): void;
139
+ isOpen(): boolean;
140
+ }
141
+ export declare function hydrateAppearance(
142
+ button: HTMLElement,
143
+ opts?: AppearanceHydrateOptions,
144
+ ): AppearanceHandle;
145
+ /** The update-waiting pill after the version chip; null hides it. */
146
+ export declare function setWaiting(
147
+ o: (WaitingOptions & { onClick?: (e: Event) => void }) | null,
148
+ root?: Document | Element,
149
+ ): HTMLElement | null;