@monster-orange/den-ui 0.7.1 → 0.7.4

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 CHANGED
@@ -83,6 +83,36 @@ data and HTML slots; it keeps no copy of the kit's markup, CSS or code.
83
83
  Also `topBarHtml`, `railHtml`, `navItemHtml`, `versionChipHtml`,
84
84
  `reportButtonHtml`, `icon(name)` (`src/icons.js`) and `esc`.
85
85
 
86
+ - **Kind tags (0.7.3).** A pin or a link into another product sets
87
+ `kind` on its nav item: `"project"`, `"den"`, `"service"`, `"hub"`, or
88
+ `{ artifact: "Mock" }` (an artifact pin's own word, in the host's
89
+ language). The kit draws a small uppercase tag at the row's end in the
90
+ scope labels' look, and the tooltip and name are always the kit's:
91
+ "North · Project"; a label that is its kind word reads once ("Hub").
92
+ A badge says what it counts with `what` (`"open"`, `"waiting"`,
93
+ `"down"`, `"running"`) and the kit words it: "North · Den, 3 waiting".
94
+ Hosts pass data, never display text: a `tip`, `title` or `aria-label`
95
+ on an entry with a kind is not used. Any other kind is dropped: the tag
96
+ never names a machine. A project pin may set `icon: { initial: "North" }`
97
+ for its initial in a disc. A pin row gets `aria-keyshortcuts="Delete"`
98
+ from the kit. The nav inventory records each entry's kind and
99
+ `compareNav` reports a `kind` difference. Host text in any rail entry
100
+ (`title`, `aria-label`, `aria-labelledby` or `aria-description` in
101
+ `attrs`, or a badge's `label`) is stamped `data-nav-host-text`:
102
+ `navWarnings` lists it and `compareNav` fails on it (`hostText`).
103
+ `data-*` attrs stay allowed.
104
+
105
+ - **Off entries (0.7.4).** An entry that can't be opened sets `off` to
106
+ why, as data: `"connect"` (not connected yet), `"reconnect"` (its
107
+ sign-in is no longer accepted), `"forbidden"` (not allowed; an admin
108
+ decides), `"unreachable"` (can't be reached right now) or `"config"`
109
+ (its settings have a problem). The kit greys the entry (`.den-off`)
110
+ and words why, in en, es and ja, after the name in the tooltip and
111
+ the accessible name: "Acme Co · Hub, reconnect in Settings"; an entry
112
+ without a kind reads "Docs, can't be reached right now". Any other
113
+ value is dropped (not greyed, no words). The nav inventory records
114
+ each entry's `off` and `compareNav` reports an `off` difference.
115
+
86
116
  - **Slots.** The top bar reads: ☰, the brand, `start` (a search, a scope
87
117
  menu), then the right group: `end` (status chips), Report, `bell`, the
88
118
  version chip, `account`. Report · bell · account keep their place
@@ -47,6 +47,12 @@ export interface NavElement {
47
47
  labelOnly?: boolean;
48
48
  /** The kit's stamp on what it draws (data-nav-kit). */
49
49
  kit?: string;
50
+ /** 0.7.3: a rail entry's kind tag (data-nav-kind): project, den, service, hub, artifact. */
51
+ kind?: string;
52
+ /** 0.7.4: why a rail entry is off (data-nav-off): connect, reconnect, forbidden, unreachable, config. */
53
+ off?: string;
54
+ /** 0.7.3: host text in an entry of the rail (data-nav-host-text): compareNav fails on it. */
55
+ hostText?: string;
50
56
  }
51
57
  export interface NavTheme {
52
58
  id: string;
@@ -84,7 +90,7 @@ export interface NavCompareOptions {
84
90
  export interface NavDiff {
85
91
  key: string;
86
92
  slot: NavSlot | "";
87
- /** "env" (another browser build), "theme" (another theme), "element", "order", "slot", "role", "tag", "name", "classes", "box.<edge>", "style.<prop>", "version". */
93
+ /** "env" (another browser build), "theme" (another theme), "element", "order", "slot", "role", "tag", "name", "classes", "kind", "off", "hostText", "box.<edge>", "style.<prop>", "version". */
88
94
  property: string;
89
95
  reference: string | number;
90
96
  actual: string | number;
@@ -122,7 +128,7 @@ export declare function topSlotDiffs(
122
128
  snap: NavSnapshot,
123
129
  tolerance?: number,
124
130
  ): NavDiff[];
125
- /** 0.7.1: host HTML in the kit's account and search slots (warnings). */
131
+ /** 0.7.1: host HTML in the kit's account and search slots; 0.7.3: host text in an entry of the rail. */
126
132
  export declare function navWarnings(snap: NavSnapshot): string[];
127
133
  export declare function collectNav(
128
134
  page: NavPage,
@@ -21,7 +21,9 @@
21
21
  * entries after its spacer, .den-rail-grow: Settings, the collapse
22
22
  * toggle). For each: its key (below), its parent's key, slot, role, tag,
23
23
  * accessible name, classes, box { x, y, w, h } and computed styles
24
- * (STYLE_PROPS).
24
+ * (STYLE_PROPS), and a rail entry's kind tag (0.7.3: `kind`, compared on
25
+ * every entry both sides draw) and why it is off (0.7.4: `off`, compared
26
+ * the same way).
25
27
  *
26
28
  * The key names an element the same way on every run: `#id` when it has
27
29
  * an id; `[data-nav="x"]` for a rail entry; else its parent's key, " > ",
@@ -300,6 +302,20 @@ export async function collectNav(page, opts = {}) {
300
302
  ...(el.hasAttribute("data-nav-kit")
301
303
  ? { kit: el.getAttribute("data-nav-kit") }
302
304
  : {}),
305
+ // Issue 307: a rail entry's kind tag (project, den, service,
306
+ // hub, artifact), compared across products.
307
+ ...(el.hasAttribute("data-nav-kind")
308
+ ? { kind: el.getAttribute("data-nav-kind") }
309
+ : {}),
310
+ // Issue 326: why an entry is off (greyed), compared across
311
+ // products.
312
+ ...(el.hasAttribute("data-nav-off")
313
+ ? { off: el.getAttribute("data-nav-off") }
314
+ : {}),
315
+ // 0.7.3: host text in an entry of the rail (the kit stamps it).
316
+ ...(el.hasAttribute("data-nav-host-text")
317
+ ? { hostText: el.getAttribute("data-nav-host-text") }
318
+ : {}),
303
319
  });
304
320
  }
305
321
  if (el.tagName.toLowerCase() === "svg") return mySlot;
@@ -678,6 +694,10 @@ export function navWarnings(snap) {
678
694
  out.push(
679
695
  `account: ${e.key} is not the kit's (host HTML; draw it with accountHtml)`,
680
696
  );
697
+ if (e.hostText)
698
+ out.push(
699
+ `rail entry: ${e.key} has the host's ${e.hostText} (pass data: the kit owns its words)`,
700
+ );
681
701
  if (
682
702
  e.slot === "top" &&
683
703
  e.classes.includes("den-search") &&
@@ -881,9 +901,36 @@ export function compareNav(actual, reference, opts = {}) {
881
901
  );
882
902
  // Issue 303: the search's slot, from the viewport alone.
883
903
  diffs.push(...topSlotDiffs(actual, tol));
904
+ // Issue 307: an entry both sides draw (host content too: its key is its
905
+ // data-nav id) has the same kind tag, or none on both. The tag's look is
906
+ // the "kind" role's, compared below with the first of each role.
907
+ {
908
+ const wantKind = new Map(allWant.map((e) => [e.key, e]));
909
+ for (const g of allGot) {
910
+ const w = wantKind.get(g.key);
911
+ if (w && (w.kind ?? "") !== (g.kind ?? ""))
912
+ add(w, "kind", w.kind ?? "(none)", g.kind ?? "(none)");
913
+ // Issue 326: an entry off on one side is off, for the same reason,
914
+ // on the other.
915
+ if (w && (w.off ?? "") !== (g.off ?? ""))
916
+ add(w, "off", w.off ?? "(none)", g.off ?? "(none)");
917
+ }
918
+ }
884
919
  // A crumb's value outlasts its label: one whose label shows while its
885
920
  // value is hidden fails, whatever the reference drew (crumbs are host
886
921
  // content, so this is checked on every element drawn).
922
+ // 0.7.3: hosts pass data; the kit owns a rail entry's words. Host text
923
+ // on an entry (a title, aria-label, aria-labelledby, aria-description,
924
+ // a badge's label) fails, whatever the reference drew.
925
+ for (const g of actual.elements)
926
+ if (g.hostText)
927
+ diffs.push({
928
+ key: g.key,
929
+ slot: g.slot,
930
+ property: "hostText",
931
+ reference: "none",
932
+ actual: g.hostText,
933
+ });
887
934
  for (const g of actual.elements)
888
935
  if (g.labelOnly)
889
936
  diffs.push({
@@ -970,14 +1017,28 @@ export function compareNav(actual, reference, opts = {}) {
970
1017
  // Name over @login is taller than @login alone: an entry with another
971
1018
  // line count than the reference's (both the kit's shapes) moves nothing
972
1019
  // else's place; its own height and what it centres are its data.
1020
+ const tall = /^(box\.(height|top|bottom)|style\.height)$/;
973
1021
  const acct = actual.elements.find((e) => e.account);
974
1022
  const acctRef = acct && reference.elements.find((e) => e.key === acct.key);
975
- if (acct && acctRef && (acct.lines ?? 0) !== (acctRef.lines ?? 0)) {
976
- const own = (k) => k === acct.key || k.startsWith(acct.key + " >");
977
- const tall = /^(box\.(height|top|bottom)|style\.height)$/;
978
- return diffs.filter((d) => !(own(d.key) && tall.test(d.property)));
979
- }
980
- return diffs;
1023
+ const acctOwn =
1024
+ acct && acctRef && (acct.lines ?? 0) !== (acctRef.lines ?? 0)
1025
+ ? (k) => k === acct.key || k.startsWith(acct.key + " >")
1026
+ : () => false;
1027
+ // Issue 313: a container empty on one side and holding something on
1028
+ // the other is as tall as what it holds; its top, bottom and height are
1029
+ // not compared (its x and width are). Children by the recorded parent.
1030
+ const kids = (snap) => {
1031
+ const n = new Map();
1032
+ for (const e of snap.elements)
1033
+ if (e.parent) n.set(e.parent, (n.get(e.parent) || 0) + 1);
1034
+ return n;
1035
+ };
1036
+ const ka = kids(actual);
1037
+ const kr = kids(reference);
1038
+ const emptyOneSide = (k) => !ka.get(k) !== !kr.get(k);
1039
+ return diffs.filter(
1040
+ (d) => !(tall.test(d.property) && (acctOwn(d.key) || emptyOneSide(d.key))),
1041
+ );
981
1042
  function styles(w, g, skip) {
982
1043
  for (const p of STYLE_PROPS) {
983
1044
  if (skip.includes(p)) continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monster-orange/den-ui",
3
- "version": "0.7.1",
3
+ "version": "0.7.4",
4
4
  "description": "Den's UI kit: tokens, fonts and shared components, framework-free",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/busy.d.ts CHANGED
@@ -5,6 +5,7 @@ export declare const NO_ANSWER_MS: number;
5
5
  export declare const SUCCESS_CLOSE_MS: number;
6
6
  export declare const POLL_MS: number;
7
7
  export declare const POLL_MAX_MS: number;
8
+ export declare const ASK_MS: number;
8
9
 
9
10
  export type Words = Record<string, Record<string, string>>;
10
11
  /** Check again's answer: how a request id ended. */
package/src/busy.js CHANGED
@@ -67,6 +67,9 @@
67
67
  * Reconnect mode: the request may get no answer (the product stopped
68
68
  * first); that counts as going down, and the pop-up waits for it to come
69
69
  * back. busyAction then resolves with the new answer from reconnect.url.
70
+ * Each ask of reconnect.url gives up after ASK_MS: an ask in flight as the
71
+ * product goes down (or one a proxy holds) may never be answered, and the
72
+ * next ask must still come.
70
73
  *
71
74
  * The request contract (Settled in v2): Try again sends the same id only
72
75
  * when no answer came back; after the server answered with an error it
@@ -84,6 +87,7 @@ export const NO_ANSWER_MS = 60_000;
84
87
  export const SUCCESS_CLOSE_MS = 1200;
85
88
  export const POLL_MS = 1000;
86
89
  export const POLL_MAX_MS = 3000;
90
+ export const ASK_MS = 3000;
87
91
 
88
92
  const hook = {
89
93
  lang: () =>
@@ -206,6 +210,20 @@ function newId() {
206
210
 
207
211
  const later = (ms) => new Promise((r) => setTimeout(r, ms));
208
212
 
213
+ /** One ask of the reconnect url: its JSON, or null (no answer in ASK_MS). */
214
+ async function askOnce(url) {
215
+ const stop = new AbortController();
216
+ const timer = setTimeout(() => stop.abort(), ASK_MS);
217
+ try {
218
+ const r = await fetch(url, { cache: "no-store", signal: stop.signal });
219
+ return r.ok ? await r.json() : null;
220
+ } catch {
221
+ return null;
222
+ } finally {
223
+ clearTimeout(timer);
224
+ }
225
+ }
226
+
209
227
  /** The first message with words: the error's own, its answer's, nothing. */
210
228
  export function messageOf(err) {
211
229
  const tries = [
@@ -625,13 +643,7 @@ export function busyAction(name, run, opts = {}) {
625
643
  while (!settled && Date.now() - startedAt < limit) {
626
644
  await later(gap);
627
645
  gap = Math.min(POLL_MAX_MS, gap + 500);
628
- let now = null;
629
- try {
630
- const r = await fetch(rc.url, { cache: "no-store" });
631
- now = r.ok ? await r.json() : null;
632
- } catch {
633
- now = null;
634
- }
646
+ const now = await askOnce(rc.url);
635
647
  if (settled) return;
636
648
  if (now && rc.back(now, before)) {
637
649
  const v = rc.version?.(now) ?? "";
@@ -650,13 +662,10 @@ export function busyAction(name, run, opts = {}) {
650
662
  // Reconnect mode: how the product answered before it went away.
651
663
  let before = opts.before ?? null;
652
664
  if (reconnect && hook.reconnect && !before)
653
- fetch(hook.reconnect.url, { cache: "no-store" })
654
- .then((r) => (r.ok ? r.json() : null))
655
- .catch(() => null)
656
- .then((b) => {
657
- before = b;
658
- attempt();
659
- });
665
+ askOnce(hook.reconnect.url).then((b) => {
666
+ before = b;
667
+ attempt();
668
+ });
660
669
  else attempt();
661
670
  return result;
662
671
  }
@@ -229,7 +229,13 @@ export function hydrateShell(root, opts = {}) {
229
229
  else el.removeAttribute("inert");
230
230
  }
231
231
  }
232
+ // The drawer's slide is armed on the person's first open or close only
233
+ // (shell.css: body.den-rail-moved), so a load never slides it (issue 311).
234
+ function armSlide() {
235
+ document.body.classList.add("den-rail-moved");
236
+ }
232
237
  function openDrawer() {
238
+ armSlide();
233
239
  document.body.classList.add("den-rail-open");
234
240
  if (menu) menu.setAttribute("aria-expanded", "true");
235
241
  railBox.setAttribute("role", "dialog");
@@ -250,6 +256,7 @@ export function hydrateShell(root, opts = {}) {
250
256
  }
251
257
  function closeDrawer(refocus) {
252
258
  if (!drawerOpen()) return;
259
+ armSlide();
253
260
  document.body.classList.remove("den-rail-open");
254
261
  if (menu) menu.setAttribute("aria-expanded", "false");
255
262
  railBox.removeAttribute("role");
@@ -17,15 +17,44 @@ export interface Product {
17
17
  */
18
18
  mark?: Mark | null;
19
19
  }
20
+ /** 0.7.3: the fixed kinds a rail entry's tag may name. */
21
+ export type NavKindId = "project" | "den" | "service" | "hub";
22
+ /**
23
+ * 0.7.3: a rail entry's kind: a fixed one (any case), or an artifact pin's
24
+ * own kind word (the host's, in its language). Never a machine's name.
25
+ */
26
+ export type NavKind = NavKindId | Uppercase<NavKindId> | { artifact: string };
27
+ /**
28
+ * 0.7.4: why a rail entry is off (greyed; the kit's words say why):
29
+ * not connected yet, its sign-in no longer accepted, not allowed (an
30
+ * admin decides), can't be reached, or its settings have a problem.
31
+ */
32
+ export type NavOff =
33
+ | "connect"
34
+ | "reconnect"
35
+ | "forbidden"
36
+ | "unreachable"
37
+ | "config";
38
+ /** 0.7.3: what a rail badge counts (the kit's words for it). */
39
+ export type BadgeWhat = "open" | "waiting" | "down" | "running";
40
+ /** 0.7.3: a project's initial, in a disc in place of the icon. */
41
+ export interface NavInitial {
42
+ initial: string;
43
+ }
20
44
  export interface NavItem {
21
45
  id: string;
22
46
  label: string;
23
47
  href: string;
24
48
  group?: string;
25
- icon?: string;
49
+ /** An icon's name (icons.js), or (0.7.3) a project's initial disc. */
50
+ icon?: string | NavInitial;
26
51
  tip?: string;
27
52
  current?: boolean;
28
- badge?: { n: number | string; bad?: boolean; label?: string } | null;
53
+ /**
54
+ * A count. `what` (0.7.3): what it counts; the kit words it with the
55
+ * name ("North · Den, 3 waiting"). Hosts pass data, never the words.
56
+ */
57
+ badge?: { n: number | string; bad?: boolean; what?: BadgeWhat } | null;
29
58
  /** HTML in place of the icon (a status dot). */
30
59
  lead?: string;
31
60
  mono?: boolean;
@@ -35,6 +64,18 @@ export interface NavItem {
35
64
  pin?: string | null;
36
65
  /** HTML after the link inside the pin row. */
37
66
  after?: string;
67
+ /**
68
+ * 0.7.3: a small uppercase tag at the row's end (pins and links into
69
+ * another product); the tooltip and name are always the kit's,
70
+ * "<label> · <Kind>" (a host's tip, title or aria-label is not used).
71
+ */
72
+ kind?: NavKind | null;
73
+ /**
74
+ * 0.7.4: the entry is off: greyed (.den-off), and its tooltip and name
75
+ * say why in the kit's words ("Acme Co · Hub, reconnect in Settings").
76
+ * Any other value is dropped.
77
+ */
78
+ off?: NavOff | null;
38
79
  }
39
80
  export interface NavGroup {
40
81
  id: string;
@@ -70,7 +111,26 @@ export interface ShellModel extends RailModel {
70
111
  /** false: no Report button (reports off). */
71
112
  report?: boolean;
72
113
  }
73
- export declare function navItemHtml(n: NavItem, navRole?: string): string;
114
+ export declare function navItemHtml(
115
+ n: NavItem,
116
+ navRole?: string,
117
+ lang?: string,
118
+ ): string;
119
+ /** 0.7.3: attributes that carry a host's words (flagged in an entry of the rail). */
120
+ export declare const HOST_TEXT_ATTRS: readonly string[];
121
+ /** 0.7.3: what a badge may count. */
122
+ export declare const BADGE_WHATS: readonly BadgeWhat[];
123
+ /** 0.7.3: the fixed kinds. */
124
+ export declare const NAV_KINDS: readonly NavKindId[];
125
+ /** 0.7.4: the reasons an entry may be off. */
126
+ export declare const NAV_OFFS: readonly NavOff[];
127
+ /** 0.7.4: an entry's off reason, from its data (any case), or null. */
128
+ export declare function navOff(off: unknown): NavOff | null;
129
+ /** 0.7.3: a kind's id ("artifact" for an artifact's) and its word. */
130
+ export declare function navKind(
131
+ kind: NavKind | null | undefined,
132
+ lang?: string,
133
+ ): { id: NavKindId | "artifact"; word: string } | null;
74
134
  export declare function railGroupHtml(
75
135
  g: NavGroup,
76
136
  body: string,
package/src/shell-html.js CHANGED
@@ -17,7 +17,8 @@
17
17
  * { text?, svg?, label } the mark beside it (text escaped;
18
18
  * svg the product's own markup; label its name)
19
19
  * nav [{ id, label, href, group, icon?, tip?, current?, badge?,
20
- * lead?, mono?, cls?, attrs?, pin?, after? }] rail entries
20
+ * lead?, mono?, cls?, attrs?, pin?, after?, kind?, off? }] rail
21
+ * entries
21
22
  * groups [{ id, label, from? }] in rail order; a group with no
22
23
  * entry is left out
23
24
  * foot entries under the rail's spacer (Settings, say), then the
@@ -34,11 +35,18 @@
34
35
  * collapsed the rail drawn collapsed (the toggle says Expand)
35
36
  * report false: no Report button (reports off)
36
37
  *
37
- * An entry: `badge` { n, bad?, label? } (label is read with the name);
38
+ * An entry: `badge` { n, bad?, what? } (what it counts: "open",
39
+ * "waiting", "down", "running", read with the name in the kit's words);
38
40
  * `lead` HTML in place of the icon (a status dot); `attrs` more
39
41
  * attributes { name: value } (escaped); `cls` more classes; `pin` the
40
42
  * pinned id (the row is a pin row: Delete unpins it); `after` HTML after
41
- * the link inside the pin row (a Visit link).
43
+ * the link inside the pin row (a Visit link); `kind` (0.7.3) "project",
44
+ * "den", "service", "hub" or { artifact: word }: a small uppercase tag at
45
+ * the row's end; its tooltip and name are the kit's ("North · Project");
46
+ * `off` (0.7.4) "connect", "reconnect", "forbidden", "unreachable" or
47
+ * "config": the entry is greyed and the kit says why ("Acme Co · Hub,
48
+ * reconnect in Settings"); `icon`
49
+ * { initial } a project's initial in a disc in place of the icon.
42
50
  *
43
51
  * 0.7.0, for the slots: scopeHtml (the scope crumbs), searchHtml (the
44
52
  * search field with ⌘K inside), bellButtonHtml and bellPanelHtml (the
@@ -61,14 +69,128 @@ function attrs(o) {
61
69
  return s;
62
70
  }
63
71
 
72
+ /** The fixed kinds a rail entry may name (issue 307). */
73
+ export const NAV_KINDS = ["project", "den", "service", "hub"];
74
+
75
+ /**
76
+ * A rail entry's kind (issue 307), from its data: one of NAV_KINDS (any
77
+ * case), or { artifact: "<word>" }, an artifact pin's own kind word (the
78
+ * host's, already in its language). Anything else is no kind: the tag
79
+ * never names a machine. → { id, word } or null.
80
+ */
81
+ export function navKind(kind, lang) {
82
+ if (kind == null) return null;
83
+ if (typeof kind === "string") {
84
+ const id = kind.trim().toLowerCase();
85
+ return NAV_KINDS.includes(id)
86
+ ? { id, word: kitT(lang, "kit.kind." + id) }
87
+ : null;
88
+ }
89
+ if (typeof kind === "object" && kind.artifact != null) {
90
+ const word = String(kind.artifact).trim();
91
+ return word ? { id: "artifact", word } : null;
92
+ }
93
+ return null;
94
+ }
95
+
96
+ /**
97
+ * Attributes that carry a host's words, not data: never in an entry of the rail
98
+ * (issue 307). data-* attributes are data and stay allowed.
99
+ */
100
+ export const HOST_TEXT_ATTRS = [
101
+ "title",
102
+ "aria-label",
103
+ "aria-labelledby",
104
+ "aria-description",
105
+ ];
106
+
107
+ /** What a badge counts (issue 307): the kit words it. */
108
+ export const BADGE_WHATS = ["open", "waiting", "down", "running"];
109
+
110
+ /**
111
+ * Why a rail entry is off (issue 326): the kit greys it (.den-off) and
112
+ * words why. "connect" (not connected yet), "reconnect" (its sign-in is
113
+ * no longer accepted), "forbidden" (not allowed; an admin decides),
114
+ * "unreachable" (can't be reached right now), "config" (its settings have
115
+ * a problem). Anything else is dropped.
116
+ */
117
+ export const NAV_OFFS = [
118
+ "connect",
119
+ "reconnect",
120
+ "forbidden",
121
+ "unreachable",
122
+ "config",
123
+ ];
124
+
125
+ /** An entry's off reason, from its data, or null. */
126
+ export function navOff(off) {
127
+ const id = typeof off === "string" ? off.trim().toLowerCase() : "";
128
+ return NAV_OFFS.includes(id) ? id : null;
129
+ }
130
+
131
+ /**
132
+ * A badge's words, from its data: "3 waiting". Without a `what` (a plain
133
+ * total) the kit reads the bare number, so "Hub Docs, 4" still says the
134
+ * count the visible badge (aria-hidden) shows. Nothing to count: none.
135
+ */
136
+ function badgeWords(b, lang) {
137
+ if (!b || b.n == null || b.n === "") return "";
138
+ const n = typeof b.n === "number" ? b.n : String(b.n);
139
+ if (BADGE_WHATS.includes(b.what))
140
+ return kitT(lang, "kit.badge." + b.what, { n });
141
+ if (typeof n !== "number") return n;
142
+ try {
143
+ return new Intl.NumberFormat(lang || undefined).format(n);
144
+ } catch {
145
+ return String(n);
146
+ }
147
+ }
148
+
149
+ /** The icon, or (issue 307) a project's initial in a disc: { initial }. */
150
+ function leadIcon(ic) {
151
+ if (ic && typeof ic === "object") {
152
+ const ch = Array.from(String(ic.initial ?? "").trim())[0] || "";
153
+ return (
154
+ '<span class="den-ini" aria-hidden="true">' +
155
+ esc(ch.toLocaleUpperCase()) +
156
+ "</span>"
157
+ );
158
+ }
159
+ return icon(ic);
160
+ }
161
+
64
162
  /**
65
163
  * One rail entry (a link, .den-ni). `navRole`: the data-nav-role the nav
66
164
  * inventory reads ("page" for a rail group's entries: host content).
165
+ * `lang`: the kit's words (the kind tag's).
166
+ *
167
+ * `kind` (issue 307): a small uppercase tag at the row's end, in the scope
168
+ * labels' look (.den-k), for pins and links into another product. The
169
+ * tooltip and the name are always the kit's: "<label> · <Kind>" (and a
170
+ * badge's label after a comma), so a collapsed rail still says it. A
171
+ * host's tip, title or aria-label on such an entry is not used: hosts pass
172
+ * data, the kit owns the words.
173
+ *
174
+ * `badge.what` ("open", "waiting", "down", "running"): what the badge
175
+ * counts; the kit words it ("North · Den, 3 waiting"). Without one, the
176
+ * bare number reads ("Hub Docs, 4"). A label that is
177
+ * its kind word reads once ("Hub", not "Hub · Hub"). A pin row gets
178
+ * aria-keyshortcuts="Delete" from the kit.
179
+ *
180
+ * `off` (issue 326, NAV_OFFS): the entry is greyed (.den-off) and its
181
+ * tooltip and name say why in the kit's words ("Acme Co · Hub, reconnect
182
+ * in Settings"); an entry without a kind reads "<label>, <why>". An `off`
183
+ * the kit doesn't know is dropped.
184
+ *
185
+ * Host text on any entry (HOST_TEXT_ATTRS in `attrs`, a badge's `label`)
186
+ * is stamped data-nav-host-text, and the nav inventory fails on it.
67
187
  */
68
- export function navItemHtml(n, navRole) {
188
+ export function navItemHtml(n, navRole, lang) {
69
189
  const role =
70
190
  typeof navRole === "string" ? ' data-nav-role="' + esc(navRole) + '"' : "";
71
191
  const b = n.badge || null;
192
+ const kind = navKind(n.kind, lang);
193
+ const off = navOff(n.off);
72
194
  const extra = b
73
195
  ? '<span class="den-bdg' +
74
196
  (b.bad ? " bad" : "") +
@@ -76,12 +198,42 @@ export function navItemHtml(n, navRole) {
76
198
  esc(b.n) +
77
199
  "</span>"
78
200
  : "";
201
+ const tag = kind
202
+ ? '<span class="den-k den-ni-kind" data-nav-role="kind" aria-hidden="true">' +
203
+ esc(kind.word) +
204
+ "</span>"
205
+ : "";
79
206
  const more = { ...(n.attrs || {}) };
80
- if (b && b.label && more["aria-label"] == null)
81
- more["aria-label"] = n.label + ", " + b.label;
207
+ // Host text: words a host put on the entry itself. Never used on an
208
+ // entry with a kind; stamped for the nav inventory, which fails on it.
209
+ const hostText = HOST_TEXT_ATTRS.filter((k) => more[k] != null);
210
+ if (b && b.label != null) hostText.push("badge.label");
211
+ // A label that is its kind word (any case) reads once: "Hub", never
212
+ // "Hub · Hub".
213
+ const same =
214
+ kind &&
215
+ String(n.label).trim().toLocaleLowerCase() ===
216
+ kind.word.trim().toLocaleLowerCase();
217
+ const named = kind && !same ? n.label + " · " + kind.word : n.label;
218
+ const counted = badgeWords(b, lang);
219
+ // Issue 326: why it is off, in the kit's words, after the name.
220
+ const why = off ? kitT(lang, "kit.off." + off) : "";
221
+ const tip = why ? named + ", " + why : named;
222
+ if (kind || off) {
223
+ for (const k of HOST_TEXT_ATTRS) delete more[k];
224
+ more["aria-label"] = [named, counted, why].filter(Boolean).join(", ");
225
+ if (kind) more["data-nav-kind"] = kind.id;
226
+ if (off) more["data-nav-off"] = off;
227
+ } else if (more["aria-label"] == null && (counted || (b && b.label)))
228
+ // Without a kind, as before: a badge's label still reads (flagged).
229
+ more["aria-label"] = named + ", " + (counted || b.label);
230
+ // A pin row's Delete (unpin) is the kit's own feature: its shortcut too.
231
+ if (n.pin != null) more["aria-keyshortcuts"] = "Delete";
232
+ if (hostText.length) more["data-nav-host-text"] = hostText.join(",");
82
233
  const link =
83
234
  '<a class="den-ni' +
84
235
  (n.cls ? " " + esc(n.cls) : "") +
236
+ (off ? " den-off" : "") +
85
237
  '" href="' +
86
238
  esc(n.href) +
87
239
  '" data-nav="' +
@@ -91,15 +243,16 @@ export function navItemHtml(n, navRole) {
91
243
  (n.current ? ' aria-current="page"' : "") +
92
244
  attrs(more) +
93
245
  ' title="' +
94
- esc(n.tip || n.label) +
246
+ esc(kind || off ? tip : n.tip || n.label) +
95
247
  '">' +
96
- (n.lead || icon(n.icon)) +
248
+ (n.lead || leadIcon(n.icon)) +
97
249
  '<span class="den-lbl' +
98
250
  (n.mono ? " den-mono" : "") +
99
251
  '">' +
100
252
  esc(n.label) +
101
253
  "</span>" +
102
254
  extra +
255
+ tag +
103
256
  "</a>";
104
257
  return n.pin != null
105
258
  ? '<div class="den-pin-row"' +
@@ -177,13 +330,13 @@ export function railHtml({
177
330
  if (!items.length) continue;
178
331
  html += railGroupHtml(
179
332
  g,
180
- items.map((n) => navItemHtml(n, "page")).join(""),
333
+ items.map((n) => navItemHtml(n, "page", lang)).join(""),
181
334
  lang,
182
335
  );
183
336
  }
184
337
  html += '<div class="den-rail-grow"></div>';
185
338
  html += foot
186
- .map((n) => (typeof n === "string" ? n : navItemHtml(n)))
339
+ .map((n) => (typeof n === "string" ? n : navItemHtml(n, undefined, lang)))
187
340
  .join("");
188
341
  html += settingsHtml(settings, lang);
189
342
  html += accountHtml(account);
package/src/shell.css CHANGED
@@ -537,6 +537,25 @@ body.den-has-shell > #den-content {
537
537
  background: color-mix(in srgb, var(--bad) 16%, transparent);
538
538
  color: var(--bad);
539
539
  }
540
+ /* Issue 307: a pin's or a cross-app link's kind (PROJECT, DEN, SERVICE,
541
+ HUB, an artifact's word), at the row's end. Its look is the scope
542
+ labels' (.den-k); this only places it. */
543
+ .den-ni-kind {
544
+ flex: none;
545
+ white-space: nowrap;
546
+ }
547
+ /* A project pin's initial, in a disc the icon's size, in place of it. */
548
+ .den-ini {
549
+ width: 18px;
550
+ height: 18px;
551
+ flex: none;
552
+ border-radius: 50%;
553
+ display: inline-grid;
554
+ place-items: center;
555
+ background: var(--sunken);
556
+ color: var(--text);
557
+ font: 500 11px/1 var(--sans);
558
+ }
540
559
  .den-rail-grow {
541
560
  flex: 1;
542
561
  }
@@ -611,7 +630,8 @@ body.den-has-shell > #den-content {
611
630
  color: var(--muted);
612
631
  border-color: transparent;
613
632
  }
614
- body.den-rail-collapsed .den-rail .den-pvisit {
633
+ body.den-rail-collapsed .den-rail .den-pvisit,
634
+ body.den-rail-collapsed .den-rail .den-ni-kind {
615
635
  display: none;
616
636
  }
617
637
  @media (max-width: 720px) {
@@ -622,6 +642,9 @@ body.den-rail-collapsed .den-rail .den-pvisit {
622
642
  body.den-rail-collapsed .den-rail .den-pvisit {
623
643
  display: grid;
624
644
  }
645
+ body.den-rail-collapsed .den-rail .den-ni-kind {
646
+ display: inline;
647
+ }
625
648
  }
626
649
  body.den-rail-collapsed .den-rail .den-lbl,
627
650
  body.den-rail-collapsed .den-rail .den-gh,
@@ -652,10 +675,16 @@ body.den-has-shell .den-upd {
652
675
  }
653
676
  .den-rail {
654
677
  transform: translateX(-105%);
655
- transition: transform 0.18s;
656
678
  box-shadow: var(--shadow);
657
679
  z-index: 42;
658
680
  }
681
+ /* The drawer slides only once the person has opened or closed it
682
+ (shell-client adds den-rail-moved then). Before that, a load or a
683
+ window narrowing past 720 puts the rail straight where it belongs;
684
+ a transition here slid it across the page (issue 311). */
685
+ body.den-rail-moved .den-rail {
686
+ transition: transform 0.18s;
687
+ }
659
688
  body.den-rail-open .den-rail {
660
689
  transform: none;
661
690
  }
@@ -713,7 +742,8 @@ body.den-has-shell .den-upd {
713
742
  }
714
743
  }
715
744
  @media (prefers-reduced-motion: reduce) {
716
- .den-rail {
745
+ .den-rail,
746
+ body.den-rail-moved .den-rail {
717
747
  transition: none;
718
748
  }
719
749
  }
package/src/strings.js CHANGED
@@ -47,6 +47,19 @@ export const en = {
47
47
  "kit.version.title": "View changelog",
48
48
  "kit.pin.pinX": "Pin {s}",
49
49
  "kit.pin.unpinX": "Unpin {s}",
50
+ "kit.badge.open": "{n} open",
51
+ "kit.badge.waiting": "{n} waiting",
52
+ "kit.badge.down": "{n} down",
53
+ "kit.badge.running": "{n} running",
54
+ "kit.kind.project": "Project",
55
+ "kit.kind.den": "Den",
56
+ "kit.kind.service": "Service",
57
+ "kit.kind.hub": "Hub",
58
+ "kit.off.connect": "connect in Settings",
59
+ "kit.off.reconnect": "reconnect in Settings",
60
+ "kit.off.forbidden": "ask an admin for access",
61
+ "kit.off.unreachable": "can't be reached right now",
62
+ "kit.off.config": "check Settings",
50
63
  "kit.whatsnew.title": "What's new",
51
64
  "kit.whatsnew.close": "Close",
52
65
  "kit.whatsnew.gotIt": "Got it",
@@ -205,6 +218,21 @@ export const es = {
205
218
  "kit.version.title": "Ver el registro de cambios",
206
219
  "kit.pin.pinX": "Fijar {s}",
207
220
  "kit.pin.unpinX": "Quitar {s}",
221
+ "kit.badge.open": "{n} abiertos",
222
+ "kit.badge.open.one": "{n} abierto",
223
+ "kit.badge.waiting": "{n} en espera",
224
+ "kit.badge.down": "{n} caídos",
225
+ "kit.badge.down.one": "{n} caído",
226
+ "kit.badge.running": "{n} en marcha",
227
+ "kit.kind.project": "Proyecto",
228
+ "kit.kind.den": "Den",
229
+ "kit.kind.service": "Servicio",
230
+ "kit.kind.hub": "Hub",
231
+ "kit.off.connect": "conéctalo en Ajustes",
232
+ "kit.off.reconnect": "vuelve a conectarlo en Ajustes",
233
+ "kit.off.forbidden": "pide acceso a un administrador",
234
+ "kit.off.unreachable": "no responde ahora mismo",
235
+ "kit.off.config": "revisa Ajustes",
208
236
  "kit.whatsnew.title": "Novedades",
209
237
  "kit.whatsnew.close": "Cerrar",
210
238
  "kit.whatsnew.gotIt": "Entendido",
@@ -367,6 +395,19 @@ export const ja = {
367
395
  "kit.version.title": "変更履歴を見る",
368
396
  "kit.pin.pinX": "{s} をピン留め",
369
397
  "kit.pin.unpinX": "{s} のピン留めを外す",
398
+ "kit.badge.open": "{n} 件開いています",
399
+ "kit.badge.waiting": "{n} 件待機中",
400
+ "kit.badge.down": "{n} 件停止",
401
+ "kit.badge.running": "{n} 件実行中",
402
+ "kit.kind.project": "プロジェクト",
403
+ "kit.kind.den": "Den",
404
+ "kit.kind.service": "サービス",
405
+ "kit.kind.hub": "Hub",
406
+ "kit.off.connect": "設定で接続してください",
407
+ "kit.off.reconnect": "設定で再接続してください",
408
+ "kit.off.forbidden": "管理者にアクセスを依頼してください",
409
+ "kit.off.unreachable": "現在接続できません",
410
+ "kit.off.config": "設定を確認してください",
370
411
  "kit.whatsnew.title": "新着情報",
371
412
  "kit.whatsnew.close": "閉じる",
372
413
  "kit.whatsnew.gotIt": "OK",