viewkitjs 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/MIGRATION.md +84 -6
  3. package/package.json +1 -1
  4. package/views/dist/contract.d.ts +171 -1
  5. package/views/dist/contract.js +162 -0
  6. package/views/dist/controls/compound-editor/map-parts-body.js +2 -1
  7. package/views/dist/controls/compound-editor/name-parts.js +10 -2
  8. package/views/dist/controls/compound-editor/place.d.ts +2 -1
  9. package/views/dist/controls/compound-editor/place.js +2 -0
  10. package/views/dist/controls/controls.d.ts +8 -0
  11. package/views/dist/controls/controls.js +8 -0
  12. package/views/dist/controls/index.d.ts +16 -0
  13. package/views/dist/controls/index.js +16 -0
  14. package/views/dist/controls/internal/editor-parts.d.ts +40 -0
  15. package/views/dist/controls/internal/editor-parts.js +43 -0
  16. package/views/dist/controls/links-editor/links-editor.d.ts +78 -0
  17. package/views/dist/controls/links-editor/links-editor.js +308 -0
  18. package/views/dist/controls/links-editor/links.d.ts +62 -0
  19. package/views/dist/controls/links-editor/links.js +50 -0
  20. package/views/dist/controls/links-editor/map-links-body.d.ts +10 -0
  21. package/views/dist/controls/links-editor/map-links-body.js +71 -0
  22. package/views/dist/controls/links-editor/tokens.d.ts +71 -0
  23. package/views/dist/controls/links-editor/tokens.js +20 -0
  24. package/views/dist/controls/links-editor/words.d.ts +56 -0
  25. package/views/dist/controls/links-editor/words.js +33 -0
  26. package/views/dist/controls/links-editor.css +132 -0
  27. package/views/dist/controls/number-editor/format.d.ts +31 -0
  28. package/views/dist/controls/number-editor/format.js +79 -0
  29. package/views/dist/controls/number-editor/looks.d.ts +14 -0
  30. package/views/dist/controls/number-editor/looks.js +17 -0
  31. package/views/dist/controls/number-editor/map-number-body.d.ts +16 -0
  32. package/views/dist/controls/number-editor/map-number-body.js +57 -0
  33. package/views/dist/controls/number-editor/number-editor.d.ts +72 -0
  34. package/views/dist/controls/number-editor/number-editor.js +202 -0
  35. package/views/dist/controls/number-editor/tokens.d.ts +28 -0
  36. package/views/dist/controls/number-editor/tokens.js +9 -0
  37. package/views/dist/controls/number-editor/words.d.ts +23 -0
  38. package/views/dist/controls/number-editor/words.js +13 -0
  39. package/views/dist/controls/number-editor.css +37 -0
  40. package/views/dist/controls/number-field/number-field.js +57 -5
  41. package/views/dist/controls/radio/radio.d.ts +33 -0
  42. package/views/dist/controls/radio/radio.js +19 -0
  43. package/views/dist/controls/radio/tokens.d.ts +127 -0
  44. package/views/dist/controls/radio/tokens.js +34 -0
  45. package/views/dist/controls/radio.css +104 -0
  46. package/views/dist/controls/text-editor/phone-number.d.ts +4 -0
  47. package/views/dist/controls/text-editor/phone-number.js +20 -0
  48. package/views/dist/controls/text-editor/text-editor.js +2 -19
  49. package/views/dist/controls/tokens.js +10 -0
  50. package/views/dist/controls/values-editor/looks.d.ts +16 -0
  51. package/views/dist/controls/values-editor/looks.js +19 -0
  52. package/views/dist/controls/values-editor/map-values-body.d.ts +12 -0
  53. package/views/dist/controls/values-editor/map-values-body.js +71 -0
  54. package/views/dist/controls/values-editor/tokens.d.ts +132 -0
  55. package/views/dist/controls/values-editor/tokens.js +35 -0
  56. package/views/dist/controls/values-editor/values-editor.d.ts +62 -0
  57. package/views/dist/controls/values-editor/values-editor.js +435 -0
  58. package/views/dist/controls/values-editor/values.d.ts +71 -0
  59. package/views/dist/controls/values-editor/values.js +59 -0
  60. package/views/dist/controls/values-editor/words.d.ts +50 -0
  61. package/views/dist/controls/values-editor/words.js +29 -0
  62. package/views/dist/controls/values-editor.css +207 -0
  63. package/views/dist/controls/views-list/looks.d.ts +13 -0
  64. package/views/dist/controls/views-list/looks.js +12 -0
  65. package/views/dist/controls/views-list/map-views-list-body.d.ts +19 -0
  66. package/views/dist/controls/views-list/map-views-list-body.js +65 -0
  67. package/views/dist/controls/views-list/rules.d.ts +72 -0
  68. package/views/dist/controls/views-list/rules.js +4 -0
  69. package/views/dist/controls/views-list/tokens.d.ts +11 -0
  70. package/views/dist/controls/views-list/tokens.js +5 -0
  71. package/views/dist/controls/views-list/views-list.d.ts +44 -0
  72. package/views/dist/controls/views-list/views-list.js +57 -0
  73. package/views/dist/controls/views-list/words.d.ts +22 -0
  74. package/views/dist/controls/views-list/words.js +3 -0
  75. package/views/dist/controls/views-list.css +8 -0
  76. package/views/dist/editors/NumberEditor.js +3 -1
  77. package/views/dist/grid/chrome/GridCellEditors.js +1 -1
  78. package/views/dist/grid/chrome/GridDateEditor.d.ts +3 -1
  79. package/views/dist/grid/chrome/GridDateEditor.js +2 -1
  80. package/views/dist/looks/index.d.ts +3 -0
  81. package/views/dist/looks/index.js +3 -0
  82. package/views/dist/looks/pieces.js +6 -0
  83. package/views/dist/provider/components.d.ts +4 -0
  84. package/views/dist/styles.css +432 -2
  85. package/views/dist/styles.unlayered.css +432 -2
  86. package/views/docs/contract.md +10 -8
  87. package/views/docs/controls/links-editor.md +25 -0
  88. package/views/docs/controls/number-editor.md +12 -0
  89. package/views/docs/controls/radio.md +39 -0
  90. package/views/docs/controls/values-editor.md +40 -0
  91. package/views/docs/controls/views-list.md +8 -0
  92. package/views/docs/reference/controls.md +117 -5
  93. package/views/docs/reference/looks.md +9 -2
  94. package/views/docs/reference/react.md +2 -2
