@measured/puck-plugin-heading-analyzer 0.16.0-canary.2c52d27 → 0.16.0-canary.3298831

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.
Files changed (2) hide show
  1. package/dist/index.js +66 -49
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -74977,34 +74977,37 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
74977
74977
  })
74978
74978
  });
74979
74979
  };
74980
- var reduceData = (data, action, config) => {
74981
- if (action.type === "insert") {
74982
- const emptyComponentData = {
74983
- type: action.componentType,
74984
- props: __spreadProps2(__spreadValues2({}, config.components[action.componentType].defaultProps || {}), {
74985
- id: generateId(action.componentType)
74986
- })
74987
- };
74988
- if (action.destinationZone === rootDroppableId2) {
74989
- return __spreadProps2(__spreadValues2({}, data), {
74990
- content: insert(
74991
- data.content,
74992
- action.destinationIndex,
74993
- emptyComponentData
74994
- )
74995
- });
74996
- }
74997
- const newData = setupZone2(data, action.destinationZone);
74980
+ var insertAction = (data, action, config) => {
74981
+ const emptyComponentData = {
74982
+ type: action.componentType,
74983
+ props: __spreadProps2(__spreadValues2({}, config.components[action.componentType].defaultProps || {}), {
74984
+ id: action.id || generateId(action.componentType)
74985
+ })
74986
+ };
74987
+ if (action.destinationZone === rootDroppableId2) {
74998
74988
  return __spreadProps2(__spreadValues2({}, data), {
74999
- zones: __spreadProps2(__spreadValues2({}, newData.zones), {
75000
- [action.destinationZone]: insert(
75001
- newData.zones[action.destinationZone],
75002
- action.destinationIndex,
75003
- emptyComponentData
75004
- )
75005
- })
74989
+ content: insert(
74990
+ data.content,
74991
+ action.destinationIndex,
74992
+ emptyComponentData
74993
+ )
75006
74994
  });
75007
74995
  }
74996
+ const newData = setupZone2(data, action.destinationZone);
74997
+ return __spreadProps2(__spreadValues2({}, data), {
74998
+ zones: __spreadProps2(__spreadValues2({}, newData.zones), {
74999
+ [action.destinationZone]: insert(
75000
+ newData.zones[action.destinationZone],
75001
+ action.destinationIndex,
75002
+ emptyComponentData
75003
+ )
75004
+ })
75005
+ });
75006
+ };
75007
+ var reduceData = (data, action, config) => {
75008
+ if (action.type === "insert") {
75009
+ return insertAction(data, action, config);
75010
+ }
75008
75011
  if (action.type === "duplicate") {
75009
75012
  const item = getItem2(
75010
75013
  { index: action.sourceIndex, zone: action.sourceZone },
@@ -75440,20 +75443,8 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
75440
75443
  },
75441
75444
  children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("inner"), children: [
75442
75445
  /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: getClassName19("history"), children: [
75443
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
75444
- Undo2,
75445
- {
75446
- size: 21,
75447
- stroke: hasPast ? "var(--puck-color-black)" : "var(--puck-color-grey-08)"
75448
- }
75449
- ) }),
75450
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
75451
- Redo2,
75452
- {
75453
- size: 21,
75454
- stroke: hasFuture ? "var(--puck-color-black)" : "var(--puck-color-grey-08)"
75455
- }
75456
- ) })
75446
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(IconButton, { title: "undo", disabled: !hasPast, onClick: back, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Undo2, { size: 21 }) }),
75447
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(IconButton, { title: "redo", disabled: !hasFuture, onClick: forward, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Redo2, { size: 21 }) })
75457
75448
  ] }),
75458
75449
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_jsx_runtime25.Fragment, { children: renderHeaderActions && renderHeaderActions({
75459
75450
  state: appState,
@@ -76789,6 +76780,36 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
76789
76780
  }
76790
76781
  );
76791
76782
  };
76783
+ init_react_import2();
76784
+ var insertComponent = (componentType, zone, index, {
76785
+ config,
76786
+ dispatch,
76787
+ resolveData,
76788
+ state
76789
+ }) => {
76790
+ const id = generateId(componentType);
76791
+ const insertActionData = {
76792
+ type: "insert",
76793
+ componentType,
76794
+ destinationIndex: index,
76795
+ destinationZone: zone,
76796
+ id
76797
+ };
76798
+ const insertedData = insertAction(state.data, insertActionData, config);
76799
+ dispatch(__spreadProps2(__spreadValues2({}, insertActionData), {
76800
+ // Dispatch insert rather set, as user's may rely on this via onAction
76801
+ recordHistory: false
76802
+ }));
76803
+ const itemSelector = {
76804
+ index,
76805
+ zone
76806
+ };
76807
+ dispatch({ type: "setUi", ui: { itemSelector } });
76808
+ resolveData({
76809
+ data: insertedData,
76810
+ ui: __spreadProps2(__spreadValues2({}, state.ui), { itemSelector })
76811
+ });
76812
+ };
76792
76813
  var import_jsx_runtime36 = require("react/jsx-runtime");
76793
76814
  var getClassName26 = get_class_name_factory_default2("Puck", styles_module_default14);
76794
76815
  var getLayoutClassName = get_class_name_factory_default2("PuckLayout", styles_module_default14);
@@ -77033,16 +77054,12 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
77033
77054
  }
77034
77055
  if (droppedItem.source.droppableId.startsWith("component-list") && droppedItem.destination) {
77035
77056
  const [_, componentType] = droppedItem.draggableId.split("::");
77036
- dispatch({
77037
- type: "insert",
77038
- componentType: componentType || droppedItem.draggableId,
77039
- destinationIndex: droppedItem.destination.index,
77040
- destinationZone: droppedItem.destination.droppableId
77041
- });
77042
- setItemSelector({
77043
- index: droppedItem.destination.index,
77044
- zone: droppedItem.destination.droppableId
77045
- });
77057
+ insertComponent(
77058
+ componentType || droppedItem.draggableId,
77059
+ droppedItem.destination.droppableId,
77060
+ droppedItem.destination.index,
77061
+ { config, dispatch, resolveData, state: appState }
77062
+ );
77046
77063
  return;
77047
77064
  } else {
77048
77065
  const { source, destination } = droppedItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck-plugin-heading-analyzer",
3
- "version": "0.16.0-canary.2c52d27",
3
+ "version": "0.16.0-canary.3298831",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",
@@ -18,7 +18,7 @@
18
18
  "dist"
19
19
  ],
20
20
  "devDependencies": {
21
- "@measured/puck": "^0.16.0-canary.2c52d27",
21
+ "@measured/puck": "^0.16.0-canary.3298831",
22
22
  "@types/react": "^18.2.0",
23
23
  "@types/react-dom": "^18.2.0",
24
24
  "eslint": "^7.32.0",