@tecof/theme-editor 0.0.28 → 0.0.30
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/index.d.mts +76 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js +405 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +403 -41
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +378 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import Blockquote from '@tiptap/extension-blockquote';
|
|
|
16
16
|
import HardBreak from '@tiptap/extension-hard-break';
|
|
17
17
|
import HorizontalRule from '@tiptap/extension-horizontal-rule';
|
|
18
18
|
import TextAlign from '@tiptap/extension-text-align';
|
|
19
|
-
import
|
|
19
|
+
import Link3 from '@tiptap/extension-link';
|
|
20
20
|
import Code2 from '@tiptap/extension-code';
|
|
21
21
|
import CodeBlock from '@tiptap/extension-code-block';
|
|
22
22
|
import * as ReactDOM from 'react-dom';
|
|
@@ -221,6 +221,49 @@ var TecofApiClient = class {
|
|
|
221
221
|
return null;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Fetch CMS collections list (for CmsCollectionField)
|
|
226
|
+
* Returns: [{ _id, name, slug, fields, ... }]
|
|
227
|
+
*/
|
|
228
|
+
async getCmsCollections() {
|
|
229
|
+
try {
|
|
230
|
+
const res2 = await fetch(`${this.apiUrl}/api/store/cms/collections`, {
|
|
231
|
+
method: "POST",
|
|
232
|
+
headers: this.headers,
|
|
233
|
+
body: JSON.stringify({})
|
|
234
|
+
});
|
|
235
|
+
return await res2.json();
|
|
236
|
+
} catch (error2) {
|
|
237
|
+
return {
|
|
238
|
+
success: false,
|
|
239
|
+
message: error2 instanceof Error ? error2.message : "Failed to fetch collections"
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Fetch items from a CMS collection by slug
|
|
245
|
+
* Returns: { items: [...], totalData: N }
|
|
246
|
+
*/
|
|
247
|
+
async getCmsCollectionItems(collectionSlug, options) {
|
|
248
|
+
try {
|
|
249
|
+
const res2 = await fetch(`${this.apiUrl}/api/store/cms/collections/${encodeURIComponent(collectionSlug)}/items`, {
|
|
250
|
+
method: "POST",
|
|
251
|
+
headers: this.headers,
|
|
252
|
+
body: JSON.stringify({
|
|
253
|
+
page: options?.page || 1,
|
|
254
|
+
limit: options?.limit || 50,
|
|
255
|
+
sort: options?.sort || "newest",
|
|
256
|
+
locale: options?.locale
|
|
257
|
+
})
|
|
258
|
+
});
|
|
259
|
+
return await res2.json();
|
|
260
|
+
} catch (error2) {
|
|
261
|
+
return {
|
|
262
|
+
success: false,
|
|
263
|
+
message: error2 instanceof Error ? error2.message : "Failed to fetch collection items"
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
}
|
|
224
267
|
/** CDN base URL (defaults to apiUrl if not set) */
|
|
225
268
|
get cdnUrl() {
|
|
226
269
|
return this.customCdnUrl || this.apiUrl;
|
|
@@ -756,16 +799,24 @@ var __iconNode5 = [
|
|
|
756
799
|
];
|
|
757
800
|
var Copy = createLucideIcon("copy", __iconNode5);
|
|
758
801
|
|
|
759
|
-
// node_modules/lucide-react/dist/esm/icons/
|
|
802
|
+
// node_modules/lucide-react/dist/esm/icons/database.js
|
|
760
803
|
var __iconNode6 = [
|
|
804
|
+
["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
|
|
805
|
+
["path", { d: "M3 5V19A9 3 0 0 0 21 19V5", key: "1wlel7" }],
|
|
806
|
+
["path", { d: "M3 12A9 3 0 0 0 21 12", key: "mv7ke4" }]
|
|
807
|
+
];
|
|
808
|
+
var Database = createLucideIcon("database", __iconNode6);
|
|
809
|
+
|
|
810
|
+
// node_modules/lucide-react/dist/esm/icons/external-link.js
|
|
811
|
+
var __iconNode7 = [
|
|
761
812
|
["path", { d: "M15 3h6v6", key: "1q9fwt" }],
|
|
762
813
|
["path", { d: "M10 14 21 3", key: "gplh6r" }],
|
|
763
814
|
["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
|
|
764
815
|
];
|
|
765
|
-
var ExternalLink = createLucideIcon("external-link",
|
|
816
|
+
var ExternalLink = createLucideIcon("external-link", __iconNode7);
|
|
766
817
|
|
|
767
818
|
// node_modules/lucide-react/dist/esm/icons/file-text.js
|
|
768
|
-
var
|
|
819
|
+
var __iconNode8 = [
|
|
769
820
|
[
|
|
770
821
|
"path",
|
|
771
822
|
{
|
|
@@ -778,10 +829,10 @@ var __iconNode7 = [
|
|
|
778
829
|
["path", { d: "M16 13H8", key: "t4e002" }],
|
|
779
830
|
["path", { d: "M16 17H8", key: "z1uh3a" }]
|
|
780
831
|
];
|
|
781
|
-
var FileText = createLucideIcon("file-text",
|
|
832
|
+
var FileText = createLucideIcon("file-text", __iconNode8);
|
|
782
833
|
|
|
783
834
|
// node_modules/lucide-react/dist/esm/icons/file.js
|
|
784
|
-
var
|
|
835
|
+
var __iconNode9 = [
|
|
785
836
|
[
|
|
786
837
|
"path",
|
|
787
838
|
{
|
|
@@ -791,10 +842,10 @@ var __iconNode8 = [
|
|
|
791
842
|
],
|
|
792
843
|
["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
|
|
793
844
|
];
|
|
794
|
-
var File2 = createLucideIcon("file",
|
|
845
|
+
var File2 = createLucideIcon("file", __iconNode9);
|
|
795
846
|
|
|
796
847
|
// node_modules/lucide-react/dist/esm/icons/folder-open.js
|
|
797
|
-
var
|
|
848
|
+
var __iconNode10 = [
|
|
798
849
|
[
|
|
799
850
|
"path",
|
|
800
851
|
{
|
|
@@ -803,18 +854,18 @@ var __iconNode9 = [
|
|
|
803
854
|
}
|
|
804
855
|
]
|
|
805
856
|
];
|
|
806
|
-
var FolderOpen = createLucideIcon("folder-open",
|
|
857
|
+
var FolderOpen = createLucideIcon("folder-open", __iconNode10);
|
|
807
858
|
|
|
808
859
|
// node_modules/lucide-react/dist/esm/icons/globe.js
|
|
809
|
-
var
|
|
860
|
+
var __iconNode11 = [
|
|
810
861
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
811
862
|
["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
|
|
812
863
|
["path", { d: "M2 12h20", key: "9i4pu4" }]
|
|
813
864
|
];
|
|
814
|
-
var Globe = createLucideIcon("globe",
|
|
865
|
+
var Globe = createLucideIcon("globe", __iconNode11);
|
|
815
866
|
|
|
816
867
|
// node_modules/lucide-react/dist/esm/icons/grip-vertical.js
|
|
817
|
-
var
|
|
868
|
+
var __iconNode12 = [
|
|
818
869
|
["circle", { cx: "9", cy: "12", r: "1", key: "1vctgf" }],
|
|
819
870
|
["circle", { cx: "9", cy: "5", r: "1", key: "hp0tcf" }],
|
|
820
871
|
["circle", { cx: "9", cy: "19", r: "1", key: "fkjjf6" }],
|
|
@@ -822,28 +873,28 @@ var __iconNode11 = [
|
|
|
822
873
|
["circle", { cx: "15", cy: "5", r: "1", key: "19l28e" }],
|
|
823
874
|
["circle", { cx: "15", cy: "19", r: "1", key: "f4zoj3" }]
|
|
824
875
|
];
|
|
825
|
-
var GripVertical = createLucideIcon("grip-vertical",
|
|
876
|
+
var GripVertical = createLucideIcon("grip-vertical", __iconNode12);
|
|
826
877
|
|
|
827
878
|
// node_modules/lucide-react/dist/esm/icons/image-plus.js
|
|
828
|
-
var
|
|
879
|
+
var __iconNode13 = [
|
|
829
880
|
["path", { d: "M16 5h6", key: "1vod17" }],
|
|
830
881
|
["path", { d: "M19 2v6", key: "4bpg5p" }],
|
|
831
882
|
["path", { d: "M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5", key: "1ue2ih" }],
|
|
832
883
|
["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }],
|
|
833
884
|
["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }]
|
|
834
885
|
];
|
|
835
|
-
var ImagePlus = createLucideIcon("image-plus",
|
|
886
|
+
var ImagePlus = createLucideIcon("image-plus", __iconNode13);
|
|
836
887
|
|
|
837
888
|
// node_modules/lucide-react/dist/esm/icons/image.js
|
|
838
|
-
var
|
|
889
|
+
var __iconNode14 = [
|
|
839
890
|
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
|
|
840
891
|
["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
|
|
841
892
|
["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
|
|
842
893
|
];
|
|
843
|
-
var Image2 = createLucideIcon("image",
|
|
894
|
+
var Image2 = createLucideIcon("image", __iconNode14);
|
|
844
895
|
|
|
845
896
|
// node_modules/lucide-react/dist/esm/icons/languages.js
|
|
846
|
-
var
|
|
897
|
+
var __iconNode15 = [
|
|
847
898
|
["path", { d: "m5 8 6 6", key: "1wu5hv" }],
|
|
848
899
|
["path", { d: "m4 14 6-6 2-3", key: "1k1g8d" }],
|
|
849
900
|
["path", { d: "M2 5h12", key: "or177f" }],
|
|
@@ -851,21 +902,29 @@ var __iconNode14 = [
|
|
|
851
902
|
["path", { d: "m22 22-5-10-5 10", key: "don7ne" }],
|
|
852
903
|
["path", { d: "M14 18h6", key: "1m8k6r" }]
|
|
853
904
|
];
|
|
854
|
-
var Languages = createLucideIcon("languages",
|
|
905
|
+
var Languages = createLucideIcon("languages", __iconNode15);
|
|
906
|
+
|
|
907
|
+
// node_modules/lucide-react/dist/esm/icons/link-2.js
|
|
908
|
+
var __iconNode16 = [
|
|
909
|
+
["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
|
|
910
|
+
["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
|
|
911
|
+
["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
|
|
912
|
+
];
|
|
913
|
+
var Link2 = createLucideIcon("link-2", __iconNode16);
|
|
855
914
|
|
|
856
915
|
// node_modules/lucide-react/dist/esm/icons/link.js
|
|
857
|
-
var
|
|
916
|
+
var __iconNode17 = [
|
|
858
917
|
["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
|
|
859
918
|
["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
|
|
860
919
|
];
|
|
861
|
-
var Link = createLucideIcon("link",
|
|
920
|
+
var Link = createLucideIcon("link", __iconNode17);
|
|
862
921
|
|
|
863
922
|
// node_modules/lucide-react/dist/esm/icons/loader-circle.js
|
|
864
|
-
var
|
|
865
|
-
var LoaderCircle = createLucideIcon("loader-circle",
|
|
923
|
+
var __iconNode18 = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
|
|
924
|
+
var LoaderCircle = createLucideIcon("loader-circle", __iconNode18);
|
|
866
925
|
|
|
867
926
|
// node_modules/lucide-react/dist/esm/icons/pencil.js
|
|
868
|
-
var
|
|
927
|
+
var __iconNode19 = [
|
|
869
928
|
[
|
|
870
929
|
"path",
|
|
871
930
|
{
|
|
@@ -875,62 +934,71 @@ var __iconNode17 = [
|
|
|
875
934
|
],
|
|
876
935
|
["path", { d: "m15 5 4 4", key: "1mk7zo" }]
|
|
877
936
|
];
|
|
878
|
-
var Pencil = createLucideIcon("pencil",
|
|
937
|
+
var Pencil = createLucideIcon("pencil", __iconNode19);
|
|
879
938
|
|
|
880
939
|
// node_modules/lucide-react/dist/esm/icons/plus.js
|
|
881
|
-
var
|
|
940
|
+
var __iconNode20 = [
|
|
882
941
|
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
883
942
|
["path", { d: "M12 5v14", key: "s699le" }]
|
|
884
943
|
];
|
|
885
|
-
var Plus = createLucideIcon("plus",
|
|
944
|
+
var Plus = createLucideIcon("plus", __iconNode20);
|
|
886
945
|
|
|
887
946
|
// node_modules/lucide-react/dist/esm/icons/refresh-ccw.js
|
|
888
|
-
var
|
|
947
|
+
var __iconNode21 = [
|
|
889
948
|
["path", { d: "M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "14sxne" }],
|
|
890
949
|
["path", { d: "M3 3v5h5", key: "1xhq8a" }],
|
|
891
950
|
["path", { d: "M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16", key: "1hlbsb" }],
|
|
892
951
|
["path", { d: "M16 16h5v5", key: "ccwih5" }]
|
|
893
952
|
];
|
|
894
|
-
var RefreshCcw = createLucideIcon("refresh-ccw",
|
|
953
|
+
var RefreshCcw = createLucideIcon("refresh-ccw", __iconNode21);
|
|
954
|
+
|
|
955
|
+
// node_modules/lucide-react/dist/esm/icons/refresh-cw.js
|
|
956
|
+
var __iconNode22 = [
|
|
957
|
+
["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
|
|
958
|
+
["path", { d: "M21 3v5h-5", key: "1q7to0" }],
|
|
959
|
+
["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
|
|
960
|
+
["path", { d: "M8 16H3v5", key: "1cv678" }]
|
|
961
|
+
];
|
|
962
|
+
var RefreshCw = createLucideIcon("refresh-cw", __iconNode22);
|
|
895
963
|
|
|
896
964
|
// node_modules/lucide-react/dist/esm/icons/rotate-ccw.js
|
|
897
|
-
var
|
|
965
|
+
var __iconNode23 = [
|
|
898
966
|
["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
|
|
899
967
|
["path", { d: "M3 3v5h5", key: "1xhq8a" }]
|
|
900
968
|
];
|
|
901
|
-
var RotateCcw = createLucideIcon("rotate-ccw",
|
|
969
|
+
var RotateCcw = createLucideIcon("rotate-ccw", __iconNode23);
|
|
902
970
|
|
|
903
971
|
// node_modules/lucide-react/dist/esm/icons/search.js
|
|
904
|
-
var
|
|
972
|
+
var __iconNode24 = [
|
|
905
973
|
["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
|
|
906
974
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
|
|
907
975
|
];
|
|
908
|
-
var Search = createLucideIcon("search",
|
|
976
|
+
var Search = createLucideIcon("search", __iconNode24);
|
|
909
977
|
|
|
910
978
|
// node_modules/lucide-react/dist/esm/icons/trash-2.js
|
|
911
|
-
var
|
|
979
|
+
var __iconNode25 = [
|
|
912
980
|
["path", { d: "M10 11v6", key: "nco0om" }],
|
|
913
981
|
["path", { d: "M14 11v6", key: "outv1u" }],
|
|
914
982
|
["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
|
|
915
983
|
["path", { d: "M3 6h18", key: "d0wm0j" }],
|
|
916
984
|
["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
|
|
917
985
|
];
|
|
918
|
-
var Trash2 = createLucideIcon("trash-2",
|
|
986
|
+
var Trash2 = createLucideIcon("trash-2", __iconNode25);
|
|
919
987
|
|
|
920
988
|
// node_modules/lucide-react/dist/esm/icons/upload.js
|
|
921
|
-
var
|
|
989
|
+
var __iconNode26 = [
|
|
922
990
|
["path", { d: "M12 3v12", key: "1x0j5s" }],
|
|
923
991
|
["path", { d: "m17 8-5-5-5 5", key: "7q97r8" }],
|
|
924
992
|
["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
|
|
925
993
|
];
|
|
926
|
-
var Upload = createLucideIcon("upload",
|
|
994
|
+
var Upload = createLucideIcon("upload", __iconNode26);
|
|
927
995
|
|
|
928
996
|
// node_modules/lucide-react/dist/esm/icons/x.js
|
|
929
|
-
var
|
|
997
|
+
var __iconNode27 = [
|
|
930
998
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
931
999
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
932
1000
|
];
|
|
933
|
-
var X = createLucideIcon("x",
|
|
1001
|
+
var X = createLucideIcon("x", __iconNode27);
|
|
934
1002
|
var FieldErrorBoundary = class extends Component {
|
|
935
1003
|
constructor(props) {
|
|
936
1004
|
super(props);
|
|
@@ -1265,7 +1333,7 @@ var createExtensions = () => [
|
|
|
1265
1333
|
Code2,
|
|
1266
1334
|
CodeBlock,
|
|
1267
1335
|
TextAlign.configure({ types: ["heading", "paragraph"] }),
|
|
1268
|
-
|
|
1336
|
+
Link3.configure({ openOnClick: false, HTMLAttributes: { target: "_blank" } })
|
|
1269
1337
|
];
|
|
1270
1338
|
var ToolbarBtn = ({
|
|
1271
1339
|
onClick,
|
|
@@ -24508,6 +24576,297 @@ var createRepeaterField = (options) => {
|
|
|
24508
24576
|
) }) })
|
|
24509
24577
|
};
|
|
24510
24578
|
};
|
|
24579
|
+
var CmsCollectionField = ({
|
|
24580
|
+
value,
|
|
24581
|
+
onChange,
|
|
24582
|
+
readOnly,
|
|
24583
|
+
defaultLimit = 10,
|
|
24584
|
+
showLimit = true,
|
|
24585
|
+
showSort = true,
|
|
24586
|
+
slots
|
|
24587
|
+
}) => {
|
|
24588
|
+
const { apiClient } = useTecof();
|
|
24589
|
+
const [collections, setCollections] = useState([]);
|
|
24590
|
+
const [loading, setLoading] = useState(true);
|
|
24591
|
+
const [error2, setError] = useState(null);
|
|
24592
|
+
const [dropdownOpen, setDropdownOpen] = useState(false);
|
|
24593
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
24594
|
+
const dropdownRef = useRef(null);
|
|
24595
|
+
const onChangeRef = useRef(onChange);
|
|
24596
|
+
onChangeRef.current = onChange;
|
|
24597
|
+
const fetchCollections = useCallback(async () => {
|
|
24598
|
+
setLoading(true);
|
|
24599
|
+
setError(null);
|
|
24600
|
+
try {
|
|
24601
|
+
const res2 = await apiClient.getCmsCollections();
|
|
24602
|
+
if (res2.success && Array.isArray(res2.data)) {
|
|
24603
|
+
setCollections(res2.data);
|
|
24604
|
+
} else {
|
|
24605
|
+
setError(res2.message || "Koleksiyonlar y\xFCklenemedi");
|
|
24606
|
+
}
|
|
24607
|
+
} catch (err) {
|
|
24608
|
+
setError(err.message || "Ba\u011Flant\u0131 hatas\u0131");
|
|
24609
|
+
} finally {
|
|
24610
|
+
setLoading(false);
|
|
24611
|
+
}
|
|
24612
|
+
}, [apiClient]);
|
|
24613
|
+
useEffect(() => {
|
|
24614
|
+
fetchCollections();
|
|
24615
|
+
}, [fetchCollections]);
|
|
24616
|
+
useEffect(() => {
|
|
24617
|
+
if (!dropdownOpen) return;
|
|
24618
|
+
const handleClick = (e3) => {
|
|
24619
|
+
if (dropdownRef.current && !dropdownRef.current.contains(e3.target)) {
|
|
24620
|
+
setDropdownOpen(false);
|
|
24621
|
+
}
|
|
24622
|
+
};
|
|
24623
|
+
document.addEventListener("mousedown", handleClick);
|
|
24624
|
+
return () => document.removeEventListener("mousedown", handleClick);
|
|
24625
|
+
}, [dropdownOpen]);
|
|
24626
|
+
const selectedCollection = useMemo(() => {
|
|
24627
|
+
if (!value?.collectionSlug) return null;
|
|
24628
|
+
return collections.find((c2) => c2.slug === value.collectionSlug) || null;
|
|
24629
|
+
}, [value?.collectionSlug, collections]);
|
|
24630
|
+
const collectionFields = useMemo(() => {
|
|
24631
|
+
return selectedCollection?.fields || [];
|
|
24632
|
+
}, [selectedCollection]);
|
|
24633
|
+
const handleSelect = useCallback((col) => {
|
|
24634
|
+
onChangeRef.current({
|
|
24635
|
+
collectionSlug: col.slug,
|
|
24636
|
+
collectionName: col.name,
|
|
24637
|
+
limit: value?.limit || defaultLimit,
|
|
24638
|
+
sort: value?.sort || "newest",
|
|
24639
|
+
fieldMap: value?.fieldMap || {}
|
|
24640
|
+
});
|
|
24641
|
+
setDropdownOpen(false);
|
|
24642
|
+
setSearchQuery("");
|
|
24643
|
+
}, [value, defaultLimit]);
|
|
24644
|
+
const handleClear = useCallback(() => {
|
|
24645
|
+
onChangeRef.current(null);
|
|
24646
|
+
}, []);
|
|
24647
|
+
const handleLimitChange = useCallback((e3) => {
|
|
24648
|
+
const num = parseInt(e3.target.value, 10);
|
|
24649
|
+
if (!value) return;
|
|
24650
|
+
onChangeRef.current({
|
|
24651
|
+
...value,
|
|
24652
|
+
limit: isNaN(num) ? defaultLimit : Math.max(1, Math.min(100, num))
|
|
24653
|
+
});
|
|
24654
|
+
}, [value, defaultLimit]);
|
|
24655
|
+
const handleSortChange = useCallback((sort) => {
|
|
24656
|
+
if (!value) return;
|
|
24657
|
+
onChangeRef.current({ ...value, sort });
|
|
24658
|
+
}, [value]);
|
|
24659
|
+
const handleFieldMapChange = useCallback((slotKey, fieldShortcode) => {
|
|
24660
|
+
if (!value) return;
|
|
24661
|
+
onChangeRef.current({
|
|
24662
|
+
...value,
|
|
24663
|
+
fieldMap: {
|
|
24664
|
+
...value.fieldMap,
|
|
24665
|
+
[slotKey]: fieldShortcode
|
|
24666
|
+
}
|
|
24667
|
+
});
|
|
24668
|
+
}, [value]);
|
|
24669
|
+
const filteredCollections = useMemo(() => {
|
|
24670
|
+
if (!searchQuery.trim()) return collections;
|
|
24671
|
+
const q = searchQuery.toLowerCase();
|
|
24672
|
+
return collections.filter(
|
|
24673
|
+
(c2) => c2.name.toLowerCase().includes(q) || c2.slug.toLowerCase().includes(q)
|
|
24674
|
+
);
|
|
24675
|
+
}, [collections, searchQuery]);
|
|
24676
|
+
if (loading) {
|
|
24677
|
+
return /* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-loading", children: [
|
|
24678
|
+
/* @__PURE__ */ jsx(LoaderCircle, { size: 16, className: "tecof-spin" }),
|
|
24679
|
+
/* @__PURE__ */ jsx("span", { children: "Koleksiyonlar y\xFCkleniyor\u2026" })
|
|
24680
|
+
] });
|
|
24681
|
+
}
|
|
24682
|
+
if (error2) {
|
|
24683
|
+
return /* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-error", children: [
|
|
24684
|
+
/* @__PURE__ */ jsx("span", { children: error2 }),
|
|
24685
|
+
/* @__PURE__ */ jsxs("button", { type: "button", className: "tecof-cms-col-retry", onClick: fetchCollections, children: [
|
|
24686
|
+
/* @__PURE__ */ jsx(RefreshCw, { size: 12 }),
|
|
24687
|
+
" Tekrar Dene"
|
|
24688
|
+
] })
|
|
24689
|
+
] });
|
|
24690
|
+
}
|
|
24691
|
+
const hasSlots = slots && Object.keys(slots).length > 0;
|
|
24692
|
+
return /* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-container", children: [
|
|
24693
|
+
/* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-selector", ref: dropdownRef, children: [
|
|
24694
|
+
/* @__PURE__ */ jsxs(
|
|
24695
|
+
"button",
|
|
24696
|
+
{
|
|
24697
|
+
type: "button",
|
|
24698
|
+
className: `tecof-cms-col-trigger ${dropdownOpen ? "open" : ""}`,
|
|
24699
|
+
onClick: () => !readOnly && setDropdownOpen(!dropdownOpen),
|
|
24700
|
+
disabled: readOnly,
|
|
24701
|
+
children: [
|
|
24702
|
+
/* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-trigger-left", children: [
|
|
24703
|
+
/* @__PURE__ */ jsx(Database, { size: 14 }),
|
|
24704
|
+
/* @__PURE__ */ jsx("span", { children: value?.collectionName || value?.collectionSlug || "Koleksiyon Se\xE7in" })
|
|
24705
|
+
] }),
|
|
24706
|
+
/* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-trigger-right", children: [
|
|
24707
|
+
value && !readOnly && /* @__PURE__ */ jsx(
|
|
24708
|
+
"button",
|
|
24709
|
+
{
|
|
24710
|
+
type: "button",
|
|
24711
|
+
className: "tecof-cms-col-clear",
|
|
24712
|
+
onClick: (e3) => {
|
|
24713
|
+
e3.stopPropagation();
|
|
24714
|
+
handleClear();
|
|
24715
|
+
},
|
|
24716
|
+
title: "Temizle",
|
|
24717
|
+
children: /* @__PURE__ */ jsx(X, { size: 12 })
|
|
24718
|
+
}
|
|
24719
|
+
),
|
|
24720
|
+
/* @__PURE__ */ jsx(
|
|
24721
|
+
ChevronDown,
|
|
24722
|
+
{
|
|
24723
|
+
size: 14,
|
|
24724
|
+
className: `tecof-cms-col-chevron ${dropdownOpen ? "rotated" : ""}`
|
|
24725
|
+
}
|
|
24726
|
+
)
|
|
24727
|
+
] })
|
|
24728
|
+
]
|
|
24729
|
+
}
|
|
24730
|
+
),
|
|
24731
|
+
dropdownOpen && /* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-dropdown", children: [
|
|
24732
|
+
/* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-search", children: [
|
|
24733
|
+
/* @__PURE__ */ jsx(Search, { size: 13 }),
|
|
24734
|
+
/* @__PURE__ */ jsx(
|
|
24735
|
+
"input",
|
|
24736
|
+
{
|
|
24737
|
+
type: "text",
|
|
24738
|
+
value: searchQuery,
|
|
24739
|
+
onChange: (e3) => setSearchQuery(e3.target.value),
|
|
24740
|
+
placeholder: "Koleksiyon ara\u2026",
|
|
24741
|
+
className: "tecof-cms-col-search-input",
|
|
24742
|
+
autoFocus: true
|
|
24743
|
+
}
|
|
24744
|
+
)
|
|
24745
|
+
] }),
|
|
24746
|
+
/* @__PURE__ */ jsx("div", { className: "tecof-cms-col-options", children: filteredCollections.length === 0 ? /* @__PURE__ */ jsx("div", { className: "tecof-cms-col-empty", children: "Koleksiyon bulunamad\u0131" }) : filteredCollections.map((col) => /* @__PURE__ */ jsxs(
|
|
24747
|
+
"button",
|
|
24748
|
+
{
|
|
24749
|
+
type: "button",
|
|
24750
|
+
className: `tecof-cms-col-option ${value?.collectionSlug === col.slug ? "selected" : ""}`,
|
|
24751
|
+
onClick: () => handleSelect(col),
|
|
24752
|
+
children: [
|
|
24753
|
+
/* @__PURE__ */ jsx(Database, { size: 13 }),
|
|
24754
|
+
/* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-option-info", children: [
|
|
24755
|
+
/* @__PURE__ */ jsx("span", { className: "tecof-cms-col-option-name", children: col.name }),
|
|
24756
|
+
/* @__PURE__ */ jsx("span", { className: "tecof-cms-col-option-slug", children: col.slug })
|
|
24757
|
+
] })
|
|
24758
|
+
]
|
|
24759
|
+
},
|
|
24760
|
+
col._id
|
|
24761
|
+
)) })
|
|
24762
|
+
] })
|
|
24763
|
+
] }),
|
|
24764
|
+
value?.collectionSlug && /* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-settings", children: [
|
|
24765
|
+
showLimit && /* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-setting", children: [
|
|
24766
|
+
/* @__PURE__ */ jsx("label", { className: "tecof-cms-col-setting-label", children: "Limit" }),
|
|
24767
|
+
/* @__PURE__ */ jsx(
|
|
24768
|
+
"input",
|
|
24769
|
+
{
|
|
24770
|
+
type: "number",
|
|
24771
|
+
min: 1,
|
|
24772
|
+
max: 100,
|
|
24773
|
+
value: value.limit || defaultLimit,
|
|
24774
|
+
onChange: handleLimitChange,
|
|
24775
|
+
className: "tecof-cms-col-setting-input",
|
|
24776
|
+
disabled: readOnly
|
|
24777
|
+
}
|
|
24778
|
+
)
|
|
24779
|
+
] }),
|
|
24780
|
+
showSort && /* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-setting", children: [
|
|
24781
|
+
/* @__PURE__ */ jsx("label", { className: "tecof-cms-col-setting-label", children: "S\u0131ralama" }),
|
|
24782
|
+
/* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-sort-btns", children: [
|
|
24783
|
+
/* @__PURE__ */ jsx(
|
|
24784
|
+
"button",
|
|
24785
|
+
{
|
|
24786
|
+
type: "button",
|
|
24787
|
+
className: `tecof-cms-col-sort-btn ${(value.sort || "newest") === "newest" ? "active" : ""}`,
|
|
24788
|
+
onClick: () => handleSortChange("newest"),
|
|
24789
|
+
disabled: readOnly,
|
|
24790
|
+
children: "Yeni\u2192Eski"
|
|
24791
|
+
}
|
|
24792
|
+
),
|
|
24793
|
+
/* @__PURE__ */ jsx(
|
|
24794
|
+
"button",
|
|
24795
|
+
{
|
|
24796
|
+
type: "button",
|
|
24797
|
+
className: `tecof-cms-col-sort-btn ${value.sort === "oldest" ? "active" : ""}`,
|
|
24798
|
+
onClick: () => handleSortChange("oldest"),
|
|
24799
|
+
disabled: readOnly,
|
|
24800
|
+
children: "Eski\u2192Yeni"
|
|
24801
|
+
}
|
|
24802
|
+
)
|
|
24803
|
+
] })
|
|
24804
|
+
] })
|
|
24805
|
+
] }),
|
|
24806
|
+
value?.collectionSlug && hasSlots && /* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-mapping", children: [
|
|
24807
|
+
/* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-mapping-header", children: [
|
|
24808
|
+
/* @__PURE__ */ jsx(Link2, { size: 12 }),
|
|
24809
|
+
/* @__PURE__ */ jsx("span", { children: "Alan E\u015Fle\u015Ftirme" })
|
|
24810
|
+
] }),
|
|
24811
|
+
/* @__PURE__ */ jsx("div", { className: "tecof-cms-col-mapping-rows", children: Object.entries(slots).map(([slotKey, slotDef]) => {
|
|
24812
|
+
const currentMapping = value.fieldMap?.[slotKey] || "";
|
|
24813
|
+
const availableFields = slotDef.fieldTypes ? collectionFields.filter((f2) => slotDef.fieldTypes.includes(f2.type)) : collectionFields;
|
|
24814
|
+
return /* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-mapping-row", children: [
|
|
24815
|
+
/* @__PURE__ */ jsx("label", { className: "tecof-cms-col-mapping-label", children: slotDef.label }),
|
|
24816
|
+
/* @__PURE__ */ jsxs(
|
|
24817
|
+
"select",
|
|
24818
|
+
{
|
|
24819
|
+
className: "tecof-cms-col-mapping-select",
|
|
24820
|
+
value: currentMapping,
|
|
24821
|
+
onChange: (e3) => handleFieldMapChange(slotKey, e3.target.value),
|
|
24822
|
+
disabled: readOnly,
|
|
24823
|
+
children: [
|
|
24824
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "\u2014 Se\xE7in \u2014" }),
|
|
24825
|
+
availableFields.map((f2) => /* @__PURE__ */ jsxs("option", { value: f2.shortcode, children: [
|
|
24826
|
+
f2.name,
|
|
24827
|
+
" (",
|
|
24828
|
+
f2.shortcode,
|
|
24829
|
+
")"
|
|
24830
|
+
] }, f2.shortcode))
|
|
24831
|
+
]
|
|
24832
|
+
}
|
|
24833
|
+
)
|
|
24834
|
+
] }, slotKey);
|
|
24835
|
+
}) })
|
|
24836
|
+
] }),
|
|
24837
|
+
selectedCollection && /* @__PURE__ */ jsxs("div", { className: "tecof-cms-col-badge", children: [
|
|
24838
|
+
/* @__PURE__ */ jsx(Database, { size: 11 }),
|
|
24839
|
+
/* @__PURE__ */ jsx("span", { children: selectedCollection.name }),
|
|
24840
|
+
selectedCollection.fields && /* @__PURE__ */ jsxs("span", { className: "tecof-cms-col-badge-count", children: [
|
|
24841
|
+
selectedCollection.fields.length,
|
|
24842
|
+
" alan"
|
|
24843
|
+
] })
|
|
24844
|
+
] })
|
|
24845
|
+
] });
|
|
24846
|
+
};
|
|
24847
|
+
CmsCollectionField.displayName = "CmsCollectionField";
|
|
24848
|
+
var createCmsCollectionField = (options = {}) => {
|
|
24849
|
+
const { label, labelIcon, visible, ...fieldOptions } = options;
|
|
24850
|
+
return {
|
|
24851
|
+
type: "custom",
|
|
24852
|
+
_fieldType: "cmsCollection",
|
|
24853
|
+
label,
|
|
24854
|
+
labelIcon,
|
|
24855
|
+
visible,
|
|
24856
|
+
render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsx(FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsx(FieldErrorBoundary, { fieldName: name3, children: /* @__PURE__ */ jsx(
|
|
24857
|
+
CmsCollectionField,
|
|
24858
|
+
{
|
|
24859
|
+
field,
|
|
24860
|
+
name: name3,
|
|
24861
|
+
id,
|
|
24862
|
+
value: value || null,
|
|
24863
|
+
onChange,
|
|
24864
|
+
readOnly,
|
|
24865
|
+
...fieldOptions
|
|
24866
|
+
}
|
|
24867
|
+
) }) })
|
|
24868
|
+
};
|
|
24869
|
+
};
|
|
24511
24870
|
|
|
24512
24871
|
// src/utils/index.ts
|
|
24513
24872
|
function hexToHsl(hex) {
|
|
@@ -24671,6 +25030,7 @@ lucide-react/dist/esm/icons/chevron-down.js:
|
|
|
24671
25030
|
lucide-react/dist/esm/icons/chevron-right.js:
|
|
24672
25031
|
lucide-react/dist/esm/icons/code.js:
|
|
24673
25032
|
lucide-react/dist/esm/icons/copy.js:
|
|
25033
|
+
lucide-react/dist/esm/icons/database.js:
|
|
24674
25034
|
lucide-react/dist/esm/icons/external-link.js:
|
|
24675
25035
|
lucide-react/dist/esm/icons/file-text.js:
|
|
24676
25036
|
lucide-react/dist/esm/icons/file.js:
|
|
@@ -24680,11 +25040,13 @@ lucide-react/dist/esm/icons/grip-vertical.js:
|
|
|
24680
25040
|
lucide-react/dist/esm/icons/image-plus.js:
|
|
24681
25041
|
lucide-react/dist/esm/icons/image.js:
|
|
24682
25042
|
lucide-react/dist/esm/icons/languages.js:
|
|
25043
|
+
lucide-react/dist/esm/icons/link-2.js:
|
|
24683
25044
|
lucide-react/dist/esm/icons/link.js:
|
|
24684
25045
|
lucide-react/dist/esm/icons/loader-circle.js:
|
|
24685
25046
|
lucide-react/dist/esm/icons/pencil.js:
|
|
24686
25047
|
lucide-react/dist/esm/icons/plus.js:
|
|
24687
25048
|
lucide-react/dist/esm/icons/refresh-ccw.js:
|
|
25049
|
+
lucide-react/dist/esm/icons/refresh-cw.js:
|
|
24688
25050
|
lucide-react/dist/esm/icons/rotate-ccw.js:
|
|
24689
25051
|
lucide-react/dist/esm/icons/search.js:
|
|
24690
25052
|
lucide-react/dist/esm/icons/trash-2.js:
|
|
@@ -24773,6 +25135,6 @@ filepond-plugin-image-edit/dist/filepond-plugin-image-edit.esm.js:
|
|
|
24773
25135
|
*)
|
|
24774
25136
|
*/
|
|
24775
25137
|
|
|
24776
|
-
export { CodeEditorField, ColorField, EditorField, FieldErrorBoundary, LanguageField, LinkField, RepeaterField, TecofApiClient, TecofEditor, TecofPicture, TecofProvider, TecofRender, UploadField, createCodeEditorField, createColorField, createEditorField, createLanguageField, createLinkField, createRepeaterField, createUploadField, darken, generateCSSVariables, getDefaultTheme, hexToHsl, hslToHex, lighten, mergeTheme, useTecof };
|
|
25138
|
+
export { CmsCollectionField, CodeEditorField, ColorField, EditorField, FieldErrorBoundary, LanguageField, LinkField, RepeaterField, TecofApiClient, TecofEditor, TecofPicture, TecofProvider, TecofRender, UploadField, createCmsCollectionField, createCodeEditorField, createColorField, createEditorField, createLanguageField, createLinkField, createRepeaterField, createUploadField, darken, generateCSSVariables, getDefaultTheme, hexToHsl, hslToHex, lighten, mergeTheme, useTecof };
|
|
24777
25139
|
//# sourceMappingURL=index.mjs.map
|
|
24778
25140
|
//# sourceMappingURL=index.mjs.map
|