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

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 (232) hide show
  1. package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.cts +877 -0
  2. package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.ts +877 -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-B48UT2ln.d.ts +302 -0
  18. package/dist/annotation-C1ttM8Wj.js +708 -0
  19. package/dist/annotation-C1ttM8Wj.js.map +1 -0
  20. package/dist/annotation-C9dVwo9b.d.cts +302 -0
  21. package/dist/annotation-Dex5EBda.cjs +830 -0
  22. package/dist/annotation-Dex5EBda.cjs.map +1 -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/commands.cjs +68 -28
  28. package/dist/commands.cjs.map +1 -1
  29. package/dist/commands.d.cts +37 -10
  30. package/dist/commands.d.ts +37 -10
  31. package/dist/commands.js +68 -31
  32. package/dist/commands.js.map +1 -1
  33. package/dist/form-55izw0jS.js +511 -0
  34. package/dist/form-55izw0jS.js.map +1 -0
  35. package/dist/form-BNqQfGGH.cjs +548 -0
  36. package/dist/form-BNqQfGGH.cjs.map +1 -0
  37. package/dist/form.cjs +5 -5
  38. package/dist/form.d.cts +41 -2
  39. package/dist/form.d.ts +41 -2
  40. package/dist/form.js +2 -3
  41. package/dist/history.cjs +38 -0
  42. package/dist/history.cjs.map +1 -0
  43. package/dist/history.d.cts +27 -0
  44. package/dist/history.d.ts +27 -0
  45. package/dist/history.js +27 -0
  46. package/dist/history.js.map +1 -0
  47. package/dist/i18n.cjs +26 -30
  48. package/dist/i18n.cjs.map +1 -1
  49. package/dist/i18n.d.cts +24 -21
  50. package/dist/i18n.d.ts +24 -21
  51. package/dist/i18n.js +24 -31
  52. package/dist/i18n.js.map +1 -1
  53. package/dist/index.cjs +200 -57
  54. package/dist/index.d.cts +31 -32
  55. package/dist/index.d.ts +31 -32
  56. package/dist/index.js +32 -30
  57. package/dist/inert-CmBEbKCn.cjs +19 -0
  58. package/dist/inert-CmBEbKCn.cjs.map +1 -0
  59. package/dist/inert-D8fkennb.js +14 -0
  60. package/dist/inert-D8fkennb.js.map +1 -0
  61. package/dist/interaction.cjs +48 -102
  62. package/dist/interaction.cjs.map +1 -1
  63. package/dist/interaction.d.cts +23 -32
  64. package/dist/interaction.d.ts +23 -32
  65. package/dist/interaction.js +33 -102
  66. package/dist/interaction.js.map +1 -1
  67. package/dist/link.cjs +65 -104
  68. package/dist/link.cjs.map +1 -1
  69. package/dist/link.d.cts +21 -16
  70. package/dist/link.d.ts +22 -17
  71. package/dist/link.js +67 -107
  72. package/dist/link.js.map +1 -1
  73. package/dist/measurement.cjs +36 -11
  74. package/dist/measurement.cjs.map +1 -1
  75. package/dist/measurement.d.cts +33 -7
  76. package/dist/measurement.d.ts +33 -7
  77. package/dist/measurement.js +35 -14
  78. package/dist/measurement.js.map +1 -1
  79. package/dist/metadata.cjs +20 -7
  80. package/dist/metadata.cjs.map +1 -1
  81. package/dist/metadata.d.cts +22 -7
  82. package/dist/metadata.d.ts +22 -7
  83. package/dist/metadata.js +20 -10
  84. package/dist/metadata.js.map +1 -1
  85. package/dist/page-edit.cjs +7 -3
  86. package/dist/page-edit.cjs.map +1 -1
  87. package/dist/page-edit.d.cts +6 -2
  88. package/dist/page-edit.d.ts +6 -2
  89. package/dist/page-edit.js +7 -4
  90. package/dist/page-edit.js.map +1 -1
  91. package/dist/page-layers-Bkaaz8Zf.js +26 -0
  92. package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
  93. package/dist/page-layers-BloZDoOV.cjs +37 -0
  94. package/dist/page-layers-BloZDoOV.cjs.map +1 -0
  95. package/dist/page-view.cjs +89 -82
  96. package/dist/page-view.cjs.map +1 -1
  97. package/dist/page-view.d.cts +14 -7
  98. package/dist/page-view.d.ts +18 -11
  99. package/dist/page-view.js +86 -81
  100. package/dist/page-view.js.map +1 -1
  101. package/dist/redaction.cjs +30 -15
  102. package/dist/redaction.cjs.map +1 -1
  103. package/dist/redaction.d.cts +27 -9
  104. package/dist/redaction.d.ts +27 -9
  105. package/dist/redaction.js +29 -18
  106. package/dist/redaction.js.map +1 -1
  107. package/dist/render.cjs +71 -46
  108. package/dist/render.cjs.map +1 -1
  109. package/dist/render.d.cts +17 -5
  110. package/dist/render.d.ts +17 -5
  111. package/dist/render.js +70 -49
  112. package/dist/render.js.map +1 -1
  113. package/dist/runtime-B6xcPsEb.js +398 -0
  114. package/dist/runtime-B6xcPsEb.js.map +1 -0
  115. package/dist/runtime-DBEBlpQV.d.cts +237 -0
  116. package/dist/runtime-V3MVMb91.d.ts +237 -0
  117. package/dist/runtime-fzpGv78v.cjs +555 -0
  118. package/dist/runtime-fzpGv78v.cjs.map +1 -0
  119. package/dist/runtime.cjs +45 -324
  120. package/dist/runtime.d.cts +2 -2
  121. package/dist/runtime.d.ts +2 -2
  122. package/dist/runtime.js +2 -306
  123. package/dist/search.cjs +81 -50
  124. package/dist/search.cjs.map +1 -1
  125. package/dist/search.d.cts +37 -24
  126. package/dist/search.d.ts +37 -24
  127. package/dist/search.js +81 -53
  128. package/dist/search.js.map +1 -1
  129. package/dist/selection.cjs +105 -108
  130. package/dist/selection.cjs.map +1 -1
  131. package/dist/selection.d.cts +54 -26
  132. package/dist/selection.d.ts +56 -28
  133. package/dist/selection.js +103 -110
  134. package/dist/selection.js.map +1 -1
  135. package/dist/shell.cjs +36 -21
  136. package/dist/shell.cjs.map +1 -1
  137. package/dist/shell.d.cts +32 -17
  138. package/dist/shell.d.ts +32 -17
  139. package/dist/shell.js +36 -24
  140. package/dist/shell.js.map +1 -1
  141. package/dist/signature.cjs +29 -48
  142. package/dist/signature.cjs.map +1 -1
  143. package/dist/signature.d.cts +26 -26
  144. package/dist/signature.d.ts +26 -26
  145. package/dist/signature.js +30 -48
  146. package/dist/signature.js.map +1 -1
  147. package/dist/stage-BIG6aeVd.cjs +369 -0
  148. package/dist/stage-BIG6aeVd.cjs.map +1 -0
  149. package/dist/stage-ByFPD-Fv.d.cts +117 -0
  150. package/dist/stage-DaboaheR.d.ts +117 -0
  151. package/dist/stage-DoVekb83.js +302 -0
  152. package/dist/stage-DoVekb83.js.map +1 -0
  153. package/dist/stage-scope-CQgCuf1w.cjs +46 -0
  154. package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
  155. package/dist/stage-scope-D7ZeNduT.js +23 -0
  156. package/dist/stage-scope-D7ZeNduT.js.map +1 -0
  157. package/dist/stage.cjs +12 -235
  158. package/dist/stage.d.cts +2 -116
  159. package/dist/stage.d.ts +2 -116
  160. package/dist/stage.js +3 -228
  161. package/dist/stamp.cjs +41 -35
  162. package/dist/stamp.cjs.map +1 -1
  163. package/dist/stamp.d.cts +25 -18
  164. package/dist/stamp.d.ts +25 -18
  165. package/dist/stamp.js +40 -37
  166. package/dist/stamp.js.map +1 -1
  167. package/dist/state-0K1I5cM4.d.cts +29 -0
  168. package/dist/state-0K1I5cM4.d.ts +29 -0
  169. package/dist/state-CbgxhwLA.js +62 -0
  170. package/dist/state-CbgxhwLA.js.map +1 -0
  171. package/dist/state-CsfZy_Eq.cjs +73 -0
  172. package/dist/state-CsfZy_Eq.cjs.map +1 -0
  173. package/dist/svg-shapes-Dm1yTR1b.js +40 -0
  174. package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
  175. package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
  176. package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
  177. package/dist/toolbar.cjs +297 -295
  178. package/dist/toolbar.cjs.map +1 -1
  179. package/dist/toolbar.d.cts +58 -68
  180. package/dist/toolbar.d.ts +67 -77
  181. package/dist/toolbar.js +271 -293
  182. package/dist/toolbar.js.map +1 -1
  183. package/dist/view-manager.cjs +34 -0
  184. package/dist/view-manager.cjs.map +1 -0
  185. package/dist/view-manager.d.cts +21 -0
  186. package/dist/view-manager.d.ts +21 -0
  187. package/dist/view-manager.js +23 -0
  188. package/dist/view-manager.js.map +1 -0
  189. package/package.json +37 -39
  190. package/dist/annotation-BCED_p9H.d.cts +0 -160
  191. package/dist/annotation-anchors-CetwM1g7.js +0 -15
  192. package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
  193. package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
  194. package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
  195. package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
  196. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
  197. package/dist/annotation-hooks-Df8EmzDO.js +0 -11
  198. package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
  199. package/dist/annotation-k38KDlIZ.d.ts +0 -160
  200. package/dist/annotation-menu.cjs +0 -64
  201. package/dist/annotation-menu.cjs.map +0 -1
  202. package/dist/annotation-menu.d.cts +0 -33
  203. package/dist/annotation-menu.d.ts +0 -33
  204. package/dist/annotation-menu.js +0 -48
  205. package/dist/annotation-menu.js.map +0 -1
  206. package/dist/annotation.cjs.map +0 -1
  207. package/dist/annotation.js.map +0 -1
  208. package/dist/form-BVumS7up.cjs +0 -926
  209. package/dist/form-BVumS7up.cjs.map +0 -1
  210. package/dist/form-Bdjk0Z3T.d.cts +0 -537
  211. package/dist/form-CK3mp99m.js +0 -895
  212. package/dist/form-CK3mp99m.js.map +0 -1
  213. package/dist/form-CYRYgthn.d.ts +0 -537
  214. package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
  215. package/dist/runtime-DE76hlnl.d.ts +0 -216
  216. package/dist/runtime-umHA_xHt.d.cts +0 -216
  217. package/dist/runtime.cjs.map +0 -1
  218. package/dist/runtime.js.map +0 -1
  219. package/dist/scrollbar.cjs +0 -241
  220. package/dist/scrollbar.cjs.map +0 -1
  221. package/dist/scrollbar.d.cts +0 -42
  222. package/dist/scrollbar.d.ts +0 -42
  223. package/dist/scrollbar.js +0 -213
  224. package/dist/scrollbar.js.map +0 -1
  225. package/dist/stage.cjs.map +0 -1
  226. package/dist/stage.js.map +0 -1
  227. package/dist/views.cjs +0 -35
  228. package/dist/views.cjs.map +0 -1
  229. package/dist/views.d.cts +0 -21
  230. package/dist/views.d.ts +0 -21
  231. package/dist/views.js +0 -27
  232. package/dist/views.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"toolbar.cjs","names":["useCapability","CommandsToken","useDocumentId","useKernelValue","React","useKernel"],"sources":["../src/toolbar.tsx"],"sourcesContent":["/**\n * The headless <Toolbar> — where measurement meets the pure solver.\n *\n * The schema is structure-only; what fits is OBSERVED, not configured:\n *\n * 1. a hidden measurement layer renders every unit in every variant (plus\n * collapsed group forms and the overflow trigger), each wrapped in a\n * ResizeObserver — so locale flips, font loads, browser zoom, and\n * embedder CSS all re-measure themselves with zero handling code;\n * 2. ui-core's solve() assigns each unit a variant / collapsed / overflow —\n * pure, deterministic, tested in isolation;\n * 3. the live row renders the assignment; the overflow menu is DERIVED\n * (projectOverflow) — the complement of the visible set, never authored.\n *\n * Rendering is render-prop driven with functional defaults: the app owns the\n * pixels, this component owns the physics.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/core-ui';\nimport * as React from 'react';\nimport { useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from 'react';\nimport { filterBar, normalizeBar, projectOverflow, projectStrip, solve } from '@embedpdf/core-ui';\nimport type {\n BarSchema,\n FitMetrics,\n NormalizedGroup,\n NormalizedSection,\n NormalizedUnit,\n OverflowSection,\n} from '@embedpdf/core-ui';\nimport { CommandsToken, resolvedCommandsEqual } from '@embedpdf/plugin-commands/contract';\nimport type { ResolvedCommand } from '@embedpdf/plugin-commands/contract';\nimport { useCapability, useDocumentId, useKernel, useKernelValue } from './runtime';\n\n// ── public render-prop contracts ─────────────────────────────────────────────\n\nexport interface CollapsedGroupView {\n readonly id: string;\n readonly labelKey?: string;\n readonly collapse: 'menu' | 'select';\n readonly role: 'buttons' | 'tabs';\n /** The group's commands (custom items via their terminal), resolved live. */\n readonly commands: readonly ResolvedCommand[];\n execute(id: string): void;\n}\n\nexport interface OverflowMenuView {\n readonly sections: readonly OverflowSection[];\n readonly isOpen: boolean;\n close(): void;\n resolve(id: string): ResolvedCommand | null;\n execute(id: string): void;\n}\n\n/**\n * A shed group's disclosure — the derived trigger rendered INSIDE the group\n * (v2's overflow-tabs-button). `commands` is what sits behind the trigger:\n * the shed children in bar order, resolved live. In the measurement layer the\n * trigger is measured with the FULL group as content, so a count-dependent\n * trigger (e.g. a \"+3\" badge) is budgeted at its widest form.\n */\nexport interface GroupDisclosureView {\n readonly id: string;\n readonly labelKey?: string;\n readonly role: 'buttons' | 'tabs';\n readonly commands: readonly ResolvedCommand[];\n execute(id: string): void;\n}\n\n// ── the strip view — a bar projected through the registry, live ──────────────\n\nexport interface StripViewGroup {\n readonly id: string;\n readonly labelKey?: string;\n /** Visible commands, bar order. Groups are separator boundaries. */\n readonly commands: readonly ResolvedCommand[];\n}\n\n/** A contextual strip, resolved: only visible commands, only non-empty groups. */\nexport interface StripView {\n readonly groups: readonly StripViewGroup[];\n execute(id: string): void;\n}\n\nconst stripGroupsEqual = (a: readonly StripViewGroup[], b: readonly StripViewGroup[]): boolean =>\n a.length === b.length &&\n a.every(\n (g, i) =>\n g.id === b[i].id &&\n g.commands.length === b[i].commands.length &&\n g.commands.every((c, j) => resolvedCommandsEqual(c, b[i].commands[j])),\n );\n\nconst NO_STRIP_GROUPS: readonly StripViewGroup[] = [];\n\n/**\n * The live projection of a bar through the command registry — <Toolbar>'s\n * un-measured sibling, for contextual strips (ChromeSchema.strips). The schema\n * declares what COULD appear; each command's `visible` derivation decides what\n * DOES; null means nothing currently applies, so `if (!view) return null` is\n * the caller's entire show/hide logic. `execute` is pre-bound to this\n * subtree's document. Reads are value-equal (resolvedCommandsEqual), so\n * consumers re-render on real change, not on every store action.\n */\nexport function useStripView(bar: BarSchema | undefined): StripView | null {\n const commands = useCapability(CommandsToken);\n const documentId = useDocumentId();\n const normalized = useMemo(() => (bar ? normalizeBar(bar) : null), [bar]);\n const groups = useKernelValue(() => {\n if (!normalized) return NO_STRIP_GROUPS;\n const resolved = new Map<string, ResolvedCommand>();\n const visible = (id: string) => {\n const cmd = commands.resolve(id, documentId ?? undefined);\n if (cmd) resolved.set(id, cmd);\n return cmd?.visible === true;\n };\n return projectStrip(normalized, visible).map((g) => ({\n id: g.id,\n labelKey: g.labelKey,\n commands: g.commands.map((id) => resolved.get(id)!),\n }));\n }, stripGroupsEqual);\n return useMemo(\n () =>\n groups.length === 0\n ? null\n : { groups, execute: (id: string) => commands.execute(id, documentId ?? undefined) },\n [groups, commands, documentId],\n );\n}\n\nexport interface ToolbarProps {\n bar: BarSchema;\n /** Px between adjacent items (CSS flex gap; the solver budgets the same number). */\n gap?: number;\n /** Width of the separator ELEMENT your renderSeparator draws. Default 1. */\n separatorWidth?: number;\n className?: string;\n style?: React.CSSProperties;\n /** A command button at a given variant. Default: a plain <button>. */\n renderCommand?: (cmd: ResolvedCommand, variant: string, run: () => void) => React.ReactNode;\n /**\n * Renderers for custom slots, per named variant. A custom unit with NO\n * entry here renders as a native `<slot name={slot}>` socket with its\n * terminal command as fallback content: in light DOM that displays the\n * fallback (today's behavior); inside a shadow root the host's light-DOM\n * children project into it — the children-as-slots contract. Sockets are\n * measured LIVE (they can't be duplicated into the measurement layer:\n * only the first same-named slot in tree order gets the projected nodes).\n */\n renderCustom?: Record<string, (variant: string, ctx: CustomSlotCtx) => React.ReactNode>;\n /** A group in its collapsed form. Default: <select> for 'select', menu button for 'menu'. */\n renderCollapsed?: (view: CollapsedGroupView) => React.ReactNode;\n /** A shed group's disclosure trigger (+ its popover — the renderer owns the\n * open state). Default: a chevron button opening a radio menu. */\n renderGroupTrigger?: (view: GroupDisclosureView) => React.ReactNode;\n /** Derived separator between adjacent visible groups. Default: a 1px line. */\n renderSeparator?: () => React.ReactNode;\n renderOverflowTrigger?: (isOpen: boolean, toggle: () => void) => React.ReactNode;\n /** The derived overflow menu. Default: a minimal popover. */\n renderOverflowMenu?: (view: OverflowMenuView) => React.ReactNode;\n}\n\n/** Passed to custom-slot renderers alongside the variant. */\nexport interface CustomSlotCtx {\n /** 'live' = the visible row; 'measure' = the hidden measurement layer. */\n layer: 'live' | 'measure';\n /** Report this unit's width to the solver — for content the measurement\n * layer can't duplicate. Identity is NOT stable across renders; capture\n * via ref if used in an effect. */\n measure: (width: number) => void;\n}\n\n// ── measurement ───────────────────────────────────────────────────────────────\n\n/** Report this node's border-box width under `k`, live, via ResizeObserver. */\nfunction Measured({\n k,\n onWidth,\n children,\n}: {\n k: string;\n onWidth: (key: string, width: number) => void;\n children: React.ReactNode;\n}) {\n const ref = useRef<HTMLSpanElement>(null);\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const report = () => onWidth(k, el.getBoundingClientRect().width);\n report();\n const observer = new ResizeObserver(report);\n observer.observe(el);\n return () => observer.disconnect();\n }, [k, onWidth]);\n return (\n <span ref={ref} style={{ display: 'inline-flex', flexShrink: 0 }}>\n {children}\n </span>\n );\n}\n\n/**\n * The socket for an unregistered custom unit: a real `<slot>` element. Inside\n * the <embedpdf-viewer> shadow root the browser projects same-named light-DOM\n * children into it; anywhere else it just displays its fallback (the terminal\n * command). Measured live — the projected content lives in the HOST's world,\n * so its width can only be observed where it actually renders.\n */\nfunction NativeSlotSocket({\n name,\n k,\n onWidth,\n children,\n}: {\n name: string;\n k: string;\n onWidth: (key: string, width: number) => void;\n children: React.ReactNode;\n}) {\n const ref = useRef<HTMLSlotElement>(null);\n useLayoutEffect(() => {\n const el = ref.current;\n if (!el) return;\n const report = () => onWidth(k, el.getBoundingClientRect().width);\n report();\n // Projection changes (a child slotted in/out) resize the socket's\n // inline-flex box, so one observer covers both content and assignment.\n const observer = new ResizeObserver(report);\n observer.observe(el);\n return () => observer.disconnect();\n }, [k, onWidth]);\n return (\n <slot\n ref={ref}\n name={name}\n style={{ display: 'inline-flex', alignItems: 'center', flexShrink: 0 }}\n >\n {children}\n </slot>\n );\n}\n\nconst measureLayerStyle: React.CSSProperties = {\n position: 'absolute',\n left: 0,\n top: 0,\n height: 0,\n overflow: 'hidden',\n visibility: 'hidden',\n pointerEvents: 'none',\n display: 'flex',\n whiteSpace: 'nowrap',\n};\n\n// ── defaults (functional, unstyled-ish; products replace them) ───────────────\n\nconst defaultRenderCommand = (\n cmd: ResolvedCommand,\n variant: string,\n run: () => void,\n): React.ReactNode => (\n <button\n type=\"button\"\n onClick={run}\n disabled={!cmd.enabled}\n aria-pressed={cmd.active || undefined}\n aria-haspopup={cmd.menu ? 'menu' : undefined}\n title={cmd.label}\n style={{\n display: 'inline-flex',\n alignItems: 'center',\n gap: 4,\n padding: '4px 8px',\n whiteSpace: 'nowrap',\n background: cmd.active ? 'rgba(0,0,0,0.12)' : 'transparent',\n border: '1px solid rgba(0,0,0,0.15)',\n borderRadius: 4,\n cursor: cmd.enabled ? 'pointer' : 'default',\n opacity: cmd.enabled ? 1 : 0.4,\n }}\n >\n {variant === 'label' ? cmd.label : (cmd.icon ?? cmd.label)}\n {variant === 'icon+label' ? ` ${cmd.label}` : null}\n </button>\n);\n\nconst defaultRenderSeparator = (): React.ReactNode => (\n <span style={{ width: 1, alignSelf: 'stretch', background: 'currentColor', opacity: 0.2 }} />\n);\n\nconst defaultRenderOverflowTrigger = (isOpen: boolean, toggle: () => void): React.ReactNode => (\n <button\n type=\"button\"\n onClick={toggle}\n aria-haspopup=\"menu\"\n aria-expanded={isOpen}\n title=\"More\"\n style={{\n display: 'inline-flex',\n alignItems: 'center',\n padding: '4px 8px',\n border: '1px solid rgba(0,0,0,0.15)',\n borderRadius: 4,\n background: isOpen ? 'rgba(0,0,0,0.12)' : 'transparent',\n cursor: 'pointer',\n }}\n >\n ⋯\n </button>\n);\n\nfunction DefaultOverflowMenu({ view }: { view: OverflowMenuView }) {\n if (!view.isOpen) return null;\n return (\n <>\n <div style={{ position: 'fixed', inset: 0, zIndex: 40 }} onClick={view.close} />\n <div\n role=\"menu\"\n style={{\n position: 'absolute',\n right: 0,\n top: '100%',\n zIndex: 41,\n minWidth: 200,\n padding: 4,\n background: 'white',\n border: '1px solid rgba(0,0,0,0.15)',\n borderRadius: 6,\n boxShadow: '0 4px 16px rgba(0,0,0,0.15)',\n }}\n >\n {view.sections.map((section, i) => (\n <React.Fragment key={i}>\n {i > 0 && <div style={{ height: 1, background: 'rgba(0,0,0,0.1)', margin: '4px 0' }} />}\n {section.rows.map((row) => {\n const cmd = view.resolve(row.command);\n if (!cmd) return null;\n const isSubmenu = row.type === 'submenu';\n return (\n <button\n key={row.command}\n type=\"button\"\n role={section.role === 'radio' ? 'menuitemradio' : 'menuitem'}\n aria-checked={section.role === 'radio' ? cmd.active : undefined}\n disabled={!cmd.enabled}\n onClick={() => {\n view.execute(row.command);\n if (!isSubmenu) view.close();\n }}\n style={{\n display: 'flex',\n width: '100%',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: 16,\n padding: '6px 8px',\n border: 'none',\n background: 'transparent',\n cursor: cmd.enabled ? 'pointer' : 'default',\n opacity: cmd.enabled ? 1 : 0.4,\n whiteSpace: 'nowrap',\n }}\n >\n <span>\n {cmd.active && section.role === 'radio' ? '• ' : ''}\n {cmd.label}\n </span>\n {isSubmenu ? <span>▸</span> : null}\n </button>\n );\n })}\n </React.Fragment>\n ))}\n </div>\n </>\n );\n}\n\nfunction DefaultCollapsed({ view }: { view: CollapsedGroupView }) {\n if (view.collapse === 'select') {\n const active = view.commands.find((c) => c.active);\n return (\n <select\n value={active?.id ?? ''}\n onChange={(e) => view.execute(e.target.value)}\n style={{ padding: '4px 6px', borderRadius: 4 }}\n >\n {view.commands.map((c) => (\n <option key={c.id} value={c.id} disabled={!c.enabled}>\n {c.label}\n </option>\n ))}\n </select>\n );\n }\n // 'menu': reuse the overflow popover, scoped to this group's commands.\n return <CollapsedMenuButton view={view} />;\n}\n\nfunction CollapsedMenuButton({ view }: { view: CollapsedGroupView }) {\n const [isOpen, setOpen] = useState(false);\n const sections: OverflowSection[] = [\n {\n labelKey: view.labelKey,\n role: view.role === 'tabs' ? 'radio' : undefined,\n rows: view.commands.map((c) => ({ type: 'command' as const, command: c.id })),\n },\n ];\n return (\n <span style={{ position: 'relative', display: 'inline-flex' }}>\n {defaultRenderOverflowTrigger(isOpen, () => setOpen((o) => !o))}\n <DefaultOverflowMenu\n view={{\n sections,\n isOpen,\n close: () => setOpen(false),\n resolve: (id) => view.commands.find((c) => c.id === id) ?? null,\n execute: view.execute,\n }}\n />\n </span>\n );\n}\n\n/** Default shed-group disclosure: a chevron opening a radio menu of the\n * hidden children — v2's overflow-tabs-button, derived. */\nfunction DefaultGroupTrigger({ view }: { view: GroupDisclosureView }) {\n const [isOpen, setOpen] = useState(false);\n const someActive = view.commands.some((c) => c.active);\n const sections: OverflowSection[] = [\n {\n labelKey: view.labelKey,\n role: view.role === 'tabs' ? 'radio' : undefined,\n rows: view.commands.map((c) => ({ type: 'command' as const, command: c.id })),\n },\n ];\n return (\n <span style={{ position: 'relative', display: 'inline-flex' }}>\n <button\n type=\"button\"\n onClick={() => setOpen((o) => !o)}\n aria-haspopup=\"menu\"\n aria-expanded={isOpen}\n title=\"More\"\n style={{\n display: 'inline-flex',\n alignItems: 'center',\n padding: '4px 6px',\n border: '1px solid rgba(0,0,0,0.15)',\n borderRadius: 4,\n // hint that the active item is hiding in here\n background: isOpen || someActive ? 'rgba(0,0,0,0.12)' : 'transparent',\n cursor: 'pointer',\n }}\n >\n ▾\n </button>\n <DefaultOverflowMenu\n view={{\n sections,\n isOpen,\n close: () => setOpen(false),\n resolve: (id) => view.commands.find((c) => c.id === id) ?? null,\n execute: view.execute,\n }}\n />\n </span>\n );\n}\n\n// ── the toolbar ───────────────────────────────────────────────────────────────\n\nconst unitKey = (u: NormalizedUnit, variant: string) => `u:${u.key}@${variant}`;\nconst groupKey = (id: string) => `g:${id}`;\nconst groupTriggerKey = (id: string) => `gt:${id}`;\nconst TRIGGER_KEY = 't:';\n\nexport function Toolbar({\n bar,\n gap = 8,\n separatorWidth = 1,\n className,\n style,\n renderCommand = defaultRenderCommand,\n renderCustom,\n renderCollapsed,\n renderGroupTrigger,\n renderSeparator = defaultRenderSeparator,\n renderOverflowTrigger = defaultRenderOverflowTrigger,\n renderOverflowMenu,\n}: ToolbarProps) {\n const kernel = useKernel();\n const commands = useCapability(CommandsToken);\n const documentId = useDocumentId();\n\n // Command state is derived-on-read; re-render on the kernel's change stream\n // so labels/active/visible (and thus the hidden layer's measurements) stay\n // live. The toolbar is small — a per-action render is the simple, correct\n // baseline.\n const [, force] = useReducer((x: number) => x + 1, 0);\n useEffect(() => kernel.subscribe(force), [kernel]);\n\n const containerRef = useRef<HTMLDivElement>(null);\n const [containerWidth, setContainerWidth] = useState(0);\n useLayoutEffect(() => {\n const el = containerRef.current;\n if (!el) return;\n const observer = new ResizeObserver((entries) => {\n const w = entries[entries.length - 1]?.contentRect.width;\n if (w !== undefined) setContainerWidth((prev) => (Math.abs(prev - w) > 0.5 ? w : prev));\n });\n observer.observe(el);\n setContainerWidth(el.clientWidth);\n return () => observer.disconnect();\n }, []);\n\n const widthsRef = useRef(new Map<string, number>());\n const [, bumpMeasureVersion] = useReducer((x: number) => x + 1, 0);\n const onWidth = useMemo(\n () => (key: string, width: number) => {\n const prev = widthsRef.current.get(key);\n if (prev !== undefined && Math.abs(prev - width) <= 0.5) return;\n widthsRef.current.set(key, width);\n bumpMeasureVersion();\n },\n [],\n );\n\n const resolveCmd = (id: string): ResolvedCommand | null =>\n commands.resolve(id, documentId ?? undefined);\n const executeCmd = (id: string) => commands.execute(id, documentId ?? undefined);\n const commandOf = (u: NormalizedUnit) => (u.kind === 'command' ? u.command : u.terminal);\n\n // Structure → visible structure → fit. Cheap enough to run per render; all\n // heavy lifting is O(items), and items is ~dozens.\n const normalized = useMemo(() => normalizeBar(bar), [bar]);\n // `=== true` and not `!== false`: an UNREGISTERED command resolves to null,\n // and a unit the registry can't name must not render or consume budget —\n // the schema validator's dev warning is the feedback channel, not raw text\n // in the toolbar.\n const visibleBar = filterBar(normalized, (u) => resolveCmd(commandOf(u))?.visible === true);\n const metrics: FitMetrics = {\n unit: (key, variant) => widthsRef.current.get(`u:${key}@${variant}`),\n groupCollapsed: (id) => widthsRef.current.get(groupKey(id)),\n groupTrigger: (id) => widthsRef.current.get(groupTriggerKey(id)),\n overflowTrigger: widthsRef.current.get(TRIGGER_KEY) ?? 32,\n gap,\n // The separator is one extra flex child: its element width plus one flex gap.\n separator: separatorWidth + gap,\n };\n const fit = solve(visibleBar, metrics, containerWidth);\n const overflowSections = projectOverflow(visibleBar, fit, (id) => commands.menuTarget(id));\n\n const [overflowOpen, setOverflowOpen] = useState(false);\n useEffect(() => {\n if (!fit.hasOverflow) setOverflowOpen(false);\n }, [fit.hasOverflow]);\n\n /** External = custom unit with no registered renderer → native socket,\n * live-measured (it must NOT appear in the measurement layer: only the\n * first same-named <slot> in tree order receives the projected nodes). */\n const isExternalSlot = (u: NormalizedUnit): boolean =>\n u.kind === 'custom' && !renderCustom?.[u.slot];\n\n // ── unit / group rendering (shared by live row and measure layer) ──────────\n const renderUnitAt = (\n u: NormalizedUnit,\n variant: string,\n layer: 'live' | 'measure',\n ): React.ReactNode => {\n if (u.kind === 'custom') {\n const registered = renderCustom?.[u.slot];\n if (registered) {\n const custom = registered(variant, {\n layer,\n measure: (width) => onWidth(unitKey(u, variant), width),\n });\n if (custom !== undefined) return custom;\n } else if (layer === 'live') {\n const cmd = resolveCmd(u.terminal);\n return (\n <NativeSlotSocket name={u.slot} k={unitKey(u, variant)} onWidth={onWidth}>\n {cmd ? renderCommand(cmd, 'icon', () => executeCmd(u.terminal)) : null}\n </NativeSlotSocket>\n );\n } else {\n return null;\n }\n const cmd = resolveCmd(u.terminal);\n return cmd ? renderCommand(cmd, 'icon', () => executeCmd(u.terminal)) : null;\n }\n const cmd = resolveCmd(u.command);\n if (!cmd)\n return renderCommand(\n {\n id: u.command,\n label: u.command,\n shortcuts: [],\n enabled: false,\n active: false,\n visible: true,\n categories: [],\n },\n variant,\n () => {},\n );\n return renderCommand(cmd, variant, () => executeCmd(u.command));\n };\n\n const collapsedView = (g: NormalizedGroup): CollapsedGroupView => ({\n id: g.id,\n labelKey: g.labelKey,\n collapse: g.collapse ?? 'menu',\n role: g.role,\n commands: g.units\n .map((u) => resolveCmd(commandOf(u)))\n .filter((c): c is ResolvedCommand => c !== null && c.visible),\n execute: executeCmd,\n });\n\n const renderCollapsedGroup = (g: NormalizedGroup): React.ReactNode =>\n renderCollapsed ? (\n renderCollapsed(collapsedView(g))\n ) : (\n <DefaultCollapsed view={collapsedView(g)} />\n );\n\n /** The disclosure view: shed children for the live trigger; the WHOLE group\n * for the measured trigger, so width is budgeted at its fullest content. */\n const disclosureView = (g: NormalizedGroup, allChildren: boolean): GroupDisclosureView => ({\n id: g.id,\n labelKey: g.labelKey,\n role: g.role,\n commands: g.units\n .filter((u) => allChildren || fit.units.get(u.key)?.kind === 'shed')\n .map((u) => resolveCmd(commandOf(u)))\n .filter((c): c is ResolvedCommand => c !== null && c.visible),\n execute: executeCmd,\n });\n\n const renderDisclosure = (g: NormalizedGroup, allChildren: boolean): React.ReactNode =>\n renderGroupTrigger ? (\n renderGroupTrigger(disclosureView(g, allChildren))\n ) : (\n <DefaultGroupTrigger view={disclosureView(g, allChildren)} />\n );\n\n const renderLiveGroup = (g: NormalizedGroup): React.ReactNode[] => {\n const assignment = fit.groups.get(g.id);\n if (!assignment || assignment.overflowed) return [];\n if (assignment.collapsed)\n return [<React.Fragment key={g.id}>{renderCollapsedGroup(g)}</React.Fragment>];\n const nodes: React.ReactNode[] = [];\n for (const u of g.units) {\n const a = fit.units.get(u.key);\n if (a?.kind !== 'variant') continue;\n nodes.push(<React.Fragment key={u.key}>{renderUnitAt(u, a.variant, 'live')}</React.Fragment>);\n }\n // The derived group-local disclosure (v2's overflow-tabs-button).\n if (assignment.shedCount > 0) {\n nodes.push(\n <React.Fragment key={`${g.id}::trigger`}>{renderDisclosure(g, false)}</React.Fragment>,\n );\n }\n return nodes.length ? [<React.Fragment key={g.id}>{nodes}</React.Fragment>] : [];\n };\n\n const renderLiveSection = (section: NormalizedSection | undefined): React.ReactNode => {\n if (!section) return null;\n const rendered = section.groups\n .map((g) => ({ id: g.id, nodes: renderLiveGroup(g) }))\n .filter((g) => g.nodes.length > 0);\n return rendered.map((g, i) => (\n <React.Fragment key={g.id}>\n {i > 0 && renderSeparator()}\n {g.nodes}\n </React.Fragment>\n ));\n };\n\n const sectionByName = (name: 'start' | 'center' | 'end') =>\n visibleBar.sections.find((s) => s.name === name);\n\n /**\n * Segment layout — v2's spacer model, natively. The center segment carries\n * auto margins: it BALANCES in the leftover space (true center when the\n * flanks are symmetric) and yields when they aren't, collapsing to zero\n * before anything can overlap. The container itself has NO gap — segments\n * space themselves — so the solver's global budget (sum of unit widths +\n * per-unit gaps) is exactly the layout's minimum width: what the solver\n * says fits, fits. Its cross-segment gap allowance (≤ 2×gap) becomes slack\n * the auto margins absorb, keeping ≥ gap between segments at the floor.\n * Segments never grow or shrink: fit is the SOLVER's job, not flexbox's.\n */\n const sectionStyle = (position: 'start' | 'center' | 'end'): React.CSSProperties => ({\n display: 'flex',\n alignItems: 'center',\n gap,\n flex: '0 0 auto',\n ...(position === 'center' ? { marginLeft: 'auto', marginRight: 'auto' } : null),\n });\n\n const overflowView: OverflowMenuView = {\n sections: overflowSections,\n isOpen: overflowOpen,\n close: () => setOverflowOpen(false),\n resolve: resolveCmd,\n execute: executeCmd,\n };\n\n return (\n <div\n ref={containerRef}\n className={className}\n style={{ position: 'relative', display: 'flex', alignItems: 'center', ...style }}\n >\n <div style={sectionStyle('start')}>{renderLiveSection(sectionByName('start'))}</div>\n <div style={sectionStyle('center')}>{renderLiveSection(sectionByName('center'))}</div>\n <div style={sectionStyle('end')}>\n {renderLiveSection(sectionByName('end'))}\n {fit.hasOverflow && (\n <span style={{ position: 'relative', display: 'inline-flex' }}>\n {renderOverflowTrigger(overflowOpen, () => setOverflowOpen((o) => !o))}\n {renderOverflowMenu ? (\n renderOverflowMenu(overflowView)\n ) : (\n <DefaultOverflowMenu view={overflowView} />\n )}\n </span>\n )}\n </div>\n\n {/* The measurement layer: every unit in every variant, every collapsed\n group form, and the trigger — hidden, inert, observed. Text reflow\n (locale, fonts, zoom) fires the observers; no change-handling code. */}\n <div aria-hidden style={measureLayerStyle}>\n {visibleBar.sections.flatMap((s) =>\n s.groups.flatMap((g) => [\n // External sockets are excluded: they are live-measured, and a\n // duplicate <slot> here would steal the projection from the row.\n ...g.units\n .filter((u) => !isExternalSlot(u))\n .flatMap((u) =>\n u.variants.map((variant) => (\n <Measured key={unitKey(u, variant)} k={unitKey(u, variant)} onWidth={onWidth}>\n {renderUnitAt(u, variant, 'measure')}\n </Measured>\n )),\n ),\n ...(g.collapse\n ? [\n <Measured key={groupKey(g.id)} k={groupKey(g.id)} onWidth={onWidth}>\n {renderCollapsedGroup(g)}\n </Measured>,\n ]\n : []),\n ...(g.shed\n ? [\n <Measured key={groupTriggerKey(g.id)} k={groupTriggerKey(g.id)} onWidth={onWidth}>\n {renderDisclosure(g, true)}\n </Measured>,\n ]\n : []),\n ]),\n )}\n <Measured k={TRIGGER_KEY} onWidth={onWidth}>\n {renderOverflowTrigger(false, () => {})}\n </Measured>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAqFA,MAAM,oBAAoB,GAA8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C,CAAC,CACjC,SAAS,MACR,EAAE,SAAS,KAAK,YACd,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;MAAoC,GAAG,QAAQ,GAAG,OAAO;MAAY;MAClE,UAAA,aAAa,GAAG,SAAS,SAAS;KAC3B,GAFK,QAAQ,GAAG,OAAO,CAEvB,CACX,CACH;KACF,GAAI,EAAE,WACF,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;MAA+B,GAAG,SAAS,EAAE,EAAE;MAAY;MACxD,UAAA,qBAAqB,CAAC;KACf,GAFK,SAAS,EAAE,EAAE,CAElB,CACZ,IACA,CAAC;KACL,GAAI,EAAE,OACF,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;MAAsC,GAAG,gBAAgB,EAAE,EAAE;MAAY;MACtE,UAAA,iBAAiB,GAAG,IAAI;KACjB,GAFK,gBAAgB,EAAE,EAAE,CAEzB,CACZ,IACA,CAAC;IACP,CAAC,CACH,GACA,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;KAAU,GAAG;KAAsB;KAChC,UAAA,sBAAsB,aAAa,CAAC,CAAC;IAC9B,CAAA,CACP;;EACF;;AAET"}
