@netlisian/softconfig 0.1.3 → 0.1.4
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/puck/index.d.mts +16 -3
- package/dist/puck/index.d.ts +16 -3
- package/dist/puck/index.js +221 -145
- package/dist/puck/index.mjs +236 -160
- package/package.json +2 -1
package/dist/puck/index.mjs
CHANGED
|
@@ -18,18 +18,6 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
return a;
|
|
19
19
|
};
|
|
20
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
-
var __objRest = (source, exclude) => {
|
|
22
|
-
var target = {};
|
|
23
|
-
for (var prop in source)
|
|
24
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
-
target[prop] = source[prop];
|
|
26
|
-
if (source != null && __getOwnPropSymbols)
|
|
27
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
-
target[prop] = source[prop];
|
|
30
|
-
}
|
|
31
|
-
return target;
|
|
32
|
-
};
|
|
33
21
|
var __async = (__this, __arguments, generator) => {
|
|
34
22
|
return new Promise((resolve, reject) => {
|
|
35
23
|
var fulfilled = (value) => {
|
|
@@ -308,7 +296,7 @@ var updateVersion = (version, increment) => {
|
|
|
308
296
|
return `${major}.${minor}.${patch}`;
|
|
309
297
|
};
|
|
310
298
|
var builderRootConfig = (config, overrides, editingComponent, showVersionFields = true) => ({
|
|
311
|
-
fields: {
|
|
299
|
+
fields: __spreadValues({
|
|
312
300
|
_name: overrides.name || {
|
|
313
301
|
type: "text",
|
|
314
302
|
label: "Soft Component Name"
|
|
@@ -358,7 +346,7 @@ var builderRootConfig = (config, overrides, editingComponent, showVersionFields
|
|
|
358
346
|
}
|
|
359
347
|
}
|
|
360
348
|
}
|
|
361
|
-
},
|
|
349
|
+
}, overrides.additionalRootFields || {}),
|
|
362
350
|
resolveFields({ props: data }, { fields, changed }) {
|
|
363
351
|
var _a, _b;
|
|
364
352
|
if (!(data == null ? void 0 : data._fields) || changed._fields || changed._fieldSettings)
|
|
@@ -400,14 +388,14 @@ var builderRootConfig = (config, overrides, editingComponent, showVersionFields
|
|
|
400
388
|
return fields;
|
|
401
389
|
},
|
|
402
390
|
resolveData: (props, params) => {
|
|
403
|
-
if (overrides.
|
|
404
|
-
overrides.
|
|
405
|
-
|
|
391
|
+
if (overrides.resolveRootData) {
|
|
392
|
+
return overrides.resolveRootData(props, params, { editingComponent });
|
|
393
|
+
}
|
|
394
|
+
let result = {
|
|
406
395
|
props,
|
|
407
|
-
readOnly:
|
|
408
|
-
_name: true
|
|
409
|
-
} : void 0
|
|
396
|
+
readOnly: void 0
|
|
410
397
|
};
|
|
398
|
+
return result;
|
|
411
399
|
},
|
|
412
400
|
render: (props) => {
|
|
413
401
|
const fieldSettings = props == null ? void 0 : props._fieldSettings;
|
|
@@ -913,6 +901,21 @@ var softComponentFromAppState = (appState, configComponents, editedItem, metadat
|
|
|
913
901
|
const rootProps = ((_a = appState.data.root) == null ? void 0 : _a.props) || {};
|
|
914
902
|
const fields = rootProps._fields || [];
|
|
915
903
|
const field_settings = rootProps._fieldSettings || {};
|
|
904
|
+
const builtInRootProps = /* @__PURE__ */ new Set([
|
|
905
|
+
"_name",
|
|
906
|
+
"_category",
|
|
907
|
+
"_version",
|
|
908
|
+
"_versions",
|
|
909
|
+
"_fields",
|
|
910
|
+
"_fieldSettings"
|
|
911
|
+
]);
|
|
912
|
+
const customRootProps = Object.keys(rootProps).filter((key) => key.startsWith("_") && !builtInRootProps.has(key)).reduce(
|
|
913
|
+
(acc, key) => {
|
|
914
|
+
acc[key] = rootProps[key];
|
|
915
|
+
return acc;
|
|
916
|
+
},
|
|
917
|
+
{}
|
|
918
|
+
);
|
|
916
919
|
const slots = {};
|
|
917
920
|
const components = getSubComponents(
|
|
918
921
|
[editedItem],
|
|
@@ -937,6 +940,7 @@ var softComponentFromAppState = (appState, configComponents, editedItem, metadat
|
|
|
937
940
|
}, {})),
|
|
938
941
|
fieldSettings: field_settings,
|
|
939
942
|
defaultProps,
|
|
943
|
+
rootProps: customRootProps,
|
|
940
944
|
components,
|
|
941
945
|
slots
|
|
942
946
|
},
|
|
@@ -948,6 +952,24 @@ var softComponentFromAppState = (appState, configComponents, editedItem, metadat
|
|
|
948
952
|
import { v4 as uuidv4 } from "uuid";
|
|
949
953
|
var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
|
|
950
954
|
|
|
955
|
+
// src/puck/lib/component-key.ts
|
|
956
|
+
var defaultToCamelCase = (value) => {
|
|
957
|
+
const tokens = value.trim().replace(/[^a-zA-Z0-9\s_-]/g, " ").split(/[\s_-]+/).filter(Boolean);
|
|
958
|
+
if (tokens.length === 0) return "";
|
|
959
|
+
const [first, ...rest] = tokens;
|
|
960
|
+
return `${first.toLowerCase()}${rest.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase()).join("")}`;
|
|
961
|
+
};
|
|
962
|
+
var createComponentKeyFromName = (displayName, overrides, context) => {
|
|
963
|
+
const key = overrides.componentNameToKey ? overrides.componentNameToKey(displayName, context) : defaultToCamelCase(displayName);
|
|
964
|
+
return key.trim();
|
|
965
|
+
};
|
|
966
|
+
var getComponentNameFromKey = (key, overrides) => {
|
|
967
|
+
if (overrides.componentKeyToName) {
|
|
968
|
+
return overrides.componentKeyToName(key);
|
|
969
|
+
}
|
|
970
|
+
return key;
|
|
971
|
+
};
|
|
972
|
+
|
|
951
973
|
// src/puck/lib/soft-component-to-appstate.ts
|
|
952
974
|
var puckFieldsToSoftFields = (fields, slots) => {
|
|
953
975
|
const softFields = [];
|
|
@@ -1066,7 +1088,7 @@ var reconstructComponents = (subComponents, componentConfigs, softComponentProps
|
|
|
1066
1088
|
return componentData;
|
|
1067
1089
|
});
|
|
1068
1090
|
};
|
|
1069
|
-
var softComponentToAppState = (softComponent, componentName, version, versions, componentProps, componentConfigs, displayName, category) => {
|
|
1091
|
+
var softComponentToAppState = (softComponent, componentName, version, versions, componentProps, componentConfigs, overrides, displayName, category) => {
|
|
1070
1092
|
const slots = new Set(Object.keys(softComponent.slots));
|
|
1071
1093
|
const { fields, fieldSettings } = puckFieldsToSoftFields(
|
|
1072
1094
|
softComponent.fields,
|
|
@@ -1077,14 +1099,17 @@ var softComponentToAppState = (softComponent, componentName, version, versions,
|
|
|
1077
1099
|
fieldSettings[key].defaultValue = value;
|
|
1078
1100
|
}
|
|
1079
1101
|
});
|
|
1080
|
-
|
|
1081
|
-
_name: displayName || componentName,
|
|
1102
|
+
let rootProps = __spreadValues({
|
|
1103
|
+
_name: displayName || getComponentNameFromKey(componentName, overrides),
|
|
1082
1104
|
_category: category,
|
|
1083
1105
|
_version: version,
|
|
1084
1106
|
_versions: versions,
|
|
1085
1107
|
_fields: fields,
|
|
1086
1108
|
_fieldSettings: fieldSettings
|
|
1087
|
-
};
|
|
1109
|
+
}, softComponent.rootProps || {});
|
|
1110
|
+
if (overrides.onRemodel) {
|
|
1111
|
+
rootProps = __spreadValues(__spreadValues({}, rootProps), overrides.onRemodel(componentName));
|
|
1112
|
+
}
|
|
1088
1113
|
const content = reconstructComponents(
|
|
1089
1114
|
softComponent.components,
|
|
1090
1115
|
componentConfigs,
|
|
@@ -1106,114 +1131,111 @@ var rootZone = "default-zone";
|
|
|
1106
1131
|
var rootDroppableId = `${rootAreaId}:${rootZone}`;
|
|
1107
1132
|
|
|
1108
1133
|
// src/puck/components/soft-render/index.tsx
|
|
1109
|
-
import { useMemo,
|
|
1110
|
-
import
|
|
1111
|
-
import equal from "fast-deep-equal";
|
|
1134
|
+
import React2, { useMemo, memo } from "react";
|
|
1135
|
+
import equal from "react-fast-compare";
|
|
1112
1136
|
import { Fragment as Fragment2, jsx as jsx5 } from "react/jsx-runtime";
|
|
1113
|
-
function
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
if (!
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
}
|
|
1128
|
-
const subComponentRootProps = useMemo(
|
|
1129
|
-
() => Object.entries(softComponentFields || {}).filter(([_, field]) => field.type !== "slot").reduce(
|
|
1130
|
-
(acc, [fieldKey]) => {
|
|
1131
|
-
acc[fieldKey] = props[fieldKey];
|
|
1132
|
-
return acc;
|
|
1133
|
-
},
|
|
1134
|
-
{}
|
|
1135
|
-
),
|
|
1136
|
-
[softComponentFields, props]
|
|
1137
|
+
function isPlainObject(val) {
|
|
1138
|
+
if (typeof val !== "object" || val === null) return false;
|
|
1139
|
+
if (React2.isValidElement(val)) return false;
|
|
1140
|
+
if ("$$typeof" in val) return false;
|
|
1141
|
+
const proto = Object.getPrototypeOf(val);
|
|
1142
|
+
return proto === Object.prototype || proto === null;
|
|
1143
|
+
}
|
|
1144
|
+
function cloneData(value) {
|
|
1145
|
+
if (value === null || value === void 0) return value;
|
|
1146
|
+
if (typeof value === "function") return value;
|
|
1147
|
+
if (Array.isArray(value)) return value.map(cloneData);
|
|
1148
|
+
if (!isPlainObject(value)) return value;
|
|
1149
|
+
return Object.fromEntries(
|
|
1150
|
+
Object.entries(value).map(([k, v]) => [k, cloneData(v)])
|
|
1137
1151
|
);
|
|
1138
|
-
|
|
1139
|
-
|
|
1152
|
+
}
|
|
1153
|
+
var SubComponentRenderer = memo(
|
|
1154
|
+
({
|
|
1155
|
+
subComponent,
|
|
1156
|
+
softComponentFields,
|
|
1157
|
+
softComponentFieldSettings,
|
|
1158
|
+
configComponents,
|
|
1159
|
+
props,
|
|
1160
|
+
depth,
|
|
1161
|
+
index
|
|
1162
|
+
}) => {
|
|
1163
|
+
const { id, puck, editMode } = props;
|
|
1140
1164
|
const componentConfig = configComponents[subComponent == null ? void 0 : subComponent.type];
|
|
1141
|
-
if (!componentConfig) return null;
|
|
1142
|
-
const resolvedProps = subComponent.fixedProps || {};
|
|
1143
1165
|
const stableId = useMemo(
|
|
1144
|
-
() => depth === 0 ? id : `${subComponent.type}-${id}-d${depth}
|
|
1145
|
-
[id, depth, subComponent.type]
|
|
1166
|
+
() => depth === 0 ? id : `${subComponent.type}-${id}-d${depth}-i${index}`,
|
|
1167
|
+
[id, depth, subComponent.type, index]
|
|
1146
1168
|
);
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1155
|
-
const
|
|
1156
|
-
|
|
1157
|
-
f
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1169
|
+
const finalProps = useMemo(() => {
|
|
1170
|
+
var _a;
|
|
1171
|
+
if (!componentConfig) return {};
|
|
1172
|
+
const clonedProps = cloneData(subComponent.fixedProps || {});
|
|
1173
|
+
if ((_a = subComponent.map) == null ? void 0 : _a.length) {
|
|
1174
|
+
subComponent.map.forEach((mapItem) => {
|
|
1175
|
+
const { from, to, transform } = mapItem || {};
|
|
1176
|
+
const fromPaths = Array.isArray(from) ? from : from ? [from] : [];
|
|
1177
|
+
const toPaths = Array.isArray(to) ? to : to ? [to] : [];
|
|
1178
|
+
const inputValues = fromPaths.map((f) => {
|
|
1179
|
+
const propValue = getFieldSettingsByPath(props, f);
|
|
1180
|
+
if (propValue !== void 0) return propValue;
|
|
1181
|
+
const setting = getFieldSettingsByPath(softComponentFieldSettings || {}, f);
|
|
1182
|
+
if (setting && Object.prototype.hasOwnProperty.call(setting, "defaultValue")) {
|
|
1183
|
+
return setting.defaultValue;
|
|
1184
|
+
}
|
|
1185
|
+
return propValue;
|
|
1186
|
+
});
|
|
1187
|
+
const result = transform ? transform(inputValues, props) : inputValues[0];
|
|
1188
|
+
if (Array.isArray(result)) {
|
|
1189
|
+
result.forEach(
|
|
1190
|
+
(val, i) => toPaths[i] && setPropertyByPath(clonedProps, toPaths[i], val)
|
|
1191
|
+
);
|
|
1192
|
+
} else if (toPaths[0]) {
|
|
1193
|
+
setPropertyByPath(clonedProps, toPaths[0], result);
|
|
1161
1194
|
}
|
|
1162
|
-
return propValue;
|
|
1163
1195
|
});
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
}
|
|
1171
|
-
if (Array.isArray(result)) {
|
|
1172
|
-
result.forEach(
|
|
1173
|
-
(val, i) => toPaths[i] && setPropertyByPath(resolvedProps, toPaths[i], val)
|
|
1174
|
-
);
|
|
1175
|
-
} else if (toPaths[0]) {
|
|
1176
|
-
setPropertyByPath(resolvedProps, toPaths[0], result);
|
|
1177
|
-
}
|
|
1178
|
-
});
|
|
1179
|
-
}
|
|
1180
|
-
Object.entries(componentConfig.fields || {}).forEach(
|
|
1181
|
-
([slotKey, field]) => {
|
|
1182
|
-
var _a3, _b;
|
|
1183
|
-
if (field.type === "slot") {
|
|
1184
|
-
const enabledSlot = (_a3 = subComponent == null ? void 0 : subComponent.enabledSlots) == null ? void 0 : _a3.find(
|
|
1196
|
+
}
|
|
1197
|
+
Object.entries(componentConfig.fields || {}).forEach(
|
|
1198
|
+
([slotKey, field]) => {
|
|
1199
|
+
var _a2, _b, _c;
|
|
1200
|
+
if (field.type !== "slot") return;
|
|
1201
|
+
const enabledSlot = (_a2 = subComponent == null ? void 0 : subComponent.enabledSlots) == null ? void 0 : _a2.find(
|
|
1185
1202
|
(s) => s.slot === slotKey
|
|
1186
1203
|
);
|
|
1187
1204
|
if (enabledSlot) {
|
|
1188
1205
|
const slotName = enabledSlot.name || `${(_b = subComponent.fixedProps) == null ? void 0 : _b.id}-${slotKey}`;
|
|
1189
|
-
|
|
1190
|
-
() => rest[slotName] || (() => null),
|
|
1191
|
-
[slotName, rest[slotName]]
|
|
1192
|
-
);
|
|
1206
|
+
clonedProps[slotKey] = (_c = props[slotName]) != null ? _c : (() => null);
|
|
1193
1207
|
} else {
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
};
|
|
1212
|
-
}, [slotKey, subComponentRootProps]);
|
|
1208
|
+
clonedProps[slotKey] = ({
|
|
1209
|
+
className,
|
|
1210
|
+
style
|
|
1211
|
+
}) => {
|
|
1212
|
+
var _a3, _b2;
|
|
1213
|
+
return /* @__PURE__ */ jsx5("div", { className, style, children: /* @__PURE__ */ jsx5(
|
|
1214
|
+
SoftRender,
|
|
1215
|
+
{
|
|
1216
|
+
softComponentFields,
|
|
1217
|
+
softComponentFieldSettings,
|
|
1218
|
+
softSubComponent: (_b2 = (_a3 = subComponent == null ? void 0 : subComponent.components) == null ? void 0 : _a3[slotKey]) != null ? _b2 : [],
|
|
1219
|
+
configComponents,
|
|
1220
|
+
props,
|
|
1221
|
+
depth: depth + 1
|
|
1222
|
+
}
|
|
1223
|
+
) });
|
|
1224
|
+
};
|
|
1213
1225
|
}
|
|
1214
1226
|
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1227
|
+
);
|
|
1228
|
+
return clonedProps;
|
|
1229
|
+
}, [
|
|
1230
|
+
componentConfig,
|
|
1231
|
+
subComponent,
|
|
1232
|
+
props,
|
|
1233
|
+
softComponentFields,
|
|
1234
|
+
softComponentFieldSettings,
|
|
1235
|
+
configComponents,
|
|
1236
|
+
depth
|
|
1237
|
+
]);
|
|
1238
|
+
if (!componentConfig) return null;
|
|
1217
1239
|
const ComponentRender = componentConfig.render;
|
|
1218
1240
|
return /* @__PURE__ */ jsx5(ErrorBoundary, { children: /* @__PURE__ */ jsx5(
|
|
1219
1241
|
ComponentRender,
|
|
@@ -1221,10 +1243,53 @@ function SoftRender({
|
|
|
1221
1243
|
id: stableId,
|
|
1222
1244
|
editMode,
|
|
1223
1245
|
puck
|
|
1224
|
-
},
|
|
1225
|
-
) }
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1246
|
+
}, finalProps)
|
|
1247
|
+
) });
|
|
1248
|
+
},
|
|
1249
|
+
// Custom comparator for SubComponentRenderer.
|
|
1250
|
+
//
|
|
1251
|
+
// Uses deep equality on subComponent (it may be a new reference even when
|
|
1252
|
+
// semantically unchanged if the parent SoftRender array is reconstructed)
|
|
1253
|
+
// and on props (the primary driver of field-mapping changes).
|
|
1254
|
+
// configComponents and softComponentFields are treated as stable config
|
|
1255
|
+
// references — reference equality is intentional and fast here.
|
|
1256
|
+
(prev, next) => prev.depth === next.depth && prev.index === next.index && prev.configComponents === next.configComponents && prev.softComponentFields === next.softComponentFields && equal(prev.props, next.props) && equal(prev.subComponent, next.subComponent) && equal(prev.softComponentFieldSettings, next.softComponentFieldSettings)
|
|
1257
|
+
);
|
|
1258
|
+
SubComponentRenderer.displayName = "SubComponentRenderer";
|
|
1259
|
+
var SoftRender = memo(
|
|
1260
|
+
({
|
|
1261
|
+
softComponentFields,
|
|
1262
|
+
softComponentFieldSettings,
|
|
1263
|
+
softSubComponent,
|
|
1264
|
+
configComponents,
|
|
1265
|
+
props,
|
|
1266
|
+
depth = 0
|
|
1267
|
+
}) => {
|
|
1268
|
+
if (!(softSubComponent == null ? void 0 : softSubComponent.length)) return null;
|
|
1269
|
+
return /* @__PURE__ */ jsx5(Fragment2, { children: softSubComponent.map((subComponent, index) => {
|
|
1270
|
+
var _a;
|
|
1271
|
+
return /* @__PURE__ */ jsx5(
|
|
1272
|
+
SubComponentRenderer,
|
|
1273
|
+
{
|
|
1274
|
+
subComponent,
|
|
1275
|
+
softComponentFields,
|
|
1276
|
+
softComponentFieldSettings: softComponentFieldSettings || {},
|
|
1277
|
+
configComponents,
|
|
1278
|
+
props,
|
|
1279
|
+
depth,
|
|
1280
|
+
index
|
|
1281
|
+
},
|
|
1282
|
+
`${(_a = subComponent == null ? void 0 : subComponent.type) != null ? _a : "comp"}-${index}-${depth}`
|
|
1283
|
+
);
|
|
1284
|
+
}) });
|
|
1285
|
+
},
|
|
1286
|
+
// Covers all five props — not just `props` and `softSubComponent`.
|
|
1287
|
+
// configComponents / softComponentFields: reference equality (stable config).
|
|
1288
|
+
// softComponentFieldSettings: deep equality (may carry dynamic defaults).
|
|
1289
|
+
// props / softSubComponent: deep equality (primary render drivers).
|
|
1290
|
+
(prev, next) => prev.configComponents === next.configComponents && prev.softComponentFields === next.softComponentFields && equal(prev.props, next.props) && equal(prev.softSubComponent, next.softSubComponent) && equal(prev.softComponentFieldSettings, next.softComponentFieldSettings)
|
|
1291
|
+
);
|
|
1292
|
+
SoftRender.displayName = "SoftRender";
|
|
1228
1293
|
|
|
1229
1294
|
// src/puck/lib/create-versioned-component-config.tsx
|
|
1230
1295
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
@@ -1378,18 +1443,6 @@ function demolishSoftComponent(componentName, data, config, softComponents) {
|
|
|
1378
1443
|
};
|
|
1379
1444
|
}
|
|
1380
1445
|
|
|
1381
|
-
// src/puck/lib/component-key.ts
|
|
1382
|
-
var defaultToCamelCase = (value) => {
|
|
1383
|
-
const tokens = value.trim().replace(/[^a-zA-Z0-9\s_-]/g, " ").split(/[\s_-]+/).filter(Boolean);
|
|
1384
|
-
if (tokens.length === 0) return "";
|
|
1385
|
-
const [first, ...rest] = tokens;
|
|
1386
|
-
return `${first.toLowerCase()}${rest.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase()).join("")}`;
|
|
1387
|
-
};
|
|
1388
|
-
var createComponentKeyFromName = (displayName, overrides, context) => {
|
|
1389
|
-
const key = overrides.componentNameToKey ? overrides.componentNameToKey(displayName, context) : defaultToCamelCase(displayName);
|
|
1390
|
-
return key.trim();
|
|
1391
|
-
};
|
|
1392
|
-
|
|
1393
1446
|
// src/puck/store/slices/builder.tsx
|
|
1394
1447
|
var createBuildersSlice = (set, get, initialConfig) => ({
|
|
1395
1448
|
build: (history, selectedItem, itemSelector, puckDispatch, name) => {
|
|
@@ -1489,6 +1542,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1489
1542
|
versions,
|
|
1490
1543
|
selectedItem.props,
|
|
1491
1544
|
get().softConfig.components,
|
|
1545
|
+
get().overrides,
|
|
1492
1546
|
(softComponentMeta == null ? void 0 : softComponentMeta.name) || softComponentName,
|
|
1493
1547
|
softComponentMeta == null ? void 0 : softComponentMeta.category
|
|
1494
1548
|
);
|
|
@@ -1541,6 +1595,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1541
1595
|
zone: itemSelector.zone || rootDroppableId
|
|
1542
1596
|
},
|
|
1543
1597
|
editingComponentId: selectedItem.props.id,
|
|
1598
|
+
editingComponent: softComponentName,
|
|
1544
1599
|
editableComponentIds: editableIds,
|
|
1545
1600
|
state: "remodeling"
|
|
1546
1601
|
}));
|
|
@@ -1557,7 +1612,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1557
1612
|
);
|
|
1558
1613
|
},
|
|
1559
1614
|
complete: (appState, setHistories, getItemBySelector) => {
|
|
1560
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1615
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1561
1616
|
if (get().state === "ready") {
|
|
1562
1617
|
throw new Error("Not building or remodeling a component.");
|
|
1563
1618
|
}
|
|
@@ -1576,10 +1631,11 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1576
1631
|
throw new Error("Cannot find item being edited");
|
|
1577
1632
|
}
|
|
1578
1633
|
const rootCategory = (_e = (_d = appState.data.root) == null ? void 0 : _d.props) == null ? void 0 : _e._category;
|
|
1579
|
-
const
|
|
1634
|
+
const rootProps = (_f = appState.data.root) == null ? void 0 : _f.props;
|
|
1635
|
+
const componentName = createComponentKeyFromName(displayName, get().overrides, __spreadProps(__spreadValues({}, rootProps || {}), {
|
|
1580
1636
|
existingKeys: Object.keys(get().softComponents),
|
|
1581
1637
|
state: get().state
|
|
1582
|
-
});
|
|
1638
|
+
}));
|
|
1583
1639
|
if (!componentName) {
|
|
1584
1640
|
throw new Error("Failed to generate component key from name.");
|
|
1585
1641
|
}
|
|
@@ -1638,6 +1694,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1638
1694
|
storedConfig: void 0,
|
|
1639
1695
|
state: "inspecting",
|
|
1640
1696
|
originalHistory: [],
|
|
1697
|
+
editingComponent: null,
|
|
1641
1698
|
editingComponentId: null,
|
|
1642
1699
|
editableComponentIds: /* @__PURE__ */ new Set()
|
|
1643
1700
|
});
|
|
@@ -1645,7 +1702,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1645
1702
|
if (!version) {
|
|
1646
1703
|
throw new Error("Failed to resolve completed component version.");
|
|
1647
1704
|
}
|
|
1648
|
-
const completedSoftComponent = (
|
|
1705
|
+
const completedSoftComponent = (_g = get().softComponents[componentName]) == null ? void 0 : _g.versions[version];
|
|
1649
1706
|
if (!completedSoftComponent) {
|
|
1650
1707
|
throw new Error(
|
|
1651
1708
|
`Completed soft component "${componentName}" version "${version}" not found.`
|
|
@@ -1697,6 +1754,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1697
1754
|
itemSelector: null,
|
|
1698
1755
|
originalItem: null,
|
|
1699
1756
|
state: "ready",
|
|
1757
|
+
editingComponent: null,
|
|
1700
1758
|
editingComponentId: null,
|
|
1701
1759
|
editableComponentIds: /* @__PURE__ */ new Set()
|
|
1702
1760
|
}));
|
|
@@ -1789,6 +1847,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
|
|
|
1789
1847
|
versions,
|
|
1790
1848
|
currentProps,
|
|
1791
1849
|
get().softConfig.components,
|
|
1850
|
+
get().overrides,
|
|
1792
1851
|
(softComponentMeta == null ? void 0 : softComponentMeta.name) || componentName,
|
|
1793
1852
|
softComponentMeta == null ? void 0 : softComponentMeta.category
|
|
1794
1853
|
);
|
|
@@ -2093,6 +2152,7 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2093
2152
|
onActions,
|
|
2094
2153
|
iframeDocRef,
|
|
2095
2154
|
showVersionFields,
|
|
2155
|
+
editingComponent: null,
|
|
2096
2156
|
setShowVersionFields: (show) => set({ showVersionFields: show }),
|
|
2097
2157
|
getIframeDoc: () => iframeDocRef.current,
|
|
2098
2158
|
setIframeDoc: (doc) => {
|
|
@@ -2386,7 +2446,7 @@ var createSoftConfigStore = (hardConfig = {
|
|
|
2386
2446
|
};
|
|
2387
2447
|
|
|
2388
2448
|
// src/puck/context/storeProvider.tsx
|
|
2389
|
-
import { useEffect as useEffect2, useMemo as useMemo2, useState
|
|
2449
|
+
import { useEffect as useEffect2, useMemo as useMemo2, useState } from "react";
|
|
2390
2450
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
2391
2451
|
var SoftConfigProvider = ({
|
|
2392
2452
|
children,
|
|
@@ -2401,10 +2461,10 @@ var SoftConfigProvider = ({
|
|
|
2401
2461
|
() => createSoftConfigStore(hardConfig, softComponents, overrides, onActions, useVersioning),
|
|
2402
2462
|
[hardConfig, softComponents, overrides, onActions, useVersioning]
|
|
2403
2463
|
);
|
|
2404
|
-
const [softConfig, setSoftConfig] =
|
|
2464
|
+
const [softConfig, setSoftConfig] = useState(
|
|
2405
2465
|
() => store.getState().softConfig
|
|
2406
2466
|
);
|
|
2407
|
-
const [internalSoftComponents, setSoftComponents] =
|
|
2467
|
+
const [internalSoftComponents, setSoftComponents] = useState(
|
|
2408
2468
|
() => store.getState().softComponents
|
|
2409
2469
|
);
|
|
2410
2470
|
const storeSetIframeDoc = useMemo2(
|
|
@@ -2413,14 +2473,19 @@ var SoftConfigProvider = ({
|
|
|
2413
2473
|
);
|
|
2414
2474
|
const validateAction = useMemo2(
|
|
2415
2475
|
() => (action) => {
|
|
2476
|
+
var _a;
|
|
2416
2477
|
const currentState = store.getState();
|
|
2417
2478
|
if (currentState.state === "ready") {
|
|
2418
2479
|
return true;
|
|
2419
2480
|
}
|
|
2420
2481
|
const editableIds = currentState.editableComponentIds;
|
|
2421
2482
|
if (action.type === "replace") {
|
|
2483
|
+
const parentId = (_a = action.destinationZone) == null ? void 0 : _a.split(":")[0];
|
|
2422
2484
|
if (action.data.props.id && editableIds.has(action.data.props.id)) {
|
|
2423
2485
|
return true;
|
|
2486
|
+
} else if (parentId && editableIds.has(parentId)) {
|
|
2487
|
+
currentState.addEditableComponentId(action.data.props.id);
|
|
2488
|
+
return true;
|
|
2424
2489
|
}
|
|
2425
2490
|
return false;
|
|
2426
2491
|
}
|
|
@@ -2633,7 +2698,7 @@ var useRemodel = () => {
|
|
|
2633
2698
|
|
|
2634
2699
|
// src/puck/actions/useComplete.tsx
|
|
2635
2700
|
import { createUsePuck as createUsePuck4 } from "@measured/puck";
|
|
2636
|
-
import { useState as
|
|
2701
|
+
import { useState as useState2, useCallback as useCallback2 } from "react";
|
|
2637
2702
|
var useCustomPuck4 = createUsePuck4();
|
|
2638
2703
|
var useComplete = () => {
|
|
2639
2704
|
const complete = useSoftConfig((s) => s.builder.complete);
|
|
@@ -2641,7 +2706,7 @@ var useComplete = () => {
|
|
|
2641
2706
|
const setHistories = useCustomPuck4((s) => s.history.setHistories);
|
|
2642
2707
|
const getItemBySelector = useCustomPuck4((s) => s.getItemBySelector);
|
|
2643
2708
|
const status = useSoftConfig((s) => s.state);
|
|
2644
|
-
const [newComponent, setNewComponent] =
|
|
2709
|
+
const [newComponent, setNewComponent] = useState2(null);
|
|
2645
2710
|
const { triggerAction } = useActionEvent();
|
|
2646
2711
|
const handleComplete = useCallback2(() => {
|
|
2647
2712
|
if (status === "ready") {
|
|
@@ -2989,7 +3054,7 @@ import { Fragment as Fragment4, jsx as jsx9, jsxs as jsxs3 } from "react/jsx-run
|
|
|
2989
3054
|
var getClassName3 = get_class_name_factory_default("ActionBar", ActionBar_module_default);
|
|
2990
3055
|
var usePuck2 = createUsePuck11();
|
|
2991
3056
|
var ActionBarOverride = (props) => {
|
|
2992
|
-
var _a;
|
|
3057
|
+
var _a, _b;
|
|
2993
3058
|
const { handleBuild } = useBuild("Custom Name");
|
|
2994
3059
|
const { handleRemodel } = useRemodel();
|
|
2995
3060
|
const { handleDecompose } = useDecompose();
|
|
@@ -2997,20 +3062,31 @@ var ActionBarOverride = (props) => {
|
|
|
2997
3062
|
const softComponents = useSoftConfig((s) => s.softComponents, shallow);
|
|
2998
3063
|
const editableIds = useSoftConfig((s) => s.editableComponentIds);
|
|
2999
3064
|
const selectedItem = usePuck2((s) => s.selectedItem);
|
|
3065
|
+
const rootProps = usePuck2((s) => s.appState.data.root.props);
|
|
3000
3066
|
const status = useSoftConfig((s) => s.state);
|
|
3067
|
+
const itemSelector = usePuck2((s) => s.appState.ui.itemSelector);
|
|
3001
3068
|
const softKeys = Object.keys(softComponents);
|
|
3002
|
-
const key = useMemo3(() =>
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3069
|
+
const key = useMemo3(() => {
|
|
3070
|
+
const selectedType = selectedItem == null ? void 0 : selectedItem.type;
|
|
3071
|
+
if (selectedType && softKeys.includes(selectedType)) {
|
|
3072
|
+
return selectedType;
|
|
3073
|
+
}
|
|
3074
|
+
return createComponentKeyFromName(props.label || "", overrides, __spreadProps(__spreadValues({}, rootProps || {}), {
|
|
3075
|
+
existingKeys: softKeys,
|
|
3076
|
+
state: status
|
|
3077
|
+
}));
|
|
3078
|
+
}, [
|
|
3006
3079
|
props.label,
|
|
3007
3080
|
overrides,
|
|
3081
|
+
selectedItem == null ? void 0 : selectedItem.type,
|
|
3008
3082
|
softKeys,
|
|
3009
|
-
status
|
|
3083
|
+
status,
|
|
3084
|
+
rootProps
|
|
3010
3085
|
]);
|
|
3011
3086
|
const isSoftComponent2 = softKeys.includes(key);
|
|
3012
3087
|
const selectedId = (_a = selectedItem == null ? void 0 : selectedItem.props) == null ? void 0 : _a.id;
|
|
3013
|
-
const
|
|
3088
|
+
const parentId = (_b = itemSelector == null ? void 0 : itemSelector.zone) == null ? void 0 : _b.split(":")[0];
|
|
3089
|
+
const isEditable = Boolean(selectedId && (editableIds.has(selectedId) || parentId && editableIds.has(parentId)));
|
|
3014
3090
|
return /* @__PURE__ */ jsx9("div", { className: getClassName3(), children: /* @__PURE__ */ jsxs3(ActionBar, { children: [
|
|
3015
3091
|
/* @__PURE__ */ jsxs3(ActionBar.Group, { children: [
|
|
3016
3092
|
props.parentAction,
|
|
@@ -3048,7 +3124,7 @@ var ActionBarOverride = (props) => {
|
|
|
3048
3124
|
};
|
|
3049
3125
|
|
|
3050
3126
|
// src/puck/overrides/DrawerItem.tsx
|
|
3051
|
-
import { useState as
|
|
3127
|
+
import { useState as useState4 } from "react";
|
|
3052
3128
|
import { Button as Button2, IconButton, createUsePuck as createUsePuck12 } from "@measured/puck";
|
|
3053
3129
|
import { GripVertical, Check, X, Trash2, Cog } from "lucide-react";
|
|
3054
3130
|
|
|
@@ -3073,7 +3149,7 @@ var confirm = (message) => __async(null, null, function* () {
|
|
|
3073
3149
|
var DrawerItem_module_default = { "DrawerItem": "_DrawerItem_182aj_1", "DrawerItem--insertDisabled": "_DrawerItem--insertDisabled_182aj_14", "DrawerItem-content": "_DrawerItem-content_182aj_21", "DrawerItem-name": "_DrawerItem-name_182aj_31", "DrawerItem-version": "_DrawerItem-version_182aj_35", "DrawerItem-actions": "_DrawerItem-actions_182aj_40", "DrawerItem-settingsButton": "_DrawerItem-settingsButton_182aj_46", "DrawerItem-grip": "_DrawerItem-grip_182aj_56", "DrawerItem-modal": "_DrawerItem-modal_182aj_63", "DrawerItem-modalHeader": "_DrawerItem-modalHeader_182aj_71", "DrawerItem-modalTitle": "_DrawerItem-modalTitle_182aj_77", "DrawerItem-modalSubtitle": "_DrawerItem-modalSubtitle_182aj_84", "DrawerItem-modalBody": "_DrawerItem-modalBody_182aj_90", "DrawerItem-section": "_DrawerItem-section_182aj_100", "DrawerItem-sectionTitle": "_DrawerItem-sectionTitle_182aj_106", "DrawerItem-sectionDescription": "_DrawerItem-sectionDescription_182aj_113", "DrawerItem-versionList": "_DrawerItem-versionList_182aj_119", "DrawerItem-versionRow": "_DrawerItem-versionRow_182aj_125", "DrawerItem-versionRow--isDefault": "_DrawerItem-versionRow--isDefault_182aj_136", "DrawerItem-versionRow--isMarkedForDeletion": "_DrawerItem-versionRow--isMarkedForDeletion_182aj_141", "DrawerItem-versionInfo": "_DrawerItem-versionInfo_182aj_146", "DrawerItem-versionNumber": "_DrawerItem-versionNumber_182aj_153", "DrawerItem-defaultBadge": "_DrawerItem-defaultBadge_182aj_159", "DrawerItem-deleteBadge": "_DrawerItem-deleteBadge_182aj_170", "DrawerItem-versionActions": "_DrawerItem-versionActions_182aj_181", "DrawerItem-migrationOptions": "_DrawerItem-migrationOptions_182aj_187", "DrawerItem-migrationList": "_DrawerItem-migrationList_182aj_191", "DrawerItem-migrationOption": "_DrawerItem-migrationOption_182aj_187", "DrawerItem-migrationOption--isSelected": "_DrawerItem-migrationOption--isSelected_182aj_229", "DrawerItem-migrationOptionLabel": "_DrawerItem-migrationOptionLabel_182aj_234", "DrawerItem-modalFooter": "_DrawerItem-modalFooter_182aj_240", "DrawerItem-footerLeft": "_DrawerItem-footerLeft_182aj_250", "DrawerItem-footerRight": "_DrawerItem-footerRight_182aj_255" };
|
|
3074
3150
|
|
|
3075
3151
|
// src/puck/components/modal/index.tsx
|
|
3076
|
-
import { useEffect as useEffect4, useState as
|
|
3152
|
+
import { useEffect as useEffect4, useState as useState3 } from "react";
|
|
3077
3153
|
import { createPortal } from "react-dom";
|
|
3078
3154
|
|
|
3079
3155
|
// css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/modal/styles.module.css#css-module
|
|
@@ -3087,7 +3163,7 @@ var Modal = ({
|
|
|
3087
3163
|
onClose,
|
|
3088
3164
|
isOpen
|
|
3089
3165
|
}) => {
|
|
3090
|
-
const [rootEl, setRootEl] =
|
|
3166
|
+
const [rootEl, setRootEl] = useState3(null);
|
|
3091
3167
|
useEffect4(() => {
|
|
3092
3168
|
setRootEl(document.getElementById("puck-portal-root"));
|
|
3093
3169
|
}, []);
|
|
@@ -3151,13 +3227,13 @@ var DrawerItem = (props) => {
|
|
|
3151
3227
|
const { handleDemolish } = useDemolish();
|
|
3152
3228
|
const { handleSetDefaultVersion, getVersions, getDefaultVersion } = useSetDefaultVersion();
|
|
3153
3229
|
const { triggerAction } = useActionEvent();
|
|
3154
|
-
const [isEditing, setIsEditing] =
|
|
3155
|
-
const [isHovering, setIsHovering] =
|
|
3156
|
-
const [selectedVersion, setSelectedVersion] =
|
|
3157
|
-
const [versionsToDelete, setVersionsToDelete] =
|
|
3230
|
+
const [isEditing, setIsEditing] = useState4(false);
|
|
3231
|
+
const [isHovering, setIsHovering] = useState4(false);
|
|
3232
|
+
const [selectedVersion, setSelectedVersion] = useState4("");
|
|
3233
|
+
const [versionsToDelete, setVersionsToDelete] = useState4(
|
|
3158
3234
|
/* @__PURE__ */ new Set()
|
|
3159
3235
|
);
|
|
3160
|
-
const [migrationTarget, setMigrationTarget] =
|
|
3236
|
+
const [migrationTarget, setMigrationTarget] = useState4("decompose");
|
|
3161
3237
|
const useVersioning = useSoftConfig((s) => s.showVersionFields);
|
|
3162
3238
|
const versions = getVersions(props.name);
|
|
3163
3239
|
const defaultVersion = getDefaultVersion(props.name);
|
|
@@ -3356,7 +3432,7 @@ var DrawerItem = (props) => {
|
|
|
3356
3432
|
var ComponentItem = DrawerItem;
|
|
3357
3433
|
|
|
3358
3434
|
// src/puck/overrides/Drawer.tsx
|
|
3359
|
-
import { useState as
|
|
3435
|
+
import { useState as useState5 } from "react";
|
|
3360
3436
|
import { createUsePuck as createUsePuck13, Drawer as PuckDrawer } from "@measured/puck";
|
|
3361
3437
|
import { ChevronDown, ChevronUp } from "lucide-react";
|
|
3362
3438
|
|
|
@@ -3415,7 +3491,7 @@ var Drawer = (_props) => {
|
|
|
3415
3491
|
const categoryEntries = Object.entries(categories).filter(
|
|
3416
3492
|
([, cat]) => cat.visible !== false
|
|
3417
3493
|
);
|
|
3418
|
-
const [expanded, setExpanded] =
|
|
3494
|
+
const [expanded, setExpanded] = useState5(() => {
|
|
3419
3495
|
const init = {};
|
|
3420
3496
|
categoryEntries.forEach(([id, cat]) => {
|
|
3421
3497
|
init[id] = cat.defaultExpanded !== false;
|