@arpproject/recrate 0.1.14 → 0.1.15
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/recrate.es.js
CHANGED
|
@@ -79550,13 +79550,61 @@ const RenderLinkedItem = ({
|
|
|
79550
79550
|
const crateManager = useContext(CrateManagerContext);
|
|
79551
79551
|
const profileManager = useContext(ProfileManagerContext);
|
|
79552
79552
|
const [associations, setAssociations] = useState([]);
|
|
79553
|
+
const effectiveEntity = useMemo$1(() => {
|
|
79554
|
+
const hasTypes = Boolean(entity == null ? void 0 : entity["@type"]);
|
|
79555
|
+
const hasName = Boolean(entity == null ? void 0 : entity.name);
|
|
79556
|
+
if (hasTypes && hasName) {
|
|
79557
|
+
return entity;
|
|
79558
|
+
}
|
|
79559
|
+
const resolved = crateManager.getEntity({
|
|
79560
|
+
id: entity["@id"],
|
|
79561
|
+
link: false,
|
|
79562
|
+
materialise: false
|
|
79563
|
+
});
|
|
79564
|
+
if (!resolved) {
|
|
79565
|
+
return entity;
|
|
79566
|
+
}
|
|
79567
|
+
return {
|
|
79568
|
+
...resolved,
|
|
79569
|
+
...entity,
|
|
79570
|
+
"@type": (entity == null ? void 0 : entity["@type"]) ?? resolved["@type"],
|
|
79571
|
+
name: (entity == null ? void 0 : entity.name) ?? resolved.name
|
|
79572
|
+
};
|
|
79573
|
+
}, [crateManager, entity]);
|
|
79553
79574
|
const showMap = useMemo$1(() => {
|
|
79554
|
-
|
|
79555
|
-
|
|
79575
|
+
const rawTypes = effectiveEntity == null ? void 0 : effectiveEntity["@type"];
|
|
79576
|
+
const typeList = Array.isArray(rawTypes) ? rawTypes : typeof rawTypes === "string" ? [rawTypes] : [];
|
|
79577
|
+
return typeList.some((type4) => String(type4).includes("Geo"));
|
|
79578
|
+
}, [effectiveEntity]);
|
|
79556
79579
|
const resolveAssociations = () => {
|
|
79557
|
-
const profile = profileManager.profile;
|
|
79580
|
+
const profile = profileManager == null ? void 0 : profileManager.profile;
|
|
79581
|
+
const resolveConfiguration = Array.isArray(profile == null ? void 0 : profile.resolve) ? profile.resolve : [];
|
|
79582
|
+
if (resolveConfiguration.length === 0) {
|
|
79583
|
+
setAssociations([]);
|
|
79584
|
+
return;
|
|
79585
|
+
}
|
|
79586
|
+
const rawTypes = entity == null ? void 0 : entity["@type"];
|
|
79587
|
+
const typeList = Array.isArray(rawTypes) ? rawTypes.map((type4) => String(type4)) : typeof rawTypes === "string" ? [rawTypes] : [];
|
|
79588
|
+
const hasResolveMatch = typeList.some(
|
|
79589
|
+
(type4) => resolveConfiguration.some(
|
|
79590
|
+
(entry) => Array.isArray(entry == null ? void 0 : entry.types) && entry.types.includes(type4)
|
|
79591
|
+
)
|
|
79592
|
+
);
|
|
79593
|
+
if (!hasResolveMatch) {
|
|
79594
|
+
setAssociations([]);
|
|
79595
|
+
return;
|
|
79596
|
+
}
|
|
79597
|
+
const sourceEntity = crateManager.getEntity({
|
|
79598
|
+
id: entity["@id"],
|
|
79599
|
+
link: false,
|
|
79600
|
+
materialise: false
|
|
79601
|
+
});
|
|
79602
|
+
if (!sourceEntity) {
|
|
79603
|
+
setAssociations([]);
|
|
79604
|
+
return;
|
|
79605
|
+
}
|
|
79558
79606
|
const resolvedAssociations = crateManager.resolveLinkedEntityAssociations({
|
|
79559
|
-
entity:
|
|
79607
|
+
entity: sourceEntity,
|
|
79560
79608
|
profile
|
|
79561
79609
|
});
|
|
79562
79610
|
setAssociations(resolvedAssociations);
|
|
@@ -79572,6 +79620,15 @@ const RenderLinkedItem = ({
|
|
|
79572
79620
|
onUnlinkEntity({ property, tgtEntityId: unlinkData.entity["@id"] });
|
|
79573
79621
|
}
|
|
79574
79622
|
};
|
|
79623
|
+
const linkDisplayEntity = useMemo$1(() => {
|
|
79624
|
+
const rawTypes = effectiveEntity == null ? void 0 : effectiveEntity["@type"];
|
|
79625
|
+
const typeList = Array.isArray(rawTypes) ? rawTypes.map((type4) => String(type4)) : typeof rawTypes === "string" ? [rawTypes] : ["Thing"];
|
|
79626
|
+
return {
|
|
79627
|
+
"@id": entity["@id"],
|
|
79628
|
+
"@type": typeList,
|
|
79629
|
+
name: (effectiveEntity == null ? void 0 : effectiveEntity.name) || entity["@id"]
|
|
79630
|
+
};
|
|
79631
|
+
}, [effectiveEntity, entity]);
|
|
79575
79632
|
if (showMap) {
|
|
79576
79633
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Flex, { className: "describo-render-item-link py-1 rounded bg-blue-200 hover:text-black hover:bg-blue-300 hover:rounded-r-none", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { vertical: true, className: "space-y-2", children: [
|
|
79577
79634
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Flex, { className: "p-2", children: [
|
|
@@ -79602,10 +79659,7 @@ const RenderLinkedItem = ({
|
|
|
79602
79659
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
79603
79660
|
ItemLink,
|
|
79604
79661
|
{
|
|
79605
|
-
entity:
|
|
79606
|
-
...entity,
|
|
79607
|
-
name: entity.name || entity["@id"]
|
|
79608
|
-
},
|
|
79662
|
+
entity: linkDisplayEntity,
|
|
79609
79663
|
onLoadEntity: handleLoadEntity
|
|
79610
79664
|
}
|
|
79611
79665
|
),
|
|
@@ -81364,8 +81418,6 @@ const EntityProperty = ({
|
|
|
81364
81418
|
const profileManager = useContext(ProfileManagerContext);
|
|
81365
81419
|
const crateManager = useContext(CrateManagerContext);
|
|
81366
81420
|
const state = useStateStore();
|
|
81367
|
-
const [linkInstances, setLinkInstances] = useState([]);
|
|
81368
|
-
const [simpleInstances, setSimpleInstances] = useState([]);
|
|
81369
81421
|
const propertyDefinition = (_a2 = profileManager == null ? void 0 : profileManager.getPropertyDefinition({
|
|
81370
81422
|
property,
|
|
81371
81423
|
entity
|
|
@@ -81375,32 +81427,24 @@ const EntityProperty = ({
|
|
|
81375
81427
|
const isNotValue = (propertyDefinition == null ? void 0 : propertyDefinition.type) !== "Value";
|
|
81376
81428
|
const profileWarnMissingProperty = profileManager == null ? void 0 : profileManager.profile.warnMissingProperty;
|
|
81377
81429
|
const showAddControl = !(propertyDefinition == null ? void 0 : propertyDefinition.readonly) && ((propertyDefinition == null ? void 0 : propertyDefinition.multiple) || !(values == null ? void 0 : values.length));
|
|
81378
|
-
const
|
|
81379
|
-
|
|
81380
|
-
|
|
81381
|
-
|
|
81382
|
-
|
|
81383
|
-
|
|
81384
|
-
|
|
81385
|
-
}
|
|
81386
|
-
|
|
81387
|
-
|
|
81388
|
-
|
|
81389
|
-
|
|
81390
|
-
}
|
|
81430
|
+
const simpleInstances = useMemo$1(() => {
|
|
81431
|
+
const simpleInsts = (propertyDefinition == null ? void 0 : propertyDefinition.handlesMultipleValues) === true ? values.length === 0 ? values : [values] : values;
|
|
81432
|
+
return simpleInsts.map((v2, i) => {
|
|
81433
|
+
if (!lodashExports.isPlainObject(v2) || typeof v2 === "boolean") {
|
|
81434
|
+
return { idx: i, value: v2 };
|
|
81435
|
+
}
|
|
81436
|
+
return null;
|
|
81437
|
+
}).filter(Boolean);
|
|
81438
|
+
}, [values, propertyDefinition == null ? void 0 : propertyDefinition.handlesMultipleValues]);
|
|
81439
|
+
const linkInstances = useMemo$1(() => {
|
|
81440
|
+
return lodashExports.orderBy(
|
|
81441
|
+
values.map((v2, i) => {
|
|
81442
|
+
if (lodashExports.isPlainObject(v2) && typeof v2 !== "boolean") return { idx: i, value: v2 };
|
|
81391
81443
|
return null;
|
|
81392
|
-
}).filter(Boolean)
|
|
81444
|
+
}).filter(Boolean),
|
|
81445
|
+
["value.@id"]
|
|
81393
81446
|
);
|
|
81394
|
-
|
|
81395
|
-
lodashExports.orderBy(
|
|
81396
|
-
values.map((v2, i) => {
|
|
81397
|
-
if (lodashExports.isPlainObject(v2) && typeof v2 !== "boolean") return { idx: i, value: v2 };
|
|
81398
|
-
return null;
|
|
81399
|
-
}).filter(Boolean),
|
|
81400
|
-
"@id"
|
|
81401
|
-
)
|
|
81402
|
-
);
|
|
81403
|
-
}, [valuesString, propertyDefinition == null ? void 0 : propertyDefinition.handlesMultipleValues]);
|
|
81447
|
+
}, [values]);
|
|
81404
81448
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
81405
81449
|
"div",
|
|
81406
81450
|
{
|
|
@@ -110503,7 +110547,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110503
110547
|
}, [entity]);
|
|
110504
110548
|
useEffect(() => {
|
|
110505
110549
|
if (profileManager && profileManager.$key) {
|
|
110506
|
-
const entityObj = crateManager.getEntity({ id: entity["@id"] });
|
|
110550
|
+
const entityObj = crateManager.getEntity({ id: entity["@id"], link: false, materialise: false });
|
|
110507
110551
|
init2({ entity: entityObj });
|
|
110508
110552
|
}
|
|
110509
110553
|
}, [profileManager == null ? void 0 : profileManager.$key]);
|
|
@@ -110529,7 +110573,7 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110529
110573
|
}
|
|
110530
110574
|
};
|
|
110531
110575
|
const refresh = () => {
|
|
110532
|
-
const entityObj = crateManager.getEntity({ id: entity["@id"] });
|
|
110576
|
+
const entityObj = crateManager.getEntity({ id: entity["@id"], link: false, materialise: false });
|
|
110533
110577
|
init2({ entity: entityObj });
|
|
110534
110578
|
};
|
|
110535
110579
|
const saveTabToState = (tabName) => {
|
|
@@ -110537,8 +110581,6 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
110537
110581
|
};
|
|
110538
110582
|
useEffect(() => {
|
|
110539
110583
|
if (entity == null ? void 0 : entity["@id"]) {
|
|
110540
|
-
const entityObj = crateManager.getEntity({ id: entity["@id"] });
|
|
110541
|
-
init2({ entity: entityObj });
|
|
110542
110584
|
refresh();
|
|
110543
110585
|
}
|
|
110544
110586
|
}, [extraProperties]);
|
|
@@ -111055,30 +111097,23 @@ const RenderEntity = forwardRef((props, ref) => {
|
|
|
111055
111097
|
),
|
|
111056
111098
|
(_o = tabs.find((tab) => tab.name === "about")) == null ? void 0 : _o.inputs.map((input) => {
|
|
111057
111099
|
if (!["@id", "@type", "name", "@reverse"].includes(input.name)) {
|
|
111058
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
111059
|
-
|
|
111100
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-2 hover:bg-sky-100 ${savedProperty === input.name ? "bg-green-200 hover:bg-green-200" : ""}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
111101
|
+
EntityProperty,
|
|
111060
111102
|
{
|
|
111061
|
-
|
|
111062
|
-
|
|
111063
|
-
|
|
111064
|
-
|
|
111065
|
-
|
|
111066
|
-
|
|
111067
|
-
|
|
111068
|
-
|
|
111069
|
-
|
|
111070
|
-
|
|
111071
|
-
|
|
111072
|
-
|
|
111073
|
-
|
|
111074
|
-
|
|
111075
|
-
onSaveProperty: handleUpdateEntity,
|
|
111076
|
-
onDeleteProperty: handleDeleteProperty
|
|
111077
|
-
}
|
|
111078
|
-
)
|
|
111079
|
-
},
|
|
111080
|
-
input.name
|
|
111081
|
-
);
|
|
111103
|
+
entity: contextEntity,
|
|
111104
|
+
property: input.name,
|
|
111105
|
+
values: Array.isArray(contextEntity[input.name]) ? contextEntity[input.name] : [contextEntity[input.name]],
|
|
111106
|
+
highlightRequired: highlightRequiredProperties,
|
|
111107
|
+
savedProperty: savedProperty === input.name,
|
|
111108
|
+
onLoadEntity,
|
|
111109
|
+
onCreateEntity: handleCreateEntity,
|
|
111110
|
+
onLinkEntity: handleLinkEntity,
|
|
111111
|
+
onUnlinkEntity: handleUnlinkEntity,
|
|
111112
|
+
onCreateProperty: handleCreateProperty,
|
|
111113
|
+
onSaveProperty: handleUpdateEntity,
|
|
111114
|
+
onDeleteProperty: handleDeleteProperty
|
|
111115
|
+
}
|
|
111116
|
+
) }, input.name);
|
|
111082
111117
|
}
|
|
111083
111118
|
return null;
|
|
111084
111119
|
})
|
|
@@ -115389,6 +115424,7 @@ var hasExports = requireHas();
|
|
|
115389
115424
|
const has = /* @__PURE__ */ getDefaultExportFromCjs(hasExports);
|
|
115390
115425
|
class ProfileManager {
|
|
115391
115426
|
constructor({ profile }) {
|
|
115427
|
+
this.propertyDefinitionCache = /* @__PURE__ */ new Map();
|
|
115392
115428
|
if (profile) {
|
|
115393
115429
|
this.profile = profile;
|
|
115394
115430
|
this.__processInputs();
|
|
@@ -115529,6 +115565,12 @@ class ProfileManager {
|
|
|
115529
115565
|
property,
|
|
115530
115566
|
entity
|
|
115531
115567
|
}) {
|
|
115568
|
+
const typeList = Array.isArray(entity["@type"]) ? entity["@type"] : [entity["@type"]];
|
|
115569
|
+
const cacheKey = `${typeList.slice().sort().join("|")}::${property.toLowerCase()}`;
|
|
115570
|
+
const cachedPropertyDefinition = this.propertyDefinitionCache.get(cacheKey);
|
|
115571
|
+
if (cachedPropertyDefinition) {
|
|
115572
|
+
return { propertyDefinition: cloneDeep(cachedPropertyDefinition) };
|
|
115573
|
+
}
|
|
115532
115574
|
let propertyDefinition = {};
|
|
115533
115575
|
let inputs = this.getInputsFromProfile({ entity });
|
|
115534
115576
|
if (inputs.length) {
|
|
@@ -115557,7 +115599,8 @@ class ProfileManager {
|
|
|
115557
115599
|
propertyDefinition.type = [propertyDefinition.type];
|
|
115558
115600
|
}
|
|
115559
115601
|
if (!has(propertyDefinition, "multiple")) propertyDefinition.multiple = true;
|
|
115560
|
-
|
|
115602
|
+
this.propertyDefinitionCache.set(cacheKey, cloneDeep(propertyDefinition));
|
|
115603
|
+
return { propertyDefinition: cloneDeep(propertyDefinition) };
|
|
115561
115604
|
}
|
|
115562
115605
|
/**
|
|
115563
115606
|
*
|
|
@@ -119457,7 +119500,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
|
|
|
119457
119500
|
}) : null
|
|
119458
119501
|
);
|
|
119459
119502
|
var CacheProvider = EmotionCacheContext.Provider;
|
|
119460
|
-
const version = "0.1.
|
|
119503
|
+
const version = "0.1.15";
|
|
119461
119504
|
const pkg = {
|
|
119462
119505
|
version
|
|
119463
119506
|
};
|
|
@@ -119495,7 +119538,6 @@ function DescriboCrateBuilder(props) {
|
|
|
119495
119538
|
onAddNewProfileRequest,
|
|
119496
119539
|
onRemoveProfile
|
|
119497
119540
|
} = props;
|
|
119498
|
-
console.log("DescriboCrateBuilder props:", { crate, profile, entityId });
|
|
119499
119541
|
const [ready, setReady] = useState(false);
|
|
119500
119542
|
const [error2, setError] = useState(false);
|
|
119501
119543
|
const [contextEntity, setContextEntity] = useState(null);
|
|
@@ -119549,8 +119591,6 @@ function DescriboCrateBuilder(props) {
|
|
|
119549
119591
|
lookup
|
|
119550
119592
|
]);
|
|
119551
119593
|
const init2 = useCallback(async () => {
|
|
119552
|
-
console.log("Initializing with crate:", crate);
|
|
119553
|
-
console.log("Profile loaded:", profile);
|
|
119554
119594
|
instance.changeLanguage(language2);
|
|
119555
119595
|
if (!crate || isEmpty(crate)) {
|
|
119556
119596
|
setReady(false);
|
|
@@ -119562,7 +119602,6 @@ function DescriboCrateBuilder(props) {
|
|
|
119562
119602
|
crate,
|
|
119563
119603
|
entityTimestamps: enableEntityTimestamps
|
|
119564
119604
|
});
|
|
119565
|
-
console.log("Entity:", newCm.getEntity({ id: entityId || "./" }));
|
|
119566
119605
|
const profileClone = profile ? JSON.parse(JSON.stringify(profile)) : {};
|
|
119567
119606
|
const newPm = new ProfileManager({
|
|
119568
119607
|
profile: profileClone
|
|
@@ -119589,32 +119628,26 @@ function DescriboCrateBuilder(props) {
|
|
|
119589
119628
|
setError(false);
|
|
119590
119629
|
state.configuration = configuration;
|
|
119591
119630
|
try {
|
|
119592
|
-
|
|
119593
|
-
|
|
119631
|
+
const rootEntity = newCm.getEntity({ id: "./", link: false, materialise: false });
|
|
119632
|
+
if (!isEmpty(rootEntity)) {
|
|
119633
|
+
setContextEntity(rootEntity);
|
|
119634
|
+
state.editorState.push({ id: rootEntity["@id"] });
|
|
119594
119635
|
} else {
|
|
119595
|
-
|
|
119596
|
-
|
|
119597
|
-
setContextEntity(rootEntity);
|
|
119598
|
-
state.editorState.push({ id: rootEntity["@id"] });
|
|
119599
|
-
} else {
|
|
119600
|
-
console.warn("Root entity './' not found");
|
|
119601
|
-
setError(true);
|
|
119602
|
-
return;
|
|
119603
|
-
}
|
|
119636
|
+
setError(true);
|
|
119637
|
+
return;
|
|
119604
119638
|
}
|
|
119605
119639
|
setReady(true);
|
|
119606
119640
|
onReady == null ? void 0 : onReady();
|
|
119607
119641
|
} catch (error22) {
|
|
119608
|
-
console.error("Error setting current entity:", error22);
|
|
119609
119642
|
setError(true);
|
|
119610
119643
|
onError == null ? void 0 : onError({ error: "Failed to initialize entity" });
|
|
119611
119644
|
}
|
|
119612
|
-
}, [crate, profile,
|
|
119645
|
+
}, [crate, profile, lookup, configuration, enableEntityTimestamps, language2, onError, onReady, state.editorState]);
|
|
119613
119646
|
const handleSetCurrentEntity = useCallback((params) => {
|
|
119614
119647
|
const { id: id2, updateState = true } = params;
|
|
119615
119648
|
if (!id2 || !cm) return;
|
|
119616
119649
|
try {
|
|
119617
|
-
const entity = cm.getEntity({ id: id2 });
|
|
119650
|
+
const entity = cm.getEntity({ id: id2, link: false, materialise: false });
|
|
119618
119651
|
if (!isEmpty(entity)) {
|
|
119619
119652
|
setContextEntity(entity);
|
|
119620
119653
|
onNavigation == null ? void 0 : onNavigation({
|