@tecof/theme-editor 0.0.26 → 0.0.28

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
@@ -469,7 +469,9 @@ var TecofEditor = ({
469
469
  ] }) });
470
470
  }
471
471
  const plugins = [
472
- ...core.fieldsPlugin ? [core.fieldsPlugin({ desktopSideBar: "left" })] : [],
472
+ { ...core.blocksPlugin(), label: "Bloklar" },
473
+ { ...core.outlinePlugin(), label: "Anahat" },
474
+ { ...core.fieldsPlugin({ desktopSideBar: "right" }), label: "Alanlar" },
473
475
  ...extraPlugins || []
474
476
  ];
475
477
  const mergedOverrides = {
@@ -488,15 +490,23 @@ var TecofEditor = ({
488
490
  data: initialData,
489
491
  onPublish: handlePuckPublish,
490
492
  onChange: handleChange,
491
- overrides: mergedOverrides
493
+ overrides: mergedOverrides,
494
+ metadata: { editMode: true }
492
495
  }
493
496
  ),
494
497
  saving && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-editor-save-indicator", children: saveStatus === "error" ? "Save failed" : "Saving..." })
495
498
  ] });
496
499
  };
497
- var TecofRender = ({ data: data3, config: config3, className }) => {
500
+ var TecofRender = ({ data: data3, config: config3, className, cmsData }) => {
498
501
  if (!data3) return null;
499
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx(core.Render, { config: config3, data: data3 }) });
502
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className, children: /* @__PURE__ */ jsxRuntime.jsx(
503
+ core.Render,
504
+ {
505
+ config: config3,
506
+ data: data3,
507
+ metadata: { cmsData: cmsData || null }
508
+ }
509
+ ) });
500
510
  };
501
511
  var IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "webp", "gif", "svg", "avif", "bmp", "tiff", "heic"];
502
512
  var VIDEO_EXTENSIONS = ["mp4", "webm", "ogg", "avi", "mov", "quicktime"];
