@dyrected/admin 2.5.49 → 2.5.51
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.
|
@@ -9,5 +9,5 @@ interface UrlFieldProps {
|
|
|
9
9
|
siblingData: any;
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
export declare function UrlField({
|
|
12
|
+
export declare function UrlField({ field, disabled }: UrlFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export {};
|
package/dist/index.mjs
CHANGED
|
@@ -6794,37 +6794,54 @@ function interpolateUrlPattern(pattern, doc) {
|
|
|
6794
6794
|
}
|
|
6795
6795
|
//#endregion
|
|
6796
6796
|
//#region src/components/forms/fields/url-field.tsx
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
};
|
|
6807
|
-
if (typeof val === "string") return {
|
|
6797
|
+
var parseValue = (val) => {
|
|
6798
|
+
if (!val) return {
|
|
6799
|
+
type: "custom",
|
|
6800
|
+
url: ""
|
|
6801
|
+
};
|
|
6802
|
+
if (typeof val === "string") {
|
|
6803
|
+
let url = val;
|
|
6804
|
+
if (url.startsWith("/")) url = `${window.location.origin}${url}`;
|
|
6805
|
+
return {
|
|
6808
6806
|
type: "custom",
|
|
6809
|
-
url
|
|
6807
|
+
url
|
|
6810
6808
|
};
|
|
6811
|
-
|
|
6809
|
+
}
|
|
6810
|
+
if (typeof val === "object") {
|
|
6811
|
+
let url = val.url || "";
|
|
6812
|
+
if (url.startsWith("/")) url = `${window.location.origin}${url}`;
|
|
6813
|
+
return {
|
|
6812
6814
|
type: val.type === "internal" ? "internal" : "custom",
|
|
6813
|
-
url
|
|
6815
|
+
url,
|
|
6814
6816
|
relationTo: val.relationTo,
|
|
6815
6817
|
value: val.value,
|
|
6816
6818
|
label: val.label
|
|
6817
6819
|
};
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6820
|
+
}
|
|
6821
|
+
return {
|
|
6822
|
+
type: "custom",
|
|
6823
|
+
url: String(val)
|
|
6822
6824
|
};
|
|
6825
|
+
};
|
|
6826
|
+
function UrlField({ field, disabled }) {
|
|
6827
|
+
const { client, schemas } = useDyrected();
|
|
6828
|
+
const [openPopover, setOpenPopover] = React$1.useState(false);
|
|
6829
|
+
const [documents, setDocuments] = React$1.useState([]);
|
|
6830
|
+
const [docsLoading, setDocsLoading] = React$1.useState(false);
|
|
6823
6831
|
const currentData = parseValue(field.value);
|
|
6824
6832
|
const [urlValue, setUrlValue] = React$1.useState(currentData.url);
|
|
6825
6833
|
const [labelValue, setLabelValue] = React$1.useState(currentData.label || "");
|
|
6826
6834
|
const [collectionValue, setCollectionValue] = React$1.useState(currentData.relationTo || "");
|
|
6827
6835
|
const [docValue, setDocValue] = React$1.useState(currentData.value || "");
|
|
6836
|
+
React$1.useEffect(() => {
|
|
6837
|
+
const next = parseValue(field.value);
|
|
6838
|
+
Promise.resolve().then(() => {
|
|
6839
|
+
setUrlValue((prev) => prev === next.url ? prev : next.url);
|
|
6840
|
+
setLabelValue((prev) => prev === next.label ? prev : next.label || "");
|
|
6841
|
+
setCollectionValue((prev) => prev === next.relationTo ? prev : next.relationTo || "");
|
|
6842
|
+
setDocValue((prev) => prev === next.value ? prev : next.value || "");
|
|
6843
|
+
});
|
|
6844
|
+
}, [field.value]);
|
|
6828
6845
|
const collections = React$1.useMemo(() => schemas?.collections || [], [schemas?.collections]);
|
|
6829
6846
|
React$1.useEffect(() => {
|
|
6830
6847
|
if (!client || !schemas?.collections) return;
|
|
@@ -6868,9 +6885,11 @@ function UrlField({ schema: _schema, field, disabled, context: _context }) {
|
|
|
6868
6885
|
]);
|
|
6869
6886
|
const handleUpdate = (url, label, relationTo, docId) => {
|
|
6870
6887
|
const isInternal = !!(relationTo && docId);
|
|
6888
|
+
let cleanedUrl = url;
|
|
6889
|
+
if (isInternal && cleanedUrl.startsWith(window.location.origin)) cleanedUrl = cleanedUrl.substring(window.location.origin.length);
|
|
6871
6890
|
const newValue = {
|
|
6872
6891
|
type: isInternal ? "internal" : "custom",
|
|
6873
|
-
url:
|
|
6892
|
+
url: cleanedUrl || void 0,
|
|
6874
6893
|
relationTo: isInternal ? relationTo : void 0,
|
|
6875
6894
|
value: isInternal ? docId : void 0,
|
|
6876
6895
|
label: label || void 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dyrected/admin",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.51",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -64,9 +64,9 @@
|
|
|
64
64
|
"tailwind-merge": "^3.5.0",
|
|
65
65
|
"tailwindcss-animate": "^1.0.7",
|
|
66
66
|
"zod": "^3.25.76",
|
|
67
|
-
"@dyrected/
|
|
68
|
-
"@dyrected/
|
|
69
|
-
"@dyrected/
|
|
67
|
+
"@dyrected/core": "^2.5.51",
|
|
68
|
+
"@dyrected/knowledge": "^0.2.8",
|
|
69
|
+
"@dyrected/sdk": "^2.5.51"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"@tanstack/react-query": "^5.0.0",
|