@embedpdf/react 3.0.0-next.14 → 3.0.0-next.16

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 (244) hide show
  1. package/dist/AnnotationList-DcyhF2kU-CiBFOq1z.d.cts +878 -0
  2. package/dist/AnnotationList-DcyhF2kU-CiBFOq1z.d.ts +878 -0
  3. package/dist/actions.cjs +25 -5
  4. package/dist/actions.cjs.map +1 -1
  5. package/dist/actions.d.cts +18 -5
  6. package/dist/actions.d.ts +18 -5
  7. package/dist/actions.js +22 -6
  8. package/dist/actions.js.map +1 -1
  9. package/dist/anchored-DeX95xSd.d.ts +85 -0
  10. package/dist/anchored-DzN3JywS.d.cts +85 -0
  11. package/dist/anchored.cjs +71 -28
  12. package/dist/anchored.cjs.map +1 -1
  13. package/dist/anchored.d.cts +2 -45
  14. package/dist/anchored.d.ts +2 -45
  15. package/dist/anchored.js +56 -19
  16. package/dist/anchored.js.map +1 -1
  17. package/dist/annotation-3UvABfJm.d.cts +305 -0
  18. package/dist/annotation-BNHQpMKv.cjs +806 -0
  19. package/dist/annotation-BNHQpMKv.cjs.map +1 -0
  20. package/dist/annotation-CDI8CFb3.js +684 -0
  21. package/dist/annotation-CDI8CFb3.js.map +1 -0
  22. package/dist/annotation-DhEfs0pH.d.ts +305 -0
  23. package/dist/annotation.cjs +20 -784
  24. package/dist/annotation.d.cts +2 -2
  25. package/dist/annotation.d.ts +2 -2
  26. package/dist/annotation.js +2 -769
  27. package/dist/attachment.cjs +39 -0
  28. package/dist/attachment.cjs.map +1 -0
  29. package/dist/attachment.d.cts +29 -0
  30. package/dist/attachment.d.ts +29 -0
  31. package/dist/attachment.js +28 -0
  32. package/dist/attachment.js.map +1 -0
  33. package/dist/commands.cjs +68 -28
  34. package/dist/commands.cjs.map +1 -1
  35. package/dist/commands.d.cts +37 -10
  36. package/dist/commands.d.ts +37 -10
  37. package/dist/commands.js +68 -31
  38. package/dist/commands.js.map +1 -1
  39. package/dist/form-BSGvjA5D.js +511 -0
  40. package/dist/form-BSGvjA5D.js.map +1 -0
  41. package/dist/form-BgztZyOK.cjs +548 -0
  42. package/dist/form-BgztZyOK.cjs.map +1 -0
  43. package/dist/form.cjs +5 -5
  44. package/dist/form.d.cts +41 -2
  45. package/dist/form.d.ts +41 -2
  46. package/dist/form.js +2 -3
  47. package/dist/history.cjs +38 -0
  48. package/dist/history.cjs.map +1 -0
  49. package/dist/history.d.cts +27 -0
  50. package/dist/history.d.ts +27 -0
  51. package/dist/history.js +27 -0
  52. package/dist/history.js.map +1 -0
  53. package/dist/i18n.cjs +26 -30
  54. package/dist/i18n.cjs.map +1 -1
  55. package/dist/i18n.d.cts +24 -21
  56. package/dist/i18n.d.ts +24 -21
  57. package/dist/i18n.js +24 -31
  58. package/dist/i18n.js.map +1 -1
  59. package/dist/index.cjs +227 -57
  60. package/dist/index.d.cts +35 -32
  61. package/dist/index.d.ts +35 -32
  62. package/dist/index.js +36 -30
  63. package/dist/inert-CmBEbKCn.cjs +19 -0
  64. package/dist/inert-CmBEbKCn.cjs.map +1 -0
  65. package/dist/inert-D8fkennb.js +14 -0
  66. package/dist/inert-D8fkennb.js.map +1 -0
  67. package/dist/interaction.cjs +48 -102
  68. package/dist/interaction.cjs.map +1 -1
  69. package/dist/interaction.d.cts +23 -32
  70. package/dist/interaction.d.ts +23 -32
  71. package/dist/interaction.js +33 -102
  72. package/dist/interaction.js.map +1 -1
  73. package/dist/link.cjs +65 -104
  74. package/dist/link.cjs.map +1 -1
  75. package/dist/link.d.cts +21 -16
  76. package/dist/link.d.ts +22 -17
  77. package/dist/link.js +67 -107
  78. package/dist/link.js.map +1 -1
  79. package/dist/measurement.cjs +36 -11
  80. package/dist/measurement.cjs.map +1 -1
  81. package/dist/measurement.d.cts +33 -7
  82. package/dist/measurement.d.ts +33 -7
  83. package/dist/measurement.js +35 -14
  84. package/dist/measurement.js.map +1 -1
  85. package/dist/metadata.cjs +20 -7
  86. package/dist/metadata.cjs.map +1 -1
  87. package/dist/metadata.d.cts +22 -7
  88. package/dist/metadata.d.ts +22 -7
  89. package/dist/metadata.js +20 -10
  90. package/dist/metadata.js.map +1 -1
  91. package/dist/outline.cjs +39 -0
  92. package/dist/outline.cjs.map +1 -0
  93. package/dist/outline.d.cts +31 -0
  94. package/dist/outline.d.ts +31 -0
  95. package/dist/outline.js +28 -0
  96. package/dist/outline.js.map +1 -0
  97. package/dist/page-edit.cjs +15 -3
  98. package/dist/page-edit.cjs.map +1 -1
  99. package/dist/page-edit.d.cts +17 -2
  100. package/dist/page-edit.d.ts +17 -2
  101. package/dist/page-edit.js +15 -5
  102. package/dist/page-edit.js.map +1 -1
  103. package/dist/page-layers-Bkaaz8Zf.js +26 -0
  104. package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
  105. package/dist/page-layers-BloZDoOV.cjs +37 -0
  106. package/dist/page-layers-BloZDoOV.cjs.map +1 -0
  107. package/dist/page-view.cjs +89 -82
  108. package/dist/page-view.cjs.map +1 -1
  109. package/dist/page-view.d.cts +14 -7
  110. package/dist/page-view.d.ts +18 -11
  111. package/dist/page-view.js +86 -81
  112. package/dist/page-view.js.map +1 -1
  113. package/dist/redaction.cjs +30 -15
  114. package/dist/redaction.cjs.map +1 -1
  115. package/dist/redaction.d.cts +27 -9
  116. package/dist/redaction.d.ts +27 -9
  117. package/dist/redaction.js +29 -18
  118. package/dist/redaction.js.map +1 -1
  119. package/dist/render.cjs +71 -46
  120. package/dist/render.cjs.map +1 -1
  121. package/dist/render.d.cts +17 -5
  122. package/dist/render.d.ts +17 -5
  123. package/dist/render.js +70 -49
  124. package/dist/render.js.map +1 -1
  125. package/dist/runtime-BfnpyfY0.cjs +556 -0
  126. package/dist/runtime-BfnpyfY0.cjs.map +1 -0
  127. package/dist/runtime-DBEBlpQV.d.cts +237 -0
  128. package/dist/runtime-V3MVMb91.d.ts +237 -0
  129. package/dist/runtime-tD5iJU83.js +399 -0
  130. package/dist/runtime-tD5iJU83.js.map +1 -0
  131. package/dist/runtime.cjs +45 -324
  132. package/dist/runtime.d.cts +2 -2
  133. package/dist/runtime.d.ts +2 -2
  134. package/dist/runtime.js +2 -306
  135. package/dist/search.cjs +81 -50
  136. package/dist/search.cjs.map +1 -1
  137. package/dist/search.d.cts +37 -24
  138. package/dist/search.d.ts +37 -24
  139. package/dist/search.js +81 -53
  140. package/dist/search.js.map +1 -1
  141. package/dist/selection.cjs +105 -108
  142. package/dist/selection.cjs.map +1 -1
  143. package/dist/selection.d.cts +54 -26
  144. package/dist/selection.d.ts +56 -28
  145. package/dist/selection.js +103 -110
  146. package/dist/selection.js.map +1 -1
  147. package/dist/shell.cjs +36 -21
  148. package/dist/shell.cjs.map +1 -1
  149. package/dist/shell.d.cts +32 -17
  150. package/dist/shell.d.ts +32 -17
  151. package/dist/shell.js +36 -24
  152. package/dist/shell.js.map +1 -1
  153. package/dist/signature.cjs +29 -48
  154. package/dist/signature.cjs.map +1 -1
  155. package/dist/signature.d.cts +26 -26
  156. package/dist/signature.d.ts +26 -26
  157. package/dist/signature.js +30 -48
  158. package/dist/signature.js.map +1 -1
  159. package/dist/stage-B7BG2e8Q.cjs +369 -0
  160. package/dist/stage-B7BG2e8Q.cjs.map +1 -0
  161. package/dist/stage-BqfBjDu6.js +302 -0
  162. package/dist/stage-BqfBjDu6.js.map +1 -0
  163. package/dist/stage-ByFPD-Fv.d.cts +117 -0
  164. package/dist/stage-DaboaheR.d.ts +117 -0
  165. package/dist/stage-scope-CQgCuf1w.cjs +46 -0
  166. package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
  167. package/dist/stage-scope-D7ZeNduT.js +23 -0
  168. package/dist/stage-scope-D7ZeNduT.js.map +1 -0
  169. package/dist/stage.cjs +12 -235
  170. package/dist/stage.d.cts +2 -116
  171. package/dist/stage.d.ts +2 -116
  172. package/dist/stage.js +3 -228
  173. package/dist/stamp.cjs +41 -35
  174. package/dist/stamp.cjs.map +1 -1
  175. package/dist/stamp.d.cts +25 -18
  176. package/dist/stamp.d.ts +25 -18
  177. package/dist/stamp.js +40 -37
  178. package/dist/stamp.js.map +1 -1
  179. package/dist/state-0K1I5cM4.d.cts +29 -0
  180. package/dist/state-0K1I5cM4.d.ts +29 -0
  181. package/dist/state-CzI2KlZb.js +62 -0
  182. package/dist/state-CzI2KlZb.js.map +1 -0
  183. package/dist/state-Dtf8HAue.cjs +73 -0
  184. package/dist/state-Dtf8HAue.cjs.map +1 -0
  185. package/dist/svg-shapes-Dm1yTR1b.js +40 -0
  186. package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
  187. package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
  188. package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
  189. package/dist/toolbar.cjs +297 -295
  190. package/dist/toolbar.cjs.map +1 -1
  191. package/dist/toolbar.d.cts +58 -68
  192. package/dist/toolbar.d.ts +67 -77
  193. package/dist/toolbar.js +271 -293
  194. package/dist/toolbar.js.map +1 -1
  195. package/dist/view-manager.cjs +34 -0
  196. package/dist/view-manager.cjs.map +1 -0
  197. package/dist/view-manager.d.cts +21 -0
  198. package/dist/view-manager.d.ts +21 -0
  199. package/dist/view-manager.js +23 -0
  200. package/dist/view-manager.js.map +1 -0
  201. package/package.json +47 -39
  202. package/dist/annotation-BCED_p9H.d.cts +0 -160
  203. package/dist/annotation-anchors-CetwM1g7.js +0 -15
  204. package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
  205. package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
  206. package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
  207. package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
  208. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
  209. package/dist/annotation-hooks-Df8EmzDO.js +0 -11
  210. package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
  211. package/dist/annotation-k38KDlIZ.d.ts +0 -160
  212. package/dist/annotation-menu.cjs +0 -64
  213. package/dist/annotation-menu.cjs.map +0 -1
  214. package/dist/annotation-menu.d.cts +0 -33
  215. package/dist/annotation-menu.d.ts +0 -33
  216. package/dist/annotation-menu.js +0 -48
  217. package/dist/annotation-menu.js.map +0 -1
  218. package/dist/annotation.cjs.map +0 -1
  219. package/dist/annotation.js.map +0 -1
  220. package/dist/form-BVumS7up.cjs +0 -926
  221. package/dist/form-BVumS7up.cjs.map +0 -1
  222. package/dist/form-Bdjk0Z3T.d.cts +0 -537
  223. package/dist/form-CK3mp99m.js +0 -895
  224. package/dist/form-CK3mp99m.js.map +0 -1
  225. package/dist/form-CYRYgthn.d.ts +0 -537
  226. package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
  227. package/dist/runtime-DE76hlnl.d.ts +0 -216
  228. package/dist/runtime-umHA_xHt.d.cts +0 -216
  229. package/dist/runtime.cjs.map +0 -1
  230. package/dist/runtime.js.map +0 -1
  231. package/dist/scrollbar.cjs +0 -241
  232. package/dist/scrollbar.cjs.map +0 -1
  233. package/dist/scrollbar.d.cts +0 -42
  234. package/dist/scrollbar.d.ts +0 -42
  235. package/dist/scrollbar.js +0 -213
  236. package/dist/scrollbar.js.map +0 -1
  237. package/dist/stage.cjs.map +0 -1
  238. package/dist/stage.js.map +0 -1
  239. package/dist/views.cjs +0 -35
  240. package/dist/views.cjs.map +0 -1
  241. package/dist/views.d.cts +0 -21
  242. package/dist/views.d.ts +0 -21
  243. package/dist/views.js +0 -27
  244. package/dist/views.js.map +0 -1