@@ -762,34 +772,38 @@ var createLucideIcon = (iconName, iconNode) => {
762
772
  var __iconNode = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
763
773
  var Check = createLucideIcon("check", __iconNode);
764
774
 
775
+ // node_modules/lucide-react/dist/esm/icons/chevron-down.js
776
+ var __iconNode2 = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
777
+ var ChevronDown = createLucideIcon("chevron-down", __iconNode2);
778
+
765
779
  // node_modules/lucide-react/dist/esm/icons/chevron-right.js
766
- var __iconNode2 = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
767
- var ChevronRight = createLucideIcon("chevron-right", __iconNode2);
780
+ var __iconNode3 = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
781
+ var ChevronRight = createLucideIcon("chevron-right", __iconNode3);
768
782
 
769
783
  // node_modules/lucide-react/dist/esm/icons/code.js
770
- var __iconNode3 = [
784
+ var __iconNode4 = [
771
785
  ["path", { d: "m16 18 6-6-6-6", key: "eg8j8" }],
772
786
  ["path", { d: "m8 6-6 6 6 6", key: "ppft3o" }]
773
787
  ];
774
- var Code = createLucideIcon("code", __iconNode3);
788
+ var Code = createLucideIcon("code", __iconNode4);
775
789
 
776
790
  // node_modules/lucide-react/dist/esm/icons/copy.js
777
- var __iconNode4 = [
791
+ var __iconNode5 = [
778
792
  ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
779
793
  ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
780
794
  ];
781
- var Copy = createLucideIcon("copy", __iconNode4);
795
+ var Copy = createLucideIcon("copy", __iconNode5);
782
796
 
783
797
  // node_modules/lucide-react/dist/esm/icons/external-link.js
784
- var __iconNode5 = [
798
+ var __iconNode6 = [
785
799
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
786
800
  ["path", { d: "M10 14 21 3", key: "gplh6r" }],
787
801
  ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
788
802
  ];
789
- var ExternalLink = createLucideIcon("external-link", __iconNode5);
803
+ var ExternalLink = createLucideIcon("external-link", __iconNode6);
790
804
 
791
805
  // node_modules/lucide-react/dist/esm/icons/file-text.js
792
- var __iconNode6 = [
806
+ var __iconNode7 = [
793
807
  [
794
808
  "path",
795
809
  {
@@ -802,10 +816,10 @@ var __iconNode6 = [
802
816
  ["path", { d: "M16 13H8", key: "t4e002" }],
803
817
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
804
818
  ];
805
- var FileText = createLucideIcon("file-text", __iconNode6);
819
+ var FileText = createLucideIcon("file-text", __iconNode7);
806
820
 
807
821
  // node_modules/lucide-react/dist/esm/icons/file.js
808
- var __iconNode7 = [
822
+ var __iconNode8 = [
809
823
  [
810
824
  "path",
811
825
  {
@@ -815,10 +829,10 @@ var __iconNode7 = [
815
829
  ],
816
830
  ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
817
831
  ];
818
- var File2 = createLucideIcon("file", __iconNode7);
832
+ var File2 = createLucideIcon("file", __iconNode8);
819
833
 
820
834
  // node_modules/lucide-react/dist/esm/icons/folder-open.js
821
- var __iconNode8 = [
835
+ var __iconNode9 = [
822
836
  [
823
837
  "path",
824
838
  {
@@ -827,36 +841,47 @@ var __iconNode8 = [
827
841
  }
828
842
  ]
829
843
  ];
830
- var FolderOpen = createLucideIcon("folder-open", __iconNode8);
844
+ var FolderOpen = createLucideIcon("folder-open", __iconNode9);
831
845
 
832
846
  // node_modules/lucide-react/dist/esm/icons/globe.js
833
- var __iconNode9 = [
847
+ var __iconNode10 = [
834
848
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
835
849
  ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
836
850
  ["path", { d: "M2 12h20", key: "9i4pu4" }]
837
851
  ];
838
- var Globe = createLucideIcon("globe", __iconNode9);
852
+ var Globe = createLucideIcon("globe", __iconNode10);
853
+
854
+ // node_modules/lucide-react/dist/esm/icons/grip-vertical.js
855
+ var __iconNode11 = [
856
+ ["circle", { cx: "9", cy: "12", r: "1", key: "1vctgf" }],
857
+ ["circle", { cx: "9", cy: "5", r: "1", key: "hp0tcf" }],
858
+ ["circle", { cx: "9", cy: "19", r: "1", key: "fkjjf6" }],
859
+ ["circle", { cx: "15", cy: "12", r: "1", key: "1tmaij" }],
860
+ ["circle", { cx: "15", cy: "5", r: "1", key: "19l28e" }],
861
+ ["circle", { cx: "15", cy: "19", r: "1", key: "f4zoj3" }]
862
+ ];
863
+ var GripVertical = createLucideIcon("grip-vertical", __iconNode11);
839
864
 
840
865
  // node_modules/lucide-react/dist/esm/icons/image-plus.js
841
- var __iconNode10 = [
866
+ var __iconNode12 = [
842
867
  ["path", { d: "M16 5h6", key: "1vod17" }],
843
868
  ["path", { d: "M19 2v6", key: "4bpg5p" }],
844
869
  ["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" }],
845
870
  ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }],
846
871
  ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }]
847
872
  ];
848
- var ImagePlus = createLucideIcon("image-plus", __iconNode10);
873
+ var ImagePlus = createLucideIcon("image-plus", __iconNode12);
849
874
 
850
875
  // node_modules/lucide-react/dist/esm/icons/image.js
851
- var __iconNode11 = [
876
+ var __iconNode13 = [
852
877
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
853
878
  ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
854
879
  ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
855
880
  ];
856
- var Image2 = createLucideIcon("image", __iconNode11);
881
+ var Image2 = createLucideIcon("image", __iconNode13);
857
882
 
858
883
  // node_modules/lucide-react/dist/esm/icons/languages.js
859
- var __iconNode12 = [
884
+ var __iconNode14 = [
860
885
  ["path", { d: "m5 8 6 6", key: "1wu5hv" }],
861
886
  ["path", { d: "m4 14 6-6 2-3", key: "1k1g8d" }],
862
887
  ["path", { d: "M2 5h12", key: "or177f" }],
@@ -864,21 +889,21 @@ var __iconNode12 = [
864
889
  ["path", { d: "m22 22-5-10-5 10", key: "don7ne" }],
865
890
  ["path", { d: "M14 18h6", key: "1m8k6r" }]
866
891
  ];
867
- var Languages = createLucideIcon("languages", __iconNode12);
892
+ var Languages = createLucideIcon("languages", __iconNode14);
868
893
 
869
894
  // node_modules/lucide-react/dist/esm/icons/link.js
870
- var __iconNode13 = [
895
+ var __iconNode15 = [
871
896
  ["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" }],
872
897
  ["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" }]
873
898
  ];
874
- var Link = createLucideIcon("link", __iconNode13);
899
+ var Link = createLucideIcon("link", __iconNode15);
875
900
 
876
901
  // node_modules/lucide-react/dist/esm/icons/loader-circle.js
877
- var __iconNode14 = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
878
- var LoaderCircle = createLucideIcon("loader-circle", __iconNode14);
902
+ var __iconNode16 = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
903
+ var LoaderCircle = createLucideIcon("loader-circle", __iconNode16);
879
904
 
880
905
  // node_modules/lucide-react/dist/esm/icons/pencil.js
881
- var __iconNode15 = [
906
+ var __iconNode17 = [
882
907
  [
883
908
  "path",
884
909
  {
@@ -888,55 +913,62 @@ var __iconNode15 = [
888
913
  ],
889
914
  ["path", { d: "m15 5 4 4", key: "1mk7zo" }]
890
915
  ];
891
- var Pencil = createLucideIcon("pencil", __iconNode15);
916
+ var Pencil = createLucideIcon("pencil", __iconNode17);
917
+
918
+ // node_modules/lucide-react/dist/esm/icons/plus.js
919
+ var __iconNode18 = [
920
+ ["path", { d: "M5 12h14", key: "1ays0h" }],
921
+ ["path", { d: "M12 5v14", key: "s699le" }]
922
+ ];
923
+ var Plus = createLucideIcon("plus", __iconNode18);
892
924
 
893
925
  // node_modules/lucide-react/dist/esm/icons/refresh-ccw.js
894
- var __iconNode16 = [
926
+ var __iconNode19 = [
895
927
  ["path", { d: "M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "14sxne" }],
896
928
  ["path", { d: "M3 3v5h5", key: "1xhq8a" }],
897
929
  ["path", { d: "M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16", key: "1hlbsb" }],
898
930
  ["path", { d: "M16 16h5v5", key: "ccwih5" }]
899
931
  ];
900
- var RefreshCcw = createLucideIcon("refresh-ccw", __iconNode16);
932
+ var RefreshCcw = createLucideIcon("refresh-ccw", __iconNode19);
901
933
 
902
934
  // node_modules/lucide-react/dist/esm/icons/rotate-ccw.js
903
- var __iconNode17 = [
935
+ var __iconNode20 = [
904
936
  ["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
905
937
  ["path", { d: "M3 3v5h5", key: "1xhq8a" }]
906
938
  ];
907
- var RotateCcw = createLucideIcon("rotate-ccw", __iconNode17);
939
+ var RotateCcw = createLucideIcon("rotate-ccw", __iconNode20);
908
940
 
909
941
  // node_modules/lucide-react/dist/esm/icons/search.js
910
- var __iconNode18 = [
942
+ var __iconNode21 = [
911
943
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
912
944
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
913
945
  ];
914
- var Search = createLucideIcon("search", __iconNode18);
946
+ var Search = createLucideIcon("search", __iconNode21);
915
947
 
916
948
  // node_modules/lucide-react/dist/esm/icons/trash-2.js
917
- var __iconNode19 = [
949
+ var __iconNode22 = [
918
950
  ["path", { d: "M10 11v6", key: "nco0om" }],
919
951
  ["path", { d: "M14 11v6", key: "outv1u" }],
920
952
  ["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
921
953
  ["path", { d: "M3 6h18", key: "d0wm0j" }],
922
954
  ["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
923
955
  ];
924
- var Trash2 = createLucideIcon("trash-2", __iconNode19);
956
+ var Trash2 = createLucideIcon("trash-2", __iconNode22);
925
957
 
926
958
  // node_modules/lucide-react/dist/esm/icons/upload.js
927
- var __iconNode20 = [
959
+ var __iconNode23 = [
928
960
  ["path", { d: "M12 3v12", key: "1x0j5s" }],
929
961
  ["path", { d: "m17 8-5-5-5 5", key: "7q97r8" }],
930
962
  ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
931
963
  ];
932
- var Upload = createLucideIcon("upload", __iconNode20);
964
+ var Upload = createLucideIcon("upload", __iconNode23);
933
965
 
934
966
  // node_modules/lucide-react/dist/esm/icons/x.js
935
- var __iconNode21 = [
967
+ var __iconNode24 = [
936
968
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
937
969
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
938
970
  ];
939
- var X = createLucideIcon("x", __iconNode21);
971
+ var X = createLucideIcon("x", __iconNode24);
940
972
  var FieldErrorBoundary = class extends React__default.Component {
941
973
  constructor(props) {
942
974
  super(props);
@@ -24020,6 +24052,25 @@ var normalizeHex = (hex) => {
24020
24052
  }
24021
24053
  return v2;
24022
24054
  };
24055
+ var toHex = (val) => {
24056
+ if (!val) return "";
24057
+ const trimmed = val.trim();
24058
+ if (trimmed.startsWith("#")) return trimmed;
24059
+ const rgbaMatch = trimmed.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)$/i);
24060
+ if (rgbaMatch) {
24061
+ const r2 = parseInt(rgbaMatch[1], 10);
24062
+ const g = parseInt(rgbaMatch[2], 10);
24063
+ const b = parseInt(rgbaMatch[3], 10);
24064
+ const a2 = rgbaMatch[4] !== void 0 ? parseFloat(rgbaMatch[4]) : 1;
24065
+ const hex = `#${[r2, g, b].map((c2) => c2.toString(16).padStart(2, "0")).join("")}`;
24066
+ if (a2 < 1) {
24067
+ const alphaHex = Math.round(a2 * 255).toString(16).padStart(2, "0");
24068
+ return hex + alphaHex;
24069
+ }
24070
+ return hex;
24071
+ }
24072
+ return trimmed;
24073
+ };
24023
24074
  var ColorField = ({
24024
24075
  value,
24025
24076
  onChange,
@@ -24029,14 +24080,15 @@ var ColorField = ({
24029
24080
  placeholder = "#000000",
24030
24081
  showReset = true
24031
24082
  }) => {
24032
- const [hexInput, setHexInput] = React__default.useState(value || "");
24083
+ const [hexInput, setHexInput] = React__default.useState(() => toHex(value || ""));
24033
24084
  const [opacity, setOpacity2] = React__default.useState(100);
24034
24085
  const [focused, setFocused] = React__default.useState(false);
24035
24086
  const inputRef = React__default.useRef(null);
24036
24087
  React__default.useEffect(() => {
24037
- setHexInput(value || "");
24038
- if (value && value.length === 9) {
24039
- const alphaHex = value.slice(7, 9);
24088
+ const hex = toHex(value || "");
24089
+ setHexInput(hex);
24090
+ if (hex && hex.length === 9) {
24091
+ const alphaHex = hex.slice(7, 9);
24040
24092
  const alphaPercent = Math.round(parseInt(alphaHex, 16) / 255 * 100);
24041
24093
  setOpacity2(alphaPercent);
24042
24094
  } else {
@@ -24192,6 +24244,308 @@ var createColorField = (options = {}) => {
24192
24244
  ) }) })
24193
24245
  };
24194
24246
  };
24247
+ var RepeaterRow = ({
24248
+ row,
24249
+ rowIndex,
24250
+ subFields,
24251
+ isExpanded,
24252
+ onToggle,
24253
+ onRemove,
24254
+ onDuplicate,
24255
+ onMoveUp,
24256
+ onMoveDown,
24257
+ onChange,
24258
+ canRemove,
24259
+ canMoveUp,
24260
+ canMoveDown,
24261
+ readOnly
24262
+ }) => {
24263
+ const previewLabel = React__default.useMemo(() => {
24264
+ const keys = Object.keys(subFields);
24265
+ if (keys.length === 0) return `Sat\u0131r ${rowIndex + 1}`;
24266
+ const firstKey = keys[0];
24267
+ const val = row[firstKey];
24268
+ if (!val) return `Sat\u0131r ${rowIndex + 1}`;
24269
+ if (Array.isArray(val) && val.length > 0 && typeof val[0] === "object" && "value" in val[0]) {
24270
+ const text2 = val[0]?.value;
24271
+ if (typeof text2 === "string" && text2.trim()) {
24272
+ return text2.length > 40 ? text2.substring(0, 40) + "\u2026" : text2;
24273
+ }
24274
+ }
24275
+ if (typeof val === "string" && val.trim()) {
24276
+ return val.length > 40 ? val.substring(0, 40) + "\u2026" : val;
24277
+ }
24278
+ return `Sat\u0131r ${rowIndex + 1}`;
24279
+ }, [row, subFields, rowIndex]);
24280
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `tecof-repeater-row ${isExpanded ? "expanded" : ""}`, children: [
24281
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-repeater-row-header", onClick: onToggle, children: [
24282
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-repeater-row-left", children: [
24283
+ /* @__PURE__ */ jsxRuntime.jsx(GripVertical, { size: 14, className: "tecof-repeater-grip" }),
24284
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tecof-repeater-row-index", children: rowIndex + 1 }),
24285
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tecof-repeater-row-preview", children: previewLabel })
24286
+ ] }),
24287
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-repeater-row-actions", children: [
24288
+ !readOnly && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
24289
+ canMoveUp && /* @__PURE__ */ jsxRuntime.jsx(
24290
+ "button",
24291
+ {
24292
+ type: "button",
24293
+ className: "tecof-repeater-action-btn",
24294
+ onClick: (e3) => {
24295
+ e3.stopPropagation();
24296
+ onMoveUp();
24297
+ },
24298
+ title: "Yukar\u0131 Ta\u015F\u0131",
24299
+ children: "\u25B2"
24300
+ }
24301
+ ),
24302
+ canMoveDown && /* @__PURE__ */ jsxRuntime.jsx(
24303
+ "button",
24304
+ {
24305
+ type: "button",
24306
+ className: "tecof-repeater-action-btn",
24307
+ onClick: (e3) => {
24308
+ e3.stopPropagation();
24309
+ onMoveDown();
24310
+ },
24311
+ title: "A\u015Fa\u011F\u0131 Ta\u015F\u0131",
24312
+ children: "\u25BC"
24313
+ }
24314
+ ),
24315
+ /* @__PURE__ */ jsxRuntime.jsx(
24316
+ "button",
24317
+ {
24318
+ type: "button",
24319
+ className: "tecof-repeater-action-btn",
24320
+ onClick: (e3) => {
24321
+ e3.stopPropagation();
24322
+ onDuplicate();
24323
+ },
24324
+ title: "Kopyala",
24325
+ children: /* @__PURE__ */ jsxRuntime.jsx(Copy, { size: 13 })
24326
+ }
24327
+ ),
24328
+ canRemove && /* @__PURE__ */ jsxRuntime.jsx(
24329
+ "button",
24330
+ {
24331
+ type: "button",
24332
+ className: "tecof-repeater-action-btn tecof-repeater-action-btn-danger",
24333
+ onClick: (e3) => {
24334
+ e3.stopPropagation();
24335
+ onRemove();
24336
+ },
24337
+ title: "Sil",
24338
+ children: /* @__PURE__ */ jsxRuntime.jsx(Trash2, { size: 13 })
24339
+ }
24340
+ )
24341
+ ] }),
24342
+ /* @__PURE__ */ jsxRuntime.jsx(
24343
+ ChevronDown,
24344
+ {
24345
+ size: 16,
24346
+ className: `tecof-repeater-chevron ${isExpanded ? "rotated" : ""}`
24347
+ }
24348
+ )
24349
+ ] })
24350
+ ] }),
24351
+ isExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-repeater-row-content", children: Object.entries(subFields).map(([key, fieldDef]) => {
24352
+ const fieldValue = row[key];
24353
+ const renderFn = fieldDef?.render;
24354
+ if (typeof renderFn !== "function") return null;
24355
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-repeater-subfield", children: renderFn({
24356
+ field: fieldDef,
24357
+ name: `${key}_${rowIndex}`,
24358
+ id: `repeater-${rowIndex}-${key}`,
24359
+ value: fieldValue,
24360
+ onChange: (val) => onChange(key, val),
24361
+ readOnly
24362
+ }) }, key);
24363
+ }) })
24364
+ ] });
24365
+ };
24366
+ var RepeaterField = ({
24367
+ value: rawValue,
24368
+ onChange,
24369
+ readOnly,
24370
+ subFields = {},
24371
+ minItems = 0,
24372
+ maxItems,
24373
+ defaultRow
24374
+ }) => {
24375
+ const items = React__default.useMemo(() => Array.isArray(rawValue) ? rawValue : [], [rawValue]);
24376
+ const [expandedRows, setExpandedRows] = React__default.useState(() => new Set(items.length > 0 ? [0] : []));
24377
+ const onChangeRef = React__default.useRef(onChange);
24378
+ onChangeRef.current = onChange;
24379
+ const canAdd = maxItems == null || items.length < maxItems;
24380
+ const canRemove = items.length > minItems;
24381
+ const buildDefaultRow = React__default.useCallback(() => {
24382
+ if (defaultRow) return { ...defaultRow };
24383
+ const row = {};
24384
+ for (const [key, fieldDef] of Object.entries(subFields)) {
24385
+ const ft = fieldDef?._fieldType;
24386
+ if (ft === "language" || ft === "editor") {
24387
+ row[key] = [];
24388
+ } else if (ft === "upload") {
24389
+ row[key] = [];
24390
+ } else if (ft === "link") {
24391
+ row[key] = [];
24392
+ } else if (ft === "color") {
24393
+ row[key] = "#000000";
24394
+ } else {
24395
+ row[key] = "";
24396
+ }
24397
+ }
24398
+ return row;
24399
+ }, [subFields, defaultRow]);
24400
+ const handleAdd = React__default.useCallback(() => {
24401
+ if (!canAdd) return;
24402
+ const newRow = buildDefaultRow();
24403
+ const newItems = [...items, newRow];
24404
+ onChangeRef.current(newItems);
24405
+ setExpandedRows((prev) => {
24406
+ const next = new Set(prev);
24407
+ next.add(newItems.length - 1);
24408
+ return next;
24409
+ });
24410
+ }, [canAdd, buildDefaultRow, items]);
24411
+ const handleRemove = React__default.useCallback((index2) => {
24412
+ if (!canRemove) return;
24413
+ const newItems = items.filter((_2, i2) => i2 !== index2);
24414
+ onChangeRef.current(newItems);
24415
+ setExpandedRows((prev) => {
24416
+ const next = /* @__PURE__ */ new Set();
24417
+ prev.forEach((idx) => {
24418
+ if (idx < index2) next.add(idx);
24419
+ else if (idx > index2) next.add(idx - 1);
24420
+ });
24421
+ return next;
24422
+ });
24423
+ }, [canRemove, items]);
24424
+ const handleDuplicate = React__default.useCallback((index2) => {
24425
+ if (!canAdd) return;
24426
+ const newItems = [...items];
24427
+ const cloned = JSON.parse(JSON.stringify(items[index2]));
24428
+ newItems.splice(index2 + 1, 0, cloned);
24429
+ onChangeRef.current(newItems);
24430
+ setExpandedRows((prev) => {
24431
+ const next = /* @__PURE__ */ new Set();
24432
+ prev.forEach((idx) => {
24433
+ if (idx <= index2) next.add(idx);
24434
+ else next.add(idx + 1);
24435
+ });
24436
+ next.add(index2 + 1);
24437
+ return next;
24438
+ });
24439
+ }, [canAdd, items]);
24440
+ const handleMove = React__default.useCallback((index2, direction) => {
24441
+ const target = direction === "up" ? index2 - 1 : index2 + 1;
24442
+ if (target < 0 || target >= items.length) return;
24443
+ const newItems = [...items];
24444
+ [newItems[index2], newItems[target]] = [newItems[target], newItems[index2]];
24445
+ onChangeRef.current(newItems);
24446
+ setExpandedRows((prev) => {
24447
+ const next = /* @__PURE__ */ new Set();
24448
+ prev.forEach((idx) => {
24449
+ if (idx === index2) next.add(target);
24450
+ else if (idx === target) next.add(index2);
24451
+ else next.add(idx);
24452
+ });
24453
+ return next;
24454
+ });
24455
+ }, [items]);
24456
+ const handleSubFieldChange = React__default.useCallback((rowIndex, key, val) => {
24457
+ const newItems = items.map((row, i2) => {
24458
+ if (i2 !== rowIndex) return row;
24459
+ return { ...row, [key]: val };
24460
+ });
24461
+ onChangeRef.current(newItems);
24462
+ }, [items]);
24463
+ const toggleRow = React__default.useCallback((index2) => {
24464
+ setExpandedRows((prev) => {
24465
+ const next = new Set(prev);
24466
+ if (next.has(index2)) next.delete(index2);
24467
+ else next.add(index2);
24468
+ return next;
24469
+ });
24470
+ }, []);
24471
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-repeater-container", children: [
24472
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-repeater-header", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "tecof-repeater-count", children: [
24473
+ items.length,
24474
+ " sat\u0131r",
24475
+ maxItems != null && ` / ${maxItems}`
24476
+ ] }) }),
24477
+ items.length === 0 && !readOnly && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-repeater-empty", children: [
24478
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "tecof-repeater-empty-text", children: "Hen\xFCz sat\u0131r eklenmemi\u015F" }),
24479
+ /* @__PURE__ */ jsxRuntime.jsxs(
24480
+ "button",
24481
+ {
24482
+ type: "button",
24483
+ className: "tecof-repeater-add-btn",
24484
+ onClick: handleAdd,
24485
+ children: [
24486
+ /* @__PURE__ */ jsxRuntime.jsx(Plus, { size: 14 }),
24487
+ " \u0130lk Sat\u0131r\u0131 Ekle"
24488
+ ]
24489
+ }
24490
+ )
24491
+ ] }),
24492
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-repeater-rows", children: items.map((row, idx) => /* @__PURE__ */ jsxRuntime.jsx(
24493
+ RepeaterRow,
24494
+ {
24495
+ row,
24496
+ rowIndex: idx,
24497
+ subFields,
24498
+ isExpanded: expandedRows.has(idx),
24499
+ onToggle: () => toggleRow(idx),
24500
+ onRemove: () => handleRemove(idx),
24501
+ onDuplicate: () => handleDuplicate(idx),
24502
+ onMoveUp: () => handleMove(idx, "up"),
24503
+ onMoveDown: () => handleMove(idx, "down"),
24504
+ onChange: (key, val) => handleSubFieldChange(idx, key, val),
24505
+ canRemove,
24506
+ canMoveUp: idx > 0,
24507
+ canMoveDown: idx < items.length - 1,
24508
+ readOnly
24509
+ },
24510
+ idx
24511
+ )) }),
24512
+ items.length > 0 && !readOnly && canAdd && /* @__PURE__ */ jsxRuntime.jsxs(
24513
+ "button",
24514
+ {
24515
+ type: "button",
24516
+ className: "tecof-repeater-add-btn-bottom",
24517
+ onClick: handleAdd,
24518
+ children: [
24519
+ /* @__PURE__ */ jsxRuntime.jsx(Plus, { size: 14 }),
24520
+ " Sat\u0131r Ekle"
24521
+ ]
24522
+ }
24523
+ )
24524
+ ] });
24525
+ };
24526
+ RepeaterField.displayName = "RepeaterField";
24527
+ var createRepeaterField = (options) => {
24528
+ const { label, labelIcon, visible, ...fieldOptions } = options;
24529
+ return {
24530
+ type: "custom",
24531
+ _fieldType: "repeater",
24532
+ label,
24533
+ labelIcon,
24534
+ visible,
24535
+ 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(
24536
+ RepeaterField,
24537
+ {
24538
+ field,
24539
+ name: name3,
24540
+ id,
24541
+ value: value || [],
24542
+ onChange,
24543
+ readOnly,
24544
+ ...fieldOptions
24545
+ }
24546
+ ) }) })
24547
+ };
24548
+ };
24195
24549
 
