@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.d.mts +44 -2
- package/dist/index.d.ts +44 -2
- package/dist/index.js +407 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +407 -50
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +234 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React__default from 'react';
|
|
2
2
|
import React__default__default, { createContext, memo, forwardRef, createElement, useRef, useCallback, useContext, useState, useEffect, useMemo, Component, useLayoutEffect } from 'react';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
import { fieldsPlugin, Puck, Render, FieldLabel } from '@puckeditor/core';
|
|
4
|
+
import { blocksPlugin, outlinePlugin, fieldsPlugin, Puck, Render, FieldLabel } from '@puckeditor/core';
|
|
5
5
|
import { useEditor, EditorContent } from '@tiptap/react';
|
|
6
6
|
import Document from '@tiptap/extension-document';
|
|
7
7
|
import Paragraph from '@tiptap/extension-paragraph';
|
|
@@ -431,7 +431,9 @@ var TecofEditor = ({
|
|
|
431
431
|
] }) });
|
|
432
432
|
}
|
|
433
433
|
const plugins = [
|
|
434
|
-
...
|
|
434
|
+
{ ...blocksPlugin(), label: "Bloklar" },
|
|
435
|
+
{ ...outlinePlugin(), label: "Anahat" },
|
|
436
|
+
{ ...fieldsPlugin({ desktopSideBar: "right" }), label: "Alanlar" },
|
|
435
437
|
...extraPlugins || []
|
|
436
438
|
];
|
|
437
439
|
const mergedOverrides = {
|
|
@@ -450,15 +452,23 @@ var TecofEditor = ({
|
|
|
450
452
|
data: initialData,
|
|
451
453
|
onPublish: handlePuckPublish,
|
|
452
454
|
onChange: handleChange,
|
|
453
|
-
overrides: mergedOverrides
|
|
455
|
+
overrides: mergedOverrides,
|
|
456
|
+
metadata: { editMode: true }
|
|
454
457
|
}
|
|
455
458
|
),
|
|
456
459
|
saving && /* @__PURE__ */ jsx("div", { className: "tecof-editor-save-indicator", children: saveStatus === "error" ? "Save failed" : "Saving..." })
|
|
457
460
|
] });
|
|
458
461
|
};
|
|
459
|
-
var TecofRender = ({ data: data3, config: config3, className }) => {
|
|
462
|
+
var TecofRender = ({ data: data3, config: config3, className, cmsData }) => {
|
|
460
463
|
if (!data3) return null;
|
|
461
|
-
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(
|
|
464
|
+
return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(
|
|
465
|
+
Render,
|
|
466
|
+
{
|
|
467
|
+
config: config3,
|
|
468
|
+
data: data3,
|
|
469
|
+
metadata: { cmsData: cmsData || null }
|
|
470
|
+
}
|
|
471
|
+
) });
|
|
462
472
|
};
|
|
463
473
|
var IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "webp", "gif", "svg", "avif", "bmp", "tiff", "heic"];
|
|
464
474
|
var VIDEO_EXTENSIONS = ["mp4", "webm", "ogg", "avi", "mov", "quicktime"];
|
|
@@ -724,34 +734,38 @@ var createLucideIcon = (iconName, iconNode) => {
|
|
|
724
734
|
var __iconNode = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
|
|
725
735
|
var Check = createLucideIcon("check", __iconNode);
|
|
726
736
|
|
|
737
|
+
// node_modules/lucide-react/dist/esm/icons/chevron-down.js
|
|
738
|
+
var __iconNode2 = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
|
|
739
|
+
var ChevronDown = createLucideIcon("chevron-down", __iconNode2);
|
|
740
|
+
|
|
727
741
|
// node_modules/lucide-react/dist/esm/icons/chevron-right.js
|
|
728
|
-
var
|
|
729
|
-
var ChevronRight = createLucideIcon("chevron-right",
|
|
742
|
+
var __iconNode3 = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
|
|
743
|
+
var ChevronRight = createLucideIcon("chevron-right", __iconNode3);
|
|
730
744
|
|
|
731
745
|
// node_modules/lucide-react/dist/esm/icons/code.js
|
|
732
|
-
var
|
|
746
|
+
var __iconNode4 = [
|
|
733
747
|
["path", { d: "m16 18 6-6-6-6", key: "eg8j8" }],
|
|
734
748
|
["path", { d: "m8 6-6 6 6 6", key: "ppft3o" }]
|
|
735
749
|
];
|
|
736
|
-
var Code = createLucideIcon("code",
|
|
750
|
+
var Code = createLucideIcon("code", __iconNode4);
|
|
737
751
|
|
|
738
752
|
// node_modules/lucide-react/dist/esm/icons/copy.js
|
|
739
|
-
var
|
|
753
|
+
var __iconNode5 = [
|
|
740
754
|
["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
|
|
741
755
|
["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" }]
|
|
742
756
|
];
|
|
743
|
-
var Copy = createLucideIcon("copy",
|
|
757
|
+
var Copy = createLucideIcon("copy", __iconNode5);
|
|
744
758
|
|
|
745
759
|
// node_modules/lucide-react/dist/esm/icons/external-link.js
|
|
746
|
-
var
|
|
760
|
+
var __iconNode6 = [
|
|
747
761
|
["path", { d: "M15 3h6v6", key: "1q9fwt" }],
|
|
748
762
|
["path", { d: "M10 14 21 3", key: "gplh6r" }],
|
|
749
763
|
["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
|
|
750
764
|
];
|
|
751
|
-
var ExternalLink = createLucideIcon("external-link",
|
|
765
|
+
var ExternalLink = createLucideIcon("external-link", __iconNode6);
|
|
752
766
|
|
|
753
767
|
// node_modules/lucide-react/dist/esm/icons/file-text.js
|
|
754
|
-
var
|
|
768
|
+
var __iconNode7 = [
|
|
755
769
|
[
|
|
756
770
|
"path",
|
|
757
771
|
{
|
|
@@ -764,10 +778,10 @@ var __iconNode6 = [
|
|
|
764
778
|
["path", { d: "M16 13H8", key: "t4e002" }],
|
|
765
779
|
["path", { d: "M16 17H8", key: "z1uh3a" }]
|
|
766
780
|
];
|
|
767
|
-
var FileText = createLucideIcon("file-text",
|
|
781
|
+
var FileText = createLucideIcon("file-text", __iconNode7);
|
|
768
782
|
|
|
769
783
|
// node_modules/lucide-react/dist/esm/icons/file.js
|
|
770
|
-
var
|
|
784
|
+
var __iconNode8 = [
|
|
771
785
|
[
|
|
772
786
|
"path",
|
|
773
787
|
{
|
|
@@ -777,10 +791,10 @@ var __iconNode7 = [
|
|
|
777
791
|
],
|
|
778
792
|
["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
|
|
779
793
|
];
|
|
780
|
-
var File2 = createLucideIcon("file",
|
|
794
|
+
var File2 = createLucideIcon("file", __iconNode8);
|
|
781
795
|
|
|
782
796
|
// node_modules/lucide-react/dist/esm/icons/folder-open.js
|
|
783
|
-
var
|
|
797
|
+
var __iconNode9 = [
|
|
784
798
|
[
|
|
785
799
|
"path",
|
|
786
800
|
{
|
|
@@ -789,36 +803,47 @@ var __iconNode8 = [
|
|
|
789
803
|
}
|
|
790
804
|
]
|
|
791
805
|
];
|
|
792
|
-
var FolderOpen = createLucideIcon("folder-open",
|
|
806
|
+
var FolderOpen = createLucideIcon("folder-open", __iconNode9);
|
|
793
807
|
|
|
794
808
|
// node_modules/lucide-react/dist/esm/icons/globe.js
|
|
795
|
-
var
|
|
809
|
+
var __iconNode10 = [
|
|
796
810
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
797
811
|
["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
|
|
798
812
|
["path", { d: "M2 12h20", key: "9i4pu4" }]
|
|
799
813
|
];
|
|
800
|
-
var Globe = createLucideIcon("globe",
|
|
814
|
+
var Globe = createLucideIcon("globe", __iconNode10);
|
|
815
|
+
|
|
816
|
+
// node_modules/lucide-react/dist/esm/icons/grip-vertical.js
|
|
817
|
+
var __iconNode11 = [
|
|
818
|
+
["circle", { cx: "9", cy: "12", r: "1", key: "1vctgf" }],
|
|
819
|
+
["circle", { cx: "9", cy: "5", r: "1", key: "hp0tcf" }],
|
|
820
|
+
["circle", { cx: "9", cy: "19", r: "1", key: "fkjjf6" }],
|
|
821
|
+
["circle", { cx: "15", cy: "12", r: "1", key: "1tmaij" }],
|
|
822
|
+
["circle", { cx: "15", cy: "5", r: "1", key: "19l28e" }],
|
|
823
|
+
["circle", { cx: "15", cy: "19", r: "1", key: "f4zoj3" }]
|
|
824
|
+
];
|
|
825
|
+
var GripVertical = createLucideIcon("grip-vertical", __iconNode11);
|
|
801
826
|
|
|
802
827
|
// node_modules/lucide-react/dist/esm/icons/image-plus.js
|
|
803
|
-
var
|
|
828
|
+
var __iconNode12 = [
|
|
804
829
|
["path", { d: "M16 5h6", key: "1vod17" }],
|
|
805
830
|
["path", { d: "M19 2v6", key: "4bpg5p" }],
|
|
806
831
|
["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" }],
|
|
807
832
|
["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }],
|
|
808
833
|
["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }]
|
|
809
834
|
];
|
|
810
|
-
var ImagePlus = createLucideIcon("image-plus",
|
|
835
|
+
var ImagePlus = createLucideIcon("image-plus", __iconNode12);
|
|
811
836
|
|
|
812
837
|
// node_modules/lucide-react/dist/esm/icons/image.js
|
|
813
|
-
var
|
|
838
|
+
var __iconNode13 = [
|
|
814
839
|
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
|
|
815
840
|
["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
|
|
816
841
|
["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
|
|
817
842
|
];
|
|
818
|
-
var Image2 = createLucideIcon("image",
|
|
843
|
+
var Image2 = createLucideIcon("image", __iconNode13);
|
|
819
844
|
|
|
820
845
|
// node_modules/lucide-react/dist/esm/icons/languages.js
|
|
821
|
-
var
|
|
846
|
+
var __iconNode14 = [
|
|
822
847
|
["path", { d: "m5 8 6 6", key: "1wu5hv" }],
|
|
823
848
|
["path", { d: "m4 14 6-6 2-3", key: "1k1g8d" }],
|
|
824
849
|
["path", { d: "M2 5h12", key: "or177f" }],
|
|
@@ -826,21 +851,21 @@ var __iconNode12 = [
|
|
|
826
851
|
["path", { d: "m22 22-5-10-5 10", key: "don7ne" }],
|
|
827
852
|
["path", { d: "M14 18h6", key: "1m8k6r" }]
|
|
828
853
|
];
|
|
829
|
-
var Languages = createLucideIcon("languages",
|
|
854
|
+
var Languages = createLucideIcon("languages", __iconNode14);
|
|
830
855
|
|
|
831
856
|
// node_modules/lucide-react/dist/esm/icons/link.js
|
|
832
|
-
var
|
|
857
|
+
var __iconNode15 = [
|
|
833
858
|
["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" }],
|
|
834
859
|
["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" }]
|
|
835
860
|
];
|
|
836
|
-
var Link = createLucideIcon("link",
|
|
861
|
+
var Link = createLucideIcon("link", __iconNode15);
|
|
837
862
|
|
|
838
863
|
// node_modules/lucide-react/dist/esm/icons/loader-circle.js
|
|
839
|
-
var
|
|
840
|
-
var LoaderCircle = createLucideIcon("loader-circle",
|
|
864
|
+
var __iconNode16 = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
|
|
865
|
+
var LoaderCircle = createLucideIcon("loader-circle", __iconNode16);
|
|
841
866
|
|
|
842
867
|
// node_modules/lucide-react/dist/esm/icons/pencil.js
|
|
843
|
-
var
|
|
868
|
+
var __iconNode17 = [
|
|
844
869
|
[
|
|
845
870
|
"path",
|
|
846
871
|
{
|
|
@@ -850,55 +875,62 @@ var __iconNode15 = [
|
|
|
850
875
|
],
|
|
851
876
|
["path", { d: "m15 5 4 4", key: "1mk7zo" }]
|
|
852
877
|
];
|
|
853
|
-
var Pencil = createLucideIcon("pencil",
|
|
878
|
+
var Pencil = createLucideIcon("pencil", __iconNode17);
|
|
879
|
+
|
|
880
|
+
// node_modules/lucide-react/dist/esm/icons/plus.js
|
|
881
|
+
var __iconNode18 = [
|
|
882
|
+
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
883
|
+
["path", { d: "M12 5v14", key: "s699le" }]
|
|
884
|
+
];
|
|
885
|
+
var Plus = createLucideIcon("plus", __iconNode18);
|
|
854
886
|
|
|
855
887
|
// node_modules/lucide-react/dist/esm/icons/refresh-ccw.js
|
|
856
|
-
var
|
|
888
|
+
var __iconNode19 = [
|
|
857
889
|
["path", { d: "M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "14sxne" }],
|
|
858
890
|
["path", { d: "M3 3v5h5", key: "1xhq8a" }],
|
|
859
891
|
["path", { d: "M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16", key: "1hlbsb" }],
|
|
860
892
|
["path", { d: "M16 16h5v5", key: "ccwih5" }]
|
|
861
893
|
];
|
|
862
|
-
var RefreshCcw = createLucideIcon("refresh-ccw",
|
|
894
|
+
var RefreshCcw = createLucideIcon("refresh-ccw", __iconNode19);
|
|
863
895
|
|
|
864
896
|
// node_modules/lucide-react/dist/esm/icons/rotate-ccw.js
|
|
865
|
-
var
|
|
897
|
+
var __iconNode20 = [
|
|
866
898
|
["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
|
|
867
899
|
["path", { d: "M3 3v5h5", key: "1xhq8a" }]
|
|
868
900
|
];
|
|
869
|
-
var RotateCcw = createLucideIcon("rotate-ccw",
|
|
901
|
+
var RotateCcw = createLucideIcon("rotate-ccw", __iconNode20);
|
|
870
902
|
|
|
871
903
|
// node_modules/lucide-react/dist/esm/icons/search.js
|
|
872
|
-
var
|
|
904
|
+
var __iconNode21 = [
|
|
873
905
|
["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
|
|
874
906
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
|
|
875
907
|
];
|
|
876
|
-
var Search = createLucideIcon("search",
|
|
908
|
+
var Search = createLucideIcon("search", __iconNode21);
|
|
877
909
|
|
|
878
910
|
// node_modules/lucide-react/dist/esm/icons/trash-2.js
|
|
879
|
-
var
|
|
911
|
+
var __iconNode22 = [
|
|
880
912
|
["path", { d: "M10 11v6", key: "nco0om" }],
|
|
881
913
|
["path", { d: "M14 11v6", key: "outv1u" }],
|
|
882
914
|
["path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6", key: "miytrc" }],
|
|
883
915
|
["path", { d: "M3 6h18", key: "d0wm0j" }],
|
|
884
916
|
["path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2", key: "e791ji" }]
|
|
885
917
|
];
|
|
886
|
-
var Trash2 = createLucideIcon("trash-2",
|
|
918
|
+
var Trash2 = createLucideIcon("trash-2", __iconNode22);
|
|
887
919
|
|
|
888
920
|
// node_modules/lucide-react/dist/esm/icons/upload.js
|
|
889
|
-
var
|
|
921
|
+
var __iconNode23 = [
|
|
890
922
|
["path", { d: "M12 3v12", key: "1x0j5s" }],
|
|
891
923
|
["path", { d: "m17 8-5-5-5 5", key: "7q97r8" }],
|
|
892
924
|
["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
|
|
893
925
|
];
|
|
894
|
-
var Upload = createLucideIcon("upload",
|
|
926
|
+
var Upload = createLucideIcon("upload", __iconNode23);
|
|
895
927
|
|
|
896
928
|
// node_modules/lucide-react/dist/esm/icons/x.js
|
|
897
|
-
var
|
|
929
|
+
var __iconNode24 = [
|
|
898
930
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
899
931
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
900
932
|
];
|
|
901
|
-
var X = createLucideIcon("x",
|
|
933
|
+
var X = createLucideIcon("x", __iconNode24);
|
|
902
934
|
var FieldErrorBoundary = class extends Component {
|
|
903
935
|
constructor(props) {
|
|
904
936
|
super(props);
|
|
@@ -23982,6 +24014,25 @@ var normalizeHex = (hex) => {
|
|
|
23982
24014
|
}
|
|
23983
24015
|
return v2;
|
|
23984
24016
|
};
|
|
24017
|
+
var toHex = (val) => {
|
|
24018
|
+
if (!val) return "";
|
|
24019
|
+
const trimmed = val.trim();
|
|
24020
|
+
if (trimmed.startsWith("#")) return trimmed;
|
|
24021
|
+
const rgbaMatch = trimmed.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)$/i);
|
|
24022
|
+
if (rgbaMatch) {
|
|
24023
|
+
const r2 = parseInt(rgbaMatch[1], 10);
|
|
24024
|
+
const g = parseInt(rgbaMatch[2], 10);
|
|
24025
|
+
const b = parseInt(rgbaMatch[3], 10);
|
|
24026
|
+
const a2 = rgbaMatch[4] !== void 0 ? parseFloat(rgbaMatch[4]) : 1;
|
|
24027
|
+
const hex = `#${[r2, g, b].map((c2) => c2.toString(16).padStart(2, "0")).join("")}`;
|
|
24028
|
+
if (a2 < 1) {
|
|
24029
|
+
const alphaHex = Math.round(a2 * 255).toString(16).padStart(2, "0");
|
|
24030
|
+
return hex + alphaHex;
|
|
24031
|
+
}
|
|
24032
|
+
return hex;
|
|
24033
|
+
}
|
|
24034
|
+
return trimmed;
|
|
24035
|
+
};
|
|
23985
24036
|
var ColorField = ({
|
|
23986
24037
|
value,
|
|
23987
24038
|
onChange,
|
|
@@ -23991,14 +24042,15 @@ var ColorField = ({
|
|
|
23991
24042
|
placeholder = "#000000",
|
|
23992
24043
|
showReset = true
|
|
23993
24044
|
}) => {
|
|
23994
|
-
const [hexInput, setHexInput] = useState(value || "");
|
|
24045
|
+
const [hexInput, setHexInput] = useState(() => toHex(value || ""));
|
|
23995
24046
|
const [opacity, setOpacity2] = useState(100);
|
|
23996
24047
|
const [focused, setFocused] = useState(false);
|
|
23997
24048
|
const inputRef = useRef(null);
|
|
23998
24049
|
useEffect(() => {
|
|
23999
|
-
|
|
24000
|
-
|
|
24001
|
-
|
|
24050
|
+
const hex = toHex(value || "");
|
|
24051
|
+
setHexInput(hex);
|
|
24052
|
+
if (hex && hex.length === 9) {
|
|
24053
|
+
const alphaHex = hex.slice(7, 9);
|
|
24002
24054
|
const alphaPercent = Math.round(parseInt(alphaHex, 16) / 255 * 100);
|
|
24003
24055
|
setOpacity2(alphaPercent);
|
|
24004
24056
|
} else {
|
|
@@ -24154,6 +24206,308 @@ var createColorField = (options = {}) => {
|
|
|
24154
24206
|
) }) })
|
|
24155
24207
|
};
|
|
24156
24208
|
};
|
|
24209
|
+
var RepeaterRow = ({
|
|
24210
|
+
row,
|
|
24211
|
+
rowIndex,
|
|
24212
|
+
subFields,
|
|
24213
|
+
isExpanded,
|
|
24214
|
+
onToggle,
|
|
24215
|
+
onRemove,
|
|
24216
|
+
onDuplicate,
|
|
24217
|
+
onMoveUp,
|
|
24218
|
+
onMoveDown,
|
|
24219
|
+
onChange,
|
|
24220
|
+
canRemove,
|
|
24221
|
+
canMoveUp,
|
|
24222
|
+
canMoveDown,
|
|
24223
|
+
readOnly
|
|
24224
|
+
}) => {
|
|
24225
|
+
const previewLabel = useMemo(() => {
|
|
24226
|
+
const keys = Object.keys(subFields);
|
|
24227
|
+
if (keys.length === 0) return `Sat\u0131r ${rowIndex + 1}`;
|
|
24228
|
+
const firstKey = keys[0];
|
|
24229
|
+
const val = row[firstKey];
|
|
24230
|
+
if (!val) return `Sat\u0131r ${rowIndex + 1}`;
|
|
24231
|
+
if (Array.isArray(val) && val.length > 0 && typeof val[0] === "object" && "value" in val[0]) {
|
|
24232
|
+
const text2 = val[0]?.value;
|
|
24233
|
+
if (typeof text2 === "string" && text2.trim()) {
|
|
24234
|
+
return text2.length > 40 ? text2.substring(0, 40) + "\u2026" : text2;
|
|
24235
|
+
}
|
|
24236
|
+
}
|
|
24237
|
+
if (typeof val === "string" && val.trim()) {
|
|
24238
|
+
return val.length > 40 ? val.substring(0, 40) + "\u2026" : val;
|
|
24239
|
+
}
|
|
24240
|
+
return `Sat\u0131r ${rowIndex + 1}`;
|
|
24241
|
+
}, [row, subFields, rowIndex]);
|
|
24242
|
+
return /* @__PURE__ */ jsxs("div", { className: `tecof-repeater-row ${isExpanded ? "expanded" : ""}`, children: [
|
|
24243
|
+
/* @__PURE__ */ jsxs("div", { className: "tecof-repeater-row-header", onClick: onToggle, children: [
|
|
24244
|
+
/* @__PURE__ */ jsxs("div", { className: "tecof-repeater-row-left", children: [
|
|
24245
|
+
/* @__PURE__ */ jsx(GripVertical, { size: 14, className: "tecof-repeater-grip" }),
|
|
24246
|
+
/* @__PURE__ */ jsx("span", { className: "tecof-repeater-row-index", children: rowIndex + 1 }),
|
|
24247
|
+
/* @__PURE__ */ jsx("span", { className: "tecof-repeater-row-preview", children: previewLabel })
|
|
24248
|
+
] }),
|
|
24249
|
+
/* @__PURE__ */ jsxs("div", { className: "tecof-repeater-row-actions", children: [
|
|
24250
|
+
!readOnly && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24251
|
+
canMoveUp && /* @__PURE__ */ jsx(
|
|
24252
|
+
"button",
|
|
24253
|
+
{
|
|
24254
|
+
type: "button",
|
|
24255
|
+
className: "tecof-repeater-action-btn",
|
|
24256
|
+
onClick: (e3) => {
|
|
24257
|
+
e3.stopPropagation();
|
|
24258
|
+
onMoveUp();
|
|
24259
|
+
},
|
|
24260
|
+
title: "Yukar\u0131 Ta\u015F\u0131",
|
|
24261
|
+
children: "\u25B2"
|
|
24262
|
+
}
|
|
24263
|
+
),
|
|
24264
|
+
canMoveDown && /* @__PURE__ */ jsx(
|
|
24265
|
+
"button",
|
|
24266
|
+
{
|
|
24267
|
+
type: "button",
|
|
24268
|
+
className: "tecof-repeater-action-btn",
|
|
24269
|
+
onClick: (e3) => {
|
|
24270
|
+
e3.stopPropagation();
|
|
24271
|
+
onMoveDown();
|
|
24272
|
+
},
|
|
24273
|
+
title: "A\u015Fa\u011F\u0131 Ta\u015F\u0131",
|
|
24274
|
+
children: "\u25BC"
|
|
24275
|
+
}
|
|
24276
|
+
),
|
|
24277
|
+
/* @__PURE__ */ jsx(
|
|
24278
|
+
"button",
|
|
24279
|
+
{
|
|
24280
|
+
type: "button",
|
|
24281
|
+
className: "tecof-repeater-action-btn",
|
|
24282
|
+
onClick: (e3) => {
|
|
24283
|
+
e3.stopPropagation();
|
|
24284
|
+
onDuplicate();
|
|
24285
|
+
},
|
|
24286
|
+
title: "Kopyala",
|
|
24287
|
+
children: /* @__PURE__ */ jsx(Copy, { size: 13 })
|
|
24288
|
+
}
|
|
24289
|
+
),
|
|
24290
|
+
canRemove && /* @__PURE__ */ jsx(
|
|
24291
|
+
"button",
|
|
24292
|
+
{
|
|
24293
|
+
type: "button",
|
|
24294
|
+
className: "tecof-repeater-action-btn tecof-repeater-action-btn-danger",
|
|
24295
|
+
onClick: (e3) => {
|
|
24296
|
+
e3.stopPropagation();
|
|
24297
|
+
onRemove();
|
|
24298
|
+
},
|
|
24299
|
+
title: "Sil",
|
|
24300
|
+
children: /* @__PURE__ */ jsx(Trash2, { size: 13 })
|
|
24301
|
+
}
|
|
24302
|
+
)
|
|
24303
|
+
] }),
|
|
24304
|
+
/* @__PURE__ */ jsx(
|
|
24305
|
+
ChevronDown,
|
|
24306
|
+
{
|
|
24307
|
+
size: 16,
|
|
24308
|
+
className: `tecof-repeater-chevron ${isExpanded ? "rotated" : ""}`
|
|
24309
|
+
}
|
|
24310
|
+
)
|
|
24311
|
+
] })
|
|
24312
|
+
] }),
|
|
24313
|
+
isExpanded && /* @__PURE__ */ jsx("div", { className: "tecof-repeater-row-content", children: Object.entries(subFields).map(([key, fieldDef]) => {
|
|
24314
|
+
const fieldValue = row[key];
|
|
24315
|
+
const renderFn = fieldDef?.render;
|
|
24316
|
+
if (typeof renderFn !== "function") return null;
|
|
24317
|
+
return /* @__PURE__ */ jsx("div", { className: "tecof-repeater-subfield", children: renderFn({
|
|
24318
|
+
field: fieldDef,
|
|
24319
|
+
name: `${key}_${rowIndex}`,
|
|
24320
|
+
id: `repeater-${rowIndex}-${key}`,
|
|
24321
|
+
value: fieldValue,
|
|
24322
|
+
onChange: (val) => onChange(key, val),
|
|
24323
|
+
readOnly
|
|
24324
|
+
}) }, key);
|
|
24325
|
+
}) })
|
|
24326
|
+
] });
|
|
24327
|
+
};
|
|
24328
|
+
var RepeaterField = ({
|
|
24329
|
+
value: rawValue,
|
|
24330
|
+
onChange,
|
|
24331
|
+
readOnly,
|
|
24332
|
+
subFields = {},
|
|
24333
|
+
minItems = 0,
|
|
24334
|
+
maxItems,
|
|
24335
|
+
defaultRow
|
|
24336
|
+
}) => {
|
|
24337
|
+
const items = useMemo(() => Array.isArray(rawValue) ? rawValue : [], [rawValue]);
|
|
24338
|
+
const [expandedRows, setExpandedRows] = useState(() => new Set(items.length > 0 ? [0] : []));
|
|
24339
|
+
const onChangeRef = useRef(onChange);
|
|
24340
|
+
onChangeRef.current = onChange;
|
|
24341
|
+
const canAdd = maxItems == null || items.length < maxItems;
|
|
24342
|
+
const canRemove = items.length > minItems;
|
|
24343
|
+
const buildDefaultRow = useCallback(() => {
|
|
24344
|
+
if (defaultRow) return { ...defaultRow };
|
|
24345
|
+
const row = {};
|
|
24346
|
+
for (const [key, fieldDef] of Object.entries(subFields)) {
|
|
24347
|
+
const ft = fieldDef?._fieldType;
|
|
24348
|
+
if (ft === "language" || ft === "editor") {
|
|
24349
|
+
row[key] = [];
|
|
24350
|
+
} else if (ft === "upload") {
|
|
24351
|
+
row[key] = [];
|
|
24352
|
+
} else if (ft === "link") {
|
|
24353
|
+
row[key] = [];
|
|
24354
|
+
} else if (ft === "color") {
|
|
24355
|
+
row[key] = "#000000";
|
|
24356
|
+
} else {
|
|
24357
|
+
row[key] = "";
|
|
24358
|
+
}
|
|
24359
|
+
}
|
|
24360
|
+
return row;
|
|
24361
|
+
}, [subFields, defaultRow]);
|
|
24362
|
+
const handleAdd = useCallback(() => {
|
|
24363
|
+
if (!canAdd) return;
|
|
24364
|
+
const newRow = buildDefaultRow();
|
|
24365
|
+
const newItems = [...items, newRow];
|
|
24366
|
+
onChangeRef.current(newItems);
|
|
24367
|
+
setExpandedRows((prev) => {
|
|
24368
|
+
const next = new Set(prev);
|
|
24369
|
+
next.add(newItems.length - 1);
|
|
24370
|
+
return next;
|
|
24371
|
+
});
|
|
24372
|
+
}, [canAdd, buildDefaultRow, items]);
|
|
24373
|
+
const handleRemove = useCallback((index2) => {
|
|
24374
|
+
if (!canRemove) return;
|
|
24375
|
+
const newItems = items.filter((_2, i2) => i2 !== index2);
|
|
24376
|
+
onChangeRef.current(newItems);
|
|
24377
|
+
setExpandedRows((prev) => {
|
|
24378
|
+
const next = /* @__PURE__ */ new Set();
|
|
24379
|
+
prev.forEach((idx) => {
|
|
24380
|
+
if (idx < index2) next.add(idx);
|
|
24381
|
+
else if (idx > index2) next.add(idx - 1);
|
|
24382
|
+
});
|
|
24383
|
+
return next;
|
|
24384
|
+
});
|
|
24385
|
+
}, [canRemove, items]);
|
|
24386
|
+
const handleDuplicate = useCallback((index2) => {
|
|
24387
|
+
if (!canAdd) return;
|
|
24388
|
+
const newItems = [...items];
|
|
24389
|
+
const cloned = JSON.parse(JSON.stringify(items[index2]));
|
|
24390
|
+
newItems.splice(index2 + 1, 0, cloned);
|
|
24391
|
+
onChangeRef.current(newItems);
|
|
24392
|
+
setExpandedRows((prev) => {
|
|
24393
|
+
const next = /* @__PURE__ */ new Set();
|
|
24394
|
+
prev.forEach((idx) => {
|
|
24395
|
+
if (idx <= index2) next.add(idx);
|
|
24396
|
+
else next.add(idx + 1);
|
|
24397
|
+
});
|
|
24398
|
+
next.add(index2 + 1);
|
|
24399
|
+
return next;
|
|
24400
|
+
});
|
|
24401
|
+
}, [canAdd, items]);
|
|
24402
|
+
const handleMove = useCallback((index2, direction) => {
|
|
24403
|
+
const target = direction === "up" ? index2 - 1 : index2 + 1;
|
|
24404
|
+
if (target < 0 || target >= items.length) return;
|
|
24405
|
+
const newItems = [...items];
|
|
24406
|
+
[newItems[index2], newItems[target]] = [newItems[target], newItems[index2]];
|
|
24407
|
+
onChangeRef.current(newItems);
|
|
24408
|
+
setExpandedRows((prev) => {
|
|
24409
|
+
const next = /* @__PURE__ */ new Set();
|
|
24410
|
+
prev.forEach((idx) => {
|
|
24411
|
+
if (idx === index2) next.add(target);
|
|
24412
|
+
else if (idx === target) next.add(index2);
|
|
24413
|
+
else next.add(idx);
|
|
24414
|
+
});
|
|
24415
|
+
return next;
|
|
24416
|
+
});
|
|
24417
|
+
}, [items]);
|
|
24418
|
+
const handleSubFieldChange = useCallback((rowIndex, key, val) => {
|
|
24419
|
+
const newItems = items.map((row, i2) => {
|
|
24420
|
+
if (i2 !== rowIndex) return row;
|
|
24421
|
+
return { ...row, [key]: val };
|
|
24422
|
+
});
|
|
24423
|
+
onChangeRef.current(newItems);
|
|
24424
|
+
}, [items]);
|
|
24425
|
+
const toggleRow = useCallback((index2) => {
|
|
24426
|
+
setExpandedRows((prev) => {
|
|
24427
|
+
const next = new Set(prev);
|
|
24428
|
+
if (next.has(index2)) next.delete(index2);
|
|
24429
|
+
else next.add(index2);
|
|
24430
|
+
return next;
|
|
24431
|
+
});
|
|
24432
|
+
}, []);
|
|
24433
|
+
return /* @__PURE__ */ jsxs("div", { className: "tecof-repeater-container", children: [
|
|
24434
|
+
/* @__PURE__ */ jsx("div", { className: "tecof-repeater-header", children: /* @__PURE__ */ jsxs("span", { className: "tecof-repeater-count", children: [
|
|
24435
|
+
items.length,
|
|
24436
|
+
" sat\u0131r",
|
|
24437
|
+
maxItems != null && ` / ${maxItems}`
|
|
24438
|
+
] }) }),
|
|
24439
|
+
items.length === 0 && !readOnly && /* @__PURE__ */ jsxs("div", { className: "tecof-repeater-empty", children: [
|
|
24440
|
+
/* @__PURE__ */ jsx("p", { className: "tecof-repeater-empty-text", children: "Hen\xFCz sat\u0131r eklenmemi\u015F" }),
|
|
24441
|
+
/* @__PURE__ */ jsxs(
|
|
24442
|
+
"button",
|
|
24443
|
+
{
|
|
24444
|
+
type: "button",
|
|
24445
|
+
className: "tecof-repeater-add-btn",
|
|
24446
|
+
onClick: handleAdd,
|
|
24447
|
+
children: [
|
|
24448
|
+
/* @__PURE__ */ jsx(Plus, { size: 14 }),
|
|
24449
|
+
" \u0130lk Sat\u0131r\u0131 Ekle"
|
|
24450
|
+
]
|
|
24451
|
+
}
|
|
24452
|
+
)
|
|
24453
|
+
] }),
|
|
24454
|
+
/* @__PURE__ */ jsx("div", { className: "tecof-repeater-rows", children: items.map((row, idx) => /* @__PURE__ */ jsx(
|
|
24455
|
+
RepeaterRow,
|
|
24456
|
+
{
|
|
24457
|
+
row,
|
|
24458
|
+
rowIndex: idx,
|
|
24459
|
+
subFields,
|
|
24460
|
+
isExpanded: expandedRows.has(idx),
|
|
24461
|
+
onToggle: () => toggleRow(idx),
|
|
24462
|
+
onRemove: () => handleRemove(idx),
|
|
24463
|
+
onDuplicate: () => handleDuplicate(idx),
|
|
24464
|
+
onMoveUp: () => handleMove(idx, "up"),
|
|
24465
|
+
onMoveDown: () => handleMove(idx, "down"),
|
|
24466
|
+
onChange: (key, val) => handleSubFieldChange(idx, key, val),
|
|
24467
|
+
canRemove,
|
|
24468
|
+
canMoveUp: idx > 0,
|
|
24469
|
+
canMoveDown: idx < items.length - 1,
|
|
24470
|
+
readOnly
|
|
24471
|
+
},
|
|
24472
|
+
idx
|
|
24473
|
+
)) }),
|
|
24474
|
+
items.length > 0 && !readOnly && canAdd && /* @__PURE__ */ jsxs(
|
|
24475
|
+
"button",
|
|
24476
|
+
{
|
|
24477
|
+
type: "button",
|
|
24478
|
+
className: "tecof-repeater-add-btn-bottom",
|
|
24479
|
+
onClick: handleAdd,
|
|
24480
|
+
children: [
|
|
24481
|
+
/* @__PURE__ */ jsx(Plus, { size: 14 }),
|
|
24482
|
+
" Sat\u0131r Ekle"
|
|
24483
|
+
]
|
|
24484
|
+
}
|
|
24485
|
+
)
|
|
24486
|
+
] });
|
|
24487
|
+
};
|
|
24488
|
+
RepeaterField.displayName = "RepeaterField";
|
|
24489
|
+
var createRepeaterField = (options) => {
|
|
24490
|
+
const { label, labelIcon, visible, ...fieldOptions } = options;
|
|
24491
|
+
return {
|
|
24492
|
+
type: "custom",
|
|
24493
|
+
_fieldType: "repeater",
|
|
24494
|
+
label,
|
|
24495
|
+
labelIcon,
|
|
24496
|
+
visible,
|
|
24497
|
+
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(
|
|
24498
|
+
RepeaterField,
|
|
24499
|
+
{
|
|
24500
|
+
field,
|
|
24501
|
+
name: name3,
|
|
24502
|
+
id,
|
|
24503
|
+
value: value || [],
|
|
24504
|
+
onChange,
|
|
24505
|
+
readOnly,
|
|
24506
|
+
...fieldOptions
|
|
24507
|
+
}
|
|
24508
|
+
) }) })
|
|
24509
|
+
};
|
|
24510
|
+
};
|
|
24157
24511
|
|
|
24158
24512
|
// src/utils/index.ts
|
|
24159
24513
|
function hexToHsl(hex) {
|
|
@@ -24313,6 +24667,7 @@ lucide-react/dist/esm/context.js:
|
|
|
24313
24667
|
lucide-react/dist/esm/Icon.js:
|
|
24314
24668
|
lucide-react/dist/esm/createLucideIcon.js:
|
|
24315
24669
|
lucide-react/dist/esm/icons/check.js:
|
|
24670
|
+
lucide-react/dist/esm/icons/chevron-down.js:
|
|
24316
24671
|
lucide-react/dist/esm/icons/chevron-right.js:
|
|
24317
24672
|
lucide-react/dist/esm/icons/code.js:
|
|
24318
24673
|
lucide-react/dist/esm/icons/copy.js:
|
|
@@ -24321,12 +24676,14 @@ lucide-react/dist/esm/icons/file-text.js:
|
|
|
24321
24676
|
lucide-react/dist/esm/icons/file.js:
|
|
24322
24677
|
lucide-react/dist/esm/icons/folder-open.js:
|
|
24323
24678
|
lucide-react/dist/esm/icons/globe.js:
|
|
24679
|
+
lucide-react/dist/esm/icons/grip-vertical.js:
|
|
24324
24680
|
lucide-react/dist/esm/icons/image-plus.js:
|
|
24325
24681
|
lucide-react/dist/esm/icons/image.js:
|
|
24326
24682
|
lucide-react/dist/esm/icons/languages.js:
|
|
24327
24683
|
lucide-react/dist/esm/icons/link.js:
|
|
24328
24684
|
lucide-react/dist/esm/icons/loader-circle.js:
|
|
24329
24685
|
lucide-react/dist/esm/icons/pencil.js:
|
|
24686
|
+
lucide-react/dist/esm/icons/plus.js:
|
|
24330
24687
|
lucide-react/dist/esm/icons/refresh-ccw.js:
|
|
24331
24688
|
lucide-react/dist/esm/icons/rotate-ccw.js:
|
|
24332
24689
|
lucide-react/dist/esm/icons/search.js:
|
|
@@ -24416,6 +24773,6 @@ filepond-plugin-image-edit/dist/filepond-plugin-image-edit.esm.js:
|
|
|
24416
24773
|
*)
|
|
24417
24774
|
*/
|
|
24418
24775
|
|
|
24419
|
-
export { CodeEditorField, ColorField, EditorField, FieldErrorBoundary, LanguageField, LinkField, TecofApiClient, TecofEditor, TecofPicture, TecofProvider, TecofRender, UploadField, createCodeEditorField, createColorField, createEditorField, createLanguageField, createLinkField, createUploadField, darken, generateCSSVariables, getDefaultTheme, hexToHsl, hslToHex, lighten, mergeTheme, useTecof };
|
|
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 };
|
|
24420
24777
|
//# sourceMappingURL=index.mjs.map
|
|
24421
24778
|
//# sourceMappingURL=index.mjs.map
|