@tecof/theme-editor 0.0.28 → 0.0.29

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.js CHANGED
@@ -17,7 +17,7 @@ var Blockquote = require('@tiptap/extension-blockquote');
17
17
  var HardBreak = require('@tiptap/extension-hard-break');
18
18
  var HorizontalRule = require('@tiptap/extension-horizontal-rule');
19
19
  var TextAlign = require('@tiptap/extension-text-align');
20
- var Link2 = require('@tiptap/extension-link');
20
+ var Link3 = require('@tiptap/extension-link');
21
21
  var Code2 = require('@tiptap/extension-code');
22
22
  var CodeBlock = require('@tiptap/extension-code-block');
23
23
  var ReactDOM = require('react-dom');
@@ -55,7 +55,7 @@ var Blockquote__default = /*#__PURE__*/_interopDefault(Blockquote);
55
55
  var HardBreak__default = /*#__PURE__*/_interopDefault(HardBreak);
56
56
  var HorizontalRule__default = /*#__PURE__*/_interopDefault(HorizontalRule);
57
57
  var TextAlign__default = /*#__PURE__*/_interopDefault(TextAlign);
58
- var Link2__default = /*#__PURE__*/_interopDefault(Link2);
58
+ var Link3__default = /*#__PURE__*/_interopDefault(Link3);
59
59
  var Code2__default = /*#__PURE__*/_interopDefault(Code2);
60
60
  var CodeBlock__default = /*#__PURE__*/_interopDefault(CodeBlock);
61
61
  var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
@@ -259,6 +259,49 @@ var TecofApiClient = class {
259
259
  return null;
260
260
  }
261
261
  }
262
+ /**
263
+ * Fetch CMS collections list (for CmsCollectionField)
264
+ * Returns: [{ _id, name, slug, fields, ... }]
265
+ */
266
+ async getCmsCollections() {
267
+ try {
268
+ const res2 = await fetch(`${this.apiUrl}/api/store/cms/collections`, {
269
+ method: "POST",
270
+ headers: this.headers,
271
+ body: JSON.stringify({})
272
+ });
273
+ return await res2.json();
274
+ } catch (error2) {
275
+ return {
276
+ success: false,
277
+ message: error2 instanceof Error ? error2.message : "Failed to fetch collections"
278
+ };
279
+ }
280
+ }
281
+ /**
282
+ * Fetch items from a CMS collection by slug
283
+ * Returns: { items: [...], totalData: N }
284
+ */
285
+ async getCmsCollectionItems(collectionSlug, options) {
286
+ try {
287
+ const res2 = await fetch(`${this.apiUrl}/api/store/cms/collections/${encodeURIComponent(collectionSlug)}/items`, {
288
+ method: "POST",
289
+ headers: this.headers,
290
+ body: JSON.stringify({
291
+ page: options?.page || 1,
292
+ limit: options?.limit || 50,
293
+ sort: options?.sort || "newest",
294
+ locale: options?.locale
295
+ })
296
+ });
297
+ return await res2.json();
298
+ } catch (error2) {
299
+ return {
300
+ success: false,
301
+ message: error2 instanceof Error ? error2.message : "Failed to fetch collection items"
302
+ };
303
+ }
304
+ }
262
305
  /** CDN base URL (defaults to apiUrl if not set) */
