@peak-ai/canvas 1.6.13 → 1.6.14-rc.1

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,4 +1,3 @@
1
- import React from 'react';
2
1
  import { Editor } from 'grapesjs';
3
2
  import 'grapesjs/dist/css/grapes.min.css';
4
3
  import type { PageAwareProps } from './types/page';
@@ -7,25 +6,23 @@ type NotificationHandler = (newData: {
7
6
  newProps: Record<string, any>;
8
7
  newAttributes: Record<string, any>;
9
8
  }) => boolean;
10
- export interface GrapesjsCanvasHandle {
11
- performInteractionWithLoaders: (payload: Record<string, any>) => Promise<Record<string, any> | undefined>;
12
- }
13
- declare const GrapejsCanvas: React.ForwardRefExoticComponent<{
9
+ type GrapesjsCanvasProps = {
14
10
  json: any;
15
- mode?: "editor" | "preview" | undefined;
11
+ mode?: 'editor' | 'preview';
16
12
  setEditor: (editor: Editor) => void;
17
13
  performInteraction: (payload: Record<string, any>) => Promise<Record<string, any> | undefined>;
18
- downloadTable?: ((data: {
14
+ downloadTable?: (data: {
19
15
  tableId: string;
20
16
  title: string;
21
17
  limit: number;
22
18
  json: any;
23
19
  headerMapper?: Record<string, string>;
24
- }) => Promise<void>) | undefined;
20
+ }) => Promise<void>;
25
21
  newDataNotifier: (notifHandler: NotificationHandler) => void;
26
22
  setHasChanged: (hasChanged: boolean) => void;
27
23
  isStreaming: boolean;
28
- isModeChangeFromToggle?: boolean | undefined;
29
- isTemplateView?: boolean | undefined;
30
- } & PageAwareProps & React.RefAttributes<GrapesjsCanvasHandle>>;
24
+ isModeChangeFromToggle?: boolean;
25
+ isTemplateView?: boolean;
26
+ } & PageAwareProps;
27
+ declare function GrapejsCanvas(props: GrapesjsCanvasProps): import("react/jsx-runtime").JSX.Element;
31
28
  export default GrapejsCanvas;
