@measured/puck 0.14.0-canary.68f97ae → 0.14.0-canary.6cadfdb

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.css CHANGED
@@ -1622,7 +1622,7 @@ textarea.styles_Input-input {
1622
1622
  border-left: 2px solid var(--puck-color-grey-11);
1623
1623
  justify-content: center;
1624
1624
  gap: 8px;
1625
- min-width: 392px;
1625
+ min-width: 358px;
1626
1626
  padding-bottom: 16px;
1627
1627
  padding-left: var(--puck-space-px);
1628
1628
  padding-right: var(--puck-space-px);
@@ -1670,7 +1670,7 @@ textarea.styles_Input-input {
1670
1670
  display: flex;
1671
1671
  height: 100%;
1672
1672
  justify-content: center;
1673
- min-width: 392px;
1673
+ min-width: 358px;
1674
1674
  overflow: hidden;
1675
1675
  position: relative;
1676
1676
  width: 100%;
package/dist/index.js CHANGED
@@ -30518,14 +30518,10 @@ var IconButton = ({
30518
30518
 
30519
30519
  // components/Puck/index.tsx
30520
30520
  init_react_import();
30521
- var import_react29 = require("react");
30521
+ var import_react28 = require("react");
30522
30522
 
30523
30523
  // lib/use-placeholder-style.ts
30524
30524
  init_react_import();
30525
- var import_react12 = require("react");
30526
-
30527
- // lib/use-frame.ts
30528
- init_react_import();
30529
30525
  var import_react11 = require("react");
30530
30526
 
30531
30527
  // lib/get-frame.ts
@@ -30533,36 +30529,27 @@ init_react_import();
30533
30529
  var getFrame = () => {
30534
30530
  let frame = document.querySelector("#preview-frame");
30535
30531
  if ((frame == null ? void 0 : frame.tagName) === "IFRAME") {
30536
- frame = frame.contentDocument.body;
30532
+ frame = frame.contentDocument;
30537
30533
  }
30538
30534
  return frame;
30539
30535
  };
30540
30536
 
30541
- // lib/use-frame.ts
30542
- var useFrame = () => {
30543
- const [el, setEl] = (0, import_react11.useState)();
30544
- (0, import_react11.useEffect)(() => {
30545
- setEl(getFrame());
30546
- }, []);
30547
- return el;
30548
- };
30549
-
30550
30537
  // lib/use-placeholder-style.ts
30551
30538
  var usePlaceholderStyle = () => {
30552
30539
  const queryAttr = "data-rfd-drag-handle-draggable-id";
30553
- const [placeholderStyle, setPlaceholderStyle] = (0, import_react12.useState)();
30554
- const frame = useFrame();
30540
+ const [placeholderStyle, setPlaceholderStyle] = (0, import_react11.useState)();
30555
30541
  const onDragStartOrUpdate = (draggedItem) => {
30556
30542
  var _a;
30557
30543
  const draggableId = draggedItem.draggableId;
30558
30544
  const destinationIndex = (draggedItem.destination || draggedItem.source).index;
30559
30545
  const droppableId = (draggedItem.destination || draggedItem.source).droppableId;
30560
30546
  const domQuery = `[${queryAttr}='${draggableId}']`;
30561
- const draggedDOM = frame == null ? void 0 : frame.ownerDocument.querySelector(domQuery);
30547
+ const frame = getFrame();
30548
+ const draggedDOM = frame == null ? void 0 : frame.querySelector(domQuery);
30562
30549
  if (!draggedDOM) {
30563
30550
  return;
30564
30551
  }
30565
- const targetListElement = frame == null ? void 0 : frame.ownerDocument.querySelector(
30552
+ const targetListElement = frame == null ? void 0 : frame.querySelector(
30566
30553
  `[data-rfd-droppable-id='${droppableId}']`
30567
30554
  );
30568
30555
  const { clientHeight } = draggedDOM;
@@ -30645,7 +30632,7 @@ var Heading = ({ children, rank, size = "m" }) => {
30645
30632
 
30646
30633
  // lib/use-breadcrumbs.ts
30647
30634
  init_react_import();
30648
- var import_react13 = require("react");
30635
+ var import_react12 = require("react");
30649
30636
  var convertPathDataToBreadcrumbs = (selectedItem, pathData, data) => {
30650
30637
  const id = selectedItem ? selectedItem == null ? void 0 : selectedItem.props.id : "";
30651
30638
  const currentPathData = pathData && id && pathData[id] ? __spreadValues({}, pathData[id]) : { label: "Page", path: [] };
@@ -30695,8 +30682,8 @@ var useBreadcrumbs = (renderCount) => {
30695
30682
  state: { data },
30696
30683
  selectedItem
30697
30684
  } = useAppContext();
30698
- const dzContext = (0, import_react13.useContext)(dropZoneContext);
30699
- return (0, import_react13.useMemo)(() => {
30685
+ const dzContext = (0, import_react12.useContext)(dropZoneContext);
30686
+ return (0, import_react12.useMemo)(() => {
30700
30687
  const breadcrumbs = convertPathDataToBreadcrumbs(
30701
30688
  selectedItem,
30702
30689
  dzContext == null ? void 0 : dzContext.pathData,
@@ -31113,7 +31100,7 @@ var flushZones = (appState) => {
31113
31100
 
31114
31101
  // lib/use-resolved-data.ts
31115
31102
  init_react_import();
31116
- var import_react14 = require("react");
31103
+ var import_react13 = require("react");
31117
31104
 
31118
31105
  // lib/resolve-component-data.ts
31119
31106
  init_react_import();
@@ -31228,13 +31215,13 @@ var resolveRootData = (data, config) => __async(void 0, null, function* () {
31228
31215
 
31229
31216
  // lib/use-resolved-data.ts
31230
31217
  var useResolvedData = (appState, config, dispatch) => {
31231
- const [{ resolverKey, newAppState }, setResolverState] = (0, import_react14.useState)({
31218
+ const [{ resolverKey, newAppState }, setResolverState] = (0, import_react13.useState)({
31232
31219
  resolverKey: 0,
31233
31220
  newAppState: appState
31234
31221
  });
31235
- const [componentState, setComponentState] = (0, import_react14.useState)({});
31222
+ const [componentState, setComponentState] = (0, import_react13.useState)({});
31236
31223
  const deferredSetStates = {};
31237
- const setComponentLoading = (0, import_react14.useCallback)(
31224
+ const setComponentLoading = (0, import_react13.useCallback)(
31238
31225
  (id, loading, defer = 0) => {
31239
31226
  if (deferredSetStates[id]) {
31240
31227
  clearTimeout(deferredSetStates[id]);
@@ -31304,10 +31291,10 @@ var useResolvedData = (appState, config, dispatch) => {
31304
31291
  });
31305
31292
  yield Promise.all(promises);
31306
31293
  });
31307
- (0, import_react14.useEffect)(() => {
31294
+ (0, import_react13.useEffect)(() => {
31308
31295
  runResolvers();
31309
31296
  }, [resolverKey]);
31310
- const resolveData = (0, import_react14.useCallback)((newAppState2 = appState) => {
31297
+ const resolveData = (0, import_react13.useCallback)((newAppState2 = appState) => {
31311
31298
  setResolverState((curr) => ({
31312
31299
  resolverKey: curr.resolverKey + 1,
31313
31300
  newAppState: newAppState2
@@ -31437,7 +31424,7 @@ var styles_default9 = {
31437
31424
  };
31438
31425
 
31439
31426
  // components/InputOrGroup/index.tsx
31440
- var import_react19 = require("react");
31427
+ var import_react18 = require("react");
31441
31428
 
31442
31429
  // components/InputOrGroup/fields/index.tsx
31443
31430
  init_react_import();
@@ -31463,7 +31450,7 @@ var styles_default10 = {
31463
31450
  };
31464
31451
 
31465
31452
  // components/InputOrGroup/fields/ArrayField/index.tsx
31466
- var import_react15 = require("react");
31453
+ var import_react14 = require("react");
31467
31454
 
31468
31455
  // components/DragDropContext/index.tsx
31469
31456
  init_react_import();
@@ -31501,11 +31488,11 @@ var ArrayField = ({
31501
31488
  }),
31502
31489
  openId: ""
31503
31490
  };
31504
- const [localState, setLocalState] = (0, import_react15.useState)({ arrayState, value });
31505
- (0, import_react15.useEffect)(() => {
31491
+ const [localState, setLocalState] = (0, import_react14.useState)({ arrayState, value });
31492
+ (0, import_react14.useEffect)(() => {
31506
31493
  setLocalState({ arrayState, value });
31507
31494
  }, [value, state.ui.arrayState[id]]);
31508
- const mapArrayStateToUi = (0, import_react15.useCallback)(
31495
+ const mapArrayStateToUi = (0, import_react14.useCallback)(
31509
31496
  (partialArrayState) => {
31510
31497
  return {
31511
31498
  arrayState: __spreadProps(__spreadValues({}, state.ui.arrayState), {
@@ -31515,13 +31502,13 @@ var ArrayField = ({
31515
31502
  },
31516
31503
  [arrayState]
31517
31504
  );
31518
- const getHighestIndex = (0, import_react15.useCallback)(() => {
31505
+ const getHighestIndex = (0, import_react14.useCallback)(() => {
31519
31506
  return arrayState.items.reduce(
31520
31507
  (acc, item) => item._originalIndex > acc ? item._originalIndex : acc,
31521
31508
  -1
31522
31509
  );
31523
31510
  }, [arrayState]);
31524
- const regenerateArrayState = (0, import_react15.useCallback)(
31511
+ const regenerateArrayState = (0, import_react14.useCallback)(
31525
31512
  (value2) => {
31526
31513
  let highestIndex = getHighestIndex();
31527
31514
  const newItems = Array.from(value2 || []).map((item, idx) => {
@@ -31540,10 +31527,10 @@ var ArrayField = ({
31540
31527
  },
31541
31528
  [arrayState]
31542
31529
  );
31543
- (0, import_react15.useEffect)(() => {
31530
+ (0, import_react14.useEffect)(() => {
31544
31531
  setUi(mapArrayStateToUi(arrayState));
31545
31532
  }, []);
31546
- const [hovering, setHovering] = (0, import_react15.useState)(false);
31533
+ const [hovering, setHovering] = (0, import_react14.useState)(false);
31547
31534
  if (field.type !== "array" || !field.arrayFields) {
31548
31535
  return null;
31549
31536
  }
@@ -31639,6 +31626,7 @@ var ArrayField = ({
31639
31626
  !readOnly && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameItem2("actions"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: getClassNameItem2("action"), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
31640
31627
  IconButton,
31641
31628
  {
31629
+ type: "button",
31642
31630
  disabled: field.min !== void 0 && field.min >= localState.arrayState.items.length,
31643
31631
  onClick: (e) => {
31644
31632
  e.stopPropagation();
@@ -31703,6 +31691,7 @@ var ArrayField = ({
31703
31691
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
31704
31692
  "button",
31705
31693
  {
31694
+ type: "button",
31706
31695
  className: getClassName10("addButton"),
31707
31696
  disabled: field.max !== void 0 && localState.arrayState.items.length >= field.max,
31708
31697
  onClick: () => {
@@ -31777,11 +31766,11 @@ var DefaultField = ({
31777
31766
 
31778
31767
  // components/InputOrGroup/fields/ExternalField/index.tsx
31779
31768
  init_react_import();
31780
- var import_react18 = require("react");
31769
+ var import_react17 = require("react");
31781
31770
 
31782
31771
  // components/ExternalInput/index.tsx
31783
31772
  init_react_import();
31784
- var import_react17 = require("react");
31773
+ var import_react16 = require("react");
31785
31774
 
31786
31775
  // components/ExternalInput/styles.module.css
31787
31776
  var styles_default11 = {
@@ -31816,7 +31805,7 @@ var styles_default11 = {
31816
31805
 
31817
31806
  // components/Modal/index.tsx
31818
31807
  init_react_import();
31819
- var import_react16 = require("react");
31808
+ var import_react15 = require("react");
31820
31809
 
31821
31810
  // components/Modal/styles.module.css
31822
31811
  var styles_default12 = {
@@ -31834,8 +31823,8 @@ var Modal = ({
31834
31823
  onClose,
31835
31824
  isOpen
31836
31825
  }) => {
31837
- const [rootEl, setRootEl] = (0, import_react16.useState)(null);
31838
- (0, import_react16.useEffect)(() => {
31826
+ const [rootEl, setRootEl] = (0, import_react15.useState)(null);
31827
+ (0, import_react15.useEffect)(() => {
31839
31828
  setRootEl(document.getElementById("puck-portal-root"));
31840
31829
  }, []);
31841
31830
  if (!rootEl) {
@@ -31872,16 +31861,16 @@ var ExternalInput = ({
31872
31861
  mapRow = (val) => val,
31873
31862
  filterFields
31874
31863
  } = field || {};
31875
- const [data, setData] = (0, import_react17.useState)([]);
31876
- const [isOpen, setOpen] = (0, import_react17.useState)(false);
31877
- const [isLoading, setIsLoading] = (0, import_react17.useState)(true);
31864
+ const [data, setData] = (0, import_react16.useState)([]);
31865
+ const [isOpen, setOpen] = (0, import_react16.useState)(false);
31866
+ const [isLoading, setIsLoading] = (0, import_react16.useState)(true);
31878
31867
  const hasFilterFields = !!filterFields;
31879
- const [filters, setFilters] = (0, import_react17.useState)(field.initialFilters || {});
31880
- const [filtersToggled, setFiltersToggled] = (0, import_react17.useState)(hasFilterFields);
31881
- const mappedData = (0, import_react17.useMemo)(() => {
31868
+ const [filters, setFilters] = (0, import_react16.useState)(field.initialFilters || {});
31869
+ const [filtersToggled, setFiltersToggled] = (0, import_react16.useState)(hasFilterFields);
31870
+ const mappedData = (0, import_react16.useMemo)(() => {
31882
31871
  return data.map(mapRow);
31883
31872
  }, [data]);
31884
- const keys = (0, import_react17.useMemo)(() => {
31873
+ const keys = (0, import_react16.useMemo)(() => {
31885
31874
  const validKeys = /* @__PURE__ */ new Set();
31886
31875
  for (const item of mappedData) {
31887
31876
  for (const key of Object.keys(item)) {
@@ -31892,8 +31881,8 @@ var ExternalInput = ({
31892
31881
  }
31893
31882
  return Array.from(validKeys);
31894
31883
  }, [mappedData]);
31895
- const [searchQuery, setSearchQuery] = (0, import_react17.useState)(field.initialQuery || "");
31896
- const search = (0, import_react17.useCallback)(
31884
+ const [searchQuery, setSearchQuery] = (0, import_react16.useState)(field.initialQuery || "");
31885
+ const search = (0, import_react16.useCallback)(
31897
31886
  (query, filters2) => __async(void 0, null, function* () {
31898
31887
  setIsLoading(true);
31899
31888
  const cacheKey = `${id}-${name}-${query}-${JSON.stringify(filters2)}`;
@@ -31906,7 +31895,7 @@ var ExternalInput = ({
31906
31895
  }),
31907
31896
  [name, field]
31908
31897
  );
31909
- (0, import_react17.useEffect)(() => {
31898
+ (0, import_react16.useEffect)(() => {
31910
31899
  search(searchQuery, filters);
31911
31900
  }, []);
31912
31901
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
@@ -31922,6 +31911,7 @@ var ExternalInput = ({
31922
31911
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
31923
31912
  "button",
31924
31913
  {
31914
+ type: "button",
31925
31915
  onClick: () => setOpen(true),
31926
31916
  className: getClassName13("button"),
31927
31917
  children: value ? field.getItemSummary ? field.getItemSummary(value) : "External item" : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
@@ -32066,7 +32056,7 @@ var ExternalField = ({
32066
32056
  var _a, _b, _c;
32067
32057
  const validField = field;
32068
32058
  const deprecatedField = field;
32069
- (0, import_react18.useEffect)(() => {
32059
+ (0, import_react17.useEffect)(() => {
32070
32060
  if (deprecatedField.adaptor) {
32071
32061
  console.error(
32072
32062
  "Warning: The `adaptor` API is deprecated. Please use updated APIs on the `external` field instead. This will be a breaking change in a future release."
@@ -32343,7 +32333,7 @@ var FieldLabelInternal = ({
32343
32333
  readOnly
32344
32334
  }) => {
32345
32335
  const { overrides } = useAppContext();
32346
- const Wrapper = (0, import_react19.useMemo)(
32336
+ const Wrapper = (0, import_react18.useMemo)(
32347
32337
  () => overrides.fieldLabel || FieldLabel,
32348
32338
  [overrides]
32349
32339
  );
@@ -32364,7 +32354,7 @@ var InputOrGroup = (_a) => {
32364
32354
  var _a2, _b2, _c, _d, _e, _f, _g, _h;
32365
32355
  const { overrides } = useAppContext();
32366
32356
  const { name, field, value, readOnly } = props;
32367
- const [localValue, setLocalValue] = (0, import_react19.useState)(value);
32357
+ const [localValue, setLocalValue] = (0, import_react18.useState)(value);
32368
32358
  const onChangeDb = (0, import_use_debounce2.useDebouncedCallback)(
32369
32359
  (val, ui) => {
32370
32360
  onChange(val, ui);
@@ -32372,11 +32362,11 @@ var InputOrGroup = (_a) => {
32372
32362
  50,
32373
32363
  { leading: true }
32374
32364
  );
32375
- const onChangeLocal = (0, import_react19.useCallback)((val, ui) => {
32365
+ const onChangeLocal = (0, import_react18.useCallback)((val, ui) => {
32376
32366
  setLocalValue(val);
32377
32367
  onChangeDb(val, ui);
32378
32368
  }, []);
32379
- (0, import_react19.useEffect)(() => {
32369
+ (0, import_react18.useEffect)(() => {
32380
32370
  setLocalValue(value);
32381
32371
  }, [value]);
32382
32372
  const localProps = {
@@ -32426,7 +32416,7 @@ var styles_default14 = {
32426
32416
  };
32427
32417
 
32428
32418
  // components/Puck/components/Fields/index.tsx
32429
- var import_react20 = require("react");
32419
+ var import_react19 = require("react");
32430
32420
  var import_jsx_runtime25 = require("react/jsx-runtime");
32431
32421
  var getClassName19 = get_class_name_factory_default("PuckFields", styles_default14);
32432
32422
  var defaultPageFields = {
@@ -32458,7 +32448,7 @@ var Fields = () => {
32458
32448
  const fields = selectedItem ? ((_b = config.components[selectedItem.type]) == null ? void 0 : _b.fields) || {} : rootFields;
32459
32449
  const isLoading = selectedItem ? (_c = componentState[selectedItem == null ? void 0 : selectedItem.props.id]) == null ? void 0 : _c.loading : (_d = componentState["puck-root"]) == null ? void 0 : _d.loading;
32460
32450
  const rootProps = data.root.props || data.root;
32461
- const Wrapper = (0, import_react20.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
32451
+ const Wrapper = (0, import_react19.useMemo)(() => overrides.fields || DefaultFields, [overrides]);
32462
32452
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
32463
32453
  "form",
32464
32454
  {
@@ -32573,7 +32563,7 @@ init_react_import();
32573
32563
 
32574
32564
  // lib/use-component-list.tsx
32575
32565
  init_react_import();
32576
- var import_react21 = require("react");
32566
+ var import_react20 = require("react");
32577
32567
 
32578
32568
  // components/ComponentList/index.tsx
32579
32569
  init_react_import();
@@ -32643,8 +32633,8 @@ ComponentList.Item = ComponentListItem;
32643
32633
  // lib/use-component-list.tsx
32644
32634
  var import_jsx_runtime27 = require("react/jsx-runtime");
32645
32635
  var useComponentList = (config, ui) => {
32646
- const [componentList, setComponentList] = (0, import_react21.useState)();
32647
- (0, import_react21.useEffect)(() => {
32636
+ const [componentList, setComponentList] = (0, import_react20.useState)();
32637
+ (0, import_react20.useEffect)(() => {
32648
32638
  var _a, _b, _c;
32649
32639
  if (Object.keys(ui.componentList).length > 0) {
32650
32640
  const matchedComponents = [];
@@ -32711,18 +32701,18 @@ var useComponentList = (config, ui) => {
32711
32701
  };
32712
32702
 
32713
32703
  // components/Puck/components/Components/index.tsx
32714
- var import_react22 = require("react");
32704
+ var import_react21 = require("react");
32715
32705
  var import_jsx_runtime28 = require("react/jsx-runtime");
32716
32706
  var Components = () => {
32717
32707
  const { config, state, overrides } = useAppContext();
32718
32708
  const componentList = useComponentList(config, state.ui);
32719
- const Wrapper = (0, import_react22.useMemo)(() => overrides.components || "div", [overrides]);
32709
+ const Wrapper = (0, import_react21.useMemo)(() => overrides.components || "div", [overrides]);
32720
32710
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Wrapper, { children: componentList ? componentList : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(ComponentList, { id: "all" }) });
32721
32711
  };
32722
32712
 
32723
32713
  // components/Puck/components/Preview/index.tsx
32724
32714
  init_react_import();
32725
- var import_react23 = require("react");
32715
+ var import_react22 = require("react");
32726
32716
  var import_auto_frame_component = __toESM(require("@measured/auto-frame-component"));
32727
32717
 
32728
32718
  // components/Puck/components/Preview/styles.module.css
@@ -32736,7 +32726,7 @@ var import_jsx_runtime29 = require("react/jsx-runtime");
32736
32726
  var getClassName21 = get_class_name_factory_default("PuckPreview", styles_default16);
32737
32727
  var Preview = ({ id = "puck-preview" }) => {
32738
32728
  const { config, dispatch, state, setStatus, iframe } = useAppContext();
32739
- const Page = (0, import_react23.useCallback)(
32729
+ const Page = (0, import_react22.useCallback)(
32740
32730
  (pageProps) => {
32741
32731
  var _a, _b;
32742
32732
  return ((_a = config.root) == null ? void 0 : _a.render) ? (_b = config.root) == null ? void 0 : _b.render(__spreadProps(__spreadValues({}, pageProps), { editMode: true })) : pageProps.children;
@@ -32744,7 +32734,7 @@ var Preview = ({ id = "puck-preview" }) => {
32744
32734
  [config.root]
32745
32735
  );
32746
32736
  const rootProps = state.data.root.props || state.data.root;
32747
- const ref = (0, import_react23.useRef)(null);
32737
+ const ref = (0, import_react22.useRef)(null);
32748
32738
  return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
32749
32739
  "div",
32750
32740
  {
@@ -32828,7 +32818,7 @@ var scrollIntoView = (el) => {
32828
32818
  };
32829
32819
 
32830
32820
  // components/LayerTree/index.tsx
32831
- var import_react24 = require("react");
32821
+ var import_react23 = require("react");
32832
32822
 
32833
32823
  // lib/is-child-of-zone.ts
32834
32824
  init_react_import();
@@ -32855,8 +32845,7 @@ var LayerTree = ({
32855
32845
  label
32856
32846
  }) => {
32857
32847
  const zones = data.zones || {};
32858
- const ctx = (0, import_react24.useContext)(dropZoneContext);
32859
- const frame = useFrame();
32848
+ const ctx = (0, import_react23.useContext)(dropZoneContext);
32860
32849
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
32861
32850
  label && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: getClassName22("zoneTitle"), children: [
32862
32851
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: getClassName22("zoneIcon"), children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Layers, { size: "16" }) }),
@@ -32904,6 +32893,7 @@ var LayerTree = ({
32904
32893
  zone
32905
32894
  });
32906
32895
  const id = zoneContent[i].props.id;
32896
+ const frame = getFrame();
32907
32897
  scrollIntoView(
32908
32898
  frame == null ? void 0 : frame.querySelector(
32909
32899
  `[data-rfd-drag-handle-draggable-id="draggable-${id}"]`
@@ -32958,13 +32948,13 @@ var LayerTree = ({
32958
32948
  };
32959
32949
 
32960
32950
  // components/Puck/components/Outline/index.tsx
32961
- var import_react25 = require("react");
32951
+ var import_react24 = require("react");
32962
32952
  var import_jsx_runtime31 = require("react/jsx-runtime");
32963
32953
  var Outline = () => {
32964
32954
  const { dispatch, state, overrides, config } = useAppContext();
32965
32955
  const { data, ui } = state;
32966
32956
  const { itemSelector } = ui;
32967
- const setItemSelector = (0, import_react25.useCallback)(
32957
+ const setItemSelector = (0, import_react24.useCallback)(
32968
32958
  (newItemSelector) => {
32969
32959
  dispatch({
32970
32960
  type: "setUi",
@@ -32973,7 +32963,7 @@ var Outline = () => {
32973
32963
  },
32974
32964
  []
32975
32965
  );
32976
- const Wrapper = (0, import_react25.useMemo)(() => overrides.outline || "div", [overrides]);
32966
+ const Wrapper = (0, import_react24.useMemo)(() => overrides.outline || "div", [overrides]);
32977
32967
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Wrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(dropZoneContext.Consumer, { children: (ctx) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
32978
32968
  (ctx == null ? void 0 : ctx.activeZones) && (ctx == null ? void 0 : ctx.activeZones[rootDroppableId]) && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
32979
32969
  LayerTree,
@@ -33073,12 +33063,12 @@ function usePuckHistory({
33073
33063
 
33074
33064
  // lib/use-history-store.ts
33075
33065
  init_react_import();
33076
- var import_react26 = require("react");
33066
+ var import_react25 = require("react");
33077
33067
  var import_use_debounce3 = require("use-debounce");
33078
33068
  var EMPTY_HISTORY_INDEX = -1;
33079
33069
  function useHistoryStore() {
33080
- const [histories, setHistories] = (0, import_react26.useState)([]);
33081
- const [index, setIndex] = (0, import_react26.useState)(EMPTY_HISTORY_INDEX);
33070
+ const [histories, setHistories] = (0, import_react25.useState)([]);
33071
+ const [index, setIndex] = (0, import_react25.useState)(EMPTY_HISTORY_INDEX);
33082
33072
  const hasPast = index > EMPTY_HISTORY_INDEX;
33083
33073
  const hasFuture = index < histories.length - 1;
33084
33074
  const currentHistory = histories[index];
@@ -33238,11 +33228,11 @@ var getBox = function getBox2(el) {
33238
33228
  };
33239
33229
 
33240
33230
  // components/Puck/components/Canvas/index.tsx
33241
- var import_react28 = require("react");
33231
+ var import_react27 = require("react");
33242
33232
 
33243
33233
  // components/ViewportControls/index.tsx
33244
33234
  init_react_import();
33245
- var import_react27 = require("react");
33235
+ var import_react26 = require("react");
33246
33236
 
33247
33237
  // components/ViewportControls/styles.module.css
33248
33238
  var styles_default18 = {
@@ -33270,8 +33260,8 @@ var ViewportButton = ({
33270
33260
  onClick
33271
33261
  }) => {
33272
33262
  const { state } = useAppContext();
33273
- const [isActive, setIsActive] = (0, import_react27.useState)(false);
33274
- (0, import_react27.useEffect)(() => {
33263
+ const [isActive, setIsActive] = (0, import_react26.useState)(false);
33264
+ (0, import_react26.useEffect)(() => {
33275
33265
  setIsActive(width === state.ui.viewports.current.width);
33276
33266
  }, [width, state.ui.viewports.current.width]);
33277
33267
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: getClassNameButton({ isActive }), children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
@@ -33306,7 +33296,7 @@ var ViewportControls = ({
33306
33296
  const defaultsContainAutoZoom = defaultZoomOptions.find(
33307
33297
  (option) => option.value === autoZoom
33308
33298
  );
33309
- const zoomOptions = (0, import_react27.useMemo)(
33299
+ const zoomOptions = (0, import_react26.useMemo)(
33310
33300
  () => [
33311
33301
  ...defaultZoomOptions,
33312
33302
  ...defaultsContainAutoZoom ? [] : [
@@ -33434,17 +33424,17 @@ var Canvas = () => {
33434
33424
  const { status, iframe } = useAppContext();
33435
33425
  const { dispatch, state, overrides, setUi, zoomConfig, setZoomConfig } = useAppContext();
33436
33426
  const { ui } = state;
33437
- const frameRef = (0, import_react28.useRef)(null);
33438
- const [showTransition, setShowTransition] = (0, import_react28.useState)(false);
33439
- const defaultRender = (0, import_react28.useMemo)(() => {
33427
+ const frameRef = (0, import_react27.useRef)(null);
33428
+ const [showTransition, setShowTransition] = (0, import_react27.useState)(false);
33429
+ const defaultRender = (0, import_react27.useMemo)(() => {
33440
33430
  const PuckDefault = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children });
33441
33431
  return PuckDefault;
33442
33432
  }, []);
33443
- const CustomPreview = (0, import_react28.useMemo)(
33433
+ const CustomPreview = (0, import_react27.useMemo)(
33444
33434
  () => overrides.preview || defaultRender,
33445
33435
  [overrides]
33446
33436
  );
33447
- const getFrameDimensions = (0, import_react28.useCallback)(() => {
33437
+ const getFrameDimensions = (0, import_react27.useCallback)(() => {
33448
33438
  if (frameRef.current) {
33449
33439
  const frame = frameRef.current;
33450
33440
  const box = getBox(frame);
@@ -33452,7 +33442,7 @@ var Canvas = () => {
33452
33442
  }
33453
33443
  return { width: 0, height: 0 };
33454
33444
  }, [frameRef]);
33455
- const resetAutoZoom = (0, import_react28.useCallback)(
33445
+ const resetAutoZoom = (0, import_react27.useCallback)(
33456
33446
  (ui2 = state.ui) => {
33457
33447
  if (frameRef.current) {
33458
33448
  setZoomConfig(
@@ -33462,11 +33452,11 @@ var Canvas = () => {
33462
33452
  },
33463
33453
  [frameRef, zoomConfig, state.ui]
33464
33454
  );
33465
- (0, import_react28.useEffect)(() => {
33455
+ (0, import_react27.useEffect)(() => {
33466
33456
  setShowTransition(false);
33467
33457
  resetAutoZoom();
33468
33458
  }, [frameRef, ui.leftSideBarVisible, ui.rightSideBarVisible]);
33469
- (0, import_react28.useEffect)(() => {
33459
+ (0, import_react27.useEffect)(() => {
33470
33460
  const { height: frameHeight } = getFrameDimensions();
33471
33461
  if (ui.viewports.current.height === "auto") {
33472
33462
  setZoomConfig(__spreadProps(__spreadValues({}, zoomConfig), {
@@ -33474,7 +33464,7 @@ var Canvas = () => {
33474
33464
  }));
33475
33465
  }
33476
33466
  }, [zoomConfig.zoom]);
33477
- (0, import_react28.useEffect)(() => {
33467
+ (0, import_react27.useEffect)(() => {
33478
33468
  const observer = new ResizeObserver(() => {
33479
33469
  setShowTransition(false);
33480
33470
  resetAutoZoom();
@@ -33565,10 +33555,10 @@ function Puck({
33565
33555
  }) {
33566
33556
  var _a;
33567
33557
  const historyStore = useHistoryStore();
33568
- const [reducer] = (0, import_react29.useState)(
33558
+ const [reducer] = (0, import_react28.useState)(
33569
33559
  () => createReducer({ config, record: historyStore.record })
33570
33560
  );
33571
- const [initialAppState] = (0, import_react29.useState)(() => {
33561
+ const [initialAppState] = (0, import_react28.useState)(() => {
33572
33562
  var _a2, _b, _c, _d;
33573
33563
  const initial = __spreadValues(__spreadValues({}, defaultAppState.ui), initialUi);
33574
33564
  let clientUiState = {};
@@ -33613,7 +33603,7 @@ function Puck({
33613
33603
  })
33614
33604
  });
33615
33605
  });
33616
- const [appState, dispatch] = (0, import_react29.useReducer)(
33606
+ const [appState, dispatch] = (0, import_react28.useReducer)(
33617
33607
  reducer,
33618
33608
  flushZones(initialAppState)
33619
33609
  );
@@ -33624,9 +33614,9 @@ function Puck({
33624
33614
  config,
33625
33615
  dispatch
33626
33616
  );
33627
- const [menuOpen, setMenuOpen] = (0, import_react29.useState)(false);
33617
+ const [menuOpen, setMenuOpen] = (0, import_react28.useState)(false);
33628
33618
  const { itemSelector, leftSideBarVisible, rightSideBarVisible } = ui;
33629
- const setItemSelector = (0, import_react29.useCallback)(
33619
+ const setItemSelector = (0, import_react28.useCallback)(
33630
33620
  (newItemSelector) => {
33631
33621
  if (newItemSelector === itemSelector)
33632
33622
  return;
@@ -33639,21 +33629,21 @@ function Puck({
33639
33629
  [itemSelector]
33640
33630
  );
33641
33631
  const selectedItem = itemSelector ? getItem(itemSelector, data) : null;
33642
- (0, import_react29.useEffect)(() => {
33632
+ (0, import_react28.useEffect)(() => {
33643
33633
  if (onChange)
33644
33634
  onChange(data);
33645
33635
  }, [data]);
33646
33636
  const { onDragStartOrUpdate, placeholderStyle } = usePlaceholderStyle();
33647
- const [draggedItem, setDraggedItem] = (0, import_react29.useState)();
33637
+ const [draggedItem, setDraggedItem] = (0, import_react28.useState)();
33648
33638
  const rootProps = data.root.props || data.root;
33649
- (0, import_react29.useEffect)(() => {
33639
+ (0, import_react28.useEffect)(() => {
33650
33640
  if (Object.keys(data.root).length > 0 && !data.root.props) {
33651
33641
  console.error(
33652
33642
  "Warning: Defining props on `root` is deprecated. Please use `root.props`. This will be a breaking change in a future release."
33653
33643
  );
33654
33644
  }
33655
33645
  }, []);
33656
- const toggleSidebars = (0, import_react29.useCallback)(
33646
+ const toggleSidebars = (0, import_react28.useCallback)(
33657
33647
  (sidebar) => {
33658
33648
  const widerViewport = window.matchMedia("(min-width: 638px)").matches;
33659
33649
  const sideBarVisible = sidebar === "left" ? leftSideBarVisible : rightSideBarVisible;
@@ -33667,7 +33657,7 @@ function Puck({
33667
33657
  },
33668
33658
  [dispatch, leftSideBarVisible, rightSideBarVisible]
33669
33659
  );
33670
- (0, import_react29.useEffect)(() => {
33660
+ (0, import_react28.useEffect)(() => {
33671
33661
  if (!window.matchMedia("(min-width: 638px)").matches) {
33672
33662
  dispatch({
33673
33663
  type: "setUi",
@@ -33690,11 +33680,11 @@ function Puck({
33690
33680
  window.removeEventListener("resize", handleResize);
33691
33681
  };
33692
33682
  }, []);
33693
- const defaultRender = (0, import_react29.useMemo)(() => {
33683
+ const defaultRender = (0, import_react28.useMemo)(() => {
33694
33684
  const PuckDefault = ({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_jsx_runtime34.Fragment, { children: children2 });
33695
33685
  return PuckDefault;
33696
33686
  }, []);
33697
- const defaultHeaderRender = (0, import_react29.useMemo)(() => {
33687
+ const defaultHeaderRender = (0, import_react28.useMemo)(() => {
33698
33688
  if (renderHeader) {
33699
33689
  console.warn(
33700
33690
  "`renderHeader` is deprecated. Please use `overrides.header` and the `usePuck` hook instead"
@@ -33708,7 +33698,7 @@ function Puck({
33708
33698
  }
33709
33699
  return defaultRender;
33710
33700
  }, [renderHeader]);
33711
- const defaultHeaderActionsRender = (0, import_react29.useMemo)(() => {
33701
+ const defaultHeaderActionsRender = (0, import_react28.useMemo)(() => {
33712
33702
  if (renderHeaderActions) {
33713
33703
  console.warn(
33714
33704
  "`renderHeaderActions` is deprecated. Please use `overrides.headerActions` and the `usePuck` hook instead."
@@ -33721,18 +33711,18 @@ function Puck({
33721
33711
  }
33722
33712
  return defaultRender;
33723
33713
  }, [renderHeader]);
33724
- const loadedOverrides = (0, import_react29.useMemo)(() => {
33714
+ const loadedOverrides = (0, import_react28.useMemo)(() => {
33725
33715
  return loadOverrides({ overrides, plugins });
33726
33716
  }, [plugins]);
33727
- const CustomPuck = (0, import_react29.useMemo)(
33717
+ const CustomPuck = (0, import_react28.useMemo)(
33728
33718
  () => loadedOverrides.puck || defaultRender,
33729
33719
  [loadedOverrides]
33730
33720
  );
33731
- const CustomHeader = (0, import_react29.useMemo)(
33721
+ const CustomHeader = (0, import_react28.useMemo)(
33732
33722
  () => loadedOverrides.header || defaultHeaderRender,
33733
33723
  [loadedOverrides]
33734
33724
  );
33735
- const CustomHeaderActions = (0, import_react29.useMemo)(
33725
+ const CustomHeaderActions = (0, import_react28.useMemo)(
33736
33726
  () => loadedOverrides.headerActions || defaultHeaderActionsRender,
33737
33727
  [loadedOverrides]
33738
33728
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@measured/puck",
3
- "version": "0.14.0-canary.68f97ae",
3
+ "version": "0.14.0-canary.6cadfdb",
4
4
  "author": "Measured Corporation Ltd <hello@measured.co>",
5
5
  "repository": "measuredco/puck",
6
6
  "bugs": "https://github.com/measuredco/puck/issues",