package/dist/toolbar.cjs CHANGED
@@ -1,62 +1,48 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_rolldown_runtime = require("./rolldown-runtime-DDXJien1.cjs");
3
- const require_runtime = require("./runtime.cjs");
3
+ const require_runtime = require("./runtime-BfnpyfY0.cjs");
4
+ const require_inert = require("./inert-CmBEbKCn.cjs");
4
5
  let react_jsx_runtime = require("react/jsx-runtime");
6
+ let _embedpdf_web = require("@embedpdf/web");
5
7
  let react = require("react");
6
8
  react = require_rolldown_runtime.__toESM(react, 1);
7
9
  let _embedpdf_core_ui = require("@embedpdf/core-ui");
10
+ let _embedpdf_plugin_commands_contract_host = require("@embedpdf/plugin-commands/contract/host");
8
11
  let _embedpdf_plugin_commands_contract = require("@embedpdf/plugin-commands/contract");
9
12
  //#region src/toolbar.tsx
10
- const stripGroupsEqual = (a, b) => a.length === b.length && a.every((g, i) => g.id === b[i].id && g.commands.length === b[i].commands.length && g.commands.every((c, j) => (0, _embedpdf_plugin_commands_contract.resolvedCommandsEqual)(c, b[i].commands[j])));
13
+ const stripGroupsEqual = (left, right) => (0, _embedpdf_core_ui.sameStripGroups)(left, right, _embedpdf_plugin_commands_contract.resolvedCommandsEqual);
11
14
  const NO_STRIP_GROUPS = [];
