@monster-orange/den-ui 0.0.0-stage → 0.6.6
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/LICENSE +21 -0
- package/README.md +408 -2
- package/bin/den-ui-parity.mjs +365 -0
- package/inventory/nav-inventory.d.ts +89 -0
- package/inventory/nav-inventory.js +590 -0
- package/inventory/reference/den-chromium-1280.json +5137 -0
- package/inventory/reference/den-chromium-390.json +3653 -0
- package/inventory/reference/den-webkit-1280.json +5137 -0
- package/inventory/reference/den-webkit-390.json +3653 -0
- package/package.json +51 -4
- package/src/base.css +80 -0
- package/src/busy-words.d.ts +2 -0
- package/src/busy-words.js +71 -0
- package/src/busy.css +155 -0
- package/src/busy.d.ts +80 -0
- package/src/busy.js +662 -0
- package/src/dialog.css +103 -0
- package/src/dialog.d.ts +44 -0
- package/src/dialog.js +282 -0
- package/src/fonts/OFL.txt +97 -0
- package/src/fonts/rubik-latin-400-normal.woff2 +0 -0
- package/src/fonts/rubik-latin-500-normal.woff2 +0 -0
- package/src/fonts/rubik-latin-ext-400-normal.woff2 +0 -0
- package/src/fonts/rubik-latin-ext-500-normal.woff2 +0 -0
- package/src/fonts/space-mono-latin-400-normal.woff2 +0 -0
- package/src/fonts/space-mono-latin-ext-400-normal.woff2 +0 -0
- package/src/fonts.css +71 -0
- package/src/icons.d.ts +4 -0
- package/src/icons.js +43 -0
- package/src/kit.d.ts +146 -0
- package/src/kit.js +224 -0
- package/src/report-shot.d.ts +47 -0
- package/src/report-shot.js +255 -0
- package/src/report.css +387 -0
- package/src/report.d.ts +61 -0
- package/src/report.js +909 -0
- package/src/shell-client.d.ts +31 -0
- package/src/shell-client.js +240 -0
- package/src/shell-html.d.ts +91 -0
- package/src/shell-html.js +289 -0
- package/src/shell.css +558 -0
- package/src/strings.d.ts +18 -0
- package/src/strings.js +514 -0
- package/src/time.d.ts +18 -0
- package/src/time.js +254 -0
- package/src/tokens.css +158 -0
- package/src/update-pill.css +32 -0
- package/src/update-pill.d.ts +17 -0
- package/src/update-pill.js +95 -0
- package/src/version.d.ts +7 -0
- package/src/version.js +31 -0
- package/src/whatsnew.css +235 -0
- package/src/whatsnew.d.ts +36 -0
- package/src/whatsnew.js +411 -0
package/src/dialog.css
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* den-ui: the ask-and-tell dialogs' look (dialog.js). Tokens only (UK-1):
|
|
2
|
+
no colour of its own. Linked, never injected: clean under style-src 'self'. */
|
|
3
|
+
.dk-dlg {
|
|
4
|
+
font-family: var(--sans);
|
|
5
|
+
position: fixed;
|
|
6
|
+
inset-block: auto;
|
|
7
|
+
inset-inline: 0;
|
|
8
|
+
top: 50%;
|
|
9
|
+
transform: translateY(-50%);
|
|
10
|
+
margin: 0 auto;
|
|
11
|
+
height: auto;
|
|
12
|
+
max-height: calc(100vh - 32px);
|
|
13
|
+
max-height: calc(100dvh - 32px);
|
|
14
|
+
overflow: auto;
|
|
15
|
+
width: min(440px, calc(100vw - 32px));
|
|
16
|
+
max-width: 100%;
|
|
17
|
+
padding: 0;
|
|
18
|
+
border: 1px solid var(--border-strong);
|
|
19
|
+
border-radius: var(--radius);
|
|
20
|
+
background: var(--surface);
|
|
21
|
+
color: var(--text);
|
|
22
|
+
box-shadow: var(--shadow-dialog);
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
}
|
|
25
|
+
.dk-dlg::backdrop {
|
|
26
|
+
background: color-mix(in srgb, var(--sunken) 70%, transparent);
|
|
27
|
+
}
|
|
28
|
+
.dk-b {
|
|
29
|
+
padding: var(--space-4) calc(var(--space-4) + 2px);
|
|
30
|
+
display: grid;
|
|
31
|
+
gap: 10px;
|
|
32
|
+
margin: 0;
|
|
33
|
+
}
|
|
34
|
+
.dk-b h2 {
|
|
35
|
+
font-size: var(--fs-l);
|
|
36
|
+
margin: 0;
|
|
37
|
+
overflow-wrap: anywhere;
|
|
38
|
+
}
|
|
39
|
+
.dk-msg {
|
|
40
|
+
margin: 0;
|
|
41
|
+
font-size: var(--fs-s);
|
|
42
|
+
line-height: 1.5;
|
|
43
|
+
white-space: pre-wrap;
|
|
44
|
+
overflow-wrap: anywhere;
|
|
45
|
+
max-height: 50dvh;
|
|
46
|
+
overflow: auto;
|
|
47
|
+
}
|
|
48
|
+
.dk-in {
|
|
49
|
+
font: inherit;
|
|
50
|
+
font-size: var(--fs-s);
|
|
51
|
+
min-height: var(--tap-min);
|
|
52
|
+
padding: 0 var(--space-2);
|
|
53
|
+
border: 1px solid var(--border-strong);
|
|
54
|
+
border-radius: var(--radius-button);
|
|
55
|
+
background: var(--bg);
|
|
56
|
+
color: var(--text);
|
|
57
|
+
width: 100%;
|
|
58
|
+
box-sizing: border-box;
|
|
59
|
+
}
|
|
60
|
+
.dk-in:focus-visible {
|
|
61
|
+
outline: 2px solid var(--accent);
|
|
62
|
+
outline-offset: 1px;
|
|
63
|
+
}
|
|
64
|
+
.dk-ft {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-wrap: wrap;
|
|
67
|
+
gap: var(--space-2);
|
|
68
|
+
justify-content: flex-end;
|
|
69
|
+
align-items: center;
|
|
70
|
+
}
|
|
71
|
+
.dk-ft > :first-child:not(.dk-btn) {
|
|
72
|
+
margin-right: auto;
|
|
73
|
+
}
|
|
74
|
+
.dk-btn {
|
|
75
|
+
font: inherit;
|
|
76
|
+
font-size: var(--fs-s);
|
|
77
|
+
min-height: var(--tap-min);
|
|
78
|
+
padding: 0 var(--space-3);
|
|
79
|
+
border-radius: var(--radius-button);
|
|
80
|
+
border: 1px solid var(--border-strong);
|
|
81
|
+
background: var(--surface);
|
|
82
|
+
color: var(--text);
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
}
|
|
85
|
+
.dk-btn:focus-visible {
|
|
86
|
+
outline: 2px solid var(--accent);
|
|
87
|
+
outline-offset: 2px;
|
|
88
|
+
}
|
|
89
|
+
.dk-btn.dk-primary {
|
|
90
|
+
background: var(--accent-fill);
|
|
91
|
+
border-color: var(--accent-fill);
|
|
92
|
+
color: var(--on-accent);
|
|
93
|
+
}
|
|
94
|
+
.dk-btn.dk-danger {
|
|
95
|
+
background: var(--bad);
|
|
96
|
+
border-color: var(--bad);
|
|
97
|
+
color: var(--on-accent);
|
|
98
|
+
}
|
|
99
|
+
@media (max-width: 480px) {
|
|
100
|
+
.dk-btn {
|
|
101
|
+
min-height: var(--tap);
|
|
102
|
+
}
|
|
103
|
+
}
|
package/src/dialog.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type DialogKind = "confirm" | "text" | "tell";
|
|
2
|
+
export interface DialogOptions {
|
|
3
|
+
title?: string;
|
|
4
|
+
message?: string;
|
|
5
|
+
okLabel?: string;
|
|
6
|
+
cancelLabel?: string;
|
|
7
|
+
danger?: boolean;
|
|
8
|
+
/** askText: the field's first text. */
|
|
9
|
+
value?: string;
|
|
10
|
+
/** askText: the field's own name (default: the title). */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** Focus goes back here on close (default: what opened it). */
|
|
13
|
+
opener?: Element | null;
|
|
14
|
+
}
|
|
15
|
+
export declare const DIALOG_WORDS: Record<string, Record<string, string>>;
|
|
16
|
+
export declare function configureDialog(h?: {
|
|
17
|
+
lang?: () => string;
|
|
18
|
+
words?: Record<string, Record<string, string>>;
|
|
19
|
+
report?: (() => string | null) | null;
|
|
20
|
+
/** Where dialog.css is, for a page that doesn't link it. */
|
|
21
|
+
css?: string | null;
|
|
22
|
+
}): void;
|
|
23
|
+
export declare function dialogWord(key: string): string;
|
|
24
|
+
export declare function dialogHtml(
|
|
25
|
+
kind: DialogKind,
|
|
26
|
+
opts: DialogOptions | null | undefined,
|
|
27
|
+
ids: { h: string; m: string },
|
|
28
|
+
): string;
|
|
29
|
+
export declare function firstFocus(
|
|
30
|
+
kind: DialogKind,
|
|
31
|
+
opts?: DialogOptions | null,
|
|
32
|
+
): "field" | "cancel" | "ok";
|
|
33
|
+
export declare function answerOf(
|
|
34
|
+
kind: DialogKind,
|
|
35
|
+
ok: boolean,
|
|
36
|
+
text?: string | null,
|
|
37
|
+
): boolean | string | null | undefined;
|
|
38
|
+
export declare function askConfirm(opts: DialogOptions): Promise<boolean>;
|
|
39
|
+
export declare function askText(opts: DialogOptions): Promise<string | null>;
|
|
40
|
+
export declare function tell(opts: DialogOptions): Promise<void>;
|
|
41
|
+
/** What opened a pop-up: `hint`, the focused element, or the control just pressed. */
|
|
42
|
+
export declare function openerOf(hint?: Element | null): HTMLElement | null;
|
|
43
|
+
/** Focuses `el` again (no scroll) when it is still on the page and focusable. */
|
|
44
|
+
export declare function focusBack(el: Element | null | undefined): boolean;
|
package/src/dialog.js
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The kit's ask-and-tell dialogs: askConfirm, askText and tell, in place of
|
|
3
|
+
* the browser's confirm(), prompt() and alert(), which speak only the
|
|
4
|
+
* browser's language and carry no Report. Framework-free; the product
|
|
5
|
+
* plugs in its language, its words and its Report:
|
|
6
|
+
*
|
|
7
|
+
* configureDialog({
|
|
8
|
+
* lang: () => "en", the page's language (en, es, ja)
|
|
9
|
+
* words: { en: {...}, ... }, extra or replaced shared words (ok, cancel)
|
|
10
|
+
* report: () => html, the Report button's HTML for the footer
|
|
11
|
+
* ("" or null: none)
|
|
12
|
+
* css: "/kit/dialog.css", where dialog.css is, for a page that
|
|
13
|
+
* doesn't link it (default: beside
|
|
14
|
+
* another kit stylesheet on the page)
|
|
15
|
+
* })
|
|
16
|
+
*
|
|
17
|
+
* askConfirm(opts) → Promise<boolean> OK true; Cancel or Esc false
|
|
18
|
+
* askText(opts) → Promise<string|null> the text; Cancel or Esc null
|
|
19
|
+
* tell(opts) → Promise<void> resolves when it closes
|
|
20
|
+
*
|
|
21
|
+
* opts.title the heading (the dialog's name)
|
|
22
|
+
* opts.message the body; line breaks show as written
|
|
23
|
+
* opts.okLabel OK's word (default: the kit's "OK")
|
|
24
|
+
* opts.cancelLabel Cancel's word (default: the kit's "Cancel")
|
|
25
|
+
* opts.danger OK destroys something: styled as danger, and focus
|
|
26
|
+
* starts on Cancel, the safe answer
|
|
27
|
+
* opts.value askText: the field's first text (selected)
|
|
28
|
+
* opts.label askText: the field's own name (default: the title)
|
|
29
|
+
*
|
|
30
|
+
* askConfirm and tell are role="alertdialog"; askText is role="dialog".
|
|
31
|
+
* Each is named by its title (aria-labelledby) and described by its
|
|
32
|
+
* message (aria-describedby). Focus moves in (Cancel for danger, the
|
|
33
|
+
* field for askText, else OK) and goes back to what opened it on close
|
|
34
|
+
* (opts.opener, else the focused element or the control just pressed).
|
|
35
|
+
* Enter in askText's field is OK.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
// Focus goes back to what opened a pop-up (here, Report, What's new). The
|
|
39
|
+
// browser's own dialog restore isn't enough: Safari doesn't focus a button
|
|
40
|
+
// on a click, so the element "focused before" a dialog opened from a click
|
|
41
|
+
// is the body. openerOf(hint) at open: the hint, else the focused element,
|
|
42
|
+
// else the control just pressed. focusBack(el) at close: focus it again,
|
|
43
|
+
// without scrolling, if it is still on the page and can take focus. Kept
|
|
44
|
+
// here, not in a file of its own: hosts that serve a list of kit files
|
|
45
|
+
// already serve this one.
|
|
46
|
+
|
|
47
|
+
const FOCUSABLE =
|
|
48
|
+
'button, a[href], input, select, textarea, summary, [tabindex], [contenteditable=""], [contenteditable="true"]';
|
|
49
|
+
|
|
50
|
+
/** A press counts as the opener for this long (ms). */
|
|
51
|
+
const PRESS_MS = 1500;
|
|
52
|
+
|
|
53
|
+
let pressed = null;
|
|
54
|
+
let pressedAt = 0;
|
|
55
|
+
|
|
56
|
+
function focusable(el) {
|
|
57
|
+
if (!el || el.nodeType !== 1 || !el.isConnected) return false;
|
|
58
|
+
if (typeof document !== "undefined" && el === document.body) return false;
|
|
59
|
+
if (el.disabled) return false;
|
|
60
|
+
return !!el.matches?.(FOCUSABLE);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const controlOf = (t) =>
|
|
64
|
+
t && t.nodeType === 1 && t.closest ? t.closest(FOCUSABLE) : null;
|
|
65
|
+
|
|
66
|
+
// The control a pointer or key just pressed, seen before any page handler.
|
|
67
|
+
if (typeof document !== "undefined" && document.addEventListener) {
|
|
68
|
+
const note = (e) => {
|
|
69
|
+
const c = controlOf(e.target);
|
|
70
|
+
if (!c) return;
|
|
71
|
+
pressed = c;
|
|
72
|
+
pressedAt = Date.now();
|
|
73
|
+
};
|
|
74
|
+
for (const type of ["pointerdown", "mousedown", "click", "keydown"])
|
|
75
|
+
document.addEventListener(type, note, true);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** What opened the pop-up: `hint`, the focused element, or the press. */
|
|
79
|
+
export function openerOf(hint) {
|
|
80
|
+
if (focusable(hint)) return hint;
|
|
81
|
+
const h = controlOf(hint);
|
|
82
|
+
if (focusable(h)) return h;
|
|
83
|
+
const at = typeof document !== "undefined" ? document.activeElement : null;
|
|
84
|
+
if (focusable(at)) return at;
|
|
85
|
+
const ev = typeof window !== "undefined" ? window.event : null;
|
|
86
|
+
const t = controlOf(ev?.target);
|
|
87
|
+
if (focusable(t)) return t;
|
|
88
|
+
if (focusable(pressed) && Date.now() - pressedAt < PRESS_MS) return pressed;
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Focus `el` again (no scroll), when it is still there and focusable. */
|
|
93
|
+
export function focusBack(el) {
|
|
94
|
+
if (!focusable(el)) return false;
|
|
95
|
+
try {
|
|
96
|
+
el.focus({ preventScroll: true });
|
|
97
|
+
} catch {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return document.activeElement === el;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const DIALOG_WORDS = {
|
|
104
|
+
en: { ok: "OK", cancel: "Cancel" },
|
|
105
|
+
es: { ok: "Aceptar", cancel: "Cancelar" },
|
|
106
|
+
ja: { ok: "OK", cancel: "キャンセル" },
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const hook = {
|
|
110
|
+
lang: () =>
|
|
111
|
+
(typeof document !== "undefined" &&
|
|
112
|
+
document.documentElement.lang?.slice(0, 2)) ||
|
|
113
|
+
"en",
|
|
114
|
+
words: {},
|
|
115
|
+
report: null,
|
|
116
|
+
css: null,
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** The product's language, words and Report (see the top of this file). */
|
|
120
|
+
export function configureDialog(h) {
|
|
121
|
+
Object.assign(hook, h ?? {});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A shared word, in the page's language, with the product's own on top. */
|
|
125
|
+
export function dialogWord(key) {
|
|
126
|
+
const l = hook.lang();
|
|
127
|
+
return (
|
|
128
|
+
hook.words?.[l]?.[key] ??
|
|
129
|
+
DIALOG_WORDS[l]?.[key] ??
|
|
130
|
+
hook.words?.en?.[key] ??
|
|
131
|
+
DIALOG_WORDS.en[key] ??
|
|
132
|
+
key
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const esc = (s) =>
|
|
137
|
+
String(s ?? "").replace(
|
|
138
|
+
/[&<>"']/g,
|
|
139
|
+
(c) =>
|
|
140
|
+
({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[
|
|
141
|
+
c
|
|
142
|
+
],
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The look is dialog.css: linked, never injected, so a page under
|
|
147
|
+
* style-src 'self' takes it. A page that links it (in its <head>) keeps
|
|
148
|
+
* its own link. Else it is linked from configureDialog({ css }), or from
|
|
149
|
+
* the folder of another kit stylesheet on the page (tokens.css, say).
|
|
150
|
+
*/
|
|
151
|
+
const KIT_SHEET = /(^|\/)(tokens|base|fonts|busy|shell|update-pill)\.css$/;
|
|
152
|
+
function ensureCss() {
|
|
153
|
+
if (document.getElementById("dk-css")) return;
|
|
154
|
+
let near = null;
|
|
155
|
+
for (const l of document.querySelectorAll('link[rel="stylesheet"]')) {
|
|
156
|
+
const u = new URL(l.href, location.href);
|
|
157
|
+
if (/(^|\/)dialog\.css$/.test(u.pathname)) return;
|
|
158
|
+
if (!near && KIT_SHEET.test(u.pathname)) near = u;
|
|
159
|
+
}
|
|
160
|
+
const href =
|
|
161
|
+
hook.css ||
|
|
162
|
+
(near ? new URL("dialog.css", near).href.replace(/\?.*$/, "") : null);
|
|
163
|
+
if (!href) return;
|
|
164
|
+
const l = document.createElement("link");
|
|
165
|
+
l.id = "dk-css";
|
|
166
|
+
l.rel = "stylesheet";
|
|
167
|
+
l.href = href;
|
|
168
|
+
document.head.append(l);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
let seq = 0;
|
|
172
|
+
|
|
173
|
+
/** The dialog's markup, for one kind: confirm, text or tell. */
|
|
174
|
+
export function dialogHtml(kind, opts, ids) {
|
|
175
|
+
const o = opts ?? {};
|
|
176
|
+
const okCls = o.danger ? "dk-danger" : "dk-primary";
|
|
177
|
+
const report = (typeof hook.report === "function" && hook.report()) || "";
|
|
178
|
+
const title = o.title ?? "";
|
|
179
|
+
const message = o.message ?? "";
|
|
180
|
+
return (
|
|
181
|
+
`<form class="dk-b" method="dialog">` +
|
|
182
|
+
(title ? `<h2 id="${ids.h}">${esc(title)}</h2>` : "") +
|
|
183
|
+
(message ? `<p class="dk-msg" id="${ids.m}">${esc(message)}</p>` : "") +
|
|
184
|
+
(kind === "text"
|
|
185
|
+
? `<input class="dk-in" type="text" data-dk="field" autocomplete="off" spellcheck="false" aria-label="${esc(o.label ?? title)}" value="${esc(o.value ?? "")}">`
|
|
186
|
+
: "") +
|
|
187
|
+
`<div class="dk-ft">${report}` +
|
|
188
|
+
(kind === "tell"
|
|
189
|
+
? ""
|
|
190
|
+
: `<button type="button" class="dk-btn" data-dk="cancel">${esc(o.cancelLabel ?? dialogWord("cancel"))}</button>`) +
|
|
191
|
+
`<button type="submit" class="dk-btn ${okCls}" data-dk="ok">${esc(o.okLabel ?? dialogWord("ok"))}</button>` +
|
|
192
|
+
`</div></form>`
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Where focus starts: Cancel for danger, the field for text, else OK. */
|
|
197
|
+
export function firstFocus(kind, opts) {
|
|
198
|
+
if (kind === "text") return "field";
|
|
199
|
+
if (kind === "confirm" && opts?.danger) return "cancel";
|
|
200
|
+
return "ok";
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** What a closed dialog answers: OK's answer, else Cancel's (Esc too). */
|
|
204
|
+
export function answerOf(kind, ok, text) {
|
|
205
|
+
if (kind === "confirm") return ok;
|
|
206
|
+
if (kind === "text") return ok ? String(text ?? "") : null;
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function open(kind, opts = {}) {
|
|
211
|
+
ensureCss();
|
|
212
|
+
const n = ++seq;
|
|
213
|
+
const ids = { h: `dk-h-${n}`, m: `dk-m-${n}` };
|
|
214
|
+
const opener = openerOf(opts.opener);
|
|
215
|
+
const d = document.createElement("dialog");
|
|
216
|
+
d.className = "dk-dlg";
|
|
217
|
+
d.dataset.dkKind = kind;
|
|
218
|
+
d.setAttribute("role", kind === "text" ? "dialog" : "alertdialog");
|
|
219
|
+
d.setAttribute("aria-modal", "true");
|
|
220
|
+
d.innerHTML = dialogHtml(kind, opts, ids);
|
|
221
|
+
if (d.querySelector(`#${ids.h}`)) d.setAttribute("aria-labelledby", ids.h);
|
|
222
|
+
else if (d.querySelector(`#${ids.m}`))
|
|
223
|
+
d.setAttribute("aria-labelledby", ids.m);
|
|
224
|
+
if (opts.title && d.querySelector(`#${ids.m}`))
|
|
225
|
+
d.setAttribute("aria-describedby", ids.m);
|
|
226
|
+
document.body.append(d);
|
|
227
|
+
|
|
228
|
+
return new Promise((resolve) => {
|
|
229
|
+
let done = false;
|
|
230
|
+
const field = d.querySelector('[data-dk="field"]');
|
|
231
|
+
const finish = (ok) => {
|
|
232
|
+
if (done) return;
|
|
233
|
+
done = true;
|
|
234
|
+
const answer = answerOf(kind, ok, field?.value);
|
|
235
|
+
if (d.open) d.close();
|
|
236
|
+
d.remove();
|
|
237
|
+
focusBack(opener);
|
|
238
|
+
resolve(answer);
|
|
239
|
+
};
|
|
240
|
+
// Esc is Cancel (for tell, it closes). Handled on the dialog's own
|
|
241
|
+
// keydown too: a page that takes Esc first (or a browser that closes
|
|
242
|
+
// without a cancel event) must never leave it open or unanswered.
|
|
243
|
+
d.addEventListener("cancel", (e) => {
|
|
244
|
+
e.preventDefault();
|
|
245
|
+
finish(kind === "tell");
|
|
246
|
+
});
|
|
247
|
+
d.addEventListener("keydown", (e) => {
|
|
248
|
+
if (e.key !== "Escape" || e.isComposing) return;
|
|
249
|
+
e.preventDefault();
|
|
250
|
+
e.stopPropagation();
|
|
251
|
+
finish(kind === "tell");
|
|
252
|
+
});
|
|
253
|
+
d.addEventListener("close", () => finish(kind === "tell"));
|
|
254
|
+
d.querySelector('[data-dk="cancel"]')?.addEventListener("click", () =>
|
|
255
|
+
finish(false),
|
|
256
|
+
);
|
|
257
|
+
d.querySelector("form").addEventListener("submit", (e) => {
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
finish(true);
|
|
260
|
+
});
|
|
261
|
+
if (typeof d.showModal === "function") d.showModal();
|
|
262
|
+
else d.setAttribute("open", "");
|
|
263
|
+
const first = d.querySelector(`[data-dk="${firstFocus(kind, opts)}"]`);
|
|
264
|
+
first?.focus();
|
|
265
|
+
if (first === field) field.select?.();
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** In place of confirm(): true on OK; false on Cancel or Esc. */
|
|
270
|
+
export function askConfirm(opts) {
|
|
271
|
+
return open("confirm", opts);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** In place of prompt(): the text on OK (Enter too); null on Cancel or Esc. */
|
|
275
|
+
export function askText(opts) {
|
|
276
|
+
return open("text", opts);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** In place of alert(): resolves once it is closed (OK or Esc). */
|
|
280
|
+
export function tell(opts) {
|
|
281
|
+
return open("tell", opts);
|
|
282
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
Rubik (rubik-*.woff2):
|
|
2
|
+
Copyright 2015 The Rubik Project Authors (https://github.com/googlefonts/rubik)
|
|
3
|
+
|
|
4
|
+
Space Mono (space-mono-*.woff2):
|
|
5
|
+
Copyright 2016 The Space Mono Project Authors (https://github.com/googlefonts/spacemono)
|
|
6
|
+
|
|
7
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
8
|
+
This license is copied below, and is also available with a FAQ at:
|
|
9
|
+
http://scripts.sil.org/OFL
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
-----------------------------------------------------------
|
|
13
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
14
|
+
-----------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
PREAMBLE
|
|
17
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
18
|
+
development of collaborative font projects, to support the font creation
|
|
19
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
20
|
+
open framework in which fonts may be shared and improved in partnership
|
|
21
|
+
with others.
|
|
22
|
+
|
|
23
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
24
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
25
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
26
|
+
redistributed and/or sold with any software provided that any reserved
|
|
27
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
28
|
+
however, cannot be released under any other type of license. The
|
|
29
|
+
requirement for fonts to remain under this license does not apply
|
|
30
|
+
to any document created using the fonts or their derivatives.
|
|
31
|
+
|
|
32
|
+
DEFINITIONS
|
|
33
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
34
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
35
|
+
include source files, build scripts and documentation.
|
|
36
|
+
|
|
37
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
38
|
+
copyright statement(s).
|
|
39
|
+
|
|
40
|
+
"Original Version" refers to the collection of Font Software components as
|
|
41
|
+
distributed by the Copyright Holder(s).
|
|
42
|
+
|
|
43
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
44
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
45
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
46
|
+
new environment.
|
|
47
|
+
|
|
48
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
49
|
+
writer or other person who contributed to the Font Software.
|
|
50
|
+
|
|
51
|
+
PERMISSION & CONDITIONS
|
|
52
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
53
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
54
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
55
|
+
Software, subject to the following conditions:
|
|
56
|
+
|
|
57
|
+
1) Neither the Font Software nor any of its individual components,
|
|
58
|
+
in Original or Modified Versions, may be sold by itself.
|
|
59
|
+
|
|
60
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
61
|
+
redistributed and/or sold with any software, provided that each copy
|
|
62
|
+
contains the above copyright notice and this license. These can be
|
|
63
|
+
included either as stand-alone text files, human-readable headers or
|
|
64
|
+
in the appropriate machine-readable metadata fields within text or
|
|
65
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
66
|
+
|
|
67
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
68
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
69
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
70
|
+
presented to the users.
|
|
71
|
+
|
|
72
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
73
|
+
Software shall not be used to promote, endorse or advertise any
|
|
74
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
75
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
76
|
+
permission.
|
|
77
|
+
|
|
78
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
79
|
+
must be distributed entirely under this license, and must not be
|
|
80
|
+
distributed under any other license. The requirement for fonts to
|
|
81
|
+
remain under this license does not apply to any document created
|
|
82
|
+
using the Font Software.
|
|
83
|
+
|
|
84
|
+
TERMINATION
|
|
85
|
+
This license becomes null and void if any of the above conditions are
|
|
86
|
+
not met.
|
|
87
|
+
|
|
88
|
+
DISCLAIMER
|
|
89
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
90
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
91
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
92
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
93
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
94
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
95
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
96
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
97
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/fonts.css
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* den-ui fonts: Rubik and Space Mono, self-hosted woff2 (SIL OFL 1.1, see
|
|
3
|
+
* fonts/OFL.txt). Latin and latin-ext only; Japanese uses the system's
|
|
4
|
+
* fonts. Bold is synthesised from the heaviest face here.
|
|
5
|
+
*/
|
|
6
|
+
@font-face {
|
|
7
|
+
font-family: "Rubik";
|
|
8
|
+
font-style: normal;
|
|
9
|
+
font-weight: 400;
|
|
10
|
+
font-display: swap;
|
|
11
|
+
src: url("fonts/rubik-latin-400-normal.woff2") format("woff2");
|
|
12
|
+
unicode-range:
|
|
13
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
14
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
15
|
+
U+2215, U+FEFF, U+FFFD;
|
|
16
|
+
}
|
|
17
|
+
@font-face {
|
|
18
|
+
font-family: "Rubik";
|
|
19
|
+
font-style: normal;
|
|
20
|
+
font-weight: 400;
|
|
21
|
+
font-display: swap;
|
|
22
|
+
src: url("fonts/rubik-latin-ext-400-normal.woff2") format("woff2");
|
|
23
|
+
unicode-range:
|
|
24
|
+
U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
|
|
25
|
+
U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
|
|
26
|
+
U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
|
27
|
+
}
|
|
28
|
+
@font-face {
|
|
29
|
+
font-family: "Rubik";
|
|
30
|
+
font-style: normal;
|
|
31
|
+
font-weight: 500;
|
|
32
|
+
font-display: swap;
|
|
33
|
+
src: url("fonts/rubik-latin-500-normal.woff2") format("woff2");
|
|
34
|
+
unicode-range:
|
|
35
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
36
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
37
|
+
U+2215, U+FEFF, U+FFFD;
|
|
38
|
+
}
|
|
39
|
+
@font-face {
|
|
40
|
+
font-family: "Rubik";
|
|
41
|
+
font-style: normal;
|
|
42
|
+
font-weight: 500;
|
|
43
|
+
font-display: swap;
|
|
44
|
+
src: url("fonts/rubik-latin-ext-500-normal.woff2") format("woff2");
|
|
45
|
+
unicode-range:
|
|
46
|
+
U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
|
|
47
|
+
U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
|
|
48
|
+
U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
|
49
|
+
}
|
|
50
|
+
@font-face {
|
|
51
|
+
font-family: "Space Mono";
|
|
52
|
+
font-style: normal;
|
|
53
|
+
font-weight: 400;
|
|
54
|
+
font-display: swap;
|
|
55
|
+
src: url("fonts/space-mono-latin-400-normal.woff2") format("woff2");
|
|
56
|
+
unicode-range:
|
|
57
|
+
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
|
|
58
|
+
U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
|
|
59
|
+
U+2215, U+FEFF, U+FFFD;
|
|
60
|
+
}
|
|
61
|
+
@font-face {
|
|
62
|
+
font-family: "Space Mono";
|
|
63
|
+
font-style: normal;
|
|
64
|
+
font-weight: 400;
|
|
65
|
+
font-display: swap;
|
|
66
|
+
src: url("fonts/space-mono-latin-ext-400-normal.woff2") format("woff2");
|
|
67
|
+
unicode-range:
|
|
68
|
+
U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
|
|
69
|
+
U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
|
|
70
|
+
U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
|
|
71
|
+
}
|
package/src/icons.d.ts
ADDED
package/src/icons.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* den-ui icons: the shell's 24px line drawings (the rail, the Report
|
|
3
|
+
* button). icon(name) gives an <svg> string; a name it doesn't know, or
|
|
4
|
+
* markup starting with "<" (a product's own drawing), is used as given,
|
|
5
|
+
* else the page icon. Pure: it runs in Node too.
|
|
6
|
+
*/
|
|
7
|
+
export const ICONS = {
|
|
8
|
+
// FB (den#81): the flat speech bubble with "!" (the Report button).
|
|
9
|
+
report: '<path d="M4 5h16v11H9l-5 4V5z"/><path d="M12 8v4M12 14.2v.01"/>',
|
|
10
|
+
overview: '<path d="M4 4h7v7H4zM13 4h7v4h-7zM13 10h7v10h-7zM4 13h7v7H4z"/>',
|
|
11
|
+
graph:
|
|
12
|
+
'<circle cx="6" cy="6" r="2.5"/><circle cx="18" cy="8" r="2.5"/><circle cx="9" cy="18" r="2.5"/><path d="M8.2 7.2 15.6 8M7 8.4l1.6 7.2M16.4 10.2l-5.6 6"/>',
|
|
13
|
+
services:
|
|
14
|
+
'<rect x="4" y="4" width="16" height="6" rx="1.5"/><rect x="4" y="14" width="16" height="6" rx="1.5"/><path d="M8 7h.01M8 17h.01"/>',
|
|
15
|
+
logs: '<path d="M5 5h14M5 9h10M5 13h14M5 17h8"/>',
|
|
16
|
+
tests:
|
|
17
|
+
'<path d="M9 4h6M10 4v5l-5 9a1.5 1.5 0 0 0 1.3 2h11.4a1.5 1.5 0 0 0 1.3-2l-5-9V4"/>',
|
|
18
|
+
envs: '<circle cx="12" cy="12" r="8"/><path d="M4 12h16M12 4c2.5 2.5 2.5 13.5 0 16M12 4c-2.5 2.5-2.5 13.5 0 16"/>',
|
|
19
|
+
releases: '<path d="M12 3v12M7 10l5 5 5-5M5 20h14"/>',
|
|
20
|
+
settings:
|
|
21
|
+
'<circle cx="12" cy="12" r="3"/><path d="M12 3v3M12 18v3M3 12h3M18 12h3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"/>',
|
|
22
|
+
page: '<rect x="5" y="4" width="14" height="16" rx="2"/><path d="M9 9h6M9 13h6"/>',
|
|
23
|
+
// The prototype's Agents icon: a terminal window with a prompt.
|
|
24
|
+
agents:
|
|
25
|
+
'<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M7 10l3 2-3 2M12 15h5"/>',
|
|
26
|
+
edge: '<path d="M12 3l8 4v5c0 4.5-3.4 8.3-8 9-4.6-.7-8-4.5-8-9V7z"/><path d="M8 12h8M12 8v8"/>',
|
|
27
|
+
// D73: a terminal: a prompt and a cursor, no window.
|
|
28
|
+
terminal: '<path d="M4 7l5 5-5 5M12 18h8"/>',
|
|
29
|
+
// ON-6: the server agent, a speech bubble with a spark.
|
|
30
|
+
assistant:
|
|
31
|
+
'<path d="M5 5h14a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1h-8l-4 3v-3H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z"/><path d="M12 8v4M10 10h4"/>',
|
|
32
|
+
// Hub: a node joined to three (the company's shared place).
|
|
33
|
+
hub: '<circle cx="12" cy="12" r="2.5"/><circle cx="5" cy="6" r="2"/><circle cx="19" cy="6" r="2"/><circle cx="12" cy="20" r="2"/><path d="M6.6 7.2l3.5 3.2M17.4 7.2l-3.5 3.2M12 14.5V18"/>',
|
|
34
|
+
// SEC-2a: who this browser is (the rail footer's identity chip).
|
|
35
|
+
person:
|
|
36
|
+
'<circle cx="12" cy="8" r="3.5"/><path d="M5 20c.8-3.6 3.6-5.5 7-5.5s6.2 1.9 7 5.5"/>',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** An icon's <svg>, aria-hidden (the label is beside it). */
|
|
40
|
+
export function icon(name) {
|
|
41
|
+
const d = ICONS[name] || (/^</.test(name || "") ? name : ICONS.page);
|
|
42
|
+
return '<svg viewBox="0 0 24 24" aria-hidden="true">' + d + "</svg>";
|
|
43
|
+
}
|