@tecof/theme-editor 0.0.16 → 0.0.18

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 CHANGED
@@ -123,11 +123,15 @@ interface LanguageFieldValue {
123
123
  value: string;
124
124
  }
125
125
  interface UploadedFile {
126
- _id: string;
126
+ _id?: string;
127
127
  name: string;
128
128
  size: number;
129
129
  type: string;
130
130
  mimeType?: string;
131
+ /** Direct URL for external images (e.g. Freepik stock photos) */
132
+ url?: string;
133
+ folder?: string;
134
+ provider?: string;
131
135
  meta?: {
132
136
  width?: number;
133
137
  height?: number;
@@ -524,10 +528,6 @@ interface ColorFieldOptions {
524
528
  visible?: boolean;
525
529
  /** Show opacity/alpha slider */
526
530
  showOpacity?: boolean;
527
- /** Show preset color palette */
528
- showPresets?: boolean;
529
- /** Custom preset colors (array of hex strings) */
530
- presetColors?: string[];
531
531
  /** Default/fallback color */
532
532
  defaultColor?: string;
533
533
  /** Placeholder text for hex input */
@@ -536,7 +536,7 @@ interface ColorFieldOptions {
536
536
  showReset?: boolean;
537
537
  }
538
538
  declare const ColorField: {
539
- ({ value, onChange, readOnly, showOpacity, showPresets, presetColors, defaultColor, placeholder, showReset, }: ColorFieldProps & ColorFieldOptions): react_jsx_runtime.JSX.Element;
539
+ ({ value, onChange, readOnly, showOpacity, defaultColor, placeholder, showReset, }: ColorFieldProps & ColorFieldOptions): react_jsx_runtime.JSX.Element;
540
540
  displayName: string;
541
541
  };
542
542
  /**
package/dist/index.d.ts CHANGED
@@ -123,11 +123,15 @@ interface LanguageFieldValue {
123
123
  value: string;
124
124
  }
125
125
  interface UploadedFile {
126
- _id: string;
126
+ _id?: string;
127
127
  name: string;
128
128
  size: number;
129
129
  type: string;
130
130
  mimeType?: string;
131
+ /** Direct URL for external images (e.g. Freepik stock photos) */
132
+ url?: string;
133
+ folder?: string;
134
+ provider?: string;
131
135
  meta?: {
132
136
  width?: number;
133
137
  height?: number;
@@ -524,10 +528,6 @@ interface ColorFieldOptions {
524
528
  visible?: boolean;
525
529
  /** Show opacity/alpha slider */
526
530
  showOpacity?: boolean;
527
- /** Show preset color palette */
528
- showPresets?: boolean;
529
- /** Custom preset colors (array of hex strings) */
530
- presetColors?: string[];
531
531
  /** Default/fallback color */
532
532
  defaultColor?: string;
533
533
  /** Placeholder text for hex input */
@@ -536,7 +536,7 @@ interface ColorFieldOptions {
536
536
  showReset?: boolean;
537
537
  }
538
538
  declare const ColorField: {
539
- ({ value, onChange, readOnly, showOpacity, showPresets, presetColors, defaultColor, placeholder, showReset, }: ColorFieldProps & ColorFieldOptions): react_jsx_runtime.JSX.Element;
539
+ ({ value, onChange, readOnly, showOpacity, defaultColor, placeholder, showReset, }: ColorFieldProps & ColorFieldOptions): react_jsx_runtime.JSX.Element;
540
540
  displayName: string;
541
541
  };
542
542
  /**
package/dist/index.js CHANGED
@@ -459,9 +459,11 @@ var TecofPicture = React__default.memo(({
459
459
  const { apiClient } = useTecof();
460
460
  const cdnUrl = apiClient.cdnUrl;
461
461
  if (!data3) return null;
462
- const fileURL = `${cdnUrl}/${data3.name}`;
463
- const isImageType2 = isImage(data3.type);
464
- const isVideoType = isVideo(data3.type);
462
+ const isExternal = data3?.type === "external" || data3?.provider === "external";
463
+ const fileURL = isExternal ? data3?.url || "" : `${cdnUrl}/${data3?.name}`;
464
+ const isImageType2 = isExternal ? true : isImage(data3?.type);
465
+ const isVideoType = isExternal ? false : isVideo(data3?.type);
466
+ if (!fileURL) return null;
465
467
  const imgWidth = width || data3?.meta?.width || 500;
466
468
  const imgHeight = height || data3?.meta?.height || 500;
467
469
  const sizes = getSizes(size);
@@ -13503,8 +13505,8 @@ var getImageTransformsFromRect = function(e3, t2, r2) {
13503
13505
  }
13504
13506
  d = createRect(p.left, p.top, p.right - p.left, p.bottom - p.top);
13505
13507
  }
13506
- var P = rectCorners(d), G = rectCenter(d), k2 = vectorRotate3(P.tl, o2, c2), D2 = vectorRotate3(P.br, o2, c2), U = k2.x + 0.5 * (D2.x - k2.x), B = k2.y + 0.5 * (D2.y - k2.y), V = rectTranslate(d, { x: U - G.x, y: B - G.y }), N = rectTranslate(l3, { x: U - G.x, y: B - G.y }), F = rectCenter(N), z = { x: V.x, y: V.y }, W2 = V.width, q = V.height, H2 = (F.x - z.x) / W2, Y2 = (F.y - z.y) / q, j = W2 / e3.width, X3 = { x: H2 * e3.width, y: Y2 * e3.height }, Z2 = 1 - j, $2 = X3.x * Z2, K2 = X3.y * Z2, Q = { x: z.x + W2 * H2, y: z.y + q * Y2 }, J = vectorRotate3(z, o2, { x: z.x + 0.5 * W2, y: z.y + 0.5 * q }), ee2 = vectorRotate3(z, o2, Q), te2 = J.x - ee2.x, re2 = J.y - ee2.y;
13507
- return { origin: X3, translation: { x: z.x - $2 + te2, y: z.y - K2 + re2 }, scale: j, rotation: r2.rotation };
13508
+ var P = rectCorners(d), G = rectCenter(d), k2 = vectorRotate3(P.tl, o2, c2), D2 = vectorRotate3(P.br, o2, c2), U = k2.x + 0.5 * (D2.x - k2.x), B = k2.y + 0.5 * (D2.y - k2.y), V = rectTranslate(d, { x: U - G.x, y: B - G.y }), N = rectTranslate(l3, { x: U - G.x, y: B - G.y }), F = rectCenter(N), z = { x: V.x, y: V.y }, W2 = V.width, q = V.height, H2 = (F.x - z.x) / W2, Y2 = (F.y - z.y) / q, j = W2 / e3.width, X2 = { x: H2 * e3.width, y: Y2 * e3.height }, Z2 = 1 - j, $2 = X2.x * Z2, K2 = X2.y * Z2, Q = { x: z.x + W2 * H2, y: z.y + q * Y2 }, J = vectorRotate3(z, o2, { x: z.x + 0.5 * W2, y: z.y + 0.5 * q }), ee2 = vectorRotate3(z, o2, Q), te2 = J.x - ee2.x, re2 = J.y - ee2.y;
13509
+ return { origin: X2, translation: { x: z.x - $2 + te2, y: z.y - K2 + re2 }, scale: j, rotation: r2.rotation };
13508
13510
  };
13509
13511
  var getEdgeTargetRect = function(e3, t2, r2, n, i2, o2, a2, c2, l3) {
13510
13512
  var u = o2.left, s2 = o2.right, d = o2.top, p = o2.bottom, f2 = s2 - u, h2 = p - d, g = i2.left, m = i2.right, v2 = i2.top, y = i2.bottom;
@@ -14948,15 +14950,15 @@ var setup = function(e3, t2, r2) {
14948
14950
  u.bindBuffer(u.ARRAY_BUFFER, S2), u.bufferData(u.ARRAY_BUFFER, C2, u.STATIC_DRAW), u.bindBuffer(u.ARRAY_BUFFER, null);
14949
14951
  var O = createProgram(u, imageVertexShader, imageFragmentShader);
14950
14952
  u.useProgram(O);
14951
- var x = u.getUniformLocation(O, "uMatrix"), b = u.getUniformLocation(O, "uTexture"), M = u.getUniformLocation(O, "uTextureSize"), L = u.getUniformLocation(O, "uOverlayColor"), P = u.getUniformLocation(O, "uOverlayLeftTop"), G = u.getUniformLocation(O, "uOverlayRightBottom"), k2 = u.getUniformLocation(O, "uColorOpacity"), D2 = u.getUniformLocation(O, "uColorOffset"), U = u.getUniformLocation(O, "uColorMatrix"), B = u.getAttribLocation(O, "aPosition"), V = u.getAttribLocation(O, "aTexCoord"), N = createTexture(u, b, M, 0, t2), F = t2.width * r2, z = t2.height * r2, W2 = -0.5 * F, q = 0.5 * z, H2 = 0.5 * F, Y2 = -0.5 * z, j = new Float32Array([W2, q, W2, Y2, H2, q, H2, Y2]), X3 = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]), Z2 = j.length / 2, $2 = u.createBuffer();
14953
+ var x = u.getUniformLocation(O, "uMatrix"), b = u.getUniformLocation(O, "uTexture"), M = u.getUniformLocation(O, "uTextureSize"), L = u.getUniformLocation(O, "uOverlayColor"), P = u.getUniformLocation(O, "uOverlayLeftTop"), G = u.getUniformLocation(O, "uOverlayRightBottom"), k2 = u.getUniformLocation(O, "uColorOpacity"), D2 = u.getUniformLocation(O, "uColorOffset"), U = u.getUniformLocation(O, "uColorMatrix"), B = u.getAttribLocation(O, "aPosition"), V = u.getAttribLocation(O, "aTexCoord"), N = createTexture(u, b, M, 0, t2), F = t2.width * r2, z = t2.height * r2, W2 = -0.5 * F, q = 0.5 * z, H2 = 0.5 * F, Y2 = -0.5 * z, j = new Float32Array([W2, q, W2, Y2, H2, q, H2, Y2]), X2 = new Float32Array([0, 0, 0, 1, 1, 0, 1, 1]), Z2 = j.length / 2, $2 = u.createBuffer();
14952
14954
  u.bindBuffer(u.ARRAY_BUFFER, $2), u.bufferData(u.ARRAY_BUFFER, j, u.STATIC_DRAW), u.bindBuffer(u.ARRAY_BUFFER, null);
14953
14955
  var K2 = u.createBuffer();
14954
- u.bindBuffer(u.ARRAY_BUFFER, K2), u.bufferData(u.ARRAY_BUFFER, X3, u.STATIC_DRAW), u.bindBuffer(u.ARRAY_BUFFER, null);
14956
+ u.bindBuffer(u.ARRAY_BUFFER, K2), u.bufferData(u.ARRAY_BUFFER, X2, u.STATIC_DRAW), u.bindBuffer(u.ARRAY_BUFFER, null);
14955
14957
  var Q = 0, J = 0, ee2 = { release: function() {
14956
14958
  e3.width = 1, e3.height = 1;
14957
14959
  }, resize: function(t3, a3) {
14958
14960
  e3.width = t3 * r2, e3.height = a3 * r2, e3.style.width = "".concat(t3, "px"), e3.style.height = "".concat(a3, "px"), n.width = t3 * r2, n.height = a3 * r2, i2.x = 0.5 * n.width, i2.y = 0.5 * n.height, o2 = n.width / n.height, u.viewport(0, 0, u.canvas.width, u.canvas.height);
14959
- }, update: function(e4, l4, E2, C3, b2, M2, F2, z2, W3, q2, H3, Y3, j2, X4, te2, re2, ne2, ie2, oe2) {
14961
+ }, update: function(e4, l4, E2, C3, b2, M2, F2, z2, W3, q2, H3, Y3, j2, X3, te2, re2, ne2, ie2, oe2) {
14960
14962
  var ae2 = H3 ? H3.height * r2 : n.height;
14961
14963
  Q = t2.width * r2, J = t2.height * r2, e4 *= r2, l4 *= r2, E2 *= r2, C3 *= r2;
14962
14964
  var ce = J / 2 / c2 * (n.height / ae2) * -1;
@@ -14964,7 +14966,7 @@ var setup = function(e3, t2, r2) {
14964
14966
  var le2 = 0.5 * Q, ue2 = 0.5 * J;
14965
14967
  e4 -= le2, l4 -= ue2;
14966
14968
  var se2 = z2, de2 = -(i2.x - le2) + E2, pe = i2.y - ue2 - C3, fe2 = mat4.create();
14967
- mat4.perspective(fe2, a2, o2, 1, 2 * -ce), mat4.translate(fe2, [de2, pe, ce]), mat4.translate(fe2, [e4, -l4, 0]), mat4.scale(fe2, [se2, se2, se2]), mat4.rotateZ(fe2, -F2), mat4.translate(fe2, [-e4, l4, 0]), mat4.rotateY(fe2, M2), mat4.rotateX(fe2, b2), u.clearColor(X4[0], X4[1], X4[2], 1), u.clear(u.COLOR_BUFFER_BIT);
14969
+ mat4.perspective(fe2, a2, o2, 1, 2 * -ce), mat4.translate(fe2, [de2, pe, ce]), mat4.translate(fe2, [e4, -l4, 0]), mat4.scale(fe2, [se2, se2, se2]), mat4.rotateZ(fe2, -F2), mat4.translate(fe2, [-e4, l4, 0]), mat4.rotateY(fe2, M2), mat4.rotateX(fe2, b2), u.clearColor(X3[0], X3[1], X3[2], 1), u.clear(u.COLOR_BUFFER_BIT);
14968
14970
  var he2 = Y3.x * r2, ge2 = Y3.y * r2, me2 = Y3.width * r2, ve2 = Y3.height * r2, ye2 = he2, Ee2 = ye2 + me2, Te2 = n.height - ge2, _e2 = n.height - (ge2 + ve2);
14969
14971
  u.useProgram(s2), u.uniform3fv(d, te2), u.uniform3fv(p, re2), u.uniform4fv(v2, oe2.map(function(e5, t3) {
14970
14972
  return t3 < 3 ? e5 / 255 : e5;
@@ -23452,7 +23454,7 @@ function Ve({ defaultValue: e3, defaultLanguage: r2, defaultPath: n, value: t2,
23452
23454
  }, [g], s2), l2(() => {
23453
23455
  d.current?.editor.setTheme(E);
23454
23456
  }, [E], s2);
23455
- let X3 = React__default.useCallback(() => {
23457
+ let X2 = React__default.useCallback(() => {
23456
23458
  if (!(!b.current || !d.current) && !Q.current) {
23457
23459
  U.current(d.current);
23458
23460
  let p = m || n, R = h(d.current, t2 || e3 || "", r2 || a2 || "", p || "");
@@ -23462,8 +23464,8 @@ function Ve({ defaultValue: e3, defaultLanguage: r2, defaultPath: n, value: t2,
23462
23464
  React__default.useEffect(() => {
23463
23465
  s2 && L.current(o2.current, d.current);
23464
23466
  }, [s2]), React__default.useEffect(() => {
23465
- !c2 && !s2 && X3();
23466
- }, [c2, s2, X3]), i2.current = t2, React__default.useEffect(() => {
23467
+ !c2 && !s2 && X2();
23468
+ }, [c2, s2, X2]), i2.current = t2, React__default.useEffect(() => {
23467
23469
  s2 && O && (I.current?.dispose(), I.current = o2.current?.onDidChangeModelContent((p) => {
23468
23470
  B.current || O(o2.current.getValue(), p);
23469
23471
  }));
@@ -23793,74 +23795,6 @@ var createLinkField = (options = {}) => {
23793
23795
  ) })
23794
23796
  };
23795
23797
  };
23796
- var PRESET_COLORS = [
23797
- // Grays
23798
- "#ffffff",
23799
- "#f4f4f5",
23800
- "#d4d4d8",
23801
- "#a1a1aa",
23802
- "#71717a",
23803
- "#3f3f46",
23804
- "#27272a",
23805
- "#18181b",
23806
- "#000000",
23807
- // Reds
23808
- "#fef2f2",
23809
- "#fca5a5",
23810
- "#f87171",
23811
- "#ef4444",
23812
- "#dc2626",
23813
- "#b91c1c",
23814
- // Oranges
23815
- "#fff7ed",
23816
- "#fdba74",
23817
- "#fb923c",
23818
- "#f97316",
23819
- "#ea580c",
23820
- "#c2410c",
23821
- // Yellows
23822
- "#fefce8",
23823
- "#fde047",
23824
- "#facc15",
23825
- "#eab308",
23826
- "#ca8a04",
23827
- "#a16207",
23828
- // Greens
23829
- "#f0fdf4",
23830
- "#86efac",
23831
- "#4ade80",
23832
- "#22c55e",
23833
- "#16a34a",
23834
- "#15803d",
23835
- // Blues
23836
- "#eff6ff",
23837
- "#93c5fd",
23838
- "#60a5fa",
23839
- "#3b82f6",
23840
- "#2563eb",
23841
- "#1d4ed8",
23842
- // Indigos
23843
- "#eef2ff",
23844
- "#a5b4fc",
23845
- "#818cf8",
23846
- "#6366f1",
23847
- "#4f46e5",
23848
- "#4338ca",
23849
- // Purples
23850
- "#faf5ff",
23851
- "#d8b4fe",
23852
- "#c084fc",
23853
- "#a855f7",
23854
- "#9333ea",
23855
- "#7e22ce",
23856
- // Pinks
23857
- "#fdf2f8",
23858
- "#f9a8d4",
23859
- "#f472b6",
23860
- "#ec4899",
23861
- "#db2777",
23862
- "#be185d"
23863
- ];
23864
23798
  var isValidHex = (hex) => /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(hex);
23865
23799
  var normalizeHex = (hex) => {
23866
23800
  if (!hex) return "";
@@ -23875,8 +23809,6 @@ var ColorField = ({
23875
23809
  onChange,
23876
23810
  readOnly,
23877
23811
  showOpacity = false,
23878
- showPresets = true,
23879
- presetColors = PRESET_COLORS,
23880
23812
  defaultColor = "",
23881
23813
  placeholder = "#000000",
23882
23814
  showReset = true
@@ -23938,13 +23870,6 @@ var ColorField = ({
23938
23870
  },
23939
23871
  [applyColor]
23940
23872
  );
23941
- const handlePresetClick = React__default.useCallback(
23942
- (color) => {
23943
- setHexInput(color);
23944
- applyColor(color);
23945
- },
23946
- [applyColor]
23947
- );
23948
23873
  const handleOpacityChange = React__default.useCallback(
23949
23874
  (e3) => {
23950
23875
  const op = parseInt(e3.target.value, 10);
@@ -24025,24 +23950,6 @@ var ColorField = ({
24025
23950
  opacity,
24026
23951
  "%"
24027
23952
  ] })
24028
- ] }),
24029
- showPresets && presetColors.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
24030
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "tecof-color-section-label", children: "Haz\u0131r Renkler" }),
24031
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-color-preset-grid", children: presetColors.map((color, idx) => {
24032
- const selected = currentColor?.toLowerCase() === color.toLowerCase();
24033
- return /* @__PURE__ */ jsxRuntime.jsx(
24034
- "button",
24035
- {
24036
- type: "button",
24037
- className: `tecof-color-preset-swatch ${selected ? "selected" : ""} ${color.toLowerCase() === "#ffffff" ? "is-white" : ""}`,
24038
- style: { background: color },
24039
- onClick: () => !readOnly && handlePresetClick(color),
24040
- title: color,
24041
- disabled: readOnly
24042
- },
24043
- `${color}-${idx}`
24044
- );
24045
- }) })
24046
23953
  ] })
24047
23954
  ] });
24048
23955
  };