12
15
  /**
13
16
  * The live projection of a bar through the command registry — <Toolbar>'s
14
- * un-measured sibling, for contextual strips (ChromeSchema.strips). The schema
15
- * declares what COULD appear; each command's `visible` derivation decides what
16
- * DOES; null means nothing currently applies, so `if (!view) return null` is
17
+ * un-measured sibling, for contextual strips (a bar over a selection). The schema
18
+ * declares what could appear; each command's `visible` derivation decides what
19
+ * does; null means nothing currently applies, so `if (!view) return null` is
17
20
  * the caller's entire show/hide logic. `execute` is pre-bound to this
18
21
  * subtree's document. Reads are value-equal (resolvedCommandsEqual), so
19
22
  * consumers re-render on real change, not on every store action.
20
23
  */
21
24
  function useStripView(bar) {
22
- const commands = require_runtime.useCapability(_embedpdf_plugin_commands_contract.CommandsToken);
25
+ const commands = require_runtime.useCapability(_embedpdf_plugin_commands_contract_host.CommandsToken);
23
26
  const documentId = require_runtime.useDocumentId();
24
27
  const normalized = (0, react.useMemo)(() => bar ? (0, _embedpdf_core_ui.normalizeBar)(bar) : null, [bar]);
25
- const groups = require_runtime.useKernelValue(() => {
26
- if (!normalized) return NO_STRIP_GROUPS;
27
- const resolved = /* @__PURE__ */ new Map();
28
- const visible = (id) => {
29
- const cmd = commands.resolve(id, documentId ?? void 0);
30
- if (cmd) resolved.set(id, cmd);
31
- return cmd?.visible === true;
32
- };
33
- return (0, _embedpdf_core_ui.projectStrip)(normalized, visible).map((g) => ({
34
- id: g.id,
35
- labelKey: g.labelKey,
36
- commands: g.commands.map((id) => resolved.get(id))
37
- }));
38
- }, stripGroupsEqual);
28
+ const groups = require_runtime.useKernelValue(() => normalized ? (0, _embedpdf_core_ui.stripGroupsOf)(normalized, (id) => commands.resolveCommand(id, documentId ?? void 0)) : NO_STRIP_GROUPS, stripGroupsEqual);
39
29
  return (0, react.useMemo)(() => groups.length === 0 ? null : {
40
30
  groups,
41
- execute: (id) => commands.execute(id, documentId ?? void 0)
31
+ execute: (id) => void commands.execute(id, { documentId: documentId ?? void 0 })
42
32
  }, [
43
33
  groups,
44
34
  commands,
45
35
  documentId
46
36
  ]);
47
37
  }