1
+ {"version":3,"file":"toolbar.cjs","names":["resolvedCommandsEqual","useCapability","CommandsToken","useDocumentId","useKernelValue","TOOLBAR_ITEM_ATTRIBUTE","React","useKernel","createToolbarLengths","unregisteredCommand","toolbarMeasureKey","INERT"],"sources":["../src/toolbar.tsx"],"sourcesContent":["/**\n * The headless <Toolbar>: it measures what fits and makes room, and you draw\n * every part.\n *\n * 1. a hidden measurement layer renders every unit in every variant (plus\n * folded groups and the \"More\" button), each watched by\n * `@embedpdf/web`'s `observeLength` along the toolbar (widths, or\n * heights when it is vertical), so a new language, a font loading,\n * browser zoom and your CSS all re-measure on their own; the lengths\n * become fit metrics (`createToolbarLengths`);\n * 2. core-ui's `solve()` gives each unit a variant, a folded group or the\n * \"More\" menu, and `layoutToolbar` turns that fit into the parts to\n * draw: pure and tested on their own;\n * 3. the live row renders that; the \"More\" menu is derived (`projectOverflow`)\n * from what didn't fit, never written by hand.\n *\n * The toolbar is one tab stop with arrow keys along it (`attachToolbarFocus`),\n * and its default menus take the menu keys (`attachMenuKeys`). Every part is a\n * render prop with a plain default: the app owns the pixels, this component\n * owns the fitting and the keyboard. The defaults' colors come from the\n * `--epdf-toolbar-*` CSS variables only.\n */\n\n// The toolbar's vocabulary: the schema a bar is written in.\nexport { DEFAULT_IMPORTANCE, PINNED, custom, group, item } from '@embedpdf/core-ui';\nexport type {\n BarChild,\n BarGroup,\n BarItem,\n BarSchema,\n BarSections,\n CustomItem,\n Importance,\n OverflowRow,\n OverflowSection,\n Variant,\n} from '@embedpdf/core-ui';\nimport * as React from 'react';\nimport { useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from 'react';\nimport {\n groupMenuView,\n layoutToolbar,\n normalizeBar,\n sameStripGroups,\n stripGroupsOf,\n} from '@embedpdf/core-ui';\nimport type {\n BarSchema,\n CollapsedGroupView as CollapsedGroupViewOf,\n CustomSlotCtx,\n GroupDisclosureView as GroupDisclosureViewOf,\n LiveSection,\n OverflowMenuView as OverflowMenuViewOf,\n StripView as StripViewOf,\n StripViewGroup as StripViewGroupOf,\n ToolbarPart,\n} from '@embedpdf/core-ui';\nimport { resolvedCommandsEqual, unregisteredCommand } from '@embedpdf/plugin-commands/contract';\n// The \"More\" menu asks which menu a command opens, a host fact, so the host lens is bound here.\nimport { CommandsToken } from '@embedpdf/plugin-commands/contract/host';\nimport type { ResolvedCommand } from '@embedpdf/plugin-commands/contract';\nimport {\n TOOLBAR_ITEM_ATTRIBUTE,\n attachMenuKeys,\n attachToolbarFocus,\n createToolbarLengths,\n focusablesIn,\n observeContentLength,\n observeLength,\n observeOutsidePress,\n paintDefault,\n toolbarMeasureKey,\n} from '@embedpdf/web';\nimport type { Orientation, RovingFocus } from '@embedpdf/web';\nimport { INERT } from './inert';\nimport { useCapability, useDocumentId, useKernel, useKernelValue } from './runtime';\n\n// ── public render-prop contracts ─────────────────────────────────────────────\n\n/** A group folded into one control: its commands, resolved live, and how to run one. */\nexport type CollapsedGroupView = CollapsedGroupViewOf<ResolvedCommand>;\n\n/** The \"More\" menu: what didn't fit, in sections, and the calls a menu needs. */\nexport type OverflowMenuView = OverflowMenuViewOf<ResolvedCommand>;\n\n/**\n * A shed group's disclosure — the derived trigger rendered inside the group.\n * `commands` is what sits behind the trigger: the shed children in bar order,\n * resolved live. In the measurement layer the trigger is measured with the\n * full group as content, so a count-dependent trigger (e.g. a \"+3\" badge) is\n * budgeted at its widest form.\n */\nexport type GroupDisclosureView = GroupDisclosureViewOf<ResolvedCommand>;\n\n/** Passed to custom-slot renderers alongside the variant. */\nexport type { CustomSlotCtx };\n\n// ── the strip view — a bar projected through the registry, live ──────────────\n\n/** A group of a strip: its visible commands, bar order. Groups are separator boundaries. */\nexport type StripViewGroup = StripViewGroupOf<ResolvedCommand>;\n\n/** A contextual strip, resolved: only visible commands, only non-empty groups. */\nexport type StripView = StripViewOf<ResolvedCommand>;\n\nconst stripGroupsEqual = (\n left: readonly StripViewGroup[],\n right: readonly StripViewGroup[],\n): boolean => sameStripGroups(left, right, resolvedCommandsEqual);\n\nconst NO_STRIP_GROUPS: readonly StripViewGroup[] = [];\n\n/**\n * The live projection of a bar through the command registry — <Toolbar>'s\n * un-measured sibling, for contextual strips (a bar over a selection). The schema\n * declares what could appear; each command's `visible` derivation decides what\n * does; null means nothing currently applies, so `if (!view) return null` is\n * the caller's entire show/hide logic. `execute` is pre-bound to this\n * subtree's document. Reads are value-equal (resolvedCommandsEqual), so\n * consumers re-render on real change, not on every store action.\n */\nexport function useStripView(bar: BarSchema | undefined): StripView | null {\n const commands = useCapability(CommandsToken);\n const documentId = useDocumentId();\n const normalized = useMemo(() => (bar ? normalizeBar(bar) : null), [bar]);\n const groups = useKernelValue(\n () =>\n normalized\n ? stripGroupsOf(normalized, (id) => commands.resolveCommand(id, documentId ?? undefined))\n : NO_STRIP_GROUPS,\n stripGroupsEqual,\n );\n return useMemo(\n () =>\n groups.length === 0\n ? null\n : {\n groups,\n execute: (id: string) =>\n void commands.execute(id, { documentId: documentId ?? undefined }),\n },\n [groups, commands, documentId],\n );\n}\n\nexport interface ToolbarProps {\n bar: BarSchema;\n /**\n * Which way the toolbar runs. A vertical toolbar fits the height it's given,\n * so give it one; it stacks its sections top, middle and bottom, and draws\n * every command at `'icon'`, with the label for a tooltip. Default\n * `'horizontal'`.\n */\n orientation?: 'horizontal' | 'vertical';\n /** Px between adjacent items (CSS flex gap; the solver budgets the same number). */\n gap?: number;\n /**\n * The thickness of the separator your renderSeparator draws: its width\n * across a horizontal toolbar, its height in a vertical one. Default 1.\n */\n separatorWidth?: number;\n /** The toolbar's name for screen readers, for a page with more than one toolbar. */\n 'aria-label'?: string;\n className?: string;\n style?: React.CSSProperties;\n /** A command button at a given variant. Default: a plain <button> with the command's label. */\n renderCommand?: (cmd: ResolvedCommand, variant: string, run: () => void) => React.ReactNode;\n /**\n * Your own items, one renderer per name (from `custom(name, command)`),\n * called with the variant the fit chose. A renderer that returns\n * `undefined` draws the item's command instead (`renderCommand` with the\n * terminal command, variant `'icon'`). An item with no entry here renders\n * as a native `<slot name={slot}>` socket with that command as fallback\n * content: in light DOM that displays the fallback; inside a shadow root\n * the host's light-DOM children project into it — the children-as-slots\n * contract. Sockets are measured live (they can't be duplicated into the\n * measurement layer: only the first same-named slot in tree order gets the\n * projected nodes). A renderer that draws nothing (`null`) in the\n * measurement layer (`ctx.layer === 'measure'`) is measured where it\n * renders instead: report its length with `ctx.measure`, a new function on\n * every render (capture it in a ref to use it in an effect). The first\n * element of an item that takes focus is the item's stop in the toolbar's\n * arrow-key order.\n */\n renderCustom?: Record<string, (variant: string, ctx: CustomSlotCtx) => React.ReactNode>;\n /**\n * A group in its collapsed form. Default: <select> for 'select', menu button for 'menu'; a\n * renderer that returns `undefined` leaves the group to the default.\n */\n renderCollapsed?: (view: CollapsedGroupView) => React.ReactNode;\n /** A shed group's disclosure trigger (+ its popover — the renderer owns the\n * open state). Default: a chevron button opening a radio menu; `undefined`\n * leaves it to the default too. */\n renderGroupTrigger?: (view: GroupDisclosureView) => React.ReactNode;\n /** Derived separator between adjacent visible groups. Default: a 1px line across the toolbar. */\n renderSeparator?: () => React.ReactNode;\n /** The \"More\" button. Default: a plain ⋯ button. */\n renderOverflowTrigger?: (isOpen: boolean, toggle: () => void) => React.ReactNode;\n /** The derived overflow menu. Default: a minimal popover. */\n renderOverflowMenu?: (view: OverflowMenuView) => React.ReactNode;\n}\n\n// ── measurement ───────────────────────────────────────────────────────────────\n\n/** Report this node's border-box length along the toolbar under `k`, live. */\nfunction Measured({\n k,\n orientation,\n onLength,\n children,\n}: {\n k: string;\n orientation: Orientation;\n onLength: (key: string, length: number) => void;\n children: React.ReactNode;\n}) {\n const ref = useRef<HTMLSpanElement>(null);\n useLayoutEffect(\n () =>\n ref.current\n ? observeLength(ref.current, orientation, (length) => onLength(k, length))\n : undefined,\n [k, orientation, onLength],\n );\n return (\n <span ref={ref} style={{ display: 'inline-flex', flexShrink: 0 }}>\n {children}\n </span>\n );\n}\n\n/**\n * The socket for an unregistered custom unit: a real `<slot>` element. Inside\n * the <embedpdf-viewer> shadow root the browser projects same-named light-DOM\n * children into it; anywhere else it just displays its fallback (the terminal\n * command). Measured live — the projected content lives in the host's world,\n * so its length can only be observed where it actually renders.\n */\nfunction NativeSlotSocket({\n name,\n k,\n orientation,\n onLength,\n children,\n}: {\n name: string;\n k: string;\n orientation: Orientation;\n onLength: (key: string, length: number) => void;\n children: React.ReactNode;\n}) {\n const ref = useRef<HTMLSlotElement>(null);\n // Projection changes (a child slotted in/out) resize the socket's\n // inline-flex box, so one observer covers both content and assignment.\n useLayoutEffect(\n () =>\n ref.current\n ? observeLength(ref.current, orientation, (length) => onLength(k, length))\n : undefined,\n [k, orientation, onLength],\n );\n return (\n <slot\n ref={ref}\n name={name}\n style={{ display: 'inline-flex', alignItems: 'center', flexShrink: 0 }}\n >\n {children}\n </slot>\n );\n}\n\n/**\n * The hidden measurement layer: a row for a horizontal toolbar, a column for a\n * vertical one, and no height either way, so it never adds to the page. A\n * column keeps each item at its own width, so no text wraps and changes the\n * heights it reports.\n */\nconst measureLayerStyle = (orientation: Orientation): React.CSSProperties => ({\n position: 'absolute',\n left: 0,\n top: 0,\n height: 0,\n overflow: 'hidden',\n visibility: 'hidden',\n pointerEvents: 'none',\n display: 'flex',\n whiteSpace: 'nowrap',\n ...(orientation === 'vertical' ? { flexDirection: 'column', alignItems: 'flex-start' } : null),\n});\n\n/** Marks the element around each item of the live row: its first focusable element is a stop. */\nconst TOOLBAR_ITEM = { [TOOLBAR_ITEM_ATTRIBUTE]: '' } as Record<string, string>;\n\n/** The element around an item adds no box, so the item lays out as the section's own child. */\nconst ITEM_STYLE: React.CSSProperties = { display: 'contents' };\n\n// ── defaults: plain, and meant to be replaced ────────────────────────────────\n\nconst SURFACE = paintDefault('toolbar-surface');\nconst BORDER = paintDefault('toolbar-border');\nconst ACTIVE = paintDefault('toolbar-active');\n\nconst defaultRenderCommand = (\n cmd: ResolvedCommand,\n _variant: string,\n run: () => void,\n): React.ReactNode => (\n <button\n type=\"button\"\n onClick={run}\n disabled={!cmd.enabled}\n aria-pressed={cmd.active || undefined}\n aria-haspopup={cmd.menu ? 'menu' : undefined}\n title={cmd.label}\n style={{\n display: 'inline-flex',\n alignItems: 'center',\n gap: 4,\n padding: '4px 8px',\n whiteSpace: 'nowrap',\n color: 'inherit',\n font: 'inherit',\n background: cmd.active ? ACTIVE : 'transparent',\n border: `1px solid ${BORDER}`,\n borderRadius: 4,\n cursor: cmd.enabled ? 'pointer' : 'default',\n opacity: cmd.enabled ? 1 : 0.4,\n }}\n >\n {/* Icons are the app's: the plain button shows the label in every variant. */}\n {cmd.label}\n </button>\n);\n\n/** A 1px line across the toolbar: upright in a horizontal one, flat in a vertical one. */\nfunction DefaultSeparator({ orientation }: { orientation: Orientation }) {\n const thickness = orientation === 'vertical' ? { height: 1 } : { width: 1 };\n return (\n <span\n style={{ ...thickness, alignSelf: 'stretch', background: 'currentColor', opacity: 0.2 }}\n />\n );\n}\n\nconst defaultRenderOverflowTrigger = (isOpen: boolean, toggle: () => void): React.ReactNode => (\n <button\n type=\"button\"\n onClick={toggle}\n aria-haspopup=\"menu\"\n aria-expanded={isOpen}\n title=\"More\"\n style={{\n display: 'inline-flex',\n alignItems: 'center',\n padding: '4px 8px',\n color: 'inherit',\n font: 'inherit',\n border: `1px solid ${BORDER}`,\n borderRadius: 4,\n background: isOpen ? ACTIVE : 'transparent',\n cursor: 'pointer',\n }}\n >\n ⋯\n </button>\n);\n\n/** Where a default menu opens: under a horizontal toolbar's button, beside a vertical one's. */\nconst menuPlacement = (orientation: Orientation): React.CSSProperties =>\n orientation === 'vertical'\n ? { top: 0, insetInlineStart: '100%' }\n : { top: '100%', insetInlineEnd: 0 };\n\n/**\n * The default menu, opened by the button beside it in the same parent: it\n * closes on a press outside that parent, and takes the menu keys while open.\n */\nfunction DefaultOverflowMenu({\n view,\n orientation,\n}: {\n view: OverflowMenuView;\n orientation: Orientation;\n}) {\n const menu = useRef<HTMLDivElement>(null);\n const close = useRef(view.close);\n close.current = view.close;\n useLayoutEffect(() => {\n const element = menu.current;\n if (!view.isOpen || !element) return;\n // The menu's parent holds its button too: a press on it is the button's own toggle.\n const container = element.parentElement ?? element;\n const trigger =\n focusablesIn(container).find((candidate) => !element.contains(candidate)) ?? null;\n const stopOutside = observeOutsidePress(container, () => close.current());\n const detachKeys = attachMenuKeys(element, { trigger, close: () => close.current() });\n return () => {\n stopOutside();\n detachKeys();\n };\n }, [view.isOpen]);\n if (!view.isOpen) return null;\n return (\n <div\n ref={menu}\n role=\"menu\"\n style={{\n position: 'absolute',\n ...menuPlacement(orientation),\n zIndex: 41,\n minWidth: 200,\n padding: 4,\n background: SURFACE,\n border: `1px solid ${BORDER}`,\n borderRadius: 6,\n boxShadow: '0 4px 16px rgba(0,0,0,0.15)',\n }}\n >\n {view.sections.map((section, i) => (\n <React.Fragment key={i}>\n {i > 0 && <div style={{ height: 1, background: BORDER, margin: '4px 0' }} />}\n {section.rows.map((row) => {\n const cmd = view.resolve(row.command);\n if (!cmd) return null;\n const isSubmenu = row.type === 'submenu';\n return (\n <button\n key={row.command}\n type=\"button\"\n role={section.role === 'radio' ? 'menuitemradio' : 'menuitem'}\n aria-checked={section.role === 'radio' ? cmd.active : undefined}\n disabled={!cmd.enabled}\n tabIndex={-1}\n onClick={() => {\n view.execute(row.command);\n if (!isSubmenu) view.close();\n }}\n style={{\n display: 'flex',\n width: '100%',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: 16,\n padding: '6px 8px',\n border: 'none',\n color: 'inherit',\n font: 'inherit',\n background: 'transparent',\n cursor: cmd.enabled ? 'pointer' : 'default',\n opacity: cmd.enabled ? 1 : 0.4,\n whiteSpace: 'nowrap',\n }}\n >\n <span>\n {cmd.active && section.role === 'radio' ? '• ' : ''}\n {cmd.label}\n </span>\n {isSubmenu ? <span>▸</span> : null}\n </button>\n );\n })}\n </React.Fragment>\n ))}\n </div>\n );\n}\n\nfunction DefaultCollapsed({\n view,\n orientation,\n}: {\n view: CollapsedGroupView;\n orientation: Orientation;\n}) {\n if (view.collapse === 'select') {\n const active = view.commands.find((command) => command.active);\n return (\n <select\n value={active?.id ?? ''}\n onChange={(event) => view.execute(event.target.value)}\n style={{\n padding: '4px 6px',\n font: 'inherit',\n borderRadius: 4,\n border: `1px solid ${BORDER}`,\n background: SURFACE,\n }}\n >\n {view.commands.map((command) => (\n <option key={command.id} value={command.id} disabled={!command.enabled}>\n {command.label}\n </option>\n ))}\n </select>\n );\n }\n // 'menu': reuse the overflow popover, scoped to this group's commands.\n return <CollapsedMenuButton view={view} orientation={orientation} />;\n}\n\nfunction CollapsedMenuButton({\n view,\n orientation,\n}: {\n view: CollapsedGroupView;\n orientation: Orientation;\n}) {\n const [isOpen, setOpen] = useState(false);\n return (\n <span style={{ position: 'relative', display: 'inline-flex' }}>\n {defaultRenderOverflowTrigger(isOpen, () => setOpen((previous) => !previous))}\n <DefaultOverflowMenu\n view={groupMenuView(view, isOpen, () => setOpen(false))}\n orientation={orientation}\n />\n </span>\n );\n}\n\n/** Default shed-group disclosure: a chevron opening a radio menu of the\n * hidden children. */\nfunction DefaultGroupTrigger({\n view,\n orientation,\n}: {\n view: GroupDisclosureView;\n orientation: Orientation;\n}) {\n const [isOpen, setOpen] = useState(false);\n const someActive = view.commands.some((command) => command.active);\n return (\n <span style={{ position: 'relative', display: 'inline-flex' }}>\n <button\n type=\"button\"\n onClick={() => setOpen((previous) => !previous)}\n aria-haspopup=\"menu\"\n aria-expanded={isOpen}\n title=\"More\"\n style={{\n display: 'inline-flex',\n alignItems: 'center',\n padding: '4px 6px',\n color: 'inherit',\n font: 'inherit',\n border: `1px solid ${BORDER}`,\n borderRadius: 4,\n // A hint that the active item is in here.\n background: isOpen || someActive ? ACTIVE : 'transparent',\n cursor: 'pointer',\n }}\n >\n ▾\n </button>\n <DefaultOverflowMenu\n view={groupMenuView(view, isOpen, () => setOpen(false))}\n orientation={orientation}\n />\n </span>\n );\n}\n\n// ── the toolbar ───────────────────────────────────────────────────────────────\n\nexport function Toolbar({\n bar,\n orientation = 'horizontal',\n gap = 8,\n separatorWidth = 1,\n 'aria-label': ariaLabel,\n className,\n style,\n renderCommand = defaultRenderCommand,\n renderCustom,\n renderCollapsed,\n renderGroupTrigger,\n renderSeparator,\n renderOverflowTrigger = defaultRenderOverflowTrigger,\n renderOverflowMenu,\n}: ToolbarProps) {\n const kernel = useKernel();\n const commands = useCapability(CommandsToken);\n const documentId = useDocumentId();\n const vertical = orientation === 'vertical';\n\n // Command state is derived-on-read; re-render on the kernel's change stream\n // so labels/active/visible (and thus the hidden layer's measurements) stay\n // live. The toolbar is small — a per-action render is the simple, correct\n // baseline.\n const [, force] = useReducer((x: number) => x + 1, 0);\n useEffect(() => kernel.subscribe(force), [kernel]);\n\n const containerRef = useRef<HTMLDivElement>(null);\n const [containerLength, setContainerLength] = useState(0);\n useLayoutEffect(\n () =>\n containerRef.current\n ? observeContentLength(containerRef.current, orientation, setContainerLength)\n : undefined,\n [orientation],\n );\n\n // A length that changed renders (and solves) again.\n const [lengths] = useState(createToolbarLengths);\n const [, bumpMeasureVersion] = useReducer((version: number) => version + 1, 0);\n const onLength = useMemo(\n () => (key: string, length: number) => {\n if (lengths.report(orientation, key, length)) bumpMeasureVersion();\n },\n [lengths, orientation],\n );\n\n // The keyboard: one tab stop, and arrow keys along the toolbar.\n const roving = useRef<RovingFocus | null>(null);\n useLayoutEffect(() => {\n const toolbar = containerRef.current;\n if (!toolbar) return;\n const focus = attachToolbarFocus(toolbar, orientation);\n roving.current = focus;\n return () => {\n focus.detach();\n roving.current = null;\n };\n }, [orientation]);\n // Any render can add, remove or disable an item, so the tab stop is checked after each one.\n useLayoutEffect(() => roving.current?.refresh());\n\n const resolveCmd = (id: string): ResolvedCommand | null =>\n commands.resolveCommand(id, documentId ?? undefined);\n const executeCmd = (id: string) =>\n void commands.execute(id, { documentId: documentId ?? undefined });\n\n // Structure → visible structure → fit → parts (core-ui's `layoutToolbar`).\n // Cheap enough to run per render: O(items), and items is ~dozens.\n const normalized = useMemo(() => normalizeBar(bar), [bar]);\n const layout = layoutToolbar({\n bar: normalized,\n resolve: resolveCmd,\n unregistered: unregisteredCommand,\n execute: executeCmd,\n menuTarget: (id) => commands.getMenuTarget(id),\n metrics: lengths.metrics(orientation, gap, separatorWidth),\n measureKey: toolbarMeasureKey,\n containerLength,\n orientation,\n });\n\n const [overflowOpen, setOverflowOpen] = useState(false);\n useEffect(() => {\n if (!layout.hasOverflow) setOverflowOpen(false);\n }, [layout.hasOverflow]);\n\n /** External = custom part with no registered renderer → native socket,\n * live-measured (it must not appear in the measurement layer: only the\n * first same-named <slot> in tree order receives the projected nodes). */\n const isExternalSlot = (part: ToolbarPart<ResolvedCommand>): boolean =>\n part.kind === 'custom' && !renderCustom?.[part.name];\n\n // ── part rendering (shared by live row and measure layer) ──────────────────\n // A render prop that returns `undefined` leaves the part to its default.\n const renderPart = (\n part: ToolbarPart<ResolvedCommand>,\n layer: 'live' | 'measure',\n ): React.ReactNode => {\n switch (part.kind) {\n case 'command':\n return renderCommand(part.command, part.variant, part.run);\n case 'custom': {\n // The item's command, as a button: what it draws when nothing else does.\n const terminal = () =>\n part.terminal ? renderCommand(part.terminal, 'icon', part.runTerminal) : null;\n const registered = renderCustom?.[part.name];\n if (registered) {\n const custom = registered(part.variant, {\n layer,\n measure: (length) => onLength(part.measureKey, length),\n });\n return custom === undefined ? terminal() : custom;\n }\n if (layer === 'measure') return null;\n return (\n <NativeSlotSocket\n name={part.name}\n k={part.measureKey}\n orientation={orientation}\n onLength={onLength}\n >\n {terminal()}\n </NativeSlotSocket>\n );\n }\n case 'collapsed': {\n const drawn = renderCollapsed?.(part.view);\n return drawn === undefined ? (\n <DefaultCollapsed view={part.view} orientation={orientation} />\n ) : (\n drawn\n );\n }\n case 'disclosure': {\n const drawn = renderGroupTrigger?.(part.view);\n return drawn === undefined ? (\n <DefaultGroupTrigger view={part.view} orientation={orientation} />\n ) : (\n drawn\n );\n }\n }\n };\n\n const renderLiveSection = (section: LiveSection<ResolvedCommand>): React.ReactNode =>\n section.groups.map((group, i) => (\n <React.Fragment key={group.id}>\n {i > 0 &&\n (renderSeparator ? renderSeparator() : <DefaultSeparator orientation={orientation} />)}\n {group.parts.map((part) => (\n <span key={part.key} {...TOOLBAR_ITEM} style={ITEM_STYLE}>\n {renderPart(part, 'live')}\n </span>\n ))}\n </React.Fragment>\n ));\n\n /**\n * Segment layout, along the toolbar's axis. The center segment carries auto\n * margins: it balances in the leftover space (true center when the flanks\n * are symmetric) and yields when they aren't, collapsing to zero before\n * anything can overlap. The container itself has no gap — segments space\n * themselves — so the solver's global budget (sum of unit lengths +\n * per-unit gaps) is exactly the layout's minimum length: what the solver\n * says fits, fits. Its cross-segment gap allowance (≤ 2×gap) becomes slack\n * the auto margins absorb, keeping ≥ gap between segments at the floor.\n * Segments never grow or shrink: fit is the solver's job, not flexbox's.\n */\n const sectionStyle = (position: 'start' | 'center' | 'end'): React.CSSProperties => ({\n display: 'flex',\n flexDirection: vertical ? 'column' : 'row',\n alignItems: 'center',\n gap,\n flex: '0 0 auto',\n ...(position !== 'center'\n ? null\n : vertical\n ? { marginTop: 'auto', marginBottom: 'auto' }\n : { marginLeft: 'auto', marginRight: 'auto' }),\n });\n\n const overflowView: OverflowMenuView = {\n sections: layout.overflow,\n isOpen: overflowOpen,\n close: () => setOverflowOpen(false),\n resolve: resolveCmd,\n execute: executeCmd,\n };\n\n return (\n <div\n ref={containerRef}\n role=\"toolbar\"\n aria-orientation={orientation}\n aria-label={ariaLabel}\n className={className}\n style={{\n position: 'relative',\n display: 'flex',\n flexDirection: vertical ? 'column' : 'row',\n alignItems: 'center',\n ...style,\n }}\n >\n {layout.sections.map((section) => (\n <div key={section.name} style={sectionStyle(section.name)}>\n {renderLiveSection(section)}\n {section.name === 'end' && layout.hasOverflow && (\n <span {...TOOLBAR_ITEM} style={{ position: 'relative', display: 'inline-flex' }}>\n {renderOverflowTrigger(overflowOpen, () => setOverflowOpen((previous) => !previous))}\n {renderOverflowMenu ? (\n renderOverflowMenu(overflowView)\n ) : (\n <DefaultOverflowMenu view={overflowView} orientation={orientation} />\n )}\n </span>\n )}\n </div>\n ))}\n\n {/* The measurement layer: every unit in every variant, every collapsed\n group form, and the trigger — hidden, inert, observed. Text reflow\n (locale, fonts, zoom) fires the observers; no change-handling code.\n External sockets are excluded: they are live-measured, and a\n duplicate <slot> here would steal the projection from the row. */}\n <div aria-hidden {...INERT} style={measureLayerStyle(orientation)}>\n {layout.measured\n .filter((part) => !isExternalSlot(part))\n .map((part) => {\n const drawn = renderPart(part, 'measure');\n // A custom item that draws nothing here is measured where it renders, by `ctx.measure`.\n if (part.kind === 'custom' && drawn === null) return null;\n return (\n <Measured\n key={part.measureKey}\n k={part.measureKey}\n orientation={orientation}\n onLength={onLength}\n >\n {drawn}\n </Measured>\n );\n })}\n <Measured\n k={toolbarMeasureKey.overflowTrigger}\n orientation={orientation}\n onLength={onLength}\n >\n {renderOverflowTrigger(false, () => {})}\n </Measured>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAyGA,MAAM,oBACJ,MACA,WAAA,GAAA,kBAAA,gBAAA,CAC4B,MAAM,OAAOA,mCAAAA,qBAAqB;AAEhE,MAAM,kBAA6C,CAAC;;;;;;;;;;AAWpD,SAAgB,aAAa,KAA8C;CACzE,MAAM,WAAWC,gBAAAA,cAAcC,wCAAAA,aAAa;CAC5C,MAAM,aAAaC,gBAAAA,cAAc;CACjC,MAAM,cAAA,GAAA,MAAA,QAAA,OAA4B,OAAA,GAAA,kBAAA,aAAA,CAAmB,GAAG,IAAI,MAAO,CAAC,GAAG,CAAC;CACxE,MAAM,SAASC,gBAAAA,qBAEX,cAAA,GAAA,kBAAA,cAAA,CACkB,aAAa,OAAO,SAAS,eAAe,IAAI,cAAc,KAAA,CAAS,CAAC,IACtF,iBACN,gBACF;CACA,QAAA,GAAA,MAAA,QAAA,OAEI,OAAO,WAAW,IACd,OACA;EACE;EACA,UAAU,OACR,KAAK,SAAS,QAAQ,IAAI,EAAE,YAAY,cAAc,KAAA,EAAU,CAAC;CACrE,GACN;EAAC;EAAQ;EAAU;CAAU,CAC/B;AACF;;AA8DA,SAAS,SAAS,EAChB,GACA,aACA,UACA,YAMC;CACD,MAAM,OAAA,GAAA,MAAA,OAAA,CAA8B,IAAI;CACxC,CAAA,GAAA,MAAA,gBAAA,OAEI,IAAI,WAAA,GAAA,cAAA,cAAA,CACc,IAAI,SAAS,cAAc,WAAW,SAAS,GAAG,MAAM,CAAC,IACvE,KAAA,GACN;EAAC;EAAG;EAAa;CAAQ,CAC3B;CACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAAW;EAAK,OAAO;GAAE,SAAS;GAAe,YAAY;EAAE;EAC5D;CACG,CAAA;AAEV;;;;;;;;AASA,SAAS,iBAAiB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AAC,QAAQ,CAAC,GAClF,qBACC,mBAAmB,YAAY,IAE/B,iBAAA,GAAA,kBAAA,IAAA,CAAC,qBAAD;KAAqB,MAAM;KAA2B;IAAc,CAAA,CAElE;GAEL,CAAA,CAAA;EAZK,GAAA,QAAQ,IAYb,CACN,GAOD,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;GAAK,eAAA;GAAY,GAAIK,cAAAA;GAAO,OAAO,kBAAkB,WAAW;GAAhE,UAAA,CACG,OAAO,SACL,QAAQ,SAAS,CAAC,eAAe,IAAI,CAAC,CAAC,CACvC,KAAK,SAAS;IACb,MAAM,QAAQ,WAAW,MAAM,SAAS;IAExC,IAAI,KAAK,SAAS,YAAY,UAAU,MAAM,OAAO;IACrD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;KAEE,GAAG,KAAK;KACK;KACH;KAET,UAAA;IACO,GANH,KAAK,UAMF;GAEd,CAAC,GACH,iBAAA,GAAA,kBAAA,IAAA,CAAC,UAAD;IACE,GAAGD,cAAAA,kBAAkB;IACR;IACH;IAET,UAAA,sBAAsB,aAAa,CAAC,CAAC;GAC9B,CAAA,CACP;EACF,CAAA,CAAA;;AAET"}
@@ -1,100 +1,90 @@
1
1
  import * as React from "react";
2
- import { BarSchema, OverflowSection } from "@embedpdf/core-ui";
2
+ import { BarChild, BarGroup, BarItem, BarSchema, BarSchema as BarSchema$1, BarSections, CollapsedGroupView as CollapsedGroupView$1, CustomItem, CustomSlotCtx, DEFAULT_IMPORTANCE, GroupDisclosureView as GroupDisclosureView$1, Importance, OverflowMenuView as OverflowMenuView$1, OverflowRow, OverflowSection, PINNED, StripView as StripView$1, StripViewGroup as StripViewGroup$1, Variant, custom, group, item } from "@embedpdf/core-ui";
3
3
  import { ResolvedCommand } from "@embedpdf/plugin-commands/contract";
4
- export * from "@embedpdf/core-ui";
5
4
  //#region src/toolbar.d.ts
6
- interface CollapsedGroupView {
7
- readonly id: string;
8
- readonly labelKey?: string;
9
- readonly collapse: 'menu' | 'select';
10
- readonly role: 'buttons' | 'tabs';
11
- /** The group's commands (custom items via their terminal), resolved live. */
12
- readonly commands: readonly ResolvedCommand[];
13
- execute(id: string): void;
14
- }
15
- interface OverflowMenuView {
16
- readonly sections: readonly OverflowSection[];
17
- readonly isOpen: boolean;
18
- close(): void;
19
- resolve(id: string): ResolvedCommand | null;
20
- execute(id: string): void;
21
- }
5
+ /** A group folded into one control: its commands, resolved live, and how to run one. */
6
+ type CollapsedGroupView = CollapsedGroupView$1<ResolvedCommand>;
7
+ /** The "More" menu: what didn't fit, in sections, and the calls a menu needs. */
8
+ type OverflowMenuView = OverflowMenuView$1<ResolvedCommand>;
22
9
  /**
23
- * A shed group's disclosure — the derived trigger rendered INSIDE the group
24
- * (v2's overflow-tabs-button). `commands` is what sits behind the trigger:
25
- * the shed children in bar order, resolved live. In the measurement layer the
26
- * trigger is measured with the FULL group as content, so a count-dependent
27
- * trigger (e.g. a "+3" badge) is budgeted at its widest form.
10
+ * A shed group's disclosure — the derived trigger rendered inside the group.
11
+ * `commands` is what sits behind the trigger: the shed children in bar order,
12
+ * resolved live. In the measurement layer the trigger is measured with the
13
+ * full group as content, so a count-dependent trigger (e.g. a "+3" badge) is
14
+ * budgeted at its widest form.
28
15
  */
29
- interface GroupDisclosureView {
30
- readonly id: string;
31
- readonly labelKey?: string;
32
- readonly role: 'buttons' | 'tabs';
33
- readonly commands: readonly ResolvedCommand[];
34
- execute(id: string): void;
35
- }
36
- interface StripViewGroup {
37
- readonly id: string;
38
- readonly labelKey?: string;
39
- /** Visible commands, bar order. Groups are separator boundaries. */
40
- readonly commands: readonly ResolvedCommand[];
41
- }
16
+ type GroupDisclosureView = GroupDisclosureView$1<ResolvedCommand>;
17
+ /** A group of a strip: its visible commands, bar order. Groups are separator boundaries. */
18
+ type StripViewGroup = StripViewGroup$1<ResolvedCommand>;
42
19
  /** A contextual strip, resolved: only visible commands, only non-empty groups. */
43
- interface StripView {
44
- readonly groups: readonly StripViewGroup[];
45
- execute(id: string): void;
46
- }
20
+ type StripView = StripView$1<ResolvedCommand>;
47
21
  /**
48
22
  * The live projection of a bar through the command registry — <Toolbar>'s
49
- * un-measured sibling, for contextual strips (ChromeSchema.strips). The schema
50
- * declares what COULD appear; each command's `visible` derivation decides what
51
- * DOES; null means nothing currently applies, so `if (!view) return null` is
23
+ * un-measured sibling, for contextual strips (a bar over a selection). The schema
24
+ * declares what could appear; each command's `visible` derivation decides what
25
+ * does; null means nothing currently applies, so `if (!view) return null` is
52
26
  * the caller's entire show/hide logic. `execute` is pre-bound to this
53
27
  * subtree's document. Reads are value-equal (resolvedCommandsEqual), so
54
28
  * consumers re-render on real change, not on every store action.
55
29
  */
56
- declare function useStripView(bar: BarSchema | undefined): StripView | null;
30
+ declare function useStripView(bar: BarSchema$1 | undefined): StripView | null;
57
31
  interface ToolbarProps {
58
- bar: BarSchema;
32
+ bar: BarSchema$1;
33
+ /**
34
+ * Which way the toolbar runs. A vertical toolbar fits the height it's given,
35
+ * so give it one; it stacks its sections top, middle and bottom, and draws
36
+ * every command at `'icon'`, with the label for a tooltip. Default
37
+ * `'horizontal'`.
38
+ */
39
+ orientation?: 'horizontal' | 'vertical';
59
40
  /** Px between adjacent items (CSS flex gap; the solver budgets the same number). */
60
41
  gap?: number;
61
- /** Width of the separator ELEMENT your renderSeparator draws. Default 1. */
42
+ /**
43
+ * The thickness of the separator your renderSeparator draws: its width
44
+ * across a horizontal toolbar, its height in a vertical one. Default 1.
45
+ */
62
46
  separatorWidth?: number;
47
+ /** The toolbar's name for screen readers, for a page with more than one toolbar. */
48
+ 'aria-label'?: string;
63
49
  className?: string;
64
50
  style?: React.CSSProperties;
65
- /** A command button at a given variant. Default: a plain <button>. */
51
+ /** A command button at a given variant. Default: a plain <button> with the command's label. */
66
52
  renderCommand?: (cmd: ResolvedCommand, variant: string, run: () => void) => React.ReactNode;
67
53
  /**
68
- * Renderers for custom slots, per named variant. A custom unit with NO
69
- * entry here renders as a native `<slot name={slot}>` socket with its
70
- * terminal command as fallback content: in light DOM that displays the
71
- * fallback (today's behavior); inside a shadow root the host's light-DOM
72
- * children project into it — the children-as-slots contract. Sockets are
73
- * measured LIVE (they can't be duplicated into the measurement layer:
74
- * only the first same-named slot in tree order gets the projected nodes).
54
+ * Your own items, one renderer per name (from `custom(name, command)`),
55
+ * called with the variant the fit chose. A renderer that returns
56
+ * `undefined` draws the item's command instead (`renderCommand` with the
57
+ * terminal command, variant `'icon'`). An item with no entry here renders
58
+ * as a native `<slot name={slot}>` socket with that command as fallback
59
+ * content: in light DOM that displays the fallback; inside a shadow root
60
+ * the host's light-DOM children project into it — the children-as-slots
61
+ * contract. Sockets are measured live (they can't be duplicated into the
62
+ * measurement layer: only the first same-named slot in tree order gets the
63
+ * projected nodes). A renderer that draws nothing (`null`) in the
64
+ * measurement layer (`ctx.layer === 'measure'`) is measured where it
65
+ * renders instead: report its length with `ctx.measure`, a new function on
66
+ * every render (capture it in a ref to use it in an effect). The first
67
+ * element of an item that takes focus is the item's stop in the toolbar's
68
+ * arrow-key order.
75
69
  */
76
70
  renderCustom?: Record<string, (variant: string, ctx: CustomSlotCtx) => React.ReactNode>;
77
- /** A group in its collapsed form. Default: <select> for 'select', menu button for 'menu'. */
71
+ /**
72
+ * A group in its collapsed form. Default: <select> for 'select', menu button for 'menu'; a
73
+ * renderer that returns `undefined` leaves the group to the default.
74
+ */
78
75
  renderCollapsed?: (view: CollapsedGroupView) => React.ReactNode;
79
76
  /** A shed group's disclosure trigger (+ its popover — the renderer owns the
80
- * open state). Default: a chevron button opening a radio menu. */
77
+ * open state). Default: a chevron button opening a radio menu; `undefined`
78
+ * leaves it to the default too. */
81
79
  renderGroupTrigger?: (view: GroupDisclosureView) => React.ReactNode;
82
- /** Derived separator between adjacent visible groups. Default: a 1px line. */
80
+ /** Derived separator between adjacent visible groups. Default: a 1px line across the toolbar. */
83
81
  renderSeparator?: () => React.ReactNode;
82
+ /** The "More" button. Default: a plain ⋯ button. */
84
83
  renderOverflowTrigger?: (isOpen: boolean, toggle: () => void) => React.ReactNode;
85
84
  /** The derived overflow menu. Default: a minimal popover. */
86
85
  renderOverflowMenu?: (view: OverflowMenuView) => React.ReactNode;
87
86
  }
