@measured/puck-plugin-heading-analyzer 0.19.0-canary.e829bea0 → 0.19.0-canary.eda38b34
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 +10 -9
- package/dist/index.d.ts +10 -9
- package/dist/index.js +125 -50
- package/dist/index.mjs +125 -50
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
@@ -100,16 +100,17 @@ type ExternalField<Props extends {
|
|
100
100
|
filterFields?: Record<string, Field>;
|
101
101
|
initialFilters?: Record<string, any>;
|
102
102
|
};
|
103
|
-
type
|
103
|
+
type CustomFieldRender<Value extends any> = (props: {
|
104
|
+
field: CustomField<Value>;
|
105
|
+
name: string;
|
106
|
+
id: string;
|
107
|
+
value: Value;
|
108
|
+
onChange: (value: Value) => void;
|
109
|
+
readOnly?: boolean;
|
110
|
+
}) => ReactElement;
|
111
|
+
type CustomField<Value extends any> = BaseField & {
|
104
112
|
type: "custom";
|
105
|
-
render:
|
106
|
-
field: CustomField<Props>;
|
107
|
-
name: string;
|
108
|
-
id: string;
|
109
|
-
value: Props;
|
110
|
-
onChange: (value: Props) => void;
|
111
|
-
readOnly?: boolean;
|
112
|
-
}) => ReactElement;
|
113
|
+
render: CustomFieldRender<Value>;
|
113
114
|
};
|
114
115
|
type SlotField = BaseField & {
|
115
116
|
type: "slot";
|
package/dist/index.d.ts
CHANGED
@@ -100,16 +100,17 @@ type ExternalField<Props extends {
|
|
100
100
|
filterFields?: Record<string, Field>;
|
101
101
|
initialFilters?: Record<string, any>;
|
102
102
|
};
|
103
|
-
type
|
103
|
+
type CustomFieldRender<Value extends any> = (props: {
|
104
|
+
field: CustomField<Value>;
|
105
|
+
name: string;
|
106
|
+
id: string;
|
107
|
+
value: Value;
|
108
|
+
onChange: (value: Value) => void;
|
109
|
+
readOnly?: boolean;
|
110
|
+
}) => ReactElement;
|
111
|
+
type CustomField<Value extends any> = BaseField & {
|
104
112
|
type: "custom";
|
105
|
-
render:
|
106
|
-
field: CustomField<Props>;
|
107
|
-
name: string;
|
108
|
-
id: string;
|
109
|
-
value: Props;
|
110
|
-
onChange: (value: Props) => void;
|
111
|
-
readOnly?: boolean;
|
112
|
-
}) => ReactElement;
|
113
|
+
render: CustomFieldRender<Value>;
|
113
114
|
};
|
114
115
|
type SlotField = BaseField & {
|
115
116
|
type: "slot";
|
package/dist/index.js
CHANGED
@@ -371,7 +371,7 @@ init_react_import();
|
|
371
371
|
// ../core/reducer/actions/set.ts
|
372
372
|
init_react_import();
|
373
373
|
|
374
|
-
// ../core/lib/data/walk-
|
374
|
+
// ../core/lib/data/walk-app-state.ts
|
375
375
|
init_react_import();
|
376
376
|
|
377
377
|
// ../core/lib/data/for-each-slot.ts
|
@@ -460,8 +460,8 @@ var stripSlots = (data) => {
|
|
460
460
|
});
|
461
461
|
};
|
462
462
|
|
463
|
-
// ../core/lib/data/walk-
|
464
|
-
function
|
463
|
+
// ../core/lib/data/walk-app-state.ts
|
464
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
465
465
|
var _a;
|
466
466
|
let newZones = {};
|
467
467
|
const newZoneIndex = {};
|
@@ -594,7 +594,7 @@ var setAction = (state, action, appStore) => {
|
|
594
594
|
console.warn(
|
595
595
|
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
596
596
|
);
|
597
|
-
return
|
597
|
+
return walkAppState(newState, appStore.config);
|
598
598
|
}
|
599
599
|
return __spreadValues(__spreadValues({}, state), action.state(state));
|
600
600
|
};
|
@@ -680,18 +680,116 @@ var getIdsForParent = (zoneCompound, state) => {
|
|
680
680
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
681
681
|
};
|
682
682
|
|
683
|
+
// ../core/lib/data/populate-ids.ts
|
684
|
+
init_react_import();
|
685
|
+
|
686
|
+
// ../core/lib/data/walk-tree.ts
|
687
|
+
init_react_import();
|
688
|
+
|
689
|
+
// ../core/lib/data/map-slots.ts
|
690
|
+
init_react_import();
|
691
|
+
function mapSlotsAsync(_0, _1) {
|
692
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
693
|
+
const props = __spreadValues({}, item.props);
|
694
|
+
const propKeys = Object.keys(props);
|
695
|
+
for (let i = 0; i < propKeys.length; i++) {
|
696
|
+
const propKey = propKeys[i];
|
697
|
+
const itemType = "type" in item ? item.type : "root";
|
698
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
699
|
+
const content = props[propKey];
|
700
|
+
const mappedContent = recursive ? yield Promise.all(
|
701
|
+
content.map((item2) => __async(this, null, function* () {
|
702
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
703
|
+
}))
|
704
|
+
) : content;
|
705
|
+
props[propKey] = yield map(mappedContent, propKey);
|
706
|
+
}
|
707
|
+
}
|
708
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
709
|
+
});
|
710
|
+
}
|
711
|
+
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
712
|
+
var _a, _b;
|
713
|
+
const props = __spreadValues({}, item.props);
|
714
|
+
const propKeys = Object.keys(props);
|
715
|
+
for (let i = 0; i < propKeys.length; i++) {
|
716
|
+
const propKey = propKeys[i];
|
717
|
+
const itemType = "type" in item ? item.type : "root";
|
718
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
719
|
+
const content = props[propKey];
|
720
|
+
const mappedContent = content.map((item2) => {
|
721
|
+
return mapSlotsSync(item2, map, isSlot2);
|
722
|
+
});
|
723
|
+
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
724
|
+
}
|
725
|
+
}
|
726
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
727
|
+
}
|
728
|
+
|
729
|
+
// ../core/lib/data/walk-tree.ts
|
730
|
+
function walkTree(data, config, callbackFn) {
|
731
|
+
var _a, _b;
|
732
|
+
const isSlot2 = createIsSlotConfig(config);
|
733
|
+
const walkItem = (item) => {
|
734
|
+
return mapSlotsSync(
|
735
|
+
item,
|
736
|
+
(content, parentId, propName) => callbackFn(content, { parentId, propName }),
|
737
|
+
isSlot2
|
738
|
+
);
|
739
|
+
};
|
740
|
+
if ("props" in data) {
|
741
|
+
return walkItem(data);
|
742
|
+
}
|
743
|
+
const _data = data;
|
744
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
745
|
+
const mappedContent = _data.content.map(walkItem);
|
746
|
+
return {
|
747
|
+
root: walkItem(_data.root),
|
748
|
+
content: (_b = callbackFn(mappedContent, {
|
749
|
+
parentId: "root",
|
750
|
+
propName: "default-zone"
|
751
|
+
})) != null ? _b : mappedContent,
|
752
|
+
zones: Object.keys(zones).reduce(
|
753
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
754
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
755
|
+
}),
|
756
|
+
{}
|
757
|
+
)
|
758
|
+
};
|
759
|
+
}
|
760
|
+
|
761
|
+
// ../core/lib/data/populate-ids.ts
|
762
|
+
var populateIds = (data, config, override = false) => {
|
763
|
+
const id = generateId(data.type);
|
764
|
+
return walkTree(
|
765
|
+
__spreadProps(__spreadValues({}, data), {
|
766
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
|
767
|
+
}),
|
768
|
+
config,
|
769
|
+
(contents) => contents.map((item) => {
|
770
|
+
const id2 = generateId(item.type);
|
771
|
+
return __spreadProps(__spreadValues({}, item), {
|
772
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
773
|
+
});
|
774
|
+
})
|
775
|
+
);
|
776
|
+
};
|
777
|
+
|
683
778
|
// ../core/reducer/actions/insert.ts
|
684
779
|
function insertAction(state, action, appStore) {
|
685
780
|
const id = action.id || generateId(action.componentType);
|
686
|
-
const emptyComponentData =
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
781
|
+
const emptyComponentData = populateIds(
|
782
|
+
{
|
783
|
+
type: action.componentType,
|
784
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
785
|
+
id
|
786
|
+
})
|
787
|
+
},
|
788
|
+
appStore.config
|
789
|
+
);
|
692
790
|
const [parentId] = action.destinationZone.split(":");
|
693
791
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
694
|
-
return
|
792
|
+
return walkAppState(
|
695
793
|
state,
|
696
794
|
appStore.config,
|
697
795
|
(content, zoneCompound) => {
|
@@ -729,25 +827,26 @@ var replaceAction = (state, action, appStore) => {
|
|
729
827
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
730
828
|
);
|
731
829
|
}
|
732
|
-
|
830
|
+
const data = populateIds(action.data, appStore.config);
|
831
|
+
return walkAppState(
|
733
832
|
state,
|
734
833
|
appStore.config,
|
735
834
|
(content, zoneCompound) => {
|
736
835
|
const newContent = [...content];
|
737
836
|
if (zoneCompound === action.destinationZone) {
|
738
|
-
newContent[action.destinationIndex] =
|
837
|
+
newContent[action.destinationIndex] = data;
|
739
838
|
}
|
740
839
|
return newContent;
|
741
840
|
},
|
742
841
|
(childItem, path) => {
|
743
842
|
const pathIds = path.map((p) => p.split(":")[0]);
|
744
|
-
if (childItem.props.id ===
|
745
|
-
return
|
843
|
+
if (childItem.props.id === data.props.id) {
|
844
|
+
return data;
|
746
845
|
} else if (childItem.props.id === parentId) {
|
747
846
|
return childItem;
|
748
847
|
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
749
848
|
return childItem;
|
750
|
-
} else if (pathIds.indexOf(
|
849
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
751
850
|
return childItem;
|
752
851
|
}
|
753
852
|
return null;
|
@@ -758,7 +857,7 @@ var replaceAction = (state, action, appStore) => {
|
|
758
857
|
// ../core/reducer/actions/replace-root.ts
|
759
858
|
init_react_import();
|
760
859
|
var replaceRootAction = (state, action, appStore) => {
|
761
|
-
return
|
860
|
+
return walkAppState(
|
762
861
|
state,
|
763
862
|
appStore.config,
|
764
863
|
(content) => content,
|
@@ -797,7 +896,7 @@ function duplicateAction(state, action, appStore) {
|
|
797
896
|
id: generateId(item.type)
|
798
897
|
})
|
799
898
|
});
|
800
|
-
const modified =
|
899
|
+
const modified = walkAppState(
|
801
900
|
state,
|
802
901
|
appStore.config,
|
803
902
|
(content, zoneCompound) => {
|
@@ -862,7 +961,7 @@ var moveAction = (state, action, appStore) => {
|
|
862
961
|
if (!item) return state;
|
863
962
|
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
864
963
|
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
865
|
-
return
|
964
|
+
return walkAppState(
|
866
965
|
state,
|
867
966
|
appStore.config,
|
868
967
|
(content, zoneCompound) => {
|
@@ -920,7 +1019,7 @@ var removeAction = (state, action, appStore) => {
|
|
920
1019
|
},
|
921
1020
|
[item.props.id]
|
922
1021
|
);
|
923
|
-
const newState =
|
1022
|
+
const newState = walkAppState(
|
924
1023
|
state,
|
925
1024
|
appStore.config,
|
926
1025
|
(content, zoneCompound) => {
|
@@ -1011,14 +1110,14 @@ var setDataAction = (state, action, appStore) => {
|
|
1011
1110
|
console.warn(
|
1012
1111
|
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1013
1112
|
);
|
1014
|
-
return
|
1113
|
+
return walkAppState(
|
1015
1114
|
__spreadProps(__spreadValues({}, state), {
|
1016
1115
|
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1017
1116
|
}),
|
1018
1117
|
appStore.config
|
1019
1118
|
);
|
1020
1119
|
}
|
1021
|
-
return
|
1120
|
+
return walkAppState(
|
1022
1121
|
__spreadProps(__spreadValues({}, state), {
|
1023
1122
|
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1024
1123
|
}),
|
@@ -1358,7 +1457,7 @@ var import_react7 = require("react");
|
|
1358
1457
|
init_react_import();
|
1359
1458
|
var flattenData = (state, config) => {
|
1360
1459
|
const data = [];
|
1361
|
-
|
1460
|
+
walkAppState(
|
1362
1461
|
state,
|
1363
1462
|
config,
|
1364
1463
|
(content) => content,
|
@@ -1495,37 +1594,13 @@ var createFieldsSlice = (_set, _get) => {
|
|
1495
1594
|
return {
|
1496
1595
|
fields: {},
|
1497
1596
|
loading: false,
|
1498
|
-
lastResolvedData: {}
|
1597
|
+
lastResolvedData: {},
|
1598
|
+
id: void 0
|
1499
1599
|
};
|
1500
1600
|
};
|
1501
1601
|
|
1502
1602
|
// ../core/lib/resolve-component-data.ts
|
1503
1603
|
init_react_import();
|
1504
|
-
|
1505
|
-
// ../core/lib/data/map-slots.ts
|
1506
|
-
init_react_import();
|
1507
|
-
function mapSlotsAsync(_0, _1) {
|
1508
|
-
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
1509
|
-
const props = __spreadValues({}, item.props);
|
1510
|
-
const propKeys = Object.keys(props);
|
1511
|
-
for (let i = 0; i < propKeys.length; i++) {
|
1512
|
-
const propKey = propKeys[i];
|
1513
|
-
const itemType = "type" in item ? item.type : "root";
|
1514
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
1515
|
-
const content = props[propKey];
|
1516
|
-
const mappedContent = recursive ? yield Promise.all(
|
1517
|
-
content.map((item2) => __async(this, null, function* () {
|
1518
|
-
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
1519
|
-
}))
|
1520
|
-
) : content;
|
1521
|
-
props[propKey] = yield map(mappedContent, propKey);
|
1522
|
-
}
|
1523
|
-
}
|
1524
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1525
|
-
});
|
1526
|
-
}
|
1527
|
-
|
1528
|
-
// ../core/lib/resolve-component-data.ts
|
1529
1604
|
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1530
1605
|
var cache = { lastChange: {} };
|
1531
1606
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
@@ -1770,7 +1845,7 @@ var createAppStore = (initialAppStore) => create()(
|
|
1770
1845
|
}),
|
1771
1846
|
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1772
1847
|
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1773
|
-
|
1848
|
+
walkAppState(
|
1774
1849
|
state,
|
1775
1850
|
config,
|
1776
1851
|
(content) => content,
|
package/dist/index.mjs
CHANGED
@@ -359,7 +359,7 @@ init_react_import();
|
|
359
359
|
// ../core/reducer/actions/set.ts
|
360
360
|
init_react_import();
|
361
361
|
|
362
|
-
// ../core/lib/data/walk-
|
362
|
+
// ../core/lib/data/walk-app-state.ts
|
363
363
|
init_react_import();
|
364
364
|
|
365
365
|
// ../core/lib/data/for-each-slot.ts
|
@@ -448,8 +448,8 @@ var stripSlots = (data) => {
|
|
448
448
|
});
|
449
449
|
};
|
450
450
|
|
451
|
-
// ../core/lib/data/walk-
|
452
|
-
function
|
451
|
+
// ../core/lib/data/walk-app-state.ts
|
452
|
+
function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
|
453
453
|
var _a;
|
454
454
|
let newZones = {};
|
455
455
|
const newZoneIndex = {};
|
@@ -582,7 +582,7 @@ var setAction = (state, action, appStore) => {
|
|
582
582
|
console.warn(
|
583
583
|
"`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
584
584
|
);
|
585
|
-
return
|
585
|
+
return walkAppState(newState, appStore.config);
|
586
586
|
}
|
587
587
|
return __spreadValues(__spreadValues({}, state), action.state(state));
|
588
588
|
};
|
@@ -668,18 +668,116 @@ var getIdsForParent = (zoneCompound, state) => {
|
|
668
668
|
return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
|
669
669
|
};
|
670
670
|
|
671
|
+
// ../core/lib/data/populate-ids.ts
|
672
|
+
init_react_import();
|
673
|
+
|
674
|
+
// ../core/lib/data/walk-tree.ts
|
675
|
+
init_react_import();
|
676
|
+
|
677
|
+
// ../core/lib/data/map-slots.ts
|
678
|
+
init_react_import();
|
679
|
+
function mapSlotsAsync(_0, _1) {
|
680
|
+
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
681
|
+
const props = __spreadValues({}, item.props);
|
682
|
+
const propKeys = Object.keys(props);
|
683
|
+
for (let i = 0; i < propKeys.length; i++) {
|
684
|
+
const propKey = propKeys[i];
|
685
|
+
const itemType = "type" in item ? item.type : "root";
|
686
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
687
|
+
const content = props[propKey];
|
688
|
+
const mappedContent = recursive ? yield Promise.all(
|
689
|
+
content.map((item2) => __async(this, null, function* () {
|
690
|
+
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
691
|
+
}))
|
692
|
+
) : content;
|
693
|
+
props[propKey] = yield map(mappedContent, propKey);
|
694
|
+
}
|
695
|
+
}
|
696
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
697
|
+
});
|
698
|
+
}
|
699
|
+
function mapSlotsSync(item, map, isSlot2 = isSlot) {
|
700
|
+
var _a, _b;
|
701
|
+
const props = __spreadValues({}, item.props);
|
702
|
+
const propKeys = Object.keys(props);
|
703
|
+
for (let i = 0; i < propKeys.length; i++) {
|
704
|
+
const propKey = propKeys[i];
|
705
|
+
const itemType = "type" in item ? item.type : "root";
|
706
|
+
if (isSlot2(itemType, propKey, props[propKey])) {
|
707
|
+
const content = props[propKey];
|
708
|
+
const mappedContent = content.map((item2) => {
|
709
|
+
return mapSlotsSync(item2, map, isSlot2);
|
710
|
+
});
|
711
|
+
props[propKey] = (_b = map(mappedContent, (_a = props.id) != null ? _a : "root", propKey)) != null ? _b : mappedContent;
|
712
|
+
}
|
713
|
+
}
|
714
|
+
return __spreadProps(__spreadValues({}, item), { props });
|
715
|
+
}
|
716
|
+
|
717
|
+
// ../core/lib/data/walk-tree.ts
|
718
|
+
function walkTree(data, config, callbackFn) {
|
719
|
+
var _a, _b;
|
720
|
+
const isSlot2 = createIsSlotConfig(config);
|
721
|
+
const walkItem = (item) => {
|
722
|
+
return mapSlotsSync(
|
723
|
+
item,
|
724
|
+
(content, parentId, propName) => callbackFn(content, { parentId, propName }),
|
725
|
+
isSlot2
|
726
|
+
);
|
727
|
+
};
|
728
|
+
if ("props" in data) {
|
729
|
+
return walkItem(data);
|
730
|
+
}
|
731
|
+
const _data = data;
|
732
|
+
const zones = (_a = _data.zones) != null ? _a : {};
|
733
|
+
const mappedContent = _data.content.map(walkItem);
|
734
|
+
return {
|
735
|
+
root: walkItem(_data.root),
|
736
|
+
content: (_b = callbackFn(mappedContent, {
|
737
|
+
parentId: "root",
|
738
|
+
propName: "default-zone"
|
739
|
+
})) != null ? _b : mappedContent,
|
740
|
+
zones: Object.keys(zones).reduce(
|
741
|
+
(acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
|
742
|
+
[zoneCompound]: zones[zoneCompound].map(walkItem)
|
743
|
+
}),
|
744
|
+
{}
|
745
|
+
)
|
746
|
+
};
|
747
|
+
}
|
748
|
+
|
749
|
+
// ../core/lib/data/populate-ids.ts
|
750
|
+
var populateIds = (data, config, override = false) => {
|
751
|
+
const id = generateId(data.type);
|
752
|
+
return walkTree(
|
753
|
+
__spreadProps(__spreadValues({}, data), {
|
754
|
+
props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({ id }, data.props)
|
755
|
+
}),
|
756
|
+
config,
|
757
|
+
(contents) => contents.map((item) => {
|
758
|
+
const id2 = generateId(item.type);
|
759
|
+
return __spreadProps(__spreadValues({}, item), {
|
760
|
+
props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
|
761
|
+
});
|
762
|
+
})
|
763
|
+
);
|
764
|
+
};
|
765
|
+
|
671
766
|
// ../core/reducer/actions/insert.ts
|
672
767
|
function insertAction(state, action, appStore) {
|
673
768
|
const id = action.id || generateId(action.componentType);
|
674
|
-
const emptyComponentData =
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
769
|
+
const emptyComponentData = populateIds(
|
770
|
+
{
|
771
|
+
type: action.componentType,
|
772
|
+
props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
|
773
|
+
id
|
774
|
+
})
|
775
|
+
},
|
776
|
+
appStore.config
|
777
|
+
);
|
680
778
|
const [parentId] = action.destinationZone.split(":");
|
681
779
|
const idsInPath = getIdsForParent(action.destinationZone, state);
|
682
|
-
return
|
780
|
+
return walkAppState(
|
683
781
|
state,
|
684
782
|
appStore.config,
|
685
783
|
(content, zoneCompound) => {
|
@@ -717,25 +815,26 @@ var replaceAction = (state, action, appStore) => {
|
|
717
815
|
`Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
|
718
816
|
);
|
719
817
|
}
|
720
|
-
|
818
|
+
const data = populateIds(action.data, appStore.config);
|
819
|
+
return walkAppState(
|
721
820
|
state,
|
722
821
|
appStore.config,
|
723
822
|
(content, zoneCompound) => {
|
724
823
|
const newContent = [...content];
|
725
824
|
if (zoneCompound === action.destinationZone) {
|
726
|
-
newContent[action.destinationIndex] =
|
825
|
+
newContent[action.destinationIndex] = data;
|
727
826
|
}
|
728
827
|
return newContent;
|
729
828
|
},
|
730
829
|
(childItem, path) => {
|
731
830
|
const pathIds = path.map((p) => p.split(":")[0]);
|
732
|
-
if (childItem.props.id ===
|
733
|
-
return
|
831
|
+
if (childItem.props.id === data.props.id) {
|
832
|
+
return data;
|
734
833
|
} else if (childItem.props.id === parentId) {
|
735
834
|
return childItem;
|
736
835
|
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
|
737
836
|
return childItem;
|
738
|
-
} else if (pathIds.indexOf(
|
837
|
+
} else if (pathIds.indexOf(data.props.id) > -1) {
|
739
838
|
return childItem;
|
740
839
|
}
|
741
840
|
return null;
|
@@ -746,7 +845,7 @@ var replaceAction = (state, action, appStore) => {
|
|
746
845
|
// ../core/reducer/actions/replace-root.ts
|
747
846
|
init_react_import();
|
748
847
|
var replaceRootAction = (state, action, appStore) => {
|
749
|
-
return
|
848
|
+
return walkAppState(
|
750
849
|
state,
|
751
850
|
appStore.config,
|
752
851
|
(content) => content,
|
@@ -785,7 +884,7 @@ function duplicateAction(state, action, appStore) {
|
|
785
884
|
id: generateId(item.type)
|
786
885
|
})
|
787
886
|
});
|
788
|
-
const modified =
|
887
|
+
const modified = walkAppState(
|
789
888
|
state,
|
790
889
|
appStore.config,
|
791
890
|
(content, zoneCompound) => {
|
@@ -850,7 +949,7 @@ var moveAction = (state, action, appStore) => {
|
|
850
949
|
if (!item) return state;
|
851
950
|
const idsInSourcePath = getIdsForParent(action.sourceZone, state);
|
852
951
|
const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
|
853
|
-
return
|
952
|
+
return walkAppState(
|
854
953
|
state,
|
855
954
|
appStore.config,
|
856
955
|
(content, zoneCompound) => {
|
@@ -908,7 +1007,7 @@ var removeAction = (state, action, appStore) => {
|
|
908
1007
|
},
|
909
1008
|
[item.props.id]
|
910
1009
|
);
|
911
|
-
const newState =
|
1010
|
+
const newState = walkAppState(
|
912
1011
|
state,
|
913
1012
|
appStore.config,
|
914
1013
|
(content, zoneCompound) => {
|
@@ -999,14 +1098,14 @@ var setDataAction = (state, action, appStore) => {
|
|
999
1098
|
console.warn(
|
1000
1099
|
"`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
|
1001
1100
|
);
|
1002
|
-
return
|
1101
|
+
return walkAppState(
|
1003
1102
|
__spreadProps(__spreadValues({}, state), {
|
1004
1103
|
data: __spreadValues(__spreadValues({}, state.data), action.data)
|
1005
1104
|
}),
|
1006
1105
|
appStore.config
|
1007
1106
|
);
|
1008
1107
|
}
|
1009
|
-
return
|
1108
|
+
return walkAppState(
|
1010
1109
|
__spreadProps(__spreadValues({}, state), {
|
1011
1110
|
data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
|
1012
1111
|
}),
|
@@ -1346,7 +1445,7 @@ import { useEffect as useEffect3 } from "react";
|
|
1346
1445
|
init_react_import();
|
1347
1446
|
var flattenData = (state, config) => {
|
1348
1447
|
const data = [];
|
1349
|
-
|
1448
|
+
walkAppState(
|
1350
1449
|
state,
|
1351
1450
|
config,
|
1352
1451
|
(content) => content,
|
@@ -1483,37 +1582,13 @@ var createFieldsSlice = (_set, _get) => {
|
|
1483
1582
|
return {
|
1484
1583
|
fields: {},
|
1485
1584
|
loading: false,
|
1486
|
-
lastResolvedData: {}
|
1585
|
+
lastResolvedData: {},
|
1586
|
+
id: void 0
|
1487
1587
|
};
|
1488
1588
|
};
|
1489
1589
|
|
1490
1590
|
// ../core/lib/resolve-component-data.ts
|
1491
1591
|
init_react_import();
|
1492
|
-
|
1493
|
-
// ../core/lib/data/map-slots.ts
|
1494
|
-
init_react_import();
|
1495
|
-
function mapSlotsAsync(_0, _1) {
|
1496
|
-
return __async(this, arguments, function* (item, map, recursive = true, isSlot2 = isSlot) {
|
1497
|
-
const props = __spreadValues({}, item.props);
|
1498
|
-
const propKeys = Object.keys(props);
|
1499
|
-
for (let i = 0; i < propKeys.length; i++) {
|
1500
|
-
const propKey = propKeys[i];
|
1501
|
-
const itemType = "type" in item ? item.type : "root";
|
1502
|
-
if (isSlot2(itemType, propKey, props[propKey])) {
|
1503
|
-
const content = props[propKey];
|
1504
|
-
const mappedContent = recursive ? yield Promise.all(
|
1505
|
-
content.map((item2) => __async(this, null, function* () {
|
1506
|
-
return yield mapSlotsAsync(item2, map, recursive, isSlot2);
|
1507
|
-
}))
|
1508
|
-
) : content;
|
1509
|
-
props[propKey] = yield map(mappedContent, propKey);
|
1510
|
-
}
|
1511
|
-
}
|
1512
|
-
return __spreadProps(__spreadValues({}, item), { props });
|
1513
|
-
});
|
1514
|
-
}
|
1515
|
-
|
1516
|
-
// ../core/lib/resolve-component-data.ts
|
1517
1592
|
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
1518
1593
|
var cache = { lastChange: {} };
|
1519
1594
|
var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
|
@@ -1758,7 +1833,7 @@ var createAppStore = (initialAppStore) => create()(
|
|
1758
1833
|
}),
|
1759
1834
|
resolveAndCommitData: () => __async(void 0, null, function* () {
|
1760
1835
|
const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
|
1761
|
-
|
1836
|
+
walkAppState(
|
1762
1837
|
state,
|
1763
1838
|
config,
|
1764
1839
|
(content) => content,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@measured/puck-plugin-heading-analyzer",
|
3
|
-
"version": "0.19.0-canary.
|
3
|
+
"version": "0.19.0-canary.eda38b34",
|
4
4
|
"author": "Chris Villa <chris@puckeditor.com>",
|
5
5
|
"repository": "measuredco/puck",
|
6
6
|
"bugs": "https://github.com/measuredco/puck/issues",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
"dist"
|
26
26
|
],
|
27
27
|
"devDependencies": {
|
28
|
-
"@measured/puck": "^0.19.0-canary.
|
28
|
+
"@measured/puck": "^0.19.0-canary.eda38b34",
|
29
29
|
"@types/react": "^19.0.1",
|
30
30
|
"@types/react-dom": "^19.0.2",
|
31
31
|
"eslint": "^7.32.0",
|