@arpproject/recrate 0.1.48 → 0.1.50
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/recrate.es.js
CHANGED
|
@@ -74008,7 +74008,7 @@ function normalise(entity, i) {
|
|
|
74008
74008
|
if (!isValid && message === "The identifier is not valid according to the RO Crate spec nor is it a valid IRI.") {
|
|
74009
74009
|
normalisedEntity["@id"] = `#${normalisedEntity["@id"]}`;
|
|
74010
74010
|
}
|
|
74011
|
-
normalisedEntity.name = shouldGenerateEntityName(entity.name) ?
|
|
74011
|
+
normalisedEntity.name = shouldGenerateEntityName(entity.name) ? "" : entity.name;
|
|
74012
74012
|
if (isArray(normalisedEntity.name)) normalisedEntity.name = normalisedEntity.name.join(" ");
|
|
74013
74013
|
for (let property of Object.keys(entity)) {
|
|
74014
74014
|
if (["@id", "@type", "name", "@reverse"].includes(property)) continue;
|
|
@@ -93918,6 +93918,12 @@ function stringifyDocumentType(documents) {
|
|
|
93918
93918
|
"@type": lodashExports.isArray(d2["@type"]) ? d2["@type"].join(", ") : d2["@type"]
|
|
93919
93919
|
}));
|
|
93920
93920
|
}
|
|
93921
|
+
const newEntityFromName = (type4, name2) => ({
|
|
93922
|
+
type: "new",
|
|
93923
|
+
"@id": name2,
|
|
93924
|
+
"@type": type4,
|
|
93925
|
+
name: name2
|
|
93926
|
+
});
|
|
93921
93927
|
const AutoComplete = ({ type: type4, onLinkEntity, onCreateEntity }) => {
|
|
93922
93928
|
const { t: t2 } = useTranslation();
|
|
93923
93929
|
const crateManager = useContext(CrateManagerContext);
|
|
@@ -93926,7 +93932,7 @@ const AutoComplete = ({ type: type4, onLinkEntity, onCreateEntity }) => {
|
|
|
93926
93932
|
const [loading, setLoading] = useState(false);
|
|
93927
93933
|
const [selection2, setSelection] = useState(null);
|
|
93928
93934
|
const [matches2, setMatches] = useState([]);
|
|
93929
|
-
const
|
|
93935
|
+
const inputValue = useRef("");
|
|
93930
93936
|
const promiseTimeout = 2500;
|
|
93931
93937
|
const querySearch = async (queryString) => {
|
|
93932
93938
|
var _a2;
|
|
@@ -93936,14 +93942,7 @@ const AutoComplete = ({ type: type4, onLinkEntity, onCreateEntity }) => {
|
|
|
93936
93942
|
lookup: lookupHandler,
|
|
93937
93943
|
crateManager
|
|
93938
93944
|
});
|
|
93939
|
-
const newEntity = queryString ? [
|
|
93940
|
-
{
|
|
93941
|
-
type: "new",
|
|
93942
|
-
"@id": queryString,
|
|
93943
|
-
"@type": type4,
|
|
93944
|
-
name: queryString
|
|
93945
|
-
}
|
|
93946
|
-
] : [];
|
|
93945
|
+
const newEntity = queryString ? [newEntityFromName(type4, queryString)] : [];
|
|
93947
93946
|
const lookups = [];
|
|
93948
93947
|
if (crateManager == null ? void 0 : crateManager.getEntities) {
|
|
93949
93948
|
lookups.push(wrapPromise(lookup.getEntities(type4, queryString), promiseTimeout));
|
|
@@ -94038,6 +94037,21 @@ const AutoComplete = ({ type: type4, onLinkEntity, onCreateEntity }) => {
|
|
|
94038
94037
|
}
|
|
94039
94038
|
setSelection(null);
|
|
94040
94039
|
};
|
|
94040
|
+
const handleSearch = (value) => {
|
|
94041
|
+
inputValue.current = value;
|
|
94042
|
+
debouncedQuerySearch(value);
|
|
94043
|
+
};
|
|
94044
|
+
const handleInputKeyDown = (event) => {
|
|
94045
|
+
const name2 = inputValue.current;
|
|
94046
|
+
if (event.key !== "Enter" || event.nativeEvent.isComposing || type4 === "ANY" || !name2) {
|
|
94047
|
+
return;
|
|
94048
|
+
}
|
|
94049
|
+
event.preventDefault();
|
|
94050
|
+
event.stopPropagation();
|
|
94051
|
+
handleSelect(name2, {
|
|
94052
|
+
entity: newEntityFromName(type4, name2)
|
|
94053
|
+
});
|
|
94054
|
+
};
|
|
94041
94055
|
const renderOption = (option) => {
|
|
94042
94056
|
const entity = option.entity;
|
|
94043
94057
|
if (!entity) return null;
|
|
@@ -94089,7 +94103,8 @@ const AutoComplete = ({ type: type4, onLinkEntity, onCreateEntity }) => {
|
|
|
94089
94103
|
placeholder: t2("select_existing_or_create_new") || "select an existing entity or create a new one",
|
|
94090
94104
|
defaultActiveFirstOption: false,
|
|
94091
94105
|
filterOption: false,
|
|
94092
|
-
onSearch:
|
|
94106
|
+
onSearch: handleSearch,
|
|
94107
|
+
onInputKeyDown: handleInputKeyDown,
|
|
94093
94108
|
onChange: handleSelect,
|
|
94094
94109
|
notFoundContent: loading ? "Loading..." : "No results",
|
|
94095
94110
|
options: matches2.flatMap((group) => [
|
|
@@ -126854,7 +126869,7 @@ class CrateManager {
|
|
|
126854
126869
|
if (shouldGenerateEntityName(crate["@graph"][i].name)) {
|
|
126855
126870
|
this.__setWarning(
|
|
126856
126871
|
"init",
|
|
126857
|
-
`Entity '${normalisedEntity["@id"]}'
|
|
126872
|
+
`Entity '${normalisedEntity["@id"]}' does not have the required name property.`
|
|
126858
126873
|
);
|
|
126859
126874
|
}
|
|
126860
126875
|
idMap[crate["@graph"][i]["@id"]] = normalisedEntity["@id"];
|
|
@@ -127622,7 +127637,7 @@ class CrateManager {
|
|
|
127622
127637
|
console.log("updateProperty", { id: id2, property, idx, value });
|
|
127623
127638
|
if (!id2) throw new Error(`'setProperty' requires 'id' to be defined`);
|
|
127624
127639
|
if (!property) throw new Error(`setProperty' requires 'property' to be defined`);
|
|
127625
|
-
if (value !== false && !value)
|
|
127640
|
+
if (value !== false && !value && property !== "name")
|
|
127626
127641
|
throw new Error(`'setProperty' requires 'value' to be defined`);
|
|
127627
127642
|
console.log("updateProperty", { id: id2, property, idx, value });
|
|
127628
127643
|
if (isPlainObject(value) && isEmpty(value)) return;
|
|
@@ -135315,7 +135330,7 @@ var EmotionCacheContext = /* @__PURE__ */ React.createContext(
|
|
|
135315
135330
|
}) : null
|
|
135316
135331
|
);
|
|
135317
135332
|
var CacheProvider = EmotionCacheContext.Provider;
|
|
135318
|
-
const version = "0.1.
|
|
135333
|
+
const version = "0.1.50";
|
|
135319
135334
|
const pkg = {
|
|
135320
135335
|
version
|
|
135321
135336
|
};
|