@oxy.so/bloom 19.9.1 → 19.10.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 (37) hide show
  1. package/docs/adoption-matrix.mdx +4 -4
  2. package/docs/menubar.mdx +3 -3
  3. package/docs/task-catalog.json +1 -1
  4. package/docs/task-catalog.mdx +1 -1
  5. package/lib/commonjs/menubar/declared.js +171 -66
  6. package/lib/commonjs/menubar/declared.js.map +1 -1
  7. package/lib/commonjs/menubar/description.js +293 -0
  8. package/lib/commonjs/menubar/description.js.map +1 -0
  9. package/lib/commonjs/menubar/use-edit-action.js +1 -0
  10. package/lib/commonjs/menubar/use-edit-action.js.map +1 -1
  11. package/lib/module/menubar/declared.js +145 -43
  12. package/lib/module/menubar/declared.js.map +1 -1
  13. package/lib/module/menubar/description.js +286 -0
  14. package/lib/module/menubar/description.js.map +1 -0
  15. package/lib/module/menubar/use-edit-action.js +1 -1
  16. package/lib/module/menubar/use-edit-action.js.map +1 -1
  17. package/lib/typescript/commonjs/menubar/declared.d.ts +29 -20
  18. package/lib/typescript/commonjs/menubar/declared.d.ts.map +1 -1
  19. package/lib/typescript/commonjs/menubar/description.d.ts +90 -0
  20. package/lib/typescript/commonjs/menubar/description.d.ts.map +1 -0
  21. package/lib/typescript/commonjs/menubar/types.d.ts +7 -6
  22. package/lib/typescript/commonjs/menubar/types.d.ts.map +1 -1
  23. package/lib/typescript/commonjs/menubar/use-edit-action.d.ts +4 -1
  24. package/lib/typescript/commonjs/menubar/use-edit-action.d.ts.map +1 -1
  25. package/lib/typescript/module/menubar/declared.d.ts +29 -20
  26. package/lib/typescript/module/menubar/declared.d.ts.map +1 -1
  27. package/lib/typescript/module/menubar/description.d.ts +90 -0
  28. package/lib/typescript/module/menubar/description.d.ts.map +1 -0
  29. package/lib/typescript/module/menubar/types.d.ts +7 -6
  30. package/lib/typescript/module/menubar/types.d.ts.map +1 -1
  31. package/lib/typescript/module/menubar/use-edit-action.d.ts +4 -1
  32. package/lib/typescript/module/menubar/use-edit-action.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/src/menubar/declared.tsx +166 -39
  35. package/src/menubar/description.ts +337 -0
  36. package/src/menubar/types.ts +7 -6
  37. package/src/menubar/use-edit-action.ts +2 -2
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.describeMenu = describeMenu;
7
+ exports.markMenubarHint = markMenubarHint;
8
+ exports.markMenubarPart = markMenubarPart;
9
+ exports.textOf = textOf;
10
+ var _react = require("react");
11
+ var _linkActivation = require("../hooks/link-activation.js");
12
+ var _chord = require("../kbd/chord.js");
13
+ var _useEditAction = require("./use-edit-action.js");
14
+ /**
15
+ * A closed menu's DESCRIPTION, read from its declaration's elements without
16
+ * mounting them (OxyOS ADR 0021).
17
+ *
18
+ * A closed menu's rows are known to its bar so that their shortcuts work while
19
+ * it is closed. Mounting them headless did that by rendering every row, which
20
+ * cost every bar render a render of every closed menu's rows (OxyOS's shell has
21
+ * a Window menu of some 27). A menu's content is a declaration: Bloom's own
22
+ * parts (an item, a check item, a radio group and its items, a label, a
23
+ * separator, a group, a submenu), with their props. So a closed menu's entries
24
+ * are read from those elements here, as a Mac's bar keeps a menu's items as
25
+ * data and builds its rows as it opens: the label, the shortcut, the state, and
26
+ * what choosing it runs, the element's own handler.
27
+ *
28
+ * POSITIONS are the ones `DeclaredChildren` gives the mounted rows (arrays and
29
+ * fragments flattened, every child, `null` included, taking a place), so the
30
+ * order a description sorts by is the same open or closed.
31
+ *
32
+ * What is not one of Bloom's parts (an application's own component that
33
+ * renders rows) cannot be read without rendering it: it is returned as
34
+ * `unread`, with its place, for the caller to mount headless as before.
35
+ */
36
+
37
+ /** Which of Bloom's menubar parts a component is (`createMenubarRows` marks each). */
38
+
39
+ const PART = Symbol.for('bloom.menubarPart');
40
+ const HINTS = new WeakSet();
41
+
42
+ /** Marks `component` as one of Bloom's menubar parts, so a description can read its elements. */
43
+ function markMenubarPart(component, part) {
44
+ component[PART] = part;
45
+ return component;
46
+ }
47
+
48
+ /** Marks a row's shortcut hint, which a label's text leaves out. */
49
+ function markMenubarHint(component) {
50
+ if ((typeof component === 'function' || typeof component === 'object') && component !== null) {
51
+ HINTS.add(component);
52
+ }
53
+ }
54
+ function partOf(type) {
55
+ if (typeof type !== 'function' && typeof type !== 'object' || type === null) return undefined;
56
+ return type[PART];
57
+ }
58
+ const isMarkedHint = type => (typeof type === 'function' || typeof type === 'object') && type !== null && HINTS.has(type);
59
+
60
+ /**
61
+ * The text of a part's children, as the platform's bar shows it: every string
62
+ * and number under it, element children included, except a shortcut hint
63
+ * (`isHint`), which is not part of the name.
64
+ */
65
+ function textOf(children, isHint) {
66
+ const parts = [];
67
+ const visit = node => {
68
+ if (typeof node === 'string' || typeof node === 'number') parts.push(String(node));else if (Array.isArray(node)) node.forEach(visit);else if (/*#__PURE__*/(0, _react.isValidElement)(node) && !isHint(node.type)) {
69
+ visit(node.props.children);
70
+ }
71
+ };
72
+ visit(children);
73
+ return parts.join('').replace(/\s+/g, ' ').trim();
74
+ }
75
+ const labelOf = children => textOf(children, isMarkedHint);
76
+
77
+ /** A radio group's selection, as its items read it. */
78
+
79
+ /** One entry of a closed menu, read from its element. */
80
+
81
+ /** What a description could not read: an element to mount headless at its place. */
82
+
83
+ /** The children of a container as `DeclaredChildren` places them: one per place. */
84
+ function places(children) {
85
+ const out = [];
86
+ const visit = node => {
87
+ if (Array.isArray(node)) {
88
+ node.forEach(visit);
89
+ return;
90
+ }
91
+ if (/*#__PURE__*/(0, _react.isValidElement)(node) && node.type === _react.Fragment) {
92
+ visit(node.props.children);
93
+ return;
94
+ }
95
+ out.push(node);
96
+ };
97
+ visit(children);
98
+ return out;
99
+ }
100
+
101
+ /** The chord a `shortcut` declares; null when it is none (the mounted row warns once). */
102
+ function chordOf(shortcut) {
103
+ return shortcut === undefined ? null : (0, _chord.parseChord)(shortcut);
104
+ }
105
+ const keyOf = path => `d${path.join('.')}`;
106
+
107
+ /**
108
+ * `children`'s description: its entries, each at `[...path, place]` under
109
+ * `parentKey`, and what it could not read.
110
+ */
111
+ function describeMenu(children) {
112
+ const entries = [];
113
+ const unread = [];
114
+ const visit = (nodes, path, parentKey, radio) => {
115
+ places(nodes).forEach((node, place) => {
116
+ const at = [...path, place];
117
+ if (node === null || node === undefined || typeof node === 'boolean') return;
118
+ if (! /*#__PURE__*/(0, _react.isValidElement)(node)) {
119
+ // Text placed in a menu draws nowhere in a description.
120
+ return;
121
+ }
122
+ const part = partOf(node.type);
123
+ const props = node.props;
124
+ const label = labelOf(props.children) || (props.accessibilityLabel ?? '');
125
+ switch (part) {
126
+ case 'item':
127
+ {
128
+ const {
129
+ action
130
+ } = props;
131
+ const handler = props.onPress ?? (props.href != null ? () => (0, _linkActivation.openHref)(props.href) : undefined);
132
+ const menuAction = (0, _useEditAction.isMenuAction)(action) ? action : undefined;
133
+ const editAction = (0, _useEditAction.isMenuAction)(action) ? undefined : action;
134
+ entries.push({
135
+ key: keyOf(at),
136
+ kind: 'item',
137
+ parentKey,
138
+ path: at,
139
+ label,
140
+ // An item with an action needs its own handler when no field takes the action (an
141
+ // application's own command never is a field's); while a field takes an editing
142
+ // action, its state is the field's (`DescribedEntry.editAction`).
143
+ enabled: !props.disabled && (action === undefined || handler !== undefined),
144
+ shortcut: chordOf(props.shortcut ?? (0, _useEditAction.actionShortcut)(action)),
145
+ keepOpen: props.keepOpen ?? false,
146
+ ...(menuAction ? {
147
+ action: menuAction
148
+ } : null),
149
+ ...(editAction ? {
150
+ editAction
151
+ } : null),
152
+ run: handler,
153
+ runs: true
154
+ });
155
+ return;
156
+ }
157
+ case 'checkbox':
158
+ {
159
+ const {
160
+ checked = false,
161
+ onCheckedChange
162
+ } = props;
163
+ entries.push({
164
+ key: keyOf(at),
165
+ kind: 'item',
166
+ parentKey,
167
+ path: at,
168
+ label,
169
+ enabled: !props.disabled,
170
+ shortcut: chordOf(props.shortcut),
171
+ checked,
172
+ keepOpen: props.keepOpen ?? false,
173
+ run: onCheckedChange ? () => onCheckedChange(!checked) : undefined,
174
+ runs: true
175
+ });
176
+ return;
177
+ }
178
+ case 'radioGroup':
179
+ {
180
+ const {
181
+ value,
182
+ onValueChange
183
+ } = props;
184
+ visit(props.children, at, parentKey, onValueChange ? {
185
+ value,
186
+ onValueChange
187
+ } : null);
188
+ return;
189
+ }
190
+ case 'radio':
191
+ {
192
+ const {
193
+ value
194
+ } = props;
195
+ entries.push({
196
+ key: keyOf(at),
197
+ kind: 'item',
198
+ parentKey,
199
+ path: at,
200
+ label,
201
+ enabled: !props.disabled,
202
+ shortcut: chordOf(props.shortcut),
203
+ checked: radio !== null && radio.value === value,
204
+ keepOpen: props.keepOpen ?? false,
205
+ run: radio && value !== undefined ? () => radio.onValueChange(value) : undefined,
206
+ runs: true
207
+ });
208
+ return;
209
+ }
210
+ case 'label':
211
+ // A group's label is shown, never chosen: an item that is never enabled.
212
+ entries.push({
213
+ key: keyOf(at),
214
+ kind: 'item',
215
+ parentKey,
216
+ path: at,
217
+ label: labelOf(props.children),
218
+ enabled: false,
219
+ shortcut: null,
220
+ runs: false
221
+ });
222
+ return;
223
+ case 'separator':
224
+ entries.push({
225
+ key: keyOf(at),
226
+ kind: 'separator',
227
+ parentKey,
228
+ path: at,
229
+ label: '',
230
+ enabled: true,
231
+ shortcut: null,
232
+ runs: false
233
+ });
234
+ return;
235
+ case 'group':
236
+ visit(props.children, at, parentKey, radio);
237
+ return;
238
+ case 'sub':
239
+ {
240
+ // A submenu: its trigger names it, its content is its entries, at the submenu's place.
241
+ const key = keyOf(at);
242
+ for (const child of places(props.children)) {
243
+ if (! /*#__PURE__*/(0, _react.isValidElement)(child)) continue;
244
+ const childPart = partOf(child.type);
245
+ if (childPart === 'subTrigger') {
246
+ entries.push({
247
+ key,
248
+ kind: 'submenu',
249
+ parentKey,
250
+ path: at,
251
+ label: labelOf(child.props.children) || (child.props.accessibilityLabel ?? ''),
252
+ enabled: !child.props.disabled,
253
+ shortcut: null,
254
+ runs: false
255
+ });
256
+ } else if (childPart === 'subContent') {
257
+ visit(child.props.children, at, key, null);
258
+ } else {
259
+ unread.push({
260
+ node: child,
261
+ parentKey: key,
262
+ path: at,
263
+ radio: null,
264
+ owner: {
265
+ parentKey
266
+ }
267
+ });
268
+ }
269
+ }
270
+ return;
271
+ }
272
+ case 'subTrigger':
273
+ case 'subContent':
274
+ // Outside a submenu they declare nothing, mounted or not.
275
+ return;
276
+ default:
277
+ unread.push({
278
+ node,
279
+ parentKey,
280
+ path: at,
281
+ radio,
282
+ owner: null
283
+ });
284
+ }
285
+ });
286
+ };
287
+ visit(children, [], null, null);
288
+ return {
289
+ entries,
290
+ unread
291
+ };
292
+ }
293
+ //# sourceMappingURL=description.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_linkActivation","_chord","_useEditAction","PART","Symbol","for","HINTS","WeakSet","markMenubarPart","component","part","markMenubarHint","add","partOf","type","undefined","isMarkedHint","has","textOf","children","isHint","parts","visit","node","push","String","Array","isArray","forEach","isValidElement","props","join","replace","trim","labelOf","places","out","Fragment","chordOf","shortcut","parseChord","keyOf","path","describeMenu","entries","unread","nodes","parentKey","radio","place","at","label","accessibilityLabel","action","handler","onPress","href","openHref","menuAction","isMenuAction","editAction","key","kind","enabled","disabled","actionShortcut","keepOpen","run","runs","checked","onCheckedChange","value","onValueChange","child","childPart","owner"],"sourceRoot":"../../../src","sources":["menubar/description.ts"],"mappings":";;;;;;;;;AAsBA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAGA,IAAAG,cAAA,GAAAH,OAAA;AA5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;;AAaA,MAAMI,IAAI,GAAGC,MAAM,CAACC,GAAG,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;YACA;UACF;QACA,KAAK,YAAY;QACjB,KAAK,YAAY;UACf;UACA;QACF;UACEF,MAAM,CAACrB,IAAI,CAAC;YAAED,IAAI;YAAEwB,SAAS;YAAEL,IAAI,EAAEQ,EAAE;YAAEF,KAAK;YAAE2B,KAAK,EAAE;UAAK,CAAC,CAAC;MAClE;IACF,CAAC,CAAC;EACJ,CAAC;EAEDrD,KAAK,CAACH,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC;EAC/B,OAAO;IAAEyB,OAAO;IAAEC;EAAO,CAAC;AAC5B","ignoreList":[]}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.MENU_ACTION_SHORTCUTS = exports.EDIT_ACTION_SHORTCUTS = void 0;
7
7
  exports.actionShortcut = actionShortcut;
