@measured/puck-plugin-heading-analyzer 0.16.0-canary.6386bd1 → 0.16.0-canary.7c79787

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 +64 -35
  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 },
@@ -76777,6 +76780,36 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
76777
76780
  }
76778
76781
  );
76779
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
+ };
76780
76813
  var import_jsx_runtime36 = require("react/jsx-runtime");
76781
76814
  var getClassName26 = get_class_name_factory_default2("Puck", styles_module_default14);
76782
76815
  var getLayoutClassName = get_class_name_factory_default2("PuckLayout", styles_module_default14);
@@ -77021,16 +77054,12 @@ See https://github.com/measuredco/puck/issues/411 for more information. This mes
77021
77054
  }
77022
77055
  if (droppedItem.source.droppableId.startsWith("component-list") && droppedItem.destination) {
77023
77056
  const [_, componentType] = droppedItem.draggableId.split("::");
77024
- dispatch({
77025
- type: "insert",
77026
- componentType: componentType || droppedItem.draggableId,
77027
- destinationIndex: droppedItem.destination.index,
77028
- destinationZone: droppedItem.destination.droppableId
77029
- });
77030
- setItemSelector({
77031
- index: droppedItem.destination.index,
77032
- zone: droppedItem.destination.droppableId
77033
- });
77057
+ insertComponent(
77058
+ componentType || droppedItem.draggableId,
77059
+ droppedItem.destination.droppableId,
77060
+ droppedItem.destination.index,
77061
+ { config, dispatch, resolveData, state: appState }
77062
+ );
77034
77063
  return;
77035
77064
  } else {
77036
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.6386bd1",
3
+ "version": "0.16.0-canary.7c79787",
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.6386bd1",
21
+ "@measured/puck": "^0.16.0-canary.7c79787",
22
22
  "@types/react": "^18.2.0",
23
23
  "@types/react-dom": "^18.2.0",
24
24
  "eslint": "^7.32.0",