@netlisian/softconfig 0.0.11 → 0.1.1

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.
@@ -86,6 +86,7 @@ __export(puck_exports, {
86
86
  Modal: () => Modal,
87
87
  SoftConfigProvider: () => SoftConfigProvider,
88
88
  confirm: () => confirm,
89
+ createActionCallback: () => createActionCallback,
89
90
  createSoftConfigStore: () => createSoftConfigStore,
90
91
  createUseSoftConfig: () => createUseSoftConfig,
91
92
  notify: () => notify,
@@ -108,6 +109,9 @@ module.exports = __toCommonJS(puck_exports);
108
109
  var import_zustand2 = require("zustand");
109
110
  var import_middleware = require("zustand/middleware");
110
111
 
112
+ // src/puck/store/slices/builder.tsx
113
+ var import_puck4 = require("@measured/puck");
114
+
111
115
  // src/puck/lib/get-root-props.ts
112
116
  var getRootProps = (appState) => appState.data.root.props;
113
117
 
@@ -315,19 +319,23 @@ var import_react = require("react");
315
319
  var import_zustand = require("zustand");
316
320
  var appStoreContext = (0, import_react.createContext)(null);
317
321
  var createUseSoftConfig = () => {
318
- return function useSoftConfig2(selector) {
322
+ return function useSoftConfig2(selector, equalityFn) {
319
323
  const context = (0, import_react.useContext)(appStoreContext);
320
324
  if (!context) {
321
325
  throw new Error(
322
326
  "useSoftConfig must be used inside a SoftConfigProvider. Wrap your tree with <SoftConfigProvider value={store}>"
323
327
  );
324
328
  }
329
+ if (equalityFn) {
330
+ return (0, import_zustand.useStore)(context, selector, equalityFn);
331
+ }
325
332
  return (0, import_zustand.useStore)(context, selector);
326
333
  };
327
334
  };
328
335
  var useSoftConfig = createUseSoftConfig();
329
336
 
330
337
  // src/puck/lib/builder/root-config.tsx
338
+ var import_use_debounce = require("use-debounce");
331
339
  var import_jsx_runtime2 = require("react/jsx-runtime");
332
340
  var useCustomPuck = (0, import_puck2.createUsePuck)();
333
341
  var breakVersion = (version) => {
@@ -348,12 +356,29 @@ var updateVersion = (version, increment) => {
348
356
  }
349
357
  return `${major}.${minor}.${patch}`;
350
358
  };
351
- var builderRootConfig = (config, overrides, editingComponent) => ({
359
+ var builderRootConfig = (config, overrides, editingComponent, showVersionFields = true) => ({
352
360
  fields: {
353
- _name: {
361
+ _name: overrides.name || {
354
362
  type: "text",
355
363
  label: "Soft Component Name"
356
364
  },
365
+ _category: overrides.categories || {
366
+ type: "select",
367
+ label: "Category",
368
+ options: [
369
+ ...Object.keys(config.categories || {}).map((cat) => {
370
+ var _a;
371
+ return {
372
+ label: ((_a = config.categories) == null ? void 0 : _a[cat].title) || cat,
373
+ value: cat
374
+ };
375
+ }) || [],
376
+ {
377
+ label: Object.keys(config.categories || {}).length ? "Other" : "Uncategorized",
378
+ value: void 0
379
+ }
380
+ ]
381
+ },
357
382
  _fields: {
358
383
  type: "array",
359
384
  label: "Fields",
@@ -396,7 +421,7 @@ var builderRootConfig = (config, overrides, editingComponent) => ({
396
421
  )
397
422
  };
398
423
  else delete fields._fieldSettings;
399
- if (((_b = data == null ? void 0 : data._versions) == null ? void 0 : _b.length) && (!(data == null ? void 0 : data._version) || changed._version || changed._fieldSettings)) {
424
+ if (showVersionFields && ((_b = data == null ? void 0 : data._versions) == null ? void 0 : _b.length) && (!(data == null ? void 0 : data._version) || changed._version || changed._fieldSettings)) {
400
425
  const latestVersion = data._versions[data._versions.length - 1] || "1.0.0";
401
426
  delete fields._version;
402
427
  fields._version = {
@@ -418,10 +443,14 @@ var builderRootConfig = (config, overrides, editingComponent) => ({
418
443
  }
419
444
  ]
420
445
  };
446
+ } else {
447
+ delete fields._version;
421
448
  }
422
449
  return fields;
423
450
  },
424
- resolveData: (props) => {
451
+ resolveData: (props, params) => {
452
+ if (overrides.onRootsDataChange)
453
+ overrides.onRootsDataChange(props, params);
425
454
  return {
426
455
  props,
427
456
  readOnly: Boolean(editingComponent) ? {
@@ -436,80 +465,78 @@ var builderRootConfig = (config, overrides, editingComponent) => ({
436
465
  const getSelectorForId = useCustomPuck((s) => s.getSelectorForId);
437
466
  const setVersion = useSoftConfig((s) => s.builder.setVersion);
438
467
  const state = useSoftConfig((s) => s.state);
468
+ const [debouncedFieldSettings] = (0, import_use_debounce.useDebounce)(fieldSettings, 500);
439
469
  (0, import_react2.useEffect)(() => {
440
- const propagateChanges = setTimeout(() => {
441
- if (!fieldSettings || Object.keys(fieldSettings).length === 0) return;
442
- (0, import_puck2.walkTree)(
443
- data,
444
- {
445
- components: config.components
446
- },
447
- (content) => content.map((child) => {
448
- var _a;
449
- const map = ((_a = child.props) == null ? void 0 : _a._map) || [];
450
- if (map.length) {
451
- map.forEach(({ from, to, transform }) => {
452
- if (!from || !to) return;
453
- const fromPaths = Array.isArray(from) ? from : [from];
454
- const toPaths = Array.isArray(to) ? to : [to];
455
- const inputValues = fromPaths.map(
456
- (f) => getFieldSettingsByPath(props._fieldSettings || {}, f)
457
- );
458
- let value = transform ? transform(
459
- inputValues.map((v) => v == null ? void 0 : v.defaultValue),
460
- child.props
461
- ) : inputValues[0];
462
- if (Array.isArray(value)) {
463
- value.forEach((val, i) => {
464
- if (toPaths[i]) {
465
- const originalValue = getFieldSettingsByPath(
466
- child.props,
467
- toPaths[i]
468
- );
469
- if (originalValue !== val) {
470
- const itemSelector = getSelectorForId(child.props.id);
471
- if (!itemSelector) return;
472
- setPropertyByPath(child.props, toPaths[i], val);
473
- dispatch({
474
- type: "replace",
475
- data: child,
476
- destinationIndex: itemSelector == null ? void 0 : itemSelector.index,
477
- destinationZone: itemSelector == null ? void 0 : itemSelector.zone
478
- });
479
- }
470
+ if (!debouncedFieldSettings || Object.keys(debouncedFieldSettings).length === 0) return;
471
+ (0, import_puck2.walkTree)(
472
+ data,
473
+ {
474
+ components: config.components
475
+ },
476
+ (content) => content.map((child) => {
477
+ var _a;
478
+ const map = ((_a = child.props) == null ? void 0 : _a._map) || [];
479
+ if (map.length) {
480
+ map.forEach(({ from, to, transform }) => {
481
+ if (!from || !to) return;
482
+ const fromPaths = Array.isArray(from) ? from : [from];
483
+ const toPaths = Array.isArray(to) ? to : [to];
484
+ const inputValues = fromPaths.map(
485
+ (f) => getFieldSettingsByPath(props._fieldSettings || {}, f)
486
+ );
487
+ let value = transform ? transform(
488
+ inputValues.map((v) => v == null ? void 0 : v.defaultValue),
489
+ child.props
490
+ ) : inputValues[0];
491
+ if (Array.isArray(value)) {
492
+ value.forEach((val, i) => {
493
+ if (toPaths[i]) {
494
+ const originalValue = getFieldSettingsByPath(
495
+ child.props,
496
+ toPaths[i]
497
+ );
498
+ if (originalValue !== val) {
499
+ const itemSelector = getSelectorForId(child.props.id);
500
+ if (!itemSelector) return;
501
+ setPropertyByPath(child.props, toPaths[i], val);
502
+ dispatch({
503
+ type: "replace",
504
+ data: child,
505
+ destinationIndex: itemSelector == null ? void 0 : itemSelector.index,
506
+ destinationZone: itemSelector == null ? void 0 : itemSelector.zone
507
+ });
480
508
  }
481
- });
482
- } else if (toPaths[0]) {
483
- const setting = getFieldSettingsByPath(
484
- fieldSettings,
485
- fromPaths.length === 1 ? fromPaths[0] : fromPaths.join(".")
486
- );
487
- const defaultValue = setting == null ? void 0 : setting.defaultValue;
488
- const originalValue = getFieldSettingsByPath(
489
- child.props,
490
- toPaths[0]
491
- );
492
- const finalValue = transform !== void 0 && value !== void 0 ? value : defaultValue !== void 0 ? defaultValue : value;
493
- if (originalValue !== finalValue) {
494
- const itemSelector = getSelectorForId(child.props.id);
495
- if (!itemSelector) return;
496
- setPropertyByPath(child.props, toPaths[0], finalValue);
497
- dispatch({
498
- type: "replace",
499
- data: child,
500
- destinationIndex: itemSelector == null ? void 0 : itemSelector.index,
501
- destinationZone: itemSelector == null ? void 0 : itemSelector.zone
502
- });
503
509
  }
510
+ });
511
+ } else if (toPaths[0]) {
512
+ const setting = getFieldSettingsByPath(
513
+ debouncedFieldSettings,
514
+ fromPaths.length === 1 ? fromPaths[0] : fromPaths.join(".")
515
+ );
516
+ const defaultValue = setting == null ? void 0 : setting.defaultValue;
517
+ const originalValue = getFieldSettingsByPath(
518
+ child.props,
519
+ toPaths[0]
520
+ );
521
+ const finalValue = transform !== void 0 && value !== void 0 ? value : defaultValue !== void 0 ? defaultValue : value;
522
+ if (originalValue !== finalValue) {
523
+ const itemSelector = getSelectorForId(child.props.id);
524
+ if (!itemSelector) return;
525
+ setPropertyByPath(child.props, toPaths[0], finalValue);
526
+ dispatch({
527
+ type: "replace",
528
+ data: child,
529
+ destinationIndex: itemSelector == null ? void 0 : itemSelector.index,
530
+ destinationZone: itemSelector == null ? void 0 : itemSelector.zone
531
+ });
504
532
  }
505
- });
506
- }
507
- return child;
508
- })
509
- );
510
- }, 300);
511
- return () => clearTimeout(propagateChanges);
512
- }, [fieldSettings]);
533
+ }
534
+ });
535
+ }
536
+ return child;
537
+ })
538
+ );
539
+ }, [debouncedFieldSettings, data, dispatch, getSelectorForId, props._fieldSettings]);
513
540
  (0, import_react2.useEffect)(() => {
514
541
  var _a;
515
542
  if (state !== "remodeling") return;
@@ -594,7 +621,7 @@ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (op
594
621
  };
595
622
  var get_class_name_factory_default = getClassNameFactory;
596
623
 
597
- // css-module:D:\osamuProjects\netlisian\packages\soft-config\src\puck\components\error-boundary\styles.module.css#css-module
624
+ // css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/error-boundary/styles.module.css#css-module
598
625
  var styles_module_default = { "ErrorBoundary": "_ErrorBoundary_1xl05_5", "ErrorBoundary-title": "_ErrorBoundary-title_1xl05_21", "ErrorBoundary-details": "_ErrorBoundary-details_1xl05_31", "ErrorBoundary-button": "_ErrorBoundary-button_1xl05_39" };
599
626
 
600
627
  // src/puck/components/error-boundary/index.tsx
@@ -653,157 +680,158 @@ var ErrorBoundary = class extends import_react3.Component {
653
680
 
654
681
  // src/puck/lib/builder/builder-config.tsx
655
682
  var import_jsx_runtime4 = require("react/jsx-runtime");
656
- var builderConfig = (config, overrides, editingComponent) => ({
657
- root: builderRootConfig(config, overrides, editingComponent),
683
+ var builderConfig = (config, overrides, editingComponent, showVersionFields = true, dependents) => ({
684
+ root: builderRootConfig(config, overrides, editingComponent, showVersionFields),
658
685
  components: Object.entries(__spreadValues({}, config.components)).reduce(
659
686
  (acc, [name, component]) => {
660
- if (!editingComponent || name !== editingComponent) {
661
- let _a;
662
- const tempComponent = __spreadProps(__spreadValues({}, component), {
663
- resolveFields(data, params) {
664
- return __async(this, null, function* () {
665
- let fields = {};
666
- if (!fields._slot) {
667
- const slotFields = Object.entries(params.fields).filter(
668
- ([_, field]) => field.type === "slot"
669
- );
670
- if (slotFields.length)
671
- fields._slot = {
672
- type: "array",
673
- label: "Enable Dropdown Slots",
674
- getItemSummary(item, index) {
675
- return item.slot || `Slot ${(index || 0) + 1}`;
676
- },
677
- arrayFields: {
678
- slot: {
679
- type: "select",
680
- label: "Slot",
681
- options: [
682
- { label: "Select a slot", value: "" },
683
- ...slotFields.filter(
684
- ([fieldName, field]) => {
685
- var _a2;
686
- return field.type === "slot" && !(((_a2 = data.props) == null ? void 0 : _a2._slot) || []).some(
687
- (s) => s.slot === fieldName
688
- );
689
- }
690
- ).map(([fieldName, field]) => ({
691
- label: field.label || fieldName,
692
- value: fieldName
693
- }))
694
- ]
695
- },
696
- name: {
697
- type: "text",
698
- label: "Name",
699
- placeholder: "Optional Slot Name"
700
- }
701
- }
702
- };
703
- }
704
- const defaultFields = component.resolveFields ? yield component.resolveFields(data, params) : component.fields || {};
705
- if (!fields._map) {
706
- const rootProps = getRootProps(params.appState);
707
- const fromOptions = generateDynamicFieldOptions(
708
- (rootProps == null ? void 0 : rootProps._fields) || [],
709
- (rootProps == null ? void 0 : rootProps._fieldSettings) || {}
710
- );
711
- const toOptions = generateFieldOptions(defaultFields, []);
712
- fields._map = overrides.map ? {
713
- type: "custom",
714
- render: ({ value, onChange, id }) => {
715
- const toOptions2 = generateFieldOptions(defaultFields, []);
716
- const rootProps2 = getRootProps(params.appState);
717
- return overrides.map({
718
- rootProps: rootProps2,
719
- value,
720
- onChange,
721
- id,
722
- props: data.props || {},
723
- fromOptions,
724
- toOptions: toOptions2
725
- });
726
- }
727
- } : {
687
+ const tempComponent = __spreadProps(__spreadValues({}, component), {
688
+ permissions: {
689
+ insert: editingComponent !== name && !(dependents == null ? void 0 : dependents.has(name))
690
+ },
691
+ resolveFields(data, params) {
692
+ return __async(this, null, function* () {
693
+ let fields = {};
694
+ if (!fields._slot) {
695
+ const slotFields = Object.entries(params.fields).filter(
696
+ ([_, field]) => field.type === "slot"
697
+ );
698
+ if (slotFields.length)
699
+ fields._slot = {
728
700
  type: "array",
729
- label: "Dynamic Field Map",
701
+ label: "Enable Dropdown Slots",
702
+ getItemSummary(item, index) {
703
+ return item.slot || `Slot ${(index || 0) + 1}`;
704
+ },
730
705
  arrayFields: {
731
- from: {
706
+ slot: {
732
707
  type: "select",
733
- label: "From",
708
+ label: "Slot",
734
709
  options: [
735
- { label: "Select a field", value: "" },
736
- ...fromOptions.map(({ label, value }) => ({
737
- label,
738
- value
710
+ { label: "Select a slot", value: "" },
711
+ ...slotFields.filter(
712
+ ([fieldName, field]) => {
713
+ var _a2;
714
+ return field.type === "slot" && !(((_a2 = data.props) == null ? void 0 : _a2._slot) || []).some(
715
+ (s) => s.slot === fieldName
716
+ );
717
+ }
718
+ ).map(([fieldName, field]) => ({
719
+ label: field.label || fieldName,
720
+ value: fieldName
739
721
  }))
740
722
  ]
741
723
  },
742
- to: {
743
- type: "select",
744
- label: "To",
745
- options: [
746
- { label: "Select a field", value: "" },
747
- ...toOptions.map(({ label, value }) => ({
748
- label,
749
- value
750
- }))
751
- ]
724
+ name: {
725
+ type: "text",
726
+ label: "Name",
727
+ placeholder: "Optional Slot Name"
752
728
  }
753
729
  }
754
730
  };
755
- }
756
- fields = __spreadValues(__spreadValues({}, fields), defaultFields);
757
- return fields;
758
- });
759
- },
760
- resolveData: ({ props }, { lastData }) => {
761
- var _a2;
762
- const _map = props._map || [];
763
- const readOnlyFields = _map.flatMap((item) => item.to);
764
- if (_map.length) {
731
+ }
732
+ const defaultFields = component.resolveFields ? yield component.resolveFields(data, params) : component.fields || {};
733
+ if (!fields._map) {
734
+ const rootProps = getRootProps(params.appState);
735
+ const fromOptions = generateDynamicFieldOptions(
736
+ (rootProps == null ? void 0 : rootProps._fields) || [],
737
+ (rootProps == null ? void 0 : rootProps._fieldSettings) || {}
738
+ );
739
+ const toOptions = generateFieldOptions(defaultFields, []);
740
+ fields._map = overrides.map ? {
741
+ type: "custom",
742
+ render: ({ value, onChange, id }) => {
743
+ const toOptions2 = generateFieldOptions(defaultFields, []);
744
+ const rootProps2 = getRootProps(params.appState);
745
+ return overrides.map({
746
+ rootProps: rootProps2,
747
+ value,
748
+ onChange,
749
+ id,
750
+ props: data.props || {},
751
+ fromOptions,
752
+ toOptions: toOptions2
753
+ });
754
+ }
755
+ } : {
756
+ type: "array",
757
+ label: "Dynamic Field Map",
758
+ arrayFields: {
759
+ from: {
760
+ type: "select",
761
+ label: "From",
762
+ options: [
763
+ { label: "Select a field", value: "" },
764
+ ...fromOptions.map(({ label, value }) => ({
765
+ label,
766
+ value
767
+ }))
768
+ ]
769
+ },
770
+ to: {
771
+ type: "select",
772
+ label: "To",
773
+ options: [
774
+ { label: "Select a field", value: "" },
775
+ ...toOptions.map(({ label, value }) => ({
776
+ label,
777
+ value
778
+ }))
779
+ ]
780
+ }
781
+ }
782
+ };
783
+ }
784
+ fields = __spreadValues(__spreadValues({}, fields), defaultFields);
785
+ return fields;
786
+ });
787
+ },
788
+ resolveData: ({ props }, { lastData }) => {
789
+ var _a2;
790
+ const _map = props._map || [];
791
+ const readOnlyFields = _map.flatMap((item) => item.to);
792
+ if (_map.length) {
793
+ return {
794
+ props,
795
+ readOnly: readOnlyFields.reduce(
796
+ (acc2, field) => __spreadProps(__spreadValues({}, acc2), { [field]: true }),
797
+ {}
798
+ )
799
+ };
800
+ }
801
+ const prevMap = (_a2 = lastData == null ? void 0 : lastData.props) == null ? void 0 : _a2._map;
802
+ if (prevMap && prevMap.length === 1) {
803
+ const lastField = prevMap[0].to;
804
+ if (typeof lastField === "string") {
805
+ return {
806
+ props,
807
+ readOnly: { [lastField]: false }
808
+ };
809
+ }
810
+ if (Array.isArray(lastField)) {
765
811
  return {
766
812
  props,
767
- readOnly: readOnlyFields.reduce(
768
- (acc2, field) => __spreadProps(__spreadValues({}, acc2), { [field]: true }),
813
+ readOnly: lastField.reduce(
814
+ (acc2, field) => __spreadProps(__spreadValues({}, acc2), { [String(field)]: false }),
769
815
  {}
770
816
  )
771
817
  };
772
818
  }
773
- const prevMap = (_a2 = lastData == null ? void 0 : lastData.props) == null ? void 0 : _a2._map;
774
- if (prevMap && prevMap.length === 1) {
775
- const lastField = prevMap[0].to;
776
- if (typeof lastField === "string") {
777
- return {
778
- props,
779
- readOnly: { [lastField]: false }
780
- };
781
- }
782
- if (Array.isArray(lastField)) {
783
- return {
784
- props,
785
- readOnly: lastField.reduce(
786
- (acc2, field) => __spreadProps(__spreadValues({}, acc2), { [String(field)]: false }),
787
- {}
788
- )
789
- };
790
- }
791
- }
792
- return {
793
- props,
794
- readOnly: {}
795
- };
796
- },
797
- render: (props) => {
798
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorBoundary, { children: component.render(props) });
799
819
  }
800
- });
801
- acc[name] = tempComponent;
802
- }
820
+ return {
821
+ props,
822
+ readOnly: {}
823
+ };
824
+ },
825
+ render: (props) => {
826
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ErrorBoundary, { children: component.render(props) });
827
+ }
828
+ });
829
+ acc[name] = tempComponent;
803
830
  return acc;
804
831
  },
805
832
  {}
806
- )
833
+ ),
834
+ categories: config.categories || {}
807
835
  });
808
836
 
809
837
  // src/puck/lib/strip-id.ts
@@ -929,14 +957,14 @@ var softFieldsToPuckFields = (fields, fieldSettings) => {
929
957
  {}
930
958
  )) || {};
931
959
  };
932
- var softComponentFromAppState = (appState, configComponents) => {
960
+ var softComponentFromAppState = (appState, configComponents, editedItem, metadata) => {
933
961
  var _a;
934
962
  const rootProps = ((_a = appState.data.root) == null ? void 0 : _a.props) || {};
935
963
  const fields = rootProps._fields || [];
936
964
  const field_settings = rootProps._fieldSettings || {};
937
965
  const slots = {};
938
966
  const components = getSubComponents(
939
- appState.data.content || [],
967
+ [editedItem],
940
968
  configComponents,
941
969
  field_settings,
942
970
  slots
@@ -950,6 +978,8 @@ var softComponentFromAppState = (appState, configComponents) => {
950
978
  )), slots);
951
979
  return [
952
980
  {
981
+ name: metadata.name,
982
+ category: metadata.category,
953
983
  fields: __spreadValues(__spreadValues({}, softFieldsToPuckFields(fields, field_settings)), Object.keys(slots).reduce((acc, slot) => {
954
984
  acc[slot] = { type: "slot", label: slot };
955
985
  return acc;
@@ -1085,7 +1115,7 @@ var reconstructComponents = (subComponents, componentConfigs, softComponentProps
1085
1115
  return componentData;
1086
1116
  });
1087
1117
  };
1088
- var softComponentToAppState = (softComponent, componentName, version, versions, componentProps, componentConfigs) => {
1118
+ var softComponentToAppState = (softComponent, componentName, version, versions, componentProps, componentConfigs, displayName, category) => {
1089
1119
  const slots = new Set(Object.keys(softComponent.slots));
1090
1120
  const { fields, fieldSettings } = puckFieldsToSoftFields(
1091
1121
  softComponent.fields,
@@ -1097,7 +1127,8 @@ var softComponentToAppState = (softComponent, componentName, version, versions,
1097
1127
  }
1098
1128
  });
1099
1129
  const rootProps = {
1100
- _name: componentName,
1130
+ _name: displayName || componentName,
1131
+ _category: category,
1101
1132
  _version: version,
1102
1133
  _versions: versions,
1103
1134
  _fields: fields,
@@ -1126,6 +1157,7 @@ var rootDroppableId = `${rootAreaId}:${rootZone}`;
1126
1157
  // src/puck/components/soft-render/index.tsx
1127
1158
  var import_react4 = require("react");
1128
1159
  var import_uuid2 = require("uuid");
1160
+ var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1129
1161
  var import_jsx_runtime5 = require("react/jsx-runtime");
1130
1162
  function SoftRender({
1131
1163
  softComponentFields,
@@ -1137,11 +1169,10 @@ function SoftRender({
1137
1169
  }) {
1138
1170
  const _a = props, { id, puck, editMode } = _a, rest = __objRest(_a, ["id", "puck", "editMode"]);
1139
1171
  const mapCacheRef = (0, import_react4.useRef)(/* @__PURE__ */ new Map());
1140
- const prevPropsRef = (0, import_react4.useRef)("");
1141
- const propsSnapshot = JSON.stringify(props);
1142
- if (prevPropsRef.current !== propsSnapshot) {
1172
+ const prevPropsRef = (0, import_react4.useRef)(null);
1173
+ if (!(0, import_fast_deep_equal.default)(prevPropsRef.current, props)) {
1143
1174
  mapCacheRef.current.clear();
1144
- prevPropsRef.current = propsSnapshot;
1175
+ prevPropsRef.current = props;
1145
1176
  }
1146
1177
  const subComponentRootProps = (0, import_react4.useMemo)(
1147
1178
  () => Object.entries(softComponentFields || {}).filter(([_, field]) => field.type !== "slot").reduce(
@@ -1153,10 +1184,6 @@ function SoftRender({
1153
1184
  ),
1154
1185
  [softComponentFields, props]
1155
1186
  );
1156
- const valuesToUpdateKey = (0, import_react4.useMemo)(
1157
- () => JSON.stringify(subComponentRootProps),
1158
- [subComponentRootProps]
1159
- );
1160
1187
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: (softSubComponent == null ? void 0 : softSubComponent.length) > 0 && softSubComponent.map((subComponent, index) => {
1161
1188
  var _a2;
1162
1189
  const componentConfig = configComponents[subComponent == null ? void 0 : subComponent.type];
@@ -1183,7 +1210,7 @@ function SoftRender({
1183
1210
  }
1184
1211
  return propValue;
1185
1212
  });
1186
- const cacheKey = JSON.stringify(inputValues);
1213
+ const cacheKey = inputValues.map((v, i) => `${i}:${typeof v === "object" ? JSON.stringify(v) : v}`).join("|");
1187
1214
  let result = mapCacheRef.current.get(cacheKey);
1188
1215
  if (!result) {
1189
1216
  const runner = transform;
@@ -1210,7 +1237,7 @@ function SoftRender({
1210
1237
  const slotName = enabledSlot.name || `${(_b = subComponent.fixedProps) == null ? void 0 : _b.id}-${slotKey}`;
1211
1238
  resolvedProps[slotKey] = (0, import_react4.useMemo)(
1212
1239
  () => rest[slotName] || (() => null),
1213
- [slotName]
1240
+ [slotName, rest[slotName]]
1214
1241
  );
1215
1242
  } else {
1216
1243
  resolvedProps[slotKey] = (0, import_react4.useMemo)(() => {
@@ -1231,7 +1258,7 @@ function SoftRender({
1231
1258
  slotKey
1232
1259
  ) });
1233
1260
  };
1234
- }, [valuesToUpdateKey]);
1261
+ }, [slotKey, subComponentRootProps]);
1235
1262
  }
1236
1263
  }
1237
1264
  }
@@ -1250,10 +1277,11 @@ function SoftRender({
1250
1277
 
1251
1278
  // src/puck/lib/create-versioned-component-config.tsx
1252
1279
  var import_jsx_runtime6 = require("react/jsx-runtime");
1253
- var createVersionedComponentConfig = (componentName, version, allVersions, config, softComponents, defaultProps) => {
1280
+ var createVersionedComponentConfig = (componentName, displayName, version, allVersions, config, softComponents, defaultProps, showVersioning = true) => {
1254
1281
  var _a, _b;
1255
1282
  const softConfig = config;
1256
1283
  return {
1284
+ label: displayName,
1257
1285
  fields: Object.fromEntries(
1258
1286
  (Object.entries(
1259
1287
  (_b = (_a = softComponents[componentName].versions) == null ? void 0 : _a[version]) == null ? void 0 : _b.fields
@@ -1268,16 +1296,18 @@ var createVersionedComponentConfig = (componentName, version, allVersions, confi
1268
1296
  var _a2, _b2;
1269
1297
  const selectedVersion = ((_a2 = data.props) == null ? void 0 : _a2.version) || version;
1270
1298
  const versionedComponent = (_b2 = softComponents[componentName]) == null ? void 0 : _b2.versions[selectedVersion];
1271
- const fieldsWithoutSlots = Object.fromEntries(
1272
- Object.entries((versionedComponent == null ? void 0 : versionedComponent.fields) || {}).filter(([, field]) => field.type !== "slot").map(([key, field]) => [key, __spreadValues({}, field)])
1273
- );
1274
- return __spreadValues({
1275
- version: {
1299
+ let fields = {};
1300
+ if (showVersioning) {
1301
+ fields.version = {
1276
1302
  label: "Version",
1277
1303
  type: "select",
1278
1304
  options: allVersions.map((v) => ({ label: v, value: v }))
1279
- }
1280
- }, fieldsWithoutSlots);
1305
+ };
1306
+ }
1307
+ Object.entries((versionedComponent == null ? void 0 : versionedComponent.fields) || {}).filter(([, field]) => field.type !== "slot").forEach(([key, field]) => {
1308
+ fields[key] = field;
1309
+ });
1310
+ return fields;
1281
1311
  },
1282
1312
  render: (props) => {
1283
1313
  var _a2;
@@ -1397,9 +1427,21 @@ function demolishSoftComponent(componentName, data, config, softComponents) {
1397
1427
  };
1398
1428
  }
1399
1429
 
1430
+ // src/puck/lib/component-key.ts
1431
+ var defaultToCamelCase = (value) => {
1432
+ const tokens = value.trim().replace(/[^a-zA-Z0-9\s_-]/g, " ").split(/[\s_-]+/).filter(Boolean);
1433
+ if (tokens.length === 0) return "";
1434
+ const [first, ...rest] = tokens;
1435
+ return `${first.toLowerCase()}${rest.map((token) => token.charAt(0).toUpperCase() + token.slice(1).toLowerCase()).join("")}`;
1436
+ };
1437
+ var createComponentKeyFromName = (displayName, overrides, context) => {
1438
+ const key = overrides.componentNameToKey ? overrides.componentNameToKey(displayName, context) : defaultToCamelCase(displayName);
1439
+ return key.trim();
1440
+ };
1441
+
1400
1442
  // src/puck/store/slices/builder.tsx
1401
1443
  var createBuildersSlice = (set, get, initialConfig) => ({
1402
- build: (history, selectedItem, itemSelector, puckDispatch) => {
1444
+ build: (history, selectedItem, itemSelector, puckDispatch, name) => {
1403
1445
  if (!selectedItem || !itemSelector) {
1404
1446
  throw new Error("No item selected to build from.");
1405
1447
  }
@@ -1412,16 +1454,31 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1412
1454
  data: __spreadProps(__spreadValues({}, previous.data), {
1413
1455
  root: {
1414
1456
  props: {
1415
- _name: "New Soft Component"
1457
+ _name: name || "New Soft Component"
1416
1458
  }
1417
- },
1418
- content: [__spreadValues({}, selectedItem)]
1459
+ }
1460
+ // content: [{ ...selectedItem }],
1419
1461
  })
1420
1462
  })
1421
1463
  });
1422
1464
  const config = __spreadValues({}, get().softConfig);
1423
1465
  const overrides = get().overrides;
1424
- const buildConfig = builderConfig(config, overrides);
1466
+ const buildConfig = builderConfig(config, overrides, void 0, get().showVersionFields);
1467
+ const editableIds = /* @__PURE__ */ new Set([selectedItem.props.id]);
1468
+ const initialContent = [__spreadValues({}, selectedItem)];
1469
+ (0, import_puck4.walkTree)(
1470
+ {
1471
+ root: {},
1472
+ content: initialContent
1473
+ },
1474
+ { components: config.components },
1475
+ (components) => {
1476
+ components.forEach((comp) => {
1477
+ editableIds.add(comp.props.id);
1478
+ });
1479
+ return components;
1480
+ }
1481
+ );
1425
1482
  set((s) => __spreadProps(__spreadValues({}, s), {
1426
1483
  softConfig: buildConfig,
1427
1484
  storedConfig: config,
@@ -1430,6 +1487,8 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1430
1487
  index: itemSelector.index,
1431
1488
  zone: itemSelector.zone || rootDroppableId
1432
1489
  },
1490
+ editingComponentId: selectedItem.props.id,
1491
+ editableComponentIds: editableIds,
1433
1492
  state: "building"
1434
1493
  }));
1435
1494
  setTimeout(
@@ -1437,7 +1496,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1437
1496
  type: "replaceRoot",
1438
1497
  root: {
1439
1498
  title: "Soft Component Builder",
1440
- _name: "New Soft Component"
1499
+ _name: name || "New Soft Component"
1441
1500
  }
1442
1501
  }),
1443
1502
  100
@@ -1454,6 +1513,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1454
1513
  }
1455
1514
  const softComponentVersion = ((_a = selectedItem.props) == null ? void 0 : _a.version) || "1.0.0";
1456
1515
  const softComponent = (_b = get().softComponents[softComponentName]) == null ? void 0 : _b.versions[softComponentVersion];
1516
+ const softComponentMeta = get().softComponents[softComponentName];
1457
1517
  const versions = Object.keys(
1458
1518
  get().softComponents[softComponentName].versions || {}
1459
1519
  );
@@ -1474,18 +1534,50 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1474
1534
  softComponentVersion,
1475
1535
  versions,
1476
1536
  selectedItem.props,
1477
- get().softConfig.components
1537
+ get().softConfig.components,
1538
+ (softComponentMeta == null ? void 0 : softComponentMeta.name) || softComponentName,
1539
+ softComponentMeta == null ? void 0 : softComponentMeta.category
1540
+ );
1541
+ const config = __spreadValues({}, get().softConfig);
1542
+ const overrides = get().overrides;
1543
+ const dependents = get().dependencyGraph.get(softComponentName) || /* @__PURE__ */ new Set();
1544
+ const buildConfig = builderConfig(config, overrides, softComponentName, get().showVersionFields, dependents);
1545
+ const editableIds = /* @__PURE__ */ new Set([]);
1546
+ const decomposedComponents = get().builder.decompose(selectedItem);
1547
+ (0, import_puck4.walkTree)(
1548
+ { root: {}, content: decomposedComponents || [] },
1549
+ { components: config.components },
1550
+ (components) => {
1551
+ components.forEach((comp) => {
1552
+ editableIds.add(comp.props.id);
1553
+ });
1554
+ return components;
1555
+ }
1478
1556
  );
1479
1557
  puckDispatch({
1480
1558
  type: "setData",
1481
- data: (previous) => __spreadProps(__spreadValues({}, previous), {
1559
+ data: (prevData) => ({
1482
1560
  root: __spreadProps(__spreadValues({}, root), { _versions: versions }),
1483
- content: content || []
1561
+ content: (0, import_puck4.walkTree)(__spreadValues({}, prevData), __spreadValues({}, config), (components) => {
1562
+ const next = components.map((component) => __spreadProps(__spreadValues({}, component), {
1563
+ props: __spreadValues({}, component.props)
1564
+ }));
1565
+ const index = next.findIndex(
1566
+ (component) => component.props.id === selectedItem.props.id
1567
+ );
1568
+ if (index !== -1) {
1569
+ next.splice(
1570
+ index,
1571
+ 1,
1572
+ ...decomposedComponents.map((component) => __spreadProps(__spreadValues({}, component), {
1573
+ props: __spreadValues({}, component.props)
1574
+ }))
1575
+ );
1576
+ }
1577
+ return next;
1578
+ }).content
1484
1579
  })
1485
1580
  });
1486
- const config = __spreadValues({}, get().softConfig);
1487
- const overrides = get().overrides;
1488
- const buildConfig = builderConfig(config, overrides, softComponentName);
1489
1581
  set((s) => __spreadProps(__spreadValues({}, s), {
1490
1582
  storedConfig: config,
1491
1583
  softConfig: buildConfig,
@@ -1494,62 +1586,109 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1494
1586
  index: itemSelector.index,
1495
1587
  zone: itemSelector.zone || rootDroppableId
1496
1588
  },
1589
+ editingComponentId: selectedItem.props.id,
1590
+ editableComponentIds: editableIds,
1497
1591
  state: "remodeling"
1498
1592
  }));
1499
1593
  setTimeout(
1500
1594
  () => puckDispatch({
1501
1595
  type: "replaceRoot",
1502
1596
  root: {
1503
- title: "Soft Component Builder",
1504
- _name: "New Soft Component"
1597
+ title: root.props.title,
1598
+ _name: root.props._name,
1599
+ _category: root.props._category
1505
1600
  }
1506
1601
  }),
1507
1602
  100
1508
1603
  );
1509
1604
  },
1510
- complete: (appState, setHistories) => {
1511
- var _a, _b;
1605
+ complete: (appState, setHistories, getItemBySelector) => {
1606
+ var _a, _b, _c, _d, _e;
1512
1607
  if (get().state === "ready") {
1513
1608
  throw new Error("Not building or remodeling a component.");
1514
1609
  }
1515
- const componentName = (_b = (_a = appState.data.root) == null ? void 0 : _a.props) == null ? void 0 : _b._name;
1516
- if (!componentName) {
1610
+ const displayName = (_c = (_b = (_a = appState.data.root) == null ? void 0 : _a.props) == null ? void 0 : _b._name) == null ? void 0 : _c.trim();
1611
+ if (!displayName) {
1517
1612
  throw new Error("Root component must have a name to compose.");
1518
1613
  }
1519
- const [newSoftComponentConfig, version] = get().builder.compose(appState, componentName) || [];
1614
+ const itemSelector = get().itemSelector;
1615
+ if (!itemSelector) {
1616
+ throw new Error("No item selector found for completed component.");
1617
+ }
1618
+ const selectedItem = getItemBySelector(
1619
+ itemSelector
1620
+ );
1621
+ if (!selectedItem) {
1622
+ throw new Error("Cannot find item being edited");
1623
+ }
1624
+ const rootCategory = (_e = (_d = appState.data.root) == null ? void 0 : _d.props) == null ? void 0 : _e._category;
1625
+ const componentName = createComponentKeyFromName(displayName, get().overrides, {
1626
+ existingKeys: Object.keys(get().softComponents),
1627
+ state: get().state
1628
+ });
1629
+ if (!componentName) {
1630
+ throw new Error("Failed to generate component key from name.");
1631
+ }
1632
+ const [newSoftComponentConfig, version] = get().builder.compose(
1633
+ appState,
1634
+ componentName,
1635
+ selectedItem,
1636
+ displayName,
1637
+ rootCategory
1638
+ ) || [];
1520
1639
  if (!newSoftComponentConfig) {
1521
1640
  throw new Error("Failed to compose new soft component config.");
1522
1641
  }
1523
1642
  const storedHistories = get().originalHistory;
1524
1643
  setHistories([...storedHistories]);
1525
1644
  const config = __spreadValues({}, get().softConfig || initialConfig);
1526
- set((s) => __spreadProps(__spreadValues({}, s), {
1527
- softConfig: __spreadProps(__spreadValues({}, config), {
1528
- root: __spreadValues({}, initialConfig.root),
1529
- components: __spreadProps(__spreadValues({}, Object.entries(config.components).reduce(
1530
- (acc, [name, component]) => {
1531
- var _a2;
1532
- let tempComponent = (_a2 = config.components) == null ? void 0 : _a2[name];
1533
- if (tempComponent) {
1534
- acc[name] = tempComponent;
1535
- acc[name].render = tempComponent.render;
1536
- } else {
1537
- tempComponent = __spreadValues({}, component);
1538
- tempComponent == null ? true : delete tempComponent.resolvePermissions;
1539
- tempComponent == null ? true : delete tempComponent.resolveData;
1540
- acc[name] = tempComponent;
1541
- }
1542
- return acc;
1543
- },
1544
- {}
1545
- )), {
1546
- [componentName]: __spreadValues({}, newSoftComponentConfig)
1645
+ set((s) => {
1646
+ var _a2, _b2;
1647
+ const nextComponents = __spreadProps(__spreadValues({}, Object.entries(config.components).reduce(
1648
+ (acc, [name, component]) => {
1649
+ var _a3;
1650
+ let tempComponent = (_a3 = config.components) == null ? void 0 : _a3[name];
1651
+ if (tempComponent) {
1652
+ acc[name] = tempComponent;
1653
+ acc[name].render = tempComponent.render;
1654
+ } else {
1655
+ tempComponent = __spreadValues({}, component);
1656
+ tempComponent == null ? true : delete tempComponent.resolvePermissions;
1657
+ tempComponent == null ? true : delete tempComponent.resolveData;
1658
+ acc[name] = tempComponent;
1659
+ }
1660
+ return acc;
1661
+ },
1662
+ {}
1663
+ )), {
1664
+ [componentName]: __spreadValues({}, newSoftComponentConfig)
1665
+ });
1666
+ const categories = get().softConfig.categories || {};
1667
+ const nextCategories = rootCategory ? __spreadProps(__spreadValues({}, categories), {
1668
+ [rootCategory]: __spreadProps(__spreadValues({}, categories[rootCategory] || {}), {
1669
+ title: ((_a2 = categories[rootCategory]) == null ? void 0 : _a2.title) || rootCategory,
1670
+ components: Array.from(
1671
+ /* @__PURE__ */ new Set([
1672
+ ...((_b2 = categories[rootCategory]) == null ? void 0 : _b2.components) || [],
1673
+ componentName
1674
+ ])
1675
+ )
1547
1676
  })
1548
- }),
1549
- storedConfig: void 0,
1550
- state: "inspecting",
1551
- originalHistory: []
1552
- }));
1677
+ }) : categories;
1678
+ return __spreadProps(__spreadValues({}, s), {
1679
+ softConfig: __spreadProps(__spreadValues({}, config), {
1680
+ root: __spreadValues({}, initialConfig.root),
1681
+ components: nextComponents,
1682
+ categories: nextCategories
1683
+ }),
1684
+ storedConfig: void 0,
1685
+ state: "inspecting",
1686
+ originalHistory: [],
1687
+ editingComponentId: null,
1688
+ editableComponentIds: /* @__PURE__ */ new Set()
1689
+ });
1690
+ });
1691
+ get().rebuildDependents(componentName, version);
1553
1692
  return componentName;
1554
1693
  },
1555
1694
  inspect: (componentName, puckDispatch) => {
@@ -1576,7 +1715,9 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1576
1715
  set((s) => __spreadProps(__spreadValues({}, s), {
1577
1716
  state: "ready",
1578
1717
  setItemSelector: void 0,
1579
- setOriginalItem: void 0
1718
+ setOriginalItem: void 0,
1719
+ editingComponentId: null,
1720
+ editableComponentIds: /* @__PURE__ */ new Set()
1580
1721
  }));
1581
1722
  },
1582
1723
  cancel: (setHistories) => {
@@ -1588,10 +1729,12 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1588
1729
  originalHistory: [],
1589
1730
  itemSelector: null,
1590
1731
  originalItem: null,
1591
- state: "ready"
1732
+ state: "ready",
1733
+ editingComponentId: null,
1734
+ editableComponentIds: /* @__PURE__ */ new Set()
1592
1735
  }));
1593
1736
  },
1594
- compose: (appState, componentName) => {
1737
+ compose: (appState, componentName, editedItem, displayName, category) => {
1595
1738
  if (!componentName) {
1596
1739
  throw new Error("Root component must have a name to compose.");
1597
1740
  }
@@ -1601,12 +1744,21 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1601
1744
  `Component name "${componentName}" already exists in the configuration.`
1602
1745
  );
1603
1746
  }
1604
- const [softComponent, version] = softComponentFromAppState(appState, componentConfigs);
1747
+ const [softComponent, version] = softComponentFromAppState(
1748
+ appState,
1749
+ componentConfigs,
1750
+ editedItem,
1751
+ {
1752
+ name: displayName,
1753
+ category
1754
+ }
1755
+ );
1605
1756
  const existingComponent = get().softComponents[componentName];
1606
1757
  const allVersions = Object.keys((existingComponent == null ? void 0 : existingComponent.versions) || {});
1607
1758
  const isNewVersion = !allVersions.includes(version);
1608
1759
  const newSoftComponentConfig = createVersionedComponentConfig(
1609
1760
  componentName,
1761
+ displayName,
1610
1762
  version,
1611
1763
  isNewVersion ? [...allVersions, version] : allVersions,
1612
1764
  get().softConfig,
@@ -1617,7 +1769,8 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1617
1769
  })
1618
1770
  })
1619
1771
  }),
1620
- softComponent.defaultProps
1772
+ softComponent.defaultProps,
1773
+ get().showVersionFields
1621
1774
  );
1622
1775
  get().setSoftComponent(componentName, version, softComponent);
1623
1776
  return [newSoftComponentConfig, version];
@@ -1653,6 +1806,7 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1653
1806
  throw new Error("Can only switch versions during remodeling.");
1654
1807
  }
1655
1808
  const softComponent = (_a = get().softComponents[componentName]) == null ? void 0 : _a.versions[newVersion];
1809
+ const softComponentMeta = get().softComponents[componentName];
1656
1810
  if (!softComponent) {
1657
1811
  throw new Error(
1658
1812
  `Soft component "${componentName}" with version "${newVersion}" not found.`
@@ -1667,7 +1821,9 @@ var createBuildersSlice = (set, get, initialConfig) => ({
1667
1821
  newVersion,
1668
1822
  versions,
1669
1823
  currentProps,
1670
- get().softConfig.components
1824
+ get().softConfig.components,
1825
+ (softComponentMeta == null ? void 0 : softComponentMeta.name) || componentName,
1826
+ softComponentMeta == null ? void 0 : softComponentMeta.category
1671
1827
  );
1672
1828
  puckDispatch({
1673
1829
  type: "setData",
@@ -1719,10 +1875,11 @@ function hydrateSoftComponentsTransforms(softComponents, hydrator) {
1719
1875
  })
1720
1876
  });
1721
1877
  });
1722
- hydrated[name] = {
1878
+ hydrated[name] = __spreadProps(__spreadValues({}, comp), {
1879
+ name: comp.name || name,
1723
1880
  defaultVersion: comp.defaultVersion,
1724
1881
  versions
1725
- };
1882
+ });
1726
1883
  });
1727
1884
  return hydrated;
1728
1885
  }
@@ -1749,6 +1906,27 @@ function extractDependencies(softComponents, componentName, version) {
1749
1906
  processSubComponents(component.components);
1750
1907
  return dependencies;
1751
1908
  }
1909
+ function buildReverseDependencyGraph(softComponents) {
1910
+ const reverseDeps = /* @__PURE__ */ new Map();
1911
+ for (const [componentName, component] of Object.entries(softComponents)) {
1912
+ const defaultVersion = component.defaultVersion || Object.keys(component.versions || {}).pop();
1913
+ if (!defaultVersion) continue;
1914
+ Object.entries(component.versions || {}).forEach(([version, versionedComp]) => {
1915
+ const dependencies = extractDependencies(softComponents, componentName, version);
1916
+ if (!component.dependencies) {
1917
+ component.dependencies = {};
1918
+ }
1919
+ component.dependencies[version] = dependencies;
1920
+ for (const dep of dependencies) {
1921
+ if (!reverseDeps.has(dep)) {
1922
+ reverseDeps.set(dep, /* @__PURE__ */ new Set());
1923
+ }
1924
+ reverseDeps.get(dep).add(componentName);
1925
+ }
1926
+ });
1927
+ }
1928
+ return reverseDeps;
1929
+ }
1752
1930
  function topologicalSort(softComponents, hardComponentNames) {
1753
1931
  const sorted = [];
1754
1932
  const visiting = /* @__PURE__ */ new Set();
@@ -1792,7 +1970,7 @@ function topologicalSort(softComponents, hardComponentNames) {
1792
1970
  }
1793
1971
  return sorted;
1794
1972
  }
1795
- function buildInitialSoftComponents(hardConfig, softComponents, overrides) {
1973
+ function buildInitialSoftComponents(hardConfig, softComponents, overrides, showVersioning = false) {
1796
1974
  var _a, _b;
1797
1975
  if (!softComponents || Object.keys(softComponents).length === 0) {
1798
1976
  return {};
@@ -1821,12 +1999,14 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides) {
1821
1999
  }
1822
2000
  const newSoftComponentConfig = createVersionedComponentConfig(
1823
2001
  name,
2002
+ comp.name || name,
1824
2003
  defaultVersion || "1.0.0",
1825
2004
  allVersions,
1826
2005
  buildingConfig,
1827
2006
  // Pass the accumulating config
1828
2007
  hydratedSoftComponents,
1829
- versionedComponent.defaultProps
2008
+ versionedComponent.defaultProps,
2009
+ showVersioning
1830
2010
  );
1831
2011
  componentConfigs[name] = newSoftComponentConfig;
1832
2012
  buildingConfig.components[name] = newSoftComponentConfig;
@@ -1848,11 +2028,13 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides) {
1848
2028
  }
1849
2029
  const newSoftComponentConfig = createVersionedComponentConfig(
1850
2030
  name,
2031
+ comp.name || name,
1851
2032
  defaultVersion || "1.0.0",
1852
2033
  allVersions,
1853
2034
  hardConfig,
1854
2035
  hydratedSoftComponents,
1855
- versionedComponent.defaultProps
2036
+ versionedComponent.defaultProps,
2037
+ showVersioning
1856
2038
  );
1857
2039
  componentConfigs[name] = newSoftComponentConfig;
1858
2040
  }
@@ -1860,21 +2042,114 @@ function buildInitialSoftComponents(hardConfig, softComponents, overrides) {
1860
2042
  }
1861
2043
  }
1862
2044
 
2045
+ // src/puck/lib/edit-visibility-utils.ts
2046
+ var setEditVisibility = (doc, context) => {
2047
+ if (!doc) return;
2048
+ try {
2049
+ const root = doc.documentElement;
2050
+ if (context.mode === "none") {
2051
+ root.removeAttribute("data-edit-mode");
2052
+ root.classList.remove("edit-visibility-mode");
2053
+ doc.querySelectorAll("[data-puck-component]").forEach((el) => {
2054
+ el.removeAttribute("data-edit-visibility");
2055
+ el.classList.remove("edit-visibility-greyed", "edit-visibility-editable", "edit-visibility-dependency");
2056
+ });
2057
+ } else {
2058
+ root.setAttribute("data-edit-mode", context.mode);
2059
+ root.classList.add("edit-visibility-mode");
2060
+ doc.querySelectorAll("[data-puck-component]").forEach((el) => {
2061
+ var _a;
2062
+ const id = el.getAttribute("data-puck-component");
2063
+ if (!id) return;
2064
+ const isEditable = context.editableIds.has(id);
2065
+ const isDependency = (_a = context.highlightDependencyIds) == null ? void 0 : _a.has(id);
2066
+ if (isEditable) {
2067
+ el.setAttribute("data-edit-visibility", "editable");
2068
+ el.classList.remove("edit-visibility-greyed", "edit-visibility-dependency");
2069
+ el.classList.add("edit-visibility-editable");
2070
+ } else if (isDependency) {
2071
+ el.setAttribute("data-edit-visibility", "dependency");
2072
+ el.classList.remove("edit-visibility-greyed", "edit-visibility-editable");
2073
+ el.classList.add("edit-visibility-dependency");
2074
+ } else {
2075
+ el.setAttribute("data-edit-visibility", "greyed");
2076
+ el.classList.remove("edit-visibility-editable", "edit-visibility-dependency");
2077
+ el.classList.add("edit-visibility-greyed");
2078
+ }
2079
+ });
2080
+ }
2081
+ } catch (error) {
2082
+ console.warn(`Failed to set edit visibility:`, error);
2083
+ }
2084
+ };
2085
+ var clearEditVisibility = (doc) => {
2086
+ if (!doc) return;
2087
+ try {
2088
+ const root = doc.documentElement;
2089
+ root.removeAttribute("data-edit-mode");
2090
+ root.classList.remove("edit-visibility-mode");
2091
+ doc.querySelectorAll("[data-puck-component]").forEach((el) => {
2092
+ el.removeAttribute("data-edit-visibility");
2093
+ el.classList.remove("edit-visibility-greyed", "edit-visibility-editable", "edit-visibility-dependency");
2094
+ });
2095
+ } catch (error) {
2096
+ console.warn(`Failed to clear edit visibility:`, error);
2097
+ }
2098
+ };
2099
+
1863
2100
  // src/puck/store/index.tsx
1864
2101
  var createSoftConfigStore = (hardConfig = {
1865
2102
  components: {}
1866
- }, softComponents = {}, overrides = {}, onActions) => {
2103
+ }, softComponents = {}, overrides = {}, onActions, showVersionFields = true) => {
2104
+ const normalizedSoftComponents = Object.fromEntries(
2105
+ Object.entries(softComponents || {}).map(([key, value]) => [
2106
+ key,
2107
+ __spreadProps(__spreadValues({}, value), {
2108
+ name: value.name || key
2109
+ })
2110
+ ])
2111
+ );
2112
+ const iframeDocRef = { current: null };
1867
2113
  const hydratedSoftComponents = (overrides == null ? void 0 : overrides.hydrateMapTransform) ? hydrateSoftComponentsTransforms(
1868
- softComponents,
2114
+ normalizedSoftComponents,
1869
2115
  overrides.hydrateMapTransform
1870
- ) : softComponents;
2116
+ ) : normalizedSoftComponents;
2117
+ const initialDependencyGraph = buildReverseDependencyGraph(
2118
+ hydratedSoftComponents
2119
+ );
1871
2120
  return (0, import_zustand2.create)()(
1872
2121
  (0, import_middleware.subscribeWithSelector)(
1873
- (0, import_middleware.devtools)((set, get) => ({
2122
+ (set, get) => ({
1874
2123
  state: "ready",
1875
2124
  originalHistory: [],
1876
2125
  overrides,
1877
2126
  onActions,
2127
+ iframeDocRef,
2128
+ showVersionFields,
2129
+ setShowVersionFields: (show) => set({ showVersionFields: show }),
2130
+ getIframeDoc: () => iframeDocRef.current,
2131
+ setIframeDoc: (doc) => {
2132
+ iframeDocRef.current = doc;
2133
+ if (!doc) {
2134
+ return;
2135
+ }
2136
+ const { state, editableComponentIds } = get();
2137
+ if (state === "building") {
2138
+ setEditVisibility(doc, {
2139
+ mode: "build",
2140
+ editableIds: editableComponentIds
2141
+ });
2142
+ return;
2143
+ }
2144
+ if (state === "remodeling") {
2145
+ setEditVisibility(doc, {
2146
+ mode: "remodel",
2147
+ editableIds: editableComponentIds
2148
+ });
2149
+ return;
2150
+ }
2151
+ clearEditVisibility(doc);
2152
+ },
1878
2153
  storeHistory: (history) => set({ originalHistory: history }),
1879
2154
  removeHistory: () => set({ originalHistory: [] }),
1880
2155
  itemSelector: null,
@@ -1883,24 +2158,29 @@ var createSoftConfigStore = (hardConfig = {
1883
2158
  setOriginalItem: (item) => set({ originalItem: item }),
1884
2159
  hydratedSoftComponents,
1885
2160
  softComponents: hydratedSoftComponents,
2161
+ dependencyGraph: initialDependencyGraph,
1886
2162
  softConfig: __spreadProps(__spreadValues({}, hardConfig), {
1887
2163
  components: __spreadValues(__spreadValues({}, hardConfig.components), buildInitialSoftComponents(
1888
2164
  hardConfig,
1889
2165
  hydratedSoftComponents,
1890
2166
  overrides
1891
- ))
2167
+ )),
2168
+ categories: __spreadValues({}, hardConfig.categories || {})
1892
2169
  }),
1893
2170
  setSoftComponent: (name, version, component) => {
2171
+ const existing = get().softComponents[name];
1894
2172
  set((state) => {
1895
- var _a;
2173
+ var _a, _b;
1896
2174
  return {
1897
2175
  softComponents: __spreadProps(__spreadValues({}, state.softComponents), {
1898
- [name]: {
2176
+ [name]: __spreadProps(__spreadValues({}, existing), {
2177
+ name: component.name || (existing == null ? void 0 : existing.name) || name,
2178
+ category: (_a = component.category) != null ? _a : existing == null ? void 0 : existing.category,
1899
2179
  defaultVersion: version,
1900
- versions: __spreadProps(__spreadValues({}, ((_a = state.softComponents[name]) == null ? void 0 : _a.versions) || {}), {
2180
+ versions: __spreadProps(__spreadValues({}, ((_b = state.softComponents[name]) == null ? void 0 : _b.versions) || {}), {
1901
2181
  [version]: component
1902
2182
  })
1903
- }
2183
+ })
1904
2184
  })
1905
2185
  };
1906
2186
  });
@@ -1912,19 +2192,23 @@ var createSoftConfigStore = (hardConfig = {
1912
2192
  Object.entries(incomingComponents).forEach(([name, data]) => {
1913
2193
  const existing = nextSoftComponents[name];
1914
2194
  const finalComponentData = existing ? __spreadProps(__spreadValues(__spreadValues({}, existing), data), {
2195
+ name: data.name || existing.name || name,
1915
2196
  versions: __spreadValues(__spreadValues({}, existing.versions), data.versions)
1916
2197
  }) : data;
2198
+ finalComponentData.name = finalComponentData.name || name;
1917
2199
  nextSoftComponents[name] = finalComponentData;
1918
2200
  const activeVersion = finalComponentData.defaultVersion;
1919
2201
  const activeVersionData = finalComponentData.versions[activeVersion];
1920
2202
  if (activeVersionData) {
1921
2203
  nextConfigComponents[name] = createVersionedComponentConfig(
1922
2204
  name,
2205
+ finalComponentData.name || name,
1923
2206
  activeVersion,
1924
2207
  Object.keys(finalComponentData.versions),
1925
2208
  state.softConfig,
1926
2209
  nextSoftComponents,
1927
- activeVersionData.defaultProps
2210
+ activeVersionData.defaultProps,
2211
+ state.showVersionFields
1928
2212
  );
1929
2213
  }
1930
2214
  });
@@ -1949,11 +2233,13 @@ var createSoftConfigStore = (hardConfig = {
1949
2233
  if (activeVersionData) {
1950
2234
  nextConfigComponents[name] = createVersionedComponentConfig(
1951
2235
  name,
2236
+ componentData.name || name,
1952
2237
  activeVersion,
1953
2238
  Object.keys(componentData.versions),
1954
2239
  softConfig,
1955
2240
  hydratedComponents,
1956
- activeVersionData.defaultProps
2241
+ activeVersionData.defaultProps,
2242
+ get().showVersionFields
1957
2243
  );
1958
2244
  }
1959
2245
  });
@@ -1965,11 +2251,12 @@ var createSoftConfigStore = (hardConfig = {
1965
2251
  });
1966
2252
  },
1967
2253
  setSoftComponentDefaultVersion: (name, version) => {
1968
- var _a, _b, _c;
2254
+ var _a, _b, _c, _d;
1969
2255
  const softComponent = (_b = (_a = get().softComponents[name]) == null ? void 0 : _a.versions) == null ? void 0 : _b[version];
1970
2256
  const allVersions = Object.keys(
1971
2257
  ((_c = get().softComponents[name]) == null ? void 0 : _c.versions) || {}
1972
2258
  );
2259
+ const displayName = ((_d = get().softComponents[name]) == null ? void 0 : _d.name) || name;
1973
2260
  if (!softComponent) {
1974
2261
  throw new Error(
1975
2262
  `Soft component "${name}" version "${version}" does not exist.`
@@ -1977,11 +2264,13 @@ var createSoftConfigStore = (hardConfig = {
1977
2264
  }
1978
2265
  const newSoftComponentConfig = createVersionedComponentConfig(
1979
2266
  name,
2267
+ displayName,
1980
2268
  version,
1981
2269
  allVersions,
1982
2270
  get().softConfig,
1983
2271
  get().softComponents,
1984
- softComponent.defaultProps
2272
+ softComponent.defaultProps,
2273
+ get().showVersionFields
1985
2274
  );
1986
2275
  set((state) => ({
1987
2276
  softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
@@ -2029,20 +2318,20 @@ var createSoftConfigStore = (hardConfig = {
2029
2318
  },
2030
2319
  setSoftComponentConfig: (key, config, category) => {
2031
2320
  set((state) => {
2032
- var _a;
2321
+ var _a, _b, _c;
2033
2322
  return {
2034
2323
  softConfig: __spreadProps(__spreadValues({}, state.softConfig), {
2035
2324
  components: __spreadProps(__spreadValues({}, state.softConfig.components), {
2036
2325
  [key]: __spreadValues({}, config)
2037
2326
  }),
2038
- categories: category && state.softConfig.categories ? __spreadProps(__spreadValues({}, state.softConfig.categories), {
2039
- [category]: __spreadProps(__spreadValues({}, state.softConfig.categories[category]), {
2327
+ categories: category ? __spreadProps(__spreadValues({}, state.softConfig.categories || {}), {
2328
+ [category]: __spreadProps(__spreadValues({}, ((_a = state.softConfig.categories) == null ? void 0 : _a[category]) || {}), {
2040
2329
  components: [
2041
- ...((_a = state.softConfig.categories[category]) == null ? void 0 : _a.components) || [],
2330
+ ...((_c = (_b = state.softConfig.categories) == null ? void 0 : _b[category]) == null ? void 0 : _c.components) || [],
2042
2331
  key
2043
2332
  ]
2044
2333
  })
2045
- }) : state.softConfig.categories
2334
+ }) : state.softConfig.categories || {}
2046
2335
  })
2047
2336
  };
2048
2337
  });
@@ -2081,8 +2370,50 @@ var createSoftConfigStore = (hardConfig = {
2081
2370
  })
2082
2371
  }));
2083
2372
  },
2084
- builder: createBuildersSlice(set, get, hardConfig)
2085
- }))
2373
+ builder: createBuildersSlice(set, get, hardConfig),
2374
+ editingComponentId: null,
2375
+ editableComponentIds: /* @__PURE__ */ new Set(),
2376
+ setEditableComponentIds: (ids) => set({ editableComponentIds: ids }),
2377
+ addEditableComponentId: (id) => {
2378
+ set((state) => {
2379
+ const newIds = new Set(state.editableComponentIds);
2380
+ newIds.add(id);
2381
+ return { editableComponentIds: newIds };
2382
+ });
2383
+ },
2384
+ clearEditingState: () => set({
2385
+ editingComponentId: null,
2386
+ editableComponentIds: /* @__PURE__ */ new Set()
2387
+ }),
2388
+ rebuildDependents: (componentName, version) => {
2389
+ const state = get();
2390
+ const dependents = state.dependencyGraph.get(componentName) || /* @__PURE__ */ new Set();
2391
+ if (dependents.size === 0) return;
2392
+ const config = __spreadValues({}, state.softConfig);
2393
+ const softComponents2 = state.softComponents;
2394
+ const toBuild = Array.from(dependents);
2395
+ for (const dependentName of toBuild) {
2396
+ const dependent = softComponents2[dependentName];
2397
+ const defaultVersion = dependent.defaultVersion || Object.keys(dependent.versions || {}).pop();
2398
+ if (!defaultVersion) continue;
2399
+ const versionedComponent = dependent.versions[defaultVersion];
2400
+ const allVersions = Object.keys(dependent.versions || {});
2401
+ if (!versionedComponent) continue;
2402
+ const newConfig = createVersionedComponentConfig(
2403
+ dependentName,
2404
+ dependent.name || dependentName,
2405
+ defaultVersion,
2406
+ allVersions,
2407
+ config,
2408
+ softComponents2,
2409
+ versionedComponent.defaultProps,
2410
+ state.showVersionFields
2411
+ );
2412
+ config.components[dependentName] = newConfig;
2413
+ }
2414
+ set((s) => __spreadProps(__spreadValues({}, s), { softConfig: config }));
2415
+ }
2416
+ })
2086
2417
  )
2087
2418
  );
2088
2419
  };
@@ -2096,11 +2427,12 @@ var SoftConfigProvider = ({
2096
2427
  softComponents,
2097
2428
  overrides,
2098
2429
  value,
2099
- onActions
2430
+ onActions,
2431
+ useVersioning = false
2100
2432
  }) => {
2101
2433
  const store = value != null ? value : (0, import_react5.useMemo)(
2102
- () => createSoftConfigStore(hardConfig, softComponents, overrides, onActions),
2103
- [hardConfig, softComponents, overrides, onActions]
2434
+ () => createSoftConfigStore(hardConfig, softComponents, overrides, onActions, useVersioning),
2435
+ [hardConfig, softComponents, overrides, onActions, useVersioning]
2104
2436
  );
2105
2437
  const [softConfig, setSoftConfig] = (0, import_react5.useState)(
2106
2438
  () => store.getState().softConfig
@@ -2108,6 +2440,53 @@ var SoftConfigProvider = ({
2108
2440
  const [internalSoftComponents, setSoftComponents] = (0, import_react5.useState)(
2109
2441
  () => store.getState().softComponents
2110
2442
  );
2443
+ const storeSetIframeDoc = (0, import_react5.useMemo)(
2444
+ () => store.getState().setIframeDoc,
2445
+ [store]
2446
+ );
2447
+ const validateAction = (0, import_react5.useMemo)(
2448
+ () => (action) => {
2449
+ const currentState = store.getState();
2450
+ if (currentState.state === "ready") {
2451
+ return true;
2452
+ }
2453
+ const editableIds = currentState.editableComponentIds;
2454
+ if (action.type === "replace") {
2455
+ if (action.data.props.id && editableIds.has(action.data.props.id)) {
2456
+ return true;
2457
+ }
2458
+ return false;
2459
+ }
2460
+ if (action.type === "insert" || action.type === "duplicate") {
2461
+ const zone = action.type === "insert" ? action.destinationZone : action.sourceZone;
2462
+ const parentId = zone == null ? void 0 : zone.split(":")[0];
2463
+ if (parentId && !editableIds.has(parentId)) {
2464
+ return false;
2465
+ }
2466
+ if (action.type === "insert") {
2467
+ const childId = action.id;
2468
+ if (childId) {
2469
+ currentState.addEditableComponentId(childId);
2470
+ }
2471
+ }
2472
+ return true;
2473
+ }
2474
+ if (action.type === "remove" || action.type === "move" || action.type === "reorder") {
2475
+ let parentId;
2476
+ if (action.type === "remove") {
2477
+ parentId = action.zone.split(":")[0];
2478
+ } else if (action.type === "move" || action.type === "reorder") {
2479
+ parentId = action.destinationZone.split(":")[0];
2480
+ }
2481
+ if (parentId && !editableIds.has(parentId)) {
2482
+ return false;
2483
+ }
2484
+ return true;
2485
+ }
2486
+ return true;
2487
+ },
2488
+ [store]
2489
+ );
2111
2490
  (0, import_react5.useEffect)(() => {
2112
2491
  const unsubscribe = store.subscribe(() => {
2113
2492
  setSoftConfig(store.getState().softConfig);
@@ -2117,11 +2496,37 @@ var SoftConfigProvider = ({
2117
2496
  unsubscribe();
2118
2497
  };
2119
2498
  }, [store]);
2120
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(appStoreContext.Provider, { value: store, children: children(softConfig, internalSoftComponents) });
2499
+ (0, import_react5.useEffect)(() => {
2500
+ const unsubscribe = store.subscribe((state, prevState) => {
2501
+ if (prevState && state.state === prevState.state && state.editableComponentIds === prevState.editableComponentIds) {
2502
+ return;
2503
+ }
2504
+ const doc = store.getState().getIframeDoc();
2505
+ if (!doc) return;
2506
+ if (state.state === "building") {
2507
+ setEditVisibility(doc, { mode: "build", editableIds: state.editableComponentIds });
2508
+ return;
2509
+ }
2510
+ if (state.state === "remodeling") {
2511
+ setEditVisibility(doc, { mode: "remodel", editableIds: state.editableComponentIds });
2512
+ return;
2513
+ }
2514
+ requestAnimationFrame(() => {
2515
+ const freshDoc = store.getState().getIframeDoc();
2516
+ if (freshDoc) {
2517
+ clearEditVisibility(freshDoc);
2518
+ }
2519
+ });
2520
+ });
2521
+ return () => {
2522
+ unsubscribe();
2523
+ };
2524
+ }, [store]);
2525
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(appStoreContext.Provider, { value: store, children: children(softConfig, internalSoftComponents, storeSetIframeDoc, validateAction) });
2121
2526
  };
2122
2527
 
2123
2528
  // src/puck/actions/useBuild.tsx
2124
- var import_puck4 = require("@measured/puck");
2529
+ var import_puck5 = require("@measured/puck");
2125
2530
 
2126
2531
  // src/puck/lib/notify.ts
2127
2532
  var customHandler = null;
@@ -2166,7 +2571,7 @@ var useActionEvent = () => {
2166
2571
  };
2167
2572
 
2168
2573
  // src/puck/actions/useBuild.tsx
2169
- var useCustomPuck2 = (0, import_puck4.createUsePuck)();
2574
+ var useCustomPuck2 = (0, import_puck5.createUsePuck)();
2170
2575
  var useBuild = () => {
2171
2576
  const build = useSoftConfig((s) => s.builder.build);
2172
2577
  const history = useCustomPuck2((s) => s.history.histories);
@@ -2201,8 +2606,8 @@ var useBuild = () => {
2201
2606
  };
2202
2607
 
2203
2608
  // src/puck/actions/useRemodel.tsx
2204
- var import_puck5 = require("@measured/puck");
2205
- var useCustomPuck3 = (0, import_puck5.createUsePuck)();
2609
+ var import_puck6 = require("@measured/puck");
2610
+ var useCustomPuck3 = (0, import_puck6.createUsePuck)();
2206
2611
  var useRemodel = () => {
2207
2612
  const remodel = useSoftConfig((s) => s.builder.remodel);
2208
2613
  const history = useCustomPuck3((s) => s.history.histories);
@@ -2211,6 +2616,7 @@ var useRemodel = () => {
2211
2616
  const dispatch = useCustomPuck3((s) => s.dispatch);
2212
2617
  const status = useSoftConfig((s) => s.state);
2213
2618
  const softComponents = useSoftConfig((s) => s.softComponents);
2619
+ const refreshPermissions = useCustomPuck3((s) => s.refreshPermissions);
2214
2620
  const { triggerAction } = useActionEvent();
2215
2621
  const handleRemodel = (componentName) => {
2216
2622
  if (status !== "ready") {
@@ -2223,7 +2629,7 @@ var useRemodel = () => {
2223
2629
  return;
2224
2630
  }
2225
2631
  try {
2226
- remodel(history, selectedItem, itemSelector, dispatch);
2632
+ remodel(history, selectedItem, itemSelector, dispatch, refreshPermissions);
2227
2633
  void triggerAction({
2228
2634
  type: "remodel",
2229
2635
  payload: {
@@ -2245,13 +2651,14 @@ var useRemodel = () => {
2245
2651
  };
2246
2652
 
2247
2653
  // src/puck/actions/useComplete.tsx
2248
- var import_puck6 = require("@measured/puck");
2654
+ var import_puck7 = require("@measured/puck");
2249
2655
  var import_react7 = require("react");
2250
- var useCustomPuck4 = (0, import_puck6.createUsePuck)();
2656
+ var useCustomPuck4 = (0, import_puck7.createUsePuck)();
2251
2657
  var useComplete = () => {
2252
2658
  const complete = useSoftConfig((s) => s.builder.complete);
2253
2659
  const appState = useCustomPuck4((s) => s.appState);
2254
2660
  const setHistories = useCustomPuck4((s) => s.history.setHistories);
2661
+ const getItemBySelector = useCustomPuck4((s) => s.getItemBySelector);
2255
2662
  const status = useSoftConfig((s) => s.state);
2256
2663
  const softComponents = useSoftConfig((s) => s.softComponents);
2257
2664
  const [newComponent, setNewComponent] = (0, import_react7.useState)(null);
@@ -2263,7 +2670,7 @@ var useComplete = () => {
2263
2670
  return null;
2264
2671
  }
2265
2672
  try {
2266
- const componentName = complete(appState, setHistories);
2673
+ const componentName = complete(appState, setHistories, getItemBySelector);
2267
2674
  setNewComponent(componentName);
2268
2675
  const componentData = appState.data.root;
2269
2676
  const softComponent = (_b = softComponents[componentName]) == null ? void 0 : _b.versions[(_a = softComponents[componentName]) == null ? void 0 : _a.defaultVersion];
@@ -2285,14 +2692,14 @@ var useComplete = () => {
2285
2692
  );
2286
2693
  return null;
2287
2694
  }
2288
- }, [complete, appState, setHistories, status, softComponents, triggerAction]);
2695
+ }, [complete, appState, setHistories, status, softComponents, triggerAction, getItemBySelector]);
2289
2696
  const canComplete = status === "building" || status === "remodeling";
2290
2697
  return { handleComplete, canComplete, newComponent, setNewComponent };
2291
2698
  };
2292
2699
 
2293
2700
  // src/puck/actions/useCancel.tsx
2294
- var import_puck7 = require("@measured/puck");
2295
- var useCustomPuck5 = (0, import_puck7.createUsePuck)();
2701
+ var import_puck8 = require("@measured/puck");
2702
+ var useCustomPuck5 = (0, import_puck8.createUsePuck)();
2296
2703
  var useCancel = () => {
2297
2704
  const cancel = useSoftConfig((s) => s.builder.cancel);
2298
2705
  const setHistories = useCustomPuck5((s) => s.history.setHistories);
@@ -2321,9 +2728,9 @@ var useCancel = () => {
2321
2728
  };
2322
2729
 
2323
2730
  // src/puck/actions/useInspect.tsx
2324
- var import_puck8 = require("@measured/puck");
2731
+ var import_puck9 = require("@measured/puck");
2325
2732
  var import_react8 = require("react");
2326
- var useCustomPuck6 = (0, import_puck8.createUsePuck)();
2733
+ var useCustomPuck6 = (0, import_puck9.createUsePuck)();
2327
2734
  var useInspect = (componentName) => {
2328
2735
  const inspect = useSoftConfig((s) => s.builder.inspect);
2329
2736
  const dispatch = useCustomPuck6((s) => s.dispatch);
@@ -2353,8 +2760,8 @@ var useInspect = (componentName) => {
2353
2760
  };
2354
2761
 
2355
2762
  // src/puck/actions/useDecompose.tsx
2356
- var import_puck9 = require("@measured/puck");
2357
- var useCustomPuck7 = (0, import_puck9.createUsePuck)();
2763
+ var import_puck10 = require("@measured/puck");
2764
+ var useCustomPuck7 = (0, import_puck10.createUsePuck)();
2358
2765
  var useDecompose = () => {
2359
2766
  const decompose = useSoftConfig((s) => s.builder.decompose);
2360
2767
  const appState = useCustomPuck7((s) => s.appState);
@@ -2385,7 +2792,7 @@ var useDecompose = () => {
2385
2792
  notify.error("Nothing to decompose.");
2386
2793
  return;
2387
2794
  }
2388
- const newData = (0, import_puck9.walkTree)(appState.data, config, (components) => {
2795
+ const newData = (0, import_puck10.walkTree)(appState.data, config, (components) => {
2389
2796
  const index = components.findIndex((c) => c.props.id === target.props.id);
2390
2797
  if (index !== -1) {
2391
2798
  components.splice(index, 1, ...decomposedComponents);
@@ -2417,8 +2824,8 @@ var useDecompose = () => {
2417
2824
  };
2418
2825
 
2419
2826
  // src/puck/actions/useDemolish.tsx
2420
- var import_puck10 = require("@measured/puck");
2421
- var useCustomPuck8 = (0, import_puck10.createUsePuck)();
2827
+ var import_puck11 = require("@measured/puck");
2828
+ var useCustomPuck8 = (0, import_puck11.createUsePuck)();
2422
2829
  var useDemolish = () => {
2423
2830
  const demolish = useSoftConfig((s) => s.builder.demolish);
2424
2831
  const dispatch = useCustomPuck8((s) => s.dispatch);
@@ -2505,14 +2912,14 @@ var useSetDefaultVersion = () => {
2505
2912
  };
2506
2913
 
2507
2914
  // src/puck/overrides/Header.tsx
2508
- var import_puck12 = require("@measured/puck");
2915
+ var import_puck13 = require("@measured/puck");
2509
2916
 
2510
- // css-module:D:\osamuProjects\netlisian\packages\soft-config\src\puck\overrides\Header.module.css#css-module
2917
+ // css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/Header.module.css#css-module
2511
2918
  var Header_module_default = { "Header": "_Header_19oj9_1" };
2512
2919
 
2513
2920
  // src/puck/actions/usePublish.tsx
2514
- var import_puck11 = require("@measured/puck");
2515
- var useCustomPuck9 = (0, import_puck11.createUsePuck)();
2921
+ var import_puck12 = require("@measured/puck");
2922
+ var useCustomPuck9 = (0, import_puck12.createUsePuck)();
2516
2923
  var usePublish = () => {
2517
2924
  const components = useSoftConfig((s) => s.softComponents);
2518
2925
  const data = useCustomPuck9((s) => s.appState.data);
@@ -2548,18 +2955,20 @@ var usePublish = () => {
2548
2955
  // src/puck/overrides/Header.tsx
2549
2956
  var import_jsx_runtime8 = require("react/jsx-runtime");
2550
2957
  var getClassName2 = get_class_name_factory_default("Header", Header_module_default);
2958
+ var usePuck = (0, import_puck13.createUsePuck)();
2551
2959
  var Header = ({
2552
2960
  onPublish,
2553
2961
  children
2554
2962
  }) => {
2555
- const { handleComplete, canComplete, newComponent, setNewComponent } = useComplete();
2963
+ const { handleComplete, newComponent, setNewComponent } = useComplete();
2556
2964
  const { handleCancel, canCancel } = useCancel();
2557
2965
  const { handlePublish } = usePublish();
2966
+ const puck = usePuck((s) => s.config);
2558
2967
  useInspect(newComponent);
2559
2968
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: getClassName2(), children: canCancel ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
2560
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_puck12.Button, { onClick: handleCancel, children: "Cancel" }),
2969
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_puck13.Button, { onClick: handleCancel, children: "Cancel" }),
2561
2970
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2562
- import_puck12.Button,
2971
+ import_puck13.Button,
2563
2972
  {
2564
2973
  variant: "primary",
2565
2974
  onClick: () => {
@@ -2572,7 +2981,7 @@ var Header = ({
2572
2981
  }
2573
2982
  )
2574
2983
  ] }) : children ? children : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2575
- import_puck12.Button,
2984
+ import_puck13.Button,
2576
2985
  {
2577
2986
  variant: "primary",
2578
2987
  onClick: () => {
@@ -2586,54 +2995,80 @@ var Header = ({
2586
2995
  };
2587
2996
 
2588
2997
  // src/puck/overrides/ActionBar.tsx
2589
- var import_puck13 = require("@measured/puck");
2998
+ var import_react9 = require("react");
2999
+ var import_puck14 = require("@measured/puck");
2590
3000
  var import_lucide_react = require("lucide-react");
2591
3001
 
2592
- // css-module:D:\osamuProjects\netlisian\packages\soft-config\src\puck\overrides\ActionBar.module.css#css-module
3002
+ // css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/ActionBar.module.css#css-module
2593
3003
  var ActionBar_module_default = { "ActionBar": "_ActionBar_pvuie_5", "ActionBar-label": "_ActionBar-label_pvuie_39", "ActionBar-action": "_ActionBar-action_pvuie_63", "ActionBar-group": "_ActionBar-group_pvuie_79" };
2594
3004
 
2595
3005
  // src/puck/overrides/ActionBar.tsx
3006
+ var import_shallow = require("zustand/shallow");
2596
3007
  var import_jsx_runtime9 = require("react/jsx-runtime");
2597
3008
  var getClassName3 = get_class_name_factory_default("ActionBar", ActionBar_module_default);
3009
+ var usePuck2 = (0, import_puck14.createUsePuck)();
2598
3010
  var ActionBarOverride = (props) => {
2599
- const { handleBuild, canBuild } = useBuild();
2600
- const { handleRemodel, canRemodel } = useRemodel();
2601
- const { handleDecompose, canDecompose } = useDecompose();
2602
- const softComponents = useSoftConfig((s) => s.softComponents);
3011
+ var _a;
3012
+ const { handleBuild } = useBuild();
3013
+ const { handleRemodel } = useRemodel();
3014
+ const { handleDecompose } = useDecompose();
3015
+ const overrides = useSoftConfig((s) => s.overrides);
3016
+ const softComponents = useSoftConfig((s) => s.softComponents, import_shallow.shallow);
3017
+ const editableIds = useSoftConfig((s) => s.editableComponentIds);
3018
+ const selectedItem = usePuck2((s) => s.selectedItem);
2603
3019
  const status = useSoftConfig((s) => s.state);
2604
- const isSoftComponent2 = Object.keys(softComponents || {}).includes(props.label);
2605
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName3(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck13.ActionBar, { children: [
2606
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck13.ActionBar.Group, { children: [
3020
+ const softKeys = Object.keys(softComponents);
3021
+ const key = (0, import_react9.useMemo)(() => createComponentKeyFromName(props.label || "", overrides, {
3022
+ existingKeys: softKeys,
3023
+ state: status
3024
+ }), [
3025
+ props.label,
3026
+ overrides,
3027
+ softKeys,
3028
+ status
3029
+ ]);
3030
+ const isSoftComponent2 = softKeys.includes(key);
3031
+ const selectedId = (_a = selectedItem == null ? void 0 : selectedItem.props) == null ? void 0 : _a.id;
3032
+ const isEditable = Boolean(selectedId && editableIds.has(selectedId));
3033
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: getClassName3(), children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck14.ActionBar, { children: [
3034
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck14.ActionBar.Group, { children: [
2607
3035
  props.parentAction,
2608
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_puck13.ActionBar.Label, { label: props.label })
3036
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_puck14.ActionBar.Label, { label: props.label })
2609
3037
  ] }),
2610
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck13.ActionBar.Group, { children: [
3038
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_puck14.ActionBar.Group, { children: [
2611
3039
  status === "ready" ? isSoftComponent2 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2612
3040
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2613
- import_puck13.ActionBar.Action,
3041
+ import_puck14.ActionBar.Action,
2614
3042
  {
2615
- onClick: () => handleRemodel(props.label),
3043
+ onClick: () => handleRemodel(key),
2616
3044
  label: "Remodel Soft Component",
2617
3045
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react.EditIcon, { size: 16 })
2618
3046
  }
2619
3047
  ),
2620
3048
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2621
- import_puck13.ActionBar.Action,
3049
+ import_puck14.ActionBar.Action,
2622
3050
  {
2623
3051
  onClick: () => handleDecompose(),
2624
3052
  label: "Decompose Soft Component",
2625
3053
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react.Combine, { size: 16 })
2626
3054
  }
2627
3055
  )
2628
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_puck13.ActionBar.Action, { onClick: handleBuild, label: "Build Soft Component", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react.ComponentIcon, { size: 16 }) }) : null,
2629
- props.children
3056
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3057
+ import_puck14.ActionBar.Action,
3058
+ {
3059
+ onClick: handleBuild,
3060
+ label: "Build Soft Component",
3061
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_lucide_react.ComponentIcon, { size: 16 })
3062
+ }
3063
+ ) : null,
3064
+ status !== "ready" && !isEditable ? null : props.children
2630
3065
  ] })
2631
3066
  ] }) });
2632
3067
  };
2633
3068
 
2634
3069
  // src/puck/overrides/ComponentItem.tsx
2635
- var import_react10 = require("react");
2636
- var import_puck14 = require("@measured/puck");
3070
+ var import_react11 = require("react");
3071
+ var import_puck15 = require("@measured/puck");
2637
3072
  var import_lucide_react2 = require("lucide-react");
2638
3073
 
2639
3074
  // src/puck/lib/confirm.ts
@@ -2653,14 +3088,14 @@ var confirm = (message) => __async(null, null, function* () {
2653
3088
  }
2654
3089
  });
2655
3090
 
2656
- // css-module:D:\osamuProjects\netlisian\packages\soft-config\src\puck\overrides\ComponentItem.module.css#css-module
2657
- var ComponentItem_module_default = { "ComponentItem": "_ComponentItem_lp9eh_1", "ComponentItem-content": "_ComponentItem-content_lp9eh_14", "ComponentItem-name": "_ComponentItem-name_lp9eh_24", "ComponentItem-version": "_ComponentItem-version_lp9eh_28", "ComponentItem-actions": "_ComponentItem-actions_lp9eh_33", "ComponentItem-settingsButton": "_ComponentItem-settingsButton_lp9eh_39", "ComponentItem-grip": "_ComponentItem-grip_lp9eh_49", "ComponentItem-modal": "_ComponentItem-modal_lp9eh_56", "ComponentItem-modalHeader": "_ComponentItem-modalHeader_lp9eh_63", "ComponentItem-modalTitle": "_ComponentItem-modalTitle_lp9eh_68", "ComponentItem-modalSubtitle": "_ComponentItem-modalSubtitle_lp9eh_75", "ComponentItem-modalBody": "_ComponentItem-modalBody_lp9eh_81", "ComponentItem-section": "_ComponentItem-section_lp9eh_90", "ComponentItem-sectionTitle": "_ComponentItem-sectionTitle_lp9eh_96", "ComponentItem-sectionDescription": "_ComponentItem-sectionDescription_lp9eh_103", "ComponentItem-versionList": "_ComponentItem-versionList_lp9eh_109", "ComponentItem-versionRow": "_ComponentItem-versionRow_lp9eh_115", "ComponentItem-versionRow--isDefault": "_ComponentItem-versionRow--isDefault_lp9eh_126", "ComponentItem-versionRow--isMarkedForDeletion": "_ComponentItem-versionRow--isMarkedForDeletion_lp9eh_131", "ComponentItem-versionInfo": "_ComponentItem-versionInfo_lp9eh_136", "ComponentItem-versionNumber": "_ComponentItem-versionNumber_lp9eh_143", "ComponentItem-defaultBadge": "_ComponentItem-defaultBadge_lp9eh_149", "ComponentItem-deleteBadge": "_ComponentItem-deleteBadge_lp9eh_160", "ComponentItem-versionActions": "_ComponentItem-versionActions_lp9eh_171", "ComponentItem-migrationOptions": "_ComponentItem-migrationOptions_lp9eh_177", "ComponentItem-select": "_ComponentItem-select_lp9eh_181", "ComponentItem-modalFooter": "_ComponentItem-modalFooter_lp9eh_202", "ComponentItem-footerLeft": "_ComponentItem-footerLeft_lp9eh_211", "ComponentItem-footerRight": "_ComponentItem-footerRight_lp9eh_216" };
3091
+ // css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/overrides/ComponentItem.module.css#css-module
3092
+ var ComponentItem_module_default = { "ComponentItem": "_ComponentItem_1kbi2_1", "ComponentItem--insertDisabled": "_ComponentItem--insertDisabled_1kbi2_14", "ComponentItem-content": "_ComponentItem-content_1kbi2_21", "ComponentItem-name": "_ComponentItem-name_1kbi2_31", "ComponentItem-version": "_ComponentItem-version_1kbi2_35", "ComponentItem-actions": "_ComponentItem-actions_1kbi2_40", "ComponentItem-settingsButton": "_ComponentItem-settingsButton_1kbi2_46", "ComponentItem-grip": "_ComponentItem-grip_1kbi2_56", "ComponentItem-modal": "_ComponentItem-modal_1kbi2_63", "ComponentItem-modalHeader": "_ComponentItem-modalHeader_1kbi2_70", "ComponentItem-modalTitle": "_ComponentItem-modalTitle_1kbi2_75", "ComponentItem-modalSubtitle": "_ComponentItem-modalSubtitle_1kbi2_82", "ComponentItem-modalBody": "_ComponentItem-modalBody_1kbi2_88", "ComponentItem-section": "_ComponentItem-section_1kbi2_97", "ComponentItem-sectionTitle": "_ComponentItem-sectionTitle_1kbi2_103", "ComponentItem-sectionDescription": "_ComponentItem-sectionDescription_1kbi2_110", "ComponentItem-versionList": "_ComponentItem-versionList_1kbi2_116", "ComponentItem-versionRow": "_ComponentItem-versionRow_1kbi2_122", "ComponentItem-versionRow--isDefault": "_ComponentItem-versionRow--isDefault_1kbi2_133", "ComponentItem-versionRow--isMarkedForDeletion": "_ComponentItem-versionRow--isMarkedForDeletion_1kbi2_138", "ComponentItem-versionInfo": "_ComponentItem-versionInfo_1kbi2_143", "ComponentItem-versionNumber": "_ComponentItem-versionNumber_1kbi2_150", "ComponentItem-defaultBadge": "_ComponentItem-defaultBadge_1kbi2_156", "ComponentItem-deleteBadge": "_ComponentItem-deleteBadge_1kbi2_167", "ComponentItem-versionActions": "_ComponentItem-versionActions_1kbi2_178", "ComponentItem-migrationOptions": "_ComponentItem-migrationOptions_1kbi2_184", "ComponentItem-select": "_ComponentItem-select_1kbi2_188", "ComponentItem-modalFooter": "_ComponentItem-modalFooter_1kbi2_209", "ComponentItem-footerLeft": "_ComponentItem-footerLeft_1kbi2_218", "ComponentItem-footerRight": "_ComponentItem-footerRight_1kbi2_223" };
2658
3093
 
2659
3094
  // src/puck/components/modal/index.tsx
2660
- var import_react9 = require("react");
3095
+ var import_react10 = require("react");
2661
3096
  var import_react_dom = require("react-dom");
2662
3097
 
2663
- // css-module:D:\osamuProjects\netlisian\packages\soft-config\src\puck\components\modal\styles.module.css#css-module
3098
+ // css-module:/media/manual_mount/osamuProjects/netlisian/packages/soft-config/src/puck/components/modal/styles.module.css#css-module
2664
3099
  var styles_module_default2 = { "Modal": "_Modal_pvj02_1", "Modal--isOpen": "_Modal--isOpen_pvj02_29", "Modal-inner": "_Modal-inner_pvj02_37" };
2665
3100
 
2666
3101
  // src/puck/components/modal/index.tsx
@@ -2671,8 +3106,8 @@ var Modal = ({
2671
3106
  onClose,
2672
3107
  isOpen
2673
3108
  }) => {
2674
- const [rootEl, setRootEl] = (0, import_react9.useState)(null);
2675
- (0, import_react9.useEffect)(() => {
3109
+ const [rootEl, setRootEl] = (0, import_react10.useState)(null);
3110
+ (0, import_react10.useEffect)(() => {
2676
3111
  setRootEl(document.getElementById("puck-portal-root"));
2677
3112
  }, []);
2678
3113
  if (!rootEl) {
@@ -2692,24 +3127,31 @@ var Modal = ({
2692
3127
  };
2693
3128
 
2694
3129
  // src/puck/overrides/ComponentItem.tsx
3130
+ var import_shallow2 = require("zustand/shallow");
2695
3131
  var import_jsx_runtime11 = require("react/jsx-runtime");
2696
3132
  var getClassName5 = get_class_name_factory_default("ComponentItem", ComponentItem_module_default);
3133
+ var usePuck3 = (0, import_puck15.createUsePuck)();
2697
3134
  var ComponentItem = (props) => {
3135
+ const componentMeta = useSoftConfig((s) => s.softComponents[props.name]);
3136
+ const displayName = (componentMeta == null ? void 0 : componentMeta.name) || props.name;
2698
3137
  const softComponents = new Set(
2699
- Object.keys(useSoftConfig((s) => s.softComponents))
3138
+ Object.keys(useSoftConfig((s) => s.softComponents, import_shallow2.shallow))
2700
3139
  );
3140
+ const getPermissions = usePuck3((s) => s.getPermissions);
3141
+ const insertAllowed = getPermissions({ type: props.name }).insert;
2701
3142
  const removeSoftComponentVersion = useSoftConfig(
2702
3143
  (s) => s.removeSoftComponentVersion
2703
3144
  );
2704
3145
  const { handleDemolish } = useDemolish();
2705
3146
  const { handleSetDefaultVersion, getVersions, getDefaultVersion } = useSetDefaultVersion();
2706
- const [isEditing, setIsEditing] = (0, import_react10.useState)(false);
2707
- const [isHovering, setIsHovering] = (0, import_react10.useState)(false);
2708
- const [selectedVersion, setSelectedVersion] = (0, import_react10.useState)("");
2709
- const [versionsToDelete, setVersionsToDelete] = (0, import_react10.useState)(
3147
+ const [isEditing, setIsEditing] = (0, import_react11.useState)(false);
3148
+ const [isHovering, setIsHovering] = (0, import_react11.useState)(false);
3149
+ const [selectedVersion, setSelectedVersion] = (0, import_react11.useState)("");
3150
+ const [versionsToDelete, setVersionsToDelete] = (0, import_react11.useState)(
2710
3151
  /* @__PURE__ */ new Set()
2711
3152
  );
2712
- const [migrateVersionMap, setMigrateVersionMap] = (0, import_react10.useState)({});
3153
+ const [migrateVersionMap, setMigrateVersionMap] = (0, import_react11.useState)({});
3154
+ const useVersioning = useSoftConfig((s) => s.showVersionFields);
2713
3155
  const versions = getVersions(props.name);
2714
3156
  const defaultVersion = getDefaultVersion(props.name);
2715
3157
  const handleApply = () => __async(null, null, function* () {
@@ -2754,7 +3196,7 @@ var ComponentItem = (props) => {
2754
3196
  };
2755
3197
  const handleDemolishClick = () => __async(null, null, function* () {
2756
3198
  const confirmed = yield confirm(
2757
- `Demolish "${props.name}" entirely? This will remove all versions.`
3199
+ `Demolish "${displayName}" entirely? This will remove all versions.`
2758
3200
  );
2759
3201
  if (confirmed) {
2760
3202
  handleDemolish(props.name);
@@ -2767,20 +3209,20 @@ var ComponentItem = (props) => {
2767
3209
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2768
3210
  "div",
2769
3211
  {
2770
- className: getClassName5(),
3212
+ className: getClassName5({ insertDisabled: !insertAllowed }),
2771
3213
  onMouseEnter: () => setIsHovering(true),
2772
3214
  onMouseLeave: () => setIsHovering(false),
2773
3215
  children: [
2774
3216
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("content"), children: [
2775
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("name"), children: props.name }),
2776
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("version"), children: [
3217
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("name"), children: displayName }),
3218
+ useVersioning && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("version"), children: [
2777
3219
  "v",
2778
3220
  defaultVersion
2779
3221
  ] })
2780
3222
  ] }),
2781
3223
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("actions"), children: [
2782
3224
  isHovering && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("settingsButton"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2783
- import_puck14.IconButton,
3225
+ import_puck15.IconButton,
2784
3226
  {
2785
3227
  title: "Settings",
2786
3228
  variant: "secondary",
@@ -2789,7 +3231,7 @@ var ComponentItem = (props) => {
2789
3231
  setIsEditing(true);
2790
3232
  setSelectedVersion(defaultVersion || "");
2791
3233
  },
2792
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Cog, { size: 14 })
3234
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Cog, { size: 12 })
2793
3235
  }
2794
3236
  ) }),
2795
3237
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("grip"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.GripVertical, { size: 16 }) })
@@ -2799,10 +3241,10 @@ var ComponentItem = (props) => {
2799
3241
  ),
2800
3242
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Modal, { isOpen: isEditing, onClose: handleCancel, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("modal"), children: [
2801
3243
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("modalHeader"), children: [
2802
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { className: getClassName5("modalTitle"), children: props.name }),
2803
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: getClassName5("modalSubtitle"), children: "Manage versions and settings" })
3244
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { className: getClassName5("modalTitle"), children: displayName }),
3245
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: getClassName5("modalSubtitle"), children: "Component Settings" })
2804
3246
  ] }),
2805
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("modalBody"), children: [
3247
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("modalBody"), children: useVersioning ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2806
3248
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("section"), children: [
2807
3249
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { className: getClassName5("sectionTitle"), children: "Versions" }),
2808
3250
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("versionList"), children: versions.map((version) => {
@@ -2811,52 +3253,30 @@ var ComponentItem = (props) => {
2811
3253
  let rowClass = getClassName5("versionRow");
2812
3254
  if (isDefault) rowClass += " " + getClassName5("versionRow--isDefault");
2813
3255
  if (isMarkedForDeletion) rowClass += " " + getClassName5("versionRow--isMarkedForDeletion");
2814
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2815
- "div",
2816
- {
2817
- className: rowClass,
2818
- children: [
2819
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("versionInfo"), children: [
2820
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: getClassName5("versionNumber"), children: [
2821
- "Version ",
2822
- version
2823
- ] }),
2824
- isDefault && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: getClassName5("defaultBadge"), children: "Default" }),
2825
- isMarkedForDeletion && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: getClassName5("deleteBadge"), children: "Marked for deletion" })
2826
- ] }),
2827
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("versionActions"), children: [
2828
- !isDefault && !isMarkedForDeletion && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2829
- import_puck14.Button,
2830
- {
2831
- variant: "secondary",
2832
- onClick: () => setSelectedVersion(version),
2833
- children: "Set as Default"
2834
- }
2835
- ),
2836
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2837
- import_puck14.Button,
2838
- {
2839
- variant: isMarkedForDeletion ? "secondary" : "secondary",
2840
- onClick: () => toggleVersionForDeletion(version),
2841
- children: isMarkedForDeletion ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2842
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.X, { size: 14 }),
2843
- "Undo"
2844
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
2845
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Trash2, { size: 14 }),
2846
- "Delete"
2847
- ] })
2848
- }
2849
- )
2850
- ] })
2851
- ]
2852
- },
2853
- version
2854
- );
3256
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: rowClass, children: [
3257
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("versionInfo"), children: [
3258
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: getClassName5("versionNumber"), children: [
3259
+ "Version ",
3260
+ version
3261
+ ] }),
3262
+ isDefault && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: getClassName5("defaultBadge"), children: "Default" }),
3263
+ isMarkedForDeletion && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: getClassName5("deleteBadge"), children: "Marked for deletion" })
3264
+ ] }),
3265
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("versionActions"), children: [
3266
+ !isDefault && !isMarkedForDeletion && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_puck15.Button, { variant: "secondary", onClick: () => setSelectedVersion(version), children: "Set as Default" }),
3267
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_puck15.Button, { variant: "secondary", onClick: () => toggleVersionForDeletion(version), children: isMarkedForDeletion ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
3268
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.X, { size: 14 }),
3269
+ " Undo"
3270
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
3271
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Trash2, { size: 14 }),
3272
+ " Delete"
3273
+ ] }) })
3274
+ ] })
3275
+ ] }, version);
2855
3276
  }) })
2856
3277
  ] }),
2857
3278
  versionsToDelete.size > 0 && availableVersions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("section"), children: [
2858
3279
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { className: getClassName5("sectionTitle"), children: "Migration Settings" }),
2859
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: getClassName5("sectionDescription"), children: "Choose what to do with components using deleted versions" }),
2860
3280
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("migrationOptions"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2861
3281
  "select",
2862
3282
  {
@@ -2879,30 +3299,26 @@ var ComponentItem = (props) => {
2879
3299
  }
2880
3300
  ) })
2881
3301
  ] })
2882
- ] }),
3302
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("section"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
3303
+ "Manage high-level settings for the ",
3304
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("strong", { children: displayName }),
3305
+ " component."
3306
+ ] }) }) }),
2883
3307
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("modalFooter"), children: [
2884
3308
  /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: getClassName5("footerLeft"), children: [
2885
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_puck14.Button, { size: "medium", onClick: handleApply, children: [
3309
+ useVersioning ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_puck15.Button, { size: "medium", onClick: handleApply, children: [
2886
3310
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Check, { size: 16 }),
2887
- "Apply Changes"
2888
- ] }),
2889
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_puck14.Button, { size: "medium", variant: "secondary", onClick: handleCancel, children: [
3311
+ " Apply Changes"
3312
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_puck15.Button, { size: "medium", onClick: handleCancel, children: "Close" }),
3313
+ useVersioning && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_puck15.Button, { size: "medium", variant: "secondary", onClick: handleCancel, children: [
2890
3314
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.X, { size: 16 }),
2891
- "Cancel"
3315
+ " Cancel"
2892
3316
  ] })
2893
3317
  ] }),
