@mandolop97/constructor-nexora 1.0.7 → 1.0.9

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.
@@ -1,5 +1,18 @@
1
- import { NodeType, NodeProps, NodeStyle } from '@/types/schema';
1
+ import { NodeType, NodeProps, NodeStyle, TemplateType } from '@/types/schema';
2
2
  import React from 'react';
3
+ export interface InspectorFieldDef {
4
+ /** Property key on NodeProps */
5
+ key: string;
6
+ /** Display label */
7
+ label: string;
8
+ /** Field type: text input, select dropdown, or color picker */
9
+ type: 'text' | 'select' | 'color' | 'number';
10
+ /** Options for 'select' type */
11
+ options?: {
12
+ label: string;
13
+ value: string;
14
+ }[];
15
+ }
3
16
  export interface BlockDefinition {
4
17
  type: NodeType;
5
18
  label: string;
@@ -20,11 +33,32 @@ export interface BlockDefinition {
20
33
  * Only relevant for canHaveChildren=true blocks.
21
34
  */
22
35
  allowedChildren?: NodeType[];
36
+ /**
37
+ * Custom inspector fields for this block type.
38
+ * When defined, these fields are rendered in the Props tab of the inspector.
39
+ * Only relevant for custom/host-defined blocks.
40
+ */
41
+ inspectorFields?: InspectorFieldDef[];
42
+ /**
43
+ * Restrict this block to specific template types.
44
+ * If undefined or empty, the block appears in all template types.
45
+ */
46
+ allowedTemplateTypes?: TemplateType[];
23
47
  }
24
48
  export declare const blockRegistry: BlockDefinition[];
25
49
  export declare function getBlockDef(type: NodeType): BlockDefinition | undefined;
50
+ /**
51
+ * Register a custom block definition at runtime.
52
+ * It will appear in the blocks palette and support drag-and-drop.
53
+ * If a block with the same type already exists it will be replaced.
54
+ */
55
+ export declare function registerBlock(def: BlockDefinition): void;
56
+ /** Register multiple custom blocks at once. */
57
+ export declare function registerBlocks(defs: BlockDefinition[]): void;
26
58
  export declare function getCategories(): string[];
27
- export declare function getBlocksByCategory(category: string): BlockDefinition[];
59
+ export declare function getBlocksByCategory(category: string, templateType?: TemplateType): BlockDefinition[];
60
+ /** Get categories that have at least one block for the given templateType */
61
+ export declare function getCategoriesForTemplate(templateType?: TemplateType): string[];
28
62
  /**
29
63
  * Check if a child node type can be placed inside a given parent node type.
30
64
  * - If child has allowedParents defined, parent must be in that list OR be the root.
@@ -1,3 +1,11 @@
1
1
  import { SchemaNode, NodeType } from '@/types/schema';
2
2
  export declare function isContainerType(type: NodeType): boolean;
3
3
  export declare function createNode(type: NodeType): SchemaNode;
4
+ /**
5
+ * Deep-clone a node and all its descendants, assigning fresh IDs.
6
+ * Returns a map of all new nodes (keyed by new ID) and the new root ID.
7
+ */
8
+ export declare function duplicateNodeTree(sourceId: string, nodes: Record<string, SchemaNode>): {
9
+ newNodes: Record<string, SchemaNode>;
10
+ newRootId: string;
11
+ };
@@ -1,4 +1,7 @@
1
- export type NodeType = 'Section' | 'Container' | 'Grid' | 'Stack' | 'Text' | 'Image' | 'Divider' | 'Badge' | 'Button' | 'Card' | 'Input' | 'ProductCard' | 'Navbar' | 'Footer' | 'AnnouncementBar' | 'FeatureBar' | 'TestimonialCard' | 'NewsletterSection' | 'HeroSection' | 'Accordion' | 'TabsBlock' | 'VideoEmbed';
1
+ import React from 'react';
2
+ export type BuiltInNodeType = 'Section' | 'Container' | 'Grid' | 'Stack' | 'Text' | 'Image' | 'Divider' | 'Badge' | 'Button' | 'Card' | 'Input' | 'ProductCard' | 'Navbar' | 'Footer' | 'AnnouncementBar' | 'FeatureBar' | 'TestimonialCard' | 'NewsletterSection' | 'HeroSection' | 'Accordion' | 'TabsBlock' | 'VideoEmbed';
3
+ /** Extensible node type — accepts all built-in types plus any custom string. */
4
+ export type NodeType = BuiltInNodeType | (string & {});
2
5
  export interface NodeStyle {
3
6
  padding?: string;
4
7
  margin?: string;
@@ -106,6 +109,8 @@ export interface SchemaNode {
106
109
  children: string[];
107
110
  locked?: boolean;
108
111
  hidden?: boolean;
112
+ /** User-defined custom name for this node (shown in Layers panel) */
113
+ customName?: string;
109
114
  }
110
115
  export interface ThemeTokens {
111
116
  colors: {
@@ -154,5 +159,19 @@ export interface PageDefinition {
154
159
  title: string;
155
160
  schema: Schema;
156
161
  status?: 'published' | 'draft';
162
+ /** Type of template being edited. Determines canvas behavior. */
163
+ templateType?: TemplateType;
164
+ /** Category for grouping in the sidebar (e.g. "Páginas", "Elementos Globales", "Templates") */
165
+ category?: string;
166
+ /** Optional icon component for the page list */
167
+ icon?: React.ComponentType;
168
+ /** Custom canvas dimensions. Overrides templateType defaults. */
169
+ canvasSize?: {
170
+ width: number;
171
+ height: number;
172
+ };
173
+ /** Mock data injected into custom components in edit/preview mode */
174
+ mockData?: Record<string, any>;
157
175
  }
158
176
  export type RenderMode = 'public' | 'preview' | 'edit';
177
+ export type TemplateType = 'page' | 'header' | 'footer' | 'component' | 'single';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mandolop97/constructor-nexora",
3
3
  "private": false,
4
- "version": "1.0.7",
4
+ "version": "1.0.9",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -17,9 +17,7 @@
17
17
  "react": "^18.0.0",
18
18
  "react-dom": "^18.0.0"
19
19
  },
20
- "files": [
21
- "dist"
22
- ],
20
+ "files": ["dist"],
23
21
  "scripts": {
24
22
  "dev": "vite",
25
23
  "build": "vite build",