8
8
  exports.isMenuAction = isMenuAction;
9
+ exports.responderOf = responderOf;
9
10
  exports.useEditAction = useEditAction;
10
11
  var _react = require("react");
11
12
  var _context = require("../platform-surface/context.js");
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_context","EDIT_ACTION_SHORTCUTS","exports","undo","redo","cut","copy","paste","pasteAndMatchStyle","delete","undefined","selectAll","MENU_ACTION_SHORTCUTS","about","settings","isMenuAction","action","actionShortcut","subscribeNowhere","responderOf","editing","state","getState","useEditAction","disabled","handler","usePlatformEditing","listen","useCallback","listener","subscribe","responder","useSyncExternalStore","run","perform","enabled"],"sourceRoot":"../../../src","sources":["menubar/use-edit-action.ts"],"mappings":";;;;;;;;;AAwBA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AA1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACO,MAAME,qBAA+E,GAAAC,OAAA,CAAAD,qBAAA,GAAG;EAC7FE,IAAI,EAAE,OAAO;EACbC,IAAI,EAAE,aAAa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,gBAAgB,CAAC,CAAC,EACtE,CAACE,OAAO,EAAEJ,MAAM,CAClB,CAAC;EACD,MAAMe,SAAS,GAAG,IAAAC,2BAAoB,EACpCL,MAAM,EACN,MAAMR,WAAW,CAACC,OAAO,EAAEJ,MAAM,CAAC,EAClC,MAAM,MACR,CAAC;EACD,MAAMiB,GAAG,GAAG,IAAAL,kBAAW,EAAC,MAAM;IAC5B,IAAIZ,MAAM,IAAII,OAAO,IAAID,WAAW,CAACC,OAAO,EAAEJ,MAAM,CAAC,KAAK,MAAM,EAAE;MAChEI,OAAO,CAACc,OAAO,CAAClB,MAAM,CAAC;MACvB;IACF;IACAS,OAAO,GAAG,CAAC;EACb,CAAC,EAAE,CAACT,MAAM,EAAEI,OAAO,EAAEK,OAAO,CAAC,CAAC;EAC9B,IAAIM,SAAS,KAAK,MAAM,EAAE,OAAO;IAAEI,OAAO,EAAEJ,SAAS,KAAK,SAAS;IAAEE;EAAI,CAAC;EAC1E,OAAO;IAAEE,OAAO,EAAE,CAACX,QAAQ,KAAKR,MAAM,KAAKN,SAAS,IAAIe,OAAO,KAAKf,SAAS,CAAC;IAAEuB;EAAI,CAAC;AACvF","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_context","EDIT_ACTION_SHORTCUTS","exports","undo","redo","cut","copy","paste","pasteAndMatchStyle","delete","undefined","selectAll","MENU_ACTION_SHORTCUTS","about","settings","isMenuAction","action","actionShortcut","subscribeNowhere","responderOf","editing","state","getState","useEditAction","disabled","handler","usePlatformEditing","listen","useCallback","listener","subscribe","responder","useSyncExternalStore","run","perform","enabled"],"sourceRoot":"../../../src","sources":["menubar/use-edit-action.ts"],"mappings":";;;;;;;;;;AAwBA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AA1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA;AAC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kBAAW,EACvBC,QAAoB,IACnBT,OAAO,IAAIJ,MAAM,GAAGI,OAAO,CAACU,SAAS,CAACD,QAAQ,CAAC,GAAGX,gBAAgB,CAAC,CAAC,EACtE,CAACE,OAAO,EAAEJ,MAAM,CAClB,CAAC;EACD,MAAMe,SAAS,GAAG,IAAAC,2BAAoB,EACpCL,MAAM,EACN,MAAMR,WAAW,CAACC,OAAO,EAAEJ,MAAM,CAAC,EAClC,MAAM,MACR,CAAC;EACD,MAAMiB,GAAG,GAAG,IAAAL,kBAAW,EAAC,MAAM;IAC5B,IAAIZ,MAAM,IAAII,OAAO,IAAID,WAAW,CAACC,OAAO,EAAEJ,MAAM,CAAC,KAAK,MAAM,EAAE;MAChEI,OAAO,CAACc,OAAO,CAAClB,MAAM,CAAC;MACvB;IACF;IACAS,OAAO,GAAG,CAAC;EACb,CAAC,EAAE,CAACT,MAAM,EAAEI,OAAO,EAAEK,OAAO,CAAC,CAAC;EAC9B,IAAIM,SAAS,KAAK,MAAM,EAAE,OAAO;IAAEI,OAAO,EAAEJ,SAAS,KAAK,SAAS;IAAEE;EAAI,CAAC;EAC1E,OAAO;IAAEE,OAAO,EAAE,CAACX,QAAQ,KAAKR,MAAM,KAAKN,SAAS,IAAIe,OAAO,KAAKf,SAAS,CAAC;IAAEuB;EAAI,CAAC;AACvF","ignoreList":[]}
@@ -11,27 +11,33 @@
11
11
  * handlers stay the application's closures, and choosing an item anywhere runs
