@sheetxl/react 0.8.0-beta.1 → 0.8.0-beta.10
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/browser/esm/BHjeSMaycUkS5dVL.mjs +66 -0
- package/browser/esm/BZcQ-KYwS62Ut45c.mjs +20 -0
- package/browser/esm/Bow9CzRJrYxak2i5.mjs +318 -0
- package/browser/esm/BuvXl14hs-1CvjeA.mjs +2706 -0
- package/browser/esm/BwRduT8FTrk5n72r.mjs +32 -0
- package/browser/esm/C6urN77szrYwODXF.mjs +134 -0
- package/browser/esm/CYMRbtPIr6SklGpp.mjs +775 -0
- package/browser/esm/CYoUd5KIl7W3AsxH.mjs +196 -0
- package/browser/esm/Cfe0kofqVKGxLqO6.mjs +31 -0
- package/browser/esm/CiRN-woJZWYOgTn4.mjs +36 -0
- package/browser/esm/Dd-ZybXAgoq9pgGv.mjs +45 -0
- package/browser/esm/DjiBz4H74I6nPUY6.mjs +79 -0
- package/browser/esm/DyU9UInRnfkPYYlR.mjs +63 -0
- package/browser/esm/J8cPagZBeXz86Lnd.mjs +777 -0
- package/browser/esm/Sp6PJavGKpF8SJzA.mjs +75 -0
- package/browser/esm/cYjYjqEsyd63x8t4.mjs +67 -0
- package/browser/esm/chart.mjs +60 -0
- package/browser/esm/control.mjs +216 -0
- package/browser/esm/group.mjs +123 -0
- package/browser/esm/index.mjs +14070 -9138
- package/browser/esm/note.mjs +86 -0
- package/browser/esm/picture.mjs +86 -0
- package/{node/esm/DAE_NG8D9uT50zUH.mjs → browser/esm/shape.mjs} +2 -4
- package/browser/esm/slicer.mjs +276 -0
- package/licenses/dependencies.txt +6 -599
- package/node/esm/BJ7ZZm63j5O6cvrB.mjs +134 -0
- package/node/esm/BfRn5S5V4X8xIAEa.mjs +20 -0
- package/node/esm/BpwE3HqTnrLLzE3C.mjs +775 -0
- package/node/esm/Buw-VKYJy3y5dbaJ.mjs +197 -0
- package/node/esm/CFFlJxNwgyInjEnh.mjs +45 -0
- package/node/esm/CM5BT7h-hMtST2bE.mjs +2706 -0
- package/node/esm/CV3bT3Hql74GcHoU.mjs +37 -0
- package/node/esm/C_ANM4feA1xV-pri.mjs +32 -0
- package/node/esm/D3YXHeOyFp00Xk3m.mjs +323 -0
- package/node/esm/DPN0n6MGYQ9vZ2KO.mjs +80 -0
- package/node/esm/DYosMUJKp-3MSO4q.mjs +76 -0
- package/node/esm/DhSq680c5tgMFFbj.mjs +68 -0
- package/node/esm/Dxbm6ryIDCEi26RO.mjs +66 -0
- package/node/esm/GkmuxU7OwRZtm2Rf.mjs +63 -0
- package/node/esm/chart.mjs +60 -0
- package/node/esm/control.mjs +216 -0
- package/node/esm/group.mjs +123 -0
- package/node/esm/index.mjs +16618 -11534
- package/node/esm/note.mjs +87 -0
- package/node/esm/picture.mjs +86 -0
- package/node/esm/shape.mjs +783 -0
- package/node/esm/slicer.mjs +278 -0
- package/package.json +53 -14
- package/resources/contents.json +18 -0
- package/resources/locales/contents.json +42 -0
- package/resources/locales/de/movable.cmd.json +154 -0
- package/resources/locales/de/picture.cmd.json +31 -0
- package/resources/locales/de/selection.cmd.json +8 -0
- package/resources/locales/de/shape.cmd.json +17 -0
- package/resources/locales/de/sheet.cmd.json +328 -21
- package/resources/locales/de/slicer.cmd.json +17 -0
- package/resources/locales/de/table.cmd.json +9 -1
- package/resources/locales/de/ui.msg.json +309 -3
- package/resources/locales/de/workbook.cmd.json +10 -6
- package/resources/locales/en/movable.cmd.json +154 -0
- package/resources/locales/en/picture.cmd.json +31 -0
- package/resources/locales/en/selection.cmd.json +8 -0
- package/resources/locales/en/shape.cmd.json +17 -0
- package/resources/locales/en/sheet.cmd.json +342 -22
- package/resources/locales/en/slicer.cmd.json +17 -0
- package/resources/locales/en/table.cmd.json +9 -1
- package/resources/locales/en/ui.msg.json +309 -3
- package/resources/locales/en/workbook.cmd.json +11 -7
- package/types/chart.d.ts +2 -0
- package/types/control.d.ts +2 -0
- package/types/group.d.ts +2 -0
- package/types/note.d.ts +2 -0
- package/types/picture.d.ts +2 -0
- package/types/shape.d.ts +2 -0
- package/types/slicer.d.ts +2 -0
- package/types/src/annotation/RangeAnnotations.d.ts +119 -0
- package/types/src/annotation/index.d.ts +2 -0
- package/types/src/autoFill/AutoFillPresets.d.ts +14 -0
- package/types/src/autoFill/FillMenu.d.ts +36 -0
- package/types/src/autoFill/FillSeries.d.ts +38 -0
- package/types/src/autoFill/index.d.ts +4 -0
- package/types/src/border/StaticBorderRenderer.d.ts +2 -2
- package/types/src/border/useBorders.d.ts +7 -7
- package/types/src/cell/CornerTriangle.d.ts +6 -0
- package/types/src/cell/FormulaCellRenderer.d.ts +1 -1
- package/types/src/cell/OutlineButton.d.ts +123 -0
- package/types/src/cell/SheetCellRenderer.d.ts +2 -2
- package/types/src/cell/SheetHeaderRenderer.d.ts +5 -0
- package/types/src/cell/StaticCellRenderer.d.ts +57 -0
- package/types/src/cell/index.d.ts +2 -0
- package/types/src/cell/useFormulaViewAnchor.d.ts +1 -1
- package/types/src/chart/index.d.ts +0 -1
- package/types/src/checklist/ValueChecklist.d.ts +112 -0
- package/types/src/checklist/index.d.ts +2 -0
- package/types/src/commands/ContextualToolbar.d.ts +19 -0
- package/types/src/commands/createTransactionalMiddleware.d.ts +4 -1
- package/types/src/commands/index.d.ts +1 -0
- package/types/src/comment/CommentCardRequest.d.ts +94 -0
- package/types/src/comment/CommentUtils.d.ts +43 -0
- package/types/src/comment/NoteEditor.d.ts +20 -0
- package/types/src/comment/index.d.ts +5 -0
- package/types/src/comment/useCommentThread.d.ts +37 -0
- package/types/src/comment/useSheetComments.d.ts +28 -0
- package/types/src/{sheet → conditionalFormat}/ConditionalFormatPresets.d.ts +6 -6
- package/types/src/conditionalFormat/index.d.ts +1 -0
- package/types/src/control/FormControlRenderers.d.ts +22 -0
- package/types/src/editor/FunctionPreviewPanel.d.ts +15 -1
- package/types/src/editor/NamedItemLabel.d.ts +29 -0
- package/types/src/editor/NamedItemsPanel.d.ts +13 -2
- package/types/src/editor/SheetCellEditorLayer.d.ts +3 -7
- package/types/src/editor/SheetCellEditorStartLayer.d.ts +44 -0
- package/types/src/editor/SheetCellInput.d.ts +26 -2
- package/types/src/editor/SheetEditable.d.ts +8 -2
- package/types/src/editor/formulaCaret.d.ts +39 -10
- package/types/src/editor/formulaEval.d.ts +9 -5
- package/types/src/editor/formulaLint.d.ts +36 -0
- package/types/src/editor/formulaPresentation.d.ts +7 -0
- package/types/src/editor/formulaText.d.ts +17 -5
- package/types/src/editor/functionArgs.d.ts +20 -0
- package/types/src/editor/index.d.ts +4 -1
- package/types/src/editor/pickedReference.d.ts +76 -0
- package/types/src/editor/useEditRejectedNotice.d.ts +32 -0
- package/types/src/editor/useFormulaHints.d.ts +93 -3
- package/types/src/editor/useFormulaInput.d.ts +30 -4
- package/types/src/editor/useReferenceMode.d.ts +12 -0
- package/types/src/editor/validationAlert.d.ts +24 -0
- package/types/src/externalLink/ExternalLinksPaneArgs.d.ts +23 -0
- package/types/src/externalLink/index.d.ts +2 -0
- package/types/src/form/FormulaInput.d.ts +18 -2
- package/types/src/form/FormulaInputParts.d.ts +10 -1
- package/types/src/form/useEditCommit.d.ts +23 -3
- package/types/src/form/useInputField.d.ts +2 -3
- package/types/src/frame/CommandContext.d.ts +188 -6
- package/types/src/group/GroupEditor.d.ts +25 -0
- package/types/src/index.d.ts +12 -2
- package/types/src/io/WorkbookIO.d.ts +2 -0
- package/types/src/layer/CellErrorLayer.d.ts +24 -7
- package/types/src/layer/CommentCardLayer.d.ts +43 -0
- package/types/src/layer/CommentsLayer.d.ts +35 -0
- package/types/src/layer/ConditionalIcons.d.ts +4 -4
- package/types/src/layer/FreezeDragLines.d.ts +17 -0
- package/types/src/layer/GridFreezeLayer.d.ts +11 -0
- package/types/src/layer/HeaderFreezeLayer.d.ts +12 -0
- package/types/src/layer/HeaderResizerLayer.d.ts +2 -1
- package/types/src/layer/HyperlinkLayer.d.ts +109 -0
- package/types/src/layer/MovableKindScope.d.ts +17 -0
- package/types/src/layer/ProtectionLayer.d.ts +52 -0
- package/types/src/layer/RangeAnnotationLayer.d.ts +71 -0
- package/types/src/layer/ResizeIndicator.d.ts +9 -8
- package/types/src/layer/ResizeTooltip.d.ts +13 -0
- package/types/src/layer/SheetHeaderCellLayer.d.ts +10 -1
- package/types/src/layer/SheetOutlineLayer.d.ts +40 -0
- package/types/src/layer/TableLayer.d.ts +5 -4
- package/types/src/layer/TableToolbar.d.ts +42 -0
- package/types/src/layer/ValidationDropdownLayer.d.ts +15 -5
- package/types/src/layer/ValidationIndicatorLayer.d.ts +9 -3
- package/types/src/layer/ValidationPromptLayer.d.ts +64 -0
- package/types/src/layer/_tableColor.d.ts +4 -0
- package/types/src/layer/cellTip.d.ts +13 -0
- package/types/src/layer/freezeDragState.d.ts +21 -0
- package/types/src/layer/index.d.ts +12 -1
- package/types/src/layer/resizeIndicatorState.d.ts +3 -1
- package/types/src/layer/useFreezeDrag.d.ts +22 -0
- package/types/src/layer/useValidationPicker.d.ts +35 -35
- package/types/src/layer/validationMark.d.ts +63 -0
- package/types/src/listener/useModelListener.d.ts +4 -4
- package/types/src/movable/ConnectionSites.d.ts +18 -0
- package/types/src/movable/IMovableArea.d.ts +56 -0
- package/types/src/movable/MovableAdornment.d.ts +26 -0
- package/types/src/movable/MovableCommandGroups.d.ts +40 -0
- package/types/src/movable/MovableCommands.d.ts +6 -1
- package/types/src/movable/MovableControl.d.ts +78 -0
- package/types/src/movable/MovableEdit.d.ts +22 -0
- package/types/src/movable/MovableFrame.d.ts +16 -13
- package/types/src/movable/MovableLayer.d.ts +25 -7
- package/types/src/movable/MovableRenderers.d.ts +210 -0
- package/types/src/movable/PlaceholderFrames.d.ts +11 -0
- package/types/src/movable/RotateHandle.d.ts +37 -0
- package/types/src/movable/TextBox.d.ts +34 -0
- package/types/src/movable/connect.d.ts +16 -0
- package/types/src/movable/framePlacement.d.ts +72 -0
- package/types/src/movable/geometry.d.ts +61 -0
- package/types/src/movable/index.d.ts +10 -0
- package/types/src/movable/pressTarget.d.ts +20 -0
- package/types/src/picker/PickerPanel.d.ts +52 -0
- package/types/src/picker/cellPickerOpen.d.ts +6 -0
- package/types/src/picker/index.d.ts +4 -0
- package/types/src/picker/useCellPicker.d.ts +95 -0
- package/types/src/picture/PictureCommands.d.ts +12 -0
- package/types/src/picture/PictureKind.d.ts +7 -0
- package/types/src/picture/index.d.ts +0 -1
- package/types/src/protection/ProtectionPaneArgs.d.ts +31 -0
- package/types/src/protection/index.d.ts +3 -0
- package/types/src/protection/unlockProtectedRanges.d.ts +23 -0
- package/types/src/richText/RichTextEditor.d.ts +41 -0
- package/types/src/richText/index.d.ts +2 -0
- package/types/src/selection/SheetSelectionLayer.d.ts +14 -10
- package/types/src/shape/ConnectorControl.d.ts +46 -0
- package/types/src/shape/ShapeCommands.d.ts +11 -0
- package/types/src/shape/ShapeControl.d.ts +8 -0
- package/types/src/shape/ShapeEditor.d.ts +15 -2
- package/types/src/shape/ShapeGallery.d.ts +31 -0
- package/types/src/shape/ShapeHandles.d.ts +28 -0
- package/types/src/shape/ShapeKind.d.ts +7 -0
- package/types/src/shape/ShapeSVG.d.ts +22 -0
- package/types/src/shape/ShapeText.d.ts +17 -0
- package/types/src/shape/icons/ShapeIcons.d.ts +16 -0
- package/types/src/shape/icons/_ShapeIconPack.d.ts +4 -0
- package/types/src/shape/index.d.ts +3 -1
- package/types/src/shape/shapeFrame.d.ts +50 -0
- package/types/src/shape/shapeStyle.d.ts +82 -0
- package/types/src/sheet/ISheetElement.d.ts +62 -65
- package/types/src/sheet/SheetCommandProvider.d.ts +9 -4
- package/types/src/sheet/SheetCommands.d.ts +21 -6
- package/types/src/sheet/SheetOutlineElement.d.ts +70 -0
- package/types/src/sheet/SheetScrollbar.d.ts +1 -10
- package/types/src/sheet/_freezeAt.d.ts +10 -0
- package/types/src/sheet/_useHeaderMetrics.d.ts +11 -0
- package/types/src/sheet/circularReferences.d.ts +9 -1
- package/types/src/sheet/index.d.ts +1 -1
- package/types/src/sheet/useCycleHighlight.d.ts +21 -0
- package/types/src/slicer/SlicerCommands.d.ts +10 -0
- package/types/src/slicer/SlicerEditor.d.ts +8 -2
- package/types/src/slicer/SlicerKind.d.ts +7 -0
- package/types/src/slicer/SlicerStylePreview.d.ts +18 -0
- package/types/src/slicer/index.d.ts +2 -1
- package/types/src/slicer/slicerStyles.d.ts +32 -0
- package/types/src/tabStrip/TabStrip.d.ts +7 -0
- package/types/src/taskPane/ITaskPane.d.ts +12 -1
- package/types/src/taskPane/MovablePane.d.ts +17 -0
- package/types/src/taskPane/index.d.ts +1 -0
- package/types/src/theme/ThemeState.d.ts +14 -1
- package/types/src/theme/useGridColorScheme.d.ts +1 -1
- package/types/src/workbook/DefaultMovableRenderers.d.ts +20 -0
- package/types/src/workbook/IWorkbookElement.d.ts +24 -0
- package/types/src/workbook/WorkbookCommands.d.ts +2 -4
- package/types/src/workbook/WorkbookStrip.d.ts +9 -0
- package/types/src/workbook/_followOrigin.d.ts +9 -0
- package/types/src/workbook/useWorkbookFormat.d.ts +3 -3
- package/browser/cjs/Bo9Kx3L_XQkGPBJ5.cjs +0 -1
- package/browser/cjs/Pl04-kDEQSO8_qFU.cjs +0 -156
- package/browser/cjs/index.cjs +0 -35
- package/browser/esm/SJMJzBwlXTJ9QIO5.mjs +0 -6286
- package/types/src/editor/useProtectedEditNotice.d.ts +0 -14
- package/types/src/layer/validationList.d.ts +0 -84
- package/types/src/list/SheetValueList.d.ts +0 -93
- package/types/src/list/index.d.ts +0 -2
- package/types/src/movable/MoveableBundle.d.ts +0 -4
|
@@ -0,0 +1,783 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license @sheetxl/react - React - React components needed to build advanced grid and spreadsheet UIs. - v0.8.0-beta.10
|
|
3
|
+
*
|
|
4
|
+
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
|
+
* License: The license can be found at https://www.sheetxl.com/license.
|
|
6
|
+
*/
|
|
7
|
+
import { t as e } from "./CFFlJxNwgyInjEnh.mjs";
|
|
8
|
+
import { n as t } from "./BfRn5S5V4X8xIAEa.mjs";
|
|
9
|
+
import { t as n } from "./GkmuxU7OwRZtm2Rf.mjs";
|
|
10
|
+
import { t as r } from "./BJ7ZZm63j5O6cvrB.mjs";
|
|
11
|
+
import { Color as o, IFill as s, IGeometry as i, IStroke as l, ShapeStyleUtils as a } from "@sheetxl/sdk";
|
|
12
|
+
import { forwardRef as h, memo as c, useCallback as u, useEffect as p, useId as d, useMemo as f, useReducer as m, useRef as y, useState as g } from "react";
|
|
13
|
+
import { Fragment as x, jsx as v, jsxs as b } from "react/jsx-runtime";
|
|
14
|
+
import { BufferUtils as k, messageKey as M } from "@sheetxl/utils";
|
|
15
|
+
import { ReactUtils as S, useImperativeElement as w } from "@sheetxl/utils-react";
|
|
16
|
+
import { useSurfaceState as D } from "@sheetxl/grid-react";
|
|
17
|
+
import { createPortal as T } from "react-dom";
|
|
18
|
+
var $ = 96 / 72, C = (e, t) => {
|
|
19
|
+
if ("string" != typeof e || !e) return null;
|
|
20
|
+
try {
|
|
21
|
+
return (t ? t.parseColor(e) : new o(e))?.toCSS("adaptive") ?? null;
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}, P = (e, t) => {
|
|
26
|
+
if (!e) return null;
|
|
27
|
+
switch (e.type) {
|
|
28
|
+
case s.Type.None: return null;
|
|
29
|
+
case s.Type.Solid: return C(e.color, t);
|
|
30
|
+
case s.Type.Gradient: {
|
|
31
|
+
const n = e.stops?.[0];
|
|
32
|
+
return C("string" == typeof n ? n : n?.color, t);
|
|
33
|
+
}
|
|
34
|
+
case s.Type.Pattern: return C(e.foreground ?? e.background, t);
|
|
35
|
+
case s.Type.Image:
|
|
36
|
+
default: return null;
|
|
37
|
+
}
|
|
38
|
+
}, j = {
|
|
39
|
+
[l.DashStyle.Solid]: null,
|
|
40
|
+
[l.DashStyle.Dot]: [1, 3],
|
|
41
|
+
[l.DashStyle.Dash]: [4, 3],
|
|
42
|
+
[l.DashStyle.DashDot]: [
|
|
43
|
+
4,
|
|
44
|
+
3,
|
|
45
|
+
1,
|
|
46
|
+
3
|
|
47
|
+
],
|
|
48
|
+
[l.DashStyle.LongDash]: [8, 3],
|
|
49
|
+
[l.DashStyle.LongDashDot]: [
|
|
50
|
+
8,
|
|
51
|
+
3,
|
|
52
|
+
1,
|
|
53
|
+
3
|
|
54
|
+
],
|
|
55
|
+
[l.DashStyle.LongDashDotDot]: [
|
|
56
|
+
8,
|
|
57
|
+
3,
|
|
58
|
+
1,
|
|
59
|
+
3,
|
|
60
|
+
1,
|
|
61
|
+
3
|
|
62
|
+
],
|
|
63
|
+
[l.DashStyle.SysDot]: [1, 1],
|
|
64
|
+
[l.DashStyle.SysDash]: [3, 1],
|
|
65
|
+
[l.DashStyle.SysDashDot]: [
|
|
66
|
+
3,
|
|
67
|
+
1,
|
|
68
|
+
1,
|
|
69
|
+
1
|
|
70
|
+
],
|
|
71
|
+
[l.DashStyle.SysDashDotDot]: [
|
|
72
|
+
3,
|
|
73
|
+
1,
|
|
74
|
+
1,
|
|
75
|
+
1,
|
|
76
|
+
1,
|
|
77
|
+
1
|
|
78
|
+
]
|
|
79
|
+
}, L = (e) => {
|
|
80
|
+
if (Array.isArray(e)) {
|
|
81
|
+
const t = e.map((e) => Math.max(0, e) / 100);
|
|
82
|
+
return t.length > 0 && t.some((e) => e > 0) ? t : null;
|
|
83
|
+
}
|
|
84
|
+
return (e && j[e]) ?? null;
|
|
85
|
+
}, N = (e) => Math.max(0, Math.min(1, e ?? 0)), E = (e, t) => {
|
|
86
|
+
const n = e.stops ?? [];
|
|
87
|
+
if (n.length < 2) return null;
|
|
88
|
+
const r = n.length - 1, o = [];
|
|
89
|
+
for (let e = 0; e < n.length; e++) {
|
|
90
|
+
const s = n[e], i = C("string" == typeof s ? s : s?.color, t);
|
|
91
|
+
if (!i) return null;
|
|
92
|
+
const l = "object" == typeof s && "number" == typeof s.offset ? s.offset : e / r;
|
|
93
|
+
o.push({
|
|
94
|
+
offset: N(l),
|
|
95
|
+
color: i
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
if (o.sort((e, t) => e.offset - t.offset), (e.gradientType ?? s.GradientType.Linear) === s.GradientType.Linear) return {
|
|
99
|
+
kind: "linear",
|
|
100
|
+
angle: (((e.angle ?? 0) - 90) % 360 + 360) % 360,
|
|
101
|
+
scaled: e.scaled ?? !0,
|
|
102
|
+
stops: o
|
|
103
|
+
};
|
|
104
|
+
const i = e.focus, l = N(i?.left), a = N(i?.top), h = N(i?.right), c = N(i?.bottom);
|
|
105
|
+
if (l > h || a > c) return null;
|
|
106
|
+
const u = (l + h) / 2, p = (a + c) / 2, d = Math.max(u, 1 - u), f = Math.max(p, 1 - p);
|
|
107
|
+
return {
|
|
108
|
+
kind: "radial",
|
|
109
|
+
cx: u,
|
|
110
|
+
cy: p,
|
|
111
|
+
r: Math.hypot(d, f),
|
|
112
|
+
stops: o
|
|
113
|
+
};
|
|
114
|
+
}, A = a.inheritedGroupFill, z = /[MLQCAZ]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g, I = {
|
|
115
|
+
M: 1,
|
|
116
|
+
L: 1,
|
|
117
|
+
Q: 2,
|
|
118
|
+
C: 3,
|
|
119
|
+
A: 1,
|
|
120
|
+
Z: 0
|
|
121
|
+
}, G = (e) => String(Math.round(1e5 * e) / 1e5), F = (e) => {
|
|
122
|
+
const t = e.match(z) ?? [], n = [], r = [], o = [];
|
|
123
|
+
let s = {
|
|
124
|
+
x: 0,
|
|
125
|
+
y: 0
|
|
126
|
+
}, i = null, l = 0, a = null;
|
|
127
|
+
for (; l < t.length;) {
|
|
128
|
+
const e = t[l];
|
|
129
|
+
if (void 0 !== I[e]) a = e, l++;
|
|
130
|
+
else if ("M" === a) a = "L";
|
|
131
|
+
else if (null === a || "Z" === a) break;
|
|
132
|
+
if ("Z" === a) {
|
|
133
|
+
i && (r.push({
|
|
134
|
+
from: s,
|
|
135
|
+
to: i
|
|
136
|
+
}), o.push(s), n.push({
|
|
137
|
+
c: a,
|
|
138
|
+
pts: []
|
|
139
|
+
}), s = i, i = null);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const h = "A" === a ? t.slice(l, l + 5) : void 0;
|
|
143
|
+
h && (l += 5);
|
|
144
|
+
const c = [];
|
|
145
|
+
for (let e = 0; e < I[a]; e++) c.push({
|
|
146
|
+
x: Number(t[l++]),
|
|
147
|
+
y: Number(t[l++])
|
|
148
|
+
});
|
|
149
|
+
const u = c[c.length - 1];
|
|
150
|
+
if (!u || Number.isNaN(u.x) || Number.isNaN(u.y)) break;
|
|
151
|
+
"M" === a ? (i && o.push(s), i = u, o.push(u)) : ("L" === a && r.push({
|
|
152
|
+
from: s,
|
|
153
|
+
to: u
|
|
154
|
+
}), i || (i = s, o.push(s))), n.push({
|
|
155
|
+
c: a,
|
|
156
|
+
pts: c,
|
|
157
|
+
arc: h
|
|
158
|
+
}), s = u;
|
|
159
|
+
}
|
|
160
|
+
return i && o.push(s), {
|
|
161
|
+
cmds: n,
|
|
162
|
+
straight: r,
|
|
163
|
+
ends: o
|
|
164
|
+
};
|
|
165
|
+
}, R = (e) => {
|
|
166
|
+
const t = [];
|
|
167
|
+
for (const n of e) {
|
|
168
|
+
const e = n.pts.map((e) => `${G(e.x)} ${G(e.y)}`).join(" ");
|
|
169
|
+
t.push("Z" === n.c ? "Z" : `${n.c}${n.arc ? `${n.arc.join(" ")} ` : ""}${e}`);
|
|
170
|
+
}
|
|
171
|
+
return t.join(" ");
|
|
172
|
+
}, H = 1e-6, W = (e, t, n, r, o) => {
|
|
173
|
+
const s = r ? (o - e) * t.zoom : e * t.zoom, i = S.snapLineCenter(s, n, t.dpr);
|
|
174
|
+
return r ? o - i / t.zoom : i / t.zoom;
|
|
175
|
+
}, B = (e, t, n) => {
|
|
176
|
+
const r = F(e), o = r.ends.map((e) => ({
|
|
177
|
+
x: e.x,
|
|
178
|
+
y: e.y
|
|
179
|
+
})), s = n * t.zoom, i = [];
|
|
180
|
+
for (const e of r.straight) {
|
|
181
|
+
const t = Math.abs(e.to.y - e.from.y) < H;
|
|
182
|
+
t !== Math.abs(e.to.x - e.from.x) < H && i.push({
|
|
183
|
+
seg: e,
|
|
184
|
+
level: t,
|
|
185
|
+
at: t ? e.from.y : e.from.x
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
for (const { seg: e, level: n, at: r } of i) n ? e.from.y = e.to.y = W(r, t, s, t.flipV, t.height) : e.from.x = e.to.x = W(r, t, s, t.flipH, t.width);
|
|
189
|
+
const l = [];
|
|
190
|
+
return r.ends.forEach((e, t) => {
|
|
191
|
+
const n = {
|
|
192
|
+
x: e.x - o[t].x,
|
|
193
|
+
y: e.y - o[t].y
|
|
194
|
+
};
|
|
195
|
+
0 === n.x && 0 === n.y || l.push({
|
|
196
|
+
at: o[t],
|
|
197
|
+
by: n
|
|
198
|
+
});
|
|
199
|
+
}), {
|
|
200
|
+
d: R(r.cmds),
|
|
201
|
+
ends: l
|
|
202
|
+
};
|
|
203
|
+
}, O = (e, t) => {
|
|
204
|
+
if (0 === t.length) return e;
|
|
205
|
+
const n = F(e);
|
|
206
|
+
let r = [], o = null;
|
|
207
|
+
const s = /* @__PURE__ */ new Set(), i = () => {
|
|
208
|
+
if (!o) return;
|
|
209
|
+
let e = null, n = 1 / 0;
|
|
210
|
+
for (const r of t) {
|
|
211
|
+
const t = Math.hypot(r.at.x - o.x, r.at.y - o.y);
|
|
212
|
+
t < n && (e = r, n = t);
|
|
213
|
+
}
|
|
214
|
+
for (const t of r) s.has(t) || (s.add(t), t.x += e.by.x, t.y += e.by.y);
|
|
215
|
+
r = [], o = null;
|
|
216
|
+
};
|
|
217
|
+
for (const e of n.cmds) {
|
|
218
|
+
"M" === e.c && (i(), o = e.pts[0]);
|
|
219
|
+
for (const t of e.pts) r.push(t);
|
|
220
|
+
}
|
|
221
|
+
return i(), R(n.cmds);
|
|
222
|
+
}, U = /* @__PURE__ */ new WeakMap(), Z = (e) => {
|
|
223
|
+
const [t, n] = g(null);
|
|
224
|
+
return p(() => {
|
|
225
|
+
if (!e) return;
|
|
226
|
+
let t = !0;
|
|
227
|
+
return ((e) => {
|
|
228
|
+
let t = U.get(e);
|
|
229
|
+
return t || (t = (async () => {
|
|
230
|
+
const t = await e.getExternalURI();
|
|
231
|
+
if (t) return t;
|
|
232
|
+
const [n, r] = await Promise.all([e.toBuffer(), e.getType()]);
|
|
233
|
+
return `data:${r?.mime ?? "image/png"};base64,${k.arrayBufferToBase64(n)}`;
|
|
234
|
+
})(), U.set(e, t)), t;
|
|
235
|
+
})(e).then((r) => {
|
|
236
|
+
t && n({
|
|
237
|
+
resource: e,
|
|
238
|
+
url: r
|
|
239
|
+
});
|
|
240
|
+
}, () => {}), () => {
|
|
241
|
+
t = !1;
|
|
242
|
+
};
|
|
243
|
+
}, [e]), e && t?.resource === e ? t.url : null;
|
|
244
|
+
}, J = (e, t, n, r) => {
|
|
245
|
+
const o = t.stops.map((e, t) => v("stop", {
|
|
246
|
+
offset: e.offset,
|
|
247
|
+
stopColor: e.color
|
|
248
|
+
}, t));
|
|
249
|
+
if ("linear" === t.kind) {
|
|
250
|
+
const s = t.angle * Math.PI / 180;
|
|
251
|
+
let i = Math.cos(s), l = Math.sin(s);
|
|
252
|
+
if (t.scaled) {
|
|
253
|
+
i *= n, l *= r;
|
|
254
|
+
const e = Math.hypot(i, l) || 1;
|
|
255
|
+
i /= e, l /= e;
|
|
256
|
+
}
|
|
257
|
+
const a = (Math.abs(n * i) + Math.abs(r * l)) / 2, h = n / 2, c = r / 2;
|
|
258
|
+
return v("linearGradient", {
|
|
259
|
+
id: e,
|
|
260
|
+
gradientUnits: "userSpaceOnUse",
|
|
261
|
+
x1: h - a * i,
|
|
262
|
+
y1: c - a * l,
|
|
263
|
+
x2: h + a * i,
|
|
264
|
+
y2: c + a * l,
|
|
265
|
+
children: o
|
|
266
|
+
}, e);
|
|
267
|
+
}
|
|
268
|
+
return v("radialGradient", {
|
|
269
|
+
id: e,
|
|
270
|
+
gradientUnits: "userSpaceOnUse",
|
|
271
|
+
cx: t.cx * n,
|
|
272
|
+
cy: t.cy * n,
|
|
273
|
+
r: t.r * n,
|
|
274
|
+
gradientTransform: `scale(1 ${r / n})`,
|
|
275
|
+
children: o
|
|
276
|
+
}, e);
|
|
277
|
+
}, Q = c(({ paths: e, style: t, width: n, height: r, zoom: o, grid: s, hit: l }) => {
|
|
278
|
+
const a = d().replace(/[^A-Za-z0-9_-]/g, ""), h = Z(t.image?.resource ?? null), c = ((e, t, n = 1) => {
|
|
279
|
+
const r = (t > 0 ? t : 1) * (n > 0 ? n : 1);
|
|
280
|
+
return Math.max(1, Math.round(Math.max(0, e || 0) * r)) / r;
|
|
281
|
+
})(t.strokeWidth, o, s?.dpr ?? S.getDevicePixelRatio()), u = n > 0 && r > 0, p = u ? t.gradient ?? null : null, m = u ? t.strokeGradient ?? null : null, y = t.image ? h ? `url(#${a}-image)` : null : p ? `url(#${a}-fill)` : t.fill, g = m ? `url(#${a}-stroke)` : t.stroke, k = null !== t.stroke && c > 0, M = k ? ((e, t, n) => {
|
|
282
|
+
if (!(e && t > 0)) return;
|
|
283
|
+
const r = "butt" !== n, o = e.map((e, n) => {
|
|
284
|
+
const o = e * t;
|
|
285
|
+
return r ? n % 2 == 0 ? Math.max(0, o - t) : o + t : o;
|
|
286
|
+
});
|
|
287
|
+
return o.length % 2 == 1 && o.push(r ? t : 0), o.map((e) => +e.toFixed(3)).join(" ");
|
|
288
|
+
})(t.dash, c, t.lineCap) : void 0, w = f(() => ((e, t, n) => {
|
|
289
|
+
const r = /* @__PURE__ */ new Map();
|
|
290
|
+
if (!t) return r;
|
|
291
|
+
const o = /* @__PURE__ */ new Map(), s = [];
|
|
292
|
+
for (const l of e) {
|
|
293
|
+
if (l.layer !== i.PathLayer.Stroke) continue;
|
|
294
|
+
let e = o.get(l.d);
|
|
295
|
+
if (void 0 === e) {
|
|
296
|
+
const r = B(l.d, t, n);
|
|
297
|
+
e = r.d, o.set(l.d, e), s.push(...r.ends);
|
|
298
|
+
}
|
|
299
|
+
r.set(l.index, e);
|
|
300
|
+
}
|
|
301
|
+
for (const t of e) if (t.layer === i.PathLayer.Fill) {
|
|
302
|
+
const e = o.get(t.d);
|
|
303
|
+
void 0 !== e && r.set(t.index, e);
|
|
304
|
+
} else t.layer === i.PathLayer.Marker && r.set(t.index, O(t.d, s));
|
|
305
|
+
return r;
|
|
306
|
+
})(e, k ? s : null, c), [
|
|
307
|
+
e,
|
|
308
|
+
k,
|
|
309
|
+
s,
|
|
310
|
+
c
|
|
311
|
+
]), D = /* @__PURE__ */ new Set(), T = [];
|
|
312
|
+
for (const n of e) {
|
|
313
|
+
const e = `p${n.index}`, r = w.get(n.index) ?? n.d;
|
|
314
|
+
switch (n.layer) {
|
|
315
|
+
case i.PathLayer.Fill:
|
|
316
|
+
if (null === y) break;
|
|
317
|
+
"norm" !== n.fill && D.add(n.fill), T.push(v("path", {
|
|
318
|
+
d: r,
|
|
319
|
+
fill: y,
|
|
320
|
+
filter: "norm" !== n.fill ? `url(#${a}-${n.fill})` : void 0,
|
|
321
|
+
stroke: "none",
|
|
322
|
+
pointerEvents: l
|
|
323
|
+
}, e));
|
|
324
|
+
break;
|
|
325
|
+
case i.PathLayer.Stroke: {
|
|
326
|
+
if (!k) break;
|
|
327
|
+
const n = 8 / (o > 0 ? o : 1);
|
|
328
|
+
"none" !== l && n > c && T.push(v("path", {
|
|
329
|
+
className: "shape-hit",
|
|
330
|
+
d: r,
|
|
331
|
+
fill: "none",
|
|
332
|
+
stroke: "transparent",
|
|
333
|
+
strokeWidth: n,
|
|
334
|
+
strokeLinejoin: "round",
|
|
335
|
+
strokeLinecap: "round",
|
|
336
|
+
pointerEvents: "stroke"
|
|
337
|
+
}, `${e}-hit`)), T.push(v("path", {
|
|
338
|
+
d: r,
|
|
339
|
+
fill: "none",
|
|
340
|
+
stroke: g,
|
|
341
|
+
strokeWidth: c,
|
|
342
|
+
strokeLinejoin: t.lineJoin,
|
|
343
|
+
strokeLinecap: t.lineCap,
|
|
344
|
+
strokeMiterlimit: "miter" === t.lineJoin ? t.miterLimit : void 0,
|
|
345
|
+
strokeDasharray: M,
|
|
346
|
+
pointerEvents: "none" === l ? "none" : "visibleStroke"
|
|
347
|
+
}, e));
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
case i.PathLayer.Marker: k && T.push(v("path", {
|
|
351
|
+
d: r,
|
|
352
|
+
fill: g,
|
|
353
|
+
stroke: "none",
|
|
354
|
+
pointerEvents: l
|
|
355
|
+
}, e));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const $ = [];
|
|
359
|
+
for (const e of D) {
|
|
360
|
+
const [t, n] = i.FillTransfer[e];
|
|
361
|
+
$.push(v("filter", {
|
|
362
|
+
id: `${a}-${e}`,
|
|
363
|
+
colorInterpolationFilters: "sRGB",
|
|
364
|
+
children: b("feComponentTransfer", { children: [
|
|
365
|
+
v("feFuncR", {
|
|
366
|
+
type: "linear",
|
|
367
|
+
slope: t,
|
|
368
|
+
intercept: n
|
|
369
|
+
}),
|
|
370
|
+
v("feFuncG", {
|
|
371
|
+
type: "linear",
|
|
372
|
+
slope: t,
|
|
373
|
+
intercept: n
|
|
374
|
+
}),
|
|
375
|
+
v("feFuncB", {
|
|
376
|
+
type: "linear",
|
|
377
|
+
slope: t,
|
|
378
|
+
intercept: n
|
|
379
|
+
})
|
|
380
|
+
] })
|
|
381
|
+
}, e));
|
|
382
|
+
}
|
|
383
|
+
if (p && !t.image && $.push(J(`${a}-fill`, p, n, r)), m && k && $.push(J(`${a}-stroke`, m, n, r)), t.image && h) {
|
|
384
|
+
const e = t.image.fill.stretch ?? {}, o = n * (e.left ?? 0) / 100, s = r * (e.top ?? 0) / 100, i = Math.max(0, n - o - n * (e.right ?? 0) / 100), l = Math.max(0, r - s - r * (e.bottom ?? 0) / 100);
|
|
385
|
+
$.push(v("pattern", {
|
|
386
|
+
id: `${a}-image`,
|
|
387
|
+
patternUnits: "userSpaceOnUse",
|
|
388
|
+
x: 0,
|
|
389
|
+
y: 0,
|
|
390
|
+
width: Math.max(n, 1),
|
|
391
|
+
height: Math.max(r, 1),
|
|
392
|
+
children: v("image", {
|
|
393
|
+
href: h,
|
|
394
|
+
x: o,
|
|
395
|
+
y: s,
|
|
396
|
+
width: i,
|
|
397
|
+
height: l,
|
|
398
|
+
preserveAspectRatio: "none"
|
|
399
|
+
})
|
|
400
|
+
}, "image"));
|
|
401
|
+
}
|
|
402
|
+
return b(x, { children: [$.length > 0 ? v("defs", { children: $ }) : null, T] });
|
|
403
|
+
});
|
|
404
|
+
Q.displayName = "PathRun";
|
|
405
|
+
var V = c(({ geometry: e, style: t, zoom: n, grid: r = null, hit: o }) => {
|
|
406
|
+
const s = f(() => {
|
|
407
|
+
const t = [];
|
|
408
|
+
return e.forEachPath((e) => t.push(e)), t;
|
|
409
|
+
}, [e]);
|
|
410
|
+
return v(Q, {
|
|
411
|
+
paths: s,
|
|
412
|
+
style: t,
|
|
413
|
+
width: e.getWidth(),
|
|
414
|
+
height: e.getHeight(),
|
|
415
|
+
zoom: n,
|
|
416
|
+
grid: r,
|
|
417
|
+
hit: o
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
V.displayName = "ShapePaths";
|
|
421
|
+
var X = c(({ handles: e, width: t, height: n, zoom: r, onDrag: o }) => {
|
|
422
|
+
const s = y(null), i = y(null), [l, a] = g(!1), h = u((e) => {
|
|
423
|
+
const t = s.current, n = t?.getScreenCTM();
|
|
424
|
+
if (!t || !n) return null;
|
|
425
|
+
const r = new DOMPoint(e.clientX, e.clientY).matrixTransform(n.inverse());
|
|
426
|
+
return {
|
|
427
|
+
x: r.x,
|
|
428
|
+
y: r.y
|
|
429
|
+
};
|
|
430
|
+
}, []), c = u((e, t) => {
|
|
431
|
+
0 === e.button && (e.stopPropagation(), e.preventDefault(), i.current = {
|
|
432
|
+
index: t,
|
|
433
|
+
pointerId: e.pointerId
|
|
434
|
+
}, e.currentTarget.setPointerCapture(e.pointerId), a(!0));
|
|
435
|
+
}, []), p = u((e) => {
|
|
436
|
+
const t = i.current;
|
|
437
|
+
if (!t || t.pointerId !== e.pointerId) return;
|
|
438
|
+
e.stopPropagation();
|
|
439
|
+
const n = h(e);
|
|
440
|
+
n && o(t.index, n.x, n.y, "move");
|
|
441
|
+
}, [h, o]), d = u((e) => {
|
|
442
|
+
const t = i.current;
|
|
443
|
+
if (!t || t.pointerId !== e.pointerId) return;
|
|
444
|
+
e.stopPropagation(), i.current = null, a(!1);
|
|
445
|
+
const n = h(e);
|
|
446
|
+
n ? o(t.index, n.x, n.y, "end") : o(t.index, 0, 0, "cancel");
|
|
447
|
+
}, [h, o]), f = u((e) => {
|
|
448
|
+
const t = i.current;
|
|
449
|
+
t && t.pointerId === e.pointerId && (i.current = null, a(!1), o(t.index, 0, 0, "cancel"));
|
|
450
|
+
}, [o]);
|
|
451
|
+
if (!(0 !== e.length && t > 0 && n > 0)) return null;
|
|
452
|
+
const m = r > 0 ? r : 1, x = 4.5 / m;
|
|
453
|
+
return v("svg", {
|
|
454
|
+
ref: s,
|
|
455
|
+
className: l ? "shape-handles movable-gesture" : "shape-handles",
|
|
456
|
+
viewBox: `0 0 ${t} ${n}`,
|
|
457
|
+
width: "100%",
|
|
458
|
+
height: "100%",
|
|
459
|
+
preserveAspectRatio: "none",
|
|
460
|
+
overflow: "visible",
|
|
461
|
+
style: {
|
|
462
|
+
position: "absolute",
|
|
463
|
+
left: 0,
|
|
464
|
+
top: 0,
|
|
465
|
+
display: "block",
|
|
466
|
+
pointerEvents: "none",
|
|
467
|
+
touchAction: "none"
|
|
468
|
+
},
|
|
469
|
+
children: e.map((e) => b("g", {
|
|
470
|
+
className: "shape-handle",
|
|
471
|
+
style: { "--shape-scale": m },
|
|
472
|
+
children: [v("circle", {
|
|
473
|
+
cx: e.x,
|
|
474
|
+
cy: e.y,
|
|
475
|
+
r: x,
|
|
476
|
+
fill: "#ffc000",
|
|
477
|
+
stroke: "#7f6000",
|
|
478
|
+
strokeWidth: 1 / m,
|
|
479
|
+
style: { pointerEvents: "none" }
|
|
480
|
+
}), v("circle", {
|
|
481
|
+
className: "shape-handle-hit",
|
|
482
|
+
cx: e.x,
|
|
483
|
+
cy: e.y,
|
|
484
|
+
r: x,
|
|
485
|
+
fill: "transparent",
|
|
486
|
+
style: {
|
|
487
|
+
pointerEvents: "all",
|
|
488
|
+
cursor: "crosshair",
|
|
489
|
+
touchAction: "none"
|
|
490
|
+
},
|
|
491
|
+
onPointerDown: (t) => c(t, e.index),
|
|
492
|
+
onPointerMove: p,
|
|
493
|
+
onPointerUp: d,
|
|
494
|
+
onPointerCancel: f,
|
|
495
|
+
onMouseDown: (e) => e.stopPropagation()
|
|
496
|
+
})]
|
|
497
|
+
}, e.index))
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
X.displayName = "ShapeHandles";
|
|
501
|
+
var Y = (e, t) => e > 0 || t > 0, _ = (e, t, n) => !e || e.getWidth() === t && e.getHeight() === n ? e : Y(t, n) ? e.resize(t, n) : null, q = (e) => {
|
|
502
|
+
const t = [];
|
|
503
|
+
return e.forEachConnection((e) => t.push(e)), t;
|
|
504
|
+
}, K = c(h((o, i) => {
|
|
505
|
+
const { children: l, disabled: h, style: c, shape: d, movable: x, zoom: k = 1, isDragging: j, onHide: N, onShow: z, onDragZone: I, adornmentHost: G, flip: F, gesture: R, debugGeometry: H = !1, ...W } = o, B = t()?.getStyles() ?? null, [O, U] = m((e) => e + 1, 0);
|
|
506
|
+
e(d, { onAnyChange: U }), e(x ?? null, {
|
|
507
|
+
onBoundsChange: U,
|
|
508
|
+
onSelectionChange: U
|
|
509
|
+
});
|
|
510
|
+
const Z = d.toJSON(), { width: J, height: Q, rotation: K, content: ee } = ((e) => {
|
|
511
|
+
const [t] = D("movable-drag", null), n = e ? t?.[e.getId()] : void 0, r = n?.bounds ?? e?.getBounds();
|
|
512
|
+
return {
|
|
513
|
+
width: r?.width ?? 0,
|
|
514
|
+
height: r?.height ?? 0,
|
|
515
|
+
rotation: n?.rotation ?? (e?.getRotation() || 0),
|
|
516
|
+
content: n?.content ?? null
|
|
517
|
+
};
|
|
518
|
+
})(x), te = d.getShapeType(), ne = d.getAdjustments(), re = Y(J, Q), [oe, se] = g(null), ie = y(0);
|
|
519
|
+
p(() => {
|
|
520
|
+
if (!re) return void se(null);
|
|
521
|
+
const e = ++ie.current, t = d.getShapeType();
|
|
522
|
+
d.getGeometry(J, Q).then((n) => {
|
|
523
|
+
ie.current === e && se(n ? {
|
|
524
|
+
shapeType: t,
|
|
525
|
+
geometry: n
|
|
526
|
+
} : null);
|
|
527
|
+
}, () => {
|
|
528
|
+
ie.current === e && se(null);
|
|
529
|
+
});
|
|
530
|
+
}, [
|
|
531
|
+
d,
|
|
532
|
+
J,
|
|
533
|
+
Q,
|
|
534
|
+
O
|
|
535
|
+
]);
|
|
536
|
+
const le = void 0 !== ee?.shapeType && ee.shapeType !== te ? ee.shapeType : null, [ae, he] = g(null);
|
|
537
|
+
p(() => {
|
|
538
|
+
if (!le || !re || ae?.shapeType === le) return;
|
|
539
|
+
let e = !0;
|
|
540
|
+
return d.getGeometry(J, Q, { shapeType: le }).then((t) => {
|
|
541
|
+
e && t && he({
|
|
542
|
+
shapeType: le,
|
|
543
|
+
geometry: t
|
|
544
|
+
});
|
|
545
|
+
}, () => {}), () => {
|
|
546
|
+
e = !1;
|
|
547
|
+
};
|
|
548
|
+
}, [
|
|
549
|
+
d,
|
|
550
|
+
le,
|
|
551
|
+
re
|
|
552
|
+
]);
|
|
553
|
+
const ce = f(() => {
|
|
554
|
+
const e = oe?.shapeType === te ? oe : ae?.shapeType === te ? ae : null;
|
|
555
|
+
return e ? _(e.geometry, J, Q)?.withAdjustments(ne) ?? null : _(oe?.geometry ?? null, J, Q);
|
|
556
|
+
}, [
|
|
557
|
+
oe,
|
|
558
|
+
ae,
|
|
559
|
+
te,
|
|
560
|
+
ne,
|
|
561
|
+
J,
|
|
562
|
+
Q
|
|
563
|
+
]), ue = u((e) => d.getResource(e), [d]);
|
|
564
|
+
p(() => {
|
|
565
|
+
const e = [];
|
|
566
|
+
for (let t = x?.getParent() ?? null; t; t = t.getParent()) e.push(t.getContent().addListeners({ onAnyChange: U }));
|
|
567
|
+
return () => {
|
|
568
|
+
for (const t of e) t();
|
|
569
|
+
};
|
|
570
|
+
}, [x]);
|
|
571
|
+
const pe = A(x), de = f(() => ((e, t, n, r) => {
|
|
572
|
+
let o = null;
|
|
573
|
+
try {
|
|
574
|
+
o = t?.getTheme()?.toJSON() ?? null;
|
|
575
|
+
} catch {
|
|
576
|
+
o = null;
|
|
577
|
+
}
|
|
578
|
+
const i = a.resolve(e, o, r), { fill: l, stroke: h } = i, c = P(h?.fill, t), u = h?.fill?.type === s.Type.Gradient ? E(h.fill, t) ?? void 0 : void 0, p = P(l, t), d = l?.type === s.Type.Gradient ? E(l, t) ?? void 0 : void 0;
|
|
579
|
+
let f;
|
|
580
|
+
if (l?.type === s.Type.Image) {
|
|
581
|
+
const e = void 0 === l.resId ? null : n?.(l.resId) ?? null;
|
|
582
|
+
e && (f = {
|
|
583
|
+
resource: e,
|
|
584
|
+
fill: l
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
return {
|
|
588
|
+
fill: p,
|
|
589
|
+
gradient: d,
|
|
590
|
+
image: f,
|
|
591
|
+
stroke: c,
|
|
592
|
+
strokeGradient: u,
|
|
593
|
+
strokeWidth: c ? Math.max(0, i.strokeWidth) * $ : 0,
|
|
594
|
+
lineJoin: h?.lineJoin ?? "miter",
|
|
595
|
+
lineCap: h?.lineCap ?? "butt",
|
|
596
|
+
miterLimit: "number" == typeof h?.miterLimit ? h.miterLimit : 18.5,
|
|
597
|
+
dash: L(h?.dash),
|
|
598
|
+
textColor: C(i.fontColor, t)
|
|
599
|
+
};
|
|
600
|
+
})(Z, B, ue, pe), [
|
|
601
|
+
Z,
|
|
602
|
+
B,
|
|
603
|
+
ue,
|
|
604
|
+
pe
|
|
605
|
+
]), [fe, me] = g(null), ye = void 0 !== ee?.adjustments ? ee.adjustments : fe ?? void 0, ge = f(() => {
|
|
606
|
+
if (le && ae?.shapeType !== le) return ce;
|
|
607
|
+
const e = le ? _(ae.geometry, J, Q) : ce;
|
|
608
|
+
return e && void 0 !== ye ? e.withAdjustments(ye) : e;
|
|
609
|
+
}, [
|
|
610
|
+
ce,
|
|
611
|
+
le,
|
|
612
|
+
ae,
|
|
613
|
+
J,
|
|
614
|
+
Q,
|
|
615
|
+
ye
|
|
616
|
+
]), xe = y(null), [ve, be] = g(!1), ke = u((e, t, n, r) => {
|
|
617
|
+
if ("cancel" === r) return xe.current && (xe.current = null, be(!1), R?.cancel()), void me(null);
|
|
618
|
+
if (!ge || !ce) return;
|
|
619
|
+
const o = ge.adjustmentsFromHandle(e, t, n);
|
|
620
|
+
if ("move" === r) {
|
|
621
|
+
if (R && !h) {
|
|
622
|
+
if (!xe.current) {
|
|
623
|
+
const e = { adjustments: o }, t = (t) => {
|
|
624
|
+
t.getContent().setAdjustments(e.adjustments);
|
|
625
|
+
};
|
|
626
|
+
if (!R.start(M("op.setShapeAdjustments"), t)) return;
|
|
627
|
+
xe.current = e, be(!0);
|
|
628
|
+
}
|
|
629
|
+
xe.current.adjustments = o, R.preview({ content: { adjustments: o } });
|
|
630
|
+
return;
|
|
631
|
+
}
|
|
632
|
+
me(o);
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
const s = xe.current;
|
|
636
|
+
if (s) return xe.current = null, be(!1), s.adjustments = o, void R?.finish();
|
|
637
|
+
me(null), h || d.setAdjustments(o);
|
|
638
|
+
}, [
|
|
639
|
+
ge,
|
|
640
|
+
ce,
|
|
641
|
+
d,
|
|
642
|
+
h,
|
|
643
|
+
R
|
|
644
|
+
]), Me = f(() => {
|
|
645
|
+
const e = [];
|
|
646
|
+
return ge?.forEachHandle((t) => e.push(t)), e;
|
|
647
|
+
}, [ge]), Se = w(i, () => ({ isShapeEditor: () => !0 }), []), we = F ?? x?.getFlip(), De = we?.horizontal ?? !1, Te = we?.vertical ?? !1, $e = K % 360 != 0, Ce = f(() => !$e && Y(J, Q) ? {
|
|
648
|
+
dpr: S.getDevicePixelRatio(),
|
|
649
|
+
zoom: k,
|
|
650
|
+
width: J,
|
|
651
|
+
height: Q,
|
|
652
|
+
flipH: De,
|
|
653
|
+
flipV: Te
|
|
654
|
+
} : null, [
|
|
655
|
+
$e,
|
|
656
|
+
k,
|
|
657
|
+
J,
|
|
658
|
+
Q,
|
|
659
|
+
De,
|
|
660
|
+
Te
|
|
661
|
+
]);
|
|
662
|
+
if (d.isDeleted() || !Z) return null;
|
|
663
|
+
const Pe = "none" === c?.pointerEvents, je = Pe ? "none" : "visiblePainted", Le = !Pe && !h && (!j || ve) && !!x?.isSelected(), Ne = {
|
|
664
|
+
transform: De || Te ? `scale(${De ? -1 : 1}, ${Te ? -1 : 1})` : void 0,
|
|
665
|
+
transformOrigin: "center"
|
|
666
|
+
};
|
|
667
|
+
let Ee = null;
|
|
668
|
+
Le && Me.length > 0 && (Ee = v(X, {
|
|
669
|
+
handles: Me,
|
|
670
|
+
width: J,
|
|
671
|
+
height: Q,
|
|
672
|
+
zoom: k,
|
|
673
|
+
onDrag: ke
|
|
674
|
+
}), G && (Ee = T(v("div", {
|
|
675
|
+
className: "shape-adornment",
|
|
676
|
+
style: {
|
|
677
|
+
position: "absolute",
|
|
678
|
+
left: 0,
|
|
679
|
+
top: 0,
|
|
680
|
+
width: "100%",
|
|
681
|
+
height: "100%",
|
|
682
|
+
...Ne,
|
|
683
|
+
pointerEvents: "none"
|
|
684
|
+
},
|
|
685
|
+
children: Ee
|
|
686
|
+
}), G)));
|
|
687
|
+
const Ae = De !== Te ? "scaleX(-1)" : void 0, ze = ge?.getTextRect(), Ie = Z.text, Ge = !!Ie && Ie.paragraphs.some((e) => e.runs.some((e) => "" !== e.text));
|
|
688
|
+
return b("div", {
|
|
689
|
+
className: "shape-editor",
|
|
690
|
+
...W,
|
|
691
|
+
ref: Se,
|
|
692
|
+
style: {
|
|
693
|
+
width: "100%",
|
|
694
|
+
height: "100%",
|
|
695
|
+
position: "relative",
|
|
696
|
+
overflow: "visible",
|
|
697
|
+
filter: h ? "blur(1px)" : void 0,
|
|
698
|
+
...Ne,
|
|
699
|
+
...c,
|
|
700
|
+
pointerEvents: "none"
|
|
701
|
+
},
|
|
702
|
+
children: [
|
|
703
|
+
Y(J, Q) ? b("svg", {
|
|
704
|
+
className: "shape-geometry",
|
|
705
|
+
viewBox: `0 0 ${J > 0 ? J : 1 / k} ${Q > 0 ? Q : 1 / k}`,
|
|
706
|
+
width: J > 0 ? "100%" : "1px",
|
|
707
|
+
height: Q > 0 ? "100%" : "1px",
|
|
708
|
+
preserveAspectRatio: "none",
|
|
709
|
+
overflow: "visible",
|
|
710
|
+
style: {
|
|
711
|
+
position: "absolute",
|
|
712
|
+
left: 0,
|
|
713
|
+
top: 0,
|
|
714
|
+
display: "block",
|
|
715
|
+
pointerEvents: "none",
|
|
716
|
+
filter: Le ? "drop-shadow(1px 1px 2px rgba(0,0,0,.15))" : void 0
|
|
717
|
+
},
|
|
718
|
+
children: [ge ? v(V, {
|
|
719
|
+
geometry: ge,
|
|
720
|
+
style: de,
|
|
721
|
+
zoom: k,
|
|
722
|
+
grid: Ce,
|
|
723
|
+
hit: je
|
|
724
|
+
}) : null, H && ge && ze ? b("g", {
|
|
725
|
+
pointerEvents: "none",
|
|
726
|
+
children: [v("rect", {
|
|
727
|
+
x: ze.l,
|
|
728
|
+
y: ze.t,
|
|
729
|
+
width: Math.max(0, ze.r - ze.l),
|
|
730
|
+
height: Math.max(0, ze.b - ze.t),
|
|
731
|
+
fill: "none",
|
|
732
|
+
stroke: "#c00",
|
|
733
|
+
strokeWidth: 1 / k,
|
|
734
|
+
strokeDasharray: `${4 / k} ${2 / k}`
|
|
735
|
+
}), q(ge).map((e) => v("rect", {
|
|
736
|
+
x: e.x - 3 / k,
|
|
737
|
+
y: e.y - 3 / k,
|
|
738
|
+
width: 6 / k,
|
|
739
|
+
height: 6 / k,
|
|
740
|
+
fill: "#0a0"
|
|
741
|
+
}, e.index))]
|
|
742
|
+
}) : null]
|
|
743
|
+
}) : null,
|
|
744
|
+
Ge && ze ? v("div", {
|
|
745
|
+
className: "shape-text-frame",
|
|
746
|
+
style: {
|
|
747
|
+
position: "absolute",
|
|
748
|
+
left: ze.l,
|
|
749
|
+
top: ze.t,
|
|
750
|
+
width: Math.max(0, ze.r - ze.l),
|
|
751
|
+
height: Math.max(0, ze.b - ze.t),
|
|
752
|
+
zoom: k,
|
|
753
|
+
transform: Ae,
|
|
754
|
+
transformOrigin: "center",
|
|
755
|
+
pointerEvents: Pe ? "none" : "auto",
|
|
756
|
+
color: de.textColor ?? void 0
|
|
757
|
+
},
|
|
758
|
+
children: v(n, {
|
|
759
|
+
movable: x,
|
|
760
|
+
disabled: !0,
|
|
761
|
+
style: {
|
|
762
|
+
fontFamily: "Calibri, Carlito, sans-serif",
|
|
763
|
+
fontSize: "11pt",
|
|
764
|
+
lineHeight: 1.2,
|
|
765
|
+
padding: 0
|
|
766
|
+
},
|
|
767
|
+
contentStyle: {
|
|
768
|
+
padding: 0,
|
|
769
|
+
overflow: "hidden"
|
|
770
|
+
},
|
|
771
|
+
children: v(r, {
|
|
772
|
+
text: Ie,
|
|
773
|
+
styles: B,
|
|
774
|
+
color: de.textColor
|
|
775
|
+
})
|
|
776
|
+
})
|
|
777
|
+
}) : null,
|
|
778
|
+
Ee
|
|
779
|
+
]
|
|
780
|
+
});
|
|
781
|
+
}));
|
|
782
|
+
K.displayName = "ShapeEditor";
|
|
783
|
+
export { K as ShapeEditor };
|