@@ -0,0 +1,308 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Avatar } from "../avatar/avatar.js";
5
+ import { Button } from "../button/button.js";
6
+ import { FieldRows, FieldRowsRow as FieldRow } from "../field/field.js";
7
+ import { Input, InputGroup, InputGroupAddon } from "../input/input.js";
8
+ import { DOTS, DOTS_LOOK, glyph, OnTop, PLUS, TICK, useDecide, useStandingRoom, X } from "../internal/editor-parts.js";
9
+ import { Icon } from "../internal/icons.js";
10
+ import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
11
+ import { usePopupHost } from "../internal/popup-host.js";
12
+ import { spacingPx } from "../internal/read-token.js";
13
+ import { drawnAt, scrollInList } from "../internal/scroll.js";
14
+ import { Menu } from "../menu/menu.js";
15
+ import { Picker } from "../picker/picker.js";
16
+ import { Popover } from "../popover/popover.js";
17
+ import { Radio, RadioGroup } from "../radio/radio.js";
18
+ import { Select } from "../select/select.js";
19
+ import { Sheet, SheetBody, SheetButton, SheetHead } from "../sheet/bottom-sheet.js";
20
+ import { Spinner } from "../spinner/spinner.js";
21
+ import { Switch } from "../switch/switch.js";
22
+ import { midWord } from "../text-editor/check.js";
23
+ import { added, found, heldOf, leadAfter, offered, removed, said, saidShort, setValue, ticked } from "./links.js";
24
+ import { linksWords } from "./words.js";
25
+ const SEARCH = ["M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0", "M21 21l-6 -6"], BACK = ["M15 6l-6 6l6 6"];
26
+ const END_LOOK = { radius: "sm", corner: "round", edge: "none", words: "inherit", colour: "faint", icon: "16" };
27
+ const MORE = ["M9 6l6 6l-6 6"];
28
+ const UNLINK = ["M17 22v-2", "M9 15l6 -6", "M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .463", "M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463", "M20 17h2", "M2 7h2", "M7 2v2"];
29
+ const CARD = { cards: "one", edge: "on", height: "56", label: "none", lines: "words" };
30
+ const ADDS = CARD;
31
+ const FIELDS = { cards: "one", edge: "on", height: "52", label: "104", lines: "words" };
32
+ function Face({ record, size }) {
33
+ const as = record.as;
34
+ const avatar = as && "avatar" in as ? as : null;
35
+ return _jsx(Avatar, { name: record.label, kind: avatar?.avatar === "person" ? "person" : "thing", id: avatar?.id, src: avatar?.src, size: size });
36
+ }
37
+ export function useLinksEditor(props) {
38
+ const { label, kind, records, fields, links, onLinksChange, lead, autoFocus = true, opens, onSearch, doing, onRetry, onMore, actions = [] } = props;
39
+ const w = linksWords(props.words), search = props.search ?? w.search;
40
+ const screen = React.useContext(PhoneHost), small = usePhone(), phone = (props.form ?? (screen || small ? "phone" : "computer")) === "phone";
41
+ const mark = phoneMark(!!screen || small);
42
+ const one = fields.length === 1 ? fields[0] : null, several = fields.length > 1;
43
+ const now = React.useRef(links);
44
+ now.current = links;
45
+ const leading = React.useRef(lead?.value ?? null);
46
+ leading.current = lead?.value ?? null;
47
+ const change = (next) => {
48
+ now.current = next;
49
+ onLinksChange(next);
50
+ if (!lead)
51
+ return;
52
+ const after = leadAfter(leading.current, next);
53
+ if (after !== leading.current) {
54
+ leading.current = after;
55
+ lead.onLead(after);
56
+ }
57
+ };
58
+ const setLead = (value) => { if (!lead || value === leading.current)
59
+ return; leading.current = value; lead.onLead(value); };
60
+ const [query, setQuery] = React.useState(props.typed ?? "");
61
+ const [lit, setLit] = React.useState(props.typed?.trim() ? 0 : null);
62
+ const { linked, rest } = found(records, links, query, !!onSearch);
63
+ const lights = rest.length + actions.length;
64
+ const litAt = lit == null || !lights ? null : Math.min(lit, lights - 1);
65
+ const typeQuery = (v) => { setQuery(v); onSearch?.(v); };
66
+ const asked = React.useRef(onMore);
67
+ asked.current = onMore;
68
+ const seenRef = React.useRef(null);
69
+ const moreRef = React.useCallback((el) => {
70
+ seenRef.current?.disconnect();
71
+ seenRef.current = null;
72
+ if (!el || typeof IntersectionObserver === "undefined")
73
+ return;
74
+ let was = false;
75
+ seenRef.current = new IntersectionObserver((seen) => { const now = seen.some((x) => x.isIntersecting); if (now && !was)
76
+ asked.current?.(); was = now; });
77
+ seenRef.current.observe(el);
78
+ }, []);
79
+ const more = onMore && !doing ? _jsxs("div", { ref: moreRef, className: "o-links-editor-loading", children: [_jsx(Spinner, { size: 16, label: "" }), _jsx("span", { children: w.loadingMore })] }) : null;
80
+ const doingNote = doing === "searching" ? w.searching : doing === "failed" ? _jsxs(_Fragment, { children: [w.failed, onRetry && _jsx(Button, { kind: "quiet", size: "2xs", className: "o-links-editor-retry", onClick: onRetry, children: w.retry })] }) : null;
81
+ const byValue = (value) => records.find((r) => r.value === value) ?? { value, label: links.find((l) => l.value === value)?.label ?? value };
82
+ const [root, setRoot] = React.useState(null);
83
+ const searchBox = React.useRef(null), list = React.useRef(null);
84
+ const [view, setView] = React.useState(null);
85
+ const placeList = React.useCallback((el) => { list.current = el; setView(el); }, []);
86
+ const ids = React.useId();
87
+ const [stepOpen, setStep] = React.useState(opens && "config" in opens ? opens.config : null);
88
+ const step = stepOpen && links.some((l) => l.value === stepOpen) ? stepOpen : null;
89
+ const [open, setOpen] = React.useState(null);
90
+ const shownList = opens && "list" in opens ? { link: opens.link, field: opens.list } : null;
91
+ const back = React.useRef(false), stepPressed = React.useRef(false);
92
+ React.useLayoutEffect(() => {
93
+ if (phone)
94
+ return;
95
+ if (step) {
96
+ if (stepPressed.current)
97
+ root?.querySelector(".o-links-editor-back")?.focus({ preventScroll: true });
98
+ stepPressed.current = false;
99
+ return;
100
+ }
101
+ if (autoFocus || back.current)
102
+ searchBox.current?.focus({ preventScroll: true });
103
+ back.current = false;
104
+ }, [phone, step, root]);
105
+ React.useEffect(() => { if (stepOpen && !step) {
106
+ setStep(null);
107
+ back.current = true;
108
+ } }, [stepOpen, step]);
109
+ React.useEffect(() => {
110
+ const el = view;
111
+ if (!el || !open)
112
+ return;
113
+ const hold = (e) => e.preventDefault();
114
+ el.addEventListener("wheel", hold, { passive: false });
115
+ el.addEventListener("touchmove", hold, { passive: false });
116
+ setLit(null);
117
+ return () => { el.removeEventListener("wheel", hold); el.removeEventListener("touchmove", hold); };
118
+ }, [view, open]);
119
+ const [refocus, setRefocus] = React.useState(null);
120
+ React.useLayoutEffect(() => {
121
+ if (refocus == null || !root)
122
+ return;
123
+ setRefocus(null);
124
+ const ends = root.querySelectorAll(".o-links-editor-row .o-links-editor-end > button");
125
+ (ends[refocus] ?? ends[ends.length - 1] ?? searchBox.current)?.focus({ preventScroll: true });
126
+ }, [refocus, root]);
127
+ const link = (value) => {
128
+ change(added(now.current, value));
129
+ if (query)
130
+ typeQuery("");
131
+ setLit(null);
132
+ if (!phone)
133
+ searchBox.current?.focus({ preventScroll: true });
134
+ };
135
+ const unlink = (value) => {
136
+ const at = linked.findIndex((r) => r.value === value);
137
+ root?.focus({ preventScroll: true });
138
+ change(removed(now.current, value));
139
+ if (step === value) {
140
+ setStep(null);
141
+ back.current = true;
142
+ }
143
+ else
144
+ setRefocus(at);
145
+ };
146
+ const setField = (value, field, to) => change(setValue(now.current, value, field, to));
147
+ const tickFrom = (value, field, next) => {
148
+ const held = heldOf(now.current.find((l) => l.value === value)?.values[field.id]);
149
+ const changed = next.find((v) => !held.includes(v)) ?? held.find((v) => !next.includes(v));
150
+ if (changed != null)
151
+ setField(value, field.id, ticked(held, changed));
152
+ };
153
+ const listOf = (l, f) => ({
154
+ label: f.label, items: offered(f, l.values[f.id]), multiple: f.kind === "several", search: w.searchField(f.label), firstFollows: true, words: w.picker,
155
+ value: f.kind === "several" ? heldOf(l.values[f.id]) : typeof l.values[f.id] === "string" ? l.values[f.id] : null,
156
+ onValueChange: (next) => (f.kind === "several" ? tickFrom(l.value, f, Array.isArray(next) ? next : []) : setField(l.value, f.id, typeof next === "string" ? next : null)),
157
+ });
158
+ const room = useStandingRoom(root, "[data-links-shown]", phone, [shownList?.link, shownList?.field, step]);
159
+ const [shownAt, setShownAt] = React.useState(null);
160
+ React.useLayoutEffect(() => {
161
+ if (!root || !shownList) {
162
+ setShownAt(null);
163
+ return;
164
+ }
165
+ const button = root.querySelector(`.o-links-editor-row[data-link="${CSS.escape(shownList.link)}"] .o-links-editor-short`);
166
+ if (!button) {
167
+ setShownAt(null);
168
+ return;
169
+ }
170
+ const r = root.getBoundingClientRect(), b = button.getBoundingClientRect(), k = drawnAt(root) || 1;
171
+ setShownAt({ top: (b.bottom - r.top) / k + spacingPx(1, root), left: (b.left - r.left) / k });
172
+ }, [root, shownList?.link, shownList?.field, links]);
173
+ const decideNow = React.useRef({ get current() { return { links: now.current, lead: leading.current }; } }).current;
174
+ const decide = useDecide(decideNow, (was) => {
175
+ now.current = was.links;
176
+ onLinksChange(was.links);
177
+ if (lead && was.lead !== leading.current) {
178
+ leading.current = was.lead;
179
+ lead.onLead(was.lead);
180
+ }
181
+ }, props.onDone, { close: w.close, save: w.save });
182
+ const placed = decide.place;
183
+ const typedFirst = React.useRef(props.typed ?? "");
184
+ typedFirst.current = props.typed ?? "";
185
+ const placeRoot = React.useCallback((el) => { setRoot(el); placed(el); if (!el)
186
+ setQuery(typedFirst.current); }, [placed]);
187
+ const [top, setTop] = React.useState(() => (phone && opens && "list" in opens ? { link: opens.link, field: opens.list, open: true } : null));
188
+ const [fieldsOf, setFieldsOf] = React.useState(() => (phone && opens && "config" in opens ? opens.config : null));
189
+ const host = usePopupHost(searchBox);
190
+ const [sheetRoom, setSheetRoom] = React.useState(null);
191
+ React.useLayoutEffect(() => {
192
+ const scroller = root?.parentElement?.closest(".o-sheet-body");
193
+ if (!phone || !scroller || root?.closest(".o-sheet")?.getAttribute("data-sheet-form") !== "full") {
194
+ setSheetRoom(null);
195
+ return;
196
+ }
197
+ const read = () => {
198
+ const c = getComputedStyle(scroller), topPad = parseFloat(c.paddingTop), under = parseFloat(c.paddingBottom);
199
+ setSheetRoom((was) => { const height = Math.max(0, scroller.clientHeight - topPad - under); return was && was.height === height && was.under === under ? was : { height, under }; });
200
+ };
201
+ read();
202
+ const watch = new ResizeObserver(read);
203
+ watch.observe(scroller);
204
+ return () => watch.disconnect();
205
+ }, [root, phone]);
206
+ if (phone) {
207
+ const addWords = w.addKind(kind);
208
+ const holds = (l) => fields.map((f) => (f.kind === "yes-no" ? (l.values[f.id] === true ? f.label : "") : said(f, l.values[f.id], w.yes) === "–" ? "" : said(f, l.values[f.id], w.yes)))
209
+ .filter(Boolean).join(" · ");
210
+ const rowWords = (f, v) => { const s = said(f, v, w.yes); return f.kind === "yes-no" ? (v === true ? w.yes : w.no) : s === "–" ? w.none : s; };
211
+ const openList = (value, field) => setTop({ link: value, field, open: true });
212
+ const fieldRow = (l, name, f) => (f.kind === "yes-no" ? (_jsxs(FieldRow, { className: "o-links-editor-open", "data-field": f.id, children: [_jsx("span", { className: "o-links-editor-open-name", children: f.label }), _jsx(Switch, { size: "lg", className: "o-links-editor-switch", checked: l.values[f.id] === true, "aria-label": w.fieldAt(f.label, name), onCheckedChange: (c) => setField(l.value, f.id, c) })] }, f.id)) : (_jsxs(FieldRow, { as: "button", className: "o-links-editor-open", "data-field": f.id, "aria-label": w.fieldAt(f.label, name), onClick: () => openList(l.value, f.id), children: [_jsx("span", { className: "o-links-editor-open-name", children: f.label }), _jsx("span", { className: "o-links-editor-open-value", children: rowWords(f, l.values[f.id]) }), glyph(MORE, "o-links-editor-open-mark")] }, f.id)));
213
+ const card = (r) => {
214
+ const l = links.find((x) => x.value === r.value), name = r.label, leads = lead != null && lead.value === r.value;
215
+ const said_ = holds(l);
216
+ return (_jsxs(FieldRows, { look: CARD, className: "o-links-editor-card", "data-link": r.value, role: "listitem", "aria-label": name, children: [_jsxs(FieldRow, { as: "div", className: "o-links-editor-card-head", children: [_jsx(Face, { record: r, size: 24 }), _jsxs("span", { className: "o-links-editor-card-name", children: [_jsx("span", { children: name }), leads && _jsx("span", { className: "o-links-editor-lead-word", children: lead.label })] }), !several
217
+ ? _jsx(Menu, { label: w.linkMenu(name), align: "end", entries: [...(lead && !leads ? [{ icon: _jsx(Icon, { name: "star" }), label: w.setLead(lead.label), onSelect: () => setLead(r.value) }] : []), { icon: glyph(UNLINK), label: w.unlink, danger: true, onSelect: () => unlink(r.value) }], trigger: _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-links-editor-more", "aria-label": w.actionsFor(name), icon: glyph(DOTS) }) })
218
+ : _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-links-editor-config", "aria-label": w.editLink(name), "aria-haspopup": "dialog", icon: _jsx(Icon, { name: "settings", size: 20 }), onClick: () => setFieldsOf(r.value) })] }), !several ? one && fieldRow(l, name, one) : _jsx("div", { className: "o-links-editor-card-line", "data-none": said_ ? undefined : "", children: said_ || w.noDetails })] }, r.value));
219
+ };
220
+ const topLink = top ? links.find((l) => l.value === top.link) : undefined, topField = top ? fields.find((f) => f.id === top.field) : undefined;
221
+ const fieldsLink = fieldsOf ? links.find((l) => l.value === fieldsOf) : undefined;
222
+ const fieldsName = fieldsOf ? byValue(fieldsOf).label : "";
223
+ const body = (_jsxs("div", { ref: placeRoot, className: "o-links-editor", "data-kit": "links-editor", ...mark, "data-links-form": "phone", "data-links-shape": "table", "data-links-fields": several ? "several" : "one", tabIndex: -1, style: sheetRoom ? { "--links-room": `${sheetRoom.height}px`, "--links-under": `${sheetRoom.under}px` } : undefined, children: [linked.length > 0 && _jsx("div", { className: "o-links-editor-cards", role: "list", "aria-label": label, children: linked.map(card) }), (rest.length > 0 || actions.length > 0) && _jsxs(_Fragment, { children: [_jsx("div", { className: "o-links-editor-label", children: addWords }), _jsxs(FieldRows, { look: ADDS, className: "o-links-editor-adds", role: "list", "aria-label": addWords, children: [rest.map((r) => (_jsxs(FieldRow, { as: "button", className: "o-links-editor-add", "data-record": r.value, role: "listitem", "aria-label": w.linkName(r.label), onClick: () => link(r.value), children: [_jsx(Face, { record: r, size: 40 }), _jsx("span", { className: "o-links-editor-add-name", children: r.label }), glyph(PLUS, "o-links-editor-add-mark")] }, r.value))), actions.map((a) => (_jsxs(FieldRow, { as: "button", className: "o-links-editor-add o-links-editor-action", role: "listitem", onClick: a.onSelect, children: [a.icon != null && _jsx("span", { className: "o-links-editor-action-mark", children: a.icon }), _jsx("span", { className: "o-links-editor-add-name", children: a.label })] }, a.key)))] }), more] }), doingNote ? _jsx("div", { className: "o-links-editor-note", children: doingNote }) : _jsxs(_Fragment, { children: [!rest.length && query.trim() && !linked.length && _jsx("div", { className: "o-links-editor-note", children: w.nothingMatchesTyped(query.trim()) }), !rest.length && !query.trim() && linked.length > 0 && _jsx("div", { className: "o-links-editor-note", children: w.everythingLinked })] }), _jsx("div", { className: "o-links-editor-bar", children: _jsxs(InputGroup, { size: "lg", className: "o-links-editor-pill", children: [_jsx(InputGroupAddon, { side: "start", children: glyph(SEARCH) }), _jsx(Input, { autofill: false, ref: searchBox, className: "o-links-editor-input", placeholder: search, "aria-label": search, value: query, onValueChange: (v) => typeQuery(v) })] }) }), top && topField && topLink && _jsx(OnTop, { open: top.open, onOpenChange: (o) => setTop((t) => (t ? { ...t, open: o } : t)), onGone: () => setTop((t) => (t && !t.open ? null : t)), container: screen ?? host, standing: !!screen, title: topField.label, words: { close: w.close }, picker: { ...listOf(topLink, topField), draft: "shell" } }, `${top.link}-${top.field}`), several && (_jsxs(_Fragment, { children: [_jsx("span", { hidden: true }), _jsxs(Sheet, { open: !!fieldsLink, onOpenChange: (o) => { if (!o)
224
+ setFieldsOf(null); }, label: fieldsName, form: "full", container: screen ?? host, standing: !!screen, children: [_jsx(SheetHead, { title: fieldsName, left: _jsx(SheetButton, { "aria-label": w.close, icon: glyph(X), onClick: () => setFieldsOf(null) }), right: _jsx(SheetButton, { kind: "primary", "aria-label": w.done, icon: glyph(TICK), onClick: () => setFieldsOf(null) }) }), _jsx(SheetBody, { children: fieldsLink && _jsxs(_Fragment, { children: [_jsxs(FieldRows, { look: FIELDS, className: "o-links-editor-fields", "data-link": fieldsLink.value, children: [fields.map((f) => f.kind === "yes-no"
225
+ ? _jsx(FieldRow, { label: f.label, "data-field": f.id, children: _jsx(Switch, { size: "lg", className: "o-links-editor-switch", checked: fieldsLink.values[f.id] === true, "aria-label": w.fieldAt(f.label, fieldsName), onCheckedChange: (c) => setField(fieldsLink.value, f.id, c) }) }, f.id)
226
+ : _jsxs(FieldRow, { as: "button", label: f.label, className: "o-links-editor-open", "data-field": f.id, "aria-label": w.fieldAt(f.label, fieldsName), onClick: () => openList(fieldsLink.value, f.id), children: [_jsx("span", { className: "o-links-editor-open-value", children: rowWords(f, fieldsLink.values[f.id]) }), glyph(MORE, "o-links-editor-open-mark")] }, f.id)), lead && _jsx(FieldRow, { label: lead.label, "data-field": "lead", children: _jsx(Switch, { size: "lg", className: "o-links-editor-switch", checked: lead.value === fieldsLink.value, "aria-label": w.isLead(fieldsName, lead.label), onCheckedChange: (c) => { if (c)
227
+ setLead(fieldsLink.value); } }) })] }), _jsx(FieldRows, { look: FIELDS, className: "o-links-editor-fields-foot", children: _jsx(FieldRow, { as: "button", className: "o-links-editor-unlink", onClick: () => { const v = fieldsLink.value; setFieldsOf(null); unlink(v); }, children: w.unlink }) })] }) })] })] }))] }));
228
+ return { body, head: decide.head };
229
+ }
230
+ const stepLink = step ? links.find((l) => l.value === step) : undefined;
231
+ if (step && stepLink) {
232
+ const record = byValue(step), name = record.label;
233
+ const leave = () => { back.current = true; setStep(null); };
234
+ const control = (f) => {
235
+ const v = stepLink.values[f.id], words = w.fieldAt(f.label, name);
236
+ if (f.kind === "yes-no")
237
+ return _jsx(Switch, { size: "md", checked: v === true, "aria-label": words, onCheckedChange: (c) => setField(step, f.id, c) });
238
+ if (f.kind === "several")
239
+ return _jsx(Select, { size: "sm", multiple: true, listWidth: "rows", items: offered(f, v), value: heldOf(v), placeholder: w.none, "aria-label": words, onValueChange: (next) => tickFrom(step, f, Array.isArray(next) ? next : []) });
240
+ return _jsx(Select, { size: "sm", listWidth: "rows", items: offered(f, v), value: typeof v === "string" ? v : null, placeholder: w.none, "aria-label": words, onValueChange: (next) => setField(step, f.id, typeof next === "string" ? next : null) });
241
+ };
242
+ const body = (_jsxs("div", { ref: setRoot, className: "o-links-editor", "data-kit": "links-editor", ...mark, "data-links-form": "computer", "data-links-shape": "table", "data-links-fields": several ? "several" : "one", "data-links-step": "", role: "group", "aria-label": name, tabIndex: -1, onKeyDown: (e) => {
243
+ if (e.key !== "Escape" || e.target.closest?.("[aria-expanded='true']"))
244
+ return;
245
+ e.preventDefault();
246
+ e.stopPropagation();
247
+ leave();
248
+ }, children: [_jsxs("div", { className: "o-links-editor-step-head o-popup-line", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", className: "o-links-editor-back", "aria-label": w.backTo(label), icon: glyph(BACK), onClick: leave }), _jsx(Face, { record: record, size: 20 }), _jsx("span", { className: "o-links-editor-step-name", children: name })] }), _jsx("div", { className: "o-links-editor-fields", "data-link": step, children: fields.map((f) => (_jsxs("div", { className: "o-links-editor-field", "data-field": f.id, children: [_jsx("span", { className: "o-links-editor-field-label", children: f.label }), _jsx("span", { className: "o-links-editor-field-control", "data-kind": f.kind, children: control(f) })] }, f.id))) }), _jsx("div", { className: "o-links-editor-step-foot", children: _jsx(Button, { kind: "quiet", size: "2xs", className: "o-links-editor-unlink", onClick: () => unlink(step), children: w.unlink }) })] }));
249
+ return { body, head: {} };
250
+ }
251
+ const keepArrows = (e) => { if (e.key.startsWith("Arrow"))
252
+ e.stopPropagation(); };
253
+ const keys = (e) => {
254
+ if ((e.key === "ArrowDown" || e.key === "ArrowUp") && lights) {
255
+ e.preventDefault();
256
+ const next = litAt == null ? (e.key === "ArrowDown" ? 0 : lights - 1) : (litAt + (e.key === "ArrowDown" ? 1 : lights - 1)) % lights;
257
+ setLit(next);
258
+ const row = list.current?.querySelector(`#${CSS.escape(`${ids}-add-${next}`)}`);
259
+ if (row)
260
+ scrollInList(row, { block: "nearest" });
261
+ }
262
+ else if (e.key === "Enter" && litAt != null && doing !== "searching" && !midWord(e.nativeEvent)) {
263
+ const r = rest[litAt], a = actions[litAt - rest.length];
264
+ if (r) {
265
+ e.preventDefault();
266
+ link(r.value);
267
+ }
268
+ else if (a) {
269
+ e.preventDefault();
270
+ a.onSelect();
271
+ }
272
+ }
273
+ };
274
+ const short = (l, name, f) => {
275
+ const words = saidShort(f, l.values[f.id], w.yes), standing = shownList?.link === l.value && shownList.field === f.id;
276
+ const button = (_jsx(Button, { kind: "quiet", size: "2xs", className: "o-links-editor-short", "data-field": f.id, "data-none": words ? undefined : "", "aria-label": w.fieldAt(f.label, name), iconEnd: _jsx(Icon, { name: "down" }), "data-popup-open": standing ? "" : undefined, children: words || f.label }));
277
+ if (standing)
278
+ return button;
279
+ return (_jsx(Popover, { trigger: button, open: open?.link === l.value && open.field === f.id, onOpenChange: (o) => setOpen(o ? { link: l.value, field: f.id } : null), side: "bottom", align: "start", className: "o-links-editor-pop", "aria-label": w.fieldAt(f.label, name), ...(props.popupData ? { popupData: props.popupData } : {}), children: _jsx(Picker, { ...listOf(l, f), form: "computer", onDone: () => setOpen(null) }) }));
280
+ };
281
+ const cell = (l, name, f) => (_jsx("span", { className: "o-links-editor-cell", "data-field": f.id, "data-kind": f.kind, onKeyDown: keepArrows, children: one && f.kind === "yes-no" ? _jsx(Switch, { size: "sm", checked: l.values[f.id] === true, "aria-label": w.fieldAt(f.label, name), onCheckedChange: (c) => setField(l.value, f.id, c) })
282
+ : one ? short(l, name, f) : said(f, l.values[f.id], w.yes) }, f.id));
283
+ const row = (r) => {
284
+ const l = links.find((x) => x.value === r.value), name = r.label;
285
+ return (_jsxs("div", { className: "o-links-editor-row", "data-link": r.value, role: "group", "aria-label": name, children: [_jsxs("span", { className: "o-links-editor-who", children: [_jsx(Face, { record: r, size: 20 }), _jsx("span", { className: "o-links-editor-name", children: name })] }), fields.map((f) => cell(l, name, f)), lead && _jsx("span", { className: "o-links-editor-lead", children: _jsx(Radio, { value: r.value, "aria-label": w.isLead(name, lead.label) }) }), _jsx("span", { className: "o-links-editor-end", onKeyDown: keepArrows, children: !several ? _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: END_LOOK, "aria-label": w.unlinkName(name), icon: glyph(X), onClick: () => unlink(r.value) })
286
+ : _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: END_LOOK, className: "o-links-editor-config", "aria-label": w.editLink(name), icon: _jsx(Icon, { name: "settings" }), onClick: () => { setOpen(null); stepPressed.current = true; setStep(r.value); } }) })] }, r.value));
287
+ };
288
+ const rows = linked.map(row);
289
+ const message = doingNote ?? (!lights && (query.trim() ? (!linked.length ? w.nothingMatches : null) : linked.length ? w.everythingLinked : null));
290
+ const shown = shownList ? (() => {
291
+ const l = links.find((x) => x.value === shownList.link), f = fields.find((x) => x.id === shownList.field);
292
+ if (!l || !f)
293
+ return null;
294
+ return (_jsx("div", { className: "o-links-editor-shown o-list o-smooth o-smooth-ease", "data-links-shown": "list", ...phoneMark(small), style: shownAt ? { top: shownAt.top, left: shownAt.left } : { visibility: "hidden" }, children: _jsx(Picker, { ...listOf(l, f), form: "computer", standing: true }) }));
295
+ })() : null;
296
+ const body = (_jsxs("div", { ref: setRoot, className: "o-links-editor", "data-kit": "links-editor", ...mark, "data-links-form": "computer", "data-links-shape": "table", "data-links-fields": several ? "several" : "one", role: "group", "aria-label": label, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, children: [_jsxs("div", { className: "o-links-editor-search o-popup-line", children: [glyph(SEARCH), _jsx(Input, { chrome: "bare", autofill: false, ref: searchBox, className: "o-links-editor-input", placeholder: search, "aria-label": search, role: "combobox", "aria-expanded": lights > 0, "aria-autocomplete": "list", "aria-controls": lights ? `${ids}-add` : undefined, "aria-activedescendant": litAt != null ? `${ids}-add-${litAt}` : undefined, value: query, onValueChange: (v) => { typeQuery(v); setLit(v.trim() ? 0 : null); }, onKeyDown: keys })] }), _jsxs("div", { ref: placeList, className: "o-links-editor-list", "data-head": linked.length ? "" : undefined, "data-held": open ? "" : undefined, children: [linked.length > 0 && _jsxs(_Fragment, { children: [_jsxs("div", { className: "o-links-editor-head", "aria-hidden": "true", children: [_jsx("span", { className: "o-links-editor-who", children: kind }), fields.map((f) => _jsx("span", { className: "o-links-editor-cell", "data-field": f.id, "data-kind": f.kind, children: f.label }, f.id)), lead && _jsx("span", { className: "o-links-editor-lead", children: lead.label }), _jsx("span", { className: "o-links-editor-end" })] }), lead
297
+ ? _jsx(RadioGroup, { className: "o-links-editor-rows", "aria-label": lead.label, value: lead.value, onValueChange: (v) => setLead(v), children: rows })
298
+ : _jsx("div", { className: "o-links-editor-rows", children: rows })] }), linked.length > 0 && lights > 0 && _jsx("div", { className: "o-list-sep", role: "presentation" }), lights > 0 && _jsxs("div", { id: `${ids}-add`, role: "listbox", "aria-label": w.addTo(label), className: "o-links-editor-adds", onPointerLeave: () => setLit(query.trim() ? 0 : null), children: [linked.length > 0 && _jsx("div", { className: "o-list-heading", "aria-hidden": "true", children: w.add }), rest.map((r, i) => (_jsxs("div", { id: `${ids}-add-${i}`, role: "option", "aria-selected": i === litAt, className: "o-list-row o-smooth o-smooth-ease o-links-editor-add", "data-record": r.value, ...phoneMark(small), "data-highlighted": i === litAt ? "" : undefined, onPointerMove: () => { if (!open && i !== litAt)
299
+ setLit(i); }, onMouseDown: (e) => e.preventDefault(), onClick: () => link(r.value), children: [_jsx(Face, { record: r, size: 20 }), _jsx("span", { className: "o-list-text", children: _jsx("span", { className: "o-list-main", children: r.label }) })] }, r.value))), actions.map((a, j) => {
300
+ const i = rest.length + j;
301
+ return (_jsxs("div", { id: `${ids}-add-${i}`, role: "option", "aria-selected": i === litAt, className: "o-list-row o-smooth o-smooth-ease o-links-editor-add o-links-editor-action", ...phoneMark(small), "data-highlighted": i === litAt ? "" : undefined, onPointerMove: () => { if (!open && i !== litAt)
302
+ setLit(i); }, onMouseDown: (e) => e.preventDefault(), onClick: a.onSelect, children: [a.icon != null && _jsx("span", { className: "o-links-editor-action-mark", children: a.icon }), _jsx("span", { className: "o-list-text", children: _jsx("span", { className: "o-list-main", children: a.label }) })] }, a.key));
303
+ })] }), more, message && _jsx("div", { className: "o-links-editor-message", children: message })] }), shown] }));
304
+ return { body, head: {} };
305
+ }
306
+ export function LinksEditor(props) {
307
+ return _jsx(_Fragment, { children: useLinksEditor(props).body });
308
+ }
@@ -0,0 +1,62 @@
1
+ /** What a field on a link holds: several of a list (a link's roles), one of a list (since when), or yes or no (billed). */
2
+ export type LinkFieldKind = "several" | "one" | "yes-no";
3
+ /** A choice of a field's list: its value and its words; an archived one (a role since retired) is offered only on a link that holds
4
+ * it, by its words, so it can be let go. */
5
+ export interface LinkChoice {
6
+ value: string;
7
+ label: string;
8
+ archived?: boolean;
9
+ }
10
+ /** A field a link holds: its id, its name, its kind and, for a list, its choices. */
11
+ export interface LinkField {
12
+ id: string;
13
+ label: string;
14
+ kind: LinkFieldKind;
15
+ choices?: LinkChoice[];
16
+ }
17
+ /** A field's value on a link: several choices, one, yes or no, or nothing. */
18
+ export type LinkValue = string[] | string | boolean | null;
19
+ /** A link: its record's value, the label it came with (used when the list doesn't hold the record), and its fields' values. */
20
+ export interface Link {
21
+ value: string;
22
+ label?: string;
23
+ values: Record<string, LinkValue>;
24
+ }
25
+ /** What the search finds: the linked records in the links' order, each the list's own record or, where the list doesn't hold it,
26
+ * the label its link came with (its value, with none); then the records to add, in the list's order, a name that starts with
27
+ * what is typed before one that holds it inside. Case and accents folded. `handed`: the records are what the editor found for
28
+ * the query (it filters or fetches), so nothing is filtered or re-sorted again: the linked ones are those the list holds (every
29
+ * link while nothing is typed), the rest in the order handed. */
30
+ export declare function found<T extends {
31
+ value: string;
32
+ label: string;
33
+ }>(records: T[], links: Link[], query: string, handed?: boolean): {
34
+ linked: (T | {
35
+ value: string;
36
+ label: string;
37
+ })[];
38
+ rest: T[];
39
+ };
40
+ /** The links with `value` linked last, holding nothing; a record already linked is not linked again. */
41
+ export declare const added: (links: Link[], value: string) => Link[];
42
+ /** The links without `value`'s, the others in their order. */
43
+ export declare const removed: (links: Link[], value: string) => Link[];
44
+ /** Which link leads after a change: the lead while it is still linked, else the first link left; none with none left. */
45
+ export declare const leadAfter: (lead: string | null, after: Link[]) => string | null;
46
+ /** The links with `field` on `value`'s link set `to`; every other link, and every other field, as it was. */
47
+ export declare const setValue: (links: Link[], value: string, field: string, to: LinkValue) => Link[];
48
+ /** What several choices hold after one is pressed: a choice not held goes last, a held one comes out. */
49
+ export declare const ticked: (held: string[], choice: string) => string[];
50
+ /** The choices a link holds on a field, in the order held: several, or the one, or none. */
51
+ export declare const heldOf: (v: LinkValue | undefined) => string[];
52
+ /** What a field's list offers on a link: its choices, an archived one only where the link holds it, then each value the link holds
53
+ * that the field no longer offers (a role since removed), as it is, so it can still be unticked. A yes or no offers none. */
54
+ export declare function offered(field: LinkField, v: LinkValue | undefined): {
55
+ value: string;
56
+ label: string;
57
+ }[];
58
+ /** A field's value on a link in words, as its column reads it: several as their labels, one as its label, yes as "Yes", and
59
+ * nothing (none held, no, or nothing set) as a dash. */
60
+ export declare function said(field: LinkField, v: LinkValue | undefined, yes?: string): string;
61
+ /** A field's value as a short button says it: two whole, more as the first and how many follow ("Champion +3"); nothing, "". */
62
+ export declare function saidShort(field: LinkField, v: LinkValue | undefined, yes?: string): string;
@@ -0,0 +1,50 @@
1
+ import { fold } from "../picker/rows.js";
2
+ export function found(records, links, query, handed = false) {
3
+ const byValue = new Map(records.map((r) => [r.value, r]));
4
+ const held = new Set(links.map((l) => l.value));
5
+ if (handed) {
6
+ const typed = query.trim() !== "";
7
+ const linked = links.flatMap((l) => {
8
+ const r = byValue.get(l.value);
9
+ return r ? [r] : typed ? [] : [{ value: l.value, label: l.label ?? l.value }];
10
+ });
11
+ return { linked, rest: records.filter((r) => !held.has(r.value)) };
12
+ }
13
+ const q = fold(query), has = (label) => !q || fold(label).includes(q);
14
+ const linked = links.map((l) => byValue.get(l.value) ?? { value: l.value, label: l.label ?? l.value }).filter((r) => has(r.label));
15
+ const left = records.filter((r) => !held.has(r.value) && has(r.label));
16
+ const rest = q ? [...left.filter((r) => fold(r.label).startsWith(q)), ...left.filter((r) => !fold(r.label).startsWith(q))] : left;
17
+ return { linked, rest };
18
+ }
19
+ export const added = (links, value) => (links.some((l) => l.value === value) ? [...links] : [...links, { value, values: {} }]);
20
+ export const removed = (links, value) => links.filter((l) => l.value !== value);
21
+ export const leadAfter = (lead, after) => (lead != null && after.some((l) => l.value === lead) ? lead : after[0]?.value ?? null);
22
+ export const setValue = (links, value, field, to) => links.map((l) => (l.value === value ? { ...l, values: { ...l.values, [field]: to } } : l));
23
+ export const ticked = (held, choice) => (held.includes(choice) ? held.filter((c) => c !== choice) : [...held, choice]);
24
+ const labelOf = (field, value) => field.choices?.find((c) => c.value === value)?.label ?? value;
25
+ export const heldOf = (v) => (Array.isArray(v) ? v : typeof v === "string" && v ? [v] : []);
26
+ export function offered(field, v) {
27
+ const holds = new Set(heldOf(v));
28
+ const choices = (field.choices ?? []).filter((c) => !c.archived || holds.has(c.value)).map((c) => ({ value: c.value, label: c.label }));
29
+ if (field.kind === "yes-no")
30
+ return choices;
31
+ const known = new Set(choices.map((c) => c.value)), out = [...choices];
32
+ for (const x of heldOf(v))
33
+ if (!known.has(x)) {
34
+ known.add(x);
35
+ out.push({ value: x, label: x });
36
+ }
37
+ return out;
38
+ }
39
+ export function said(field, v, yes = "Yes") {
40
+ if (field.kind === "yes-no")
41
+ return v === true ? yes : "–";
42
+ const held = heldOf(v);
43
+ return held.length ? held.map((x) => labelOf(field, x)).join(", ") : "–";
44
+ }
45
+ export function saidShort(field, v, yes = "Yes") {
46
+ if (field.kind === "yes-no")
47
+ return v === true ? yes : "";
48
+ const held = heldOf(v).map((x) => labelOf(field, x));
49
+ return held.length <= 2 ? held.join(", ") : `${held[0]} +${held.length - 1}`;
50
+ }
@@ -0,0 +1,10 @@
1
+ import { type ViewsMessageResolver } from "../../contract.js";
2
+ import type { ViewsLinksBodyProps, ViewsResolvedComponents } from "../../provider/components.js";
3
+ import { type LinksEditorProps } from "./links-editor.js";
4
+ import type { LinksEditorWords } from "./words.js";
5
+ /** The Links editor's words in the app's messages: the Picker's keys where the words are the same, the rest its own. */
6
+ export declare function linksEditorWordsOf(say: ViewsMessageResolver, makeLead?: string): LinksEditorWords;
7
+ /** ViewKit's links body's props as the Links editor's, its roles' column named `rolesWord`. */
8
+ export declare function linksEditorPropsOf(p: ViewsLinksBodyProps, words: LinksEditorWords, rolesWord: string, AppIcon?: ViewsResolvedComponents["AppIcon"]): LinksEditorProps;
9
+ /** ViewKit's links body, drawn as the Links editor. */
10
+ export declare function MapLinksBody(props: ViewsLinksBodyProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,71 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { resolveViewsMessage } from "../../contract.js";
5
+ import { EDITOR_INNER_ESCAPE } from "../../editors/inner-escape.js";
6
+ import { ViewsContext } from "../../provider/context.js";
7
+ import { pickerItemsOf, pickerWordsOf } from "../picker/map-picker.js";
8
+ import { useLinksEditor } from "./links-editor.js";
9
+ import { heldOf } from "./links.js";
10
+ const ROLES = "roles";
11
+ export function linksEditorWordsOf(say, makeLead) {
12
+ const searchRoles = say({ key: "views.editors.links-search-roles" }), add = say({ key: "views.editors.links-add" });
13
+ return {
14
+ add,
15
+ addKind: () => add,
16
+ addTo: (label) => say({ key: "views.editors.links-add-to", values: { label } }),
17
+ linkName: (label) => say({ key: "views.editors.links-link", values: { label } }),
18
+ unlink: say({ key: "views.editors.links-unlink" }),
19
+ unlinkName: (label) => say({ key: "views.editors.links-unlink-record", values: { label } }),
20
+ setLead: (lead) => makeLead ?? lead,
21
+ isLead: (label, lead) => say({ key: "views.editors.links-is-lead", values: { label, lead } }),
22
+ actionsFor: (label) => say({ key: "views.picker.row-actions", values: { label } }),
23
+ linkMenu: (label) => say({ key: "views.editors.links-menu", values: { label } }),
24
+ editLink: (label) => say({ key: "views.editors.links-edit", values: { label } }),
25
+ backTo: (label) => say({ key: "views.picker.back", values: { label } }),
26
+ fieldAt: (field, label) => say({ key: "views.editors.links-field-at", values: { field, label } }),
27
+ searchField: () => searchRoles,
28
+ search: say({ key: "views.editors.links-search" }),
29
+ none: say({ key: "views.editors.links-none" }),
30
+ noDetails: say({ key: "views.editors.links-no-details" }),
31
+ yes: say({ key: "views.editors.links-yes" }),
32
+ no: say({ key: "views.editors.links-no" }),
33
+ everythingLinked: say({ key: "views.editors.links-all-linked" }),
34
+ nothingMatches: say({ key: "views.picker.nothing-matches" }),
35
+ nothingMatchesTyped: (typed) => say({ key: "views.picker.none-typed", values: { typed } }),
36
+ close: say({ key: "views.panels.close" }),
37
+ done: say({ key: "views.editors.links-done" }),
38
+ save: say({ key: "views.picker.save" }),
39
+ searching: say({ key: "views.picker.searching" }),
40
+ failed: say({ key: "views.picker.failed" }),
41
+ retry: say({ key: "views.picker.retry" }),
42
+ loadingMore: say({ key: "views.picker.loading-more" }),
43
+ picker: pickerWordsOf(say),
44
+ };
45
+ }
46
+ export function linksEditorPropsOf(p, words, rolesWord, AppIcon) {
47
+ const roles = { id: ROLES, label: rolesWord, kind: "several",
48
+ choices: p.roles.map((r) => ({ value: r.value, label: r.label, ...(r.archived ? { archived: true } : {}) })) };
49
+ const lead = p.lead;
50
+ return {
51
+ label: p.label, kind: p.label, records: pickerItemsOf(p.items, AppIcon ? { AppIcon } : {}), fields: p.roles.length ? [roles] : [],
52
+ links: p.links.map((l) => ({ value: l.value, values: { [ROLES]: [...l.roles] } })),
53
+ onLinksChange: (next) => p.onLinksChange(next.map((l) => ({ value: l.value, roles: heldOf(l.values[ROLES]) }))),
54
+ onDone: p.onDone, form: p.form, words, popupData: { [EDITOR_INNER_ESCAPE]: "" },
55
+ ...(p.autoFocus !== undefined ? { autoFocus: p.autoFocus } : {}),
56
+ ...(lead ? { lead: { value: lead.value, label: lead.label, onLead: (v) => { if (v != null)
57
+ lead.onLead(v); } } } : {}),
58
+ ...(p.search ? { search: p.search } : {}), ...(p.typed != null ? { typed: p.typed } : {}),
59
+ ...(p.onSearch ? { onSearch: p.onSearch } : {}), ...(p.doing ? { doing: p.doing } : {}),
60
+ ...(p.onRetry ? { onRetry: p.onRetry } : {}), ...(p.onMore ? { onMore: p.onMore } : {}),
61
+ ...(p.actions ? { actions: p.actions.map((a) => ({ key: a.key, label: a.label, ...(a.icon != null ? { icon: a.icon } : {}), onSelect: a.onSelect })) } : {}),
62
+ };
63
+ }
64
+ export function MapLinksBody(props) {
65
+ const views = React.useContext(ViewsContext);
66
+ const messages = views?.messages ?? resolveViewsMessage;
67
+ const makeLead = props.lead?.makeLabel;
68
+ const words = React.useMemo(() => linksEditorWordsOf(messages, makeLead), [messages, makeLead]);
69
+ const rolesWord = messages({ key: "views.editors.links-roles" });
70
+ return _jsx(_Fragment, { children: useLinksEditor(linksEditorPropsOf(props, words, rolesWord, views?.components.AppIcon)).body });
71
+ }
@@ -0,0 +1,71 @@
1
+ export declare const LINKS_EDITOR_TOKENS: readonly [{
2
+ readonly name: "--vk-danger";
3
+ readonly kind: "colour";
4
+ readonly outright: "--text-danger";
5
+ }, {
6
+ readonly name: "--vk-duration-fast";
7
+ readonly kind: "motion";
8
+ readonly outright: "--duration-fast";
9
+ }, {
10
+ readonly name: "--vk-ease-out";
11
+ readonly kind: "motion";
12
+ readonly outright: "--ease-out";
13
+ }, {
14
+ readonly name: "--vk-fg";
15
+ readonly kind: "colour";
16
+ readonly outright: "--text";
17
+ }, {
18
+ readonly name: "--vk-fg-subtle";
19
+ readonly kind: "colour";
20
+ readonly outright: "--text-subtle";
21
+ }, {
22
+ readonly name: "--vk-fg-subtlest";
23
+ readonly kind: "colour";
24
+ readonly outright: "--text-subtlest";
25
+ }, {
26
+ readonly name: "--vk-font-size-base";
27
+ readonly kind: "size";
28
+ readonly outright: "--text-base";
29
+ }, {
30
+ readonly name: "--vk-font-size-sm";
31
+ readonly kind: "size";
32
+ readonly outright: "--text-sm";
33
+ }, {
34
+ readonly name: "--vk-font-size-xs";
35
+ readonly kind: "size";
36
+ readonly outright: "--text-xs";
37
+ }, {
38
+ readonly name: "--vk-font-weight-medium";
39
+ readonly kind: "size";
40
+ readonly outright: "--font-weight-medium";
41
+ }, {
42
+ readonly name: "--vk-font-weight-normal";
43
+ readonly kind: "size";
44
+ readonly outright: "--font-weight-normal";
45
+ }, {
46
+ readonly name: "--vk-layer-popup";
47
+ readonly kind: "size";
48
+ readonly outright: "--layer-popup";
49
+ }, {
50
+ readonly name: "--vk-line-height-base";
51
+ readonly kind: "size";
52
+ readonly outright: "--text-base--line-height";
53
+ }, {
54
+ readonly name: "--vk-line-height-sm";
55
+ readonly kind: "size";
56
+ readonly outright: "--text-sm--line-height";
57
+ }, {
58
+ readonly name: "--vk-line-height-xs";
59
+ readonly kind: "size";
60
+ readonly outright: "--text-xs--line-height";
61
+ }, {
62
+ readonly name: "--vk-overlay";
63
+ readonly kind: "colour";
64
+ readonly outright: "--surface-overlay";
65
+ }, {
66
+ readonly name: "--vk-spacing";
67
+ readonly kind: "size";
68
+ readonly outright: "--spacing";
69
+ }];
70
+ /** The prefixes of the Links editor's own machinery, set and read by it alone: not public. */
71
+ export declare const LINKS_EDITOR_PRIVATE: readonly ["--links-"];
@@ -0,0 +1,20 @@
1
+ export const LINKS_EDITOR_TOKENS = [
2
+ { name: "--vk-danger", kind: "colour", outright: "--text-danger" },
3
+ { name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
4
+ { name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
5
+ { name: "--vk-fg", kind: "colour", outright: "--text" },
6
+ { name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
7
+ { name: "--vk-fg-subtlest", kind: "colour", outright: "--text-subtlest" },
8
+ { name: "--vk-font-size-base", kind: "size", outright: "--text-base" },
9
+ { name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
10
+ { name: "--vk-font-size-xs", kind: "size", outright: "--text-xs" },
11
+ { name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
12
+ { name: "--vk-font-weight-normal", kind: "size", outright: "--font-weight-normal" },
13
+ { name: "--vk-layer-popup", kind: "size", outright: "--layer-popup" },
14
+ { name: "--vk-line-height-base", kind: "size", outright: "--text-base--line-height" },
15
+ { name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
16
+ { name: "--vk-line-height-xs", kind: "size", outright: "--text-xs--line-height" },
17
+ { name: "--vk-overlay", kind: "colour", outright: "--surface-overlay" },
18
+ { name: "--vk-spacing", kind: "size", outright: "--spacing" },
19
+ ];
20
+ export const LINKS_EDITOR_PRIVATE = ["--links-"];