48
- /** Report this node's border-box width under `k`, live, via ResizeObserver. */
49
- function Measured({ k, onWidth, children }) {
38
+ /** Report this node's border-box length along the toolbar under `k`, live. */
39
+ function Measured({ k, orientation, onLength, children }) {
50
40
  const ref = (0, react.useRef)(null);
51
- (0, react.useLayoutEffect)(() => {
52
- const el = ref.current;
53
- if (!el) return;
54
- const report = () => onWidth(k, el.getBoundingClientRect().width);
55
- report();
56
- const observer = new ResizeObserver(report);
57
- observer.observe(el);
58
- return () => observer.disconnect();
59
- }, [k, onWidth]);
41
+ (0, react.useLayoutEffect)(() => ref.current ? (0, _embedpdf_web.observeLength)(ref.current, orientation, (length) => onLength(k, length)) : void 0, [
42
+ k,
43
+ orientation,
44
+ onLength
45
+ ]);
60
46
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
61
47
  ref,
62
48
  style: {
@@ -70,20 +56,16 @@ function Measured({ k, onWidth, children }) {
70
56
  * The socket for an unregistered custom unit: a real `<slot>` element. Inside
71
57
  * the <embedpdf-viewer> shadow root the browser projects same-named light-DOM
72
58
  * children into it; anywhere else it just displays its fallback (the terminal
73
- * command). Measured live — the projected content lives in the HOST's world,
74
- * so its width can only be observed where it actually renders.
59
+ * command). Measured live — the projected content lives in the host's world,
60
+ * so its length can only be observed where it actually renders.
75
61
  */
76
- function NativeSlotSocket({ name, k, onWidth, children }) {
62
+ function NativeSlotSocket({ name, k, orientation, onLength, children }) {
77
63
  const ref = (0, react.useRef)(null);
78
- (0, react.useLayoutEffect)(() => {
79
- const el = ref.current;
80
- if (!el) return;
81
- const report = () => onWidth(k, el.getBoundingClientRect().width);
82
- report();
83
- const observer = new ResizeObserver(report);
84
- observer.observe(el);
85
- return () => observer.disconnect();
86
- }, [k, onWidth]);
64
+ (0, react.useLayoutEffect)(() => ref.current ? (0, _embedpdf_web.observeLength)(ref.current, orientation, (length) => onLength(k, length)) : void 0, [
65
+ k,
66
+ orientation,
67
+ onLength
68
+ ]);
87
69
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("slot", {
88
70
  ref,
89
71
  name,
@@ -95,7 +77,13 @@ function NativeSlotSocket({ name, k, onWidth, children }) {
95
77
  children
96
78
  });
97
79
  }
98
- const measureLayerStyle = {
80
+ /**
81
+ * The hidden measurement layer: a row for a horizontal toolbar, a column for a
82
+ * vertical one, and no height either way, so it never adds to the page. A
83
+ * column keeps each item at its own width, so no text wraps and changes the
84
+ * heights it reports.
85
+ */
86
+ const measureLayerStyle = (orientation) => ({
99
87
  position: "absolute",
100
88
  left: 0,
101
89
  top: 0,
@@ -104,9 +92,20 @@ const measureLayerStyle = {
104
92
  visibility: "hidden",
105
93
  pointerEvents: "none",
106
94
  display: "flex",
107
- whiteSpace: "nowrap"
108
- };
109
- const defaultRenderCommand = (cmd, variant, run) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
95
+ whiteSpace: "nowrap",
96
+ ...orientation === "vertical" ? {
97
+ flexDirection: "column",
98
+ alignItems: "flex-start"
99
+ } : null
100
+ });
101
+ /** Marks the element around each item of the live row: its first focusable element is a stop. */
102
+ const TOOLBAR_ITEM = { [_embedpdf_web.TOOLBAR_ITEM_ATTRIBUTE]: "" };
103
+ /** The element around an item adds no box, so the item lays out as the section's own child. */
104
+ const ITEM_STYLE = { display: "contents" };
105
+ const SURFACE = (0, _embedpdf_web.paintDefault)("toolbar-surface");
106
+ const BORDER = (0, _embedpdf_web.paintDefault)("toolbar-border");
107
+ const ACTIVE = (0, _embedpdf_web.paintDefault)("toolbar-active");
108
+ const defaultRenderCommand = (cmd, _variant, run) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
110
109
  type: "button",
111
110
  onClick: run,
112
111
  disabled: !cmd.enabled,
@@ -119,20 +118,25 @@ const defaultRenderCommand = (cmd, variant, run) => /* @__PURE__ */ (0, react_js
119
118
  gap: 4,
120
119
  padding: "4px 8px",
121
120
  whiteSpace: "nowrap",
122
- background: cmd.active ? "rgba(0,0,0,0.12)" : "transparent",
123
- border: "1px solid rgba(0,0,0,0.15)",
121
+ color: "inherit",
122
+ font: "inherit",
123
+ background: cmd.active ? ACTIVE : "transparent",
124
+ border: `1px solid ${BORDER}`,
124
125
  borderRadius: 4,
125
126
  cursor: cmd.enabled ? "pointer" : "default",
126
127
  opacity: cmd.enabled ? 1 : .4
127
128
  },
128
- children: [variant === "label" ? cmd.label : cmd.icon ?? cmd.label, variant === "icon+label" ? ` ${cmd.label}` : null]
129
+ children: cmd.label
129
130
  });
130
- const defaultRenderSeparator = () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: {
131
- width: 1,
132
- alignSelf: "stretch",
133
- background: "currentColor",
134
- opacity: .2
135
- } });
131
+ /** A 1px line across the toolbar: upright in a horizontal one, flat in a vertical one. */
132
+ function DefaultSeparator({ orientation }) {
133
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { style: {
134
+ ...orientation === "vertical" ? { height: 1 } : { width: 1 },
135
+ alignSelf: "stretch",
136
+ background: "currentColor",
137
+ opacity: .2
138
+ } });
139
+ }
136
140
  const defaultRenderOverflowTrigger = (isOpen, toggle) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
137
141
  type: "button",
138
142
  onClick: toggle,
@@ -143,39 +147,64 @@ const defaultRenderOverflowTrigger = (isOpen, toggle) => /* @__PURE__ */ (0, rea
143
147
  display: "inline-flex",
144
148
  alignItems: "center",
145
149
  padding: "4px 8px",
146
- border: "1px solid rgba(0,0,0,0.15)",
150
+ color: "inherit",
151
+ font: "inherit",
152
+ border: `1px solid ${BORDER}`,
147
153
  borderRadius: 4,
148
- background: isOpen ? "rgba(0,0,0,0.12)" : "transparent",
154
+ background: isOpen ? ACTIVE : "transparent",
149
155
  cursor: "pointer"
150
156
  },
151
157
  children: "⋯"
152
158
  });