package/GrapesjsCanvas.js CHANGED
@@ -1,13 +1,13 @@
1
- import _extends from"@babel/runtime/helpers/extends";import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _regeneratorRuntime from"@babel/runtime/regenerator";/* eslint-disable @typescript-eslint/no-explicit-any */import React,{forwardRef,useEffect,useImperativeHandle,useRef,useState}from"react";// eslint-disable-next-line import/no-named-as-default
1
+ import _extends from"@babel/runtime/helpers/extends";import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _regeneratorRuntime from"@babel/runtime/regenerator";/* eslint-disable @typescript-eslint/no-explicit-any */import React,{useEffect,useRef,useState}from"react";// eslint-disable-next-line import/no-named-as-default
2
2
  import grapesjs from"grapesjs";import"grapesjs/dist/css/grapes.min.css";import tailwind from"grapesjs-tailwind";import{TypesToRegister}from"./constants";import{toKebabCase}from"./helpers";import{tailwindCompiledCss}from"./helpers/css";import{datePickerCss}from"./helpers/date-picker";import{extractPageMetadata,getCurrentPage,mergeStyles,normalizeMultiPageJson}from"./helpers/page-utils";import{createGrapesjsShadcnGenericPlugin}from"./plugins/grapejs-plugin";import{StyledEditor}from"./index.styles";import{PageProvider,usePageContext}from"./contexts/PageContext";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function isEditorCanvasReady(editor){try{var canvas=editor.Canvas;if(!canvas){return false}var canvasDoc=canvas.getDocument==null?void 0:canvas.getDocument();if(!canvasDoc){return false}var canvasBody=canvasDoc.body;if(!canvasBody){return false}return true}catch(_unused){return false}}function safeStoreEditor(_x){return _safeStoreEditor.apply(this,arguments)}function _safeStoreEditor(){_safeStoreEditor=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(editor){var _editor$Pages,wrapper,pages;return _regeneratorRuntime.wrap(function _callee6$(_context6){while(1)switch(_context6.prev=_context6.next){case 0:_context6.prev=0;wrapper=editor.getWrapper();if(wrapper){_context6.next=4;break}return _context6.abrupt("return",null);case 4:pages=((_editor$Pages=editor.Pages)==null||_editor$Pages.getAll==null?void 0:_editor$Pages.getAll())||[];if(!(pages.length===0)){_context6.next=7;break}return _context6.abrupt("return",null);case 7:_context6.next=9;return editor.store();case 9:return _context6.abrupt("return",_context6.sent);case 12:_context6.prev=12;_context6.t0=_context6["catch"](0);// eslint-disable-next-line no-console
3
3
  console.warn("Error during store operation:",_context6.t0);return _context6.abrupt("return",null);case 16:case"end":return _context6.stop()}},_callee6,null,[[0,12]])}));return _safeStoreEditor.apply(this,arguments)}function setComponentProperties(editor,isPreview,isStreaming){if(!editor){return}function setPropertiesRecursively(comp){if(!comp){return}var isMutable=!isPreview&&!isStreaming;comp.set({editable:isMutable,draggable:isMutable,droppable:isMutable&&comp.getName()!=="Shadcn-generic",selectable:isMutable,hoverable:isMutable,highlightable:isMutable,copyable:false,resizable:false,removable:isMutable,badgable:false});comp.set("attributes",_extends({},comp.get("attributes")||{},{isEditable:isMutable}));if(isMutable){comp.set("toolbar",[{attributes:{"class":"fa fa-arrows"},command:"tlb-move"},{attributes:{"class":"fa fa-trash"},command:"tlb-delete"}])}else{comp.set("toolbar",[])}comp.components().forEach(setPropertiesRecursively)}var wrapper=editor.getWrapper();var components=(wrapper==null?void 0:wrapper.find("*"))||[];components.forEach(setPropertiesRecursively);if(isEditorCanvasReady(editor)){if(isPreview){editor.runCommand("core:preview")}else{editor.stopCommand("core:preview")}}}function convertStyles(stylesArray){return stylesArray.map(function(block){var selectors=Array.isArray(block.selectors)?block.selectors.join(", "):block.selectors;var declarations=Object.entries(block.style).map(function(_ref){var prop=_ref[0],value=_ref[1];return toKebabCase(prop)+": "+value+";"}).join(" ");return selectors+" { "+declarations+" }"}).join("\n")}function createActionCardConfig(action){var icon=action.icon,title=action.title,description=action.description;return{type:"shadcn-generic",componentName:"ActionCard",badgable:false,copyable:false,removable:true,draggable:true,componentProps:{icon:icon,headerContent:title,bodyContent:description}}}function expandActions(node){if(node.type==="shadcn-generic"&&node.componentName==="Actions"){var _node$componentProps;var actions=(_node$componentProps=node.componentProps)==null?void 0:_node$componentProps.actions;if(Array.isArray(actions)&&actions.length>0){return _extends({},node,{type:"div",classes:["dashboard-cards"].concat(node.classes||[]),componentName:undefined,componentProps:undefined,components:actions.map(function(action,i){return _extends({},createActionCardConfig(action),{id:node.id+"--action-card-"+i})})})}return node}if(Array.isArray(node.components)){return _extends({},node,{components:node.components.map(expandActions)})}return node}function setInteracting(renderedComponents,components,inProgress){components.forEach(function(component){var componentId=component.componentId,showLoader=component.showLoader;if(!showLoader){return}var gjsModel=renderedComponents[componentId];if(gjsModel){gjsModel.set("attributes",_extends({},gjsModel.get("attributes"),{interactionApiInProgress:inProgress}))}})}function expandActionsComponent(model,actions){model.components("");actions.forEach(function(action){model.append(createActionCardConfig(action))});model.set("type","div");model.addClass("dashboard-cards");model.set("componentName",undefined);model.set("componentProps",{})}function resetStreamingComponent(comp){var attrs=comp.get("attributes")||{};var props=comp.get("componentProps")||{};var cleanedProps=_extends({},props);delete cleanedProps.bodyContent;delete cleanedProps.data;delete cleanedProps.rows;delete cleanedProps.series;delete cleanedProps.pagination;delete cleanedProps.error;delete cleanedProps.isMissing;comp.set({attributes:_extends({},attrs,{loading:true,error:undefined,isMissing:undefined}),componentProps:cleanedProps})}function GrapejsCanvasInternal(_ref2){var _pages$;var json=_ref2.json,_ref2$mode=_ref2.mode,mode=_ref2$mode===void 0?"preview":_ref2$mode,setEditor=_ref2.setEditor,performInteraction=_ref2.performInteraction,downloadTable=_ref2.downloadTable,_ref2$newDataNotifier=_ref2.newDataNotifier,newDataNotifier=_ref2$newDataNotifier===void 0?function(){// no op
4
4
  }:_ref2$newDataNotifier,_ref2$setHasChanged=_ref2.setHasChanged,setHasChanged=_ref2$setHasChanged===void 0?function(){// no op
5
- }:_ref2$setHasChanged,isStreaming=_ref2.isStreaming,_ref2$isModeChangeFro=_ref2.isModeChangeFromToggle,isModeChangeFromToggle=_ref2$isModeChangeFro===void 0?false:_ref2$isModeChangeFro,_ref2$isTemplateView=_ref2.isTemplateView,isTemplateView=_ref2$isTemplateView===void 0?false:_ref2$isTemplateView,externalCurrentPageId=_ref2.currentPageId,externalOnPageChange=_ref2.onPageChange,onRequestPageData=_ref2.onRequestPageData,imperativeRef=_ref2.imperativeRef;var pageContext=usePageContext();var normalizedJson=normalizeMultiPageJson(json);var pages=normalizedJson.pages.map(extractPageMetadata);var effectiveCurrentPageId=externalCurrentPageId||(pageContext==null?void 0:pageContext.currentPageId)||((_pages$=pages[0])==null?void 0:_pages$.id)||"";var editorRef=useRef(null);var editorInstance=useRef(null);var renderedComponents=useRef({});var pageDataCache=useRef({});var currentPageIdRef=useRef(effectiveCurrentPageId);var isStreamingRef=useRef(isStreaming!=null?isStreaming:false);var modeRef=useRef(mode);var isSystemUpdateRef=useRef(false);var lastJsonRef=useRef("");var isEditorAliveRef=useRef(false);var onRequestPageDataRef=useRef(onRequestPageData);var rowNavigationContextRef=useRef(null);var _useState=useState(false),isTransitioning=_useState[0],setIsTransitioning=_useState[1];useEffect(function(){currentPageIdRef.current=effectiveCurrentPageId},[effectiveCurrentPageId]);useEffect(function(){isStreamingRef.current=isStreaming!=null?isStreaming:false},[isStreaming!=null?isStreaming:false]);useEffect(function(){modeRef.current=mode},[mode]);useEffect(function(){onRequestPageDataRef.current=onRequestPageData},[onRequestPageData]);function notificationHandler(props){var _model$get;if(!props){return true}var compId=props.componentId,_props$newProps=props.newProps,newProps=_props$newProps===void 0?{}:_props$newProps,_props$newAttributes=props.newAttributes,newAttributes=_props$newAttributes===void 0?{}:_props$newAttributes;var model=renderedComponents.current[compId];if(!model){var pageId=currentPageIdRef.current;if(pageId){if(!pageDataCache.current[pageId]){pageDataCache.current[pageId]={}}pageDataCache.current[pageId][compId]={newProps:newProps,newAttributes:newAttributes,timestamp:Date.now()}}return false}// Filter out complex placeholder objects by setting them to null
5
+ }:_ref2$setHasChanged,isStreaming=_ref2.isStreaming,_ref2$isModeChangeFro=_ref2.isModeChangeFromToggle,isModeChangeFromToggle=_ref2$isModeChangeFro===void 0?false:_ref2$isModeChangeFro,_ref2$isTemplateView=_ref2.isTemplateView,isTemplateView=_ref2$isTemplateView===void 0?false:_ref2$isTemplateView,externalCurrentPageId=_ref2.currentPageId,externalOnPageChange=_ref2.onPageChange,onRequestPageData=_ref2.onRequestPageData;var pageContext=usePageContext();var normalizedJson=normalizeMultiPageJson(json);var pages=normalizedJson.pages.map(extractPageMetadata);var effectiveCurrentPageId=externalCurrentPageId||(pageContext==null?void 0:pageContext.currentPageId)||((_pages$=pages[0])==null?void 0:_pages$.id)||"";var editorRef=useRef(null);var editorInstance=useRef(null);var renderedComponents=useRef({});var pageDataCache=useRef({});var currentPageIdRef=useRef(effectiveCurrentPageId);var isStreamingRef=useRef(isStreaming!=null?isStreaming:false);var modeRef=useRef(mode);var isSystemUpdateRef=useRef(false);var lastJsonRef=useRef("");var isEditorAliveRef=useRef(false);var onRequestPageDataRef=useRef(onRequestPageData);var rowNavigationContextRef=useRef(null);var _useState=useState(false),isTransitioning=_useState[0],setIsTransitioning=_useState[1];useEffect(function(){currentPageIdRef.current=effectiveCurrentPageId},[effectiveCurrentPageId]);useEffect(function(){isStreamingRef.current=isStreaming!=null?isStreaming:false},[isStreaming!=null?isStreaming:false]);useEffect(function(){modeRef.current=mode},[mode]);useEffect(function(){onRequestPageDataRef.current=onRequestPageData},[onRequestPageData]);function notificationHandler(props){var _model$get;if(!props){return true}var compId=props.componentId,_props$newProps=props.newProps,newProps=_props$newProps===void 0?{}:_props$newProps,_props$newAttributes=props.newAttributes,newAttributes=_props$newAttributes===void 0?{}:_props$newAttributes;var model=renderedComponents.current[compId];if(!model){var pageId=currentPageIdRef.current;if(pageId){if(!pageDataCache.current[pageId]){pageDataCache.current[pageId]={}}pageDataCache.current[pageId][compId]={newProps:newProps,newAttributes:newAttributes,timestamp:Date.now()}}return false}// Filter out complex placeholder objects by setting them to null
6
6
  // This ensures placeholder values are properly cleared and don't cause stale data issues
7
7
  var filteredProps=_extends({},newProps);Object.keys(filteredProps).forEach(function(key){var value=filteredProps[key];if(value&&typeof value==="object"&&value.name==="__peak_placeholder"){filteredProps[key]=null}});var parsedNewProps=_extends({},filteredProps);if(filteredProps.pagination){parsedNewProps.pagination=_extends({},model.get("componentProps").pagination||{},filteredProps.pagination)}// Handle Actions component: expand into ActionCards when data arrives via streaming
8
- var isActionsComponent=model.get("componentName")==="Actions";var hasValidActionsData=parsedNewProps.actions&&parsedNewProps.actions!==null&&Array.isArray(parsedNewProps.actions)&&parsedNewProps.actions.length>0;if(isActionsComponent&&hasValidActionsData){var _model$components$at;var isAlreadyExpanded=model.components().length>0&&((_model$components$at=model.components().at(0))==null?void 0:_model$components$at.get("componentName"))==="ActionCard";if(!isAlreadyExpanded&&editorInstance.current&&isEditorAliveRef.current){expandActionsComponent(model,parsedNewProps.actions);return true}}model.set("componentProps",_extends({},model.get("componentProps"),parsedNewProps,{headerMapper:((_model$get=model.get("componentProps"))==null?void 0:_model$get.headerMapper)||parsedNewProps.headerMapper}));var currentAttrs=model.get("attributes")||{};var hasRealValue=(parsedNewProps==null?void 0:parsedNewProps.bodyContent)!==undefined&&(parsedNewProps==null?void 0:parsedNewProps.bodyContent)!==null||(parsedNewProps==null?void 0:parsedNewProps.data)!==undefined&&(parsedNewProps==null?void 0:parsedNewProps.data)!==null||(parsedNewProps==null?void 0:parsedNewProps.rows)!==undefined&&(parsedNewProps==null?void 0:parsedNewProps.rows)!==null||(parsedNewProps==null?void 0:parsedNewProps.series)!==undefined&&(parsedNewProps==null?void 0:parsedNewProps.series)!==null;var shouldStopLoading=hasRealValue||(newAttributes==null?void 0:newAttributes.error)||(parsedNewProps==null?void 0:parsedNewProps.isMissing);model.set("attributes",_extends({},currentAttrs,newAttributes,shouldStopLoading?{loading:false}:{}));if(model.view){model.view.render()}return true}useEffect(function(){newDataNotifier(notificationHandler)},[]);function handleNavigateToPage(targetPageId,rowContext){rowNavigationContextRef.current=rowContext!=null?rowContext:null;if(externalOnPageChange){externalOnPageChange(targetPageId,rowContext)}if(pageContext){pageContext.navigateToPage(targetPageId,rowContext)}}function downloadTableWrapper(_x2){return _downloadTableWrapper.apply(this,arguments)}function _downloadTableWrapper(){_downloadTableWrapper=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data){var updatedJson;return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:if(downloadTable){_context4.next=2;break}return _context4.abrupt("return");case 2:updatedJson=null;if(!editorInstance.current){_context4.next=7;break}_context4.next=6;return safeStoreEditor(editorInstance.current);case 6:updatedJson=_context4.sent;case 7:_context4.next=9;return downloadTable(_extends({},data,{json:updatedJson}));case 9:case"end":return _context4.stop()}},_callee4)}));return _downloadTableWrapper.apply(this,arguments)}function performInteractionWrapper(_x3){return _performInteractionWrapper.apply(this,arguments)}function _performInteractionWrapper(){_performInteractionWrapper=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(payload){var _payload$json;var updatedJson,apiResponse,componentUpdates;return _regeneratorRuntime.wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:updatedJson=(_payload$json=payload.json)!=null?_payload$json:null;if(!(!updatedJson&&editorInstance.current)){_context5.next=5;break}_context5.next=4;return safeStoreEditor(editorInstance.current);case 4:updatedJson=_context5.sent;case 5:setInteracting(renderedComponents.current,payload.affectedComponents,true);_context5.prev=6;_context5.next=9;return performInteraction(_extends({},payload,{json:updatedJson}));case 9:apiResponse=_context5.sent;componentUpdates=apiResponse||{};Object.entries(componentUpdates).forEach(function(_ref8){var key=_ref8[0],value=_ref8[1];var model=renderedComponents.current[key];if(model){model.set("attributes",_extends({},model.get("attributes"),{error:undefined}));model.set("componentProps",_extends({},model.get("componentProps"),value,{error:undefined,isMissing:undefined}))}});return _context5.abrupt("return",componentUpdates);case 15:_context5.prev=15;_context5.t0=_context5["catch"](6);payload.affectedComponents.forEach(function(component){var model=renderedComponents.current[component.componentId];if(model){var errorMessage=_context5.t0 instanceof Error?_context5.t0.message:"Something went wrong. Please try again.";model.set("attributes",_extends({},model.get("attributes"),{error:errorMessage}));model.set("componentProps",_extends({},model.get("componentProps"),{error:errorMessage,isMissing:undefined}))}});throw _context5.t0;case 19:_context5.prev=19;setInteracting(renderedComponents.current,payload.affectedComponents,false);return _context5.finish(19);case 22:case"end":return _context5.stop()}},_callee5,null,[[6,15,19,22]])}));return _performInteractionWrapper.apply(this,arguments)}useImperativeHandle(imperativeRef,function(){return{performInteractionWithLoaders:performInteractionWrapper}},[]);useEffect(function(){if(!editorRef.current){return function(){// no op
8
+ var isActionsComponent=model.get("componentName")==="Actions";var hasValidActionsData=parsedNewProps.actions&&parsedNewProps.actions!==null&&Array.isArray(parsedNewProps.actions)&&parsedNewProps.actions.length>0;if(isActionsComponent&&hasValidActionsData){var _model$components$at;var isAlreadyExpanded=model.components().length>0&&((_model$components$at=model.components().at(0))==null?void 0:_model$components$at.get("componentName"))==="ActionCard";if(!isAlreadyExpanded&&editorInstance.current&&isEditorAliveRef.current){expandActionsComponent(model,parsedNewProps.actions);return true}}model.set("componentProps",_extends({},model.get("componentProps"),parsedNewProps,{headerMapper:((_model$get=model.get("componentProps"))==null?void 0:_model$get.headerMapper)||parsedNewProps.headerMapper}));var currentAttrs=model.get("attributes")||{};var hasRealValue=(parsedNewProps==null?void 0:parsedNewProps.bodyContent)!==undefined&&(parsedNewProps==null?void 0:parsedNewProps.bodyContent)!==null||(parsedNewProps==null?void 0:parsedNewProps.data)!==undefined&&(parsedNewProps==null?void 0:parsedNewProps.data)!==null||(parsedNewProps==null?void 0:parsedNewProps.rows)!==undefined&&(parsedNewProps==null?void 0:parsedNewProps.rows)!==null||(parsedNewProps==null?void 0:parsedNewProps.series)!==undefined&&(parsedNewProps==null?void 0:parsedNewProps.series)!==null;var shouldStopLoading=hasRealValue||(newAttributes==null?void 0:newAttributes.error)||(parsedNewProps==null?void 0:parsedNewProps.isMissing);model.set("attributes",_extends({},currentAttrs,newAttributes,shouldStopLoading?{loading:false}:{}));if(model.view){model.view.render()}return true}useEffect(function(){newDataNotifier(notificationHandler)},[]);function handleNavigateToPage(targetPageId,rowContext){rowNavigationContextRef.current=rowContext!=null?rowContext:null;if(externalOnPageChange){externalOnPageChange(targetPageId,rowContext)}if(pageContext){pageContext.navigateToPage(targetPageId,rowContext)}}function downloadTableWrapper(_x2){return _downloadTableWrapper.apply(this,arguments)}function _downloadTableWrapper(){_downloadTableWrapper=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data){var updatedJson;return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:if(downloadTable){_context4.next=2;break}return _context4.abrupt("return");case 2:updatedJson=null;if(!editorInstance.current){_context4.next=7;break}_context4.next=6;return safeStoreEditor(editorInstance.current);case 6:updatedJson=_context4.sent;case 7:_context4.next=9;return downloadTable(_extends({},data,{json:updatedJson}));case 9:case"end":return _context4.stop()}},_callee4)}));return _downloadTableWrapper.apply(this,arguments)}function performInteractionWrapper(_x3){return _performInteractionWrapper.apply(this,arguments)}function _performInteractionWrapper(){_performInteractionWrapper=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(payload){var updatedJson,apiResponse,componentUpdates;return _regeneratorRuntime.wrap(function _callee5$(_context5){while(1)switch(_context5.prev=_context5.next){case 0:updatedJson=null;if(!editorInstance.current){_context5.next=5;break}_context5.next=4;return safeStoreEditor(editorInstance.current);case 4:updatedJson=_context5.sent;case 5:setInteracting(renderedComponents.current,payload.affectedComponents,true);_context5.prev=6;_context5.next=9;return performInteraction(_extends({},payload,{json:updatedJson}));case 9:apiResponse=_context5.sent;componentUpdates=apiResponse||{};Object.entries(componentUpdates).forEach(function(_ref8){var key=_ref8[0],value=_ref8[1];var model=renderedComponents.current[key];if(model){model.set("attributes",_extends({},model.get("attributes"),{error:undefined}));model.set("componentProps",_extends({},model.get("componentProps"),value,{error:undefined,isMissing:undefined}))}});return _context5.abrupt("return",componentUpdates);case 15:_context5.prev=15;_context5.t0=_context5["catch"](6);payload.affectedComponents.forEach(function(componentId){var model=renderedComponents.current[componentId];if(model){var errorMessage=_context5.t0 instanceof Error?_context5.t0.message:"Something went wrong. Please try again.";model.set("attributes",_extends({},model.get("attributes"),{error:errorMessage}));model.set("componentProps",_extends({},model.get("componentProps"),{error:errorMessage,isMissing:undefined}))}});throw _context5.t0;case 19:_context5.prev=19;setInteracting(renderedComponents.current,payload.affectedComponents,false);return _context5.finish(19);case 22:case"end":return _context5.stop()}},_callee5,null,[[6,15,19,22]])}));return _performInteractionWrapper.apply(this,arguments)}useEffect(function(){if(!editorRef.current){return function(){// no op
9
9
  }}if(editorInstance.current){editorInstance.current.destroy();editorInstance.current=null;isEditorAliveRef.current=false}var currentMode=modeRef.current;var editor=grapesjs.init({container:editorRef.current,height:"100%",plugins:[tailwind,createGrapesjsShadcnGenericPlugin(modeRef,performInteractionWrapper,renderedComponents.current,setHasChanged,isTemplateView,isStreamingRef,handleNavigateToPage,downloadTableWrapper)],storageManager:{type:"none"},richTextEditor:{actions:["bold","italic","underline","strikethrough"]},canvas:{customBadgeLabel:function customBadgeLabel(component){var tagName=component.get("tagName");return tagName==="body"?"":tagName||""}}});isEditorAliveRef.current=true;var injectionAttempts=0;function injectStylesEarly(){var _editor$Canvas;var iframeDoc=(_editor$Canvas=editor.Canvas)==null||_editor$Canvas.getDocument==null?void 0:_editor$Canvas.getDocument();if(iframeDoc&&iframeDoc.head){if(!iframeDoc.head.querySelector("[data-grapesjs-styles]")){var style=iframeDoc.createElement("style");var fullCss="\n "+tailwindCompiledCss+"\n "+datePickerCss+"\n ::-webkit-scrollbar {\n width: 0px;\n height: 0px;\n }\n html, body {\n overflow: auto !important;\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n }\n ";style.innerHTML=fullCss;style.setAttribute("type","text/css");style.setAttribute("data-grapesjs-styles","true");iframeDoc.head.appendChild(style)}}else if(injectionAttempts<50){injectionAttempts+=1;requestAnimationFrame(injectStylesEarly)}}requestAnimationFrame(injectStylesEarly);function checkDirty(){return _checkDirty.apply(this,arguments)}function _checkDirty(){_checkDirty=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(){var stored,newJson;return _regeneratorRuntime.wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!(isStreamingRef.current||isSystemUpdateRef.current)){_context2.next=2;break}return _context2.abrupt("return");case 2:if(!(!isEditorAliveRef.current||!editorInstance.current)){_context2.next=4;break}return _context2.abrupt("return");case 4:stored=null;_context2.next=7;return safeStoreEditor(editorInstance.current);case 7:stored=_context2.sent;if(stored){_context2.next=10;break}return _context2.abrupt("return");case 10:newJson=JSON.stringify(stored);if(newJson!==lastJsonRef.current){setHasChanged(true);lastJsonRef.current=newJson}case 12:case"end":return _context2.stop()}},_callee2)}));return _checkDirty.apply(this,arguments)}var debouncedCheckDirty=function(){var timeout=null;return function(){if(timeout){clearTimeout(timeout)}timeout=setTimeout(checkDirty,200)}}();["component:add","component:remove","component:update:content","style:update","component:drag:end","rte:change"].forEach(function(evt){editor.on(evt,debouncedCheckDirty)});editor.on("component:update",function(model,prop){if(["attributes","componentProps","content"].includes(prop)){debouncedCheckDirty()}});// Tailwind CSS rules aren't fully added to our component
10
10
  // So, adding them from here!
