@tecof/theme-editor 0.0.21 → 0.0.23
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 +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +87 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +87 -30
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +9 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -206,6 +206,14 @@ declare class TecofApiClient {
|
|
|
206
206
|
code: string;
|
|
207
207
|
value: string;
|
|
208
208
|
}[]>>;
|
|
209
|
+
/**
|
|
210
|
+
* Get a component preview screenshot as a Blob URL.
|
|
211
|
+
* Calls POST /api/store/component-preview with domain + componentName.
|
|
212
|
+
* Returns a blob:// URL that can be used as an img src.
|
|
213
|
+
* Results are cached client-side in a Map.
|
|
214
|
+
*/
|
|
215
|
+
private previewBlobCache;
|
|
216
|
+
getComponentPreview(domain: string, componentName: string): Promise<string | null>;
|
|
209
217
|
/** CDN base URL (defaults to apiUrl if not set) */
|
|
210
218
|
get cdnUrl(): string;
|
|
211
219
|
}
|
|
@@ -312,6 +320,7 @@ interface LanguageFieldOptions {
|
|
|
312
320
|
declare const LanguageField: ({ value, onChange, readOnly, isTextarea, textareaRows, placeholder, isHtml, }: LanguageFieldProps & LanguageFieldOptions) => react_jsx_runtime.JSX.Element | null;
|
|
313
321
|
declare const createLanguageField: (options?: LanguageFieldOptions) => {
|
|
314
322
|
type: "custom";
|
|
323
|
+
_fieldType: "language";
|
|
315
324
|
label: string | undefined;
|
|
316
325
|
labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
|
|
317
326
|
visible: boolean | undefined;
|
|
@@ -368,6 +377,7 @@ declare const EditorField: ({ value, onChange, readOnly, }: EditorFieldProps & E
|
|
|
368
377
|
*/
|
|
369
378
|
declare const createEditorField: (options?: EditorFieldOptions) => {
|
|
370
379
|
type: "custom";
|
|
380
|
+
_fieldType: "editor";
|
|
371
381
|
label: string | undefined;
|
|
372
382
|
labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
|
|
373
383
|
visible: boolean | undefined;
|
|
@@ -417,6 +427,7 @@ declare const UploadField: {
|
|
|
417
427
|
};
|
|
418
428
|
declare const createUploadField: (options?: UploadFieldOptions) => {
|
|
419
429
|
type: "custom";
|
|
430
|
+
_fieldType: "upload";
|
|
420
431
|
label: string | undefined;
|
|
421
432
|
labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
|
|
422
433
|
visible: boolean | undefined;
|
|
@@ -473,6 +484,7 @@ declare const CodeEditorField: react__default.ForwardRefExoticComponent<CodeEdit
|
|
|
473
484
|
*/
|
|
474
485
|
declare const createCodeEditorField: (options?: CodeEditorFieldOptions) => {
|
|
475
486
|
type: "custom";
|
|
487
|
+
_fieldType: "code";
|
|
476
488
|
label: string | undefined;
|
|
477
489
|
labelIcon: ReactElement<unknown, string | react__default.JSXElementConstructor<any>> | undefined;
|
|
478
490
|
visible: boolean | undefined;
|
|
@@ -505,6 +517,7 @@ declare const LinkField: {
|
|
|
505
517
|
};
|
|
506
518
|
declare const createLinkField: (options?: LinkFieldOptions) => {
|
|
507
519
|
type: "custom";
|
|
520
|
+
_fieldType: "link";
|
|
508
521
|
label: string | undefined;
|
|
509
522
|
labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
|
|
510
523
|
visible: boolean | undefined;
|
|
@@ -558,6 +571,7 @@ declare const ColorField: {
|
|
|
558
571
|
*/
|
|
559
572
|
declare const createColorField: (options?: ColorFieldOptions) => {
|
|
560
573
|
type: "custom";
|
|
574
|
+
_fieldType: "color";
|
|
561
575
|
label: string | undefined;
|
|
562
576
|
labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
|
|
563
577
|
visible: boolean | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -206,6 +206,14 @@ declare class TecofApiClient {
|
|
|
206
206
|
code: string;
|
|
207
207
|
value: string;
|
|
208
208
|
}[]>>;
|
|
209
|
+
/**
|
|
210
|
+
* Get a component preview screenshot as a Blob URL.
|
|
211
|
+
* Calls POST /api/store/component-preview with domain + componentName.
|
|
212
|
+
* Returns a blob:// URL that can be used as an img src.
|
|
213
|
+
* Results are cached client-side in a Map.
|
|
214
|
+
*/
|
|
215
|
+
private previewBlobCache;
|
|
216
|
+
getComponentPreview(domain: string, componentName: string): Promise<string | null>;
|
|
209
217
|
/** CDN base URL (defaults to apiUrl if not set) */
|
|
210
218
|
get cdnUrl(): string;
|
|
211
219
|
}
|
|
@@ -312,6 +320,7 @@ interface LanguageFieldOptions {
|
|
|
312
320
|
declare const LanguageField: ({ value, onChange, readOnly, isTextarea, textareaRows, placeholder, isHtml, }: LanguageFieldProps & LanguageFieldOptions) => react_jsx_runtime.JSX.Element | null;
|
|
313
321
|
declare const createLanguageField: (options?: LanguageFieldOptions) => {
|
|
314
322
|
type: "custom";
|
|
323
|
+
_fieldType: "language";
|
|
315
324
|
label: string | undefined;
|
|
316
325
|
labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
|
|
317
326
|
visible: boolean | undefined;
|
|
@@ -368,6 +377,7 @@ declare const EditorField: ({ value, onChange, readOnly, }: EditorFieldProps & E
|
|
|
368
377
|
*/
|
|
369
378
|
declare const createEditorField: (options?: EditorFieldOptions) => {
|
|
370
379
|
type: "custom";
|
|
380
|
+
_fieldType: "editor";
|
|
371
381
|
label: string | undefined;
|
|
372
382
|
labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
|
|
373
383
|
visible: boolean | undefined;
|
|
@@ -417,6 +427,7 @@ declare const UploadField: {
|
|
|
417
427
|
};
|
|
418
428
|
declare const createUploadField: (options?: UploadFieldOptions) => {
|
|
419
429
|
type: "custom";
|
|
430
|
+
_fieldType: "upload";
|
|
420
431
|
label: string | undefined;
|
|
421
432
|
labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
|
|
422
433
|
visible: boolean | undefined;
|
|
@@ -473,6 +484,7 @@ declare const CodeEditorField: react__default.ForwardRefExoticComponent<CodeEdit
|
|
|
473
484
|
*/
|
|
474
485
|
declare const createCodeEditorField: (options?: CodeEditorFieldOptions) => {
|
|
475
486
|
type: "custom";
|
|
487
|
+
_fieldType: "code";
|
|
476
488
|
label: string | undefined;
|
|
477
489
|
labelIcon: ReactElement<unknown, string | react__default.JSXElementConstructor<any>> | undefined;
|
|
478
490
|
visible: boolean | undefined;
|
|
@@ -505,6 +517,7 @@ declare const LinkField: {
|
|
|
505
517
|
};
|
|
506
518
|
declare const createLinkField: (options?: LinkFieldOptions) => {
|
|
507
519
|
type: "custom";
|
|
520
|
+
_fieldType: "link";
|
|
508
521
|
label: string | undefined;
|
|
509
522
|
labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
|
|
510
523
|
visible: boolean | undefined;
|
|
@@ -558,6 +571,7 @@ declare const ColorField: {
|
|
|
558
571
|
*/
|
|
559
572
|
declare const createColorField: (options?: ColorFieldOptions) => {
|
|
560
573
|
type: "custom";
|
|
574
|
+
_fieldType: "color";
|
|
561
575
|
label: string | undefined;
|
|
562
576
|
labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
|
|
563
577
|
visible: boolean | undefined;
|
package/dist/index.js
CHANGED
|
@@ -65,6 +65,13 @@ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
|
65
65
|
// src/api.ts
|
|
66
66
|
var TecofApiClient = class {
|
|
67
67
|
constructor(apiUrl, secretKey, customCdnUrl) {
|
|
68
|
+
/**
|
|
69
|
+
* Get a component preview screenshot as a Blob URL.
|
|
70
|
+
* Calls POST /api/store/component-preview with domain + componentName.
|
|
71
|
+
* Returns a blob:// URL that can be used as an img src.
|
|
72
|
+
* Results are cached client-side in a Map.
|
|
73
|
+
*/
|
|
74
|
+
this.previewBlobCache = /* @__PURE__ */ new Map();
|
|
68
75
|
this.apiUrl = apiUrl.replace(/\/+$/, "");
|
|
69
76
|
this.secretKey = secretKey;
|
|
70
77
|
this.customCdnUrl = customCdnUrl ? customCdnUrl.replace(/\/+$/, "") : void 0;
|
|
@@ -228,6 +235,30 @@ var TecofApiClient = class {
|
|
|
228
235
|
};
|
|
229
236
|
}
|
|
230
237
|
}
|
|
238
|
+
async getComponentPreview(domain, componentName) {
|
|
239
|
+
const cacheKey = `${domain}:${componentName}`;
|
|
240
|
+
if (this.previewBlobCache.has(cacheKey)) {
|
|
241
|
+
return this.previewBlobCache.get(cacheKey);
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
const res2 = await fetch(`${this.apiUrl}/api/store/component-preview`, {
|
|
245
|
+
method: "POST",
|
|
246
|
+
headers: {
|
|
247
|
+
"x-secret-key": this.secretKey,
|
|
248
|
+
Accept: "image/png",
|
|
249
|
+
"Content-Type": "application/json"
|
|
250
|
+
},
|
|
251
|
+
body: JSON.stringify({ domain, componentName })
|
|
252
|
+
});
|
|
253
|
+
if (!res2.ok) return null;
|
|
254
|
+
const blob2 = await res2.blob();
|
|
255
|
+
const blobUrl = URL.createObjectURL(blob2);
|
|
256
|
+
this.previewBlobCache.set(cacheKey, blobUrl);
|
|
257
|
+
return blobUrl;
|
|
258
|
+
} catch {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
231
262
|
/** CDN base URL (defaults to apiUrl if not set) */
|
|
232
263
|
get cdnUrl() {
|
|
233
264
|
return this.customCdnUrl || this.apiUrl;
|
|
@@ -254,6 +285,55 @@ function useTecof() {
|
|
|
254
285
|
return ctx;
|
|
255
286
|
}
|
|
256
287
|
var EMPTY_PAGE = { content: [], root: { props: {} }, zones: {} };
|
|
288
|
+
var ComponentDrawerItem = ({
|
|
289
|
+
name: name3,
|
|
290
|
+
apiClient,
|
|
291
|
+
children
|
|
292
|
+
}) => {
|
|
293
|
+
const [imgSrc, setImgSrc] = React__default.useState(null);
|
|
294
|
+
const [loading, setLoading] = React__default.useState(false);
|
|
295
|
+
const [error2, setError] = React__default.useState(false);
|
|
296
|
+
const fetchedRef = React__default.useRef(false);
|
|
297
|
+
const handleMouseEnter = React__default.useCallback(async () => {
|
|
298
|
+
if (fetchedRef.current) return;
|
|
299
|
+
fetchedRef.current = true;
|
|
300
|
+
setLoading(true);
|
|
301
|
+
try {
|
|
302
|
+
const domain = typeof window !== "undefined" ? window.location.hostname : "";
|
|
303
|
+
const blobUrl = await apiClient.getComponentPreview(domain, name3);
|
|
304
|
+
if (blobUrl) {
|
|
305
|
+
setImgSrc(blobUrl);
|
|
306
|
+
} else {
|
|
307
|
+
setError(true);
|
|
308
|
+
}
|
|
309
|
+
} catch {
|
|
310
|
+
setError(true);
|
|
311
|
+
} finally {
|
|
312
|
+
setLoading(false);
|
|
313
|
+
}
|
|
314
|
+
}, [name3, apiClient]);
|
|
315
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-drawer-item-group group", onMouseEnter: handleMouseEnter, children: [
|
|
316
|
+
children,
|
|
317
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-drawer-popover", children: [
|
|
318
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-drawer-popover-header", children: [
|
|
319
|
+
name3,
|
|
320
|
+
" \xD6nizleme"
|
|
321
|
+
] }),
|
|
322
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-drawer-popover-body", children: [
|
|
323
|
+
(loading || !imgSrc && !error2) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-drawer-skeleton" }),
|
|
324
|
+
imgSrc && /* @__PURE__ */ jsxRuntime.jsx(
|
|
325
|
+
"img",
|
|
326
|
+
{
|
|
327
|
+
src: imgSrc,
|
|
328
|
+
alt: `${name3} preview`,
|
|
329
|
+
className: "tecof-drawer-img"
|
|
330
|
+
}
|
|
331
|
+
),
|
|
332
|
+
error2 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-drawer-preview-error", children: "\xD6nizleme y\xFCklenemedi" })
|
|
333
|
+
] })
|
|
334
|
+
] })
|
|
335
|
+
] });
|
|
336
|
+
};
|
|
257
337
|
var TecofEditor = ({
|
|
258
338
|
pageId,
|
|
259
339
|
config: config3,
|
|
@@ -395,36 +475,7 @@ var TecofEditor = ({
|
|
|
395
475
|
const mergedOverrides = {
|
|
396
476
|
header: () => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {}),
|
|
397
477
|
drawerItem: ({ children, name: name3 }) => {
|
|
398
|
-
|
|
399
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-drawer-item-group group", children: [
|
|
400
|
-
children,
|
|
401
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-drawer-popover", children: [
|
|
402
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-drawer-popover-header", children: [
|
|
403
|
-
name3,
|
|
404
|
-
" \xD6nizleme"
|
|
405
|
-
] }),
|
|
406
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tecof-drawer-popover-body", children: [
|
|
407
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "tecof-drawer-skeleton" }),
|
|
408
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
409
|
-
"img",
|
|
410
|
-
{
|
|
411
|
-
src: `/api/screenshot?componentName=${name3}&token=${token}`,
|
|
412
|
-
alt: `${name3} preview`,
|
|
413
|
-
className: "tecof-drawer-img",
|
|
414
|
-
onLoad: (e3) => {
|
|
415
|
-
const loader2 = e3.currentTarget.previousElementSibling;
|
|
416
|
-
if (loader2) loader2.remove();
|
|
417
|
-
},
|
|
418
|
-
onError: (e3) => {
|
|
419
|
-
const loader2 = e3.currentTarget.previousElementSibling;
|
|
420
|
-
if (loader2) loader2.remove();
|
|
421
|
-
e3.currentTarget.style.display = "none";
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
)
|
|
425
|
-
] })
|
|
426
|
-
] })
|
|
427
|
-
] });
|
|
478
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ComponentDrawerItem, { name: name3, apiClient, children });
|
|
428
479
|
},
|
|
429
480
|
...overrides || {}
|
|
430
481
|
};
|
|
@@ -1067,6 +1118,7 @@ var createLanguageField = (options = {}) => {
|
|
|
1067
1118
|
const { label, labelIcon, visible, ...fieldOptions } = options;
|
|
1068
1119
|
return {
|
|
1069
1120
|
type: "custom",
|
|
1121
|
+
_fieldType: "language",
|
|
1070
1122
|
label,
|
|
1071
1123
|
labelIcon,
|
|
1072
1124
|
visible,
|
|
@@ -1357,6 +1409,7 @@ var createEditorField = (options = {}) => {
|
|
|
1357
1409
|
const { label, labelIcon, visible, ...fieldOptions } = options;
|
|
1358
1410
|
return {
|
|
1359
1411
|
type: "custom",
|
|
1412
|
+
_fieldType: "editor",
|
|
1360
1413
|
label,
|
|
1361
1414
|
labelIcon,
|
|
1362
1415
|
visible,
|
|
@@ -22877,6 +22930,7 @@ var createUploadField = (options = {}) => {
|
|
|
22877
22930
|
const { label, labelIcon, visible, ...fieldOptions } = options;
|
|
22878
22931
|
return {
|
|
22879
22932
|
type: "custom",
|
|
22933
|
+
_fieldType: "upload",
|
|
22880
22934
|
label,
|
|
22881
22935
|
labelIcon,
|
|
22882
22936
|
visible,
|
|
@@ -23571,6 +23625,7 @@ var createCodeEditorField = (options = {}) => {
|
|
|
23571
23625
|
const { label, labelIcon, visible, ...fieldOptions } = options;
|
|
23572
23626
|
return {
|
|
23573
23627
|
type: "custom",
|
|
23628
|
+
_fieldType: "code",
|
|
23574
23629
|
label,
|
|
23575
23630
|
labelIcon,
|
|
23576
23631
|
visible,
|
|
@@ -23813,6 +23868,7 @@ var createLinkField = (options = {}) => {
|
|
|
23813
23868
|
const { label, labelIcon, visible, ...fieldOptions } = options;
|
|
23814
23869
|
return {
|
|
23815
23870
|
type: "custom",
|
|
23871
|
+
_fieldType: "link",
|
|
23816
23872
|
label,
|
|
23817
23873
|
labelIcon,
|
|
23818
23874
|
visible,
|
|
@@ -23993,6 +24049,7 @@ var createColorField = (options = {}) => {
|
|
|
23993
24049
|
const { label, labelIcon, visible, ...fieldOptions } = options;
|
|
23994
24050
|
return {
|
|
23995
24051
|
type: "custom",
|
|
24052
|
+
_fieldType: "color",
|
|
23996
24053
|
label,
|
|
23997
24054
|
labelIcon,
|
|
23998
24055
|
visible,
|