263
306
  get cdnUrl() {
264
307
  return this.customCdnUrl || this.apiUrl;
@@ -794,16 +837,24 @@ var __iconNode5 = [
794
837
  ];
795
838
  var Copy = createLucideIcon("copy", __iconNode5);
796
839
 
797
- // node_modules/lucide-react/dist/esm/icons/external-link.js
840
+ // node_modules/lucide-react/dist/esm/icons/database.js
798
841
  var __iconNode6 = [
842
+ ["ellipse", { cx: "12", cy: "5", rx: "9", ry: "3", key: "msslwz" }],
843
+ ["path", { d: "M3 5V19A9 3 0 0 0 21 19V5", key: "1wlel7" }],
844
+ ["path", { d: "M3 12A9 3 0 0 0 21 12", key: "mv7ke4" }]
845
+ ];
846
+ var Database = createLucideIcon("database", __iconNode6);
847
+
848
+ // node_modules/lucide-react/dist/esm/icons/external-link.js
849
+ var __iconNode7 = [
799
850
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
800
851
  ["path", { d: "M10 14 21 3", key: "gplh6r" }],
801
852
  ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
802
853
  ];
803
- var ExternalLink = createLucideIcon("external-link", __iconNode6);
854
+ var ExternalLink = createLucideIcon("external-link", __iconNode7);
804
855
 
805
856
  // node_modules/lucide-react/dist/esm/icons/file-text.js
806
- var __iconNode7 = [
857
+ var __iconNode8 = [
807
858
  [
808
859
  "path",
809
860
  {
@@ -816,10 +867,10 @@ var __iconNode7 = [
816
867
  ["path", { d: "M16 13H8", key: "t4e002" }],
817
868
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
818
869
  ];
819
- var FileText = createLucideIcon("file-text", __iconNode7);
870
+ var FileText = createLucideIcon("file-text", __iconNode8);
820
871
 
821
872
  // node_modules/lucide-react/dist/esm/icons/file.js
822
- var __iconNode8 = [
873
+ var __iconNode9 = [
823
874
  [
824
875
  "path",
825
876
  {
@@ -829,10 +880,10 @@ var __iconNode8 = [
829
880
  ],
830
881
  ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
831
882
  ];
832
- var File2 = createLucideIcon("file", __iconNode8);
883
+ var File2 = createLucideIcon("file", __iconNode9);
833
884
 
834
885
  // node_modules/lucide-react/dist/esm/icons/folder-open.js
835
- var __iconNode9 = [
886
+ var __iconNode10 = [
836
887
  [
837
888
  "path",
838
889
  {
@@ -841,18 +892,18 @@ var __iconNode9 = [
841
892
  }
842
893
  ]
843
894
  ];
844
- var FolderOpen = createLucideIcon("folder-open", __iconNode9);
895
+ var FolderOpen = createLucideIcon("folder-open", __iconNode10);
845
896
 
846
897
  // node_modules/lucide-react/dist/esm/icons/globe.js
847
- var __iconNode10 = [
898
+ var __iconNode11 = [
848
899
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
849
900
  ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
850
901
  ["path", { d: "M2 12h20", key: "9i4pu4" }]
851
902
  ];
852
- var Globe = createLucideIcon("globe", __iconNode10);
903
+ var Globe = createLucideIcon("globe", __iconNode11);
853
904
 
854
905
  // node_modules/lucide-react/dist/esm/icons/grip-vertical.js
855
- var __iconNode11 = [
906
+ var __iconNode12 = [
856
907
  ["circle", { cx: "9", cy: "12", r: "1", key: "1vctgf" }],
857
908
  ["circle", { cx: "9", cy: "5", r: "1", key: "hp0tcf" }],
858
909
  ["circle", { cx: "9", cy: "19", r: "1", key: "fkjjf6" }],
@@ -860,28 +911,28 @@ var __iconNode11 = [
860
911
  ["circle", { cx: "15", cy: "5", r: "1", key: "19l28e" }],
861
912
  ["circle", { cx: "15", cy: "19", r: "1", key: "f4zoj3" }]
862
913
  ];
863
- var GripVertical = createLucideIcon("grip-vertical", __iconNode11);
914
+ var GripVertical = createLucideIcon("grip-vertical", __iconNode12);
864
915
 
865
916
  // node_modules/lucide-react/dist/esm/icons/image-plus.js
866
- var __iconNode12 = [
917
+ var __iconNode13 = [
867
918
  ["path", { d: "M16 5h6", key: "1vod17" }],
868
919
  ["path", { d: "M19 2v6", key: "4bpg5p" }],
869
920
  ["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" }],
870
921
  ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }],
871
922
  ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }]
872
923
  ];
873
- var ImagePlus = createLucideIcon("image-plus", __iconNode12);
924
+ var ImagePlus = createLucideIcon("image-plus", __iconNode13);
874
925
 
875
926
  // node_modules/lucide-react/dist/esm/icons/image.js
876
- var __iconNode13 = [
927
+ var __iconNode14 = [
877
928
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
878
929
  ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
879
930
  ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
880
931
  ];
881
- var Image2 = createLucideIcon("image", __iconNode13);
932
+ var Image2 = createLucideIcon("image", __iconNode14);
882
933
 
883
934
  // node_modules/lucide-react/dist/esm/icons/languages.js
884
- var __iconNode14 = [
935
+ var __iconNode15 = [
885
936
  ["path", { d: "m5 8 6 6", key: "1wu5hv" }],
886
937
  ["path", { d: "m4 14 6-6 2-3", key: "1k1g8d" }],
887
938
  ["path", { d: "M2 5h12", key: "or177f" }],
@@ -889,21 +940,29 @@ var __iconNode14 = [
889
940
  ["path", { d: "m22 22-5-10-5 10", key: "don7ne" }],
890
941
  ["path", { d: "M14 18h6", key: "1m8k6r" }]
891
942
  ];
892
- var Languages = createLucideIcon("languages", __iconNode14);
943
+ var Languages = createLucideIcon("languages", __iconNode15);
944
+
945
+ // node_modules/lucide-react/dist/esm/icons/link-2.js
946
+ var __iconNode16 = [
947
+ ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
948
+ ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
949
+ ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
950
+ ];
951
+ var Link2 = createLucideIcon("link-2", __iconNode16);
893
952
 
894
953
  // node_modules/lucide-react/dist/esm/icons/link.js
895
- var __iconNode15 = [
954
+ var __iconNode17 = [
896
955
  ["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" }],
897
956
  ["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" }]
898
957
  ];
899
- var Link = createLucideIcon("link", __iconNode15);
958
+ var Link = createLucideIcon("link", __iconNode17);
900
959
 
901
960
  // node_modules/lucide-react/dist/esm/icons/loader-circle.js
902
- var __iconNode16 = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
903
- var LoaderCircle = createLucideIcon("loader-circle", __iconNode16);
961
+ var __iconNode18 = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
962
+ var LoaderCircle = createLucideIcon("loader-circle", __iconNode18);
904
963
 
905
964
  // node_modules/lucide-react/dist/esm/icons/pencil.js
906
- var __iconNode17 = [
965
+ var __iconNode19 = [
907
966
  [
908
967
  "path",
909
968
  {
@@ -913,62 +972,71 @@ var __iconNode17 = [
913
972
  ],
914
973
  ["path", { d: "m15 5 4 4", key: "1mk7zo" }]
915
974
  ];
916
- var Pencil = createLucideIcon("pencil", __iconNode17);
975
+ var Pencil = createLucideIcon("pencil", __iconNode19);
917
976
 
918
977
  // node_modules/lucide-react/dist/esm/icons/plus.js
919
- var __iconNode18 = [
978
+ var __iconNode20 = [
920
979
  ["path", { d: "M5 12h14", key: "1ays0h" }],
921
980
  ["path", { d: "M12 5v14", key: "s699le" }]
922
981
  ];
923
- var Plus = createLucideIcon("plus", __iconNode18);
982
+ var Plus = createLucideIcon("plus", __iconNode20);
924
983
 
925
984
  // node_modules/lucide-react/dist/esm/icons/refresh-ccw.js
926
- var __iconNode19 = [
985
+ var __iconNode21 = [
927
986
  ["path", { d: "M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "14sxne" }],
928
987
  ["path", { d: "M3 3v5h5", key: "1xhq8a" }],
929
988
  ["path", { d: "M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16", key: "1hlbsb" }],
930
989
  ["path", { d: "M16 16h5v5", key: "ccwih5" }]
931
990
  ];
932
- var RefreshCcw = createLucideIcon("refresh-ccw", __iconNode19);
991
+ var RefreshCcw = createLucideIcon("refresh-ccw", __iconNode21);
992
+
993
+ // node_modules/lucide-react/dist/esm/icons/refresh-cw.js
994
+ var __iconNode22 = [
995
+ ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
996
+ ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
997
+ ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
998
+ ["path", { d: "M8 16H3v5", key: "1cv678" }]
999
+ ];
1000
+ var RefreshCw = createLucideIcon("refresh-cw", __iconNode22);
933
1001
 
934
1002
  // node_modules/lucide-react/dist/esm/icons/rotate-ccw.js
935
- var __iconNode20 = [
1003
+ var __iconNode23 = [
936
1004
  ["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
937
1005
  ["path", { d: "M3 3v5h5", key: "1xhq8a" }]
938
1006
  ];
939
- var RotateCcw = createLucideIcon("rotate-ccw", __iconNode20);
1007
+ var RotateCcw = createLucideIcon("rotate-ccw", __iconNode23);
940
1008
 
941
1009
  // node_modules/lucide-react/dist/esm/icons/search.js
942
- var __iconNode21 = [
1010
+ var __iconNode24 = [
943
1011
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
944
1012
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
945
1013
  ];
946
- var Search = createLucideIcon("search", __iconNode21);
1014
+ var Search = createLucideIcon("search", __iconNode24);
947
1015
 
948
1016
  // node_modules/lucide-react/dist/esm/icons/trash-2.js
949
- var __iconNode22 = [
1017
+ var __iconNode25 = [
950
1018
  ["path", { d: "M10 11v6", key: "nco0om" }],
951
1019
  ["path", { d: "M14 11v6", key: "outv1u" }],
952
1020
  ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
953
1021
  ["path", { d: "M3 6h18", key: "d0wm0j" }],
954
1022
  ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
955
1023
  ];
956
- var Trash2 = createLucideIcon("trash-2", __iconNode22);
1024
+ var Trash2 = createLucideIcon("trash-2", __iconNode25);
957
1025
 
958
1026
  // node_modules/lucide-react/dist/esm/icons/upload.js
959
- var __iconNode23 = [
1027
+ var __iconNode26 = [
960
1028
  ["path", { d: "M12 3v12", key: "1x0j5s" }],
961
1029
  ["path", { d: "m17 8-5-5-5 5", key: "7q97r8" }],
962
1030
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
963
1031
  ];
964
- var Upload = createLucideIcon("upload", __iconNode23);
1032
+ var Upload = createLucideIcon("upload", __iconNode26);
965
1033
 
966
1034
  // node_modules/lucide-react/dist/esm/icons/x.js
967
- var __iconNode24 = [
1035
+ var __iconNode27 = [
968
1036
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
969
1037
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
970
1038
  ];
971
- var X = createLucideIcon("x", __iconNode24);
1039
+ var X = createLucideIcon("x", __iconNode27);
972
1040
  var FieldErrorBoundary = class extends React__default.Component {
973
1041
  constructor(props) {
974
1042
  super(props);
@@ -1303,7 +1371,7 @@ var createExtensions = () => [
1303
1371
  Code2__default.default,
1304
1372
  CodeBlock__default.default,
1305
1373
  TextAlign__default.default.configure({ types: ["heading", "paragraph"] }),
1306
- Link2__default.default.configure({ openOnClick: false, HTMLAttributes: { target: "_blank" } })
1374
+ Link3__default.default.configure({ openOnClick: false, HTMLAttributes: { target: "_blank" } })
1307
1375
  ];
1308
1376
  var ToolbarBtn = ({
1309
1377
  onClick,
@@ -24546,6 +24614,297 @@ var createRepeaterField = (options) => {
24546
24614
  ) }) })
24547
24615
  };
24548
24616
  };
24617
+ var CmsCollectionField = ({
24618
+ value,
24619
+ onChange,
24620
+ readOnly,
24621
+ defaultLimit = 10,
24622
+ showLimit = true,
24623
+ showSort = true,
24624
+ slots
24625
+ }) => {
24626
+ const { apiClient } = useTecof();
24627
+ const [collections, setCollections] = React__default.useState([]);
24628
+ const [loading, setLoading] = React__default.useState(true);
24629
+ const [error2, setError] = React__default.useState(null);
24630
+ const [dropdownOpen, setDropdownOpen] = React__default.useState(false);
24631
+ const [searchQuery, setSearchQuery] = React__default.useState("");
24632
+ const dropdownRef = React__default.useRef(null);
24633
+ const onChangeRef = React__default.useRef(onChange);
24634
+ onChangeRef.current = onChange;
24635
+ const fetchCollections = React__default.useCallback(async () => {
24636
+ setLoading(true);
24637
+ setError(null);
24638
+ try {
24639
+ const res2 = await apiClient.getCmsCollections();
24640
+ if (res2.success && Array.isArray(res2.data)) {
24641
+ setCollections(res2.data);
24642
+ } else {
24643
+ setError(res2.message || "Koleksiyonlar y\xFCklenemedi");
24644
+ }
24645
+ } catch (err) {
24646
+ setError(err.message || "Ba\u011Flant\u0131 hatas\u0131");
24647
+ } finally {
24648
+ setLoading(false);
24649
+ }
24650
+ }, [apiClient]);
24651
+ React__default.useEffect(() => {
24652
+ fetchCollections();
24653
+ }, [fetchCollections]);
24654
+ React__default.useEffect(() => {
24655
+ if (!dropdownOpen) return;
24656
+ const handleClick = (e3) => {
24657
+ if (dropdownRef.current && !dropdownRef.current.contains(e3.target)) {
24658
+ setDropdownOpen(false);
24659
+ }
24660
+ };
24661
+ document.addEventListener("mousedown", handleClick);
24662
+ return () => document.removeEventListener("mousedown", handleClick);
24663
+ }, [dropdownOpen]);
24664
+ const selectedCollection = React__default.useMemo(() => {
24665
+ if (!value?.collectionSlug) return null;
24666
+ return collections.find((c2) => c2.slug === value.collectionSlug) || null;
24667
+ }, [value?.collectionSlug, collections]);
24668
+ const collectionFields = React__default.useMemo(() => {
24669
+ return selectedCollection?.fields || [];
24670
+ }, [selectedCollection]);
24671
+ const handleSelect = React__default.useCallback((col) => {
24672
+ onChangeRef.current({
24673
+ collectionSlug: col.slug,
24674
+ collectionName: col.name,
24675
+ limit: value?.limit || defaultLimit,
24676
+ sort: value?.sort || "newest",
24677
+ fieldMap: value?.fieldMap || {}
24678
+ });
24679
+ setDropdownOpen(false);
24680
+ setSearchQuery("");
24681
+ }, [value, defaultLimit]);
24682
+ const handleClear = React__default.useCallback(() => {
24683
+ onChangeRef.current(null);
24684
+ }, []);
24685
+ const handleLimitChange = React__default.useCallback((e3) => {
24686
+ const num = parseInt(e3.target.value, 10);
24687
+ if (!value) return;
24688
+ onChangeRef.current({
24689
+ ...value,
24690
+ limit: isNaN(num) ? defaultLimit : Math.max(1, Math.min(100, num))
24691
+ });
24692
+ }, [value, defaultLimit]);
24693
+ const handleSortChange = React__default.useCallback((sort) => {
24694
+ if (!value) return;
24695
+ onChangeRef.current({ ...value, sort });
24696
+ }, [value]);
24697
+ const handleFieldMapChange = React__default.useCallback((slotKey, fieldShortcode) => {
24698
+ if (!value) return;
24699
+ onChangeRef.current({
24700
+ ...value,
24701
+ fieldMap: {
24702
+ ...value.fieldMap,
24703
+ [slotKey]: fieldShortcode
24704
+ }
24705
+ });
24706
+ }, [value]);
24707
+ const filteredCollections = React__default.useMemo(() => {
24708
+ if (!searchQuery.trim()) return collections;
24709
+ const q = searchQuery.toLowerCase();
24710
+ return collections.filter(
24711
+ (c2) => c2.name.toLowerCase().includes(q) || c2.slug.toLowerCase().includes(q)
24712
+ );
24713
+ }, [collections, searchQuery]);
24714
+ if (loading) {
24715
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-loading", children: [
24716
+ /* @__PURE__ */ jsxRuntime.jsx(LoaderCircle, { size: 16, className: "tecof-spin" }),
24717
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Koleksiyonlar y\xFCkleniyor\u2026" })
24718
+ ] });
24719
+ }
24720
+ if (error2) {
24721
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-error", children: [
24722
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: error2 }),
24723
+ /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", className: "tecof-cms-col-retry", onClick: fetchCollections, children: [
24724
+ /* @__PURE__ */ jsxRuntime.jsx(RefreshCw, { size: 12 }),
24725
+ " Tekrar Dene"
24726
+ ] })
24727
+ ] });
24728
+ }
24729
+ const hasSlots = slots && Object.keys(slots).length > 0;
24730
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-container", children: [
24731
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-selector", ref: dropdownRef, children: [
24732
+ /* @__PURE__ */ jsxRuntime.jsxs(
24733
+ "button",
24734
+ {
24735
+ type: "button",
24736
+ className: `tecof-cms-col-trigger ${dropdownOpen ? "open" : ""}`,
24737
+ onClick: () => !readOnly && setDropdownOpen(!dropdownOpen),
24738
+ disabled: readOnly,
24739
+ children: [
24740
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-trigger-left", children: [
24741
+ /* @__PURE__ */ jsxRuntime.jsx(Database, { size: 14 }),
24742
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: value?.collectionName || value?.collectionSlug || "Koleksiyon Se\xE7in" })
24743
+ ] }),
24744
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-trigger-right", children: [
24745
+ value && !readOnly && /* @__PURE__ */ jsxRuntime.jsx(
24746
+ "button",
24747
+ {
24748
+ type: "button",
24749
+ className: "tecof-cms-col-clear",
24750
+ onClick: (e3) => {
24751
+ e3.stopPropagation();
24752
+ handleClear();
24753
+ },
24754
+ title: "Temizle",
24755
+ children: /* @__PURE__ */ jsxRuntime.jsx(X, { size: 12 })
24756
+ }
24757
+ ),
24758
+ /* @__PURE__ */ jsxRuntime.jsx(
24759
+ ChevronDown,
24760
+ {
24761
+ size: 14,
24762
+ className: `tecof-cms-col-chevron ${dropdownOpen ? "rotated" : ""}`
24763
+ }
24764
+ )
24765
+ ] })
24766
+ ]
24767
+ }
24768
+ ),
24769
+ dropdownOpen && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-dropdown", children: [
24770
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-search", children: [
24771
+ /* @__PURE__ */ jsxRuntime.jsx(Search, { size: 13 }),
24772
+ /* @__PURE__ */ jsxRuntime.jsx(
24773
+ "input",
24774
+ {
24775
+ type: "text",
24776
+ value: searchQuery,
24777
+ onChange: (e3) => setSearchQuery(e3.target.value),
24778
+ placeholder: "Koleksiyon ara\u2026",
24779
+ className: "tecof-cms-col-search-input",
24780
+ autoFocus: true
24781
+ }
24782
+ )
24783
+ ] }),
24784
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-cms-col-options", children: filteredCollections.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-cms-col-empty", children: "Koleksiyon bulunamad\u0131" }) : filteredCollections.map((col) => /* @__PURE__ */ jsxRuntime.jsxs(
24785
+ "button",
24786
+ {
24787
+ type: "button",
24788
+ className: `tecof-cms-col-option ${value?.collectionSlug === col.slug ? "selected" : ""}`,
24789
+ onClick: () => handleSelect(col),
24790
+ children: [
24791
+ /* @__PURE__ */ jsxRuntime.jsx(Database, { size: 13 }),
24792
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-option-info", children: [
24793
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tecof-cms-col-option-name", children: col.name }),
24794
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tecof-cms-col-option-slug", children: col.slug })
24795
+ ] })
24796
+ ]
24797
+ },
24798
+ col._id
24799
+ )) })
24800
+ ] })
24801
+ ] }),
24802
+ value?.collectionSlug && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-settings", children: [
24803
+ showLimit && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-setting", children: [
24804
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "tecof-cms-col-setting-label", children: "Limit" }),
24805
+ /* @__PURE__ */ jsxRuntime.jsx(
24806
+ "input",
24807
+ {
24808
+ type: "number",
24809
+ min: 1,
24810
+ max: 100,
24811
+ value: value.limit || defaultLimit,
24812
+ onChange: handleLimitChange,
24813
+ className: "tecof-cms-col-setting-input",
24814
+ disabled: readOnly
24815
+ }
24816
+ )
24817
+ ] }),
24818
+ showSort && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-setting", children: [
24819
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "tecof-cms-col-setting-label", children: "S\u0131ralama" }),
24820
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-sort-btns", children: [
24821
+ /* @__PURE__ */ jsxRuntime.jsx(
24822
+ "button",
24823
+ {
24824
+ type: "button",
24825
+ className: `tecof-cms-col-sort-btn ${(value.sort || "newest") === "newest" ? "active" : ""}`,
24826
+ onClick: () => handleSortChange("newest"),
24827
+ disabled: readOnly,
24828
+ children: "Yeni\u2192Eski"
24829
+ }
24830
+ ),
24831
+ /* @__PURE__ */ jsxRuntime.jsx(
24832
+ "button",
24833
+ {
24834
+ type: "button",
24835
+ className: `tecof-cms-col-sort-btn ${value.sort === "oldest" ? "active" : ""}`,
24836
+ onClick: () => handleSortChange("oldest"),
24837
+ disabled: readOnly,
24838
+ children: "Eski\u2192Yeni"
24839
+ }
24840
+ )
24841
+ ] })
24842
+ ] })
24843
+ ] }),
24844
+ value?.collectionSlug && hasSlots && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-mapping", children: [
24845
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-mapping-header", children: [
24846
+ /* @__PURE__ */ jsxRuntime.jsx(Link2, { size: 12 }),
24847
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Alan E\u015Fle\u015Ftirme" })
24848
+ ] }),
24849
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-cms-col-mapping-rows", children: Object.entries(slots).map(([slotKey, slotDef]) => {
24850
+ const currentMapping = value.fieldMap?.[slotKey] || "";
24851
+ const availableFields = slotDef.fieldTypes ? collectionFields.filter((f2) => slotDef.fieldTypes.includes(f2.type)) : collectionFields;
24852
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-mapping-row", children: [
24853
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "tecof-cms-col-mapping-label", children: slotDef.label }),
24854
+ /* @__PURE__ */ jsxRuntime.jsxs(
24855
+ "select",
24856
+ {
24857
+ className: "tecof-cms-col-mapping-select",
24858
+ value: currentMapping,
24859
+ onChange: (e3) => handleFieldMapChange(slotKey, e3.target.value),
24860
+ disabled: readOnly,
24861
+ children: [
24862
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "", children: "\u2014 Se\xE7in \u2014" }),
24863
+ availableFields.map((f2) => /* @__PURE__ */ jsxRuntime.jsxs("option", { value: f2.shortcode, children: [
24864
+ f2.name,
24865
+ " (",
24866
+ f2.shortcode,
24867
+ ")"
24868
+ ] }, f2.shortcode))
24869
+ ]
24870
+ }
24871
+ )
24872
+ ] }, slotKey);
24873
+ }) })
24874
+ ] }),
24875
+ selectedCollection && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-cms-col-badge", children: [
24876
+ /* @__PURE__ */ jsxRuntime.jsx(Database, { size: 11 }),
24877
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: selectedCollection.name }),
24878
+ selectedCollection.fields && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "tecof-cms-col-badge-count", children: [
24879
+ selectedCollection.fields.length,
24880
+ " alan"
24881
+ ] })
24882
+ ] })
24883
+ ] });
24884
+ };
24885
+ CmsCollectionField.displayName = "CmsCollectionField";
24886
+ var createCmsCollectionField = (options = {}) => {
24887
+ const { label, labelIcon, visible, ...fieldOptions } = options;
24888
+ return {
24889
+ type: "custom",
24890
+ _fieldType: "cmsCollection",
24891
+ label,
24892
+ labelIcon,
24893
+ visible,
24894
+ render: ({ value, onChange, readOnly, field, name: name3, id }) => /* @__PURE__ */ jsxRuntime.jsx(core.FieldLabel, { label: label || "", icon: labelIcon, readOnly, children: /* @__PURE__ */ jsxRuntime.jsx(FieldErrorBoundary, { fieldName: name3, children: /* @__PURE__ */ jsxRuntime.jsx(
24895
+ CmsCollectionField,
24896
+ {
24897
+ field,
24898
+ name: name3,
24899
+ id,
24900
+ value: value || null,
24901
+ onChange,
24902
+ readOnly,
24903
+ ...fieldOptions
24904
+ }
24905
+ ) }) })
24906
+ };
24907
+ };
24549
24908
 