12
12
  * exactly what a press on its row runs.
13
13
  *
14
- * A declaration is mounted HEADLESS where it must be known but not drawn: the
15
- * whole bar with the `menu-bar` capability (the platform draws it), and a
16
- * closed menu's or submenu's content without it (so its shortcuts work while
17
- * it is closed). A headless part registers and renders nothing; its containers
18
- * (a menu's content, a group, a radio group, a submenu) render only their
19
- * children, each in a slot that records its position for the description's
20
- * order. Open, the parts draw exactly as before and register too.
14
+ * With the `menu-bar` capability (the platform draws the bar) the whole bar
15
+ * is mounted HEADLESS: known but not drawn. A headless part registers and
16
+ * renders nothing; its containers (a menu's content, a group, a radio group, a
17
+ * submenu) render only their children, each in a slot that records its
18
+ * position for the description's order.
19
+ *
20
+ * Without it, a CLOSED menu's or submenu's content is not mounted at all: its
21
+ * entries are read from its elements (`description.ts`, `StaticDeclaration`)
22
+ * so that its shortcuts work while it is closed, and its rows mount as it
23
+ * opens, register, and draw. Only an element that is not one of Bloom's parts
24
+ * (an application's own component rendering rows) is mounted headless there,
25
+ * since it cannot be read without rendering it.
21
26
  *
22
27
  * A menu's content is its rows. Anything else placed inside one (a bare
23
- * `View` or `Text`) is mounted with the declaration and so would draw where
24
- * the declaration is mounted headless; it is not part of the description.
28
+ * `View` or `Text`) is not part of the description.
25
29
  */
