@cniot/mdd-editor 0.3.5 → 0.3.7
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 +12 -0
- package/build/index.cjs.js +21 -21
- package/build/index.es.js +41 -15
- package/package.json +2 -1
package/build/index.es.js
CHANGED
|
@@ -7213,6 +7213,22 @@ class HTML5BackendImpl {
|
|
|
7213
7213
|
const HTML5Backend = function createBackend(manager, context, options) {
|
|
7214
7214
|
return new HTML5BackendImpl(manager, context, options);
|
|
7215
7215
|
};
|
|
7216
|
+
let sharedDragDropManager;
|
|
7217
|
+
function getSharedDragDropManager() {
|
|
7218
|
+
if (!sharedDragDropManager) {
|
|
7219
|
+
sharedDragDropManager = createDragDropManager(HTML5Backend);
|
|
7220
|
+
}
|
|
7221
|
+
return sharedDragDropManager;
|
|
7222
|
+
}
|
|
7223
|
+
function MddDndProvider({ children }) {
|
|
7224
|
+
const { dragDropManager } = React$1.useContext(DndContext);
|
|
7225
|
+
if (dragDropManager) {
|
|
7226
|
+
return children;
|
|
7227
|
+
}
|
|
7228
|
+
return /* @__PURE__ */ React$1.createElement(DndProvider, {
|
|
7229
|
+
manager: getSharedDragDropManager()
|
|
7230
|
+
}, children);
|
|
7231
|
+
}
|
|
7216
7232
|
const FormLayoutDeepContext$1 = createContext(null);
|
|
7217
7233
|
const FormLayoutShallowContext$1 = createContext(null);
|
|
7218
7234
|
const useFormShallowLayout$1 = () => useContext(FormLayoutShallowContext$1);
|
|
@@ -26366,6 +26382,7 @@ function MddTableForm(props, ref) {
|
|
|
26366
26382
|
const [_2, _update] = useState(0);
|
|
26367
26383
|
const [sortUpdateFlag, setSortUpdateFlag] = useState({});
|
|
26368
26384
|
const dataRef = useRef(data);
|
|
26385
|
+
const panelKeysRef = useRef([]);
|
|
26369
26386
|
const CompSchemaMap = useMemo(
|
|
26370
26387
|
() => penetrateType === PenetrateTypes.FORM ? { ...CompSchema, ...formItems } : CompSchema,
|
|
26371
26388
|
[]
|
|
@@ -26373,12 +26390,24 @@ function MddTableForm(props, ref) {
|
|
|
26373
26390
|
const forceUpdate = () => {
|
|
26374
26391
|
_update(Math.random());
|
|
26375
26392
|
};
|
|
26393
|
+
const syncPanelKeys = (list) => {
|
|
26394
|
+
const currentKeys = panelKeysRef.current;
|
|
26395
|
+
panelKeysRef.current = list.map((_22, index2) => currentKeys[index2] || uuidv4());
|
|
26396
|
+
};
|
|
26397
|
+
const getPanelKey = (index2) => {
|
|
26398
|
+
if (!panelKeysRef.current[index2]) {
|
|
26399
|
+
panelKeysRef.current[index2] = uuidv4();
|
|
26400
|
+
}
|
|
26401
|
+
return panelKeysRef.current[index2];
|
|
26402
|
+
};
|
|
26376
26403
|
const updateData = (newData) => {
|
|
26377
|
-
dataRef.current = newData;
|
|
26404
|
+
dataRef.current = Array.isArray(newData) ? newData : [];
|
|
26405
|
+
syncPanelKeys(dataRef.current);
|
|
26378
26406
|
forceUpdate();
|
|
26379
26407
|
};
|
|
26380
26408
|
useEffect(() => {
|
|
26381
26409
|
dataRef.current = Array.isArray(data) ? data : [];
|
|
26410
|
+
syncPanelKeys(dataRef.current);
|
|
26382
26411
|
forceUpdate();
|
|
26383
26412
|
}, [data]);
|
|
26384
26413
|
useImperativeHandle(
|
|
@@ -26391,6 +26420,7 @@ function MddTableForm(props, ref) {
|
|
|
26391
26420
|
[]
|
|
26392
26421
|
);
|
|
26393
26422
|
const onRemoveHandle = (idx) => {
|
|
26423
|
+
panelKeysRef.current.splice(idx, 1);
|
|
26394
26424
|
onRemove(idx);
|
|
26395
26425
|
forceUpdate();
|
|
26396
26426
|
};
|
|
@@ -26403,6 +26433,8 @@ function MddTableForm(props, ref) {
|
|
|
26403
26433
|
const min = Math.min(dragIndex, hoverIndex);
|
|
26404
26434
|
const max = Math.max(dragIndex, hoverIndex);
|
|
26405
26435
|
dataRef.current.splice(hoverIndex, 0, dataRef.current.splice(dragIndex, 1)[0]);
|
|
26436
|
+
const movedPanelKey = panelKeysRef.current.splice(dragIndex, 1)[0] || uuidv4();
|
|
26437
|
+
panelKeysRef.current.splice(hoverIndex, 0, movedPanelKey);
|
|
26406
26438
|
onSort(dataRef.current);
|
|
26407
26439
|
forceUpdate();
|
|
26408
26440
|
for (let i = min; i <= max; i++) {
|
|
@@ -26430,14 +26462,11 @@ function MddTableForm(props, ref) {
|
|
|
26430
26462
|
className: styles$b.tableFormAction
|
|
26431
26463
|
}, actionContent)), /* @__PURE__ */ React$1.createElement("div", {
|
|
26432
26464
|
className: styles$b.tableFormContent
|
|
26433
|
-
}, /* @__PURE__ */ React$1.createElement(
|
|
26434
|
-
backend: HTML5Backend
|
|
26435
|
-
}, /* @__PURE__ */ React$1.createElement(Collapse, {
|
|
26465
|
+
}, /* @__PURE__ */ React$1.createElement(MddDndProvider, null, /* @__PURE__ */ React$1.createElement(Collapse, {
|
|
26436
26466
|
accordion: true
|
|
26437
26467
|
}, dataRef.current.map((item, idx) => {
|
|
26438
|
-
const compKey = item.name || item.dataIndex || `${title2}_${idx}`;
|
|
26439
26468
|
return /* @__PURE__ */ React$1.createElement(Panel$3, {
|
|
26440
|
-
key:
|
|
26469
|
+
key: getPanelKey(idx),
|
|
26441
26470
|
title: /* @__PURE__ */ React$1.createElement(TitleRender$2, {
|
|
26442
26471
|
index: idx,
|
|
26443
26472
|
draggable,
|
|
@@ -27791,9 +27820,7 @@ function MddTableSimpleArray(props) {
|
|
|
27791
27820
|
align: "t"
|
|
27792
27821
|
}, tip)), /* @__PURE__ */ React$1.createElement("div", {
|
|
27793
27822
|
className: styles$9.tableArrayContent
|
|
27794
|
-
}, /* @__PURE__ */ React$1.createElement(
|
|
27795
|
-
backend: HTML5Backend
|
|
27796
|
-
}, /* @__PURE__ */ React$1.createElement(Collapse, {
|
|
27823
|
+
}, /* @__PURE__ */ React$1.createElement(MddDndProvider, null, /* @__PURE__ */ React$1.createElement(Collapse, {
|
|
27797
27824
|
accordion: true
|
|
27798
27825
|
}, (_a2 = data == null ? void 0 : data.map) == null ? void 0 : _a2.call(data, (item, idx) => {
|
|
27799
27826
|
return /* @__PURE__ */ React$1.createElement(Panel$2, {
|
|
@@ -28383,9 +28410,7 @@ function MddTableArray(props) {
|
|
|
28383
28410
|
className: styles$6.tableArrayTitle
|
|
28384
28411
|
}, title2), /* @__PURE__ */ React$1.createElement("div", {
|
|
28385
28412
|
className: styles$6.tableArrayContent
|
|
28386
|
-
}, /* @__PURE__ */ React$1.createElement(
|
|
28387
|
-
backend: HTML5Backend
|
|
28388
|
-
}, /* @__PURE__ */ React$1.createElement(Collapse, {
|
|
28413
|
+
}, /* @__PURE__ */ React$1.createElement(MddDndProvider, null, /* @__PURE__ */ React$1.createElement(Collapse, {
|
|
28389
28414
|
accordion: true
|
|
28390
28415
|
}, data.map((item, idx) => {
|
|
28391
28416
|
var _a2;
|
|
@@ -31185,11 +31210,11 @@ function MDDEditor(props) {
|
|
|
31185
31210
|
const Comp = CompAndSchema[0];
|
|
31186
31211
|
return /* @__PURE__ */ React$1.createElement("div", {
|
|
31187
31212
|
className: "mdd-editor-build-content"
|
|
31188
|
-
}, /* @__PURE__ */ React$1.createElement(Comp, {
|
|
31213
|
+
}, /* @__PURE__ */ React$1.createElement(MddDndProvider, null, /* @__PURE__ */ React$1.createElement(Comp, {
|
|
31189
31214
|
key: editorRefreshKey,
|
|
31190
31215
|
schema,
|
|
31191
31216
|
moduleMap
|
|
31192
|
-
}), /* @__PURE__ */ React$1.createElement(Toolbar, {
|
|
31217
|
+
})), /* @__PURE__ */ React$1.createElement(Toolbar, {
|
|
31193
31218
|
schema,
|
|
31194
31219
|
scriptInfo: schemaAndScriptRef.current.scriptInfo,
|
|
31195
31220
|
showScript,
|
|
@@ -31449,7 +31474,7 @@ function getDefaultIndexStyle() {
|
|
|
31449
31474
|
`;
|
|
31450
31475
|
}
|
|
31451
31476
|
const name = "@cniot/mdd-editor";
|
|
31452
|
-
const version = "0.3.
|
|
31477
|
+
const version = "0.3.7";
|
|
31453
31478
|
const description = "\u6A21\u578B\u9A71\u52A8\u7F16\u8F91\u5668";
|
|
31454
31479
|
const scripts = {
|
|
31455
31480
|
build: "vite build"
|
|
@@ -31465,6 +31490,7 @@ const dependencies = {
|
|
|
31465
31490
|
ahooks: "^3.2.0",
|
|
31466
31491
|
classnames: "^2.3.1",
|
|
31467
31492
|
"cn-address-select-pro": "^0.1.5",
|
|
31493
|
+
"dnd-core": "^16.0.1",
|
|
31468
31494
|
hox: "^1.1.6",
|
|
31469
31495
|
"immutability-helper": "^3.1.1",
|
|
31470
31496
|
"js-cookie": "^3.0.5",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cniot/mdd-editor",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "模型驱动编辑器",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build"
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"ahooks": "^3.2.0",
|
|
17
17
|
"classnames": "^2.3.1",
|
|
18
18
|
"cn-address-select-pro": "^0.1.5",
|
|
19
|
+
"dnd-core": "^16.0.1",
|
|
19
20
|
"hox": "^1.1.6",
|
|
20
21
|
"immutability-helper": "^3.1.1",
|
|
21
22
|
"js-cookie": "^3.0.5",
|