24550
24909
  // src/utils/index.ts
24551
24910
  function hexToHsl(hex) {
@@ -24709,6 +25068,7 @@ lucide-react/dist/esm/icons/chevron-down.js:
24709
25068
  lucide-react/dist/esm/icons/chevron-right.js:
24710
25069
  lucide-react/dist/esm/icons/code.js:
24711
25070
  lucide-react/dist/esm/icons/copy.js:
25071
+ lucide-react/dist/esm/icons/database.js:
24712
25072
  lucide-react/dist/esm/icons/external-link.js:
24713
25073
  lucide-react/dist/esm/icons/file-text.js:
24714
25074
  lucide-react/dist/esm/icons/file.js:
@@ -24718,11 +25078,13 @@ lucide-react/dist/esm/icons/grip-vertical.js:
24718
25078
  lucide-react/dist/esm/icons/image-plus.js:
24719
25079
  lucide-react/dist/esm/icons/image.js:
24720
25080
  lucide-react/dist/esm/icons/languages.js:
25081
+ lucide-react/dist/esm/icons/link-2.js:
24721
25082
  lucide-react/dist/esm/icons/link.js:
24722
25083
  lucide-react/dist/esm/icons/loader-circle.js:
24723
25084
  lucide-react/dist/esm/icons/pencil.js:
24724
25085
  lucide-react/dist/esm/icons/plus.js:
24725
25086
  lucide-react/dist/esm/icons/refresh-ccw.js:
25087
+ lucide-react/dist/esm/icons/refresh-cw.js:
24726
25088
  lucide-react/dist/esm/icons/rotate-ccw.js:
24727
25089
  lucide-react/dist/esm/icons/search.js:
24728
25090
  lucide-react/dist/esm/icons/trash-2.js:
@@ -24811,6 +25173,7 @@ filepond-plugin-image-edit/dist/filepond-plugin-image-edit.esm.js:
24811
25173
  *)
24812
25174
  */
24813
25175
 
25176
+ exports.CmsCollectionField = CmsCollectionField;
24814
25177
  exports.CodeEditorField = CodeEditorField;
24815
25178
  exports.ColorField = ColorField;
24816
25179
  exports.EditorField = EditorField;
@@ -24824,6 +25187,7 @@ exports.TecofPicture = TecofPicture;
24824
25187
  exports.TecofProvider = TecofProvider;
24825
25188
  exports.TecofRender = TecofRender;
24826
25189
  exports.UploadField = UploadField;
25190
+ exports.createCmsCollectionField = createCmsCollectionField;
24827
25191
  exports.createCodeEditorField = createCodeEditorField;
24828
25192
  exports.createColorField = createColorField;
24829
25193
  exports.createEditorField = createEditorField;