2894
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("footerRight"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
2895
- import_puck14.Button,
2896
- {
2897
- size: "medium",
2898
- variant: "secondary",
2899
- onClick: handleDemolishClick,
2900
- children: [
2901
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Trash2, { size: 16 }),
2902
- "Demolish Component"
2903
- ]
2904
- }
2905
- ) })
3318
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: getClassName5("footerRight"), children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_puck15.Button, { size: "medium", variant: "secondary", onClick: handleDemolishClick, children: [
3319
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_lucide_react2.Trash2, { size: 16 }),
3320
+ " Demolish Component"
3321
+ ] }) })
2906
3322
  ] })
2907
3323
  ] }) })
2908
3324
  ] });
@@ -2910,6 +3326,27 @@ var ComponentItem = (props) => {
2910
3326
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: props.children });
2911
3327
  };
2912
3328
 
3329
+ // src/puck/lib/action-callback.ts
3330
+ var createActionCallback = (validateAction, undo) => {
3331
+ return (action) => {
3332
+ const isValid = validateAction(action);
3333
+ if (!isValid) {
3334
+ notify.error(
3335
+ "Editing outside the soft component is not allowed when you are editing component definition."
3336
+ );
3337
+ if (typeof requestAnimationFrame === "function") {
3338
+ requestAnimationFrame(() => {
3339
+ requestAnimationFrame(() => {
3340
+ undo();
3341
+ });
3342
+ });
3343
+ } else {
3344
+ setTimeout(() => undo(), 0);
3345
+ }
3346
+ }
3347
+ };
3348
+ };
3349
+
2913
3350
  // src/puck/lib/dissolve-all-soft-components.ts
2914
3351
  function extractDependencies2(softComponents, componentName, version) {
2915
3352
  var _a, _b;
@@ -3119,6 +3556,7 @@ var resolveSoftConfig = (data, softComponents, config) => {
3119
3556
  Modal,
3120
3557
  SoftConfigProvider,
3121
3558
  confirm,
3559
+ createActionCallback,
3122
3560
  createSoftConfigStore,
3123
3561
  createUseSoftConfig,
3124
3562
  notify,