@mandolop97/constructor-nexora 1.3.1 → 1.7.0

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.
Files changed (39) hide show
  1. package/dist/NexoraBuilderApp.d.ts +8 -1
  2. package/dist/components/builder/ArrayEditor.d.ts +27 -0
  3. package/dist/components/builder/BindingsPanel.d.ts +7 -0
  4. package/dist/components/builder/BuilderCanvas.d.ts +10 -1
  5. package/dist/components/builder/BuilderEditorShell.d.ts +8 -1
  6. package/dist/components/builder/Inspector.d.ts +5 -2
  7. package/dist/components/builder/ThemeEditor.d.ts +4 -2
  8. package/dist/components/schema/NodeRegistry.d.ts +3 -1
  9. package/dist/components/schema/PageRenderer.d.ts +10 -1
  10. package/dist/components/schema/ScrollAnimationWrapper.d.ts +10 -0
  11. package/dist/components/schema/SortableNodeWrapper.d.ts +4 -1
  12. package/dist/components/schema/ThemeContext.d.ts +3 -0
  13. package/dist/components/schema/nodes/CommerceNodes.d.ts +3 -0
  14. package/dist/components/schema/nodes/TemplateNodes.d.ts +5 -0
  15. package/dist/components/ui/badge.d.ts +1 -1
  16. package/dist/components/ui/button.d.ts +2 -2
  17. package/dist/components/ui/resizable.d.ts +1 -1
  18. package/dist/components/ui/sheet.d.ts +1 -1
  19. package/dist/components/ui/sidebar.d.ts +1 -1
  20. package/dist/components/ui/toggle-group.d.ts +2 -2
  21. package/dist/components/ui/toggle.d.ts +2 -2
  22. package/dist/{index-7fNEj0ds.js → index-BPfPxgpF.js} +11889 -9283
  23. package/dist/index.css +1 -1
  24. package/dist/index.d.ts +14 -1
  25. package/dist/index.js +81 -40
  26. package/dist/lib/binding-utils.d.ts +51 -0
  27. package/dist/lib/block-registry.d.ts +30 -4
  28. package/dist/lib/card-template-utils.d.ts +35 -0
  29. package/dist/lib/host-data.d.ts +69 -0
  30. package/dist/lib/mock-data.d.ts +5 -0
  31. package/dist/lib/publish-validator.d.ts +33 -0
  32. package/dist/lib/render-context-utils.d.ts +55 -0
  33. package/dist/lib/slot-utils.d.ts +66 -0
  34. package/dist/lib/style-utils.d.ts +13 -0
  35. package/dist/{lucide-react-xAdwTOxQ.js → lucide-react-D6zDllQb.js} +8214 -8313
  36. package/dist/types/contract.d.ts +475 -0
  37. package/dist/types/page-types.d.ts +65 -0
  38. package/dist/types/schema.d.ts +21 -1
  39. package/package.json +1 -1
