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