26
- import { Fragment, isValidElement, createContext, useContext, useMemo, useRef, useState } from 'react';
30
+ import { Fragment, isValidElement, createContext, useContext, useCallback, useMemo, useRef, useState, useSyncExternalStore } from 'react';
27
31
  import { openHref } from "../hooks/link-activation.js";
28
32
  import { MenuRadioGroupProvider, useMenuRadioGroup } from "../floating/context.js";
29
33
  import { useControllableState } from "../hooks/use-controllable-state.js";
30
34
  import { formatChord, parseChord } from "../kbd/chord.js";
35
+ import { usePlatformEditing } from "../platform-surface/context.js";
31
36
  import { useIsomorphicLayoutEffect } from "../theme/use-isomorphic-layout-effect.js";
32
37
  import { MenubarScopeProvider, useMenubarMenu, useMenubarScope } from "./context.js";
38
+ import { describeMenu, markMenubarHint, markMenubarPart, textOf } from "./description.js";
33
39
  import { nextMenuEntryId } from "./registry.js";
34
- import { actionShortcut, isMenuAction, useEditAction } from "./use-edit-action.js";
40
+ import { actionShortcut, isMenuAction, responderOf, useEditAction } from "./use-edit-action.js";
35
41
  import { useMenubarLeaving } from "./viewport.js";
