@open-mercato/ui 0.8.1-develop.7237.1.635faf2c7a → 0.8.1-develop.7239.1.d90c352076
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/CrudForm.js +47 -12
- package/dist/backend/CrudForm.js.map +2 -2
- package/dist/portal/PortalShell.js +1 -1
- package/dist/portal/PortalShell.js.map +2 -2
- package/package.json +3 -3
- package/src/backend/CrudForm.tsx +70 -12
- package/src/backend/__tests__/CrudForm.fieldInjection.test.tsx +8 -1
- package/src/backend/__tests__/CrudForm.legacyInjectionBridge.test.tsx +188 -0
- package/src/portal/PortalShell.tsx +6 -1
- package/src/portal/__tests__/PortalShell.test.tsx +138 -0
package/dist/backend/CrudForm.js
CHANGED
|
@@ -173,6 +173,12 @@ function buildResolvedEntityIdsKey(entityId, entityIds) {
|
|
|
173
173
|
}
|
|
174
174
|
return list.join("\0");
|
|
175
175
|
}
|
|
176
|
+
function mergeByKey(primary, legacy, keyOf) {
|
|
177
|
+
if (!legacy.length) return primary;
|
|
178
|
+
const seen = new Set(primary.map(keyOf));
|
|
179
|
+
const extra = legacy.filter((item) => !seen.has(keyOf(item)));
|
|
180
|
+
return extra.length ? [...primary, ...extra] : primary;
|
|
181
|
+
}
|
|
176
182
|
function readByDotPath(source, path) {
|
|
177
183
|
if (!source || !path) return void 0;
|
|
178
184
|
if (Object.prototype.hasOwnProperty.call(source, path)) return source[path];
|
|
@@ -393,6 +399,7 @@ function CrudForm({
|
|
|
393
399
|
customFieldsetBindings,
|
|
394
400
|
customFieldsManageMode = "inline",
|
|
395
401
|
injectionSpotId,
|
|
402
|
+
legacyInjectionSpotId,
|
|
396
403
|
replacementHandle,
|
|
397
404
|
collapsibleGroups,
|
|
398
405
|
sortableGroups,
|
|
@@ -480,6 +487,7 @@ function CrudForm({
|
|
|
480
487
|
return ComponentReplacementHandles.crudForm("unknown");
|
|
481
488
|
}, [replacementHandle, resolvedEntityIds]);
|
|
482
489
|
const headerInjectionSpotId = resolvedInjectionSpotId ? extensionSpotChildId(resolvedInjectionSpotId, "header") : void 0;
|
|
490
|
+
const legacyHeaderInjectionSpotId = legacyInjectionSpotId ? extensionSpotChildId(legacyInjectionSpotId, "header") : void 0;
|
|
483
491
|
const recordId = React.useMemo(() => {
|
|
484
492
|
const raw = values.id;
|
|
485
493
|
if (typeof raw === "string") return raw;
|
|
@@ -716,13 +724,28 @@ function CrudForm({
|
|
|
716
724
|
window.history.replaceState = originalReplaceState;
|
|
717
725
|
};
|
|
718
726
|
}, [allowNextNavigation, clearDirtyState, confirmUnsavedChanges, embedded, hasUnsavedChanges, router, trackDirtyWhenEmbedded]);
|
|
719
|
-
const { widgets:
|
|
727
|
+
const { widgets: primaryInjectionWidgets } = useInjectionWidgets(resolvedInjectionSpotId, {
|
|
728
|
+
context: injectionContext,
|
|
729
|
+
triggerOnLoad: true
|
|
730
|
+
});
|
|
731
|
+
const { widgets: legacyInjectionWidgets } = useInjectionWidgets(legacyInjectionSpotId, {
|
|
720
732
|
context: injectionContext,
|
|
721
733
|
triggerOnLoad: true
|
|
722
734
|
});
|
|
723
|
-
const
|
|
735
|
+
const injectionWidgets = React.useMemo(
|
|
736
|
+
() => mergeByKey(primaryInjectionWidgets, legacyInjectionWidgets, (w) => w.widgetId),
|
|
737
|
+
[primaryInjectionWidgets, legacyInjectionWidgets]
|
|
738
|
+
);
|
|
739
|
+
const { widgets: primaryFieldWidgets } = useInjectionDataWidgets(
|
|
724
740
|
resolvedInjectionSpotId ? extensionSpotChildId(resolvedInjectionSpotId, "fields") : "__disabled__:fields"
|
|
725
741
|
);
|
|
742
|
+
const { widgets: legacyFieldWidgets } = useInjectionDataWidgets(
|
|
743
|
+
legacyInjectionSpotId ? extensionSpotChildId(legacyInjectionSpotId, "fields") : "__disabled__:fields"
|
|
744
|
+
);
|
|
745
|
+
const injectedFieldWidgets = React.useMemo(
|
|
746
|
+
() => mergeByKey(primaryFieldWidgets, legacyFieldWidgets, (w) => w.metadata.id),
|
|
747
|
+
[primaryFieldWidgets, legacyFieldWidgets]
|
|
748
|
+
);
|
|
726
749
|
const { triggerEvent: triggerInjectionEvent } = useInjectionSpotEvents(resolvedInjectionSpotId ?? "", injectionWidgets);
|
|
727
750
|
const extendedInjectionEventsEnabled = CRUDFORM_EXTENDED_EVENTS_ENABLED && Boolean(resolvedInjectionSpotId);
|
|
728
751
|
const widgetRequiredFieldIds = React.useMemo(() => {
|
|
@@ -1063,16 +1086,28 @@ function CrudForm({
|
|
|
1063
1086
|
autoCheckAcl: versionHistory?.autoCheckAcl
|
|
1064
1087
|
}
|
|
1065
1088
|
);
|
|
1066
|
-
const headerInjectionAction = headerInjectionSpotId ? /* @__PURE__ */
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1089
|
+
const headerInjectionAction = headerInjectionSpotId || legacyHeaderInjectionSpotId ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1090
|
+
headerInjectionSpotId ? /* @__PURE__ */ jsx(
|
|
1091
|
+
InjectionSpot,
|
|
1092
|
+
{
|
|
1093
|
+
spotId: headerInjectionSpotId,
|
|
1094
|
+
context: injectionContext,
|
|
1095
|
+
data: values,
|
|
1096
|
+
onDataChange: (newData) => setValues(newData),
|
|
1097
|
+
disabled: pending
|
|
1098
|
+
}
|
|
1099
|
+
) : null,
|
|
1100
|
+
legacyHeaderInjectionSpotId ? /* @__PURE__ */ jsx(
|
|
1101
|
+
InjectionSpot,
|
|
1102
|
+
{
|
|
1103
|
+
spotId: legacyHeaderInjectionSpotId,
|
|
1104
|
+
context: injectionContext,
|
|
1105
|
+
data: values,
|
|
1106
|
+
onDataChange: (newData) => setValues(newData),
|
|
1107
|
+
disabled: pending
|
|
1108
|
+
}
|
|
1109
|
+
) : null
|
|
1110
|
+
] }) : null;
|
|
1076
1111
|
const headerExtraActions = versionHistoryEnabled || headerInjectionAction || extraActions ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1077
1112
|
versionHistoryEnabled ? versionHistoryAction : null,
|
|
1078
1113
|
headerInjectionAction,
|