153
- function DefaultOverflowMenu({ view }) {
159
+ /** Where a default menu opens: under a horizontal toolbar's button, beside a vertical one's. */
160
+ const menuPlacement = (orientation) => orientation === "vertical" ? {
161
+ top: 0,
162
+ insetInlineStart: "100%"
163
+ } : {
164
+ top: "100%",
165
+ insetInlineEnd: 0
166
+ };
167
+ /**
168
+ * The default menu, opened by the button beside it in the same parent: it
169
+ * closes on a press outside that parent, and takes the menu keys while open.
170
+ */
171
+ function DefaultOverflowMenu({ view, orientation }) {
172
+ const menu = (0, react.useRef)(null);
173
+ const close = (0, react.useRef)(view.close);
174
+ close.current = view.close;
175
+ (0, react.useLayoutEffect)(() => {
176
+ const element = menu.current;
177
+ if (!view.isOpen || !element) return;
178
+ const container = element.parentElement ?? element;
179
+ const trigger = (0, _embedpdf_web.focusablesIn)(container).find((candidate) => !element.contains(candidate)) ?? null;
180
+ const stopOutside = (0, _embedpdf_web.observeOutsidePress)(container, () => close.current());
181
+ const detachKeys = (0, _embedpdf_web.attachMenuKeys)(element, {
182
+ trigger,
183
+ close: () => close.current()
184
+ });
185
+ return () => {
186
+ stopOutside();
187
+ detachKeys();
188
+ };
189
+ }, [view.isOpen]);
154
190
  if (!view.isOpen) return null;
155
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
156
- style: {
157
- position: "fixed",
158
- inset: 0,
159
- zIndex: 40
160
- },
161
- onClick: view.close
162
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
191
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
192
+ ref: menu,
163
193
  role: "menu",
164
194
  style: {
165
195
  position: "absolute",
166
- right: 0,
167
- top: "100%",
196
+ ...menuPlacement(orientation),
168
197
  zIndex: 41,
169
198
  minWidth: 200,
170
199
  padding: 4,
171
- background: "white",
172
- border: "1px solid rgba(0,0,0,0.15)",
200
+ background: SURFACE,
201
+ border: `1px solid ${BORDER}`,
173
202
  borderRadius: 6,
174
203
  boxShadow: "0 4px 16px rgba(0,0,0,0.15)"
175
204
  },
176
205
  children: view.sections.map((section, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [i > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: {
177
206
  height: 1,
178
- background: "rgba(0,0,0,0.1)",
207
+ background: BORDER,
179
208
  margin: "4px 0"
180
209
  } }), section.rows.map((row) => {
181
210
  const cmd = view.resolve(row.command);
@@ -186,6 +215,7 @@ function DefaultOverflowMenu({ view }) {
186
215
  role: section.role === "radio" ? "menuitemradio" : "menuitem",
187
216
  "aria-checked": section.role === "radio" ? cmd.active : void 0,
188
217
  disabled: !cmd.enabled,
218
+ tabIndex: -1,
189
219
  onClick: () => {
190
220
  view.execute(row.command);
191
221
  if (!isSubmenu) view.close();
@@ -198,6 +228,8 @@ function DefaultOverflowMenu({ view }) {
198
228
  gap: 16,
199
229
  padding: "6px 8px",
200
230
  border: "none",
231
+ color: "inherit",
232
+ font: "inherit",
201
233
  background: "transparent",
202
234
  cursor: cmd.enabled ? "pointer" : "default",
203
235
  opacity: cmd.enabled ? 1 : .4,
@@ -206,61 +238,48 @@ function DefaultOverflowMenu({ view }) {
206
238
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [cmd.active && section.role === "radio" ? "• " : "", cmd.label] }), isSubmenu ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "▸" }) : null]
207
239
  }, row.command);
208
240
  })] }, i))
209
- })] });
241
+ });
210
242
  }
211
- function DefaultCollapsed({ view }) {
243
+ function DefaultCollapsed({ view, orientation }) {
212
244
  if (view.collapse === "select") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
213
- value: view.commands.find((c) => c.active)?.id ?? "",
214
- onChange: (e) => view.execute(e.target.value),
245
+ value: view.commands.find((command) => command.active)?.id ?? "",
246
+ onChange: (event) => view.execute(event.target.value),
215
247
  style: {
216
248
  padding: "4px 6px",
217
- borderRadius: 4
249
+ font: "inherit",
250
+ borderRadius: 4,
251
+ border: `1px solid ${BORDER}`,
252
+ background: SURFACE
218
253
  },
219
- children: view.commands.map((c) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
220
- value: c.id,
221
- disabled: !c.enabled,
222
- children: c.label
223
- }, c.id))
254
+ children: view.commands.map((command) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
255
+ value: command.id,
256
+ disabled: !command.enabled,
257
+ children: command.label
258
+ }, command.id))
259
+ });
260
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CollapsedMenuButton, {
261
+ view,
262
+ orientation
224
263
  });
225
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CollapsedMenuButton, { view });
226
264
  }
227
- function CollapsedMenuButton({ view }) {
265
+ function CollapsedMenuButton({ view, orientation }) {
228
266
  const [isOpen, setOpen] = (0, react.useState)(false);
229
- const sections = [{
230
- labelKey: view.labelKey,
231
- role: view.role === "tabs" ? "radio" : void 0,
232
- rows: view.commands.map((c) => ({
233
- type: "command",
234
- command: c.id
235
- }))
236
- }];
237
267
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
238
268
  style: {
239
269
  position: "relative",
240
270
  display: "inline-flex"
241
271
  },
242
- children: [defaultRenderOverflowTrigger(isOpen, () => setOpen((o) => !o)), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultOverflowMenu, { view: {
243
- sections,
244
- isOpen,
245
- close: () => setOpen(false),
246
- resolve: (id) => view.commands.find((c) => c.id === id) ?? null,
247
- execute: view.execute
248
- } })]
272
+ children: [defaultRenderOverflowTrigger(isOpen, () => setOpen((previous) => !previous)), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultOverflowMenu, {
273
+ view: (0, _embedpdf_core_ui.groupMenuView)(view, isOpen, () => setOpen(false)),
274
+ orientation
275
+ })]
249
276
  });
250
277
  }
251
278
  /** Default shed-group disclosure: a chevron opening a radio menu of the
252
- * hidden children — v2's overflow-tabs-button, derived. */
253
- function DefaultGroupTrigger({ view }) {
279
+ * hidden children. */
280
+ function DefaultGroupTrigger({ view, orientation }) {
254
281
  const [isOpen, setOpen] = (0, react.useState)(false);
255
- const someActive = view.commands.some((c) => c.active);
256
- const sections = [{
257
- labelKey: view.labelKey,
258
- role: view.role === "tabs" ? "radio" : void 0,
259
- rows: view.commands.map((c) => ({
260
- type: "command",
261
- command: c.id
262
- }))
263
- }];
282
+ const someActive = view.commands.some((command) => command.active);
264
283
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
265
284
  style: {
266
285
  position: "relative",
@@ -268,7 +287,7 @@ function DefaultGroupTrigger({ view }) {
268
287
  },
269
288
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
270
289
  type: "button",
271
- onClick: () => setOpen((o) => !o),
290
+ onClick: () => setOpen((previous) => !previous),
272
291
  "aria-haspopup": "menu",
273
292
  "aria-expanded": isOpen,
274
293
  title: "More",
@@ -276,169 +295,138 @@ function DefaultGroupTrigger({ view }) {
276
295
  display: "inline-flex",
277
296
  alignItems: "center",
278
297
  padding: "4px 6px",
279
- border: "1px solid rgba(0,0,0,0.15)",
298
+ color: "inherit",
299
+ font: "inherit",
300
+ border: `1px solid ${BORDER}`,
280
301
  borderRadius: 4,
281
- background: isOpen || someActive ? "rgba(0,0,0,0.12)" : "transparent",
302
+ background: isOpen || someActive ? ACTIVE : "transparent",
282
303
  cursor: "pointer"
283
304
  },
284
305
  children: "▾"
285
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultOverflowMenu, { view: {
286
- sections,
287
- isOpen,
288
- close: () => setOpen(false),
289
- resolve: (id) => view.commands.find((c) => c.id === id) ?? null,
290
- execute: view.execute
291
- } })]
306
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultOverflowMenu, {
307
+ view: (0, _embedpdf_core_ui.groupMenuView)(view, isOpen, () => setOpen(false)),
308
+ orientation
309
+ })]
292
310
  });
