@open-mercato/ui 0.6.6-develop.6410.1.2ad881013e → 0.6.6-develop.6411.1.825382313f
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
CHANGED
|
@@ -96,6 +96,7 @@ import { CollapsibleGroup } from "./crud/CollapsibleGroup.js";
|
|
|
96
96
|
import { SortableGroupHandleProvider } from "./crud/SortableGroupHandle.js";
|
|
97
97
|
import { useGroupOrder } from "./crud/useGroupOrder.js";
|
|
98
98
|
import { InjectedField } from "./injection/InjectedField.js";
|
|
99
|
+
import { insertByInjectionPlacement } from "@open-mercato/shared/modules/widgets/injection-position";
|
|
99
100
|
import { evaluateInjectedVisibility } from "./injection/visibility-utils.js";
|
|
100
101
|
import { ComponentReplacementHandles } from "@open-mercato/shared/modules/widgets/component-registry";
|
|
101
102
|
import { RichEditor } from "../primitives/rich-editor.js";
|
|
@@ -1295,22 +1296,25 @@ function CrudForm({
|
|
|
1295
1296
|
[injectedFieldDefinitions]
|
|
1296
1297
|
);
|
|
1297
1298
|
const injectedCrudFields = React.useMemo(() => {
|
|
1298
|
-
return injectedFieldDefinitions.map((definition) =>
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
{
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1299
|
+
return injectedFieldDefinitions.map((definition) => {
|
|
1300
|
+
const injectedFieldRendersOwnLabel = !(definition.type === "custom" && definition.customComponent);
|
|
1301
|
+
return {
|
|
1302
|
+
id: definition.id,
|
|
1303
|
+
label: injectedFieldRendersOwnLabel ? "" : definition.label,
|
|
1304
|
+
type: "custom",
|
|
1305
|
+
readOnly: definition.readOnly,
|
|
1306
|
+
component: ({ value, setValue: setValue2, values: formValues }) => /* @__PURE__ */ jsx(
|
|
1307
|
+
InjectedField,
|
|
1308
|
+
{
|
|
1309
|
+
field: definition,
|
|
1310
|
+
value,
|
|
1311
|
+
onChange: (_, nextValue) => setValue2(nextValue),
|
|
1312
|
+
context: injectedFieldContext,
|
|
1313
|
+
formData: formValues ?? values
|
|
1314
|
+
}
|
|
1315
|
+
)
|
|
1316
|
+
};
|
|
1317
|
+
});
|
|
1314
1318
|
}, [injectedFieldContext, injectedFieldDefinitions, values]);
|
|
1315
1319
|
const allFields = React.useMemo(() => {
|
|
1316
1320
|
const base = [...fields, ...injectedCrudFields];
|
|
@@ -1480,10 +1484,16 @@ function CrudForm({
|
|
|
1480
1484
|
}
|
|
1481
1485
|
if (index < 0) continue;
|
|
1482
1486
|
const fieldEntries = cloned[index].fields ?? [];
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
+
const alreadyPresent = fieldEntries.some((entry) => {
|
|
1488
|
+
const entryId = typeof entry === "string" ? entry : entry.id;
|
|
1489
|
+
return entryId === definition.id;
|
|
1490
|
+
});
|
|
1491
|
+
cloned[index].fields = alreadyPresent ? fieldEntries : insertByInjectionPlacement(
|
|
1492
|
+
fieldEntries,
|
|
1493
|
+
definition.id,
|
|
1494
|
+
definition.placement,
|
|
1495
|
+
(entry) => typeof entry === "string" ? entry : entry.id
|
|
1496
|
+
);
|
|
1487
1497
|
}
|
|
1488
1498
|
return cloned;
|
|
1489
1499
|
}, [groups, injectedFieldDefinitions]);
|