@mistriwork/kit 1.0.0-rc.38 → 1.0.0-rc.40

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.
@@ -12,7 +12,7 @@ import { useRef, useState } from 'react';
12
12
  import { formatBytes } from '../locale.js';
13
13
  import { toast } from '../core.js';
14
14
  import { Empty } from './Notes.js';
15
- import { Button, buttonClass } from '@mistriwork/ui/Button.js';
15
+ import { Button, ButtonLink } from '@mistriwork/ui/Button.js';
16
16
  import { Field } from '@mistriwork/ui/Field.js';
17
17
  import { Modal } from '@mistriwork/ui/Modal.js';
18
18
  import { DropItem, DropMenu } from '@mistriwork/ui/DropMenu.js';
@@ -119,7 +119,7 @@ export function AttachmentList({ items, emptyText, empty, upload }) {
119
119
  return (_jsxs("li", { className: "attachments-item", children: [_jsx("span", { className: "attachments-badge", "aria-hidden": "true", children: badge(item.name) }), renaming === item.id && item.rename ? (_jsx(RenameRow, { item: item, onDone: () => setRenaming(undefined) })) : (_jsxs(_Fragment, { children: [_jsxs("span", { className: "attachments-text", children: [preview ? (_jsx("button", { type: "button", className: "attachments-name", title: say('preview', { name: item.name }), onClick: (event) => {
120
120
  back.current = event.currentTarget;
121
121
  setPreviewing(preview);
122
- }, children: item.name })) : (_jsx("a", { className: "attachments-name", href: item.href, download: item.name, onClick: saveOnLease(item), children: item.name })), item.meta.length > 0 && _jsx("span", { className: "attachments-meta", children: item.meta.join(' · ') })] }), _jsxs("span", { className: "attachments-actions", children: [_jsx("a", { className: buttonClass({ intent: 'quiet', size: 'compact', className: 'attachments-download' }), href: item.href, download: item.name, onClick: saveOnLease(item), "aria-label": say('downloadName', { name: item.name }), children: say('download') }), (item.onOpen || item.rename || item.remove) && (_jsxs(DropMenu, { className: "row-actions-menu", triggerClassName: "ghost row-actions-trigger", triggerTitle: say('more', { name: item.name }), triggerLabel: say('more', { name: item.name }), label: "\u22EF", popupClassName: "page-actions-popup", align: "end", children: [item.onOpen && (_jsx(DropItem, { className: "page-actions-item", onClick: item.onOpen, children: say('detailsItem') })), item.rename && (_jsx(DropItem, { className: "page-actions-item", onClick: () => setRenaming(item.id), children: say('common.rename') })), item.remove && (_jsx(DropItem, { className: "page-actions-item is-danger", onClick: () => setRemoving(item), children: say('removeMore') }))] }))] })] }))] }, item.id));
122
+ }, children: item.name })) : (_jsx("a", { className: "attachments-name", href: item.href, download: item.name, onClick: saveOnLease(item), children: item.name })), item.meta.length > 0 && _jsx("span", { className: "attachments-meta", children: item.meta.join(' · ') })] }), _jsxs("span", { className: "attachments-actions", children: [_jsx(ButtonLink, { intent: "quiet", size: "compact", className: "attachments-download", href: item.href, download: item.name, onClick: saveOnLease(item), "aria-label": say('downloadName', { name: item.name }), children: say('download') }), (item.onOpen || item.rename || item.remove) && (_jsxs(DropMenu, { className: "row-actions-menu", triggerClassName: "ghost row-actions-trigger", triggerTitle: say('more', { name: item.name }), triggerLabel: say('more', { name: item.name }), label: "\u22EF", popupClassName: "page-actions-popup", align: "end", children: [item.onOpen && (_jsx(DropItem, { className: "page-actions-item", onClick: item.onOpen, children: say('detailsItem') })), item.rename && (_jsx(DropItem, { className: "page-actions-item", onClick: () => setRenaming(item.id), children: say('common.rename') })), item.remove && (_jsx(DropItem, { className: "page-actions-item is-danger", onClick: () => setRemoving(item), children: say('removeMore') }))] }))] })] }))] }, item.id));
123
123
  }) })) : ((empty ?? _jsx(Empty, { className: "attachments-empty", text: emptyText }))), previewing && _jsx(FilePreview, { file: previewing, onClose: () => setPreviewing(undefined), finalFocus: back }), removing && _jsx(RemoveConfirm, { item: removing, onClose: () => setRemoving(undefined) })] }));