293
311
  }
294
- const unitKey = (u, variant) => `u:${u.key}@${variant}`;
295
- const groupKey = (id) => `g:${id}`;
296
- const groupTriggerKey = (id) => `gt:${id}`;
297
- const TRIGGER_KEY = "t:";
298
- function Toolbar({ bar, gap = 8, separatorWidth = 1, className, style, renderCommand = defaultRenderCommand, renderCustom, renderCollapsed, renderGroupTrigger, renderSeparator = defaultRenderSeparator, renderOverflowTrigger = defaultRenderOverflowTrigger, renderOverflowMenu }) {
312
+ function Toolbar({ bar, orientation = "horizontal", gap = 8, separatorWidth = 1, "aria-label": ariaLabel, className, style, renderCommand = defaultRenderCommand, renderCustom, renderCollapsed, renderGroupTrigger, renderSeparator, renderOverflowTrigger = defaultRenderOverflowTrigger, renderOverflowMenu }) {
299
313
  const kernel = require_runtime.useKernel();
300
- const commands = require_runtime.useCapability(_embedpdf_plugin_commands_contract.CommandsToken);
314
+ const commands = require_runtime.useCapability(_embedpdf_plugin_commands_contract_host.CommandsToken);
301
315
  const documentId = require_runtime.useDocumentId();
316
+ const vertical = orientation === "vertical";
302
317
  const [, force] = (0, react.useReducer)((x) => x + 1, 0);
303
318
  (0, react.useEffect)(() => kernel.subscribe(force), [kernel]);
304
319
  const containerRef = (0, react.useRef)(null);
305
- const [containerWidth, setContainerWidth] = (0, react.useState)(0);
320
+ const [containerLength, setContainerLength] = (0, react.useState)(0);
321
+ (0, react.useLayoutEffect)(() => containerRef.current ? (0, _embedpdf_web.observeContentLength)(containerRef.current, orientation, setContainerLength) : void 0, [orientation]);
322
+ const [lengths] = (0, react.useState)(_embedpdf_web.createToolbarLengths);
323
+ const [, bumpMeasureVersion] = (0, react.useReducer)((version) => version + 1, 0);
324
+ const onLength = (0, react.useMemo)(() => (key, length) => {
325
+ if (lengths.report(orientation, key, length)) bumpMeasureVersion();
326
+ }, [lengths, orientation]);
327
+ const roving = (0, react.useRef)(null);
306
328
  (0, react.useLayoutEffect)(() => {
307
- const el = containerRef.current;
308
- if (!el) return;
309
- const observer = new ResizeObserver((entries) => {
310
- const w = entries[entries.length - 1]?.contentRect.width;
311
- if (w !== void 0) setContainerWidth((prev) => Math.abs(prev - w) > .5 ? w : prev);
312
- });
313
- observer.observe(el);
314
- setContainerWidth(el.clientWidth);
315
- return () => observer.disconnect();
316
- }, []);
317
- const widthsRef = (0, react.useRef)(/* @__PURE__ */ new Map());
318
- const [, bumpMeasureVersion] = (0, react.useReducer)((x) => x + 1, 0);
319
- const onWidth = (0, react.useMemo)(() => (key, width) => {
320
- const prev = widthsRef.current.get(key);
321
- if (prev !== void 0 && Math.abs(prev - width) <= .5) return;
322
- widthsRef.current.set(key, width);
323
- bumpMeasureVersion();
324
- }, []);
325
- const resolveCmd = (id) => commands.resolve(id, documentId ?? void 0);
326
- const executeCmd = (id) => commands.execute(id, documentId ?? void 0);
327
- const commandOf = (u) => u.kind === "command" ? u.command : u.terminal;
328
- const visibleBar = (0, _embedpdf_core_ui.filterBar)((0, react.useMemo)(() => (0, _embedpdf_core_ui.normalizeBar)(bar), [bar]), (u) => resolveCmd(commandOf(u))?.visible === true);
329
- const fit = (0, _embedpdf_core_ui.solve)(visibleBar, {
330
- unit: (key, variant) => widthsRef.current.get(`u:${key}@${variant}`),
331
- groupCollapsed: (id) => widthsRef.current.get(groupKey(id)),
332
- groupTrigger: (id) => widthsRef.current.get(groupTriggerKey(id)),
333
- overflowTrigger: widthsRef.current.get(TRIGGER_KEY) ?? 32,
334
- gap,
335
- separator: separatorWidth + gap
336
- }, containerWidth);
337
- const overflowSections = (0, _embedpdf_core_ui.projectOverflow)(visibleBar, fit, (id) => commands.menuTarget(id));
329
+ const toolbar = containerRef.current;
330
+ if (!toolbar) return;
331
+ const focus = (0, _embedpdf_web.attachToolbarFocus)(toolbar, orientation);
332
+ roving.current = focus;
333
+ return () => {
334
+ focus.detach();
335
+ roving.current = null;
336
+ };
337
+ }, [orientation]);
338
+ (0, react.useLayoutEffect)(() => roving.current?.refresh());
339
+ const resolveCmd = (id) => commands.resolveCommand(id, documentId ?? void 0);
340
+ const executeCmd = (id) => void commands.execute(id, { documentId: documentId ?? void 0 });
341
+ const layout = (0, _embedpdf_core_ui.layoutToolbar)({
342
+ bar: (0, react.useMemo)(() => (0, _embedpdf_core_ui.normalizeBar)(bar), [bar]),
343
+ resolve: resolveCmd,
344
+ unregistered: _embedpdf_plugin_commands_contract.unregisteredCommand,
345
+ execute: executeCmd,
346
+ menuTarget: (id) => commands.getMenuTarget(id),
347
+ metrics: lengths.metrics(orientation, gap, separatorWidth),
348
+ measureKey: _embedpdf_web.toolbarMeasureKey,
349
+ containerLength,
350
+ orientation
351
+ });
338
352
  const [overflowOpen, setOverflowOpen] = (0, react.useState)(false);
339
353
  (0, react.useEffect)(() => {
340
- if (!fit.hasOverflow) setOverflowOpen(false);
341
- }, [fit.hasOverflow]);
342
- /** External = custom unit with no registered renderer → native socket,
343
- * live-measured (it must NOT appear in the measurement layer: only the
354
+ if (!layout.hasOverflow) setOverflowOpen(false);
355
+ }, [layout.hasOverflow]);
356
+ /** External = custom part with no registered renderer → native socket,
357
+ * live-measured (it must not appear in the measurement layer: only the
344
358
  * first same-named <slot> in tree order receives the projected nodes). */