88
- /** Passed to custom-slot renderers alongside the variant. */
89
- interface CustomSlotCtx {
90
- /** 'live' = the visible row; 'measure' = the hidden measurement layer. */
91
- layer: 'live' | 'measure';
92
- /** Report this unit's width to the solver — for content the measurement
93
- * layer can't duplicate. Identity is NOT stable across renders; capture
94
- * via ref if used in an effect. */
95
- measure: (width: number) => void;
96
- }
97
- declare function Toolbar({ bar, gap, separatorWidth, className, style, renderCommand, renderCustom, renderCollapsed, renderGroupTrigger, renderSeparator, renderOverflowTrigger, renderOverflowMenu }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
87
+ declare function Toolbar({ bar, orientation, gap, separatorWidth, 'aria-label': ariaLabel, className, style, renderCommand, renderCustom, renderCollapsed, renderGroupTrigger, renderSeparator, renderOverflowTrigger, renderOverflowMenu }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
98
88
  //#endregion
99
- export { CollapsedGroupView, CustomSlotCtx, GroupDisclosureView, OverflowMenuView, StripView, StripViewGroup, Toolbar, ToolbarProps, useStripView };
89
+ export { type BarChild, type BarGroup, type BarItem, type BarSchema, type BarSections, CollapsedGroupView, type CustomItem, type CustomSlotCtx, DEFAULT_IMPORTANCE, GroupDisclosureView, type Importance, OverflowMenuView, type OverflowRow, type OverflowSection, PINNED, StripView, StripViewGroup, Toolbar, ToolbarProps, type Variant, custom, group, item, useStripView };
100
90
  //# sourceMappingURL=toolbar.d.cts.map
package/dist/toolbar.d.ts CHANGED
@@ -1,100 +1,90 @@
1
- import * as React from "react";
2
- import { BarSchema, OverflowSection } from "@embedpdf/core-ui";
1
+ import * as React$1 from "react";
2
+ import { BarChild, BarGroup, BarItem, BarSchema, BarSchema as BarSchema$1, BarSections, CollapsedGroupView as CollapsedGroupView$1, CustomItem, CustomSlotCtx, DEFAULT_IMPORTANCE, GroupDisclosureView as GroupDisclosureView$1, Importance, OverflowMenuView as OverflowMenuView$1, OverflowRow, OverflowSection, PINNED, StripView as StripView$1, StripViewGroup as StripViewGroup$1, Variant, custom, group, item } from "@embedpdf/core-ui";
3
3
  import { ResolvedCommand } from "@embedpdf/plugin-commands/contract";
4
- export * from "@embedpdf/core-ui";
5
4
  //#region src/toolbar.d.ts
6
- interface CollapsedGroupView {
7
- readonly id: string;
8
- readonly labelKey?: string;
9
- readonly collapse: 'menu' | 'select';
10
- readonly role: 'buttons' | 'tabs';
11
- /** The group's commands (custom items via their terminal), resolved live. */
12
- readonly commands: readonly ResolvedCommand[];
13
- execute(id: string): void;
14
- }
15
- interface OverflowMenuView {
16
- readonly sections: readonly OverflowSection[];
17
- readonly isOpen: boolean;
18
- close(): void;
19
- resolve(id: string): ResolvedCommand | null;
20
- execute(id: string): void;
21
- }
5
+ /** A group folded into one control: its commands, resolved live, and how to run one. */
6
+ type CollapsedGroupView = CollapsedGroupView$1<ResolvedCommand>;
7
+ /** The "More" menu: what didn't fit, in sections, and the calls a menu needs. */
8
+ type OverflowMenuView = OverflowMenuView$1<ResolvedCommand>;
22
9
  /**
23
- * A shed group's disclosure — the derived trigger rendered INSIDE the group
24
- * (v2's overflow-tabs-button). `commands` is what sits behind the trigger:
25
- * the shed children in bar order, resolved live. In the measurement layer the
26
- * trigger is measured with the FULL group as content, so a count-dependent
27
- * trigger (e.g. a "+3" badge) is budgeted at its widest form.
10
+ * A shed group's disclosure — the derived trigger rendered inside the group.
11
+ * `commands` is what sits behind the trigger: the shed children in bar order,
12
+ * resolved live. In the measurement layer the trigger is measured with the
13
+ * full group as content, so a count-dependent trigger (e.g. a "+3" badge) is
14
+ * budgeted at its widest form.
28
15
  */
29
- interface GroupDisclosureView {
30
- readonly id: string;
31
- readonly labelKey?: string;
32
- readonly role: 'buttons' | 'tabs';
33
- readonly commands: readonly ResolvedCommand[];
34
- execute(id: string): void;
35
- }
36
- interface StripViewGroup {
37
- readonly id: string;
38
- readonly labelKey?: string;
39
- /** Visible commands, bar order. Groups are separator boundaries. */
40
- readonly commands: readonly ResolvedCommand[];
41
- }
16
+ type GroupDisclosureView = GroupDisclosureView$1<ResolvedCommand>;
17
+ /** A group of a strip: its visible commands, bar order. Groups are separator boundaries. */
18
+ type StripViewGroup = StripViewGroup$1<ResolvedCommand>;
42
19
  /** A contextual strip, resolved: only visible commands, only non-empty groups. */
43
- interface StripView {
44
- readonly groups: readonly StripViewGroup[];
45
- execute(id: string): void;
46
- }
20
+ type StripView = StripView$1<ResolvedCommand>;
47
21
  /**
48
22
  * The live projection of a bar through the command registry — <Toolbar>'s
49
- * un-measured sibling, for contextual strips (ChromeSchema.strips). The schema
50
- * declares what COULD appear; each command's `visible` derivation decides what
51
- * DOES; null means nothing currently applies, so `if (!view) return null` is
23
+ * un-measured sibling, for contextual strips (a bar over a selection). The schema
24
+ * declares what could appear; each command's `visible` derivation decides what
25
+ * does; null means nothing currently applies, so `if (!view) return null` is
52
26
  * the caller's entire show/hide logic. `execute` is pre-bound to this
53
27
  * subtree's document. Reads are value-equal (resolvedCommandsEqual), so
54
28
  * consumers re-render on real change, not on every store action.
55
29
  */
56
- declare function useStripView(bar: BarSchema | undefined): StripView | null;
30
+ declare function useStripView(bar: BarSchema$1 | undefined): StripView | null;
57
31
  interface ToolbarProps {
58
- bar: BarSchema;
32
+ bar: BarSchema$1;
33
+ /**
34
+ * Which way the toolbar runs. A vertical toolbar fits the height it's given,
35
+ * so give it one; it stacks its sections top, middle and bottom, and draws
36
+ * every command at `'icon'`, with the label for a tooltip. Default
37
+ * `'horizontal'`.
38
+ */
39
+ orientation?: 'horizontal' | 'vertical';
59
40
  /** Px between adjacent items (CSS flex gap; the solver budgets the same number). */
60
41
  gap?: number;
61
- /** Width of the separator ELEMENT your renderSeparator draws. Default 1. */
42
+ /**
43
+ * The thickness of the separator your renderSeparator draws: its width
44
+ * across a horizontal toolbar, its height in a vertical one. Default 1.
45
+ */
62
46
  separatorWidth?: number;
47
+ /** The toolbar's name for screen readers, for a page with more than one toolbar. */
48
+ 'aria-label'?: string;
63
49
  className?: string;
64
- style?: React.CSSProperties;
65
- /** A command button at a given variant. Default: a plain <button>. */
66
- renderCommand?: (cmd: ResolvedCommand, variant: string, run: () => void) => React.ReactNode;
50
+ style?: React$1.CSSProperties;
51
+ /** A command button at a given variant. Default: a plain <button> with the command's label. */
52
+ renderCommand?: (cmd: ResolvedCommand, variant: string, run: () => void) => React$1.ReactNode;
67
53
  /**
68
- * Renderers for custom slots, per named variant. A custom unit with NO
69
- * entry here renders as a native `<slot name={slot}>` socket with its
70
- * terminal command as fallback content: in light DOM that displays the
71
- * fallback (today's behavior); inside a shadow root the host's light-DOM
72
- * children project into it — the children-as-slots contract. Sockets are
73
- * measured LIVE (they can't be duplicated into the measurement layer:
74
- * only the first same-named slot in tree order gets the projected nodes).
54
+ * Your own items, one renderer per name (from `custom(name, command)`),
55
+ * called with the variant the fit chose. A renderer that returns
56
+ * `undefined` draws the item's command instead (`renderCommand` with the
57
+ * terminal command, variant `'icon'`). An item with no entry here renders
58
+ * as a native `<slot name={slot}>` socket with that command as fallback
59
+ * content: in light DOM that displays the fallback; inside a shadow root
60
+ * the host's light-DOM children project into it — the children-as-slots
61
+ * contract. Sockets are measured live (they can't be duplicated into the
62
+ * measurement layer: only the first same-named slot in tree order gets the
63
+ * projected nodes). A renderer that draws nothing (`null`) in the
64
+ * measurement layer (`ctx.layer === 'measure'`) is measured where it
65
+ * renders instead: report its length with `ctx.measure`, a new function on
66
+ * every render (capture it in a ref to use it in an effect). The first
67
+ * element of an item that takes focus is the item's stop in the toolbar's
68
+ * arrow-key order.
75
69
  */
76
- renderCustom?: Record<string, (variant: string, ctx: CustomSlotCtx) => React.ReactNode>;
77
- /** A group in its collapsed form. Default: <select> for 'select', menu button for 'menu'. */
78
- renderCollapsed?: (view: CollapsedGroupView) => React.ReactNode;
70
+ renderCustom?: Record<string, (variant: string, ctx: CustomSlotCtx) => React$1.ReactNode>;
71
+ /**
72
+ * A group in its collapsed form. Default: <select> for 'select', menu button for 'menu'; a
73
+ * renderer that returns `undefined` leaves the group to the default.
74
+ */
75
+ renderCollapsed?: (view: CollapsedGroupView) => React$1.ReactNode;
79
76
  /** A shed group's disclosure trigger (+ its popover — the renderer owns the
80
- * open state). Default: a chevron button opening a radio menu. */
81
- renderGroupTrigger?: (view: GroupDisclosureView) => React.ReactNode;
82
- /** Derived separator between adjacent visible groups. Default: a 1px line. */
83
- renderSeparator?: () => React.ReactNode;
84
- renderOverflowTrigger?: (isOpen: boolean, toggle: () => void) => React.ReactNode;
77
+ * open state). Default: a chevron button opening a radio menu; `undefined`
78
+ * leaves it to the default too. */
79
+ renderGroupTrigger?: (view: GroupDisclosureView) => React$1.ReactNode;
80
+ /** Derived separator between adjacent visible groups. Default: a 1px line across the toolbar. */
81
+ renderSeparator?: () => React$1.ReactNode;
82
+ /** The "More" button. Default: a plain ⋯ button. */
83
+ renderOverflowTrigger?: (isOpen: boolean, toggle: () => void) => React$1.ReactNode;
85
84
  /** The derived overflow menu. Default: a minimal popover. */
86
- renderOverflowMenu?: (view: OverflowMenuView) => React.ReactNode;
87
- }
88
- /** Passed to custom-slot renderers alongside the variant. */
89
- interface CustomSlotCtx {
90
- /** 'live' = the visible row; 'measure' = the hidden measurement layer. */
91
- layer: 'live' | 'measure';
92
- /** Report this unit's width to the solver — for content the measurement
93
- * layer can't duplicate. Identity is NOT stable across renders; capture
94
- * via ref if used in an effect. */
95
- measure: (width: number) => void;
85
+ renderOverflowMenu?: (view: OverflowMenuView) => React$1.ReactNode;
96
86
  }
97
- declare function Toolbar({ bar, gap, separatorWidth, className, style, renderCommand, renderCustom, renderCollapsed, renderGroupTrigger, renderSeparator, renderOverflowTrigger, renderOverflowMenu }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
87
+ declare function Toolbar({ bar, orientation, gap, separatorWidth, 'aria-label': ariaLabel, className, style, renderCommand, renderCustom, renderCollapsed, renderGroupTrigger, renderSeparator, renderOverflowTrigger, renderOverflowMenu }: ToolbarProps): import("react/jsx-runtime").JSX.Element;
98
88
  //#endregion
99
- export { CollapsedGroupView, CustomSlotCtx, GroupDisclosureView, OverflowMenuView, StripView, StripViewGroup, Toolbar, ToolbarProps, useStripView };
89
+ export { type BarChild, type BarGroup, type BarItem, type BarSchema, type BarSections, CollapsedGroupView, type CustomItem, type CustomSlotCtx, DEFAULT_IMPORTANCE, GroupDisclosureView, type Importance, OverflowMenuView, type OverflowRow, type OverflowSection, PINNED, StripView, StripViewGroup, Toolbar, ToolbarProps, type Variant, custom, group, item, useStripView };
100
90
  //# sourceMappingURL=toolbar.d.ts.map