@@ -1,12 +1,20 @@
1
- import { NodeType, NodeProps, NodeStyle, TemplateType } from '@/types/schema';
2
- import React from 'react';
1
+ import { NodeType, NodeProps, NodeStyle, TemplateType, SchemaNode } from '@/types/schema';
2
+ import { PageType } from '@/types/page-types';
3
+ export interface ArrayFieldDef {
4
+ key: string;
5
+ label: string;
6
+ type: 'text' | 'textarea' | 'number' | 'image' | 'toggle';
7
+ placeholder?: string;
8
+ rows?: number;
9
+ defaultValue?: any;
10
+ }
3
11
  export interface InspectorFieldDef {
4
12
  /** Property key on NodeProps */
5
13
  key: string;
6
14
  /** Display label */
7
15
  label: string;
8
16
  /** Field type */
9
- type: 'text' | 'select' | 'color' | 'number' | 'image' | 'toggle' | 'slider' | 'textarea' | 'link' | 'icon' | 'spacing' | 'group';
17
+ type: 'text' | 'select' | 'color' | 'number' | 'image' | 'toggle' | 'slider' | 'textarea' | 'link' | 'icon' | 'spacing' | 'group' | 'binding' | 'array';
10
18
  /** Options for 'select' type */
11
19
  options?: {
12
20
  label: string;
@@ -28,10 +36,22 @@ export interface InspectorFieldDef {
28
36
  children?: InspectorFieldDef[];
29
37
  /** Default value */
30
38
  defaultValue?: any;
39
+ /** For binding type: allowed data sources */
40
+ allowedDataSources?: string[];
41
+ /** For binding type: available fields */
42
+ bindableFields?: string[];
43
+ /** For 'array' type: field definitions per item */
44
+ arrayFields?: ArrayFieldDef[];
45
+ /** For 'array' type: default values for new items */
46
+ newItemDefaults?: Record<string, any>;
47
+ /** For 'array' type: add button label */
48
+ addLabel?: string;
49
+ /** For 'array' type: max items */
50
+ maxItems?: number;
31
51
  }
32
52
  export interface CompositeNodeTree {
33
53
  rootId: string;
34
- nodes: Record<string, import('@/types/schema').SchemaNode>;
54
+ nodes: Record<string, SchemaNode>;
35
55
  }
36
56
  export interface BlockDefinition {
37
57
  type: NodeType;
@@ -47,6 +67,12 @@ export interface BlockDefinition {
47
67
  allowedTemplateTypes?: TemplateType[];
48
68
  /** Factory that generates a composite tree of child nodes when this block is created */
49
69
  compositeFactory?: () => CompositeNodeTree;
70
+ /** Whether this block supports data binding */
71
+ supportsBinding?: boolean;
72
+ /** Description for documentation */
73
+ description?: string;
74
+ /** Restrict this block to specific page types */
75
+ allowedPageTypes?: PageType[];
50
76
  }
51
77
  export declare const blockRegistry: BlockDefinition[];
52
78
  export declare function getBlockDef(type: NodeType): BlockDefinition | undefined;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Utilities for hydrating a Product Card template with real product data.
3
+ * The template is stored as a schema in page_schemas (slug: '__template/product-card').
4
+ */
5
+ import { SchemaNode } from '@/types/schema';
6
+ export interface ProductData {
7
+ id: string;
8
+ name: string;
9
+ price: number;
10
+ original_price?: number | null;
11
+ image_url?: string | null;
12
+ badge?: string | null;
13
+ description?: string | null;
14
+ category?: string | null;
15
+ in_stock?: boolean | null;
16
+ sku?: string | null;
17
+ }
18
+ /**
19
+ * Clones a template's node tree and injects product data into the appropriate nodes.
20
+ * Detection strategy:
21
+ * - Image node → src = product.image_url
22
+ * - Text with level 'h3' → text = product.name
23
+ * - Text with fontWeight '600' (price) → text = formatted price
24
+ * - Text with textDecoration 'line-through' → text = original price (hidden if null)
25
+ * - Badge → text = product.badge (hidden if null)
26
+ * - Button → locked, emits addToCart event
27
+ */
28
+ export declare function hydrateCardTemplate(templateNodes: Record<string, SchemaNode>, rootNodeId: string, product: ProductData): {
29
+ nodes: Record<string, SchemaNode>;
30
+ rootId: string;
31
+ };
32
+ /**
33
+ * Formats a number as a currency string.
34
+ */
35
+ export declare function formatPrice(price: number): string;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Default sample data for builder edit/preview mode.
3
+ * Used to populate data-bound blocks when no real host data is available.
4
+ */
5
+ export declare const DEFAULT_SAMPLE_PRODUCTS: {
6
+ id: string;
7
+ name: string;
8
+ price: number;
9
+ original_price: number;
10
+ image_url: string;
11
+ category: string;
12
+ badge: string;
13
+ sku: string;
14
+ in_stock: boolean;
15
+ description: string;
16
+ }[];
17
+ export declare const DEFAULT_SAMPLE_COLLECTIONS: {
18
+ id: string;
19
+ name: string;
20
+ slug: string;
21
+ image: string;
22
+ description: string;
23
+ productCount: number;
24
+ }[];
25
+ export declare const DEFAULT_SAMPLE_SETTINGS: {
26
+ storeName: string;
27
+ currency: string;
28
+ language: string;
29
+ };
30
+ /**
31
+ * Build a complete RenderContext data object from host data.
32
+ */
33
+ export declare function buildHostData(hostData?: Record<string, any>): {
34
+ products: any;
35
+ collections: any;
36
+ settings: any;
37
+ pages: any;
38
+ custom: any;
39
+ };
40
+ /** @deprecated Use DEFAULT_SAMPLE_PRODUCTS */
41
+ export declare const DEFAULT_MOCK_PRODUCTS: {
42
+ id: string;
43
+ name: string;
44
+ price: number;
45
+ original_price: number;
46
+ image_url: string;
47
+ category: string;
48
+ badge: string;
49
+ sku: string;
50
+ in_stock: boolean;
51
+ description: string;
52
+ }[];
53
+ /** @deprecated Use DEFAULT_SAMPLE_COLLECTIONS */
54
+ export declare const DEFAULT_MOCK_COLLECTIONS: {
55
+ id: string;
56
+ name: string;
57
+ slug: string;
58
+ image: string;
59
+ description: string;
60
+ productCount: number;
61
+ }[];
62
+ /** @deprecated Use DEFAULT_SAMPLE_SETTINGS */
63
+ export declare const DEFAULT_MOCK_SETTINGS: {
64
+ storeName: string;
65
+ currency: string;
66
+ language: string;
67
+ };
68
+ /** @deprecated Use buildHostData */
69
+ export declare const buildMockRenderData: typeof buildHostData;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @deprecated This file is a backward-compatibility shim.
3
+ * Import from '@/lib/host-data' instead.
4
+ */
5
+ export { DEFAULT_SAMPLE_PRODUCTS as DEFAULT_MOCK_PRODUCTS, DEFAULT_SAMPLE_COLLECTIONS as DEFAULT_MOCK_COLLECTIONS, DEFAULT_SAMPLE_SETTINGS as DEFAULT_MOCK_SETTINGS, buildHostData as buildMockRenderData, DEFAULT_SAMPLE_PRODUCTS, DEFAULT_SAMPLE_COLLECTIONS, DEFAULT_SAMPLE_SETTINGS, buildHostData, } from './host-data';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * ════════════════════════════════════════════════════════════════════════════
3
+ * NEXORA — PUBLISH VALIDATOR
4
+ * ════════════════════════════════════════════════════════════════════════════
5
+ * Validates a schema before publishing to catch structural issues,
6
+ * missing required props, orphan nodes, and binding errors.
7
+ */
8
+ import { Schema, NodeType } from '@/types/schema';
9
+ import { PageType } from '@/types/page-types';
10
+ export type ValidationSeverity = 'error' | 'warning';
11
+ export interface ValidationIssue {
12
+ severity: ValidationSeverity;
13
+ nodeId?: string;
14
+ nodeType?: string;
15
+ message: string;
16
+ code: string;
17
+ }
18
+ export interface PublishValidationResult {
19
+ valid: boolean;
20
+ issues: ValidationIssue[];
21
+ errors: ValidationIssue[];
22
+ warnings: ValidationIssue[];
23
+ }
24
+ interface ValidatorOptions {
25
+ /** Current page type for compatibility checks */
26
+ pageType?: PageType;
27
+ /** Whether to check bindings */
28
+ checkBindings?: boolean;
29
+ /** Custom required props per node type */
30
+ requiredProps?: Partial<Record<NodeType, string[]>>;
31
+ }
32
+ export declare function validateForPublish(schema: Schema, options?: ValidatorOptions): PublishValidationResult;
33
+ export {};
@@ -0,0 +1,55 @@
1
+ /**
2
+ * ════════════════════════════════════════════════════════════════════════════
3
+ * RENDER CONTEXT UTILITIES
4
+ * ════════════════════════════════════════════════════════════════════════════
5
+ *
6
+ * Helper functions for building and validating RenderContext objects.
7
+ * Used by both the builder and consumer templates.
8
+ */
9
+ import { RenderContext, PageContext, RenderMode } from '@/types/contract';
10
+ import { ThemeTokens, SchemaNode } from '@/types/schema';
11
+ export interface BuildRenderContextOptions {
12
+ mode: RenderMode;
13
+ page?: Partial<PageContext>;
14
+ products?: any[];
15
+ collections?: any[];
16
+ pages?: any[];
17
+ settings?: Record<string, any>;
18
+ cardTemplate?: {
19
+ nodes: Record<string, SchemaNode>;
20
+ rootNodeId: string;
21
+ themeTokens?: ThemeTokens;
22
+ };
23
+ custom?: Record<string, any>;
24
+ theme?: ThemeTokens;
25
+ resolveAssetUrl?: (path: string) => string;
26
+ /** Use sample data when data is not provided */
27
+ useSampleData?: boolean;
28
+ }
29
+ /**
30
+ * Build a complete RenderContext from options.
31
+ *
32
+ * This is the recommended way to create a RenderContext in both
33
+ * builder (edit mode) and template (public/preview mode).
34
+ */
35
+ export declare function buildRenderContext(options: BuildRenderContextOptions): RenderContext;
36
+ /**
37
+ * Validate a RenderContext and return any issues.
38
+ * Used for debugging and pre-render checks.
39
+ */
40
+ export declare function validateRenderContext(ctx: RenderContext | undefined): string[];
41
+ /**
42
+ * Check if RenderContext is "strict" (has all required fields for production).
43
+ * V1.1 will make these fields required; this helper aids migration.
44
+ */
45
+ export declare function isStrictRenderContext(ctx: RenderContext): boolean;
46
+ /**
47
+ * Build RenderContext for edit mode using hostData.
48
+ * This is the standard builder context builder.
49
+ */
50
+ export declare function buildEditContext(hostData: Record<string, any> | undefined, theme?: ThemeTokens): RenderContext;
51
+ /**
52
+ * Create an iteration context for collection rendering (e.g., ProductGrid).
53
+ * Clones the parent context and adds currentItem/currentIndex.
54
+ */
55
+ export declare function createIterationContext(parentContext: RenderContext, item: any, index: number): RenderContext;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * ════════════════════════════════════════════════════════════════════════════
3
+ * SLOT UTILITIES
4
+ * ════════════════════════════════════════════════════════════════════════════
5
+ *
6
+ * Runtime utilities for handling slot behavior in the builder and renderer.
7
+ */
8
+ import { SchemaNode, Schema } from '@/types/schema';
9
+ import { SlotBehavior, SlotAssignment } from '@/types/contract';
10
+ /**
11
+ * Get the slot assignment for a node, if any.
12
+ */
13
+ export declare function getSlotAssignment(node: SchemaNode): SlotAssignment | undefined;
14
+ /**
15
+ * Check if a node is assigned to a specific slot.
16
+ */
17
+ export declare function isInSlot(node: SchemaNode, slotName: string): boolean;
18
+ /**
19
+ * Get the behavior of a node's slot.
20
+ * Returns 'editable' as default if no slot is assigned.
21
+ */
22
+ export declare function getSlotBehavior(node: SchemaNode): SlotBehavior;
23
+ /**
24
+ * Check if a node is locked (cannot be edited/moved/deleted).
25
+ */
26
+ export declare function isSlotLocked(node: SchemaNode): boolean;
27
+ /**
28
+ * Check if a node is editable in the current context.
29
+ */
30
+ export declare function isSlotEditable(node: SchemaNode): boolean;
31
+ /**
32
+ * Check if a node is dynamic (data-driven).
33
+ */
34
+ export declare function isSlotDynamic(node: SchemaNode): boolean;
35
+ /**
36
+ * Get all nodes assigned to a specific slot.
37
+ */
38
+ export declare function getNodesInSlot(schema: Schema, slotName: string): SchemaNode[];
39
+ /**
40
+ * Get the fallback node ID for a slot, if configured.
41
+ */
42
+ export declare function getSlotFallback(node: SchemaNode): string | undefined;
43
+ /**
44
+ * Build slot constraints for the Inspector.
45
+ * Returns which props/actions should be disabled based on slot behavior.
46
+ */
47
+ export interface SlotConstraints {
48
+ /** Can edit props in inspector */
49
+ canEditProps: boolean;
50
+ /** Can edit styles in inspector */
51
+ canEditStyles: boolean;
52
+ /** Can delete the node */
53
+ canDelete: boolean;
54
+ /** Can move/reorder the node */
55
+ canMove: boolean;
56
+ /** Can duplicate the node */
57
+ canDuplicate: boolean;
58
+ /** Reason for restrictions (shown to user) */
59
+ restrictionReason?: string;
60
+ }
61
+ export declare function getSlotConstraints(node: SchemaNode): SlotConstraints;
62
+ /**
63
+ * Validate slot assignments in a schema.
64
+ * Returns issues found.
65
+ */
66
+ export declare function validateSlots(schema: Schema): string[];
@@ -14,3 +14,16 @@ export declare function generatePseudoStateCSS(nodeId: string, style: NodeStyle)
14
14
  * Generate @container query CSS for responsive overrides.
15
15
  */
16
16
  export declare function generateResponsiveCSS(nodeId: string, style: NodeStyle): string;
17
+ /**
18
+ * Merge global styles into a node's style object.
19
+ * Local node styles take priority over global styles.
20
+ */
21
+ export declare function mergeGlobalStyles(nodeStyle: NodeStyle, appliedIds: string[] | undefined, globalStyles: Record<string, {
22
+ label: string;
23
+ style: Partial<NodeStyle>;
24
+ }> | undefined): NodeStyle;
25
+ /**
26
+ * Convert ThemeTokens into inline CSS custom properties (same logic as PageRenderer).
27
+ * Useful for scoping a template's theme onto a container div.
28
+ */
29
+ export declare function themeTokensToCSS(t: import('@/types/schema').ThemeTokens): React.CSSProperties;