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