@peak-ai/canvas 1.4.35-rc.2 → 1.4.35-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/GrapesjsCanvas.js +4 -4
- package/GrapesjsCanvas.js.map +1 -1
- package/package.json +1 -1
- package/plugins/grapejs-plugin.js +1 -1
- package/plugins/grapejs-plugin.js.map +1 -1
- package/plugins/helpers/query-details-modal.js +1 -1
- package/plugins/helpers/query-details-modal.js.map +1 -1
- package/plugins/helpers/render-components.js +8 -7
- package/plugins/helpers/render-components.js.map +1 -1
- package/plugins/helpers/styled-info-button.js +4 -4
- package/plugins/helpers/styled-info-button.js.map +1 -1
- package/types/grapesjs-tailwind.d.js.map +1 -1
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
|
-
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});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
|
|
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
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
|
|
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$
|
|
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
|
|
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)],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;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;
|
|
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;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;
|
|
11
11
|
//# sourceMappingURL=GrapesjsCanvas.js.map
|
package/GrapesjsCanvas.js.map
CHANGED
|
@@ -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","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","_extends","classes","concat","undefined","i","id","setInteracting","renderedComponents","inProgress","component","componentId","showLoader","gjsModel","get","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$curre","updatedJson","apiResponse","componentUpdates","wrap","_callee4$","_context4","prev","next","store","sent","affectedComponents","_ref6","error","isMissing","abrupt","t0","errorMessage","Error","message","finish","stop","_json$pages","_json$pages$0$frames","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","_callee3","stored","newJson","_callee3$","_context3","JSON","stringify","debouncedCheckDirty","timeout","clearTimeout","setTimeout","evt","on","includes","_callee","canvasDoc","canvasHead","_callee$","_context","t1","call","_ref4","DomComponents","getType","addType","defaults","view","pages","frames","raw","processed","setComponents","cssText","styles","setStyle","_callee2","_callee2$","_context2","cleanup","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 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 setComponentProperties(editor, mode === 'preview');\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 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 editor.setComponents(processed);\n\n const cssText = convertStyles(json.styles || []);\n editor.setStyle(cssText);\n\n editor.on('load', async () => {\n lastJsonRef.current = JSON.stringify(await editor.store());\n isSystemUpdateRef.current = false;\n });\n }\n\n return function cleanup() {\n editor.destroy();\n isEditorAliveRef.current = false;\n };\n }, [json, 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,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AE,SAAAyF,SAAA,SAAA1F,mBAAA,CAAAQ,IAAA,UAAAmF,UAAAC,SAAA,iBAAAA,SAAA,CAAAjF,IAAA,CAAAiF,SAAA,CAAAhF,IAAA,SAAAgF,SAAA,CAAAxE,EAAA,CACMwC,IAAI,CAAAgC,SAAA,CAAAhF,IAAA,SAAiB,CAAAhI,MAAM,CAACiI,KAAK,CAAC,CAAC,QAAA+E,SAAA,CAAAlB,EAAA,CAAAkB,SAAA,CAAA9E,IAAA,CAAzDxC,WAAW,CAACE,OAAO,CAAAoH,SAAA,CAAAxE,EAAA,CAAQyC,SAAS,CAAAc,IAAA,CAAAiB,SAAA,CAAAxE,EAAA,CAAAwE,SAAA,CAAAlB,EAAA,EACpCrG,iBAAiB,CAACG,OAAO,CAAG,KAAK,CAAC,wBAAAoH,SAAA,CAAAnE,IAAA,KAAAiE,QAAA,EACnC,GACH,CAEA,MAAO,SAAS,CAAAG,OAAOA,CAAA,CAAG,CACxBjN,MAAM,CAACgJ,OAAO,CAAC,CAAC,CAChBrD,gBAAgB,CAACC,OAAO,CAAG,KAC7B,CACF,CAAC,CAAE,CAAChB,IAAI,CAAEE,IAAI,CAAC,CAAC,CAEhB,mBACEhF,KAAA,CAACd,KAAK,CAACkO,QAAQ,EAAAC,QAAA,eACbvN,IAAA,CAACF,YAAY,GAAE,CAAC,cAChBE,IAAA,QAAKwN,GAAG,CAAE9H,SAAU,CAAC1B,EAAE,CAAC,iBAAiB,CAAE,CAAC,EAC9B,CAEpB,CAEA,cAAe,CAAAc,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","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","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"],"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,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CAAAc,IAAA,CAAAsB,SAAA,CAAA3E,EAAA,CAAA2E,SAAA,CAAAvB,EAAA,EACpCnG,iBAAiB,CAACG,OAAO,CAAG,KAAK,CAAC,wBAAAuH,SAAA,CAAAtE,IAAA,KAAAoE,QAAA,EAErC,GAAE,GAAG,CACR,CACF,CAAC,CAAE,CAACrI,IAAI,CAAC,CAAC,CAEV5F,SAAS,CAAC,UAAM,CACd,GAAI8F,IAAI,EAAIS,cAAc,CAACK,OAAO,CAAE,CAClCH,iBAAiB,CAACG,OAAO,CAAG,IAAI,CAEhCuF,UAAU,CAAC,UAAM,CACfrL,sBAAsB,CAACyF,cAAc,CAACK,OAAO,CAAYd,IAAI,GAAK,SAAS,CAAC,CAE5EqG,UAAU,CAAC,UAAM,CACf1F,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,CAACqO,QAAQ,EAAAC,QAAA,eACb1N,IAAA,CAACF,YAAY,GAAE,CAAC,cAChBE,IAAA,QAAK2N,GAAG,CAAEhI,SAAU,CAACzB,EAAE,CAAC,iBAAiB,CAAE,CAAC,EAC9B,CAEpB,CAEA,cAAe,CAAAa,cAAc","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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.
|
|
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
|
|
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","isEditable","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.isEditable = mode === 'editor';\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,MA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,CAAG,IAAI,CAACE,EAAE,CAAClE,GAAG,CAAC,eAAe,CAAC,CAACmE,OAAO,CAACpF,KAAK,CAACiB,GAAG,CAAC,MAAM,CAAC,CAAC,eAAvDgE,oBAAA,CAAyD1E,IAAI,CAEnF,GAAI,CAAC2E,aAAa,CAAE,CAClB;AACA3C,OAAO,CAAC8C,IAAI,CAAC,mCAAmC,CAAErF,KAAK,CAACiB,GAAG,CAAC,MAAM,CAAC,CAAC,CAEpE,MAAO,KACT,CAEA,GAAM,CAAAV,IAAI,CAAG,GAAI,CAAA2E,aAAa,CAAC,CAC7BlF,KAAK,CAALA,KAAK,CACLsF,MAAM,CAAE,IAAI,CAACA,MAAM,CACnBC,cAAc,CAAE,IAAI,CAACA,cACvB,CAAC,CAAC,CAEF,MAAO,CAAAhF,IACT,CAAC,CACDiF,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
|
+
{"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,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,CAAC0E,aAAa,CAAE,CAClB;AACA1C,OAAO,CAAC6C,IAAI,CAAC,mCAAmC,CAAEpF,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;AACArG,QAAQ,CAACsG,sBAAsB,CAAC,IAAI,CAACxC,EAAE,CAAC,CAExC,MAAO,KACT,CACF,CACF,CAAC,CACH,CACF","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import _extends from"@babel/runtime/helpers/extends";import _asyncToGenerator from"@babel/runtime/helpers/asyncToGenerator";import _regeneratorRuntime from"@babel/runtime/regenerator";import React,{useState,useEffect}from"react";import{CustomModal}from"./custom-modal";import{Copy,Check,ChevronDown,ChevronUp}from"lucide-react";import{formatQueryHeading}from"./query-heading-formatter";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";function CopyButton(_ref){var onClick=_ref.onClick,isCopied=_ref.isCopied,_ref$variant=_ref.variant,variant=_ref$variant===void 0?"default":_ref$variant;var baseClasses="flex items-center gap-1 px-2 py-1 text-xs border rounded transition-colors";var variantClasses=variant==="light"?"bg-gray-50 border-gray-300 hover:bg-gray-100":"bg-gray-100 border-gray-300 hover:bg-gray-200";return/*#__PURE__*/_jsx("button",{onClick:onClick,className:baseClasses+" "+variantClasses,type:"button",children:isCopied?/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(Check,{className:"w-3 h-3 text-green-600"}),/*#__PURE__*/_jsx("span",{className:"text-green-600",children:"Copied!"})]}):/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(Copy,{className:"w-3 h-3 text-gray-600"}),/*#__PURE__*/_jsx("span",{className:"text-gray-600",children:"Copy"})]})})}function ContentText(_ref2){var children=_ref2.children,_ref2$hasOverflowHand=_ref2.hasOverflowHandling,hasOverflowHandling=_ref2$hasOverflowHand===void 0?true:_ref2$hasOverflowHand;var overflowClasses=hasOverflowHandling?"overflow-hidden break-words":"";return/*#__PURE__*/_jsx("pre",{className:"whitespace-pre-wrap leading-relaxed text-xs text-gray-700 m-0 p-0 "+overflowClasses,children:children})}function ContentBlock(_ref3){var title=_ref3.title,children=_ref3.children,copyContent=_ref3.copyContent,copyId=_ref3.copyId,copied=_ref3.copied,onCopy=_ref3.onCopy,_ref3$variant=_ref3.variant,variant=_ref3$variant===void 0?"bordered":_ref3$variant,_ref3$copyButtonVaria=_ref3.copyButtonVariant,copyButtonVariant=_ref3$copyButtonVaria===void 0?"default":_ref3$copyButtonVaria;var containerClasses=variant==="bordered"?"rounded-lg p-3":"bg-white border border-gray-200 rounded-lg p-4";var containerStyle=variant==="bordered"?{border:"1px solid #E9EAF5"}:{};var titleClasses=variant==="bordered"?"text-sm font-medium text-gray-600":"font-semibold text-sm text-gray-500 m-0";return/*#__PURE__*/_jsxs("div",{className:containerClasses,style:containerStyle,children:[/*#__PURE__*/_jsxs("div",{className:"flex justify-between items-start mb-2",children:[/*#__PURE__*/_jsx("span",{className:titleClasses,children:title}),copyContent&&/*#__PURE__*/_jsx(CopyButton,{onClick:function onClick(){return onCopy(copyContent,copyId)},isCopied:copied[copyId]||false,variant:copyButtonVariant})]}),children]})}export function QueryDetailsModal(_ref4){var isOpen=_ref4.isOpen,onClose=_ref4.onClose,isLoading=_ref4.isLoading,error=_ref4.error,sqlQuery=_ref4.sqlQuery,_ref4$queryHeadings=_ref4.queryHeadings,queryHeadings=_ref4$queryHeadings===void 0?[]:_ref4$queryHeadings,_ref4$tableButtonExpl=_ref4.tableButtonExplanations,tableButtonExplanations=_ref4$tableButtonExpl===void 0?[]:_ref4$tableButtonExpl,onRetry=_ref4.onRetry;var _useState=useState({}),copied=_useState[0],setCopied=_useState[1];var _useState2=useState({}),expandedButtons=_useState2[0],setExpandedButtons=_useState2[1];// Reset expanded state when modal closes
|
|
2
2
|
useEffect(function(){if(!isOpen){setExpandedButtons({})}},[isOpen]);function copyToClipboard(_x,_x2){return _copyToClipboard.apply(this,arguments)}function _copyToClipboard(){_copyToClipboard=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(queryToCopy,copyId){var textToCopy,id;return _regeneratorRuntime.wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:textToCopy=queryToCopy;if(!textToCopy){if(Array.isArray(sqlQuery)){textToCopy=sqlQuery.filter(function(q){return q&&typeof q==="string"}).join("\n\n-- Next Query --\n\n")}else if(typeof sqlQuery==="string"){textToCopy=sqlQuery}else{textToCopy=""}}if(textToCopy){_context.next=4;break}return _context.abrupt("return");case 4:id=copyId||"main";_context.prev=5;_context.next=8;return navigator.clipboard.writeText(textToCopy);case 8:setCopied(function(prev){var _extends3;return _extends({},prev,(_extends3={},_extends3[id]=true,_extends3))});setTimeout(function(){return setCopied(function(prev){var _extends4;return _extends({},prev,(_extends4={},_extends4[id]=false,_extends4))})},2000);_context.next=14;break;case 12:_context.prev=12;_context.t0=_context["catch"](5);case 14:case"end":return _context.stop()}},_callee,null,[[5,12]])}));return _copyToClipboard.apply(this,arguments)}function toggleButtonExpansion(buttonIndex){setExpandedButtons(function(prev){var _extends2;return _extends({},prev,(_extends2={},_extends2[buttonIndex]=!prev[buttonIndex],_extends2))})}function renderTableButtonExplanations(){if(!tableButtonExplanations||tableButtonExplanations.length===0){return null}function hasValidJsonBody(jsonBody){return jsonBody!==null&&jsonBody!==undefined&&jsonBody!==""}function hasValidFormFields(formFields){return formFields!==null&&formFields!==undefined&&Object.keys(formFields||{}).length>0}return/*#__PURE__*/_jsx("div",{className:"mb-6",children:tableButtonExplanations.map(function(button,index){var _button$buttonStyle,_button$buttonStyle2,_button$buttonStyle3;return/*#__PURE__*/_jsxs("div",{className:"mb-3 border border-gray-200 rounded-lg",children:[/*#__PURE__*/_jsxs("div",{className:"w-full px-4 py-3 flex items-center justify-between rounded-lg",children:[/*#__PURE__*/_jsxs("div",{className:"flex items-center",children:[/*#__PURE__*/_jsx("button",{onClick:function onClick(){return toggleButtonExpansion(index)},className:button.buttonClassName||"flex items-center justify-center px-3 rounded text-xs font-medium",style:_extends({height:"35px",width:"fit-content",minWidth:"fit-content",backgroundColor:(_button$buttonStyle=button.buttonStyle)==null?void 0:_button$buttonStyle.backgroundColor,color:(_button$buttonStyle2=button.buttonStyle)==null?void 0:_button$buttonStyle2.color,border:(_button$buttonStyle3=button.buttonStyle)==null?void 0:_button$buttonStyle3.border},button.buttonStyle||{},button.buttonStyle||{},{display:"flex",alignItems:"center",justifyContent:"center"}),children:button.action}),/*#__PURE__*/_jsx("div",{className:"ml-3 flex flex-col",children:button.operationSummary&&/*#__PURE__*/_jsx("span",{className:"text-xs text-gray-700 font-medium",children:button.operationSummary})})]}),expandedButtons[index]?/*#__PURE__*/_jsx(ChevronUp,{className:"w-4 h-4 text-gray-500 transition-transform cursor-pointer",onClick:function onClick(){return toggleButtonExpansion(index)}}):/*#__PURE__*/_jsx(ChevronDown,{className:"w-4 h-4 text-gray-500 transition-transform cursor-pointer",onClick:function onClick(){return toggleButtonExpansion(index)}})]}),expandedButtons[index]&&/*#__PURE__*/_jsx("div",{className:"px-4 pb-3 border-t border-gray-200",children:/*#__PURE__*/_jsxs("div",{className:"mt-2 space-y-3",children:[button.operationDescription&&/*#__PURE__*/_jsx(ContentBlock,{title:"Description",copyId:"description-"+index,copied:copied,onCopy:copyToClipboard,variant:"bordered",children:/*#__PURE__*/_jsx(ContentText,{children:button.operationDescription})}),(button.requestUrl||button.explanation)&&/*#__PURE__*/_jsx(ContentBlock,{title:"URL",copyContent:button.requestUrl||button.explanation,copyId:"url-"+index,copied:copied,onCopy:copyToClipboard,variant:"bordered",children:/*#__PURE__*/_jsx(ContentText,{children:button.requestUrl||button.explanation})}),(hasValidJsonBody(button.jsonBody)||hasValidFormFields(button.formFields))&&/*#__PURE__*/_jsx(ContentBlock,{title:"Payload",copyContent:JSON.stringify(hasValidJsonBody(button.jsonBody)?button.jsonBody:button.formFields,null,2),copyId:"payload-"+index,copied:copied,onCopy:copyToClipboard,variant:"bordered",children:/*#__PURE__*/_jsx(ContentText,{children:hasValidJsonBody(button.jsonBody)?JSON.stringify(button.jsonBody,null,2):JSON.stringify(button.formFields,null,2)})})]})})]},index)})})}function renderModalContent(){if(isLoading){return/*#__PURE__*/_jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[/*#__PURE__*/_jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-purple-600 mb-4"}),/*#__PURE__*/_jsx("span",{className:"text-xs text-gray-600",children:"Fetching query details from semantic layer..."}),/*#__PURE__*/_jsx("span",{className:"text-xs text-gray-400 mt-2",children:"This may take a few moments"})]})}if(error){return/*#__PURE__*/_jsxs("div",{className:"text-red-600 p-4 bg-red-50 rounded-lg border border-red-200 m-6",children:[/*#__PURE__*/_jsx("p",{className:"font-medium mb-2 text-xs",children:"Unable to fetch query details"}),/*#__PURE__*/_jsx("p",{className:"text-xs mb-3",children:error}),/*#__PURE__*/_jsx("button",{onClick:onRetry,className:"px-4 py-2 bg-red-100 hover:bg-red-200 rounded text-xs font-medium transition-colors",type:"button",children:"Retry"})]})}if(!sqlQuery||Array.isArray(sqlQuery)&&sqlQuery.length===0){return/*#__PURE__*/_jsx("div",{className:"text-gray-600 p-6",children:/*#__PURE__*/_jsx("p",{className:"text-xs",children:"No query details available"})})}// Handle multiple queries
|
|
3
|
-
if(Array.isArray(sqlQuery)){return/*#__PURE__*/_jsxs("div",{className:"p-6 space-y-4",children:[sqlQuery.filter(function(query){return query&&typeof query==="string"&&query.trim()}).map(function(query,index){var rawHeading=queryHeadings[index]||"Query "+(index+1);var heading=formatQueryHeading(rawHeading);return/*#__PURE__*/_jsx(ContentBlock,{title:heading,copyContent:query,copyId:"query-"+index,copied:copied,onCopy:copyToClipboard,variant:"default",copyButtonVariant:"light",children:/*#__PURE__*/_jsx(ContentText,{hasOverflowHandling:false,children:query})},index)}),renderTableButtonExplanations()]})}return/*#__PURE__*/_jsxs("div",{className:"p-6 space-y-4",children:[/*#__PURE__*/_jsx(ContentBlock,{title:formatQueryHeading(queryHeadings[0]||"Query details"),copyContent:typeof sqlQuery==="string"?sqlQuery:"",copyId:"single",copied:copied,onCopy:copyToClipboard,variant:"default",copyButtonVariant:"light",children:/*#__PURE__*/_jsx(ContentText,{hasOverflowHandling:false,children:sqlQuery})}),renderTableButtonExplanations()]})}return/*#__PURE__*/_jsx(CustomModal,{isOpen:isOpen,onClose:onClose,title:"
|
|
3
|
+
if(Array.isArray(sqlQuery)){return/*#__PURE__*/_jsxs("div",{className:"p-6 space-y-4",children:[sqlQuery.filter(function(query){return query&&typeof query==="string"&&query.trim()}).map(function(query,index){var rawHeading=queryHeadings[index]||"Query "+(index+1);var heading=formatQueryHeading(rawHeading);return/*#__PURE__*/_jsx(ContentBlock,{title:heading,copyContent:query,copyId:"query-"+index,copied:copied,onCopy:copyToClipboard,variant:"default",copyButtonVariant:"light",children:/*#__PURE__*/_jsx(ContentText,{hasOverflowHandling:false,children:query})},index)}),renderTableButtonExplanations()]})}return/*#__PURE__*/_jsxs("div",{className:"p-6 space-y-4",children:[/*#__PURE__*/_jsx(ContentBlock,{title:formatQueryHeading(queryHeadings[0]||"Query details"),copyContent:typeof sqlQuery==="string"?sqlQuery:"",copyId:"single",copied:copied,onCopy:copyToClipboard,variant:"default",copyButtonVariant:"light",children:/*#__PURE__*/_jsx(ContentText,{hasOverflowHandling:false,children:sqlQuery})}),renderTableButtonExplanations()]})}return/*#__PURE__*/_jsx(CustomModal,{isOpen:isOpen,onClose:onClose,title:"How was this metric calculated?",children:renderModalContent()})}export default QueryDetailsModal;
|
|
4
4
|
//# sourceMappingURL=query-details-modal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-details-modal.js","names":["React","useState","useEffect","CustomModal","Copy","Check","ChevronDown","ChevronUp","formatQueryHeading","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","CopyButton","_ref","onClick","isCopied","_ref$variant","variant","baseClasses","variantClasses","className","type","children","ContentText","_ref2","_ref2$hasOverflowHand","hasOverflowHandling","overflowClasses","ContentBlock","_ref3","title","copyContent","copyId","copied","onCopy","_ref3$variant","_ref3$copyButtonVaria","copyButtonVariant","containerClasses","containerStyle","border","titleClasses","style","QueryDetailsModal","_ref4","isOpen","onClose","isLoading","error","sqlQuery","_ref4$queryHeadings","queryHeadings","_ref4$tableButtonExpl","tableButtonExplanations","onRetry","_useState","setCopied","_useState2","expandedButtons","setExpandedButtons","copyToClipboard","_x","_x2","_copyToClipboard","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","queryToCopy","textToCopy","id","wrap","_callee$","_context","prev","next","Array","isArray","filter","q","join","abrupt","navigator","clipboard","writeText","_extends3","_extends","setTimeout","_extends4","t0","stop","toggleButtonExpansion","buttonIndex","_extends2","renderTableButtonExplanations","length","hasValidJsonBody","jsonBody","undefined","hasValidFormFields","formFields","Object","keys","map","button","index","_button$buttonStyle","_button$buttonStyle2","_button$buttonStyle3","buttonClassName","height","width","minWidth","backgroundColor","buttonStyle","color","display","alignItems","justifyContent","action","operationSummary","operationDescription","requestUrl","explanation","JSON","stringify","renderModalContent","query","trim","rawHeading","heading"],"sources":["../../../src/plugins/helpers/query-details-modal.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { CustomModal } from './custom-modal';\nimport { Copy, Check, ChevronDown, ChevronUp, X } from 'lucide-react';\nimport { formatQueryHeading } from './query-heading-formatter';\n\ntype CopyButtonProps = {\n onClick: () => void;\n isCopied: boolean;\n variant?: 'default' | 'light';\n};\n\nfunction CopyButton({ onClick, isCopied, variant = 'default' }: CopyButtonProps) {\n const baseClasses = \"flex items-center gap-1 px-2 py-1 text-xs border rounded transition-colors\";\n const variantClasses = variant === 'light' \n ? \"bg-gray-50 border-gray-300 hover:bg-gray-100\"\n : \"bg-gray-100 border-gray-300 hover:bg-gray-200\";\n\n return (\n <button\n onClick={onClick}\n className={`${baseClasses} ${variantClasses}`}\n type=\"button\"\n >\n {isCopied ? (\n <>\n <Check className=\"w-3 h-3 text-green-600\" />\n <span className=\"text-green-600\">Copied!</span>\n </>\n ) : (\n <>\n <Copy className=\"w-3 h-3 text-gray-600\" />\n <span className=\"text-gray-600\">Copy</span>\n </>\n )}\n </button>\n );\n}\n\ntype ContentTextProps = {\n children: React.ReactNode;\n hasOverflowHandling?: boolean;\n};\n\nfunction ContentText({ children, hasOverflowHandling = true }: ContentTextProps) {\n const overflowClasses = hasOverflowHandling ? \"overflow-hidden break-words\" : \"\";\n\n return (\n <pre className={`whitespace-pre-wrap leading-relaxed text-xs text-gray-700 m-0 p-0 ${overflowClasses}`}>\n {children}\n </pre>\n );\n}\n\ntype ContentBlockProps = {\n title: string;\n children: React.ReactNode;\n copyContent?: string;\n copyId: string;\n copied: Record<string, boolean>;\n onCopy: (content: string, id: string) => void;\n variant?: 'default' | 'bordered';\n copyButtonVariant?: 'default' | 'light';\n};\n\nfunction ContentBlock({ \n title, \n children, \n copyContent, \n copyId, \n copied, \n onCopy,\n variant = 'bordered',\n copyButtonVariant = 'default'\n}: ContentBlockProps) {\n const containerClasses = variant === 'bordered' \n ? \"rounded-lg p-3\"\n : \"bg-white border border-gray-200 rounded-lg p-4\";\n \n const containerStyle = variant === 'bordered' \n ? { border: '1px solid #E9EAF5' }\n : {};\n\n const titleClasses = variant === 'bordered'\n ? \"text-sm font-medium text-gray-600\"\n : \"font-semibold text-sm text-gray-500 m-0\";\n\n return (\n <div className={containerClasses} style={containerStyle}>\n <div className=\"flex justify-between items-start mb-2\">\n <span className={titleClasses}>{title}</span>\n {copyContent && (\n <CopyButton\n onClick={() => onCopy(copyContent, copyId)}\n isCopied={copied[copyId] || false}\n variant={copyButtonVariant}\n />\n )}\n </div>\n {children}\n </div>\n );\n}\n\ntype QueryDetailsModalProps = {\n isOpen: boolean;\n onClose: () => void;\n isLoading: boolean;\n error: string;\n sqlQuery: string | string[];\n queryHeadings?: string[];\n tableButtonExplanations?: Array<{\n action: string, \n explanation: string, \n operationSummary?: string,\n operationDescription?: string,\n buttonClassName?: string, \n buttonStyle?: Record<string, unknown>,\n formFields?: Record<string, unknown>;\n jsonBody?: unknown;\n requestUrl?: string;\n }>;\n onRetry: () => void;\n};\n\nexport function QueryDetailsModal({\n isOpen,\n onClose,\n isLoading,\n error,\n sqlQuery,\n queryHeadings = [],\n tableButtonExplanations = [],\n onRetry\n}: QueryDetailsModalProps) {\n const [copied, setCopied] = useState<{ [key: string]: boolean }>({});\n const [expandedButtons, setExpandedButtons] = useState<{ [key: string]: boolean }>({});\n\n // Reset expanded state when modal closes\n useEffect(() => {\n if (!isOpen) {\n setExpandedButtons({});\n }\n }, [isOpen]);\n\n async function copyToClipboard(queryToCopy?: string, copyId?: string) {\n let textToCopy = queryToCopy;\n \n if (!textToCopy) {\n if (Array.isArray(sqlQuery)) {\n textToCopy = sqlQuery.filter(q => q && typeof q === 'string').join('\\n\\n-- Next Query --\\n\\n');\n } else if (typeof sqlQuery === 'string') {\n textToCopy = sqlQuery;\n } else {\n textToCopy = '';\n }\n }\n \n if (!textToCopy) {\n return;\n }\n \n const id = copyId || 'main';\n \n try {\n await navigator.clipboard.writeText(textToCopy);\n setCopied(prev => ({ ...prev, [id]: true }));\n setTimeout(() => setCopied(prev => ({ ...prev, [id]: false })), 2000);\n } catch (err) {\n // Silently fail if clipboard API is not available\n }\n }\n\n function toggleButtonExpansion(buttonIndex: number) {\n setExpandedButtons(prev => ({\n ...prev,\n [buttonIndex]: !prev[buttonIndex]\n }));\n }\n\n function renderTableButtonExplanations() {\n if (!tableButtonExplanations || tableButtonExplanations.length === 0) {\n return null;\n }\n\n function hasValidJsonBody(jsonBody: unknown): boolean {\n return jsonBody !== null && jsonBody !== undefined && jsonBody !== '';\n }\n\n function hasValidFormFields(formFields: Record<string, unknown> | undefined): boolean {\n return formFields !== null && formFields !== undefined && Object.keys(formFields || {}).length > 0;\n }\n\n return (\n <div className=\"mb-6\">\n {tableButtonExplanations.map((button, index) => (\n <div key={index} className=\"mb-3 border border-gray-200 rounded-lg\">\n <div className=\"w-full px-4 py-3 flex items-center justify-between rounded-lg\">\n <div className=\"flex items-center\">\n <button\n onClick={() => toggleButtonExpansion(index)}\n className={button.buttonClassName || \"flex items-center justify-center px-3 rounded text-xs font-medium\"}\n style={{\n height: '35px',\n width: 'fit-content',\n minWidth: 'fit-content',\n backgroundColor: (button.buttonStyle?.backgroundColor as string),\n color: (button.buttonStyle?.color as string),\n border: (button.buttonStyle?.border as string),\n ...(button.buttonStyle as React.CSSProperties || {})\n , ...button.buttonStyle as React.CSSProperties || {},\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center'\n }}\n >\n {button.action}\n </button>\n <div className=\"ml-3 flex flex-col\">\n {button.operationSummary && (\n <span className=\"text-xs text-gray-700 font-medium\">\n {button.operationSummary}\n </span>\n )}\n </div>\n </div>\n {expandedButtons[index] ? (\n <ChevronUp \n className=\"w-4 h-4 text-gray-500 transition-transform cursor-pointer\"\n onClick={() => toggleButtonExpansion(index)}\n />\n ) : (\n <ChevronDown \n className=\"w-4 h-4 text-gray-500 transition-transform cursor-pointer\"\n onClick={() => toggleButtonExpansion(index)}\n />\n )}\n </div>\n \n {expandedButtons[index] && (\n <div className=\"px-4 pb-3 border-t border-gray-200\">\n <div className=\"mt-2 space-y-3\">\n {/* Description Block */}\n {button.operationDescription && (\n <ContentBlock\n title=\"Description\"\n copyId={`description-${index}`}\n copied={copied}\n onCopy={copyToClipboard}\n variant=\"bordered\"\n >\n <ContentText>\n {button.operationDescription}\n </ContentText>\n </ContentBlock>\n )}\n\n {(button.requestUrl || button.explanation) && (\n <ContentBlock\n title=\"URL\"\n copyContent={button.requestUrl || button.explanation}\n copyId={`url-${index}`}\n copied={copied}\n onCopy={copyToClipboard}\n variant=\"bordered\"\n >\n <ContentText>\n {button.requestUrl || button.explanation}\n </ContentText>\n </ContentBlock>\n )}\n \n {(hasValidJsonBody(button.jsonBody) || hasValidFormFields(button.formFields)) && (\n <ContentBlock\n title=\"Payload\"\n copyContent={JSON.stringify(\n hasValidJsonBody(button.jsonBody) ? button.jsonBody : button.formFields, \n null, \n 2\n )}\n copyId={`payload-${index}`}\n copied={copied}\n onCopy={copyToClipboard}\n variant=\"bordered\"\n >\n <ContentText>\n {hasValidJsonBody(button.jsonBody) \n ? JSON.stringify(button.jsonBody, null, 2)\n : JSON.stringify(button.formFields, null, 2)}\n </ContentText>\n </ContentBlock>\n )}\n </div>\n </div>\n )}\n </div>\n ))}\n </div>\n );\n }\n\n function renderModalContent() {\n if (isLoading) {\n return (\n <div className=\"flex flex-col items-center justify-center py-12\">\n <div className=\"animate-spin rounded-full h-12 w-12 border-b-2 border-purple-600 mb-4\"></div>\n <span className=\"text-xs text-gray-600\">Fetching query details from semantic layer...</span>\n <span className=\"text-xs text-gray-400 mt-2\">This may take a few moments</span>\n </div>\n );\n }\n\n if (error) {\n return (\n <div className=\"text-red-600 p-4 bg-red-50 rounded-lg border border-red-200 m-6\">\n <p className=\"font-medium mb-2 text-xs\">Unable to fetch query details</p>\n <p className=\"text-xs mb-3\">{error}</p>\n <button \n onClick={onRetry}\n className=\"px-4 py-2 bg-red-100 hover:bg-red-200 rounded text-xs font-medium transition-colors\"\n type=\"button\"\n >\n Retry\n </button>\n </div>\n );\n }\n\n if (!sqlQuery || (Array.isArray(sqlQuery) && sqlQuery.length === 0)) {\n return (\n <div className=\"text-gray-600 p-6\">\n <p className=\"text-xs\">No query details available</p>\n </div>\n );\n }\n\n // Handle multiple queries\n if (Array.isArray(sqlQuery)) {\n return (\n <div className=\"p-6 space-y-4\">\n {sqlQuery\n .filter(query => query && typeof query === 'string' && query.trim())\n .map((query, index) => {\n\n const rawHeading = queryHeadings[index] || `Query ${index + 1}`;\n const heading = formatQueryHeading(rawHeading);\n\n return (\n <ContentBlock\n key={index}\n title={heading}\n copyContent={query}\n copyId={`query-${index}`}\n copied={copied}\n onCopy={copyToClipboard}\n variant=\"default\"\n copyButtonVariant=\"light\"\n >\n <ContentText hasOverflowHandling={false}>\n {query}\n </ContentText>\n </ContentBlock>\n );\n })}\n {renderTableButtonExplanations()}\n </div>\n );\n }\n\n return (\n <div className=\"p-6 space-y-4\">\n <ContentBlock\n title={formatQueryHeading(queryHeadings[0] || \"Query details\")}\n copyContent={typeof sqlQuery === 'string' ? sqlQuery : ''}\n copyId=\"single\"\n copied={copied}\n onCopy={copyToClipboard}\n variant=\"default\"\n copyButtonVariant=\"light\"\n >\n <ContentText hasOverflowHandling={false}>\n {sqlQuery}\n </ContentText>\n </ContentBlock>\n {renderTableButtonExplanations()}\n </div>\n );\n }\n\n return (\n <CustomModal\n isOpen={isOpen}\n onClose={onClose}\n title=\"blah\"\n >\n {renderModalContent()}\n </CustomModal>\n );\n}\n\nexport default QueryDetailsModal;\n"],"mappings":"wLAAA,MAAO,CAAAA,KAAK,EAAIC,QAAQ,CAAEC,SAAS,KAAQ,OAAO,CAClD,OAASC,WAAW,KAAQ,gBAAgB,CAC5C,OAASC,IAAI,CAAEC,KAAK,CAAEC,WAAW,CAAEC,SAAS,KAAW,cAAc,CACrE,OAASC,kBAAkB,KAAQ,2BAA2B,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,QAAA,IAAAC,SAAA,CAAAC,IAAA,IAAAC,KAAA,yBAQ/D,QAAS,CAAAC,UAAUA,CAAAC,IAAA,CAA8D,IAA3D,CAAAC,OAAO,CAAAD,IAAA,CAAPC,OAAO,CAAEC,QAAQ,CAAAF,IAAA,CAARE,QAAQ,CAAAC,YAAA,CAAAH,IAAA,CAAEI,OAAO,CAAPA,OAAO,CAAAD,YAAA,UAAG,SAAS,CAAAA,YAAA,CAC1D,GAA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ACF,CAAC,CACd+C,6BAA6B,CAAC,CAAC,EAC7B,CAEX,CAEA,mBACEzF,IAAA,CAACP,WAAW,EACV6C,MAAM,CAAEA,MAAO,CACfC,OAAO,CAAEA,OAAQ,CACjBhB,KAAK,CAAC,MAAM,CAAAR,QAAA,CAEX0G,kBAAkB,CAAC,CAAC,CACV,CAEjB,CAEA,cAAe,CAAArF,iBAAiB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"query-details-modal.js","names":["React","useState","useEffect","CustomModal","Copy","Check","ChevronDown","ChevronUp","formatQueryHeading","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","CopyButton","_ref","onClick","isCopied","_ref$variant","variant","baseClasses","variantClasses","className","type","children","ContentText","_ref2","_ref2$hasOverflowHand","hasOverflowHandling","overflowClasses","ContentBlock","_ref3","title","copyContent","copyId","copied","onCopy","_ref3$variant","_ref3$copyButtonVaria","copyButtonVariant","containerClasses","containerStyle","border","titleClasses","style","QueryDetailsModal","_ref4","isOpen","onClose","isLoading","error","sqlQuery","_ref4$queryHeadings","queryHeadings","_ref4$tableButtonExpl","tableButtonExplanations","onRetry","_useState","setCopied","_useState2","expandedButtons","setExpandedButtons","copyToClipboard","_x","_x2","_copyToClipboard","apply","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","queryToCopy","textToCopy","id","wrap","_callee$","_context","prev","next","Array","isArray","filter","q","join","abrupt","navigator","clipboard","writeText","_extends3","_extends","setTimeout","_extends4","t0","stop","toggleButtonExpansion","buttonIndex","_extends2","renderTableButtonExplanations","length","hasValidJsonBody","jsonBody","undefined","hasValidFormFields","formFields","Object","keys","map","button","index","_button$buttonStyle","_button$buttonStyle2","_button$buttonStyle3","buttonClassName","height","width","minWidth","backgroundColor","buttonStyle","color","display","alignItems","justifyContent","action","operationSummary","operationDescription","requestUrl","explanation","JSON","stringify","renderModalContent","query","trim","rawHeading","heading"],"sources":["../../../src/plugins/helpers/query-details-modal.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { CustomModal } from './custom-modal';\nimport { Copy, Check, ChevronDown, ChevronUp, X } from 'lucide-react';\nimport { formatQueryHeading } from './query-heading-formatter';\n\ntype CopyButtonProps = {\n onClick: () => void;\n isCopied: boolean;\n variant?: 'default' | 'light';\n};\n\nfunction CopyButton({ onClick, isCopied, variant = 'default' }: CopyButtonProps) {\n const baseClasses = \"flex items-center gap-1 px-2 py-1 text-xs border rounded transition-colors\";\n const variantClasses = variant === 'light' \n ? \"bg-gray-50 border-gray-300 hover:bg-gray-100\"\n : \"bg-gray-100 border-gray-300 hover:bg-gray-200\";\n\n return (\n <button\n onClick={onClick}\n className={`${baseClasses} ${variantClasses}`}\n type=\"button\"\n >\n {isCopied ? (\n <>\n <Check className=\"w-3 h-3 text-green-600\" />\n <span className=\"text-green-600\">Copied!</span>\n </>\n ) : (\n <>\n <Copy className=\"w-3 h-3 text-gray-600\" />\n <span className=\"text-gray-600\">Copy</span>\n </>\n )}\n </button>\n );\n}\n\ntype ContentTextProps = {\n children: React.ReactNode;\n hasOverflowHandling?: boolean;\n};\n\nfunction ContentText({ children, hasOverflowHandling = true }: ContentTextProps) {\n const overflowClasses = hasOverflowHandling ? \"overflow-hidden break-words\" : \"\";\n\n return (\n <pre className={`whitespace-pre-wrap leading-relaxed text-xs text-gray-700 m-0 p-0 ${overflowClasses}`}>\n {children}\n </pre>\n );\n}\n\ntype ContentBlockProps = {\n title: string;\n children: React.ReactNode;\n copyContent?: string;\n copyId: string;\n copied: Record<string, boolean>;\n onCopy: (content: string, id: string) => void;\n variant?: 'default' | 'bordered';\n copyButtonVariant?: 'default' | 'light';\n};\n\nfunction ContentBlock({ \n title, \n children, \n copyContent, \n copyId, \n copied, \n onCopy,\n variant = 'bordered',\n copyButtonVariant = 'default'\n}: ContentBlockProps) {\n const containerClasses = variant === 'bordered' \n ? \"rounded-lg p-3\"\n : \"bg-white border border-gray-200 rounded-lg p-4\";\n \n const containerStyle = variant === 'bordered' \n ? { border: '1px solid #E9EAF5' }\n : {};\n\n const titleClasses = variant === 'bordered'\n ? \"text-sm font-medium text-gray-600\"\n : \"font-semibold text-sm text-gray-500 m-0\";\n\n return (\n <div className={containerClasses} style={containerStyle}>\n <div className=\"flex justify-between items-start mb-2\">\n <span className={titleClasses}>{title}</span>\n {copyContent && (\n <CopyButton\n onClick={() => onCopy(copyContent, copyId)}\n isCopied={copied[copyId] || false}\n variant={copyButtonVariant}\n />\n )}\n </div>\n {children}\n </div>\n );\n}\n\ntype QueryDetailsModalProps = {\n isOpen: boolean;\n onClose: () => void;\n isLoading: boolean;\n error: string;\n sqlQuery: string | string[];\n queryHeadings?: string[];\n tableButtonExplanations?: Array<{\n action: string, \n explanation: string, \n operationSummary?: string,\n operationDescription?: string,\n buttonClassName?: string, \n buttonStyle?: Record<string, unknown>,\n formFields?: Record<string, unknown>;\n jsonBody?: unknown;\n requestUrl?: string;\n }>;\n onRetry: () => void;\n};\n\nexport function QueryDetailsModal({\n isOpen,\n onClose,\n isLoading,\n error,\n sqlQuery,\n queryHeadings = [],\n tableButtonExplanations = [],\n onRetry\n}: QueryDetailsModalProps) {\n const [copied, setCopied] = useState<{ [key: string]: boolean }>({});\n const [expandedButtons, setExpandedButtons] = useState<{ [key: string]: boolean }>({});\n\n // Reset expanded state when modal closes\n useEffect(() => {\n if (!isOpen) {\n setExpandedButtons({});\n }\n }, [isOpen]);\n\n async function copyToClipboard(queryToCopy?: string, copyId?: string) {\n let textToCopy = queryToCopy;\n \n if (!textToCopy) {\n if (Array.isArray(sqlQuery)) {\n textToCopy = sqlQuery.filter(q => q && typeof q === 'string').join('\\n\\n-- Next Query --\\n\\n');\n } else if (typeof sqlQuery === 'string') {\n textToCopy = sqlQuery;\n } else {\n textToCopy = '';\n }\n }\n \n if (!textToCopy) {\n return;\n }\n \n const id = copyId || 'main';\n \n try {\n await navigator.clipboard.writeText(textToCopy);\n setCopied(prev => ({ ...prev, [id]: true }));\n setTimeout(() => setCopied(prev => ({ ...prev, [id]: false })), 2000);\n } catch (err) {\n // Silently fail if clipboard API is not available\n }\n }\n\n function toggleButtonExpansion(buttonIndex: number) {\n setExpandedButtons(prev => ({\n ...prev,\n [buttonIndex]: !prev[buttonIndex]\n }));\n }\n\n function renderTableButtonExplanations() {\n if (!tableButtonExplanations || tableButtonExplanations.length === 0) {\n return null;\n }\n\n function hasValidJsonBody(jsonBody: unknown): boolean {\n return jsonBody !== null && jsonBody !== undefined && jsonBody !== '';\n }\n\n function hasValidFormFields(formFields: Record<string, unknown> | undefined): boolean {\n return formFields !== null && formFields !== undefined && Object.keys(formFields || {}).length > 0;\n }\n\n return (\n <div className=\"mb-6\">\n {tableButtonExplanations.map((button, index) => (\n <div key={index} className=\"mb-3 border border-gray-200 rounded-lg\">\n <div className=\"w-full px-4 py-3 flex items-center justify-between rounded-lg\">\n <div className=\"flex items-center\">\n <button\n onClick={() => toggleButtonExpansion(index)}\n className={button.buttonClassName || \"flex items-center justify-center px-3 rounded text-xs font-medium\"}\n style={{\n height: '35px',\n width: 'fit-content',\n minWidth: 'fit-content',\n backgroundColor: (button.buttonStyle?.backgroundColor as string),\n color: (button.buttonStyle?.color as string),\n border: (button.buttonStyle?.border as string),\n ...(button.buttonStyle as React.CSSProperties || {})\n , ...button.buttonStyle as React.CSSProperties || {},\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center'\n }}\n >\n {button.action}\n </button>\n <div className=\"ml-3 flex flex-col\">\n {button.operationSummary && (\n <span className=\"text-xs text-gray-700 font-medium\">\n {button.operationSummary}\n </span>\n )}\n </div>\n </div>\n {expandedButtons[index] ? (\n <ChevronUp \n className=\"w-4 h-4 text-gray-500 transition-transform cursor-pointer\"\n onClick={() => toggleButtonExpansion(index)}\n />\n ) : (\n <ChevronDown \n className=\"w-4 h-4 text-gray-500 transition-transform cursor-pointer\"\n onClick={() => toggleButtonExpansion(index)}\n />\n )}\n </div>\n \n {expandedButtons[index] && (\n <div className=\"px-4 pb-3 border-t border-gray-200\">\n <div className=\"mt-2 space-y-3\">\n {/* Description Block */}\n {button.operationDescription && (\n <ContentBlock\n title=\"Description\"\n copyId={`description-${index}`}\n copied={copied}\n onCopy={copyToClipboard}\n variant=\"bordered\"\n >\n <ContentText>\n {button.operationDescription}\n </ContentText>\n </ContentBlock>\n )}\n\n {(button.requestUrl || button.explanation) && (\n <ContentBlock\n title=\"URL\"\n copyContent={button.requestUrl || button.explanation}\n copyId={`url-${index}`}\n copied={copied}\n onCopy={copyToClipboard}\n variant=\"bordered\"\n >\n <ContentText>\n {button.requestUrl || button.explanation}\n </ContentText>\n </ContentBlock>\n )}\n \n {(hasValidJsonBody(button.jsonBody) || hasValidFormFields(button.formFields)) && (\n <ContentBlock\n title=\"Payload\"\n copyContent={JSON.stringify(\n hasValidJsonBody(button.jsonBody) ? button.jsonBody : button.formFields, \n null, \n 2\n )}\n copyId={`payload-${index}`}\n copied={copied}\n onCopy={copyToClipboard}\n variant=\"bordered\"\n >\n <ContentText>\n {hasValidJsonBody(button.jsonBody) \n ? JSON.stringify(button.jsonBody, null, 2)\n : JSON.stringify(button.formFields, null, 2)}\n </ContentText>\n </ContentBlock>\n )}\n </div>\n </div>\n )}\n </div>\n ))}\n </div>\n );\n }\n\n function renderModalContent() {\n if (isLoading) {\n return (\n <div className=\"flex flex-col items-center justify-center py-12\">\n <div className=\"animate-spin rounded-full h-12 w-12 border-b-2 border-purple-600 mb-4\"></div>\n <span className=\"text-xs text-gray-600\">Fetching query details from semantic layer...</span>\n <span className=\"text-xs text-gray-400 mt-2\">This may take a few moments</span>\n </div>\n );\n }\n\n if (error) {\n return (\n <div className=\"text-red-600 p-4 bg-red-50 rounded-lg border border-red-200 m-6\">\n <p className=\"font-medium mb-2 text-xs\">Unable to fetch query details</p>\n <p className=\"text-xs mb-3\">{error}</p>\n <button \n onClick={onRetry}\n className=\"px-4 py-2 bg-red-100 hover:bg-red-200 rounded text-xs font-medium transition-colors\"\n type=\"button\"\n >\n Retry\n </button>\n </div>\n );\n }\n\n if (!sqlQuery || (Array.isArray(sqlQuery) && sqlQuery.length === 0)) {\n return (\n <div className=\"text-gray-600 p-6\">\n <p className=\"text-xs\">No query details available</p>\n </div>\n );\n }\n\n // Handle multiple queries\n if (Array.isArray(sqlQuery)) {\n return (\n <div className=\"p-6 space-y-4\">\n {sqlQuery\n .filter(query => query && typeof query === 'string' && query.trim())\n .map((query, index) => {\n\n const rawHeading = queryHeadings[index] || `Query ${index + 1}`;\n const heading = formatQueryHeading(rawHeading);\n\n return (\n <ContentBlock\n key={index}\n title={heading}\n copyContent={query}\n copyId={`query-${index}`}\n copied={copied}\n onCopy={copyToClipboard}\n variant=\"default\"\n copyButtonVariant=\"light\"\n >\n <ContentText hasOverflowHandling={false}>\n {query}\n </ContentText>\n </ContentBlock>\n );\n })}\n {renderTableButtonExplanations()}\n </div>\n );\n }\n\n return (\n <div className=\"p-6 space-y-4\">\n <ContentBlock\n title={formatQueryHeading(queryHeadings[0] || \"Query details\")}\n copyContent={typeof sqlQuery === 'string' ? sqlQuery : ''}\n copyId=\"single\"\n copied={copied}\n onCopy={copyToClipboard}\n variant=\"default\"\n copyButtonVariant=\"light\"\n >\n <ContentText hasOverflowHandling={false}>\n {sqlQuery}\n </ContentText>\n </ContentBlock>\n {renderTableButtonExplanations()}\n </div>\n );\n }\n\n return (\n <CustomModal\n isOpen={isOpen}\n onClose={onClose}\n title=\"How was this metric calculated?\"\n >\n {renderModalContent()}\n </CustomModal>\n );\n}\n\nexport default QueryDetailsModal;\n"],"mappings":"wLAAA,MAAO,CAAAA,KAAK,EAAIC,QAAQ,CAAEC,SAAS,KAAQ,OAAO,CAClD,OAASC,WAAW,KAAQ,gBAAgB,CAC5C,OAASC,IAAI,CAAEC,KAAK,CAAEC,WAAW,CAAEC,SAAS,KAAW,cAAc,CACrE,OAASC,kBAAkB,KAAQ,2BAA2B,CAAC,OAAAC,GAAA,IAAAC,IAAA,CAAAC,QAAA,IAAAC,SAAA,CAAAC,IAAA,IAAAC,KAAA,yBAQ/D,QAAS,CAAAC,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