@measured/puck-plugin-heading-analyzer 0.19.0-canary.896a6279 → 0.19.0-canary.a6dd529f

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/index.d.mts CHANGED
@@ -13,6 +13,7 @@ type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
13
13
  type BaseField = {
14
14
  label?: string;
15
15
  labelIcon?: ReactElement;
16
+ metadata?: Metadata;
16
17
  };
17
18
  type TextField = BaseField & {
18
19
  type: "text";
@@ -112,6 +113,8 @@ type CustomField<Props extends any = {}> = BaseField & {
112
113
  };
113
114
  type SlotField = BaseField & {
114
115
  type: "slot";
116
+ allow?: string[];
117
+ disallow?: string[];
115
118
  };
116
119
  type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
117
120
  [key: string]: any;
@@ -130,6 +133,10 @@ type FieldProps<F = Field<any>, ValueType = any> = {
130
133
  readOnly?: boolean;
131
134
  };
132
135
 
136
+ type Metadata = {
137
+ [key: string]: any;
138
+ };
139
+
133
140
  type ItemWithId = {
134
141
  _arrayId: string;
135
142
  _originalIndex: number;
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@ type FieldOptions = Array<FieldOption> | ReadonlyArray<FieldOption>;
13
13
  type BaseField = {
14
14
  label?: string;
15
15
  labelIcon?: ReactElement;
16
+ metadata?: Metadata;
16
17
  };
17
18
  type TextField = BaseField & {
18
19
  type: "text";
@@ -112,6 +113,8 @@ type CustomField<Props extends any = {}> = BaseField & {
112
113
  };
113
114
  type SlotField = BaseField & {
114
115
  type: "slot";
116
+ allow?: string[];
117
+ disallow?: string[];
115
118
  };
116
119
  type Field<Props extends any = any> = TextField | NumberField | TextareaField | SelectField | RadioField | ArrayField<Props extends {
117
120
  [key: string]: any;
@@ -130,6 +133,10 @@ type FieldProps<F = Field<any>, ValueType = any> = {
130
133
  readOnly?: boolean;
131
134
  };
132
135
 
136
+ type Metadata = {
137
+ [key: string]: any;
138
+ };
139
+
133
140
  type ItemWithId = {
134
141
  _arrayId: string;
135
142
  _originalIndex: number;
package/dist/index.js CHANGED
@@ -910,7 +910,6 @@ var reorderAction = (state, action, appStore) => {
910
910
  init_react_import();
911
911
  var removeAction = (state, action, appStore) => {
912
912
  const item = getItem({ index: action.index, zone: action.zone }, state);
913
- const [parentId] = action.zone.split(":");
914
913
  const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
915
914
  (acc, [nodeId, nodeData]) => {
916
915
  const pathIds = nodeData.path.map((p) => p.split(":")[0]);
@@ -929,24 +928,17 @@ var removeAction = (state, action, appStore) => {
929
928
  return remove(content, action.index);
930
929
  }
931
930
  return content;
932
- },
933
- (childItem, path) => {
934
- const parentIds = path.map((p) => p.split(":")[0]);
935
- if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
936
- return childItem;
937
- }
938
- return null;
939
931
  }
940
932
  );
941
933
  Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
942
- const parentId2 = zoneCompound.split(":")[0];
943
- if (nodesToDelete.includes(parentId2) && newState.data.zones) {
934
+ const parentId = zoneCompound.split(":")[0];
935
+ if (nodesToDelete.includes(parentId) && newState.data.zones) {
944
936
  delete newState.data.zones[zoneCompound];
945
937
  }
946
938
  });
947
939
  Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
948
- const parentId2 = zoneCompound.split(":")[0];
949
- if (nodesToDelete.includes(parentId2)) {
940
+ const parentId = zoneCompound.split(":")[0];
941
+ if (nodesToDelete.includes(parentId)) {
950
942
  delete newState.indexes.zones[zoneCompound];
951
943
  }
952
944
  });
@@ -1313,7 +1305,7 @@ var createHistorySlice = (set, get) => {
1313
1305
  const { dispatch, history } = get();
1314
1306
  dispatch({
1315
1307
  type: "set",
1316
- state: ((_a = history.histories[history.index]) == null ? void 0 : _a.state) || history.initialAppState
1308
+ state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
1317
1309
  });
1318
1310
  set({ history: __spreadProps(__spreadValues({}, history), { index }) });
1319
1311
  },
@@ -1512,7 +1504,7 @@ init_react_import();
1512
1504
 
1513
1505
  // ../core/lib/data/map-slots.ts
1514
1506
  init_react_import();
1515
- function mapSlots(_0, _1) {
1507
+ function mapSlotsAsync(_0, _1) {
1516
1508
  return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
1517
1509
  const props = __spreadValues({}, item.props);
1518
1510
  const propKeys = Object.keys(props);
@@ -1523,7 +1515,7 @@ function mapSlots(_0, _1) {
1523
1515
  const content = props[propKey];
1524
1516
  const mappedContent = recursive ? yield Promise.all(
1525
1517
  content.map((item2) => __async(this, null, function* () {
1526
- return yield mapSlots(item2, map, recursive, isSlot2);
1518
+ return yield mapSlotsAsync(item2, map, recursive, isSlot2);
1527
1519
  }))
1528
1520
  ) : content;
1529
1521
  props[propKey] = yield map(mappedContent, propKey);
@@ -1551,14 +1543,14 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
1551
1543
  const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1552
1544
  changed,
1553
1545
  lastData: oldItem,
1554
- metadata,
1546
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1555
1547
  trigger
1556
1548
  });
1557
1549
  let resolvedItem = __spreadProps(__spreadValues({}, item), {
1558
1550
  props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
1559
1551
  });
1560
1552
  if (recursive) {
1561
- resolvedItem = yield mapSlots(
1553
+ resolvedItem = yield mapSlotsAsync(
1562
1554
  resolvedItem,
1563
1555
  (content) => __async(void 0, null, function* () {
1564
1556
  return Promise.all(
package/dist/index.mjs CHANGED
@@ -898,7 +898,6 @@ var reorderAction = (state, action, appStore) => {
898
898
  init_react_import();
899
899
  var removeAction = (state, action, appStore) => {
900
900
  const item = getItem({ index: action.index, zone: action.zone }, state);
901
- const [parentId] = action.zone.split(":");
902
901
  const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
903
902
  (acc, [nodeId, nodeData]) => {
904
903
  const pathIds = nodeData.path.map((p) => p.split(":")[0]);
@@ -917,24 +916,17 @@ var removeAction = (state, action, appStore) => {
917
916
  return remove(content, action.index);
918
917
  }
919
918
  return content;
920
- },
921
- (childItem, path) => {
922
- const parentIds = path.map((p) => p.split(":")[0]);
923
- if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
924
- return childItem;
925
- }
926
- return null;
927
919
  }
928
920
  );
929
921
  Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
930
- const parentId2 = zoneCompound.split(":")[0];
931
- if (nodesToDelete.includes(parentId2) && newState.data.zones) {
922
+ const parentId = zoneCompound.split(":")[0];
923
+ if (nodesToDelete.includes(parentId) && newState.data.zones) {
932
924
  delete newState.data.zones[zoneCompound];
933
925
  }
934
926
  });
935
927
  Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
936
- const parentId2 = zoneCompound.split(":")[0];
937
- if (nodesToDelete.includes(parentId2)) {
928
+ const parentId = zoneCompound.split(":")[0];
929
+ if (nodesToDelete.includes(parentId)) {
938
930
  delete newState.indexes.zones[zoneCompound];
939
931
  }
940
932
  });
@@ -1301,7 +1293,7 @@ var createHistorySlice = (set, get) => {
1301
1293
  const { dispatch, history } = get();
1302
1294
  dispatch({
1303
1295
  type: "set",
1304
- state: ((_a = history.histories[history.index]) == null ? void 0 : _a.state) || history.initialAppState
1296
+ state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
1305
1297
  });
1306
1298
  set({ history: __spreadProps(__spreadValues({}, history), { index }) });
1307
1299
  },
@@ -1500,7 +1492,7 @@ init_react_import();
1500
1492
 
1501
1493
  // ../core/lib/data/map-slots.ts
1502
1494
  init_react_import();
1503
- function mapSlots(_0, _1) {
1495
+ function mapSlotsAsync(_0, _1) {
1504
1496
  return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
1505
1497
  const props = __spreadValues({}, item.props);
1506
1498
  const propKeys = Object.keys(props);
@@ -1511,7 +1503,7 @@ function mapSlots(_0, _1) {
1511
1503
  const content = props[propKey];
1512
1504
  const mappedContent = recursive ? yield Promise.all(
1513
1505
  content.map((item2) => __async(this, null, function* () {
1514
- return yield mapSlots(item2, map, recursive, isSlot2);
1506
+ return yield mapSlotsAsync(item2, map, recursive, isSlot2);
1515
1507
  }))
1516
1508
  ) : content;
1517
1509
  props[propKey] = yield map(mappedContent, propKey);
@@ -1539,14 +1531,14 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
1539
1531
  const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1540
1532
  changed,
1541
1533
  lastData: oldItem,
1542
- metadata,
1534
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1543
1535
  trigger
1544
1536
  });
1545
1537
  let resolvedItem = __spreadProps(__spreadValues({}, item), {
1546
1538
  props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
1547
1539
  });
1548
1540
  if (recursive) {
1549
- resolvedItem = yield mapSlots(
1541
+ resolvedItem = yield mapSlotsAsync(
1550
1542
  resolvedItem,
1551
1543
  (content) => __async(void 0, null, function* () {
1552
1544
  return Promise.all(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck-plugin-heading-analyzer",
3
- "version": "0.19.0-canary.896a6279",
3
+ "version": "0.19.0-canary.a6dd529f",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",
@@ -25,7 +25,7 @@
25
25
  "dist"
26
26
  ],
27
27
  "devDependencies": {
28
- "@measured/puck": "^0.19.0-canary.896a6279",
28
+ "@measured/puck": "^0.19.0-canary.a6dd529f",
29
29
  "@types/react": "^19.0.1",
30
30
  "@types/react-dom": "^19.0.2",
31
31
  "eslint": "^7.32.0",