@measured/puck 0.12.0-canary.f882878 → 0.12.1-canary.15284aa

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/dist/index.js +22 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -32470,8 +32470,7 @@ var ArrayField = ({
32470
32470
  items: Array.from(value || []).map((item, idx) => {
32471
32471
  return {
32472
32472
  _originalIndex: idx,
32473
- _arrayId: `${id}-${idx}`,
32474
- data: item
32473
+ _arrayId: `${id}-${idx}`
32475
32474
  };
32476
32475
  }),
32477
32476
  openId: ""
@@ -32502,11 +32501,14 @@ var ArrayField = ({
32502
32501
  const newItems = Array.from(value2 || []).map((item, idx) => {
32503
32502
  var _a;
32504
32503
  const arrayStateItem = arrayState.items[idx];
32505
- return {
32506
- _originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex : ++highestIndex,
32507
- _arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex}`,
32508
- data: item
32504
+ const newItem = {
32505
+ _originalIndex: typeof (arrayStateItem == null ? void 0 : arrayStateItem._originalIndex) !== "undefined" ? arrayStateItem._originalIndex : highestIndex + 1,
32506
+ _arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || `${id}-${highestIndex + 1}`
32509
32507
  };
32508
+ if (newItem._originalIndex > highestIndex) {
32509
+ highestIndex = newItem._originalIndex;
32510
+ }
32511
+ return newItem;
32510
32512
  });
32511
32513
  return __spreadProps(__spreadValues({}, arrayState), { items: newItems });
32512
32514
  },
@@ -32515,6 +32517,7 @@ var ArrayField = ({
32515
32517
  (0, import_react27.useEffect)(() => {
32516
32518
  setUi(mapArrayStateToUi(arrayState));
32517
32519
  }, []);
32520
+ const [hovering, setHovering] = (0, import_react27.useState)(false);
32518
32521
  if (field.type !== "array" || !field.arrayFields) {
32519
32522
  return null;
32520
32523
  }
@@ -32561,6 +32564,14 @@ var ArrayField = ({
32561
32564
  isDraggingFrom: !!snapshot.draggingFromThisWith,
32562
32565
  hasItems: Array.isArray(value) && value.length > 0
32563
32566
  }),
32567
+ onMouseOver: (e) => {
32568
+ e.stopPropagation();
32569
+ setHovering(true);
32570
+ },
32571
+ onMouseOut: (e) => {
32572
+ e.stopPropagation();
32573
+ setHovering(false);
32574
+ },
32564
32575
  children: [
32565
32576
  localState.arrayState.items.map((item, i) => {
32566
32577
  const { _arrayId = `${id}-${i}`, _originalIndex = i } = item;
@@ -32575,7 +32586,7 @@ var ArrayField = ({
32575
32586
  isDragging: snapshot2 == null ? void 0 : snapshot2.isDragging,
32576
32587
  readOnly
32577
32588
  }),
32578
- isDragDisabled: readOnly,
32589
+ isDragDisabled: readOnly || !hovering,
32579
32590
  children: () => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
32580
32591
  /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
32581
32592
  "div",
@@ -32638,16 +32649,17 @@ var ArrayField = ({
32638
32649
  {
32639
32650
  name: subFieldName,
32640
32651
  label: subField.label || fieldName,
32641
- id: `${id}_${fieldName}`,
32652
+ id: `${_arrayId}_${fieldName}`,
32642
32653
  readOnly: typeof readOnlyFields[subFieldName] !== "undefined" ? readOnlyFields[subFieldName] : readOnlyFields[wildcardFieldName],
32643
32654
  readOnlyFields,
32644
32655
  field: subField,
32645
32656
  value: data[fieldName],
32646
- onChange: (val) => {
32657
+ onChange: (val, ui) => {
32647
32658
  onChange(
32648
32659
  replace(value, i, __spreadProps(__spreadValues({}, data), {
32649
32660
  [fieldName]: val
32650
- }))
32661
+ })),
32662
+ ui
32651
32663
  );
32652
32664
  }
32653
32665
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.12.0-canary.f882878",
3
+ "version": "0.12.1-canary.15284aa",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",