345
- const isExternalSlot = (u) => u.kind === "custom" && !renderCustom?.[u.slot];
346
- const renderUnitAt = (u, variant, layer) => {
347
- if (u.kind === "custom") {
348
- const registered = renderCustom?.[u.slot];
349
- if (registered) {
350
- const custom = registered(variant, {
351
- layer,
352
- measure: (width) => onWidth(unitKey(u, variant), width)
353
- });
354
- if (custom !== void 0) return custom;
355
- } else if (layer === "live") {
356
- const cmd = resolveCmd(u.terminal);
359
+ const isExternalSlot = (part) => part.kind === "custom" && !renderCustom?.[part.name];
360
+ const renderPart = (part, layer) => {
361
+ switch (part.kind) {
362
+ case "command": return renderCommand(part.command, part.variant, part.run);
363
+ case "custom": {
364
+ const terminal = () => part.terminal ? renderCommand(part.terminal, "icon", part.runTerminal) : null;
365
+ const registered = renderCustom?.[part.name];
366
+ if (registered) {
367
+ const custom = registered(part.variant, {
368
+ layer,
369
+ measure: (length) => onLength(part.measureKey, length)
370
+ });
371
+ return custom === void 0 ? terminal() : custom;
372
+ }
373
+ if (layer === "measure") return null;
357
374
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(NativeSlotSocket, {
358
- name: u.slot,
359
- k: unitKey(u, variant),
360
- onWidth,
361
- children: cmd ? renderCommand(cmd, "icon", () => executeCmd(u.terminal)) : null
375
+ name: part.name,
376
+ k: part.measureKey,
377
+ orientation,
378
+ onLength,
379
+ children: terminal()
362
380
  });
363
- } else return null;
364
- const cmd = resolveCmd(u.terminal);
365
- return cmd ? renderCommand(cmd, "icon", () => executeCmd(u.terminal)) : null;
366
- }
367
- const cmd = resolveCmd(u.command);
368
- if (!cmd) return renderCommand({
369
- id: u.command,
370
- label: u.command,
371
- shortcuts: [],
372
- enabled: false,
373
- active: false,
374
- visible: true,
375
- categories: []
376
- }, variant, () => {});
377
- return renderCommand(cmd, variant, () => executeCmd(u.command));
378
- };
379
- const collapsedView = (g) => ({
380
- id: g.id,
381
- labelKey: g.labelKey,
382
- collapse: g.collapse ?? "menu",
383
- role: g.role,
384
- commands: g.units.map((u) => resolveCmd(commandOf(u))).filter((c) => c !== null && c.visible),
385
- execute: executeCmd
386
- });
387
- const renderCollapsedGroup = (g) => renderCollapsed ? renderCollapsed(collapsedView(g)) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultCollapsed, { view: collapsedView(g) });
388
- /** The disclosure view: shed children for the live trigger; the WHOLE group
389
- * for the measured trigger, so width is budgeted at its fullest content. */
390
- const disclosureView = (g, allChildren) => ({
391
- id: g.id,
392
- labelKey: g.labelKey,
393
- role: g.role,
394
- commands: g.units.filter((u) => allChildren || fit.units.get(u.key)?.kind === "shed").map((u) => resolveCmd(commandOf(u))).filter((c) => c !== null && c.visible),
395
- execute: executeCmd
396
- });
397
- const renderDisclosure = (g, allChildren) => renderGroupTrigger ? renderGroupTrigger(disclosureView(g, allChildren)) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultGroupTrigger, { view: disclosureView(g, allChildren) });
398
- const renderLiveGroup = (g) => {
399
- const assignment = fit.groups.get(g.id);
400
- if (!assignment || assignment.overflowed) return [];
401
- if (assignment.collapsed) return [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: renderCollapsedGroup(g) }, g.id)];
402
- const nodes = [];
403
- for (const u of g.units) {
404
- const a = fit.units.get(u.key);
405
- if (a?.kind !== "variant") continue;
406
- nodes.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: renderUnitAt(u, a.variant, "live") }, u.key));
381
+ }
382
+ case "collapsed": {
383
+ const drawn = renderCollapsed?.(part.view);
384
+ return drawn === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultCollapsed, {
385
+ view: part.view,
386
+ orientation
387
+ }) : drawn;
388
+ }
389
+ case "disclosure": {
390
+ const drawn = renderGroupTrigger?.(part.view);
391
+ return drawn === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultGroupTrigger, {
392
+ view: part.view,
393
+ orientation
394
+ }) : drawn;
395
+ }
407
396
  }
408
- if (assignment.shedCount > 0) nodes.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: renderDisclosure(g, false) }, `${g.id}::trigger`));
409
- return nodes.length ? [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Fragment, { children: nodes }, g.id)] : [];
410
- };
411
- const renderLiveSection = (section) => {
412
- if (!section) return null;
413
- return section.groups.map((g) => ({
414
- id: g.id,
415
- nodes: renderLiveGroup(g)
416
- })).filter((g) => g.nodes.length > 0).map((g, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [i > 0 && renderSeparator(), g.nodes] }, g.id));
417
397
  };
418
- const sectionByName = (name) => visibleBar.sections.find((s) => s.name === name);
398
+ const renderLiveSection = (section) => section.groups.map((group, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [i > 0 && (renderSeparator ? renderSeparator() : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultSeparator, { orientation })), group.parts.map((part) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
399
+ ...TOOLBAR_ITEM,
400
+ style: ITEM_STYLE,
401
+ children: renderPart(part, "live")
402
+ }, part.key))] }, group.id));
419
403
  /**
420
- * Segment layout — v2's spacer model, natively. The center segment carries
421
- * auto margins: it BALANCES in the leftover space (true center when the
422
- * flanks are symmetric) and yields when they aren't, collapsing to zero
423
- * before anything can overlap. The container itself has NO gap — segments
424
- * space themselves — so the solver's global budget (sum of unit widths +
425
- * per-unit gaps) is exactly the layout's minimum width: what the solver
404
+ * Segment layout, along the toolbar's axis. The center segment carries auto
405
+ * margins: it balances in the leftover space (true center when the flanks
406
+ * are symmetric) and yields when they aren't, collapsing to zero before
407
+ * anything can overlap. The container itself has no gap — segments space
408
+ * themselves — so the solver's global budget (sum of unit lengths +
409
+ * per-unit gaps) is exactly the layout's minimum length: what the solver
426
410
  * says fits, fits. Its cross-segment gap allowance (≤ 2×gap) becomes slack
427
411
  * the auto margins absorb, keeping ≥ gap between segments at the floor.
428
- * Segments never grow or shrink: fit is the SOLVER's job, not flexbox's.
412
+ * Segments never grow or shrink: fit is the solver's job, not flexbox's.
429
413
  */
