@peak-ai/canvas 1.4.38 → 1.4.39-rc.3

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.
@@ -13,6 +13,8 @@ type GrapesjsCanvasProps = {
13
13
  newDataNotifier: (notifHandler: NotificationHandler) => void;
14
14
  setHasChanged: (hasChanged: boolean) => void;
15
15
  isStreaming: boolean;
16
+ isModeChangeFromToggle?: boolean;
17
+ isCreatingAssetFromTemplate?: boolean;
16
18
  };
17
- declare function GrapesjsCanvas({ json, mode, setEditor, performInteraction, newDataNotifier, setHasChanged, isStreaming, }: GrapesjsCanvasProps): import("react/jsx-runtime").JSX.Element;
19
+ declare function GrapesjsCanvas({ json, mode, setEditor, performInteraction, newDataNotifier, setHasChanged, isStreaming, isModeChangeFromToggle, isCreatingAssetFromTemplate, }: GrapesjsCanvasProps): import("react/jsx-runtime").JSX.Element;
18
20
  export default GrapesjsCanvas;
package/GrapesjsCanvas.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _extends from"@babel/runtime/helpers/extends";import _regeneratorRuntime from"@babel/runtime/regenerator";/* eslint-disable @typescript-eslint/no-explicit-any */import React,{useEffect,useRef}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{createGrapesjsShadcnGenericPlugin}from"./plugins/grapejs-plugin";import{StyledEditor}from"./index.styles";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function setComponentProperties(editor,isPreview){function setPropertiesRecursively(comp){comp.set({editable:!isPreview,draggable:!isPreview,droppable:!isPreview&&comp.getName()!=="Shadcn-generic",selectable:!isPreview,hoverable:!isPreview,highlightable:!isPreview,copyable:false,resizable:false,removable:!isPreview,badgable:false});comp.set("attributes",_extends({},comp.get("attributes")||{},{isEditable:!isPreview}));if(!isPreview){comp.set("toolbar",[{attributes:{"class":"fa fa-arrows"},command:"tlb-move"},{attributes:{"class":"fa fa-trash"},command:"tlb-delete"}])}comp.components().forEach(setPropertiesRecursively)}if(isPreview){editor.runCommand("core:preview")}else{editor.stopCommand("core:preview")}var wrapper=editor.getWrapper();wrapper==null||wrapper.find("*").forEach(setPropertiesRecursively)}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 GrapesjsCanvas(_ref2){var json=_ref2.json,_ref2$mode=_ref2.mode,mode=_ref2$mode===void 0?"preview":_ref2$mode,setEditor=_ref2.setEditor,performInteraction=_ref2.performInteraction,_ref2$newDataNotifier=_ref2.newDataNotifier,newDataNotifier=_ref2$newDataNotifier===void 0?function(){// no op
3
3
  }:_ref2$newDataNotifier,_ref2$setHasChanged=_ref2.setHasChanged,setHasChanged=_ref2$setHasChanged===void 0?function(){// no op
4
- }:_ref2$setHasChanged,isStreaming=_ref2.isStreaming;var editorRef=useRef(null);var editorInstance=useRef(null);var renderedComponents=useRef({});var isStreamingRef=useRef(isStreaming);var isSystemUpdateRef=useRef(false);var lastJsonRef=useRef("");var isEditorAliveRef=useRef(false);useEffect(function(){isStreamingRef.current=isStreaming},[isStreaming]);function notificationHandler(props){if(!props){return true}var componentId=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[componentId];if(!model){return false}// Filter out complex placeholder objects by setting them to null
4
+ }:_ref2$setHasChanged,isStreaming=_ref2.isStreaming,_ref2$isModeChangeFro=_ref2.isModeChangeFromToggle,isModeChangeFromToggle=_ref2$isModeChangeFro===void 0?false:_ref2$isModeChangeFro,_ref2$isCreatingAsset=_ref2.isCreatingAssetFromTemplate,isCreatingAssetFromTemplate=_ref2$isCreatingAsset===void 0?false:_ref2$isCreatingAsset;var editorRef=useRef(null);var editorInstance=useRef(null);var renderedComponents=useRef({});var isStreamingRef=useRef(isStreaming);var isSystemUpdateRef=useRef(false);var lastJsonRef=useRef("");var isEditorAliveRef=useRef(false);var _React$useState=React.useState(false),isTransitioning=_React$useState[0],setIsTransitioning=_React$useState[1];useEffect(function(){isStreamingRef.current=isStreaming},[isStreaming]);function notificationHandler(props){if(!props){return true}var componentId=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[componentId];if(!model){return false}// Filter out complex placeholder objects by setting them to null
5
5
  // This ensures placeholder values are properly cleared and don't cause stale data issues
6
6
  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
7
- 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){expandActionsComponent(model,parsedNewProps.actions);return true}}model.set("componentProps",_extends({},model.get("componentProps"),parsedNewProps));model.set("attributes",_extends({},model.get("attributes"),newAttributes));return true}useEffect(function(){newDataNotifier(notificationHandler)},[]);function performInteractionWrapper(_x){return _performInteractionWrapper.apply(this,arguments)}function _performInteractionWrapper(){_performInteractionWrapper=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(payload){var _editorInstance$curre3;var updatedJson,apiResponse,componentUpdates,_t4;return _regeneratorRuntime.wrap(function(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_context4.next=1;return(_editorInstance$curre3=editorInstance.current)==null?void 0:_editorInstance$curre3.store();case 1:updatedJson=_context4.sent;setInteracting(renderedComponents.current,payload.affectedComponents,true);_context4.prev=2;_context4.next=3;return performInteraction(_extends({},payload,{json:updatedJson}));case 3:apiResponse=_context4.sent;componentUpdates=apiResponse||{};Object.entries(componentUpdates).forEach(function(_ref6){var key=_ref6[0],value=_ref6[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 _context4.abrupt("return",componentUpdates);case 4:_context4.prev=4;_t4=_context4["catch"](2);payload.affectedComponents.forEach(function(componentId){var model=renderedComponents.current[componentId];if(model){var errorMessage=_t4 instanceof Error?_t4.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 _t4;case 5:_context4.prev=5;setInteracting(renderedComponents.current,payload.affectedComponents,false);return _context4.finish(5);case 6:case"end":return _context4.stop()}},_callee4,null,[[2,4,5,6]])}));return _performInteractionWrapper.apply(this,arguments)}useEffect(function(){if(!editorRef.current){return function(){// no op
8
- }}if(editorInstance.current){editorInstance.current.destroy();editorInstance.current=null;isEditorAliveRef.current=false}var currentMode=mode;var editor=grapesjs.init({container:editorRef.current,height:"100%",plugins:[tailwind,createGrapesjsShadcnGenericPlugin(currentMode,performInteractionWrapper,renderedComponents.current,setHasChanged)],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,_t2;return _regeneratorRuntime.wrap(function(_context2){while(1)switch(_context2.prev=_context2.next){case 0:if(!(isStreamingRef.current||isSystemUpdateRef.current)){_context2.next=1;break}return _context2.abrupt("return");case 1:if(!(!isEditorAliveRef.current||!editorInstance.current)){_context2.next=2;break}return _context2.abrupt("return");case 2:stored=null;_context2.prev=3;_context2.next=4;return editorInstance.current.store();case 4:stored=_context2.sent;_context2.next=6;break;case 5:_context2.prev=5;_t2=_context2["catch"](3);return _context2.abrupt("return");case 6:if(stored){_context2.next=7;break}return _context2.abrupt("return");case 7:newJson=JSON.stringify(stored);if(newJson!==lastJsonRef.current){setHasChanged(true);lastJsonRef.current=newJson}case 8:case"end":return _context2.stop()}},_callee2,null,[[3,5]])}));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
7
+ 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){expandActionsComponent(model,parsedNewProps.actions);return true}}model.set("componentProps",_extends({},model.get("componentProps"),parsedNewProps));model.set("attributes",_extends({},model.get("attributes"),newAttributes));return true}useEffect(function(){newDataNotifier(notificationHandler)},[]);function performInteractionWrapper(_x){return _performInteractionWrapper.apply(this,arguments)}function _performInteractionWrapper(){_performInteractionWrapper=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(payload){var _editorInstance$curre3;var updatedJson,apiResponse,componentUpdates;return _regeneratorRuntime.wrap(function _callee4$(_context4){while(1)switch(_context4.prev=_context4.next){case 0:_context4.next=2;return(_editorInstance$curre3=editorInstance.current)==null?void 0:_editorInstance$curre3.store();case 2:updatedJson=_context4.sent;setInteracting(renderedComponents.current,payload.affectedComponents,true);_context4.prev=4;_context4.next=7;return performInteraction(_extends({},payload,{json:updatedJson}));case 7:apiResponse=_context4.sent;componentUpdates=apiResponse||{};Object.entries(componentUpdates).forEach(function(_ref6){var key=_ref6[0],value=_ref6[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 _context4.abrupt("return",componentUpdates);case 13:_context4.prev=13;_context4.t0=_context4["catch"](4);payload.affectedComponents.forEach(function(componentId){var model=renderedComponents.current[componentId];if(model){var errorMessage=_context4.t0 instanceof Error?_context4.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 _context4.t0;case 17:_context4.prev=17;setInteracting(renderedComponents.current,payload.affectedComponents,false);return _context4.finish(17);case 20:case"end":return _context4.stop()}},_callee4,null,[[4,13,17,20]])}));return _performInteractionWrapper.apply(this,arguments)}useEffect(function(){if(!editorRef.current){return function(){// no op
8
+ }}if(editorInstance.current){editorInstance.current.destroy();editorInstance.current=null;isEditorAliveRef.current=false}var currentMode=mode;var editor=grapesjs.init({container:editorRef.current,height:"100%",plugins:[tailwind,createGrapesjsShadcnGenericPlugin(currentMode,performInteractionWrapper,renderedComponents.current,setHasChanged,isCreatingAssetFromTemplate)],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.prev=5;_context2.next=8;return editorInstance.current.store();case 8:stored=_context2.sent;_context2.next=14;break;case 11:_context2.prev=11;_context2.t0=_context2["catch"](5);return _context2.abrupt("return");case 14:if(stored){_context2.next=16;break}return _context2.abrupt("return");case 16:newJson=JSON.stringify(stored);if(newJson!==lastJsonRef.current){setHasChanged(true);lastJsonRef.current=newJson}case 18:case"end":return _context2.stop()}},_callee2,null,[[5,11]])}));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
9
9
  // So, adding them from here!
10
- editor.on("load",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var canvasDoc,canvasHead,style,fullCss,_t;return _regeneratorRuntime.wrap(function(_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;_t=JSON;_context.next=1;return editor.store();case 1:lastJsonRef.current=_t.stringify.call(_t,_context.sent);isSystemUpdateRef.current=false;case 2: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,_json$pages$0$frames;if(json&&((_json$pages=json.pages)==null?void 0:_json$pages.length)>0&&((_json$pages$0$frames=json.pages[0].frames)==null?void 0:_json$pages$0$frames.length)>0){var _editorInstance$curre,_editorInstance$curre2;isSystemUpdateRef.current=true;var raw=json.pages[0].frames[0].component;var processed=expandActions(raw);(_editorInstance$curre=editorInstance.current)==null||_editorInstance$curre.setComponents(processed);var cssText=convertStyles(json.styles||[]);(_editorInstance$curre2=editorInstance.current)==null||_editorInstance$curre2.setStyle(cssText);setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){var _t3;return _regeneratorRuntime.wrap(function(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(!editorInstance.current){_context3.next=2;break}_t3=JSON;_context3.next=1;return editorInstance.current.store();case 1:lastJsonRef.current=_t3.stringify.call(_t3,_context3.sent);isSystemUpdateRef.current=false;case 2:case"end":return _context3.stop()}},_callee3)})),100)}},[json]);useEffect(function(){if(mode&&editorInstance.current){isSystemUpdateRef.current=true;setTimeout(function(){setComponentProperties(editorInstance.current,mode==="preview");setTimeout(function(){isSystemUpdateRef.current=false},50)},0)}},[mode]);return/*#__PURE__*/_jsxs(React.Fragment,{children:[/*#__PURE__*/_jsx(StyledEditor,{}),/*#__PURE__*/_jsx("div",{ref:editorRef,id:"grapesjs-editor"})]})}export default GrapesjsCanvas;
10
+ editor.on("load",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(){var canvasDoc,canvasHead,style,fullCss;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.t0=JSON;_context.next=7;return editor.store();case 7:_context.t1=_context.sent;lastJsonRef.current=_context.t0.stringify.call(_context.t0,_context.t1);isSystemUpdateRef.current=false;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,_json$pages$0$frames;if(json&&((_json$pages=json.pages)==null?void 0:_json$pages.length)>0&&((_json$pages$0$frames=json.pages[0].frames)==null?void 0:_json$pages$0$frames.length)>0){var _editorInstance$curre,_editorInstance$curre2;isSystemUpdateRef.current=true;var raw=json.pages[0].frames[0].component;var processed=expandActions(raw);(_editorInstance$curre=editorInstance.current)==null||_editorInstance$curre.setComponents(processed);var cssText=convertStyles(json.styles||[]);(_editorInstance$curre2=editorInstance.current)==null||_editorInstance$curre2.setStyle(cssText);setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(){return _regeneratorRuntime.wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(!editorInstance.current){_context3.next=7;break}_context3.t0=JSON;_context3.next=4;return editorInstance.current.store();case 4:_context3.t1=_context3.sent;lastJsonRef.current=_context3.t0.stringify.call(_context3.t0,_context3.t1);isSystemUpdateRef.current=false;case 7:case"end":return _context3.stop()}},_callee3)})),100)}},[json]);useEffect(function(){if(mode&&editorInstance.current){isSystemUpdateRef.current=true;if(isModeChangeFromToggle){setIsTransitioning(true)}setTimeout(function(){setComponentProperties(editorInstance.current,mode==="preview");setTimeout(function(){isSystemUpdateRef.current=false;setIsTransitioning(false)},50)},0)}},[mode,isModeChangeFromToggle]);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"}})]})}export default GrapesjsCanvas;
11
11
  //# sourceMappingURL=GrapesjsCanvas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GrapesjsCanvas.js","names":["React","useEffect","useRef","grapesjs","tailwind","TypesToRegister","toKebabCase","tailwindCompiledCss","datePickerCss","createGrapesjsShadcnGenericPlugin","StyledEditor","jsx","_jsx","jsxs","_jsxs","setComponentProperties","editor","isPreview","setPropertiesRecursively","comp","set","editable","draggable","droppable","getName","selectable","hoverable","highlightable","copyable","resizable","removable","badgable","_extends","get","isEditable","attributes","command","components","forEach","runCommand","stopCommand","wrapper","getWrapper","find","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","length","classes","concat","undefined","i","id","setInteracting","renderedComponents","inProgress","component","componentId","showLoader","gjsModel","interactionApiInProgress","expandActionsComponent","model","append","addClass","GrapesjsCanvas","_ref2","json","_ref2$mode","mode","setEditor","performInteraction","_ref2$newDataNotifier","newDataNotifier","_ref2$setHasChanged","setHasChanged","isStreaming","editorRef","editorInstance","isStreamingRef","isSystemUpdateRef","lastJsonRef","isEditorAliveRef","current","notificationHandler","props","_props$newProps","newProps","_props$newAttributes","newAttributes","filteredProps","keys","key","name","parsedNewProps","pagination","isActionsComponent","hasValidActionsData","_model$components$at","isAlreadyExpanded","at","performInteractionWrapper","_x","_performInteractionWrapper","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee4","payload","_editorInstance$curre3","updatedJson","apiResponse","componentUpdates","_t4","wrap","_context4","prev","next","store","sent","affectedComponents","_ref6","error","isMissing","abrupt","errorMessage","Error","message","finish","stop","destroy","currentMode","init","container","height","plugins","storageManager","richTextEditor","canvas","customBadgeLabel","tagName","injectionAttempts","injectStylesEarly","_editor$Canvas","iframeDoc","Canvas","getDocument","head","querySelector","createElement","fullCss","innerHTML","setAttribute","appendChild","requestAnimationFrame","checkDirty","_checkDirty","_callee2","stored","newJson","_t2","_context2","JSON","stringify","debouncedCheckDirty","timeout","clearTimeout","setTimeout","evt","on","includes","_callee","canvasDoc","canvasHead","_t","_context","call","_ref4","DomComponents","getType","addType","defaults","view","cleanup","_json$pages","_json$pages$0$frames","pages","frames","_editorInstance$curre","_editorInstance$curre2","raw","processed","setComponents","cssText","styles","setStyle","_callee3","_t3","_context3","Fragment","children","ref"],"sources":["../src/GrapesjsCanvas.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useRef } 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 { createGrapesjsShadcnGenericPlugin } from './plugins/grapejs-plugin';\nimport { StyledEditor } from './index.styles';\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 newDataNotifier: (notifHandler: NotificationHandler) => void;\n setHasChanged: (hasChanged: boolean) => void;\n isStreaming: boolean;\n};\n\nfunction setComponentProperties(editor: Editor, isPreview: boolean) {\n function setPropertiesRecursively(comp: Component) {\n comp.set({\n editable: !isPreview,\n draggable: !isPreview,\n droppable: !isPreview && comp.getName() !== 'Shadcn-generic',\n selectable: !isPreview,\n hoverable: !isPreview,\n highlightable: !isPreview,\n copyable: false,\n resizable: false,\n removable: !isPreview,\n badgable: false,\n });\n\n comp.set('attributes', {\n ...(comp.get('attributes') || {}),\n isEditable: !isPreview,\n });\n\n if (!isPreview) {\n comp.set('toolbar', [\n { attributes: { class: 'fa fa-arrows' }, command: 'tlb-move' },\n { attributes: { class: 'fa fa-trash' }, command: 'tlb-delete' },\n ]);\n }\n\n comp.components().forEach(setPropertiesRecursively);\n }\n\n if (isPreview) {\n editor.runCommand('core:preview');\n } else {\n editor.stopCommand('core:preview');\n }\n\n const wrapper = editor.getWrapper();\n wrapper?.find('*').forEach(setPropertiesRecursively);\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 GrapesjsCanvas({\n json,\n mode = 'preview',\n setEditor,\n performInteraction,\n newDataNotifier = () => {\n // no op\n },\n setHasChanged = () => {\n // no op\n },\n isStreaming,\n}: GrapesjsCanvasProps) {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<Editor | null>(null);\n const renderedComponents = useRef<Record<string, Component>>({});\n const isStreamingRef = useRef(isStreaming);\n const isSystemUpdateRef = useRef(false);\n const lastJsonRef = useRef<string>('');\n const isEditorAliveRef = useRef(false);\n\n useEffect(() => {\n isStreamingRef.current = isStreaming;\n }, [isStreaming]);\n\n function notificationHandler(\n props: Parameters<NotificationHandler>[0],\n ): ReturnType<NotificationHandler> {\n if (!props) {\n return true;\n }\n\n const { componentId, newProps = {}, newAttributes = {} } = props;\n\n const model = renderedComponents.current[componentId];\n\n if (!model) {\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) {\n expandActionsComponent(model, parsedNewProps.actions);\n\n return true;\n }\n }\n\n model.set('componentProps', {\n ...model.get('componentProps'),\n ...parsedNewProps,\n });\n\n model.set('attributes', {\n ...model.get('attributes'),\n ...newAttributes,\n });\n\n return true;\n }\n\n useEffect(() => {\n newDataNotifier(notificationHandler);\n }, []);\n\n async function performInteractionWrapper(payload: Record<string, any>) {\n const updatedJson = await editorInstance.current?.store();\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 = mode;\n\n const editor = grapesjs.init({\n container: editorRef.current,\n height: '100%',\n plugins: [\n tailwind,\n createGrapesjsShadcnGenericPlugin(\n currentMode,\n performInteractionWrapper,\n renderedComponents.current,\n setHasChanged,\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 try {\n stored = await editorInstance.current.store();\n } catch (err) {\n return;\n }\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 lastJsonRef.current = JSON.stringify(await editor.store());\n isSystemUpdateRef.current = false;\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 && json.pages[0].frames?.length > 0) {\n isSystemUpdateRef.current = true;\n const raw = json.pages[0].frames[0].component;\n const processed = expandActions(raw);\n editorInstance.current?.setComponents(processed);\n\n const cssText = convertStyles(json.styles || []);\n editorInstance.current?.setStyle(cssText);\n\n setTimeout(async () => {\n if (editorInstance.current) {\n lastJsonRef.current = JSON.stringify(await editorInstance.current.store());\n isSystemUpdateRef.current = false;\n }\n }, 100);\n }\n }, [json]);\n\n useEffect(() => {\n if (mode && editorInstance.current) {\n isSystemUpdateRef.current = true;\n\n setTimeout(() => {\n setComponentProperties(editorInstance.current as Editor, mode === 'preview');\n\n setTimeout(() => {\n isSystemUpdateRef.current = false;\n }, 50);\n }, 0);\n }\n }, [mode]);\n\n return (\n <React.Fragment>\n <StyledEditor />\n <div ref={editorRef} id=\"grapesjs-editor\" />\n </React.Fragment>\n );\n}\n\nexport default GrapesjsCanvas;\n"],"mappings":"wLAAA,uDACA,MAAO,CAAAA,KAAK,EAAIC,SAAS,CAAEC,MAAM,KAAQ,OAAO,CAChD;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,OAASC,iCAAiC,KAAQ,0BAA0B,CAC5E,OAASC,YAAY,KAAQ,gBAAgB,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAkB9C,QAAS,CAAAC,sBAAsBA,CAACC,MAAc,CAAEC,SAAkB,CAAE,CAClE,QAAS,CAAAC,wBAAwBA,CAACC,IAAe,CAAE,CACjDA,IAAI,CAACC,GAAG,CAAC,CACPC,QAAQ,CAAE,CAACJ,SAAS,CACpBK,SAAS,CAAE,CAACL,SAAS,CACrBM,SAAS,CAAE,CAACN,SAAS,EAAIE,IAAI,CAACK,OAAO,CAAC,CAAC,GAAK,gBAAgB,CAC5DC,UAAU,CAAE,CAACR,SAAS,CACtBS,SAAS,CAAE,CAACT,SAAS,CACrBU,aAAa,CAAE,CAACV,SAAS,CACzBW,QAAQ,CAAE,KAAK,CACfC,SAAS,CAAE,KAAK,CAChBC,SAAS,CAAE,CAACb,SAAS,CACrBc,QAAQ,CAAE,KACZ,CAAC,CAAC,CAEFZ,IAAI,CAACC,GAAG,CAAC,YAAY,CAAAY,QAAA,IACfb,IAAI,CAACc,GAAG,CAAC,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AAAgF,GAAA,CACFnC,IAAI,CAAAoC,SAAA,CAAAjF,IAAA,SAAiB,CAAAzC,cAAc,CAACK,OAAO,CAACqC,KAAK,CAAC,CAAC,QAAzEvC,WAAW,CAACE,OAAO,CAAAoH,GAAA,CAAQlC,SAAS,CAAAa,IAAA,CAAAqB,GAAA,CAAAC,SAAA,CAAA/E,IAAA,EACpCzC,iBAAiB,CAACG,OAAO,CAAG,KAAK,CAAC,wBAAAqH,SAAA,CAAArE,IAAA,KAAAmE,QAAA,EAErC,GAAE,GAAG,CACR,CACF,CAAC,CAAE,CAACnI,IAAI,CAAC,CAAC,CAEV5F,SAAS,CAAC,UAAM,CACd,GAAI8F,IAAI,EAAIS,cAAc,CAACK,OAAO,CAAE,CAClCH,iBAAiB,CAACG,OAAO,CAAG,IAAI,CAEhCsF,UAAU,CAAC,UAAM,CACfpL,sBAAsB,CAACyF,cAAc,CAACK,OAAO,CAAYd,IAAI,GAAK,SAAS,CAAC,CAE5EoG,UAAU,CAAC,UAAM,CACfzF,iBAAiB,CAACG,OAAO,CAAG,KAC9B,CAAC,CAAE,EAAE,CACP,CAAC,CAAE,CAAC,CACN,CACF,CAAC,CAAE,CAACd,IAAI,CAAC,CAAC,CAEV,mBACEjF,KAAA,CAACd,KAAK,CAACmO,QAAQ,EAAAC,QAAA,eACbxN,IAAA,CAACF,YAAY,GAAE,CAAC,cAChBE,IAAA,QAAKyN,GAAG,CAAE9H,SAAU,CAACzB,EAAE,CAAC,iBAAiB,CAAE,CAAC,EAC9B,CAEpB,CAEA,cAAe,CAAAa,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"GrapesjsCanvas.js","names":["React","useEffect","useRef","grapesjs","tailwind","TypesToRegister","toKebabCase","tailwindCompiledCss","datePickerCss","createGrapesjsShadcnGenericPlugin","StyledEditor","jsx","_jsx","jsxs","_jsxs","setComponentProperties","editor","isPreview","setPropertiesRecursively","comp","set","editable","draggable","droppable","getName","selectable","hoverable","highlightable","copyable","resizable","removable","badgable","_extends","get","isEditable","attributes","command","components","forEach","runCommand","stopCommand","wrapper","getWrapper","find","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","length","classes","concat","undefined","i","id","setInteracting","renderedComponents","inProgress","component","componentId","showLoader","gjsModel","interactionApiInProgress","expandActionsComponent","model","append","addClass","GrapesjsCanvas","_ref2","json","_ref2$mode","mode","setEditor","performInteraction","_ref2$newDataNotifier","newDataNotifier","_ref2$setHasChanged","setHasChanged","isStreaming","_ref2$isModeChangeFro","isModeChangeFromToggle","_ref2$isCreatingAsset","isCreatingAssetFromTemplate","editorRef","editorInstance","isStreamingRef","isSystemUpdateRef","lastJsonRef","isEditorAliveRef","_React$useState","useState","isTransitioning","setIsTransitioning","current","notificationHandler","props","_props$newProps","newProps","_props$newAttributes","newAttributes","filteredProps","keys","key","name","parsedNewProps","pagination","isActionsComponent","hasValidActionsData","_model$components$at","isAlreadyExpanded","at","performInteractionWrapper","_x","_performInteractionWrapper","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee4","payload","_editorInstance$curre3","updatedJson","apiResponse","componentUpdates","wrap","_callee4$","_context4","prev","next","store","sent","affectedComponents","_ref6","error","isMissing","abrupt","t0","errorMessage","Error","message","finish","stop","destroy","currentMode","init","container","height","plugins","storageManager","richTextEditor","canvas","customBadgeLabel","tagName","injectionAttempts","injectStylesEarly","_editor$Canvas","iframeDoc","Canvas","getDocument","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","canvasDoc","canvasHead","_callee$","_context","t1","call","_ref4","DomComponents","getType","addType","defaults","view","cleanup","_json$pages","_json$pages$0$frames","pages","frames","_editorInstance$curre","_editorInstance$curre2","raw","processed","setComponents","cssText","styles","setStyle","_callee3","_callee3$","_context3","Fragment","children","ref","opacity","transition"],"sources":["../src/GrapesjsCanvas.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React, { useEffect, useRef } 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 { createGrapesjsShadcnGenericPlugin } from './plugins/grapejs-plugin';\nimport { StyledEditor } from './index.styles';\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 newDataNotifier: (notifHandler: NotificationHandler) => void;\n setHasChanged: (hasChanged: boolean) => void;\n isStreaming: boolean;\n isModeChangeFromToggle?: boolean;\n isCreatingAssetFromTemplate?: boolean;\n};\n\nfunction setComponentProperties(editor: Editor, isPreview: boolean) {\n function setPropertiesRecursively(comp: Component) {\n comp.set({\n editable: !isPreview,\n draggable: !isPreview,\n droppable: !isPreview && comp.getName() !== 'Shadcn-generic',\n selectable: !isPreview,\n hoverable: !isPreview,\n highlightable: !isPreview,\n copyable: false,\n resizable: false,\n removable: !isPreview,\n badgable: false,\n });\n\n comp.set('attributes', {\n ...(comp.get('attributes') || {}),\n isEditable: !isPreview,\n });\n\n if (!isPreview) {\n comp.set('toolbar', [\n { attributes: { class: 'fa fa-arrows' }, command: 'tlb-move' },\n { attributes: { class: 'fa fa-trash' }, command: 'tlb-delete' },\n ]);\n }\n\n comp.components().forEach(setPropertiesRecursively);\n }\n\n if (isPreview) {\n editor.runCommand('core:preview');\n } else {\n editor.stopCommand('core:preview');\n }\n\n const wrapper = editor.getWrapper();\n wrapper?.find('*').forEach(setPropertiesRecursively);\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 GrapesjsCanvas({\n json,\n mode = 'preview',\n setEditor,\n performInteraction,\n newDataNotifier = () => {\n // no op\n },\n setHasChanged = () => {\n // no op\n },\n isStreaming,\n isModeChangeFromToggle = false,\n isCreatingAssetFromTemplate = false,\n}: GrapesjsCanvasProps) {\n const editorRef = useRef<HTMLDivElement>(null);\n const editorInstance = useRef<Editor | null>(null);\n const renderedComponents = useRef<Record<string, Component>>({});\n const isStreamingRef = useRef(isStreaming);\n const isSystemUpdateRef = useRef(false);\n const lastJsonRef = useRef<string>('');\n const isEditorAliveRef = useRef(false);\n const [isTransitioning, setIsTransitioning] = React.useState(false);\n\n useEffect(() => {\n isStreamingRef.current = isStreaming;\n }, [isStreaming]);\n\n function notificationHandler(\n props: Parameters<NotificationHandler>[0],\n ): ReturnType<NotificationHandler> {\n if (!props) {\n return true;\n }\n\n const { componentId, newProps = {}, newAttributes = {} } = props;\n\n const model = renderedComponents.current[componentId];\n\n if (!model) {\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) {\n expandActionsComponent(model, parsedNewProps.actions);\n\n return true;\n }\n }\n\n model.set('componentProps', {\n ...model.get('componentProps'),\n ...parsedNewProps,\n });\n\n model.set('attributes', {\n ...model.get('attributes'),\n ...newAttributes,\n });\n\n return true;\n }\n\n useEffect(() => {\n newDataNotifier(notificationHandler);\n }, []);\n\n async function performInteractionWrapper(payload: Record<string, any>) {\n const updatedJson = await editorInstance.current?.store();\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 = mode;\n\n const editor = grapesjs.init({\n container: editorRef.current,\n height: '100%',\n plugins: [\n tailwind,\n createGrapesjsShadcnGenericPlugin(\n currentMode,\n performInteractionWrapper,\n renderedComponents.current,\n setHasChanged,\n isCreatingAssetFromTemplate,\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 try {\n stored = await editorInstance.current.store();\n } catch (err) {\n return;\n }\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 lastJsonRef.current = JSON.stringify(await editor.store());\n isSystemUpdateRef.current = false;\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 && json.pages[0].frames?.length > 0) {\n isSystemUpdateRef.current = true;\n const raw = json.pages[0].frames[0].component;\n const processed = expandActions(raw);\n editorInstance.current?.setComponents(processed);\n\n const cssText = convertStyles(json.styles || []);\n editorInstance.current?.setStyle(cssText);\n\n setTimeout(async () => {\n if (editorInstance.current) {\n lastJsonRef.current = JSON.stringify(await editorInstance.current.store());\n isSystemUpdateRef.current = false;\n }\n }, 100);\n }\n }, [json]);\n\n useEffect(() => {\n if (mode && editorInstance.current) {\n isSystemUpdateRef.current = true;\n\n if(isModeChangeFromToggle){\n setIsTransitioning(true);\n }\n\n setTimeout(() => {\n setComponentProperties(editorInstance.current as Editor, mode === 'preview');\n\n setTimeout(() => {\n isSystemUpdateRef.current = false;\n setIsTransitioning(false);\n }, 50);\n }, 0);\n }\n }, [mode, isModeChangeFromToggle]);\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\nexport default GrapesjsCanvas;\n"],"mappings":"wLAAA,uDACA,MAAO,CAAAA,KAAK,EAAIC,SAAS,CAAEC,MAAM,KAAQ,OAAO,CAChD;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,OAASC,iCAAiC,KAAQ,0BAA0B,CAC5E,OAASC,YAAY,KAAQ,gBAAgB,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAoB9C,QAAS,CAAAC,sBAAsBA,CAACC,MAAc,CAAEC,SAAkB,CAAE,CAClE,QAAS,CAAAC,wBAAwBA,CAACC,IAAe,CAAE,CACjDA,IAAI,CAACC,GAAG,CAAC,CACPC,QAAQ,CAAE,CAACJ,SAAS,CACpBK,SAAS,CAAE,CAACL,SAAS,CACrBM,SAAS,CAAE,CAACN,SAAS,EAAIE,IAAI,CAACK,OAAO,CAAC,CAAC,GAAK,gBAAgB,CAC5DC,UAAU,CAAE,CAACR,SAAS,CACtBS,SAAS,CAAE,CAACT,SAAS,CACrBU,aAAa,CAAE,CAACV,SAAS,CACzBW,QAAQ,CAAE,KAAK,CACfC,SAAS,CAAE,KAAK,CAChBC,SAAS,CAAE,CAACb,SAAS,CACrBc,QAAQ,CAAE,KACZ,CAAC,CAAC,CAEFZ,IAAI,CAACC,GAAG,CAAC,YAAY,CAAAY,QAAA,IACfb,IAAI,CAACc,GAAG,CAAC,YAAY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S,CAAC,CAE5E6G,UAAU,CAAC,UAAM,CACf9F,iBAAiB,CAACO,OAAO,CAAG,KAAK,CACjCD,kBAAkB,CAAC,KAAK,CAC1B,CAAC,CAAE,EAAE,CACP,CAAC,CAAE,CAAC,CACN,CACF,CAAC,CAAE,CAACrB,IAAI,CAAES,sBAAsB,CAAC,CAAC,CAElC,mBACE1F,KAAA,CAACd,KAAK,CAAC6O,QAAQ,EAAAC,QAAA,eACblO,IAAA,CAACF,YAAY,GAAE,CAAC,cAChBE,IAAA,QACEmO,GAAG,CAAEpI,SAAU,CACf7B,EAAE,CAAC,iBAAiB,CACpBvB,KAAK,CAAE,CACLyL,OAAO,CAAE7H,eAAe,CAAG,CAAC,CAAG,CAAC,CAChC8H,UAAU,CAAE,2BACd,CAAE,CACH,CAAC,EACY,CAEpB,CAEA,cAAe,CAAAtJ,cAAc","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.4.38",