11
11
  editor.on("load",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var canvasDoc,canvasHead,style,fullCss,storeResult;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:canvasDoc=editor.Canvas.getDocument();canvasHead=canvasDoc.head;if(!canvasHead.querySelector("[data-grapesjs-styles]")){style=canvasDoc.createElement("style");fullCss="\n "+tailwindCompiledCss+"\n "+datePickerCss+"\n ::-webkit-scrollbar {\n width: 0px;\n height: 0px;\n }\n html, body {\n overflow: auto !important;\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n }\n ";style.innerHTML=fullCss;style.setAttribute("type","text/css");style.setAttribute("data-grapesjs-styles","true");canvasHead.appendChild(style)}isSystemUpdateRef.current=true;_context.next=6;return safeStoreEditor(editor);case 6:storeResult=_context.sent;if(storeResult){lastJsonRef.current=JSON.stringify(storeResult)}isSystemUpdateRef.current=false;setComponentProperties(editor,currentMode==="preview",isStreamingRef.current);case 10:case"end":return _context.stop()}},_callee)})));editorInstance.current=editor;if(setEditor){setEditor(editor)}TypesToRegister.forEach(function(_ref4){var type=_ref4.type,tagName=_ref4.tagName;if(!editor.DomComponents.getType(type)){editor.DomComponents.addType(type,{model:{defaults:{tagName:tagName}},view:{}})}});return function cleanup(){editor.destroy();isEditorAliveRef.current=false}},[]);useEffect(function(){var _json$pages;if(json&&((_json$pages=json.pages)==null?void 0:_json$pages.length)>0){var _currentPage$frames,_editorInstance$curre3;if(!isEditorAliveRef.current||!editorInstance.current){return}var pageNormalizedJson=normalizeMultiPageJson(json);var currentPage=getCurrentPage(pageNormalizedJson.pages,effectiveCurrentPageId);if(!currentPage||!((_currentPage$frames=currentPage.frames)!=null&&_currentPage$frames.length)){return}isSystemUpdateRef.current=true;var raw=currentPage.frames[0].component;var processed=expandActions(raw);try{var _editorInstance$curre;(_editorInstance$curre=editorInstance.current)==null||_editorInstance$curre.setComponents(processed);setTimeout(function(){if(editorInstance.current&&isEditorAliveRef.current){var _editorInstance$curre2;var domComponents=(_editorInstance$curre2=editorInstance.current)==null?void 0:_editorInstance$curre2.DomComponents;if(domComponents){var _domComponents$getWra;var allComponents=domComponents==null||(_domComponents$getWra=domComponents.getWrapper())==null?void 0:_domComponents$getWra.findType("shadcn-generic");allComponents==null||allComponents.forEach(function(comp){if(comp.get("componentName")==="Tabs"){var _comp$view;(_comp$view=comp.view)==null||_comp$view.render()}})}}},100)}catch(error){// eslint-disable-next-line no-console
12
- console.error("Error during component restoration:",error)}var globalStyles=pageNormalizedJson.styles||[];var pageStyles=currentPage.styles||[];var mergedStyles=mergeStyles(globalStyles,pageStyles);var cssText=convertStyles(mergedStyles);(_editorInstance$curre3=editorInstance.current)==null||_editorInstance$curre3.setStyle(cssText);if(onRequestPageDataRef.current){var _rowNavigationContext;var isMultiPage=Boolean(pageNormalizedJson.isMultiPage);var pageId=isMultiPage?currentPage.id:"";var rowContext=(_rowNavigationContext=rowNavigationContextRef.current)!=null?_rowNavigationContext:undefined;onRequestPageDataRef.current(pageId,[],rowContext);rowNavigationContextRef.current=null}if(editorInstance.current){setComponentProperties(editorInstance.current,mode==="preview",isStreaming);setTimeout(function(){if(editorInstance.current&&isEditorAliveRef.current&&mode==="preview"){setComponentProperties(editorInstance.current,true,isStreaming)}},50)}setTimeout(function(){if(currentPage&&pageDataCache.current[currentPage.id]){var cachedData=pageDataCache.current[currentPage.id];Object.entries(cachedData).forEach(function(_ref5){var componentId=_ref5[0],data=_ref5[1];var model=renderedComponents.current[componentId];if(model&&data){if(data.newProps){model.set("componentProps",_extends({},model.get("componentProps"),data.newProps))}var updatedAttributes=_extends({},model.get("attributes"),data.newAttributes||{});model.set("attributes",updatedAttributes);if(model.view){model.view.render()}}});delete pageDataCache.current[currentPage.id]}},150);var cacheCheckInterval=setInterval(function(){if(!currentPage||!pageDataCache.current[currentPage.id]){return}var cachedData=pageDataCache.current[currentPage.id];var appliedAny=false;Object.entries(cachedData).forEach(function(_ref6){var componentId=_ref6[0],data=_ref6[1];var model=renderedComponents.current[componentId];if(model&&data){if(data.newProps){model.set("componentProps",_extends({},model.get("componentProps"),data.newProps))}var updatedAttributes=_extends({},model.get("attributes"),data.newAttributes||{});model.set("attributes",updatedAttributes);if(model.view){model.view.render()}appliedAny=true}});if(appliedAny){Object.keys(cachedData).forEach(function(componentId){if(renderedComponents.current[componentId]){delete cachedData[componentId]}});if(Object.keys(cachedData).length===0){delete pageDataCache.current[currentPage.id]}}},100);setTimeout(function(){clearInterval(cacheCheckInterval)},5000);setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){var storeResult;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(!(editorInstance.current&&isEditorAliveRef.current)){_context3.next=6;break}_context3.next=3;return safeStoreEditor(editorInstance.current);case 3:storeResult=_context3.sent;if(storeResult){lastJsonRef.current=JSON.stringify(storeResult)}isSystemUpdateRef.current=false;case 6:case"end":return _context3.stop()}},_callee3)})),100)}},[json,effectiveCurrentPageId]);useEffect(function(){var editor=editorInstance.current;if(!editor||!isEditorAliveRef.current){return}if(isModeChangeFromToggle){setIsTransitioning(true)}setComponentProperties(editorInstance.current,mode==="preview",isStreaming!=null?isStreaming:false);var wrapper=editor.getWrapper();var shadcnComponents=(wrapper==null?void 0:wrapper.find("[data-gjs-type=\"shadcn-generic\"]"))||[];shadcnComponents.forEach(function(comp){if(comp.view&&typeof comp.view.render==="function"){comp.view.render()}});if(isModeChangeFromToggle){requestAnimationFrame(function(){setIsTransitioning(false)})}},[mode,isStreaming!=null?isStreaming:false]);useEffect(function(){var editor=editorInstance.current;var currentIsStreaming=isStreaming!=null?isStreaming:false;var prevIsStreaming=isStreamingRef.current;if(editor&&isEditorAliveRef.current&&currentIsStreaming&&!prevIsStreaming){var wrapper=editor.getWrapper();var shadcnComponents=(wrapper==null?void 0:wrapper.findType("shadcn-generic"))||[];shadcnComponents.forEach(function(comp){resetStreamingComponent(comp)})}isStreamingRef.current=currentIsStreaming},[isStreaming]);return/*#__PURE__*/_jsxs(React.Fragment,{children:[/*#__PURE__*/_jsx(StyledEditor,{}),/*#__PURE__*/_jsx("div",{ref:editorRef,id:"grapesjs-editor",style:{opacity:isTransitioning?0:1,transition:"opacity 0.15s ease-in-out"}})]})}var GrapejsCanvas=/*#__PURE__*/forwardRef(function(props,ref){var _pages$2;var existingContext=usePageContext();if(existingContext){return/*#__PURE__*/_jsx(GrapejsCanvasInternal,_extends({},props,{imperativeRef:ref}))}var normalizedJson=normalizeMultiPageJson(props.json);var pages=normalizedJson.pages.map(extractPageMetadata);var initialPageId=props.currentPageId||((_pages$2=pages[0])==null?void 0:_pages$2.id)||"";return/*#__PURE__*/_jsx(PageProvider,{pages:pages,initialPageId:initialPageId,onPageChange:props.onPageChange,children:/*#__PURE__*/_jsx(GrapejsCanvasInternal,_extends({},props,{imperativeRef:ref}))})});export default GrapejsCanvas;
12
+ console.error("Error during component restoration:",error)}var globalStyles=pageNormalizedJson.styles||[];var pageStyles=currentPage.styles||[];var mergedStyles=mergeStyles(globalStyles,pageStyles);var cssText=convertStyles(mergedStyles);(_editorInstance$curre3=editorInstance.current)==null||_editorInstance$curre3.setStyle(cssText);if(onRequestPageDataRef.current){var _rowNavigationContext;var isMultiPage=Boolean(pageNormalizedJson.isMultiPage);var pageId=isMultiPage?currentPage.id:"";var rowContext=(_rowNavigationContext=rowNavigationContextRef.current)!=null?_rowNavigationContext:undefined;onRequestPageDataRef.current(pageId,[],rowContext);rowNavigationContextRef.current=null}if(editorInstance.current){setComponentProperties(editorInstance.current,mode==="preview",isStreaming);setTimeout(function(){if(editorInstance.current&&isEditorAliveRef.current&&mode==="preview"){setComponentProperties(editorInstance.current,true,isStreaming)}},50)}setTimeout(function(){if(currentPage&&pageDataCache.current[currentPage.id]){var cachedData=pageDataCache.current[currentPage.id];Object.entries(cachedData).forEach(function(_ref5){var componentId=_ref5[0],data=_ref5[1];var model=renderedComponents.current[componentId];if(model&&data){if(data.newProps){model.set("componentProps",_extends({},model.get("componentProps"),data.newProps))}var updatedAttributes=_extends({},model.get("attributes"),data.newAttributes||{});model.set("attributes",updatedAttributes);if(model.view){model.view.render()}}});delete pageDataCache.current[currentPage.id]}},150);var cacheCheckInterval=setInterval(function(){if(!currentPage||!pageDataCache.current[currentPage.id]){return}var cachedData=pageDataCache.current[currentPage.id];var appliedAny=false;Object.entries(cachedData).forEach(function(_ref6){var componentId=_ref6[0],data=_ref6[1];var model=renderedComponents.current[componentId];if(model&&data){if(data.newProps){model.set("componentProps",_extends({},model.get("componentProps"),data.newProps))}var updatedAttributes=_extends({},model.get("attributes"),data.newAttributes||{});model.set("attributes",updatedAttributes);if(model.view){model.view.render()}appliedAny=true}});if(appliedAny){Object.keys(cachedData).forEach(function(componentId){if(renderedComponents.current[componentId]){delete cachedData[componentId]}});if(Object.keys(cachedData).length===0){delete pageDataCache.current[currentPage.id]}}},100);setTimeout(function(){clearInterval(cacheCheckInterval)},5000);setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){var storeResult;return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(!(editorInstance.current&&isEditorAliveRef.current)){_context3.next=6;break}_context3.next=3;return safeStoreEditor(editorInstance.current);case 3:storeResult=_context3.sent;if(storeResult){lastJsonRef.current=JSON.stringify(storeResult)}isSystemUpdateRef.current=false;case 6:case"end":return _context3.stop()}},_callee3)})),100)}},[json,effectiveCurrentPageId]);useEffect(function(){var editor=editorInstance.current;if(!editor||!isEditorAliveRef.current){return}if(isModeChangeFromToggle){setIsTransitioning(true)}setComponentProperties(editorInstance.current,mode==="preview",isStreaming!=null?isStreaming:false);var wrapper=editor.getWrapper();var shadcnComponents=(wrapper==null?void 0:wrapper.find("[data-gjs-type=\"shadcn-generic\"]"))||[];shadcnComponents.forEach(function(comp){if(comp.view&&typeof comp.view.render==="function"){comp.view.render()}});if(isModeChangeFromToggle){requestAnimationFrame(function(){setIsTransitioning(false)})}},[mode,isStreaming!=null?isStreaming:false]);useEffect(function(){var editor=editorInstance.current;var currentIsStreaming=isStreaming!=null?isStreaming:false;var prevIsStreaming=isStreamingRef.current;if(editor&&isEditorAliveRef.current&&currentIsStreaming&&!prevIsStreaming){var wrapper=editor.getWrapper();var shadcnComponents=(wrapper==null?void 0:wrapper.findType("shadcn-generic"))||[];shadcnComponents.forEach(function(comp){resetStreamingComponent(comp)})}isStreamingRef.current=currentIsStreaming},[isStreaming]);return/*#__PURE__*/_jsxs(React.Fragment,{children:[/*#__PURE__*/_jsx(StyledEditor,{}),/*#__PURE__*/_jsx("div",{ref:editorRef,id:"grapesjs-editor",style:{opacity:isTransitioning?0:1,transition:"opacity 0.15s ease-in-out"}})]})}function GrapejsCanvas(props){var _pages$2;var existingContext=usePageContext();if(existingContext){return/*#__PURE__*/_jsx(GrapejsCanvasInternal,_extends({},props))}var normalizedJson=normalizeMultiPageJson(props.json);var pages=normalizedJson.pages.map(extractPageMetadata);var initialPageId=props.currentPageId||((_pages$2=pages[0])==null?void 0:_pages$2.id)||"";return/*#__PURE__*/_jsx(PageProvider,{pages:pages,initialPageId:initialPageId,onPageChange:props.onPageChange,children:/*#__PURE__*/_jsx(GrapejsCanvasInternal,_extends({},props))})}export default GrapejsCanvas;
13
13
  //# sourceMappingURL=GrapesjsCanvas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GrapesjsCanvas.js","names":["React","forwardRef","useEffect","useImperativeHandle","useRef","useState","grapesjs","tailwind","TypesToRegister","toKebabCase","tailwindCompiledCss","datePickerCss","extractPageMetadata","getCurrentPage","mergeStyles","normalizeMultiPageJson","createGrapesjsShadcnGenericPlugin","StyledEditor","PageProvider","usePageContext","jsx","_jsx","jsxs","_jsxs","isEditorCanvasReady","editor","canvas","Canvas","canvasDoc","getDocument","canvasBody","body","_unused","safeStoreEditor","_x","_safeStoreEditor","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee6","_editor$Pages","wrapper","pages","wrap","_callee6$","_context6","prev","next","getWrapper","abrupt","Pages","getAll","length","store","sent","t0","console","warn","stop","setComponentProperties","isPreview","isStreaming","setPropertiesRecursively","comp","isMutable","set","editable","draggable","droppable","getName","selectable","hoverable","highlightable","copyable","resizable","removable","badgable","_extends","get","isEditable","attributes","command","components","forEach","find","runCommand","stopCommand","convertStyles","stylesArray","map","block","selectors","Array","isArray","join","declarations","Object","entries","style","_ref","prop","value","createActionCardConfig","action","icon","title","description","type","componentName","componentProps","headerContent","bodyContent","expandActions","node","_node$componentProps","actions","classes","concat","undefined","i","id","setInteracting","renderedComponents","inProgress","component","componentId","showLoader","gjsModel","interactionApiInProgress","expandActionsComponent","model","append","addClass","resetStreamingComponent","attrs","props","cleanedProps","data","rows","series","pagination","error","isMissing","loading","GrapejsCanvasInternal","_ref2","_pages$","json","_ref2$mode","mode","setEditor","performInteraction","downloadTable","_ref2$newDataNotifier","newDataNotifier","_ref2$setHasChanged","setHasChanged","_ref2$isModeChangeFro","isModeChangeFromToggle","_ref2$isTemplateView","isTemplateView","externalCurrentPageId","currentPageId","externalOnPageChange","onPageChange","onRequestPageData","imperativeRef","pageContext","normalizedJson","effectiveCurrentPageId","editorRef","editorInstance","pageDataCache","currentPageIdRef","isStreamingRef","modeRef","isSystemUpdateRef","lastJsonRef","isEditorAliveRef","onRequestPageDataRef","rowNavigationContextRef","_useState","isTransitioning","setIsTransitioning","current","notificationHandler","_model$get","compId","_props$newProps","newProps","_props$newAttributes","newAttributes","pageId","timestamp","Date","now","filteredProps","keys","key","name","parsedNewProps","isActionsComponent","hasValidActionsData","_model$components$at","isAlreadyExpanded","at","headerMapper","currentAttrs","hasRealValue","shouldStopLoading","view","render","handleNavigateToPage","targetPageId","rowContext","navigateToPage","downloadTableWrapper","_x2","_downloadTableWrapper","_callee4","updatedJson","_callee4$","_context4","performInteractionWrapper","_x3","_performInteractionWrapper","_callee5","payload","_payload$json","apiResponse","componentUpdates","_callee5$","_context5","affectedComponents","_ref8","errorMessage","Error","message","finish","performInteractionWithLoaders","destroy","currentMode","init","container","height","plugins","storageManager","richTextEditor","customBadgeLabel","tagName","injectionAttempts","injectStylesEarly","_editor$Canvas","iframeDoc","head","querySelector","createElement","fullCss","innerHTML","setAttribute","appendChild","requestAnimationFrame","checkDirty","_checkDirty","_callee2","stored","newJson","_callee2$","_context2","JSON","stringify","debouncedCheckDirty","timeout","clearTimeout","setTimeout","evt","on","includes","_callee","canvasHead","storeResult","_callee$","_context","_ref4","DomComponents","getType","addType","defaults","cleanup","_json$pages","_currentPage$frames","_editorInstance$curre3","pageNormalizedJson","currentPage","frames","raw","processed","_editorInstance$curre","setComponents","_editorInstance$curre2","domComponents","_domComponents$getWra","allComponents","findType","_comp$view","globalStyles","styles","pageStyles","mergedStyles","cssText","setStyle","_rowNavigationContext","isMultiPage","Boolean","cachedData","_ref5","updatedAttributes","cacheCheckInterval","setInterval","appliedAny","_ref6","clearInterval","_callee3","_callee3$","_context3","shadcnComponents","currentIsStreaming","prevIsStreaming","Fragment","children","ref","opacity","transition","GrapejsCanvas","_pages$2","existingContext","initialPageId"],"sources":["../src/GrapesjsCanvas.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';\n// eslint-disable-next-line import/no-named-as-default\nimport grapesjs, { Component, Editor } from 'grapesjs';\nimport 'grapesjs/dist/css/grapes.min.css';\nimport tailwind from 'grapesjs-tailwind';\n\nimport { TypesToRegister } from './constants';\nimport { toKebabCase } from './helpers';\nimport { tailwindCompiledCss } from './helpers/css';\nimport { datePickerCss } from './helpers/date-picker';\nimport {\n extractPageMetadata,\n getCurrentPage,\n mergeStyles,\n normalizeMultiPageJson,\n} from './helpers/page-utils';\nimport { createGrapesjsShadcnGenericPlugin } from './plugins/grapejs-plugin';\nimport { StyledEditor } from './index.styles';\nimport type { PageAwareProps } from './types/page';\nimport { PageProvider, usePageContext } from './contexts/PageContext';\n\ntype NotificationHandler = (newData: {\n componentId: string;\n newProps: Record<string, any>;\n newAttributes: Record<string, any>;\n}) => boolean;\n\ntype GrapesjsCanvasProps = {\n json: any;\n mode?: 'editor' | 'preview';\n setEditor: (editor: Editor) => void;\n performInteraction: (payload: Record<string, any>) => Promise<Record<string, any> | undefined>;\n downloadTable?: (data: {\n tableId: string;\n title: string;\n limit: number;\n json: any;\n headerMapper?: Record<string, string>;\n }) => Promise<void>;\n newDataNotifier: (notifHandler: NotificationHandler) => void;\n setHasChanged: (hasChanged: boolean) => void;\n isStreaming: boolean;\n isModeChangeFromToggle?: boolean;\n isTemplateView?: boolean;\n} & PageAwareProps;\n\nexport interface GrapesjsCanvasHandle {\n performInteractionWithLoaders: (payload: Record<string, any>) => Promise<Record<string, any> | undefined>;\n}\n\nfunction isEditorCanvasReady(editor: Editor): boolean {\n try {\n const canvas = editor.Canvas;\n\n if (!canvas) {\n return false;\n }\n\n const canvasDoc = canvas.getDocument?.();\n\n if (!canvasDoc) {\n return false;\n }\n\n const canvasBody = canvasDoc.body;\n\n if (!canvasBody) {\n return false;\n }\n\n return true;\n } catch {\n return false;\n }\n}\n\nasync function safeStoreEditor(editor: Editor): Promise<any | null> {\n try {\n const wrapper = editor.getWrapper();\n\n if (!wrapper) {\n return null;\n }\n\n const pages = editor.Pages?.getAll?.() || [];\n\n if (pages.length === 0) {\n return null;\n }\n\n return await editor.store();\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn('Error during store operation:', error);\n\n return null;\n }\n}\n\nfunction setComponentProperties(editor: Editor, isPreview: boolean, isStreaming: boolean): void {\n if (!editor) {\n return;\n }\n\n function setPropertiesRecursively(comp: Component) {\n if (!comp) {\n return;\n }\n\n const isMutable = !isPreview && !isStreaming;\n\n comp.set({\n editable: isMutable,\n draggable: isMutable,\n droppable: isMutable && comp.getName() !== 'Shadcn-generic',\n selectable: isMutable,\n hoverable: isMutable,\n highlightable: isMutable,\n copyable: false,\n resizable: false,\n removable: isMutable,\n badgable: false,\n });\n\n comp.set('attributes', {\n ...(comp.get('attributes') || {}),\n isEditable: isMutable,\n });\n\n if (isMutable) {\n comp.set('toolbar', [\n { attributes: { class: 'fa fa-arrows' }, command: 'tlb-move' },\n { attributes: { class: 'fa fa-trash' }, command: 'tlb-delete' },\n ]);\n } else {\n comp.set('toolbar', []);\n }\n\n comp.components().forEach(setPropertiesRecursively);\n }\n\n const wrapper = editor.getWrapper();\n const components = wrapper?.find('*') || [];\n\n components.forEach(setPropertiesRecursively);\n\n if (isEditorCanvasReady(editor)) {\n if (isPreview) {\n editor.runCommand('core:preview');\n } else {\n editor.stopCommand('core:preview');\n }\n }\n}\n\nfunction convertStyles(stylesArray: any[]): string {\n return stylesArray\n .map((block) => {\n const selectors = Array.isArray(block.selectors)\n ? block.selectors.join(', ')\n : block.selectors;\n const declarations = Object.entries(block.style)\n .map(([prop, value]) => `${toKebabCase(prop)}: ${value};`)\n .join(' ');\n\n return `${selectors} { ${declarations} }`;\n })\n .join('\\n');\n}\n\nfunction createActionCardConfig(action: any): any {\n const { icon, title, description } = action;\n\n return {\n type: 'shadcn-generic',\n componentName: 'ActionCard',\n badgable: false,\n copyable: false,\n removable: true,\n draggable: true,\n componentProps: {\n icon,\n headerContent: title,\n bodyContent: description,\n },\n };\n}\n\nfunction expandActions(node: any): any {\n if (node.type === 'shadcn-generic' && node.componentName === 'Actions') {\n const actions = node.componentProps?.actions;\n\n if (Array.isArray(actions) && actions.length > 0) {\n return {\n ...node,\n type: 'div',\n classes: ['dashboard-cards', ...(node.classes || [])],\n componentName: undefined,\n componentProps: undefined,\n components: actions.map((action: any, i: number) => ({\n ...createActionCardConfig(action),\n id: `${node.id}--action-card-${i}`,\n })),\n };\n }\n\n return node;\n }\n\n if (Array.isArray(node.components)) {\n return {\n ...node,\n components: node.components.map(expandActions),\n };\n }\n\n return node;\n}\n\nfunction setInteracting(\n renderedComponents: Record<string, Component>,\n components: { componentId: string; showLoader: boolean }[],\n inProgress: boolean,\n) {\n components.forEach((component) => {\n const { componentId, showLoader } = component;\n\n if (!showLoader) {\n return;\n }\n\n const gjsModel = renderedComponents[componentId];\n\n if (gjsModel) {\n gjsModel.set('attributes', {\n ...gjsModel.get('attributes'),\n interactionApiInProgress: inProgress,\n });\n }\n });\n}\n\nfunction expandActionsComponent(model: Component, actions: any[]): void {\n model.components('');\n\n actions.forEach((action: any) => {\n model.append(createActionCardConfig(action));\n });\n\n model.set('type', 'div');\n model.addClass('dashboard-cards');\n model.set('componentName', undefined);\n model.set('componentProps', {});\n}\n\nfunction resetStreamingComponent(comp: Component): void {\n const attrs = comp.get('attributes') || {};\n const props = comp.get('componentProps') || {};\n\n const cleanedProps = { ...props };\n\n delete cleanedProps.bodyContent;\n delete cleanedProps.data;\n delete cleanedProps.rows;\n delete cleanedProps.series;\n delete cleanedProps.pagination;\n delete cleanedProps.error;\n delete cleanedProps.isMissing;\n\n comp.set({\n attributes: {\n ...attrs,\n loading: true,\n error: undefined,\n isMissing: undefined,\n },\n componentProps: cleanedProps,\n });\n}\n\nfunction GrapejsCanvasInternal({\n json,\n mode = 'preview',\n setEditor,\n performInteraction,\n downloadTable,\n newDataNotifier = () => {\n // no op\n },\n setHasChanged = () => {\n // no op\n },\n isStreaming,\n isModeChangeFromToggle = false,\n isTemplateView = false,\n currentPageId: externalCurrentPageId,\n onPageChange: externalOnPageChange, // eslint-disable-line @typescript-eslint/no-unused-vars\n onRequestPageData,\n imperativeRef,\n}: GrapesjsCanvasProps & { imperativeRef?: React.Ref<GrapesjsCanvasHandle> }) {\n const pageContext = usePageContext();\n\n const normalizedJson = normalizeMultiPageJson(json);\n const pages = normalizedJson.pages.map(extractPageMetadata);\n const effectiveCurrentPageId =\n externalCurrentPageId || pageContext?.currentPageId || pages[0]?.id || '';\n\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<Editor | null>(null);\n const renderedComponents = useRef<Record<string, Component>>({});\n const pageDataCache = useRef<Record<string, Record<string, any>>>({});\n const currentPageIdRef = useRef<string>(effectiveCurrentPageId);\n const isStreamingRef = useRef(isStreaming ?? false);\n const modeRef = useRef(mode);\n const isSystemUpdateRef = useRef(false);\n const lastJsonRef = useRef<string>('');\n const isEditorAliveRef = useRef(false);\n const onRequestPageDataRef = useRef(onRequestPageData);\n const rowNavigationContextRef = useRef<Record<string, any> | null>(null);\n const [isTransitioning, setIsTransitioning] = useState(false);\n\n useEffect(() => {\n currentPageIdRef.current = effectiveCurrentPageId;\n }, [effectiveCurrentPageId]);\n\n useEffect(() => {\n isStreamingRef.current = isStreaming ?? false;\n }, [isStreaming ?? false]);\n\n useEffect(() => {\n modeRef.current = mode;\n }, [mode]);\n\n useEffect(() => {\n onRequestPageDataRef.current = onRequestPageData;\n }, [onRequestPageData]);\n\n function notificationHandler(\n props: Parameters<NotificationHandler>[0],\n ): ReturnType<NotificationHandler> {\n if (!props) {\n return true;\n }\n\n const { componentId: compId, newProps = {}, newAttributes = {} } = props;\n\n const model = renderedComponents.current[compId];\n\n if (!model) {\n const pageId = currentPageIdRef.current;\n\n if (pageId) {\n if (!pageDataCache.current[pageId]) {\n pageDataCache.current[pageId] = {};\n }\n\n pageDataCache.current[pageId][compId] = {\n newProps,\n newAttributes,\n timestamp: Date.now(),\n };\n }\n\n return false;\n }\n\n // Filter out complex placeholder objects by setting them to null\n // This ensures placeholder values are properly cleared and don't cause stale data issues\n const filteredProps = { ...newProps };\n\n Object.keys(filteredProps).forEach((key) => {\n const value = filteredProps[key];\n\n if (value && typeof value === 'object' && value.name === '__peak_placeholder') {\n filteredProps[key] = null;\n }\n });\n\n const parsedNewProps = {\n ...filteredProps,\n };\n\n if (filteredProps.pagination) {\n parsedNewProps.pagination = {\n ...(model.get('componentProps').pagination || {}),\n ...filteredProps.pagination,\n };\n }\n\n // Handle Actions component: expand into ActionCards when data arrives via streaming\n const isActionsComponent = model.get('componentName') === 'Actions';\n const hasValidActionsData =\n parsedNewProps.actions &&\n parsedNewProps.actions !== null &&\n Array.isArray(parsedNewProps.actions) &&\n parsedNewProps.actions.length > 0;\n\n if (isActionsComponent && hasValidActionsData) {\n const isAlreadyExpanded =\n model.components().length > 0 &&\n model.components().at(0)?.get('componentName') === 'ActionCard';\n\n if (!isAlreadyExpanded && editorInstance.current && isEditorAliveRef.current) {\n expandActionsComponent(model, parsedNewProps.actions);\n\n return true;\n }\n }\n\n model.set('componentProps', {\n ...model.get('componentProps'),\n ...parsedNewProps,\n headerMapper: model.get('componentProps')?.headerMapper || parsedNewProps.headerMapper,\n });\n\n const currentAttrs = model.get('attributes') || {};\n\n const hasRealValue =\n (parsedNewProps?.bodyContent !== undefined && parsedNewProps?.bodyContent !== null) ||\n (parsedNewProps?.data !== undefined && parsedNewProps?.data !== null) ||\n (parsedNewProps?.rows !== undefined && parsedNewProps?.rows !== null) ||\n (parsedNewProps?.series !== undefined && parsedNewProps?.series !== null);\n\n const shouldStopLoading = hasRealValue || newAttributes?.error || parsedNewProps?.isMissing;\n\n model.set('attributes', {\n ...currentAttrs,\n ...newAttributes,\n ...(shouldStopLoading ? { loading: false } : {}),\n });\n\n if (model.view) {\n model.view.render();\n }\n\n return true;\n }\n\n useEffect(() => {\n newDataNotifier(notificationHandler);\n }, []);\n\n function handleNavigateToPage(targetPageId: string, rowContext?: Record<string, any>) {\n rowNavigationContextRef.current = rowContext ?? null;\n\n if (externalOnPageChange) {\n externalOnPageChange(targetPageId, rowContext);\n }\n\n if (pageContext) {\n pageContext.navigateToPage(targetPageId, rowContext);\n }\n }\n\n async function downloadTableWrapper(data: {\n tableId: string;\n title: string;\n limit: number;\n headerMapper?: Record<string, string>;\n }) {\n if (!downloadTable) {\n return;\n }\n\n let updatedJson = null;\n\n if (editorInstance.current) {\n updatedJson = await safeStoreEditor(editorInstance.current);\n }\n\n await downloadTable({ ...data, json: updatedJson });\n }\n\n async function performInteractionWrapper(payload: Record<string, any>) {\n let updatedJson = payload.json ?? null;\n\n if (!updatedJson && editorInstance.current) {\n updatedJson = await safeStoreEditor(editorInstance.current);\n }\n\n setInteracting(renderedComponents.current, payload.affectedComponents, true);\n\n try {\n const apiResponse = await performInteraction({\n ...payload,\n json: updatedJson,\n });\n\n const componentUpdates = apiResponse || {};\n\n Object.entries(componentUpdates).forEach(([key, value]) => {\n const model = renderedComponents.current[key];\n\n if (model) {\n model.set('attributes', {\n ...model.get('attributes'),\n error: undefined,\n });\n\n model.set('componentProps', {\n ...model.get('componentProps'),\n ...value,\n error: undefined,\n isMissing: undefined,\n });\n }\n });\n\n return componentUpdates;\n } catch (error) {\n payload.affectedComponents.forEach((component: { componentId: string; showLoader: boolean }) => {\n const model = renderedComponents.current[component.componentId];\n\n if (model) {\n const errorMessage =\n error instanceof Error ? error.message : 'Something went wrong. Please try again.';\n\n model.set('attributes', {\n ...model.get('attributes'),\n error: errorMessage,\n });\n\n model.set('componentProps', {\n ...model.get('componentProps'),\n error: errorMessage,\n isMissing: undefined,\n });\n }\n });\n\n throw error;\n } finally {\n setInteracting(renderedComponents.current, payload.affectedComponents, false);\n }\n }\n\n useImperativeHandle(imperativeRef, () => ({\n performInteractionWithLoaders: performInteractionWrapper,\n }), []);\n\n useEffect(() => {\n if (!editorRef.current) {\n return () => {\n // no op\n };\n }\n\n if (editorInstance.current) {\n editorInstance.current.destroy();\n editorInstance.current = null;\n isEditorAliveRef.current = false;\n }\n\n const currentMode = modeRef.current;\n\n const editor = grapesjs.init({\n container: editorRef.current,\n height: '100%',\n plugins: [\n tailwind,\n createGrapesjsShadcnGenericPlugin(\n modeRef,\n performInteractionWrapper,\n renderedComponents.current,\n setHasChanged,\n isTemplateView,\n isStreamingRef,\n handleNavigateToPage,\n downloadTableWrapper,\n ),\n ],\n storageManager: { type: 'none' },\n richTextEditor: {\n actions: ['bold', 'italic', 'underline', 'strikethrough'],\n },\n canvas: {\n customBadgeLabel: (component) => {\n const tagName = component.get('tagName');\n\n return tagName === 'body' ? '' : tagName || '';\n },\n },\n });\n\n isEditorAliveRef.current = true;\n\n let injectionAttempts = 0;\n\n function injectStylesEarly() {\n const iframeDoc = editor.Canvas?.getDocument?.();\n\n if (iframeDoc && iframeDoc.head) {\n if (!iframeDoc.head.querySelector('[data-grapesjs-styles]')) {\n const style = iframeDoc.createElement('style');\n const fullCss = `\n ${tailwindCompiledCss}\n ${datePickerCss}\n ::-webkit-scrollbar {\n width: 0px;\n height: 0px;\n }\n html, body {\n overflow: auto !important;\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n }\n `;\n style.innerHTML = fullCss;\n style.setAttribute('type', 'text/css');\n style.setAttribute('data-grapesjs-styles', 'true');\n iframeDoc.head.appendChild(style);\n }\n } else if (injectionAttempts < 50) {\n injectionAttempts += 1;\n requestAnimationFrame(injectStylesEarly);\n }\n }\n\n requestAnimationFrame(injectStylesEarly);\n\n async function checkDirty() {\n if (isStreamingRef.current || isSystemUpdateRef.current) {\n return;\n }\n\n if (!isEditorAliveRef.current || !editorInstance.current) {\n return;\n }\n\n let stored = null;\n\n stored = await safeStoreEditor(editorInstance.current);\n\n if (!stored) {\n return;\n }\n\n const newJson = JSON.stringify(stored);\n\n if (newJson !== lastJsonRef.current) {\n setHasChanged(true);\n lastJsonRef.current = newJson;\n }\n }\n\n const debouncedCheckDirty = (() => {\n let timeout: NodeJS.Timeout | null = null;\n\n return () => {\n if (timeout) {\n clearTimeout(timeout);\n }\n\n timeout = setTimeout(checkDirty, 200);\n };\n })();\n\n [\n 'component:add',\n 'component:remove',\n 'component:update:content',\n 'style:update',\n 'component:drag:end',\n 'rte:change',\n ].forEach((evt) => {\n editor.on(evt, debouncedCheckDirty);\n });\n\n editor.on('component:update', (model, prop) => {\n if (['attributes', 'componentProps', 'content'].includes(prop)) {\n debouncedCheckDirty();\n }\n });\n\n // Tailwind CSS rules aren't fully added to our component\n // So, adding them from here!\n editor.on('load', async () => {\n const canvasDoc = editor.Canvas.getDocument();\n const canvasHead = canvasDoc.head;\n\n if (!canvasHead.querySelector('[data-grapesjs-styles]')) {\n const style = canvasDoc.createElement('style');\n const fullCss = `\n ${tailwindCompiledCss}\n ${datePickerCss}\n ::-webkit-scrollbar {\n width: 0px;\n height: 0px;\n }\n html, body {\n overflow: auto !important;\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n }\n `;\n style.innerHTML = fullCss;\n style.setAttribute('type', 'text/css');\n style.setAttribute('data-grapesjs-styles', 'true');\n canvasHead.appendChild(style);\n }\n\n isSystemUpdateRef.current = true;\n const storeResult = await safeStoreEditor(editor);\n\n if (storeResult) {\n lastJsonRef.current = JSON.stringify(storeResult);\n }\n\n isSystemUpdateRef.current = false;\n\n setComponentProperties(editor, currentMode === 'preview', isStreamingRef.current);\n });\n\n editorInstance.current = editor;\n\n if (setEditor) {\n setEditor(editor);\n }\n\n TypesToRegister.forEach(({ type, tagName }) => {\n if (!editor.DomComponents.getType(type)) {\n editor.DomComponents.addType(type, {\n model: {\n defaults: { tagName },\n },\n view: {},\n });\n }\n });\n\n return function cleanup() {\n editor.destroy();\n isEditorAliveRef.current = false;\n };\n }, []);\n\n useEffect(() => {\n if (json && json.pages?.length > 0) {\n if (!isEditorAliveRef.current || !editorInstance.current) {\n return;\n }\n\n const pageNormalizedJson = normalizeMultiPageJson(json);\n\n const currentPage = getCurrentPage(pageNormalizedJson.pages, effectiveCurrentPageId);\n\n if (!currentPage || !currentPage.frames?.length) {\n return;\n }\n\n isSystemUpdateRef.current = true;\n const raw = currentPage.frames[0].component;\n const processed = expandActions(raw);\n\n try {\n editorInstance.current?.setComponents(processed);\n\n setTimeout(() => {\n if (editorInstance.current && isEditorAliveRef.current) {\n const domComponents = editorInstance.current?.DomComponents;\n\n if (domComponents) {\n const allComponents = domComponents?.getWrapper()?.findType('shadcn-generic');\n allComponents?.forEach((comp: any) => {\n if (comp.get('componentName') === 'Tabs') {\n comp.view?.render();\n }\n });\n }\n }\n }, 100);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error during component restoration:', error);\n }\n\n const globalStyles = pageNormalizedJson.styles || [];\n const pageStyles = currentPage.styles || [];\n const mergedStyles = mergeStyles(globalStyles, pageStyles);\n const cssText = convertStyles(mergedStyles);\n editorInstance.current?.setStyle(cssText);\n\n if (onRequestPageDataRef.current) {\n const isMultiPage = Boolean(pageNormalizedJson.isMultiPage);\n const pageId = isMultiPage ? currentPage.id : '';\n const rowContext = rowNavigationContextRef.current ?? undefined;\n\n onRequestPageDataRef.current(pageId, [], rowContext);\n rowNavigationContextRef.current = null;\n }\n\n if (editorInstance.current) {\n setComponentProperties(editorInstance.current, mode === 'preview', isStreaming);\n\n setTimeout(() => {\n if (editorInstance.current && isEditorAliveRef.current && mode === 'preview') {\n setComponentProperties(editorInstance.current, true, isStreaming);\n }\n }, 50);\n }\n\n setTimeout(() => {\n if (currentPage && pageDataCache.current[currentPage.id]) {\n const cachedData = pageDataCache.current[currentPage.id];\n\n Object.entries(cachedData).forEach(([componentId, data]) => {\n const model = renderedComponents.current[componentId];\n\n if (model && data) {\n if (data.newProps) {\n model.set('componentProps', {\n ...model.get('componentProps'),\n ...data.newProps,\n });\n }\n\n const updatedAttributes = {\n ...model.get('attributes'),\n ...(data.newAttributes || {}),\n };\n\n model.set('attributes', updatedAttributes);\n\n if (model.view) {\n model.view.render();\n }\n }\n });\n\n delete pageDataCache.current[currentPage.id];\n }\n }, 150);\n\n const cacheCheckInterval = setInterval(() => {\n if (!currentPage || !pageDataCache.current[currentPage.id]) {\n return;\n }\n\n const cachedData = pageDataCache.current[currentPage.id];\n let appliedAny = false;\n\n Object.entries(cachedData).forEach(([componentId, data]) => {\n const model = renderedComponents.current[componentId];\n\n if (model && data) {\n if (data.newProps) {\n model.set('componentProps', {\n ...model.get('componentProps'),\n ...data.newProps,\n });\n }\n\n const updatedAttributes = {\n ...model.get('attributes'),\n ...(data.newAttributes || {}),\n };\n\n model.set('attributes', updatedAttributes);\n\n if (model.view) {\n model.view.render();\n }\n\n appliedAny = true;\n }\n });\n\n if (appliedAny) {\n Object.keys(cachedData).forEach((componentId) => {\n if (renderedComponents.current[componentId]) {\n delete cachedData[componentId];\n }\n });\n\n if (Object.keys(cachedData).length === 0) {\n delete pageDataCache.current[currentPage.id];\n }\n }\n }, 100);\n\n setTimeout(() => {\n clearInterval(cacheCheckInterval);\n }, 5000);\n\n setTimeout(async () => {\n if (editorInstance.current && isEditorAliveRef.current) {\n const storeResult = await safeStoreEditor(editorInstance.current);\n\n if (storeResult) {\n lastJsonRef.current = JSON.stringify(storeResult);\n }\n\n isSystemUpdateRef.current = false;\n }\n }, 100);\n }\n }, [json, effectiveCurrentPageId]);\n\n useEffect(() => {\n const editor = editorInstance.current;\n\n if (!editor || !isEditorAliveRef.current) {\n return;\n }\n\n if (isModeChangeFromToggle) {\n setIsTransitioning(true);\n }\n\n setComponentProperties(\n editorInstance.current as Editor,\n mode === 'preview',\n isStreaming ?? false,\n );\n\n const wrapper = editor.getWrapper();\n const shadcnComponents = wrapper?.find('[data-gjs-type=\"shadcn-generic\"]') || [];\n\n shadcnComponents.forEach((comp: Component) => {\n if (comp.view && typeof comp.view.render === 'function') {\n comp.view.render();\n }\n });\n\n if (isModeChangeFromToggle) {\n requestAnimationFrame(() => {\n setIsTransitioning(false);\n });\n }\n }, [mode, isStreaming ?? false]);\n\n useEffect(() => {\n const editor = editorInstance.current;\n const currentIsStreaming = isStreaming ?? false;\n const prevIsStreaming = isStreamingRef.current;\n\n if (editor && isEditorAliveRef.current && currentIsStreaming && !prevIsStreaming) {\n const wrapper = editor.getWrapper();\n const shadcnComponents = wrapper?.findType('shadcn-generic') || [];\n\n shadcnComponents.forEach((comp: Component) => {\n resetStreamingComponent(comp);\n });\n }\n\n isStreamingRef.current = currentIsStreaming;\n }, [isStreaming]);\n\n return (\n <React.Fragment>\n <StyledEditor />\n <div\n ref={editorRef}\n id=\"grapesjs-editor\"\n style={{\n opacity: isTransitioning ? 0 : 1,\n transition: 'opacity 0.15s ease-in-out',\n }}\n />\n </React.Fragment>\n );\n}\n\nconst GrapejsCanvas = forwardRef<GrapesjsCanvasHandle, GrapesjsCanvasProps>(\n (props, ref) => {\n const existingContext = usePageContext();\n\n if (existingContext) {\n return <GrapejsCanvasInternal {...props} imperativeRef={ref} />;\n }\n\n const normalizedJson = normalizeMultiPageJson(props.json);\n const pages = normalizedJson.pages.map(extractPageMetadata);\n const initialPageId = props.currentPageId || pages[0]?.id || '';\n\n return (\n <PageProvider pages={pages} initialPageId={initialPageId} onPageChange={props.onPageChange}>\n <GrapejsCanvasInternal {...props} imperativeRef={ref} />\n </PageProvider>\n );\n }\n);\n\nexport default GrapejsCanvas;\n"],"mappings":"wLAAA,uDACA,MAAO,CAAAA,KAAK,EAAIC,UAAU,CAAEC,SAAS,CAAEC,mBAAmB,CAAEC,MAAM,CAAEC,QAAQ,KAAQ,OAAO,CAC3F;AACA,MAAO,CAAAC,QAAQ,KAA6B,UAAU,CACtD,M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AAE,CAAC,CAC5C,CAElB,CACF,CAAC,CAED,cAAe,CAAAG,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"GrapesjsCanvas.js","names":["React","useEffect","useRef","useState","grapesjs","tailwind","TypesToRegister","toKebabCase","tailwindCompiledCss","datePickerCss","extractPageMetadata","getCurrentPage","mergeStyles","normalizeMultiPageJson","createGrapesjsShadcnGenericPlugin","StyledEditor","PageProvider","usePageContext","jsx","_jsx","jsxs","_jsxs","isEditorCanvasReady","editor","canvas","Canvas","canvasDoc","getDocument","canvasBody","body","_unused","safeStoreEditor","_x","_safeStoreEditor","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee6","_editor$Pages","wrapper","pages","wrap","_callee6$","_context6","prev","next","getWrapper","abrupt","Pages","getAll","length","store","sent","t0","console","warn","stop","setComponentProperties","isPreview","isStreaming","setPropertiesRecursively","comp","isMutable","set","editable","draggable","droppable","getName","selectable","hoverable","highlightable","copyable","resizable","removable","badgable","_extends","get","isEditable","attributes","command","components","forEach","find","runCommand","stopCommand","convertStyles","stylesArray","map","block","selectors","Array","isArray","join","declarations","Object","entries","style","_ref","prop","value","createActionCardConfig","action","icon","title","description","type","componentName","componentProps","headerContent","bodyContent","expandActions","node","_node$componentProps","actions","classes","concat","undefined","i","id","setInteracting","renderedComponents","inProgress","component","componentId","showLoader","gjsModel","interactionApiInProgress","expandActionsComponent","model","append","addClass","resetStreamingComponent","attrs","props","cleanedProps","data","rows","series","pagination","error","isMissing","loading","GrapejsCanvasInternal","_ref2","_pages$","json","_ref2$mode","mode","setEditor","performInteraction","downloadTable","_ref2$newDataNotifier","newDataNotifier","_ref2$setHasChanged","setHasChanged","_ref2$isModeChangeFro","isModeChangeFromToggle","_ref2$isTemplateView","isTemplateView","externalCurrentPageId","currentPageId","externalOnPageChange","onPageChange","onRequestPageData","pageContext","normalizedJson","effectiveCurrentPageId","editorRef","editorInstance","pageDataCache","currentPageIdRef","isStreamingRef","modeRef","isSystemUpdateRef","lastJsonRef","isEditorAliveRef","onRequestPageDataRef","rowNavigationContextRef","_useState","isTransitioning","setIsTransitioning","current","notificationHandler","_model$get","compId","_props$newProps","newProps","_props$newAttributes","newAttributes","pageId","timestamp","Date","now","filteredProps","keys","key","name","parsedNewProps","isActionsComponent","hasValidActionsData","_model$components$at","isAlreadyExpanded","at","headerMapper","currentAttrs","hasRealValue","shouldStopLoading","view","render","handleNavigateToPage","targetPageId","rowContext","navigateToPage","downloadTableWrapper","_x2","_downloadTableWrapper","_callee4","updatedJson","_callee4$","_context4","performInteractionWrapper","_x3","_performInteractionWrapper","_callee5","payload","apiResponse","componentUpdates","_callee5$","_context5","affectedComponents","_ref8","errorMessage","Error","message","finish","destroy","currentMode","init","container","height","plugins","storageManager","richTextEditor","customBadgeLabel","tagName","injectionAttempts","injectStylesEarly","_editor$Canvas","iframeDoc","head","querySelector","createElement","fullCss","innerHTML","setAttribute","appendChild","requestAnimationFrame","checkDirty","_checkDirty","_callee2","stored","newJson","_callee2$","_context2","JSON","stringify","debouncedCheckDirty","timeout","clearTimeout","setTimeout","evt","on","includes","_callee","canvasHead","storeResult","_callee$","_context","_ref4","DomComponents","getType","addType","defaults","cleanup","_json$pages","_currentPage$frames","_editorInstance$curre3","pageNormalizedJson","currentPage","frames","raw","processed","_editorInstance$curre","setComponents","_editorInstance$curre2","domComponents","_domComponents$getWra","allComponents","findType","_comp$view","globalStyles","styles","pageStyles","mergedStyles","cssText","setStyle","_rowNavigationContext","isMultiPage","Boolean","cachedData","_ref5","updatedAttributes","cacheCheckInterval","setInterval","appliedAny","_ref6","clearInterval","_callee3","_callee3$","_context3","shadcnComponents","currentIsStreaming","prevIsStreaming","Fragment","children","ref","opacity","transition","GrapejsCanvas","_pages$2","existingContext","initialPageId"],"sources":["../src/GrapesjsCanvas.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useRef, useState } from 'react';\n// eslint-disable-next-line import/no-named-as-default\nimport grapesjs, { Component, Editor } from 'grapesjs';\nimport 'grapesjs/dist/css/grapes.min.css';\nimport tailwind from 'grapesjs-tailwind';\n\nimport { TypesToRegister } from './constants';\nimport { toKebabCase } from './helpers';\nimport { tailwindCompiledCss } from './helpers/css';\nimport { datePickerCss } from './helpers/date-picker';\nimport {\n extractPageMetadata,\n getCurrentPage,\n mergeStyles,\n normalizeMultiPageJson,\n} from './helpers/page-utils';\nimport { createGrapesjsShadcnGenericPlugin } from './plugins/grapejs-plugin';\nimport { StyledEditor } from './index.styles';\nimport type { PageAwareProps } from './types/page';\nimport { PageProvider, usePageContext } from './contexts/PageContext';\n\ntype NotificationHandler = (newData: {\n componentId: string;\n newProps: Record<string, any>;\n newAttributes: Record<string, any>;\n}) => boolean;\n\ntype GrapesjsCanvasProps = {\n json: any;\n mode?: 'editor' | 'preview';\n setEditor: (editor: Editor) => void;\n performInteraction: (payload: Record<string, any>) => Promise<Record<string, any> | undefined>;\n downloadTable?: (data: {\n tableId: string;\n title: string;\n limit: number;\n json: any;\n headerMapper?: Record<string, string>;\n }) => Promise<void>;\n newDataNotifier: (notifHandler: NotificationHandler) => void;\n setHasChanged: (hasChanged: boolean) => void;\n isStreaming: boolean;\n isModeChangeFromToggle?: boolean;\n isTemplateView?: boolean;\n} & PageAwareProps;\n\nfunction isEditorCanvasReady(editor: Editor): boolean {\n try {\n const canvas = editor.Canvas;\n\n if (!canvas) {\n return false;\n }\n\n const canvasDoc = canvas.getDocument?.();\n\n if (!canvasDoc) {\n return false;\n }\n\n const canvasBody = canvasDoc.body;\n\n if (!canvasBody) {\n return false;\n }\n\n return true;\n } catch {\n return false;\n }\n}\n\nasync function safeStoreEditor(editor: Editor): Promise<any | null> {\n try {\n const wrapper = editor.getWrapper();\n\n if (!wrapper) {\n return null;\n }\n\n const pages = editor.Pages?.getAll?.() || [];\n\n if (pages.length === 0) {\n return null;\n }\n\n return await editor.store();\n } catch (error) {\n // eslint-disable-next-line no-console\n console.warn('Error during store operation:', error);\n\n return null;\n }\n}\n\nfunction setComponentProperties(editor: Editor, isPreview: boolean, isStreaming: boolean): void {\n if (!editor) {\n return;\n }\n\n function setPropertiesRecursively(comp: Component) {\n if (!comp) {\n return;\n }\n\n const isMutable = !isPreview && !isStreaming;\n\n comp.set({\n editable: isMutable,\n draggable: isMutable,\n droppable: isMutable && comp.getName() !== 'Shadcn-generic',\n selectable: isMutable,\n hoverable: isMutable,\n highlightable: isMutable,\n copyable: false,\n resizable: false,\n removable: isMutable,\n badgable: false,\n });\n\n comp.set('attributes', {\n ...(comp.get('attributes') || {}),\n isEditable: isMutable,\n });\n\n if (isMutable) {\n comp.set('toolbar', [\n { attributes: { class: 'fa fa-arrows' }, command: 'tlb-move' },\n { attributes: { class: 'fa fa-trash' }, command: 'tlb-delete' },\n ]);\n } else {\n comp.set('toolbar', []);\n }\n\n comp.components().forEach(setPropertiesRecursively);\n }\n\n const wrapper = editor.getWrapper();\n const components = wrapper?.find('*') || [];\n\n components.forEach(setPropertiesRecursively);\n\n if (isEditorCanvasReady(editor)) {\n if (isPreview) {\n editor.runCommand('core:preview');\n } else {\n editor.stopCommand('core:preview');\n }\n }\n}\n\nfunction convertStyles(stylesArray: any[]): string {\n return stylesArray\n .map((block) => {\n const selectors = Array.isArray(block.selectors)\n ? block.selectors.join(', ')\n : block.selectors;\n const declarations = Object.entries(block.style)\n .map(([prop, value]) => `${toKebabCase(prop)}: ${value};`)\n .join(' ');\n\n return `${selectors} { ${declarations} }`;\n })\n .join('\\n');\n}\n\nfunction createActionCardConfig(action: any): any {\n const { icon, title, description } = action;\n\n return {\n type: 'shadcn-generic',\n componentName: 'ActionCard',\n badgable: false,\n copyable: false,\n removable: true,\n draggable: true,\n componentProps: {\n icon,\n headerContent: title,\n bodyContent: description,\n },\n };\n}\n\nfunction expandActions(node: any): any {\n if (node.type === 'shadcn-generic' && node.componentName === 'Actions') {\n const actions = node.componentProps?.actions;\n\n if (Array.isArray(actions) && actions.length > 0) {\n return {\n ...node,\n type: 'div',\n classes: ['dashboard-cards', ...(node.classes || [])],\n componentName: undefined,\n componentProps: undefined,\n components: actions.map((action: any, i: number) => ({\n ...createActionCardConfig(action),\n id: `${node.id}--action-card-${i}`,\n })),\n };\n }\n\n return node;\n }\n\n if (Array.isArray(node.components)) {\n return {\n ...node,\n components: node.components.map(expandActions),\n };\n }\n\n return node;\n}\n\nfunction setInteracting(\n renderedComponents: Record<string, Component>,\n components: { componentId: string; showLoader: boolean }[],\n inProgress: boolean,\n) {\n components.forEach((component) => {\n const { componentId, showLoader } = component;\n\n if (!showLoader) {\n return;\n }\n\n const gjsModel = renderedComponents[componentId];\n\n if (gjsModel) {\n gjsModel.set('attributes', {\n ...gjsModel.get('attributes'),\n interactionApiInProgress: inProgress,\n });\n }\n });\n}\n\nfunction expandActionsComponent(model: Component, actions: any[]): void {\n model.components('');\n\n actions.forEach((action: any) => {\n model.append(createActionCardConfig(action));\n });\n\n model.set('type', 'div');\n model.addClass('dashboard-cards');\n model.set('componentName', undefined);\n model.set('componentProps', {});\n}\n\nfunction resetStreamingComponent(comp: Component): void {\n const attrs = comp.get('attributes') || {};\n const props = comp.get('componentProps') || {};\n\n const cleanedProps = { ...props };\n\n delete cleanedProps.bodyContent;\n delete cleanedProps.data;\n delete cleanedProps.rows;\n delete cleanedProps.series;\n delete cleanedProps.pagination;\n delete cleanedProps.error;\n delete cleanedProps.isMissing;\n\n comp.set({\n attributes: {\n ...attrs,\n loading: true,\n error: undefined,\n isMissing: undefined,\n },\n componentProps: cleanedProps,\n });\n}\n\nfunction GrapejsCanvasInternal({\n json,\n mode = 'preview',\n setEditor,\n performInteraction,\n downloadTable,\n newDataNotifier = () => {\n // no op\n },\n setHasChanged = () => {\n // no op\n },\n isStreaming,\n isModeChangeFromToggle = false,\n isTemplateView = false,\n currentPageId: externalCurrentPageId,\n onPageChange: externalOnPageChange, // eslint-disable-line @typescript-eslint/no-unused-vars\n onRequestPageData,\n}: GrapesjsCanvasProps) {\n const pageContext = usePageContext();\n\n const normalizedJson = normalizeMultiPageJson(json);\n const pages = normalizedJson.pages.map(extractPageMetadata);\n const effectiveCurrentPageId =\n externalCurrentPageId || pageContext?.currentPageId || pages[0]?.id || '';\n\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<Editor | null>(null);\n const renderedComponents = useRef<Record<string, Component>>({});\n const pageDataCache = useRef<Record<string, Record<string, any>>>({});\n const currentPageIdRef = useRef<string>(effectiveCurrentPageId);\n const isStreamingRef = useRef(isStreaming ?? false);\n const modeRef = useRef(mode);\n const isSystemUpdateRef = useRef(false);\n const lastJsonRef = useRef<string>('');\n const isEditorAliveRef = useRef(false);\n const onRequestPageDataRef = useRef(onRequestPageData);\n const rowNavigationContextRef = useRef<Record<string, any> | null>(null);\n const [isTransitioning, setIsTransitioning] = useState(false);\n\n useEffect(() => {\n currentPageIdRef.current = effectiveCurrentPageId;\n }, [effectiveCurrentPageId]);\n\n useEffect(() => {\n isStreamingRef.current = isStreaming ?? false;\n }, [isStreaming ?? false]);\n\n useEffect(() => {\n modeRef.current = mode;\n }, [mode]);\n\n useEffect(() => {\n onRequestPageDataRef.current = onRequestPageData;\n }, [onRequestPageData]);\n\n function notificationHandler(\n props: Parameters<NotificationHandler>[0],\n ): ReturnType<NotificationHandler> {\n if (!props) {\n return true;\n }\n\n const { componentId: compId, newProps = {}, newAttributes = {} } = props;\n\n const model = renderedComponents.current[compId];\n\n if (!model) {\n const pageId = currentPageIdRef.current;\n\n if (pageId) {\n if (!pageDataCache.current[pageId]) {\n pageDataCache.current[pageId] = {};\n }\n\n pageDataCache.current[pageId][compId] = {\n newProps,\n newAttributes,\n timestamp: Date.now(),\n };\n }\n\n return false;\n }\n\n // Filter out complex placeholder objects by setting them to null\n // This ensures placeholder values are properly cleared and don't cause stale data issues\n const filteredProps = { ...newProps };\n\n Object.keys(filteredProps).forEach((key) => {\n const value = filteredProps[key];\n\n if (value && typeof value === 'object' && value.name === '__peak_placeholder') {\n filteredProps[key] = null;\n }\n });\n\n const parsedNewProps = {\n ...filteredProps,\n };\n\n if (filteredProps.pagination) {\n parsedNewProps.pagination = {\n ...(model.get('componentProps').pagination || {}),\n ...filteredProps.pagination,\n };\n }\n\n // Handle Actions component: expand into ActionCards when data arrives via streaming\n const isActionsComponent = model.get('componentName') === 'Actions';\n const hasValidActionsData =\n parsedNewProps.actions &&\n parsedNewProps.actions !== null &&\n Array.isArray(parsedNewProps.actions) &&\n parsedNewProps.actions.length > 0;\n\n if (isActionsComponent && hasValidActionsData) {\n const isAlreadyExpanded =\n model.components().length > 0 &&\n model.components().at(0)?.get('componentName') === 'ActionCard';\n\n if (!isAlreadyExpanded && editorInstance.current && isEditorAliveRef.current) {\n expandActionsComponent(model, parsedNewProps.actions);\n\n return true;\n }\n }\n\n model.set('componentProps', {\n ...model.get('componentProps'),\n ...parsedNewProps,\n headerMapper: model.get('componentProps')?.headerMapper || parsedNewProps.headerMapper,\n });\n\n const currentAttrs = model.get('attributes') || {};\n\n const hasRealValue =\n (parsedNewProps?.bodyContent !== undefined && parsedNewProps?.bodyContent !== null) ||\n (parsedNewProps?.data !== undefined && parsedNewProps?.data !== null) ||\n (parsedNewProps?.rows !== undefined && parsedNewProps?.rows !== null) ||\n (parsedNewProps?.series !== undefined && parsedNewProps?.series !== null);\n\n const shouldStopLoading = hasRealValue || newAttributes?.error || parsedNewProps?.isMissing;\n\n model.set('attributes', {\n ...currentAttrs,\n ...newAttributes,\n ...(shouldStopLoading ? { loading: false } : {}),\n });\n\n if (model.view) {\n model.view.render();\n }\n\n return true;\n }\n\n useEffect(() => {\n newDataNotifier(notificationHandler);\n }, []);\n\n function handleNavigateToPage(targetPageId: string, rowContext?: Record<string, any>) {\n rowNavigationContextRef.current = rowContext ?? null;\n\n if (externalOnPageChange) {\n externalOnPageChange(targetPageId, rowContext);\n }\n\n if (pageContext) {\n pageContext.navigateToPage(targetPageId, rowContext);\n }\n }\n\n async function downloadTableWrapper(data: {\n tableId: string;\n title: string;\n limit: number;\n headerMapper?: Record<string, string>;\n }) {\n if (!downloadTable) {\n return;\n }\n\n let updatedJson = null;\n\n if (editorInstance.current) {\n updatedJson = await safeStoreEditor(editorInstance.current);\n }\n\n await downloadTable({ ...data, json: updatedJson });\n }\n\n async function performInteractionWrapper(payload: Record<string, any>) {\n let updatedJson = null;\n\n if (editorInstance.current) {\n updatedJson = await safeStoreEditor(editorInstance.current);\n }\n\n setInteracting(renderedComponents.current, payload.affectedComponents, true);\n\n try {\n const apiResponse = await performInteraction({\n ...payload,\n json: updatedJson,\n });\n\n const componentUpdates = apiResponse || {};\n\n Object.entries(componentUpdates).forEach(([key, value]) => {\n const model = renderedComponents.current[key];\n\n if (model) {\n model.set('attributes', {\n ...model.get('attributes'),\n error: undefined,\n });\n\n model.set('componentProps', {\n ...model.get('componentProps'),\n ...value,\n error: undefined,\n isMissing: undefined,\n });\n }\n });\n\n return componentUpdates;\n } catch (error) {\n payload.affectedComponents.forEach((componentId: string) => {\n const model = renderedComponents.current[componentId];\n\n if (model) {\n const errorMessage =\n error instanceof Error ? error.message : 'Something went wrong. Please try again.';\n\n model.set('attributes', {\n ...model.get('attributes'),\n error: errorMessage,\n });\n\n model.set('componentProps', {\n ...model.get('componentProps'),\n error: errorMessage,\n isMissing: undefined,\n });\n }\n });\n\n throw error;\n } finally {\n setInteracting(renderedComponents.current, payload.affectedComponents, false);\n }\n }\n\n useEffect(() => {\n if (!editorRef.current) {\n return () => {\n // no op\n };\n }\n\n if (editorInstance.current) {\n editorInstance.current.destroy();\n editorInstance.current = null;\n isEditorAliveRef.current = false;\n }\n\n const currentMode = modeRef.current;\n\n const editor = grapesjs.init({\n container: editorRef.current,\n height: '100%',\n plugins: [\n tailwind,\n createGrapesjsShadcnGenericPlugin(\n modeRef,\n performInteractionWrapper,\n renderedComponents.current,\n setHasChanged,\n isTemplateView,\n isStreamingRef,\n handleNavigateToPage,\n downloadTableWrapper,\n ),\n ],\n storageManager: { type: 'none' },\n richTextEditor: {\n actions: ['bold', 'italic', 'underline', 'strikethrough'],\n },\n canvas: {\n customBadgeLabel: (component) => {\n const tagName = component.get('tagName');\n\n return tagName === 'body' ? '' : tagName || '';\n },\n },\n });\n\n isEditorAliveRef.current = true;\n\n let injectionAttempts = 0;\n\n function injectStylesEarly() {\n const iframeDoc = editor.Canvas?.getDocument?.();\n\n if (iframeDoc && iframeDoc.head) {\n if (!iframeDoc.head.querySelector('[data-grapesjs-styles]')) {\n const style = iframeDoc.createElement('style');\n const fullCss = `\n ${tailwindCompiledCss}\n ${datePickerCss}\n ::-webkit-scrollbar {\n width: 0px;\n height: 0px;\n }\n html, body {\n overflow: auto !important;\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n }\n `;\n style.innerHTML = fullCss;\n style.setAttribute('type', 'text/css');\n style.setAttribute('data-grapesjs-styles', 'true');\n iframeDoc.head.appendChild(style);\n }\n } else if (injectionAttempts < 50) {\n injectionAttempts += 1;\n requestAnimationFrame(injectStylesEarly);\n }\n }\n\n requestAnimationFrame(injectStylesEarly);\n\n async function checkDirty() {\n if (isStreamingRef.current || isSystemUpdateRef.current) {\n return;\n }\n\n if (!isEditorAliveRef.current || !editorInstance.current) {\n return;\n }\n\n let stored = null;\n\n stored = await safeStoreEditor(editorInstance.current);\n\n if (!stored) {\n return;\n }\n\n const newJson = JSON.stringify(stored);\n\n if (newJson !== lastJsonRef.current) {\n setHasChanged(true);\n lastJsonRef.current = newJson;\n }\n }\n\n const debouncedCheckDirty = (() => {\n let timeout: NodeJS.Timeout | null = null;\n\n return () => {\n if (timeout) {\n clearTimeout(timeout);\n }\n\n timeout = setTimeout(checkDirty, 200);\n };\n })();\n\n [\n 'component:add',\n 'component:remove',\n 'component:update:content',\n 'style:update',\n 'component:drag:end',\n 'rte:change',\n ].forEach((evt) => {\n editor.on(evt, debouncedCheckDirty);\n });\n\n editor.on('component:update', (model, prop) => {\n if (['attributes', 'componentProps', 'content'].includes(prop)) {\n debouncedCheckDirty();\n }\n });\n\n // Tailwind CSS rules aren't fully added to our component\n // So, adding them from here!\n editor.on('load', async () => {\n const canvasDoc = editor.Canvas.getDocument();\n const canvasHead = canvasDoc.head;\n\n if (!canvasHead.querySelector('[data-grapesjs-styles]')) {\n const style = canvasDoc.createElement('style');\n const fullCss = `\n ${tailwindCompiledCss}\n ${datePickerCss}\n ::-webkit-scrollbar {\n width: 0px;\n height: 0px;\n }\n html, body {\n overflow: auto !important;\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n }\n `;\n style.innerHTML = fullCss;\n style.setAttribute('type', 'text/css');\n style.setAttribute('data-grapesjs-styles', 'true');\n canvasHead.appendChild(style);\n }\n\n isSystemUpdateRef.current = true;\n const storeResult = await safeStoreEditor(editor);\n\n if (storeResult) {\n lastJsonRef.current = JSON.stringify(storeResult);\n }\n\n isSystemUpdateRef.current = false;\n\n setComponentProperties(editor, currentMode === 'preview', isStreamingRef.current);\n });\n\n editorInstance.current = editor;\n\n if (setEditor) {\n setEditor(editor);\n }\n\n TypesToRegister.forEach(({ type, tagName }) => {\n if (!editor.DomComponents.getType(type)) {\n editor.DomComponents.addType(type, {\n model: {\n defaults: { tagName },\n },\n view: {},\n });\n }\n });\n\n return function cleanup() {\n editor.destroy();\n isEditorAliveRef.current = false;\n };\n }, []);\n\n useEffect(() => {\n if (json && json.pages?.length > 0) {\n if (!isEditorAliveRef.current || !editorInstance.current) {\n return;\n }\n\n const pageNormalizedJson = normalizeMultiPageJson(json);\n\n const currentPage = getCurrentPage(pageNormalizedJson.pages, effectiveCurrentPageId);\n\n if (!currentPage || !currentPage.frames?.length) {\n return;\n }\n\n isSystemUpdateRef.current = true;\n const raw = currentPage.frames[0].component;\n const processed = expandActions(raw);\n\n try {\n editorInstance.current?.setComponents(processed);\n\n setTimeout(() => {\n if (editorInstance.current && isEditorAliveRef.current) {\n const domComponents = editorInstance.current?.DomComponents;\n\n if (domComponents) {\n const allComponents = domComponents?.getWrapper()?.findType('shadcn-generic');\n allComponents?.forEach((comp: any) => {\n if (comp.get('componentName') === 'Tabs') {\n comp.view?.render();\n }\n });\n }\n }\n }, 100);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Error during component restoration:', error);\n }\n\n const globalStyles = pageNormalizedJson.styles || [];\n const pageStyles = currentPage.styles || [];\n const mergedStyles = mergeStyles(globalStyles, pageStyles);\n const cssText = convertStyles(mergedStyles);\n editorInstance.current?.setStyle(cssText);\n\n if (onRequestPageDataRef.current) {\n const isMultiPage = Boolean(pageNormalizedJson.isMultiPage);\n const pageId = isMultiPage ? currentPage.id : '';\n const rowContext = rowNavigationContextRef.current ?? undefined;\n\n onRequestPageDataRef.current(pageId, [], rowContext);\n rowNavigationContextRef.current = null;\n }\n\n if (editorInstance.current) {\n setComponentProperties(editorInstance.current, mode === 'preview', isStreaming);\n\n setTimeout(() => {\n if (editorInstance.current && isEditorAliveRef.current && mode === 'preview') {\n setComponentProperties(editorInstance.current, true, isStreaming);\n }\n }, 50);\n }\n\n setTimeout(() => {\n if (currentPage && pageDataCache.current[currentPage.id]) {\n const cachedData = pageDataCache.current[currentPage.id];\n\n Object.entries(cachedData).forEach(([componentId, data]) => {\n const model = renderedComponents.current[componentId];\n\n if (model && data) {\n if (data.newProps) {\n model.set('componentProps', {\n ...model.get('componentProps'),\n ...data.newProps,\n });\n }\n\n const updatedAttributes = {\n ...model.get('attributes'),\n ...(data.newAttributes || {}),\n };\n\n model.set('attributes', updatedAttributes);\n\n if (model.view) {\n model.view.render();\n }\n }\n });\n\n delete pageDataCache.current[currentPage.id];\n }\n }, 150);\n\n const cacheCheckInterval = setInterval(() => {\n if (!currentPage || !pageDataCache.current[currentPage.id]) {\n return;\n }\n\n const cachedData = pageDataCache.current[currentPage.id];\n let appliedAny = false;\n\n Object.entries(cachedData).forEach(([componentId, data]) => {\n const model = renderedComponents.current[componentId];\n\n if (model && data) {\n if (data.newProps) {\n model.set('componentProps', {\n ...model.get('componentProps'),\n ...data.newProps,\n });\n }\n\n const updatedAttributes = {\n ...model.get('attributes'),\n ...(data.newAttributes || {}),\n };\n\n model.set('attributes', updatedAttributes);\n\n if (model.view) {\n model.view.render();\n }\n\n appliedAny = true;\n }\n });\n\n if (appliedAny) {\n Object.keys(cachedData).forEach((componentId) => {\n if (renderedComponents.current[componentId]) {\n delete cachedData[componentId];\n }\n });\n\n if (Object.keys(cachedData).length === 0) {\n delete pageDataCache.current[currentPage.id];\n }\n }\n }, 100);\n\n setTimeout(() => {\n clearInterval(cacheCheckInterval);\n }, 5000);\n\n setTimeout(async () => {\n if (editorInstance.current && isEditorAliveRef.current) {\n const storeResult = await safeStoreEditor(editorInstance.current);\n\n if (storeResult) {\n lastJsonRef.current = JSON.stringify(storeResult);\n }\n\n isSystemUpdateRef.current = false;\n }\n }, 100);\n }\n }, [json, effectiveCurrentPageId]);\n\n useEffect(() => {\n const editor = editorInstance.current;\n\n if (!editor || !isEditorAliveRef.current) {\n return;\n }\n\n if (isModeChangeFromToggle) {\n setIsTransitioning(true);\n }\n\n setComponentProperties(\n editorInstance.current as Editor,\n mode === 'preview',\n isStreaming ?? false,\n );\n\n const wrapper = editor.getWrapper();\n const shadcnComponents = wrapper?.find('[data-gjs-type=\"shadcn-generic\"]') || [];\n\n shadcnComponents.forEach((comp: Component) => {\n if (comp.view && typeof comp.view.render === 'function') {\n comp.view.render();\n }\n });\n\n if (isModeChangeFromToggle) {\n requestAnimationFrame(() => {\n setIsTransitioning(false);\n });\n }\n }, [mode, isStreaming ?? false]);\n\n useEffect(() => {\n const editor = editorInstance.current;\n const currentIsStreaming = isStreaming ?? false;\n const prevIsStreaming = isStreamingRef.current;\n\n if (editor && isEditorAliveRef.current && currentIsStreaming && !prevIsStreaming) {\n const wrapper = editor.getWrapper();\n const shadcnComponents = wrapper?.findType('shadcn-generic') || [];\n\n shadcnComponents.forEach((comp: Component) => {\n resetStreamingComponent(comp);\n });\n }\n\n isStreamingRef.current = currentIsStreaming;\n }, [isStreaming]);\n\n return (\n <React.Fragment>\n <StyledEditor />\n <div\n ref={editorRef}\n id=\"grapesjs-editor\"\n style={{\n opacity: isTransitioning ? 0 : 1,\n transition: 'opacity 0.15s ease-in-out',\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction GrapejsCanvas(props: GrapesjsCanvasProps) {\n const existingContext = usePageContext();\n\n if (existingContext) {\n return <GrapejsCanvasInternal {...props} />;\n }\n\n const normalizedJson = normalizeMultiPageJson(props.json);\n const pages = normalizedJson.pages.map(extractPageMetadata);\n const initialPageId = props.currentPageId || pages[0]?.id || '';\n\n return (\n <PageProvider pages={pages} initialPageId={initialPageId} onPageChange={props.onPageChange}>\n <GrapejsCanvasInternal {...props} />\n </PageProvider>\n );\n}\n\nexport default GrapejsCanvas;\n"],"mappings":"wLAAA,uDACA,MAAO,CAAAA,KAAK,EAAIC,SAAS,CAAEC,MAAM,CAAEC,QAAQ,KAAQ,OAAO,CAC1D;AACA,MAAO,CAAAC,QAAQ,KAA6B,UAAU,CACtD,MAAO,kCAAkC,CACzC,MAAO,CAAAC,QAAQ,KAAM,mBAAmB,CAExC,OAASC,eAAe,KAAQ,aAAa,CAC7C,OAASC,WAAW,KAAQ,WAAW,CACvC,OAASC,mBAAmB,KAAQ,eAAe,CACnD,OAASC,aAAa,KAAQ,uBAAuB,CACrD,OACEC,mBAAmB,CACnBC,cAAc,CACdC,WAAW,CACXC,sBAAsB,KACjB,sBAAsB,CAC7B,OAASC,iCAAiC,KAAQ,0BAA0B,CAC5E,OAASC,YAAY,KAAQ,gBAAgB,CAE7C,OAASC,YAAY,CAAEC,cAAc,KAAQ,wBAAwB,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBA2BtE,QAAS,CAAAC,mBAAmBA,CAACC,MAAc,CAAW,CACpD,GAAI,CACF,GAAM,CAAAC,MAAM,CAAGD,MAAM,CAACE,MAAM,CAE5B,GAAI,CAACD,MAAM,CAAE,CACX,MAAO,MACT,CAEA,GAAM,CAAAE,SAAS,CAAGF,MAAM,CAACG,WAAW,cAAlBH,MAAM,CAACG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IjS,KAAK,CAAC,CAAC,CAAC,eAARiS,QAAA,CAAUnN,EAAE,GAAI,EAAE,CAE/D,mBACErG,IAAA,CAACH,YAAY,EAAC0B,KAAK,CAAEA,KAAM,CAACmS,aAAa,CAAEA,aAAc,CAACzK,YAAY,CAAE7B,KAAK,CAAC6B,YAAa,CAAAkK,QAAA,cACzFnT,IAAA,CAAC6H,qBAAqB,CAAAnE,QAAA,IAAK0D,KAAK,CAAG,CAAC,CACxB,CAElB,CAEA,cAAe,CAAAmM,aAAa","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export { default as GrapejsCanvas } from './GrapesjsCanvas';
