@measured/puck 0.21.0-canary.a3dabae1 → 0.21.0-canary.ace4c8b3

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.
@@ -111,32 +111,27 @@ var walkField = ({
111
111
  config,
112
112
  recurseSlots = false
113
113
  }) => {
114
- var _a, _b, _c, _d, _e;
114
+ var _a, _b, _c;
115
115
  const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
116
116
  const map = mappers[fieldType];
117
117
  if (map && fieldType === "slot") {
118
118
  const content = value || [];
119
- let mappedContent = content;
120
- if (recurseSlots) {
121
- for (let i = 0; i < content.length; i++) {
122
- const el = content[i];
123
- const componentConfig = config.components[el.type];
124
- if (!componentConfig || !((_b = el.props) == null ? void 0 : _b.id)) {
125
- continue;
126
- }
127
- const fields2 = (_c = componentConfig.fields) != null ? _c : {};
128
- mappedContent.push(
129
- walkField({
130
- value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
131
- fields: fields2,
132
- mappers,
133
- id: el.props.id,
134
- config,
135
- recurseSlots
136
- })
137
- );
119
+ const mappedContent = recurseSlots ? content.map((el) => {
120
+ var _a2;
121
+ const componentConfig = config.components[el.type];
122
+ if (!componentConfig) {
123
+ throw new Error(`Could not find component config for ${el.type}`);
138
124
  }
139
- }
125
+ const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
126
+ return walkField({
127
+ value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
128
+ fields: fields2,
129
+ mappers,
130
+ id: el.props.id,
131
+ config,
132
+ recurseSlots
133
+ });
134
+ }) : content;
140
135
  if (containsPromise(mappedContent)) {
141
136
  return Promise.all(mappedContent);
142
137
  }
@@ -158,7 +153,7 @@ var walkField = ({
158
153
  }
159
154
  if (value && typeof value === "object") {
160
155
  if (Array.isArray(value)) {
161
- const arrayFields = ((_d = fields[propKey]) == null ? void 0 : _d.type) === "array" ? fields[propKey].arrayFields : null;
156
+ const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
162
157
  if (!arrayFields) return value;
163
158
  const newValue = value.map(
164
159
  (el, idx) => walkField({
@@ -179,7 +174,7 @@ var walkField = ({
179
174
  } else if ("$$typeof" in value) {
180
175
  return value;
181
176
  } else {
182
- const objectFields = ((_e = fields[propKey]) == null ? void 0 : _e.type) === "object" ? fields[propKey].objectFields : fields;
177
+ const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
183
178
  return walkObject({
184
179
  value,
185
180
  fields: objectFields,
@@ -300,8 +295,7 @@ init_react_import();
300
295
  var defaultViewports = [
301
296
  { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
302
297
  { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
303
- { width: 1280, height: "auto", icon: "Monitor", label: "Large" },
304
- { width: "100%", height: "auto", icon: "FullWidth", label: "Full-width" }
298
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
305
299
  ];
306
300
 
307
301
  // store/default-app-state.ts
@@ -323,8 +317,7 @@ var defaultAppState = {
323
317
  options: [],
324
318
  controlsVisible: true
325
319
  },
326
- field: { focus: null },
327
- plugin: { current: null }
320
+ field: { focus: null }
328
321
  },
329
322
  indexes: {
330
323
  nodes: {},
@@ -702,7 +695,7 @@ var getChanged = (newItem, oldItem) => {
702
695
  // lib/resolve-component-data.ts
703
696
  import { deepEqual as deepEqual2 } from "fast-equals";
704
697
  var cache = { lastChange: {} };
705
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
698
+ var resolveComponentData = (_0, _1, ..._2) => __async(null, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
706
699
  const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
707
700
  const resolvedItem = __spreadValues({}, item);
708
701
  const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
@@ -730,11 +723,11 @@ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], f
730
723
  let itemWithResolvedChildren = yield mapFields(
731
724
  resolvedItem,
732
725
  {
733
- slot: (_02) => __async(void 0, [_02], function* ({ value }) {
726
+ slot: (_02) => __async(null, [_02], function* ({ value }) {
734
727
  const content = value;
735
728
  return yield Promise.all(
736
729
  content.map(
737
- (childItem) => __async(void 0, null, function* () {
730
+ (childItem) => __async(null, null, function* () {
738
731
  return (yield resolveComponentData(
739
732
  childItem,
740
733
  config,
@@ -777,7 +770,7 @@ function resolveAllData(_0, _1) {
777
770
  return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
778
771
  var _a;
779
772
  const defaultedData = defaultData(data);
780
- const resolveNode = (_node) => __async(this, null, function* () {
773
+ const resolveNode = (_node) => __async(null, null, function* () {
781
774
  const node = toComponent(_node);
782
775
  onResolveStart == null ? void 0 : onResolveStart(node);
783
776
  const resolved = (yield resolveComponentData(
@@ -798,13 +791,13 @@ function resolveAllData(_0, _1) {
798
791
  onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
799
792
  return resolvedDeep;
800
793
  });
801
- const processContent = (content) => __async(this, null, function* () {
794
+ const processContent = (content) => __async(null, null, function* () {
802
795
  return Promise.all(content.map(resolveNode));
803
796
  });
804
- const processZones = () => __async(this, null, function* () {
797
+ const processZones = () => __async(null, null, function* () {
805
798
  var _a2;
806
799
  const zones = (_a2 = data.zones) != null ? _a2 : {};
807
- Object.entries(zones).forEach((_02) => __async(this, [_02], function* ([zoneKey, content]) {
800
+ Object.entries(zones).forEach((_02) => __async(null, [_02], function* ([zoneKey, content]) {
808
801
  zones[zoneKey] = yield Promise.all(content.map(resolveNode));
809
802
  }));
810
803
  return zones;
@@ -814,7 +807,7 @@ function resolveAllData(_0, _1) {
814
807
  content: yield processContent(defaultedData.content),
815
808
  zones: yield processZones()
816
809
  };
817
- Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
810
+ Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(null, null, function* () {
818
811
  const content = defaultedData.zones[zoneKey];
819
812
  dynamic.zones[zoneKey] = yield processContent(content);
820
813
  }), {});
@@ -965,6 +958,7 @@ export {
965
958
  useSlots,
966
959
  SlotRenderPure,
967
960
  SlotRender,
961
+ toComponent,
968
962
  migrate,
969
963
  transformProps,
970
964
  resolveAllData