@measured/puck 0.18.0-canary.df3d1c2 → 0.18.0-canary.e2139f5

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
@@ -100,7 +100,8 @@ type DropZoneContext<UserConfig extends Config = Config> = {
100
100
  unregisterZone?: (zoneCompound: string) => void;
101
101
  activeZones?: Record<string, boolean>;
102
102
  pathData?: PathData;
103
- registerPath?: (selector: ItemSelector) => void;
103
+ registerPath?: (id: string, selector: ItemSelector, label: string) => void;
104
+ unregisterPath?: (id: string) => void;
104
105
  mode?: "edit" | "render";
105
106
  depth: number;
106
107
  registerLocalZone?: (zone: string, active: boolean) => void;
package/dist/index.d.ts CHANGED
@@ -100,7 +100,8 @@ type DropZoneContext<UserConfig extends Config = Config> = {
100
100
  unregisterZone?: (zoneCompound: string) => void;
101
101
  activeZones?: Record<string, boolean>;
102
102
  pathData?: PathData;
103
- registerPath?: (selector: ItemSelector) => void;
103
+ registerPath?: (id: string, selector: ItemSelector, label: string) => void;
104
+ unregisterPath?: (id: string) => void;
104
105
  mode?: "edit" | "render";
105
106
  depth: number;
106
107
  registerLocalZone?: (zone: string, active: boolean) => void;
package/dist/index.js CHANGED
@@ -3256,13 +3256,19 @@ var DraggableComponent = ({
3256
3256
  }
3257
3257
  }, [ref.current]);
3258
3258
  (0, import_react23.useEffect)(() => {
3259
- if (isSelected) {
3260
- ctx == null ? void 0 : ctx.registerPath({
3259
+ ctx == null ? void 0 : ctx.registerPath(
3260
+ id,
3261
+ {
3261
3262
  index,
3262
3263
  zone: zoneCompound
3263
- });
3264
- }
3265
- }, [isSelected]);
3264
+ },
3265
+ componentType
3266
+ );
3267
+ return () => {
3268
+ var _a;
3269
+ (_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
3270
+ };
3271
+ }, [id, zoneCompound, index, componentType]);
3266
3272
  const CustomActionBar = (0, import_react23.useMemo)(
3267
3273
  () => overrides.actionBar || DefaultActionBar,
3268
3274
  [overrides.actionBar]
@@ -5044,27 +5050,33 @@ var DragDropContextClient = ({
5044
5050
  const [pathData, setPathData] = (0, import_react31.useState)();
5045
5051
  const dragMode = (0, import_react31.useRef)(null);
5046
5052
  const registerPath = (0, import_react31.useCallback)(
5047
- (selector) => {
5048
- const item = getItem(selector, data);
5049
- if (!item) {
5050
- return;
5051
- }
5053
+ (id2, selector, label) => {
5052
5054
  const [area] = getZoneId(selector.zone);
5053
5055
  setPathData((latestPathData = {}) => {
5054
5056
  const parentPathData = latestPathData[area] || { path: [] };
5055
5057
  return __spreadProps(__spreadValues({}, latestPathData), {
5056
- [item.props.id]: {
5058
+ [id2]: {
5057
5059
  path: [
5058
5060
  ...parentPathData.path,
5059
5061
  ...selector.zone ? [selector.zone] : []
5060
5062
  ],
5061
- label: item.type
5063
+ label
5062
5064
  }
5063
5065
  });
5064
5066
  });
5065
5067
  },
5066
5068
  [data, setPathData]
5067
5069
  );
5070
+ const unregisterPath = (0, import_react31.useCallback)(
5071
+ (id2) => {
5072
+ setPathData((latestPathData = {}) => {
5073
+ const newPathData = __spreadValues({}, latestPathData);
5074
+ delete newPathData[id2];
5075
+ return newPathData;
5076
+ });
5077
+ },
5078
+ [data, setPathData]
5079
+ );
5068
5080
  const initialSelector = (0, import_react31.useRef)(void 0);
5069
5081
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { id, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
5070
5082
  dragListenerContext.Provider,
@@ -5261,6 +5273,7 @@ var DragDropContextClient = ({
5261
5273
  areaId: "root",
5262
5274
  depth: 0,
5263
5275
  registerPath,
5276
+ unregisterPath,
5264
5277
  pathData,
5265
5278
  path: []
5266
5279
  },
package/dist/index.mjs CHANGED
@@ -3099,13 +3099,19 @@ var DraggableComponent = ({
3099
3099
  }
3100
3100
  }, [ref.current]);
3101
3101
  useEffect10(() => {
3102
- if (isSelected) {
3103
- ctx == null ? void 0 : ctx.registerPath({
3102
+ ctx == null ? void 0 : ctx.registerPath(
3103
+ id,
3104
+ {
3104
3105
  index,
3105
3106
  zone: zoneCompound
3106
- });
3107
- }
3108
- }, [isSelected]);
3107
+ },
3108
+ componentType
3109
+ );
3110
+ return () => {
3111
+ var _a;
3112
+ (_a = ctx == null ? void 0 : ctx.unregisterPath) == null ? void 0 : _a.call(ctx, id);
3113
+ };
3114
+ }, [id, zoneCompound, index, componentType]);
3109
3115
  const CustomActionBar = useMemo7(
3110
3116
  () => overrides.actionBar || DefaultActionBar,
3111
3117
  [overrides.actionBar]
@@ -4896,27 +4902,33 @@ var DragDropContextClient = ({
4896
4902
  const [pathData, setPathData] = useState17();
4897
4903
  const dragMode = useRef3(null);
4898
4904
  const registerPath = useCallback11(
4899
- (selector) => {
4900
- const item = getItem(selector, data);
4901
- if (!item) {
4902
- return;
4903
- }
4905
+ (id2, selector, label) => {
4904
4906
  const [area] = getZoneId(selector.zone);
4905
4907
  setPathData((latestPathData = {}) => {
4906
4908
  const parentPathData = latestPathData[area] || { path: [] };
4907
4909
  return __spreadProps(__spreadValues({}, latestPathData), {
4908
- [item.props.id]: {
4910
+ [id2]: {
4909
4911
  path: [
4910
4912
  ...parentPathData.path,
4911
4913
  ...selector.zone ? [selector.zone] : []
4912
4914
  ],
4913
- label: item.type
4915
+ label
4914
4916
  }
4915
4917
  });
4916
4918
  });
4917
4919
  },
4918
4920
  [data, setPathData]
4919
4921
  );
4922
+ const unregisterPath = useCallback11(
4923
+ (id2) => {
4924
+ setPathData((latestPathData = {}) => {
4925
+ const newPathData = __spreadValues({}, latestPathData);
4926
+ delete newPathData[id2];
4927
+ return newPathData;
4928
+ });
4929
+ },
4930
+ [data, setPathData]
4931
+ );
4920
4932
  const initialSelector = useRef3(void 0);
4921
4933
  return /* @__PURE__ */ jsx23("div", { id, children: /* @__PURE__ */ jsx23(
4922
4934
  dragListenerContext.Provider,
@@ -5113,6 +5125,7 @@ var DragDropContextClient = ({
5113
5125
  areaId: "root",
5114
5126
  depth: 0,
5115
5127
  registerPath,
5128
+ unregisterPath,
5116
5129
  pathData,
5117
5130
  path: []
5118
5131
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.18.0-canary.df3d1c2",
3
+ "version": "0.18.0-canary.e2139f5",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",