2
- export type { GrapesjsCanvasHandle } from './GrapesjsCanvas';
3
2
  export * from './index.styles';
4
3
  export { getUpdatedUiJson } from './helpers/merge-json';
5
4
  export { DataTable } from './plugins/helpers/data-table';
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","GrapejsCanvas","getUpdatedUiJson","DataTable","StyledInfoButton","AiAvatarIcon","CustomModal","QueryDetailsModal","QueryLoadingModal","PageProvider","usePageContext","useRequiredPageContext","useCurrentPage","usePageNavigation","mergeStyles","getCurrentPage","extractPageMetadata","validateMultiPageJson","normalizeMultiPageJson"],"sources":["../src/index.ts"],"sourcesContent":["export { default as GrapejsCanvas } from './GrapesjsCanvas';\nexport type { GrapesjsCanvasHandle } from './GrapesjsCanvas';\nexport * from './index.styles';\nexport { getUpdatedUiJson } from './helpers/merge-json';\nexport { DataTable } from './plugins/helpers/data-table';\nexport { StyledInfoButton } from './plugins/helpers/styled-info-button';\nexport { AiAvatarIcon } from './shadcn/components/icons/AiAvatarIcon';\nexport { CustomModal } from './plugins/helpers/custom-modal';\nexport { QueryDetailsModal } from './plugins/helpers/query-details-modal';\nexport { QueryLoadingModal } from './plugins/helpers/query-loading-modal';\nexport {\n PageProvider,\n usePageContext,\n useRequiredPageContext,\n useCurrentPage,\n usePageNavigation,\n} from './contexts/PageContext';\nexport {\n mergeStyles,\n getCurrentPage,\n extractPageMetadata,\n validateMultiPageJson,\n normalizeMultiPageJson,\n} from './helpers/page-utils';\nexport type {\n PageMetadata,\n PageStyle,\n NavigateToPageAction,\n Page,\n PageContext,\n PageAwareProps,\n MultiPageUIJson,\n} from './types/page';\n"],"mappings":"AAAA,OAASA,OAAO,GAAI,CAAAC,aAAa,KAAQ,kBAAkB,CAE3D,WAAc,gBAAgB,CAC9B,OAASC,gBAAgB,KAAQ,sBAAsB,CACvD,OAASC,SAAS,KAAQ,8BAA8B,CACxD,OAASC,gBAAgB,KAAQ,sCAAsC,CACvE,OAASC,YAAY,KAAQ,wCAAwC,CACrE,OAASC,WAAW,KAAQ,gCAAgC,CAC5D,OAASC,iBAAiB,KAAQ,uCAAuC,CACzE,OAASC,iBAAiB,KAAQ,uCAAuC,CACzE,OACEC,YAAY,CACZC,cAAc,CACdC,sBAAsB,CACtBC,cAAc,CACdC,iBAAiB,KACZ,wBAAwB,CAC/B,OACEC,WAAW,CACXC,cAAc,CACdC,mBAAmB,CACnBC,qBAAqB,CACrBC,sBAAsB,KACjB,sBAAsB","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["default","GrapejsCanvas","getUpdatedUiJson","DataTable","StyledInfoButton","AiAvatarIcon","CustomModal","QueryDetailsModal","QueryLoadingModal","PageProvider","usePageContext","useRequiredPageContext","useCurrentPage","usePageNavigation","mergeStyles","getCurrentPage","extractPageMetadata","validateMultiPageJson","normalizeMultiPageJson"],"sources":["../src/index.ts"],"sourcesContent":["export { default as GrapejsCanvas } from './GrapesjsCanvas';\nexport * from './index.styles';\nexport { getUpdatedUiJson } from './helpers/merge-json';\nexport { DataTable } from './plugins/helpers/data-table';\nexport { StyledInfoButton } from './plugins/helpers/styled-info-button';\nexport { AiAvatarIcon } from './shadcn/components/icons/AiAvatarIcon';\nexport { CustomModal } from './plugins/helpers/custom-modal';\nexport { QueryDetailsModal } from './plugins/helpers/query-details-modal';\nexport { QueryLoadingModal } from './plugins/helpers/query-loading-modal';\nexport {\n PageProvider,\n usePageContext,\n useRequiredPageContext,\n useCurrentPage,\n usePageNavigation,\n} from './contexts/PageContext';\nexport {\n mergeStyles,\n getCurrentPage,\n extractPageMetadata,\n validateMultiPageJson,\n normalizeMultiPageJson,\n} from './helpers/page-utils';\nexport type {\n PageMetadata,\n PageStyle,\n NavigateToPageAction,\n Page,\n PageContext,\n PageAwareProps,\n MultiPageUIJson,\n} from './types/page';\n"],"mappings":"AAAA,OAASA,OAAO,GAAI,CAAAC,aAAa,KAAQ,kBAAkB,CAC3D,WAAc,gBAAgB,CAC9B,OAASC,gBAAgB,KAAQ,sBAAsB,CACvD,OAASC,SAAS,KAAQ,8BAA8B,CACxD,OAASC,gBAAgB,KAAQ,sCAAsC,CACvE,OAASC,YAAY,KAAQ,wCAAwC,CACrE,OAASC,WAAW,KAAQ,gCAAgC,CAC5D,OAASC,iBAAiB,KAAQ,uCAAuC,CACzE,OAASC,iBAAiB,KAAQ,uCAAuC,CACzE,OACEC,YAAY,CACZC,cAAc,CACdC,sBAAsB,CACtBC,cAAc,CACdC,iBAAiB,KACZ,wBAAwB,CAC/B,OACEC,WAAW,CACXC,cAAc,CACdC,mBAAmB,CACnBC,qBAAqB,CACrBC,sBAAsB,KACjB,sBAAsB","ignoreList":[]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@peak-ai/canvas",
3
3
  "author": "squad-builder-experience",