430
414
  const sectionStyle = (position) => ({
431
415
  display: "flex",
416
+ flexDirection: vertical ? "column" : "row",
432
417
  alignItems: "center",
433
418
  gap,
434
419
  flex: "0 0 auto",
435
- ...position === "center" ? {
420
+ ...position !== "center" ? null : vertical ? {
421
+ marginTop: "auto",
422
+ marginBottom: "auto"
423
+ } : {
436
424
  marginLeft: "auto",
437
425
  marginRight: "auto"
438
- } : null
426
+ }
439
427
  });
440
428
  const overflowView = {
441
- sections: overflowSections,
429
+ sections: layout.overflow,
442
430
  isOpen: overflowOpen,
443
431
  close: () => setOverflowOpen(false),
444
432
  resolve: resolveCmd,
@@ -446,70 +434,84 @@ function Toolbar({ bar, gap = 8, separatorWidth = 1, className, style, renderCom
446
434
  };
447
435
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
448
436
  ref: containerRef,
437
+ role: "toolbar",
438
+ "aria-orientation": orientation,
439
+ "aria-label": ariaLabel,
449
440
  className,
450
441
  style: {
451
442
  position: "relative",
452
443
  display: "flex",
444
+ flexDirection: vertical ? "column" : "row",
453
445
  alignItems: "center",
454
446
  ...style
455
447
  },
456
- children: [
457
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
458
- style: sectionStyle("start"),
459
- children: renderLiveSection(sectionByName("start"))
460
- }),
461
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
462
- style: sectionStyle("center"),
463
- children: renderLiveSection(sectionByName("center"))
464
- }),
465
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
466
- style: sectionStyle("end"),
467
- children: [renderLiveSection(sectionByName("end")), fit.hasOverflow && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
468
- style: {
469
- position: "relative",
470
- display: "inline-flex"
471
- },
472
- children: [renderOverflowTrigger(overflowOpen, () => setOverflowOpen((o) => !o)), renderOverflowMenu ? renderOverflowMenu(overflowView) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultOverflowMenu, { view: overflowView })]
473
- })]
474
- }),
475
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
476
- "aria-hidden": true,
477
- style: measureLayerStyle,
478
- children: [visibleBar.sections.flatMap((s) => s.groups.flatMap((g) => [
479
- ...g.units.filter((u) => !isExternalSlot(u)).flatMap((u) => u.variants.map((variant) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Measured, {
480
- k: unitKey(u, variant),
481
- onWidth,
482
- children: renderUnitAt(u, variant, "measure")
483
- }, unitKey(u, variant)))),
484
- ...g.collapse ? [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Measured, {
485
- k: groupKey(g.id),
486
- onWidth,
487
- children: renderCollapsedGroup(g)
488
- }, groupKey(g.id))] : [],
489
- ...g.shed ? [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Measured, {
490
- k: groupTriggerKey(g.id),
491
- onWidth,
492
- children: renderDisclosure(g, true)
493
- }, groupTriggerKey(g.id))] : []
494
- ])), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Measured, {
495
- k: TRIGGER_KEY,
496
- onWidth,
497
- children: renderOverflowTrigger(false, () => {})
448
+ children: [layout.sections.map((section) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
449
+ style: sectionStyle(section.name),
450
+ children: [renderLiveSection(section), section.name === "end" && layout.hasOverflow && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
451
+ ...TOOLBAR_ITEM,
452
+ style: {
453
+ position: "relative",
454
+ display: "inline-flex"
455
+ },
456
+ children: [renderOverflowTrigger(overflowOpen, () => setOverflowOpen((previous) => !previous)), renderOverflowMenu ? renderOverflowMenu(overflowView) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultOverflowMenu, {
457
+ view: overflowView,
458
+ orientation
498
459
  })]
499
- })
500
- ]
460
+ })]
461
+ }, section.name)), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
462
+ "aria-hidden": true,
463
+ ...require_inert.INERT,
464
+ style: measureLayerStyle(orientation),
465
+ children: [layout.measured.filter((part) => !isExternalSlot(part)).map((part) => {
466
+ const drawn = renderPart(part, "measure");
467
+ if (part.kind === "custom" && drawn === null) return null;
468
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Measured, {
469
+ k: part.measureKey,
470
+ orientation,
471
+ onLength,
472
+ children: drawn
473
+ }, part.measureKey);
474
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Measured, {
475
+ k: _embedpdf_web.toolbarMeasureKey.overflowTrigger,
476
+ orientation,
477
+ onLength,
478
+ children: renderOverflowTrigger(false, () => {})
479
+ })]
480
+ })]
501
481
  });
502
482
  }
503
483
  //#endregion
484
+ Object.defineProperty(exports, "DEFAULT_IMPORTANCE", {
485
+ enumerable: true,
486
+ get: function() {
487
+ return _embedpdf_core_ui.DEFAULT_IMPORTANCE;
488
+ }
489
+ });
490
+ Object.defineProperty(exports, "PINNED", {
491
+ enumerable: true,
492
+ get: function() {
493
+ return _embedpdf_core_ui.PINNED;
494
+ }
495
+ });
504
496
  exports.Toolbar = Toolbar;
505
- exports.useStripView = useStripView;
506
- Object.keys(_embedpdf_core_ui).forEach(function(k) {
507
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
508
- enumerable: true,
509
- get: function() {
510
- return _embedpdf_core_ui[k];
511
- }
512
- });
497
+ Object.defineProperty(exports, "custom", {
498
+ enumerable: true,
499
+ get: function() {
500
+ return _embedpdf_core_ui.custom;
501
+ }
502
+ });
503
+ Object.defineProperty(exports, "group", {
504
+ enumerable: true,
505
+ get: function() {
506
+ return _embedpdf_core_ui.group;
507
+ }
513
508
  });
509
+ Object.defineProperty(exports, "item", {
510
+ enumerable: true,
511
+ get: function() {
512
+ return _embedpdf_core_ui.item;
513
+ }
514
+ });
515
+ exports.useStripView = useStripView;
514
516
 
515
517
  //# sourceMappingURL=toolbar.cjs.map