@tecof/theme-editor 0.0.27 → 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.d.mts CHANGED
@@ -111,6 +111,8 @@ interface TecofRenderProps {
111
111
  config: any;
112
112
  /** Additional class name */
113
113
  className?: string;
114
+ /** Raw CMS item data (only present for CMS template pages) */
115
+ cmsData?: Record<string, any> | null;
114
116
  }
115
117
  interface MerchantInfoData {
116
118
  /** Available language codes (e.g. ["tr", "en", "de"]) */
@@ -214,6 +216,21 @@ declare class TecofApiClient {
214
216
  */
215
217
  private previewBlobCache;
216
218
  getComponentPreview(domain: string, componentName: string): Promise<string | null>;
219
+ /**
220
+ * Fetch CMS collections list (for CmsCollectionField)
221
+ * Returns: [{ _id, name, slug, fields, ... }]
222
+ */
223
+ getCmsCollections(): Promise<ApiResponse<any[]>>;
224
+ /**
225
+ * Fetch items from a CMS collection by slug
226
+ * Returns: { items: [...], totalData: N }
227
+ */
228
+ getCmsCollectionItems(collectionSlug: string, options?: {
229
+ page?: number;
230
+ limit?: number;
231
+ sort?: 'newest' | 'oldest';
232
+ locale?: string;
233
+ }): Promise<ApiResponse<any>>;
217
234
  /** CDN base URL (defaults to apiUrl if not set) */
218
235
  get cdnUrl(): string;
219
236
  }
@@ -250,9 +267,12 @@ declare const TecofEditor: ({ pageId, config, accessToken, onSave, onChange, ove
250
267
  * TecofRender — Puck page renderer.
251
268
  *
252
269
  * Pass `data` (PuckPageData) and `config` (Puck Config) directly.
270
+ * Optionally pass `cmsData` to make CMS item data available to all
271
+ * Puck components via `puck.metadata.cmsData`.
272
+ *
253
273
  * No API fetch, no provider required.
254
274
  */
255
- declare const TecofRender: ({ data, config, className }: TecofRenderProps) => react_jsx_runtime.JSX.Element | null;
275
+ declare const TecofRender: ({ data, config, className, cmsData }: TecofRenderProps) => react_jsx_runtime.JSX.Element | null;
256
276
 
257
277
  type PictureSize = 'thumbnail' | 'medium' | 'large' | 'full';
258
278
  interface TecofPictureProps {
@@ -578,6 +598,103 @@ declare const createColorField: (options?: ColorFieldOptions) => {
578
598
  render: ({ value, onChange, readOnly, field, name, id }: ColorFieldProps) => react_jsx_runtime.JSX.Element;
579
599
  };
580
600
 
601
+ interface RepeaterFieldProps {
602
+ field: any;
603
+ name: string;
604
+ id: string;
605
+ value: Record<string, any>[];
606
+ onChange: (value: Record<string, any>[]) => void;
607
+ readOnly?: boolean;
608
+ }
609
+ interface RepeaterFieldOptions {
610
+ /** Field label displayed in the Puck sidebar */
611
+ label?: string;
612
+ /** Icon displayed next to the label */
613
+ labelIcon?: ReactElement;
614
+ /** Whether this field is visible in the sidebar */
615
+ visible?: boolean;
616
+ /** Sub-fields definition — each key maps to a createXxxField() result */
617
+ subFields: Record<string, any>;
618
+ /** Minimum number of rows */
619
+ minItems?: number;
620
+ /** Maximum number of rows */
621
+ maxItems?: number;
622
+ /** Default values for a new row */
623
+ defaultRow?: Record<string, any>;
624
+ }
625
+ declare const RepeaterField: {
626
+ ({ value: rawValue, onChange, readOnly, subFields, minItems, maxItems, defaultRow, }: RepeaterFieldProps & RepeaterFieldOptions): react_jsx_runtime.JSX.Element;
627
+ displayName: string;
628
+ };
629
+ declare const createRepeaterField: (options: RepeaterFieldOptions) => {
630
+ type: "custom";
631
+ _fieldType: "repeater";
632
+ label: string | undefined;
633
+ labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
634
+ visible: boolean | undefined;
635
+ render: ({ value, onChange, readOnly, field, name, id }: RepeaterFieldProps) => react_jsx_runtime.JSX.Element;
636
+ };
637
+
638
+ /** Slot definition: describes a data slot the component needs */
639
+ interface CmsSlotDefinition {
640
+ /** Label shown in the editor (e.g. "Başlık") */
641
+ label: string;
642
+ /** Optional: filter to specific CMS field types */
643
+ fieldTypes?: string[];
644
+ }
645
+ interface CmsCollectionFieldValue {
646
+ /** Selected collection slug */
647
+ collectionSlug: string;
648
+ /** Collection name (for display) */
649
+ collectionName?: string;
650
+ /** Max items to fetch */
651
+ limit?: number;
652
+ /** Sort order */
653
+ sort?: 'newest' | 'oldest';
654
+ /** Field mapping: slotKey → CMS field shortcode */
655
+ fieldMap?: Record<string, string>;
656
+ }
657
+ interface CmsCollectionFieldProps {
658
+ field: any;
659
+ name: string;
660
+ id: string;
661
+ value: CmsCollectionFieldValue | null;
662
+ onChange: (value: CmsCollectionFieldValue | null) => void;
663
+ readOnly?: boolean;
664
+ }
665
+ interface CmsCollectionFieldOptions {
666
+ /** Field label displayed in the Puck sidebar */
667
+ label?: string;
668
+ /** Icon displayed next to the label */
669
+ labelIcon?: ReactElement;
670
+ /** Whether this field is visible in the sidebar */
671
+ visible?: boolean;
672
+ /** Default limit for items */
673
+ defaultLimit?: number;
674
+ /** Show limit control */
675
+ showLimit?: boolean;
676
+ /** Show sort control */
677
+ showSort?: boolean;
678
+ /**
679
+ * Mappable slots: defines what data the component needs.
680
+ * Key = slot name used in code, Value = slot definition.
681
+ * Example: { title: { label: "Başlık" }, image: { label: "Görsel" } }
682
+ */
683
+ slots?: Record<string, CmsSlotDefinition>;
684
+ }
685
+ declare const CmsCollectionField: {
686
+ ({ value, onChange, readOnly, defaultLimit, showLimit, showSort, slots, }: CmsCollectionFieldProps & CmsCollectionFieldOptions): react_jsx_runtime.JSX.Element;
687
+ displayName: string;
688
+ };
689
+ declare const createCmsCollectionField: (options?: CmsCollectionFieldOptions) => {
690
+ type: "custom";
691
+ _fieldType: "cmsCollection";
692
+ label: string | undefined;
693
+ labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
694
+ visible: boolean | undefined;
695
+ render: ({ value, onChange, readOnly, field, name, id }: CmsCollectionFieldProps) => react_jsx_runtime.JSX.Element;
696
+ };
697
+
581
698
  interface FieldErrorBoundaryProps {
582
699
  /** The field name (for error reporting) */
583
700
  fieldName?: string;
@@ -619,4 +736,4 @@ declare function generateCSSVariables(theme: ThemeConfig): string;
619
736
  declare function getDefaultTheme(): ThemeConfig;
620
737
  declare function mergeTheme(base: ThemeConfig, overrides: Partial<ThemeConfig>): ThemeConfig;
621
738
 
622
- export { type ApiResponse, CodeEditorField, ColorField, EditorField, FieldErrorBoundary, type HSL, LanguageField, type LanguageFieldValue, LinkField, type LinkFieldValue, type MerchantInfoData, type PageApiData, type PuckContentItem, type PuckPageData, TecofApiClient, TecofEditor, type TecofEditorProps, TecofPicture, type TecofPictureProps, TecofProvider, type TecofProviderProps, TecofRender, type TecofRenderProps, type ThemeColors, type ThemeConfig, type ThemeSpacing, type ThemeTypography, UploadField, type UploadedFile, createCodeEditorField, createColorField, createEditorField, createLanguageField, createLinkField, createUploadField, darken, generateCSSVariables, getDefaultTheme, hexToHsl, hslToHex, lighten, mergeTheme, useTecof };
739
+ export { type ApiResponse, CmsCollectionField, CodeEditorField, ColorField, EditorField, FieldErrorBoundary, type HSL, LanguageField, type LanguageFieldValue, LinkField, type LinkFieldValue, type MerchantInfoData, type PageApiData, type PuckContentItem, type PuckPageData, RepeaterField, TecofApiClient, TecofEditor, type TecofEditorProps, TecofPicture, type TecofPictureProps, TecofProvider, type TecofProviderProps, TecofRender, type TecofRenderProps, type ThemeColors, type ThemeConfig, type ThemeSpacing, type ThemeTypography, UploadField, type UploadedFile, createCmsCollectionField, createCodeEditorField, createColorField, createEditorField, createLanguageField, createLinkField, createRepeaterField, createUploadField, darken, generateCSSVariables, getDefaultTheme, hexToHsl, hslToHex, lighten, mergeTheme, useTecof };
package/dist/index.d.ts CHANGED
@@ -111,6 +111,8 @@ interface TecofRenderProps {
111
111
  config: any;
112
112
  /** Additional class name */
113
113
  className?: string;
114
+ /** Raw CMS item data (only present for CMS template pages) */
115
+ cmsData?: Record<string, any> | null;
114
116
  }
115
117
  interface MerchantInfoData {
116
118
  /** Available language codes (e.g. ["tr", "en", "de"]) */
@@ -214,6 +216,21 @@ declare class TecofApiClient {
214
216
  */
215
217
  private previewBlobCache;
216
218
  getComponentPreview(domain: string, componentName: string): Promise<string | null>;
219
+ /**
220
+ * Fetch CMS collections list (for CmsCollectionField)
221
+ * Returns: [{ _id, name, slug, fields, ... }]
222
+ */
223
+ getCmsCollections(): Promise<ApiResponse<any[]>>;
224
+ /**
225
+ * Fetch items from a CMS collection by slug
226
+ * Returns: { items: [...], totalData: N }
227
+ */
228
+ getCmsCollectionItems(collectionSlug: string, options?: {
229
+ page?: number;
230
+ limit?: number;
231
+ sort?: 'newest' | 'oldest';
232
+ locale?: string;
233
+ }): Promise<ApiResponse<any>>;
217
234
  /** CDN base URL (defaults to apiUrl if not set) */
218
235
  get cdnUrl(): string;
219
236
  }
@@ -250,9 +267,12 @@ declare const TecofEditor: ({ pageId, config, accessToken, onSave, onChange, ove
250
267
  * TecofRender — Puck page renderer.
251
268
  *
252
269
  * Pass `data` (PuckPageData) and `config` (Puck Config) directly.
270
+ * Optionally pass `cmsData` to make CMS item data available to all
271
+ * Puck components via `puck.metadata.cmsData`.
272
+ *
253
273
  * No API fetch, no provider required.
254
274
  */
255
- declare const TecofRender: ({ data, config, className }: TecofRenderProps) => react_jsx_runtime.JSX.Element | null;
275
+ declare const TecofRender: ({ data, config, className, cmsData }: TecofRenderProps) => react_jsx_runtime.JSX.Element | null;
256
276
 
257
277
  type PictureSize = 'thumbnail' | 'medium' | 'large' | 'full';
258
278
  interface TecofPictureProps {
@@ -578,6 +598,103 @@ declare const createColorField: (options?: ColorFieldOptions) => {
578
598
  render: ({ value, onChange, readOnly, field, name, id }: ColorFieldProps) => react_jsx_runtime.JSX.Element;
579
599
  };
580
600
 
601
+ interface RepeaterFieldProps {
602
+ field: any;
603
+ name: string;
604
+ id: string;
605
+ value: Record<string, any>[];
606
+ onChange: (value: Record<string, any>[]) => void;
607
+ readOnly?: boolean;
608
+ }
609
+ interface RepeaterFieldOptions {
610
+ /** Field label displayed in the Puck sidebar */
611
+ label?: string;
612
+ /** Icon displayed next to the label */
613
+ labelIcon?: ReactElement;
614
+ /** Whether this field is visible in the sidebar */
615
+ visible?: boolean;
616
+ /** Sub-fields definition — each key maps to a createXxxField() result */
617
+ subFields: Record<string, any>;
618
+ /** Minimum number of rows */
619
+ minItems?: number;
620
+ /** Maximum number of rows */
621
+ maxItems?: number;
622
+ /** Default values for a new row */
623
+ defaultRow?: Record<string, any>;
624
+ }
625
+ declare const RepeaterField: {
626
+ ({ value: rawValue, onChange, readOnly, subFields, minItems, maxItems, defaultRow, }: RepeaterFieldProps & RepeaterFieldOptions): react_jsx_runtime.JSX.Element;
627
+ displayName: string;
628
+ };
629
+ declare const createRepeaterField: (options: RepeaterFieldOptions) => {
630
+ type: "custom";
631
+ _fieldType: "repeater";
632
+ label: string | undefined;
633
+ labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
634
+ visible: boolean | undefined;
635
+ render: ({ value, onChange, readOnly, field, name, id }: RepeaterFieldProps) => react_jsx_runtime.JSX.Element;
636
+ };
637
+
638
+ /** Slot definition: describes a data slot the component needs */
639
+ interface CmsSlotDefinition {
640
+ /** Label shown in the editor (e.g. "Başlık") */
641
+ label: string;
642
+ /** Optional: filter to specific CMS field types */
643
+ fieldTypes?: string[];
644
+ }
645
+ interface CmsCollectionFieldValue {
646
+ /** Selected collection slug */
647
+ collectionSlug: string;
648
+ /** Collection name (for display) */
649
+ collectionName?: string;
650
+ /** Max items to fetch */
651
+ limit?: number;
652
+ /** Sort order */
653
+ sort?: 'newest' | 'oldest';
654
+ /** Field mapping: slotKey → CMS field shortcode */
655
+ fieldMap?: Record<string, string>;
656
+ }
657
+ interface CmsCollectionFieldProps {
658
+ field: any;
659
+ name: string;
660
+ id: string;
661
+ value: CmsCollectionFieldValue | null;
662
+ onChange: (value: CmsCollectionFieldValue | null) => void;
663
+ readOnly?: boolean;
664
+ }
665
+ interface CmsCollectionFieldOptions {
666
+ /** Field label displayed in the Puck sidebar */
667
+ label?: string;
668
+ /** Icon displayed next to the label */
669
+ labelIcon?: ReactElement;
670
+ /** Whether this field is visible in the sidebar */
671
+ visible?: boolean;
672
+ /** Default limit for items */
673
+ defaultLimit?: number;
674
+ /** Show limit control */
675
+ showLimit?: boolean;
676
+ /** Show sort control */
677
+ showSort?: boolean;
678
+ /**
679
+ * Mappable slots: defines what data the component needs.
680
+ * Key = slot name used in code, Value = slot definition.
681
+ * Example: { title: { label: "Başlık" }, image: { label: "Görsel" } }
682
+ */
683
+ slots?: Record<string, CmsSlotDefinition>;
684
+ }
685
+ declare const CmsCollectionField: {
686
+ ({ value, onChange, readOnly, defaultLimit, showLimit, showSort, slots, }: CmsCollectionFieldProps & CmsCollectionFieldOptions): react_jsx_runtime.JSX.Element;
687
+ displayName: string;
688
+ };
689
+ declare const createCmsCollectionField: (options?: CmsCollectionFieldOptions) => {
690
+ type: "custom";
691
+ _fieldType: "cmsCollection";
692
+ label: string | undefined;
693
+ labelIcon: ReactElement<unknown, string | react.JSXElementConstructor<any>> | undefined;
694
+ visible: boolean | undefined;
695
+ render: ({ value, onChange, readOnly, field, name, id }: CmsCollectionFieldProps) => react_jsx_runtime.JSX.Element;
696
+ };
697
+
581
698
  interface FieldErrorBoundaryProps {
582
699
  /** The field name (for error reporting) */
583
700
  fieldName?: string;
@@ -619,4 +736,4 @@ declare function generateCSSVariables(theme: ThemeConfig): string;
619
736
  declare function getDefaultTheme(): ThemeConfig;
620
737
  declare function mergeTheme(base: ThemeConfig, overrides: Partial<ThemeConfig>): ThemeConfig;
621
738
 
622
- export { type ApiResponse, CodeEditorField, ColorField, EditorField, FieldErrorBoundary, type HSL, LanguageField, type LanguageFieldValue, LinkField, type LinkFieldValue, type MerchantInfoData, type PageApiData, type PuckContentItem, type PuckPageData, TecofApiClient, TecofEditor, type TecofEditorProps, TecofPicture, type TecofPictureProps, TecofProvider, type TecofProviderProps, TecofRender, type TecofRenderProps, type ThemeColors, type ThemeConfig, type ThemeSpacing, type ThemeTypography, UploadField, type UploadedFile, createCodeEditorField, createColorField, createEditorField, createLanguageField, createLinkField, createUploadField, darken, generateCSSVariables, getDefaultTheme, hexToHsl, hslToHex, lighten, mergeTheme, useTecof };
739
+ export { type ApiResponse, CmsCollectionField, CodeEditorField, ColorField, EditorField, FieldErrorBoundary, type HSL, LanguageField, type LanguageFieldValue, LinkField, type LinkFieldValue, type MerchantInfoData, type PageApiData, type PuckContentItem, type PuckPageData, RepeaterField, TecofApiClient, TecofEditor, type TecofEditorProps, TecofPicture, type TecofPictureProps, TecofProvider, type TecofProviderProps, TecofRender, type TecofRenderProps, type ThemeColors, type ThemeConfig, type ThemeSpacing, type ThemeTypography, UploadField, type UploadedFile, createCmsCollectionField, createCodeEditorField, createColorField, createEditorField, createLanguageField, createLinkField, createRepeaterField, createUploadField, darken, generateCSSVariables, getDefaultTheme, hexToHsl, hslToHex, lighten, mergeTheme, useTecof };