5
+ "version": "1.4.39-rc.3",
6
6
  "description": "",
7
7
  "dependencies": {
8
8
  "@emotion/react": "^11.11.4",
@@ -21,6 +21,7 @@
21
21
  "@tailwindcss/cli": "^4.1.3",
22
22
  "@types/chroma-js": "^3.1.1",
23
23
  "@types/react-datepicker": "^7.0.0",
24
+ "@types/d3-force": "^3.0.0",
24
25
  "chroma-js": "^3.1.2",
25
26
  "class-variance-authority": "^0.7.1",
26
27
  "clsx": "^2.1.1",
@@ -44,7 +45,15 @@
44
45
  "tslib": "^2.7.0",
45
46
  "tw-animate-css": "^1.2.5",
46
47
  "sherlockjs": "^1.4.2",
47
- "date-fns-tz": "^2.0.0"
48
+ "date-fns-tz": "^2.0.0",
49
+ "@visx/group": "^3.8.0",
50
+ "@visx/scale": "^3.8.0",
51
+ "@visx/shape": "^3.8.0",
52
+ "@visx/axis": "^3.8.0",
53
+ "@visx/grid": "^3.8.0",
54
+ "@visx/tooltip": "^3.8.0",
55
+ "@visx/event": "^3.8.0",
56
+ "d3-force": "^3.0.0"
48
57
  },