36
42
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
37
43
  /**
@@ -63,22 +69,7 @@ export function useMenuEntry(scope, fields, run) {
63
69
  }, [registry, id]);
64
70
  return id;
65
71
  }
66
-
67
- /**
68
- * The text of a part's children, as the platform's bar shows it: every string
69
- * and number under it, element children included, except a shortcut hint
70
- * (`isHint`), which is not part of the name.
71
- */
72
- export function textOf(children, isHint) {
73
- const parts = [];
74
- const visit = node => {
75
- if (typeof node === 'string' || typeof node === 'number') parts.push(String(node));else if (Array.isArray(node)) node.forEach(visit);else if (/*#__PURE__*/isValidElement(node) && !isHint(node.type)) {
76
- visit(node.props.children);
77
- }
78
- };
79
- visit(children);
80
- return parts.join('').replace(/\s+/g, ' ').trim();
81
- }
72
+ export { textOf };
82
73
 
83
74
  /** Whether the drawn submenu around a `MenubarSubContent` is open. */
84
75
  const SubOpenContext = /*#__PURE__*/createContext(false);
@@ -149,29 +140,129 @@ export function DeclaredChildren({
149
140
  children: slots
150
141
  });
151
142
  }
143
+ const subscribeNowhere = () => () => undefined;
152
144
 
