@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.
- package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.cts +877 -0
- package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.ts +877 -0
- package/dist/actions.cjs +25 -5
- package/dist/actions.cjs.map +1 -1
- package/dist/actions.d.cts +18 -5
- package/dist/actions.d.ts +18 -5
- package/dist/actions.js +22 -6
- package/dist/actions.js.map +1 -1
- package/dist/anchored-DeX95xSd.d.ts +85 -0
- package/dist/anchored-DzN3JywS.d.cts +85 -0
- package/dist/anchored.cjs +71 -28
- package/dist/anchored.cjs.map +1 -1
- package/dist/anchored.d.cts +2 -45
- package/dist/anchored.d.ts +2 -45
- package/dist/anchored.js +56 -19
- package/dist/anchored.js.map +1 -1
- package/dist/annotation-B48UT2ln.d.ts +302 -0
- package/dist/annotation-C1ttM8Wj.js +708 -0
- package/dist/annotation-C1ttM8Wj.js.map +1 -0
- package/dist/annotation-C9dVwo9b.d.cts +302 -0
- package/dist/annotation-Dex5EBda.cjs +830 -0
- package/dist/annotation-Dex5EBda.cjs.map +1 -0
- package/dist/annotation.cjs +20 -784
- package/dist/annotation.d.cts +2 -2
- package/dist/annotation.d.ts +2 -2
- package/dist/annotation.js +2 -769
- package/dist/commands.cjs +68 -28
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +37 -10
- package/dist/commands.d.ts +37 -10
- package/dist/commands.js +68 -31
- package/dist/commands.js.map +1 -1
- package/dist/form-55izw0jS.js +511 -0
- package/dist/form-55izw0jS.js.map +1 -0
- package/dist/form-BNqQfGGH.cjs +548 -0
- package/dist/form-BNqQfGGH.cjs.map +1 -0
- package/dist/form.cjs +5 -5
- package/dist/form.d.cts +41 -2
- package/dist/form.d.ts +41 -2
- package/dist/form.js +2 -3
- package/dist/history.cjs +38 -0
- package/dist/history.cjs.map +1 -0
- package/dist/history.d.cts +27 -0
- package/dist/history.d.ts +27 -0
- package/dist/history.js +27 -0
- package/dist/history.js.map +1 -0
- package/dist/i18n.cjs +26 -30
- package/dist/i18n.cjs.map +1 -1
- package/dist/i18n.d.cts +24 -21
- package/dist/i18n.d.ts +24 -21
- package/dist/i18n.js +24 -31
- package/dist/i18n.js.map +1 -1
- package/dist/index.cjs +200 -57
- package/dist/index.d.cts +31 -32
- package/dist/index.d.ts +31 -32
- package/dist/index.js +32 -30
- package/dist/inert-CmBEbKCn.cjs +19 -0
- package/dist/inert-CmBEbKCn.cjs.map +1 -0
- package/dist/inert-D8fkennb.js +14 -0
- package/dist/inert-D8fkennb.js.map +1 -0
- package/dist/interaction.cjs +48 -102
- package/dist/interaction.cjs.map +1 -1
- package/dist/interaction.d.cts +23 -32
- package/dist/interaction.d.ts +23 -32
- package/dist/interaction.js +33 -102
- package/dist/interaction.js.map +1 -1
- package/dist/link.cjs +65 -104
- package/dist/link.cjs.map +1 -1
- package/dist/link.d.cts +21 -16
- package/dist/link.d.ts +22 -17
- package/dist/link.js +67 -107
- package/dist/link.js.map +1 -1
- package/dist/measurement.cjs +36 -11
- package/dist/measurement.cjs.map +1 -1
- package/dist/measurement.d.cts +33 -7
- package/dist/measurement.d.ts +33 -7
- package/dist/measurement.js +35 -14
- package/dist/measurement.js.map +1 -1
- package/dist/metadata.cjs +20 -7
- package/dist/metadata.cjs.map +1 -1
- package/dist/metadata.d.cts +22 -7
- package/dist/metadata.d.ts +22 -7
- package/dist/metadata.js +20 -10
- package/dist/metadata.js.map +1 -1
- package/dist/page-edit.cjs +7 -3
- package/dist/page-edit.cjs.map +1 -1
- package/dist/page-edit.d.cts +6 -2
- package/dist/page-edit.d.ts +6 -2
- package/dist/page-edit.js +7 -4
- package/dist/page-edit.js.map +1 -1
- package/dist/page-layers-Bkaaz8Zf.js +26 -0
- package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
- package/dist/page-layers-BloZDoOV.cjs +37 -0
- package/dist/page-layers-BloZDoOV.cjs.map +1 -0
- package/dist/page-view.cjs +89 -82
- package/dist/page-view.cjs.map +1 -1
- package/dist/page-view.d.cts +14 -7
- package/dist/page-view.d.ts +18 -11
- package/dist/page-view.js +86 -81
- package/dist/page-view.js.map +1 -1
- package/dist/redaction.cjs +30 -15
- package/dist/redaction.cjs.map +1 -1
- package/dist/redaction.d.cts +27 -9
- package/dist/redaction.d.ts +27 -9
- package/dist/redaction.js +29 -18
- package/dist/redaction.js.map +1 -1
- package/dist/render.cjs +71 -46
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +17 -5
- package/dist/render.d.ts +17 -5
- package/dist/render.js +70 -49
- package/dist/render.js.map +1 -1
- package/dist/runtime-B6xcPsEb.js +398 -0
- package/dist/runtime-B6xcPsEb.js.map +1 -0
- package/dist/runtime-DBEBlpQV.d.cts +237 -0
- package/dist/runtime-V3MVMb91.d.ts +237 -0
- package/dist/runtime-fzpGv78v.cjs +555 -0
- package/dist/runtime-fzpGv78v.cjs.map +1 -0
- package/dist/runtime.cjs +45 -324
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +2 -306
- package/dist/search.cjs +81 -50
- package/dist/search.cjs.map +1 -1
- package/dist/search.d.cts +37 -24
- package/dist/search.d.ts +37 -24
- package/dist/search.js +81 -53
- package/dist/search.js.map +1 -1
- package/dist/selection.cjs +105 -108
- package/dist/selection.cjs.map +1 -1
- package/dist/selection.d.cts +54 -26
- package/dist/selection.d.ts +56 -28
- package/dist/selection.js +103 -110
- package/dist/selection.js.map +1 -1
- package/dist/shell.cjs +36 -21
- package/dist/shell.cjs.map +1 -1
- package/dist/shell.d.cts +32 -17
- package/dist/shell.d.ts +32 -17
- package/dist/shell.js +36 -24
- package/dist/shell.js.map +1 -1
- package/dist/signature.cjs +29 -48
- package/dist/signature.cjs.map +1 -1
- package/dist/signature.d.cts +26 -26
- package/dist/signature.d.ts +26 -26
- package/dist/signature.js +30 -48
- package/dist/signature.js.map +1 -1
- package/dist/stage-BIG6aeVd.cjs +369 -0
- package/dist/stage-BIG6aeVd.cjs.map +1 -0
- package/dist/stage-ByFPD-Fv.d.cts +117 -0
- package/dist/stage-DaboaheR.d.ts +117 -0
- package/dist/stage-DoVekb83.js +302 -0
- package/dist/stage-DoVekb83.js.map +1 -0
- package/dist/stage-scope-CQgCuf1w.cjs +46 -0
- package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
- package/dist/stage-scope-D7ZeNduT.js +23 -0
- package/dist/stage-scope-D7ZeNduT.js.map +1 -0
- package/dist/stage.cjs +12 -235
- package/dist/stage.d.cts +2 -116
- package/dist/stage.d.ts +2 -116
- package/dist/stage.js +3 -228
- package/dist/stamp.cjs +41 -35
- package/dist/stamp.cjs.map +1 -1
- package/dist/stamp.d.cts +25 -18
- package/dist/stamp.d.ts +25 -18
- package/dist/stamp.js +40 -37
- package/dist/stamp.js.map +1 -1
- package/dist/state-0K1I5cM4.d.cts +29 -0
- package/dist/state-0K1I5cM4.d.ts +29 -0
- package/dist/state-CbgxhwLA.js +62 -0
- package/dist/state-CbgxhwLA.js.map +1 -0
- package/dist/state-CsfZy_Eq.cjs +73 -0
- package/dist/state-CsfZy_Eq.cjs.map +1 -0
- package/dist/svg-shapes-Dm1yTR1b.js +40 -0
- package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
- package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
- package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
- package/dist/toolbar.cjs +297 -295
- package/dist/toolbar.cjs.map +1 -1
- package/dist/toolbar.d.cts +58 -68
- package/dist/toolbar.d.ts +67 -77
- package/dist/toolbar.js +271 -293
- package/dist/toolbar.js.map +1 -1
- package/dist/view-manager.cjs +34 -0
- package/dist/view-manager.cjs.map +1 -0
- package/dist/view-manager.d.cts +21 -0
- package/dist/view-manager.d.ts +21 -0
- package/dist/view-manager.js +23 -0
- package/dist/view-manager.js.map +1 -0
- package/package.json +37 -39
- package/dist/annotation-BCED_p9H.d.cts +0 -160
- package/dist/annotation-anchors-CetwM1g7.js +0 -15
- package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
- package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
- package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
- package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
- package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
- package/dist/annotation-hooks-Df8EmzDO.js +0 -11
- package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
- package/dist/annotation-k38KDlIZ.d.ts +0 -160
- package/dist/annotation-menu.cjs +0 -64
- package/dist/annotation-menu.cjs.map +0 -1
- package/dist/annotation-menu.d.cts +0 -33
- package/dist/annotation-menu.d.ts +0 -33
- package/dist/annotation-menu.js +0 -48
- package/dist/annotation-menu.js.map +0 -1
- package/dist/annotation.cjs.map +0 -1
- package/dist/annotation.js.map +0 -1
- package/dist/form-BVumS7up.cjs +0 -926
- package/dist/form-BVumS7up.cjs.map +0 -1
- package/dist/form-Bdjk0Z3T.d.cts +0 -537
- package/dist/form-CK3mp99m.js +0 -895
- package/dist/form-CK3mp99m.js.map +0 -1
- package/dist/form-CYRYgthn.d.ts +0 -537
- package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
- package/dist/runtime-DE76hlnl.d.ts +0 -216
- package/dist/runtime-umHA_xHt.d.cts +0 -216
- package/dist/runtime.cjs.map +0 -1
- package/dist/runtime.js.map +0 -1
- package/dist/scrollbar.cjs +0 -241
- package/dist/scrollbar.cjs.map +0 -1
- package/dist/scrollbar.d.cts +0 -42
- package/dist/scrollbar.d.ts +0 -42
- package/dist/scrollbar.js +0 -213
- package/dist/scrollbar.js.map +0 -1
- package/dist/stage.cjs.map +0 -1
- package/dist/stage.js.map +0 -1
- package/dist/views.cjs +0 -35
- package/dist/views.cjs.map +0 -1
- package/dist/views.d.cts +0 -21
- package/dist/views.d.ts +0 -21
- package/dist/views.js +0 -27
- 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-fzpGv78v.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 = (
|
|
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 (
|
|
15
|
-
* declares what
|
|
16
|
-
*
|
|
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(
|
|
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
|
|
49
|
-
function Measured({ k,
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
74
|
-
* so its
|
|
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,
|
|
62
|
+
function NativeSlotSocket({ name, k, orientation, onLength, children }) {
|
|
77
63
|
const ref = (0, react.useRef)(null);
|
|
78
|
-
(0, react.useLayoutEffect)(() =>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
123
|
-
|
|
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:
|
|
129
|
+
children: cmd.label
|
|
129
130
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
150
|
+
color: "inherit",
|
|
151
|
+
font: "inherit",
|
|
152
|
+
border: `1px solid ${BORDER}`,
|
|
147
153
|
borderRadius: 4,
|
|
148
|
-
background: isOpen ?
|
|
154
|
+
background: isOpen ? ACTIVE : "transparent",
|
|
149
155
|
cursor: "pointer"
|
|
150
156
|
},
|
|
151
157
|
children: "⋯"
|
|
152
158
|
});
|
|
153
|
-
|
|
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.
|
|
156
|
-
|
|
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
|
-
|
|
167
|
-
top: "100%",
|
|
196
|
+
...menuPlacement(orientation),
|
|
168
197
|
zIndex: 41,
|
|
169
198
|
minWidth: 200,
|
|
170
199
|
padding: 4,
|
|
171
|
-
background:
|
|
172
|
-
border:
|
|
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:
|
|
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((
|
|
214
|
-
onChange: (
|
|
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
|
-
|
|
249
|
+
font: "inherit",
|
|
250
|
+
borderRadius: 4,
|
|
251
|
+
border: `1px solid ${BORDER}`,
|
|
252
|
+
background: SURFACE
|
|
218
253
|
},
|
|
219
|
-
children: view.commands.map((
|
|
220
|
-
value:
|
|
221
|
-
disabled: !
|
|
222
|
-
children:
|
|
223
|
-
},
|
|
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((
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
|
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((
|
|
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((
|
|
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
|
-
|
|
298
|
+
color: "inherit",
|
|
299
|
+
font: "inherit",
|
|
300
|
+
border: `1px solid ${BORDER}`,
|
|
280
301
|
borderRadius: 4,
|
|
281
|
-
background: isOpen || someActive ?
|
|
302
|
+
background: isOpen || someActive ? ACTIVE : "transparent",
|
|
282
303
|
cursor: "pointer"
|
|
283
304
|
},
|
|
284
305
|
children: "▾"
|
|
285
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultOverflowMenu, {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
-
|
|
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(
|
|
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 [
|
|
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
|
|
308
|
-
if (!
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const
|
|
318
|
-
const
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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 (!
|
|
341
|
-
}, [
|
|
342
|
-
/** External = custom
|
|
343
|
-
* live-measured (it must
|
|
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 = (
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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:
|
|
359
|
-
k:
|
|
360
|
-
|
|
361
|
-
|
|
375
|
+
name: part.name,
|
|
376
|
+
k: part.measureKey,
|
|
377
|
+
orientation,
|
|
378
|
+
onLength,
|
|
379
|
+
children: terminal()
|
|
362
380
|
});
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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
|
|
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
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
* per-unit gaps) is exactly the layout's minimum
|
|
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
|
|
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
|
|
420
|
+
...position !== "center" ? null : vertical ? {
|
|
421
|
+
marginTop: "auto",
|
|
422
|
+
marginBottom: "auto"
|
|
423
|
+
} : {
|
|
436
424
|
marginLeft: "auto",
|
|
437
425
|
marginRight: "auto"
|
|
438
|
-
}
|
|
426
|
+
}
|
|
439
427
|
});
|
|
440
428
|
const overflowView = {
|
|
441
|
-
sections:
|
|
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
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
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
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
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
|