24196
24550
  // src/utils/index.ts
24197
24551
  function hexToHsl(hex) {
@@ -24351,6 +24705,7 @@ lucide-react/dist/esm/context.js:
24351
24705
  lucide-react/dist/esm/Icon.js:
24352
24706
  lucide-react/dist/esm/createLucideIcon.js:
24353
24707
  lucide-react/dist/esm/icons/check.js:
24708
+ lucide-react/dist/esm/icons/chevron-down.js:
24354
24709
  lucide-react/dist/esm/icons/chevron-right.js:
24355
24710
  lucide-react/dist/esm/icons/code.js:
24356
24711
  lucide-react/dist/esm/icons/copy.js:
@@ -24359,12 +24714,14 @@ lucide-react/dist/esm/icons/file-text.js:
24359
24714
  lucide-react/dist/esm/icons/file.js:
24360
24715
  lucide-react/dist/esm/icons/folder-open.js:
24361
24716
  lucide-react/dist/esm/icons/globe.js:
24717
+ lucide-react/dist/esm/icons/grip-vertical.js:
24362
24718
  lucide-react/dist/esm/icons/image-plus.js:
24363
24719
  lucide-react/dist/esm/icons/image.js:
24364
24720
  lucide-react/dist/esm/icons/languages.js:
24365
24721
  lucide-react/dist/esm/icons/link.js:
24366
24722
  lucide-react/dist/esm/icons/loader-circle.js:
24367
24723
  lucide-react/dist/esm/icons/pencil.js:
24724
+ lucide-react/dist/esm/icons/plus.js:
24368
24725
  lucide-react/dist/esm/icons/refresh-ccw.js:
24369
24726
  lucide-react/dist/esm/icons/rotate-ccw.js:
24370
24727
  lucide-react/dist/esm/icons/search.js:
@@ -24460,6 +24817,7 @@ exports.EditorField = EditorField;
24460
24817
  exports.FieldErrorBoundary = FieldErrorBoundary;
24461
24818
  exports.LanguageField = LanguageField;
24462
24819
  exports.LinkField = LinkField;
24820
+ exports.RepeaterField = RepeaterField;
24463
24821
  exports.TecofApiClient = TecofApiClient;
24464
24822
  exports.TecofEditor = TecofEditor;
24465
24823
  exports.TecofPicture = TecofPicture;
@@ -24471,6 +24829,7 @@ exports.createColorField = createColorField;
24471
24829
  exports.createEditorField = createEditorField;
24472
24830
  exports.createLanguageField = createLanguageField;
24473
24831
  exports.createLinkField = createLinkField;
24832
+ exports.createRepeaterField = createRepeaterField;
24474
24833
  exports.createUploadField = createUploadField;
24475
24834
  exports.darken = darken;
24476
24835
  exports.generateCSSVariables = generateCSSVariables;