124
124
  }
125
125
  /** The name, edited where it stood: Enter saves, Escape puts it back. */
@@ -24,6 +24,9 @@ const tickSay = (say) => say.tick ?? say;
24
24
  const f1 = (n) => n.toFixed(1);
25
25
  const MONTH = /^(\d{4})-(\d{2})$/;
26
26
  const DAY = /^(\d{4})-\d{2}-\d{2}$/;
27
+ /** A category's key as a chart says it unless told otherwise: a bucket of no value is a dash, never "null". The
28
+ caller's `label` (a column's groupLabel) says it in the field's own `empty` word where it has one. */
29
+ const keyWord = (key) => (key == null ? '—' : String(key));
27
30
  /**
28
31
  * A month bucket as a reader says it, in the App's locale: "Jan 2026" where
29
32
  * the year starts or changes from the tick before it, "Feb" after it. The
@@ -442,7 +445,7 @@ const PERIOD = /^\d{4}(-\d{2}(-\d{2})?|-Q[1-4])?$/;
442
445
  * The levels are on the left, in a gutter of their own, and every bar is a
443
446
  * row of a table assistive technology reads, as a line's points are.
444
447
  */
445
- export function BarChart({ rows, say = String, label = String, wide = 600, high, target, tone, partial, }) {
448
+ export function BarChart({ rows, say = String, label = keyWord, wide = 600, high, target, tone, partial, }) {
446
449
  const periods = rows.length > 0 && rows.every((r) => r.key != null && PERIOD.test(String(r.key)));
447
450
  const bars = periods
448
451
  ? fillGaps(rows.map((r) => ({ key: String(r.key), value: Number(r.value) })).filter((p) => Number.isFinite(p.value))).map((p) => ({ raw: p.key, value: p.value }))
@@ -661,12 +664,12 @@ export function sliceRing(center, radius, from, length, width = 7) {
661
664
  * A donut with its legend: how the whole divides, said twice — arc length
662
665
  * and a labelled figure. Past six slices the tail is gathered into "others".
663
666
  */
664
- export function DonutChart({ rows, say = String, label = String, onPick, total, ordered, tone, }) {
667
+ export function DonutChart({ rows, say = String, label = keyWord, onPick, total, ordered, tone, }) {
665
668
  /* The slice's stroke as the look draws it (.chart-slice: 7 units, 4.5 in Lumen's line charts), read as a slice takes
666
669
  the keyboard, the moment its ring is drawn: a look is picked while the page is open, and a stylesheet says it. */
667
670
  const [sliceWidth, setSliceWidth] = useState(7);
668
671
  const all = rows
669
- .map((r) => ({ key: r.key == null ? '—' : label(r.key), raw: r.key, value: Number(r.value) }))
672
+ .map((r) => ({ key: label(r.key), raw: r.key, value: Number(r.value) }))
670
673
  .filter((p) => Number.isFinite(p.value) && p.value > 0);
671
674
  if (!all.length)
672
675
  return _jsx("p", { className: "note", children: sayCopy('nothingToDivide') });
@@ -745,7 +748,7 @@ export const TIMED_HEIGHT = 180;
745
748
  * and past seven series the tail is gathered into "others", the eighth
746
749
  * token. A target is a rule across every track and a word in the legend.
747
750
  */
748
- export function StackedBars({ rows, say = String, label = String, seriesLabel = String, target, limit = 10, onPick, seriesVocabulary, seriesOrdered, seriesTone, sayLegend, }) {
751
+ export function StackedBars({ rows, say = String, label = keyWord, seriesLabel = String, target, limit = 10, onPick, seriesVocabulary, seriesOrdered, seriesTone, sayLegend, }) {
749
752
  const MAX_SERIES = 7;
750
753
  const name = (v) => (v == null ? '—' : String(v));
751
754
  const bars = new Map();
@@ -11,7 +11,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  * to learn and no examples to fetch.
12
12
  */
13
13
  import { useEffect, useRef, useState } from 'react';
14
- import { currentEntry, state, trapFocus } from '../core.js';
14
+ import { Modal } from '@mistriwork/ui/Modal.js';
15
+ import { currentEntry, state } from '../core.js';
15
16
  import { SECTIONS, buildExamples, runExample, sampleRows } from '../helpContent.js';
16
17
  import { say } from '../copy/workbench/components/HelpPanel.js';
17
18
  import '../help.css';
@@ -45,17 +46,12 @@ function useExamples(enabled) {
45
46
  return built;
46
47
  }
47
48
  export function HelpPanel({ onClose, keysOnly = false }) {
48
- const backdrop = useRef(null);
49
49
  const close = useRef(null);
50
50
  const built = useExamples(!keysOnly);
51
- useEffect(() => {
52
- const release = trapFocus(backdrop.current);
53
- close.current?.focus();
54
- return () => release?.();
55
- }, []);
56
51
  useEffect(() => {
57
52
  const onKey = (e) => {
58
- if (e.key === 'Escape' || e.key === '?') {
53
+ /* Escape is the dialog's own (Modal); `?` is the key that opened the panel, so it closes it too. */
54
+ if (e.key === '?') {
59
55
  e.preventDefault();
60
56
  e.stopPropagation();
61
57
  onClose();
@@ -77,10 +73,7 @@ export function HelpPanel({ onClose, keysOnly = false }) {
77
73
  ...offered.filter((spec) => !(here && spec.rooms?.includes(here))),
78
74
  ];
79
75
  const title = keysOnly ? say('keyboard') : say('queryLanguage');
80
- return (_jsx("div", { ref: backdrop, className: "help-backdrop", onPointerDown: (e) => {
81
- if (e.target === e.currentTarget)
82
- onClose();
83
- }, children: _jsxs("div", { className: "help-panel", role: "dialog", "aria-modal": "true", "aria-label": title, children: [_jsxs("header", { className: "help-head", children: [_jsxs("div", { children: [_jsx("h2", { className: "help-title", children: title }), _jsx("p", { className: "help-sub", children: keysOnly ? say('theKeysThisPage') : say('everyExampleBelowRuns', { label }) })] }), _jsx("button", { ref: close, type: "button", className: "help-close", "aria-label": say('common.close'), title: say('closeParenEsc'), onClick: onClose, children: _jsx("span", { "aria-hidden": "true", children: "\u00D7" }) })] }), _jsx("div", { className: "help-body", children: ordered.map((spec) => (_jsx(Section, { spec: spec, examples: built.examples, onRun: onClose, here: Boolean(here && spec.rooms?.includes(here)) }, spec.title))) })] }) }));
76
+ return (_jsxs(Modal, { className: "help-panel", onClose: onClose, ariaLabel: title, initialFocus: close, fullscreen: false, children: [_jsxs("header", { className: "help-head", children: [_jsxs("div", { children: [_jsx("h2", { className: "help-title", children: title }), _jsx("p", { className: "help-sub", children: keysOnly ? say('theKeysThisPage') : say('everyExampleBelowRuns', { label }) })] }), _jsx("button", { ref: close, type: "button", className: "help-close", "aria-label": say('common.close'), title: say('closeParenEsc'), onClick: onClose, children: _jsx("span", { "aria-hidden": "true", children: "\u00D7" }) })] }), _jsx("div", { className: "help-body", children: ordered.map((spec) => (_jsx(Section, { spec: spec, examples: built.examples, onRun: onClose, here: Boolean(here && spec.rooms?.includes(here)) }, spec.title))) })] }));
84
77
  }
85
78
  function Section({ spec, examples, onRun, here, }) {
86
79
  /* A section with no `keys` is static reference and must not reach for examples it never claimed. */
@@ -132,6 +132,8 @@ export declare function ruleSays(rule: DisplayRule | null | undefined, value: un
132
132
  /** Vocabulary captions only: identifiers and arbitrary grouped text stay exact.
133
133
  * A toned value is a word everywhere; a value of the column's own vocabulary
134
134
  * (`allowed`) is a word in an App, where the Workbench shows the data.
135
+ * A group of no value is the field's missing value, said in the field's own
136
+ * `empty` word where it has one, as its cell says it, and a dash where not.
135
137
  * Callers keep the raw key for navigation and aggregation. */
136
138
  export declare function groupLabel(rule: DisplayRule | null | undefined, value: unknown, allowed?: readonly string[]): string;
137
139
  export { subtitlePath, leadTonePath };
@@ -94,10 +94,12 @@ export function ruleSays(rule, value) {
94
94
  /** Vocabulary captions only: identifiers and arbitrary grouped text stay exact.
95
95
  * A toned value is a word everywhere; a value of the column's own vocabulary
96
96
  * (`allowed`) is a word in an App, where the Workbench shows the data.
97
+ * A group of no value is the field's missing value, said in the field's own
98
+ * `empty` word where it has one, as its cell says it, and a dash where not.
97
99
  * Callers keep the raw key for navigation and aggregation. */
98
100
  export function groupLabel(rule, value, allowed) {
99
101
  if (value == null)
100
- return '—';
102
+ return rule?.empty ?? '—';
101
103
  const text = String(value);
102
104
  const vocabulary = allowed?.includes(text) && typeof document !== 'undefined' && shellBody()?.classList.contains('app-mode');
103
105
  return wordFor(rule, text) ?? (rule?.tone || vocabulary ? vocabularyWord(text) : text);
@@ -59,14 +59,13 @@
59
59
 
60
60
  /* ---------- the panel ---------- */
61
61
 
62
- .help-backdrop {
63
- position: fixed; inset: 0; z-index: 60;
64
- background: var(--scrim);
65
- display: flex; justify-content: center;
66
- padding: 8vh var(--space-5) var(--space-5);
67
- }
68
- .help-panel {
69
- width: min(720px, 96vw); max-height: 84vh;
62
+ /* A Modal (HelpPanel.tsx): the scrim is its backdrop, and the box hangs from the top rather than sitting centered, so
63
+ the sections do not jump as the examples sharpen. */
64
+ .modal-backdrop.help-panel-backdrop { background: var(--scrim); }
65
+ .modal.help-panel {
66
+ inset: 8vh 0 auto; margin: 0 auto; padding: 0;
67
+ width: min(720px, 96vw); max-width: none; height: auto; max-height: 84vh;
68
+ color: var(--ink);
70
69
  display: flex; flex-direction: column;
71
70
  background: var(--surface);
72
71
  border: 1px solid var(--line-strong);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistriwork/kit",
3
- "version": "1.0.0-rc.38",
3
+ "version": "1.0.0-rc.40",
4
4
  "description": "The shared React client both shells are drawn with: the walk and the address, Grid, Value, the record page, lists, filters and charts.",
5
5
  "homepage": "https://mistriwork.dev",
6
6
  "bugs": {
@@ -83,8 +83,8 @@
83
83
  "./package.json": "./package.json"
84
84
  },
85
85
  "dependencies": {
86
- "@mistriwork/engine": "1.0.0-rc.38",
87
- "@mistriwork/ui": "1.0.0-rc.38",
86
+ "@mistriwork/engine": "1.0.0-rc.40",
87
+ "@mistriwork/ui": "1.0.0-rc.40",
88
88
  "intl-messageformat": "12.1.2",
89
89
  "qrcode-generator": "^2.0.4"
90
90
  },