@canvas-components/print-design-plugin 0.1.6 → 0.1.8
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/README.md +47 -5
- package/dist/index.cjs +445 -13
- package/dist/index.js +445 -13
- package/dist/list-table-print.cjs +519 -13
- package/dist/list-table-print.css +334 -0
- package/dist/list-table-print.js +519 -13
- package/dist/native.cjs +445 -13
- package/dist/native.js +445 -13
- package/dist/react.cjs +2136 -22
- package/dist/react.css +334 -0
- package/dist/react.d.cts +99 -1
- package/dist/react.d.ts +99 -1
- package/dist/react.js +2138 -25
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -994,13 +994,45 @@ function validateListTemplateData(element, data) {
|
|
|
994
994
|
);
|
|
995
995
|
}
|
|
996
996
|
|
|
997
|
+
// src/plugins/list/interaction/commands.ts
|
|
998
|
+
var listCommands = {
|
|
999
|
+
execute(element, command, payload) {
|
|
1000
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
1001
|
+
const args = payload;
|
|
1002
|
+
const index = args.index;
|
|
1003
|
+
if (!Number.isInteger(index)) return;
|
|
1004
|
+
const at = index;
|
|
1005
|
+
const items = [...element.items];
|
|
1006
|
+
if (command === "remove-item") {
|
|
1007
|
+
if (at < 0 || at >= items.length) return;
|
|
1008
|
+
items.splice(at, 1);
|
|
1009
|
+
} else if (command === "insert-item") {
|
|
1010
|
+
if (at < 0 || at > items.length || typeof args.text !== "string") return;
|
|
1011
|
+
items.splice(at, 0, { text: args.text, checked: false });
|
|
1012
|
+
} else if (command === "update-item") {
|
|
1013
|
+
if (at < 0 || at >= items.length) return;
|
|
1014
|
+
if (args.text !== void 0 && typeof args.text !== "string") return;
|
|
1015
|
+
if (args.checked !== void 0 && typeof args.checked !== "boolean")
|
|
1016
|
+
return;
|
|
1017
|
+
items[at] = {
|
|
1018
|
+
...items[at],
|
|
1019
|
+
...args.text === void 0 ? {} : { text: args.text },
|
|
1020
|
+
...args.checked === void 0 ? {} : { checked: args.checked }
|
|
1021
|
+
};
|
|
1022
|
+
} else return;
|
|
1023
|
+
const next = { ...element, items };
|
|
1024
|
+
return validateListElement(next) ? next : void 0;
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
|
|
997
1028
|
// src/plugins/list/native.ts
|
|
998
1029
|
var listNativePlugin = defineNativePlugin(
|
|
999
1030
|
"list",
|
|
1000
|
-
"0.1.
|
|
1031
|
+
"0.1.9",
|
|
1001
1032
|
printDesign.definePrintDesignPluginRenderer({
|
|
1002
1033
|
type: "list",
|
|
1003
1034
|
validate: validateListElement,
|
|
1035
|
+
commands: listCommands,
|
|
1004
1036
|
bindingInfo: listBindingInfo,
|
|
1005
1037
|
validateTemplateData: validateListTemplateData,
|
|
1006
1038
|
drawCanvas: drawListElement,
|
|
@@ -2637,16 +2669,51 @@ function pointToSegmentDistance(point, a, b) {
|
|
|
2637
2669
|
return Math.hypot(point.x - a.x - t * dx, point.y - a.y - t * dy);
|
|
2638
2670
|
}
|
|
2639
2671
|
|
|
2672
|
+
// src/plugins/shape/interaction/commands.ts
|
|
2673
|
+
var validPoints = (value) => Array.isArray(value) && value.every(
|
|
2674
|
+
(point) => point && typeof point === "object" && Number.isFinite(point.x) && Number.isFinite(point.y)
|
|
2675
|
+
);
|
|
2676
|
+
var shapeCommands = {
|
|
2677
|
+
execute(element, command, payload) {
|
|
2678
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
2679
|
+
const args = payload;
|
|
2680
|
+
if (!validPoints(args.points)) return;
|
|
2681
|
+
const points = args.points;
|
|
2682
|
+
let next;
|
|
2683
|
+
if (command === "set-polygon-points") {
|
|
2684
|
+
if (!["triangle", "polygon", "star"].includes(element.shape) || points.length < 3)
|
|
2685
|
+
return;
|
|
2686
|
+
next = { ...element, polygonPoints: points };
|
|
2687
|
+
} else if (command === "set-curve-points") {
|
|
2688
|
+
if (!["curve-quadratic", "curve-cubic", "curve-multi"].includes(
|
|
2689
|
+
element.shape
|
|
2690
|
+
) || points.length < 2)
|
|
2691
|
+
return;
|
|
2692
|
+
next = { ...element, curvePoints: points };
|
|
2693
|
+
} else if (command === "set-path-points") {
|
|
2694
|
+
if (element.shape !== "curve-path") return;
|
|
2695
|
+
if (args.closed !== void 0 && typeof args.closed !== "boolean") return;
|
|
2696
|
+
next = {
|
|
2697
|
+
...element,
|
|
2698
|
+
pathPoints: points,
|
|
2699
|
+
...args.closed === void 0 ? {} : { pathClosed: args.closed }
|
|
2700
|
+
};
|
|
2701
|
+
} else return;
|
|
2702
|
+
return validateShapeElement(next) ? next : void 0;
|
|
2703
|
+
}
|
|
2704
|
+
};
|
|
2705
|
+
|
|
2640
2706
|
// src/plugins/shape/native.ts
|
|
2641
2707
|
var shapeNativePlugin = defineNativePlugin(
|
|
2642
2708
|
"shape",
|
|
2643
|
-
"0.1.
|
|
2709
|
+
"0.1.21",
|
|
2644
2710
|
printDesign.definePrintDesignPluginRenderer({
|
|
2645
2711
|
type: "shape",
|
|
2646
2712
|
dataFields: shapeDataFields,
|
|
2647
2713
|
bindingInfo: (element) => registeredFieldBindingInfo(element, shapeDataFields),
|
|
2648
2714
|
validateTemplateData: (element, data) => validateRegisteredFieldBindings(element, shapeDataFields, data),
|
|
2649
2715
|
validate: validateShapeElement,
|
|
2716
|
+
commands: shapeCommands,
|
|
2650
2717
|
drawCanvas: drawShapeElement,
|
|
2651
2718
|
renderHtml: (element, context) => renderShapeHtml(element, context.data),
|
|
2652
2719
|
hitTest: hitShape,
|
|
@@ -2988,13 +3055,42 @@ var brushPointerStroke = {
|
|
|
2988
3055
|
}
|
|
2989
3056
|
};
|
|
2990
3057
|
|
|
3058
|
+
// src/plugins/brush/interaction/commands.ts
|
|
3059
|
+
var brushCommands = {
|
|
3060
|
+
execute(element, command, payload) {
|
|
3061
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
3062
|
+
const args = payload;
|
|
3063
|
+
if (command === "append-stroke") {
|
|
3064
|
+
if (!Array.isArray(args.points) || args.points.length < 2) return;
|
|
3065
|
+
const next2 = {
|
|
3066
|
+
...element,
|
|
3067
|
+
strokes: [
|
|
3068
|
+
...element.strokes,
|
|
3069
|
+
args.points
|
|
3070
|
+
]
|
|
3071
|
+
};
|
|
3072
|
+
return validateBrushElement(next2) ? next2 : void 0;
|
|
3073
|
+
}
|
|
3074
|
+
if (command !== "remove-stroke" || !Number.isInteger(args.index)) return;
|
|
3075
|
+
const index = args.index;
|
|
3076
|
+
if (index < 0 || index >= element.strokes.length) return;
|
|
3077
|
+
const next = {
|
|
3078
|
+
...element,
|
|
3079
|
+
strokes: element.strokes.filter((_, at) => at !== index),
|
|
3080
|
+
strokeStyles: element.strokeStyles?.filter((_, at) => at !== index)
|
|
3081
|
+
};
|
|
3082
|
+
return validateBrushElement(next) ? next : void 0;
|
|
3083
|
+
}
|
|
3084
|
+
};
|
|
3085
|
+
|
|
2991
3086
|
// src/plugins/brush/native.ts
|
|
2992
3087
|
var brushNativePlugin = defineNativePlugin(
|
|
2993
3088
|
"brush",
|
|
2994
|
-
"0.1.
|
|
3089
|
+
"0.1.5",
|
|
2995
3090
|
printDesign.definePrintDesignPluginRenderer({
|
|
2996
3091
|
type: "brush",
|
|
2997
3092
|
validate: validateBrushElement,
|
|
3093
|
+
commands: brushCommands,
|
|
2998
3094
|
drawCanvas: drawBrushElement,
|
|
2999
3095
|
renderHtml: (element) => renderBrushHtml(element),
|
|
3000
3096
|
hitTest: hitBrush,
|
|
@@ -3990,6 +4086,46 @@ function validateConnectorElement(value) {
|
|
|
3990
4086
|
const validPoint = (point) => !!point && Number.isFinite(point.x) && Number.isFinite(point.y);
|
|
3991
4087
|
return element.type === "connector" && (element.lineType === void 0 || ["straight", "curve", "polyline"].includes(element.lineType)) && (element.polylinePoints === void 0 || Array.isArray(element.polylinePoints) && element.polylinePoints.every(validPoint)) && (element.strokeWidth === void 0 || Number.isFinite(element.strokeWidth) && element.strokeWidth >= 0) && (element.textPosition === void 0 || Number.isFinite(element.textPosition) && element.textPosition >= 0 && element.textPosition <= 1);
|
|
3992
4088
|
}
|
|
4089
|
+
|
|
4090
|
+
// src/plugins/connector/interaction/commands.ts
|
|
4091
|
+
var validEndpoint = (value) => {
|
|
4092
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
4093
|
+
const endpoint2 = value;
|
|
4094
|
+
return (endpoint2.elementId === void 0 || typeof endpoint2.elementId === "string") && (endpoint2.anchor === void 0 || typeof endpoint2.anchor === "string" && ([
|
|
4095
|
+
"auto",
|
|
4096
|
+
"top",
|
|
4097
|
+
"right",
|
|
4098
|
+
"bottom",
|
|
4099
|
+
"left",
|
|
4100
|
+
"top-left",
|
|
4101
|
+
"top-right",
|
|
4102
|
+
"bottom-right",
|
|
4103
|
+
"bottom-left"
|
|
4104
|
+
].includes(endpoint2.anchor) || /^(edge|vertex):\d+$/.test(endpoint2.anchor)));
|
|
4105
|
+
};
|
|
4106
|
+
var connectorCommands = {
|
|
4107
|
+
execute(element, command, payload) {
|
|
4108
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
4109
|
+
const args = payload;
|
|
4110
|
+
if (command === "set-endpoint") {
|
|
4111
|
+
if (args.side !== "start" && args.side !== "end") return;
|
|
4112
|
+
if (!validEndpoint(args.endpoint)) return;
|
|
4113
|
+
const next2 = { ...element, [args.side]: args.endpoint };
|
|
4114
|
+
return validateConnectorElement(next2) ? next2 : void 0;
|
|
4115
|
+
}
|
|
4116
|
+
if (command !== "set-waypoints" || element.lineType !== "polyline")
|
|
4117
|
+
return;
|
|
4118
|
+
if (!Array.isArray(args.points) || !args.points.every(
|
|
4119
|
+
(point) => point && typeof point === "object" && Number.isFinite(point.x) && Number.isFinite(point.y)
|
|
4120
|
+
))
|
|
4121
|
+
return;
|
|
4122
|
+
const next = {
|
|
4123
|
+
...element,
|
|
4124
|
+
polylinePoints: args.points
|
|
4125
|
+
};
|
|
4126
|
+
return validateConnectorElement(next) ? next : void 0;
|
|
4127
|
+
}
|
|
4128
|
+
};
|
|
3993
4129
|
var CONNECTOR_EXPRESSION = /\{\{\s*([\w.[\]-]+)(?:\|(?:date|dateSlash))?\s*\}\}/g;
|
|
3994
4130
|
function labelPaths(element) {
|
|
3995
4131
|
return [...(element.text ?? "").matchAll(CONNECTOR_EXPRESSION)].map(
|
|
@@ -4010,10 +4146,11 @@ function validateConnectorTemplateData(element, data) {
|
|
|
4010
4146
|
// src/plugins/connector/native.ts
|
|
4011
4147
|
var connectorNativePlugin = defineNativePlugin(
|
|
4012
4148
|
"connector",
|
|
4013
|
-
"0.1.
|
|
4149
|
+
"0.1.32",
|
|
4014
4150
|
printDesign.definePrintDesignPluginRenderer({
|
|
4015
4151
|
type: "connector",
|
|
4016
4152
|
validate: validateConnectorElement,
|
|
4153
|
+
commands: connectorCommands,
|
|
4017
4154
|
bindingInfo: connectorBindingInfo,
|
|
4018
4155
|
validateTemplateData: validateConnectorTemplateData,
|
|
4019
4156
|
allowSignedSize: true,
|
|
@@ -4892,13 +5029,68 @@ function gridDebugRegions(element, context, hitElement = element) {
|
|
|
4892
5029
|
return [...cells, ...loops, ...columnLoops];
|
|
4893
5030
|
}
|
|
4894
5031
|
|
|
5032
|
+
// src/plugins/grid/interaction/commands.ts
|
|
5033
|
+
function executeGridCommand(element, command, payload, validate) {
|
|
5034
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
5035
|
+
const args = payload;
|
|
5036
|
+
if (command === "resize-grid") {
|
|
5037
|
+
const rows = args.rows;
|
|
5038
|
+
const columns = args.columns;
|
|
5039
|
+
if (!Number.isInteger(rows) || !Number.isInteger(columns)) return;
|
|
5040
|
+
if (rows < 1 || rows > 50 || columns < 1 || columns > 50)
|
|
5041
|
+
return;
|
|
5042
|
+
const cells2 = Array.from(
|
|
5043
|
+
{ length: rows * columns },
|
|
5044
|
+
(_, index2) => {
|
|
5045
|
+
const row = Math.floor(index2 / columns);
|
|
5046
|
+
const column = index2 % columns;
|
|
5047
|
+
return element.cells?.[row * element.columns + column] ?? {};
|
|
5048
|
+
}
|
|
5049
|
+
);
|
|
5050
|
+
const next2 = {
|
|
5051
|
+
...element,
|
|
5052
|
+
rows,
|
|
5053
|
+
columns,
|
|
5054
|
+
cells: cells2
|
|
5055
|
+
};
|
|
5056
|
+
return validate(next2) ? next2 : void 0;
|
|
5057
|
+
}
|
|
5058
|
+
if (command !== "set-cell") return;
|
|
5059
|
+
const rowIndex = args.rowIndex;
|
|
5060
|
+
const columnIndex = args.columnIndex;
|
|
5061
|
+
if (!Number.isInteger(rowIndex) || !Number.isInteger(columnIndex)) return;
|
|
5062
|
+
if (rowIndex < 0 || rowIndex >= element.rows || columnIndex < 0 || columnIndex >= element.columns)
|
|
5063
|
+
return;
|
|
5064
|
+
const cell = args.cell;
|
|
5065
|
+
if (!cell || typeof cell !== "object" || Array.isArray(cell)) return;
|
|
5066
|
+
const index = rowIndex * element.columns + columnIndex;
|
|
5067
|
+
const cells = Array.from(
|
|
5068
|
+
{ length: element.rows * element.columns },
|
|
5069
|
+
(_, at) => ({ ...element.cells?.[at] })
|
|
5070
|
+
);
|
|
5071
|
+
cells[index] = { ...cells[index], ...cell };
|
|
5072
|
+
const next = { ...element, cells };
|
|
5073
|
+
return validate(next) ? next : void 0;
|
|
5074
|
+
}
|
|
5075
|
+
var gridCommands = {
|
|
5076
|
+
execute(element, command, payload) {
|
|
5077
|
+
return executeGridCommand(
|
|
5078
|
+
element,
|
|
5079
|
+
command,
|
|
5080
|
+
payload,
|
|
5081
|
+
(value) => !!value && typeof value === "object" && value.type === "grid" && validateGridSettings(value)
|
|
5082
|
+
);
|
|
5083
|
+
}
|
|
5084
|
+
};
|
|
5085
|
+
|
|
4895
5086
|
// src/plugins/grid/native.ts
|
|
4896
5087
|
var gridNativePlugin = defineNativePlugin(
|
|
4897
5088
|
"grid",
|
|
4898
|
-
"0.1.
|
|
5089
|
+
"0.1.16",
|
|
4899
5090
|
printDesign.definePrintDesignPluginRenderer({
|
|
4900
5091
|
type: "grid",
|
|
4901
5092
|
validate: validateGridElement,
|
|
5093
|
+
commands: gridCommands,
|
|
4902
5094
|
validateTemplateData: validateGridTemplateData,
|
|
4903
5095
|
bindingInfo: getGridBindingInfo,
|
|
4904
5096
|
drawCanvas: drawGridElement,
|
|
@@ -5209,10 +5401,18 @@ function coordinateDebugRegions(element, context) {
|
|
|
5209
5401
|
// src/plugins/coordinate/native.ts
|
|
5210
5402
|
var coordinateNativePlugin = defineNativePlugin(
|
|
5211
5403
|
"coordinate",
|
|
5212
|
-
"0.1.
|
|
5404
|
+
"0.1.16",
|
|
5213
5405
|
printDesign.definePrintDesignPluginRenderer({
|
|
5214
5406
|
type: "coordinate",
|
|
5215
5407
|
validate: validateCoordinateElement,
|
|
5408
|
+
commands: {
|
|
5409
|
+
execute: (element, command, payload) => executeGridCommand(
|
|
5410
|
+
element,
|
|
5411
|
+
command,
|
|
5412
|
+
payload,
|
|
5413
|
+
validateCoordinateElement
|
|
5414
|
+
)
|
|
5415
|
+
},
|
|
5216
5416
|
validateTemplateData: validateGridTemplateData,
|
|
5217
5417
|
bindingInfo: getGridBindingInfo,
|
|
5218
5418
|
drawCanvas: drawCoordinateElement,
|
|
@@ -5709,17 +5909,48 @@ function validateFlowTemplateData(element, data) {
|
|
|
5709
5909
|
return [];
|
|
5710
5910
|
}
|
|
5711
5911
|
|
|
5912
|
+
// src/plugins/flow/interaction/commands.ts
|
|
5913
|
+
var flowCommands = {
|
|
5914
|
+
execute(element, command, payload) {
|
|
5915
|
+
if (element.locked || element.dataMode === "binding" || !payload || typeof payload !== "object")
|
|
5916
|
+
return;
|
|
5917
|
+
const args = payload;
|
|
5918
|
+
const index = args.index;
|
|
5919
|
+
if (!Number.isInteger(index)) return;
|
|
5920
|
+
const at = index;
|
|
5921
|
+
if (command === "remove-item") {
|
|
5922
|
+
if (at < 0 || at >= element.items.length) return;
|
|
5923
|
+
return { ...element, items: element.items.filter((_, i) => i !== at) };
|
|
5924
|
+
}
|
|
5925
|
+
const item = args.item;
|
|
5926
|
+
if (!item || typeof item !== "object" || Array.isArray(item)) return;
|
|
5927
|
+
const items = [...element.items];
|
|
5928
|
+
if (command === "insert-item") {
|
|
5929
|
+
if (at < 0 || at > items.length) return;
|
|
5930
|
+
items.splice(at, 0, item);
|
|
5931
|
+
} else if (command === "update-item") {
|
|
5932
|
+
if (at < 0 || at >= items.length) return;
|
|
5933
|
+
items[at] = { ...items[at], ...item };
|
|
5934
|
+
} else return;
|
|
5935
|
+
const next = { ...element, items };
|
|
5936
|
+
return validateFlowElement(next) ? next : void 0;
|
|
5937
|
+
}
|
|
5938
|
+
};
|
|
5939
|
+
|
|
5712
5940
|
// src/plugins/flow/native.ts
|
|
5713
5941
|
var flowNativePlugin = defineNativePlugin(
|
|
5714
5942
|
"flow",
|
|
5715
|
-
"0.1.
|
|
5943
|
+
"0.1.7",
|
|
5716
5944
|
printDesign.definePrintDesignPluginRenderer({
|
|
5717
5945
|
type: "flow",
|
|
5718
5946
|
validate: validateFlowElement,
|
|
5947
|
+
commands: flowCommands,
|
|
5719
5948
|
validateTemplateData: validateFlowTemplateData,
|
|
5720
5949
|
bindingInfo: (element) => ({
|
|
5721
5950
|
bound: (element.dataMode ?? element.dataConfig?.mode) === "binding",
|
|
5722
|
-
paths: (element.dataMode ?? element.dataConfig?.mode) === "binding" ? [
|
|
5951
|
+
paths: (element.dataMode ?? element.dataConfig?.mode) === "binding" ? [
|
|
5952
|
+
element.dataPath ?? element.dataConfig?.bindings?.items ?? ""
|
|
5953
|
+
].filter(Boolean) : []
|
|
5723
5954
|
}),
|
|
5724
5955
|
drawCanvas: drawFlowElement,
|
|
5725
5956
|
renderHtml: (element, context) => renderFlowHtml(element, context.data)
|
|
@@ -6435,6 +6666,19 @@ function fitImageToPage(image, page, current) {
|
|
|
6435
6666
|
return { x, y, width, height };
|
|
6436
6667
|
}
|
|
6437
6668
|
|
|
6669
|
+
// src/plugins/image/interaction/commands.ts
|
|
6670
|
+
var imageCommands = {
|
|
6671
|
+
execute(element, command, payload) {
|
|
6672
|
+
if (element.locked) return;
|
|
6673
|
+
if (command === "clear-crop") return { ...element, crop: void 0 };
|
|
6674
|
+
if (command !== "set-crop" || !payload || typeof payload !== "object")
|
|
6675
|
+
return;
|
|
6676
|
+
const crop = payload;
|
|
6677
|
+
const next = { ...element, crop };
|
|
6678
|
+
return validateImageElement(next) ? next : void 0;
|
|
6679
|
+
}
|
|
6680
|
+
};
|
|
6681
|
+
|
|
6438
6682
|
// src/plugins/image/native.ts
|
|
6439
6683
|
var componentCropBehavior = {
|
|
6440
6684
|
source: (element) => element.src,
|
|
@@ -6455,7 +6699,7 @@ var componentCropBehavior = {
|
|
|
6455
6699
|
};
|
|
6456
6700
|
var imageNativePlugin = defineNativePlugin(
|
|
6457
6701
|
"image",
|
|
6458
|
-
"0.1.
|
|
6702
|
+
"0.1.17",
|
|
6459
6703
|
printDesign.definePrintDesignPluginRenderer({
|
|
6460
6704
|
type: "image",
|
|
6461
6705
|
dataFields: imageDataFields,
|
|
@@ -6464,6 +6708,7 @@ var imageNativePlugin = defineNativePlugin(
|
|
|
6464
6708
|
replaceResourceUri: (element, uri, replacement) => element.src === uri ? { ...element, src: replacement } : element,
|
|
6465
6709
|
validateTemplateData: validateImageTemplateData,
|
|
6466
6710
|
validate: validateImageElement,
|
|
6711
|
+
commands: imageCommands,
|
|
6467
6712
|
drawCanvas: drawImageElement,
|
|
6468
6713
|
prepareCanvas: (element, { signal }) => prepareImage(element.src, signal),
|
|
6469
6714
|
needsCanvasPreparation: (element) => Boolean(element.src && !getLoadedImageSize(element.src)),
|
|
@@ -6733,6 +6978,45 @@ function validateChartTemplateData(element, data) {
|
|
|
6733
6978
|
var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
6734
6979
|
var seriesList = (value) => (Array.isArray(value) ? value : value ? [value] : []).map(record);
|
|
6735
6980
|
var numeric = (value) => typeof value === "number" && Number.isFinite(value) ? value : typeof value === "string" && value.trim() && Number.isFinite(Number(value)) ? Number(value) : 0;
|
|
6981
|
+
function readChartData(element) {
|
|
6982
|
+
if (element.chartData) return element.chartData;
|
|
6983
|
+
const option = record(element.option);
|
|
6984
|
+
const series = seriesList(option.series);
|
|
6985
|
+
const first = series[0] ?? {};
|
|
6986
|
+
if (element.chartType === "pie" || element.chartType === "gauge") {
|
|
6987
|
+
const items = Array.isArray(first.data) ? first.data : [];
|
|
6988
|
+
return {
|
|
6989
|
+
mode: "static",
|
|
6990
|
+
categories: items.map((d) => String(record(d).name ?? "")),
|
|
6991
|
+
series: [
|
|
6992
|
+
{
|
|
6993
|
+
name: first.name ?? "\u7CFB\u5217 1",
|
|
6994
|
+
values: items.map((d) => numeric(record(d).value))
|
|
6995
|
+
}
|
|
6996
|
+
]
|
|
6997
|
+
};
|
|
6998
|
+
}
|
|
6999
|
+
if (element.chartType === "radar") {
|
|
7000
|
+
const indicators = record(option.radar).indicator ?? [];
|
|
7001
|
+
return {
|
|
7002
|
+
mode: "static",
|
|
7003
|
+
categories: indicators.map((d) => String(record(d).name ?? "")),
|
|
7004
|
+
max: indicators[0]?.max ?? 100,
|
|
7005
|
+
series: (first.data ?? []).map((d, i) => ({
|
|
7006
|
+
name: record(d).name ?? `\u7CFB\u5217 ${i + 1}`,
|
|
7007
|
+
values: (record(d).value ?? []).map(numeric)
|
|
7008
|
+
}))
|
|
7009
|
+
};
|
|
7010
|
+
}
|
|
7011
|
+
return {
|
|
7012
|
+
mode: "static",
|
|
7013
|
+
categories: (record(option.xAxis).data ?? []).map(String),
|
|
7014
|
+
series: series.map((s, i) => ({
|
|
7015
|
+
name: s.name ?? `\u7CFB\u5217 ${i + 1}`,
|
|
7016
|
+
values: (s.data ?? []).map(numeric)
|
|
7017
|
+
}))
|
|
7018
|
+
};
|
|
7019
|
+
}
|
|
6736
7020
|
function resolveChartOption(element, data = {}) {
|
|
6737
7021
|
const option = record(element.option);
|
|
6738
7022
|
const singleSeries = ["pie", "radar", "gauge"].includes(element.chartType);
|
|
@@ -6841,13 +7125,58 @@ function renderChartHtml(element, data) {
|
|
|
6841
7125
|
});
|
|
6842
7126
|
}
|
|
6843
7127
|
|
|
7128
|
+
// src/plugins/chart/interaction/commands.ts
|
|
7129
|
+
var chartCommands = {
|
|
7130
|
+
execute(element, command, payload) {
|
|
7131
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
7132
|
+
const args = payload;
|
|
7133
|
+
const chartData = readChartData(element);
|
|
7134
|
+
if (command === "set-categories") {
|
|
7135
|
+
if (!Array.isArray(args.categories) || !args.categories.every((item) => typeof item === "string"))
|
|
7136
|
+
return;
|
|
7137
|
+
const categories = args.categories;
|
|
7138
|
+
const next2 = {
|
|
7139
|
+
...element,
|
|
7140
|
+
chartData: {
|
|
7141
|
+
...chartData,
|
|
7142
|
+
categories,
|
|
7143
|
+
series: chartData.series.map((series2) => ({
|
|
7144
|
+
...series2,
|
|
7145
|
+
values: categories.map((_, index2) => series2.values[index2] ?? 0)
|
|
7146
|
+
}))
|
|
7147
|
+
}
|
|
7148
|
+
};
|
|
7149
|
+
return validateChartElement(next2) ? next2 : void 0;
|
|
7150
|
+
}
|
|
7151
|
+
if (command !== "set-series") return;
|
|
7152
|
+
const index = args.index;
|
|
7153
|
+
if (!Number.isInteger(index) || index < 0 || index > chartData.series.length)
|
|
7154
|
+
return;
|
|
7155
|
+
if (typeof args.name !== "string" || !Array.isArray(args.values) || args.values.length !== chartData.categories.length || !args.values.every(
|
|
7156
|
+
(value) => typeof value === "number" && Number.isFinite(value)
|
|
7157
|
+
))
|
|
7158
|
+
return;
|
|
7159
|
+
if (["pie", "gauge"].includes(element.chartType) && index > 0)
|
|
7160
|
+
return;
|
|
7161
|
+
const series = [...chartData.series];
|
|
7162
|
+
series[index] = {
|
|
7163
|
+
name: args.name,
|
|
7164
|
+
values: args.values,
|
|
7165
|
+
...typeof args.field === "string" ? { field: args.field } : {}
|
|
7166
|
+
};
|
|
7167
|
+
const next = { ...element, chartData: { ...chartData, series } };
|
|
7168
|
+
return validateChartElement(next) ? next : void 0;
|
|
7169
|
+
}
|
|
7170
|
+
};
|
|
7171
|
+
|
|
6844
7172
|
// src/plugins/chart/native.ts
|
|
6845
7173
|
var chartNativePlugin = defineNativePlugin(
|
|
6846
7174
|
"chart",
|
|
6847
|
-
"0.1.
|
|
7175
|
+
"0.1.9",
|
|
6848
7176
|
printDesign.definePrintDesignPluginRenderer({
|
|
6849
7177
|
type: "chart",
|
|
6850
7178
|
validate: validateChartElement,
|
|
7179
|
+
commands: chartCommands,
|
|
6851
7180
|
validateTemplateData: validateChartTemplateData,
|
|
6852
7181
|
bindingInfo: (element) => ({
|
|
6853
7182
|
bound: element.chartData?.mode === "binding",
|
|
@@ -10673,7 +11002,7 @@ function validateTableTemplateData(element, data) {
|
|
|
10673
11002
|
// src/plugins/table/native.ts
|
|
10674
11003
|
var tableNativePlugin = defineNativePlugin(
|
|
10675
11004
|
"table",
|
|
10676
|
-
"0.1.
|
|
11005
|
+
"0.1.69",
|
|
10677
11006
|
printDesign.definePrintDesignPluginRenderer({
|
|
10678
11007
|
type: "table",
|
|
10679
11008
|
validate: validateTableElement,
|
|
@@ -10717,6 +11046,37 @@ var tableNativePlugin = defineNativePlugin(
|
|
|
10717
11046
|
);
|
|
10718
11047
|
|
|
10719
11048
|
// src/plugins/pivot-table/layout/field-layout.ts
|
|
11049
|
+
function movePivotField(layout, fieldKey, area, index, sourceArea) {
|
|
11050
|
+
const next = {
|
|
11051
|
+
filters: [...layout.filters],
|
|
11052
|
+
columns: [...layout.columns],
|
|
11053
|
+
rows: [...layout.rows],
|
|
11054
|
+
values: [...layout.values]
|
|
11055
|
+
};
|
|
11056
|
+
const areaKey = (value) => value === "filter" ? "filters" : value === "column" ? "columns" : value === "row" ? "rows" : "values";
|
|
11057
|
+
const targets = area === "value" ? ["values"] : ["filters", "columns", "rows"];
|
|
11058
|
+
for (const target2 of targets)
|
|
11059
|
+
next[target2] = next[target2].filter((key) => key !== fieldKey);
|
|
11060
|
+
if (sourceArea && sourceArea !== area) {
|
|
11061
|
+
const source = areaKey(sourceArea);
|
|
11062
|
+
next[source] = next[source].filter((key) => key !== fieldKey);
|
|
11063
|
+
}
|
|
11064
|
+
const target = next[areaKey(area)];
|
|
11065
|
+
target.splice(
|
|
11066
|
+
Math.max(0, Math.min(index ?? target.length, target.length)),
|
|
11067
|
+
0,
|
|
11068
|
+
fieldKey
|
|
11069
|
+
);
|
|
11070
|
+
return next;
|
|
11071
|
+
}
|
|
11072
|
+
function removePivotField(layout, fieldKey) {
|
|
11073
|
+
return {
|
|
11074
|
+
filters: layout.filters.filter((key) => key !== fieldKey),
|
|
11075
|
+
columns: layout.columns.filter((key) => key !== fieldKey),
|
|
11076
|
+
rows: layout.rows.filter((key) => key !== fieldKey),
|
|
11077
|
+
values: layout.values.filter((key) => key !== fieldKey)
|
|
11078
|
+
};
|
|
11079
|
+
}
|
|
10720
11080
|
function pivotFieldTitle(field) {
|
|
10721
11081
|
return field.title ?? field.key;
|
|
10722
11082
|
}
|
|
@@ -10968,6 +11328,41 @@ var pivotTableBoundaryResize = {
|
|
|
10968
11328
|
}
|
|
10969
11329
|
};
|
|
10970
11330
|
|
|
11331
|
+
// src/plugins/pivot-table/interaction/commands.ts
|
|
11332
|
+
var areas = ["filter", "column", "row", "value"];
|
|
11333
|
+
var pivotTableCommands = {
|
|
11334
|
+
execute(element, command, payload) {
|
|
11335
|
+
if (element.locked || !payload || typeof payload !== "object") return;
|
|
11336
|
+
const args = payload;
|
|
11337
|
+
const fieldKey = args.fieldKey;
|
|
11338
|
+
if (typeof fieldKey !== "string" || !element.fields.some((field) => field.key === fieldKey))
|
|
11339
|
+
return;
|
|
11340
|
+
if (command === "remove-field")
|
|
11341
|
+
return {
|
|
11342
|
+
...element,
|
|
11343
|
+
layout: removePivotField(element.layout, fieldKey)
|
|
11344
|
+
};
|
|
11345
|
+
if (command !== "move-field" || !areas.includes(args.area))
|
|
11346
|
+
return;
|
|
11347
|
+
const index = args.index;
|
|
11348
|
+
if (index !== void 0 && (!Number.isInteger(index) || index < 0))
|
|
11349
|
+
return;
|
|
11350
|
+
const sourceArea = args.sourceArea;
|
|
11351
|
+
if (sourceArea !== void 0 && !areas.includes(sourceArea))
|
|
11352
|
+
return;
|
|
11353
|
+
return {
|
|
11354
|
+
...element,
|
|
11355
|
+
layout: movePivotField(
|
|
11356
|
+
element.layout,
|
|
11357
|
+
fieldKey,
|
|
11358
|
+
args.area,
|
|
11359
|
+
index,
|
|
11360
|
+
sourceArea
|
|
11361
|
+
)
|
|
11362
|
+
};
|
|
11363
|
+
}
|
|
11364
|
+
};
|
|
11365
|
+
|
|
10971
11366
|
// src/plugins/pivot-table/model.ts
|
|
10972
11367
|
function validatePivotTableElement(value) {
|
|
10973
11368
|
if (!value || typeof value !== "object") return false;
|
|
@@ -10981,11 +11376,12 @@ function validatePivotTableElement(value) {
|
|
|
10981
11376
|
// src/plugins/pivot-table/native.ts
|
|
10982
11377
|
var pivotTableNativePlugin = defineNativePlugin(
|
|
10983
11378
|
"pivotTable",
|
|
10984
|
-
"0.1.
|
|
11379
|
+
"0.1.19",
|
|
10985
11380
|
printDesign.definePrintDesignPluginRenderer({
|
|
10986
11381
|
type: "pivotTable",
|
|
10987
11382
|
htmlCss: tableHtmlCss,
|
|
10988
11383
|
validate: validatePivotTableElement,
|
|
11384
|
+
commands: pivotTableCommands,
|
|
10989
11385
|
validateTemplateData: validatePivotTemplateData,
|
|
10990
11386
|
bindingInfo: (element) => ({
|
|
10991
11387
|
bound: element.dataMode === "binding",
|
|
@@ -11496,13 +11892,49 @@ function ganttMarkup(element, data, pageNumber) {
|
|
|
11496
11892
|
return `<svg class="pd-media" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${width} ${height}" preserveAspectRatio="none"><rect width="${width}" height="${height}" fill="${printDesign.cssColor(theme.backgroundColor, "transparent")}"/>${header > 0 ? `<rect width="${width}" height="${header}" fill="${printDesign.cssColor(theme.headerBackgroundColor, "transparent")}"/>` : ""}${ticks}${taskSplit}${headerEdges}${headerTitle}${maskedDependencies}${bars}${frame}</svg>`;
|
|
11497
11893
|
}
|
|
11498
11894
|
|
|
11895
|
+
// src/plugins/gantt/interaction/commands.ts
|
|
11896
|
+
var ganttCommands = {
|
|
11897
|
+
execute(element, command, payload) {
|
|
11898
|
+
if (element.locked || element.dataMode === "binding" || !payload || typeof payload !== "object")
|
|
11899
|
+
return;
|
|
11900
|
+
const args = payload;
|
|
11901
|
+
const tasks = [...element.tasks];
|
|
11902
|
+
if (command === "insert-task") {
|
|
11903
|
+
const index = args.index;
|
|
11904
|
+
if (!Number.isInteger(index) || index < 0 || index > tasks.length)
|
|
11905
|
+
return;
|
|
11906
|
+
if (!args.task || typeof args.task !== "object" || Array.isArray(args.task))
|
|
11907
|
+
return;
|
|
11908
|
+
const task = args.task;
|
|
11909
|
+
if (tasks.some((existing) => existing.id === task.id)) return;
|
|
11910
|
+
tasks.splice(index, 0, task);
|
|
11911
|
+
} else {
|
|
11912
|
+
const taskId = args.taskId;
|
|
11913
|
+
if (typeof taskId !== "string") return;
|
|
11914
|
+
const index = tasks.findIndex((task) => task.id === taskId);
|
|
11915
|
+
if (index < 0) return;
|
|
11916
|
+
if (command === "remove-task") tasks.splice(index, 1);
|
|
11917
|
+
else if (command === "update-task") {
|
|
11918
|
+
if (!args.patch || typeof args.patch !== "object" || Array.isArray(args.patch))
|
|
11919
|
+
return;
|
|
11920
|
+
const patch = args.patch;
|
|
11921
|
+
if (patch.id !== void 0 || patch.tasks !== void 0) return;
|
|
11922
|
+
tasks[index] = { ...tasks[index], ...patch };
|
|
11923
|
+
} else return;
|
|
11924
|
+
}
|
|
11925
|
+
const next = { ...element, tasks };
|
|
11926
|
+
return validateGanttElement(next) ? next : void 0;
|
|
11927
|
+
}
|
|
11928
|
+
};
|
|
11929
|
+
|
|
11499
11930
|
// src/plugins/gantt/native.ts
|
|
11500
11931
|
var ganttNativePlugin = defineNativePlugin(
|
|
11501
11932
|
"gantt",
|
|
11502
|
-
"0.1.
|
|
11933
|
+
"0.1.7",
|
|
11503
11934
|
printDesign.definePrintDesignPluginRenderer({
|
|
11504
11935
|
type: "gantt",
|
|
11505
11936
|
validate: validateGanttElement,
|
|
11937
|
+
commands: ganttCommands,
|
|
11506
11938
|
validateTemplateData: validateGanttTemplateData,
|
|
11507
11939
|
bindingInfo: (element) => ({
|
|
11508
11940
|
bound: element.dataMode === "binding",
|