49
58
  "peerDependencies": {
50
59
  "react": "^17.0.2",
@@ -59,4 +68,4 @@
59
68
  "types": "index.d.ts",
60
69
  "module": "index.js",
61
70
  "sideEffects": false
62
- }
71
+ }
@@ -1,2 +1,2 @@
1
1
  import { Editor, Component } from 'grapesjs';
2
- export declare function createGrapesjsShadcnGenericPlugin(mode: 'editor' | 'preview', performInteraction: (payload: Record<string, any>) => void, renderedComponents: Record<string, Component> | undefined, setHasChanged: (hasChanged: boolean) => void): (editor: Editor) => void;
2
+ export declare function createGrapesjsShadcnGenericPlugin(mode: 'editor' | 'preview', performInteraction: (payload: Record<string, any>) => void, renderedComponents: Record<string, Component> | undefined, setHasChanged: (hasChanged: boolean) => void, isCreatingAssetFromTemplate?: boolean): (editor: Editor) => void;
@@ -1,5 +1,5 @@
1
- import _extends from"@babel/runtime/helpers/extends";/* eslint-disable import/no-named-as-default-member *//* eslint-disable func-names *//* eslint-disable @typescript-eslint/no-explicit-any */import ReactDOM from"react-dom";import{getRenderers}from"./helpers/render-components";import{QueryCacheProvider}from"./helpers/query-cache-context";import{jsx as _jsx}from"react/jsx-runtime";export function createGrapesjsShadcnGenericPlugin(mode,performInteraction,renderedComponents,setHasChanged){if(renderedComponents===void 0){renderedComponents={}}return function grapesjsShadcnGenericPlugin(editor){editor.DomComponents.addType("shadcn-generic",{model:{defaults:{tagName:"div",droppable:false,componentName:"Card",componentProps:{},traits:[]}},view:{events:{"input [data-slot]":"handleSlotInput"},handleSlotInput:function handleSlotInput(e){var target=e.target;var slot=target.dataset.slot;var text=target.innerText;var props=this.model.get("componentProps")||{};if(!slot){return}if(slot.startsWith("table-header-")){var _props$data;var idx=parseInt(slot.split("-")[2],10);var dataKeys=Object.keys(((_props$data=props.data)==null?void 0:_props$data[0])||{});if(!props.headerMapper){props.headerMapper={}}var key=dataKeys[idx];if(key){props.headerMapper[key]=text}}else{props[slot]=text}this.model.set("componentProps",_extends({},props));if(!["search-input"].includes(slot)){setHasChanged(true)}},render:function render(){var _this=this;var compName=this.model.get("componentName");var compProps=this.model.get("componentProps");if(typeof compProps==="string"){try{compProps=JSON.parse(compProps)}catch(err){// eslint-disable-next-line no-console
2
- console.error("Invalid JSON in componentProps",err);compProps={}}}compProps.performInteraction=performInteraction;compProps.onChange=function(data){_this.model.set("componentProps",_extends({},_this.model.get("componentProps"),data))};var renderers=getRenderers();var Renderer=renderers[compName];if(Renderer){if(compName==="Tabs"){ReactDOM.render(/*#__PURE__*/_jsx(QueryCacheProvider,{maxCacheSize:100,maxCacheAge:5*60*1000,children:/*#__PURE__*/_jsx(Renderer,_extends({},compProps,{gjsModel:this.model}))}),this.el);var children=this.model.components();var tabsContent=this.el.querySelectorAll(".tabs-content");var tabAttributes=this.model.get("attributes")||{};var hasTabsError=tabAttributes.error||compProps.error;var hasTabsMissing=tabAttributes.isMissing||compProps.isMissing;var isFallback=Array.from(tabsContent).some(function(el){return el.dataset.fallback==="true"});if(!isFallback&&tabsContent.length>0){// Helper function to sync child attributes
1
+ import _extends from"@babel/runtime/helpers/extends";/* eslint-disable import/no-named-as-default-member *//* eslint-disable func-names *//* eslint-disable @typescript-eslint/no-explicit-any */import ReactDOM from"react-dom";import{getRenderers}from"./helpers/render-components";import{QueryCacheProvider}from"./helpers/query-cache-context";import{jsx as _jsx}from"react/jsx-runtime";export function createGrapesjsShadcnGenericPlugin(mode,performInteraction,renderedComponents,setHasChanged,isCreatingAssetFromTemplate){if(renderedComponents===void 0){renderedComponents={}}if(isCreatingAssetFromTemplate===void 0){isCreatingAssetFromTemplate=false}return function grapesjsShadcnGenericPlugin(editor){editor.DomComponents.addType("shadcn-generic",{model:{defaults:{tagName:"div",droppable:false,componentName:"Card",componentProps:{},traits:[]}},view:{events:{"input [data-slot]":"handleSlotInput"},handleSlotInput:function handleSlotInput(e){var target=e.target;var slot=target.dataset.slot;var text=target.innerText;var props=this.model.get("componentProps")||{};if(!slot){return}if(slot.startsWith("table-header-")){var _props$data;var idx=parseInt(slot.split("-")[2],10);var dataKeys=Object.keys(((_props$data=props.data)==null?void 0:_props$data[0])||{});if(!props.headerMapper){props.headerMapper={}}var key=dataKeys[idx];if(key){props.headerMapper[key]=text}}else{props[slot]=text}this.model.set("componentProps",_extends({},props));if(!["search-input"].includes(slot)){setHasChanged(true)}},render:function render(){var _this=this;var compName=this.model.get("componentName");var compProps=this.model.get("componentProps");if(typeof compProps==="string"){try{compProps=JSON.parse(compProps)}catch(err){// eslint-disable-next-line no-console
2
+ console.error("Invalid JSON in componentProps",err);compProps={}}}compProps.performInteraction=performInteraction;compProps.isCreatingAssetFromTemplate=isCreatingAssetFromTemplate;compProps.onChange=function(data){_this.model.set("componentProps",_extends({},_this.model.get("componentProps"),data))};var renderers=getRenderers();var Renderer=renderers[compName];if(Renderer){if(compName==="Tabs"){ReactDOM.render(/*#__PURE__*/_jsx(QueryCacheProvider,{maxCacheSize:100,maxCacheAge:5*60*1000,children:/*#__PURE__*/_jsx(Renderer,_extends({},compProps,{gjsModel:this.model}))}),this.el);var children=this.model.components();var tabsContent=this.el.querySelectorAll(".tabs-content");var tabAttributes=this.model.get("attributes")||{};var hasTabsError=tabAttributes.error||compProps.error;var hasTabsMissing=tabAttributes.isMissing||compProps.isMissing;var isFallback=Array.from(tabsContent).some(function(el){return el.dataset.fallback==="true"});if(!isFallback&&tabsContent.length>0){// Helper function to sync child attributes
3
3
  // eslint-disable-next-line no-inner-declarations
4
4
  var syncChildAttributes=function syncChildAttributes(childModel){var childAttributes=childModel.get("attributes")||{};var childProps=childModel.get("componentProps")||{};var hasError=hasTabsError||childAttributes.error||childProps.error;var hasMissing=hasTabsMissing||childAttributes.isMissing||childProps.isMissing;if(hasError||hasMissing){var newAttributes=_extends({},childAttributes,{loading:false,error:hasError,isMissing:hasMissing,inheritedFromParent:!!(hasTabsError||hasTabsMissing)});childModel.set("attributes",newAttributes,{silent:false})}};children.each(function(childModel,i){var childView=_this.createView(childModel);if(childView&&tabsContent[i]){childView.render();tabsContent[i].appendChild(childView.el);setTimeout(function(){syncChildAttributes(childModel)},100);childModel.on("change:attributes",function(){syncChildAttributes(childModel)})}})}}else{ReactDOM.render(/*#__PURE__*/_jsx(QueryCacheProvider,{maxCacheSize:100,maxCacheAge:5*60*1000,children:/*#__PURE__*/_jsx(Renderer,_extends({},compProps,{gjsModel:this.model}))}),this.el)}}else{this.el.innerHTML="<div>Unsupported component: "+compName+"</div>"}renderedComponents[this.model.get("id")]=this.model;return this},createView:function createView(model){var _this$em$get$getType;var ComponentView=(_this$em$get$getType=this.em.get("DomComponents").getType(model.get("type")))==null?void 0:_this$em$get$getType.view;if(!ComponentView){// eslint-disable-next-line no-console
5
5
  console.warn("No view found for component type:",model.get("type"));return null}var view=new ComponentView({model:model,config:this.config,componentTypes:this.componentTypes});return view},remove:function remove(){// eslint-disable-next-line import/no-named-as-default-member
@@ -1 +1 @@
1
- {"version":3,"file":"grapejs-plugin.js","names":["ReactDOM","getRenderers","QueryCacheProvider","jsx","_jsx","createGrapesjsShadcnGenericPlugin","mode","performInteraction","renderedComponents","setHasChanged","grapesjsShadcnGenericPlugin","editor","DomComponents","addType","model","defaults","tagName","droppable","componentName","componentProps","traits","view","events","handleSlotInput","e","target","slot","dataset","text","innerText","props","get","startsWith","_props$data","idx","parseInt","split","dataKeys","Object","keys","data","headerMapper","key","set","_extends","includes","render","_this","compName","compProps","JSON","parse","err","console","error","onChange","renderers","Renderer","maxCacheSize","maxCacheAge","children","gjsModel","el","components","tabsContent","querySelectorAll","tabAttributes","hasTabsError","hasTabsMissing","isMissing","isFallback","Array","from","some","fallback","length","syncChildAttributes","childModel","childAttributes","childProps","hasError","hasMissing","newAttributes","loading","inheritedFromParent","silent","each","i","childView","createView","appendChild","setTimeout","on","innerHTML","_this$em$get$getType","ComponentView","em","getType","warn","config","componentTypes","remove","unmountComponentAtNode"],"sources":["../../src/plugins/grapejs-plugin.tsx"],"sourcesContent":["/* eslint-disable import/no-named-as-default-member */\n/* eslint-disable func-names */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport ReactDOM from 'react-dom';\nimport { Editor, Component } from 'grapesjs';\nimport { getRenderers } from './helpers/render-components';\nimport { QueryCacheProvider } from './helpers/query-cache-context';\n\nexport function createGrapesjsShadcnGenericPlugin(\n mode: 'editor' | 'preview',\n performInteraction: (payload: Record<string, any>) => void,\n renderedComponents: Record<string, Component> = {},\n setHasChanged: (hasChanged: boolean) => void,\n) {\n return function grapesjsShadcnGenericPlugin(editor: Editor): void {\n editor.DomComponents.addType('shadcn-generic', {\n model: {\n defaults: {\n tagName: 'div',\n droppable: false,\n componentName: 'Card',\n componentProps: {},\n traits: [],\n },\n },\n view: {\n events: {\n 'input [data-slot]': 'handleSlotInput',\n } as any,\n handleSlotInput(e: Event) {\n const target = e.target as HTMLElement;\n const slot = target.dataset.slot;\n const text = target.innerText;\n\n const props = this.model.get('componentProps') || {};\n\n if (!slot) {\n return;\n }\n\n if (slot.startsWith('table-header-')) {\n const idx = parseInt(slot.split('-')[2], 10);\n const dataKeys = Object.keys(props.data?.[0] || {});\n\n if (!props.headerMapper) {\n props.headerMapper = {};\n }\n\n const key = dataKeys[idx];\n\n if (key) {\n props.headerMapper[key] = text;\n }\n } else {\n props[slot] = text;\n }\n\n this.model.set('componentProps', {\n ...props,\n });\n\n if (!['search-input'].includes(slot)) {\n setHasChanged(true);\n }\n },\n render: function () {\n const compName: string = this.model.get('componentName');\n let compProps: any = this.model.get('componentProps');\n\n if (typeof compProps === 'string') {\n try {\n compProps = JSON.parse(compProps);\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('Invalid JSON in componentProps', err);\n compProps = {};\n }\n }\n\n compProps.performInteraction = performInteraction;\n\n compProps.onChange = (data: Record<string, any>) => {\n this.model.set('componentProps', {\n ...this.model.get('componentProps'),\n ...data,\n });\n };\n\n const renderers = getRenderers();\n const Renderer = renderers[compName];\n\n if (Renderer) {\n if (compName === 'Tabs') {\n ReactDOM.render(\n <QueryCacheProvider maxCacheSize={100} maxCacheAge={5 * 60 * 1000}>\n <Renderer {...compProps} gjsModel={this.model} />\n </QueryCacheProvider>,\n this.el\n );\n\n const children = this.model.components();\n const tabsContent = this.el.querySelectorAll('.tabs-content');\n\n const tabAttributes = this.model.get('attributes') || {};\n const hasTabsError = tabAttributes.error || compProps.error;\n const hasTabsMissing = tabAttributes.isMissing || compProps.isMissing;\n const isFallback = Array.from(tabsContent).some(\n (el: Element) => (el as HTMLElement).dataset.fallback === 'true',\n );\n\n if (!isFallback && tabsContent.length > 0) {\n // Helper function to sync child attributes\n // eslint-disable-next-line no-inner-declarations\n function syncChildAttributes(childModel: any) {\n const childAttributes = childModel.get('attributes') || {};\n const childProps = childModel.get('componentProps') || {};\n\n const hasError = hasTabsError || childAttributes.error || childProps.error;\n const hasMissing =\n hasTabsMissing || childAttributes.isMissing || childProps.isMissing;\n\n if (hasError || hasMissing) {\n const newAttributes = {\n ...childAttributes,\n loading: false,\n error: hasError,\n isMissing: hasMissing,\n inheritedFromParent: !!(hasTabsError || hasTabsMissing),\n };\n\n childModel.set('attributes', newAttributes, { silent: false });\n }\n }\n\n children.each((childModel, i) => {\n const childView = this.createView(childModel);\n\n if (childView && tabsContent[i]) {\n childView.render();\n tabsContent[i].appendChild(childView.el);\n\n setTimeout(() => {\n syncChildAttributes(childModel);\n }, 100);\n\n childModel.on('change:attributes', () => {\n syncChildAttributes(childModel);\n });\n }\n });\n }\n } else {\n ReactDOM.render(\n <QueryCacheProvider maxCacheSize={100} maxCacheAge={5 * 60 * 1000}>\n <Renderer {...compProps} gjsModel={this.model} />\n </QueryCacheProvider>,\n this.el\n );\n }\n } else {\n this.el.innerHTML = `<div>Unsupported component: ${compName}</div>`;\n }\n\n renderedComponents[this.model.get('id')] = this.model;\n\n return this;\n },\n createView(model: any) {\n const ComponentView = this.em.get('DomComponents').getType(model.get('type'))?.view;\n\n if (!ComponentView) {\n // eslint-disable-next-line no-console\n console.warn('No view found for component type:', model.get('type'));\n\n return null;\n }\n\n const view = new ComponentView({\n model,\n config: this.config,\n componentTypes: this.componentTypes,\n });\n\n return view;\n },\n remove: function () {\n // eslint-disable-next-line import/no-named-as-default-member\n ReactDOM.unmountComponentAtNode(this.el);\n\n return this;\n },\n },\n });\n };\n}\n"],"mappings":"qDAAA,sDACA,+BACA,uDACA,MAAO,CAAAA,QAAQ,KAAM,WAAW,CAEhC,OAASC,YAAY,KAAQ,6BAA6B,CAC1D,OAASC,kBAAkB,KAAQ,+BAA+B,CAAC,OAAAC,GAAA,IAAAC,IAAA,yBAEnE,MAAO,SAAS,CAAAC,iCAAiCA,CAC/CC,IAA0B,CAC1BC,kBAA0D,CAC1DC,kBAA6C,CAC7CC,aAA4C,CAC5C,IAFAD,kBAA6C,WAA7CA,kBAA6C,CAAG,CAAC,CAAC,CAGlD,MAAO,SAAS,CAAAE,2BAA2BA,CAACC,MAAc,CAAQ,CAChEA,MAAM,CAACC,aAAa,CAACC,OAAO,CAAC,gBAAgB,CAAE,CAC7CC,KAAK,CAAE,CACLC,QAAQ,CAAE,CACRC,OAAO,CAAE,KAAK,CACdC,SAAS,CAAE,KAAK,CAChBC,aAAa,CAAE,MAAM,CACrBC,cAAc,CAAE,CAAC,CAAC,CAClBC,MAAM,CAAE,EACV,CACF,CAAC,CACDC,IAAI,CAAE,CACJC,MAAM,CAAE,CACN,mBAAmB,CAAE,iBACvB,CAAQ,CACRC,eAAe,SAAf,CAAAA,eAAeA,CAACC,CAAQ,CAAE,CACxB,GAAM,CAAAC,MAAM,CAAGD,CAAC,CAACC,MAAqB,CACtC,GAAM,CAAAC,IAAI,CAAGD,MAAM,CAACE,OAAO,CAACD,IAAI,CAChC,GAAM,CAAAE,IAAI,CAAGH,MAAM,CAACI,SAAS,CAE7B,GAAM,CAAAC,KAAK,CAAG,IAAI,CAAChB,KAAK,CAACiB,GAAG,CAAC,gBAAgB,CAAC,EAAI,CAAC,CAAC,CAEpD,GAAI,CAACL,IAAI,C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CAAC,MAAM,CAAC,CAAC,CAEpE,MAAO,KACT,CAEA,GAAM,CAAAV,IAAI,CAAG,GAAI,CAAA0E,aAAa,CAAC,CAC7BjF,KAAK,CAALA,KAAK,CACLqF,MAAM,CAAE,IAAI,CAACA,MAAM,CACnBC,cAAc,CAAE,IAAI,CAACA,cACvB,CAAC,CAAC,CAEF,MAAO,CAAA/E,IACT,CAAC,CACDgF,MAAM,CAAE,QAAR,CAAAA,MAAMA,CAAA,CAAc,CAClB;AACArG,QAAQ,CAACsG,sBAAsB,CAAC,IAAI,CAACxC,EAAE,CAAC,CAExC,MAAO,KACT,CACF,CACF,CAAC,CACH,CACF","ignoreList":[]}
1
+ {"version":3,"file":"grapejs-plugin.js","names":["ReactDOM","getRenderers","QueryCacheProvider","jsx","_jsx","createGrapesjsShadcnGenericPlugin","mode","performInteraction","renderedComponents","setHasChanged","isCreatingAssetFromTemplate","grapesjsShadcnGenericPlugin","editor","DomComponents","addType","model","defaults","tagName","droppable","componentName","componentProps","traits","view","events","handleSlotInput","e","target","slot","dataset","text","innerText","props","get","startsWith","_props$data","idx","parseInt","split","dataKeys","Object","keys","data","headerMapper","key","set","_extends","includes","render","_this","compName","compProps","JSON","parse","err","console","error","onChange","renderers","Renderer","maxCacheSize","maxCacheAge","children","gjsModel","el","components","tabsContent","querySelectorAll","tabAttributes","hasTabsError","hasTabsMissing","isMissing","isFallback","Array","from","some","fallback","length","syncChildAttributes","childModel","childAttributes","childProps","hasError","hasMissing","newAttributes","loading","inheritedFromParent","silent","each","i","childView","createView","appendChild","setTimeout","on","innerHTML","_this$em$get$getType","ComponentView","em","getType","warn","config","componentTypes","remove","unmountComponentAtNode"],"sources":["../../src/plugins/grapejs-plugin.tsx"],"sourcesContent":["/* eslint-disable import/no-named-as-default-member */\n/* eslint-disable func-names */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport ReactDOM from 'react-dom';\nimport { Editor, Component } from 'grapesjs';\nimport { getRenderers } from './helpers/render-components';\nimport { QueryCacheProvider } from './helpers/query-cache-context';\n\nexport function createGrapesjsShadcnGenericPlugin(\n mode: 'editor' | 'preview',\n performInteraction: (payload: Record<string, any>) => void,\n renderedComponents: Record<string, Component> = {},\n setHasChanged: (hasChanged: boolean) => void,\n isCreatingAssetFromTemplate: boolean = false,\n) {\n return function grapesjsShadcnGenericPlugin(editor: Editor): void {\n editor.DomComponents.addType('shadcn-generic', {\n model: {\n defaults: {\n tagName: 'div',\n droppable: false,\n componentName: 'Card',\n componentProps: {},\n traits: [],\n },\n },\n view: {\n events: {\n 'input [data-slot]': 'handleSlotInput',\n } as any,\n handleSlotInput(e: Event) {\n const target = e.target as HTMLElement;\n const slot = target.dataset.slot;\n const text = target.innerText;\n\n const props = this.model.get('componentProps') || {};\n\n if (!slot) {\n return;\n }\n\n if (slot.startsWith('table-header-')) {\n const idx = parseInt(slot.split('-')[2], 10);\n const dataKeys = Object.keys(props.data?.[0] || {});\n\n if (!props.headerMapper) {\n props.headerMapper = {};\n }\n\n const key = dataKeys[idx];\n\n if (key) {\n props.headerMapper[key] = text;\n }\n } else {\n props[slot] = text;\n }\n\n this.model.set('componentProps', {\n ...props,\n });\n\n if (!['search-input'].includes(slot)) {\n setHasChanged(true);\n }\n },\n render: function () {\n const compName: string = this.model.get('componentName');\n let compProps: any = this.model.get('componentProps');\n\n if (typeof compProps === 'string') {\n try {\n compProps = JSON.parse(compProps);\n } catch (err) {\n // eslint-disable-next-line no-console\n console.error('Invalid JSON in componentProps', err);\n compProps = {};\n }\n }\n\n compProps.performInteraction = performInteraction;\n compProps.isCreatingAssetFromTemplate = isCreatingAssetFromTemplate;\n\n compProps.onChange = (data: Record<string, any>) => {\n this.model.set('componentProps', {\n ...this.model.get('componentProps'),\n ...data,\n });\n };\n\n const renderers = getRenderers();\n const Renderer = renderers[compName];\n\n if (Renderer) {\n if (compName === 'Tabs') {\n ReactDOM.render(\n <QueryCacheProvider maxCacheSize={100} maxCacheAge={5 * 60 * 1000}>\n <Renderer {...compProps} gjsModel={this.model} />\n </QueryCacheProvider>,\n this.el\n );\n\n const children = this.model.components();\n const tabsContent = this.el.querySelectorAll('.tabs-content');\n\n const tabAttributes = this.model.get('attributes') || {};\n const hasTabsError = tabAttributes.error || compProps.error;\n const hasTabsMissing = tabAttributes.isMissing || compProps.isMissing;\n const isFallback = Array.from(tabsContent).some(\n (el: Element) => (el as HTMLElement).dataset.fallback === 'true',\n );\n\n if (!isFallback && tabsContent.length > 0) {\n // Helper function to sync child attributes\n // eslint-disable-next-line no-inner-declarations\n function syncChildAttributes(childModel: any) {\n const childAttributes = childModel.get('attributes') || {};\n const childProps = childModel.get('componentProps') || {};\n\n const hasError = hasTabsError || childAttributes.error || childProps.error;\n const hasMissing =\n hasTabsMissing || childAttributes.isMissing || childProps.isMissing;\n\n if (hasError || hasMissing) {\n const newAttributes = {\n ...childAttributes,\n loading: false,\n error: hasError,\n isMissing: hasMissing,\n inheritedFromParent: !!(hasTabsError || hasTabsMissing),\n };\n\n childModel.set('attributes', newAttributes, { silent: false });\n }\n }\n\n children.each((childModel, i) => {\n const childView = this.createView(childModel);\n\n if (childView && tabsContent[i]) {\n childView.render();\n tabsContent[i].appendChild(childView.el);\n\n setTimeout(() => {\n syncChildAttributes(childModel);\n }, 100);\n\n childModel.on('change:attributes', () => {\n syncChildAttributes(childModel);\n });\n }\n });\n }\n } else {\n ReactDOM.render(\n <QueryCacheProvider maxCacheSize={100} maxCacheAge={5 * 60 * 1000}>\n <Renderer {...compProps} gjsModel={this.model} />\n </QueryCacheProvider>,\n this.el\n );\n }\n } else {\n this.el.innerHTML = `<div>Unsupported component: ${compName}</div>`;\n }\n\n renderedComponents[this.model.get('id')] = this.model;\n\n return this;\n },\n createView(model: any) {\n const ComponentView = this.em.get('DomComponents').getType(model.get('type'))?.view;\n\n if (!ComponentView) {\n // eslint-disable-next-line no-console\n console.warn('No view found for component type:', model.get('type'));\n\n return null;\n }\n\n const view = new ComponentView({\n model,\n config: this.config,\n componentTypes: this.componentTypes,\n });\n\n return view;\n },\n remove: function () {\n // eslint-disable-next-line import/no-named-as-default-member\n ReactDOM.unmountComponentAtNode(this.el);\n\n return this;\n },\n },\n });\n };\n}\n"],"mappings":"qDAAA,sDACA,+BACA,uDACA,MAAO,CAAAA,QAAQ,KAAM,WAAW,CAEhC,OAASC,YAAY,KAAQ,6BAA6B,CAC1D,OAASC,kBAAkB,KAAQ,+BAA+B,CAAC,OAAAC,GAAA,IAAAC,IAAA,yBAEnE,MAAO,SAAS,CAAAC,iCAAiCA,CAC/CC,IAA0B,CAC1BC,kBAA0D,CAC1DC,kBAA6C,CAC7CC,aAA4C,CAC5CC,2BAAoC,CACpC,IAHAF,kBAA6C,WAA7CA,kBAA6C,CAAG,CAAC,CAAC,IAElDE,2BAAoC,WAApCA,2BAAoC,CAAG,KAAK,CAE5C,MAAO,SAAS,CAAAC,2BAA2BA,CAACC,MAAc,CAAQ,CAChEA,MAAM,CAACC,aAAa,CAACC,OAAO,CAAC,gBAAgB,CAAE,CAC7CC,KAAK,CAAE,CACLC,QAAQ,CAAE,CACRC,OAAO,CAAE,KAAK,CACdC,SAAS,CAAE,KAAK,CAChBC,aAAa,CAAE,MAAM,CACrBC,cAAc,CAAE,CAAC,CAAC,CAClBC,MAAM,CAAE,EACV,CACF,CAAC,CACDC,IAAI,CAAE,CACJC,MAAM,CAAE,CACN,mBAAmB,CAAE,iBACvB,CAAQ,CACRC,eAAe,SAAf,CAAAA,eAAeA,CAACC,CAAQ,CAAE,CACxB,GAAM,CAAAC,MAAM,CAAGD,CAAC,CAACC,MAAqB,CACtC,GAAM,CAAAC,IAAI,CAAGD,MAAM,CAACE,OAAO,CAACD,IAAI,CAChC,GAAM,CAAAE,IAAI,CAAGH,MAAM,CAACI,SAAS,CAE7B,GAAM,CAAAC,KAAK,CAAG,IAAI,CAAChB,KAAK,CAACiB,GAAG,CAAC,gBAAgB,CAAC,EAAI,CAAC,CAAC,CAEpD,GAAI,CAACL,IAAI,CAAE,CACT,MACF,CAEA,GAA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pF,KAAK,CAACiB,GAAG,CAAC,MAAM,CAAC,CAAC,CAEpE,MAAO,KACT,CAEA,GAAM,CAAAV,IAAI,CAAG,GAAI,CAAA0E,aAAa,CAAC,CAC7BjF,KAAK,CAALA,KAAK,CACLqF,MAAM,CAAE,IAAI,CAACA,MAAM,CACnBC,cAAc,CAAE,IAAI,CAACA,cACvB,CAAC,CAAC,CAEF,MAAO,CAAA/E,IACT,CAAC,CACDgF,MAAM,CAAE,QAAR,CAAAA,MAAMA,CAAA,CAAc,CAClB;AACAtG,QAAQ,CAACuG,sBAAsB,CAAC,IAAI,CAACxC,EAAE,CAAC,CAExC,MAAO,KACT,CACF,CACF,CAAC,CACH,CACF","ignoreList":[]}
@@ -1,2 +1,2 @@
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{useEffect,useState,Fragment}from"react";import{Table,TableHeader,TableRow,TableHead,TableBody,TableCell,TableHeadSortable}from"../../shadcn/components/ui/table";import{TableLoader}from"../../shadcn/components/ui/skeleton";import{ScrollArea,ScrollBar}from"../../shadcn/components/ui/scroll-area";import{Pagination,PaginationContent,renderPaginationArrows}from"../../shadcn/components/ui/pagination";import{TableButton}from"../../shadcn/components/ui/button";import{cn}from"../../shadcn/utils";import{renderNoDataFallback}from"./extra";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function DataTable(_ref){var _ref2,_pagination$values$pa,_pagination$values,_ref3,_pagination$values$pa2,_pagination$values2;var _ref$data=_ref.data,data=_ref$data===void 0?[]:_ref$data,_ref$headerMapper=_ref.headerMapper,headerMapper=_ref$headerMapper===void 0?{}:_ref$headerMapper,_ref$className=_ref.className,className=_ref$className===void 0?"":_ref$className,_ref$actions=_ref.actions,actions=_ref$actions===void 0?[]:_ref$actions,_ref$isEditable=_ref.isEditable,isEditable=_ref$isEditable===void 0?false:_ref$isEditable,pagination=_ref.pagination,_ref$isLoading=_ref.isLoading,isLoading=_ref$isLoading===void 0?false:_ref$isLoading,onRowAction=_ref.onRowAction,onPageChange=_ref.onPageChange,onSort=_ref.onSort,sortConfig=_ref.sortConfig,_ref$otherProps=_ref.otherProps,otherProps=_ref$otherProps===void 0?{}:_ref$otherProps,height=_ref.height;if(!data||data.length===0){return/*#__PURE__*/_jsx(Fragment,{children:/*#__PURE__*/_jsx("div",{className:"flex flex-col overflow-hidden",children:/*#__PURE__*/_jsx("div",{"data-slot":"table-container",className:"aspect-auto w-full",style:{height:"auto",minHeight:"180px"},children:isLoading?/*#__PURE__*/_jsx(TableLoader,{}):renderNoDataFallback()})})})}var _useState=useState(null),activeSortColumn=_useState[0],setActiveSortColumn=_useState[1];var _useState2=useState({}),sortDirections=_useState2[0],setSortDirections=_useState2[1];var _useState3=useState(Number((_ref2=(_pagination$values$pa=pagination==null||(_pagination$values=pagination.values)==null?void 0:_pagination$values.pageNumber)!=null?_pagination$values$pa:pagination==null?void 0:pagination.initialPage)!=null?_ref2:1)),pageNumber=_useState3[0],setPageNumber=_useState3[1];var _useState4=useState(Number((_ref3=(_pagination$values$pa2=pagination==null||(_pagination$values2=pagination.values)==null?void 0:_pagination$values2.pageSize)!=null?_pagination$values$pa2:pagination==null?void 0:pagination.initialPageSize)!=null?_ref3:10)),pageSize=_useState4[0],setPageSize=_useState4[1];var _useState5=useState(Math.ceil(((pagination==null?void 0:pagination.totalCount)||0)/pageSize)||1),totalPages=_useState5[0],setTotalPages=_useState5[1];useEffect(function(){var _ref4,_pagination$values$pa3,_pagination$values3,_ref5,_pagination$values$pa4,_pagination$values4;setPageNumber(Number((_ref4=(_pagination$values$pa3=pagination==null||(_pagination$values3=pagination.values)==null?void 0:_pagination$values3.pageNumber)!=null?_pagination$values$pa3:pagination==null?void 0:pagination.initialPage)!=null?_ref4:1));setPageSize(Number((_ref5=(_pagination$values$pa4=pagination==null||(_pagination$values4=pagination.values)==null?void 0:_pagination$values4.pageSize)!=null?_pagination$values$pa4:pagination==null?void 0:pagination.initialPageSize)!=null?_ref5:25))},[pagination]);useEffect(function(){setTotalPages(Math.ceil(((pagination==null?void 0:pagination.totalCount)||0)/pageSize)||1)},[pagination==null?void 0:pagination.totalCount,pageSize]);useEffect(function(){if(sortConfig){setSortDirections(sortConfig);var first=Object.keys(sortConfig)[0];if(first){setActiveSortColumn(first)}}},[sortConfig]);useEffect(function(){if(sortConfig!=null&&sortConfig.sortColumn||sortConfig!=null&&sortConfig.sortDirection){sortConfig.sortColumn=null;sortConfig.sortDirection=null}setActiveSortColumn(null);setSortDirections({})},[]);var originalKeys=Object.keys(data[0]||{}).filter(function(key){return key in headerMapper});var headers=originalKeys.map(function(key){return headerMapper[key]});if(actions.length>0){headers.push("")}var rows=data.map(function(datum){return originalKeys.map(function(key){return datum[key]})});function handlePageChange(_x,_x2){return _handlePageChange.apply(this,arguments)}function _handlePageChange(){_handlePageChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(newPage,newSize){return _regeneratorRuntime.wrap(function(_context){while(1)switch(_context.prev=_context.next){case 0:if(newPage===void 0){newPage=pageNumber}if(newSize===void 0){newSize=pageSize}setPageNumber(newPage);setPageSize(newSize);onPageChange==null||onPageChange(newPage,newSize);case 1:case"end":return _context.stop()}},_callee)}));return _handlePageChange.apply(this,arguments)}function handleSortClick(column,direction){setActiveSortColumn(direction?column:null);setSortDirections(function(prev){var _extends2;return _extends({},prev,(_extends2={},_extends2[column]=direction,_extends2))});onSort==null||onSort(column,direction)}function renderActions(rowIndex,rowActions){if(!actions.length){return null}return/*#__PURE__*/_jsx(TableCell,{className:"sticky right-0 bg-white",children:rowActions.map(function(action){return/*#__PURE__*/_jsx(TableButton,{className:action.className,isEditable:isEditable,onClick:function onClick(){return onRowAction==null?void 0:onRowAction(rowIndex,action.id)},variant:action.variant,text:action.text,tooltipContent:action.tooltipContent,disabled:isLoading},action.id)})})}var defaultClasses="aspect-auto w-full";var mergedClasses=className?cn(defaultClasses,className):defaultClasses;function renderTableComponent(){if(isLoading||!data||data.length===0){return/*#__PURE__*/_jsx(TableLoader,{})}return/*#__PURE__*/_jsxs(Table,_extends({},otherProps,{className:"caption-bottom text-sm relative "+mergedClasses,"data-slot":"table",children:[/*#__PURE__*/_jsx(TableHeader,{"data-slot":"table-header",className:"sticky top-0 z-2",children:/*#__PURE__*/_jsx(TableRow,{children:headers.map(function(head,idx){var isActionColumn=actions.length>0&&idx===headers.length-1;var originalKey=originalKeys[idx];if(isActionColumn){return/*#__PURE__*/_jsx(TableHead,{"data-slot":"table-header-"+idx,contentEditable:isEditable,className:"sticky right-0 bg-slate-100",children:head},idx)}return/*#__PURE__*/_jsx(TableHeadSortable,{"data-slot":"table-header-"+idx,sortDirection:sortDirections[originalKey]||"asc",isActive:activeSortColumn===originalKey,onSort:function onSort(direction){return handleSortClick(originalKey,direction)},sortable:!isLoading,isEditable:isEditable,children:head},idx)})})}),/*#__PURE__*/_jsx(TableBody,{"data-slot":"table-body",children:rows.map(function(row,rIdx){return/*#__PURE__*/_jsxs(TableRow,{"data-slot":"row-"+rIdx,className:"hover:bg-muted/50 border-b transition-colors",children:[row.map(function(cell,cIdx){return/*#__PURE__*/_jsx(TableCell,{"data-slot":"cell-"+rIdx+"-"+cIdx,className:"p-2 align-middle whitespace-nowrap",contentEditable:false,children:cell===null?"-":String(cell)},cIdx)}),renderActions(rIdx,actions)]},rIdx)})})]}))}return/*#__PURE__*/_jsxs(Fragment,{children:[/*#__PURE__*/_jsx("div",{className:"flex flex-col h-full overflow-hidden",children:/*#__PURE__*/_jsxs(ScrollArea,_extends({"data-slot":"table-container",className:mergedClasses},height!==undefined&&{style:{height:height}},{children:[renderTableComponent(),/*#__PURE__*/_jsx(ScrollBar,{orientation:"horizontal"})]}))}),pagination&&pagination.totalCount>0&&/*#__PURE__*/_jsxs("div",{className:"flex-shrink-0 flex items-center justify-between mt-2 w-full overflow-x-auto border-t pt-2",children:[/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[/*#__PURE__*/_jsx("label",{htmlFor:"page-size-select",className:"text-sm whitespace-nowrap",children:"Rows per page:"}),/*#__PURE__*/_jsx("select",{id:"page-size-select",value:pageSize,onChange:function onChange(e){return handlePageChange(1,Number(e.target.value))},className:"border rounded px-2 py-1 text-sm cursor-pointer",disabled:isLoading,children:pagination.pageSizeOptions.map(function(size){return/*#__PURE__*/_jsx("option",{value:size,children:size},size)})})]}),/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[/*#__PURE__*/_jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap ml-1.5",children:[(pageNumber-1)*pageSize+1,"\u2013",Math.min(pageNumber*pageSize,pagination.totalCount)," of ",pagination.totalCount]}),/*#__PURE__*/_jsx(Pagination,{children:/*#__PURE__*/_jsx(PaginationContent,{className:"gap-0.2 flex-shrink-0",children:renderPaginationArrows(pageNumber,totalPages,isLoading,handlePageChange)})})]})]})]})}
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{useEffect,useState,Fragment}from"react";import{Table,TableHeader,TableRow,TableHead,TableBody,TableCell,TableHeadSortable}from"../../shadcn/components/ui/table";import{TableLoader}from"../../shadcn/components/ui/skeleton";import{ScrollArea,ScrollBar}from"../../shadcn/components/ui/scroll-area";import{Pagination,PaginationContent,renderPaginationArrows}from"../../shadcn/components/ui/pagination";import{TableButton}from"../../shadcn/components/ui/button";import{cn}from"../../shadcn/utils";import{renderNoDataFallback}from"./extra";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export function DataTable(_ref){var _ref2,_pagination$values$pa,_pagination$values,_ref3,_pagination$values$pa2,_pagination$values2;var _ref$data=_ref.data,data=_ref$data===void 0?[]:_ref$data,_ref$headerMapper=_ref.headerMapper,headerMapper=_ref$headerMapper===void 0?{}:_ref$headerMapper,_ref$className=_ref.className,className=_ref$className===void 0?"":_ref$className,_ref$actions=_ref.actions,actions=_ref$actions===void 0?[]:_ref$actions,_ref$isEditable=_ref.isEditable,isEditable=_ref$isEditable===void 0?false:_ref$isEditable,pagination=_ref.pagination,_ref$isLoading=_ref.isLoading,isLoading=_ref$isLoading===void 0?false:_ref$isLoading,onRowAction=_ref.onRowAction,onPageChange=_ref.onPageChange,onSort=_ref.onSort,sortConfig=_ref.sortConfig,_ref$otherProps=_ref.otherProps,otherProps=_ref$otherProps===void 0?{}:_ref$otherProps,height=_ref.height;if(!data||data.length===0){return/*#__PURE__*/_jsx(Fragment,{children:/*#__PURE__*/_jsx("div",{className:"flex flex-col overflow-hidden",children:/*#__PURE__*/_jsx("div",{"data-slot":"table-container",className:"aspect-auto w-full",style:{height:"auto",minHeight:"180px"},children:isLoading?/*#__PURE__*/_jsx(TableLoader,{}):renderNoDataFallback()})})})}var _useState=useState(null),activeSortColumn=_useState[0],setActiveSortColumn=_useState[1];var _useState2=useState({}),sortDirections=_useState2[0],setSortDirections=_useState2[1];var _useState3=useState(Number((_ref2=(_pagination$values$pa=pagination==null||(_pagination$values=pagination.values)==null?void 0:_pagination$values.pageNumber)!=null?_pagination$values$pa:pagination==null?void 0:pagination.initialPage)!=null?_ref2:1)),pageNumber=_useState3[0],setPageNumber=_useState3[1];var _useState4=useState(Number((_ref3=(_pagination$values$pa2=pagination==null||(_pagination$values2=pagination.values)==null?void 0:_pagination$values2.pageSize)!=null?_pagination$values$pa2:pagination==null?void 0:pagination.initialPageSize)!=null?_ref3:10)),pageSize=_useState4[0],setPageSize=_useState4[1];var _useState5=useState(Math.ceil(((pagination==null?void 0:pagination.totalCount)||0)/pageSize)||1),totalPages=_useState5[0],setTotalPages=_useState5[1];useEffect(function(){var _ref4,_pagination$values$pa3,_pagination$values3,_ref5,_pagination$values$pa4,_pagination$values4;setPageNumber(Number((_ref4=(_pagination$values$pa3=pagination==null||(_pagination$values3=pagination.values)==null?void 0:_pagination$values3.pageNumber)!=null?_pagination$values$pa3:pagination==null?void 0:pagination.initialPage)!=null?_ref4:1));setPageSize(Number((_ref5=(_pagination$values$pa4=pagination==null||(_pagination$values4=pagination.values)==null?void 0:_pagination$values4.pageSize)!=null?_pagination$values$pa4:pagination==null?void 0:pagination.initialPageSize)!=null?_ref5:25))},[pagination]);useEffect(function(){setTotalPages(Math.ceil(((pagination==null?void 0:pagination.totalCount)||0)/pageSize)||1)},[pagination==null?void 0:pagination.totalCount,pageSize]);useEffect(function(){if(sortConfig){setSortDirections(sortConfig);var first=Object.keys(sortConfig)[0];if(first){setActiveSortColumn(first)}}},[sortConfig]);useEffect(function(){if(sortConfig!=null&&sortConfig.sortColumn||sortConfig!=null&&sortConfig.sortDirection){sortConfig.sortColumn=null;sortConfig.sortDirection=null}setActiveSortColumn(null);setSortDirections({})},[]);var originalKeys=Object.keys(data[0]||{}).filter(function(key){return key in headerMapper});var headers=originalKeys.map(function(key){return headerMapper[key]});if(actions.length>0){headers.push("")}var rows=data.map(function(datum){return originalKeys.map(function(key){return datum[key]})});function handlePageChange(_x,_x2){return _handlePageChange.apply(this,arguments)}function _handlePageChange(){_handlePageChange=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(newPage,newSize){return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(newPage===void 0){newPage=pageNumber}if(newSize===void 0){newSize=pageSize}setPageNumber(newPage);setPageSize(newSize);onPageChange==null||onPageChange(newPage,newSize);case 5:case"end":return _context.stop()}},_callee)}));return _handlePageChange.apply(this,arguments)}function handleSortClick(column,direction){setActiveSortColumn(direction?column:null);setSortDirections(function(prev){var _extends2;return _extends({},prev,(_extends2={},_extends2[column]=direction,_extends2))});onSort==null||onSort(column,direction)}function renderActions(rowIndex,rowActions){if(!actions.length){return null}return/*#__PURE__*/_jsx(TableCell,{className:"sticky right-0 bg-white",children:rowActions.map(function(action){return/*#__PURE__*/_jsx(TableButton,{className:action.className,isEditable:isEditable,onClick:function onClick(){return onRowAction==null?void 0:onRowAction(rowIndex,action.id)},variant:action.variant,text:action.text,tooltipContent:action.tooltipContent,disabled:isLoading},action.id)})})}var defaultClasses="aspect-auto w-full";var mergedClasses=className?cn(defaultClasses,className):defaultClasses;function renderTableComponent(){if(isLoading||!data||data.length===0){return/*#__PURE__*/_jsx(TableLoader,{})}return/*#__PURE__*/_jsxs(Table,_extends({},otherProps,{className:"caption-bottom text-sm relative "+mergedClasses,"data-slot":"table",children:[/*#__PURE__*/_jsx(TableHeader,{"data-slot":"table-header",className:"sticky top-0 z-2",children:/*#__PURE__*/_jsx(TableRow,{children:headers.map(function(head,idx){var isActionColumn=actions.length>0&&idx===headers.length-1;var originalKey=originalKeys[idx];if(isActionColumn){return/*#__PURE__*/_jsx(TableHead,{"data-slot":"table-header-"+idx,contentEditable:isEditable,className:"sticky right-0 bg-slate-100",children:head},idx)}return/*#__PURE__*/_jsx(TableHeadSortable,{"data-slot":"table-header-"+idx,sortDirection:sortDirections[originalKey]||"asc",isActive:activeSortColumn===originalKey,onSort:function onSort(direction){return handleSortClick(originalKey,direction)},sortable:!isLoading,isEditable:isEditable,children:head},idx)})})}),/*#__PURE__*/_jsx(TableBody,{"data-slot":"table-body",children:rows.map(function(row,rIdx){return/*#__PURE__*/_jsxs(TableRow,{"data-slot":"row-"+rIdx,className:"hover:bg-muted/50 border-b transition-colors",children:[row.map(function(cell,cIdx){return/*#__PURE__*/_jsx(TableCell,{"data-slot":"cell-"+rIdx+"-"+cIdx,className:"p-2 align-middle whitespace-nowrap",contentEditable:false,children:cell===null?"-":String(cell)},cIdx)}),renderActions(rIdx,actions)]},rIdx)})})]}))}return/*#__PURE__*/_jsxs(Fragment,{children:[/*#__PURE__*/_jsx("div",{className:"flex flex-col h-full overflow-hidden",children:/*#__PURE__*/_jsxs(ScrollArea,_extends({"data-slot":"table-container",className:mergedClasses},height!==undefined&&{style:{height:height}},{children:[renderTableComponent(),/*#__PURE__*/_jsx(ScrollBar,{orientation:"horizontal"})]}))}),pagination&&pagination.totalCount>0&&/*#__PURE__*/_jsxs("div",{className:"flex-shrink-0 flex items-center justify-between mt-2 w-full overflow-x-auto border-t pt-2",children:[/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[/*#__PURE__*/_jsx("label",{htmlFor:"page-size-select",className:"text-sm whitespace-nowrap",children:"Rows per page:"}),/*#__PURE__*/_jsx("select",{id:"page-size-select",value:pageSize,onChange:function onChange(e){return handlePageChange(1,Number(e.target.value))},className:"border rounded px-2 py-1 text-sm cursor-pointer",disabled:isLoading,children:pagination.pageSizeOptions.map(function(size){return/*#__PURE__*/_jsx("option",{value:size,children:size},size)})})]}),/*#__PURE__*/_jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[/*#__PURE__*/_jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap ml-1.5",children:[(pageNumber-1)*pageSize+1,"\u2013",Math.min(pageNumber*pageSize,pagination.totalCount)," of ",pagination.totalCount]}),/*#__PURE__*/_jsx(Pagination,{children:/*#__PURE__*/_jsx(PaginationContent,{className:"gap-0.2 flex-shrink-0",children:renderPaginationArrows(pageNumber,totalPages,isLoading,handlePageChange)})})]})]})]})}
2
2
  //# sourceMappingURL=data-table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-table.js","names":["useEffect","useState","Fragment","Table","TableHeader","TableRow","TableHead","TableBody","TableCell","TableHeadSortable","TableLoader","ScrollArea","ScrollBar","Pagination","PaginationContent","renderPaginationArrows","TableButton","cn","renderNoDataFallback","jsx","_jsx","jsxs","_jsxs","DataTable","_ref","_ref2","_pagination$values$pa","_pagination$values","_ref3","_pagination$values$pa2","_pagination$values2","_ref$data","data","_ref$headerMapper","headerMapper","_ref$className","className","_ref$actions","actions","_ref$isEditable","isEditable","pagination","_ref$isLoading","isLoading","onRowAction","onPageChange","onSort","sortConfig","_ref$otherProps","otherProps","height","length","children","style","minHeight","_useState","activeSortColumn","setActiveSortColumn","_useState2","sortDirections","setSortDirections","_useState3","Number","values","pageNumber","initialPage","setPageNumber","_useState4","pageSize","initialPageSize","setPageSize","_useState5","Math","ceil","totalCount","totalPages","setTotalPages","_ref4","_pagination$values$pa3","_pagination$values3","_ref5","_pagination$values$pa4","_pagination$values4","first","Object","keys","sortColumn","sortDirection","originalKeys","filter","key","headers","map","push","rows","datum","handlePageChange","_x","_x2","_handlePageChange","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","newPage","newSize","wrap","_context","prev","next","stop","handleSortClick","column","direction","_extends2","_extends","renderActions","rowIndex","rowActions","action","onClick","id","variant","text","tooltipContent","disabled","defaultClasses","mergedClasses","renderTableComponent","head","idx","isActionColumn","originalKey","contentEditable","isActive","sortable","row","rIdx","cell","cIdx","String","undefined","orientation","htmlFor","value","onChange","e","target","pageSizeOptions","size","min"],"sources":["../../../src/plugins/helpers/data-table.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useEffect, useState, Fragment } from 'react';\nimport {\n Table,\n TableHeader,\n TableRow,\n TableHead,\n TableBody,\n TableCell,\n TableHeadSortable,\n SortDirection,\n} from '../../shadcn/components/ui/table';\nimport { TableLoader } from '../../shadcn/components/ui/skeleton';\nimport { ScrollArea, ScrollBar } from '../../shadcn/components/ui/scroll-area';\nimport {\n Pagination,\n PaginationContent,\n renderPaginationArrows,\n} from '../../shadcn/components/ui/pagination';\nimport { TableButton } from '../../shadcn/components/ui/button';\nimport { cn } from '../../shadcn/utils';\nimport { renderNoDataFallback } from './extra'\n\ntype RowAction = {\n id: string;\n text: string;\n variant?: string;\n tooltipContent?: string;\n className?: string;\n};\n\nexport type DataTableProps = {\n data: Record<string, any>[];\n headerMapper?: Record<string, string>;\n className?: string;\n isEditable?: boolean;\n actions?: RowAction[];\n pagination?: {\n values?: {\n pageNumber: number;\n pageSize: number;\n };\n initialPage?: number;\n initialPageSize?: number;\n totalCount: number;\n pageSizeOptions: number[];\n };\n isLoading?: boolean;\n onRowAction?: (rowIndex: number, actionId: string) => void;\n onPageChange?: (pageNumber: number, pageSize: number) => void;\n onSort?: (column: string, direction: SortDirection) => void;\n sortConfig?: Record<string, SortDirection>;\n otherProps?: Record<string, any>;\n height?: string | number;\n};\n\nexport function DataTable({\n data = [],\n headerMapper = {},\n className = '',\n actions = [],\n isEditable = false,\n pagination,\n isLoading = false,\n onRowAction,\n onPageChange,\n onSort,\n sortConfig,\n otherProps = {},\n height,\n}: DataTableProps) {\n\n if (!data || data.length === 0) {\n return (\n <Fragment>\n <div className=\"flex flex-col overflow-hidden\">\n <div\n data-slot=\"table-container\"\n className=\"aspect-auto w-full\"\n style={{ height: 'auto', minHeight: '180px' }}\n >\n {isLoading ? <TableLoader /> : renderNoDataFallback()}\n </div>\n </div>\n </Fragment>\n );\n }\n\n const [activeSortColumn, setActiveSortColumn] = useState<string | null>(null);\n const [sortDirections, setSortDirections] = useState<Record<string, SortDirection>>({});\n\n const [pageNumber, setPageNumber] = useState(\n Number(pagination?.values?.pageNumber ?? pagination?.initialPage ?? 1),\n );\n const [pageSize, setPageSize] = useState(\n Number(pagination?.values?.pageSize ?? pagination?.initialPageSize ?? 10),\n );\n const [totalPages, setTotalPages] = useState(\n Math.ceil((pagination?.totalCount || 0) / pageSize) || 1,\n );\n\n useEffect(() => {\n setPageNumber(Number(pagination?.values?.pageNumber ?? pagination?.initialPage ?? 1));\n setPageSize(Number(pagination?.values?.pageSize ?? pagination?.initialPageSize ?? 25));\n }, [pagination]);\n\n useEffect(() => {\n setTotalPages(Math.ceil((pagination?.totalCount || 0) / pageSize) || 1);\n }, [pagination?.totalCount, pageSize]);\n\n useEffect(() => {\n if (sortConfig) {\n setSortDirections(sortConfig);\n const first = Object.keys(sortConfig)[0];\n\n if (first) {\n setActiveSortColumn(first);\n }\n }\n }, [sortConfig]);\n\n useEffect(() => {\n if (sortConfig?.sortColumn || sortConfig?.sortDirection) {\n sortConfig.sortColumn = null;\n sortConfig.sortDirection = null;\n }\n \n setActiveSortColumn(null);\n setSortDirections({});\n }, []);\n \n const originalKeys = Object.keys(data[0] || {}).filter((key) => key in headerMapper);\n const headers = originalKeys.map((key) => headerMapper[key]);\n\n if (actions.length > 0) {\n headers.push('');\n }\n\n const rows = data.map((datum: any) => originalKeys.map((key) => datum[key]));\n\n async function handlePageChange(newPage = pageNumber, newSize = pageSize) {\n setPageNumber(newPage);\n setPageSize(newSize);\n onPageChange?.(newPage, newSize);\n }\n\n function handleSortClick(column: string, direction: SortDirection) {\n setActiveSortColumn(direction ? column : null);\n setSortDirections((prev) => ({\n ...prev,\n [column]: direction,\n }));\n onSort?.(column, direction);\n }\n\n function renderActions(rowIndex: number, rowActions: RowAction[]) {\n if (!actions.length) {\n return null;\n }\n\n return (\n <TableCell className=\"sticky right-0 bg-white\">\n {rowActions.map((action) => (\n <TableButton\n key={action.id}\n className={action.className}\n isEditable={isEditable}\n onClick={() => onRowAction?.(rowIndex, action.id)}\n variant={action.variant}\n text={action.text}\n tooltipContent={action.tooltipContent}\n disabled={isLoading}\n />\n ))}\n </TableCell>\n );\n }\n\n const defaultClasses = `aspect-auto w-full`;\n const mergedClasses = className ? cn(defaultClasses, className) : defaultClasses;\n\n function renderTableComponent() {\n if (isLoading || (!data || data.length === 0)) {\n return <TableLoader />;\n }\n\n return (\n <Table\n {...otherProps}\n className={`caption-bottom text-sm relative ${mergedClasses}`}\n data-slot=\"table\"\n >\n <TableHeader data-slot=\"table-header\" className=\"sticky top-0 z-2\">\n <TableRow>\n {headers.map((head: string, idx: number) => {\n const isActionColumn = actions.length > 0 && idx === headers.length - 1;\n const originalKey = originalKeys[idx];\n\n if (isActionColumn) {\n return (\n <TableHead\n key={idx}\n data-slot={`table-header-${idx}`}\n contentEditable={isEditable}\n className=\"sticky right-0 bg-slate-100\"\n >\n {head}\n </TableHead>\n );\n }\n\n return (\n <TableHeadSortable\n key={idx}\n data-slot={`table-header-${idx}`}\n sortDirection={sortDirections[originalKey] || 'asc'}\n isActive={activeSortColumn === originalKey}\n onSort={(direction) => handleSortClick(originalKey, direction)}\n sortable={!isLoading}\n isEditable={isEditable}\n >\n {head}\n </TableHeadSortable>\n );\n })}\n </TableRow>\n </TableHeader>\n <TableBody data-slot=\"table-body\">\n {rows.map((row: any[], rIdx: number) => (\n <TableRow\n key={rIdx}\n data-slot={`row-${rIdx}`}\n className=\"hover:bg-muted/50 border-b transition-colors\"\n >\n {row.map((cell: string, cIdx: number) => (\n <TableCell\n key={cIdx}\n data-slot={`cell-${rIdx}-${cIdx}`}\n className=\"p-2 align-middle whitespace-nowrap\"\n contentEditable={false}\n >\n {cell === null ? '-' : String(cell)}\n </TableCell>\n ))}\n {renderActions(rIdx, actions)}\n </TableRow>\n ))}\n </TableBody>\n </Table>\n );\n }\n\n return (\n <Fragment>\n <div className=\"flex flex-col h-full overflow-hidden\">\n <ScrollArea\n data-slot=\"table-container\"\n className={mergedClasses}\n {...(height !== undefined && { style: { height } })}\n >\n {renderTableComponent()}\n <ScrollBar orientation=\"horizontal\" />\n </ScrollArea>\n </div>\n {pagination && pagination.totalCount > 0 && (\n <div className=\"flex-shrink-0 flex items-center justify-between mt-2 w-full overflow-x-auto border-t pt-2\">\n <div className=\"flex items-center gap-2 flex-shrink-0\">\n <label htmlFor=\"page-size-select\" className=\"text-sm whitespace-nowrap\">\n Rows per page:\n </label>\n <select\n id=\"page-size-select\"\n value={pageSize}\n onChange={(e) => handlePageChange(1, Number(e.target.value))}\n className=\"border rounded px-2 py-1 text-sm cursor-pointer\"\n disabled={isLoading}\n >\n {pagination.pageSizeOptions.map((size: number) => (\n <option key={size} value={size}>\n {size}\n </option>\n ))}\n </select>\n </div>\n <div className=\"flex items-center gap-1 flex-shrink-0\">\n <span className=\"text-xs text-muted-foreground whitespace-nowrap ml-1.5\">\n {(pageNumber - 1) * pageSize + 1}–\n {Math.min(pageNumber * pageSize, pagination.totalCount)} of {pagination.totalCount}\n </span>\n <Pagination>\n <PaginationContent className=\"gap-0.2 flex-shrink-0\">\n {renderPaginationArrows(pageNumber, totalPages, isLoading, handlePageChange)}\n </PaginationContent>\n </Pagination>\n </div>\n </div>\n )}\n </Fragment>\n );\n}\n"],"mappings":"wLAAA,uDACA,OAASA,SAAS,CAAEC,QAAQ,CAAEC,QAAQ,KAAQ,OAAO,CACrD,OACEC,KAAK,CACLC,WAAW,CACXC,QAAQ,CACRC,SAAS,CACTC,SAAS,CACTC,SAAS,CACTC,iBAAiB,KAEZ,kCAAkC,CACzC,OAASC,WAAW,KAAQ,qCAAqC,CACjE,OAASC,UAAU,CAAEC,SAAS,KAAQ,wCAAwC,CAC9E,OACEC,UAAU,CACVC,iBAAiB,CACjBC,sBAAsB,KACjB,uCAAuC,CAC9C,OAASC,WAAW,KAAQ,mCAAmC,CAC/D,OAASC,EAAE,KAAQ,oBAAoB,CACvC,OAASC,oBAAoB,KAAQ,SAAS,QAAAC,GAAA,IAAAC,IAAA,CAAAC,IAAA,IAAAC,KAAA,yBAmC9C,MAAO,SAAS,CAAAC,SAASA,CAAAC,IAAA,CAcN,KAAAC,KAAA,CAAAC,qBAAA,CAAAC,kBAAA,CAAAC,KAAA,CAAAC,sBAAA,CAAAC,mBAAA,KAAAC,SAAA,CAAAP,IAAA,CAbjBQ,IAAI,CAAJA,IAAI,CAAAD,SAAA,UAAG,EAAE,CAAAA,SAAA,CAAAE,iBAAA,CAAAT,IAAA,CACTU,YAAY,CAAZA,YAAY,CAAAD,iBAAA,UAAG,CAAC,CAAC,CAAAA,iBAAA,CAAAE,cAAA,CAAAX,IAAA,CACjBY,SAAS,CAATA,SAAS,CAAAD,cAAA,UAAG,EAAE,CAAAA,cAAA,CAAAE,YAAA,CAAAb,IAAA,CACdc,OAAO,CAAPA,OAAO,CAAAD,YAAA,UAAG,EAAE,CAAAA,YAAA,CAAAE,eAAA,CAAAf,IAAA,CACZgB,UAAU,CAAVA,UAAU,CAAAD,eAAA,UAAG,KAAK,CAAAA,eAAA,CAClBE,UAAU,CAAAjB,IAAA,CAAViB,UA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,CAAAS,QAAA,CAEnBX,UAAU,CAAC6G,eAAe,CAAC1D,GAAG,CAAC,SAAC2D,IAAY,qBAC3CnI,IAAA,WAAmB8H,KAAK,CAAEK,IAAK,CAAAnG,QAAA,CAC5BmG,IAAI,EADMA,IAEL,CAAC,CACV,CAAC,CACI,CAAC,EACN,CAAC,cACNjI,KAAA,QAAKc,SAAS,CAAC,uCAAuC,CAAAgB,QAAA,eACpD9B,KAAA,SAAMc,SAAS,CAAC,wDAAwD,CAAAgB,QAAA,EACrE,CAACY,UAAU,CAAG,CAAC,EAAII,QAAQ,CAAG,CAAC,CAAC,QACjC,CAACI,IAAI,CAACgF,GAAG,CAACxF,UAAU,CAAGI,QAAQ,CAAE3B,UAAU,CAACiC,UAAU,CAAC,CAAC,MAAI,CAACjC,UAAU,CAACiC,UAAU,EAC9E,CAAC,cACPtD,IAAA,CAACP,UAAU,EAAAuC,QAAA,cACThC,IAAA,CAACN,iBAAiB,EAACsB,SAAS,CAAC,uBAAuB,CAAAgB,QAAA,CACjDrC,sBAAsB,CAACiD,UAAU,CAAEW,UAAU,CAAEhC,SAAS,CAAEqD,gBAAgB,CAAC,CAC3D,CAAC,CACV,CAAC,EACV,CAAC,EACH,CACN,EACO,CAEd","ignoreList":[]}
1
+ {"version":3,"file":"data-table.js","names":["useEffect","useState","Fragment","Table","TableHeader","TableRow","TableHead","TableBody","TableCell","TableHeadSortable","TableLoader","ScrollArea","ScrollBar","Pagination","PaginationContent","renderPaginationArrows","TableButton","cn","renderNoDataFallback","jsx","_jsx","jsxs","_jsxs","DataTable","_ref","_ref2","_pagination$values$pa","_pagination$values","_ref3","_pagination$values$pa2","_pagination$values2","_ref$data","data","_ref$headerMapper","headerMapper","_ref$className","className","_ref$actions","actions","_ref$isEditable","isEditable","pagination","_ref$isLoading","isLoading","onRowAction","onPageChange","onSort","sortConfig","_ref$otherProps","otherProps","height","length","children","style","minHeight","_useState","activeSortColumn","setActiveSortColumn","_useState2","sortDirections","setSortDirections","_useState3","Number","values","pageNumber","initialPage","setPageNumber","_useState4","pageSize","initialPageSize","setPageSize","_useState5","Math","ceil","totalCount","totalPages","setTotalPages","_ref4","_pagination$values$pa3","_pagination$values3","_ref5","_pagination$values$pa4","_pagination$values4","first","Object","keys","sortColumn","sortDirection","originalKeys","filter","key","headers","map","push","rows","datum","handlePageChange","_x","_x2","_handlePageChange","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","newPage","newSize","wrap","_callee$","_context","prev","next","stop","handleSortClick","column","direction","_extends2","_extends","renderActions","rowIndex","rowActions","action","onClick","id","variant","text","tooltipContent","disabled","defaultClasses","mergedClasses","renderTableComponent","head","idx","isActionColumn","originalKey","contentEditable","isActive","sortable","row","rIdx","cell","cIdx","String","undefined","orientation","htmlFor","value","onChange","e","target","pageSizeOptions","size","min"],"sources":["../../../src/plugins/helpers/data-table.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { useEffect, useState, Fragment } from 'react';\nimport {\n Table,\n TableHeader,\n TableRow,\n TableHead,\n TableBody,\n TableCell,\n TableHeadSortable,\n SortDirection,\n} from '../../shadcn/components/ui/table';\nimport { TableLoader } from '../../shadcn/components/ui/skeleton';\nimport { ScrollArea, ScrollBar } from '../../shadcn/components/ui/scroll-area';\nimport {\n Pagination,\n PaginationContent,\n renderPaginationArrows,\n} from '../../shadcn/components/ui/pagination';\nimport { TableButton } from '../../shadcn/components/ui/button';\nimport { cn } from '../../shadcn/utils';\nimport { renderNoDataFallback } from './extra'\n\ntype RowAction = {\n id: string;\n text: string;\n variant?: string;\n tooltipContent?: string;\n className?: string;\n};\n\nexport type DataTableProps = {\n data: Record<string, any>[];\n headerMapper?: Record<string, string>;\n className?: string;\n isEditable?: boolean;\n actions?: RowAction[];\n pagination?: {\n values?: {\n pageNumber: number;\n pageSize: number;\n };\n initialPage?: number;\n initialPageSize?: number;\n totalCount: number;\n pageSizeOptions: number[];\n };\n isLoading?: boolean;\n onRowAction?: (rowIndex: number, actionId: string) => void;\n onPageChange?: (pageNumber: number, pageSize: number) => void;\n onSort?: (column: string, direction: SortDirection) => void;\n sortConfig?: Record<string, SortDirection>;\n otherProps?: Record<string, any>;\n height?: string | number;\n};\n\nexport function DataTable({\n data = [],\n headerMapper = {},\n className = '',\n actions = [],\n isEditable = false,\n pagination,\n isLoading = false,\n onRowAction,\n onPageChange,\n onSort,\n sortConfig,\n otherProps = {},\n height,\n}: DataTableProps) {\n\n if (!data || data.length === 0) {\n return (\n <Fragment>\n <div className=\"flex flex-col overflow-hidden\">\n <div\n data-slot=\"table-container\"\n className=\"aspect-auto w-full\"\n style={{ height: 'auto', minHeight: '180px' }}\n >\n {isLoading ? <TableLoader /> : renderNoDataFallback()}\n </div>\n </div>\n </Fragment>\n );\n }\n\n const [activeSortColumn, setActiveSortColumn] = useState<string | null>(null);\n const [sortDirections, setSortDirections] = useState<Record<string, SortDirection>>({});\n\n const [pageNumber, setPageNumber] = useState(\n Number(pagination?.values?.pageNumber ?? pagination?.initialPage ?? 1),\n );\n const [pageSize, setPageSize] = useState(\n Number(pagination?.values?.pageSize ?? pagination?.initialPageSize ?? 10),\n );\n const [totalPages, setTotalPages] = useState(\n Math.ceil((pagination?.totalCount || 0) / pageSize) || 1,\n );\n\n useEffect(() => {\n setPageNumber(Number(pagination?.values?.pageNumber ?? pagination?.initialPage ?? 1));\n setPageSize(Number(pagination?.values?.pageSize ?? pagination?.initialPageSize ?? 25));\n }, [pagination]);\n\n useEffect(() => {\n setTotalPages(Math.ceil((pagination?.totalCount || 0) / pageSize) || 1);\n }, [pagination?.totalCount, pageSize]);\n\n useEffect(() => {\n if (sortConfig) {\n setSortDirections(sortConfig);\n const first = Object.keys(sortConfig)[0];\n\n if (first) {\n setActiveSortColumn(first);\n }\n }\n }, [sortConfig]);\n\n useEffect(() => {\n if (sortConfig?.sortColumn || sortConfig?.sortDirection) {\n sortConfig.sortColumn = null;\n sortConfig.sortDirection = null;\n }\n \n setActiveSortColumn(null);\n setSortDirections({});\n }, []);\n \n const originalKeys = Object.keys(data[0] || {}).filter((key) => key in headerMapper);\n const headers = originalKeys.map((key) => headerMapper[key]);\n\n if (actions.length > 0) {\n headers.push('');\n }\n\n const rows = data.map((datum: any) => originalKeys.map((key) => datum[key]));\n\n async function handlePageChange(newPage = pageNumber, newSize = pageSize) {\n setPageNumber(newPage);\n setPageSize(newSize);\n onPageChange?.(newPage, newSize);\n }\n\n function handleSortClick(column: string, direction: SortDirection) {\n setActiveSortColumn(direction ? column : null);\n setSortDirections((prev) => ({\n ...prev,\n [column]: direction,\n }));\n onSort?.(column, direction);\n }\n\n function renderActions(rowIndex: number, rowActions: RowAction[]) {\n if (!actions.length) {\n return null;\n }\n\n return (\n <TableCell className=\"sticky right-0 bg-white\">\n {rowActions.map((action) => (\n <TableButton\n key={action.id}\n className={action.className}\n isEditable={isEditable}\n onClick={() => onRowAction?.(rowIndex, action.id)}\n variant={action.variant}\n text={action.text}\n tooltipContent={action.tooltipContent}\n disabled={isLoading}\n />\n ))}\n </TableCell>\n );\n }\n\n const defaultClasses = `aspect-auto w-full`;\n const mergedClasses = className ? cn(defaultClasses, className) : defaultClasses;\n\n function renderTableComponent() {\n if (isLoading || (!data || data.length === 0)) {\n return <TableLoader />;\n }\n\n return (\n <Table\n {...otherProps}\n className={`caption-bottom text-sm relative ${mergedClasses}`}\n data-slot=\"table\"\n >\n <TableHeader data-slot=\"table-header\" className=\"sticky top-0 z-2\">\n <TableRow>\n {headers.map((head: string, idx: number) => {\n const isActionColumn = actions.length > 0 && idx === headers.length - 1;\n const originalKey = originalKeys[idx];\n\n if (isActionColumn) {\n return (\n <TableHead\n key={idx}\n data-slot={`table-header-${idx}`}\n contentEditable={isEditable}\n className=\"sticky right-0 bg-slate-100\"\n >\n {head}\n </TableHead>\n );\n }\n\n return (\n <TableHeadSortable\n key={idx}\n data-slot={`table-header-${idx}`}\n sortDirection={sortDirections[originalKey] || 'asc'}\n isActive={activeSortColumn === originalKey}\n onSort={(direction) => handleSortClick(originalKey, direction)}\n sortable={!isLoading}\n isEditable={isEditable}\n >\n {head}\n </TableHeadSortable>\n );\n })}\n </TableRow>\n </TableHeader>\n <TableBody data-slot=\"table-body\">\n {rows.map((row: any[], rIdx: number) => (\n <TableRow\n key={rIdx}\n data-slot={`row-${rIdx}`}\n className=\"hover:bg-muted/50 border-b transition-colors\"\n >\n {row.map((cell: string, cIdx: number) => (\n <TableCell\n key={cIdx}\n data-slot={`cell-${rIdx}-${cIdx}`}\n className=\"p-2 align-middle whitespace-nowrap\"\n contentEditable={false}\n >\n {cell === null ? '-' : String(cell)}\n </TableCell>\n ))}\n {renderActions(rIdx, actions)}\n </TableRow>\n ))}\n </TableBody>\n </Table>\n );\n }\n\n return (\n <Fragment>\n <div className=\"flex flex-col h-full overflow-hidden\">\n <ScrollArea\n data-slot=\"table-container\"\n className={mergedClasses}\n {...(height !== undefined && { style: { height } })}\n >\n {renderTableComponent()}\n <ScrollBar orientation=\"horizontal\" />\n </ScrollArea>\n </div>\n {pagination && pagination.totalCount > 0 && (\n <div className=\"flex-shrink-0 flex items-center justify-between mt-2 w-full overflow-x-auto border-t pt-2\">\n <div className=\"flex items-center gap-2 flex-shrink-0\">\n <label htmlFor=\"page-size-select\" className=\"text-sm whitespace-nowrap\">\n Rows per page:\n </label>\n <select\n id=\"page-size-select\"\n value={pageSize}\n onChange={(e) => handlePageChange(1, Number(e.target.value))}\n className=\"border rounded px-2 py-1 text-sm cursor-pointer\"\n disabled={isLoading}\n >\n {pagination.pageSizeOptions.map((size: number) => (\n <option key={size} value={size}>\n {size}\n </option>\n ))}\n </select>\n </div>\n <div className=\"flex items-center gap-1 flex-shrink-0\">\n <span className=\"text-xs text-muted-foreground whitespace-nowrap ml-1.5\">\n {(pageNumber - 1) * pageSize + 1}–\n {Math.min(pageNumber * pageSize, pagination.totalCount)} of {pagination.totalCount}\n </span>\n <Pagination>\n <PaginationContent className=\"gap-0.2 flex-shrink-0\">\n {renderPaginationArrows(pageNumber, totalPages, isLoading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