@steedos-widgets/sortable 1.3.4-beta.16 → 1.3.4-beta.17

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.
@@ -31619,7 +31619,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
31619
31619
  "type": "tpl",
31620
31620
  "tpl": "${label}",
31621
31621
  }] : _r, _s = props.boardFooter, boardFooter = _s === void 0 ? [] : _s, _t = props.wrapperClassName, wrapperClassName = _t === void 0 ? "gap-2" : _t, _u = props.boardClassName, boardClassName = _u === void 0 ? "border rounded" : _u, _v = props.cardClassName, cardClassName = _v === void 0 ? "" : _v;
31622
- // defaultValue && delete(defaultValue.$$id);
31622
+ value && delete (value.$$id);
31623
31623
  var _w = __read(React.useState(function () {
31624
31624
  var _a;
31625
31625
  return (_a = value) !== null && _a !== void 0 ? _a : {
@@ -31629,14 +31629,14 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
31629
31629
  };
31630
31630
  }), 2), items = _w[0], setItems = _w[1];
31631
31631
  var _x = __read(React.useState(Object.keys(items)), 2), containers = _x[0], setContainers = _x[1];
31632
- var handleChange = function () { return __awaiter(_this, void 0, void 0, function () {
31632
+ var handleChange = function (newItems) { return __awaiter(_this, void 0, void 0, function () {
31633
31633
  var value, rendererEvent;
31634
31634
  return __generator(this, function (_a) {
31635
31635
  switch (_a.label) {
31636
31636
  case 0:
31637
31637
  if (!amisDispatchEvent || !amisOnChange)
31638
31638
  return [2 /*return*/];
31639
- value = items;
31639
+ value = newItems || items;
31640
31640
  return [4 /*yield*/, amisDispatchEvent('change', createObject(amisData, {
31641
31641
  value: value
31642
31642
  }))];
@@ -31823,19 +31823,21 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
31823
31823
  return;
31824
31824
  }
31825
31825
  var overContainer = findContainer(overId);
31826
+ var newItems = items;
31826
31827
  if (overContainer) {
31827
31828
  var activeIndex_1 = items[activeContainer].indexOf(active.id);
31828
31829
  var overIndex_1 = items[overContainer].indexOf(overId);
31829
31830
  if (activeIndex_1 !== overIndex_1) {
31830
31831
  setItems(function (items) {
31831
31832
  var _a;
31832
- return (__assign$1(__assign$1({}, items), (_a = {}, _a[overContainer] = arrayMove(items[overContainer], activeIndex_1, overIndex_1), _a)));
31833
+ newItems = __assign$1(__assign$1({}, items), (_a = {}, _a[overContainer] = arrayMove(items[overContainer], activeIndex_1, overIndex_1), _a));
31834
+ return newItems;
31833
31835
  });
31834
31836
  }
31835
31837
  }
31836
31838
  setActiveId(null);
31837
31839
  // console.log('拖动结束2,更新form value')
31838
- handleChange();
31840
+ handleChange(newItems);
31839
31841
  }, cancelDrop: cancelDrop, onDragCancel: onDragCancel, modifiers: modifiers },
31840
31842
  React__default["default"].createElement("div", { style: {
31841
31843
  display: 'inline-grid',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos-widgets/sortable",
3
- "version": "1.3.4-beta.16",
3
+ "version": "1.3.4-beta.17",
4
4
  "main": "dist/sortable.cjs.js",
5
5
  "module": "dist/sortable.esm.js",
6
6
  "unpkg": "dist/sortable.umd.js",
@@ -45,7 +45,7 @@
45
45
  "dependencies": {
46
46
  "@dnd-kit/core": "^6.0.5",
47
47
  "@dnd-kit/sortable": "^7.0.1",
48
- "@steedos-widgets/amis-lib": "1.3.4-beta.16"
48
+ "@steedos-widgets/amis-lib": "1.3.4-beta.17"
49
49
  },
50
- "gitHead": "0e609d74ccbe4cf4fe69728349010d6fab90a439"
50
+ "gitHead": "184247f4260015e19c82a49fa4d6562839e73d2c"
51
51
  }
@@ -211,7 +211,7 @@ export function MultipleContainers(props) {
211
211
  cardClassName = "",
212
212
  }: Props = props
213
213
 
214
- // defaultValue && delete(defaultValue.$$id);
214
+ value && delete(value.$$id);
215
215
 
216
216
  const [items, setItems] = useState<Items>(
217
217
  () => {
@@ -227,10 +227,10 @@ export function MultipleContainers(props) {
227
227
  Object.keys(items) as UniqueIdentifier[]
228
228
  );
229
229
 
230
- const handleChange = async () => {
230
+ const handleChange = async (newItems? : any) => {
231
231
  if (!amisDispatchEvent || !amisOnChange)
232
232
  return
233
- const value = items;
233
+ const value = newItems || items;
234
234
 
235
235
  // 支持 amis OnEvent.change
236
236
  const rendererEvent = await amisDispatchEvent(
@@ -493,26 +493,31 @@ export function MultipleContainers(props) {
493
493
 
494
494
  const overContainer = findContainer(overId);
495
495
 
496
+ let newItems = items;
497
+
496
498
  if (overContainer) {
497
499
  const activeIndex = items[activeContainer].indexOf(active.id);
498
500
  const overIndex = items[overContainer].indexOf(overId);
499
501
 
500
502
  if (activeIndex !== overIndex) {
501
- setItems((items) => ({
502
- ...items,
503
- [overContainer]: arrayMove(
504
- items[overContainer],
505
- activeIndex,
506
- overIndex
507
- ),
508
- }));
503
+ setItems((items) => {
504
+ newItems = {
505
+ ...items,
506
+ [overContainer]: arrayMove(
507
+ items[overContainer],
508
+ activeIndex,
509
+ overIndex
510
+ ),
511
+ }
512
+ return newItems;
513
+ });
509
514
  }
510
515
  }
511
516
 
512
517
  setActiveId(null);
513
518
 
514
519
  // console.log('拖动结束2,更新form value')
515
- handleChange()
520
+ handleChange(newItems)
516
521
  }}
517
522
  cancelDrop={cancelDrop}
518
523
  onDragCancel={onDragCancel}