@pixerate/editor-react 0.92.0 → 0.93.1
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/animation-editor/AnimationEditor.d.cts +11 -1
- package/dist/animation-editor/AnimationEditor.d.ts +11 -1
- package/dist/animation-editor/index.cjs +494 -366
- package/dist/animation-editor/index.js +48 -4
- package/dist/canvas/index.cjs +3 -2
- package/dist/canvas/index.js +4 -4
- package/dist/chart/ChartEditor.d.cts +12 -1
- package/dist/chart/ChartEditor.d.ts +12 -1
- package/dist/chart/index.cjs +187 -29
- package/dist/chart/index.js +74 -10
- package/dist/{chunk-6MDTFAPY.js → chunk-6YRSQW2V.js} +5 -5
- package/dist/chunk-7I73DW4V.js +43 -0
- package/dist/{chunk-GML6BYCN.js → chunk-GECXTPSH.js} +53 -3
- package/dist/{chunk-ECBC4HD7.js → chunk-IPVWWVSF.js} +3 -2
- package/dist/image-editor/index.cjs +3 -2
- package/dist/image-editor/index.js +2 -2
- package/dist/index.cjs +609 -527
- package/dist/index.js +10 -6
- package/dist/paint-editor/PaintEditor.d.cts +12 -1
- package/dist/paint-editor/PaintEditor.d.ts +12 -1
- package/dist/paint-editor/index.cjs +319 -164
- package/dist/paint-editor/index.js +84 -11
- package/dist/parameters/ParametersPanel.d.cts +11 -1
- package/dist/parameters/ParametersPanel.d.ts +11 -1
- package/dist/parameters/index.cjs +190 -41
- package/dist/parameters/index.js +23 -4
- package/dist/playback/index.d.cts +1 -0
- package/dist/playback/index.d.ts +1 -0
- package/dist/playback/useElementPlaybackSurface.d.cts +19 -0
- package/dist/playback/useElementPlaybackSurface.d.ts +19 -0
- package/dist/playback/usePlaybackSurface.d.cts +3 -1
- package/dist/playback/usePlaybackSurface.d.ts +3 -1
- package/dist/spreadsheet/SpreadsheetEditor.d.cts +10 -0
- package/dist/spreadsheet/SpreadsheetEditor.d.ts +10 -0
- package/dist/spreadsheet/index.cjs +443 -313
- package/dist/spreadsheet/index.js +2 -1
- package/dist/vector/index.cjs +3 -2
- package/dist/vector/index.js +5 -5
- package/dist/video-editor/VideoEditor.d.cts +6 -1
- package/dist/video-editor/VideoEditor.d.ts +6 -1
- package/dist/video-editor/VideoTimeline.d.cts +11 -1
- package/dist/video-editor/VideoTimeline.d.ts +11 -1
- package/dist/video-editor/index.cjs +463 -332
- package/dist/video-editor/index.js +53 -5
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -99,6 +99,7 @@ __export(src_exports, {
|
|
|
99
99
|
useDocxExport: () => useDocxExport,
|
|
100
100
|
useEditor: () => useEditor2,
|
|
101
101
|
useEditorSlots: () => useEditorSlots,
|
|
102
|
+
useElementPlaybackSurface: () => useElementPlaybackSurface,
|
|
102
103
|
useFileImport: () => useFileImport,
|
|
103
104
|
useFillHandle: () => useFillHandle,
|
|
104
105
|
useFindReplace: () => useFindReplace,
|
|
@@ -799,10 +800,11 @@ function useAgentPlayback() {
|
|
|
799
800
|
// src/playback/usePlaybackSurface.ts
|
|
800
801
|
var import_react14 = require("react");
|
|
801
802
|
var import_tools = require("@pixerate/editor/tools");
|
|
802
|
-
function usePlaybackSurface(playback, id, options = {}) {
|
|
803
|
+
function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
803
804
|
const ambient = useAgentPlayback();
|
|
804
805
|
const target = playback === void 0 ? ambient : playback;
|
|
805
|
-
const [
|
|
806
|
+
const [ownPresence] = (0, import_react14.useState)(() => new import_tools.PresenceStore());
|
|
807
|
+
const presence = sharedPresence ?? ownPresence;
|
|
806
808
|
const latest = (0, import_react14.useRef)(options);
|
|
807
809
|
latest.current = options;
|
|
808
810
|
(0, import_react14.useEffect)(() => {
|
|
@@ -832,13 +834,49 @@ function usePlaybackSurface(playback, id, options = {}) {
|
|
|
832
834
|
return presence;
|
|
833
835
|
}
|
|
834
836
|
|
|
835
|
-
// src/
|
|
837
|
+
// src/playback/useElementPlaybackSurface.ts
|
|
836
838
|
var import_react15 = require("react");
|
|
839
|
+
function useElementPlaybackSurface(playback, id, element, options) {
|
|
840
|
+
const latest = (0, import_react15.useRef)(options);
|
|
841
|
+
latest.current = options;
|
|
842
|
+
const box = () => element.current?.getBoundingClientRect() ?? null;
|
|
843
|
+
return usePlaybackSurface(playback, id, {
|
|
844
|
+
get defaultKind() {
|
|
845
|
+
return latest.current.defaultKind;
|
|
846
|
+
},
|
|
847
|
+
locate: (ref) => {
|
|
848
|
+
const selector = latest.current.selectors[ref.kind]?.(ref.id);
|
|
849
|
+
const b = box();
|
|
850
|
+
const r = selector ? element.current?.querySelector(selector)?.getBoundingClientRect() : null;
|
|
851
|
+
return b && r && r.width > 0 ? { x: r.left - b.left, y: r.top - b.top, width: r.width, height: r.height } : null;
|
|
852
|
+
},
|
|
853
|
+
bounds: () => {
|
|
854
|
+
const r = box();
|
|
855
|
+
return r && r.width > 0 ? { x: 0, y: 0, width: r.width, height: r.height } : null;
|
|
856
|
+
},
|
|
857
|
+
visible: () => {
|
|
858
|
+
const r = box();
|
|
859
|
+
return !!r && r.width > 0 && r.height > 0 && !(typeof document !== "undefined" && document.visibilityState === "hidden");
|
|
860
|
+
},
|
|
861
|
+
toViewport: (p) => {
|
|
862
|
+
const r = box();
|
|
863
|
+
return { x: (r?.left ?? 0) + p.x, y: (r?.top ?? 0) + p.y };
|
|
864
|
+
},
|
|
865
|
+
fromViewport: (p) => {
|
|
866
|
+
const r = box();
|
|
867
|
+
return { x: p.x - (r?.left ?? 0), y: p.y - (r?.top ?? 0) };
|
|
868
|
+
},
|
|
869
|
+
reveal: () => latest.current.reveal?.()
|
|
870
|
+
});
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
// src/hooks/useToolBridge.ts
|
|
874
|
+
var import_react16 = require("react");
|
|
837
875
|
var import_tools2 = require("@pixerate/editor/tools");
|
|
838
876
|
function useToolBridge(registry, options) {
|
|
839
|
-
const [state, setState] = (0,
|
|
877
|
+
const [state, setState] = (0, import_react16.useState)({ status: "off", editorId: null });
|
|
840
878
|
const key = options ? JSON.stringify([options.url, options.token, options.name, options.kind, options.reconnect]) : null;
|
|
841
|
-
(0,
|
|
879
|
+
(0, import_react16.useEffect)(() => {
|
|
842
880
|
if (!registry || !options) {
|
|
843
881
|
setState({ status: "off", editorId: null });
|
|
844
882
|
return;
|
|
@@ -858,36 +896,36 @@ function useToolBridge(registry, options) {
|
|
|
858
896
|
}
|
|
859
897
|
|
|
860
898
|
// src/hooks/useToolRegistryView.ts
|
|
861
|
-
var
|
|
899
|
+
var import_react17 = require("react");
|
|
862
900
|
function useToolRegistryView(registry, options = {}) {
|
|
863
901
|
const { toolsets, readOnly, discovery } = options;
|
|
864
|
-
const view = (0,
|
|
902
|
+
const view = (0, import_react17.useMemo)(
|
|
865
903
|
() => registry ? registry.view({ toolsets, readOnly, discovery }) : null,
|
|
866
904
|
// toolsets is applied below without making a new view, so enabled tools survive.
|
|
867
905
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
868
906
|
[registry, readOnly, discovery]
|
|
869
907
|
);
|
|
870
908
|
const toolsetsKey = typeof toolsets === "function" ? toolsets : JSON.stringify(toolsets ?? null);
|
|
871
|
-
(0,
|
|
909
|
+
(0, import_react17.useEffect)(() => {
|
|
872
910
|
view?.setToolsets(toolsets);
|
|
873
911
|
}, [view, toolsetsKey]);
|
|
874
|
-
(0,
|
|
912
|
+
(0, import_react17.useEffect)(() => () => view?.dispose(), [view]);
|
|
875
913
|
return view;
|
|
876
914
|
}
|
|
877
915
|
|
|
878
916
|
// src/components/EditorContent.tsx
|
|
879
|
-
var
|
|
917
|
+
var import_react18 = require("@tiptap/react");
|
|
880
918
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
881
919
|
var EditorContent = ({
|
|
882
920
|
className,
|
|
883
921
|
editor,
|
|
884
922
|
...props
|
|
885
923
|
}) => {
|
|
886
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
924
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react18.EditorContent, { editor, ...props }) });
|
|
887
925
|
};
|
|
888
926
|
|
|
889
927
|
// src/components/BubbleMenu.tsx
|
|
890
|
-
var
|
|
928
|
+
var import_react19 = require("react");
|
|
891
929
|
var import_react_dom = require("react-dom");
|
|
892
930
|
var import_extension_bubble_menu = require("@tiptap/extension-bubble-menu");
|
|
893
931
|
var BubbleMenu = ({
|
|
@@ -899,12 +937,12 @@ var BubbleMenu = ({
|
|
|
899
937
|
pluginKey = "bubbleMenu",
|
|
900
938
|
updateDelay
|
|
901
939
|
}) => {
|
|
902
|
-
const menuEl = (0,
|
|
903
|
-
const [mounted, setMounted] = (0,
|
|
940
|
+
const menuEl = (0, import_react19.useRef)(null);
|
|
941
|
+
const [mounted, setMounted] = (0, import_react19.useState)(false);
|
|
904
942
|
if (!menuEl.current && typeof document !== "undefined") {
|
|
905
943
|
menuEl.current = document.createElement("div");
|
|
906
944
|
}
|
|
907
|
-
(0,
|
|
945
|
+
(0, import_react19.useEffect)(() => {
|
|
908
946
|
if (!editor || !menuEl.current || editor.isDestroyed) {
|
|
909
947
|
return;
|
|
910
948
|
}
|
|
@@ -935,7 +973,7 @@ var BubbleMenu = ({
|
|
|
935
973
|
};
|
|
936
974
|
|
|
937
975
|
// src/components/TemplateRenderer.tsx
|
|
938
|
-
var
|
|
976
|
+
var import_react20 = require("react");
|
|
939
977
|
var import_editor6 = require("@pixerate/editor");
|
|
940
978
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
941
979
|
var TemplateRenderer = ({
|
|
@@ -949,11 +987,11 @@ var TemplateRenderer = ({
|
|
|
949
987
|
onTemplateClick,
|
|
950
988
|
onVariableClick
|
|
951
989
|
}) => {
|
|
952
|
-
const displayText = (0,
|
|
990
|
+
const displayText = (0, import_react20.useMemo)(() => {
|
|
953
991
|
if (!resolve || templates.length === 0) return content;
|
|
954
992
|
return (0, import_editor6.resolveTemplates)(content, templates, { bindings });
|
|
955
993
|
}, [content, templates, resolve, bindings]);
|
|
956
|
-
const tokens = (0,
|
|
994
|
+
const tokens = (0, import_react20.useMemo)(() => {
|
|
957
995
|
return (0, import_editor6.evaluatePromptTokens)(displayText, values);
|
|
958
996
|
}, [displayText, values]);
|
|
959
997
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className, children: tokens.map((token, index) => {
|
|
@@ -1042,7 +1080,7 @@ var TemplateRenderer = ({
|
|
|
1042
1080
|
};
|
|
1043
1081
|
|
|
1044
1082
|
// src/components/VariableForm.tsx
|
|
1045
|
-
var
|
|
1083
|
+
var import_react21 = require("react");
|
|
1046
1084
|
var import_editor7 = require("@pixerate/editor");
|
|
1047
1085
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1048
1086
|
var VariableForm = ({
|
|
@@ -1054,12 +1092,12 @@ var VariableForm = ({
|
|
|
1054
1092
|
onChange,
|
|
1055
1093
|
className = "flex flex-col gap-3 text-sm"
|
|
1056
1094
|
}) => {
|
|
1057
|
-
const idPrefix = (0,
|
|
1058
|
-
const [internal, setInternal] = (0,
|
|
1095
|
+
const idPrefix = (0, import_react21.useId)();
|
|
1096
|
+
const [internal, setInternal] = (0, import_react21.useState)(
|
|
1059
1097
|
() => defaultValues ?? {}
|
|
1060
1098
|
);
|
|
1061
1099
|
const entered = values ?? internal;
|
|
1062
|
-
const fields = (0,
|
|
1100
|
+
const fields = (0, import_react21.useMemo)(
|
|
1063
1101
|
() => (0, import_editor7.getVariableFormFields)(content, { templates, bindings }),
|
|
1064
1102
|
[content, templates, bindings]
|
|
1065
1103
|
);
|
|
@@ -1127,26 +1165,26 @@ var VariableForm = ({
|
|
|
1127
1165
|
};
|
|
1128
1166
|
|
|
1129
1167
|
// src/components/MergePreview.tsx
|
|
1130
|
-
var
|
|
1168
|
+
var import_react23 = require("react");
|
|
1131
1169
|
|
|
1132
1170
|
// src/hooks/useMergePreview.ts
|
|
1133
|
-
var
|
|
1171
|
+
var import_react22 = require("react");
|
|
1134
1172
|
var import_editor8 = require("@pixerate/editor");
|
|
1135
1173
|
function useMergePreview(options) {
|
|
1136
1174
|
const { template, templates, bindings, parseOptions } = options;
|
|
1137
|
-
const [sourceText, setSourceTextState] = (0,
|
|
1138
|
-
const [overrides, setOverrides] = (0,
|
|
1139
|
-
const [index, setIndexState] = (0,
|
|
1140
|
-
const [result, setResult] = (0,
|
|
1141
|
-
const source = (0,
|
|
1175
|
+
const [sourceText, setSourceTextState] = (0, import_react22.useState)(options.initialSource ?? "");
|
|
1176
|
+
const [overrides, setOverrides] = (0, import_react22.useState)({});
|
|
1177
|
+
const [index, setIndexState] = (0, import_react22.useState)(0);
|
|
1178
|
+
const [result, setResult] = (0, import_react22.useState)(null);
|
|
1179
|
+
const source = (0, import_react22.useMemo)(
|
|
1142
1180
|
() => (0, import_editor8.parseDataSource)(sourceText, parseOptions),
|
|
1143
1181
|
[sourceText, parseOptions]
|
|
1144
1182
|
);
|
|
1145
|
-
const variables = (0,
|
|
1183
|
+
const variables = (0, import_react22.useMemo)(
|
|
1146
1184
|
() => (0, import_editor8.extractVariables)(template, { templates, bindings }).map((v) => v.name),
|
|
1147
1185
|
[template, templates, bindings]
|
|
1148
1186
|
);
|
|
1149
|
-
const mapping = (0,
|
|
1187
|
+
const mapping = (0, import_react22.useMemo)(() => {
|
|
1150
1188
|
const merged = {
|
|
1151
1189
|
...(0, import_editor8.matchFields)(variables, source.fields).mapping
|
|
1152
1190
|
};
|
|
@@ -1160,29 +1198,29 @@ function useMergePreview(options) {
|
|
|
1160
1198
|
const count = source.records.length;
|
|
1161
1199
|
const current = count === 0 ? 0 : Math.min(index, count - 1);
|
|
1162
1200
|
const record = source.records[current];
|
|
1163
|
-
const values = (0,
|
|
1201
|
+
const values = (0, import_react22.useMemo)(
|
|
1164
1202
|
() => record ? (0, import_editor8.recordToValues)(record, mapping) : {},
|
|
1165
1203
|
[record, mapping]
|
|
1166
1204
|
);
|
|
1167
|
-
const setSourceText = (0,
|
|
1205
|
+
const setSourceText = (0, import_react22.useCallback)((text) => {
|
|
1168
1206
|
setSourceTextState(text);
|
|
1169
1207
|
setIndexState(0);
|
|
1170
1208
|
setResult(null);
|
|
1171
1209
|
}, []);
|
|
1172
|
-
const loadFile = (0,
|
|
1210
|
+
const loadFile = (0, import_react22.useCallback)(
|
|
1173
1211
|
async (file) => setSourceText(await file.text()),
|
|
1174
1212
|
[setSourceText]
|
|
1175
1213
|
);
|
|
1176
|
-
const setIndex = (0,
|
|
1214
|
+
const setIndex = (0, import_react22.useCallback)(
|
|
1177
1215
|
(next) => setIndexState(Math.max(0, Math.min(next, count - 1))),
|
|
1178
1216
|
[count]
|
|
1179
1217
|
);
|
|
1180
|
-
const setFieldMapping = (0,
|
|
1218
|
+
const setFieldMapping = (0, import_react22.useCallback)((variable, field) => {
|
|
1181
1219
|
setOverrides((previous) => ({ ...previous, [variable]: field }));
|
|
1182
1220
|
setResult(null);
|
|
1183
1221
|
}, []);
|
|
1184
|
-
const resetMapping = (0,
|
|
1185
|
-
const merge = (0,
|
|
1222
|
+
const resetMapping = (0, import_react22.useCallback)(() => setOverrides({}), []);
|
|
1223
|
+
const merge = (0, import_react22.useCallback)(() => {
|
|
1186
1224
|
const merged = (0, import_editor8.mergeRecords)(template, source, {
|
|
1187
1225
|
templates,
|
|
1188
1226
|
bindings,
|
|
@@ -1194,7 +1232,7 @@ function useMergePreview(options) {
|
|
|
1194
1232
|
setResult(merged);
|
|
1195
1233
|
return merged;
|
|
1196
1234
|
}, [template, source, templates, bindings, mapping, options.skipIf, options.separator, options.maxOutputs]);
|
|
1197
|
-
const serialize = (0,
|
|
1235
|
+
const serialize = (0, import_react22.useCallback)(
|
|
1198
1236
|
(format) => result ? (0, import_editor8.serializeMergeOutputs)(result.outputs, format, options.separator) : "",
|
|
1199
1237
|
[result, options.separator]
|
|
1200
1238
|
);
|
|
@@ -1247,7 +1285,7 @@ var MergePreview = ({
|
|
|
1247
1285
|
downloadName = "merged",
|
|
1248
1286
|
className = "flex flex-col gap-3 text-sm"
|
|
1249
1287
|
}) => {
|
|
1250
|
-
const id = (0,
|
|
1288
|
+
const id = (0, import_react23.useId)();
|
|
1251
1289
|
const merge = useMergePreview({
|
|
1252
1290
|
template: content,
|
|
1253
1291
|
templates,
|
|
@@ -1258,7 +1296,7 @@ var MergePreview = ({
|
|
|
1258
1296
|
separator,
|
|
1259
1297
|
maxOutputs
|
|
1260
1298
|
});
|
|
1261
|
-
const [copied, setCopied] = (0,
|
|
1299
|
+
const [copied, setCopied] = (0, import_react23.useState)(false);
|
|
1262
1300
|
const { source, result } = merge;
|
|
1263
1301
|
const copy = async () => {
|
|
1264
1302
|
try {
|
|
@@ -1415,11 +1453,11 @@ var MergePreview = ({
|
|
|
1415
1453
|
};
|
|
1416
1454
|
|
|
1417
1455
|
// src/hooks/useOutline.ts
|
|
1418
|
-
var
|
|
1456
|
+
var import_react24 = require("react");
|
|
1419
1457
|
var import_editor9 = require("@pixerate/editor");
|
|
1420
1458
|
function useOutline(editor) {
|
|
1421
|
-
const store = (0,
|
|
1422
|
-
return (0,
|
|
1459
|
+
const store = (0, import_react24.useMemo)(() => (0, import_editor9.createOutlineStore)(editor), [editor]);
|
|
1460
|
+
return (0, import_react24.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1423
1461
|
}
|
|
1424
1462
|
|
|
1425
1463
|
// src/components/OutlinePanel.tsx
|
|
@@ -1464,12 +1502,12 @@ var OutlinePanel = ({
|
|
|
1464
1502
|
};
|
|
1465
1503
|
|
|
1466
1504
|
// src/hooks/useParagraphStyles.ts
|
|
1467
|
-
var
|
|
1505
|
+
var import_react25 = require("react");
|
|
1468
1506
|
var import_editor11 = require("@pixerate/editor");
|
|
1469
1507
|
function useParagraphStyles(editor) {
|
|
1470
|
-
const store = (0,
|
|
1471
|
-
const snapshot = (0,
|
|
1472
|
-
return (0,
|
|
1508
|
+
const store = (0, import_react25.useMemo)(() => (0, import_editor11.createParagraphStylesStore)(editor), [editor]);
|
|
1509
|
+
const snapshot = (0, import_react25.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
1510
|
+
return (0, import_react25.useMemo)(() => {
|
|
1473
1511
|
const registry = (0, import_editor11.getStyleRegistry)(editor);
|
|
1474
1512
|
const live = () => editor && !editor.isDestroyed ? editor : null;
|
|
1475
1513
|
return {
|
|
@@ -1492,7 +1530,7 @@ function useParagraphStyles(editor) {
|
|
|
1492
1530
|
}
|
|
1493
1531
|
|
|
1494
1532
|
// src/components/StylesGallery.tsx
|
|
1495
|
-
var
|
|
1533
|
+
var import_react26 = require("react");
|
|
1496
1534
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1497
1535
|
var camel = (property) => property.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1498
1536
|
var keepSelection = (event) => event.preventDefault();
|
|
@@ -1508,9 +1546,9 @@ var StylesGallery = ({
|
|
|
1508
1546
|
onChange
|
|
1509
1547
|
}) => {
|
|
1510
1548
|
const styles = useParagraphStyles(editor);
|
|
1511
|
-
const [open, setOpen] = (0,
|
|
1512
|
-
const [creating, setCreating] = (0,
|
|
1513
|
-
const [name, setName] = (0,
|
|
1549
|
+
const [open, setOpen] = (0, import_react26.useState)(false);
|
|
1550
|
+
const [creating, setCreating] = (0, import_react26.useState)(false);
|
|
1551
|
+
const [name, setName] = (0, import_react26.useState)("");
|
|
1514
1552
|
const list = showAllStyles ? styles.styles : styles.gallery;
|
|
1515
1553
|
const current = styles.currentStyle;
|
|
1516
1554
|
const expanded = variant === "gallery" || open;
|
|
@@ -1626,13 +1664,13 @@ var StylesGallery = ({
|
|
|
1626
1664
|
var import_editor21 = require("@pixerate/editor");
|
|
1627
1665
|
|
|
1628
1666
|
// src/spreadsheet/useSpreadsheetEditor.ts
|
|
1629
|
-
var
|
|
1667
|
+
var import_react27 = require("react");
|
|
1630
1668
|
var import_spreadsheet = require("@pixerate/editor/spreadsheet");
|
|
1631
1669
|
function useSpreadsheetEditor(options = {}) {
|
|
1632
|
-
const optionsRef = (0,
|
|
1670
|
+
const optionsRef = (0, import_react27.useRef)(options);
|
|
1633
1671
|
optionsRef.current = options;
|
|
1634
|
-
const settersRef = (0,
|
|
1635
|
-
const [controller] = (0,
|
|
1672
|
+
const settersRef = (0, import_react27.useRef)({});
|
|
1673
|
+
const [controller] = (0, import_react27.useState)(
|
|
1636
1674
|
() => new import_spreadsheet.SpreadsheetController({
|
|
1637
1675
|
...options,
|
|
1638
1676
|
onDocumentChange: (updated) => {
|
|
@@ -1649,37 +1687,37 @@ function useSpreadsheetEditor(options = {}) {
|
|
|
1649
1687
|
}
|
|
1650
1688
|
})
|
|
1651
1689
|
);
|
|
1652
|
-
const [doc, setDoc] = (0,
|
|
1653
|
-
const [activeCell, setActiveCell] = (0,
|
|
1654
|
-
const [selectedRange, setSelectedRange] = (0,
|
|
1655
|
-
const [editingCell, setEditingCell] = (0,
|
|
1656
|
-
const [draftValue, setDraftState] = (0,
|
|
1657
|
-
const [validationPrompt, setValidationPrompt] = (0,
|
|
1690
|
+
const [doc, setDoc] = (0, import_react27.useState)(() => ({ ...controller.document }));
|
|
1691
|
+
const [activeCell, setActiveCell] = (0, import_react27.useState)(controller.activeCell);
|
|
1692
|
+
const [selectedRange, setSelectedRange] = (0, import_react27.useState)(controller.selectedRange);
|
|
1693
|
+
const [editingCell, setEditingCell] = (0, import_react27.useState)(null);
|
|
1694
|
+
const [draftValue, setDraftState] = (0, import_react27.useState)("");
|
|
1695
|
+
const [validationPrompt, setValidationPrompt] = (0, import_react27.useState)(null);
|
|
1658
1696
|
settersRef.current = { setDoc, setActiveCell, setSelectedRange };
|
|
1659
|
-
const setDraftValue = (0,
|
|
1697
|
+
const setDraftValue = (0, import_react27.useCallback)((value) => {
|
|
1660
1698
|
controller.draftValue = value;
|
|
1661
1699
|
setDraftState(value);
|
|
1662
1700
|
}, [controller]);
|
|
1663
|
-
const setCellValue = (0,
|
|
1701
|
+
const setCellValue = (0, import_react27.useCallback)((rowId, colId, raw) => {
|
|
1664
1702
|
controller.setCellValue(rowId, colId, raw);
|
|
1665
1703
|
setDoc({ ...controller.document });
|
|
1666
1704
|
}, [controller]);
|
|
1667
|
-
const selectCell = (0,
|
|
1705
|
+
const selectCell = (0, import_react27.useCallback)((row, col, extendSelection = false) => {
|
|
1668
1706
|
controller.selectCell(row, col, extendSelection);
|
|
1669
1707
|
setActiveCell(controller.activeCell);
|
|
1670
1708
|
setSelectedRange(controller.selectedRange);
|
|
1671
1709
|
}, [controller]);
|
|
1672
|
-
const selectRange = (0,
|
|
1710
|
+
const selectRange = (0, import_react27.useCallback)((range) => {
|
|
1673
1711
|
controller.selectRange(range);
|
|
1674
1712
|
setSelectedRange(controller.selectedRange);
|
|
1675
1713
|
}, [controller]);
|
|
1676
|
-
const startEditing = (0,
|
|
1714
|
+
const startEditing = (0, import_react27.useCallback)((row, col, initialVal) => {
|
|
1677
1715
|
controller.startEditing(row, col, initialVal);
|
|
1678
1716
|
setActiveCell(controller.activeCell);
|
|
1679
1717
|
setEditingCell(controller.editingCell);
|
|
1680
1718
|
setDraftValue(controller.draftValue);
|
|
1681
1719
|
}, [controller]);
|
|
1682
|
-
const syncEditing = (0,
|
|
1720
|
+
const syncEditing = (0, import_react27.useCallback)(() => {
|
|
1683
1721
|
setEditingCell(controller.editingCell);
|
|
1684
1722
|
setDraftValue(controller.draftValue);
|
|
1685
1723
|
setValidationPrompt(controller.validationPrompt);
|
|
@@ -1687,90 +1725,90 @@ function useSpreadsheetEditor(options = {}) {
|
|
|
1687
1725
|
setSelectedRange(controller.selectedRange);
|
|
1688
1726
|
setDoc({ ...controller.document });
|
|
1689
1727
|
}, [controller]);
|
|
1690
|
-
const commitEditing = (0,
|
|
1728
|
+
const commitEditing = (0, import_react27.useCallback)((val) => {
|
|
1691
1729
|
const result = controller.commitEditing(val);
|
|
1692
1730
|
syncEditing();
|
|
1693
1731
|
return result;
|
|
1694
1732
|
}, [controller, syncEditing]);
|
|
1695
|
-
const commitCellInput = (0,
|
|
1733
|
+
const commitCellInput = (0, import_react27.useCallback)((rowId, colId, raw) => {
|
|
1696
1734
|
const result = controller.commitCellInput(rowId, colId, raw);
|
|
1697
1735
|
syncEditing();
|
|
1698
1736
|
return result;
|
|
1699
1737
|
}, [controller, syncEditing]);
|
|
1700
|
-
const resolveValidationPrompt = (0,
|
|
1738
|
+
const resolveValidationPrompt = (0, import_react27.useCallback)((action) => {
|
|
1701
1739
|
controller.resolveValidationPrompt(action);
|
|
1702
1740
|
syncEditing();
|
|
1703
1741
|
}, [controller, syncEditing]);
|
|
1704
|
-
const cancelEditing = (0,
|
|
1742
|
+
const cancelEditing = (0, import_react27.useCallback)(() => {
|
|
1705
1743
|
controller.cancelEditing();
|
|
1706
1744
|
setEditingCell(null);
|
|
1707
1745
|
setDraftValue("");
|
|
1708
1746
|
}, [controller]);
|
|
1709
|
-
const moveCursor = (0,
|
|
1747
|
+
const moveCursor = (0, import_react27.useCallback)((dir, extend = false) => {
|
|
1710
1748
|
controller.moveCursor(dir, extend);
|
|
1711
1749
|
setActiveCell(controller.activeCell);
|
|
1712
1750
|
setSelectedRange(controller.selectedRange);
|
|
1713
1751
|
}, [controller]);
|
|
1714
|
-
const insertColumn = (0,
|
|
1752
|
+
const insertColumn = (0, import_react27.useCallback)((index, config) => {
|
|
1715
1753
|
controller.insertColumn(index, config);
|
|
1716
1754
|
setDoc({ ...controller.document });
|
|
1717
1755
|
}, [controller]);
|
|
1718
|
-
const deleteColumn = (0,
|
|
1756
|
+
const deleteColumn = (0, import_react27.useCallback)((colId) => {
|
|
1719
1757
|
controller.deleteColumn(colId);
|
|
1720
1758
|
setDoc({ ...controller.document });
|
|
1721
1759
|
}, [controller]);
|
|
1722
|
-
const insertRow = (0,
|
|
1760
|
+
const insertRow = (0, import_react27.useCallback)((index, config) => {
|
|
1723
1761
|
controller.insertRow(index, config);
|
|
1724
1762
|
setDoc({ ...controller.document });
|
|
1725
1763
|
}, [controller]);
|
|
1726
|
-
const deleteRow = (0,
|
|
1764
|
+
const deleteRow = (0, import_react27.useCallback)((rowId) => {
|
|
1727
1765
|
controller.deleteRow(rowId);
|
|
1728
1766
|
setDoc({ ...controller.document });
|
|
1729
1767
|
}, [controller]);
|
|
1730
|
-
const setColumnWidth = (0,
|
|
1768
|
+
const setColumnWidth = (0, import_react27.useCallback)((colId, width) => {
|
|
1731
1769
|
controller.setColumnWidth(colId, width);
|
|
1732
1770
|
setDoc({ ...controller.document });
|
|
1733
1771
|
}, [controller]);
|
|
1734
|
-
const autoFitColumnWidth = (0,
|
|
1772
|
+
const autoFitColumnWidth = (0, import_react27.useCallback)((colId, customWidth) => {
|
|
1735
1773
|
controller.autoFitColumnWidth(colId, customWidth);
|
|
1736
1774
|
setDoc({ ...controller.document });
|
|
1737
1775
|
}, [controller]);
|
|
1738
|
-
const registerDataSource = (0,
|
|
1776
|
+
const registerDataSource = (0, import_react27.useCallback)((ds) => {
|
|
1739
1777
|
controller.registerDataSource(ds);
|
|
1740
1778
|
setDoc({ ...controller.document });
|
|
1741
1779
|
}, [controller]);
|
|
1742
|
-
const setPrimaryDataSource = (0,
|
|
1780
|
+
const setPrimaryDataSource = (0, import_react27.useCallback)((id) => {
|
|
1743
1781
|
controller.setPrimaryDataSource(id);
|
|
1744
1782
|
setDoc({ ...controller.document });
|
|
1745
1783
|
}, [controller]);
|
|
1746
|
-
const recalculateAll = (0,
|
|
1784
|
+
const recalculateAll = (0, import_react27.useCallback)(() => {
|
|
1747
1785
|
controller.recalculateAll();
|
|
1748
1786
|
setDoc({ ...controller.document });
|
|
1749
1787
|
}, [controller]);
|
|
1750
|
-
const undo = (0,
|
|
1788
|
+
const undo = (0, import_react27.useCallback)(() => {
|
|
1751
1789
|
controller.undo();
|
|
1752
1790
|
setDoc({ ...controller.document });
|
|
1753
1791
|
setActiveCell(controller.activeCell);
|
|
1754
1792
|
setSelectedRange(controller.selectedRange);
|
|
1755
1793
|
}, [controller]);
|
|
1756
|
-
const redo = (0,
|
|
1794
|
+
const redo = (0, import_react27.useCallback)(() => {
|
|
1757
1795
|
controller.redo();
|
|
1758
1796
|
setDoc({ ...controller.document });
|
|
1759
1797
|
setActiveCell(controller.activeCell);
|
|
1760
1798
|
setSelectedRange(controller.selectedRange);
|
|
1761
1799
|
}, [controller]);
|
|
1762
|
-
const tableActions = (0,
|
|
1763
|
-
const viewModel = (0,
|
|
1764
|
-
const sheets = (0,
|
|
1765
|
-
const names = (0,
|
|
1766
|
-
const afterSheetSwitch = (0,
|
|
1800
|
+
const tableActions = (0, import_react27.useMemo)(() => (0, import_spreadsheet.bindSpreadsheetTableActions)(controller), [controller]);
|
|
1801
|
+
const viewModel = (0, import_react27.useMemo)(() => controller.getViewModel(), [controller, doc]);
|
|
1802
|
+
const sheets = (0, import_react27.useMemo)(() => controller.getSheets(), [controller, doc]);
|
|
1803
|
+
const names = (0, import_react27.useMemo)(() => controller.getNames(), [controller, doc]);
|
|
1804
|
+
const afterSheetSwitch = (0, import_react27.useCallback)(() => {
|
|
1767
1805
|
setEditingCell(controller.editingCell);
|
|
1768
1806
|
setDraftValue(controller.draftValue);
|
|
1769
1807
|
setActiveCell(controller.activeCell);
|
|
1770
1808
|
setSelectedRange(controller.selectedRange);
|
|
1771
1809
|
setDoc({ ...controller.document });
|
|
1772
1810
|
}, [controller, setDraftValue]);
|
|
1773
|
-
const workbookActions = (0,
|
|
1811
|
+
const workbookActions = (0, import_react27.useMemo)(
|
|
1774
1812
|
() => ({
|
|
1775
1813
|
setActiveSheet: (idOrName) => {
|
|
1776
1814
|
const changed = controller.setActiveSheet(idOrName);
|
|
@@ -1800,7 +1838,7 @@ function useSpreadsheetEditor(options = {}) {
|
|
|
1800
1838
|
}),
|
|
1801
1839
|
[controller, afterSheetSwitch]
|
|
1802
1840
|
);
|
|
1803
|
-
const conditionalFormatOverlay = (0,
|
|
1841
|
+
const conditionalFormatOverlay = (0, import_react27.useMemo)(() => controller.getConditionalFormatOverlay(), [controller, doc]);
|
|
1804
1842
|
return {
|
|
1805
1843
|
document: doc,
|
|
1806
1844
|
activeCell,
|
|
@@ -1862,20 +1900,20 @@ function useSpreadsheetEditor(options = {}) {
|
|
|
1862
1900
|
}
|
|
1863
1901
|
|
|
1864
1902
|
// src/spreadsheet/SpreadsheetEditor.tsx
|
|
1865
|
-
var
|
|
1903
|
+
var import_react36 = require("react");
|
|
1866
1904
|
var import_spreadsheet8 = require("@pixerate/editor/spreadsheet");
|
|
1867
1905
|
|
|
1868
1906
|
// src/spreadsheet/SpreadsheetContextMenu.tsx
|
|
1869
|
-
var
|
|
1907
|
+
var import_react28 = __toESM(require("react"), 1);
|
|
1870
1908
|
var import_spreadsheet2 = require("@pixerate/editor/spreadsheet");
|
|
1871
1909
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1872
1910
|
var VIEWPORT_MARGIN = 4;
|
|
1873
1911
|
var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "Table actions" }) => {
|
|
1874
|
-
const menuRef = (0,
|
|
1875
|
-
const onCloseRef = (0,
|
|
1912
|
+
const menuRef = (0, import_react28.useRef)(null);
|
|
1913
|
+
const onCloseRef = (0, import_react28.useRef)(onClose);
|
|
1876
1914
|
onCloseRef.current = onClose;
|
|
1877
|
-
const [position, setPosition] = (0,
|
|
1878
|
-
(0,
|
|
1915
|
+
const [position, setPosition] = (0, import_react28.useState)({ x, y });
|
|
1916
|
+
(0, import_react28.useLayoutEffect)(() => {
|
|
1879
1917
|
const menu = menuRef.current;
|
|
1880
1918
|
if (!menu || typeof window === "undefined") return;
|
|
1881
1919
|
const { width, height } = menu.getBoundingClientRect();
|
|
@@ -1887,7 +1925,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
|
|
|
1887
1925
|
);
|
|
1888
1926
|
setPosition((prev) => prev.x === next.x && prev.y === next.y ? prev : next);
|
|
1889
1927
|
}, [x, y, items]);
|
|
1890
|
-
(0,
|
|
1928
|
+
(0, import_react28.useEffect)(() => {
|
|
1891
1929
|
const handlePointer = (e) => {
|
|
1892
1930
|
if (!menuRef.current?.contains(e.target)) onCloseRef.current();
|
|
1893
1931
|
};
|
|
@@ -1917,7 +1955,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
|
|
|
1917
1955
|
},
|
|
1918
1956
|
onContextMenu: (e) => e.preventDefault(),
|
|
1919
1957
|
onKeyDown: (e) => e.stopPropagation(),
|
|
1920
|
-
children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1958
|
+
children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react28.default.Fragment, { children: [
|
|
1921
1959
|
item.separatorBefore && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { role: "separator", className: "my-1 h-px bg-border" }),
|
|
1922
1960
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1923
1961
|
"button",
|
|
@@ -1942,7 +1980,7 @@ var SpreadsheetContextMenu = ({ items, x, y, onClose, onOpenPanel, ariaLabel = "
|
|
|
1942
1980
|
};
|
|
1943
1981
|
|
|
1944
1982
|
// src/spreadsheet/SpreadsheetGroupRow.tsx
|
|
1945
|
-
var
|
|
1983
|
+
var import_react29 = __toESM(require("react"), 1);
|
|
1946
1984
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1947
1985
|
var formatSummary = (value) => value === null ? "\u2013" : String(value);
|
|
1948
1986
|
var SpreadsheetGroupRow = ({
|
|
@@ -1976,7 +2014,7 @@ var SpreadsheetGroupRow = ({
|
|
|
1976
2014
|
columns.map(({ column }, i) => {
|
|
1977
2015
|
const summary = group.summaries[column.id];
|
|
1978
2016
|
const before = leadingColumns !== void 0 && i === leadingColumns && leftSpace > 0 ? spacer("space:left") : null;
|
|
1979
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
2017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_react29.default.Fragment, { children: [
|
|
1980
2018
|
before,
|
|
1981
2019
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("td", { className: "border-r border-border px-2 py-1 truncate max-w-0 text-foreground", style: { maxWidth: 0, overflow: "hidden" }, children: column.id === labelColId ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: "truncate", children: [
|
|
1982
2020
|
group.label,
|
|
@@ -1996,7 +2034,7 @@ var SpreadsheetGroupRow = ({
|
|
|
1996
2034
|
};
|
|
1997
2035
|
|
|
1998
2036
|
// src/spreadsheet/useSpreadsheetTableInteractions.ts
|
|
1999
|
-
var
|
|
2037
|
+
var import_react30 = require("react");
|
|
2000
2038
|
var import_spreadsheet3 = require("@pixerate/editor/spreadsheet");
|
|
2001
2039
|
function gridHasFocus(grid) {
|
|
2002
2040
|
if (!grid || typeof document === "undefined") return false;
|
|
@@ -2005,12 +2043,12 @@ function gridHasFocus(grid) {
|
|
|
2005
2043
|
return !(active instanceof HTMLInputElement || active instanceof HTMLTextAreaElement);
|
|
2006
2044
|
}
|
|
2007
2045
|
function useSpreadsheetClipboard(gridRef, state, readOnly) {
|
|
2008
|
-
const stateRef = (0,
|
|
2046
|
+
const stateRef = (0, import_react30.useRef)(state);
|
|
2009
2047
|
stateRef.current = state;
|
|
2010
|
-
const readOnlyRef = (0,
|
|
2048
|
+
const readOnlyRef = (0, import_react30.useRef)(readOnly);
|
|
2011
2049
|
readOnlyRef.current = readOnly;
|
|
2012
|
-
const copiedRef = (0,
|
|
2013
|
-
(0,
|
|
2050
|
+
const copiedRef = (0, import_react30.useRef)(false);
|
|
2051
|
+
(0, import_react30.useEffect)(() => {
|
|
2014
2052
|
if (typeof document === "undefined") return;
|
|
2015
2053
|
const handleCopy = (e) => {
|
|
2016
2054
|
const s = stateRef.current;
|
|
@@ -2033,7 +2071,7 @@ function useSpreadsheetClipboard(gridRef, state, readOnly) {
|
|
|
2033
2071
|
document.removeEventListener("paste", handlePaste);
|
|
2034
2072
|
};
|
|
2035
2073
|
}, [gridRef]);
|
|
2036
|
-
const copyShortcutFallback = (0,
|
|
2074
|
+
const copyShortcutFallback = (0, import_react30.useCallback)(() => {
|
|
2037
2075
|
copiedRef.current = false;
|
|
2038
2076
|
setTimeout(() => {
|
|
2039
2077
|
if (copiedRef.current) return;
|
|
@@ -2045,13 +2083,13 @@ function useSpreadsheetClipboard(gridRef, state, readOnly) {
|
|
|
2045
2083
|
return { copyShortcutFallback };
|
|
2046
2084
|
}
|
|
2047
2085
|
function useFillHandle(state) {
|
|
2048
|
-
const [drag, setDrag] = (0,
|
|
2049
|
-
const dragRef = (0,
|
|
2086
|
+
const [drag, setDrag] = (0, import_react30.useState)(null);
|
|
2087
|
+
const dragRef = (0, import_react30.useRef)(drag);
|
|
2050
2088
|
dragRef.current = drag;
|
|
2051
|
-
const stateRef = (0,
|
|
2089
|
+
const stateRef = (0, import_react30.useRef)(state);
|
|
2052
2090
|
stateRef.current = state;
|
|
2053
2091
|
const dragging = drag !== null;
|
|
2054
|
-
(0,
|
|
2092
|
+
(0, import_react30.useEffect)(() => {
|
|
2055
2093
|
if (!dragging) return;
|
|
2056
2094
|
const handleMouseUp = () => {
|
|
2057
2095
|
const current = dragRef.current;
|
|
@@ -2061,13 +2099,13 @@ function useFillHandle(state) {
|
|
|
2061
2099
|
window.addEventListener("mouseup", handleMouseUp);
|
|
2062
2100
|
return () => window.removeEventListener("mouseup", handleMouseUp);
|
|
2063
2101
|
}, [dragging]);
|
|
2064
|
-
const startFill = (0,
|
|
2102
|
+
const startFill = (0, import_react30.useCallback)((e) => {
|
|
2065
2103
|
e.preventDefault();
|
|
2066
2104
|
e.stopPropagation();
|
|
2067
2105
|
const range = stateRef.current.selectedRange;
|
|
2068
2106
|
if (range) setDrag({ source: (0, import_spreadsheet3.normalizeRange)(range), target: null });
|
|
2069
2107
|
}, []);
|
|
2070
|
-
const extendFill = (0,
|
|
2108
|
+
const extendFill = (0, import_react30.useCallback)((row, col) => {
|
|
2071
2109
|
const current = dragRef.current;
|
|
2072
2110
|
if (!current) return;
|
|
2073
2111
|
setDrag({ source: current.source, target: (0, import_spreadsheet3.computeFillTarget)(current.source, { row, col }) });
|
|
@@ -2076,12 +2114,12 @@ function useFillHandle(state) {
|
|
|
2076
2114
|
}
|
|
2077
2115
|
|
|
2078
2116
|
// src/spreadsheet/SpreadsheetValidationDialog.tsx
|
|
2079
|
-
var
|
|
2117
|
+
var import_react31 = require("react");
|
|
2080
2118
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2081
2119
|
var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
|
|
2082
2120
|
const style = prompt.result.errorStyle ?? "stop";
|
|
2083
|
-
const firstButton = (0,
|
|
2084
|
-
(0,
|
|
2121
|
+
const firstButton = (0, import_react31.useRef)(null);
|
|
2122
|
+
(0, import_react31.useEffect)(() => {
|
|
2085
2123
|
firstButton.current?.focus();
|
|
2086
2124
|
}, [prompt]);
|
|
2087
2125
|
const buttons = style === "stop" ? [
|
|
@@ -2147,7 +2185,7 @@ var SpreadsheetValidationDialog = ({ prompt, onResolve }) => {
|
|
|
2147
2185
|
};
|
|
2148
2186
|
|
|
2149
2187
|
// src/spreadsheet/SpreadsheetRulePanels.tsx
|
|
2150
|
-
var
|
|
2188
|
+
var import_react32 = require("react");
|
|
2151
2189
|
var import_spreadsheet4 = require("@pixerate/editor/spreadsheet");
|
|
2152
2190
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2153
2191
|
var inputClass = "w-full rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground";
|
|
@@ -2201,18 +2239,18 @@ function RuleSwatch({ rule }) {
|
|
|
2201
2239
|
}
|
|
2202
2240
|
var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
|
|
2203
2241
|
const rules = state.document.table?.conditionalFormats ?? [];
|
|
2204
|
-
const [kind, setKind] = (0,
|
|
2205
|
-
const [appliesTo, setAppliesTo] = (0,
|
|
2206
|
-
const [value, setValue] = (0,
|
|
2207
|
-
const [value2, setValue2] = (0,
|
|
2208
|
-
const [text, setText] = (0,
|
|
2209
|
-
const [formula, setFormula] = (0,
|
|
2210
|
-
const [rank, setRank] = (0,
|
|
2211
|
-
const [period, setPeriod] = (0,
|
|
2212
|
-
const [iconSet, setIconSet] = (0,
|
|
2213
|
-
const [color, setColor] = (0,
|
|
2214
|
-
const [styleId, setStyleId] = (0,
|
|
2215
|
-
const preset = (0,
|
|
2242
|
+
const [kind, setKind] = (0, import_react32.useState)("greaterThan");
|
|
2243
|
+
const [appliesTo, setAppliesTo] = (0, import_react32.useState)(() => selectionText(state.selectedRange));
|
|
2244
|
+
const [value, setValue] = (0, import_react32.useState)("");
|
|
2245
|
+
const [value2, setValue2] = (0, import_react32.useState)("");
|
|
2246
|
+
const [text, setText] = (0, import_react32.useState)("");
|
|
2247
|
+
const [formula, setFormula] = (0, import_react32.useState)("=");
|
|
2248
|
+
const [rank, setRank] = (0, import_react32.useState)("10");
|
|
2249
|
+
const [period, setPeriod] = (0, import_react32.useState)("today");
|
|
2250
|
+
const [iconSet, setIconSet] = (0, import_react32.useState)("3TrafficLights1");
|
|
2251
|
+
const [color, setColor] = (0, import_react32.useState)("#638ec6");
|
|
2252
|
+
const [styleId, setStyleId] = (0, import_react32.useState)(import_spreadsheet4.CONDITIONAL_FORMAT_STYLE_PRESETS[0].id);
|
|
2253
|
+
const preset = (0, import_react32.useMemo)(() => import_spreadsheet4.CONDITIONAL_FORMAT_PRESETS.find((p) => p.kind === kind), [kind]);
|
|
2216
2254
|
const ranges = (0, import_spreadsheet4.parseRuleRanges)(appliesTo);
|
|
2217
2255
|
const add = () => {
|
|
2218
2256
|
if (!ranges) return;
|
|
@@ -2296,15 +2334,15 @@ var SpreadsheetConditionalFormatPanel = ({ state, onClose }) => {
|
|
|
2296
2334
|
};
|
|
2297
2335
|
var SpreadsheetDataValidationPanel = ({ state, onClose }) => {
|
|
2298
2336
|
const rules = state.document.table?.dataValidations ?? [];
|
|
2299
|
-
const [type, setType] = (0,
|
|
2300
|
-
const [operator, setOperator] = (0,
|
|
2301
|
-
const [formula1, setFormula1] = (0,
|
|
2302
|
-
const [formula2, setFormula2] = (0,
|
|
2303
|
-
const [errorStyle, setErrorStyle] = (0,
|
|
2304
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
2305
|
-
const [inputMessage, setInputMessage] = (0,
|
|
2306
|
-
const [ignoreBlank, setIgnoreBlank] = (0,
|
|
2307
|
-
const [appliesTo, setAppliesTo] = (0,
|
|
2337
|
+
const [type, setType] = (0, import_react32.useState)("list");
|
|
2338
|
+
const [operator, setOperator] = (0, import_react32.useState)("between");
|
|
2339
|
+
const [formula1, setFormula1] = (0, import_react32.useState)("");
|
|
2340
|
+
const [formula2, setFormula2] = (0, import_react32.useState)("");
|
|
2341
|
+
const [errorStyle, setErrorStyle] = (0, import_react32.useState)("stop");
|
|
2342
|
+
const [errorMessage, setErrorMessage] = (0, import_react32.useState)("");
|
|
2343
|
+
const [inputMessage, setInputMessage] = (0, import_react32.useState)("");
|
|
2344
|
+
const [ignoreBlank, setIgnoreBlank] = (0, import_react32.useState)(true);
|
|
2345
|
+
const [appliesTo, setAppliesTo] = (0, import_react32.useState)(() => selectionText(state.selectedRange));
|
|
2308
2346
|
const ranges = (0, import_spreadsheet4.parseRuleRanges)(appliesTo);
|
|
2309
2347
|
const usesOperator = type === "whole" || type === "decimal" || type === "date" || type === "time" || type === "textLength";
|
|
2310
2348
|
const needsTwo = usesOperator && (operator === "between" || operator === "notBetween");
|
|
@@ -2378,29 +2416,29 @@ var SpreadsheetDataValidationPanel = ({ state, onClose }) => {
|
|
|
2378
2416
|
};
|
|
2379
2417
|
|
|
2380
2418
|
// src/spreadsheet/useSpreadsheetViewport.ts
|
|
2381
|
-
var
|
|
2419
|
+
var import_react33 = require("react");
|
|
2382
2420
|
var import_spreadsheet5 = require("@pixerate/editor/spreadsheet");
|
|
2383
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ?
|
|
2421
|
+
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_react33.useLayoutEffect : import_react33.useEffect;
|
|
2384
2422
|
function useSpreadsheetViewport(scrollRef, view, options = {}) {
|
|
2385
|
-
const metrics = (0,
|
|
2423
|
+
const metrics = (0, import_react33.useMemo)(() => (0, import_spreadsheet5.measureSpreadsheetView)(view), [view]);
|
|
2386
2424
|
const virtual = (0, import_spreadsheet5.shouldVirtualizeSpreadsheet)(view, options.virtualize ?? "auto");
|
|
2387
|
-
const [viewport, setViewport] = (0,
|
|
2388
|
-
const windowOptions = (0,
|
|
2425
|
+
const [viewport, setViewport] = (0, import_react33.useState)({ scrollTop: 0, scrollLeft: 0, width: 0, height: 0 });
|
|
2426
|
+
const windowOptions = (0, import_react33.useMemo)(
|
|
2389
2427
|
() => ({ merges: options.merges, overscanRows: options.overscanRows, overscanColumns: options.overscanColumns }),
|
|
2390
2428
|
[options.merges, options.overscanRows, options.overscanColumns]
|
|
2391
2429
|
);
|
|
2392
|
-
const win = (0,
|
|
2430
|
+
const win = (0, import_react33.useMemo)(
|
|
2393
2431
|
() => virtual ? (0, import_spreadsheet5.getSpreadsheetViewWindow)(metrics, viewport, windowOptions) : (0, import_spreadsheet5.fullSpreadsheetViewWindow)(metrics),
|
|
2394
2432
|
[virtual, metrics, viewport, windowOptions]
|
|
2395
2433
|
);
|
|
2396
|
-
const latest = (0,
|
|
2434
|
+
const latest = (0, import_react33.useRef)({ metrics, viewport, virtual, windowOptions });
|
|
2397
2435
|
latest.current = { metrics, viewport, virtual, windowOptions };
|
|
2398
|
-
const readViewport = (0,
|
|
2436
|
+
const readViewport = (0, import_react33.useCallback)(() => {
|
|
2399
2437
|
const el = scrollRef.current;
|
|
2400
2438
|
if (!el) return null;
|
|
2401
2439
|
return { scrollTop: el.scrollTop, scrollLeft: el.scrollLeft, width: el.clientWidth, height: el.clientHeight };
|
|
2402
2440
|
}, [scrollRef]);
|
|
2403
|
-
const updateViewport = (0,
|
|
2441
|
+
const updateViewport = (0, import_react33.useCallback)((next) => {
|
|
2404
2442
|
setViewport((prev) => {
|
|
2405
2443
|
const { metrics: m, virtual: v, windowOptions: o } = latest.current;
|
|
2406
2444
|
if (!v) return prev;
|
|
@@ -2408,7 +2446,7 @@ function useSpreadsheetViewport(scrollRef, view, options = {}) {
|
|
|
2408
2446
|
return same ? prev : next;
|
|
2409
2447
|
});
|
|
2410
2448
|
}, []);
|
|
2411
|
-
const onScroll = (0,
|
|
2449
|
+
const onScroll = (0, import_react33.useCallback)(() => {
|
|
2412
2450
|
const next = readViewport();
|
|
2413
2451
|
if (next) updateViewport(next);
|
|
2414
2452
|
}, [readViewport, updateViewport]);
|
|
@@ -2442,24 +2480,24 @@ function useSpreadsheetViewport(scrollRef, view, options = {}) {
|
|
|
2442
2480
|
}
|
|
2443
2481
|
|
|
2444
2482
|
// src/spreadsheet/FormulaHints.tsx
|
|
2445
|
-
var
|
|
2483
|
+
var import_react34 = require("react");
|
|
2446
2484
|
var import_spreadsheet6 = require("@pixerate/editor/spreadsheet");
|
|
2447
2485
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2448
2486
|
var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
|
|
2449
|
-
const [caret, setCaret] = (0,
|
|
2450
|
-
const [focused, setFocused] = (0,
|
|
2451
|
-
const [selected, setSelected] = (0,
|
|
2452
|
-
const [dismissed, setDismissed] = (0,
|
|
2453
|
-
const [position, setPosition] = (0,
|
|
2454
|
-
const pendingCaret = (0,
|
|
2455
|
-
const hints = (0,
|
|
2487
|
+
const [caret, setCaret] = (0, import_react34.useState)(null);
|
|
2488
|
+
const [focused, setFocused] = (0, import_react34.useState)(false);
|
|
2489
|
+
const [selected, setSelected] = (0, import_react34.useState)(0);
|
|
2490
|
+
const [dismissed, setDismissed] = (0, import_react34.useState)(false);
|
|
2491
|
+
const [position, setPosition] = (0, import_react34.useState)(null);
|
|
2492
|
+
const pendingCaret = (0, import_react34.useRef)(null);
|
|
2493
|
+
const hints = (0, import_react34.useMemo)(
|
|
2456
2494
|
() => (0, import_spreadsheet6.getFormulaHints)(value, caret ?? value.length, { limit, names }),
|
|
2457
2495
|
[value, caret, limit, names]
|
|
2458
2496
|
);
|
|
2459
2497
|
const suggestions = dismissed ? [] : hints.suggestions;
|
|
2460
2498
|
const selectedIndex = Math.max(0, Math.min(selected, suggestions.length - 1));
|
|
2461
2499
|
const visible = focused && value.trimStart().startsWith("=") && (suggestions.length > 0 || !!hints.activeCall);
|
|
2462
|
-
const latest = (0,
|
|
2500
|
+
const latest = (0, import_react34.useRef)({ suggestions, selected: selectedIndex, value, caret, onAccept });
|
|
2463
2501
|
latest.current = { suggestions, selected: selectedIndex, value, caret, onAccept };
|
|
2464
2502
|
const accept = (index) => {
|
|
2465
2503
|
const { suggestions: list, value: current, caret: at, onAccept: commit } = latest.current;
|
|
@@ -2469,7 +2507,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
|
|
|
2469
2507
|
pendingCaret.current = next.caret;
|
|
2470
2508
|
commit(next.value);
|
|
2471
2509
|
};
|
|
2472
|
-
(0,
|
|
2510
|
+
(0, import_react34.useEffect)(() => {
|
|
2473
2511
|
const input = inputRef.current;
|
|
2474
2512
|
if (!input) return;
|
|
2475
2513
|
const syncCaret = () => setCaret(input.selectionStart ?? input.value.length);
|
|
@@ -2519,7 +2557,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
|
|
|
2519
2557
|
input.removeEventListener("keydown", onKeyDown);
|
|
2520
2558
|
};
|
|
2521
2559
|
}, [inputRef]);
|
|
2522
|
-
(0,
|
|
2560
|
+
(0, import_react34.useLayoutEffect)(() => {
|
|
2523
2561
|
const input = inputRef.current;
|
|
2524
2562
|
const at = pendingCaret.current;
|
|
2525
2563
|
if (!input || at === null || input.value !== value) return;
|
|
@@ -2528,7 +2566,7 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
|
|
|
2528
2566
|
setCaret(at);
|
|
2529
2567
|
setSelected(0);
|
|
2530
2568
|
}, [value, inputRef]);
|
|
2531
|
-
(0,
|
|
2569
|
+
(0, import_react34.useLayoutEffect)(() => {
|
|
2532
2570
|
const input = inputRef.current;
|
|
2533
2571
|
if (!visible || !input) return;
|
|
2534
2572
|
const rect = input.getBoundingClientRect();
|
|
@@ -2592,16 +2630,16 @@ var FormulaHints = ({ inputRef, value, onAccept, limit = 8, names }) => {
|
|
|
2592
2630
|
};
|
|
2593
2631
|
|
|
2594
2632
|
// src/spreadsheet/SheetTabs.tsx
|
|
2595
|
-
var
|
|
2633
|
+
var import_react35 = require("react");
|
|
2596
2634
|
var import_spreadsheet7 = require("@pixerate/editor/spreadsheet");
|
|
2597
2635
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2598
2636
|
var SheetTabs = ({ state, readOnly = false, className = "" }) => {
|
|
2599
2637
|
const { controller, sheets } = state;
|
|
2600
|
-
const [renaming, setRenaming] = (0,
|
|
2601
|
-
const [error, setError] = (0,
|
|
2602
|
-
const [menu, setMenu] = (0,
|
|
2603
|
-
const dragFrom = (0,
|
|
2604
|
-
const [dropTarget, setDropTarget] = (0,
|
|
2638
|
+
const [renaming, setRenaming] = (0, import_react35.useState)(null);
|
|
2639
|
+
const [error, setError] = (0, import_react35.useState)(null);
|
|
2640
|
+
const [menu, setMenu] = (0, import_react35.useState)(null);
|
|
2641
|
+
const dragFrom = (0, import_react35.useRef)(null);
|
|
2642
|
+
const [dropTarget, setDropTarget] = (0, import_react35.useState)(null);
|
|
2605
2643
|
const commitRename = (cancelOnError) => {
|
|
2606
2644
|
if (!renaming) return;
|
|
2607
2645
|
const sheet = sheets.find((s) => s.id === renaming.id);
|
|
@@ -2799,25 +2837,67 @@ var SpreadsheetEditor = ({
|
|
|
2799
2837
|
onColumnHeaderClick,
|
|
2800
2838
|
onColumnResize,
|
|
2801
2839
|
showSheetTabs = false,
|
|
2802
|
-
virtualize = "auto"
|
|
2840
|
+
virtualize = "auto",
|
|
2841
|
+
playback,
|
|
2842
|
+
playbackId = "spreadsheet",
|
|
2843
|
+
onPlaybackReveal
|
|
2803
2844
|
}) => {
|
|
2804
2845
|
const defaultState = useSpreadsheetEditor();
|
|
2805
2846
|
const state = externalState || defaultState;
|
|
2806
|
-
const gridRef = (0,
|
|
2807
|
-
const
|
|
2808
|
-
const
|
|
2809
|
-
const
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2847
|
+
const gridRef = (0, import_react36.useRef)(null);
|
|
2848
|
+
const ambientPlayback = useAgentPlayback();
|
|
2849
|
+
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
2850
|
+
const agentPresence = usePlaybackSurface(playing, playbackId, {
|
|
2851
|
+
defaultKind: "cell",
|
|
2852
|
+
locate: (ref) => {
|
|
2853
|
+
const grid2 = gridRef.current;
|
|
2854
|
+
const range = (0, import_spreadsheet8.parseSpreadsheetPlaybackRef)(ref);
|
|
2855
|
+
if (!grid2 || !range) return null;
|
|
2856
|
+
const box = grid2.getBoundingClientRect();
|
|
2857
|
+
const inside = (v, a, b) => (a === null || v >= a) && (b === null || v <= b);
|
|
2858
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
2859
|
+
for (const td of grid2.querySelectorAll("td[data-row][data-col]")) {
|
|
2860
|
+
if (!inside(Number(td.dataset.row), range.startRow, range.endRow) || !inside(Number(td.dataset.col), range.startCol, range.endCol)) continue;
|
|
2861
|
+
const r = td.getBoundingClientRect();
|
|
2862
|
+
minX = Math.min(minX, r.left - box.left);
|
|
2863
|
+
minY = Math.min(minY, r.top - box.top);
|
|
2864
|
+
maxX = Math.max(maxX, r.right - box.left);
|
|
2865
|
+
maxY = Math.max(maxY, r.bottom - box.top);
|
|
2866
|
+
}
|
|
2867
|
+
return minX < maxX ? { x: minX, y: minY, width: maxX - minX, height: maxY - minY } : null;
|
|
2868
|
+
},
|
|
2869
|
+
bounds: () => {
|
|
2870
|
+
const r = gridRef.current?.getBoundingClientRect();
|
|
2871
|
+
return r && r.width > 0 ? { x: 0, y: 0, width: r.width, height: r.height } : null;
|
|
2872
|
+
},
|
|
2873
|
+
visible: () => {
|
|
2874
|
+
const r = gridRef.current?.getBoundingClientRect();
|
|
2875
|
+
return !!r && r.width > 0 && r.height > 0 && !(typeof document !== "undefined" && document.visibilityState === "hidden");
|
|
2876
|
+
},
|
|
2877
|
+
toViewport: (p) => {
|
|
2878
|
+
const r = gridRef.current?.getBoundingClientRect();
|
|
2879
|
+
return { x: (r?.left ?? 0) + p.x, y: (r?.top ?? 0) + p.y };
|
|
2880
|
+
},
|
|
2881
|
+
fromViewport: (p) => {
|
|
2882
|
+
const r = gridRef.current?.getBoundingClientRect();
|
|
2883
|
+
return { x: p.x - (r?.left ?? 0), y: p.y - (r?.top ?? 0) };
|
|
2884
|
+
},
|
|
2885
|
+
reveal: () => onPlaybackReveal?.()
|
|
2886
|
+
});
|
|
2887
|
+
const scrollRef = (0, import_react36.useRef)(null);
|
|
2888
|
+
const formulaBarRef = (0, import_react36.useRef)(null);
|
|
2889
|
+
const cellInputRef = (0, import_react36.useRef)(null);
|
|
2890
|
+
const [resizingColId, setResizingColId] = (0, import_react36.useState)(null);
|
|
2891
|
+
const [hoveredColId, setHoveredColId] = (0, import_react36.useState)(null);
|
|
2892
|
+
const [resizeStartX, setResizeStartX] = (0, import_react36.useState)(0);
|
|
2893
|
+
const [resizeStartWidth, setResizeStartWidth] = (0, import_react36.useState)(0);
|
|
2814
2894
|
const view = state.viewModel;
|
|
2815
2895
|
const { window: viewWindow, onScroll: handleGridScroll } = useSpreadsheetViewport(scrollRef, view, {
|
|
2816
2896
|
virtualize,
|
|
2817
2897
|
merges: state.document.table?.merges,
|
|
2818
2898
|
activeCell: state.activeCell
|
|
2819
2899
|
});
|
|
2820
|
-
const columnSlots = (0,
|
|
2900
|
+
const columnSlots = (0, import_react36.useMemo)(() => {
|
|
2821
2901
|
const col = (viewCol) => ({ kind: "col", viewCol });
|
|
2822
2902
|
if (!viewWindow.virtual) return view.columns.map(col);
|
|
2823
2903
|
const slots = view.columns.slice(0, viewWindow.frozenColumns).map(col);
|
|
@@ -2826,11 +2906,11 @@ var SpreadsheetEditor = ({
|
|
|
2826
2906
|
if (viewWindow.rightSpace > 0) slots.push({ kind: "space", key: "space:right", width: viewWindow.rightSpace });
|
|
2827
2907
|
return slots;
|
|
2828
2908
|
}, [view, viewWindow]);
|
|
2829
|
-
const renderedColumns = (0,
|
|
2909
|
+
const renderedColumns = (0, import_react36.useMemo)(
|
|
2830
2910
|
() => columnSlots.flatMap((slot) => slot.kind === "col" ? [slot.viewCol] : []),
|
|
2831
2911
|
[columnSlots]
|
|
2832
2912
|
);
|
|
2833
|
-
const rowSlots = (0,
|
|
2913
|
+
const rowSlots = (0, import_react36.useMemo)(() => {
|
|
2834
2914
|
const row = (viewRow) => ({ kind: "row", viewRow });
|
|
2835
2915
|
if (!viewWindow.virtual) return view.rows.map(row);
|
|
2836
2916
|
const slots = view.rows.slice(0, viewWindow.frozenRows).map(row);
|
|
@@ -2841,16 +2921,16 @@ var SpreadsheetEditor = ({
|
|
|
2841
2921
|
}, [view, viewWindow]);
|
|
2842
2922
|
const { copyShortcutFallback } = useSpreadsheetClipboard(gridRef, state, readOnly);
|
|
2843
2923
|
const { fillTarget, startFill, extendFill } = useFillHandle(state);
|
|
2844
|
-
const [menu, setMenu] = (0,
|
|
2845
|
-
const [panel, setPanel] = (0,
|
|
2846
|
-
const [listMenu, setListMenu] = (0,
|
|
2924
|
+
const [menu, setMenu] = (0, import_react36.useState)(null);
|
|
2925
|
+
const [panel, setPanel] = (0, import_react36.useState)(null);
|
|
2926
|
+
const [listMenu, setListMenu] = (0, import_react36.useState)(null);
|
|
2847
2927
|
const overlay = state.conditionalFormatOverlay;
|
|
2848
2928
|
const filter = state.document.table?.filter;
|
|
2849
|
-
const filteredColIds = (0,
|
|
2929
|
+
const filteredColIds = (0, import_react36.useMemo)(
|
|
2850
2930
|
() => new Set(filter?.enabled ? filter.rules.map((r) => r.colId) : []),
|
|
2851
2931
|
[filter]
|
|
2852
2932
|
);
|
|
2853
|
-
const handleCellContextMenu = (0,
|
|
2933
|
+
const handleCellContextMenu = (0, import_react36.useCallback)((rIdx, cIdx, e) => {
|
|
2854
2934
|
if (readOnly) return;
|
|
2855
2935
|
e.preventDefault();
|
|
2856
2936
|
if (state.editingCell) state.commitEditing();
|
|
@@ -2859,33 +2939,33 @@ var SpreadsheetEditor = ({
|
|
|
2859
2939
|
}
|
|
2860
2940
|
setMenu({ x: e.clientX, y: e.clientY, items: (0, import_spreadsheet8.getSpreadsheetMenuItems)(state.controller, { row: rIdx, col: cIdx }) });
|
|
2861
2941
|
}, [readOnly, state]);
|
|
2862
|
-
const nameSuggestions = (0,
|
|
2942
|
+
const nameSuggestions = (0, import_react36.useMemo)(
|
|
2863
2943
|
() => state.controller.getNameSuggestions(),
|
|
2864
2944
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2865
2945
|
[state.controller, state.document]
|
|
2866
2946
|
);
|
|
2867
|
-
const activeRawValue = (0,
|
|
2947
|
+
const activeRawValue = (0, import_react36.useMemo)(() => {
|
|
2868
2948
|
if (!state.activeCell) return "";
|
|
2869
2949
|
const row = state.document.rows[state.activeCell.row];
|
|
2870
2950
|
const col = state.document.columns[state.activeCell.col];
|
|
2871
2951
|
if (!row || !col) return "";
|
|
2872
2952
|
return state.getCell(row.id, col.id).raw;
|
|
2873
2953
|
}, [state.activeCell, state.document]);
|
|
2874
|
-
const activeSpill = (0,
|
|
2954
|
+
const activeSpill = (0, import_react36.useMemo)(
|
|
2875
2955
|
() => state.activeCell ? state.controller.getSpillAt(state.activeCell.row, state.activeCell.col) : null,
|
|
2876
2956
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2877
2957
|
[state.controller, state.activeCell, state.document]
|
|
2878
2958
|
);
|
|
2879
2959
|
const spillFormula = activeSpill && !activeRawValue && activeSpill.key !== coordKey(state.activeCell) ? activeSpill.formula : "";
|
|
2880
|
-
const coordLabel = (0,
|
|
2960
|
+
const coordLabel = (0, import_react36.useMemo)(() => {
|
|
2881
2961
|
if (!state.activeCell) return "--";
|
|
2882
2962
|
const colName = (0, import_spreadsheet8.indexToColName)(state.activeCell.col);
|
|
2883
2963
|
return `${colName}${state.activeCell.row + 1}`;
|
|
2884
2964
|
}, [state.activeCell]);
|
|
2885
|
-
const [formulaDraft, setFormulaDraft] = (0,
|
|
2965
|
+
const [formulaDraft, setFormulaDraft] = (0, import_react36.useState)(null);
|
|
2886
2966
|
const activeColumn = state.activeCell ? state.document.columns[state.activeCell.col] : void 0;
|
|
2887
2967
|
const formulaBarReadOnly = readOnly || !state.activeCell || !!activeColumn?.readOnly;
|
|
2888
|
-
(0,
|
|
2968
|
+
(0, import_react36.useEffect)(() => {
|
|
2889
2969
|
setFormulaDraft(null);
|
|
2890
2970
|
}, [state.activeCell?.row, state.activeCell?.col]);
|
|
2891
2971
|
const commitFormulaBar = () => {
|
|
@@ -2901,19 +2981,19 @@ var SpreadsheetEditor = ({
|
|
|
2901
2981
|
}
|
|
2902
2982
|
setFormulaDraft(null);
|
|
2903
2983
|
};
|
|
2904
|
-
const handleCellClick = (0,
|
|
2984
|
+
const handleCellClick = (0, import_react36.useCallback)((rIdx, cIdx, e) => {
|
|
2905
2985
|
if (state.editingCell && (state.editingCell.row !== rIdx || state.editingCell.col !== cIdx)) {
|
|
2906
2986
|
state.commitEditing();
|
|
2907
2987
|
}
|
|
2908
2988
|
state.selectCell(rIdx, cIdx, e.shiftKey);
|
|
2909
2989
|
}, [state]);
|
|
2910
|
-
const handleCellDblClick = (0,
|
|
2990
|
+
const handleCellDblClick = (0, import_react36.useCallback)((rIdx, cIdx) => {
|
|
2911
2991
|
if (readOnly) return;
|
|
2912
2992
|
const col = state.document.columns[cIdx];
|
|
2913
2993
|
if (col?.readOnly) return;
|
|
2914
2994
|
state.startEditing(rIdx, cIdx);
|
|
2915
2995
|
}, [readOnly, state]);
|
|
2916
|
-
const handleKeyDown = (0,
|
|
2996
|
+
const handleKeyDown = (0, import_react36.useCallback)((e) => {
|
|
2917
2997
|
if (state.editingCell) {
|
|
2918
2998
|
if (e.key === "Enter") {
|
|
2919
2999
|
e.preventDefault();
|
|
@@ -2985,12 +3065,12 @@ var SpreadsheetEditor = ({
|
|
|
2985
3065
|
}
|
|
2986
3066
|
}
|
|
2987
3067
|
}, [readOnly, state, copyShortcutFallback]);
|
|
2988
|
-
const activeListValues = (0,
|
|
3068
|
+
const activeListValues = (0, import_react36.useMemo)(
|
|
2989
3069
|
() => state.activeCell && !readOnly ? state.controller.getValidationListValues(state.activeCell.row, state.activeCell.col) : null,
|
|
2990
3070
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2991
3071
|
[state.controller, state.activeCell, state.document, readOnly]
|
|
2992
3072
|
);
|
|
2993
|
-
const activeRule = (0,
|
|
3073
|
+
const activeRule = (0, import_react36.useMemo)(
|
|
2994
3074
|
() => state.activeCell ? state.controller.getDataValidationAt(state.activeCell.row, state.activeCell.col) : void 0,
|
|
2995
3075
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2996
3076
|
[state.controller, state.activeCell, state.document]
|
|
@@ -3004,7 +3084,7 @@ var SpreadsheetEditor = ({
|
|
|
3004
3084
|
const rect = td?.getBoundingClientRect();
|
|
3005
3085
|
setListMenu({ x: rect ? rect.left : 0, y: rect ? rect.bottom : 0, row, col, values });
|
|
3006
3086
|
}
|
|
3007
|
-
(0,
|
|
3087
|
+
(0, import_react36.useEffect)(() => {
|
|
3008
3088
|
if (!listMenu) return;
|
|
3009
3089
|
const close = (e) => {
|
|
3010
3090
|
if (!e.target?.closest?.('[aria-label="Allowed values"], .spreadsheet-list-arrow')) setListMenu(null);
|
|
@@ -3027,11 +3107,11 @@ var SpreadsheetEditor = ({
|
|
|
3027
3107
|
else gridRef.current?.focus();
|
|
3028
3108
|
});
|
|
3029
3109
|
};
|
|
3030
|
-
const stateRef = (0,
|
|
3110
|
+
const stateRef = (0, import_react36.useRef)(state);
|
|
3031
3111
|
stateRef.current = state;
|
|
3032
|
-
const onColumnResizeRef = (0,
|
|
3112
|
+
const onColumnResizeRef = (0, import_react36.useRef)(onColumnResize);
|
|
3033
3113
|
onColumnResizeRef.current = onColumnResize;
|
|
3034
|
-
(0,
|
|
3114
|
+
(0, import_react36.useEffect)(() => {
|
|
3035
3115
|
if (!resizingColId) return;
|
|
3036
3116
|
if (typeof document !== "undefined") {
|
|
3037
3117
|
document.body.style.cursor = "col-resize";
|
|
@@ -3082,7 +3162,7 @@ var SpreadsheetEditor = ({
|
|
|
3082
3162
|
window.removeEventListener("mouseup", handleMouseUp);
|
|
3083
3163
|
};
|
|
3084
3164
|
}, [resizingColId, resizeStartX, resizeStartWidth]);
|
|
3085
|
-
const measureElementContentWidth = (0,
|
|
3165
|
+
const measureElementContentWidth = (0, import_react36.useCallback)((el, container) => {
|
|
3086
3166
|
if (typeof document === "undefined") return 0;
|
|
3087
3167
|
let maxW = el.scrollWidth || 0;
|
|
3088
3168
|
const firstChild = el.firstElementChild;
|
|
@@ -3130,7 +3210,7 @@ var SpreadsheetEditor = ({
|
|
|
3130
3210
|
}
|
|
3131
3211
|
return maxW;
|
|
3132
3212
|
}, []);
|
|
3133
|
-
const autoFitColumn = (0,
|
|
3213
|
+
const autoFitColumn = (0, import_react36.useCallback)((colId, colIndex) => {
|
|
3134
3214
|
const col = state.document.columns.find((c) => c.id === colId);
|
|
3135
3215
|
if (!col) return;
|
|
3136
3216
|
let calculatedWidth = 0;
|
|
@@ -3166,12 +3246,12 @@ var SpreadsheetEditor = ({
|
|
|
3166
3246
|
onColumnResize(updatedCol.id, updatedCol.width || 130);
|
|
3167
3247
|
}
|
|
3168
3248
|
}, [state, measureElementContentWidth, onColumnResize]);
|
|
3169
|
-
const handleResizeDblClick = (0,
|
|
3249
|
+
const handleResizeDblClick = (0, import_react36.useCallback)((colId, colIndex, e) => {
|
|
3170
3250
|
e.preventDefault();
|
|
3171
3251
|
e.stopPropagation();
|
|
3172
3252
|
autoFitColumn(colId, colIndex);
|
|
3173
3253
|
}, [autoFitColumn]);
|
|
3174
|
-
const handleHeaderDblClick = (0,
|
|
3254
|
+
const handleHeaderDblClick = (0, import_react36.useCallback)((colId, colIndex, e) => {
|
|
3175
3255
|
const target = e.currentTarget;
|
|
3176
3256
|
if (target) {
|
|
3177
3257
|
const rect = target.getBoundingClientRect();
|
|
@@ -3197,7 +3277,7 @@ var SpreadsheetEditor = ({
|
|
|
3197
3277
|
"div",
|
|
3198
3278
|
{
|
|
3199
3279
|
ref: gridRef,
|
|
3200
|
-
className: "flex flex-col h-full w-full overflow-hidden border border-border bg-background select-none outline-none text-foreground font-sans text-xs",
|
|
3280
|
+
className: "relative flex flex-col h-full w-full overflow-hidden border border-border bg-background select-none outline-none text-foreground font-sans text-xs",
|
|
3201
3281
|
tabIndex: 0,
|
|
3202
3282
|
onKeyDown: handleKeyDown,
|
|
3203
3283
|
role: "grid",
|
|
@@ -3534,6 +3614,7 @@ var SpreadsheetEditor = ({
|
|
|
3534
3614
|
}
|
|
3535
3615
|
),
|
|
3536
3616
|
state.validationPrompt && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SpreadsheetValidationDialog, { prompt: state.validationPrompt, onResolve: resolveValidation }),
|
|
3617
|
+
playing && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PresenceLayer, { presence: agentPresence }),
|
|
3537
3618
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("style", { children: `
|
|
3538
3619
|
.col-resize-handle:hover .col-resize-handle-line {
|
|
3539
3620
|
background-color: var(--primary, #6366f1);
|
|
@@ -3562,19 +3643,19 @@ var SpreadsheetEditor = ({
|
|
|
3562
3643
|
};
|
|
3563
3644
|
|
|
3564
3645
|
// src/spreadsheet/NameManager.tsx
|
|
3565
|
-
var
|
|
3646
|
+
var import_react37 = require("react");
|
|
3566
3647
|
var import_spreadsheet9 = require("@pixerate/editor/spreadsheet");
|
|
3567
3648
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3568
3649
|
var EMPTY_DRAFT = { original: null, name: "", refersTo: "=", scope: "", comment: "" };
|
|
3569
3650
|
var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
|
|
3570
3651
|
const { controller, sheets } = state;
|
|
3571
|
-
const rows = (0,
|
|
3652
|
+
const rows = (0, import_react37.useMemo)(
|
|
3572
3653
|
() => (0, import_spreadsheet9.getNameManagerRows)(controller),
|
|
3573
3654
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3574
3655
|
[controller, state.document, state.names]
|
|
3575
3656
|
);
|
|
3576
|
-
const [draft, setDraft] = (0,
|
|
3577
|
-
const [error, setError] = (0,
|
|
3657
|
+
const [draft, setDraft] = (0, import_react37.useState)(EMPTY_DRAFT);
|
|
3658
|
+
const [error, setError] = (0, import_react37.useState)(null);
|
|
3578
3659
|
const edit = (row) => {
|
|
3579
3660
|
setError(null);
|
|
3580
3661
|
setDraft({
|
|
@@ -3717,7 +3798,7 @@ var NameManager = ({ state, readOnly = false, onClose, className = "" }) => {
|
|
|
3717
3798
|
};
|
|
3718
3799
|
|
|
3719
3800
|
// src/slots.tsx
|
|
3720
|
-
var
|
|
3801
|
+
var import_react38 = require("react");
|
|
3721
3802
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3722
3803
|
var defaultSlots = {
|
|
3723
3804
|
Button: (props) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
@@ -3739,119 +3820,119 @@ var defaultSlots = {
|
|
|
3739
3820
|
props.onClose && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("button", { type: "button", onClick: props.onClose, className: "opacity-70 hover:opacity-100", children: "\xD7" })
|
|
3740
3821
|
] })
|
|
3741
3822
|
};
|
|
3742
|
-
var EditorSlotsContext = (0,
|
|
3823
|
+
var EditorSlotsContext = (0, import_react38.createContext)(defaultSlots);
|
|
3743
3824
|
function EditorSlotsProvider({ slots, children }) {
|
|
3744
|
-
const mergedSlots = (0,
|
|
3825
|
+
const mergedSlots = (0, import_react38.useMemo)(() => ({ ...defaultSlots, ...slots }), [slots]);
|
|
3745
3826
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(EditorSlotsContext.Provider, { value: mergedSlots, children });
|
|
3746
3827
|
}
|
|
3747
3828
|
function useEditorSlots() {
|
|
3748
|
-
return (0,
|
|
3829
|
+
return (0, import_react38.useContext)(EditorSlotsContext);
|
|
3749
3830
|
}
|
|
3750
3831
|
|
|
3751
3832
|
// src/image-editor/useImageEditor.ts
|
|
3752
|
-
var
|
|
3833
|
+
var import_react39 = require("react");
|
|
3753
3834
|
var import_image_editor = require("@pixerate/editor/image-editor");
|
|
3754
3835
|
function useImageEditor(options = {}) {
|
|
3755
|
-
const controllerRef = (0,
|
|
3836
|
+
const controllerRef = (0, import_react39.useRef)(null);
|
|
3756
3837
|
if (!controllerRef.current) {
|
|
3757
3838
|
controllerRef.current = new import_image_editor.ImageEditorController(options);
|
|
3758
3839
|
}
|
|
3759
3840
|
const controller = controllerRef.current;
|
|
3760
|
-
const [state, setState] = (0,
|
|
3761
|
-
const [historyTicks, setHistoryTicks] = (0,
|
|
3762
|
-
const [histogram, setHistogram] = (0,
|
|
3763
|
-
(0,
|
|
3764
|
-
(0,
|
|
3841
|
+
const [state, setState] = (0, import_react39.useState)(() => controller.getState());
|
|
3842
|
+
const [historyTicks, setHistoryTicks] = (0, import_react39.useState)(0);
|
|
3843
|
+
const [histogram, setHistogram] = (0, import_react39.useState)(() => controller.getHistogram());
|
|
3844
|
+
(0, import_react39.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
|
|
3845
|
+
(0, import_react39.useEffect)(() => {
|
|
3765
3846
|
const unsub = controller.subscribe((next) => {
|
|
3766
3847
|
setState(next);
|
|
3767
3848
|
setHistoryTicks((t) => t + 1);
|
|
3768
3849
|
});
|
|
3769
3850
|
return unsub;
|
|
3770
3851
|
}, [controller]);
|
|
3771
|
-
const loadedImageRef = (0,
|
|
3772
|
-
(0,
|
|
3852
|
+
const loadedImageRef = (0, import_react39.useRef)(options.image);
|
|
3853
|
+
(0, import_react39.useEffect)(() => {
|
|
3773
3854
|
if (options.image === loadedImageRef.current) return;
|
|
3774
3855
|
loadedImageRef.current = options.image;
|
|
3775
3856
|
if (options.image) {
|
|
3776
3857
|
controller.loadImage(options.image);
|
|
3777
3858
|
}
|
|
3778
3859
|
}, [options.image, controller]);
|
|
3779
|
-
const setTool = (0,
|
|
3780
|
-
const setCrop = (0,
|
|
3860
|
+
const setTool = (0, import_react39.useCallback)((tool) => controller.setTool(tool), [controller]);
|
|
3861
|
+
const setCrop = (0, import_react39.useCallback)(
|
|
3781
3862
|
(crop, addToHistory = true) => controller.setCrop(crop, addToHistory),
|
|
3782
3863
|
[controller]
|
|
3783
3864
|
);
|
|
3784
|
-
const applyCropPreset = (0,
|
|
3785
|
-
const resetCrop = (0,
|
|
3786
|
-
const rotate = (0,
|
|
3787
|
-
const setRotation = (0,
|
|
3788
|
-
const flipHorizontal = (0,
|
|
3789
|
-
const flipVertical = (0,
|
|
3790
|
-
const setAdjustments = (0,
|
|
3865
|
+
const applyCropPreset = (0, import_react39.useCallback)((ratio) => controller.applyCropPreset(ratio), [controller]);
|
|
3866
|
+
const resetCrop = (0, import_react39.useCallback)(() => controller.resetCrop(), [controller]);
|
|
3867
|
+
const rotate = (0, import_react39.useCallback)((deg) => controller.rotate(deg), [controller]);
|
|
3868
|
+
const setRotation = (0, import_react39.useCallback)((deg) => controller.setRotation(deg), [controller]);
|
|
3869
|
+
const flipHorizontal = (0, import_react39.useCallback)(() => controller.flipHorizontal(), [controller]);
|
|
3870
|
+
const flipVertical = (0, import_react39.useCallback)(() => controller.flipVertical(), [controller]);
|
|
3871
|
+
const setAdjustments = (0, import_react39.useCallback)(
|
|
3791
3872
|
(partial, commitToHistory = true) => controller.setAdjustments(partial, commitToHistory),
|
|
3792
3873
|
[controller]
|
|
3793
3874
|
);
|
|
3794
|
-
const resetAdjustments = (0,
|
|
3795
|
-
const upgradeProcess = (0,
|
|
3796
|
-
const addAdjustmentLayer = (0,
|
|
3875
|
+
const resetAdjustments = (0, import_react39.useCallback)(() => controller.resetAdjustments(), [controller]);
|
|
3876
|
+
const upgradeProcess = (0, import_react39.useCallback)(() => controller.upgradeProcess(), [controller]);
|
|
3877
|
+
const addAdjustmentLayer = (0, import_react39.useCallback)(
|
|
3797
3878
|
(init, index) => controller.addAdjustmentLayer(init, index),
|
|
3798
3879
|
[controller]
|
|
3799
3880
|
);
|
|
3800
|
-
const updateAdjustmentLayer = (0,
|
|
3881
|
+
const updateAdjustmentLayer = (0, import_react39.useCallback)(
|
|
3801
3882
|
(id, update, commitToHistory = true) => controller.updateAdjustmentLayer(id, update, commitToHistory),
|
|
3802
3883
|
[controller]
|
|
3803
3884
|
);
|
|
3804
|
-
const removeAdjustmentLayer = (0,
|
|
3805
|
-
const moveAdjustmentLayer = (0,
|
|
3806
|
-
const toggleAdjustmentLayer = (0,
|
|
3885
|
+
const removeAdjustmentLayer = (0, import_react39.useCallback)((id) => controller.removeAdjustmentLayer(id), [controller]);
|
|
3886
|
+
const moveAdjustmentLayer = (0, import_react39.useCallback)((id, to) => controller.moveAdjustmentLayer(id, to), [controller]);
|
|
3887
|
+
const toggleAdjustmentLayer = (0, import_react39.useCallback)(
|
|
3807
3888
|
(id, enabled) => controller.toggleAdjustmentLayer(id, enabled),
|
|
3808
3889
|
[controller]
|
|
3809
3890
|
);
|
|
3810
|
-
const setDepthMask = (0,
|
|
3811
|
-
const resetDepthMask = (0,
|
|
3812
|
-
const addAnnotation = (0,
|
|
3813
|
-
const updateAnnotation = (0,
|
|
3891
|
+
const setDepthMask = (0, import_react39.useCallback)((partial) => controller.setDepthMask(partial), [controller]);
|
|
3892
|
+
const resetDepthMask = (0, import_react39.useCallback)(() => controller.resetDepthMask(), [controller]);
|
|
3893
|
+
const addAnnotation = (0, import_react39.useCallback)((ann) => controller.addAnnotation(ann), [controller]);
|
|
3894
|
+
const updateAnnotation = (0, import_react39.useCallback)(
|
|
3814
3895
|
(id, partial, commitToHistory = true) => controller.updateAnnotation(id, partial, commitToHistory),
|
|
3815
3896
|
[controller]
|
|
3816
3897
|
);
|
|
3817
|
-
const removeAnnotation = (0,
|
|
3818
|
-
const clearAnnotations = (0,
|
|
3819
|
-
const selectAnnotation = (0,
|
|
3820
|
-
const undo = (0,
|
|
3821
|
-
const redo = (0,
|
|
3822
|
-
const reset = (0,
|
|
3823
|
-
const zoomIn = (0,
|
|
3824
|
-
const zoomOut = (0,
|
|
3825
|
-
const resetZoom = (0,
|
|
3826
|
-
const setZoom = (0,
|
|
3827
|
-
const setPan = (0,
|
|
3828
|
-
const setComparing = (0,
|
|
3829
|
-
const loadImage = (0,
|
|
3830
|
-
const toDataURL = (0,
|
|
3831
|
-
const toBlob = (0,
|
|
3832
|
-
const toJSON = (0,
|
|
3833
|
-
const loadJSON = (0,
|
|
3834
|
-
const renderMask = (0,
|
|
3898
|
+
const removeAnnotation = (0, import_react39.useCallback)((id) => controller.removeAnnotation(id), [controller]);
|
|
3899
|
+
const clearAnnotations = (0, import_react39.useCallback)(() => controller.clearAnnotations(), [controller]);
|
|
3900
|
+
const selectAnnotation = (0, import_react39.useCallback)((id) => controller.selectAnnotation(id), [controller]);
|
|
3901
|
+
const undo = (0, import_react39.useCallback)(() => controller.undo(), [controller]);
|
|
3902
|
+
const redo = (0, import_react39.useCallback)(() => controller.redo(), [controller]);
|
|
3903
|
+
const reset = (0, import_react39.useCallback)(() => controller.reset(), [controller]);
|
|
3904
|
+
const zoomIn = (0, import_react39.useCallback)((factor) => controller.zoomIn(factor), [controller]);
|
|
3905
|
+
const zoomOut = (0, import_react39.useCallback)((factor) => controller.zoomOut(factor), [controller]);
|
|
3906
|
+
const resetZoom = (0, import_react39.useCallback)(() => controller.resetZoom(), [controller]);
|
|
3907
|
+
const setZoom = (0, import_react39.useCallback)((zoom) => controller.setZoom(zoom), [controller]);
|
|
3908
|
+
const setPan = (0, import_react39.useCallback)((pan) => controller.setPan(pan), [controller]);
|
|
3909
|
+
const setComparing = (0, import_react39.useCallback)((comp) => controller.setComparing(comp), [controller]);
|
|
3910
|
+
const loadImage = (0, import_react39.useCallback)((src) => controller.loadImage(src), [controller]);
|
|
3911
|
+
const toDataURL = (0, import_react39.useCallback)((opts) => controller.toDataURL(opts), [controller]);
|
|
3912
|
+
const toBlob = (0, import_react39.useCallback)((opts) => controller.toBlob(opts), [controller]);
|
|
3913
|
+
const toJSON = (0, import_react39.useCallback)(() => controller.toJSON(), [controller]);
|
|
3914
|
+
const loadJSON = (0, import_react39.useCallback)((data) => controller.loadJSON(data), [controller]);
|
|
3915
|
+
const renderMask = (0, import_react39.useCallback)(
|
|
3835
3916
|
(opts) => controller.renderMask(opts),
|
|
3836
3917
|
[controller]
|
|
3837
3918
|
);
|
|
3838
|
-
const toMaskDataURL = (0,
|
|
3919
|
+
const toMaskDataURL = (0, import_react39.useCallback)(
|
|
3839
3920
|
(opts) => controller.toMaskDataURL(opts),
|
|
3840
3921
|
[controller]
|
|
3841
3922
|
);
|
|
3842
|
-
const toSourceDataURL = (0,
|
|
3923
|
+
const toSourceDataURL = (0, import_react39.useCallback)(
|
|
3843
3924
|
(opts) => controller.toSourceDataURL(opts),
|
|
3844
3925
|
[controller]
|
|
3845
3926
|
);
|
|
3846
|
-
const applyInpaintedImage = (0,
|
|
3927
|
+
const applyInpaintedImage = (0, import_react39.useCallback)(
|
|
3847
3928
|
(newDataUrl, options2) => controller.applyInpaintedImage(newDataUrl, options2),
|
|
3848
3929
|
[controller]
|
|
3849
3930
|
);
|
|
3850
|
-
const applyBackgroundRemovedImage = (0,
|
|
3931
|
+
const applyBackgroundRemovedImage = (0, import_react39.useCallback)(
|
|
3851
3932
|
(newDataUrl, options2) => controller.applyBackgroundRemovedImage(newDataUrl, options2),
|
|
3852
3933
|
[controller]
|
|
3853
3934
|
);
|
|
3854
|
-
return (0,
|
|
3935
|
+
return (0, import_react39.useMemo)(
|
|
3855
3936
|
() => ({
|
|
3856
3937
|
controller,
|
|
3857
3938
|
state,
|
|
@@ -3907,14 +3988,14 @@ function useImageEditor(options = {}) {
|
|
|
3907
3988
|
}
|
|
3908
3989
|
function useImageEffectsTools(registry, controller, options = {}) {
|
|
3909
3990
|
const { id, namespace, readOnly } = options;
|
|
3910
|
-
(0,
|
|
3991
|
+
(0, import_react39.useEffect)(() => {
|
|
3911
3992
|
if (!registry) return;
|
|
3912
3993
|
return registry.register((0, import_image_editor.createImageEffectsToolProvider)(controller, { id, namespace, readOnly }));
|
|
3913
3994
|
}, [registry, controller, id, namespace, readOnly]);
|
|
3914
3995
|
}
|
|
3915
3996
|
|
|
3916
3997
|
// src/image-editor/ImageEditor.tsx
|
|
3917
|
-
var
|
|
3998
|
+
var import_react59 = __toESM(require("react"), 1);
|
|
3918
3999
|
var import_image_editor18 = require("@pixerate/editor/image-editor");
|
|
3919
4000
|
|
|
3920
4001
|
// src/image-editor/ControlSlider.tsx
|
|
@@ -3947,7 +4028,7 @@ var ControlSlider = ({ spec, value, onChange, disabled, label }) => {
|
|
|
3947
4028
|
};
|
|
3948
4029
|
|
|
3949
4030
|
// src/image-editor/Histogram.tsx
|
|
3950
|
-
var
|
|
4031
|
+
var import_react40 = require("react");
|
|
3951
4032
|
var import_image_editor3 = require("@pixerate/editor/image-editor");
|
|
3952
4033
|
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3953
4034
|
var FILL = {
|
|
@@ -3959,7 +4040,7 @@ var FILL = {
|
|
|
3959
4040
|
var W = 256;
|
|
3960
4041
|
var Histogram = ({ histogram, channel = "rgb", height = 64, className = "", style }) => {
|
|
3961
4042
|
const channels = channel === "rgb" ? ["luminance", "red", "green", "blue"] : [channel];
|
|
3962
|
-
const paths = (0,
|
|
4043
|
+
const paths = (0, import_react40.useMemo)(
|
|
3963
4044
|
() => histogram && histogram.samples > 0 ? channels.map((c) => ({ c, d: (0, import_image_editor3.histogramPath)(histogram, c, W, height) })) : [],
|
|
3964
4045
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3965
4046
|
[histogram, channel, height]
|
|
@@ -3985,24 +4066,24 @@ var Histogram = ({ histogram, channel = "rgb", height = 64, className = "", styl
|
|
|
3985
4066
|
);
|
|
3986
4067
|
};
|
|
3987
4068
|
function useImageHistogram(controller) {
|
|
3988
|
-
const [histogram, setHistogram] = (0,
|
|
3989
|
-
(0,
|
|
4069
|
+
const [histogram, setHistogram] = (0, import_react40.useState)(() => controller.getHistogram());
|
|
4070
|
+
(0, import_react40.useEffect)(() => controller.subscribeHistogram(setHistogram), [controller]);
|
|
3990
4071
|
return histogram;
|
|
3991
4072
|
}
|
|
3992
4073
|
|
|
3993
4074
|
// src/image-editor/AdjustmentLayersPanel.tsx
|
|
3994
|
-
var
|
|
4075
|
+
var import_react42 = require("react");
|
|
3995
4076
|
var import_image_editor5 = require("@pixerate/editor/image-editor");
|
|
3996
4077
|
|
|
3997
4078
|
// src/image-editor/CurvesEditor.tsx
|
|
3998
|
-
var
|
|
4079
|
+
var import_react41 = require("react");
|
|
3999
4080
|
var import_image_editor4 = require("@pixerate/editor/image-editor");
|
|
4000
4081
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
4001
4082
|
var BOX = 256;
|
|
4002
4083
|
var STROKE = { master: "#e2e8f0", red: "#ef4444", green: "#22c55e", blue: "#3b82f6" };
|
|
4003
4084
|
var CurvesEditor = ({ points, onChange, histogram, channel = "master", size = 200 }) => {
|
|
4004
|
-
const svgRef = (0,
|
|
4005
|
-
const [drag, setDrag] = (0,
|
|
4085
|
+
const svgRef = (0, import_react41.useRef)(null);
|
|
4086
|
+
const [drag, setDrag] = (0, import_react41.useState)(null);
|
|
4006
4087
|
const toBox = (e) => {
|
|
4007
4088
|
const rect = svgRef.current?.getBoundingClientRect();
|
|
4008
4089
|
if (!rect || !rect.width || !rect.height) return { x: 0, y: 0 };
|
|
@@ -4101,14 +4182,14 @@ var HueRangeStrip = ({ bounds }) => {
|
|
|
4101
4182
|
};
|
|
4102
4183
|
var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram }) => {
|
|
4103
4184
|
const follow = layersProp === void 0;
|
|
4104
|
-
const [, setTick] = (0,
|
|
4105
|
-
(0,
|
|
4185
|
+
const [, setTick] = (0, import_react42.useState)(0);
|
|
4186
|
+
(0, import_react42.useEffect)(() => follow ? controller.subscribe(() => setTick((n) => n + 1)) : void 0, [controller, follow]);
|
|
4106
4187
|
const layers = layersProp ?? controller.getAdjustmentLayers();
|
|
4107
|
-
const [newKind, setNewKind] = (0,
|
|
4108
|
-
const [selectedId, setSelectedId] = (0,
|
|
4109
|
-
const [channel, setChannel] = (0,
|
|
4110
|
-
const [range, setRange] = (0,
|
|
4111
|
-
const [tone, setTone] = (0,
|
|
4188
|
+
const [newKind, setNewKind] = (0, import_react42.useState)("curves");
|
|
4189
|
+
const [selectedId, setSelectedId] = (0, import_react42.useState)(null);
|
|
4190
|
+
const [channel, setChannel] = (0, import_react42.useState)("master");
|
|
4191
|
+
const [range, setRange] = (0, import_react42.useState)(-1);
|
|
4192
|
+
const [tone, setTone] = (0, import_react42.useState)("midtones");
|
|
4112
4193
|
const selected = layers.find((l) => l.id === selectedId) ?? null;
|
|
4113
4194
|
const topFirst = [...layers].reverse();
|
|
4114
4195
|
const setParam = (layer, path, value, commit = true) => controller.updateAdjustmentLayer(layer.id, { params: (0, import_image_editor5.setControlPath)(layer.params, path, value) }, commit);
|
|
@@ -4347,19 +4428,19 @@ var AdjustmentLayersPanel = ({ controller, layers: layersProp, histogram }) => {
|
|
|
4347
4428
|
};
|
|
4348
4429
|
|
|
4349
4430
|
// src/image-editor/LayersPanel.tsx
|
|
4350
|
-
var
|
|
4431
|
+
var import_react44 = require("react");
|
|
4351
4432
|
|
|
4352
4433
|
// src/image-editor/LayerEffectsPanel.tsx
|
|
4353
|
-
var
|
|
4434
|
+
var import_react43 = require("react");
|
|
4354
4435
|
var import_image_editor6 = require("@pixerate/editor/image-editor");
|
|
4355
4436
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
4356
4437
|
var button = "px-1.5 py-0.5 rounded text-[10px] bg-slate-800 text-slate-300 hover:text-white disabled:opacity-40";
|
|
4357
4438
|
var LayerEffectsPanel = ({ controller, layerId, className }) => {
|
|
4358
|
-
const [, setTick] = (0,
|
|
4359
|
-
(0,
|
|
4360
|
-
const [open, setOpen] = (0,
|
|
4361
|
-
const [error, setError] = (0,
|
|
4362
|
-
const commitNext = (0,
|
|
4439
|
+
const [, setTick] = (0, import_react43.useState)(0);
|
|
4440
|
+
(0, import_react43.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
4441
|
+
const [open, setOpen] = (0, import_react43.useState)(null);
|
|
4442
|
+
const [error, setError] = (0, import_react43.useState)(null);
|
|
4443
|
+
const commitNext = (0, import_react43.useRef)(true);
|
|
4363
4444
|
const layer = layerId ? controller.getLayer(layerId) : controller.getActiveLayer();
|
|
4364
4445
|
const model = (0, import_image_editor6.layerEffectsPanel)(layer);
|
|
4365
4446
|
const id = layer?.id;
|
|
@@ -4549,8 +4630,8 @@ var Thumbnail = ({
|
|
|
4549
4630
|
selected,
|
|
4550
4631
|
testId
|
|
4551
4632
|
}) => {
|
|
4552
|
-
const ref = (0,
|
|
4553
|
-
(0,
|
|
4633
|
+
const ref = (0, import_react44.useRef)(null);
|
|
4634
|
+
(0, import_react44.useEffect)(() => {
|
|
4554
4635
|
const canvas = ref.current;
|
|
4555
4636
|
const ctx = canvas?.getContext("2d");
|
|
4556
4637
|
if (!canvas || !ctx || !pixels || typeof ctx.createImageData !== "function") return;
|
|
@@ -4574,14 +4655,14 @@ var Thumbnail = ({
|
|
|
4574
4655
|
);
|
|
4575
4656
|
};
|
|
4576
4657
|
var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "image", effects = true, className }) => {
|
|
4577
|
-
const [, setTick] = (0,
|
|
4578
|
-
(0,
|
|
4579
|
-
const [error, setError] = (0,
|
|
4580
|
-
const [renaming, setRenaming] = (0,
|
|
4581
|
-
const [menu, setMenu] = (0,
|
|
4582
|
-
const [drag, setDrag] = (0,
|
|
4583
|
-
const [psdNotes, setPsdNotes] = (0,
|
|
4584
|
-
const fileInput = (0,
|
|
4658
|
+
const [, setTick] = (0, import_react44.useState)(0);
|
|
4659
|
+
(0, import_react44.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
4660
|
+
const [error, setError] = (0, import_react44.useState)(null);
|
|
4661
|
+
const [renaming, setRenaming] = (0, import_react44.useState)(null);
|
|
4662
|
+
const [menu, setMenu] = (0, import_react44.useState)(null);
|
|
4663
|
+
const [drag, setDrag] = (0, import_react44.useState)(null);
|
|
4664
|
+
const [psdNotes, setPsdNotes] = (0, import_react44.useState)([]);
|
|
4665
|
+
const fileInput = (0, import_react44.useRef)(null);
|
|
4585
4666
|
const psdTask = async (fn) => {
|
|
4586
4667
|
try {
|
|
4587
4668
|
setError(null);
|
|
@@ -4590,7 +4671,7 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
|
|
|
4590
4671
|
setError(err instanceof Error ? err.message : String(err));
|
|
4591
4672
|
}
|
|
4592
4673
|
};
|
|
4593
|
-
const commitNext = (0,
|
|
4674
|
+
const commitNext = (0, import_react44.useRef)(true);
|
|
4594
4675
|
const state = controller.getState();
|
|
4595
4676
|
const rows = (0, import_image_editor7.layerPanelRows)(state.layers, state.activeLayerId);
|
|
4596
4677
|
const active = controller.getActiveLayer();
|
|
@@ -4965,21 +5046,21 @@ var LayersPanel = ({ controller, thumbnailSize = 32, psd = true, psdFileName = "
|
|
|
4965
5046
|
};
|
|
4966
5047
|
|
|
4967
5048
|
// src/image-editor/ImageProviderEffectsPanel.tsx
|
|
4968
|
-
var
|
|
5049
|
+
var import_react50 = __toESM(require("react"), 1);
|
|
4969
5050
|
var import_image_editor8 = require("@pixerate/editor/image-editor");
|
|
4970
5051
|
|
|
4971
5052
|
// src/effects/useEffects.ts
|
|
4972
|
-
var
|
|
5053
|
+
var import_react45 = require("react");
|
|
4973
5054
|
function useEffects(host, provider) {
|
|
4974
|
-
(0,
|
|
5055
|
+
(0, import_react45.useEffect)(() => {
|
|
4975
5056
|
if (!host || !provider) return;
|
|
4976
5057
|
return host.useEffects(provider);
|
|
4977
5058
|
}, [host, provider]);
|
|
4978
5059
|
}
|
|
4979
5060
|
function useEffectDescription(provider, effect) {
|
|
4980
|
-
const [state, setState] = (0,
|
|
5061
|
+
const [state, setState] = (0, import_react45.useState)({ key: "", description: null, error: null });
|
|
4981
5062
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
4982
|
-
(0,
|
|
5063
|
+
(0, import_react45.useEffect)(() => {
|
|
4983
5064
|
if (!provider || !effect) return;
|
|
4984
5065
|
let live = true;
|
|
4985
5066
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -4994,13 +5075,13 @@ function useEffectDescription(provider, effect) {
|
|
|
4994
5075
|
}
|
|
4995
5076
|
|
|
4996
5077
|
// src/effects/EffectThumbnail.tsx
|
|
4997
|
-
var
|
|
5078
|
+
var import_react46 = require("react");
|
|
4998
5079
|
var import_effects = require("@pixerate/editor/effects");
|
|
4999
5080
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
5000
5081
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
5001
|
-
const ref = (0,
|
|
5002
|
-
const [failed, setFailed] = (0,
|
|
5003
|
-
(0,
|
|
5082
|
+
const ref = (0, import_react46.useRef)(null);
|
|
5083
|
+
const [failed, setFailed] = (0, import_react46.useState)(effect.kind === "motion");
|
|
5084
|
+
(0, import_react46.useEffect)(() => {
|
|
5004
5085
|
if (effect.kind === "motion") return;
|
|
5005
5086
|
let live = true;
|
|
5006
5087
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -5027,16 +5108,16 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
5027
5108
|
}
|
|
5028
5109
|
|
|
5029
5110
|
// src/effects/EffectsBrowser.tsx
|
|
5030
|
-
var
|
|
5111
|
+
var import_react47 = require("react");
|
|
5031
5112
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
5032
5113
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
5033
5114
|
function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
|
|
5034
|
-
const [all, setAll] = (0,
|
|
5035
|
-
const [query, setQuery] = (0,
|
|
5036
|
-
const [category, setCategory] = (0,
|
|
5037
|
-
const [use, setUse] = (0,
|
|
5038
|
-
const [error, setError] = (0,
|
|
5039
|
-
(0,
|
|
5115
|
+
const [all, setAll] = (0, import_react47.useState)([]);
|
|
5116
|
+
const [query, setQuery] = (0, import_react47.useState)("");
|
|
5117
|
+
const [category, setCategory] = (0, import_react47.useState)("");
|
|
5118
|
+
const [use, setUse] = (0, import_react47.useState)("");
|
|
5119
|
+
const [error, setError] = (0, import_react47.useState)(null);
|
|
5120
|
+
(0, import_react47.useEffect)(() => {
|
|
5040
5121
|
if (!provider) return setAll([]);
|
|
5041
5122
|
let live = true;
|
|
5042
5123
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -5047,8 +5128,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
5047
5128
|
live = false;
|
|
5048
5129
|
};
|
|
5049
5130
|
}, [provider]);
|
|
5050
|
-
const [found, setFound] = (0,
|
|
5051
|
-
(0,
|
|
5131
|
+
const [found, setFound] = (0, import_react47.useState)([]);
|
|
5132
|
+
(0, import_react47.useEffect)(() => {
|
|
5052
5133
|
if (!provider) return setFound([]);
|
|
5053
5134
|
let live = true;
|
|
5054
5135
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -5057,7 +5138,7 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
5057
5138
|
};
|
|
5058
5139
|
}, [provider, query, category, use]);
|
|
5059
5140
|
const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (uses ? e.kind !== "motion" || uses.includes("motion") : e.kind !== "motion") && (!uses || e.uses.some((u) => uses.includes(u)));
|
|
5060
|
-
const categories = (0,
|
|
5141
|
+
const categories = (0, import_react47.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
5061
5142
|
const shown = found.filter(allowed);
|
|
5062
5143
|
if (!provider)
|
|
5063
5144
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
|
|
@@ -5105,12 +5186,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
5105
5186
|
}
|
|
5106
5187
|
|
|
5107
5188
|
// src/effects/EffectParameters.tsx
|
|
5108
|
-
var
|
|
5189
|
+
var import_react49 = __toESM(require("react"), 1);
|
|
5109
5190
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
5110
5191
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
5111
5192
|
|
|
5112
5193
|
// src/parameters/fields.tsx
|
|
5113
|
-
var
|
|
5194
|
+
var import_react48 = require("react");
|
|
5114
5195
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
5115
5196
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
5116
5197
|
var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-background px-2 text-xs text-foreground tabular-nums focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
@@ -5175,7 +5256,7 @@ function ParameterNumberInput({
|
|
|
5175
5256
|
}
|
|
5176
5257
|
function ParameterSlider(props) {
|
|
5177
5258
|
const { field, value, onChange, onGestureStart, onGestureEnd, disabled } = props;
|
|
5178
|
-
const dragging = (0,
|
|
5259
|
+
const dragging = (0, import_react48.useRef)(false);
|
|
5179
5260
|
const end = () => {
|
|
5180
5261
|
if (!dragging.current) return;
|
|
5181
5262
|
dragging.current = false;
|
|
@@ -5268,7 +5349,7 @@ function ParameterSelect({ field, value, onChange, disabled, id }) {
|
|
|
5268
5349
|
);
|
|
5269
5350
|
}
|
|
5270
5351
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id }) {
|
|
5271
|
-
const picking = (0,
|
|
5352
|
+
const picking = (0, import_react48.useRef)(false);
|
|
5272
5353
|
const alpha = !!field.alpha;
|
|
5273
5354
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
5274
5355
|
const rgb = hex.slice(0, 7);
|
|
@@ -5474,10 +5555,10 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
5474
5555
|
// src/effects/EffectParameters.tsx
|
|
5475
5556
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
5476
5557
|
function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
|
|
5477
|
-
const fields = (0,
|
|
5478
|
-
const idBase = (0,
|
|
5479
|
-
const gesture =
|
|
5480
|
-
const count =
|
|
5558
|
+
const fields = (0, import_react49.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
|
|
5559
|
+
const idBase = (0, import_react49.useId)();
|
|
5560
|
+
const gesture = import_react49.default.useRef(null);
|
|
5561
|
+
const count = import_react49.default.useRef(0);
|
|
5481
5562
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
|
|
5482
5563
|
onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
5483
5564
|
"select",
|
|
@@ -5548,11 +5629,11 @@ function Controls({
|
|
|
5548
5629
|
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(EffectParameters, { description, values, onChange, onReset: (k) => onChange(k, description.defaults[k], null), onPreset });
|
|
5549
5630
|
}
|
|
5550
5631
|
function ImageProviderEffectsPanel({ controller, className = "" }) {
|
|
5551
|
-
const [, setTick] = (0,
|
|
5552
|
-
(0,
|
|
5553
|
-
const [browse, setBrowse] = (0,
|
|
5554
|
-
const [message, setMessage] = (0,
|
|
5555
|
-
const [open, setOpen] = (0,
|
|
5632
|
+
const [, setTick] = (0, import_react50.useState)(0);
|
|
5633
|
+
(0, import_react50.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
5634
|
+
const [browse, setBrowse] = (0, import_react50.useState)(null);
|
|
5635
|
+
const [message, setMessage] = (0, import_react50.useState)(null);
|
|
5636
|
+
const [open, setOpen] = (0, import_react50.useState)(null);
|
|
5556
5637
|
const provider = controller.effectsProvider;
|
|
5557
5638
|
const state = controller.getState();
|
|
5558
5639
|
const layer = state.activeLayerId ? (0, import_image_editor8.findLayer)(state.layers, state.activeLayerId)?.layer ?? null : null;
|
|
@@ -5560,7 +5641,7 @@ function ImageProviderEffectsPanel({ controller, className = "" }) {
|
|
|
5560
5641
|
setMessage(null);
|
|
5561
5642
|
Promise.resolve().then(work).catch((e) => setMessage(e instanceof Error ? e.message : String(e)));
|
|
5562
5643
|
};
|
|
5563
|
-
const drags =
|
|
5644
|
+
const drags = import_react50.default.useRef(/* @__PURE__ */ new Set());
|
|
5564
5645
|
const commit = (gesture) => {
|
|
5565
5646
|
if (gesture) {
|
|
5566
5647
|
if (!drags.current.has(gesture)) {
|
|
@@ -5656,7 +5737,7 @@ function ImageProviderEffectsPanel({ controller, className = "" }) {
|
|
|
5656
5737
|
}
|
|
5657
5738
|
|
|
5658
5739
|
// src/image-editor/BrushOptionsBar.tsx
|
|
5659
|
-
var
|
|
5740
|
+
var import_react52 = require("react");
|
|
5660
5741
|
var import_image_editor10 = require("@pixerate/editor/image-editor");
|
|
5661
5742
|
var import_image_editor11 = require("@pixerate/editor/image-editor");
|
|
5662
5743
|
|
|
@@ -5664,7 +5745,7 @@ var import_image_editor11 = require("@pixerate/editor/image-editor");
|
|
|
5664
5745
|
var import_image_editor9 = require("@pixerate/editor/image-editor");
|
|
5665
5746
|
|
|
5666
5747
|
// src/paint-editor/PaintGradientEditorView.tsx
|
|
5667
|
-
var
|
|
5748
|
+
var import_react51 = require("react");
|
|
5668
5749
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
5669
5750
|
var button2 = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-200 hover:bg-slate-700 disabled:opacity-40";
|
|
5670
5751
|
var select = "rounded bg-slate-800 px-1 py-0.5 text-[11px]";
|
|
@@ -5686,7 +5767,7 @@ var PaintGradientEditorView = ({ value, onChange, colors, className, kit }) => {
|
|
|
5686
5767
|
reversePaintGradient,
|
|
5687
5768
|
updatePaintGradientStop
|
|
5688
5769
|
} = kit;
|
|
5689
|
-
const [selected, setSelected] = (0,
|
|
5770
|
+
const [selected, setSelected] = (0, import_react51.useState)(0);
|
|
5690
5771
|
const sel = Math.min(selected, value.stops.length - 1);
|
|
5691
5772
|
const stop = value.stops[sel];
|
|
5692
5773
|
const map = value.map;
|
|
@@ -5793,9 +5874,9 @@ var PaintGradientEditor = (props) => /* @__PURE__ */ (0, import_jsx_runtime31.js
|
|
|
5793
5874
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
5794
5875
|
var chip = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
|
|
5795
5876
|
var BrushOptionsBar = ({ controller, className }) => {
|
|
5796
|
-
const [, setTick] = (0,
|
|
5797
|
-
(0,
|
|
5798
|
-
const [error, setError] = (0,
|
|
5877
|
+
const [, setTick] = (0, import_react52.useState)(0);
|
|
5878
|
+
(0, import_react52.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
5879
|
+
const [error, setError] = (0, import_react52.useState)(null);
|
|
5799
5880
|
const state = controller.getState();
|
|
5800
5881
|
const { brush, foreground, background, mixer, mixerLoad, retouch, cloneSource, paint } = state.paint;
|
|
5801
5882
|
const tool = state.activeTool;
|
|
@@ -6007,18 +6088,18 @@ var BrushOptionsBar = ({ controller, className }) => {
|
|
|
6007
6088
|
};
|
|
6008
6089
|
|
|
6009
6090
|
// src/image-editor/ColorProfilePanel.tsx
|
|
6010
|
-
var
|
|
6091
|
+
var import_react53 = require("react");
|
|
6011
6092
|
var import_image_editor12 = require("@pixerate/editor/image-editor");
|
|
6012
6093
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
6013
6094
|
var chip2 = "px-2 py-1 rounded text-[11px] bg-slate-800 text-slate-300 hover:text-white";
|
|
6014
6095
|
var select2 = "rounded bg-slate-800 px-1 py-0.5 text-[11px] text-slate-200";
|
|
6015
6096
|
var ColorProfilePanel = ({ controller, className }) => {
|
|
6016
|
-
const [, setTick] = (0,
|
|
6017
|
-
(0,
|
|
6018
|
-
const [target, setTarget] = (0,
|
|
6019
|
-
const [intent, setIntent] = (0,
|
|
6020
|
-
const [bpc, setBpc] = (0,
|
|
6021
|
-
const [error, setError] = (0,
|
|
6097
|
+
const [, setTick] = (0, import_react53.useState)(0);
|
|
6098
|
+
(0, import_react53.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
6099
|
+
const [target, setTarget] = (0, import_react53.useState)("display-p3");
|
|
6100
|
+
const [intent, setIntent] = (0, import_react53.useState)("relative");
|
|
6101
|
+
const [bpc, setBpc] = (0, import_react53.useState)(true);
|
|
6102
|
+
const [error, setError] = (0, import_react53.useState)(null);
|
|
6022
6103
|
const view = (0, import_image_editor12.colorPanelView)(controller);
|
|
6023
6104
|
const attempt = (fn) => {
|
|
6024
6105
|
try {
|
|
@@ -6092,7 +6173,7 @@ var ColorProfilePanel = ({ controller, className }) => {
|
|
|
6092
6173
|
};
|
|
6093
6174
|
|
|
6094
6175
|
// src/image-editor/SelectionOptionsBar.tsx
|
|
6095
|
-
var
|
|
6176
|
+
var import_react54 = require("react");
|
|
6096
6177
|
var import_image_editor13 = require("@pixerate/editor/image-editor");
|
|
6097
6178
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
6098
6179
|
var MODIFY_OPS = [
|
|
@@ -6111,7 +6192,7 @@ var SelectionOptionsBar = ({
|
|
|
6111
6192
|
quickMask,
|
|
6112
6193
|
className = ""
|
|
6113
6194
|
}) => {
|
|
6114
|
-
const [radius, setRadius] = (0,
|
|
6195
|
+
const [radius, setRadius] = (0, import_react54.useState)(2);
|
|
6115
6196
|
const set = (patch) => onOptionsChange({ ...options, ...patch });
|
|
6116
6197
|
const sel = selection === void 0 ? controller.getSelection() : selection;
|
|
6117
6198
|
const qm = quickMask ?? Boolean(controller.getState().quickMask);
|
|
@@ -6197,17 +6278,17 @@ var SelectionOptionsBar = ({
|
|
|
6197
6278
|
};
|
|
6198
6279
|
|
|
6199
6280
|
// src/image-editor/RefineEdgePanel.tsx
|
|
6200
|
-
var
|
|
6281
|
+
var import_react55 = require("react");
|
|
6201
6282
|
var import_image_editor14 = require("@pixerate/editor/image-editor");
|
|
6202
6283
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
6203
6284
|
var DEFAULT_PARAMS = { radius: 8, smartRadius: false, smooth: 0, feather: 0, contrast: 0, shiftEdge: 0 };
|
|
6204
6285
|
var button3 = "px-2 py-1 rounded-md border border-slate-800 bg-slate-950 text-[11px] text-slate-200 hover:text-white disabled:opacity-40";
|
|
6205
6286
|
var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
6206
|
-
const [params, setParams] = (0,
|
|
6207
|
-
const [busy, setBusy] = (0,
|
|
6208
|
-
const [error, setError] = (0,
|
|
6209
|
-
const [layerId, setLayerId] = (0,
|
|
6210
|
-
const [newKind, setNewKind] = (0,
|
|
6287
|
+
const [params, setParams] = (0, import_react55.useState)(DEFAULT_PARAMS);
|
|
6288
|
+
const [busy, setBusy] = (0, import_react55.useState)(false);
|
|
6289
|
+
const [error, setError] = (0, import_react55.useState)(null);
|
|
6290
|
+
const [layerId, setLayerId] = (0, import_react55.useState)("");
|
|
6291
|
+
const [newKind, setNewKind] = (0, import_react55.useState)("hueSaturation");
|
|
6211
6292
|
const sel = selection === void 0 ? controller.getSelection() : selection;
|
|
6212
6293
|
const list = layers ?? controller.getAdjustmentLayers();
|
|
6213
6294
|
const target = list.find((l) => l.id === layerId) ?? list[list.length - 1];
|
|
@@ -6348,14 +6429,14 @@ var RefineEdgePanel = ({ controller, selection, layers, className = "" }) => {
|
|
|
6348
6429
|
};
|
|
6349
6430
|
|
|
6350
6431
|
// src/image-editor/FreeTransformOptionsBar.tsx
|
|
6351
|
-
var
|
|
6432
|
+
var import_react56 = require("react");
|
|
6352
6433
|
var import_image_editor15 = require("@pixerate/editor/image-editor");
|
|
6353
6434
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
6354
6435
|
var chip3 = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
|
|
6355
6436
|
var round = (v, unit) => unit === "px" ? Math.round(v * 10) / 10 : Math.round(v * 100) / 100;
|
|
6356
6437
|
var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
6357
|
-
const [, setTick] = (0,
|
|
6358
|
-
(0,
|
|
6438
|
+
const [, setTick] = (0, import_react56.useState)(0);
|
|
6439
|
+
(0, import_react56.useEffect)(() => tool.subscribe(() => setTick((n) => n + 1)), [tool]);
|
|
6359
6440
|
const bar = tool.bar();
|
|
6360
6441
|
if (!tool.active || !bar) return null;
|
|
6361
6442
|
const warp = tool.warpBar();
|
|
@@ -6487,14 +6568,14 @@ var FreeTransformOptionsBar = ({ tool, className }) => {
|
|
|
6487
6568
|
};
|
|
6488
6569
|
|
|
6489
6570
|
// src/image-editor/ShapeOptionsBar.tsx
|
|
6490
|
-
var
|
|
6571
|
+
var import_react57 = require("react");
|
|
6491
6572
|
var import_image_editor16 = require("@pixerate/editor/image-editor");
|
|
6492
6573
|
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
6493
6574
|
var chip4 = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
|
|
6494
6575
|
var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
6495
|
-
const [, setTick] = (0,
|
|
6496
|
-
(0,
|
|
6497
|
-
const [error, setError] = (0,
|
|
6576
|
+
const [, setTick] = (0, import_react57.useState)(0);
|
|
6577
|
+
(0, import_react57.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
6578
|
+
const [error, setError] = (0, import_react57.useState)(null);
|
|
6498
6579
|
const active = controller.getActiveLayer();
|
|
6499
6580
|
const shapeId = active?.type === "shape" ? active.id : null;
|
|
6500
6581
|
const set = (change) => {
|
|
@@ -6605,16 +6686,16 @@ var ShapeOptionsBar = ({ controller, options, onChange, className }) => {
|
|
|
6605
6686
|
};
|
|
6606
6687
|
|
|
6607
6688
|
// src/image-editor/TypeOptionsBar.tsx
|
|
6608
|
-
var
|
|
6689
|
+
var import_react58 = require("react");
|
|
6609
6690
|
var import_image_editor17 = require("@pixerate/editor/image-editor");
|
|
6610
6691
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
6611
6692
|
var chip5 = (on) => `px-2 py-1 rounded text-[11px] ${on ? "bg-indigo-600 text-white" : "bg-slate-800 text-slate-300 hover:text-white"}`;
|
|
6612
6693
|
var ALIGN_LABELS = { left: "Left", center: "Centre", right: "Right", justify: "Justify" };
|
|
6613
6694
|
var TypeOptionsBar = ({ controller, options, onChange, session, className }) => {
|
|
6614
|
-
const [, setTick] = (0,
|
|
6615
|
-
(0,
|
|
6616
|
-
(0,
|
|
6617
|
-
const [error, setError] = (0,
|
|
6695
|
+
const [, setTick] = (0, import_react58.useState)(0);
|
|
6696
|
+
(0, import_react58.useEffect)(() => controller.subscribe(() => setTick((n) => n + 1)), [controller]);
|
|
6697
|
+
(0, import_react58.useEffect)(() => session?.subscribe(() => setTick((n) => n + 1)), [session]);
|
|
6698
|
+
const [error, setError] = (0, import_react58.useState)(null);
|
|
6618
6699
|
const active = controller.getActiveLayer();
|
|
6619
6700
|
const typeId = !session && active?.type === "type" ? active.id : null;
|
|
6620
6701
|
const here = session?.alive ? session.styleHere() : {};
|
|
@@ -6718,15 +6799,15 @@ var ImageEditor = ({
|
|
|
6718
6799
|
return l.type === "pixel" && !!l.generator || l.type === "smart" && !!l.smartFilters?.filters.some((f) => f.kind === "effect") || l.type === "group" && l.children.some(has);
|
|
6719
6800
|
});
|
|
6720
6801
|
const legacyProcess = (0, import_image_editor18.normalizeProcessVersion)(state.adjustments.process) < import_image_editor18.LATEST_PROCESS_VERSION;
|
|
6721
|
-
const canvasRef = (0,
|
|
6722
|
-
const containerRef = (0,
|
|
6723
|
-
const [activeTab, setActiveTab] = (0,
|
|
6724
|
-
const rootRef = (0,
|
|
6725
|
-
const activeTabRef = (0,
|
|
6802
|
+
const canvasRef = (0, import_react59.useRef)(null);
|
|
6803
|
+
const containerRef = (0, import_react59.useRef)(null);
|
|
6804
|
+
const [activeTab, setActiveTab] = (0, import_react59.useState)("crop");
|
|
6805
|
+
const rootRef = (0, import_react59.useRef)(null);
|
|
6806
|
+
const activeTabRef = (0, import_react59.useRef)(activeTab);
|
|
6726
6807
|
activeTabRef.current = activeTab;
|
|
6727
6808
|
const ambientPlayback = useAgentPlayback();
|
|
6728
6809
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
6729
|
-
const [locateLayer] = (0,
|
|
6810
|
+
const [locateLayer] = (0, import_react59.useState)(() => (0, import_image_editor18.createImagePlaybackLocator)(controller));
|
|
6730
6811
|
const docToRoot = (p) => {
|
|
6731
6812
|
const canvas = canvasRef.current;
|
|
6732
6813
|
const root = rootRef.current;
|
|
@@ -6783,26 +6864,26 @@ var ImageEditor = ({
|
|
|
6783
6864
|
fromViewport: clientToDoc,
|
|
6784
6865
|
reveal: () => onPlaybackReveal?.()
|
|
6785
6866
|
});
|
|
6786
|
-
const [activeCropRatio, setActiveCropRatio] = (0,
|
|
6787
|
-
const [selectionOptions, setSelectionOptions] = (0,
|
|
6788
|
-
const selectionOptionsRef = (0,
|
|
6867
|
+
const [activeCropRatio, setActiveCropRatio] = (0, import_react59.useState)(null);
|
|
6868
|
+
const [selectionOptions, setSelectionOptions] = (0, import_react59.useState)(import_image_editor18.DEFAULT_SELECTION_TOOL_OPTIONS);
|
|
6869
|
+
const selectionOptionsRef = (0, import_react59.useRef)(selectionOptions);
|
|
6789
6870
|
selectionOptionsRef.current = selectionOptions;
|
|
6790
|
-
const selectionGestureRef = (0,
|
|
6871
|
+
const selectionGestureRef = (0, import_react59.useRef)(null);
|
|
6791
6872
|
if (!selectionGestureRef.current || selectionGestureRef.current.controller !== controller) {
|
|
6792
6873
|
selectionGestureRef.current = new import_image_editor18.SelectionGesture(controller, () => selectionOptionsRef.current);
|
|
6793
6874
|
}
|
|
6794
|
-
const selectionDraftRef = (0,
|
|
6795
|
-
const [selectionError, setSelectionError] = (0,
|
|
6796
|
-
const paintGestureRef = (0,
|
|
6797
|
-
const paintControllerRef = (0,
|
|
6875
|
+
const selectionDraftRef = (0, import_react59.useRef)(null);
|
|
6876
|
+
const [selectionError, setSelectionError] = (0, import_react59.useState)(null);
|
|
6877
|
+
const paintGestureRef = (0, import_react59.useRef)(null);
|
|
6878
|
+
const paintControllerRef = (0, import_react59.useRef)(controller);
|
|
6798
6879
|
if (!paintGestureRef.current || paintControllerRef.current !== controller) {
|
|
6799
6880
|
paintGestureRef.current = new import_image_editor18.PaintGesture(controller);
|
|
6800
6881
|
paintControllerRef.current = controller;
|
|
6801
6882
|
}
|
|
6802
|
-
const brushCursorRef = (0,
|
|
6803
|
-
const [paintError, setPaintError] = (0,
|
|
6804
|
-
const transformToolRef = (0,
|
|
6805
|
-
const transformControllerRef = (0,
|
|
6883
|
+
const brushCursorRef = (0, import_react59.useRef)(null);
|
|
6884
|
+
const [paintError, setPaintError] = (0, import_react59.useState)(null);
|
|
6885
|
+
const transformToolRef = (0, import_react59.useRef)(null);
|
|
6886
|
+
const transformControllerRef = (0, import_react59.useRef)(controller);
|
|
6806
6887
|
if (!transformToolRef.current || transformControllerRef.current !== controller) {
|
|
6807
6888
|
transformToolRef.current?.cancel();
|
|
6808
6889
|
transformToolRef.current = new import_image_editor18.FreeTransformTool(controller, {
|
|
@@ -6811,33 +6892,33 @@ var ImageEditor = ({
|
|
|
6811
6892
|
transformControllerRef.current = controller;
|
|
6812
6893
|
}
|
|
6813
6894
|
const transformTool = transformToolRef.current;
|
|
6814
|
-
const [, setTransformTick] = (0,
|
|
6815
|
-
const [transformCursor, setTransformCursor] = (0,
|
|
6816
|
-
const [shapeOptions, setShapeOptions] = (0,
|
|
6817
|
-
const shapeOptionsRef = (0,
|
|
6895
|
+
const [, setTransformTick] = (0, import_react59.useState)(0);
|
|
6896
|
+
const [transformCursor, setTransformCursor] = (0, import_react59.useState)("default");
|
|
6897
|
+
const [shapeOptions, setShapeOptions] = (0, import_react59.useState)(import_image_editor18.DEFAULT_SHAPE_TOOL_OPTIONS);
|
|
6898
|
+
const shapeOptionsRef = (0, import_react59.useRef)(shapeOptions);
|
|
6818
6899
|
shapeOptionsRef.current = shapeOptions;
|
|
6819
|
-
const [typeOptions, setTypeOptions] = (0,
|
|
6820
|
-
const typeOptionsRef = (0,
|
|
6900
|
+
const [typeOptions, setTypeOptions] = (0, import_react59.useState)(import_image_editor18.DEFAULT_TYPE_TOOL_OPTIONS);
|
|
6901
|
+
const typeOptionsRef = (0, import_react59.useRef)(typeOptions);
|
|
6821
6902
|
typeOptionsRef.current = typeOptions;
|
|
6822
|
-
const shapeGestureRef = (0,
|
|
6823
|
-
const typeToolRef = (0,
|
|
6824
|
-
const shapeTypeControllerRef = (0,
|
|
6903
|
+
const shapeGestureRef = (0, import_react59.useRef)(null);
|
|
6904
|
+
const typeToolRef = (0, import_react59.useRef)(null);
|
|
6905
|
+
const shapeTypeControllerRef = (0, import_react59.useRef)(controller);
|
|
6825
6906
|
if (!shapeGestureRef.current || !typeToolRef.current || shapeTypeControllerRef.current !== controller) {
|
|
6826
6907
|
typeToolRef.current?.finish();
|
|
6827
6908
|
shapeGestureRef.current = new import_image_editor18.ShapeDrawGesture(controller, () => shapeOptionsRef.current);
|
|
6828
6909
|
typeToolRef.current = new import_image_editor18.TypeToolGesture(controller, () => typeOptionsRef.current);
|
|
6829
6910
|
shapeTypeControllerRef.current = controller;
|
|
6830
6911
|
}
|
|
6831
|
-
const typeInputRef = (0,
|
|
6832
|
-
const [typeSession, setTypeSession] = (0,
|
|
6833
|
-
const [shapeTypeError, setShapeTypeError] = (0,
|
|
6834
|
-
const [inpaintPrompt, setInpaintPrompt] = (0,
|
|
6835
|
-
const [inpaintMaskMode, setInpaintMaskMode] = (0,
|
|
6836
|
-
const [isRemovingBg, setIsRemovingBg] = (0,
|
|
6837
|
-
const [isInpainting, setIsInpainting] = (0,
|
|
6838
|
-
const [aiError, setAiError] = (0,
|
|
6839
|
-
const [aiSuccess, setAiSuccess] = (0,
|
|
6840
|
-
const [aiTarget, setAiTarget] = (0,
|
|
6912
|
+
const typeInputRef = (0, import_react59.useRef)(null);
|
|
6913
|
+
const [typeSession, setTypeSession] = (0, import_react59.useState)(typeToolRef.current.session);
|
|
6914
|
+
const [shapeTypeError, setShapeTypeError] = (0, import_react59.useState)(null);
|
|
6915
|
+
const [inpaintPrompt, setInpaintPrompt] = (0, import_react59.useState)("");
|
|
6916
|
+
const [inpaintMaskMode, setInpaintMaskMode] = (0, import_react59.useState)("annotations");
|
|
6917
|
+
const [isRemovingBg, setIsRemovingBg] = (0, import_react59.useState)(false);
|
|
6918
|
+
const [isInpainting, setIsInpainting] = (0, import_react59.useState)(false);
|
|
6919
|
+
const [aiError, setAiError] = (0, import_react59.useState)(null);
|
|
6920
|
+
const [aiSuccess, setAiSuccess] = (0, import_react59.useState)(null);
|
|
6921
|
+
const [aiTarget, setAiTarget] = (0, import_react59.useState)("auto");
|
|
6841
6922
|
const aiOptions = aiTarget === "auto" ? {} : { target: aiTarget };
|
|
6842
6923
|
const effectiveOnInpaint = onInpaint || aiHooks?.onInpaint;
|
|
6843
6924
|
const effectiveOnRemoveBg = onRemoveBackground || aiHooks?.onRemoveBackground;
|
|
@@ -6900,18 +6981,18 @@ var ImageEditor = ({
|
|
|
6900
6981
|
setIsInpainting(false);
|
|
6901
6982
|
}
|
|
6902
6983
|
};
|
|
6903
|
-
const [activeColor, setActiveColor] = (0,
|
|
6904
|
-
const [strokeWidth, setStrokeWidth] = (0,
|
|
6905
|
-
const [fontSize, setFontSize] = (0,
|
|
6906
|
-
const [textInput, setTextInput] = (0,
|
|
6907
|
-
const draftAnnotationRef = (0,
|
|
6908
|
-
const draftCropRef = (0,
|
|
6909
|
-
const cropDragInfoRef = (0,
|
|
6910
|
-
const annotationDragInfoRef = (0,
|
|
6911
|
-
const isDrawingRef = (0,
|
|
6912
|
-
const currentPathRef = (0,
|
|
6913
|
-
const dragStartPointRef = (0,
|
|
6914
|
-
const renderCanvas = (0,
|
|
6984
|
+
const [activeColor, setActiveColor] = (0, import_react59.useState)("#ef4444");
|
|
6985
|
+
const [strokeWidth, setStrokeWidth] = (0, import_react59.useState)(3);
|
|
6986
|
+
const [fontSize, setFontSize] = (0, import_react59.useState)(24);
|
|
6987
|
+
const [textInput, setTextInput] = (0, import_react59.useState)("");
|
|
6988
|
+
const draftAnnotationRef = (0, import_react59.useRef)(null);
|
|
6989
|
+
const draftCropRef = (0, import_react59.useRef)(null);
|
|
6990
|
+
const cropDragInfoRef = (0, import_react59.useRef)(null);
|
|
6991
|
+
const annotationDragInfoRef = (0, import_react59.useRef)(null);
|
|
6992
|
+
const isDrawingRef = (0, import_react59.useRef)(false);
|
|
6993
|
+
const currentPathRef = (0, import_react59.useRef)([]);
|
|
6994
|
+
const dragStartPointRef = (0, import_react59.useRef)(null);
|
|
6995
|
+
const renderCanvas = (0, import_react59.useCallback)(
|
|
6915
6996
|
async (draftAnnotation, draftCrop) => {
|
|
6916
6997
|
const canvas = canvasRef.current;
|
|
6917
6998
|
const container = containerRef.current;
|
|
@@ -6934,8 +7015,8 @@ var ImageEditor = ({
|
|
|
6934
7015
|
},
|
|
6935
7016
|
[controller, activeTab, transformTool]
|
|
6936
7017
|
);
|
|
6937
|
-
(0,
|
|
6938
|
-
(0,
|
|
7018
|
+
(0, import_react59.useEffect)(() => typeSession?.subscribe(() => void renderCanvas()), [typeSession, renderCanvas]);
|
|
7019
|
+
(0, import_react59.useEffect)(() => {
|
|
6939
7020
|
if (activeTab === "annotate" && state.activeTool === "type") return;
|
|
6940
7021
|
if (typeToolRef.current?.session) {
|
|
6941
7022
|
typeToolRef.current.finish();
|
|
@@ -6970,7 +7051,7 @@ var ImageEditor = ({
|
|
|
6970
7051
|
el.value = "";
|
|
6971
7052
|
}
|
|
6972
7053
|
};
|
|
6973
|
-
(0,
|
|
7054
|
+
(0, import_react59.useEffect)(() => transformTool.subscribe(() => {
|
|
6974
7055
|
setTransformTick((n) => n + 1);
|
|
6975
7056
|
void renderCanvas();
|
|
6976
7057
|
}), [transformTool, renderCanvas]);
|
|
@@ -7013,7 +7094,7 @@ var ImageEditor = ({
|
|
|
7013
7094
|
transformTool.up();
|
|
7014
7095
|
return true;
|
|
7015
7096
|
};
|
|
7016
|
-
(0,
|
|
7097
|
+
(0, import_react59.useEffect)(() => {
|
|
7017
7098
|
if (typeof window === "undefined") return;
|
|
7018
7099
|
const onKey = (e) => {
|
|
7019
7100
|
if (transformTool.key(e)) e.preventDefault();
|
|
@@ -7021,7 +7102,7 @@ var ImageEditor = ({
|
|
|
7021
7102
|
window.addEventListener("keydown", onKey);
|
|
7022
7103
|
return () => window.removeEventListener("keydown", onKey);
|
|
7023
7104
|
}, [transformTool]);
|
|
7024
|
-
(0,
|
|
7105
|
+
(0, import_react59.useEffect)(() => {
|
|
7025
7106
|
const raf = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : (cb) => setTimeout(cb, 0);
|
|
7026
7107
|
const caf = typeof cancelAnimationFrame !== "undefined" ? cancelAnimationFrame : (id) => clearTimeout(id);
|
|
7027
7108
|
const animId = raf(() => {
|
|
@@ -7029,12 +7110,12 @@ var ImageEditor = ({
|
|
|
7029
7110
|
});
|
|
7030
7111
|
return () => caf(animId);
|
|
7031
7112
|
}, [renderCanvas, state]);
|
|
7032
|
-
(0,
|
|
7113
|
+
(0, import_react59.useEffect)(() => {
|
|
7033
7114
|
if (activeTab === "crop" && editor.state.activeTool !== "crop") {
|
|
7034
7115
|
editor.setTool("crop");
|
|
7035
7116
|
}
|
|
7036
7117
|
}, [activeTab, editor]);
|
|
7037
|
-
(0,
|
|
7118
|
+
(0, import_react59.useEffect)(() => {
|
|
7038
7119
|
const container = containerRef.current;
|
|
7039
7120
|
if (!container) return;
|
|
7040
7121
|
if (typeof ResizeObserver !== "undefined") {
|
|
@@ -7102,7 +7183,7 @@ var ImageEditor = ({
|
|
|
7102
7183
|
if (g.error) setPaintError(g.error);
|
|
7103
7184
|
}
|
|
7104
7185
|
};
|
|
7105
|
-
(0,
|
|
7186
|
+
(0, import_react59.useEffect)(() => {
|
|
7106
7187
|
if (activeTab !== "paint" || typeof window === "undefined") return;
|
|
7107
7188
|
const onKey = (e) => {
|
|
7108
7189
|
if ((0, import_image_editor18.handlePaintShortcut)(controller, e)) e.preventDefault();
|
|
@@ -7875,7 +7956,7 @@ var ImageEditor = ({
|
|
|
7875
7956
|
)
|
|
7876
7957
|
] }),
|
|
7877
7958
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Histogram, { histogram: editor.histogram }),
|
|
7878
|
-
import_image_editor18.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
7959
|
+
import_image_editor18.IMAGE_ADJUSTMENT_CONTROLS.map((spec) => /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_react59.default.Fragment, { children: [
|
|
7879
7960
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
7880
7961
|
ControlSlider,
|
|
7881
7962
|
{
|
|
@@ -8374,7 +8455,7 @@ var ImageEditor = ({
|
|
|
8374
8455
|
};
|
|
8375
8456
|
|
|
8376
8457
|
// src/review/useReview.ts
|
|
8377
|
-
var
|
|
8458
|
+
var import_react60 = require("react");
|
|
8378
8459
|
var import_editor12 = require("@pixerate/editor");
|
|
8379
8460
|
var EMPTY_COMMENTS = Object.freeze({
|
|
8380
8461
|
threads: [],
|
|
@@ -8393,23 +8474,23 @@ function isCommentStore(value) {
|
|
|
8393
8474
|
}
|
|
8394
8475
|
function useComments(source) {
|
|
8395
8476
|
const store = isCommentStore(source) ? source : (0, import_editor12.getCommentStore)(source);
|
|
8396
|
-
const subscribe = (0,
|
|
8477
|
+
const subscribe = (0, import_react60.useCallback)(
|
|
8397
8478
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
8398
8479
|
[store]
|
|
8399
8480
|
);
|
|
8400
8481
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_COMMENTS;
|
|
8401
|
-
const snapshot = (0,
|
|
8402
|
-
return (0,
|
|
8482
|
+
const snapshot = (0, import_react60.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
8483
|
+
return (0, import_react60.useMemo)(() => ({ ...snapshot, store }), [snapshot, store]);
|
|
8403
8484
|
}
|
|
8404
8485
|
function useTrackChanges(editor) {
|
|
8405
8486
|
const store = (0, import_editor12.getTrackChangesStore)(editor ?? null);
|
|
8406
|
-
const subscribe = (0,
|
|
8487
|
+
const subscribe = (0, import_react60.useCallback)(
|
|
8407
8488
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe,
|
|
8408
8489
|
[store]
|
|
8409
8490
|
);
|
|
8410
8491
|
const getSnapshot = () => store?.getSnapshot() ?? EMPTY_TRACK_CHANGES;
|
|
8411
|
-
const snapshot = (0,
|
|
8412
|
-
return (0,
|
|
8492
|
+
const snapshot = (0, import_react60.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
8493
|
+
return (0, import_react60.useMemo)(() => {
|
|
8413
8494
|
const run = (fn) => () => {
|
|
8414
8495
|
if (editor && !editor.isDestroyed) fn(editor);
|
|
8415
8496
|
};
|
|
@@ -8432,7 +8513,7 @@ function useTrackChanges(editor) {
|
|
|
8432
8513
|
}
|
|
8433
8514
|
|
|
8434
8515
|
// src/review/CommentsPanel.tsx
|
|
8435
|
-
var
|
|
8516
|
+
var import_react61 = require("react");
|
|
8436
8517
|
var import_editor13 = require("@pixerate/editor");
|
|
8437
8518
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
8438
8519
|
var buttonClass2 = "rounded px-2 py-1 text-xs text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50";
|
|
@@ -8448,7 +8529,7 @@ var CommentsPanel = ({
|
|
|
8448
8529
|
emptyMessage = "No comments yet. Select text and add a comment."
|
|
8449
8530
|
}) => {
|
|
8450
8531
|
const { threads, activeThreadId, store } = useComments(storeProp ?? editor);
|
|
8451
|
-
const [showResolved, setShowResolved] = (0,
|
|
8532
|
+
const [showResolved, setShowResolved] = (0, import_react61.useState)(showResolvedInitial);
|
|
8452
8533
|
const author = authorProp ?? (0, import_editor13.getCommentAuthor)(editor) ?? { id: "anonymous", name: "Anonymous" };
|
|
8453
8534
|
const visible = threads.filter((t) => showResolved || !t.resolved);
|
|
8454
8535
|
const resolvedCount = threads.filter((t) => t.resolved).length;
|
|
@@ -8492,7 +8573,7 @@ var CommentThreadCard = ({
|
|
|
8492
8573
|
author,
|
|
8493
8574
|
formatTime
|
|
8494
8575
|
}) => {
|
|
8495
|
-
const [draft, setDraft] = (0,
|
|
8576
|
+
const [draft, setDraft] = (0, import_react61.useState)("");
|
|
8496
8577
|
const isDraft = thread.body === "";
|
|
8497
8578
|
const quote = thread.anchor?.quote ?? thread.lastQuote ?? "";
|
|
8498
8579
|
const live = editor && !editor.isDestroyed ? editor : null;
|
|
@@ -8706,13 +8787,13 @@ var CommentButton = ({
|
|
|
8706
8787
|
);
|
|
8707
8788
|
|
|
8708
8789
|
// src/review/useDocumentCompare.ts
|
|
8709
|
-
var
|
|
8790
|
+
var import_react62 = require("react");
|
|
8710
8791
|
var import_editor14 = require("@pixerate/editor");
|
|
8711
8792
|
function useDocumentCompare(editor, options) {
|
|
8712
|
-
const [summary, setSummary] = (0,
|
|
8713
|
-
const defaults = (0,
|
|
8793
|
+
const [summary, setSummary] = (0, import_react62.useState)(null);
|
|
8794
|
+
const defaults = (0, import_react62.useRef)(options);
|
|
8714
8795
|
defaults.current = options;
|
|
8715
|
-
const compare = (0,
|
|
8796
|
+
const compare = (0, import_react62.useCallback)(
|
|
8716
8797
|
(original, revised, overrides) => {
|
|
8717
8798
|
if (!editor || editor.isDestroyed) return null;
|
|
8718
8799
|
const result = (0, import_editor14.applyDocumentComparison)(editor, original, revised, {
|
|
@@ -8724,8 +8805,8 @@ function useDocumentCompare(editor, options) {
|
|
|
8724
8805
|
},
|
|
8725
8806
|
[editor]
|
|
8726
8807
|
);
|
|
8727
|
-
const clear = (0,
|
|
8728
|
-
return (0,
|
|
8808
|
+
const clear = (0, import_react62.useCallback)(() => setSummary(null), []);
|
|
8809
|
+
return (0, import_react62.useMemo)(() => ({ summary, compare, clear }), [summary, compare, clear]);
|
|
8729
8810
|
}
|
|
8730
8811
|
|
|
8731
8812
|
// src/review/TrackedChangesList.tsx
|
|
@@ -8776,12 +8857,12 @@ var TrackedChangesList = ({
|
|
|
8776
8857
|
};
|
|
8777
8858
|
|
|
8778
8859
|
// src/commands/useCommandPalette.ts
|
|
8779
|
-
var
|
|
8860
|
+
var import_react63 = require("react");
|
|
8780
8861
|
var import_commands2 = require("@pixerate/editor/commands");
|
|
8781
8862
|
function useCommandPalette(registry, options = {}) {
|
|
8782
|
-
const optionsRef = (0,
|
|
8863
|
+
const optionsRef = (0, import_react63.useRef)(options);
|
|
8783
8864
|
optionsRef.current = options;
|
|
8784
|
-
const controller = (0,
|
|
8865
|
+
const controller = (0, import_react63.useMemo)(
|
|
8785
8866
|
() => (0, import_commands2.createCommandPaletteController)(registry, {
|
|
8786
8867
|
context: () => {
|
|
8787
8868
|
const c = optionsRef.current.context;
|
|
@@ -8802,9 +8883,9 @@ function useCommandPalette(registry, options = {}) {
|
|
|
8802
8883
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
8803
8884
|
[registry]
|
|
8804
8885
|
);
|
|
8805
|
-
const state = (0,
|
|
8886
|
+
const state = (0, import_react63.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
8806
8887
|
const { hotkey, hotkeyTarget } = options;
|
|
8807
|
-
(0,
|
|
8888
|
+
(0, import_react63.useEffect)(() => {
|
|
8808
8889
|
if (!hotkey) return;
|
|
8809
8890
|
const target = hotkeyTarget ?? (typeof window !== "undefined" ? window : null);
|
|
8810
8891
|
if (!target) return;
|
|
@@ -8832,13 +8913,13 @@ function useCommandPalette(registry, options = {}) {
|
|
|
8832
8913
|
}
|
|
8833
8914
|
|
|
8834
8915
|
// src/commands/CommandPalette.tsx
|
|
8835
|
-
var
|
|
8916
|
+
var import_react64 = __toESM(require("react"), 1);
|
|
8836
8917
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
8837
8918
|
function HighlightedLabel({ item }) {
|
|
8838
8919
|
if (item.labelIndices.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_jsx_runtime44.Fragment, { children: item.label });
|
|
8839
8920
|
const marked = new Set(item.labelIndices);
|
|
8840
8921
|
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_jsx_runtime44.Fragment, { children: Array.from(item.label).map(
|
|
8841
|
-
(ch, i) => marked.has(i) ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "font-semibold text-foreground", "data-match": "", children: ch }, i) : /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
8922
|
+
(ch, i) => marked.has(i) ? /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "font-semibold text-foreground", "data-match": "", children: ch }, i) : /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react64.default.Fragment, { children: ch }, i)
|
|
8842
8923
|
) });
|
|
8843
8924
|
}
|
|
8844
8925
|
var CommandPalette = ({
|
|
@@ -8847,16 +8928,16 @@ var CommandPalette = ({
|
|
|
8847
8928
|
emptyMessage = "No matching commands",
|
|
8848
8929
|
className = ""
|
|
8849
8930
|
}) => {
|
|
8850
|
-
const inputRef = (0,
|
|
8851
|
-
const listRef = (0,
|
|
8852
|
-
const baseId = (0,
|
|
8931
|
+
const inputRef = (0, import_react64.useRef)(null);
|
|
8932
|
+
const listRef = (0, import_react64.useRef)(null);
|
|
8933
|
+
const baseId = (0, import_react64.useId)();
|
|
8853
8934
|
const listId = `${baseId}-list`;
|
|
8854
8935
|
const optionId = (index) => `${baseId}-option-${index}`;
|
|
8855
8936
|
const { open, query, items, activeIndex } = palette;
|
|
8856
|
-
(0,
|
|
8937
|
+
(0, import_react64.useEffect)(() => {
|
|
8857
8938
|
if (open) inputRef.current?.focus();
|
|
8858
8939
|
}, [open]);
|
|
8859
|
-
(0,
|
|
8940
|
+
(0, import_react64.useEffect)(() => {
|
|
8860
8941
|
if (!open) return;
|
|
8861
8942
|
const active = listRef.current?.querySelector('[aria-selected="true"]');
|
|
8862
8943
|
active?.scrollIntoView?.({ block: "nearest" });
|
|
@@ -8932,12 +9013,12 @@ var CommandPalette = ({
|
|
|
8932
9013
|
};
|
|
8933
9014
|
|
|
8934
9015
|
// src/commands/useCommandShortcuts.ts
|
|
8935
|
-
var
|
|
9016
|
+
var import_react65 = require("react");
|
|
8936
9017
|
function useCommandShortcuts(registry, options = {}) {
|
|
8937
|
-
const optionsRef = (0,
|
|
9018
|
+
const optionsRef = (0, import_react65.useRef)(options);
|
|
8938
9019
|
optionsRef.current = options;
|
|
8939
9020
|
const { enabled = true, target } = options;
|
|
8940
|
-
(0,
|
|
9021
|
+
(0, import_react65.useEffect)(() => {
|
|
8941
9022
|
if (!registry || !enabled) return;
|
|
8942
9023
|
const eventTarget = target ?? (typeof window !== "undefined" ? window : null);
|
|
8943
9024
|
if (!eventTarget) return;
|
|
@@ -8955,14 +9036,14 @@ function useCommandShortcuts(registry, options = {}) {
|
|
|
8955
9036
|
}, [registry, enabled, target]);
|
|
8956
9037
|
}
|
|
8957
9038
|
function useRegisterCommands(registry, specs) {
|
|
8958
|
-
(0,
|
|
9039
|
+
(0, import_react65.useEffect)(() => {
|
|
8959
9040
|
if (!registry || !specs || specs.length === 0) return;
|
|
8960
9041
|
return registry.register(specs);
|
|
8961
9042
|
}, [registry, specs]);
|
|
8962
9043
|
}
|
|
8963
9044
|
|
|
8964
9045
|
// src/persistence/useAutosave.ts
|
|
8965
|
-
var
|
|
9046
|
+
var import_react66 = require("react");
|
|
8966
9047
|
var import_persistence = require("@pixerate/editor/persistence");
|
|
8967
9048
|
var IDLE = {
|
|
8968
9049
|
status: "idle",
|
|
@@ -8973,18 +9054,18 @@ var IDLE = {
|
|
|
8973
9054
|
ready: false
|
|
8974
9055
|
};
|
|
8975
9056
|
function useAutosave(options) {
|
|
8976
|
-
const optionsRef = (0,
|
|
9057
|
+
const optionsRef = (0, import_react66.useRef)(options);
|
|
8977
9058
|
optionsRef.current = options;
|
|
8978
9059
|
const { storage, key, history, dirty } = options;
|
|
8979
9060
|
const recover = options.recover !== false;
|
|
8980
9061
|
const flushOnHide = options.flushOnHide !== false;
|
|
8981
9062
|
const ready = options.ready !== false;
|
|
8982
|
-
const [controller, setController] = (0,
|
|
8983
|
-
const [status, setStatus] = (0,
|
|
8984
|
-
const [recovery, setRecovery] = (0,
|
|
8985
|
-
const [pendingRecovery, setPendingRecovery] = (0,
|
|
8986
|
-
const revisionsRef = (0,
|
|
8987
|
-
(0,
|
|
9063
|
+
const [controller, setController] = (0, import_react66.useState)(null);
|
|
9064
|
+
const [status, setStatus] = (0, import_react66.useState)(IDLE);
|
|
9065
|
+
const [recovery, setRecovery] = (0, import_react66.useState)(null);
|
|
9066
|
+
const [pendingRecovery, setPendingRecovery] = (0, import_react66.useState)(recover);
|
|
9067
|
+
const revisionsRef = (0, import_react66.useRef)(null);
|
|
9068
|
+
(0, import_react66.useEffect)(() => {
|
|
8988
9069
|
const revisions = (0, import_persistence.createRevisionTracker)({ history, dirty });
|
|
8989
9070
|
const o = optionsRef.current;
|
|
8990
9071
|
const instance = (0, import_persistence.createAutosaveController)({
|
|
@@ -9027,10 +9108,10 @@ function useAutosave(options) {
|
|
|
9027
9108
|
if (revisionsRef.current === revisions) revisionsRef.current = null;
|
|
9028
9109
|
};
|
|
9029
9110
|
}, [storage, key, history, dirty, recover]);
|
|
9030
|
-
(0,
|
|
9111
|
+
(0, import_react66.useEffect)(() => {
|
|
9031
9112
|
if (controller && ready && !pendingRecovery) controller.ready();
|
|
9032
9113
|
}, [controller, ready, pendingRecovery]);
|
|
9033
|
-
(0,
|
|
9114
|
+
(0, import_react66.useEffect)(() => {
|
|
9034
9115
|
if (!controller || !flushOnHide || typeof window === "undefined") return;
|
|
9035
9116
|
const flush = () => void controller.flushNow();
|
|
9036
9117
|
const onVisibility = () => {
|
|
@@ -9043,25 +9124,25 @@ function useAutosave(options) {
|
|
|
9043
9124
|
document.removeEventListener("visibilitychange", onVisibility);
|
|
9044
9125
|
};
|
|
9045
9126
|
}, [controller, flushOnHide]);
|
|
9046
|
-
const restore = (0,
|
|
9127
|
+
const restore = (0, import_react66.useCallback)(() => {
|
|
9047
9128
|
const snapshot = recovery?.snapshot;
|
|
9048
9129
|
setRecovery(null);
|
|
9049
9130
|
setPendingRecovery(false);
|
|
9050
9131
|
return snapshot;
|
|
9051
9132
|
}, [recovery]);
|
|
9052
|
-
const discard = (0,
|
|
9133
|
+
const discard = (0, import_react66.useCallback)(async () => {
|
|
9053
9134
|
if (controller) await controller.discardRecovery();
|
|
9054
9135
|
setRecovery(null);
|
|
9055
9136
|
setPendingRecovery(false);
|
|
9056
9137
|
}, [controller]);
|
|
9057
|
-
const flushNow = (0,
|
|
9138
|
+
const flushNow = (0, import_react66.useCallback)(async () => {
|
|
9058
9139
|
await controller?.flushNow();
|
|
9059
9140
|
}, [controller]);
|
|
9060
|
-
const markClean = (0,
|
|
9141
|
+
const markClean = (0, import_react66.useCallback)(async () => {
|
|
9061
9142
|
revisionsRef.current?.markSaved();
|
|
9062
9143
|
await controller?.markClean();
|
|
9063
9144
|
}, [controller]);
|
|
9064
|
-
const notifyChange = (0,
|
|
9145
|
+
const notifyChange = (0, import_react66.useCallback)(() => revisionsRef.current?.bump(), []);
|
|
9065
9146
|
return { status, recovery, pendingRecovery, restore, discard, flushNow, markClean, notifyChange, controller };
|
|
9066
9147
|
}
|
|
9067
9148
|
|
|
@@ -9121,17 +9202,17 @@ var RecoveryPrompt = ({
|
|
|
9121
9202
|
};
|
|
9122
9203
|
|
|
9123
9204
|
// src/generation/useGenerationPlan.ts
|
|
9124
|
-
var
|
|
9205
|
+
var import_react67 = require("react");
|
|
9125
9206
|
var import_generation = require("@pixerate/editor/generation");
|
|
9126
9207
|
function useGenerationPlan(request, capabilities, options = {}) {
|
|
9127
9208
|
const key = JSON.stringify([request, capabilities, options]);
|
|
9128
|
-
return (0,
|
|
9209
|
+
return (0, import_react67.useMemo)(() => (0, import_generation.planGenerationRequest)(request, capabilities, options), [key]);
|
|
9129
9210
|
}
|
|
9130
9211
|
function useJobProgress(options) {
|
|
9131
9212
|
const { startedAt, expectedMs, done, now, intervalMs = 1e3 } = options;
|
|
9132
|
-
const [tick, setTick] = (0,
|
|
9213
|
+
const [tick, setTick] = (0, import_react67.useState)(() => Date.now());
|
|
9133
9214
|
const ticking = !done && now === void 0;
|
|
9134
|
-
(0,
|
|
9215
|
+
(0, import_react67.useEffect)(() => {
|
|
9135
9216
|
if (!ticking) return;
|
|
9136
9217
|
setTick(Date.now());
|
|
9137
9218
|
const id = setInterval(() => setTick(Date.now()), Math.max(16, intervalMs));
|
|
@@ -9141,7 +9222,7 @@ function useJobProgress(options) {
|
|
|
9141
9222
|
}
|
|
9142
9223
|
|
|
9143
9224
|
// src/generation/GenerationSettings.tsx
|
|
9144
|
-
var
|
|
9225
|
+
var import_react68 = require("react");
|
|
9145
9226
|
var import_generation2 = require("@pixerate/editor/generation");
|
|
9146
9227
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
9147
9228
|
var inputClass2 = "w-full rounded-md border border-border bg-background px-2 py-1 text-sm outline-none focus:ring-1 focus:ring-ring";
|
|
@@ -9224,8 +9305,8 @@ var GenerationSettings = ({
|
|
|
9224
9305
|
renderReference,
|
|
9225
9306
|
className = ""
|
|
9226
9307
|
}) => {
|
|
9227
|
-
const baseId = (0,
|
|
9228
|
-
const controls = (0,
|
|
9308
|
+
const baseId = (0, import_react68.useId)();
|
|
9309
|
+
const controls = (0, import_react68.useMemo)(() => (0, import_generation2.getGenerationControls)(capabilities), [capabilities]);
|
|
9229
9310
|
const computed = useGenerationPlan(value, capabilities, { strategy });
|
|
9230
9311
|
const plan = planProp ?? computed;
|
|
9231
9312
|
const slots = (0, import_generation2.getReferenceSlots)(capabilities, value);
|
|
@@ -9320,7 +9401,7 @@ var JobProgress = ({ title, className = "", ...options }) => {
|
|
|
9320
9401
|
};
|
|
9321
9402
|
|
|
9322
9403
|
// src/generation/AssetMentionChips.tsx
|
|
9323
|
-
var
|
|
9404
|
+
var import_react69 = require("react");
|
|
9324
9405
|
var import_generation3 = require("@pixerate/editor/generation");
|
|
9325
9406
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
9326
9407
|
var AssetMentionChips = ({
|
|
@@ -9332,14 +9413,14 @@ var AssetMentionChips = ({
|
|
|
9332
9413
|
renderAsset,
|
|
9333
9414
|
className = ""
|
|
9334
9415
|
}) => {
|
|
9335
|
-
const [open, setOpen] = (0,
|
|
9336
|
-
const rootRef = (0,
|
|
9337
|
-
const chips = (0,
|
|
9416
|
+
const [open, setOpen] = (0, import_react69.useState)(null);
|
|
9417
|
+
const rootRef = (0, import_react69.useRef)(null);
|
|
9418
|
+
const chips = (0, import_react69.useMemo)(
|
|
9338
9419
|
() => (0, import_generation3.describeAssetMentions)((0, import_generation3.findTextMentions)(content), assets, capabilities),
|
|
9339
9420
|
[content, assets, capabilities]
|
|
9340
9421
|
);
|
|
9341
9422
|
const options = roles ?? (capabilities ? (0, import_generation3.getAssetRoleOptions)(capabilities) : (0, import_generation3.defaultAssetRoleOptions)());
|
|
9342
|
-
(0,
|
|
9423
|
+
(0, import_react69.useEffect)(() => {
|
|
9343
9424
|
if (open === null) return;
|
|
9344
9425
|
const onPointer = (event) => {
|
|
9345
9426
|
if (!rootRef.current?.contains(event.target)) setOpen(null);
|
|
@@ -9434,15 +9515,15 @@ var AssetMentionChips = ({
|
|
|
9434
9515
|
};
|
|
9435
9516
|
|
|
9436
9517
|
// src/generation/GenerationHistory.tsx
|
|
9437
|
-
var
|
|
9518
|
+
var import_react70 = require("react");
|
|
9438
9519
|
var import_generation4 = require("@pixerate/editor/generation");
|
|
9439
9520
|
var import_jsx_runtime49 = require("react/jsx-runtime");
|
|
9440
9521
|
function useGenerationRecords(store, filter) {
|
|
9441
|
-
const [records, setRecords] = (0,
|
|
9442
|
-
const [loading, setLoading] = (0,
|
|
9443
|
-
const [error, setError] = (0,
|
|
9522
|
+
const [records, setRecords] = (0, import_react70.useState)([]);
|
|
9523
|
+
const [loading, setLoading] = (0, import_react70.useState)(!!store);
|
|
9524
|
+
const [error, setError] = (0, import_react70.useState)(null);
|
|
9444
9525
|
const filterKey = (0, import_generation4.stableStringify)(filter ?? {});
|
|
9445
|
-
const refresh = (0,
|
|
9526
|
+
const refresh = (0, import_react70.useCallback)(async () => {
|
|
9446
9527
|
if (!store) {
|
|
9447
9528
|
setRecords([]);
|
|
9448
9529
|
setLoading(false);
|
|
@@ -9459,7 +9540,7 @@ function useGenerationRecords(store, filter) {
|
|
|
9459
9540
|
setLoading(false);
|
|
9460
9541
|
}
|
|
9461
9542
|
}, [store, filterKey]);
|
|
9462
|
-
(0,
|
|
9543
|
+
(0, import_react70.useEffect)(() => {
|
|
9463
9544
|
void refresh();
|
|
9464
9545
|
if (!store) return;
|
|
9465
9546
|
return store.subscribe(() => void refresh());
|
|
@@ -9485,15 +9566,15 @@ var GenerationHistory = ({
|
|
|
9485
9566
|
emptyText = "No generations yet.",
|
|
9486
9567
|
className = ""
|
|
9487
9568
|
}) => {
|
|
9488
|
-
const [innerMode, setInnerMode] = (0,
|
|
9569
|
+
const [innerMode, setInnerMode] = (0, import_react70.useState)("exact");
|
|
9489
9570
|
const mode = modeProp ?? innerMode;
|
|
9490
9571
|
const setMode = (next) => {
|
|
9491
9572
|
if (modeProp === void 0) setInnerMode(next);
|
|
9492
9573
|
onModeChange?.(next);
|
|
9493
9574
|
};
|
|
9494
|
-
const options = (0,
|
|
9495
|
-
const results = (0,
|
|
9496
|
-
const models = (0,
|
|
9575
|
+
const options = (0, import_react70.useMemo)(() => ({ templates, capabilities, assets, mode }), [templates, capabilities, assets, mode]);
|
|
9576
|
+
const results = (0, import_react70.useMemo)(() => records.map((record) => (0, import_generation4.recreateRequest)(record, options)), [records, options]);
|
|
9577
|
+
const models = (0, import_react70.useMemo)(
|
|
9497
9578
|
() => capabilities ? Array.isArray(capabilities) ? capabilities : [capabilities] : [],
|
|
9498
9579
|
[capabilities]
|
|
9499
9580
|
);
|
|
@@ -9604,19 +9685,19 @@ var GenerationHistory = ({
|
|
|
9604
9685
|
};
|
|
9605
9686
|
|
|
9606
9687
|
// src/find-replace/useFindReplace.ts
|
|
9607
|
-
var
|
|
9688
|
+
var import_react71 = require("react");
|
|
9608
9689
|
var import_editor16 = require("@pixerate/editor");
|
|
9609
9690
|
var noopUnsubscribe2 = () => {
|
|
9610
9691
|
};
|
|
9611
9692
|
function useFindReplace(editor) {
|
|
9612
9693
|
const store = (0, import_editor16.getFindReplaceStore)(editor ?? null);
|
|
9613
|
-
const subscribe = (0,
|
|
9694
|
+
const subscribe = (0, import_react71.useCallback)(
|
|
9614
9695
|
(onChange) => store ? store.subscribe(() => onChange()) : noopUnsubscribe2,
|
|
9615
9696
|
[store]
|
|
9616
9697
|
);
|
|
9617
9698
|
const getSnapshot = () => store?.getSnapshot() ?? import_editor16.EMPTY_FIND_REPLACE_SNAPSHOT;
|
|
9618
|
-
const snapshot = (0,
|
|
9619
|
-
return (0,
|
|
9699
|
+
const snapshot = (0, import_react71.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
9700
|
+
return (0, import_react71.useMemo)(() => {
|
|
9620
9701
|
const run = (fn) => {
|
|
9621
9702
|
if (editor && !editor.isDestroyed && store) fn(editor);
|
|
9622
9703
|
};
|
|
@@ -9640,7 +9721,7 @@ function useFindReplace(editor) {
|
|
|
9640
9721
|
}
|
|
9641
9722
|
|
|
9642
9723
|
// src/find-replace/FindReplaceBar.tsx
|
|
9643
|
-
var
|
|
9724
|
+
var import_react72 = require("react");
|
|
9644
9725
|
var import_editor17 = require("@pixerate/editor");
|
|
9645
9726
|
var import_jsx_runtime50 = require("react/jsx-runtime");
|
|
9646
9727
|
var inputClass3 = "min-w-0 flex-1 rounded border border-input bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-ring";
|
|
@@ -9655,10 +9736,10 @@ var FindReplaceBar = ({
|
|
|
9655
9736
|
onClose
|
|
9656
9737
|
}) => {
|
|
9657
9738
|
const find = useFindReplace(editor);
|
|
9658
|
-
const findInput = (0,
|
|
9659
|
-
const [moreOpen, setMoreOpen] = (0,
|
|
9739
|
+
const findInput = (0, import_react72.useRef)(null);
|
|
9740
|
+
const [moreOpen, setMoreOpen] = (0, import_react72.useState)(false);
|
|
9660
9741
|
const visible = find.available && (alwaysOpen || find.open);
|
|
9661
|
-
(0,
|
|
9742
|
+
(0, import_react72.useEffect)(() => {
|
|
9662
9743
|
if (!visible || find.focusRequest === 0) return;
|
|
9663
9744
|
findInput.current?.focus();
|
|
9664
9745
|
findInput.current?.select();
|
|
@@ -9802,12 +9883,12 @@ var FindReplaceBar = ({
|
|
|
9802
9883
|
};
|
|
9803
9884
|
|
|
9804
9885
|
// src/tables/useTableMenu.ts
|
|
9805
|
-
var
|
|
9886
|
+
var import_react73 = require("react");
|
|
9806
9887
|
var import_editor18 = require("@pixerate/editor");
|
|
9807
9888
|
function useTableMenu(editor) {
|
|
9808
|
-
const store = (0,
|
|
9809
|
-
const snapshot = (0,
|
|
9810
|
-
return (0,
|
|
9889
|
+
const store = (0, import_react73.useMemo)(() => (0, import_editor18.createTableStore)(editor), [editor]);
|
|
9890
|
+
const snapshot = (0, import_react73.useSyncExternalStore)(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
9891
|
+
return (0, import_react73.useMemo)(
|
|
9811
9892
|
() => ({
|
|
9812
9893
|
...snapshot,
|
|
9813
9894
|
run: (action, params) => (0, import_editor18.runTableAction)(editor, action, params, { focus: true }),
|
|
@@ -9818,7 +9899,7 @@ function useTableMenu(editor) {
|
|
|
9818
9899
|
}
|
|
9819
9900
|
|
|
9820
9901
|
// src/tables/TableToolbar.tsx
|
|
9821
|
-
var
|
|
9902
|
+
var import_react74 = __toESM(require("react"), 1);
|
|
9822
9903
|
var import_editor19 = require("@pixerate/editor");
|
|
9823
9904
|
var import_jsx_runtime51 = require("react/jsx-runtime");
|
|
9824
9905
|
var keepSelection2 = (event) => event.preventDefault();
|
|
@@ -9839,7 +9920,7 @@ var TableToolbar = ({
|
|
|
9839
9920
|
const enabled = status === true;
|
|
9840
9921
|
const active = item.active?.(table);
|
|
9841
9922
|
const separator = index > 0 && items[index - 1].group !== item.group;
|
|
9842
|
-
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
|
|
9923
|
+
return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_react74.default.Fragment, { children: [
|
|
9843
9924
|
separator && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("span", { className: separatorClassName, "aria-hidden": "true" }),
|
|
9844
9925
|
/* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
|
|
9845
9926
|
"button",
|
|
@@ -9863,7 +9944,7 @@ var TableToolbar = ({
|
|
|
9863
9944
|
};
|
|
9864
9945
|
|
|
9865
9946
|
// src/tables/InsertTableGrid.tsx
|
|
9866
|
-
var
|
|
9947
|
+
var import_react75 = require("react");
|
|
9867
9948
|
var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
9868
9949
|
var keepSelection3 = (event) => event.preventDefault();
|
|
9869
9950
|
var InsertTableGrid = ({
|
|
@@ -9877,7 +9958,7 @@ var InsertTableGrid = ({
|
|
|
9877
9958
|
onInsert
|
|
9878
9959
|
}) => {
|
|
9879
9960
|
const table = useTableMenu(editor);
|
|
9880
|
-
const [hover, setHover] = (0,
|
|
9961
|
+
const [hover, setHover] = (0, import_react75.useState)(null);
|
|
9881
9962
|
const status = table.actions.insertTable;
|
|
9882
9963
|
const disabled = !editor || !status.enabled;
|
|
9883
9964
|
const insert = (size) => {
|
|
@@ -9944,14 +10025,14 @@ var TableBubbleMenu = ({
|
|
|
9944
10025
|
var import_client = require("react-dom/client");
|
|
9945
10026
|
|
|
9946
10027
|
// src/chart/ChartCanvas.tsx
|
|
9947
|
-
var
|
|
10028
|
+
var import_react77 = require("react");
|
|
9948
10029
|
var import_chart2 = require("@pixerate/editor/chart");
|
|
9949
10030
|
|
|
9950
10031
|
// src/chart/useChartEditor.ts
|
|
9951
|
-
var
|
|
10032
|
+
var import_react76 = require("react");
|
|
9952
10033
|
var import_chart = require("@pixerate/editor/chart");
|
|
9953
10034
|
function useChartState(controller) {
|
|
9954
|
-
return (0,
|
|
10035
|
+
return (0, import_react76.useSyncExternalStore)(controller.subscribe, controller.getState, controller.getState);
|
|
9955
10036
|
}
|
|
9956
10037
|
|
|
9957
10038
|
// src/chart/ChartCanvas.tsx
|
|
@@ -10003,7 +10084,7 @@ function renderChartMark(mark, fontFamily, interactive) {
|
|
|
10003
10084
|
}
|
|
10004
10085
|
}
|
|
10005
10086
|
function ChartPresenceLayer({ presence }) {
|
|
10006
|
-
const { actors } = (0,
|
|
10087
|
+
const { actors } = (0, import_react77.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
10007
10088
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("g", { "data-chart-presence": "", pointerEvents: "none", children: actors.map((a) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("g", { transform: `translate(${a.x} ${a.y})`, "data-actor": a.id, children: [
|
|
10008
10089
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 }, transform: a.pressed ? "scale(0.9)" : void 0 }),
|
|
10009
10090
|
/* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("g", { transform: "translate(13 16)", children: [
|
|
@@ -10014,12 +10095,12 @@ function ChartPresenceLayer({ presence }) {
|
|
|
10014
10095
|
}
|
|
10015
10096
|
function ChartCanvas({ controller, width = 640, height = 400, responsive = true, theme, editable = true, measureText, emptyMessage, className, presence, sceneRef }) {
|
|
10016
10097
|
const state = useChartState(controller);
|
|
10017
|
-
const wrapper = (0,
|
|
10018
|
-
const svg = (0,
|
|
10019
|
-
const drag = (0,
|
|
10020
|
-
const [measured, setMeasured] = (0,
|
|
10021
|
-
const [frozen, setFrozen] = (0,
|
|
10022
|
-
(0,
|
|
10098
|
+
const wrapper = (0, import_react77.useRef)(null);
|
|
10099
|
+
const svg = (0, import_react77.useRef)(null);
|
|
10100
|
+
const drag = (0, import_react77.useRef)(null);
|
|
10101
|
+
const [measured, setMeasured] = (0, import_react77.useState)(null);
|
|
10102
|
+
const [frozen, setFrozen] = (0, import_react77.useState)(null);
|
|
10103
|
+
(0, import_react77.useEffect)(() => {
|
|
10023
10104
|
const el = wrapper.current;
|
|
10024
10105
|
if (!responsive || !el || typeof ResizeObserver === "undefined") return;
|
|
10025
10106
|
const observer = new ResizeObserver(([entry]) => {
|
|
@@ -10030,8 +10111,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
10030
10111
|
return () => observer.disconnect();
|
|
10031
10112
|
}, [responsive]);
|
|
10032
10113
|
const sceneWidth = responsive && measured || width;
|
|
10033
|
-
const fullTheme = (0,
|
|
10034
|
-
const scene = (0,
|
|
10114
|
+
const fullTheme = (0, import_react77.useMemo)(() => ({ ...import_chart2.CSS_VARIABLE_CHART_THEME, ...theme }), [theme]);
|
|
10115
|
+
const scene = (0, import_react77.useMemo)(
|
|
10035
10116
|
() => (0, import_chart2.layoutChart)(state.spec, {
|
|
10036
10117
|
width: sceneWidth,
|
|
10037
10118
|
height,
|
|
@@ -10047,8 +10128,8 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
10047
10128
|
[state.spec, state.selection, sceneWidth, height, fullTheme, editable, measureText, emptyMessage, frozen]
|
|
10048
10129
|
);
|
|
10049
10130
|
if (sceneRef) sceneRef.current = scene;
|
|
10050
|
-
const byKey = (0,
|
|
10051
|
-
(0,
|
|
10131
|
+
const byKey = (0, import_react77.useMemo)(() => new Map(scene.marks.map((m) => [m.key, m])), [scene]);
|
|
10132
|
+
(0, import_react77.useEffect)(() => () => drag.current?.end(), []);
|
|
10052
10133
|
const scenePoint = (e) => (0, import_chart2.chartClientToScene)(scene, svg.current.getBoundingClientRect(), e.clientX, e.clientY);
|
|
10053
10134
|
const onPointerDown = (e) => {
|
|
10054
10135
|
if (!editable || e.button !== 0) return;
|
|
@@ -10106,7 +10187,7 @@ function ChartCanvas({ controller, width = 640, height = 400, responsive = true,
|
|
|
10106
10187
|
}
|
|
10107
10188
|
|
|
10108
10189
|
// src/chart/ChartDataGrid.tsx
|
|
10109
|
-
var
|
|
10190
|
+
var import_react78 = require("react");
|
|
10110
10191
|
var import_chart3 = require("@pixerate/editor/chart");
|
|
10111
10192
|
|
|
10112
10193
|
// src/chart/styles.ts
|
|
@@ -10121,9 +10202,9 @@ var chartCellClass = "h-7 w-full min-w-[4.5rem] bg-transparent px-2 text-right t
|
|
|
10121
10202
|
// src/chart/ChartDataGrid.tsx
|
|
10122
10203
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
10123
10204
|
function ChartCommitInput({ value, onCommit, onKeyDown, onBlur, ...rest }) {
|
|
10124
|
-
const [draft, setDraft] = (0,
|
|
10125
|
-
const typing = (0,
|
|
10126
|
-
(0,
|
|
10205
|
+
const [draft, setDraft] = (0, import_react78.useState)(value);
|
|
10206
|
+
const typing = (0, import_react78.useRef)(false);
|
|
10207
|
+
(0, import_react78.useEffect)(() => {
|
|
10127
10208
|
if (!typing.current) setDraft(value);
|
|
10128
10209
|
}, [value]);
|
|
10129
10210
|
const commit = () => {
|
|
@@ -10259,7 +10340,7 @@ function ChartDataGrid({ controller, categoryHeader = "Category", readOnly = fal
|
|
|
10259
10340
|
}
|
|
10260
10341
|
|
|
10261
10342
|
// src/chart/ChartInspector.tsx
|
|
10262
|
-
var
|
|
10343
|
+
var import_react79 = require("react");
|
|
10263
10344
|
var import_chart4 = require("@pixerate/editor/chart");
|
|
10264
10345
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
10265
10346
|
var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
@@ -10424,7 +10505,7 @@ function ErrorBarFields({ controller, series, which, idBase }) {
|
|
|
10424
10505
|
}
|
|
10425
10506
|
function ChartInspector({ controller, sections, className }) {
|
|
10426
10507
|
const { spec, selectedSeries } = useChartState(controller);
|
|
10427
|
-
const idBase = (0,
|
|
10508
|
+
const idBase = (0, import_react79.useId)();
|
|
10428
10509
|
const show = (section) => !sections || sections.includes(section);
|
|
10429
10510
|
const cartesian = (0, import_chart4.isCartesianChart)(spec.type);
|
|
10430
10511
|
const family = (0, import_chart4.chartFamily)(spec);
|
|
@@ -10734,6 +10815,7 @@ function createReactChartNodeView(options = {}) {
|
|
|
10734
10815
|
useDocxExport,
|
|
10735
10816
|
useEditor,
|
|
10736
10817
|
useEditorSlots,
|
|
10818
|
+
useElementPlaybackSurface,
|
|
10737
10819
|
useFileImport,
|
|
10738
10820
|
useFillHandle,
|
|
10739
10821
|
useFindReplace,
|