@cniot/mdd-editor 0.3.6 → 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/build/index.es.js CHANGED
@@ -26382,6 +26382,7 @@ function MddTableForm(props, ref) {
26382
26382
  const [_2, _update] = useState(0);
26383
26383
  const [sortUpdateFlag, setSortUpdateFlag] = useState({});
26384
26384
  const dataRef = useRef(data);
26385
+ const panelKeysRef = useRef([]);
26385
26386
  const CompSchemaMap = useMemo(
26386
26387
  () => penetrateType === PenetrateTypes.FORM ? { ...CompSchema, ...formItems } : CompSchema,
26387
26388
  []
@@ -26389,12 +26390,24 @@ function MddTableForm(props, ref) {
26389
26390
  const forceUpdate = () => {
26390
26391
  _update(Math.random());
26391
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
+ };
26392
26403
  const updateData = (newData) => {
26393
- dataRef.current = newData;
26404
+ dataRef.current = Array.isArray(newData) ? newData : [];
26405
+ syncPanelKeys(dataRef.current);
26394
26406
  forceUpdate();
26395
26407
  };
26396
26408
  useEffect(() => {
26397
26409
  dataRef.current = Array.isArray(data) ? data : [];
26410
+ syncPanelKeys(dataRef.current);
26398
26411
  forceUpdate();
26399
26412
  }, [data]);
26400
26413
  useImperativeHandle(
@@ -26407,6 +26420,7 @@ function MddTableForm(props, ref) {
26407
26420
  []
26408
26421
  );
26409
26422
  const onRemoveHandle = (idx) => {
26423
+ panelKeysRef.current.splice(idx, 1);
26410
26424
  onRemove(idx);
26411
26425
  forceUpdate();
26412
26426
  };
@@ -26419,6 +26433,8 @@ function MddTableForm(props, ref) {
26419
26433
  const min = Math.min(dragIndex, hoverIndex);
26420
26434
  const max = Math.max(dragIndex, hoverIndex);
26421
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);
26422
26438
  onSort(dataRef.current);
26423
26439
  forceUpdate();
26424
26440
  for (let i = min; i <= max; i++) {
@@ -26449,9 +26465,8 @@ function MddTableForm(props, ref) {
26449
26465
  }, /* @__PURE__ */ React$1.createElement(MddDndProvider, null, /* @__PURE__ */ React$1.createElement(Collapse, {
26450
26466
  accordion: true
26451
26467
  }, dataRef.current.map((item, idx) => {
26452
- const compKey = item.name || item.dataIndex || `${title2}_${idx}`;
26453
26468
  return /* @__PURE__ */ React$1.createElement(Panel$3, {
26454
- key: `${compKey}_${item.type || "unknown"}_${idx}`,
26469
+ key: getPanelKey(idx),
26455
26470
  title: /* @__PURE__ */ React$1.createElement(TitleRender$2, {
26456
26471
  index: idx,
26457
26472
  draggable,
@@ -31459,7 +31474,7 @@ function getDefaultIndexStyle() {
31459
31474
  `;
31460
31475
  }
31461
31476
  const name = "@cniot/mdd-editor";
31462
- const version = "0.3.6";
31477
+ const version = "0.3.7";
31463
31478
  const description = "\u6A21\u578B\u9A71\u52A8\u7F16\u8F91\u5668";
31464
31479
  const scripts = {
31465
31480
  build: "vite build"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cniot/mdd-editor",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "模型驱动编辑器",
5
5
  "scripts": {
6
6
  "build": "vite build"