4
4
  "license": "UNLICENSED",
5
- "version": "1.6.13",
5
+ "version": "1.6.14-rc.1",
6
6
  "description": "",
7
7
  "dependencies": {
8
8
  "@emotion/react": "^11.11.4",
@@ -35,6 +35,8 @@ export type DataTableProps = {
35
35
  columnWithChipClass?: Record<string, 'useMap' | 'useRandom'>;
36
36
  chipStylesMapping?: Record<string, Record<string, string>>;
37
37
  columnTooltips?: Record<string, Record<string, string>>;
38
+ columnClassMapping?: Record<string, string>;
39
+ columnWidths?: Record<string, string>;
38
40
  navigateToPage?: (pageId: string, rowContext?: Record<string, any>) => void;
39
41
  isBulkSelectionEnabled?: boolean;
40
42
  selectedIndices?: number[];
@@ -42,5 +44,5 @@ export type DataTableProps = {
42
44
  title?: string;
43
45
  onDownload?: (limit: number) => Promise<void>;
44
46
  };
45
- export declare function DataTable({ data, headerMapper, className, actions, isEditable, pagination, isLoading, onRowAction, onPageChange, onSort, sortConfig, sortable: sortableGlobal, otherProps, height, decimalPrecision, columnWithChipClass, chipStylesMapping, columnTooltips, navigateToPage, isBulkSelectionEnabled, selectedIndices, setSelectedIndices, title, onDownload, }: DataTableProps): import("react/jsx-runtime").JSX.Element;
47
+ export declare function DataTable({ data, headerMapper, className, actions, isEditable, pagination, isLoading, onRowAction, onPageChange, onSort, sortConfig, sortable: sortableGlobal, otherProps, height, decimalPrecision, columnWithChipClass, chipStylesMapping, columnTooltips, columnClassMapping, columnWidths, navigateToPage, isBulkSelectionEnabled, selectedIndices, setSelectedIndices, title, onDownload, }: DataTableProps): import("react/jsx-runtime").JSX.Element;
46
48
  export {};