153
- /** Mounts a declaration to be known but not drawn (see the file comment). */
154
- export function HeadlessDeclaration({
145
+ /**
146
+ * A closed menu's or submenu's content, KNOWN to its bar without being
147
+ * mounted: its entries read from its elements (`describeMenu`) and registered
148
+ * here, each at the place its row would take; what is not one of Bloom's parts
149
+ * is mounted headless at its place, as before.
150
+ *
151
+ * An entry's `run` is stable while it keeps its place and calls the current
152
+ * element's handler, so a re-render of the application's bar is no change to
153
+ * the registry unless what the menu says changed. An item with an editing
154
+ * action follows the focused field, as its row would (`use-edit-action.ts`).
155
+ */
156
+ export function StaticDeclaration({
155
157
  children
156
158
  }) {
157
159
  const scope = useMenubarScope();
158
- const value = useMemo(() => scope ? {
159
- ...scope,
160
- headless: true
161
- } : null, [scope]);
162
- if (!value) return null;
163
- return /*#__PURE__*/_jsx(MenubarScopeProvider, {
164
- value: value,
165
- children: /*#__PURE__*/_jsx(DeclaredChildren, {
166
- children: children
160
+ const description = useMemo(() => describeMenu(children), [children]);
161
+ const editing = usePlatformEditing();
162
+ const edits = description.entries.some(entry => entry.editAction !== undefined);
163
+ // What a focused field can do with each editing action, as one value: a change re-renders.
164
+ const listen = useCallback(listener => edits && editing ? editing.subscribe(listener) : subscribeNowhere(), [edits, editing]);
165
+ useSyncExternalStore(listen, () => edits ? description.entries.map(entry => responderOf(editing, entry.editAction)).join() : '', () => '');
166
+ const registry = scope?.registry;
167
+ const parent = scope?.parent ?? null;
168
+ const idOf = useCallback(key => `${parent ?? 'bar'}/${key}`, [parent]);
169
+ const latest = useRef(new Map());
170
+ const latestEditing = useRef(editing);
171
+ const runs = useRef(new Map());
172
+ const registered = useRef(new Set());
173
+ const runFor = key => {
174
+ let run = runs.current.get(key);
175
+ if (!run) {
176
+ run = () => {
177
+ const entry = latest.current.get(key);
178
+ if (!entry) return;
179
+ const field = latestEditing.current;
180
+ if (entry.editAction && field && responderOf(field, entry.editAction) !== 'none') {
181
+ field.perform(entry.editAction);
182
+ return;
183
+ }
184
+ entry.run?.();
185
+ };
186
+ runs.current.set(key, run);
187
+ }
188
+ return run;
189
+ };
190
+ useIsomorphicLayoutEffect(() => {
191
+ if (!registry || !scope) return;
192
+ latest.current = new Map(description.entries.map(entry => [entry.key, entry]));
193
+ latestEditing.current = editing;
194
+ const now = new Set();
195
+ for (const entry of description.entries) {
196
+ const id = idOf(entry.key);
197
+ now.add(id);
198
+ const responder = responderOf(editing, entry.editAction);
199
+ registry.set({
200
+ id,
201
+ kind: entry.kind,
202
+ parent: entry.parentKey === null ? parent : idOf(entry.parentKey),
203
+ path: [...scope.path, ...entry.path],
204
+ label: entry.label,
205
+ enabled: responder === 'none' ? entry.enabled : responder === 'enabled',
206
+ shortcut: entry.shortcut,
207
+ ...(entry.checked === undefined ? null : {
208
+ checked: entry.checked
209
+ }),
210
+ ...(entry.keepOpen === undefined ? null : {
211
+ keepOpen: entry.keepOpen
212
+ }),
213
+ ...(entry.action ? {
214
+ action: entry.action
215
+ } : null),
216
+ run: entry.runs ? runFor(entry.key) : undefined
217
+ });
218
+ }
219
+ for (const id of registered.current) if (!now.has(id)) registry.delete(id);
220
+ registered.current = now;
221
+ for (const key of runs.current.keys()) if (!latest.current.has(key)) runs.current.delete(key);
222
+ });
223
+ useIsomorphicLayoutEffect(() => {
224
+ if (!registry) return undefined;
225
+ return () => {
226
+ for (const id of registered.current) registry.delete(id);
227
+ registered.current = new Set();
228
+ };
229
+ }, [registry, idOf]);
230
+ if (!scope) return null;
231
+ return /*#__PURE__*/_jsx(_Fragment, {
232
+ children: description.unread.map(element => {
233
+ const subKey = element.parentKey;
234
+ const path = [...scope.path, ...element.path];
235
+ const {
236
+ owner
237
+ } = element;
238
+ const value = {
239
+ ...scope,
240
+ headless: true,
241
+ parent: subKey === null ? parent : idOf(subKey),
242
+ path,
243
+ owner: owner && subKey !== null ? {
244
+ kind: 'submenu',
245
+ id: idOf(subKey),
246
+ parent: owner.parentKey === null ? parent : idOf(owner.parentKey),
247
+ path
248
+ } : undefined
249
+ };
250
+ const node = element.radio ? /*#__PURE__*/_jsx(MenuRadioGroupProvider, {
251
+ value: element.radio,
252
+ children: element.node
253
+ }) : element.node;
254
+ return /*#__PURE__*/_jsx(MenubarScopeProvider, {
255
+ value: value,
256
+ children: node
257
+ }, `${subKey ?? ''}@${element.path.join('.')}`);
167
258
  })
168
259
  });
169
260
  }
170
261
 
171
262
  /**
172
263
  * A fork's `MenubarContent`: its panel (`Panel`, the sheet or the anchored
173
- * panel) as before, with the content headless beside it while the menu is
174
- * closed; only the headless content with the capability.
264
+ * panel) as before, with the content known to the bar while the menu is
265
+ * closed (`StaticDeclaration`); only the headless content with the capability.
175
266
  */
176
267
  export function createMenubarContent(Panel) {
177
268
  function MenubarContent(props) {
@@ -181,7 +272,7 @@ export function createMenubarContent(Panel) {
181
272
  children: props.children
182
273
  });
183
274
  return /*#__PURE__*/_jsxs(_Fragment, {
184
- children: [menu.open || scope?.declareClosed === false ? null : /*#__PURE__*/_jsx(HeadlessDeclaration, {
275
+ children: [menu.open || scope?.declareClosed === false ? null : /*#__PURE__*/_jsx(StaticDeclaration, {
185
276
  children: props.children
186
277
  }), /*#__PURE__*/_jsx(Panel, {
187
278
  ...props
@@ -436,17 +527,28 @@ export function createMenubarRows(rows) {
436
527
  }
437
528
  MenubarSubContent.displayName = 'MenubarSubContent';
438
529
 
439
- /** Drawn: the fork's sub content, with its content headless beside it while it is closed. */
530
+ /** Drawn: the fork's sub content, with its content known to the bar while it is closed. */
440
531
  function DrawnSubContent(props) {
441
532
  const open = useContext(SubOpenContext);
442
533
  return /*#__PURE__*/_jsxs(_Fragment, {
443
- children: [open ? null : /*#__PURE__*/_jsx(HeadlessDeclaration, {
534
+ children: [open ? null : /*#__PURE__*/_jsx(StaticDeclaration, {
444
535
  children: props.children
445
536
  }), /*#__PURE__*/_jsx(rows.SubContent, {
446
537
  ...props
447
538
  })]
448
539
  });
449
540
  }
541
+ markMenubarHint(Shortcut);
542
+ markMenubarPart(MenubarItem, 'item');
543
+ markMenubarPart(MenubarCheckboxItem, 'checkbox');
544
+ markMenubarPart(MenubarRadioGroup, 'radioGroup');
545
+ markMenubarPart(MenubarRadioItem, 'radio');
546
+ markMenubarPart(MenubarLabel, 'label');
547
+ markMenubarPart(MenubarSeparator, 'separator');
548
+ markMenubarPart(MenubarGroup, 'group');
549
+ markMenubarPart(MenubarSub, 'sub');
550
+ markMenubarPart(MenubarSubTrigger, 'subTrigger');
551
+ markMenubarPart(MenubarSubContent, 'subContent');
450
552
  return {
451
553
  Item: MenubarItem,
452
554
  CheckboxItem: MenubarCheckboxItem,